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

Function optionValue

packages/inputs/src/features/options.ts:71–90  ·  view source on GitHub ↗
(
  options: FormKitOptionsListWithGroups,
  value: string,
  undefinedIfNotFound = false
)

Source from the content-addressed store, hash-verified

69 * @public
70 */
71export function optionValue(
72 options: FormKitOptionsListWithGroups,
73 value: string,
74 undefinedIfNotFound = false
75): unknown {
76 if (Array.isArray(options)) {
77 for (const option of options) {
78 if (typeof option !== 'object' && option) continue
79 if (isGroupOption(option)) {
80 const found = optionValue(option.options, value, true)
81 if (found !== undefined) {
82 return found
83 }
84 } else if (value == option.value) {
85 return '__original' in option ? option.__original : option.value
86 }
87 }
88 }
89 return undefinedIfNotFound ? undefined : value
90}
91
92/**
93 * Determines if the value should be selected.

Callers 5

selectInputFunction · 0.90
toggleCheckedFunction · 0.90
isCheckedFunction · 0.90
toggleCheckedFunction · 0.90
isCheckedFunction · 0.90

Calls 1

isGroupOptionFunction · 0.90

Tested by

no test coverage detected