@shell-shock/plugin-prompts 0.3.48 → 0.3.49
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/dist/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/components/index.cjs +1 -12
- package/dist/components/index.mjs +1 -3
- package/dist/components/prompts-builtin.cjs +80 -2042
- package/dist/components/prompts-builtin.mjs +80 -2031
- package/dist/components/prompts-builtin.mjs.map +1 -1
- package/dist/index.cjs +1 -30
- package/dist/index.mjs +1 -26
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +9 -9
|
@@ -1,404 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
-
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
-
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
|
-
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
7
|
-
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
8
|
-
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
9
|
-
let _powerlines_plugin_alloy_typescript_components_class_declaration = require("@powerlines/plugin-alloy/typescript/components/class-declaration");
|
|
10
|
-
let _powerlines_plugin_alloy_typescript_components_interface_declaration = require("@powerlines/plugin-alloy/typescript/components/interface-declaration");
|
|
11
|
-
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
12
|
-
let _powerlines_plugin_alloy_typescript_components_type_declaration = require("@powerlines/plugin-alloy/typescript/components/type-declaration");
|
|
13
|
-
let _shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
|
|
14
|
-
let defu = require("defu");
|
|
15
|
-
defu = require_runtime.__toESM(defu);
|
|
16
|
-
|
|
17
|
-
//#region src/components/prompts-builtin.tsx
|
|
18
|
-
/**
|
|
19
|
-
* A component that generates TypeScript declarations for built-in prompt types and related utilities, such as the base Prompt class, specific prompt types like TextPrompt and SelectPrompt, and utility functions for handling prompt cancellations. This component serves as a central place to define the types and interfaces for prompts used in the Shell Shock CLI, providing a consistent API for creating and managing prompts throughout the application.
|
|
20
|
-
*/
|
|
21
|
-
function BasePromptDeclarations() {
|
|
22
|
-
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
23
|
-
return [
|
|
24
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
25
|
-
"export": true,
|
|
26
|
-
name: "PromptParser",
|
|
27
|
-
typeParameters: [{
|
|
28
|
-
name: "TValue",
|
|
29
|
-
default: "string"
|
|
30
|
-
}],
|
|
31
|
-
doc: "A type for a custom prompt input parser, which can be used to create custom input styles for prompts. The function should return the parsed value for the given input string.",
|
|
32
|
-
children: _alloy_js_core.code`(this: Prompt<TValue>, input: string) => TValue; `
|
|
33
|
-
}),
|
|
34
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
35
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
36
|
-
"export": true,
|
|
37
|
-
name: "PromptFormatter",
|
|
38
|
-
typeParameters: [{
|
|
39
|
-
name: "TValue",
|
|
40
|
-
default: "string"
|
|
41
|
-
}],
|
|
42
|
-
doc: "A type for a custom prompt input formatter, which can be used to create custom display styles for prompts. The function should return the formatted string to display for the given input value.",
|
|
43
|
-
children: _alloy_js_core.code`(this: Prompt<TValue>, input: TValue) => string; `
|
|
44
|
-
}),
|
|
45
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
46
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
47
|
-
"export": true,
|
|
48
|
-
name: "noMask",
|
|
49
|
-
doc: "A built-in prompt mask function that just returns the input as is, making it invisible",
|
|
50
|
-
parameters: [{
|
|
51
|
-
name: "input",
|
|
52
|
-
type: "string"
|
|
53
|
-
}],
|
|
54
|
-
returnType: "string",
|
|
55
|
-
children: _alloy_js_core.code`return input; `
|
|
56
|
-
}),
|
|
57
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
58
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
59
|
-
"export": true,
|
|
60
|
-
name: "invisibleMask",
|
|
61
|
-
doc: "A built-in prompt mask function that makes input invisible",
|
|
62
|
-
parameters: [{
|
|
63
|
-
name: "input",
|
|
64
|
-
type: "string"
|
|
65
|
-
}],
|
|
66
|
-
returnType: "string",
|
|
67
|
-
children: _alloy_js_core.code`return " ".repeat(input.length); `
|
|
68
|
-
}),
|
|
69
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
70
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
71
|
-
"export": true,
|
|
72
|
-
name: "PromptState",
|
|
73
|
-
doc: "The current state of a prompt",
|
|
74
|
-
typeParameters: [{
|
|
75
|
-
name: "TValue",
|
|
76
|
-
default: "string"
|
|
77
|
-
}],
|
|
78
|
-
get children() {
|
|
79
|
-
return [
|
|
80
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
81
|
-
name: "value",
|
|
82
|
-
type: "TValue",
|
|
83
|
-
doc: "The current value of the prompt"
|
|
84
|
-
}),
|
|
85
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
86
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
87
|
-
name: "isError",
|
|
88
|
-
type: "boolean",
|
|
89
|
-
doc: "Indicates whether the prompt is in an error state"
|
|
90
|
-
}),
|
|
91
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
92
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
93
|
-
name: "errorMessage",
|
|
94
|
-
optional: true,
|
|
95
|
-
type: "string",
|
|
96
|
-
doc: "If the prompt is in an error state, this will contain the error message to display"
|
|
97
|
-
}),
|
|
98
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
99
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
100
|
-
name: "isSubmitted",
|
|
101
|
-
type: "boolean",
|
|
102
|
-
doc: "Indicates whether the prompt is submitted"
|
|
103
|
-
}),
|
|
104
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
105
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
106
|
-
name: "isCancelled",
|
|
107
|
-
type: "boolean",
|
|
108
|
-
doc: "Indicates whether the prompt is cancelled"
|
|
109
|
-
}),
|
|
110
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
111
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
112
|
-
name: "isCompleted",
|
|
113
|
-
type: "boolean",
|
|
114
|
-
doc: "Indicates whether the prompt is completed, which can be used to indicate that the prompt interaction is finished regardless of whether it was submitted or cancelled"
|
|
115
|
-
}),
|
|
116
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
117
|
-
];
|
|
118
|
-
}
|
|
119
|
-
}),
|
|
120
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
121
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
122
|
-
name: "PromptConfig",
|
|
123
|
-
doc: "Configuration options for creating a prompt",
|
|
124
|
-
typeParameters: [{
|
|
125
|
-
name: "TValue",
|
|
126
|
-
default: "string"
|
|
127
|
-
}],
|
|
128
|
-
get children() {
|
|
129
|
-
return [
|
|
130
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
131
|
-
name: "input",
|
|
132
|
-
optional: true,
|
|
133
|
-
type: "NodeJS.ReadStream",
|
|
134
|
-
doc: "The readable stream to use for prompt input, defaults to process.stdin"
|
|
135
|
-
}),
|
|
136
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
137
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
138
|
-
name: "output",
|
|
139
|
-
optional: true,
|
|
140
|
-
type: "NodeJS.WriteStream",
|
|
141
|
-
doc: "The writable stream to use for prompt output, defaults to process.stdout"
|
|
142
|
-
}),
|
|
143
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
144
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
145
|
-
name: "message",
|
|
146
|
-
type: "string",
|
|
147
|
-
doc: "The prompt message to display"
|
|
148
|
-
}),
|
|
149
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
150
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
151
|
-
name: "description",
|
|
152
|
-
optional: true,
|
|
153
|
-
type: "string",
|
|
154
|
-
doc: "The prompt description message to display"
|
|
155
|
-
}),
|
|
156
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
157
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
158
|
-
name: "initialValue",
|
|
159
|
-
optional: true,
|
|
160
|
-
type: "TValue",
|
|
161
|
-
doc: "The initial value of the prompt"
|
|
162
|
-
}),
|
|
163
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
164
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
165
|
-
name: "validate",
|
|
166
|
-
optional: true,
|
|
167
|
-
type: "(value: TValue) => boolean | string | null | undefined | Promise<boolean | string | null | undefined>",
|
|
168
|
-
doc: "A validation function that returns true if the input is valid, false or a string error message if the input is invalid"
|
|
169
|
-
}),
|
|
170
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
171
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
172
|
-
name: "parse",
|
|
173
|
-
optional: true,
|
|
174
|
-
type: "PromptParser<TValue>",
|
|
175
|
-
doc: "A function that parses the input value and returns the parsed result or throws an error if the input is invalid"
|
|
176
|
-
}),
|
|
177
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
178
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
179
|
-
name: "format",
|
|
180
|
-
optional: true,
|
|
181
|
-
type: "PromptFormatter<TValue>",
|
|
182
|
-
doc: "A function that formats the input value and returns the formatted result or throws an error if the input is invalid"
|
|
183
|
-
}),
|
|
184
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
185
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
186
|
-
name: "mask",
|
|
187
|
-
optional: true,
|
|
188
|
-
type: "(input: string) => string",
|
|
189
|
-
doc: "A function that masks the input value and returns the masked result. This can be used to create password inputs or other sensitive input types where the actual input value should not be displayed. If not provided, the prompt will display the input as is without masking."
|
|
190
|
-
}),
|
|
191
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
192
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
193
|
-
name: "maskCompleted",
|
|
194
|
-
optional: true,
|
|
195
|
-
type: "(input: string) => string",
|
|
196
|
-
doc: "A function that masks the value submitted by the user so that it can then be used in the console output or elsewhere without exposing sensitive information. If not provided, the prompt will use the same mask function for both input and submitted value masking."
|
|
197
|
-
}),
|
|
198
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
199
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
200
|
-
name: "defaultErrorMessage",
|
|
201
|
-
optional: true,
|
|
202
|
-
type: "string",
|
|
203
|
-
doc: "The default error message to display when validation fails"
|
|
204
|
-
}),
|
|
205
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
206
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
207
|
-
name: "timeout",
|
|
208
|
-
optional: true,
|
|
209
|
-
type: "number",
|
|
210
|
-
doc: "The timeout duration in milliseconds for the prompt. If none is provided, the prompt will not time out."
|
|
211
|
-
})
|
|
212
|
-
];
|
|
213
|
-
}
|
|
214
|
-
}),
|
|
215
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
216
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
217
|
-
abstract: true,
|
|
218
|
-
name: "Prompt",
|
|
219
|
-
doc: "Base prompt class that other prompt types can extend from",
|
|
220
|
-
"extends": "EventEmitter",
|
|
221
|
-
typeParameters: [{
|
|
222
|
-
name: "TValue",
|
|
223
|
-
default: "string"
|
|
224
|
-
}],
|
|
225
|
-
get children() {
|
|
226
|
-
return [
|
|
227
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
228
|
-
name: "readline",
|
|
229
|
-
isPrivateMember: true,
|
|
230
|
-
type: "Interface"
|
|
231
|
-
}),
|
|
232
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
233
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
234
|
-
name: "value",
|
|
235
|
-
isPrivateMember: true,
|
|
236
|
-
optional: true,
|
|
237
|
-
type: "TValue"
|
|
238
|
-
}),
|
|
239
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
240
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
241
|
-
name: "isKeyPressed",
|
|
242
|
-
isPrivateMember: true,
|
|
243
|
-
type: "boolean",
|
|
244
|
-
children: _alloy_js_core.code`false; `
|
|
245
|
-
}),
|
|
246
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
247
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
248
|
-
name: "isDirty",
|
|
249
|
-
isPrivateMember: true,
|
|
250
|
-
type: "boolean",
|
|
251
|
-
children: _alloy_js_core.code`false; `
|
|
252
|
-
}),
|
|
253
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
254
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
255
|
-
name: "isClosed",
|
|
256
|
-
isPrivateMember: true,
|
|
257
|
-
type: "boolean",
|
|
258
|
-
children: _alloy_js_core.code`false; `
|
|
259
|
-
}),
|
|
260
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
261
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
262
|
-
name: "initialValue",
|
|
263
|
-
abstract: true,
|
|
264
|
-
"protected": true,
|
|
265
|
-
type: "TValue"
|
|
266
|
-
}),
|
|
267
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
268
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
269
|
-
name: "input",
|
|
270
|
-
"protected": true,
|
|
271
|
-
type: "NodeJS.ReadStream",
|
|
272
|
-
children: _alloy_js_core.code`process.stdin; `
|
|
273
|
-
}),
|
|
274
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
275
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
276
|
-
name: "output",
|
|
277
|
-
"protected": true,
|
|
278
|
-
type: "NodeJS.WriteStream",
|
|
279
|
-
children: _alloy_js_core.code`process.stdout; `
|
|
280
|
-
}),
|
|
281
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
282
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
283
|
-
name: "message",
|
|
284
|
-
"protected": true,
|
|
285
|
-
type: "string",
|
|
286
|
-
children: _alloy_js_core.code`""; `
|
|
287
|
-
}),
|
|
288
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
289
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
290
|
-
name: "description",
|
|
291
|
-
"protected": true,
|
|
292
|
-
type: "string",
|
|
293
|
-
children: _alloy_js_core.code`""; `
|
|
294
|
-
}),
|
|
295
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
296
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
297
|
-
name: "errorMessage",
|
|
298
|
-
"protected": true,
|
|
299
|
-
type: "string | null",
|
|
300
|
-
children: _alloy_js_core.code`null; `
|
|
301
|
-
}),
|
|
302
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
303
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
304
|
-
name: "defaultErrorMessage",
|
|
305
|
-
"protected": true,
|
|
306
|
-
type: "string",
|
|
307
|
-
children: _alloy_js_core.code`"An invalid value was provided"; `
|
|
308
|
-
}),
|
|
309
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
310
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
311
|
-
name: "isSubmitted",
|
|
312
|
-
"protected": true,
|
|
313
|
-
type: "boolean",
|
|
314
|
-
children: _alloy_js_core.code`false; `
|
|
315
|
-
}),
|
|
316
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
317
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
318
|
-
name: "isCancelled",
|
|
319
|
-
"protected": true,
|
|
320
|
-
type: "boolean",
|
|
321
|
-
children: _alloy_js_core.code`false; `
|
|
322
|
-
}),
|
|
323
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
324
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
325
|
-
name: "isInitial",
|
|
326
|
-
"protected": true,
|
|
327
|
-
type: "boolean",
|
|
328
|
-
children: _alloy_js_core.code`true; `
|
|
329
|
-
}),
|
|
330
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
331
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
332
|
-
name: "consoleOutput",
|
|
333
|
-
"protected": true,
|
|
334
|
-
type: "string",
|
|
335
|
-
children: _alloy_js_core.code`""; `
|
|
336
|
-
}),
|
|
337
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
338
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
339
|
-
name: "consoleStatus",
|
|
340
|
-
"protected": true,
|
|
341
|
-
type: "string",
|
|
342
|
-
children: _alloy_js_core.code`""; `
|
|
343
|
-
}),
|
|
344
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
345
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
346
|
-
name: "displayValue",
|
|
347
|
-
"protected": true,
|
|
348
|
-
type: "string",
|
|
349
|
-
children: _alloy_js_core.code`""; `
|
|
350
|
-
}),
|
|
351
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
352
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
353
|
-
name: "validate",
|
|
354
|
-
"protected": true,
|
|
355
|
-
type: "(value: TValue) => boolean | string | null | undefined | Promise<boolean | string | null | undefined>",
|
|
356
|
-
children: _alloy_js_core.code`() => true; `
|
|
357
|
-
}),
|
|
358
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
359
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
360
|
-
name: "parse",
|
|
361
|
-
"protected": true,
|
|
362
|
-
type: "PromptParser<TValue>",
|
|
363
|
-
children: _alloy_js_core.code`(value: string) => value as TValue; `
|
|
364
|
-
}),
|
|
365
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
366
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
367
|
-
name: "format",
|
|
368
|
-
"protected": true,
|
|
369
|
-
type: "PromptFormatter<TValue>",
|
|
370
|
-
children: _alloy_js_core.code`(value: TValue) => String(value); `
|
|
371
|
-
}),
|
|
372
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
373
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
374
|
-
name: "mask",
|
|
375
|
-
"protected": true,
|
|
376
|
-
type: "(input: string) => string",
|
|
377
|
-
children: _alloy_js_core.code`noMask; `
|
|
378
|
-
}),
|
|
379
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
380
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
381
|
-
name: "maskCompleted",
|
|
382
|
-
"protected": true,
|
|
383
|
-
type: "(input: string) => string",
|
|
384
|
-
children: _alloy_js_core.code`this.mask; `
|
|
385
|
-
}),
|
|
386
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
387
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
388
|
-
name: "cursor",
|
|
389
|
-
"protected": true,
|
|
390
|
-
type: "number",
|
|
391
|
-
children: _alloy_js_core.code`0; `
|
|
392
|
-
}),
|
|
393
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
394
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
395
|
-
name: "cursorHidden",
|
|
396
|
-
"protected": true,
|
|
397
|
-
type: "boolean",
|
|
398
|
-
children: _alloy_js_core.code`false; `
|
|
399
|
-
}),
|
|
400
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
401
|
-
_alloy_js_core.code`constructor(protected config: PromptConfig<TValue>) {
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`@alloy-js/core/jsx-runtime`),n=require(`@alloy-js/core`),r=require(`@alloy-js/typescript`),i=require(`@powerlines/deepkit/vendor/type`),a=require(`@powerlines/plugin-alloy/core/components/spacing`),o=require(`@powerlines/plugin-alloy/typescript/components/builtin-file`),s=require(`@powerlines/plugin-alloy/typescript/components/class-declaration`),c=require(`@powerlines/plugin-alloy/typescript/components/interface-declaration`),l=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),u=require(`@powerlines/plugin-alloy/typescript/components/type-declaration`),d=require(`@shell-shock/plugin-theme/contexts/theme`),f=require(`defu`);f=e.__toESM(f);function p(){let e=(0,d.useTheme)();return[(0,t.createComponent)(u.TypeDeclaration,{export:!0,name:`PromptParser`,typeParameters:[{name:`TValue`,default:`string`}],doc:`A type for a custom prompt input parser, which can be used to create custom input styles for prompts. The function should return the parsed value for the given input string.`,children:n.code`(this: Prompt<TValue>, input: string) => TValue; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(u.TypeDeclaration,{export:!0,name:`PromptFormatter`,typeParameters:[{name:`TValue`,default:`string`}],doc:`A type for a custom prompt input formatter, which can be used to create custom display styles for prompts. The function should return the formatted string to display for the given input value.`,children:n.code`(this: Prompt<TValue>, input: TValue) => string; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(r.FunctionDeclaration,{export:!0,name:`noMask`,doc:`A built-in prompt mask function that just returns the input as is, making it invisible`,parameters:[{name:`input`,type:`string`}],returnType:`string`,children:n.code`return input; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(r.FunctionDeclaration,{export:!0,name:`invisibleMask`,doc:`A built-in prompt mask function that makes input invisible`,parameters:[{name:`input`,type:`string`}],returnType:`string`,children:n.code`return " ".repeat(input.length); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceDeclaration,{export:!0,name:`PromptState`,doc:`The current state of a prompt`,typeParameters:[{name:`TValue`,default:`string`}],get children(){return[(0,t.createComponent)(c.InterfaceMember,{name:`value`,type:`TValue`,doc:`The current value of the prompt`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`isError`,type:`boolean`,doc:`Indicates whether the prompt is in an error state`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`errorMessage`,optional:!0,type:`string`,doc:`If the prompt is in an error state, this will contain the error message to display`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`isSubmitted`,type:`boolean`,doc:`Indicates whether the prompt is submitted`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`isCancelled`,type:`boolean`,doc:`Indicates whether the prompt is cancelled`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`isCompleted`,type:`boolean`,doc:`Indicates whether the prompt is completed, which can be used to indicate that the prompt interaction is finished regardless of whether it was submitted or cancelled`}),(0,t.createComponent)(a.Spacing,{})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceDeclaration,{name:`PromptConfig`,doc:`Configuration options for creating a prompt`,typeParameters:[{name:`TValue`,default:`string`}],get children(){return[(0,t.createComponent)(c.InterfaceMember,{name:`input`,optional:!0,type:`NodeJS.ReadStream`,doc:`The readable stream to use for prompt input, defaults to process.stdin`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`output`,optional:!0,type:`NodeJS.WriteStream`,doc:`The writable stream to use for prompt output, defaults to process.stdout`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`message`,type:`string`,doc:`The prompt message to display`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`description`,optional:!0,type:`string`,doc:`The prompt description message to display`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`initialValue`,optional:!0,type:`TValue`,doc:`The initial value of the prompt`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`validate`,optional:!0,type:`(value: TValue) => boolean | string | null | undefined | Promise<boolean | string | null | undefined>`,doc:`A validation function that returns true if the input is valid, false or a string error message if the input is invalid`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`parse`,optional:!0,type:`PromptParser<TValue>`,doc:`A function that parses the input value and returns the parsed result or throws an error if the input is invalid`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`format`,optional:!0,type:`PromptFormatter<TValue>`,doc:`A function that formats the input value and returns the formatted result or throws an error if the input is invalid`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`mask`,optional:!0,type:`(input: string) => string`,doc:`A function that masks the input value and returns the masked result. This can be used to create password inputs or other sensitive input types where the actual input value should not be displayed. If not provided, the prompt will display the input as is without masking.`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`maskCompleted`,optional:!0,type:`(input: string) => string`,doc:`A function that masks the value submitted by the user so that it can then be used in the console output or elsewhere without exposing sensitive information. If not provided, the prompt will use the same mask function for both input and submitted value masking.`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`defaultErrorMessage`,optional:!0,type:`string`,doc:`The default error message to display when validation fails`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`timeout`,optional:!0,type:`number`,doc:`The timeout duration in milliseconds for the prompt. If none is provided, the prompt will not time out.`})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassDeclaration,{abstract:!0,name:`Prompt`,doc:`Base prompt class that other prompt types can extend from`,extends:`EventEmitter`,typeParameters:[{name:`TValue`,default:`string`}],get children(){return[(0,t.createComponent)(s.ClassField,{name:`readline`,isPrivateMember:!0,type:`Interface`}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`value`,isPrivateMember:!0,optional:!0,type:`TValue`}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`isKeyPressed`,isPrivateMember:!0,type:`boolean`,children:n.code`false; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`isDirty`,isPrivateMember:!0,type:`boolean`,children:n.code`false; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`isClosed`,isPrivateMember:!0,type:`boolean`,children:n.code`false; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassField,{name:`initialValue`,abstract:!0,protected:!0,type:`TValue`}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`input`,protected:!0,type:`NodeJS.ReadStream`,children:n.code`process.stdin; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`output`,protected:!0,type:`NodeJS.WriteStream`,children:n.code`process.stdout; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`message`,protected:!0,type:`string`,children:n.code`""; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`description`,protected:!0,type:`string`,children:n.code`""; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`errorMessage`,protected:!0,type:`string | null`,children:n.code`null; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`defaultErrorMessage`,protected:!0,type:`string`,children:n.code`"An invalid value was provided"; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`isSubmitted`,protected:!0,type:`boolean`,children:n.code`false; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`isCancelled`,protected:!0,type:`boolean`,children:n.code`false; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`isInitial`,protected:!0,type:`boolean`,children:n.code`true; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`consoleOutput`,protected:!0,type:`string`,children:n.code`""; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`consoleStatus`,protected:!0,type:`string`,children:n.code`""; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`displayValue`,protected:!0,type:`string`,children:n.code`""; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`validate`,protected:!0,type:`(value: TValue) => boolean | string | null | undefined | Promise<boolean | string | null | undefined>`,children:n.code`() => true; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`parse`,protected:!0,type:`PromptParser<TValue>`,children:n.code`(value: string) => value as TValue; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`format`,protected:!0,type:`PromptFormatter<TValue>`,children:n.code`(value: TValue) => String(value); `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`mask`,protected:!0,type:`(input: string) => string`,children:n.code`noMask; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`maskCompleted`,protected:!0,type:`(input: string) => string`,children:n.code`this.mask; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`cursor`,protected:!0,type:`number`,children:n.code`0; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`cursorHidden`,protected:!0,type:`boolean`,children:n.code`false; `}),(0,t.createComponent)(a.Spacing,{}),n.code`constructor(protected config: PromptConfig<TValue>) {
|
|
402
2
|
super();
|
|
403
3
|
|
|
404
4
|
if (config.input) {
|
|
@@ -455,49 +55,7 @@ function BasePromptDeclarations() {
|
|
|
455
55
|
|
|
456
56
|
[Symbol.dispose]() {
|
|
457
57
|
this.close();
|
|
458
|
-
} `,
|
|
459
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
460
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
461
|
-
"public": true,
|
|
462
|
-
name: "value",
|
|
463
|
-
type: "TValue",
|
|
464
|
-
doc: "A getter for the prompt value that returns the current value or the initial value if the current value is not set",
|
|
465
|
-
children: _alloy_js_core.code`return this.#value || this.initialValue; `
|
|
466
|
-
}),
|
|
467
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
468
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
469
|
-
"public": true,
|
|
470
|
-
name: "isError",
|
|
471
|
-
type: "boolean",
|
|
472
|
-
children: _alloy_js_core.code`return !!this.errorMessage; `
|
|
473
|
-
}),
|
|
474
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
475
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
476
|
-
"protected": true,
|
|
477
|
-
name: "isSelect",
|
|
478
|
-
type: "boolean",
|
|
479
|
-
children: _alloy_js_core.code`return false; `
|
|
480
|
-
}),
|
|
481
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
482
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
483
|
-
"protected": true,
|
|
484
|
-
name: "isCompleted",
|
|
485
|
-
type: "boolean",
|
|
486
|
-
children: _alloy_js_core.code`return this.isCancelled || this.isSubmitted; `
|
|
487
|
-
}),
|
|
488
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
489
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
490
|
-
"protected": true,
|
|
491
|
-
name: "isPlaceholder",
|
|
492
|
-
type: "boolean",
|
|
493
|
-
children: _alloy_js_core.code`return (this.displayValue === this.format(this.initialValue) && !this.#isDirty) || !this.#isKeyPressed; `
|
|
494
|
-
}),
|
|
495
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
496
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
497
|
-
"protected": true,
|
|
498
|
-
name: "status",
|
|
499
|
-
type: "string",
|
|
500
|
-
children: _alloy_js_core.code`return this.isSubmitted ? "" : \` \\n \${
|
|
58
|
+
} `,(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassPropertyGet,{public:!0,name:`value`,type:`TValue`,doc:`A getter for the prompt value that returns the current value or the initial value if the current value is not set`,children:n.code`return this.#value || this.initialValue; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassPropertyGet,{public:!0,name:`isError`,type:`boolean`,children:n.code`return !!this.errorMessage; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassPropertyGet,{protected:!0,name:`isSelect`,type:`boolean`,children:n.code`return false; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassPropertyGet,{protected:!0,name:`isCompleted`,type:`boolean`,children:n.code`return this.isCancelled || this.isSubmitted; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassPropertyGet,{protected:!0,name:`isPlaceholder`,type:`boolean`,children:n.code`return (this.displayValue === this.format(this.initialValue) && !this.#isDirty) || !this.#isKeyPressed; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassPropertyGet,{protected:!0,name:`status`,type:`string`,children:n.code`return this.isSubmitted ? "" : \` \\n \${
|
|
501
59
|
italic(
|
|
502
60
|
this.isError
|
|
503
61
|
? textColors.prompt.description.error(splitText(this.errorMessage, "3/4").join("\\n"))
|
|
@@ -507,34 +65,7 @@ function BasePromptDeclarations() {
|
|
|
507
65
|
? textColors.prompt.description.active(splitText(this.description, "3/4").join("\\n"))
|
|
508
66
|
: ""
|
|
509
67
|
)
|
|
510
|
-
}\`; `
|
|
511
|
-
}),
|
|
512
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
513
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
514
|
-
doc: "A property to check if the cursor is at the start",
|
|
515
|
-
name: "isCursorAtStart",
|
|
516
|
-
"protected": true,
|
|
517
|
-
type: "boolean",
|
|
518
|
-
children: _alloy_js_core.code`return this.cursor <= 0 || (this.isPlaceholder && this.cursor <= 1); `
|
|
519
|
-
}),
|
|
520
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
521
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
522
|
-
doc: "A property to check if the cursor is at the end",
|
|
523
|
-
name: "isCursorAtEnd",
|
|
524
|
-
"protected": true,
|
|
525
|
-
type: "boolean",
|
|
526
|
-
children: _alloy_js_core.code`return this.cursor >= this.displayValue.length || (this.isPlaceholder && this.cursor >= this.displayValue.length - 1); `
|
|
527
|
-
}),
|
|
528
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
529
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
530
|
-
doc: "A method to change the prompt value, which also updates the display value and fires a state update event. This method can be called by subclasses whenever the prompt value needs to be updated based on user input or other interactions.",
|
|
531
|
-
name: "changeValue",
|
|
532
|
-
"protected": true,
|
|
533
|
-
parameters: [{
|
|
534
|
-
name: "value",
|
|
535
|
-
type: "TValue"
|
|
536
|
-
}],
|
|
537
|
-
children: _alloy_js_core.code`const previousValue = this.value;
|
|
68
|
+
}\`; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassPropertyGet,{doc:`A property to check if the cursor is at the start`,name:`isCursorAtStart`,protected:!0,type:`boolean`,children:n.code`return this.cursor <= 0 || (this.isPlaceholder && this.cursor <= 1); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassPropertyGet,{doc:`A property to check if the cursor is at the end`,name:`isCursorAtEnd`,protected:!0,type:`boolean`,children:n.code`return this.cursor >= this.displayValue.length || (this.isPlaceholder && this.cursor >= this.displayValue.length - 1); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to change the prompt value, which also updates the display value and fires a state update event. This method can be called by subclasses whenever the prompt value needs to be updated based on user input or other interactions.`,name:`changeValue`,protected:!0,parameters:[{name:`value`,type:`TValue`}],children:n.code`const previousValue = this.value;
|
|
538
69
|
|
|
539
70
|
let updatedValue = value;
|
|
540
71
|
if (value === undefined || value === "") {
|
|
@@ -555,14 +86,7 @@ function BasePromptDeclarations() {
|
|
|
555
86
|
Promise.resolve(this.checkValidations(updatedValue)).then(() => this.sync());
|
|
556
87
|
}, 0);
|
|
557
88
|
|
|
558
|
-
this.sync(); `
|
|
559
|
-
}),
|
|
560
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
561
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
562
|
-
doc: "A method to emit the current state",
|
|
563
|
-
name: "sync",
|
|
564
|
-
"protected": true,
|
|
565
|
-
children: _alloy_js_core.code`this.emit("state", {
|
|
89
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to emit the current state`,name:`sync`,protected:!0,children:n.code`this.emit("state", {
|
|
566
90
|
value: this.value,
|
|
567
91
|
errorMessage: this.errorMessage,
|
|
568
92
|
isError: this.isError,
|
|
@@ -570,22 +94,7 @@ function BasePromptDeclarations() {
|
|
|
570
94
|
isCancelled: this.isCancelled,
|
|
571
95
|
isCompleted: this.isCompleted
|
|
572
96
|
});
|
|
573
|
-
this.render(); `
|
|
574
|
-
}),
|
|
575
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
576
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
577
|
-
doc: "A method to ring the bell",
|
|
578
|
-
name: "bell",
|
|
579
|
-
"protected": true,
|
|
580
|
-
children: _alloy_js_core.code`this.output.write(beep); `
|
|
581
|
-
}),
|
|
582
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
583
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
584
|
-
doc: "A method to render the prompt",
|
|
585
|
-
name: "onRender",
|
|
586
|
-
"protected": true,
|
|
587
|
-
returnType: "string",
|
|
588
|
-
children: _alloy_js_core.code`return this.isPlaceholder
|
|
97
|
+
this.render(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to ring the bell`,name:`bell`,protected:!0,children:n.code`this.output.write(beep); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to render the prompt`,name:`onRender`,protected:!0,returnType:`string`,children:n.code`return this.isPlaceholder
|
|
589
98
|
? textColors.prompt.input.disabled(this.displayValue)
|
|
590
99
|
: this.isError
|
|
591
100
|
? textColors.prompt.input.error(this.displayValue)
|
|
@@ -593,45 +102,12 @@ function BasePromptDeclarations() {
|
|
|
593
102
|
? textColors.prompt.input.submitted(this.maskCompleted(this.displayValue))
|
|
594
103
|
: this.isCancelled
|
|
595
104
|
? textColors.prompt.input.cancelled(this.maskCompleted(this.displayValue))
|
|
596
|
-
: bold(textColors.prompt.input.active(this.displayValue)); `
|
|
597
|
-
}),
|
|
598
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
599
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
600
|
-
doc: "A method to handle changes in the prompt value",
|
|
601
|
-
name: "onChange",
|
|
602
|
-
"protected": true,
|
|
603
|
-
parameters: [{
|
|
604
|
-
name: "previousValue",
|
|
605
|
-
type: "TValue"
|
|
606
|
-
}],
|
|
607
|
-
children: _alloy_js_core.code` // can be implemented by subclasses to handle value changes if needed, this method is called whenever the prompt value changes and receives the previous value as an argument for reference`
|
|
608
|
-
}),
|
|
609
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
610
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
611
|
-
doc: "A method to handle key press events and determine the corresponding action",
|
|
612
|
-
name: "onKeyPress",
|
|
613
|
-
"protected": true,
|
|
614
|
-
parameters: [{
|
|
615
|
-
name: "char",
|
|
616
|
-
type: "string"
|
|
617
|
-
}, {
|
|
618
|
-
name: "key",
|
|
619
|
-
type: "Key"
|
|
620
|
-
}],
|
|
621
|
-
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
105
|
+
: bold(textColors.prompt.input.active(this.displayValue)); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to handle changes in the prompt value`,name:`onChange`,protected:!0,parameters:[{name:`previousValue`,type:`TValue`}],children:n.code` // can be implemented by subclasses to handle value changes if needed, this method is called whenever the prompt value changes and receives the previous value as an argument for reference`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to handle key press events and determine the corresponding action`,name:`onKeyPress`,protected:!0,parameters:[{name:`char`,type:`string`},{name:`key`,type:`Key`}],children:n.code`const action = this.getAction(key);
|
|
622
106
|
if (!action) {
|
|
623
107
|
this.bell();
|
|
624
108
|
} else if (typeof (this as any)[action] === "function") {
|
|
625
109
|
(this as any)[action](key);
|
|
626
|
-
} `
|
|
627
|
-
}),
|
|
628
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
629
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
630
|
-
doc: "A method to close the prompt and clean up resources, which also emits a submit or cancel event based on the prompt state. This method should be called when the prompt interaction is finished and the prompt needs to be closed.",
|
|
631
|
-
name: "close",
|
|
632
|
-
async: true,
|
|
633
|
-
"protected": true,
|
|
634
|
-
children: _alloy_js_core.code`if (this.#isClosed) {
|
|
110
|
+
} `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to close the prompt and clean up resources, which also emits a submit or cancel event based on the prompt state. This method should be called when the prompt interaction is finished and the prompt needs to be closed.`,name:`close`,async:!0,protected:!0,children:n.code`if (this.#isClosed) {
|
|
635
111
|
return;
|
|
636
112
|
}
|
|
637
113
|
|
|
@@ -644,38 +120,14 @@ function BasePromptDeclarations() {
|
|
|
644
120
|
|
|
645
121
|
this.#readline.close();
|
|
646
122
|
this.emit(this.isSubmitted ? "submit" : "cancel", this.value);
|
|
647
|
-
this.#isClosed = true; `
|
|
648
|
-
}),
|
|
649
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
650
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
651
|
-
doc: "A method to validate the prompt input using the provided validator function, which updates the error message and error state based on the validation result. This method is called whenever the prompt value changes and needs to be validated.",
|
|
652
|
-
name: "checkValidations",
|
|
653
|
-
async: true,
|
|
654
|
-
"protected": true,
|
|
655
|
-
parameters: [{
|
|
656
|
-
name: "value",
|
|
657
|
-
type: "TValue"
|
|
658
|
-
}],
|
|
659
|
-
children: _alloy_js_core.code`let result = await this.validate(value);
|
|
123
|
+
this.#isClosed = true; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to validate the prompt input using the provided validator function, which updates the error message and error state based on the validation result. This method is called whenever the prompt value changes and needs to be validated.`,name:`checkValidations`,async:!0,protected:!0,parameters:[{name:`value`,type:`TValue`}],children:n.code`let result = await this.validate(value);
|
|
660
124
|
if (typeof result === "string") {
|
|
661
125
|
this.errorMessage = result;
|
|
662
126
|
} else if (typeof result === "boolean") {
|
|
663
127
|
this.errorMessage = result ? null : this.defaultErrorMessage;
|
|
664
128
|
} else {
|
|
665
129
|
this.errorMessage = null;
|
|
666
|
-
} `
|
|
667
|
-
}),
|
|
668
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
669
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
670
|
-
doc: "A method to route key press events to specific prompt actions based on the key pressed. This method maps various key combinations and keys to corresponding actions that can be handled by the prompt, such as submitting, cancelling, navigating, etc.",
|
|
671
|
-
name: "getAction",
|
|
672
|
-
"protected": true,
|
|
673
|
-
parameters: [{
|
|
674
|
-
name: "key",
|
|
675
|
-
type: "Key"
|
|
676
|
-
}],
|
|
677
|
-
returnType: "string | false",
|
|
678
|
-
children: _alloy_js_core.code`if (key.meta && key.name !== "escape") {
|
|
130
|
+
} `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to route key press events to specific prompt actions based on the key pressed. This method maps various key combinations and keys to corresponding actions that can be handled by the prompt, such as submitting, cancelling, navigating, etc.`,name:`getAction`,protected:!0,parameters:[{name:`key`,type:`Key`}],returnType:`string | false`,children:n.code`if (key.meta && key.name !== "escape") {
|
|
679
131
|
return false;
|
|
680
132
|
}
|
|
681
133
|
|
|
@@ -705,18 +157,7 @@ function BasePromptDeclarations() {
|
|
|
705
157
|
if (key.name === "right") action = "right";
|
|
706
158
|
if (key.name === "left") action = "left";
|
|
707
159
|
|
|
708
|
-
return action || false; `
|
|
709
|
-
}),
|
|
710
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
711
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
712
|
-
doc: "A method to move the cursor to the left or right by a \\`count\\` of positions",
|
|
713
|
-
name: "moveCursor",
|
|
714
|
-
parameters: [{
|
|
715
|
-
name: "count",
|
|
716
|
-
type: "number"
|
|
717
|
-
}],
|
|
718
|
-
"protected": true,
|
|
719
|
-
children: _alloy_js_core.code`if (this.cursor + count < 0) {
|
|
160
|
+
return action || false; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:"A method to move the cursor to the left or right by a \\`count\\` of positions",name:`moveCursor`,parameters:[{name:`count`,type:`number`}],protected:!0,children:n.code`if (this.cursor + count < 0) {
|
|
720
161
|
this.cursor = 0;
|
|
721
162
|
} else if (this.cursor + count > this.displayValue.length) {
|
|
722
163
|
this.cursor = this.displayValue.length;
|
|
@@ -724,14 +165,7 @@ function BasePromptDeclarations() {
|
|
|
724
165
|
this.cursor += count;
|
|
725
166
|
}
|
|
726
167
|
|
|
727
|
-
`
|
|
728
|
-
}),
|
|
729
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
730
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
731
|
-
doc: "A method to remove the character backward of the cursor",
|
|
732
|
-
name: "backspace",
|
|
733
|
-
"protected": true,
|
|
734
|
-
children: _alloy_js_core.code`if (this.isCursorAtStart) {
|
|
168
|
+
`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to remove the character backward of the cursor`,name:`backspace`,protected:!0,children:n.code`if (this.isCursorAtStart) {
|
|
735
169
|
return this.bell();
|
|
736
170
|
}
|
|
737
171
|
|
|
@@ -749,14 +183,7 @@ function BasePromptDeclarations() {
|
|
|
749
183
|
|
|
750
184
|
this.moveCursor(isCursorAtEnd ? -1 : -2);
|
|
751
185
|
|
|
752
|
-
this.sync(); `
|
|
753
|
-
}),
|
|
754
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
755
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
756
|
-
doc: "A method to remove the character forward of the cursor",
|
|
757
|
-
name: "delete",
|
|
758
|
-
"protected": true,
|
|
759
|
-
children: _alloy_js_core.code`if (this.isCursorAtEnd) {
|
|
186
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to remove the character forward of the cursor`,name:`delete`,protected:!0,children:n.code`if (this.isCursorAtEnd) {
|
|
760
187
|
return this.bell();
|
|
761
188
|
}
|
|
762
189
|
|
|
@@ -770,42 +197,20 @@ function BasePromptDeclarations() {
|
|
|
770
197
|
this.moveCursor(-1);
|
|
771
198
|
}
|
|
772
199
|
|
|
773
|
-
this.sync(); `
|
|
774
|
-
}),
|
|
775
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
776
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
777
|
-
doc: "A method to reset the prompt input",
|
|
778
|
-
name: "reset",
|
|
779
|
-
"protected": true,
|
|
780
|
-
children: _alloy_js_core.code`this.changeValue(this.initialValue);
|
|
200
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to reset the prompt input`,name:`reset`,protected:!0,children:n.code`this.changeValue(this.initialValue);
|
|
781
201
|
this.cursor = 0;
|
|
782
202
|
|
|
783
203
|
this.errorMessage = null;
|
|
784
204
|
this.isCancelled = false;
|
|
785
205
|
this.isSubmitted = false;
|
|
786
206
|
|
|
787
|
-
this.sync(); `
|
|
788
|
-
}),
|
|
789
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
790
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
791
|
-
doc: "A method to cancel the prompt input",
|
|
792
|
-
name: "cancel",
|
|
793
|
-
"protected": true,
|
|
794
|
-
children: _alloy_js_core.code`this.errorMessage = null;
|
|
207
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to cancel the prompt input`,name:`cancel`,protected:!0,children:n.code`this.errorMessage = null;
|
|
795
208
|
this.isCancelled = true;
|
|
796
209
|
this.isSubmitted = false;
|
|
797
210
|
|
|
798
211
|
this.sync();
|
|
799
212
|
this.output.write("\\n");
|
|
800
|
-
this.close(); `
|
|
801
|
-
}),
|
|
802
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
803
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
804
|
-
doc: "A method to submit the prompt input",
|
|
805
|
-
name: "submit",
|
|
806
|
-
async: true,
|
|
807
|
-
"protected": true,
|
|
808
|
-
children: _alloy_js_core.code`this.cursor = this.displayValue.length;
|
|
213
|
+
this.close(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to submit the prompt input`,name:`submit`,async:!0,protected:!0,children:n.code`this.cursor = this.displayValue.length;
|
|
809
214
|
|
|
810
215
|
await this.checkValidations(this.value);
|
|
811
216
|
if (this.isError) {
|
|
@@ -818,15 +223,7 @@ function BasePromptDeclarations() {
|
|
|
818
223
|
this.sync();
|
|
819
224
|
this.output.write("\\n");
|
|
820
225
|
this.close();
|
|
821
|
-
} `
|
|
822
|
-
}),
|
|
823
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
824
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
825
|
-
doc: "A method to render the prompt",
|
|
826
|
-
name: "render",
|
|
827
|
-
"private": true,
|
|
828
|
-
get children() {
|
|
829
|
-
return _alloy_js_core.code`if (this.#isClosed) {
|
|
226
|
+
} `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to render the prompt`,name:`render`,private:!0,get children(){return n.code`if (this.#isClosed) {
|
|
830
227
|
return;
|
|
831
228
|
}
|
|
832
229
|
|
|
@@ -847,12 +244,12 @@ function BasePromptDeclarations() {
|
|
|
847
244
|
|
|
848
245
|
this.consoleOutput = \` \${
|
|
849
246
|
this.isSubmitted
|
|
850
|
-
? textColors.prompt.icon.submitted("${
|
|
247
|
+
? textColors.prompt.icon.submitted("${e.icons.prompt.submitted}")
|
|
851
248
|
: this.isCancelled
|
|
852
|
-
? textColors.prompt.icon.cancelled("${
|
|
249
|
+
? textColors.prompt.icon.cancelled("${e.icons.prompt.cancelled}")
|
|
853
250
|
: this.isError
|
|
854
|
-
? textColors.prompt.icon.error("${
|
|
855
|
-
: textColors.prompt.icon.active("${
|
|
251
|
+
? textColors.prompt.icon.error("${e.icons.prompt.error}")
|
|
252
|
+
: textColors.prompt.icon.active("${e.icons.prompt.active}")
|
|
856
253
|
} \${
|
|
857
254
|
this.isCompleted
|
|
858
255
|
? textColors.prompt.message.submitted(this.message)
|
|
@@ -875,22 +272,7 @@ function BasePromptDeclarations() {
|
|
|
875
272
|
this.consoleStatus = this.status;
|
|
876
273
|
} finally {
|
|
877
274
|
clearTimeout(timeout);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
}),
|
|
881
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
882
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
883
|
-
doc: "A method to handle key press events and determine the corresponding action",
|
|
884
|
-
name: "keypress",
|
|
885
|
-
"private": true,
|
|
886
|
-
parameters: [{
|
|
887
|
-
name: "char",
|
|
888
|
-
type: "string"
|
|
889
|
-
}, {
|
|
890
|
-
name: "key",
|
|
891
|
-
type: "Key"
|
|
892
|
-
}],
|
|
893
|
-
children: _alloy_js_core.code`if (this.#isClosed) {
|
|
275
|
+
} `}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to handle key press events and determine the corresponding action`,name:`keypress`,private:!0,parameters:[{name:`char`,type:`string`},{name:`key`,type:`Key`}],children:n.code`if (this.#isClosed) {
|
|
894
276
|
return;
|
|
895
277
|
}
|
|
896
278
|
|
|
@@ -898,124 +280,7 @@ function BasePromptDeclarations() {
|
|
|
898
280
|
this.#isKeyPressed = true;
|
|
899
281
|
}
|
|
900
282
|
|
|
901
|
-
return this.onKeyPress(char, key); `
|
|
902
|
-
})
|
|
903
|
-
];
|
|
904
|
-
}
|
|
905
|
-
}),
|
|
906
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
907
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
908
|
-
name: "PromptFactoryConfig",
|
|
909
|
-
"extends": "PromptConfig<TValue>",
|
|
910
|
-
doc: "Configuration options for creating a prompt with a prompt factory function",
|
|
911
|
-
typeParameters: [{
|
|
912
|
-
name: "TValue",
|
|
913
|
-
default: "string"
|
|
914
|
-
}],
|
|
915
|
-
get children() {
|
|
916
|
-
return [
|
|
917
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
918
|
-
name: "onState",
|
|
919
|
-
optional: true,
|
|
920
|
-
type: "(state: PromptState<TValue>) => any",
|
|
921
|
-
doc: "A function that is called when the prompt state changes, useful for updating the prompt message or other properties dynamically"
|
|
922
|
-
}),
|
|
923
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
924
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
925
|
-
name: "onSubmit",
|
|
926
|
-
optional: true,
|
|
927
|
-
type: "(value: TValue) => any",
|
|
928
|
-
doc: "A function that is called when the prompt is submitted, useful for handling the submitted value or performing actions based on the prompt state"
|
|
929
|
-
}),
|
|
930
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
931
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
932
|
-
name: "onCancel",
|
|
933
|
-
optional: true,
|
|
934
|
-
type: "(event: any) => any",
|
|
935
|
-
doc: "A function that is called when the prompt is canceled, useful for handling the canceled value or performing actions based on the prompt state"
|
|
936
|
-
})
|
|
937
|
-
];
|
|
938
|
-
}
|
|
939
|
-
}),
|
|
940
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
941
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "A unique symbol used to indicate that a prompt was cancelled, which can be returned from a prompt function to signal that the prompt interaction should be cancelled and any pending promises should be rejected with this symbol. This allows for a consistent way to handle prompt cancellations across different prompt types and interactions." }),
|
|
942
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
943
|
-
"export": true,
|
|
944
|
-
name: "CANCEL_SYMBOL",
|
|
945
|
-
children: _alloy_js_core.code`Symbol("shell-shock:prompts:cancel"); `
|
|
946
|
-
}),
|
|
947
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
948
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
949
|
-
heading: "A utility function to check if a given value is the {@link CANCEL_SYMBOL | cancel symbol}, which can be used to determine if a prompt interaction was cancelled based on the value returned from a prompt factory function. This function checks if the provided value is strictly equal to the {@link CANCEL_SYMBOL | CANCEL_SYMBOL}, allowing for a consistent way to handle prompt cancellations across different prompt types and interactions.",
|
|
950
|
-
get children() {
|
|
951
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
952
|
-
name: "value",
|
|
953
|
-
children: `The value to check.`
|
|
954
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A boolean indicating whether the provided value is the {@link CANCEL_SYMBOL | cancel symbol}, which can be used to determine if a prompt interaction was cancelled.` })];
|
|
955
|
-
}
|
|
956
|
-
}),
|
|
957
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
958
|
-
name: "isCancel",
|
|
959
|
-
"export": true,
|
|
960
|
-
parameters: [{
|
|
961
|
-
name: "value",
|
|
962
|
-
type: "any"
|
|
963
|
-
}],
|
|
964
|
-
returnType: "value is typeof CANCEL_SYMBOL",
|
|
965
|
-
children: _alloy_js_core.code`return value === CANCEL_SYMBOL; `
|
|
966
|
-
})
|
|
967
|
-
];
|
|
968
|
-
}
|
|
969
|
-
/**
|
|
970
|
-
* Declarations for a text-based prompt that allows users to input and edit text, with support for cursor movement, deletion, and custom masking. This prompt type can be used for various text input scenarios, such as entering a username, password, or any other string input. The TextPrompt class extends the base Prompt class and implements specific logic for handling text input and editing interactions.
|
|
971
|
-
*/
|
|
972
|
-
function TextPromptDeclarations() {
|
|
973
|
-
return [
|
|
974
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
975
|
-
name: "StringPromptConfig",
|
|
976
|
-
"extends": "PromptConfig<string>",
|
|
977
|
-
doc: "Configuration options for creating a text-based prompt",
|
|
978
|
-
get children() {
|
|
979
|
-
return [
|
|
980
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
981
|
-
name: "initialValue",
|
|
982
|
-
optional: true,
|
|
983
|
-
type: "string",
|
|
984
|
-
doc: "The initial value of the prompt"
|
|
985
|
-
}),
|
|
986
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
987
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
988
|
-
name: "mask",
|
|
989
|
-
optional: true,
|
|
990
|
-
type: "(input: string) => string",
|
|
991
|
-
doc: "A function that masks the input value and returns the masked result"
|
|
992
|
-
})
|
|
993
|
-
];
|
|
994
|
-
}
|
|
995
|
-
}),
|
|
996
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
997
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
998
|
-
name: "StringPrompt",
|
|
999
|
-
doc: "A prompt for text input",
|
|
1000
|
-
"extends": "Prompt<string>",
|
|
1001
|
-
get children() {
|
|
1002
|
-
return [
|
|
1003
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1004
|
-
name: "isInvalid",
|
|
1005
|
-
isPrivateMember: true,
|
|
1006
|
-
type: "boolean",
|
|
1007
|
-
children: _alloy_js_core.code`false; `
|
|
1008
|
-
}),
|
|
1009
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1010
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1011
|
-
name: "initialValue",
|
|
1012
|
-
"protected": true,
|
|
1013
|
-
override: true,
|
|
1014
|
-
type: "string",
|
|
1015
|
-
children: _alloy_js_core.code`""; `
|
|
1016
|
-
}),
|
|
1017
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1018
|
-
_alloy_js_core.code`constructor(config: StringPromptConfig) {
|
|
283
|
+
return this.onKeyPress(char, key); `})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceDeclaration,{name:`PromptFactoryConfig`,extends:`PromptConfig<TValue>`,doc:`Configuration options for creating a prompt with a prompt factory function`,typeParameters:[{name:`TValue`,default:`string`}],get children(){return[(0,t.createComponent)(c.InterfaceMember,{name:`onState`,optional:!0,type:`(state: PromptState<TValue>) => any`,doc:`A function that is called when the prompt state changes, useful for updating the prompt message or other properties dynamically`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`onSubmit`,optional:!0,type:`(value: TValue) => any`,doc:`A function that is called when the prompt is submitted, useful for handling the submitted value or performing actions based on the prompt state`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`onCancel`,optional:!0,type:`(event: any) => any`,doc:`A function that is called when the prompt is canceled, useful for handling the canceled value or performing actions based on the prompt state`})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A unique symbol used to indicate that a prompt was cancelled, which can be returned from a prompt function to signal that the prompt interaction should be cancelled and any pending promises should be rejected with this symbol. This allows for a consistent way to handle prompt cancellations across different prompt types and interactions.`}),(0,t.createComponent)(r.VarDeclaration,{export:!0,name:`CANCEL_SYMBOL`,children:n.code`Symbol("shell-shock:prompts:cancel"); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A utility function to check if a given value is the {@link CANCEL_SYMBOL | cancel symbol}, which can be used to determine if a prompt interaction was cancelled based on the value returned from a prompt factory function. This function checks if the provided value is strictly equal to the {@link CANCEL_SYMBOL | CANCEL_SYMBOL}, allowing for a consistent way to handle prompt cancellations across different prompt types and interactions.`,get children(){return[(0,t.createComponent)(l.TSDocParam,{name:`value`,children:`The value to check.`}),(0,t.createComponent)(l.TSDocReturns,{children:`A boolean indicating whether the provided value is the {@link CANCEL_SYMBOL | cancel symbol}, which can be used to determine if a prompt interaction was cancelled.`})]}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`isCancel`,export:!0,parameters:[{name:`value`,type:`any`}],returnType:`value is typeof CANCEL_SYMBOL`,children:n.code`return value === CANCEL_SYMBOL; `})]}function m(){return[(0,t.createComponent)(c.InterfaceDeclaration,{name:`StringPromptConfig`,extends:`PromptConfig<string>`,doc:`Configuration options for creating a text-based prompt`,get children(){return[(0,t.createComponent)(c.InterfaceMember,{name:`initialValue`,optional:!0,type:`string`,doc:`The initial value of the prompt`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`mask`,optional:!0,type:`(input: string) => string`,doc:`A function that masks the input value and returns the masked result`})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassDeclaration,{name:`StringPrompt`,doc:`A prompt for text input`,extends:`Prompt<string>`,get children(){return[(0,t.createComponent)(s.ClassField,{name:`isInvalid`,isPrivateMember:!0,type:`boolean`,children:n.code`false; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`initialValue`,protected:!0,override:!0,type:`string`,children:n.code`""; `}),(0,t.createComponent)(a.Spacing,{}),n.code`constructor(config: StringPromptConfig) {
|
|
1019
284
|
super(config);
|
|
1020
285
|
|
|
1021
286
|
if (config.initialValue) {
|
|
@@ -1029,21 +294,7 @@ function TextPromptDeclarations() {
|
|
|
1029
294
|
this.cursor = 0;
|
|
1030
295
|
this.sync();
|
|
1031
296
|
this.last();
|
|
1032
|
-
} `,
|
|
1033
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1034
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1035
|
-
doc: "A method to handle onKeyPress events and determine the corresponding action",
|
|
1036
|
-
name: "onKeyPress",
|
|
1037
|
-
override: true,
|
|
1038
|
-
"protected": true,
|
|
1039
|
-
parameters: [{
|
|
1040
|
-
name: "char",
|
|
1041
|
-
type: "string"
|
|
1042
|
-
}, {
|
|
1043
|
-
name: "key",
|
|
1044
|
-
type: "Key"
|
|
1045
|
-
}],
|
|
1046
|
-
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
297
|
+
} `,(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to handle onKeyPress events and determine the corresponding action`,name:`onKeyPress`,override:!0,protected:!0,parameters:[{name:`char`,type:`string`},{name:`key`,type:`Key`}],children:n.code`const action = this.getAction(key);
|
|
1047
298
|
if (action && typeof (this as any)[action] === "function") {
|
|
1048
299
|
return (this as any)[action]();
|
|
1049
300
|
}
|
|
@@ -1057,97 +308,24 @@ function TextPromptDeclarations() {
|
|
|
1057
308
|
}\${char}\${
|
|
1058
309
|
this.displayValue.slice(this.cursor)
|
|
1059
310
|
}\`);
|
|
1060
|
-
this.sync(); `
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
doc: "A method to handle changes in the prompt value",
|
|
1065
|
-
name: "onChange",
|
|
1066
|
-
override: true,
|
|
1067
|
-
"protected": true,
|
|
1068
|
-
parameters: [{
|
|
1069
|
-
name: "previousValue",
|
|
1070
|
-
type: "string"
|
|
1071
|
-
}],
|
|
1072
|
-
children: _alloy_js_core.code`this.#isInvalid = false;
|
|
1073
|
-
this.cursor = this.displayValue.slice(0, this.cursor).length + 1; `
|
|
1074
|
-
}),
|
|
1075
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1076
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1077
|
-
doc: "A method to reset the prompt input",
|
|
1078
|
-
name: "reset",
|
|
1079
|
-
override: true,
|
|
1080
|
-
"protected": true,
|
|
1081
|
-
children: _alloy_js_core.code`this.cursor = Number(!!this.initialValue);
|
|
1082
|
-
super.reset(); `
|
|
1083
|
-
}),
|
|
1084
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1085
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1086
|
-
doc: "A method to validate the prompt input",
|
|
1087
|
-
name: "checkValidations",
|
|
1088
|
-
override: true,
|
|
1089
|
-
async: true,
|
|
1090
|
-
"protected": true,
|
|
1091
|
-
children: _alloy_js_core.code`await super.checkValidations(this.value);
|
|
1092
|
-
this.#isInvalid = this.isError; `
|
|
1093
|
-
}),
|
|
1094
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1095
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1096
|
-
doc: "A method to move the cursor to the end of the input",
|
|
1097
|
-
name: "next",
|
|
1098
|
-
"protected": true,
|
|
1099
|
-
children: _alloy_js_core.code`this.changeValue(this.initialValue);
|
|
311
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to handle changes in the prompt value`,name:`onChange`,override:!0,protected:!0,parameters:[{name:`previousValue`,type:`string`}],children:n.code`this.#isInvalid = false;
|
|
312
|
+
this.cursor = this.displayValue.slice(0, this.cursor).length + 1; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to reset the prompt input`,name:`reset`,override:!0,protected:!0,children:n.code`this.cursor = Number(!!this.initialValue);
|
|
313
|
+
super.reset(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to validate the prompt input`,name:`checkValidations`,override:!0,async:!0,protected:!0,children:n.code`await super.checkValidations(this.value);
|
|
314
|
+
this.#isInvalid = this.isError; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the end of the input`,name:`next`,protected:!0,children:n.code`this.changeValue(this.initialValue);
|
|
1100
315
|
this.cursor = this.displayValue.length;
|
|
1101
|
-
this.sync(); `
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1105
|
-
doc: "A method to move the cursor to the start",
|
|
1106
|
-
name: "first",
|
|
1107
|
-
"protected": true,
|
|
1108
|
-
children: _alloy_js_core.code`this.cursor = 0;
|
|
1109
|
-
this.sync(); `
|
|
1110
|
-
}),
|
|
1111
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1112
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1113
|
-
doc: "A method to move the cursor to the end",
|
|
1114
|
-
name: "last",
|
|
1115
|
-
"protected": true,
|
|
1116
|
-
children: _alloy_js_core.code`this.cursor = this.displayValue.length;
|
|
1117
|
-
this.sync(); `
|
|
1118
|
-
}),
|
|
1119
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1120
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1121
|
-
doc: "A method to move the cursor to the left",
|
|
1122
|
-
name: "left",
|
|
1123
|
-
"protected": true,
|
|
1124
|
-
children: _alloy_js_core.code`if (this.cursor <= 0) {
|
|
316
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the start`,name:`first`,protected:!0,children:n.code`this.cursor = 0;
|
|
317
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the end`,name:`last`,protected:!0,children:n.code`this.cursor = this.displayValue.length;
|
|
318
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the left`,name:`left`,protected:!0,children:n.code`if (this.cursor <= 0) {
|
|
1125
319
|
return this.bell();
|
|
1126
320
|
}
|
|
1127
321
|
|
|
1128
322
|
this.moveCursor(-1);
|
|
1129
|
-
this.sync(); `
|
|
1130
|
-
}),
|
|
1131
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1132
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1133
|
-
doc: "A method to move the cursor to the right",
|
|
1134
|
-
name: "right",
|
|
1135
|
-
"protected": true,
|
|
1136
|
-
children: _alloy_js_core.code`if (this.cursor >= this.displayValue.length) {
|
|
323
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the right`,name:`right`,protected:!0,children:n.code`if (this.cursor >= this.displayValue.length) {
|
|
1137
324
|
return this.bell();
|
|
1138
325
|
}
|
|
1139
326
|
|
|
1140
327
|
this.moveCursor(1);
|
|
1141
|
-
this.sync(); `
|
|
1142
|
-
}),
|
|
1143
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1144
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1145
|
-
doc: "A method to render the prompt",
|
|
1146
|
-
name: "onRender",
|
|
1147
|
-
override: true,
|
|
1148
|
-
"protected": true,
|
|
1149
|
-
returnType: "string",
|
|
1150
|
-
children: _alloy_js_core.code`return this.isPlaceholder
|
|
328
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to render the prompt`,name:`onRender`,override:!0,protected:!0,returnType:`string`,children:n.code`return this.isPlaceholder
|
|
1151
329
|
? textColors.prompt.input.disabled(this.displayValue)
|
|
1152
330
|
: this.#isInvalid
|
|
1153
331
|
? textColors.prompt.input.error(this.displayValue)
|
|
@@ -1155,25 +333,7 @@ function TextPromptDeclarations() {
|
|
|
1155
333
|
? textColors.prompt.input.submitted(this.displayValue)
|
|
1156
334
|
: this.isCancelled
|
|
1157
335
|
? textColors.prompt.input.cancelled(this.displayValue)
|
|
1158
|
-
: bold(textColors.prompt.input.active(this.displayValue)); `
|
|
1159
|
-
})
|
|
1160
|
-
];
|
|
1161
|
-
}
|
|
1162
|
-
}),
|
|
1163
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1164
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "A type definition for the configuration options to pass to the text prompt, which extends the base PromptConfig with additional options specific to text prompts. This type can be used when creating a text prompt using the {@link text | text prompt factory function} or when manually creating an instance of the TextPrompt class. The TextConfig type includes all the properties of the base PromptConfig, such as message, description, initialValue, validate, parse, format, mask, etc., as well as any additional properties that are specific to text prompts." }),
|
|
1165
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
1166
|
-
name: "TextConfig",
|
|
1167
|
-
"export": true,
|
|
1168
|
-
children: _alloy_js_core.code`PromptFactoryConfig<string> & StringPromptConfig; `
|
|
1169
|
-
}),
|
|
1170
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1171
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1172
|
-
heading: "A function to create and run a text prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.",
|
|
1173
|
-
get children() {
|
|
1174
|
-
return [
|
|
1175
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: _alloy_js_core.code`This function can be used to easily create and run a text prompt without needing to manually create an instance of the TextPrompt class and handle its events. The function accepts a configuration object that extends the base PromptFactoryConfig with additional options specific to text prompts, such as the initial value and mask function. The returned promise allows for easy handling of the prompt result using async/await syntax or traditional promise chaining.` }),
|
|
1176
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { text, isCancel } from "shell-shock:prompts";
|
|
336
|
+
: bold(textColors.prompt.input.active(this.displayValue)); `})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A type definition for the configuration options to pass to the text prompt, which extends the base PromptConfig with additional options specific to text prompts. This type can be used when creating a text prompt using the {@link text | text prompt factory function} or when manually creating an instance of the TextPrompt class. The TextConfig type includes all the properties of the base PromptConfig, such as message, description, initialValue, validate, parse, format, mask, etc., as well as any additional properties that are specific to text prompts.`}),(0,t.createComponent)(u.TypeDeclaration,{name:`TextConfig`,export:!0,children:n.code`PromptFactoryConfig<string> & StringPromptConfig; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A function to create and run a text prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.`,get children(){return[(0,t.createComponent)(l.TSDocRemarks,{children:n.code`This function can be used to easily create and run a text prompt without needing to manually create an instance of the TextPrompt class and handle its events. The function accepts a configuration object that extends the base PromptFactoryConfig with additional options specific to text prompts, such as the initial value and mask function. The returned promise allows for easy handling of the prompt result using async/await syntax or traditional promise chaining.`}),(0,t.createComponent)(l.TSDocExample,{children:`import { text, isCancel } from "shell-shock:prompts";
|
|
1177
337
|
|
|
1178
338
|
async function run() {
|
|
1179
339
|
const name = await text({
|
|
@@ -1189,202 +349,13 @@ async function run() {
|
|
|
1189
349
|
console.log("Hello, " + name + "!");
|
|
1190
350
|
}
|
|
1191
351
|
|
|
1192
|
-
run(); ` }),
|
|
1193
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1194
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1195
|
-
name: "config",
|
|
1196
|
-
children: `The configuration options to pass to the text prompt, which extends the base PromptConfig with additional options specific to text prompts`
|
|
1197
|
-
}),
|
|
1198
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled` })
|
|
1199
|
-
];
|
|
1200
|
-
}
|
|
1201
|
-
}),
|
|
1202
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1203
|
-
name: "text",
|
|
1204
|
-
"export": true,
|
|
1205
|
-
parameters: [{
|
|
1206
|
-
name: "config",
|
|
1207
|
-
type: "TextConfig"
|
|
1208
|
-
}],
|
|
1209
|
-
returnType: "Promise<string | symbol>",
|
|
1210
|
-
children: _alloy_js_core.code`return new Promise<string | symbol>((response, reject) => {
|
|
352
|
+
run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocParam,{name:`config`,children:`The configuration options to pass to the text prompt, which extends the base PromptConfig with additional options specific to text prompts`}),(0,t.createComponent)(l.TSDocReturns,{children:`A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled`})]}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`text`,export:!0,parameters:[{name:`config`,type:`TextConfig`}],returnType:`Promise<string | symbol>`,children:n.code`return new Promise<string | symbol>((response, reject) => {
|
|
1211
353
|
const prompt = new StringPrompt(config);
|
|
1212
354
|
|
|
1213
355
|
prompt.on("state", state => config.onState?.(state));
|
|
1214
356
|
prompt.on("submit", value => response(value));
|
|
1215
357
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
1216
|
-
});`
|
|
1217
|
-
})
|
|
1218
|
-
];
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* Declarations for a select prompt that allows users to choose from a list of options, with support for pagination, option descriptions, and disabled options. This prompt type can be used for scenarios where the user needs to select one option from a predefined list, such as choosing a color, selecting a file, or picking an item from a menu. The SelectPrompt class extends the base Prompt class and implements specific logic for handling option selection and navigation interactions.
|
|
1222
|
-
*/
|
|
1223
|
-
function SelectPromptDeclarations() {
|
|
1224
|
-
return [
|
|
1225
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
1226
|
-
name: "PromptOptionConfig",
|
|
1227
|
-
doc: "Configuration for an option the user can select from the select prompt",
|
|
1228
|
-
typeParameters: [{
|
|
1229
|
-
name: "TValue",
|
|
1230
|
-
default: "string"
|
|
1231
|
-
}],
|
|
1232
|
-
get children() {
|
|
1233
|
-
return [
|
|
1234
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1235
|
-
name: "label",
|
|
1236
|
-
optional: true,
|
|
1237
|
-
type: "string",
|
|
1238
|
-
doc: "The message label for the option"
|
|
1239
|
-
}),
|
|
1240
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1241
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1242
|
-
name: "icon",
|
|
1243
|
-
optional: true,
|
|
1244
|
-
type: "string",
|
|
1245
|
-
doc: "An icon for the option"
|
|
1246
|
-
}),
|
|
1247
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1248
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1249
|
-
name: "value",
|
|
1250
|
-
type: "TValue",
|
|
1251
|
-
doc: "The value of the option"
|
|
1252
|
-
}),
|
|
1253
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1254
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1255
|
-
name: "description",
|
|
1256
|
-
optional: true,
|
|
1257
|
-
type: "string",
|
|
1258
|
-
doc: "The description of the option"
|
|
1259
|
-
}),
|
|
1260
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1261
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1262
|
-
name: "selected",
|
|
1263
|
-
optional: true,
|
|
1264
|
-
type: "boolean",
|
|
1265
|
-
doc: "Whether the option is selected"
|
|
1266
|
-
}),
|
|
1267
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1268
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1269
|
-
name: "disabled",
|
|
1270
|
-
optional: true,
|
|
1271
|
-
type: "boolean",
|
|
1272
|
-
doc: "Whether the option is disabled"
|
|
1273
|
-
})
|
|
1274
|
-
];
|
|
1275
|
-
}
|
|
1276
|
-
}),
|
|
1277
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1278
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
1279
|
-
"export": true,
|
|
1280
|
-
name: "PromptOption",
|
|
1281
|
-
"extends": "PromptOptionConfig<TValue>",
|
|
1282
|
-
doc: "An option the user can select from the select prompt",
|
|
1283
|
-
typeParameters: [{
|
|
1284
|
-
name: "TValue",
|
|
1285
|
-
default: "string"
|
|
1286
|
-
}],
|
|
1287
|
-
get children() {
|
|
1288
|
-
return [
|
|
1289
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1290
|
-
name: "label",
|
|
1291
|
-
type: "string",
|
|
1292
|
-
doc: "The message label for the option"
|
|
1293
|
-
}),
|
|
1294
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1295
|
-
name: "index",
|
|
1296
|
-
type: "number",
|
|
1297
|
-
doc: "The index of the option"
|
|
1298
|
-
}),
|
|
1299
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1300
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1301
|
-
name: "selected",
|
|
1302
|
-
type: "boolean",
|
|
1303
|
-
doc: "Whether the option is selected"
|
|
1304
|
-
}),
|
|
1305
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1306
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1307
|
-
name: "disabled",
|
|
1308
|
-
type: "boolean",
|
|
1309
|
-
doc: "Whether the option is disabled"
|
|
1310
|
-
})
|
|
1311
|
-
];
|
|
1312
|
-
}
|
|
1313
|
-
}),
|
|
1314
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1315
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
1316
|
-
name: "SelectPromptConfig",
|
|
1317
|
-
"extends": "PromptConfig<TValue>",
|
|
1318
|
-
doc: "An options object for configuring a select prompt",
|
|
1319
|
-
typeParameters: [{
|
|
1320
|
-
name: "TValue",
|
|
1321
|
-
default: "string"
|
|
1322
|
-
}],
|
|
1323
|
-
get children() {
|
|
1324
|
-
return [
|
|
1325
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1326
|
-
name: "hint",
|
|
1327
|
-
optional: true,
|
|
1328
|
-
type: "string",
|
|
1329
|
-
doc: "A hint to display to the user"
|
|
1330
|
-
}),
|
|
1331
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1332
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1333
|
-
name: "options",
|
|
1334
|
-
type: "Array<string | PromptOptionConfig<TValue>>",
|
|
1335
|
-
doc: "The options available for the select prompt"
|
|
1336
|
-
}),
|
|
1337
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1338
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1339
|
-
name: "optionsPerPage",
|
|
1340
|
-
optional: true,
|
|
1341
|
-
type: "number",
|
|
1342
|
-
doc: "The number of options to display per page, defaults to 8"
|
|
1343
|
-
})
|
|
1344
|
-
];
|
|
1345
|
-
}
|
|
1346
|
-
}),
|
|
1347
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1348
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
1349
|
-
name: "SelectPrompt",
|
|
1350
|
-
doc: "A prompt for selecting an option from a list",
|
|
1351
|
-
"extends": "Prompt<TValue>",
|
|
1352
|
-
typeParameters: [{
|
|
1353
|
-
name: "TValue",
|
|
1354
|
-
default: "string"
|
|
1355
|
-
}],
|
|
1356
|
-
get children() {
|
|
1357
|
-
return [
|
|
1358
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1359
|
-
name: "initialValue",
|
|
1360
|
-
"protected": true,
|
|
1361
|
-
override: true,
|
|
1362
|
-
type: "TValue"
|
|
1363
|
-
}),
|
|
1364
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1365
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1366
|
-
name: "optionsPerPage",
|
|
1367
|
-
"protected": true,
|
|
1368
|
-
type: "number",
|
|
1369
|
-
children: _alloy_js_core.code`8; `
|
|
1370
|
-
}),
|
|
1371
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1372
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1373
|
-
name: "options",
|
|
1374
|
-
"protected": true,
|
|
1375
|
-
type: "PromptOption<TValue>[]",
|
|
1376
|
-
children: _alloy_js_core.code`[]; `
|
|
1377
|
-
}),
|
|
1378
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1379
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1380
|
-
name: "cursorHidden",
|
|
1381
|
-
"protected": true,
|
|
1382
|
-
override: true,
|
|
1383
|
-
type: "boolean",
|
|
1384
|
-
children: _alloy_js_core.code`true; `
|
|
1385
|
-
}),
|
|
1386
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1387
|
-
_alloy_js_core.code`constructor(config: SelectPromptConfig<TValue>) {
|
|
358
|
+
});`})]}function h(){return[(0,t.createComponent)(c.InterfaceDeclaration,{name:`PromptOptionConfig`,doc:`Configuration for an option the user can select from the select prompt`,typeParameters:[{name:`TValue`,default:`string`}],get children(){return[(0,t.createComponent)(c.InterfaceMember,{name:`label`,optional:!0,type:`string`,doc:`The message label for the option`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`icon`,optional:!0,type:`string`,doc:`An icon for the option`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`value`,type:`TValue`,doc:`The value of the option`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`description`,optional:!0,type:`string`,doc:`The description of the option`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`selected`,optional:!0,type:`boolean`,doc:`Whether the option is selected`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`disabled`,optional:!0,type:`boolean`,doc:`Whether the option is disabled`})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceDeclaration,{export:!0,name:`PromptOption`,extends:`PromptOptionConfig<TValue>`,doc:`An option the user can select from the select prompt`,typeParameters:[{name:`TValue`,default:`string`}],get children(){return[(0,t.createComponent)(c.InterfaceMember,{name:`label`,type:`string`,doc:`The message label for the option`}),(0,t.createComponent)(c.InterfaceMember,{name:`index`,type:`number`,doc:`The index of the option`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`selected`,type:`boolean`,doc:`Whether the option is selected`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`disabled`,type:`boolean`,doc:`Whether the option is disabled`})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceDeclaration,{name:`SelectPromptConfig`,extends:`PromptConfig<TValue>`,doc:`An options object for configuring a select prompt`,typeParameters:[{name:`TValue`,default:`string`}],get children(){return[(0,t.createComponent)(c.InterfaceMember,{name:`hint`,optional:!0,type:`string`,doc:`A hint to display to the user`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`options`,type:`Array<string | PromptOptionConfig<TValue>>`,doc:`The options available for the select prompt`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`optionsPerPage`,optional:!0,type:`number`,doc:`The number of options to display per page, defaults to 8`})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassDeclaration,{name:`SelectPrompt`,doc:`A prompt for selecting an option from a list`,extends:`Prompt<TValue>`,typeParameters:[{name:`TValue`,default:`string`}],get children(){return[(0,t.createComponent)(s.ClassField,{name:`initialValue`,protected:!0,override:!0,type:`TValue`}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`optionsPerPage`,protected:!0,type:`number`,children:n.code`8; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`options`,protected:!0,type:`PromptOption<TValue>[]`,children:n.code`[]; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`cursorHidden`,protected:!0,override:!0,type:`boolean`,children:n.code`true; `}),(0,t.createComponent)(a.Spacing,{}),n.code`constructor(config: SelectPromptConfig<TValue>) {
|
|
1388
359
|
super(config);
|
|
1389
360
|
|
|
1390
361
|
if (config.initialValue) {
|
|
@@ -1429,136 +400,37 @@ function SelectPromptDeclarations() {
|
|
|
1429
400
|
}
|
|
1430
401
|
|
|
1431
402
|
this.sync();
|
|
1432
|
-
} `,
|
|
1433
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1434
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
1435
|
-
doc: "Returns the currently selected option",
|
|
1436
|
-
name: "selectedOption",
|
|
1437
|
-
type: "PromptOption<TValue> | null",
|
|
1438
|
-
"protected": true,
|
|
1439
|
-
children: _alloy_js_core.code`return this.options.find(option => option.value === this.value) ?? null; `
|
|
1440
|
-
}),
|
|
1441
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1442
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1443
|
-
doc: "A method to route key press events to specific prompt actions based on the key pressed. This method maps various key combinations and keys to corresponding actions that can be handled by the prompt, such as submitting, cancelling, navigating, etc.",
|
|
1444
|
-
name: "getAction",
|
|
1445
|
-
override: true,
|
|
1446
|
-
"protected": true,
|
|
1447
|
-
parameters: [{
|
|
1448
|
-
name: "key",
|
|
1449
|
-
type: "Key"
|
|
1450
|
-
}],
|
|
1451
|
-
returnType: "string | false",
|
|
1452
|
-
children: _alloy_js_core.code`let action = super.getAction(key);
|
|
403
|
+
} `,(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassPropertyGet,{doc:`Returns the currently selected option`,name:`selectedOption`,type:`PromptOption<TValue> | null`,protected:!0,children:n.code`return this.options.find(option => option.value === this.value) ?? null; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to route key press events to specific prompt actions based on the key pressed. This method maps various key combinations and keys to corresponding actions that can be handled by the prompt, such as submitting, cancelling, navigating, etc.`,name:`getAction`,override:!0,protected:!0,parameters:[{name:`key`,type:`Key`}],returnType:`string | false`,children:n.code`let action = super.getAction(key);
|
|
1453
404
|
if (!action) {
|
|
1454
405
|
if (key.name === "j") action = "down";
|
|
1455
406
|
if (key.name === "k") action = "up";
|
|
1456
407
|
}
|
|
1457
408
|
|
|
1458
|
-
return action || false; `
|
|
1459
|
-
|
|
1460
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1461
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1462
|
-
doc: "A method to reset the prompt input",
|
|
1463
|
-
name: "reset",
|
|
1464
|
-
override: true,
|
|
1465
|
-
"protected": true,
|
|
1466
|
-
children: _alloy_js_core.code`this.moveCursor(0);
|
|
1467
|
-
super.reset(); `
|
|
1468
|
-
}),
|
|
1469
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1470
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1471
|
-
doc: "A method to submit the prompt input",
|
|
1472
|
-
name: "submit",
|
|
1473
|
-
async: true,
|
|
1474
|
-
override: true,
|
|
1475
|
-
"protected": true,
|
|
1476
|
-
children: _alloy_js_core.code`if (!this.selectedOption?.disabled) {
|
|
409
|
+
return action || false; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to reset the prompt input`,name:`reset`,override:!0,protected:!0,children:n.code`this.moveCursor(0);
|
|
410
|
+
super.reset(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to submit the prompt input`,name:`submit`,async:!0,override:!0,protected:!0,children:n.code`if (!this.selectedOption?.disabled) {
|
|
1477
411
|
await super.submit();
|
|
1478
412
|
} else {
|
|
1479
413
|
this.bell();
|
|
1480
|
-
} `
|
|
1481
|
-
|
|
1482
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1483
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1484
|
-
doc: "A method to move the cursor to the end of the input",
|
|
1485
|
-
name: "next",
|
|
1486
|
-
"protected": true,
|
|
1487
|
-
children: _alloy_js_core.code`this.moveCursor((this.cursor + 1) % this.options.length);
|
|
1488
|
-
this.sync(); `
|
|
1489
|
-
}),
|
|
1490
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1491
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1492
|
-
doc: "A method to move the cursor to the left or right by a \\`count\\` of positions",
|
|
1493
|
-
name: "moveCursor",
|
|
1494
|
-
parameters: [{
|
|
1495
|
-
name: "count",
|
|
1496
|
-
type: "number"
|
|
1497
|
-
}],
|
|
1498
|
-
override: true,
|
|
1499
|
-
"protected": true,
|
|
1500
|
-
children: _alloy_js_core.code`this.cursor = count;
|
|
414
|
+
} `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the end of the input`,name:`next`,protected:!0,children:n.code`this.moveCursor((this.cursor + 1) % this.options.length);
|
|
415
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:"A method to move the cursor to the left or right by a \\`count\\` of positions",name:`moveCursor`,parameters:[{name:`count`,type:`number`}],override:!0,protected:!0,children:n.code`this.cursor = count;
|
|
1501
416
|
|
|
1502
417
|
this.changeValue(this.options[count]!.value);
|
|
1503
|
-
this.sync(); `
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
doc: "A method to move the cursor to the first option",
|
|
1508
|
-
name: "first",
|
|
1509
|
-
"protected": true,
|
|
1510
|
-
children: _alloy_js_core.code`this.moveCursor(0);
|
|
1511
|
-
this.sync(); `
|
|
1512
|
-
}),
|
|
1513
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1514
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1515
|
-
doc: "A method to move the cursor to the last option",
|
|
1516
|
-
name: "last",
|
|
1517
|
-
"protected": true,
|
|
1518
|
-
children: _alloy_js_core.code`this.moveCursor(this.options.length - 1);
|
|
1519
|
-
this.sync(); `
|
|
1520
|
-
}),
|
|
1521
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1522
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1523
|
-
doc: "A method to move the cursor to the start",
|
|
1524
|
-
name: "first",
|
|
1525
|
-
"protected": true,
|
|
1526
|
-
children: _alloy_js_core.code`this.cursor = 0;
|
|
1527
|
-
this.sync(); `
|
|
1528
|
-
}),
|
|
1529
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1530
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1531
|
-
doc: "A method to move the cursor to the up",
|
|
1532
|
-
name: "up",
|
|
1533
|
-
"protected": true,
|
|
1534
|
-
children: _alloy_js_core.code`if (this.cursor === 0) {
|
|
418
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the first option`,name:`first`,protected:!0,children:n.code`this.moveCursor(0);
|
|
419
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the last option`,name:`last`,protected:!0,children:n.code`this.moveCursor(this.options.length - 1);
|
|
420
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the start`,name:`first`,protected:!0,children:n.code`this.cursor = 0;
|
|
421
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the up`,name:`up`,protected:!0,children:n.code`if (this.cursor === 0) {
|
|
1535
422
|
this.moveCursor(this.options.length - 1);
|
|
1536
423
|
} else {
|
|
1537
424
|
this.moveCursor(this.cursor - 1);
|
|
1538
425
|
}
|
|
1539
426
|
|
|
1540
|
-
this.sync(); `
|
|
1541
|
-
}),
|
|
1542
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1543
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1544
|
-
doc: "A method to move the cursor to the down",
|
|
1545
|
-
name: "down",
|
|
1546
|
-
"protected": true,
|
|
1547
|
-
children: _alloy_js_core.code`if (this.cursor === this.options.length - 1) {
|
|
427
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the down`,name:`down`,protected:!0,children:n.code`if (this.cursor === this.options.length - 1) {
|
|
1548
428
|
this.moveCursor(0);
|
|
1549
429
|
} else {
|
|
1550
430
|
this.moveCursor(this.cursor + 1);
|
|
1551
431
|
}
|
|
1552
432
|
|
|
1553
|
-
this.sync(); `
|
|
1554
|
-
}),
|
|
1555
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1556
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1557
|
-
doc: "A method to render the prompt",
|
|
1558
|
-
name: "onRender",
|
|
1559
|
-
override: true,
|
|
1560
|
-
"protected": true,
|
|
1561
|
-
children: _alloy_js_core.code`const spacing = Math.max(...this.options.map(option => option.label?.length || 0)) + 2;
|
|
433
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to render the prompt`,name:`onRender`,override:!0,protected:!0,children:n.code`const spacing = Math.max(...this.options.map(option => option.label?.length || 0)) + 2;
|
|
1562
434
|
|
|
1563
435
|
const startIndex = Math.max(Math.min(this.options.length - this.optionsPerPage, this.cursor - Math.floor(this.optionsPerPage / 2)), 0);
|
|
1564
436
|
const endIndex = Math.min(startIndex + this.optionsPerPage, this.options.length);
|
|
@@ -1610,29 +482,7 @@ function SelectPromptDeclarations() {
|
|
|
1610
482
|
output += super.onRender();
|
|
1611
483
|
}
|
|
1612
484
|
|
|
1613
|
-
return output; `
|
|
1614
|
-
})
|
|
1615
|
-
];
|
|
1616
|
-
}
|
|
1617
|
-
}),
|
|
1618
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1619
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1620
|
-
heading: "A type definition for the configuration options to pass to the select prompt, which extends the base PromptConfig with additional options specific to select prompts. This type can be used when creating a select prompt using the {@link select | select prompt factory function}.",
|
|
1621
|
-
get children() {
|
|
1622
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The Select Config type includes all the properties of the base PromptConfig, such as message, description, initialValue, validate, parse, format, etc., as well as any additional properties that are specific to select prompts, such as the list of options and pagination settings.` });
|
|
1623
|
-
}
|
|
1624
|
-
}),
|
|
1625
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
1626
|
-
"export": true,
|
|
1627
|
-
name: "SelectConfig",
|
|
1628
|
-
children: _alloy_js_core.code`PromptFactoryConfig<string> & SelectPromptConfig; `
|
|
1629
|
-
}),
|
|
1630
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1631
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1632
|
-
heading: "A function to create and run a select prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.",
|
|
1633
|
-
get children() {
|
|
1634
|
-
return [
|
|
1635
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { select, isCancel } from "shell-shock:prompts";
|
|
485
|
+
return output; `})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A type definition for the configuration options to pass to the select prompt, which extends the base PromptConfig with additional options specific to select prompts. This type can be used when creating a select prompt using the {@link select | select prompt factory function}.`,get children(){return(0,t.createComponent)(l.TSDocRemarks,{children:`The Select Config type includes all the properties of the base PromptConfig, such as message, description, initialValue, validate, parse, format, etc., as well as any additional properties that are specific to select prompts, such as the list of options and pagination settings.`})}}),(0,t.createComponent)(u.TypeDeclaration,{export:!0,name:`SelectConfig`,children:n.code`PromptFactoryConfig<string> & SelectPromptConfig; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A function to create and run a select prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.`,get children(){return[(0,t.createComponent)(l.TSDocExample,{children:`import { select, isCancel } from "shell-shock:prompts";
|
|
1636
486
|
|
|
1637
487
|
async function run() {
|
|
1638
488
|
const color = await select({
|
|
@@ -1654,148 +504,13 @@ async function run() {
|
|
|
1654
504
|
console.log("Your favorite color is " + color + "!");
|
|
1655
505
|
}
|
|
1656
506
|
|
|
1657
|
-
run(); ` }),
|
|
1658
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1659
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1660
|
-
name: "config",
|
|
1661
|
-
children: `The configuration options to pass to the select prompt, which extends the base PromptConfig with additional options specific to select prompts`
|
|
1662
|
-
}),
|
|
1663
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled` })
|
|
1664
|
-
];
|
|
1665
|
-
}
|
|
1666
|
-
}),
|
|
1667
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1668
|
-
name: "select",
|
|
1669
|
-
"export": true,
|
|
1670
|
-
parameters: [{
|
|
1671
|
-
name: "config",
|
|
1672
|
-
type: "SelectConfig"
|
|
1673
|
-
}],
|
|
1674
|
-
returnType: "Promise<string | symbol>",
|
|
1675
|
-
children: _alloy_js_core.code`return new Promise<string | symbol>((response, reject) => {
|
|
507
|
+
run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocParam,{name:`config`,children:`The configuration options to pass to the select prompt, which extends the base PromptConfig with additional options specific to select prompts`}),(0,t.createComponent)(l.TSDocReturns,{children:`A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled`})]}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`select`,export:!0,parameters:[{name:`config`,type:`SelectConfig`}],returnType:`Promise<string | symbol>`,children:n.code`return new Promise<string | symbol>((response, reject) => {
|
|
1676
508
|
const prompt = new SelectPrompt(config);
|
|
1677
509
|
|
|
1678
510
|
prompt.on("state", state => config.onState?.(state));
|
|
1679
511
|
prompt.on("submit", value => response(value));
|
|
1680
512
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
1681
|
-
});`
|
|
1682
|
-
})
|
|
1683
|
-
];
|
|
1684
|
-
}
|
|
1685
|
-
/**
|
|
1686
|
-
* A component that renders the declarations for the built-in numeric prompt, which allows users to input and select numeric values with various configuration options such as floating point support, precision, increment, and min/max values.
|
|
1687
|
-
*/
|
|
1688
|
-
function NumericPromptDeclarations() {
|
|
1689
|
-
return [
|
|
1690
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
1691
|
-
name: "NumberPromptConfig",
|
|
1692
|
-
"extends": "PromptConfig<number>",
|
|
1693
|
-
doc: "Configuration options for creating a numeric prompt",
|
|
1694
|
-
get children() {
|
|
1695
|
-
return [
|
|
1696
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1697
|
-
name: "isFloat",
|
|
1698
|
-
optional: true,
|
|
1699
|
-
type: "boolean",
|
|
1700
|
-
doc: "Whether the prompt should accept floating point numbers"
|
|
1701
|
-
}),
|
|
1702
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1703
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1704
|
-
name: "precision",
|
|
1705
|
-
optional: true,
|
|
1706
|
-
type: "number",
|
|
1707
|
-
doc: "The number of decimal places to round the input to, defaults to 2"
|
|
1708
|
-
}),
|
|
1709
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1710
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1711
|
-
name: "increment",
|
|
1712
|
-
optional: true,
|
|
1713
|
-
type: "number",
|
|
1714
|
-
doc: "The increment value for the number prompt, defaults to 1"
|
|
1715
|
-
}),
|
|
1716
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1717
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1718
|
-
name: "min",
|
|
1719
|
-
optional: true,
|
|
1720
|
-
type: "number",
|
|
1721
|
-
doc: "The minimum value for the number prompt, defaults to -Infinity"
|
|
1722
|
-
}),
|
|
1723
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1724
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1725
|
-
name: "max",
|
|
1726
|
-
optional: true,
|
|
1727
|
-
type: "number",
|
|
1728
|
-
doc: "The maximum value for the number prompt, defaults to Infinity"
|
|
1729
|
-
})
|
|
1730
|
-
];
|
|
1731
|
-
}
|
|
1732
|
-
}),
|
|
1733
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1734
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
1735
|
-
name: "NumberPrompt",
|
|
1736
|
-
doc: "A prompt for selecting a number input",
|
|
1737
|
-
"extends": "Prompt<number>",
|
|
1738
|
-
get children() {
|
|
1739
|
-
return [
|
|
1740
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1741
|
-
name: "isInvalid",
|
|
1742
|
-
isPrivateMember: true,
|
|
1743
|
-
type: "boolean",
|
|
1744
|
-
children: _alloy_js_core.code`false; `
|
|
1745
|
-
}),
|
|
1746
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1747
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1748
|
-
name: "initialValue",
|
|
1749
|
-
"protected": true,
|
|
1750
|
-
override: true,
|
|
1751
|
-
type: "number",
|
|
1752
|
-
children: _alloy_js_core.code`0; `
|
|
1753
|
-
}),
|
|
1754
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1755
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1756
|
-
name: "defaultErrorMessage",
|
|
1757
|
-
"protected": true,
|
|
1758
|
-
override: true,
|
|
1759
|
-
type: "string",
|
|
1760
|
-
children: _alloy_js_core.code`"A valid numeric value must be provided"; `
|
|
1761
|
-
}),
|
|
1762
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1763
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1764
|
-
name: "isFloat",
|
|
1765
|
-
"protected": true,
|
|
1766
|
-
type: "boolean",
|
|
1767
|
-
children: _alloy_js_core.code`false; `
|
|
1768
|
-
}),
|
|
1769
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1770
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1771
|
-
name: "precision",
|
|
1772
|
-
"protected": true,
|
|
1773
|
-
type: "number",
|
|
1774
|
-
children: _alloy_js_core.code`2; `
|
|
1775
|
-
}),
|
|
1776
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1777
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1778
|
-
name: "increment",
|
|
1779
|
-
"protected": true,
|
|
1780
|
-
type: "number",
|
|
1781
|
-
children: _alloy_js_core.code`1; `
|
|
1782
|
-
}),
|
|
1783
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1784
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1785
|
-
name: "min",
|
|
1786
|
-
"protected": true,
|
|
1787
|
-
type: "number",
|
|
1788
|
-
children: _alloy_js_core.code`Number.NEGATIVE_INFINITY; `
|
|
1789
|
-
}),
|
|
1790
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1791
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1792
|
-
name: "max",
|
|
1793
|
-
"protected": true,
|
|
1794
|
-
type: "number",
|
|
1795
|
-
children: _alloy_js_core.code`Number.POSITIVE_INFINITY; `
|
|
1796
|
-
}),
|
|
1797
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1798
|
-
_alloy_js_core.code`constructor(config: NumberPromptConfig) {
|
|
513
|
+
});`})]}function g(){return[(0,t.createComponent)(c.InterfaceDeclaration,{name:`NumberPromptConfig`,extends:`PromptConfig<number>`,doc:`Configuration options for creating a numeric prompt`,get children(){return[(0,t.createComponent)(c.InterfaceMember,{name:`isFloat`,optional:!0,type:`boolean`,doc:`Whether the prompt should accept floating point numbers`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`precision`,optional:!0,type:`number`,doc:`The number of decimal places to round the input to, defaults to 2`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`increment`,optional:!0,type:`number`,doc:`The increment value for the number prompt, defaults to 1`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`min`,optional:!0,type:`number`,doc:`The minimum value for the number prompt, defaults to -Infinity`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`max`,optional:!0,type:`number`,doc:`The maximum value for the number prompt, defaults to Infinity`})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassDeclaration,{name:`NumberPrompt`,doc:`A prompt for selecting a number input`,extends:`Prompt<number>`,get children(){return[(0,t.createComponent)(s.ClassField,{name:`isInvalid`,isPrivateMember:!0,type:`boolean`,children:n.code`false; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassField,{name:`initialValue`,protected:!0,override:!0,type:`number`,children:n.code`0; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`defaultErrorMessage`,protected:!0,override:!0,type:`string`,children:n.code`"A valid numeric value must be provided"; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`isFloat`,protected:!0,type:`boolean`,children:n.code`false; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`precision`,protected:!0,type:`number`,children:n.code`2; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`increment`,protected:!0,type:`number`,children:n.code`1; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`min`,protected:!0,type:`number`,children:n.code`Number.NEGATIVE_INFINITY; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`max`,protected:!0,type:`number`,children:n.code`Number.POSITIVE_INFINITY; `}),(0,t.createComponent)(a.Spacing,{}),n.code`constructor(config: NumberPromptConfig) {
|
|
1799
514
|
super(config);
|
|
1800
515
|
|
|
1801
516
|
if (config.initialValue) {
|
|
@@ -1835,21 +550,7 @@ function NumericPromptDeclarations() {
|
|
|
1835
550
|
this.cursor = 0;
|
|
1836
551
|
this.sync();
|
|
1837
552
|
this.last();
|
|
1838
|
-
} `,
|
|
1839
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1840
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1841
|
-
doc: "A method to handle key press events and determine the corresponding action",
|
|
1842
|
-
name: "onKeyPress",
|
|
1843
|
-
override: true,
|
|
1844
|
-
"protected": true,
|
|
1845
|
-
parameters: [{
|
|
1846
|
-
name: "char",
|
|
1847
|
-
type: "string"
|
|
1848
|
-
}, {
|
|
1849
|
-
name: "key",
|
|
1850
|
-
type: "Key"
|
|
1851
|
-
}],
|
|
1852
|
-
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
553
|
+
} `,(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to handle key press events and determine the corresponding action`,name:`onKeyPress`,override:!0,protected:!0,parameters:[{name:`char`,type:`string`},{name:`key`,type:`Key`}],children:n.code`const action = this.getAction(key);
|
|
1853
554
|
if (action && typeof (this as any)[action] === "function") {
|
|
1854
555
|
return (this as any)[action]();
|
|
1855
556
|
}
|
|
@@ -1877,45 +578,10 @@ function NumericPromptDeclarations() {
|
|
|
1877
578
|
}
|
|
1878
579
|
|
|
1879
580
|
this.changeValue(value);
|
|
1880
|
-
this.sync(); `
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
doc: "A method to handle changes in the prompt value",
|
|
1885
|
-
name: "onChange",
|
|
1886
|
-
override: true,
|
|
1887
|
-
"protected": true,
|
|
1888
|
-
parameters: [{
|
|
1889
|
-
name: "previousValue",
|
|
1890
|
-
type: "number"
|
|
1891
|
-
}],
|
|
1892
|
-
children: _alloy_js_core.code`this.#isInvalid = false;
|
|
1893
|
-
this.cursor = this.displayValue.slice(0, this.cursor).length + 1; `
|
|
1894
|
-
}),
|
|
1895
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1896
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1897
|
-
doc: "A method to validate the prompt input",
|
|
1898
|
-
name: "checkValidations",
|
|
1899
|
-
override: true,
|
|
1900
|
-
async: true,
|
|
1901
|
-
"protected": true,
|
|
1902
|
-
children: _alloy_js_core.code`await super.checkValidations(this.value);
|
|
1903
|
-
this.#isInvalid = this.isError; `
|
|
1904
|
-
}),
|
|
1905
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1906
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1907
|
-
doc: "A method to move the cursor to the end of the input",
|
|
1908
|
-
name: "next",
|
|
1909
|
-
"protected": true,
|
|
1910
|
-
children: _alloy_js_core.code`this.changeValue(this.initialValue);
|
|
1911
|
-
this.sync(); `
|
|
1912
|
-
}),
|
|
1913
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1914
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1915
|
-
doc: "A method to move the cursor to the up",
|
|
1916
|
-
name: "up",
|
|
1917
|
-
"protected": true,
|
|
1918
|
-
children: _alloy_js_core.code`let value = this.value;
|
|
581
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to handle changes in the prompt value`,name:`onChange`,override:!0,protected:!0,parameters:[{name:`previousValue`,type:`number`}],children:n.code`this.#isInvalid = false;
|
|
582
|
+
this.cursor = this.displayValue.slice(0, this.cursor).length + 1; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to validate the prompt input`,name:`checkValidations`,override:!0,async:!0,protected:!0,children:n.code`await super.checkValidations(this.value);
|
|
583
|
+
this.#isInvalid = this.isError; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the end of the input`,name:`next`,protected:!0,children:n.code`this.changeValue(this.initialValue);
|
|
584
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the up`,name:`up`,protected:!0,children:n.code`let value = this.value;
|
|
1919
585
|
if (this.isPlaceholder) {
|
|
1920
586
|
value = this.min < 0 ? 0 : this.min;
|
|
1921
587
|
} else if (value >= this.max) {
|
|
@@ -1925,14 +591,7 @@ function NumericPromptDeclarations() {
|
|
|
1925
591
|
this.changeValue(value + this.increment);
|
|
1926
592
|
|
|
1927
593
|
this.sync();
|
|
1928
|
-
this.last(); `
|
|
1929
|
-
}),
|
|
1930
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1931
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1932
|
-
doc: "A method to move the cursor to the down",
|
|
1933
|
-
name: "down",
|
|
1934
|
-
"protected": true,
|
|
1935
|
-
children: _alloy_js_core.code`let value = this.value;
|
|
594
|
+
this.last(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the down`,name:`down`,protected:!0,children:n.code`let value = this.value;
|
|
1936
595
|
if (this.isPlaceholder) {
|
|
1937
596
|
value = this.min < 0 ? 0 : this.min;
|
|
1938
597
|
} else if (value <= this.min) {
|
|
@@ -1941,56 +600,19 @@ function NumericPromptDeclarations() {
|
|
|
1941
600
|
|
|
1942
601
|
this.changeValue(value === this.min ? this.min : value - this.increment);
|
|
1943
602
|
this.sync();
|
|
1944
|
-
this.last(); `
|
|
1945
|
-
}),
|
|
1946
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1947
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1948
|
-
doc: "A method to move the cursor to the left",
|
|
1949
|
-
name: "left",
|
|
1950
|
-
"protected": true,
|
|
1951
|
-
children: _alloy_js_core.code`if (this.cursor <= 0) {
|
|
603
|
+
this.last(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the left`,name:`left`,protected:!0,children:n.code`if (this.cursor <= 0) {
|
|
1952
604
|
return this.bell();
|
|
1953
605
|
}
|
|
1954
606
|
|
|
1955
607
|
this.moveCursor(-1);
|
|
1956
|
-
this.sync(); `
|
|
1957
|
-
}),
|
|
1958
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1959
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1960
|
-
doc: "A method to move the cursor to the right",
|
|
1961
|
-
name: "right",
|
|
1962
|
-
"protected": true,
|
|
1963
|
-
children: _alloy_js_core.code`if (this.cursor >= this.displayValue.length) {
|
|
608
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the right`,name:`right`,protected:!0,children:n.code`if (this.cursor >= this.displayValue.length) {
|
|
1964
609
|
return this.bell();
|
|
1965
610
|
}
|
|
1966
611
|
|
|
1967
612
|
this.moveCursor(1);
|
|
1968
|
-
this.sync(); `
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1972
|
-
doc: "A method to move the cursor to the start",
|
|
1973
|
-
name: "first",
|
|
1974
|
-
"protected": true,
|
|
1975
|
-
children: _alloy_js_core.code`this.cursor = 0;
|
|
1976
|
-
this.sync(); `
|
|
1977
|
-
}),
|
|
1978
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1979
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1980
|
-
doc: "A method to move the cursor to the end",
|
|
1981
|
-
name: "last",
|
|
1982
|
-
"protected": true,
|
|
1983
|
-
children: _alloy_js_core.code`this.cursor = this.displayValue.length;
|
|
1984
|
-
this.sync(); `
|
|
1985
|
-
}),
|
|
1986
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1987
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1988
|
-
doc: "A method to render the prompt",
|
|
1989
|
-
name: "onRender",
|
|
1990
|
-
override: true,
|
|
1991
|
-
"protected": true,
|
|
1992
|
-
returnType: "string",
|
|
1993
|
-
children: _alloy_js_core.code`return this.isPlaceholder
|
|
613
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the start`,name:`first`,protected:!0,children:n.code`this.cursor = 0;
|
|
614
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the end`,name:`last`,protected:!0,children:n.code`this.cursor = this.displayValue.length;
|
|
615
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to render the prompt`,name:`onRender`,override:!0,protected:!0,returnType:`string`,children:n.code`return this.isPlaceholder
|
|
1994
616
|
? textColors.prompt.input.disabled(this.displayValue)
|
|
1995
617
|
: this.#isInvalid
|
|
1996
618
|
? textColors.prompt.input.error(this.displayValue)
|
|
@@ -1998,24 +620,7 @@ function NumericPromptDeclarations() {
|
|
|
1998
620
|
? textColors.prompt.input.submitted(this.displayValue)
|
|
1999
621
|
: this.isCancelled
|
|
2000
622
|
? textColors.prompt.input.cancelled(this.displayValue)
|
|
2001
|
-
: bold(textColors.prompt.input.active(this.displayValue)); `
|
|
2002
|
-
})
|
|
2003
|
-
];
|
|
2004
|
-
}
|
|
2005
|
-
}),
|
|
2006
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2007
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "An object representing the configuration options for a numeric prompt." }),
|
|
2008
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2009
|
-
name: "NumericConfig",
|
|
2010
|
-
"export": true,
|
|
2011
|
-
children: _alloy_js_core.code`PromptFactoryConfig<number> & NumberPromptConfig; `
|
|
2012
|
-
}),
|
|
2013
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2014
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2015
|
-
heading: "A function to create and run a numeric prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.",
|
|
2016
|
-
get children() {
|
|
2017
|
-
return [
|
|
2018
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { numeric, isCancel } from "shell-shock:prompts";
|
|
623
|
+
: bold(textColors.prompt.input.active(this.displayValue)); `})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`An object representing the configuration options for a numeric prompt.`}),(0,t.createComponent)(u.TypeDeclaration,{name:`NumericConfig`,export:!0,children:n.code`PromptFactoryConfig<number> & NumberPromptConfig; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A function to create and run a numeric prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.`,get children(){return[(0,t.createComponent)(l.TSDocExample,{children:`import { numeric, isCancel } from "shell-shock:prompts";
|
|
2019
624
|
|
|
2020
625
|
async function run() {
|
|
2021
626
|
const age = await numeric({
|
|
@@ -2031,102 +636,13 @@ async function run() {
|
|
|
2031
636
|
console.log("Your age is " + age + "!");
|
|
2032
637
|
}
|
|
2033
638
|
|
|
2034
|
-
run(); ` }),
|
|
2035
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2036
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2037
|
-
name: "config",
|
|
2038
|
-
children: `The configuration options to pass to the numeric prompt, which extends the base PromptFactoryConfig with additional options specific to numeric prompts`
|
|
2039
|
-
}),
|
|
2040
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled` })
|
|
2041
|
-
];
|
|
2042
|
-
}
|
|
2043
|
-
}),
|
|
2044
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2045
|
-
name: "numeric",
|
|
2046
|
-
"export": true,
|
|
2047
|
-
parameters: [{
|
|
2048
|
-
name: "config",
|
|
2049
|
-
type: "NumericConfig"
|
|
2050
|
-
}],
|
|
2051
|
-
returnType: "Promise<number | symbol>",
|
|
2052
|
-
children: _alloy_js_core.code`return new Promise<number | symbol>((response, reject) => {
|
|
639
|
+
run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocParam,{name:`config`,children:`The configuration options to pass to the numeric prompt, which extends the base PromptFactoryConfig with additional options specific to numeric prompts`}),(0,t.createComponent)(l.TSDocReturns,{children:`A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled`})]}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`numeric`,export:!0,parameters:[{name:`config`,type:`NumericConfig`}],returnType:`Promise<number | symbol>`,children:n.code`return new Promise<number | symbol>((response, reject) => {
|
|
2053
640
|
const prompt = new NumberPrompt(config);
|
|
2054
641
|
|
|
2055
642
|
prompt.on("state", state => config.onState?.(state));
|
|
2056
643
|
prompt.on("submit", value => response(value));
|
|
2057
644
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
2058
|
-
});`
|
|
2059
|
-
})
|
|
2060
|
-
];
|
|
2061
|
-
}
|
|
2062
|
-
/**
|
|
2063
|
-
* A component that renders the declarations for the built-in toggle prompt, which allows users to select a boolean value (true/false) with support for custom messages for the true and false states. This prompt type can be used for scenarios where the user needs to toggle a setting on or off, such as enabling or disabling a feature. The TogglePrompt class extends the base Prompt class and implements specific logic for handling boolean input and rendering interactions.
|
|
2064
|
-
*/
|
|
2065
|
-
function TogglePromptDeclarations() {
|
|
2066
|
-
return [
|
|
2067
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
2068
|
-
"export": true,
|
|
2069
|
-
name: "TogglePromptConfig",
|
|
2070
|
-
"extends": "PromptConfig<boolean>",
|
|
2071
|
-
doc: "Configuration options for creating a boolean toggle prompt",
|
|
2072
|
-
get children() {
|
|
2073
|
-
return [
|
|
2074
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2075
|
-
name: "trueMessage",
|
|
2076
|
-
optional: true,
|
|
2077
|
-
type: "string",
|
|
2078
|
-
doc: "The message for the true state of the prompt"
|
|
2079
|
-
}),
|
|
2080
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2081
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2082
|
-
name: "falseMessage",
|
|
2083
|
-
optional: true,
|
|
2084
|
-
type: "string",
|
|
2085
|
-
doc: "The message for the false state of the prompt"
|
|
2086
|
-
}),
|
|
2087
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
2088
|
-
];
|
|
2089
|
-
}
|
|
2090
|
-
}),
|
|
2091
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2092
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
2093
|
-
"export": true,
|
|
2094
|
-
name: "TogglePrompt",
|
|
2095
|
-
doc: "A prompt for toggling a boolean input",
|
|
2096
|
-
"extends": "Prompt<boolean>",
|
|
2097
|
-
get children() {
|
|
2098
|
-
return [
|
|
2099
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2100
|
-
name: "initialValue",
|
|
2101
|
-
"protected": true,
|
|
2102
|
-
override: true,
|
|
2103
|
-
type: "boolean",
|
|
2104
|
-
children: _alloy_js_core.code`false; `
|
|
2105
|
-
}),
|
|
2106
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2107
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2108
|
-
name: "trueMessage",
|
|
2109
|
-
"protected": true,
|
|
2110
|
-
type: "string",
|
|
2111
|
-
children: _alloy_js_core.code`"Yes"; `
|
|
2112
|
-
}),
|
|
2113
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2114
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2115
|
-
name: "falseMessage",
|
|
2116
|
-
"protected": true,
|
|
2117
|
-
type: "string",
|
|
2118
|
-
children: _alloy_js_core.code`"No"; `
|
|
2119
|
-
}),
|
|
2120
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2121
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2122
|
-
name: "cursorHidden",
|
|
2123
|
-
"protected": true,
|
|
2124
|
-
override: true,
|
|
2125
|
-
type: "boolean",
|
|
2126
|
-
children: _alloy_js_core.code`true; `
|
|
2127
|
-
}),
|
|
2128
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2129
|
-
_alloy_js_core.code`constructor(config: TogglePromptConfig) {
|
|
645
|
+
});`})]}function _(){return[(0,t.createComponent)(c.InterfaceDeclaration,{export:!0,name:`TogglePromptConfig`,extends:`PromptConfig<boolean>`,doc:`Configuration options for creating a boolean toggle prompt`,get children(){return[(0,t.createComponent)(c.InterfaceMember,{name:`trueMessage`,optional:!0,type:`string`,doc:`The message for the true state of the prompt`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(c.InterfaceMember,{name:`falseMessage`,optional:!0,type:`string`,doc:`The message for the false state of the prompt`}),(0,t.createComponent)(a.Spacing,{})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassDeclaration,{export:!0,name:`TogglePrompt`,doc:`A prompt for toggling a boolean input`,extends:`Prompt<boolean>`,get children(){return[(0,t.createComponent)(s.ClassField,{name:`initialValue`,protected:!0,override:!0,type:`boolean`,children:n.code`false; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`trueMessage`,protected:!0,type:`string`,children:n.code`"Yes"; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`falseMessage`,protected:!0,type:`string`,children:n.code`"No"; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`cursorHidden`,protected:!0,override:!0,type:`boolean`,children:n.code`true; `}),(0,t.createComponent)(a.Spacing,{}),n.code`constructor(config: TogglePromptConfig) {
|
|
2130
646
|
super(config);
|
|
2131
647
|
|
|
2132
648
|
if (config.initialValue) {
|
|
@@ -2141,45 +657,17 @@ function TogglePromptDeclarations() {
|
|
|
2141
657
|
}
|
|
2142
658
|
|
|
2143
659
|
this.sync();
|
|
2144
|
-
} `,
|
|
2145
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2146
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2147
|
-
doc: "Update the toggle value to a checked state based on user input",
|
|
2148
|
-
name: "check",
|
|
2149
|
-
"protected": true,
|
|
2150
|
-
children: _alloy_js_core.code`if (this.value === true) {
|
|
660
|
+
} `,(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`Update the toggle value to a checked state based on user input`,name:`check`,protected:!0,children:n.code`if (this.value === true) {
|
|
2151
661
|
return this.bell();
|
|
2152
662
|
}
|
|
2153
663
|
|
|
2154
664
|
this.changeValue(true);
|
|
2155
|
-
this.sync(); `
|
|
2156
|
-
}),
|
|
2157
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2158
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2159
|
-
doc: "Update the toggle value to an unchecked state based on user input",
|
|
2160
|
-
name: "uncheck",
|
|
2161
|
-
"protected": true,
|
|
2162
|
-
children: _alloy_js_core.code`if (this.value === false) {
|
|
665
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`Update the toggle value to an unchecked state based on user input`,name:`uncheck`,protected:!0,children:n.code`if (this.value === false) {
|
|
2163
666
|
return this.bell();
|
|
2164
667
|
}
|
|
2165
668
|
|
|
2166
669
|
this.changeValue(false);
|
|
2167
|
-
this.sync(); `
|
|
2168
|
-
}),
|
|
2169
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2170
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2171
|
-
doc: "A method to handle key press events and determine the corresponding action",
|
|
2172
|
-
name: "onKeyPress",
|
|
2173
|
-
override: true,
|
|
2174
|
-
"protected": true,
|
|
2175
|
-
parameters: [{
|
|
2176
|
-
name: "char",
|
|
2177
|
-
type: "string"
|
|
2178
|
-
}, {
|
|
2179
|
-
name: "key",
|
|
2180
|
-
type: "Key"
|
|
2181
|
-
}],
|
|
2182
|
-
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
670
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to handle key press events and determine the corresponding action`,name:`onKeyPress`,override:!0,protected:!0,parameters:[{name:`char`,type:`string`},{name:`key`,type:`Key`}],children:n.code`const action = this.getAction(key);
|
|
2183
671
|
if (action && typeof (this as any)[action] === "function") {
|
|
2184
672
|
return (this as any)[action]();
|
|
2185
673
|
}
|
|
@@ -2194,59 +682,8 @@ function TogglePromptDeclarations() {
|
|
|
2194
682
|
return this.bell();
|
|
2195
683
|
}
|
|
2196
684
|
|
|
2197
|
-
this.sync(); `
|
|
2198
|
-
|
|
2199
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2200
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2201
|
-
doc: "A method to remove the character backward of the cursor",
|
|
2202
|
-
name: "backspace",
|
|
2203
|
-
"protected": true,
|
|
2204
|
-
children: _alloy_js_core.code`this.uncheck(); `
|
|
2205
|
-
}),
|
|
2206
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2207
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2208
|
-
doc: "A method to move the cursor to the left",
|
|
2209
|
-
name: "left",
|
|
2210
|
-
"protected": true,
|
|
2211
|
-
children: _alloy_js_core.code`this.uncheck(); `
|
|
2212
|
-
}),
|
|
2213
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2214
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2215
|
-
doc: "A method to move the cursor to the right",
|
|
2216
|
-
name: "right",
|
|
2217
|
-
"protected": true,
|
|
2218
|
-
children: _alloy_js_core.code`this.check(); `
|
|
2219
|
-
}),
|
|
2220
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2221
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2222
|
-
doc: "A method to move the cursor to down",
|
|
2223
|
-
name: "down",
|
|
2224
|
-
"protected": true,
|
|
2225
|
-
children: _alloy_js_core.code`this.uncheck(); `
|
|
2226
|
-
}),
|
|
2227
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2228
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2229
|
-
doc: "A method to move the cursor to up",
|
|
2230
|
-
name: "up",
|
|
2231
|
-
"protected": true,
|
|
2232
|
-
children: _alloy_js_core.code`this.check(); `
|
|
2233
|
-
}),
|
|
2234
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2235
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2236
|
-
doc: "A method to move to the next value",
|
|
2237
|
-
name: "next",
|
|
2238
|
-
"protected": true,
|
|
2239
|
-
children: _alloy_js_core.code`this.changeValue(!this.value);
|
|
2240
|
-
this.sync(); `
|
|
2241
|
-
}),
|
|
2242
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2243
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2244
|
-
doc: "A method to render the prompt",
|
|
2245
|
-
name: "onRender",
|
|
2246
|
-
override: true,
|
|
2247
|
-
"protected": true,
|
|
2248
|
-
returnType: "string",
|
|
2249
|
-
children: _alloy_js_core.code`return this.isSubmitted
|
|
685
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to remove the character backward of the cursor`,name:`backspace`,protected:!0,children:n.code`this.uncheck(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the left`,name:`left`,protected:!0,children:n.code`this.uncheck(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to the right`,name:`right`,protected:!0,children:n.code`this.check(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to down`,name:`down`,protected:!0,children:n.code`this.uncheck(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move the cursor to up`,name:`up`,protected:!0,children:n.code`this.check(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to move to the next value`,name:`next`,protected:!0,children:n.code`this.changeValue(!this.value);
|
|
686
|
+
this.sync(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to render the prompt`,name:`onRender`,override:!0,protected:!0,returnType:`string`,children:n.code`return this.isSubmitted
|
|
2250
687
|
? textColors.prompt.input.submitted(this.value ? this.trueMessage : this.falseMessage)
|
|
2251
688
|
: this.isCancelled
|
|
2252
689
|
? textColors.prompt.input.cancelled(this.value ? this.trueMessage : this.falseMessage)
|
|
@@ -2254,24 +691,7 @@ function TogglePromptDeclarations() {
|
|
|
2254
691
|
this.value ? textColors.prompt.input.inactive(this.falseMessage) : underline(bold(textColors.prompt.input.active(this.falseMessage)))
|
|
2255
692
|
} \${borderColors.app.divider.tertiary("/")} \${
|
|
2256
693
|
this.value ? underline(bold(textColors.prompt.input.active(this.trueMessage))) : textColors.prompt.input.inactive(this.trueMessage)
|
|
2257
|
-
}\`; `
|
|
2258
|
-
})
|
|
2259
|
-
];
|
|
2260
|
-
}
|
|
2261
|
-
}),
|
|
2262
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2263
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "An object representing the configuration options for a toggle prompt, which extends the base PromptFactoryConfig with additional options specific to the toggle prompt." }),
|
|
2264
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2265
|
-
name: "ToggleConfig",
|
|
2266
|
-
"export": true,
|
|
2267
|
-
children: _alloy_js_core.code`PromptFactoryConfig<boolean> & TogglePromptConfig; `
|
|
2268
|
-
}),
|
|
2269
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2270
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2271
|
-
heading: "A function to create and run a toggle prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.",
|
|
2272
|
-
get children() {
|
|
2273
|
-
return [
|
|
2274
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { toggle, isCancel } from "shell-shock:prompts";
|
|
694
|
+
}\`; `})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`An object representing the configuration options for a toggle prompt, which extends the base PromptFactoryConfig with additional options specific to the toggle prompt.`}),(0,t.createComponent)(u.TypeDeclaration,{name:`ToggleConfig`,export:!0,children:n.code`PromptFactoryConfig<boolean> & TogglePromptConfig; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A function to create and run a toggle prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.`,get children(){return[(0,t.createComponent)(l.TSDocExample,{children:`import { toggle, isCancel } from "shell-shock:prompts";
|
|
2275
695
|
|
|
2276
696
|
async function run() {
|
|
2277
697
|
const likesIceCream = await toggle({
|
|
@@ -2285,169 +705,13 @@ async function run() {
|
|
|
2285
705
|
console.log("You" + (likesIceCream ? " like ice cream" : " don't like ice cream") + "!");
|
|
2286
706
|
}
|
|
2287
707
|
|
|
2288
|
-
run(); ` }),
|
|
2289
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2290
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2291
|
-
name: "config",
|
|
2292
|
-
children: `The configuration options to pass to the toggle prompt, which extends the base PromptFactoryConfig with additional options specific to the toggle prompt`
|
|
2293
|
-
}),
|
|
2294
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled` })
|
|
2295
|
-
];
|
|
2296
|
-
}
|
|
2297
|
-
}),
|
|
2298
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2299
|
-
name: "toggle",
|
|
2300
|
-
"export": true,
|
|
2301
|
-
parameters: [{
|
|
2302
|
-
name: "config",
|
|
2303
|
-
type: "ToggleConfig"
|
|
2304
|
-
}],
|
|
2305
|
-
returnType: "Promise<boolean | symbol>",
|
|
2306
|
-
children: _alloy_js_core.code`return new Promise<boolean | symbol>((response, reject) => {
|
|
708
|
+
run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocParam,{name:`config`,children:`The configuration options to pass to the toggle prompt, which extends the base PromptFactoryConfig with additional options specific to the toggle prompt`}),(0,t.createComponent)(l.TSDocReturns,{children:`A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled`})]}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`toggle`,export:!0,parameters:[{name:`config`,type:`ToggleConfig`}],returnType:`Promise<boolean | symbol>`,children:n.code`return new Promise<boolean | symbol>((response, reject) => {
|
|
2307
709
|
const prompt = new TogglePrompt(config);
|
|
2308
710
|
|
|
2309
711
|
prompt.on("state", state => config.onState?.(state));
|
|
2310
712
|
prompt.on("submit", value => response(value));
|
|
2311
713
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
2312
|
-
});`
|
|
2313
|
-
})
|
|
2314
|
-
];
|
|
2315
|
-
}
|
|
2316
|
-
/**
|
|
2317
|
-
* A component that renders the declarations for the built-in confirm prompt, which allows users to select a boolean value (true/false) with support for custom messages for the true and false states. This prompt type can be used for scenarios where the user needs to toggle a setting on or off, such as enabling or disabling a feature. The ConfirmPrompt class extends the base Prompt class and implements specific logic for handling boolean input and rendering interactions.
|
|
2318
|
-
*/
|
|
2319
|
-
function ConfirmPromptDeclarations() {
|
|
2320
|
-
return [
|
|
2321
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
2322
|
-
"export": true,
|
|
2323
|
-
name: "ConfirmPromptConfig",
|
|
2324
|
-
"extends": "PromptConfig<boolean>",
|
|
2325
|
-
doc: "Configuration options for creating a boolean confirm prompt",
|
|
2326
|
-
get children() {
|
|
2327
|
-
return [
|
|
2328
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2329
|
-
heading: "The message for the \\`Yes\\` state of the prompt",
|
|
2330
|
-
get children() {
|
|
2331
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2332
|
-
get type() {
|
|
2333
|
-
return _powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
2334
|
-
},
|
|
2335
|
-
defaultValue: "Yes"
|
|
2336
|
-
});
|
|
2337
|
-
}
|
|
2338
|
-
}),
|
|
2339
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2340
|
-
name: "yesMessage",
|
|
2341
|
-
optional: true,
|
|
2342
|
-
type: "string"
|
|
2343
|
-
}),
|
|
2344
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2345
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2346
|
-
heading: "The \\`Yes\\` option when choosing between yes/no",
|
|
2347
|
-
get children() {
|
|
2348
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2349
|
-
get type() {
|
|
2350
|
-
return _powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
2351
|
-
},
|
|
2352
|
-
defaultValue: "1"
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
2355
|
-
}),
|
|
2356
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2357
|
-
name: "yesOption",
|
|
2358
|
-
optional: true,
|
|
2359
|
-
type: "string"
|
|
2360
|
-
}),
|
|
2361
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2362
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2363
|
-
heading: "The message for the \\`No\\` state of the prompt",
|
|
2364
|
-
get children() {
|
|
2365
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2366
|
-
get type() {
|
|
2367
|
-
return _powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
2368
|
-
},
|
|
2369
|
-
defaultValue: "(Y/n)"
|
|
2370
|
-
});
|
|
2371
|
-
}
|
|
2372
|
-
}),
|
|
2373
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2374
|
-
name: "noMessage",
|
|
2375
|
-
optional: true,
|
|
2376
|
-
type: "string"
|
|
2377
|
-
}),
|
|
2378
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2379
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2380
|
-
heading: "The \\`No\\` option when choosing between yes/no",
|
|
2381
|
-
get children() {
|
|
2382
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2383
|
-
get type() {
|
|
2384
|
-
return _powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
2385
|
-
},
|
|
2386
|
-
defaultValue: "(y/N)"
|
|
2387
|
-
});
|
|
2388
|
-
}
|
|
2389
|
-
}),
|
|
2390
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2391
|
-
name: "noOption",
|
|
2392
|
-
optional: true,
|
|
2393
|
-
type: "string"
|
|
2394
|
-
})
|
|
2395
|
-
];
|
|
2396
|
-
}
|
|
2397
|
-
}),
|
|
2398
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2399
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
2400
|
-
"export": true,
|
|
2401
|
-
name: "ConfirmPrompt",
|
|
2402
|
-
doc: "A prompt for confirming a boolean input",
|
|
2403
|
-
"extends": "Prompt<boolean>",
|
|
2404
|
-
get children() {
|
|
2405
|
-
return [
|
|
2406
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2407
|
-
name: "initialValue",
|
|
2408
|
-
"protected": true,
|
|
2409
|
-
override: true,
|
|
2410
|
-
type: "boolean",
|
|
2411
|
-
children: _alloy_js_core.code`false; `
|
|
2412
|
-
}),
|
|
2413
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2414
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2415
|
-
name: "yesMessage",
|
|
2416
|
-
"protected": true,
|
|
2417
|
-
type: "string",
|
|
2418
|
-
children: _alloy_js_core.code`"Yes"; `
|
|
2419
|
-
}),
|
|
2420
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2421
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2422
|
-
name: "yesOption",
|
|
2423
|
-
"protected": true,
|
|
2424
|
-
type: "string",
|
|
2425
|
-
children: _alloy_js_core.code`"(Y/n)"; `
|
|
2426
|
-
}),
|
|
2427
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2428
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2429
|
-
name: "noMessage",
|
|
2430
|
-
"protected": true,
|
|
2431
|
-
type: "string",
|
|
2432
|
-
children: _alloy_js_core.code`"No"; `
|
|
2433
|
-
}),
|
|
2434
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2435
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2436
|
-
name: "noOption",
|
|
2437
|
-
"protected": true,
|
|
2438
|
-
type: "string",
|
|
2439
|
-
children: _alloy_js_core.code`"(y/N)"; `
|
|
2440
|
-
}),
|
|
2441
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2442
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2443
|
-
name: "cursorHidden",
|
|
2444
|
-
"protected": true,
|
|
2445
|
-
override: true,
|
|
2446
|
-
type: "boolean",
|
|
2447
|
-
children: _alloy_js_core.code`true; `
|
|
2448
|
-
}),
|
|
2449
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2450
|
-
_alloy_js_core.code`constructor(config: ConfirmPromptConfig) {
|
|
714
|
+
});`})]}function v(){return[(0,t.createComponent)(c.InterfaceDeclaration,{export:!0,name:`ConfirmPromptConfig`,extends:`PromptConfig<boolean>`,doc:`Configuration options for creating a boolean confirm prompt`,get children(){return[(0,t.createComponent)(l.TSDoc,{heading:"The message for the \\`Yes\\` state of the prompt",get children(){return(0,t.createComponent)(l.TSDocDefaultValue,{get type(){return i.ReflectionKind.string},defaultValue:`Yes`})}}),(0,t.createComponent)(c.InterfaceMember,{name:`yesMessage`,optional:!0,type:`string`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:"The \\`Yes\\` option when choosing between yes/no",get children(){return(0,t.createComponent)(l.TSDocDefaultValue,{get type(){return i.ReflectionKind.string},defaultValue:`1`})}}),(0,t.createComponent)(c.InterfaceMember,{name:`yesOption`,optional:!0,type:`string`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:"The message for the \\`No\\` state of the prompt",get children(){return(0,t.createComponent)(l.TSDocDefaultValue,{get type(){return i.ReflectionKind.string},defaultValue:`(Y/n)`})}}),(0,t.createComponent)(c.InterfaceMember,{name:`noMessage`,optional:!0,type:`string`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:"The \\`No\\` option when choosing between yes/no",get children(){return(0,t.createComponent)(l.TSDocDefaultValue,{get type(){return i.ReflectionKind.string},defaultValue:`(y/N)`})}}),(0,t.createComponent)(c.InterfaceMember,{name:`noOption`,optional:!0,type:`string`})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassDeclaration,{export:!0,name:`ConfirmPrompt`,doc:`A prompt for confirming a boolean input`,extends:`Prompt<boolean>`,get children(){return[(0,t.createComponent)(s.ClassField,{name:`initialValue`,protected:!0,override:!0,type:`boolean`,children:n.code`false; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`yesMessage`,protected:!0,type:`string`,children:n.code`"Yes"; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`yesOption`,protected:!0,type:`string`,children:n.code`"(Y/n)"; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`noMessage`,protected:!0,type:`string`,children:n.code`"No"; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`noOption`,protected:!0,type:`string`,children:n.code`"(y/N)"; `}),(0,t.createIntrinsic)(`hbr`,{}),(0,t.createComponent)(s.ClassField,{name:`cursorHidden`,protected:!0,override:!0,type:`boolean`,children:n.code`true; `}),(0,t.createComponent)(a.Spacing,{}),n.code`constructor(config: ConfirmPromptConfig) {
|
|
2451
715
|
super(config);
|
|
2452
716
|
|
|
2453
717
|
if (config.initialValue) {
|
|
@@ -2468,21 +732,7 @@ function ConfirmPromptDeclarations() {
|
|
|
2468
732
|
}
|
|
2469
733
|
|
|
2470
734
|
this.sync();
|
|
2471
|
-
} `,
|
|
2472
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2473
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2474
|
-
doc: "A method to handle key press events and determine the corresponding action",
|
|
2475
|
-
name: "onKeyPress",
|
|
2476
|
-
override: true,
|
|
2477
|
-
"protected": true,
|
|
2478
|
-
parameters: [{
|
|
2479
|
-
name: "char",
|
|
2480
|
-
type: "string"
|
|
2481
|
-
}, {
|
|
2482
|
-
name: "key",
|
|
2483
|
-
type: "Key"
|
|
2484
|
-
}],
|
|
2485
|
-
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
735
|
+
} `,(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to handle key press events and determine the corresponding action`,name:`onKeyPress`,override:!0,protected:!0,parameters:[{name:`char`,type:`string`},{name:`key`,type:`Key`}],children:n.code`const action = this.getAction(key);
|
|
2486
736
|
if (action && typeof (this as any)[action] === "function") {
|
|
2487
737
|
return (this as any)[action]();
|
|
2488
738
|
}
|
|
@@ -2495,37 +745,11 @@ function ConfirmPromptDeclarations() {
|
|
|
2495
745
|
return this.submit();
|
|
2496
746
|
} else {
|
|
2497
747
|
return this.bell();
|
|
2498
|
-
} `
|
|
2499
|
-
}),
|
|
2500
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2501
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2502
|
-
doc: "A method to render the prompt",
|
|
2503
|
-
name: "onRender",
|
|
2504
|
-
override: true,
|
|
2505
|
-
"protected": true,
|
|
2506
|
-
returnType: "string",
|
|
2507
|
-
children: _alloy_js_core.code`return this.isSubmitted
|
|
748
|
+
} `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.ClassMethod,{doc:`A method to render the prompt`,name:`onRender`,override:!0,protected:!0,returnType:`string`,children:n.code`return this.isSubmitted
|
|
2508
749
|
? textColors.prompt.input.submitted(this.value ? this.yesMessage : this.noMessage)
|
|
2509
750
|
: this.isCancelled
|
|
2510
751
|
? textColors.prompt.input.cancelled(this.value ? this.yesMessage : this.noMessage)
|
|
2511
|
-
: textColors.prompt.input.inactive(this.initialValue ? this.yesOption : this.noOption); `
|
|
2512
|
-
})
|
|
2513
|
-
];
|
|
2514
|
-
}
|
|
2515
|
-
}),
|
|
2516
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2517
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "An object representing the configuration options for a confirm prompt, which extends the base PromptFactoryConfig with additional options specific to the confirm prompt." }),
|
|
2518
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2519
|
-
name: "ConfirmConfig",
|
|
2520
|
-
"export": true,
|
|
2521
|
-
children: _alloy_js_core.code`PromptFactoryConfig<boolean> & ConfirmPromptConfig; `
|
|
2522
|
-
}),
|
|
2523
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2524
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2525
|
-
heading: "A function to create and run a confirm prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.",
|
|
2526
|
-
get children() {
|
|
2527
|
-
return [
|
|
2528
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { confirm, isCancel } from "shell-shock:prompts";
|
|
752
|
+
: textColors.prompt.input.inactive(this.initialValue ? this.yesOption : this.noOption); `})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`An object representing the configuration options for a confirm prompt, which extends the base PromptFactoryConfig with additional options specific to the confirm prompt.`}),(0,t.createComponent)(u.TypeDeclaration,{name:`ConfirmConfig`,export:!0,children:n.code`PromptFactoryConfig<boolean> & ConfirmPromptConfig; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A function to create and run a confirm prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.`,get children(){return[(0,t.createComponent)(l.TSDocExample,{children:`import { confirm, isCancel } from "shell-shock:prompts";
|
|
2529
753
|
|
|
2530
754
|
async function run() {
|
|
2531
755
|
const likesIceCream = await confirm({
|
|
@@ -2539,65 +763,13 @@ async function run() {
|
|
|
2539
763
|
console.log("You" + (likesIceCream ? " like ice cream" : " don't like ice cream") + "!");
|
|
2540
764
|
}
|
|
2541
765
|
|
|
2542
|
-
run(); ` }),
|
|
2543
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2544
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2545
|
-
name: "config",
|
|
2546
|
-
children: `The configuration options to pass to the confirm prompt, which extends the base PromptFactoryConfig with additional options specific to the confirm prompt`
|
|
2547
|
-
}),
|
|
2548
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled` })
|
|
2549
|
-
];
|
|
2550
|
-
}
|
|
2551
|
-
}),
|
|
2552
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2553
|
-
name: "confirm",
|
|
2554
|
-
"export": true,
|
|
2555
|
-
parameters: [{
|
|
2556
|
-
name: "config",
|
|
2557
|
-
type: "ConfirmConfig"
|
|
2558
|
-
}],
|
|
2559
|
-
returnType: "Promise<boolean | symbol>",
|
|
2560
|
-
children: _alloy_js_core.code`return new Promise<boolean | symbol>((response, reject) => {
|
|
766
|
+
run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocParam,{name:`config`,children:`The configuration options to pass to the confirm prompt, which extends the base PromptFactoryConfig with additional options specific to the confirm prompt`}),(0,t.createComponent)(l.TSDocReturns,{children:`A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled`})]}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`confirm`,export:!0,parameters:[{name:`config`,type:`ConfirmConfig`}],returnType:`Promise<boolean | symbol>`,children:n.code`return new Promise<boolean | symbol>((response, reject) => {
|
|
2561
767
|
const prompt = new ConfirmPrompt(config);
|
|
2562
768
|
|
|
2563
769
|
prompt.on("state", state => config.onState?.(state));
|
|
2564
770
|
prompt.on("submit", value => response(value));
|
|
2565
771
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
2566
|
-
}); `
|
|
2567
|
-
})
|
|
2568
|
-
];
|
|
2569
|
-
}
|
|
2570
|
-
/**
|
|
2571
|
-
* Declarations for a password prompt that allows users to input and edit text, with support for cursor movement, deletion, and custom masking. This prompt type can be used for various text input scenarios, such as entering a password or any other string input. The PasswordPrompt class extends the base Prompt class and implements specific logic for handling password input and editing interactions.
|
|
2572
|
-
*/
|
|
2573
|
-
function PasswordPromptDeclaration() {
|
|
2574
|
-
return [
|
|
2575
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2576
|
-
"export": true,
|
|
2577
|
-
name: "passwordMask",
|
|
2578
|
-
doc: "A built-in prompt mask function that masks input with asterisks",
|
|
2579
|
-
parameters: [{
|
|
2580
|
-
name: "input",
|
|
2581
|
-
type: "string"
|
|
2582
|
-
}],
|
|
2583
|
-
returnType: "string",
|
|
2584
|
-
children: _alloy_js_core.code`return "*".repeat(input.length); `
|
|
2585
|
-
}),
|
|
2586
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2587
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "An object representing the configuration options for a password prompt, which extends the base PromptFactoryConfig with additional options specific to password prompts." }),
|
|
2588
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2589
|
-
name: "PasswordConfig",
|
|
2590
|
-
"export": true,
|
|
2591
|
-
children: _alloy_js_core.code`Omit<TextConfig, "mask" | "maskCompleted">; `
|
|
2592
|
-
}),
|
|
2593
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2594
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2595
|
-
heading: "A function to create and run a password prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.",
|
|
2596
|
-
get children() {
|
|
2597
|
-
return [
|
|
2598
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: _alloy_js_core.code`This function creates an instance of the TextPrompt class with the provided configuration options and a custom mask function to handle password input. It sets up event listeners for state updates, submission, and cancellation to handle the prompt interactions and return the appropriate results. The password prompt allows users to input text that is masked for privacy, making it suitable for scenarios like entering passwords or sensitive information.` }),
|
|
2599
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2600
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { password, isCancel } from "shell-shock:prompts";
|
|
772
|
+
}); `})]}function y(){return[(0,t.createComponent)(r.FunctionDeclaration,{export:!0,name:`passwordMask`,doc:`A built-in prompt mask function that masks input with asterisks`,parameters:[{name:`input`,type:`string`}],returnType:`string`,children:n.code`return "*".repeat(input.length); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`An object representing the configuration options for a password prompt, which extends the base PromptFactoryConfig with additional options specific to password prompts.`}),(0,t.createComponent)(u.TypeDeclaration,{name:`PasswordConfig`,export:!0,children:n.code`Omit<TextConfig, "mask" | "maskCompleted">; `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDoc,{heading:`A function to create and run a password prompt, which returns a promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.`,get children(){return[(0,t.createComponent)(l.TSDocRemarks,{children:n.code`This function creates an instance of the TextPrompt class with the provided configuration options and a custom mask function to handle password input. It sets up event listeners for state updates, submission, and cancellation to handle the prompt interactions and return the appropriate results. The password prompt allows users to input text that is masked for privacy, making it suitable for scenarios like entering passwords or sensitive information.`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocExample,{children:`import { password, isCancel } from "shell-shock:prompts";
|
|
2601
773
|
|
|
2602
774
|
async function run() {
|
|
2603
775
|
const userPassword = await password({
|
|
@@ -2611,63 +783,18 @@ async function run() {
|
|
|
2611
783
|
console.log("You entered a password!");
|
|
2612
784
|
}
|
|
2613
785
|
|
|
2614
|
-
run(); ` }),
|
|
2615
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2616
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2617
|
-
name: "config",
|
|
2618
|
-
children: `The configuration options to pass to the password prompt, which extends the base PromptConfig with additional options specific to password prompts`
|
|
2619
|
-
}),
|
|
2620
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled` })
|
|
2621
|
-
];
|
|
2622
|
-
}
|
|
2623
|
-
}),
|
|
2624
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2625
|
-
name: "password",
|
|
2626
|
-
"export": true,
|
|
2627
|
-
parameters: [{
|
|
2628
|
-
name: "config",
|
|
2629
|
-
type: "PasswordConfig"
|
|
2630
|
-
}],
|
|
2631
|
-
returnType: "Promise<string | symbol>",
|
|
2632
|
-
children: _alloy_js_core.code`return text({
|
|
786
|
+
run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocParam,{name:`config`,children:`The configuration options to pass to the password prompt, which extends the base PromptConfig with additional options specific to password prompts`}),(0,t.createComponent)(l.TSDocReturns,{children:`A promise that resolves with the submitted value or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled`})]}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`password`,export:!0,parameters:[{name:`config`,type:`PasswordConfig`}],returnType:`Promise<string | symbol>`,children:n.code`return text({
|
|
2633
787
|
...config,
|
|
2634
788
|
mask: passwordMask,
|
|
2635
789
|
maskCompleted: () => "*******"
|
|
2636
|
-
});`
|
|
2637
|
-
})
|
|
2638
|
-
];
|
|
2639
|
-
}
|
|
2640
|
-
function WaitForKeyPressDeclaration() {
|
|
2641
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2642
|
-
heading: "A function to create and run a wait-for-key-press prompt, which returns a promise that resolves when any key is pressed or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.",
|
|
2643
|
-
get children() {
|
|
2644
|
-
return [
|
|
2645
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: _alloy_js_core.code`This function creates an instance of the Prompt class with a custom onKeyPress handler that resolves the promise when any key is pressed. It sets up event listeners for state updates and cancellation to handle the prompt interactions and return the appropriate results. The wait-for-key-press prompt is useful for scenarios where you want to pause execution until the user presses any key, such as waiting for user input before proceeding with a task.` }),
|
|
2646
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2647
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { waitForKeyPress } from "shell-shock:prompts";
|
|
790
|
+
});`})]}function b(){return[(0,t.createComponent)(l.TSDoc,{heading:`A function to create and run a wait-for-key-press prompt, which returns a promise that resolves when any key is pressed or rejects with a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.`,get children(){return[(0,t.createComponent)(l.TSDocRemarks,{children:n.code`This function creates an instance of the Prompt class with a custom onKeyPress handler that resolves the promise when any key is pressed. It sets up event listeners for state updates and cancellation to handle the prompt interactions and return the appropriate results. The wait-for-key-press prompt is useful for scenarios where you want to pause execution until the user presses any key, such as waiting for user input before proceeding with a task.`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocExample,{children:`import { waitForKeyPress } from "shell-shock:prompts";
|
|
2648
791
|
|
|
2649
792
|
async function run() {
|
|
2650
793
|
const result = await waitForKeyPress();
|
|
2651
794
|
console.log("A key was pressed!");
|
|
2652
795
|
}
|
|
2653
796
|
|
|
2654
|
-
run(); ` }),
|
|
2655
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2656
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2657
|
-
name: "timeout",
|
|
2658
|
-
children: `The amount of time in milliseconds to wait before automatically resolving the prompt, defaults to 2 hours (7200000 ms)`
|
|
2659
|
-
}),
|
|
2660
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A promise that resolves when any key is pressed` })
|
|
2661
|
-
];
|
|
2662
|
-
}
|
|
2663
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2664
|
-
name: "waitForKeyPress",
|
|
2665
|
-
"export": true,
|
|
2666
|
-
parameters: [{
|
|
2667
|
-
name: "timeout",
|
|
2668
|
-
default: "7200000"
|
|
2669
|
-
}],
|
|
2670
|
-
children: _alloy_js_core.code`process.stdin.setRawMode(true);
|
|
797
|
+
run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocParam,{name:`timeout`,children:`The amount of time in milliseconds to wait before automatically resolving the prompt, defaults to 2 hours (7200000 ms)`}),(0,t.createComponent)(l.TSDocReturns,{children:`A promise that resolves when any key is pressed`})]}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`waitForKeyPress`,export:!0,parameters:[{name:`timeout`,default:`7200000`}],children:n.code`process.stdin.setRawMode(true);
|
|
2671
798
|
return new Promise(resolve => process.stdin.once("data", () => {
|
|
2672
799
|
if (timeout >= 0) {
|
|
2673
800
|
setTimeout(() => {
|
|
@@ -2678,93 +805,4 @@ run(); ` }),
|
|
|
2678
805
|
|
|
2679
806
|
process.stdin.setRawMode(false);
|
|
2680
807
|
resolve(void 0);
|
|
2681
|
-
})); `
|
|
2682
|
-
})];
|
|
2683
|
-
}
|
|
2684
|
-
/**
|
|
2685
|
-
* A built-in prompts module for Shell Shock.
|
|
2686
|
-
*/
|
|
2687
|
-
function PromptsBuiltin(props) {
|
|
2688
|
-
const [{ children }, rest] = (0, _alloy_js_core.splitProps)(props, ["children"]);
|
|
2689
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
2690
|
-
id: "prompts",
|
|
2691
|
-
description: "A collection of prompts that allow for interactive input in command-line applications."
|
|
2692
|
-
}, rest, {
|
|
2693
|
-
get imports() {
|
|
2694
|
-
return (0, defu.default)(rest.imports ?? {}, {
|
|
2695
|
-
"node:events": "EventEmitter",
|
|
2696
|
-
"node:readline": [
|
|
2697
|
-
"Interface",
|
|
2698
|
-
"Key",
|
|
2699
|
-
"createInterface",
|
|
2700
|
-
"emitKeypressEvents"
|
|
2701
|
-
]
|
|
2702
|
-
});
|
|
2703
|
-
},
|
|
2704
|
-
get builtinImports() {
|
|
2705
|
-
return (0, defu.default)(rest.builtinImports ?? {}, {
|
|
2706
|
-
console: [
|
|
2707
|
-
"erase",
|
|
2708
|
-
"beep",
|
|
2709
|
-
"cursor",
|
|
2710
|
-
"textColors",
|
|
2711
|
-
"borderColors",
|
|
2712
|
-
"bold",
|
|
2713
|
-
"italic",
|
|
2714
|
-
"underline",
|
|
2715
|
-
"strikethrough",
|
|
2716
|
-
"clear",
|
|
2717
|
-
"stripAnsi",
|
|
2718
|
-
"splitText",
|
|
2719
|
-
"error"
|
|
2720
|
-
],
|
|
2721
|
-
env: [
|
|
2722
|
-
"env",
|
|
2723
|
-
"isCI",
|
|
2724
|
-
"isTest",
|
|
2725
|
-
"isWindows",
|
|
2726
|
-
"isDevelopment",
|
|
2727
|
-
"isDebug"
|
|
2728
|
-
]
|
|
2729
|
-
});
|
|
2730
|
-
},
|
|
2731
|
-
get children() {
|
|
2732
|
-
return [
|
|
2733
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2734
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(BasePromptDeclarations, {}),
|
|
2735
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2736
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(TextPromptDeclarations, {}),
|
|
2737
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2738
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(SelectPromptDeclarations, {}),
|
|
2739
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2740
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(NumericPromptDeclarations, {}),
|
|
2741
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2742
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(TogglePromptDeclarations, {}),
|
|
2743
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2744
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(PasswordPromptDeclaration, {}),
|
|
2745
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2746
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(ConfirmPromptDeclarations, {}),
|
|
2747
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2748
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(WaitForKeyPressDeclaration, {}),
|
|
2749
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2750
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
2751
|
-
get when() {
|
|
2752
|
-
return Boolean(children);
|
|
2753
|
-
},
|
|
2754
|
-
children
|
|
2755
|
-
})
|
|
2756
|
-
];
|
|
2757
|
-
}
|
|
2758
|
-
}));
|
|
2759
|
-
}
|
|
2760
|
-
|
|
2761
|
-
//#endregion
|
|
2762
|
-
exports.BasePromptDeclarations = BasePromptDeclarations;
|
|
2763
|
-
exports.ConfirmPromptDeclarations = ConfirmPromptDeclarations;
|
|
2764
|
-
exports.NumericPromptDeclarations = NumericPromptDeclarations;
|
|
2765
|
-
exports.PasswordPromptDeclaration = PasswordPromptDeclaration;
|
|
2766
|
-
exports.PromptsBuiltin = PromptsBuiltin;
|
|
2767
|
-
exports.SelectPromptDeclarations = SelectPromptDeclarations;
|
|
2768
|
-
exports.TextPromptDeclarations = TextPromptDeclarations;
|
|
2769
|
-
exports.TogglePromptDeclarations = TogglePromptDeclarations;
|
|
2770
|
-
exports.WaitForKeyPressDeclaration = WaitForKeyPressDeclaration;
|
|
808
|
+
})); `})]}function x(e){let[{children:r},i]=(0,n.splitProps)(e,[`children`]);return(0,t.createComponent)(o.BuiltinFile,(0,t.mergeProps)({id:`prompts`,description:`A collection of prompts that allow for interactive input in command-line applications.`},i,{get imports(){return(0,f.default)(i.imports??{},{"node:events":`EventEmitter`,"node:readline":[`Interface`,`Key`,`createInterface`,`emitKeypressEvents`]})},get builtinImports(){return(0,f.default)(i.builtinImports??{},{console:[`erase`,`beep`,`cursor`,`textColors`,`borderColors`,`bold`,`italic`,`underline`,`strikethrough`,`clear`,`stripAnsi`,`splitText`,`error`],env:[`env`,`isCI`,`isTest`,`isWindows`,`isDevelopment`,`isDebug`]})},get children(){return[(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(p,{}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(m,{}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(h,{}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(g,{}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(_,{}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(y,{}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(v,{}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(b,{}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(n.Show,{get when(){return!!r},children:r})]}}))}exports.BasePromptDeclarations=p,exports.ConfirmPromptDeclarations=v,exports.NumericPromptDeclarations=g,exports.PasswordPromptDeclaration=y,exports.PromptsBuiltin=x,exports.SelectPromptDeclarations=h,exports.TextPromptDeclarations=m,exports.TogglePromptDeclarations=_,exports.WaitForKeyPressDeclaration=b;
|