MCPcopy Create free account
hub / github.com/bombshell-dev/clack / opt

Function opt

packages/prompts/src/autocomplete.ts:148–162  ·  view source on GitHub ↗
(option: Option<Value>, state: 'inactive' | 'active' | 'disabled')

Source from the content-addressed store, hash-verified

146 const placeholder = opts.placeholder;
147 const showPlaceholder = userInput === '' && placeholder !== undefined;
148 const opt = (option: Option<Value>, state: 'inactive' | 'active' | 'disabled') => {
149 const label = getLabel(option);
150 const hint =
151 option.hint && option.value === this.focusedValue
152 ? styleText('dim', ` (${option.hint})`)
153 : '';
154 switch (state) {
155 case 'active':
156 return `${styleText('green', S_RADIO_ACTIVE)} ${label}${hint}`;
157 case 'inactive':
158 return `${styleText('dim', S_RADIO_INACTIVE)} ${styleText('dim', label)}`;
159 case 'disabled':
160 return `${styleText('gray', S_RADIO_INACTIVE)} ${styleText(['strikethrough', 'gray'], label)}`;
161 }
162 };
163
164 // Handle different states
165 switch (this.state) {

Callers 1

renderFunction · 0.70

Calls 1

getLabelFunction · 0.85

Tested by

no test coverage detected