@topcli/prompts 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -170,7 +170,36 @@ Use `options.caseSensitive` to make autocomplete filters case sensitive. Default
170
170
 
171
171
  Use `options.signal` to set an `AbortSignal` (throws a [AbortError](#aborterror)).
172
172
 
173
- Use `options.skip` to skip prompt. It will return the first choice.
173
+ Use `options.skip` to skip prompt. It will return the first non-separator choice.
174
+
175
+ Use `Separator` items in `choices` to visually group options. Separators are not selectable and are skipped during keyboard navigation. When `autocomplete` is active and the user has typed a filter, separators are hidden.
176
+
177
+ ```js
178
+ import { select } from "@topcli/prompts";
179
+
180
+ const framework = await select("Choose a framework", {
181
+ choices: [
182
+ { type: "separator", label: "Frontend" },
183
+ { value: "react", label: "React" },
184
+ { value: "vue", label: "Vue" },
185
+ { type: "separator", label: "Backend" },
186
+ { value: "express", label: "Express" },
187
+ { value: "fastify", label: "Fastify" },
188
+ ]
189
+ });
190
+ ```
191
+
192
+ Use `choice.disabled` to mark a choice as non-selectable.
193
+
194
+ ```js
195
+ const runner = await select("Choose a runner", {
196
+ choices: [
197
+ { value: "node", label: "Node.js" },
198
+ { value: "bun", label: "Bun", disabled: "not available" },
199
+ { value: "deno", label: "Deno", disabled: true }
200
+ ]
201
+ });
202
+ ```
174
203
 
175
204
  ### `multiselect()`
176
205
 
@@ -193,6 +222,10 @@ Use `options.signal` to set an `AbortSignal` (throws a [AbortError](#aborterror)
193
222
 
194
223
  Use `options.skip` to skip prompt. It will return `options.preSelectedChoices` if given, `[]` otherwise.
195
224
 
225
+ Use `Separator` items in `choices` to visually group options. Separators are not selectable and are skipped during keyboard navigation. When `autocomplete` is active and the user has typed a filter, separators are hidden.
226
+
227
+ Use `choice.disabled` to mark a choice as non-selectable.
228
+
196
229
  ### `confirm()`
197
230
 
198
231
  ```ts
@@ -287,10 +320,16 @@ export interface Choice<T = any> {
287
320
  value: T;
288
321
  label: string;
289
322
  description?: string;
323
+ disabled?: boolean | string;
324
+ }
325
+
326
+ export interface Separator {
327
+ type: "separator";
328
+ label?: string;
290
329
  }
291
330
 
292
331
  export interface SelectOptions<T extends string> extends AbstractPromptOptions {
293
- choices: (Choice<T> | T)[];
332
+ choices: (Choice<T> | T | Separator)[];
294
333
  maxVisible?: number;
295
334
  ignoreValues?: (T | number | boolean)[];
296
335
  validators?: PromptValidator<string>[];
@@ -299,7 +338,7 @@ export interface SelectOptions<T extends string> extends AbstractPromptOptions {
299
338
  }
300
339
 
301
340
  export interface MultiselectOptions<T extends string> extends AbstractPromptOptions {
302
- choices: (Choice<T> | T)[];
341
+ choices: (Choice<T> | T | Separator)[];
303
342
  maxVisible?: number;
304
343
  preSelectedChoices?: (Choice<T> | T)[];
305
344
  validators?: PromptValidator<string[]>[];