(options: AutoCompleteOptions<A>)
| 1170 | * @since 4.0.0 |
| 1171 | */ |
| 1172 | export const autoComplete = <const A>(options: AutoCompleteOptions<A>): Prompt<A> => { |
| 1173 | const opts: AutoCompleteOptionsReq<A> = { |
| 1174 | maxPerPage: 10, |
| 1175 | filterLabel: "filter", |
| 1176 | filterPlaceholder: "type to filter", |
| 1177 | emptyMessage: "No matches", |
| 1178 | ...options |
| 1179 | } |
| 1180 | const initialIndex = getSelectInitialIndex(opts.choices) |
| 1181 | const filtered = filterAutoCompleteChoices(opts.choices, "") |
| 1182 | const index = filtered.length === 0 |
| 1183 | ? 0 |
| 1184 | : filtered.includes(initialIndex) |
| 1185 | ? initialIndex |
| 1186 | : filtered[0] |
| 1187 | const initialState: AutoCompleteState = { |
| 1188 | query: "", |
| 1189 | index, |
| 1190 | filtered |
| 1191 | } |
| 1192 | return custom(initialState, { |
| 1193 | render: handleAutoCompleteRender(opts), |
| 1194 | process: handleAutoCompleteProcess(opts), |
| 1195 | clear: handleAutoCompleteClear(opts) |
| 1196 | }) |
| 1197 | } |
| 1198 | |
| 1199 | /** |
| 1200 | * Creates a prompt that lets the user select multiple choices and returns their |
nothing calls this directly
no test coverage detected