@nan0web/ui-cli 1.1.1 → 2.0.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.
Files changed (115) hide show
  1. package/README.md +114 -207
  2. package/package.json +22 -12
  3. package/src/CLI.js +22 -30
  4. package/src/CLiMessage.js +2 -3
  5. package/src/Command.js +26 -24
  6. package/src/CommandError.js +3 -5
  7. package/src/CommandHelp.js +40 -36
  8. package/src/CommandMessage.js +56 -40
  9. package/src/CommandParser.js +27 -25
  10. package/src/InputAdapter.js +630 -90
  11. package/src/OutputAdapter.js +7 -8
  12. package/src/README.md.js +190 -316
  13. package/src/components/Alert.js +3 -6
  14. package/src/components/prompt/Autocomplete.js +12 -0
  15. package/src/components/prompt/Confirm.js +29 -0
  16. package/src/components/prompt/DateTime.js +26 -0
  17. package/src/components/prompt/Input.js +15 -0
  18. package/src/components/prompt/Mask.js +12 -0
  19. package/src/components/prompt/Multiselect.js +26 -0
  20. package/src/components/prompt/Next.js +8 -0
  21. package/src/components/prompt/Password.js +13 -0
  22. package/src/components/prompt/Pause.js +9 -0
  23. package/src/components/prompt/ProgressBar.js +16 -0
  24. package/src/components/prompt/Select.js +29 -0
  25. package/src/components/prompt/Slider.js +16 -0
  26. package/src/components/prompt/Spinner.js +29 -0
  27. package/src/components/prompt/Toggle.js +13 -0
  28. package/src/components/prompt/Tree.js +17 -0
  29. package/src/components/view/Alert.js +78 -0
  30. package/src/components/view/Badge.js +11 -0
  31. package/src/components/view/Nav.js +23 -0
  32. package/src/components/view/Table.js +12 -0
  33. package/src/components/view/Toast.js +9 -0
  34. package/src/core/Component.js +79 -0
  35. package/src/core/PropValidation.js +138 -0
  36. package/src/core/render.js +37 -0
  37. package/src/index.js +80 -41
  38. package/src/test/PlaygroundTest.js +37 -25
  39. package/src/test/index.js +2 -4
  40. package/src/ui/alert.js +58 -0
  41. package/src/ui/autocomplete.js +86 -0
  42. package/src/ui/badge.js +35 -0
  43. package/src/ui/confirm.js +49 -0
  44. package/src/ui/date-time.js +45 -0
  45. package/src/ui/form.js +120 -55
  46. package/src/ui/index.js +18 -4
  47. package/src/ui/input.js +79 -152
  48. package/src/ui/mask.js +132 -0
  49. package/src/ui/multiselect.js +59 -0
  50. package/src/ui/nav.js +74 -0
  51. package/src/ui/next.js +18 -13
  52. package/src/ui/progress.js +88 -0
  53. package/src/ui/select.js +49 -72
  54. package/src/ui/slider.js +154 -0
  55. package/src/ui/spinner.js +65 -0
  56. package/src/ui/table.js +163 -0
  57. package/src/ui/toast.js +34 -0
  58. package/src/ui/toggle.js +34 -0
  59. package/src/ui/tree.js +393 -0
  60. package/src/utils/parse.js +1 -1
  61. package/types/CLI.d.ts +5 -5
  62. package/types/CLiMessage.d.ts +1 -1
  63. package/types/Command.d.ts +2 -2
  64. package/types/CommandHelp.d.ts +3 -3
  65. package/types/CommandMessage.d.ts +8 -8
  66. package/types/CommandParser.d.ts +3 -3
  67. package/types/InputAdapter.d.ts +149 -15
  68. package/types/OutputAdapter.d.ts +1 -1
  69. package/types/README.md.d.ts +1 -1
  70. package/types/UiMessage.d.ts +31 -29
  71. package/types/components/prompt/Autocomplete.d.ts +6 -0
  72. package/types/components/prompt/Confirm.d.ts +6 -0
  73. package/types/components/prompt/DateTime.d.ts +6 -0
  74. package/types/components/prompt/Input.d.ts +6 -0
  75. package/types/components/prompt/Mask.d.ts +6 -0
  76. package/types/components/prompt/Multiselect.d.ts +6 -0
  77. package/types/components/prompt/Next.d.ts +6 -0
  78. package/types/components/prompt/Password.d.ts +6 -0
  79. package/types/components/prompt/Pause.d.ts +6 -0
  80. package/types/components/prompt/ProgressBar.d.ts +12 -0
  81. package/types/components/prompt/Select.d.ts +18 -0
  82. package/types/components/prompt/Slider.d.ts +6 -0
  83. package/types/components/prompt/Spinner.d.ts +21 -0
  84. package/types/components/prompt/Toggle.d.ts +6 -0
  85. package/types/components/prompt/Tree.d.ts +6 -0
  86. package/types/components/view/Alert.d.ts +21 -0
  87. package/types/components/view/Badge.d.ts +5 -0
  88. package/types/components/view/Nav.d.ts +15 -0
  89. package/types/components/view/Table.d.ts +10 -0
  90. package/types/components/view/Toast.d.ts +5 -0
  91. package/types/core/Component.d.ts +34 -0
  92. package/types/core/PropValidation.d.ts +48 -0
  93. package/types/core/render.d.ts +6 -0
  94. package/types/index.d.ts +47 -15
  95. package/types/test/PlaygroundTest.d.ts +12 -8
  96. package/types/test/index.d.ts +1 -1
  97. package/types/ui/alert.d.ts +14 -0
  98. package/types/ui/autocomplete.d.ts +20 -0
  99. package/types/ui/badge.d.ts +8 -0
  100. package/types/ui/confirm.d.ts +21 -0
  101. package/types/ui/date-time.d.ts +19 -0
  102. package/types/ui/form.d.ts +43 -12
  103. package/types/ui/index.d.ts +17 -2
  104. package/types/ui/input.d.ts +31 -74
  105. package/types/ui/mask.d.ts +29 -0
  106. package/types/ui/multiselect.d.ts +25 -0
  107. package/types/ui/nav.d.ts +27 -0
  108. package/types/ui/progress.d.ts +43 -0
  109. package/types/ui/select.d.ts +25 -64
  110. package/types/ui/slider.d.ts +23 -0
  111. package/types/ui/spinner.d.ts +28 -0
  112. package/types/ui/table.d.ts +28 -0
  113. package/types/ui/toast.d.ts +8 -0
  114. package/types/ui/toggle.d.ts +17 -0
  115. package/types/ui/tree.d.ts +48 -0
package/types/index.d.ts CHANGED
@@ -1,16 +1,48 @@
1
- export { str2argv } from "./utils/parse.js";
2
- export { generateForm } from "./ui/form.js";
3
- export const renderers: Map<string, (data: any) => string>;
1
+ export { select } from "./ui/select.js";
2
+ export { confirm } from "./ui/confirm.js";
3
+ export { multiselect } from "./ui/multiselect.js";
4
+ export { mask } from "./ui/mask.js";
5
+ export { table } from "./ui/table.js";
6
+ export { autocomplete } from "./ui/autocomplete.js";
7
+ export { alert } from "./ui/alert.js";
8
+ export { badge } from "./ui/badge.js";
9
+ export { toast } from "./ui/toast.js";
10
+ export { spinner } from "./ui/spinner.js";
11
+ export { progress } from "./ui/progress.js";
12
+ export { tree } from "./ui/tree.js";
13
+ export { datetime } from "./ui/date-time.js";
14
+ export { toggle } from "./ui/toggle.js";
15
+ export { slider } from "./ui/slider.js";
4
16
  export default CLiInputAdapter;
5
- export type CommandHelpField = import("./CommandHelp.js").CommandHelpField;
6
- import CLI from "./CLI.js";
7
- import CLiInputAdapter from "./InputAdapter.js";
8
- import { CancelError } from "@nan0web/ui/core";
9
- import OutputAdapter from "./OutputAdapter.js";
10
- import Command from "./Command.js";
11
- import CommandError from "./CommandError.js";
12
- import CommandMessage from "./CommandMessage.js";
13
- import CommandParser from "./CommandParser.js";
14
- import CommandHelp from "./CommandHelp.js";
15
- export { CLI, CLiInputAdapter, CancelError, OutputAdapter, Command, CommandError, CommandMessage, CommandParser, CommandHelp };
16
- export { select, next, pause, createInput, ask, Input } from "./ui/index.js";
17
+ import { render } from './core/render.js';
18
+ import CLiInputAdapter from './InputAdapter.js';
19
+ import { CancelError } from '@nan0web/ui/core';
20
+ import { Alert } from './components/view/Alert.js';
21
+ import { Badge } from './components/view/Badge.js';
22
+ import { Table } from './components/view/Table.js';
23
+ import { Breadcrumbs } from './components/view/Nav.js';
24
+ import { Tabs } from './components/view/Nav.js';
25
+ import { Steps } from './components/view/Nav.js';
26
+ import { Toast } from './components/view/Toast.js';
27
+ import { Select } from './components/prompt/Select.js';
28
+ import { Input } from './components/prompt/Input.js';
29
+ import { Password } from './components/prompt/Password.js';
30
+ import { Confirm } from './components/prompt/Confirm.js';
31
+ import { Multiselect } from './components/prompt/Multiselect.js';
32
+ import { Mask } from './components/prompt/Mask.js';
33
+ import { Autocomplete } from './components/prompt/Autocomplete.js';
34
+ import { Slider } from './components/prompt/Slider.js';
35
+ import { Toggle } from './components/prompt/Toggle.js';
36
+ import { DateTime } from './components/prompt/DateTime.js';
37
+ import { Next } from './components/prompt/Next.js';
38
+ import { Pause } from './components/prompt/Pause.js';
39
+ import { Tree } from './components/prompt/Tree.js';
40
+ import { Spinner } from './components/prompt/Spinner.js';
41
+ import { ProgressBar } from './components/prompt/ProgressBar.js';
42
+ import CLI from './CLI.js';
43
+ import CommandParser from './CommandParser.js';
44
+ import OutputAdapter from './OutputAdapter.js';
45
+ export { render, CLiInputAdapter, CancelError, Alert, Badge, Table, Breadcrumbs, Tabs, Steps, Toast, Select, Input, Password, Confirm, Multiselect, Mask, Autocomplete, Slider, Toggle, DateTime, Next, Pause, Tree, Spinner, ProgressBar, CLI, CommandParser, OutputAdapter };
46
+ export { createInput, ask, text } from "./ui/input.js";
47
+ export { next, pause } from "./ui/next.js";
48
+ export { breadcrumbs, tabs, steps } from "./ui/nav.js";
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @typedef {object} PlaygroundTestConfig
3
3
  * @property {NodeJS.ProcessEnv} env Environment variables for the child process.
4
- * @property {{ includeDebugger?: boolean }} [config={}] Configuration options.
4
+ * @property {{ includeDebugger?: boolean, includeEmptyLines?: boolean, feedStdin?: boolean }} [config={}] Configuration options.
5
5
  */
6
6
  /**
7
7
  * Utility class to run playground demos and capture output.
@@ -18,16 +18,18 @@
18
18
  export default class PlaygroundTest {
19
19
  /**
20
20
  * @param {NodeJS.ProcessEnv} env Environment variables for the child process.
21
- * @param {{ includeDebugger?: boolean, includeEmptyLines?: boolean }} [config={}] Configuration options.
21
+ * @param {{ includeDebugger?: boolean, includeEmptyLines?: boolean, feedStdin?: boolean }} [config={}] Configuration options.
22
22
  */
23
23
  constructor(env: NodeJS.ProcessEnv, config?: {
24
- includeDebugger?: boolean | undefined;
25
- includeEmptyLines?: boolean | undefined;
26
- } | undefined);
24
+ includeDebugger?: boolean;
25
+ includeEmptyLines?: boolean;
26
+ feedStdin?: boolean;
27
+ });
27
28
  env: NodeJS.ProcessEnv;
28
29
  /** @type {boolean} Include debugger lines in output (default: false). */
29
30
  includeDebugger: boolean;
30
31
  incldeEmptyLines: boolean;
32
+ feedStdin: boolean;
31
33
  /**
32
34
  * Subscribe to an event.
33
35
  */
@@ -53,7 +55,7 @@ export default class PlaygroundTest {
53
55
  *
54
56
  * @param {string[]} [args=["play/main.js"]] Arguments passed to the node process.
55
57
  */
56
- run(args?: string[] | undefined): Promise<{
58
+ run(args?: string[]): Promise<{
57
59
  stdout: any;
58
60
  stderr: any;
59
61
  exitCode: any;
@@ -74,7 +76,9 @@ export type PlaygroundTestConfig = {
74
76
  * Configuration options.
75
77
  */
76
78
  config?: {
77
- includeDebugger?: boolean | undefined;
79
+ includeDebugger?: boolean;
80
+ includeEmptyLines?: boolean;
81
+ feedStdin?: boolean;
78
82
  } | undefined;
79
83
  };
80
- import { EventContext } from "@nan0web/event";
84
+ import { EventContext } from '@nan0web/event';
@@ -1,3 +1,3 @@
1
1
  export { PlaygroundTest };
2
2
  export default PlaygroundTest;
3
- import PlaygroundTest from "./PlaygroundTest.js";
3
+ import PlaygroundTest from './PlaygroundTest.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Renders an alert box and optionally plays a sound.
3
+ *
4
+ * @param {string} message - Message content.
5
+ * @param {'info'|'success'|'warning'|'error'} [variant='info']
6
+ * @param {Object} [options]
7
+ * @param {string} [options.title] - Optional title.
8
+ * @param {boolean} [options.sound=false] - Play beep sound.
9
+ * @returns {string} Styled message block.
10
+ */
11
+ export function alert(message: string, variant?: "info" | "success" | "warning" | "error", options?: {
12
+ title?: string | undefined;
13
+ sound?: boolean | undefined;
14
+ }): string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Renders a searchable selection list.
3
+ *
4
+ * @param {Object} input
5
+ * @param {string} [input.message] - Prompt message.
6
+ * @param {string} [input.title] - Alternative prompt title.
7
+ * @param {Array|Function} input.options - List of options or async function to fetch them.
8
+ * @param {number} [input.limit=10] - Max visible items.
9
+ * @returns {Promise<{index:number,value:any,cancelled:boolean}>}
10
+ */
11
+ export function autocomplete(input: {
12
+ message?: string | undefined;
13
+ title?: string | undefined;
14
+ options: any[] | Function;
15
+ limit?: number | undefined;
16
+ }): Promise<{
17
+ index: number;
18
+ value: any;
19
+ cancelled: boolean;
20
+ }>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Renders a status badge.
3
+ *
4
+ * @param {string} label - Text to display.
5
+ * @param {'info'|'success'|'warning'|'error'|'neutral'} [variant='neutral']
6
+ * @returns {string} Styled string.
7
+ */
8
+ export function badge(label: string, variant?: "info" | "success" | "warning" | "error" | "neutral"): string;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @param {Object} config
3
+ * @param {string} config.message
4
+ * @param {boolean} [config.initial=true] - Default value (true=Yes, false=No)
5
+ * @param {Function} [config.format] - Output value formatter
6
+ * @param {string} [config.active] - Label for "Yes" state
7
+ * @param {string} [config.inactive] - Label for "No" state
8
+ * @param {Function} [config.t] - Optional translation function.
9
+ * @returns {Promise<{value:boolean, cancelled:boolean}>}
10
+ */
11
+ export function confirm(config: {
12
+ message: string;
13
+ initial?: boolean | undefined;
14
+ format?: Function | undefined;
15
+ active?: string | undefined;
16
+ inactive?: string | undefined;
17
+ t?: Function | undefined;
18
+ }): Promise<{
19
+ value: boolean;
20
+ cancelled: boolean;
21
+ }>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Prompt user for a date or time.
3
+ *
4
+ * @param {Object} config
5
+ * @param {string} config.message
6
+ * @param {Date} [config.initial]
7
+ * @param {string} [config.mask] - Optional mask (e.g. 'YYYY-MM-DD HH:mm')
8
+ * @param {Function} [config.t] - Optional translation function.
9
+ * @returns {Promise<{value:Date, cancelled:boolean}>}
10
+ */
11
+ export function datetime(config: {
12
+ message: string;
13
+ initial?: Date | undefined;
14
+ mask?: string | undefined;
15
+ t?: Function | undefined;
16
+ }): Promise<{
17
+ value: Date;
18
+ cancelled: boolean;
19
+ }>;
@@ -14,7 +14,7 @@
14
14
  export function generateForm(BodyClass: Function, options?: {
15
15
  initialState?: any;
16
16
  t?: Function | undefined;
17
- } | undefined): UiForm;
17
+ }): UiForm;
18
18
  /**
19
19
  * CLI-specific form handler that introspects a model class for static field schemas.
20
20
  *
@@ -38,24 +38,54 @@ export default class Form {
38
38
  * @param {Object} [options={}] - Options.
39
39
  * @param {string[]} [options.stops=["quit", "cancel", "exit"]] - Stop words.
40
40
  * @param {(prompt: string) => Promise<Input>} [options.inputFn] - Custom input function.
41
+ * @param {(config: object) => Promise<{index:number, value:any}>} [options.selectFn] - Custom select function.
42
+ * @param {(config: object) => Promise<{value: number, cancelled: boolean}>} [options.sliderFn] - Custom slider function.
43
+ * @param {(config: object) => Promise<{value: boolean, cancelled: boolean}>} [options.toggleFn] - Custom toggle function.
44
+ * @param {Function} [options.t] - Optional translation function.
41
45
  * @throws {TypeError} If model is not an object with a constructor.
42
46
  */
43
47
  constructor(model: any, options?: {
44
48
  stops?: string[] | undefined;
45
49
  inputFn?: ((prompt: string) => Promise<Input>) | undefined;
46
- } | undefined);
50
+ selectFn?: ((config: object) => Promise<{
51
+ index: number;
52
+ value: any;
53
+ }>) | undefined;
54
+ sliderFn?: ((config: object) => Promise<{
55
+ value: number;
56
+ cancelled: boolean;
57
+ }>) | undefined;
58
+ toggleFn?: ((config: object) => Promise<{
59
+ value: boolean;
60
+ cancelled: boolean;
61
+ }>) | undefined;
62
+ t?: Function | undefined;
63
+ });
47
64
  /** @type {Function} Input handler with cancellation support. */
48
65
  handler: Function;
49
- /**
50
- * Prompts for selection using the provided configuration.
51
- *
52
- * @param {Object} config - Selection configuration.
53
- * @returns {Promise<{index:number, value:any}>} Selected option.
54
- */
55
- select(config: any): Promise<{
66
+ options: {
67
+ stops?: string[] | undefined;
68
+ inputFn?: ((prompt: string) => Promise<Input>) | undefined;
69
+ selectFn?: ((config: object) => Promise<{
70
+ index: number;
71
+ value: any;
72
+ }>) | undefined;
73
+ sliderFn?: ((config: object) => Promise<{
74
+ value: number;
75
+ cancelled: boolean;
76
+ }>) | undefined;
77
+ toggleFn?: ((config: object) => Promise<{
78
+ value: boolean;
79
+ cancelled: boolean;
80
+ }>) | undefined;
81
+ t?: Function | undefined;
82
+ };
83
+ t: Function;
84
+ select: typeof select | ((config: object) => Promise<{
56
85
  index: number;
57
86
  value: any;
58
- }>;
87
+ }>);
88
+ get fields(): any[];
59
89
  /**
60
90
  * Prompts for input using the internal handler.
61
91
  *
@@ -86,5 +116,6 @@ export default class Form {
86
116
  get body(): any;
87
117
  #private;
88
118
  }
89
- import { UiForm } from "@nan0web/ui";
90
- import { Input } from "./input.js";
119
+ import { UiForm } from '@nan0web/ui';
120
+ import { Input } from './input.js';
121
+ import { select } from './select.js';
@@ -1,3 +1,18 @@
1
- export { Input, createInput, ask } from "./input.js";
2
- export { select, default as baseSelect } from "./select.js";
1
+ export { badge } from "./badge.js";
2
+ export { alert } from "./alert.js";
3
+ export { toast } from "./toast.js";
4
+ export { tree } from "./tree.js";
5
+ export { datetime } from "./date-time.js";
6
+ export { Input, text, createInput, ask } from "./input.js";
7
+ export { select, select as baseSelect } from "./select.js";
8
+ export { confirm, confirm as baseConfirm } from "./confirm.js";
3
9
  export { next, pause } from "./next.js";
10
+ export { autocomplete, autocomplete as baseAutocomplete } from "./autocomplete.js";
11
+ export { table, table as baseTable } from "./table.js";
12
+ export { multiselect, multiselect as baseMultiselect } from "./multiselect.js";
13
+ export { mask, mask as baseMask } from "./mask.js";
14
+ export { toggle, toggle as baseToggle } from "./toggle.js";
15
+ export { slider, slider as baseSlider } from "./slider.js";
16
+ export { progress, ProgressBar, progress as baseProgress } from "./progress.js";
17
+ export { spinner, Spinner, spinner as baseSpinner } from "./spinner.js";
18
+ export { breadcrumbs, tabs, steps } from "./nav.js";
@@ -1,60 +1,43 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /** @typedef {import("./select.js").ConsoleLike} ConsoleLike */
3
- /** @typedef {(input: Input) => Promise<boolean>} LoopFn */
4
- /** @typedef {(input: Input) => string} NextQuestionFn */
5
1
  /**
6
- * Input function.
7
- * ---
8
- * Must be used only as a type — typedef does not work with full arguments description for functions.
9
- * ---
10
- * @param {string} question - Prompt displayed to the user.
11
- * @param {boolean | LoopFn} [loop=false] - Loop‑control flag, validator or boolean that forces a single answer.
12
- * @param {string | NextQuestionFn} [nextQuestion] - When `false` the prompt ends after one answer.
13
- * When a `function` is supplied it receives the current {@link Input}
14
- * and must return a new question string for the next iteration.
15
- *
16
- * @returns {Promise<Input>} Resolves with an {@link Input} instance that contains the final answer,
17
- * the raw value and cancellation state.
18
- *
19
- * @throws {Error} May propagate errors from the underlying readline interface.
2
+ * Triggers a system beep (ASCII Bell).
20
3
  */
21
- export function InputFn(question: string, loop?: boolean | LoopFn | undefined, nextQuestion?: string | NextQuestionFn | undefined): Promise<Input>;
4
+ export function beep(): void;
22
5
  /**
23
- * Low‑level prompt that returns a trimmed string.
24
- *
25
- * @param {Object} input
26
- * @param {string} input.question - Text displayed as a prompt.
27
- * @param {string} [input.predef] - Optional predefined answer (useful for testing).
28
- * @param {ConsoleLike} [input.console] - Optional console to show predefined value
29
- * @param {import("node:readline").Interface} [input.rl] - Readline interface instnace
30
- * @returns {Promise<string>} The answer without surrounding whitespace.
31
- *
32
- * When `predef` is supplied the function mimics the usual readline output
33
- * (`question + answer + newline`) and returns the trimmed value.
6
+ * Modern text input with validation and default value.
7
+ *
8
+ * @param {Object} config
9
+ * @param {string} config.message - Prompt question
10
+ * @param {string} [config.initial] - Default value
11
+ * @param {string} [config.type] - Prompt type (text, password, etc)
12
+ * @param {(value:string)=>boolean|string|Promise<boolean|string>} [config.validate] - Validator
13
+ * @param {(value:string)=>string} [config.format] - Formatter
14
+ * @returns {Promise<{value:string, cancelled:boolean}>}
34
15
  */
35
- export function _askRaw(input: {
36
- question: string;
37
- predef?: string | undefined;
38
- console?: import("./select.js").ConsoleLike | undefined;
39
- rl?: import("readline").Interface | undefined;
40
- }): Promise<string>;
16
+ export function text(config: {
17
+ message: string;
18
+ initial?: string | undefined;
19
+ type?: string | undefined;
20
+ validate?: ((value: string) => boolean | string | Promise<boolean | string>) | undefined;
21
+ format?: ((value: string) => string) | undefined;
22
+ }): Promise<{
23
+ value: string;
24
+ cancelled: boolean;
25
+ }>;
41
26
  /**
42
27
  * Factory that creates a reusable async input handler.
28
+ * Adapter for legacy ask() signature.
43
29
  *
44
30
  * @param {string[]} [stops=[]] Words that trigger cancellation.
45
31
  * @param {string|undefined} [predef] Optional predefined answer for testing.
46
- * @param {ConsoleLike} [console] Optional console instance.
47
- * @returns {InputFn} Async function that resolves to an {@link Input}.
32
+ * @param {Object} [console] Optional console instance.
33
+ * @param {(input: Input) => Promise<boolean>|boolean} [loop] Optional loop validator.
34
+ * @returns {Function} Async function that resolves to an {@link Input}.
48
35
  */
49
- export function createInput(stops?: string[] | undefined, predef?: string | undefined, console?: import("./select.js").ConsoleLike | undefined): typeof InputFn;
36
+ export function createInput(stops?: string[], predef?: string | undefined, console?: any, loop?: (input: Input) => Promise<boolean> | boolean): Function;
50
37
  /**
51
- * @param {string[]} predefined
52
- * @param {ConsoleLike} console
53
- * @param {string[]} [stops=[]]
54
- * @returns {import("./select.js").InputFn}
55
- * @throws {CancelError}
38
+ * Mock helper for predefined inputs (Testing).
56
39
  */
57
- export function createPredefinedInput(predefined: string[], console: ConsoleLike, stops?: string[] | undefined): import("./select.js").InputFn;
40
+ export function createPredefinedInput(predefined: any, console: any, stops?: any[]): (question: any) => Promise<Input>;
58
41
  /**
59
42
  * Represents a line of user input.
60
43
  *
@@ -64,43 +47,17 @@ export function createPredefinedInput(predefined: string[], console: ConsoleLike
64
47
  * @property {boolean} cancelled – True when the answer matches a stop word.
65
48
  */
66
49
  export class Input {
67
- /**
68
- * Create a new {@link Input} instance.
69
- *
70
- * @param {Object} [input={}] - Optional initial values.
71
- * @param {string} [input.value] - Initial answer string.
72
- * @param {boolean} [input.cancelled] - Initial cancel flag.
73
- * @param {string|string[]} [input.stops] - Words that trigger cancellation.
74
- */
75
- constructor(input?: {
76
- value?: string | undefined;
77
- cancelled?: boolean | undefined;
78
- stops?: string | string[] | undefined;
79
- } | undefined);
50
+ constructor(input?: {});
80
51
  /** @type {string} */
81
52
  value: string;
82
53
  /** @type {string[]} */
83
54
  stops: string[];
84
- /**
85
- * Returns whether the input has been cancelled either explicitly or via a stop word.
86
- *
87
- * @returns {boolean}
88
- */
89
55
  get cancelled(): boolean;
90
- /** @returns {string} The raw answer value. */
91
56
  toString(): string;
92
57
  #private;
93
58
  }
94
59
  /**
95
60
  * High‑level input helper `ask`.
96
- *
97
- * This constant inherits the full {@link InputFn} signature **and** the
98
- * detailed JSDoc description for each argument, as defined in {@link InputFn}.
99
- *
100
- * @type {InputFn}
61
+ * Use this for simple string prompts.
101
62
  */
102
- export const ask: typeof InputFn;
103
- export default createInput;
104
- export type ConsoleLike = import("./select.js").ConsoleLike;
105
- export type LoopFn = (input: Input) => Promise<boolean>;
106
- export type NextQuestionFn = (input: Input) => string;
63
+ export const ask: Function;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Validates and optionally formats user input based on a pattern.
3
+ * Pattern uses '#' for numbers and 'A' for letters.
4
+ * Example: '(###) ###-####'
5
+ *
6
+ * @param {Object} config
7
+ * @param {string} config.message - Prompt question
8
+ * @param {string} config.mask - Mask pattern (e.g., '###-###')
9
+ * @param {string} [config.placeholder] - Hint for the user
10
+ * @param {Function} [config.t] - Translation function
11
+ * @returns {Promise<{value: string, cancelled: boolean}>}
12
+ */
13
+ /**
14
+ * Cleans the input value by stripping non-alphanumerics and smart prefix.
15
+ */
16
+ export function cleanMaskInput(value: any, mask: any): any;
17
+ /**
18
+ * Formats a value according to the given mask.
19
+ * pattern: # = digit, A = letter, 0 = digit.
20
+ *
21
+ * @param {string} value
22
+ * @param {string} mask
23
+ * @returns {string}
24
+ */
25
+ export function formatMask(value: string, mask: string): string;
26
+ export function mask(config: any): Promise<{
27
+ value: string;
28
+ cancelled: boolean;
29
+ }>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Interactive multiple selection with checkboxes.
3
+ *
4
+ * @param {Object} config
5
+ * @param {string} config.message - Prompt question
6
+ * @param {Array<string|Object>} config.options - List of choices
7
+ * @param {number} [config.limit=10] - Visible items limit
8
+ * @param {Array<any>} [config.initial=[]] - Initial selected values
9
+ * @param {string|boolean} [config.instructions] - Custom instructions
10
+ * @param {string} [config.hint] - Navigation hint
11
+ * @param {Function} [config.t] - Translation function
12
+ * @returns {Promise<{value: Array<any>, cancelled: boolean}>}
13
+ */
14
+ export function multiselect(config: {
15
+ message: string;
16
+ options: Array<string | any>;
17
+ limit?: number | undefined;
18
+ initial?: any[] | undefined;
19
+ instructions?: string | boolean | undefined;
20
+ hint?: string | undefined;
21
+ t?: Function | undefined;
22
+ }): Promise<{
23
+ value: Array<any>;
24
+ cancelled: boolean;
25
+ }>;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Renders a breadcrumb trail.
3
+ *
4
+ * @param {string[]} items - List of path segments.
5
+ * @param {Object} [options]
6
+ * @param {string} [options.separator='›'] - Separator character.
7
+ * @returns {string} Styled string.
8
+ */
9
+ export function breadcrumbs(items: string[], options?: {
10
+ separator?: string | undefined;
11
+ }): string;
12
+ /**
13
+ * Renders a tab bar (visual only).
14
+ *
15
+ * @param {string[]} items - List of tab labels.
16
+ * @param {number} [active=0] - Index of active tab.
17
+ * @returns {string} Styled string.
18
+ */
19
+ export function tabs(items: string[], active?: number): string;
20
+ /**
21
+ * Renders a step indicator (wizard).
22
+ *
23
+ * @param {string[]} items - List of step labels.
24
+ * @param {number} [current=0] - Index of current step.
25
+ * @returns {string} Styled string.
26
+ */
27
+ export function steps(items: string[], current?: number): string;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Functional helper for progress.
3
+ * @param {Object} options
4
+ * @returns {ProgressBar}
5
+ */
6
+ export function progress(options: any): ProgressBar;
7
+ /**
8
+ * Progress module – visual progress bar with timers.
9
+ * @module ui/progress
10
+ */
11
+ /**
12
+ * Renders a progress bar.
13
+ */
14
+ export class ProgressBar {
15
+ /**
16
+ * @param {Object} options
17
+ * @param {number} options.total
18
+ * @param {string} [options.title]
19
+ * @param {number} [options.width=40]
20
+ */
21
+ constructor(options: {
22
+ total: number;
23
+ title?: string | undefined;
24
+ width?: number | undefined;
25
+ });
26
+ total: number;
27
+ title: string | undefined;
28
+ width: number;
29
+ current: number;
30
+ startTime: number;
31
+ /**
32
+ * Update progress.
33
+ * @param {number} current
34
+ */
35
+ update(current: number): void;
36
+ /**
37
+ * Increment progress.
38
+ * @param {number} [step=1]
39
+ */
40
+ tick(step?: number): void;
41
+ render(): void;
42
+ formatTime(seconds: any): string;
43
+ }