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

Function opt

packages/prompts/src/select-key.ts:14–33  ·  view source on GitHub ↗
(
		option: Option<Value>,
		state: 'inactive' | 'active' | 'selected' | 'cancelled' = 'inactive'
	)

Source from the content-addressed store, hash-verified

12
13export const selectKey = <Value extends string>(opts: SelectKeyOptions<Value>) => {
14 const opt = (
15 option: Option<Value>,
16 state: 'inactive' | 'active' | 'selected' | 'cancelled' = 'inactive'
17 ) => {
18 const label = option.label ?? String(option.value);
19 if (state === 'selected') {
20 return `${styleText('dim', label)}`;
21 }
22 if (state === 'cancelled') {
23 return `${styleText(['strikethrough', 'dim'], label)}`;
24 }
25 if (state === 'active') {
26 return `${styleText(['bgCyan', 'gray'], ` ${option.value} `)} ${label}${
27 option.hint ? ` ${styleText('dim', `(${option.hint})`)}` : ''
28 }`;
29 }
30 return `${styleText(['gray', 'bgWhite', 'inverse'], ` ${option.value} `)} ${label}${
31 option.hint ? ` ${styleText('dim', `(${option.hint})`)}` : ''
32 }`;
33 };
34
35 return new SelectKeyPrompt({
36 options: opts.options,

Callers 1

renderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected