MCPcopy Create free account
hub / github.com/formkit/formkit / isChecked

Function isChecked

packages/inputs/src/features/checkboxes.ts:57–67  ·  view source on GitHub ↗

* Checks if a given option is present in the node value. * * @param node - The The @formkit/node#FormKitNode | FormKitNode being checked. * @param value - The value of any option. * * @returns `boolean` * * @public

(node: FormKitNode, value: any)

Source from the content-addressed store, hash-verified

55 * @public
56 */
57function isChecked(node: FormKitNode, value: any) {
58 // We need to force vue’s reactivity to respond when the value is run:
59 node.context?.value
60 node.context?._value
61 if (Array.isArray(node._value)) {
62 return node._value.some((existingValue) =>
63 shouldSelect(optionValue(node.props.options, value), existingValue)
64 )
65 }
66 return false
67}
68
69/**
70 * A feature that adds checkbox selection support.

Callers

nothing calls this directly

Calls 2

shouldSelectFunction · 0.90
optionValueFunction · 0.90

Tested by

no test coverage detected