@nan0web/ui-cli 1.1.1 → 2.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 +153 -203
- package/bin/cli.js +11 -0
- package/bin/nan0cli.js +86 -0
- package/package.json +27 -13
- package/src/CLI.js +22 -30
- package/src/CLiMessage.js +2 -3
- package/src/Command.js +26 -24
- package/src/CommandError.js +3 -5
- package/src/CommandHelp.js +40 -36
- package/src/CommandMessage.js +56 -40
- package/src/CommandParser.js +27 -25
- package/src/InputAdapter.js +630 -90
- package/src/OutputAdapter.js +7 -8
- package/src/README.md.js +241 -312
- package/src/components/Alert.js +3 -6
- package/src/components/prompt/Autocomplete.js +12 -0
- package/src/components/prompt/Confirm.js +29 -0
- package/src/components/prompt/DateTime.js +26 -0
- package/src/components/prompt/Input.js +15 -0
- package/src/components/prompt/Mask.js +12 -0
- package/src/components/prompt/Multiselect.js +26 -0
- package/src/components/prompt/Next.js +8 -0
- package/src/components/prompt/Password.js +13 -0
- package/src/components/prompt/Pause.js +9 -0
- package/src/components/prompt/ProgressBar.js +16 -0
- package/src/components/prompt/Select.js +29 -0
- package/src/components/prompt/Slider.js +16 -0
- package/src/components/prompt/Spinner.js +29 -0
- package/src/components/prompt/Toggle.js +13 -0
- package/src/components/prompt/Tree.js +17 -0
- package/src/components/view/Alert.js +78 -0
- package/src/components/view/Badge.js +11 -0
- package/src/components/view/Nav.js +23 -0
- package/src/components/view/Table.js +12 -0
- package/src/components/view/Toast.js +9 -0
- package/src/core/Component.js +79 -0
- package/src/core/PropValidation.js +138 -0
- package/src/core/render.js +37 -0
- package/src/index.js +85 -40
- package/src/test/PlaygroundTest.js +37 -25
- package/src/test/index.js +2 -4
- package/src/ui/alert.js +58 -0
- package/src/ui/autocomplete.js +86 -0
- package/src/ui/badge.js +35 -0
- package/src/ui/confirm.js +49 -0
- package/src/ui/date-time.js +45 -0
- package/src/ui/form.js +120 -55
- package/src/ui/index.js +18 -4
- package/src/ui/input.js +79 -152
- package/src/ui/mask.js +132 -0
- package/src/ui/multiselect.js +59 -0
- package/src/ui/nav.js +74 -0
- package/src/ui/next.js +18 -13
- package/src/ui/progress.js +88 -0
- package/src/ui/select.js +49 -72
- package/src/ui/slider.js +154 -0
- package/src/ui/spinner.js +65 -0
- package/src/ui/table.js +163 -0
- package/src/ui/toast.js +34 -0
- package/src/ui/toggle.js +34 -0
- package/src/ui/tree.js +393 -0
- package/src/utils/parse.js +1 -1
- package/types/CLI.d.ts +5 -5
- package/types/CLiMessage.d.ts +1 -1
- package/types/Command.d.ts +2 -2
- package/types/CommandHelp.d.ts +3 -3
- package/types/CommandMessage.d.ts +8 -8
- package/types/CommandParser.d.ts +3 -3
- package/types/InputAdapter.d.ts +149 -15
- package/types/OutputAdapter.d.ts +1 -1
- package/types/README.md.d.ts +1 -1
- package/types/UiMessage.d.ts +31 -29
- package/types/components/prompt/Autocomplete.d.ts +6 -0
- package/types/components/prompt/Confirm.d.ts +6 -0
- package/types/components/prompt/DateTime.d.ts +6 -0
- package/types/components/prompt/Input.d.ts +6 -0
- package/types/components/prompt/Mask.d.ts +6 -0
- package/types/components/prompt/Multiselect.d.ts +6 -0
- package/types/components/prompt/Next.d.ts +6 -0
- package/types/components/prompt/Password.d.ts +6 -0
- package/types/components/prompt/Pause.d.ts +6 -0
- package/types/components/prompt/ProgressBar.d.ts +12 -0
- package/types/components/prompt/Select.d.ts +18 -0
- package/types/components/prompt/Slider.d.ts +6 -0
- package/types/components/prompt/Spinner.d.ts +21 -0
- package/types/components/prompt/Toggle.d.ts +6 -0
- package/types/components/prompt/Tree.d.ts +6 -0
- package/types/components/view/Alert.d.ts +21 -0
- package/types/components/view/Badge.d.ts +5 -0
- package/types/components/view/Nav.d.ts +15 -0
- package/types/components/view/Table.d.ts +10 -0
- package/types/components/view/Toast.d.ts +5 -0
- package/types/core/Component.d.ts +34 -0
- package/types/core/PropValidation.d.ts +48 -0
- package/types/core/render.d.ts +6 -0
- package/types/index.d.ts +47 -15
- package/types/test/PlaygroundTest.d.ts +12 -8
- package/types/test/index.d.ts +1 -1
- package/types/ui/alert.d.ts +14 -0
- package/types/ui/autocomplete.d.ts +20 -0
- package/types/ui/badge.d.ts +8 -0
- package/types/ui/confirm.d.ts +21 -0
- package/types/ui/date-time.d.ts +19 -0
- package/types/ui/form.d.ts +43 -12
- package/types/ui/index.d.ts +17 -2
- package/types/ui/input.d.ts +31 -74
- package/types/ui/mask.d.ts +29 -0
- package/types/ui/multiselect.d.ts +25 -0
- package/types/ui/nav.d.ts +27 -0
- package/types/ui/progress.d.ts +43 -0
- package/types/ui/select.d.ts +25 -64
- package/types/ui/slider.d.ts +23 -0
- package/types/ui/spinner.d.ts +28 -0
- package/types/ui/table.d.ts +28 -0
- package/types/ui/toast.d.ts +8 -0
- package/types/ui/toggle.d.ts +17 -0
- package/types/ui/tree.d.ts +48 -0
package/types/InputAdapter.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} ConsoleLike
|
|
3
|
+
* @property {(...args: any[]) => void} debug
|
|
4
|
+
* @property {(...args: any[]) => void} log
|
|
5
|
+
* @property {(...args: any[]) => void} info
|
|
6
|
+
* @property {(...args: any[]) => void} warn
|
|
7
|
+
* @property {(...args: any[]) => void} error
|
|
8
|
+
*/
|
|
3
9
|
/**
|
|
4
10
|
* Extends the generic {@link BaseInputAdapter} with CLI‑specific behaviour.
|
|
5
11
|
*
|
|
@@ -9,16 +15,34 @@
|
|
|
9
15
|
export default class CLiInputAdapter extends BaseInputAdapter {
|
|
10
16
|
constructor(options?: {});
|
|
11
17
|
/** @returns {ConsoleLike} */
|
|
12
|
-
get console():
|
|
18
|
+
get console(): ConsoleLike;
|
|
19
|
+
/** @param {Function} val */
|
|
20
|
+
set t(val: Function);
|
|
21
|
+
/** @returns {Function} */
|
|
22
|
+
get t(): Function;
|
|
13
23
|
/** @returns {NodeJS.WriteStream} */
|
|
14
24
|
get stdout(): NodeJS.WriteStream;
|
|
25
|
+
/** @returns {string[]} */
|
|
26
|
+
getRemainingAnswers(): string[];
|
|
15
27
|
/**
|
|
16
28
|
* Create a handler with stop words that supports predefined answers.
|
|
17
29
|
*
|
|
18
30
|
* @param {string[]} stops - Stop words for cancellation.
|
|
19
|
-
* @returns {
|
|
31
|
+
* @returns {Function}
|
|
32
|
+
*/
|
|
33
|
+
createHandler(stops?: string[]): Function;
|
|
34
|
+
/**
|
|
35
|
+
* Create a select handler that supports predefined answers.
|
|
36
|
+
* @returns {Function}
|
|
20
37
|
*/
|
|
21
|
-
|
|
38
|
+
createSelectHandler(): Function;
|
|
39
|
+
/**
|
|
40
|
+
* Pause execution and wait for user input (Press any key).
|
|
41
|
+
*
|
|
42
|
+
* @param {string} [message] - Message to display.
|
|
43
|
+
* @returns {Promise<void>}
|
|
44
|
+
*/
|
|
45
|
+
pause(message?: string): Promise<void>;
|
|
22
46
|
/**
|
|
23
47
|
* Prompt the user for a full form, handling navigation and validation.
|
|
24
48
|
*
|
|
@@ -29,7 +53,7 @@ export default class CLiInputAdapter extends BaseInputAdapter {
|
|
|
29
53
|
*/
|
|
30
54
|
requestForm(form: UiForm, options?: {
|
|
31
55
|
silent?: boolean | undefined;
|
|
32
|
-
}
|
|
56
|
+
}): Promise<any>;
|
|
33
57
|
/**
|
|
34
58
|
* Render a UI component in the CLI environment.
|
|
35
59
|
*
|
|
@@ -52,16 +76,120 @@ export default class CLiInputAdapter extends BaseInputAdapter {
|
|
|
52
76
|
* Prompt the user to select an option from a list.
|
|
53
77
|
*
|
|
54
78
|
* @param {Object} config - Configuration object.
|
|
55
|
-
* @returns {Promise<string>} Selected value (or
|
|
79
|
+
* @returns {Promise<{value: string|undefined, cancelled: boolean}>} Selected value (or undefined on cancel).
|
|
56
80
|
*/
|
|
57
|
-
requestSelect(config: any): Promise<
|
|
81
|
+
requestSelect(config: any): Promise<{
|
|
82
|
+
value: string | undefined;
|
|
83
|
+
cancelled: boolean;
|
|
84
|
+
}>;
|
|
58
85
|
/**
|
|
59
86
|
* Prompt for a single string input.
|
|
60
87
|
*
|
|
61
88
|
* @param {Object} config - Prompt configuration.
|
|
62
|
-
* @returns {Promise<string>} User response string.
|
|
89
|
+
* @returns {Promise<{value: string|undefined, cancelled: boolean}>} User response string or undefined on cancel.
|
|
90
|
+
*/
|
|
91
|
+
requestInput(config: any): Promise<{
|
|
92
|
+
value: string | undefined;
|
|
93
|
+
cancelled: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Prompt the user for an autocomplete selection.
|
|
97
|
+
*
|
|
98
|
+
* @param {Object} config - Configuration object.
|
|
99
|
+
* @returns {Promise<{value: any, cancelled: boolean}>} Selected value.
|
|
100
|
+
*/
|
|
101
|
+
requestAutocomplete(config: any): Promise<{
|
|
102
|
+
value: any;
|
|
103
|
+
cancelled: boolean;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Requests confirmation (yes/no).
|
|
107
|
+
*
|
|
108
|
+
* @param {Object} config - Confirmation configuration.
|
|
109
|
+
* @returns {Promise<{value: boolean|undefined, cancelled: boolean}>} User confirmation.
|
|
110
|
+
*/
|
|
111
|
+
requestConfirm(config: any): Promise<{
|
|
112
|
+
value: boolean | undefined;
|
|
113
|
+
cancelled: boolean;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Display an interactive table.
|
|
117
|
+
*
|
|
118
|
+
* @param {Object} config - Table configuration.
|
|
119
|
+
* @returns {Promise<{value: any, cancelled: boolean}>}
|
|
120
|
+
*/
|
|
121
|
+
requestTable(config: any): Promise<{
|
|
122
|
+
value: any;
|
|
123
|
+
cancelled: boolean;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Requests multiple selection.
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} config - Multiselect configuration.
|
|
129
|
+
* @returns {Promise<{value: any[]|undefined, cancelled: boolean}>} Selected values.
|
|
130
|
+
*/
|
|
131
|
+
requestMultiselect(config: any): Promise<{
|
|
132
|
+
value: any[] | undefined;
|
|
133
|
+
cancelled: boolean;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Requests masked input.
|
|
137
|
+
*
|
|
138
|
+
* @param {Object} config - Mask configuration.
|
|
139
|
+
* @returns {Promise<{value: string|undefined, cancelled: boolean}>} Masked value.
|
|
140
|
+
*/
|
|
141
|
+
requestMask(config: any): Promise<{
|
|
142
|
+
value: string | undefined;
|
|
143
|
+
cancelled: boolean;
|
|
144
|
+
}>;
|
|
145
|
+
/**
|
|
146
|
+
* Request a toggle switch.
|
|
147
|
+
* @param {Object} config
|
|
148
|
+
* @returns {Promise<{value: boolean|undefined, cancelled: boolean}>}
|
|
149
|
+
*/
|
|
150
|
+
requestToggle(config: any): Promise<{
|
|
151
|
+
value: boolean | undefined;
|
|
152
|
+
cancelled: boolean;
|
|
153
|
+
}>;
|
|
154
|
+
/**
|
|
155
|
+
* Request a numeric slider.
|
|
156
|
+
* @param {Object} config
|
|
157
|
+
* @returns {Promise<{value: number|undefined, cancelled: boolean}>}
|
|
63
158
|
*/
|
|
64
|
-
|
|
159
|
+
requestSlider(config: any): Promise<{
|
|
160
|
+
value: number | undefined;
|
|
161
|
+
cancelled: boolean;
|
|
162
|
+
}>;
|
|
163
|
+
/**
|
|
164
|
+
* Create a progress bar.
|
|
165
|
+
* @param {Object} options
|
|
166
|
+
* @returns {import('./ui/progress.js').ProgressBar}
|
|
167
|
+
*/
|
|
168
|
+
requestProgress(options: any): import("./ui/progress.js").ProgressBar;
|
|
169
|
+
/**
|
|
170
|
+
* Create and start a spinner.
|
|
171
|
+
* @param {string} message
|
|
172
|
+
* @returns {import('./ui/spinner.js').Spinner}
|
|
173
|
+
*/
|
|
174
|
+
requestSpinner(message: string): import("./ui/spinner.js").Spinner;
|
|
175
|
+
/**
|
|
176
|
+
* Request a selection from a tree view.
|
|
177
|
+
* @param {Object} config
|
|
178
|
+
* @returns {Promise<{value: any, cancelled: boolean}>} Selected node(s).
|
|
179
|
+
*/
|
|
180
|
+
requestTree(config: any): Promise<{
|
|
181
|
+
value: any;
|
|
182
|
+
cancelled: boolean;
|
|
183
|
+
}>;
|
|
184
|
+
/**
|
|
185
|
+
* Request a date or time from the user.
|
|
186
|
+
* @param {Object} config
|
|
187
|
+
* @returns {Promise<{value: Date|undefined, cancelled: boolean}>}
|
|
188
|
+
*/
|
|
189
|
+
requestDateTime(config: any): Promise<{
|
|
190
|
+
value: Date | undefined;
|
|
191
|
+
cancelled: boolean;
|
|
192
|
+
}>;
|
|
65
193
|
/**
|
|
66
194
|
* Asks user a question or form and returns the completed form
|
|
67
195
|
* @param {string | UiForm} question
|
|
@@ -73,6 +201,7 @@ export default class CLiInputAdapter extends BaseInputAdapter {
|
|
|
73
201
|
select(cfg: any): Promise<{
|
|
74
202
|
index: number;
|
|
75
203
|
value: any;
|
|
204
|
+
cancelled: boolean;
|
|
76
205
|
}>;
|
|
77
206
|
/**
|
|
78
207
|
* **New API** – Require input for a {@link UiMessage} instance.
|
|
@@ -89,8 +218,13 @@ export default class CLiInputAdapter extends BaseInputAdapter {
|
|
|
89
218
|
requireInput(msg: UiMessage): Promise<any>;
|
|
90
219
|
#private;
|
|
91
220
|
}
|
|
92
|
-
export type
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
221
|
+
export type ConsoleLike = {
|
|
222
|
+
debug: (...args: any[]) => void;
|
|
223
|
+
log: (...args: any[]) => void;
|
|
224
|
+
info: (...args: any[]) => void;
|
|
225
|
+
warn: (...args: any[]) => void;
|
|
226
|
+
error: (...args: any[]) => void;
|
|
227
|
+
};
|
|
228
|
+
import { InputAdapter as BaseInputAdapter } from '@nan0web/ui';
|
|
229
|
+
import { UiForm } from '@nan0web/ui';
|
|
230
|
+
import { UiMessage } from '@nan0web/ui';
|
package/types/OutputAdapter.d.ts
CHANGED
package/types/README.md.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
package/types/UiMessage.d.ts
CHANGED
|
@@ -8,33 +8,35 @@
|
|
|
8
8
|
* @extends {Message}
|
|
9
9
|
*/
|
|
10
10
|
export default class UiMessage<T extends Record<string, any>> extends Message {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
constructor(
|
|
12
|
+
input?: import('../node_modules/@nan0web/co/types/Message.js').MessageInput | undefined,
|
|
13
|
+
)
|
|
14
|
+
/**
|
|
15
|
+
* Validates the message body against its schema.
|
|
16
|
+
*
|
|
17
|
+
* NOTE: The signature must exactly match `Message.validate` – it returns a
|
|
18
|
+
* `Map<string,string>` regardless of the generic type, otherwise TypeScript
|
|
19
|
+
* reports incompatibility with the base class.
|
|
20
|
+
*
|
|
21
|
+
* @param {any} [body=this.body] - Optional body to validate.
|
|
22
|
+
* @returns {Map<string,string>} Map of validation errors (empty if valid).
|
|
23
|
+
*/
|
|
24
|
+
validate(body?: any): Map<string, string>
|
|
25
|
+
/**
|
|
26
|
+
* Requires input via UI adapter. Validates fields according to the static `Body` schema.
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} ui - UI adapter with input/output capabilities.
|
|
29
|
+
* @param {InputAdapter} ui.input - Input adapter for prompts.
|
|
30
|
+
* @param {OutputAdapter} [ui.output] - Optional output adapter for rendering.
|
|
31
|
+
* @returns {Promise<T>} Resolves with updated body or rejects if cancelled.
|
|
32
|
+
* @throws {CancelError} When user cancels the input process.
|
|
33
|
+
*/
|
|
34
|
+
requireInput(ui: {
|
|
35
|
+
input: InputAdapter
|
|
36
|
+
output?: import('./OutputAdapter.js').default | undefined
|
|
37
|
+
}): Promise<T>
|
|
36
38
|
}
|
|
37
|
-
export type MessageBodySchema = import(
|
|
38
|
-
export type InputAdapter = import(
|
|
39
|
-
export type OutputAdapter = import(
|
|
40
|
-
import { Message } from
|
|
39
|
+
export type MessageBodySchema = import('@nan0web/co').MessageBodySchema
|
|
40
|
+
export type InputAdapter = import('./InputAdapter.js').default
|
|
41
|
+
export type OutputAdapter = import('./OutputAdapter.js').default
|
|
42
|
+
import { Message } from '@nan0web/co'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select Prompt Component.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} props
|
|
5
|
+
* @param {string} props.message - Question/Title.
|
|
6
|
+
* @param {Array} props.options - Options list.
|
|
7
|
+
* @param {number} [props.limit] - Max visible options.
|
|
8
|
+
*/
|
|
9
|
+
export function Select(props: {
|
|
10
|
+
message: string;
|
|
11
|
+
options: any[];
|
|
12
|
+
limit?: number | undefined;
|
|
13
|
+
}): {
|
|
14
|
+
$$typeof: symbol;
|
|
15
|
+
type: string;
|
|
16
|
+
props: any;
|
|
17
|
+
execute: () => any;
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spinner Component.
|
|
3
|
+
* Usage: await render(Spinner({ message: 'Loading...', action: promise }))
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} props
|
|
6
|
+
* @param {string} props.message - Main message.
|
|
7
|
+
* @param {Promise<any>} [props.action] - Async action to wait for.
|
|
8
|
+
* @param {string} [props.successMessage] - Message on success.
|
|
9
|
+
* @param {string} [props.errorMessage] - Message on error.
|
|
10
|
+
*/
|
|
11
|
+
export function Spinner(props: {
|
|
12
|
+
message: string;
|
|
13
|
+
action?: Promise<any> | undefined;
|
|
14
|
+
successMessage?: string | undefined;
|
|
15
|
+
errorMessage?: string | undefined;
|
|
16
|
+
}): {
|
|
17
|
+
$$typeof: symbol;
|
|
18
|
+
type: string;
|
|
19
|
+
props: any;
|
|
20
|
+
execute: () => any;
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alert View Component.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} props
|
|
5
|
+
* @param {string} props.title - Title of the alert.
|
|
6
|
+
* @param {string} props.children - Message content.
|
|
7
|
+
* @param {'info'|'success'|'warning'|'error'} [props.variant='info'] - Style variant.
|
|
8
|
+
* @param {string} [props.message] - Alias for children (legacy support).
|
|
9
|
+
* @param {boolean} [props.sound] - Play sound (side-effect during toString is acceptable here as it invokes on print).
|
|
10
|
+
*/
|
|
11
|
+
export function Alert(props: {
|
|
12
|
+
title: string;
|
|
13
|
+
children: string;
|
|
14
|
+
variant?: "error" | "info" | "success" | "warning" | undefined;
|
|
15
|
+
message?: string | undefined;
|
|
16
|
+
sound?: boolean | undefined;
|
|
17
|
+
}): {
|
|
18
|
+
$$typeof: symbol;
|
|
19
|
+
type: string;
|
|
20
|
+
props: any;
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function Breadcrumbs(props: any): {
|
|
2
|
+
$$typeof: symbol;
|
|
3
|
+
type: string;
|
|
4
|
+
props: any;
|
|
5
|
+
};
|
|
6
|
+
export function Tabs(props: any): {
|
|
7
|
+
$$typeof: symbol;
|
|
8
|
+
type: string;
|
|
9
|
+
props: any;
|
|
10
|
+
};
|
|
11
|
+
export function Steps(props: any): {
|
|
12
|
+
$$typeof: symbol;
|
|
13
|
+
type: string;
|
|
14
|
+
props: any;
|
|
15
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a Static View Component.
|
|
3
|
+
* These components are synchronous and can be stringified directly.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} displayName - Name of the component (e.g. 'Alert').
|
|
6
|
+
* @param {any} props - Props passed to the component.
|
|
7
|
+
* @param {Function} formatFn - Pure function (props) => string.
|
|
8
|
+
*/
|
|
9
|
+
export function createView(displayName: string, props: any, formatFn: Function): {
|
|
10
|
+
$$typeof: symbol;
|
|
11
|
+
type: string;
|
|
12
|
+
props: any;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Creates an Interactive Prompt Component.
|
|
16
|
+
* These components are asynchronous and require `render()` or `await` handling.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} displayName - Name of the component.
|
|
19
|
+
* @param {any} props - Props.
|
|
20
|
+
* @param {Function} executorFn - Async function (props) => Promise<result>.
|
|
21
|
+
*/
|
|
22
|
+
export function createPrompt(displayName: string, props: any, executorFn: Function): {
|
|
23
|
+
$$typeof: symbol;
|
|
24
|
+
type: string;
|
|
25
|
+
props: any;
|
|
26
|
+
execute: () => any;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Core Component logic.
|
|
30
|
+
*
|
|
31
|
+
* Defines the contract for View (static) and Prompt (interactive) components.
|
|
32
|
+
*/
|
|
33
|
+
export const ComponentSymbol: unique symbol;
|
|
34
|
+
export const PromptSymbol: unique symbol;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop validation utilities for UI components.
|
|
3
|
+
* @module core/PropValidation
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Validates that a value is a valid Date object or a parseable date string.
|
|
7
|
+
* @param {any} value
|
|
8
|
+
* @param {string} propName
|
|
9
|
+
* @param {string} componentName
|
|
10
|
+
* @throws {TypeError} if validation fails
|
|
11
|
+
*/
|
|
12
|
+
export function validateDate(value: any, propName: string, componentName: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Validates that a value is a string.
|
|
15
|
+
* @param {any} value
|
|
16
|
+
* @param {string} propName
|
|
17
|
+
* @param {string} componentName
|
|
18
|
+
* @param {boolean} required
|
|
19
|
+
* @throws {TypeError} if validation fails
|
|
20
|
+
*/
|
|
21
|
+
export function validateString(value: any, propName: string, componentName: string, required?: boolean): void;
|
|
22
|
+
/**
|
|
23
|
+
* Validates that a value is a function.
|
|
24
|
+
* @param {any} value
|
|
25
|
+
* @param {string} propName
|
|
26
|
+
* @param {string} componentName
|
|
27
|
+
* @param {boolean} required
|
|
28
|
+
* @throws {TypeError} if validation fails
|
|
29
|
+
*/
|
|
30
|
+
export function validateFunction(value: any, propName: string, componentName: string, required?: boolean): void;
|
|
31
|
+
/**
|
|
32
|
+
* Validates that a value is a boolean.
|
|
33
|
+
* @param {any} value
|
|
34
|
+
* @param {string} propName
|
|
35
|
+
* @param {string} componentName
|
|
36
|
+
* @param {boolean} required
|
|
37
|
+
* @throws {TypeError} if validation fails
|
|
38
|
+
*/
|
|
39
|
+
export function validateBoolean(value: any, propName: string, componentName: string, required?: boolean): void;
|
|
40
|
+
/**
|
|
41
|
+
* Validates that a value is a number.
|
|
42
|
+
* @param {any} value
|
|
43
|
+
* @param {string} propName
|
|
44
|
+
* @param {string} componentName
|
|
45
|
+
* @param {boolean} required
|
|
46
|
+
* @throws {TypeError} if validation fails
|
|
47
|
+
*/
|
|
48
|
+
export function validateNumber(value: any, propName: string, componentName: string, required?: boolean): void;
|