@hyperfrontend/questions 0.2.0 → 0.2.1

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/render.d.ts DELETED
@@ -1,120 +0,0 @@
1
- /**
2
- * Unicode symbols for prompt rendering.
3
- */
4
- export declare const Symbol: Readonly<{
5
- readonly Pointer: "❯";
6
- readonly Radio: "◯";
7
- readonly RadioSelected: "◉";
8
- readonly Checkbox: "☐";
9
- readonly CheckboxSelected: "☑";
10
- readonly Check: "✔";
11
- readonly Cross: "✖";
12
- readonly Question: "?";
13
- readonly Ellipsis: "…";
14
- }>;
15
- /**
16
- * Style functions for ANSI text formatting.
17
- */
18
- export declare const style: Readonly<{
19
- /**
20
- * Applies bold styling to text.
21
- *
22
- * @param text - Text to style
23
- * @returns Text wrapped in bold ANSI codes
24
- */
25
- bold: (text: string) => string;
26
- /**
27
- * Applies dim styling to text.
28
- *
29
- * @param text - Text to style
30
- * @returns Text wrapped in dim ANSI codes
31
- */
32
- dim: (text: string) => string;
33
- /**
34
- * Applies cyan color to text.
35
- *
36
- * @param text - Text to style
37
- * @returns Text wrapped in cyan ANSI codes
38
- */
39
- cyan: (text: string) => string;
40
- /**
41
- * Applies green color to text.
42
- *
43
- * @param text - Text to style
44
- * @returns Text wrapped in green ANSI codes
45
- */
46
- green: (text: string) => string;
47
- /**
48
- * Applies yellow color to text.
49
- *
50
- * @param text - Text to style
51
- * @returns Text wrapped in yellow ANSI codes
52
- */
53
- yellow: (text: string) => string;
54
- /**
55
- * Applies red color to text.
56
- *
57
- * @param text - Text to style
58
- * @returns Text wrapped in red ANSI codes
59
- */
60
- red: (text: string) => string;
61
- /**
62
- * Applies gray color to text.
63
- *
64
- * @param text - Text to style
65
- * @returns Text wrapped in gray ANSI codes
66
- */
67
- gray: (text: string) => string;
68
- }>;
69
- /**
70
- * Renders a prompt message with consistent styling.
71
- *
72
- * @param message - The prompt message to display
73
- * @returns Formatted message string with cyan question mark and bold text
74
- *
75
- * @example Render a prompt message
76
- * ```typescript
77
- * const output = renderMessage('Enter your name')
78
- * // Returns "? Enter your name " with styling
79
- * ```
80
- */
81
- export declare function renderMessage(message: string): string;
82
- /**
83
- * Renders a submitted value with visual confirmation styling.
84
- *
85
- * @param value - The value that was submitted
86
- * @returns Value string styled in cyan
87
- *
88
- * @example Render submitted input
89
- * ```typescript
90
- * const output = renderSubmitted('John Doe')
91
- * // Returns "John Doe" in cyan
92
- * ```
93
- */
94
- export declare function renderSubmitted(value: string): string;
95
- /**
96
- * Renders a cancellation indicator.
97
- *
98
- * @returns Dimmed "(cancelled)" string
99
- *
100
- * @example Show cancellation
101
- * ```typescript
102
- * const output = renderCancelled()
103
- * // Returns "(cancelled)" in dim style
104
- * ```
105
- */
106
- export declare function renderCancelled(): string;
107
- /**
108
- * Renders hint text in a subdued style.
109
- *
110
- * @param hint - The hint text to display
111
- * @returns Dimmed hint string with leading space
112
- *
113
- * @example Render a hint
114
- * ```typescript
115
- * const output = renderHint('press enter to confirm')
116
- * // Returns " press enter to confirm" in dim style
117
- * ```
118
- */
119
- export declare function renderHint(hint: string): string;
120
- //# sourceMappingURL=render.d.ts.map
package/render.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../../../libs/questions/src/render.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;EAUjB,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;OAKG;iBACU,MAAM,KAAG,MAAM;IAC5B;;;;;OAKG;gBACS,MAAM,KAAG,MAAM;IAC3B;;;;;OAKG;iBACU,MAAM,KAAG,MAAM;IAC5B;;;;;OAKG;kBACW,MAAM,KAAG,MAAM;IAC7B;;;;;OAKG;mBACY,MAAM,KAAG,MAAM;IAC9B;;;;;OAKG;gBACS,MAAM,KAAG,MAAM;IAC3B;;;;;OAKG;iBACU,MAAM,KAAG,MAAM;EAC5B,CAAA;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C"}
package/terminal.d.ts DELETED
@@ -1,118 +0,0 @@
1
- /**
2
- * Key codes for terminal navigation.
3
- */
4
- export declare const Key: Readonly<{
5
- readonly Up: "\u001B[A";
6
- readonly Down: "\u001B[B";
7
- readonly Left: "\u001B[D";
8
- readonly Right: "\u001B[C";
9
- readonly Enter: "\r";
10
- readonly Space: " ";
11
- readonly Tab: "\t";
12
- readonly Escape: "\u001B";
13
- readonly Backspace: "";
14
- readonly Delete: "\u001B[3~";
15
- readonly CtrlC: "\u0003";
16
- }>;
17
- /** Terminal key code type. */
18
- export type Key = (typeof Key)[keyof typeof Key];
19
- /**
20
- * ANSI escape codes for terminal styling.
21
- */
22
- export declare const Ansi: Readonly<{
23
- /** Clear entire line */
24
- readonly ClearLine: "\u001B[2K";
25
- /** Move cursor to start of line */
26
- readonly CursorStart: "\r";
27
- /**
28
- * Generates ANSI escape code to move cursor up by specified lines.
29
- *
30
- * @param n - Number of lines to move up
31
- * @returns ANSI escape sequence string
32
- */
33
- readonly cursorUp: (n: number) => string;
34
- /**
35
- * Generates ANSI escape code to move cursor down by specified lines.
36
- *
37
- * @param n - Number of lines to move down
38
- * @returns ANSI escape sequence string
39
- */
40
- readonly cursorDown: (n: number) => string;
41
- /**
42
- * Generates ANSI escape code to move cursor left by specified columns.
43
- *
44
- * @param n - Number of columns to move left
45
- * @returns ANSI escape sequence string
46
- */
47
- readonly cursorLeft: (n: number) => string;
48
- /** Escape code to hide cursor */
49
- readonly HideCursor: "\u001B[?25l";
50
- /** Escape code to show cursor */
51
- readonly ShowCursor: "\u001B[?25h";
52
- /** Escape code to save cursor position */
53
- readonly SaveCursor: "\u001B7";
54
- /** Escape code to restore cursor position */
55
- readonly RestoreCursor: "\u001B8";
56
- /** Clear from cursor to end of screen */
57
- readonly ClearToEnd: "\u001B[J";
58
- /** Escape code for bold text */
59
- readonly Bold: "\u001B[1m";
60
- /** Escape code for dim text */
61
- readonly Dim: "\u001B[2m";
62
- /** Escape code to reset all styles */
63
- readonly Reset: "\u001B[0m";
64
- /** Escape code for cyan foreground */
65
- readonly Cyan: "\u001B[36m";
66
- /** Escape code for green foreground */
67
- readonly Green: "\u001B[32m";
68
- /** Escape code for yellow foreground */
69
- readonly Yellow: "\u001B[33m";
70
- /** Escape code for red foreground */
71
- readonly Red: "\u001B[31m";
72
- /** Escape code for gray foreground */
73
- readonly Gray: "\u001B[90m";
74
- }>;
75
- /**
76
- * Terminal interface configuration.
77
- */
78
- export interface TerminalConfig {
79
- /** Stream to read input from */
80
- readonly input?: NodeJS.ReadStream;
81
- /** Stream to write output to */
82
- readonly output?: NodeJS.WriteStream;
83
- }
84
- /**
85
- * Terminal interface for interactive prompts.
86
- */
87
- export interface Terminal {
88
- /** Write text to output */
89
- readonly write: (text: string) => void;
90
- /** Read a single keypress */
91
- readonly readKey: () => Promise<string>;
92
- /** Read a line of text */
93
- readonly readLine: () => Promise<string>;
94
- /** Clear N lines from current position */
95
- readonly clearLines: (count: number) => void;
96
- /** Close the terminal interface */
97
- readonly close: () => void;
98
- /** Check if cancelled (Ctrl+C pressed) */
99
- readonly isCancelled: () => boolean;
100
- /** Set cancelled state */
101
- readonly cancel: () => void;
102
- }
103
- /**
104
- * Creates a terminal interface for interactive prompts.
105
- *
106
- * @param config - Terminal configuration options
107
- * @returns Terminal interface with read/write methods
108
- *
109
- * @example Create terminal for prompts
110
- * ```typescript
111
- * const term = createTerminal()
112
- * term.write('Enter name: ')
113
- * const name = await term.readLine()
114
- * term.close()
115
- * ```
116
- */
117
- export declare function createTerminal(config?: TerminalConfig): Terminal;
118
- //# sourceMappingURL=terminal.d.ts.map
package/terminal.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../../../../../libs/questions/src/terminal.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;EAYd,CAAA;AAEF,8BAA8B;AAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,MAAM,OAAO,GAAG,CAAC,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,IAAI;IACf,wBAAwB;;IAExB,mCAAmC;;IAEnC;;;;;OAKG;2BACW,MAAM,KAAG,MAAM;IAC7B;;;;;OAKG;6BACa,MAAM,KAAG,MAAM;IAC/B;;;;;OAKG;6BACa,MAAM,KAAG,MAAM;IAC/B,iCAAiC;;IAEjC,iCAAiC;;IAEjC,0CAA0C;;IAE1C,6CAA6C;;IAE7C,yCAAyC;;IAEzC,gCAAgC;;IAEhC,+BAA+B;;IAE/B,sCAAsC;;IAEtC,sCAAsC;;IAEtC,uCAAuC;;IAEvC,wCAAwC;;IAExC,qCAAqC;;IAErC,sCAAsC;;EAEtC,CAAA;AAEF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IAClC,gCAAgC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACvC,0BAA0B;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACxC,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAA;IACnC,0BAA0B;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAA;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,cAAmB,GAAG,QAAQ,CAiFpE"}
package/types.d.ts DELETED
@@ -1,112 +0,0 @@
1
- /**
2
- * Result state of a prompt interaction.
3
- */
4
- export declare const PromptResult: Readonly<{
5
- /** User submitted a value */
6
- readonly Submitted: "submitted";
7
- /** User cancelled the prompt (Ctrl+C) */
8
- readonly Cancelled: "cancelled";
9
- }>;
10
- /** Result state of a prompt interaction. */
11
- export type PromptResult = (typeof PromptResult)[keyof typeof PromptResult];
12
- /**
13
- * Base configuration shared by all prompts.
14
- */
15
- export interface PromptConfig {
16
- /** The question message to display */
17
- readonly message: string;
18
- /** Stream to read input from (defaults to stdin) */
19
- readonly input?: NodeJS.ReadStream;
20
- /** Stream to write output to (defaults to stdout) */
21
- readonly output?: NodeJS.WriteStream;
22
- }
23
- /**
24
- * Outcome when user submits a value.
25
- */
26
- export interface PromptSubmittedOutcome<T> {
27
- /** Submission result indicator */
28
- readonly result: typeof PromptResult.Submitted;
29
- /** The submitted value */
30
- readonly value: T;
31
- }
32
- /**
33
- * Outcome when user cancels the prompt.
34
- */
35
- export interface PromptCancelledOutcome {
36
- /** Cancellation result indicator */
37
- readonly result: typeof PromptResult.Cancelled;
38
- /** No value on cancellation */
39
- readonly value: undefined;
40
- }
41
- /**
42
- * Outcome of a prompt interaction.
43
- */
44
- export type PromptOutcome<T> = PromptSubmittedOutcome<T> | PromptCancelledOutcome;
45
- /**
46
- * A prompt function that asks a question and returns a value.
47
- */
48
- export type PromptFunction<TConfig extends PromptConfig, TValue> = (config: TConfig) => Promise<PromptOutcome<TValue>>;
49
- /**
50
- * Choice item for select/multiselect prompts.
51
- */
52
- export interface Choice<T = string> {
53
- /** Display label */
54
- readonly label: string;
55
- /** Value returned when selected */
56
- readonly value: T;
57
- /** Optional hint text shown after label */
58
- readonly hint?: string;
59
- /** Whether this choice is disabled */
60
- readonly disabled?: boolean;
61
- }
62
- /**
63
- * Configuration for text input prompts.
64
- */
65
- export interface TextConfig extends PromptConfig {
66
- /** Default value if user submits empty input */
67
- readonly initial?: string;
68
- /** Validator function - return error message string to reject, undefined to accept */
69
- readonly validate?: (value: string) => string | undefined;
70
- /** Transform display of input (e.g., for password masking) */
71
- readonly format?: (value: string) => string;
72
- /** Dynamic message recomputed on every keystroke; overrides `message` when present */
73
- readonly renderMessage?: (value: string) => string;
74
- }
75
- /**
76
- * Configuration for confirmation prompts.
77
- */
78
- export interface ConfirmConfig extends PromptConfig {
79
- /** Default value if user just presses enter */
80
- readonly initial?: boolean;
81
- }
82
- /**
83
- * Configuration for single-select prompts.
84
- */
85
- export interface SelectConfig<T = string> extends PromptConfig {
86
- /** Available choices */
87
- readonly choices: ReadonlyArray<Choice<T>>;
88
- /** Index of initially selected choice */
89
- readonly initial?: number;
90
- /** Maximum number of visible choices (enables scrolling) */
91
- readonly maxVisible?: number;
92
- /** Enable type-to-filter */
93
- readonly searchable?: boolean;
94
- }
95
- /**
96
- * Configuration for multi-select prompts.
97
- */
98
- export interface MultiselectConfig<T = string> extends PromptConfig {
99
- /** Available choices */
100
- readonly choices: ReadonlyArray<Choice<T>>;
101
- /** Indices of initially selected choices */
102
- readonly initial?: ReadonlyArray<number>;
103
- /** Maximum number of visible choices (enables scrolling) */
104
- readonly maxVisible?: number;
105
- /** Minimum required selections */
106
- readonly min?: number;
107
- /** Maximum allowed selections */
108
- readonly max?: number;
109
- /** Enable type-to-filter */
110
- readonly searchable?: boolean;
111
- }
112
- //# sourceMappingURL=types.d.ts.map
package/types.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/questions/src/types.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB,6BAA6B;;IAE7B,yCAAyC;;EAEzC,CAAA;AAEF,4CAA4C;AAC5C,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAA;AAE3E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IAClC,qDAAqD;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,kCAAkC;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,YAAY,CAAC,SAAS,CAAA;IAC9C,0BAA0B;IAC1B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,YAAY,CAAC,SAAS,CAAA;IAC9C,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAA;AAEjF;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,YAAY,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CA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