[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

chore: type

Simon He (Nov 14, 2024, 6:40 PM +0800) a5434c24 1d855b3b

+7 -8
+7 -8
packages/core/src/prompts/search.ts
··· 1 1 import fuzzy from 'fuzzy'; 2 2 import Prompt, { PromptOptions } from './prompt'; 3 - interface SearchOptions<T extends { value: any; label?: string }, MaxItems extends number> 4 - extends PromptOptions<SearchPrompt<T, MaxItems>> { 3 + interface SearchOptions<T extends { value: any; label?: string }> 4 + extends PromptOptions<SearchPrompt<T>> { 5 5 options: T[]; 6 6 initialValue?: T['value']; 7 - maxItems?: MaxItems; 7 + maxItems?: number; 8 8 } 9 9 export default class SearchPrompt< 10 - T extends { value: any; label?: string; isSelected?: boolean }, 11 - MaxItems extends number, 10 + T extends { value: any; label?: string; hint?: string }, 12 11 > extends Prompt { 13 12 options: T[]; 14 13 valueWithCursor = ''; 15 14 16 15 selectCursor = 0; 17 16 inputCursor = 0; 18 - maxItems: MaxItems; 17 + maxItems: number; 19 18 selected: T[] = []; 20 19 21 20 value: T['value'] | T['value'][] = ''; ··· 27 26 this.value = this._value?.value; 28 27 } 29 28 30 - constructor(opts: SearchOptions<T, any>) { 29 + constructor(opts: SearchOptions<T>) { 31 30 super(opts, false); 32 31 this.options = opts.options; 33 32 this.maxItems = opts.maxItems || 1; ··· 97 96 this.changeValue(); 98 97 }); 99 98 } 100 - fuzzyFilter(opts: SearchOptions<T, MaxItems>) { 99 + fuzzyFilter(opts: SearchOptions<T>) { 101 100 const fuzzyOptions = fuzzy.filter(this.valueWithCursor, opts.options, { 102 101 extract: ({ label, value }) => label || value, 103 102 });