( options: FormKitOptionsListWithGroups, value: string, undefinedIfNotFound = false )
| 69 | * @public |
| 70 | */ |
| 71 | export 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. |
no test coverage detected