(options: AutoCompleteOptions<A>)
| 1342 | * @since 4.0.0 |
| 1343 | */ |
| 1344 | export const AutoComplete = <const A>(options: AutoCompleteOptions<A>): Prompt<A> => { |
| 1345 | const opts: AutoCompleteOptionsReq<A> = { |
| 1346 | maxPerPage: 10, |
| 1347 | filterLabel: "filter", |
| 1348 | filterPlaceholder: "type to filter", |
| 1349 | emptyMessage: "No matches", |
| 1350 | ...options |
| 1351 | } |
| 1352 | const initialIndex = getSelectInitialIndex(opts.choices) |
| 1353 | const filtered = filterAutoCompleteChoices(opts.choices, "") |
| 1354 | const index = filtered.length === 0 |
| 1355 | ? 0 |
| 1356 | : filtered.includes(initialIndex) |
| 1357 | ? initialIndex |
| 1358 | : filtered[0] |
| 1359 | const initialState: AutoCompleteState = { |
| 1360 | query: "", |
| 1361 | index, |
| 1362 | filtered |
| 1363 | } |
| 1364 | return Custom(initialState, { |
| 1365 | render: handleAutoCompleteRender(opts), |
| 1366 | process: handleAutoCompleteProcess(opts), |
| 1367 | clear: handleAutoCompleteClear(opts) |
| 1368 | }) |
| 1369 | } |
| 1370 | |
| 1371 | /** |
| 1372 | * Creates a prompt that lets the user select multiple choices and returns their |
nothing calls this directly
no test coverage detected