( options: Prompt.Prompt.SelectOptions<A> & Prompt.Prompt.MultiSelectOptions )
| 304 | |
| 305 | /** @internal */ |
| 306 | export const multiSelect = <const A>( |
| 307 | options: Prompt.Prompt.SelectOptions<A> & Prompt.Prompt.MultiSelectOptions |
| 308 | ): Prompt.Prompt<Array<A>> => { |
| 309 | const opts: SelectOptions<A> & MultiSelectOptions = { |
| 310 | maxPerPage: 10, |
| 311 | ...options |
| 312 | } |
| 313 | // Seed initial selection from choices marked as selected: true |
| 314 | const initialSelected = new Set<number>() |
| 315 | for (let i = 0; i < opts.choices.length; i++) { |
| 316 | const choice = opts.choices[i] as Prompt.Prompt.SelectChoice<A> |
| 317 | if (choice.selected === true) { |
| 318 | initialSelected.add(i) |
| 319 | } |
| 320 | } |
| 321 | return InternalPrompt.custom({ index: 0, selectedIndices: initialSelected, error: Option.none() }, { |
| 322 | render: handleRender(opts), |
| 323 | process: handleProcess(opts), |
| 324 | clear: () => handleClear(opts) |
| 325 | }) |
| 326 | } |
nothing calls this directly
no test coverage detected