(opts: {
options: SelectOption<T>[];
initialSelectedKeys?: ReadonlySet<string>;
getKey: (value: T) => string;
minSelected?: number;
})
| 37 | return opts.options[index].value; |
| 38 | }, |
| 39 | async selectMany<T>(opts: { |
| 40 | options: SelectOption<T>[]; |
| 41 | initialSelectedKeys?: ReadonlySet<string>; |
| 42 | getKey: (value: T) => string; |
| 43 | minSelected?: number; |
| 44 | }): Promise<T[]> { |
| 45 | const selected = opts.options.filter((option) => |
| 46 | (opts.initialSelectedKeys ?? new Set<string>()).has(opts.getKey(option.value)), |
| 47 | ); |
| 48 | if (selected.length > 0) { |
| 49 | return selected.map((option) => option.value); |
| 50 | } |
| 51 | |
| 52 | const minSelected = opts.minSelected ?? 0; |
| 53 | return opts.options.slice(0, minSelected).map((option) => option.value); |
| 54 | }, |
| 55 | async confirm(opts: { defaultValue: boolean }): Promise<boolean> { |
| 56 | return opts.defaultValue; |
| 57 | }, |
nothing calls this directly
no test coverage detected