MCPcopy
hub / github.com/codeaashu/claude-code / useSelectState

Function useSelectState

src/components/CustomSelect/use-select-state.ts:127–157  ·  view source on GitHub ↗
({
  visibleOptionCount = 5,
  options,
  defaultValue,
  onChange,
  onCancel,
  onFocus,
  focusValue,
}: UseSelectStateProps<T>)

Source from the content-addressed store, hash-verified

125}
126
127export function useSelectState<T>({
128 visibleOptionCount = 5,
129 options,
130 defaultValue,
131 onChange,
132 onCancel,
133 onFocus,
134 focusValue,
135}: UseSelectStateProps<T>): SelectState<T> {
136 const [value, setValue] = useState<T | undefined>(defaultValue)
137
138 const navigation = useSelectNavigation<T>({
139 visibleOptionCount,
140 options,
141 initialFocusValue: undefined,
142 onFocus,
143 focusValue,
144 })
145
146 const selectFocusedOption = useCallback(() => {
147 setValue(navigation.focusedValue)
148 }, [navigation.focusedValue])
149
150 return {
151 ...navigation,
152 value,
153 selectFocusedOption,
154 onChange,
155 onCancel,
156 }
157}
158

Callers 1

SelectFunction · 0.85

Calls 1

useSelectNavigationFunction · 0.85

Tested by

no test coverage detected