MCPcopy Index your code
hub / github.com/bombshell-dev/clack / formatOption

Function formatOption

packages/prompts/src/autocomplete.ts:307–330  ·  view source on GitHub ↗
(
		option: Option<Value>,
		active: boolean,
		selectedValues: Value[],
		focusedValue: Value | undefined
	)

Source from the content-addressed store, hash-verified

305 */
306export const autocompleteMultiselect = <Value>(opts: AutocompleteMultiSelectOptions<Value>) => {
307 const formatOption = (
308 option: Option<Value>,
309 active: boolean,
310 selectedValues: Value[],
311 focusedValue: Value | undefined
312 ) => {
313 const isSelected = selectedValues.includes(option.value);
314 const label = option.label ?? String(option.value ?? '');
315 const hint =
316 option.hint && focusedValue !== undefined && option.value === focusedValue
317 ? styleText('dim', ` (${option.hint})`)
318 : '';
319 const checkbox = isSelected
320 ? styleText('green', S_CHECKBOX_SELECTED)
321 : styleText('dim', S_CHECKBOX_INACTIVE);
322
323 if (option.disabled) {
324 return `${styleText('gray', S_CHECKBOX_INACTIVE)} ${styleText(['strikethrough', 'gray'], label)}`;
325 }
326 if (active) {
327 return `${checkbox} ${label}${hint}`;
328 }
329 return `${checkbox} ${styleText('dim', label)}`;
330 };
331
332 // Create text prompt which we'll use as foundation
333 const prompt = new AutocompletePrompt<Option<Value>>({

Callers 1

renderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected