@shell-shock/plugin-prompts 0.3.49 → 0.3.51

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.
@@ -1,4 +1,404 @@
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>) {
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>) {
2
402
  super();
3
403
 
4
404
  if (config.input) {
@@ -55,7 +455,49 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
55
455
 
56
456
  [Symbol.dispose]() {
57
457
  this.close();
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 \${
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 \${
59
501
  italic(
60
502
  this.isError
61
503
  ? textColors.prompt.description.error(splitText(this.errorMessage, "3/4").join("\\n"))
@@ -65,7 +507,34 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
65
507
  ? textColors.prompt.description.active(splitText(this.description, "3/4").join("\\n"))
66
508
  : ""
67
509
  )
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;
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;
69
538
 
70
539
  let updatedValue = value;
71
540
  if (value === undefined || value === "") {
@@ -86,7 +555,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
86
555
  Promise.resolve(this.checkValidations(updatedValue)).then(() => this.sync());
87
556
  }, 0);
88
557
 
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", {
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", {
90
566
  value: this.value,
91
567
  errorMessage: this.errorMessage,
92
568
  isError: this.isError,
@@ -94,7 +570,22 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
94
570
  isCancelled: this.isCancelled,
95
571
  isCompleted: this.isCompleted
96
572
  });
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
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
98
589
  ? textColors.prompt.input.disabled(this.displayValue)
99
590
  : this.isError
100
591
  ? textColors.prompt.input.error(this.displayValue)
@@ -102,12 +593,45 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
102
593
  ? textColors.prompt.input.submitted(this.maskCompleted(this.displayValue))
103
594
  : this.isCancelled
104
595
  ? textColors.prompt.input.cancelled(this.maskCompleted(this.displayValue))
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);
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);
106
622
  if (!action) {
107
623
  this.bell();
108
624
  } else if (typeof (this as any)[action] === "function") {
109
625
  (this as any)[action](key);
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) {
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) {
111
635
  return;
112
636
  }
113
637
 
@@ -120,14 +644,38 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
120
644
 
121
645
  this.#readline.close();
122
646
  this.emit(this.isSubmitted ? "submit" : "cancel", this.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);
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);
124
660
  if (typeof result === "string") {
125
661
  this.errorMessage = result;
126
662
  } else if (typeof result === "boolean") {
127
663
  this.errorMessage = result ? null : this.defaultErrorMessage;
128
664
  } else {
129
665
  this.errorMessage = null;
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") {
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") {
131
679
  return false;
132
680
  }
133
681
 
@@ -157,7 +705,18 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
157
705
  if (key.name === "right") action = "right";
158
706
  if (key.name === "left") action = "left";
159
707
 
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) {
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) {
161
720
  this.cursor = 0;
162
721
  } else if (this.cursor + count > this.displayValue.length) {
163
722
  this.cursor = this.displayValue.length;
@@ -165,7 +724,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
165
724
  this.cursor += count;
166
725
  }
167
726
 
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) {
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) {
169
735
  return this.bell();
170
736
  }
171
737
 
@@ -183,7 +749,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
183
749
 
184
750
  this.moveCursor(isCursorAtEnd ? -1 : -2);
185
751
 
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) {
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) {
187
760
  return this.bell();
188
761
  }
189
762
 
@@ -197,20 +770,42 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
197
770
  this.moveCursor(-1);
198
771
  }
199
772
 
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);
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);
201
781
  this.cursor = 0;
202
782
 
203
783
  this.errorMessage = null;
204
784
  this.isCancelled = false;
205
785
  this.isSubmitted = false;
206
786
 
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;
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;
208
795
  this.isCancelled = true;
209
796
  this.isSubmitted = false;
210
797
 
211
798
  this.sync();
212
799
  this.output.write("\\n");
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;
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;
214
809
 
215
810
  await this.checkValidations(this.value);
216
811
  if (this.isError) {
@@ -223,7 +818,15 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
223
818
  this.sync();
224
819
  this.output.write("\\n");
225
820
  this.close();
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) {
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) {
227
830
  return;
228
831
  }
229
832
 
@@ -244,12 +847,12 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
244
847
 
245
848
  this.consoleOutput = \` \${
246
849
  this.isSubmitted
247
- ? textColors.prompt.icon.submitted("${e.icons.prompt.submitted}")
850
+ ? textColors.prompt.icon.submitted("${theme.icons.prompt.submitted}")
248
851
  : this.isCancelled
249
- ? textColors.prompt.icon.cancelled("${e.icons.prompt.cancelled}")
852
+ ? textColors.prompt.icon.cancelled("${theme.icons.prompt.cancelled}")
250
853
  : this.isError
251
- ? textColors.prompt.icon.error("${e.icons.prompt.error}")
252
- : textColors.prompt.icon.active("${e.icons.prompt.active}")
854
+ ? textColors.prompt.icon.error("${theme.icons.prompt.error}")
855
+ : textColors.prompt.icon.active("${theme.icons.prompt.active}")
253
856
  } \${
254
857
  this.isCompleted
255
858
  ? textColors.prompt.message.submitted(this.message)
@@ -272,7 +875,22 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
272
875
  this.consoleStatus = this.status;
273
876
  } finally {
274
877
  clearTimeout(timeout);
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) {
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) {
276
894
  return;
277
895
  }
278
896
 
@@ -280,7 +898,124 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
280
898
  this.#isKeyPressed = true;
281
899
  }
282
900
 
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) {
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) {
284
1019
  super(config);
285
1020
 
286
1021
  if (config.initialValue) {
@@ -294,7 +1029,21 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
294
1029
  this.cursor = 0;
295
1030
  this.sync();
296
1031
  this.last();
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);
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);
298
1047
  if (action && typeof (this as any)[action] === "function") {
299
1048
  return (this as any)[action]();
300
1049
  }
@@ -308,24 +1057,97 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
308
1057
  }\${char}\${
309
1058
  this.displayValue.slice(this.cursor)
310
1059
  }\`);
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);
1060
+ this.sync(); `
1061
+ }),
1062
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1063
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
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);
315
1100
  this.cursor = this.displayValue.length;
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) {
1101
+ this.sync(); `
1102
+ }),
1103
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
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) {
319
1125
  return this.bell();
320
1126
  }
321
1127
 
322
1128
  this.moveCursor(-1);
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) {
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) {
324
1137
  return this.bell();
325
1138
  }
326
1139
 
327
1140
  this.moveCursor(1);
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
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
329
1151
  ? textColors.prompt.input.disabled(this.displayValue)
330
1152
  : this.#isInvalid
331
1153
  ? textColors.prompt.input.error(this.displayValue)
@@ -333,7 +1155,25 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
333
1155
  ? textColors.prompt.input.submitted(this.displayValue)
334
1156
  : this.isCancelled
335
1157
  ? textColors.prompt.input.cancelled(this.displayValue)
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";
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";
337
1177
 
338
1178
  async function run() {
339
1179
  const name = await text({
@@ -349,13 +1189,202 @@ async function run() {
349
1189
  console.log("Hello, " + name + "!");
350
1190
  }
351
1191
 
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) => {
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) => {
353
1211
  const prompt = new StringPrompt(config);
354
1212
 
355
1213
  prompt.on("state", state => config.onState?.(state));
356
1214
  prompt.on("submit", value => response(value));
357
1215
  prompt.on("cancel", event => response(CANCEL_SYMBOL));
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>) {
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>) {
359
1388
  super(config);
360
1389
 
361
1390
  if (config.initialValue) {
@@ -400,37 +1429,136 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
400
1429
  }
401
1430
 
402
1431
  this.sync();
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);
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);
404
1453
  if (!action) {
405
1454
  if (key.name === "j") action = "down";
406
1455
  if (key.name === "k") action = "up";
407
1456
  }
408
1457
 
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) {
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) {
411
1477
  await super.submit();
412
1478
  } else {
413
1479
  this.bell();
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;
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;
416
1501
 
417
1502
  this.changeValue(this.options[count]!.value);
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) {
1503
+ this.sync(); `
1504
+ }),
1505
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1506
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
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) {
422
1535
  this.moveCursor(this.options.length - 1);
423
1536
  } else {
424
1537
  this.moveCursor(this.cursor - 1);
425
1538
  }
426
1539
 
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) {
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) {
428
1548
  this.moveCursor(0);
429
1549
  } else {
430
1550
  this.moveCursor(this.cursor + 1);
431
1551
  }
432
1552
 
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;
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;
434
1562
 
435
1563
  const startIndex = Math.max(Math.min(this.options.length - this.optionsPerPage, this.cursor - Math.floor(this.optionsPerPage / 2)), 0);
436
1564
  const endIndex = Math.min(startIndex + this.optionsPerPage, this.options.length);
@@ -482,7 +1610,29 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
482
1610
  output += super.onRender();
483
1611
  }
484
1612
 
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";
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";
486
1636
 
487
1637
  async function run() {
488
1638
  const color = await select({
@@ -504,13 +1654,148 @@ async function run() {
504
1654
  console.log("Your favorite color is " + color + "!");
505
1655
  }
506
1656
 
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) => {
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) => {
508
1676
  const prompt = new SelectPrompt(config);
509
1677
 
510
1678
  prompt.on("state", state => config.onState?.(state));
511
1679
  prompt.on("submit", value => response(value));
512
1680
  prompt.on("cancel", event => response(CANCEL_SYMBOL));
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) {
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) {
514
1799
  super(config);
515
1800
 
516
1801
  if (config.initialValue) {
@@ -550,7 +1835,21 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
550
1835
  this.cursor = 0;
551
1836
  this.sync();
552
1837
  this.last();
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);
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);
554
1853
  if (action && typeof (this as any)[action] === "function") {
555
1854
  return (this as any)[action]();
556
1855
  }
@@ -578,10 +1877,45 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
578
1877
  }
579
1878
 
580
1879
  this.changeValue(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;
1880
+ this.sync(); `
1881
+ }),
1882
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1883
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
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;
585
1919
  if (this.isPlaceholder) {
586
1920
  value = this.min < 0 ? 0 : this.min;
587
1921
  } else if (value >= this.max) {
@@ -591,7 +1925,14 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
591
1925
  this.changeValue(value + this.increment);
592
1926
 
593
1927
  this.sync();
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;
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;
595
1936
  if (this.isPlaceholder) {
596
1937
  value = this.min < 0 ? 0 : this.min;
597
1938
  } else if (value <= this.min) {
@@ -600,19 +1941,56 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
600
1941
 
601
1942
  this.changeValue(value === this.min ? this.min : value - this.increment);
602
1943
  this.sync();
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) {
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) {
604
1952
  return this.bell();
605
1953
  }
606
1954
 
607
1955
  this.moveCursor(-1);
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) {
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) {
609
1964
  return this.bell();
610
1965
  }
611
1966
 
612
1967
  this.moveCursor(1);
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
1968
+ this.sync(); `
1969
+ }),
1970
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
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
616
1994
  ? textColors.prompt.input.disabled(this.displayValue)
617
1995
  : this.#isInvalid
618
1996
  ? textColors.prompt.input.error(this.displayValue)
@@ -620,7 +1998,24 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
620
1998
  ? textColors.prompt.input.submitted(this.displayValue)
621
1999
  : this.isCancelled
622
2000
  ? textColors.prompt.input.cancelled(this.displayValue)
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";
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";
624
2019
 
625
2020
  async function run() {
626
2021
  const age = await numeric({
@@ -636,13 +2031,102 @@ async function run() {
636
2031
  console.log("Your age is " + age + "!");
637
2032
  }
638
2033
 
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) => {
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) => {
640
2053
  const prompt = new NumberPrompt(config);
641
2054
 
642
2055
  prompt.on("state", state => config.onState?.(state));
643
2056
  prompt.on("submit", value => response(value));
644
2057
  prompt.on("cancel", event => response(CANCEL_SYMBOL));
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) {
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) {
646
2130
  super(config);
647
2131
 
648
2132
  if (config.initialValue) {
@@ -657,17 +2141,45 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
657
2141
  }
658
2142
 
659
2143
  this.sync();
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) {
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) {
661
2151
  return this.bell();
662
2152
  }
663
2153
 
664
2154
  this.changeValue(true);
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) {
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) {
666
2163
  return this.bell();
667
2164
  }
668
2165
 
669
2166
  this.changeValue(false);
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);
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);
671
2183
  if (action && typeof (this as any)[action] === "function") {
672
2184
  return (this as any)[action]();
673
2185
  }
@@ -682,8 +2194,59 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
682
2194
  return this.bell();
683
2195
  }
684
2196
 
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
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
687
2250
  ? textColors.prompt.input.submitted(this.value ? this.trueMessage : this.falseMessage)
688
2251
  : this.isCancelled
689
2252
  ? textColors.prompt.input.cancelled(this.value ? this.trueMessage : this.falseMessage)
@@ -691,7 +2254,24 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
691
2254
  this.value ? textColors.prompt.input.inactive(this.falseMessage) : underline(bold(textColors.prompt.input.active(this.falseMessage)))
692
2255
  } \${borderColors.app.divider.tertiary("/")} \${
693
2256
  this.value ? underline(bold(textColors.prompt.input.active(this.trueMessage))) : textColors.prompt.input.inactive(this.trueMessage)
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";
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";
695
2275
 
696
2276
  async function run() {
697
2277
  const likesIceCream = await toggle({
@@ -705,13 +2285,169 @@ async function run() {
705
2285
  console.log("You" + (likesIceCream ? " like ice cream" : " don't like ice cream") + "!");
706
2286
  }
707
2287
 
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) => {
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) => {
709
2307
  const prompt = new TogglePrompt(config);
710
2308
 
711
2309
  prompt.on("state", state => config.onState?.(state));
712
2310
  prompt.on("submit", value => response(value));
713
2311
  prompt.on("cancel", event => response(CANCEL_SYMBOL));
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) {
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) {
715
2451
  super(config);
716
2452
 
717
2453
  if (config.initialValue) {
@@ -732,7 +2468,21 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
732
2468
  }
733
2469
 
734
2470
  this.sync();
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);
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);
736
2486
  if (action && typeof (this as any)[action] === "function") {
737
2487
  return (this as any)[action]();
738
2488
  }
@@ -745,11 +2495,37 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
745
2495
  return this.submit();
746
2496
  } else {
747
2497
  return this.bell();
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
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
749
2508
  ? textColors.prompt.input.submitted(this.value ? this.yesMessage : this.noMessage)
750
2509
  : this.isCancelled
751
2510
  ? textColors.prompt.input.cancelled(this.value ? this.yesMessage : this.noMessage)
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";
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";
753
2529
 
754
2530
  async function run() {
755
2531
  const likesIceCream = await confirm({
@@ -763,13 +2539,65 @@ async function run() {
763
2539
  console.log("You" + (likesIceCream ? " like ice cream" : " don't like ice cream") + "!");
764
2540
  }
765
2541
 
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) => {
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) => {
767
2561
  const prompt = new ConfirmPrompt(config);
768
2562
 
769
2563
  prompt.on("state", state => config.onState?.(state));
770
2564
  prompt.on("submit", value => response(value));
771
2565
  prompt.on("cancel", event => response(CANCEL_SYMBOL));
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";
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";
773
2601
 
774
2602
  async function run() {
775
2603
  const userPassword = await password({
@@ -783,18 +2611,63 @@ async function run() {
783
2611
  console.log("You entered a password!");
784
2612
  }
785
2613
 
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({
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({
787
2633
  ...config,
788
2634
  mask: passwordMask,
789
2635
  maskCompleted: () => "*******"
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";
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";
791
2648
 
792
2649
  async function run() {
793
2650
  const result = await waitForKeyPress();
794
2651
  console.log("A key was pressed!");
795
2652
  }
796
2653
 
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);
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);
798
2671
  return new Promise(resolve => process.stdin.once("data", () => {
799
2672
  if (timeout >= 0) {
800
2673
  setTimeout(() => {
@@ -805,4 +2678,93 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
805
2678
 
806
2679
  process.stdin.setRawMode(false);
807
2680
  resolve(void 0);
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;
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;