@shell-shock/plugin-prompts 0.3.49 → 0.3.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/components/index.cjs +13 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +3 -1
- package/dist/components/prompts-builtin.cjs +2446 -80
- package/dist/components/prompts-builtin.d.cts +14 -11
- package/dist/components/prompts-builtin.d.cts.map +1 -1
- package/dist/components/prompts-builtin.d.mts +14 -11
- package/dist/components/prompts-builtin.d.mts.map +1 -1
- package/dist/components/prompts-builtin.mjs +2434 -80
- package/dist/components/prompts-builtin.mjs.map +1 -1
- package/dist/index.cjs +30 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +26 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +12 -12
|
@@ -1,4 +1,402 @@
|
|
|
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_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
7
|
+
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
8
|
+
let _powerlines_plugin_alloy_typescript_components_class_declaration = require("@powerlines/plugin-alloy/typescript/components/class-declaration");
|
|
9
|
+
let _powerlines_plugin_alloy_typescript_components_interface_declaration = require("@powerlines/plugin-alloy/typescript/components/interface-declaration");
|
|
10
|
+
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
11
|
+
let _powerlines_plugin_alloy_typescript_components_type_declaration = require("@powerlines/plugin-alloy/typescript/components/type-declaration");
|
|
12
|
+
let _shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
|
|
13
|
+
let defu = require("defu");
|
|
14
|
+
defu = require_runtime.__toESM(defu);
|
|
15
|
+
|
|
16
|
+
//#region src/components/prompts-builtin.tsx
|
|
17
|
+
/**
|
|
18
|
+
* 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.
|
|
19
|
+
*/
|
|
20
|
+
function BasePromptDeclarations() {
|
|
21
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
22
|
+
return [
|
|
23
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
24
|
+
"export": true,
|
|
25
|
+
name: "PromptParser",
|
|
26
|
+
typeParameters: [{
|
|
27
|
+
name: "TValue",
|
|
28
|
+
default: "string"
|
|
29
|
+
}],
|
|
30
|
+
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.",
|
|
31
|
+
children: _alloy_js_core.code`(this: Prompt<TValue>, input: string) => TValue; `
|
|
32
|
+
}),
|
|
33
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
34
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
35
|
+
"export": true,
|
|
36
|
+
name: "PromptFormatter",
|
|
37
|
+
typeParameters: [{
|
|
38
|
+
name: "TValue",
|
|
39
|
+
default: "string"
|
|
40
|
+
}],
|
|
41
|
+
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.",
|
|
42
|
+
children: _alloy_js_core.code`(this: Prompt<TValue>, input: TValue) => string; `
|
|
43
|
+
}),
|
|
44
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
45
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
46
|
+
"export": true,
|
|
47
|
+
name: "noMask",
|
|
48
|
+
doc: "A built-in prompt mask function that just returns the input as is, making it invisible",
|
|
49
|
+
parameters: [{
|
|
50
|
+
name: "input",
|
|
51
|
+
type: "string"
|
|
52
|
+
}],
|
|
53
|
+
returnType: "string",
|
|
54
|
+
children: _alloy_js_core.code`return input; `
|
|
55
|
+
}),
|
|
56
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
57
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
58
|
+
"export": true,
|
|
59
|
+
name: "invisibleMask",
|
|
60
|
+
doc: "A built-in prompt mask function that makes input invisible",
|
|
61
|
+
parameters: [{
|
|
62
|
+
name: "input",
|
|
63
|
+
type: "string"
|
|
64
|
+
}],
|
|
65
|
+
returnType: "string",
|
|
66
|
+
children: _alloy_js_core.code`return " ".repeat(input.length); `
|
|
67
|
+
}),
|
|
68
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
69
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
70
|
+
"export": true,
|
|
71
|
+
name: "PromptState",
|
|
72
|
+
doc: "The current state of a prompt",
|
|
73
|
+
typeParameters: [{
|
|
74
|
+
name: "TValue",
|
|
75
|
+
default: "string"
|
|
76
|
+
}],
|
|
77
|
+
get children() {
|
|
78
|
+
return [
|
|
79
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
80
|
+
name: "value",
|
|
81
|
+
type: "TValue",
|
|
82
|
+
doc: "The current value of the prompt"
|
|
83
|
+
}),
|
|
84
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
85
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
86
|
+
name: "isError",
|
|
87
|
+
type: "boolean",
|
|
88
|
+
doc: "Indicates whether the prompt is in an error state"
|
|
89
|
+
}),
|
|
90
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
91
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
92
|
+
name: "errorMessage",
|
|
93
|
+
required: false,
|
|
94
|
+
type: "string",
|
|
95
|
+
doc: "If the prompt is in an error state, this will contain the error message to display"
|
|
96
|
+
}),
|
|
97
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
98
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
99
|
+
name: "isSubmitted",
|
|
100
|
+
type: "boolean",
|
|
101
|
+
doc: "Indicates whether the prompt is submitted"
|
|
102
|
+
}),
|
|
103
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
104
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
105
|
+
name: "isCancelled",
|
|
106
|
+
type: "boolean",
|
|
107
|
+
doc: "Indicates whether the prompt is cancelled"
|
|
108
|
+
}),
|
|
109
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
110
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
111
|
+
name: "isCompleted",
|
|
112
|
+
type: "boolean",
|
|
113
|
+
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"
|
|
114
|
+
}),
|
|
115
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
}),
|
|
119
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
120
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
121
|
+
name: "PromptConfig",
|
|
122
|
+
doc: "Configuration options for creating a prompt",
|
|
123
|
+
typeParameters: [{
|
|
124
|
+
name: "TValue",
|
|
125
|
+
default: "string"
|
|
126
|
+
}],
|
|
127
|
+
get children() {
|
|
128
|
+
return [
|
|
129
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
130
|
+
name: "input",
|
|
131
|
+
required: false,
|
|
132
|
+
type: "NodeJS.ReadStream",
|
|
133
|
+
doc: "The readable stream to use for prompt input, defaults to process.stdin"
|
|
134
|
+
}),
|
|
135
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
136
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
137
|
+
name: "output",
|
|
138
|
+
required: false,
|
|
139
|
+
type: "NodeJS.WriteStream",
|
|
140
|
+
doc: "The writable stream to use for prompt output, defaults to process.stdout"
|
|
141
|
+
}),
|
|
142
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
143
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
144
|
+
name: "message",
|
|
145
|
+
type: "string",
|
|
146
|
+
doc: "The prompt message to display"
|
|
147
|
+
}),
|
|
148
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
149
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
150
|
+
name: "description",
|
|
151
|
+
required: false,
|
|
152
|
+
type: "string",
|
|
153
|
+
doc: "The prompt description message to display"
|
|
154
|
+
}),
|
|
155
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
156
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
157
|
+
name: "initialValue",
|
|
158
|
+
required: false,
|
|
159
|
+
type: "TValue",
|
|
160
|
+
doc: "The initial value of the prompt"
|
|
161
|
+
}),
|
|
162
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
163
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
164
|
+
name: "validate",
|
|
165
|
+
required: false,
|
|
166
|
+
type: "(value: TValue) => boolean | string | null | undefined | Promise<boolean | string | null | undefined>",
|
|
167
|
+
doc: "A validation function that returns true if the input is valid, false or a string error message if the input is invalid"
|
|
168
|
+
}),
|
|
169
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
170
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
171
|
+
name: "parse",
|
|
172
|
+
required: false,
|
|
173
|
+
type: "PromptParser<TValue>",
|
|
174
|
+
doc: "A function that parses the input value and returns the parsed result or throws an error if the input is invalid"
|
|
175
|
+
}),
|
|
176
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
177
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
178
|
+
name: "format",
|
|
179
|
+
required: false,
|
|
180
|
+
type: "PromptFormatter<TValue>",
|
|
181
|
+
doc: "A function that formats the input value and returns the formatted result or throws an error if the input is invalid"
|
|
182
|
+
}),
|
|
183
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
184
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
185
|
+
name: "mask",
|
|
186
|
+
required: false,
|
|
187
|
+
type: "(input: string) => string",
|
|
188
|
+
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."
|
|
189
|
+
}),
|
|
190
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
191
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
192
|
+
name: "maskCompleted",
|
|
193
|
+
required: false,
|
|
194
|
+
type: "(input: string) => string",
|
|
195
|
+
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."
|
|
196
|
+
}),
|
|
197
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
198
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
199
|
+
name: "defaultErrorMessage",
|
|
200
|
+
required: false,
|
|
201
|
+
type: "string",
|
|
202
|
+
doc: "The default error message to display when validation fails"
|
|
203
|
+
}),
|
|
204
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
205
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
206
|
+
name: "timeout",
|
|
207
|
+
required: false,
|
|
208
|
+
type: "number",
|
|
209
|
+
doc: "The timeout duration in milliseconds for the prompt. If none is provided, the prompt will not time out."
|
|
210
|
+
})
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
}),
|
|
214
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
215
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
216
|
+
abstract: true,
|
|
217
|
+
name: "Prompt",
|
|
218
|
+
doc: "Base prompt class that other prompt types can extend from",
|
|
219
|
+
"extends": "EventEmitter",
|
|
220
|
+
typeParameters: [{
|
|
221
|
+
name: "TValue",
|
|
222
|
+
default: "string"
|
|
223
|
+
}],
|
|
224
|
+
get children() {
|
|
225
|
+
return [
|
|
226
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
227
|
+
name: "readline",
|
|
228
|
+
isPrivateMember: true,
|
|
229
|
+
type: "Interface"
|
|
230
|
+
}),
|
|
231
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
232
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
233
|
+
name: "value",
|
|
234
|
+
isPrivateMember: true,
|
|
235
|
+
type: "TValue | undefined"
|
|
236
|
+
}),
|
|
237
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
238
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
239
|
+
name: "isKeyPressed",
|
|
240
|
+
isPrivateMember: true,
|
|
241
|
+
type: "boolean",
|
|
242
|
+
children: _alloy_js_core.code`false; `
|
|
243
|
+
}),
|
|
244
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
245
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
246
|
+
name: "isDirty",
|
|
247
|
+
isPrivateMember: true,
|
|
248
|
+
type: "boolean",
|
|
249
|
+
children: _alloy_js_core.code`false; `
|
|
250
|
+
}),
|
|
251
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
252
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
253
|
+
name: "isClosed",
|
|
254
|
+
isPrivateMember: true,
|
|
255
|
+
type: "boolean",
|
|
256
|
+
children: _alloy_js_core.code`false; `
|
|
257
|
+
}),
|
|
258
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
259
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
260
|
+
name: "initialValue",
|
|
261
|
+
abstract: true,
|
|
262
|
+
"protected": true,
|
|
263
|
+
type: "TValue"
|
|
264
|
+
}),
|
|
265
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
266
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
267
|
+
name: "input",
|
|
268
|
+
"protected": true,
|
|
269
|
+
type: "NodeJS.ReadStream",
|
|
270
|
+
children: _alloy_js_core.code`process.stdin; `
|
|
271
|
+
}),
|
|
272
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
273
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
274
|
+
name: "output",
|
|
275
|
+
"protected": true,
|
|
276
|
+
type: "NodeJS.WriteStream",
|
|
277
|
+
children: _alloy_js_core.code`process.stdout; `
|
|
278
|
+
}),
|
|
279
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
280
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
281
|
+
name: "message",
|
|
282
|
+
"protected": true,
|
|
283
|
+
type: "string",
|
|
284
|
+
children: _alloy_js_core.code`""; `
|
|
285
|
+
}),
|
|
286
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
287
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
288
|
+
name: "description",
|
|
289
|
+
"protected": true,
|
|
290
|
+
type: "string",
|
|
291
|
+
children: _alloy_js_core.code`""; `
|
|
292
|
+
}),
|
|
293
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
294
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
295
|
+
name: "errorMessage",
|
|
296
|
+
"protected": true,
|
|
297
|
+
type: "string | null",
|
|
298
|
+
children: _alloy_js_core.code`null; `
|
|
299
|
+
}),
|
|
300
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
301
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
302
|
+
name: "defaultErrorMessage",
|
|
303
|
+
"protected": true,
|
|
304
|
+
type: "string",
|
|
305
|
+
children: _alloy_js_core.code`"An invalid value was provided"; `
|
|
306
|
+
}),
|
|
307
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
308
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
309
|
+
name: "isSubmitted",
|
|
310
|
+
"protected": true,
|
|
311
|
+
type: "boolean",
|
|
312
|
+
children: _alloy_js_core.code`false; `
|
|
313
|
+
}),
|
|
314
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
315
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
316
|
+
name: "isCancelled",
|
|
317
|
+
"protected": true,
|
|
318
|
+
type: "boolean",
|
|
319
|
+
children: _alloy_js_core.code`false; `
|
|
320
|
+
}),
|
|
321
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
322
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
323
|
+
name: "isInitial",
|
|
324
|
+
"protected": true,
|
|
325
|
+
type: "boolean",
|
|
326
|
+
children: _alloy_js_core.code`true; `
|
|
327
|
+
}),
|
|
328
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
329
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
330
|
+
name: "consoleOutput",
|
|
331
|
+
"protected": true,
|
|
332
|
+
type: "string",
|
|
333
|
+
children: _alloy_js_core.code`""; `
|
|
334
|
+
}),
|
|
335
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
336
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
337
|
+
name: "consoleStatus",
|
|
338
|
+
"protected": true,
|
|
339
|
+
type: "string",
|
|
340
|
+
children: _alloy_js_core.code`""; `
|
|
341
|
+
}),
|
|
342
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
343
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
344
|
+
name: "displayValue",
|
|
345
|
+
"protected": true,
|
|
346
|
+
type: "string",
|
|
347
|
+
children: _alloy_js_core.code`""; `
|
|
348
|
+
}),
|
|
349
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
350
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
351
|
+
name: "validate",
|
|
352
|
+
"protected": true,
|
|
353
|
+
type: "(value: TValue) => boolean | string | null | undefined | Promise<boolean | string | null | undefined>",
|
|
354
|
+
children: _alloy_js_core.code`() => true; `
|
|
355
|
+
}),
|
|
356
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
357
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
358
|
+
name: "parse",
|
|
359
|
+
"protected": true,
|
|
360
|
+
type: "PromptParser<TValue>",
|
|
361
|
+
children: _alloy_js_core.code`(value: string) => value as TValue; `
|
|
362
|
+
}),
|
|
363
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
364
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
365
|
+
name: "format",
|
|
366
|
+
"protected": true,
|
|
367
|
+
type: "PromptFormatter<TValue>",
|
|
368
|
+
children: _alloy_js_core.code`(value: TValue) => String(value); `
|
|
369
|
+
}),
|
|
370
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
371
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
372
|
+
name: "mask",
|
|
373
|
+
"protected": true,
|
|
374
|
+
type: "(input: string) => string",
|
|
375
|
+
children: _alloy_js_core.code`noMask; `
|
|
376
|
+
}),
|
|
377
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
378
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
379
|
+
name: "maskCompleted",
|
|
380
|
+
"protected": true,
|
|
381
|
+
type: "(input: string) => string",
|
|
382
|
+
children: _alloy_js_core.code`this.mask; `
|
|
383
|
+
}),
|
|
384
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
385
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
386
|
+
name: "cursor",
|
|
387
|
+
"protected": true,
|
|
388
|
+
type: "number",
|
|
389
|
+
children: _alloy_js_core.code`0; `
|
|
390
|
+
}),
|
|
391
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
392
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
393
|
+
name: "cursorHidden",
|
|
394
|
+
"protected": true,
|
|
395
|
+
type: "boolean",
|
|
396
|
+
children: _alloy_js_core.code`false; `
|
|
397
|
+
}),
|
|
398
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
399
|
+
_alloy_js_core.code`constructor(protected config: PromptConfig<TValue>) {
|
|
2
400
|
super();
|
|
3
401
|
|
|
4
402
|
if (config.input) {
|
|
@@ -55,7 +453,49 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
55
453
|
|
|
56
454
|
[Symbol.dispose]() {
|
|
57
455
|
this.close();
|
|
58
|
-
} `,
|
|
456
|
+
} `,
|
|
457
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
458
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
459
|
+
"public": true,
|
|
460
|
+
name: "value",
|
|
461
|
+
type: "TValue",
|
|
462
|
+
doc: "A getter for the prompt value that returns the current value or the initial value if the current value is not set",
|
|
463
|
+
children: _alloy_js_core.code`return this.#value || this.initialValue; `
|
|
464
|
+
}),
|
|
465
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
466
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
467
|
+
"public": true,
|
|
468
|
+
name: "isError",
|
|
469
|
+
type: "boolean",
|
|
470
|
+
children: _alloy_js_core.code`return !!this.errorMessage; `
|
|
471
|
+
}),
|
|
472
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
473
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
474
|
+
"protected": true,
|
|
475
|
+
name: "isSelect",
|
|
476
|
+
type: "boolean",
|
|
477
|
+
children: _alloy_js_core.code`return false; `
|
|
478
|
+
}),
|
|
479
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
480
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
481
|
+
"protected": true,
|
|
482
|
+
name: "isCompleted",
|
|
483
|
+
type: "boolean",
|
|
484
|
+
children: _alloy_js_core.code`return this.isCancelled || this.isSubmitted; `
|
|
485
|
+
}),
|
|
486
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
487
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
488
|
+
"protected": true,
|
|
489
|
+
name: "isPlaceholder",
|
|
490
|
+
type: "boolean",
|
|
491
|
+
children: _alloy_js_core.code`return (this.displayValue === this.format(this.initialValue) && !this.#isDirty) || !this.#isKeyPressed; `
|
|
492
|
+
}),
|
|
493
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
494
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
495
|
+
"protected": true,
|
|
496
|
+
name: "status",
|
|
497
|
+
type: "string",
|
|
498
|
+
children: _alloy_js_core.code`return this.isSubmitted ? "" : \` \\n \${
|
|
59
499
|
italic(
|
|
60
500
|
this.isError
|
|
61
501
|
? textColors.prompt.description.error(splitText(this.errorMessage, "3/4").join("\\n"))
|
|
@@ -65,7 +505,34 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
65
505
|
? textColors.prompt.description.active(splitText(this.description, "3/4").join("\\n"))
|
|
66
506
|
: ""
|
|
67
507
|
)
|
|
68
|
-
}\`; `
|
|
508
|
+
}\`; `
|
|
509
|
+
}),
|
|
510
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
511
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
512
|
+
doc: "A property to check if the cursor is at the start",
|
|
513
|
+
name: "isCursorAtStart",
|
|
514
|
+
"protected": true,
|
|
515
|
+
type: "boolean",
|
|
516
|
+
children: _alloy_js_core.code`return this.cursor <= 0 || (this.isPlaceholder && this.cursor <= 1); `
|
|
517
|
+
}),
|
|
518
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
519
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
520
|
+
doc: "A property to check if the cursor is at the end",
|
|
521
|
+
name: "isCursorAtEnd",
|
|
522
|
+
"protected": true,
|
|
523
|
+
type: "boolean",
|
|
524
|
+
children: _alloy_js_core.code`return this.cursor >= this.displayValue.length || (this.isPlaceholder && this.cursor >= this.displayValue.length - 1); `
|
|
525
|
+
}),
|
|
526
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
527
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
528
|
+
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.",
|
|
529
|
+
name: "changeValue",
|
|
530
|
+
"protected": true,
|
|
531
|
+
parameters: [{
|
|
532
|
+
name: "value",
|
|
533
|
+
type: "TValue"
|
|
534
|
+
}],
|
|
535
|
+
children: _alloy_js_core.code`const previousValue = this.value;
|
|
69
536
|
|
|
70
537
|
let updatedValue = value;
|
|
71
538
|
if (value === undefined || value === "") {
|
|
@@ -86,7 +553,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
86
553
|
Promise.resolve(this.checkValidations(updatedValue)).then(() => this.sync());
|
|
87
554
|
}, 0);
|
|
88
555
|
|
|
89
|
-
this.sync(); `
|
|
556
|
+
this.sync(); `
|
|
557
|
+
}),
|
|
558
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
559
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
560
|
+
doc: "A method to emit the current state",
|
|
561
|
+
name: "sync",
|
|
562
|
+
"protected": true,
|
|
563
|
+
children: _alloy_js_core.code`this.emit("state", {
|
|
90
564
|
value: this.value,
|
|
91
565
|
errorMessage: this.errorMessage,
|
|
92
566
|
isError: this.isError,
|
|
@@ -94,7 +568,22 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
94
568
|
isCancelled: this.isCancelled,
|
|
95
569
|
isCompleted: this.isCompleted
|
|
96
570
|
});
|
|
97
|
-
this.render(); `
|
|
571
|
+
this.render(); `
|
|
572
|
+
}),
|
|
573
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
574
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
575
|
+
doc: "A method to ring the bell",
|
|
576
|
+
name: "bell",
|
|
577
|
+
"protected": true,
|
|
578
|
+
children: _alloy_js_core.code`this.output.write(beep); `
|
|
579
|
+
}),
|
|
580
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
581
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
582
|
+
doc: "A method to render the prompt",
|
|
583
|
+
name: "onRender",
|
|
584
|
+
"protected": true,
|
|
585
|
+
returnType: "string",
|
|
586
|
+
children: _alloy_js_core.code`return this.isPlaceholder
|
|
98
587
|
? textColors.prompt.input.disabled(this.displayValue)
|
|
99
588
|
: this.isError
|
|
100
589
|
? textColors.prompt.input.error(this.displayValue)
|
|
@@ -102,12 +591,45 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
102
591
|
? textColors.prompt.input.submitted(this.maskCompleted(this.displayValue))
|
|
103
592
|
: this.isCancelled
|
|
104
593
|
? textColors.prompt.input.cancelled(this.maskCompleted(this.displayValue))
|
|
105
|
-
: bold(textColors.prompt.input.active(this.displayValue)); `
|
|
594
|
+
: bold(textColors.prompt.input.active(this.displayValue)); `
|
|
595
|
+
}),
|
|
596
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
597
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
598
|
+
doc: "A method to handle changes in the prompt value",
|
|
599
|
+
name: "onChange",
|
|
600
|
+
"protected": true,
|
|
601
|
+
parameters: [{
|
|
602
|
+
name: "previousValue",
|
|
603
|
+
type: "TValue"
|
|
604
|
+
}],
|
|
605
|
+
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`
|
|
606
|
+
}),
|
|
607
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
608
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
609
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
610
|
+
name: "onKeyPress",
|
|
611
|
+
"protected": true,
|
|
612
|
+
parameters: [{
|
|
613
|
+
name: "char",
|
|
614
|
+
type: "string"
|
|
615
|
+
}, {
|
|
616
|
+
name: "key",
|
|
617
|
+
type: "Key"
|
|
618
|
+
}],
|
|
619
|
+
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
106
620
|
if (!action) {
|
|
107
621
|
this.bell();
|
|
108
622
|
} else if (typeof (this as any)[action] === "function") {
|
|
109
623
|
(this as any)[action](key);
|
|
110
|
-
} `
|
|
624
|
+
} `
|
|
625
|
+
}),
|
|
626
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
627
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
628
|
+
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.",
|
|
629
|
+
name: "close",
|
|
630
|
+
async: true,
|
|
631
|
+
"protected": true,
|
|
632
|
+
children: _alloy_js_core.code`if (this.#isClosed) {
|
|
111
633
|
return;
|
|
112
634
|
}
|
|
113
635
|
|
|
@@ -120,14 +642,38 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
120
642
|
|
|
121
643
|
this.#readline.close();
|
|
122
644
|
this.emit(this.isSubmitted ? "submit" : "cancel", this.value);
|
|
123
|
-
this.#isClosed = true; `
|
|
645
|
+
this.#isClosed = true; `
|
|
646
|
+
}),
|
|
647
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
648
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
649
|
+
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.",
|
|
650
|
+
name: "checkValidations",
|
|
651
|
+
async: true,
|
|
652
|
+
"protected": true,
|
|
653
|
+
parameters: [{
|
|
654
|
+
name: "value",
|
|
655
|
+
type: "TValue"
|
|
656
|
+
}],
|
|
657
|
+
children: _alloy_js_core.code`let result = await this.validate(value);
|
|
124
658
|
if (typeof result === "string") {
|
|
125
659
|
this.errorMessage = result;
|
|
126
660
|
} else if (typeof result === "boolean") {
|
|
127
661
|
this.errorMessage = result ? null : this.defaultErrorMessage;
|
|
128
662
|
} else {
|
|
129
663
|
this.errorMessage = null;
|
|
130
|
-
} `
|
|
664
|
+
} `
|
|
665
|
+
}),
|
|
666
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
667
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
668
|
+
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.",
|
|
669
|
+
name: "getAction",
|
|
670
|
+
"protected": true,
|
|
671
|
+
parameters: [{
|
|
672
|
+
name: "key",
|
|
673
|
+
type: "Key"
|
|
674
|
+
}],
|
|
675
|
+
returnType: "string | false",
|
|
676
|
+
children: _alloy_js_core.code`if (key.meta && key.name !== "escape") {
|
|
131
677
|
return false;
|
|
132
678
|
}
|
|
133
679
|
|
|
@@ -157,7 +703,18 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
157
703
|
if (key.name === "right") action = "right";
|
|
158
704
|
if (key.name === "left") action = "left";
|
|
159
705
|
|
|
160
|
-
return action || false; `
|
|
706
|
+
return action || false; `
|
|
707
|
+
}),
|
|
708
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
709
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
710
|
+
doc: "A method to move the cursor to the left or right by a \\`count\\` of positions",
|
|
711
|
+
name: "moveCursor",
|
|
712
|
+
parameters: [{
|
|
713
|
+
name: "count",
|
|
714
|
+
type: "number"
|
|
715
|
+
}],
|
|
716
|
+
"protected": true,
|
|
717
|
+
children: _alloy_js_core.code`if (this.cursor + count < 0) {
|
|
161
718
|
this.cursor = 0;
|
|
162
719
|
} else if (this.cursor + count > this.displayValue.length) {
|
|
163
720
|
this.cursor = this.displayValue.length;
|
|
@@ -165,7 +722,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
165
722
|
this.cursor += count;
|
|
166
723
|
}
|
|
167
724
|
|
|
168
|
-
`
|
|
725
|
+
`
|
|
726
|
+
}),
|
|
727
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
728
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
729
|
+
doc: "A method to remove the character backward of the cursor",
|
|
730
|
+
name: "backspace",
|
|
731
|
+
"protected": true,
|
|
732
|
+
children: _alloy_js_core.code`if (this.isCursorAtStart) {
|
|
169
733
|
return this.bell();
|
|
170
734
|
}
|
|
171
735
|
|
|
@@ -183,7 +747,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
183
747
|
|
|
184
748
|
this.moveCursor(isCursorAtEnd ? -1 : -2);
|
|
185
749
|
|
|
186
|
-
this.sync(); `
|
|
750
|
+
this.sync(); `
|
|
751
|
+
}),
|
|
752
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
753
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
754
|
+
doc: "A method to remove the character forward of the cursor",
|
|
755
|
+
name: "delete",
|
|
756
|
+
"protected": true,
|
|
757
|
+
children: _alloy_js_core.code`if (this.isCursorAtEnd) {
|
|
187
758
|
return this.bell();
|
|
188
759
|
}
|
|
189
760
|
|
|
@@ -197,20 +768,42 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
197
768
|
this.moveCursor(-1);
|
|
198
769
|
}
|
|
199
770
|
|
|
200
|
-
this.sync(); `
|
|
771
|
+
this.sync(); `
|
|
772
|
+
}),
|
|
773
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
774
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
775
|
+
doc: "A method to reset the prompt input",
|
|
776
|
+
name: "reset",
|
|
777
|
+
"protected": true,
|
|
778
|
+
children: _alloy_js_core.code`this.changeValue(this.initialValue);
|
|
201
779
|
this.cursor = 0;
|
|
202
780
|
|
|
203
781
|
this.errorMessage = null;
|
|
204
782
|
this.isCancelled = false;
|
|
205
783
|
this.isSubmitted = false;
|
|
206
784
|
|
|
207
|
-
this.sync(); `
|
|
785
|
+
this.sync(); `
|
|
786
|
+
}),
|
|
787
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
788
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
789
|
+
doc: "A method to cancel the prompt input",
|
|
790
|
+
name: "cancel",
|
|
791
|
+
"protected": true,
|
|
792
|
+
children: _alloy_js_core.code`this.errorMessage = null;
|
|
208
793
|
this.isCancelled = true;
|
|
209
794
|
this.isSubmitted = false;
|
|
210
795
|
|
|
211
796
|
this.sync();
|
|
212
797
|
this.output.write("\\n");
|
|
213
|
-
this.close(); `
|
|
798
|
+
this.close(); `
|
|
799
|
+
}),
|
|
800
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
801
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
802
|
+
doc: "A method to submit the prompt input",
|
|
803
|
+
name: "submit",
|
|
804
|
+
async: true,
|
|
805
|
+
"protected": true,
|
|
806
|
+
children: _alloy_js_core.code`this.cursor = this.displayValue.length;
|
|
214
807
|
|
|
215
808
|
await this.checkValidations(this.value);
|
|
216
809
|
if (this.isError) {
|
|
@@ -223,7 +816,15 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
223
816
|
this.sync();
|
|
224
817
|
this.output.write("\\n");
|
|
225
818
|
this.close();
|
|
226
|
-
} `
|
|
819
|
+
} `
|
|
820
|
+
}),
|
|
821
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
822
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
823
|
+
doc: "A method to render the prompt",
|
|
824
|
+
name: "render",
|
|
825
|
+
"private": true,
|
|
826
|
+
get children() {
|
|
827
|
+
return _alloy_js_core.code`if (this.#isClosed) {
|
|
227
828
|
return;
|
|
228
829
|
}
|
|
229
830
|
|
|
@@ -244,12 +845,12 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
244
845
|
|
|
245
846
|
this.consoleOutput = \` \${
|
|
246
847
|
this.isSubmitted
|
|
247
|
-
? textColors.prompt.icon.submitted("${
|
|
848
|
+
? textColors.prompt.icon.submitted("${theme.icons.prompt.submitted}")
|
|
248
849
|
: this.isCancelled
|
|
249
|
-
? textColors.prompt.icon.cancelled("${
|
|
850
|
+
? textColors.prompt.icon.cancelled("${theme.icons.prompt.cancelled}")
|
|
250
851
|
: this.isError
|
|
251
|
-
? textColors.prompt.icon.error("${
|
|
252
|
-
: textColors.prompt.icon.active("${
|
|
852
|
+
? textColors.prompt.icon.error("${theme.icons.prompt.error}")
|
|
853
|
+
: textColors.prompt.icon.active("${theme.icons.prompt.active}")
|
|
253
854
|
} \${
|
|
254
855
|
this.isCompleted
|
|
255
856
|
? textColors.prompt.message.submitted(this.message)
|
|
@@ -272,7 +873,22 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
272
873
|
this.consoleStatus = this.status;
|
|
273
874
|
} finally {
|
|
274
875
|
clearTimeout(timeout);
|
|
275
|
-
}
|
|
876
|
+
} `;
|
|
877
|
+
}
|
|
878
|
+
}),
|
|
879
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
880
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
881
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
882
|
+
name: "keypress",
|
|
883
|
+
"private": true,
|
|
884
|
+
parameters: [{
|
|
885
|
+
name: "char",
|
|
886
|
+
type: "string"
|
|
887
|
+
}, {
|
|
888
|
+
name: "key",
|
|
889
|
+
type: "Key"
|
|
890
|
+
}],
|
|
891
|
+
children: _alloy_js_core.code`if (this.#isClosed) {
|
|
276
892
|
return;
|
|
277
893
|
}
|
|
278
894
|
|
|
@@ -280,7 +896,124 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
280
896
|
this.#isKeyPressed = true;
|
|
281
897
|
}
|
|
282
898
|
|
|
283
|
-
return this.onKeyPress(char, key); `
|
|
899
|
+
return this.onKeyPress(char, key); `
|
|
900
|
+
})
|
|
901
|
+
];
|
|
902
|
+
}
|
|
903
|
+
}),
|
|
904
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
905
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
906
|
+
name: "PromptFactoryConfig",
|
|
907
|
+
"extends": "PromptConfig<TValue>",
|
|
908
|
+
doc: "Configuration options for creating a prompt with a prompt factory function",
|
|
909
|
+
typeParameters: [{
|
|
910
|
+
name: "TValue",
|
|
911
|
+
default: "string"
|
|
912
|
+
}],
|
|
913
|
+
get children() {
|
|
914
|
+
return [
|
|
915
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
916
|
+
name: "onState",
|
|
917
|
+
required: false,
|
|
918
|
+
type: "(state: PromptState<TValue>) => any",
|
|
919
|
+
doc: "A function that is called when the prompt state changes, useful for updating the prompt message or other properties dynamically"
|
|
920
|
+
}),
|
|
921
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
922
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
923
|
+
name: "onSubmit",
|
|
924
|
+
required: false,
|
|
925
|
+
type: "(value: TValue) => any",
|
|
926
|
+
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"
|
|
927
|
+
}),
|
|
928
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
929
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
930
|
+
name: "onCancel",
|
|
931
|
+
required: false,
|
|
932
|
+
type: "(event: any) => any",
|
|
933
|
+
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"
|
|
934
|
+
})
|
|
935
|
+
];
|
|
936
|
+
}
|
|
937
|
+
}),
|
|
938
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
939
|
+
(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." }),
|
|
940
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
941
|
+
"export": true,
|
|
942
|
+
name: "CANCEL_SYMBOL",
|
|
943
|
+
children: _alloy_js_core.code`Symbol("shell-shock:prompts:cancel"); `
|
|
944
|
+
}),
|
|
945
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
946
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
947
|
+
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.",
|
|
948
|
+
get children() {
|
|
949
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
950
|
+
name: "value",
|
|
951
|
+
children: `The value to check.`
|
|
952
|
+
}), (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.` })];
|
|
953
|
+
}
|
|
954
|
+
}),
|
|
955
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
956
|
+
name: "isCancel",
|
|
957
|
+
"export": true,
|
|
958
|
+
parameters: [{
|
|
959
|
+
name: "value",
|
|
960
|
+
type: "any"
|
|
961
|
+
}],
|
|
962
|
+
returnType: "value is typeof CANCEL_SYMBOL",
|
|
963
|
+
children: _alloy_js_core.code`return value === CANCEL_SYMBOL; `
|
|
964
|
+
})
|
|
965
|
+
];
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* 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.
|
|
969
|
+
*/
|
|
970
|
+
function TextPromptDeclarations() {
|
|
971
|
+
return [
|
|
972
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
973
|
+
name: "StringPromptConfig",
|
|
974
|
+
"extends": "PromptConfig<string>",
|
|
975
|
+
doc: "Configuration options for creating a text-based prompt",
|
|
976
|
+
get children() {
|
|
977
|
+
return [
|
|
978
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
979
|
+
name: "initialValue",
|
|
980
|
+
required: false,
|
|
981
|
+
type: "string",
|
|
982
|
+
doc: "The initial value of the prompt"
|
|
983
|
+
}),
|
|
984
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
985
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
986
|
+
name: "mask",
|
|
987
|
+
required: false,
|
|
988
|
+
type: "(input: string) => string",
|
|
989
|
+
doc: "A function that masks the input value and returns the masked result"
|
|
990
|
+
})
|
|
991
|
+
];
|
|
992
|
+
}
|
|
993
|
+
}),
|
|
994
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
995
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
996
|
+
name: "StringPrompt",
|
|
997
|
+
doc: "A prompt for text input",
|
|
998
|
+
"extends": "Prompt<string>",
|
|
999
|
+
get children() {
|
|
1000
|
+
return [
|
|
1001
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1002
|
+
name: "isInvalid",
|
|
1003
|
+
isPrivateMember: true,
|
|
1004
|
+
type: "boolean",
|
|
1005
|
+
children: _alloy_js_core.code`false; `
|
|
1006
|
+
}),
|
|
1007
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1008
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1009
|
+
name: "initialValue",
|
|
1010
|
+
"protected": true,
|
|
1011
|
+
override: true,
|
|
1012
|
+
type: "string",
|
|
1013
|
+
children: _alloy_js_core.code`""; `
|
|
1014
|
+
}),
|
|
1015
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1016
|
+
_alloy_js_core.code`constructor(config: StringPromptConfig) {
|
|
284
1017
|
super(config);
|
|
285
1018
|
|
|
286
1019
|
if (config.initialValue) {
|
|
@@ -294,7 +1027,21 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
294
1027
|
this.cursor = 0;
|
|
295
1028
|
this.sync();
|
|
296
1029
|
this.last();
|
|
297
|
-
} `,
|
|
1030
|
+
} `,
|
|
1031
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1032
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1033
|
+
doc: "A method to handle onKeyPress events and determine the corresponding action",
|
|
1034
|
+
name: "onKeyPress",
|
|
1035
|
+
override: true,
|
|
1036
|
+
"protected": true,
|
|
1037
|
+
parameters: [{
|
|
1038
|
+
name: "char",
|
|
1039
|
+
type: "string"
|
|
1040
|
+
}, {
|
|
1041
|
+
name: "key",
|
|
1042
|
+
type: "Key"
|
|
1043
|
+
}],
|
|
1044
|
+
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
298
1045
|
if (action && typeof (this as any)[action] === "function") {
|
|
299
1046
|
return (this as any)[action]();
|
|
300
1047
|
}
|
|
@@ -308,24 +1055,97 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
308
1055
|
}\${char}\${
|
|
309
1056
|
this.displayValue.slice(this.cursor)
|
|
310
1057
|
}\`);
|
|
311
|
-
this.sync(); `
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
1058
|
+
this.sync(); `
|
|
1059
|
+
}),
|
|
1060
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1061
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1062
|
+
doc: "A method to handle changes in the prompt value",
|
|
1063
|
+
name: "onChange",
|
|
1064
|
+
override: true,
|
|
1065
|
+
"protected": true,
|
|
1066
|
+
parameters: [{
|
|
1067
|
+
name: "previousValue",
|
|
1068
|
+
type: "string"
|
|
1069
|
+
}],
|
|
1070
|
+
children: _alloy_js_core.code`this.#isInvalid = false;
|
|
1071
|
+
this.cursor = this.displayValue.slice(0, this.cursor).length + 1; `
|
|
1072
|
+
}),
|
|
1073
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1074
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1075
|
+
doc: "A method to reset the prompt input",
|
|
1076
|
+
name: "reset",
|
|
1077
|
+
override: true,
|
|
1078
|
+
"protected": true,
|
|
1079
|
+
children: _alloy_js_core.code`this.cursor = Number(!!this.initialValue);
|
|
1080
|
+
super.reset(); `
|
|
1081
|
+
}),
|
|
1082
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1083
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1084
|
+
doc: "A method to validate the prompt input",
|
|
1085
|
+
name: "checkValidations",
|
|
1086
|
+
override: true,
|
|
1087
|
+
async: true,
|
|
1088
|
+
"protected": true,
|
|
1089
|
+
children: _alloy_js_core.code`await super.checkValidations(this.value);
|
|
1090
|
+
this.#isInvalid = this.isError; `
|
|
1091
|
+
}),
|
|
1092
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1093
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1094
|
+
doc: "A method to move the cursor to the end of the input",
|
|
1095
|
+
name: "next",
|
|
1096
|
+
"protected": true,
|
|
1097
|
+
children: _alloy_js_core.code`this.changeValue(this.initialValue);
|
|
315
1098
|
this.cursor = this.displayValue.length;
|
|
316
|
-
this.sync(); `
|
|
317
|
-
|
|
318
|
-
|
|
1099
|
+
this.sync(); `
|
|
1100
|
+
}),
|
|
1101
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1102
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1103
|
+
doc: "A method to move the cursor to the start",
|
|
1104
|
+
name: "first",
|
|
1105
|
+
"protected": true,
|
|
1106
|
+
children: _alloy_js_core.code`this.cursor = 0;
|
|
1107
|
+
this.sync(); `
|
|
1108
|
+
}),
|
|
1109
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1110
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1111
|
+
doc: "A method to move the cursor to the end",
|
|
1112
|
+
name: "last",
|
|
1113
|
+
"protected": true,
|
|
1114
|
+
children: _alloy_js_core.code`this.cursor = this.displayValue.length;
|
|
1115
|
+
this.sync(); `
|
|
1116
|
+
}),
|
|
1117
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1118
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1119
|
+
doc: "A method to move the cursor to the left",
|
|
1120
|
+
name: "left",
|
|
1121
|
+
"protected": true,
|
|
1122
|
+
children: _alloy_js_core.code`if (this.cursor <= 0) {
|
|
319
1123
|
return this.bell();
|
|
320
1124
|
}
|
|
321
1125
|
|
|
322
1126
|
this.moveCursor(-1);
|
|
323
|
-
this.sync(); `
|
|
1127
|
+
this.sync(); `
|
|
1128
|
+
}),
|
|
1129
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1130
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1131
|
+
doc: "A method to move the cursor to the right",
|
|
1132
|
+
name: "right",
|
|
1133
|
+
"protected": true,
|
|
1134
|
+
children: _alloy_js_core.code`if (this.cursor >= this.displayValue.length) {
|
|
324
1135
|
return this.bell();
|
|
325
1136
|
}
|
|
326
1137
|
|
|
327
1138
|
this.moveCursor(1);
|
|
328
|
-
this.sync(); `
|
|
1139
|
+
this.sync(); `
|
|
1140
|
+
}),
|
|
1141
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1142
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1143
|
+
doc: "A method to render the prompt",
|
|
1144
|
+
name: "onRender",
|
|
1145
|
+
override: true,
|
|
1146
|
+
"protected": true,
|
|
1147
|
+
returnType: "string",
|
|
1148
|
+
children: _alloy_js_core.code`return this.isPlaceholder
|
|
329
1149
|
? textColors.prompt.input.disabled(this.displayValue)
|
|
330
1150
|
: this.#isInvalid
|
|
331
1151
|
? textColors.prompt.input.error(this.displayValue)
|
|
@@ -333,7 +1153,25 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
333
1153
|
? textColors.prompt.input.submitted(this.displayValue)
|
|
334
1154
|
: this.isCancelled
|
|
335
1155
|
? textColors.prompt.input.cancelled(this.displayValue)
|
|
336
|
-
: bold(textColors.prompt.input.active(this.displayValue)); `
|
|
1156
|
+
: bold(textColors.prompt.input.active(this.displayValue)); `
|
|
1157
|
+
})
|
|
1158
|
+
];
|
|
1159
|
+
}
|
|
1160
|
+
}),
|
|
1161
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1162
|
+
(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." }),
|
|
1163
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
1164
|
+
name: "TextConfig",
|
|
1165
|
+
"export": true,
|
|
1166
|
+
children: _alloy_js_core.code`PromptFactoryConfig<string> & StringPromptConfig; `
|
|
1167
|
+
}),
|
|
1168
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1169
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1170
|
+
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.",
|
|
1171
|
+
get children() {
|
|
1172
|
+
return [
|
|
1173
|
+
(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.` }),
|
|
1174
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { text, isCancel } from "shell-shock:prompts";
|
|
337
1175
|
|
|
338
1176
|
async function run() {
|
|
339
1177
|
const name = await text({
|
|
@@ -349,13 +1187,202 @@ async function run() {
|
|
|
349
1187
|
console.log("Hello, " + name + "!");
|
|
350
1188
|
}
|
|
351
1189
|
|
|
352
|
-
run(); `
|
|
1190
|
+
run(); ` }),
|
|
1191
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1192
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1193
|
+
name: "config",
|
|
1194
|
+
children: `The configuration options to pass to the text prompt, which extends the base PromptConfig with additional options specific to text prompts`
|
|
1195
|
+
}),
|
|
1196
|
+
(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` })
|
|
1197
|
+
];
|
|
1198
|
+
}
|
|
1199
|
+
}),
|
|
1200
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1201
|
+
name: "text",
|
|
1202
|
+
"export": true,
|
|
1203
|
+
parameters: [{
|
|
1204
|
+
name: "config",
|
|
1205
|
+
type: "TextConfig"
|
|
1206
|
+
}],
|
|
1207
|
+
returnType: "Promise<string | symbol>",
|
|
1208
|
+
children: _alloy_js_core.code`return new Promise<string | symbol>((response, reject) => {
|
|
353
1209
|
const prompt = new StringPrompt(config);
|
|
354
1210
|
|
|
355
1211
|
prompt.on("state", state => config.onState?.(state));
|
|
356
1212
|
prompt.on("submit", value => response(value));
|
|
357
1213
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
358
|
-
});`
|
|
1214
|
+
});`
|
|
1215
|
+
})
|
|
1216
|
+
];
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* 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.
|
|
1220
|
+
*/
|
|
1221
|
+
function SelectPromptDeclarations() {
|
|
1222
|
+
return [
|
|
1223
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
1224
|
+
name: "PromptOptionConfig",
|
|
1225
|
+
doc: "Configuration for an option the user can select from the select prompt",
|
|
1226
|
+
typeParameters: [{
|
|
1227
|
+
name: "TValue",
|
|
1228
|
+
default: "string"
|
|
1229
|
+
}],
|
|
1230
|
+
get children() {
|
|
1231
|
+
return [
|
|
1232
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1233
|
+
name: "label",
|
|
1234
|
+
schema: { type: "string" },
|
|
1235
|
+
required: false,
|
|
1236
|
+
doc: "The message label for the option"
|
|
1237
|
+
}),
|
|
1238
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1239
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1240
|
+
name: "icon",
|
|
1241
|
+
schema: { type: "string" },
|
|
1242
|
+
required: false,
|
|
1243
|
+
doc: "An icon for the option"
|
|
1244
|
+
}),
|
|
1245
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1246
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1247
|
+
name: "value",
|
|
1248
|
+
type: "TValue",
|
|
1249
|
+
doc: "The value of the option"
|
|
1250
|
+
}),
|
|
1251
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1252
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1253
|
+
name: "description",
|
|
1254
|
+
schema: { type: "string" },
|
|
1255
|
+
required: false,
|
|
1256
|
+
doc: "The description of the option"
|
|
1257
|
+
}),
|
|
1258
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1259
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1260
|
+
name: "selected",
|
|
1261
|
+
schema: { type: "boolean" },
|
|
1262
|
+
required: false,
|
|
1263
|
+
doc: "Whether the option is selected"
|
|
1264
|
+
}),
|
|
1265
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1266
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1267
|
+
name: "disabled",
|
|
1268
|
+
schema: { type: "boolean" },
|
|
1269
|
+
required: false,
|
|
1270
|
+
doc: "Whether the option is disabled"
|
|
1271
|
+
})
|
|
1272
|
+
];
|
|
1273
|
+
}
|
|
1274
|
+
}),
|
|
1275
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1276
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
1277
|
+
"export": true,
|
|
1278
|
+
name: "PromptOption",
|
|
1279
|
+
"extends": "PromptOptionConfig<TValue>",
|
|
1280
|
+
doc: "An option the user can select from the select prompt",
|
|
1281
|
+
typeParameters: [{
|
|
1282
|
+
name: "TValue",
|
|
1283
|
+
default: "string"
|
|
1284
|
+
}],
|
|
1285
|
+
get children() {
|
|
1286
|
+
return [
|
|
1287
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1288
|
+
name: "label",
|
|
1289
|
+
type: "string",
|
|
1290
|
+
doc: "The message label for the option"
|
|
1291
|
+
}),
|
|
1292
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1293
|
+
name: "index",
|
|
1294
|
+
type: "number",
|
|
1295
|
+
doc: "The index of the option"
|
|
1296
|
+
}),
|
|
1297
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1298
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1299
|
+
name: "selected",
|
|
1300
|
+
type: "boolean",
|
|
1301
|
+
doc: "Whether the option is selected"
|
|
1302
|
+
}),
|
|
1303
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1304
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1305
|
+
name: "disabled",
|
|
1306
|
+
type: "boolean",
|
|
1307
|
+
doc: "Whether the option is disabled"
|
|
1308
|
+
})
|
|
1309
|
+
];
|
|
1310
|
+
}
|
|
1311
|
+
}),
|
|
1312
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1313
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
1314
|
+
name: "SelectPromptConfig",
|
|
1315
|
+
"extends": "PromptConfig<TValue>",
|
|
1316
|
+
doc: "An options object for configuring a select prompt",
|
|
1317
|
+
typeParameters: [{
|
|
1318
|
+
name: "TValue",
|
|
1319
|
+
default: "string"
|
|
1320
|
+
}],
|
|
1321
|
+
get children() {
|
|
1322
|
+
return [
|
|
1323
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1324
|
+
name: "hint",
|
|
1325
|
+
required: false,
|
|
1326
|
+
type: "string",
|
|
1327
|
+
doc: "A hint to display to the user"
|
|
1328
|
+
}),
|
|
1329
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1330
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1331
|
+
name: "options",
|
|
1332
|
+
type: "Array<string | PromptOptionConfig<TValue>>",
|
|
1333
|
+
doc: "The options available for the select prompt"
|
|
1334
|
+
}),
|
|
1335
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1336
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1337
|
+
name: "optionsPerPage",
|
|
1338
|
+
required: false,
|
|
1339
|
+
type: "number",
|
|
1340
|
+
doc: "The number of options to display per page, defaults to 8"
|
|
1341
|
+
})
|
|
1342
|
+
];
|
|
1343
|
+
}
|
|
1344
|
+
}),
|
|
1345
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1346
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
1347
|
+
name: "SelectPrompt",
|
|
1348
|
+
doc: "A prompt for selecting an option from a list",
|
|
1349
|
+
"extends": "Prompt<TValue>",
|
|
1350
|
+
typeParameters: [{
|
|
1351
|
+
name: "TValue",
|
|
1352
|
+
default: "string"
|
|
1353
|
+
}],
|
|
1354
|
+
get children() {
|
|
1355
|
+
return [
|
|
1356
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1357
|
+
name: "initialValue",
|
|
1358
|
+
"protected": true,
|
|
1359
|
+
override: true,
|
|
1360
|
+
type: "TValue"
|
|
1361
|
+
}),
|
|
1362
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1363
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1364
|
+
name: "optionsPerPage",
|
|
1365
|
+
"protected": true,
|
|
1366
|
+
type: "number",
|
|
1367
|
+
children: _alloy_js_core.code`8; `
|
|
1368
|
+
}),
|
|
1369
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1370
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1371
|
+
name: "options",
|
|
1372
|
+
"protected": true,
|
|
1373
|
+
type: "PromptOption<TValue>[]",
|
|
1374
|
+
children: _alloy_js_core.code`[]; `
|
|
1375
|
+
}),
|
|
1376
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1377
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1378
|
+
name: "cursorHidden",
|
|
1379
|
+
"protected": true,
|
|
1380
|
+
override: true,
|
|
1381
|
+
type: "boolean",
|
|
1382
|
+
children: _alloy_js_core.code`true; `
|
|
1383
|
+
}),
|
|
1384
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1385
|
+
_alloy_js_core.code`constructor(config: SelectPromptConfig<TValue>) {
|
|
359
1386
|
super(config);
|
|
360
1387
|
|
|
361
1388
|
if (config.initialValue) {
|
|
@@ -400,37 +1427,136 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
400
1427
|
}
|
|
401
1428
|
|
|
402
1429
|
this.sync();
|
|
403
|
-
} `,
|
|
1430
|
+
} `,
|
|
1431
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1432
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
1433
|
+
doc: "Returns the currently selected option",
|
|
1434
|
+
name: "selectedOption",
|
|
1435
|
+
type: "PromptOption<TValue> | null",
|
|
1436
|
+
"protected": true,
|
|
1437
|
+
children: _alloy_js_core.code`return this.options.find(option => option.value === this.value) ?? null; `
|
|
1438
|
+
}),
|
|
1439
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1440
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1441
|
+
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.",
|
|
1442
|
+
name: "getAction",
|
|
1443
|
+
override: true,
|
|
1444
|
+
"protected": true,
|
|
1445
|
+
parameters: [{
|
|
1446
|
+
name: "key",
|
|
1447
|
+
type: "Key"
|
|
1448
|
+
}],
|
|
1449
|
+
returnType: "string | false",
|
|
1450
|
+
children: _alloy_js_core.code`let action = super.getAction(key);
|
|
404
1451
|
if (!action) {
|
|
405
1452
|
if (key.name === "j") action = "down";
|
|
406
1453
|
if (key.name === "k") action = "up";
|
|
407
1454
|
}
|
|
408
1455
|
|
|
409
|
-
return action || false; `
|
|
410
|
-
|
|
1456
|
+
return action || false; `
|
|
1457
|
+
}),
|
|
1458
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1459
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1460
|
+
doc: "A method to reset the prompt input",
|
|
1461
|
+
name: "reset",
|
|
1462
|
+
override: true,
|
|
1463
|
+
"protected": true,
|
|
1464
|
+
children: _alloy_js_core.code`this.moveCursor(0);
|
|
1465
|
+
super.reset(); `
|
|
1466
|
+
}),
|
|
1467
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1468
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1469
|
+
doc: "A method to submit the prompt input",
|
|
1470
|
+
name: "submit",
|
|
1471
|
+
async: true,
|
|
1472
|
+
override: true,
|
|
1473
|
+
"protected": true,
|
|
1474
|
+
children: _alloy_js_core.code`if (!this.selectedOption?.disabled) {
|
|
411
1475
|
await super.submit();
|
|
412
1476
|
} else {
|
|
413
1477
|
this.bell();
|
|
414
|
-
} `
|
|
415
|
-
|
|
1478
|
+
} `
|
|
1479
|
+
}),
|
|
1480
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1481
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1482
|
+
doc: "A method to move the cursor to the end of the input",
|
|
1483
|
+
name: "next",
|
|
1484
|
+
"protected": true,
|
|
1485
|
+
children: _alloy_js_core.code`this.moveCursor((this.cursor + 1) % this.options.length);
|
|
1486
|
+
this.sync(); `
|
|
1487
|
+
}),
|
|
1488
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1489
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1490
|
+
doc: "A method to move the cursor to the left or right by a \\`count\\` of positions",
|
|
1491
|
+
name: "moveCursor",
|
|
1492
|
+
parameters: [{
|
|
1493
|
+
name: "count",
|
|
1494
|
+
type: "number"
|
|
1495
|
+
}],
|
|
1496
|
+
override: true,
|
|
1497
|
+
"protected": true,
|
|
1498
|
+
children: _alloy_js_core.code`this.cursor = count;
|
|
416
1499
|
|
|
417
1500
|
this.changeValue(this.options[count]!.value);
|
|
418
|
-
this.sync(); `
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
1501
|
+
this.sync(); `
|
|
1502
|
+
}),
|
|
1503
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1504
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1505
|
+
doc: "A method to move the cursor to the first option",
|
|
1506
|
+
name: "first",
|
|
1507
|
+
"protected": true,
|
|
1508
|
+
children: _alloy_js_core.code`this.moveCursor(0);
|
|
1509
|
+
this.sync(); `
|
|
1510
|
+
}),
|
|
1511
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1512
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1513
|
+
doc: "A method to move the cursor to the last option",
|
|
1514
|
+
name: "last",
|
|
1515
|
+
"protected": true,
|
|
1516
|
+
children: _alloy_js_core.code`this.moveCursor(this.options.length - 1);
|
|
1517
|
+
this.sync(); `
|
|
1518
|
+
}),
|
|
1519
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1520
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1521
|
+
doc: "A method to move the cursor to the start",
|
|
1522
|
+
name: "first",
|
|
1523
|
+
"protected": true,
|
|
1524
|
+
children: _alloy_js_core.code`this.cursor = 0;
|
|
1525
|
+
this.sync(); `
|
|
1526
|
+
}),
|
|
1527
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1528
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1529
|
+
doc: "A method to move the cursor to the up",
|
|
1530
|
+
name: "up",
|
|
1531
|
+
"protected": true,
|
|
1532
|
+
children: _alloy_js_core.code`if (this.cursor === 0) {
|
|
422
1533
|
this.moveCursor(this.options.length - 1);
|
|
423
1534
|
} else {
|
|
424
1535
|
this.moveCursor(this.cursor - 1);
|
|
425
1536
|
}
|
|
426
1537
|
|
|
427
|
-
this.sync(); `
|
|
1538
|
+
this.sync(); `
|
|
1539
|
+
}),
|
|
1540
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1541
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1542
|
+
doc: "A method to move the cursor to the down",
|
|
1543
|
+
name: "down",
|
|
1544
|
+
"protected": true,
|
|
1545
|
+
children: _alloy_js_core.code`if (this.cursor === this.options.length - 1) {
|
|
428
1546
|
this.moveCursor(0);
|
|
429
1547
|
} else {
|
|
430
1548
|
this.moveCursor(this.cursor + 1);
|
|
431
1549
|
}
|
|
432
1550
|
|
|
433
|
-
this.sync(); `
|
|
1551
|
+
this.sync(); `
|
|
1552
|
+
}),
|
|
1553
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1554
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1555
|
+
doc: "A method to render the prompt",
|
|
1556
|
+
name: "onRender",
|
|
1557
|
+
override: true,
|
|
1558
|
+
"protected": true,
|
|
1559
|
+
children: _alloy_js_core.code`const spacing = Math.max(...this.options.map(option => option.label?.length || 0)) + 2;
|
|
434
1560
|
|
|
435
1561
|
const startIndex = Math.max(Math.min(this.options.length - this.optionsPerPage, this.cursor - Math.floor(this.optionsPerPage / 2)), 0);
|
|
436
1562
|
const endIndex = Math.min(startIndex + this.optionsPerPage, this.options.length);
|
|
@@ -482,7 +1608,29 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
482
1608
|
output += super.onRender();
|
|
483
1609
|
}
|
|
484
1610
|
|
|
485
|
-
return output; `
|
|
1611
|
+
return output; `
|
|
1612
|
+
})
|
|
1613
|
+
];
|
|
1614
|
+
}
|
|
1615
|
+
}),
|
|
1616
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1617
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1618
|
+
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}.",
|
|
1619
|
+
get children() {
|
|
1620
|
+
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.` });
|
|
1621
|
+
}
|
|
1622
|
+
}),
|
|
1623
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
1624
|
+
"export": true,
|
|
1625
|
+
name: "SelectConfig",
|
|
1626
|
+
children: _alloy_js_core.code`PromptFactoryConfig<string> & SelectPromptConfig; `
|
|
1627
|
+
}),
|
|
1628
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1629
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1630
|
+
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.",
|
|
1631
|
+
get children() {
|
|
1632
|
+
return [
|
|
1633
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { select, isCancel } from "shell-shock:prompts";
|
|
486
1634
|
|
|
487
1635
|
async function run() {
|
|
488
1636
|
const color = await select({
|
|
@@ -504,13 +1652,558 @@ async function run() {
|
|
|
504
1652
|
console.log("Your favorite color is " + color + "!");
|
|
505
1653
|
}
|
|
506
1654
|
|
|
507
|
-
run(); `
|
|
1655
|
+
run(); ` }),
|
|
1656
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1657
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1658
|
+
name: "config",
|
|
1659
|
+
children: `The configuration options to pass to the select prompt, which extends the base PromptConfig with additional options specific to select prompts`
|
|
1660
|
+
}),
|
|
1661
|
+
(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` })
|
|
1662
|
+
];
|
|
1663
|
+
}
|
|
1664
|
+
}),
|
|
1665
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1666
|
+
name: "select",
|
|
1667
|
+
"export": true,
|
|
1668
|
+
parameters: [{
|
|
1669
|
+
name: "config",
|
|
1670
|
+
type: "SelectConfig"
|
|
1671
|
+
}],
|
|
1672
|
+
returnType: "Promise<string | symbol>",
|
|
1673
|
+
children: _alloy_js_core.code`return new Promise<string | symbol>((response, reject) => {
|
|
508
1674
|
const prompt = new SelectPrompt(config);
|
|
509
1675
|
|
|
510
1676
|
prompt.on("state", state => config.onState?.(state));
|
|
511
1677
|
prompt.on("submit", value => response(value));
|
|
512
1678
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
513
|
-
});`
|
|
1679
|
+
});`
|
|
1680
|
+
})
|
|
1681
|
+
];
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Declarations for a multi-select prompt that allows users to choose multiple options from a list, with support for disabled options, bulk selection shortcuts, and required validation. This prompt type is useful for scenarios where users need to select one or more values from a predefined set.
|
|
1685
|
+
*/
|
|
1686
|
+
function MultiSelectPromptDeclarations() {
|
|
1687
|
+
return [
|
|
1688
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
1689
|
+
name: "MultiSelectPromptConfig",
|
|
1690
|
+
"extends": "PromptConfig<TValue[]>",
|
|
1691
|
+
doc: "An options object for configuring a multi-select prompt",
|
|
1692
|
+
typeParameters: [{
|
|
1693
|
+
name: "TValue",
|
|
1694
|
+
default: "string"
|
|
1695
|
+
}],
|
|
1696
|
+
get children() {
|
|
1697
|
+
return [
|
|
1698
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1699
|
+
name: "options",
|
|
1700
|
+
type: "Array<string | PromptOptionConfig<TValue>>",
|
|
1701
|
+
doc: "The options available for the multi-select prompt"
|
|
1702
|
+
}),
|
|
1703
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1704
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1705
|
+
name: "required",
|
|
1706
|
+
required: false,
|
|
1707
|
+
type: "boolean",
|
|
1708
|
+
doc: "Whether at least one option must be selected, defaults to true"
|
|
1709
|
+
}),
|
|
1710
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1711
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1712
|
+
name: "initialValue",
|
|
1713
|
+
required: false,
|
|
1714
|
+
type: "TValue[]",
|
|
1715
|
+
doc: "The initial selected values"
|
|
1716
|
+
}),
|
|
1717
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1718
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1719
|
+
name: "cursorAt",
|
|
1720
|
+
required: false,
|
|
1721
|
+
type: "TValue",
|
|
1722
|
+
doc: "A value indicating which option should be focused initially"
|
|
1723
|
+
}),
|
|
1724
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1725
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
1726
|
+
name: "optionsPerPage",
|
|
1727
|
+
required: false,
|
|
1728
|
+
type: "number",
|
|
1729
|
+
doc: "The number of options to display per page, defaults to 8"
|
|
1730
|
+
})
|
|
1731
|
+
];
|
|
1732
|
+
}
|
|
1733
|
+
}),
|
|
1734
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1735
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
1736
|
+
name: "MultiSelectPrompt",
|
|
1737
|
+
doc: "A prompt for selecting multiple options from a list",
|
|
1738
|
+
"extends": "Prompt<TValue[]>",
|
|
1739
|
+
typeParameters: [{
|
|
1740
|
+
name: "TValue",
|
|
1741
|
+
default: "string"
|
|
1742
|
+
}],
|
|
1743
|
+
get children() {
|
|
1744
|
+
return [
|
|
1745
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1746
|
+
name: "initialValue",
|
|
1747
|
+
"protected": true,
|
|
1748
|
+
override: true,
|
|
1749
|
+
type: "TValue[]",
|
|
1750
|
+
children: _alloy_js_core.code`[]; `
|
|
1751
|
+
}),
|
|
1752
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1753
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1754
|
+
name: "required",
|
|
1755
|
+
"protected": true,
|
|
1756
|
+
type: "boolean",
|
|
1757
|
+
children: _alloy_js_core.code`true; `
|
|
1758
|
+
}),
|
|
1759
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1760
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1761
|
+
name: "optionsPerPage",
|
|
1762
|
+
"protected": true,
|
|
1763
|
+
type: "number",
|
|
1764
|
+
children: _alloy_js_core.code`8; `
|
|
1765
|
+
}),
|
|
1766
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1767
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1768
|
+
name: "options",
|
|
1769
|
+
"protected": true,
|
|
1770
|
+
type: "PromptOption<TValue>[]",
|
|
1771
|
+
children: _alloy_js_core.code`[]; `
|
|
1772
|
+
}),
|
|
1773
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1774
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1775
|
+
name: "cursorHidden",
|
|
1776
|
+
"protected": true,
|
|
1777
|
+
override: true,
|
|
1778
|
+
type: "boolean",
|
|
1779
|
+
children: _alloy_js_core.code`true; `
|
|
1780
|
+
}),
|
|
1781
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1782
|
+
_alloy_js_core.code`constructor(config: MultiSelectPromptConfig<TValue>) {
|
|
1783
|
+
super(config);
|
|
1784
|
+
|
|
1785
|
+
this.required = config.required ?? true;
|
|
1786
|
+
this.initialValue = Array.isArray(config.initialValue) ? [...config.initialValue] : [];
|
|
1787
|
+
|
|
1788
|
+
if (config.optionsPerPage) {
|
|
1789
|
+
this.optionsPerPage = config.optionsPerPage;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
this.options = config.options.map((opt, index) => {
|
|
1793
|
+
let option = {} as Partial<PromptOption<TValue>>;
|
|
1794
|
+
if (typeof opt === "string") {
|
|
1795
|
+
option = {
|
|
1796
|
+
label: opt,
|
|
1797
|
+
value: opt as TValue,
|
|
1798
|
+
selected: this.initialValue.includes(opt as TValue),
|
|
1799
|
+
disabled: false
|
|
1800
|
+
};
|
|
1801
|
+
} else if (typeof opt === "object" && opt !== null) {
|
|
1802
|
+
option = {
|
|
1803
|
+
...opt,
|
|
1804
|
+
selected: this.initialValue.includes(opt.value as TValue) || !!opt.selected
|
|
1805
|
+
};
|
|
1806
|
+
} else {
|
|
1807
|
+
throw new Error("Invalid option provided to MultiSelectPrompt at index #" + index);
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
return {
|
|
1811
|
+
label: option.label || String(option.value),
|
|
1812
|
+
...option,
|
|
1813
|
+
description: option.description,
|
|
1814
|
+
selected: !!option.selected,
|
|
1815
|
+
disabled: !!option.disabled,
|
|
1816
|
+
index
|
|
1817
|
+
} as PromptOption<TValue>;
|
|
1818
|
+
});
|
|
1819
|
+
|
|
1820
|
+
if (config.cursorAt !== undefined) {
|
|
1821
|
+
const index = this.options.findIndex(option => option.value === config.cursorAt);
|
|
1822
|
+
if (index > -1) {
|
|
1823
|
+
this.cursor = index;
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
if (this.options[this.cursor]?.disabled) {
|
|
1828
|
+
this.moveCursor(this.findNextEnabled(this.cursor, 1));
|
|
1829
|
+
} else {
|
|
1830
|
+
this.changeValue(this.getSelectedValues());
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
this.sync();
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
protected getAction(key: Key): string | false {
|
|
1837
|
+
let action = super.getAction(key);
|
|
1838
|
+
if (!action) {
|
|
1839
|
+
if (key.name === "j") action = "down";
|
|
1840
|
+
if (key.name === "k") action = "up";
|
|
1841
|
+
if (key.name === "a") action = "toggleAll";
|
|
1842
|
+
if (key.name === "i") action = "toggleInvert";
|
|
1843
|
+
if (key.name === "space") action = "toggleCurrent";
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
return action || false;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
protected override async submit() {
|
|
1850
|
+
const selectedValues = this.getSelectedValues();
|
|
1851
|
+
if (this.required && selectedValues.length === 0) {
|
|
1852
|
+
this.error(
|
|
1853
|
+
"Please select at least one option. Press <space> to toggle and <enter> to submit."
|
|
1854
|
+
);
|
|
1855
|
+
this.bell();
|
|
1856
|
+
return;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
this.changeValue(selectedValues);
|
|
1860
|
+
await super.submit();
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
protected toggleCurrent() {
|
|
1864
|
+
const option = this.options[this.cursor];
|
|
1865
|
+
if (!option || option.disabled) {
|
|
1866
|
+
this.bell();
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
option.selected = !option.selected;
|
|
1871
|
+
this.changeValue(this.getSelectedValues());
|
|
1872
|
+
this.sync();
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
protected toggleAll() {
|
|
1876
|
+
const enabled = this.options.filter(option => !option.disabled);
|
|
1877
|
+
const areAllSelected = enabled.every(option => option.selected);
|
|
1878
|
+
for (const option of enabled) {
|
|
1879
|
+
option.selected = !areAllSelected;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
this.changeValue(this.getSelectedValues());
|
|
1883
|
+
this.sync();
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
protected toggleInvert() {
|
|
1887
|
+
for (const option of this.options) {
|
|
1888
|
+
if (!option.disabled) {
|
|
1889
|
+
option.selected = !option.selected;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
this.changeValue(this.getSelectedValues());
|
|
1894
|
+
this.sync();
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
protected findNextEnabled(from: number, direction: 1 | -1): number {
|
|
1898
|
+
if (this.options.length === 0) {
|
|
1899
|
+
return 0;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
let index = from;
|
|
1903
|
+
for (let i = 0; i < this.options.length; i++) {
|
|
1904
|
+
index = (index + direction + this.options.length) % this.options.length;
|
|
1905
|
+
if (!this.options[index]?.disabled) {
|
|
1906
|
+
return index;
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
return from;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
protected getSelectedValues(): TValue[] {
|
|
1914
|
+
return this.options
|
|
1915
|
+
.filter(option => option.selected)
|
|
1916
|
+
.map(option => option.value as TValue);
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
protected next() {
|
|
1920
|
+
this.moveCursor(this.findNextEnabled(this.cursor, 1));
|
|
1921
|
+
this.sync();
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
protected up() {
|
|
1925
|
+
this.moveCursor(this.findNextEnabled(this.cursor, -1));
|
|
1926
|
+
this.sync();
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
protected down() {
|
|
1930
|
+
this.moveCursor(this.findNextEnabled(this.cursor, 1));
|
|
1931
|
+
this.sync();
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
protected first() {
|
|
1935
|
+
this.moveCursor(this.findNextEnabled(0, 1));
|
|
1936
|
+
this.sync();
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
protected last() {
|
|
1940
|
+
this.moveCursor(this.findNextEnabled(this.options.length - 1, -1));
|
|
1941
|
+
this.sync();
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
protected override moveCursor(count: number) {
|
|
1945
|
+
this.cursor = count;
|
|
1946
|
+
this.changeValue(this.getSelectedValues());
|
|
1947
|
+
this.sync();
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
protected override onRender() {
|
|
1951
|
+
const spacing = Math.max(...this.options.map(option => option.label?.length || 0), 0) + 2;
|
|
1952
|
+
const startIndex = Math.max(
|
|
1953
|
+
Math.min(
|
|
1954
|
+
this.options.length - this.optionsPerPage,
|
|
1955
|
+
this.cursor - Math.floor(this.optionsPerPage / 2)
|
|
1956
|
+
),
|
|
1957
|
+
0
|
|
1958
|
+
);
|
|
1959
|
+
const endIndex = Math.min(startIndex + this.optionsPerPage, this.options.length);
|
|
1960
|
+
|
|
1961
|
+
let output = "";
|
|
1962
|
+
if (!this.isCompleted) {
|
|
1963
|
+
output += " \\\n";
|
|
1964
|
+
|
|
1965
|
+
for (let index = startIndex; index < endIndex; index++) {
|
|
1966
|
+
const option = this.options[index]!;
|
|
1967
|
+
const active = this.cursor === index;
|
|
1968
|
+
const selected = !!option.selected;
|
|
1969
|
+
const disabled = !!option.disabled;
|
|
1970
|
+
|
|
1971
|
+
const pointer = disabled
|
|
1972
|
+
? active
|
|
1973
|
+
? bold(textColors.prompt.input.disabled(">"))
|
|
1974
|
+
: index === startIndex
|
|
1975
|
+
? borderColors.app.divider.tertiary("↑")
|
|
1976
|
+
: index === endIndex - 1
|
|
1977
|
+
? borderColors.app.divider.tertiary("↓")
|
|
1978
|
+
: " "
|
|
1979
|
+
: active
|
|
1980
|
+
? bold(textColors.prompt.input.active(">"))
|
|
1981
|
+
: index === startIndex
|
|
1982
|
+
? borderColors.app.divider.tertiary("↑")
|
|
1983
|
+
: index === endIndex - 1
|
|
1984
|
+
? borderColors.app.divider.tertiary("↓")
|
|
1985
|
+
: " ";
|
|
1986
|
+
|
|
1987
|
+
const marker = isUnicodeSupported ? (selected ? "🗹" : "☐") : (selected ? "[x]" : "[ ]");
|
|
1988
|
+
const markerText = disabled
|
|
1989
|
+
? active
|
|
1990
|
+
? bold(textColors.prompt.input.disabled(marker))
|
|
1991
|
+
: textColors.prompt.input.disabled(marker)
|
|
1992
|
+
: active
|
|
1993
|
+
? bold(textColors.prompt.input.active(marker))
|
|
1994
|
+
: textColors.prompt.input.inactive(marker);
|
|
1995
|
+
|
|
1996
|
+
const labelText = disabled
|
|
1997
|
+
? active
|
|
1998
|
+
? bold(underline(textColors.prompt.input.disabled(option.label)))
|
|
1999
|
+
: strikethrough(textColors.prompt.input.disabled(option.label))
|
|
2000
|
+
: active
|
|
2001
|
+
? bold(underline(textColors.prompt.input.active(option.label)))
|
|
2002
|
+
: selected
|
|
2003
|
+
? textColors.prompt.input.active(option.label)
|
|
2004
|
+
: textColors.prompt.input.inactive(option.label);
|
|
2005
|
+
|
|
2006
|
+
output +=
|
|
2007
|
+
pointer +
|
|
2008
|
+
" " +
|
|
2009
|
+
markerText +
|
|
2010
|
+
" " +
|
|
2011
|
+
labelText +
|
|
2012
|
+
" " +
|
|
2013
|
+
" ".repeat(Math.max(0, spacing - option.label.length)) +
|
|
2014
|
+
(option.description && active
|
|
2015
|
+
? italic(textColors.prompt.description.active(option.description))
|
|
2016
|
+
: "") +
|
|
2017
|
+
" \\\n";
|
|
2018
|
+
}
|
|
2019
|
+
} else {
|
|
2020
|
+
const selected = this.options.filter(option => option.selected);
|
|
2021
|
+
this.displayValue =
|
|
2022
|
+
selected.length > 0
|
|
2023
|
+
? selected.map(option => option.label).join(", ")
|
|
2024
|
+
: "(none)";
|
|
2025
|
+
output += super.onRender();
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
return output;
|
|
2029
|
+
}`
|
|
2030
|
+
];
|
|
2031
|
+
}
|
|
2032
|
+
}),
|
|
2033
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2034
|
+
(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 multi-select prompt, which extends the base PromptConfig with additional options specific to multi-select prompts." }),
|
|
2035
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2036
|
+
"export": true,
|
|
2037
|
+
name: "MultiSelectConfig",
|
|
2038
|
+
children: _alloy_js_core.code`PromptFactoryConfig<string[]> & MultiSelectPromptConfig; `
|
|
2039
|
+
}),
|
|
2040
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2041
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2042
|
+
heading: "A function to create and run a multi-select prompt, which returns a promise that resolves with the submitted values or a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled.",
|
|
2043
|
+
get children() {
|
|
2044
|
+
return [
|
|
2045
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { multiselect, isCancel } from "shell-shock:prompts";
|
|
2046
|
+
|
|
2047
|
+
async function run() {
|
|
2048
|
+
const tools = await multiselect({
|
|
2049
|
+
message: "Select tools",
|
|
2050
|
+
options: [
|
|
2051
|
+
{ value: "eslint", label: "ESLint" },
|
|
2052
|
+
{ value: "prettier", label: "Prettier" },
|
|
2053
|
+
{ value: "vitest", label: "Vitest", disabled: true }
|
|
2054
|
+
]
|
|
2055
|
+
});
|
|
2056
|
+
|
|
2057
|
+
if (isCancel(tools)) {
|
|
2058
|
+
console.log("Prompt was cancelled");
|
|
2059
|
+
return;
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
console.log("Selected tools:", tools.join(", "));
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
run(); ` }),
|
|
2066
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2067
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2068
|
+
name: "config",
|
|
2069
|
+
children: `The configuration options to pass to the multi-select prompt`
|
|
2070
|
+
}),
|
|
2071
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A promise that resolves with the selected values or a {@link CANCEL_SYMBOL | cancel symbol} if the prompt is cancelled` })
|
|
2072
|
+
];
|
|
2073
|
+
}
|
|
2074
|
+
}),
|
|
2075
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2076
|
+
name: "multiselect",
|
|
2077
|
+
"export": true,
|
|
2078
|
+
parameters: [{
|
|
2079
|
+
name: "config",
|
|
2080
|
+
type: "MultiSelectConfig"
|
|
2081
|
+
}],
|
|
2082
|
+
returnType: "Promise<string[] | symbol>",
|
|
2083
|
+
children: _alloy_js_core.code`return new Promise<string[] | symbol>((response, reject) => {
|
|
2084
|
+
const prompt = new MultiSelectPrompt(config);
|
|
2085
|
+
|
|
2086
|
+
prompt.on("state", state => config.onState?.(state));
|
|
2087
|
+
prompt.on("submit", value => response(value));
|
|
2088
|
+
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
2089
|
+
});`
|
|
2090
|
+
})
|
|
2091
|
+
];
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* 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.
|
|
2095
|
+
*/
|
|
2096
|
+
function NumericPromptDeclarations() {
|
|
2097
|
+
return [
|
|
2098
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
2099
|
+
name: "NumberPromptConfig",
|
|
2100
|
+
"extends": "PromptConfig<number>",
|
|
2101
|
+
doc: "Configuration options for creating a numeric prompt",
|
|
2102
|
+
get children() {
|
|
2103
|
+
return [
|
|
2104
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2105
|
+
name: "isFloat",
|
|
2106
|
+
required: false,
|
|
2107
|
+
type: "boolean",
|
|
2108
|
+
doc: "Whether the prompt should accept floating point numbers"
|
|
2109
|
+
}),
|
|
2110
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2111
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2112
|
+
name: "precision",
|
|
2113
|
+
required: false,
|
|
2114
|
+
type: "number",
|
|
2115
|
+
doc: "The number of decimal places to round the input to, defaults to 2"
|
|
2116
|
+
}),
|
|
2117
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2118
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2119
|
+
name: "increment",
|
|
2120
|
+
required: false,
|
|
2121
|
+
type: "number",
|
|
2122
|
+
doc: "The increment value for the number prompt, defaults to 1"
|
|
2123
|
+
}),
|
|
2124
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2125
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2126
|
+
name: "min",
|
|
2127
|
+
required: false,
|
|
2128
|
+
type: "number",
|
|
2129
|
+
doc: "The minimum value for the number prompt, defaults to -Infinity"
|
|
2130
|
+
}),
|
|
2131
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2132
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2133
|
+
name: "max",
|
|
2134
|
+
required: false,
|
|
2135
|
+
type: "number",
|
|
2136
|
+
doc: "The maximum value for the number prompt, defaults to Infinity"
|
|
2137
|
+
})
|
|
2138
|
+
];
|
|
2139
|
+
}
|
|
2140
|
+
}),
|
|
2141
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2142
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
2143
|
+
name: "NumberPrompt",
|
|
2144
|
+
doc: "A prompt for selecting a number input",
|
|
2145
|
+
"extends": "Prompt<number>",
|
|
2146
|
+
get children() {
|
|
2147
|
+
return [
|
|
2148
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2149
|
+
name: "isInvalid",
|
|
2150
|
+
isPrivateMember: true,
|
|
2151
|
+
type: "boolean",
|
|
2152
|
+
children: _alloy_js_core.code`false; `
|
|
2153
|
+
}),
|
|
2154
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2155
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2156
|
+
name: "initialValue",
|
|
2157
|
+
"protected": true,
|
|
2158
|
+
override: true,
|
|
2159
|
+
type: "number",
|
|
2160
|
+
children: _alloy_js_core.code`0; `
|
|
2161
|
+
}),
|
|
2162
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2163
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2164
|
+
name: "defaultErrorMessage",
|
|
2165
|
+
"protected": true,
|
|
2166
|
+
override: true,
|
|
2167
|
+
type: "string",
|
|
2168
|
+
children: _alloy_js_core.code`"A valid numeric value must be provided"; `
|
|
2169
|
+
}),
|
|
2170
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2171
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2172
|
+
name: "isFloat",
|
|
2173
|
+
"protected": true,
|
|
2174
|
+
type: "boolean",
|
|
2175
|
+
children: _alloy_js_core.code`false; `
|
|
2176
|
+
}),
|
|
2177
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2178
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2179
|
+
name: "precision",
|
|
2180
|
+
"protected": true,
|
|
2181
|
+
type: "number",
|
|
2182
|
+
children: _alloy_js_core.code`2; `
|
|
2183
|
+
}),
|
|
2184
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2185
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2186
|
+
name: "increment",
|
|
2187
|
+
"protected": true,
|
|
2188
|
+
type: "number",
|
|
2189
|
+
children: _alloy_js_core.code`1; `
|
|
2190
|
+
}),
|
|
2191
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2192
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2193
|
+
name: "min",
|
|
2194
|
+
"protected": true,
|
|
2195
|
+
type: "number",
|
|
2196
|
+
children: _alloy_js_core.code`Number.NEGATIVE_INFINITY; `
|
|
2197
|
+
}),
|
|
2198
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2199
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2200
|
+
name: "max",
|
|
2201
|
+
"protected": true,
|
|
2202
|
+
type: "number",
|
|
2203
|
+
children: _alloy_js_core.code`Number.POSITIVE_INFINITY; `
|
|
2204
|
+
}),
|
|
2205
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2206
|
+
_alloy_js_core.code`constructor(config: NumberPromptConfig) {
|
|
514
2207
|
super(config);
|
|
515
2208
|
|
|
516
2209
|
if (config.initialValue) {
|
|
@@ -550,7 +2243,21 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
550
2243
|
this.cursor = 0;
|
|
551
2244
|
this.sync();
|
|
552
2245
|
this.last();
|
|
553
|
-
} `,
|
|
2246
|
+
} `,
|
|
2247
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2248
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2249
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
2250
|
+
name: "onKeyPress",
|
|
2251
|
+
override: true,
|
|
2252
|
+
"protected": true,
|
|
2253
|
+
parameters: [{
|
|
2254
|
+
name: "char",
|
|
2255
|
+
type: "string"
|
|
2256
|
+
}, {
|
|
2257
|
+
name: "key",
|
|
2258
|
+
type: "Key"
|
|
2259
|
+
}],
|
|
2260
|
+
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
554
2261
|
if (action && typeof (this as any)[action] === "function") {
|
|
555
2262
|
return (this as any)[action]();
|
|
556
2263
|
}
|
|
@@ -578,10 +2285,45 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
578
2285
|
}
|
|
579
2286
|
|
|
580
2287
|
this.changeValue(value);
|
|
581
|
-
this.sync(); `
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
2288
|
+
this.sync(); `
|
|
2289
|
+
}),
|
|
2290
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2291
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2292
|
+
doc: "A method to handle changes in the prompt value",
|
|
2293
|
+
name: "onChange",
|
|
2294
|
+
override: true,
|
|
2295
|
+
"protected": true,
|
|
2296
|
+
parameters: [{
|
|
2297
|
+
name: "previousValue",
|
|
2298
|
+
type: "number"
|
|
2299
|
+
}],
|
|
2300
|
+
children: _alloy_js_core.code`this.#isInvalid = false;
|
|
2301
|
+
this.cursor = this.displayValue.slice(0, this.cursor).length + 1; `
|
|
2302
|
+
}),
|
|
2303
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2304
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2305
|
+
doc: "A method to validate the prompt input",
|
|
2306
|
+
name: "checkValidations",
|
|
2307
|
+
override: true,
|
|
2308
|
+
async: true,
|
|
2309
|
+
"protected": true,
|
|
2310
|
+
children: _alloy_js_core.code`await super.checkValidations(this.value);
|
|
2311
|
+
this.#isInvalid = this.isError; `
|
|
2312
|
+
}),
|
|
2313
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2314
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2315
|
+
doc: "A method to move the cursor to the end of the input",
|
|
2316
|
+
name: "next",
|
|
2317
|
+
"protected": true,
|
|
2318
|
+
children: _alloy_js_core.code`this.changeValue(this.initialValue);
|
|
2319
|
+
this.sync(); `
|
|
2320
|
+
}),
|
|
2321
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2322
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2323
|
+
doc: "A method to move the cursor to the up",
|
|
2324
|
+
name: "up",
|
|
2325
|
+
"protected": true,
|
|
2326
|
+
children: _alloy_js_core.code`let value = this.value;
|
|
585
2327
|
if (this.isPlaceholder) {
|
|
586
2328
|
value = this.min < 0 ? 0 : this.min;
|
|
587
2329
|
} else if (value >= this.max) {
|
|
@@ -591,7 +2333,14 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
591
2333
|
this.changeValue(value + this.increment);
|
|
592
2334
|
|
|
593
2335
|
this.sync();
|
|
594
|
-
this.last(); `
|
|
2336
|
+
this.last(); `
|
|
2337
|
+
}),
|
|
2338
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2339
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2340
|
+
doc: "A method to move the cursor to the down",
|
|
2341
|
+
name: "down",
|
|
2342
|
+
"protected": true,
|
|
2343
|
+
children: _alloy_js_core.code`let value = this.value;
|
|
595
2344
|
if (this.isPlaceholder) {
|
|
596
2345
|
value = this.min < 0 ? 0 : this.min;
|
|
597
2346
|
} else if (value <= this.min) {
|
|
@@ -600,19 +2349,56 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
600
2349
|
|
|
601
2350
|
this.changeValue(value === this.min ? this.min : value - this.increment);
|
|
602
2351
|
this.sync();
|
|
603
|
-
this.last(); `
|
|
2352
|
+
this.last(); `
|
|
2353
|
+
}),
|
|
2354
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2355
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2356
|
+
doc: "A method to move the cursor to the left",
|
|
2357
|
+
name: "left",
|
|
2358
|
+
"protected": true,
|
|
2359
|
+
children: _alloy_js_core.code`if (this.cursor <= 0) {
|
|
604
2360
|
return this.bell();
|
|
605
2361
|
}
|
|
606
2362
|
|
|
607
2363
|
this.moveCursor(-1);
|
|
608
|
-
this.sync(); `
|
|
2364
|
+
this.sync(); `
|
|
2365
|
+
}),
|
|
2366
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2367
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2368
|
+
doc: "A method to move the cursor to the right",
|
|
2369
|
+
name: "right",
|
|
2370
|
+
"protected": true,
|
|
2371
|
+
children: _alloy_js_core.code`if (this.cursor >= this.displayValue.length) {
|
|
609
2372
|
return this.bell();
|
|
610
2373
|
}
|
|
611
2374
|
|
|
612
2375
|
this.moveCursor(1);
|
|
613
|
-
this.sync(); `
|
|
614
|
-
|
|
615
|
-
|
|
2376
|
+
this.sync(); `
|
|
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_class_declaration.ClassMethod, {
|
|
2380
|
+
doc: "A method to move the cursor to the start",
|
|
2381
|
+
name: "first",
|
|
2382
|
+
"protected": true,
|
|
2383
|
+
children: _alloy_js_core.code`this.cursor = 0;
|
|
2384
|
+
this.sync(); `
|
|
2385
|
+
}),
|
|
2386
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2387
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2388
|
+
doc: "A method to move the cursor to the end",
|
|
2389
|
+
name: "last",
|
|
2390
|
+
"protected": true,
|
|
2391
|
+
children: _alloy_js_core.code`this.cursor = this.displayValue.length;
|
|
2392
|
+
this.sync(); `
|
|
2393
|
+
}),
|
|
2394
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2395
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2396
|
+
doc: "A method to render the prompt",
|
|
2397
|
+
name: "onRender",
|
|
2398
|
+
override: true,
|
|
2399
|
+
"protected": true,
|
|
2400
|
+
returnType: "string",
|
|
2401
|
+
children: _alloy_js_core.code`return this.isPlaceholder
|
|
616
2402
|
? textColors.prompt.input.disabled(this.displayValue)
|
|
617
2403
|
: this.#isInvalid
|
|
618
2404
|
? textColors.prompt.input.error(this.displayValue)
|
|
@@ -620,7 +2406,24 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
620
2406
|
? textColors.prompt.input.submitted(this.displayValue)
|
|
621
2407
|
: this.isCancelled
|
|
622
2408
|
? textColors.prompt.input.cancelled(this.displayValue)
|
|
623
|
-
: bold(textColors.prompt.input.active(this.displayValue)); `
|
|
2409
|
+
: bold(textColors.prompt.input.active(this.displayValue)); `
|
|
2410
|
+
})
|
|
2411
|
+
];
|
|
2412
|
+
}
|
|
2413
|
+
}),
|
|
2414
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2415
|
+
(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." }),
|
|
2416
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2417
|
+
name: "NumericConfig",
|
|
2418
|
+
"export": true,
|
|
2419
|
+
children: _alloy_js_core.code`PromptFactoryConfig<number> & NumberPromptConfig; `
|
|
2420
|
+
}),
|
|
2421
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2422
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2423
|
+
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.",
|
|
2424
|
+
get children() {
|
|
2425
|
+
return [
|
|
2426
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { numeric, isCancel } from "shell-shock:prompts";
|
|
624
2427
|
|
|
625
2428
|
async function run() {
|
|
626
2429
|
const age = await numeric({
|
|
@@ -636,13 +2439,102 @@ async function run() {
|
|
|
636
2439
|
console.log("Your age is " + age + "!");
|
|
637
2440
|
}
|
|
638
2441
|
|
|
639
|
-
run(); `
|
|
2442
|
+
run(); ` }),
|
|
2443
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2444
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2445
|
+
name: "config",
|
|
2446
|
+
children: `The configuration options to pass to the numeric prompt, which extends the base PromptFactoryConfig with additional options specific to numeric prompts`
|
|
2447
|
+
}),
|
|
2448
|
+
(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` })
|
|
2449
|
+
];
|
|
2450
|
+
}
|
|
2451
|
+
}),
|
|
2452
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2453
|
+
name: "numeric",
|
|
2454
|
+
"export": true,
|
|
2455
|
+
parameters: [{
|
|
2456
|
+
name: "config",
|
|
2457
|
+
type: "NumericConfig"
|
|
2458
|
+
}],
|
|
2459
|
+
returnType: "Promise<number | symbol>",
|
|
2460
|
+
children: _alloy_js_core.code`return new Promise<number | symbol>((response, reject) => {
|
|
640
2461
|
const prompt = new NumberPrompt(config);
|
|
641
2462
|
|
|
642
2463
|
prompt.on("state", state => config.onState?.(state));
|
|
643
2464
|
prompt.on("submit", value => response(value));
|
|
644
2465
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
645
|
-
});`
|
|
2466
|
+
});`
|
|
2467
|
+
})
|
|
2468
|
+
];
|
|
2469
|
+
}
|
|
2470
|
+
/**
|
|
2471
|
+
* 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.
|
|
2472
|
+
*/
|
|
2473
|
+
function TogglePromptDeclarations() {
|
|
2474
|
+
return [
|
|
2475
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
2476
|
+
"export": true,
|
|
2477
|
+
name: "TogglePromptConfig",
|
|
2478
|
+
"extends": "PromptConfig<boolean>",
|
|
2479
|
+
doc: "Configuration options for creating a boolean toggle prompt",
|
|
2480
|
+
get children() {
|
|
2481
|
+
return [
|
|
2482
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2483
|
+
name: "trueMessage",
|
|
2484
|
+
required: false,
|
|
2485
|
+
type: "string",
|
|
2486
|
+
doc: "The message for the true state of the prompt"
|
|
2487
|
+
}),
|
|
2488
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2489
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2490
|
+
name: "falseMessage",
|
|
2491
|
+
required: false,
|
|
2492
|
+
type: "string",
|
|
2493
|
+
doc: "The message for the false state of the prompt"
|
|
2494
|
+
}),
|
|
2495
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
2496
|
+
];
|
|
2497
|
+
}
|
|
2498
|
+
}),
|
|
2499
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2500
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
2501
|
+
"export": true,
|
|
2502
|
+
name: "TogglePrompt",
|
|
2503
|
+
doc: "A prompt for toggling a boolean input",
|
|
2504
|
+
"extends": "Prompt<boolean>",
|
|
2505
|
+
get children() {
|
|
2506
|
+
return [
|
|
2507
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2508
|
+
name: "initialValue",
|
|
2509
|
+
"protected": true,
|
|
2510
|
+
override: true,
|
|
2511
|
+
type: "boolean",
|
|
2512
|
+
children: _alloy_js_core.code`false; `
|
|
2513
|
+
}),
|
|
2514
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2515
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2516
|
+
name: "trueMessage",
|
|
2517
|
+
"protected": true,
|
|
2518
|
+
type: "string",
|
|
2519
|
+
children: _alloy_js_core.code`"Yes"; `
|
|
2520
|
+
}),
|
|
2521
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2522
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2523
|
+
name: "falseMessage",
|
|
2524
|
+
"protected": true,
|
|
2525
|
+
type: "string",
|
|
2526
|
+
children: _alloy_js_core.code`"No"; `
|
|
2527
|
+
}),
|
|
2528
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2529
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2530
|
+
name: "cursorHidden",
|
|
2531
|
+
"protected": true,
|
|
2532
|
+
override: true,
|
|
2533
|
+
type: "boolean",
|
|
2534
|
+
children: _alloy_js_core.code`true; `
|
|
2535
|
+
}),
|
|
2536
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2537
|
+
_alloy_js_core.code`constructor(config: TogglePromptConfig) {
|
|
646
2538
|
super(config);
|
|
647
2539
|
|
|
648
2540
|
if (config.initialValue) {
|
|
@@ -657,17 +2549,45 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
657
2549
|
}
|
|
658
2550
|
|
|
659
2551
|
this.sync();
|
|
660
|
-
} `,
|
|
2552
|
+
} `,
|
|
2553
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2554
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2555
|
+
doc: "Update the toggle value to a checked state based on user input",
|
|
2556
|
+
name: "check",
|
|
2557
|
+
"protected": true,
|
|
2558
|
+
children: _alloy_js_core.code`if (this.value === true) {
|
|
661
2559
|
return this.bell();
|
|
662
2560
|
}
|
|
663
2561
|
|
|
664
2562
|
this.changeValue(true);
|
|
665
|
-
this.sync(); `
|
|
2563
|
+
this.sync(); `
|
|
2564
|
+
}),
|
|
2565
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2566
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2567
|
+
doc: "Update the toggle value to an unchecked state based on user input",
|
|
2568
|
+
name: "uncheck",
|
|
2569
|
+
"protected": true,
|
|
2570
|
+
children: _alloy_js_core.code`if (this.value === false) {
|
|
666
2571
|
return this.bell();
|
|
667
2572
|
}
|
|
668
2573
|
|
|
669
2574
|
this.changeValue(false);
|
|
670
|
-
this.sync(); `
|
|
2575
|
+
this.sync(); `
|
|
2576
|
+
}),
|
|
2577
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2578
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2579
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
2580
|
+
name: "onKeyPress",
|
|
2581
|
+
override: true,
|
|
2582
|
+
"protected": true,
|
|
2583
|
+
parameters: [{
|
|
2584
|
+
name: "char",
|
|
2585
|
+
type: "string"
|
|
2586
|
+
}, {
|
|
2587
|
+
name: "key",
|
|
2588
|
+
type: "Key"
|
|
2589
|
+
}],
|
|
2590
|
+
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
671
2591
|
if (action && typeof (this as any)[action] === "function") {
|
|
672
2592
|
return (this as any)[action]();
|
|
673
2593
|
}
|
|
@@ -682,8 +2602,59 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
682
2602
|
return this.bell();
|
|
683
2603
|
}
|
|
684
2604
|
|
|
685
|
-
this.sync(); `
|
|
686
|
-
|
|
2605
|
+
this.sync(); `
|
|
2606
|
+
}),
|
|
2607
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2608
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2609
|
+
doc: "A method to remove the character backward of the cursor",
|
|
2610
|
+
name: "backspace",
|
|
2611
|
+
"protected": true,
|
|
2612
|
+
children: _alloy_js_core.code`this.uncheck(); `
|
|
2613
|
+
}),
|
|
2614
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2615
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2616
|
+
doc: "A method to move the cursor to the left",
|
|
2617
|
+
name: "left",
|
|
2618
|
+
"protected": true,
|
|
2619
|
+
children: _alloy_js_core.code`this.uncheck(); `
|
|
2620
|
+
}),
|
|
2621
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2622
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2623
|
+
doc: "A method to move the cursor to the right",
|
|
2624
|
+
name: "right",
|
|
2625
|
+
"protected": true,
|
|
2626
|
+
children: _alloy_js_core.code`this.check(); `
|
|
2627
|
+
}),
|
|
2628
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2629
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2630
|
+
doc: "A method to move the cursor to down",
|
|
2631
|
+
name: "down",
|
|
2632
|
+
"protected": true,
|
|
2633
|
+
children: _alloy_js_core.code`this.uncheck(); `
|
|
2634
|
+
}),
|
|
2635
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2636
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2637
|
+
doc: "A method to move the cursor to up",
|
|
2638
|
+
name: "up",
|
|
2639
|
+
"protected": true,
|
|
2640
|
+
children: _alloy_js_core.code`this.check(); `
|
|
2641
|
+
}),
|
|
2642
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2643
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2644
|
+
doc: "A method to move to the next value",
|
|
2645
|
+
name: "next",
|
|
2646
|
+
"protected": true,
|
|
2647
|
+
children: _alloy_js_core.code`this.changeValue(!this.value);
|
|
2648
|
+
this.sync(); `
|
|
2649
|
+
}),
|
|
2650
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2651
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2652
|
+
doc: "A method to render the prompt",
|
|
2653
|
+
name: "onRender",
|
|
2654
|
+
override: true,
|
|
2655
|
+
"protected": true,
|
|
2656
|
+
returnType: "string",
|
|
2657
|
+
children: _alloy_js_core.code`return this.isSubmitted
|
|
687
2658
|
? textColors.prompt.input.submitted(this.value ? this.trueMessage : this.falseMessage)
|
|
688
2659
|
: this.isCancelled
|
|
689
2660
|
? textColors.prompt.input.cancelled(this.value ? this.trueMessage : this.falseMessage)
|
|
@@ -691,7 +2662,24 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
691
2662
|
this.value ? textColors.prompt.input.inactive(this.falseMessage) : underline(bold(textColors.prompt.input.active(this.falseMessage)))
|
|
692
2663
|
} \${borderColors.app.divider.tertiary("/")} \${
|
|
693
2664
|
this.value ? underline(bold(textColors.prompt.input.active(this.trueMessage))) : textColors.prompt.input.inactive(this.trueMessage)
|
|
694
|
-
}\`; `
|
|
2665
|
+
}\`; `
|
|
2666
|
+
})
|
|
2667
|
+
];
|
|
2668
|
+
}
|
|
2669
|
+
}),
|
|
2670
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2671
|
+
(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." }),
|
|
2672
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2673
|
+
name: "ToggleConfig",
|
|
2674
|
+
"export": true,
|
|
2675
|
+
children: _alloy_js_core.code`PromptFactoryConfig<boolean> & TogglePromptConfig; `
|
|
2676
|
+
}),
|
|
2677
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2678
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2679
|
+
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.",
|
|
2680
|
+
get children() {
|
|
2681
|
+
return [
|
|
2682
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { toggle, isCancel } from "shell-shock:prompts";
|
|
695
2683
|
|
|
696
2684
|
async function run() {
|
|
697
2685
|
const likesIceCream = await toggle({
|
|
@@ -705,13 +2693,161 @@ async function run() {
|
|
|
705
2693
|
console.log("You" + (likesIceCream ? " like ice cream" : " don't like ice cream") + "!");
|
|
706
2694
|
}
|
|
707
2695
|
|
|
708
|
-
run(); `
|
|
2696
|
+
run(); ` }),
|
|
2697
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2698
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2699
|
+
name: "config",
|
|
2700
|
+
children: `The configuration options to pass to the toggle prompt, which extends the base PromptFactoryConfig with additional options specific to the toggle prompt`
|
|
2701
|
+
}),
|
|
2702
|
+
(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` })
|
|
2703
|
+
];
|
|
2704
|
+
}
|
|
2705
|
+
}),
|
|
2706
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2707
|
+
name: "toggle",
|
|
2708
|
+
"export": true,
|
|
2709
|
+
parameters: [{
|
|
2710
|
+
name: "config",
|
|
2711
|
+
type: "ToggleConfig"
|
|
2712
|
+
}],
|
|
2713
|
+
returnType: "Promise<boolean | symbol>",
|
|
2714
|
+
children: _alloy_js_core.code`return new Promise<boolean | symbol>((response, reject) => {
|
|
709
2715
|
const prompt = new TogglePrompt(config);
|
|
710
2716
|
|
|
711
2717
|
prompt.on("state", state => config.onState?.(state));
|
|
712
2718
|
prompt.on("submit", value => response(value));
|
|
713
2719
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
714
|
-
});`
|
|
2720
|
+
});`
|
|
2721
|
+
})
|
|
2722
|
+
];
|
|
2723
|
+
}
|
|
2724
|
+
/**
|
|
2725
|
+
* 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.
|
|
2726
|
+
*/
|
|
2727
|
+
function ConfirmPromptDeclarations() {
|
|
2728
|
+
return [
|
|
2729
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
2730
|
+
"export": true,
|
|
2731
|
+
name: "ConfirmPromptConfig",
|
|
2732
|
+
"extends": "PromptConfig<boolean>",
|
|
2733
|
+
doc: "Configuration options for creating a boolean confirm prompt",
|
|
2734
|
+
get children() {
|
|
2735
|
+
return [
|
|
2736
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2737
|
+
heading: "The message for the \\`Yes\\` state of the prompt",
|
|
2738
|
+
get children() {
|
|
2739
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2740
|
+
type: "string",
|
|
2741
|
+
defaultValue: "Yes"
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
}),
|
|
2745
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2746
|
+
name: "yesMessage",
|
|
2747
|
+
required: false,
|
|
2748
|
+
type: "string"
|
|
2749
|
+
}),
|
|
2750
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2751
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2752
|
+
heading: "The \\`Yes\\` option when choosing between yes/no",
|
|
2753
|
+
get children() {
|
|
2754
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2755
|
+
type: "string",
|
|
2756
|
+
defaultValue: "1"
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
}),
|
|
2760
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2761
|
+
name: "yesOption",
|
|
2762
|
+
required: false,
|
|
2763
|
+
type: "string"
|
|
2764
|
+
}),
|
|
2765
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2766
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2767
|
+
heading: "The message for the \\`No\\` state of the prompt",
|
|
2768
|
+
get children() {
|
|
2769
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2770
|
+
type: "string",
|
|
2771
|
+
defaultValue: "(Y/n)"
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
}),
|
|
2775
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2776
|
+
name: "noMessage",
|
|
2777
|
+
required: false,
|
|
2778
|
+
type: "string"
|
|
2779
|
+
}),
|
|
2780
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2781
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2782
|
+
heading: "The \\`No\\` option when choosing between yes/no",
|
|
2783
|
+
get children() {
|
|
2784
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2785
|
+
type: "string",
|
|
2786
|
+
defaultValue: "(y/N)"
|
|
2787
|
+
});
|
|
2788
|
+
}
|
|
2789
|
+
}),
|
|
2790
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2791
|
+
name: "noOption",
|
|
2792
|
+
required: false,
|
|
2793
|
+
type: "string"
|
|
2794
|
+
})
|
|
2795
|
+
];
|
|
2796
|
+
}
|
|
2797
|
+
}),
|
|
2798
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2799
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
2800
|
+
"export": true,
|
|
2801
|
+
name: "ConfirmPrompt",
|
|
2802
|
+
doc: "A prompt for confirming a boolean input",
|
|
2803
|
+
"extends": "Prompt<boolean>",
|
|
2804
|
+
get children() {
|
|
2805
|
+
return [
|
|
2806
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2807
|
+
name: "initialValue",
|
|
2808
|
+
"protected": true,
|
|
2809
|
+
override: true,
|
|
2810
|
+
type: "boolean",
|
|
2811
|
+
children: _alloy_js_core.code`false; `
|
|
2812
|
+
}),
|
|
2813
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2814
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2815
|
+
name: "yesMessage",
|
|
2816
|
+
"protected": true,
|
|
2817
|
+
type: "string",
|
|
2818
|
+
children: _alloy_js_core.code`"Yes"; `
|
|
2819
|
+
}),
|
|
2820
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2821
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2822
|
+
name: "yesOption",
|
|
2823
|
+
"protected": true,
|
|
2824
|
+
type: "string",
|
|
2825
|
+
children: _alloy_js_core.code`"(Y/n)"; `
|
|
2826
|
+
}),
|
|
2827
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2828
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2829
|
+
name: "noMessage",
|
|
2830
|
+
"protected": true,
|
|
2831
|
+
type: "string",
|
|
2832
|
+
children: _alloy_js_core.code`"No"; `
|
|
2833
|
+
}),
|
|
2834
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2835
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2836
|
+
name: "noOption",
|
|
2837
|
+
"protected": true,
|
|
2838
|
+
type: "string",
|
|
2839
|
+
children: _alloy_js_core.code`"(y/N)"; `
|
|
2840
|
+
}),
|
|
2841
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2842
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2843
|
+
name: "cursorHidden",
|
|
2844
|
+
"protected": true,
|
|
2845
|
+
override: true,
|
|
2846
|
+
type: "boolean",
|
|
2847
|
+
children: _alloy_js_core.code`true; `
|
|
2848
|
+
}),
|
|
2849
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2850
|
+
_alloy_js_core.code`constructor(config: ConfirmPromptConfig) {
|
|
715
2851
|
super(config);
|
|
716
2852
|
|
|
717
2853
|
if (config.initialValue) {
|
|
@@ -732,7 +2868,21 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
732
2868
|
}
|
|
733
2869
|
|
|
734
2870
|
this.sync();
|
|
735
|
-
} `,
|
|
2871
|
+
} `,
|
|
2872
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2873
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2874
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
2875
|
+
name: "onKeyPress",
|
|
2876
|
+
override: true,
|
|
2877
|
+
"protected": true,
|
|
2878
|
+
parameters: [{
|
|
2879
|
+
name: "char",
|
|
2880
|
+
type: "string"
|
|
2881
|
+
}, {
|
|
2882
|
+
name: "key",
|
|
2883
|
+
type: "Key"
|
|
2884
|
+
}],
|
|
2885
|
+
children: _alloy_js_core.code`const action = this.getAction(key);
|
|
736
2886
|
if (action && typeof (this as any)[action] === "function") {
|
|
737
2887
|
return (this as any)[action]();
|
|
738
2888
|
}
|
|
@@ -745,11 +2895,37 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
745
2895
|
return this.submit();
|
|
746
2896
|
} else {
|
|
747
2897
|
return this.bell();
|
|
748
|
-
} `
|
|
2898
|
+
} `
|
|
2899
|
+
}),
|
|
2900
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2901
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2902
|
+
doc: "A method to render the prompt",
|
|
2903
|
+
name: "onRender",
|
|
2904
|
+
override: true,
|
|
2905
|
+
"protected": true,
|
|
2906
|
+
returnType: "string",
|
|
2907
|
+
children: _alloy_js_core.code`return this.isSubmitted
|
|
749
2908
|
? textColors.prompt.input.submitted(this.value ? this.yesMessage : this.noMessage)
|
|
750
2909
|
: this.isCancelled
|
|
751
2910
|
? textColors.prompt.input.cancelled(this.value ? this.yesMessage : this.noMessage)
|
|
752
|
-
: textColors.prompt.input.inactive(this.initialValue ? this.yesOption : this.noOption); `
|
|
2911
|
+
: textColors.prompt.input.inactive(this.initialValue ? this.yesOption : this.noOption); `
|
|
2912
|
+
})
|
|
2913
|
+
];
|
|
2914
|
+
}
|
|
2915
|
+
}),
|
|
2916
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2917
|
+
(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." }),
|
|
2918
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2919
|
+
name: "ConfirmConfig",
|
|
2920
|
+
"export": true,
|
|
2921
|
+
children: _alloy_js_core.code`PromptFactoryConfig<boolean> & ConfirmPromptConfig; `
|
|
2922
|
+
}),
|
|
2923
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2924
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2925
|
+
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.",
|
|
2926
|
+
get children() {
|
|
2927
|
+
return [
|
|
2928
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { confirm, isCancel } from "shell-shock:prompts";
|
|
753
2929
|
|
|
754
2930
|
async function run() {
|
|
755
2931
|
const likesIceCream = await confirm({
|
|
@@ -763,13 +2939,65 @@ async function run() {
|
|
|
763
2939
|
console.log("You" + (likesIceCream ? " like ice cream" : " don't like ice cream") + "!");
|
|
764
2940
|
}
|
|
765
2941
|
|
|
766
|
-
run(); `
|
|
2942
|
+
run(); ` }),
|
|
2943
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2944
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2945
|
+
name: "config",
|
|
2946
|
+
children: `The configuration options to pass to the confirm prompt, which extends the base PromptFactoryConfig with additional options specific to the confirm prompt`
|
|
2947
|
+
}),
|
|
2948
|
+
(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` })
|
|
2949
|
+
];
|
|
2950
|
+
}
|
|
2951
|
+
}),
|
|
2952
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2953
|
+
name: "confirm",
|
|
2954
|
+
"export": true,
|
|
2955
|
+
parameters: [{
|
|
2956
|
+
name: "config",
|
|
2957
|
+
type: "ConfirmConfig"
|
|
2958
|
+
}],
|
|
2959
|
+
returnType: "Promise<boolean | symbol>",
|
|
2960
|
+
children: _alloy_js_core.code`return new Promise<boolean | symbol>((response, reject) => {
|
|
767
2961
|
const prompt = new ConfirmPrompt(config);
|
|
768
2962
|
|
|
769
2963
|
prompt.on("state", state => config.onState?.(state));
|
|
770
2964
|
prompt.on("submit", value => response(value));
|
|
771
2965
|
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
772
|
-
}); `
|
|
2966
|
+
}); `
|
|
2967
|
+
})
|
|
2968
|
+
];
|
|
2969
|
+
}
|
|
2970
|
+
/**
|
|
2971
|
+
* 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.
|
|
2972
|
+
*/
|
|
2973
|
+
function PasswordPromptDeclaration() {
|
|
2974
|
+
return [
|
|
2975
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
2976
|
+
"export": true,
|
|
2977
|
+
name: "passwordMask",
|
|
2978
|
+
doc: "A built-in prompt mask function that masks input with asterisks",
|
|
2979
|
+
parameters: [{
|
|
2980
|
+
name: "input",
|
|
2981
|
+
type: "string"
|
|
2982
|
+
}],
|
|
2983
|
+
returnType: "string",
|
|
2984
|
+
children: _alloy_js_core.code`return "*".repeat(input.length); `
|
|
2985
|
+
}),
|
|
2986
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2987
|
+
(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." }),
|
|
2988
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2989
|
+
name: "PasswordConfig",
|
|
2990
|
+
"export": true,
|
|
2991
|
+
children: _alloy_js_core.code`Omit<TextConfig, "mask" | "maskCompleted">; `
|
|
2992
|
+
}),
|
|
2993
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2994
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2995
|
+
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.",
|
|
2996
|
+
get children() {
|
|
2997
|
+
return [
|
|
2998
|
+
(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.` }),
|
|
2999
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3000
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { password, isCancel } from "shell-shock:prompts";
|
|
773
3001
|
|
|
774
3002
|
async function run() {
|
|
775
3003
|
const userPassword = await password({
|
|
@@ -783,18 +3011,63 @@ async function run() {
|
|
|
783
3011
|
console.log("You entered a password!");
|
|
784
3012
|
}
|
|
785
3013
|
|
|
786
|
-
run(); `
|
|
3014
|
+
run(); ` }),
|
|
3015
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3016
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
3017
|
+
name: "config",
|
|
3018
|
+
children: `The configuration options to pass to the password prompt, which extends the base PromptConfig with additional options specific to password prompts`
|
|
3019
|
+
}),
|
|
3020
|
+
(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` })
|
|
3021
|
+
];
|
|
3022
|
+
}
|
|
3023
|
+
}),
|
|
3024
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
3025
|
+
name: "password",
|
|
3026
|
+
"export": true,
|
|
3027
|
+
parameters: [{
|
|
3028
|
+
name: "config",
|
|
3029
|
+
type: "PasswordConfig"
|
|
3030
|
+
}],
|
|
3031
|
+
returnType: "Promise<string | symbol>",
|
|
3032
|
+
children: _alloy_js_core.code`return text({
|
|
787
3033
|
...config,
|
|
788
3034
|
mask: passwordMask,
|
|
789
3035
|
maskCompleted: () => "*******"
|
|
790
|
-
});`
|
|
3036
|
+
});`
|
|
3037
|
+
})
|
|
3038
|
+
];
|
|
3039
|
+
}
|
|
3040
|
+
function WaitForKeyPressDeclaration() {
|
|
3041
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
3042
|
+
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.",
|
|
3043
|
+
get children() {
|
|
3044
|
+
return [
|
|
3045
|
+
(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.` }),
|
|
3046
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3047
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { waitForKeyPress } from "shell-shock:prompts";
|
|
791
3048
|
|
|
792
3049
|
async function run() {
|
|
793
3050
|
const result = await waitForKeyPress();
|
|
794
3051
|
console.log("A key was pressed!");
|
|
795
3052
|
}
|
|
796
3053
|
|
|
797
|
-
run(); `
|
|
3054
|
+
run(); ` }),
|
|
3055
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3056
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
3057
|
+
name: "timeout",
|
|
3058
|
+
children: `The amount of time in milliseconds to wait before automatically resolving the prompt, defaults to 2 hours (7200000 ms)`
|
|
3059
|
+
}),
|
|
3060
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A promise that resolves when any key is pressed` })
|
|
3061
|
+
];
|
|
3062
|
+
}
|
|
3063
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
3064
|
+
name: "waitForKeyPress",
|
|
3065
|
+
"export": true,
|
|
3066
|
+
parameters: [{
|
|
3067
|
+
name: "timeout",
|
|
3068
|
+
default: "7200000"
|
|
3069
|
+
}],
|
|
3070
|
+
children: _alloy_js_core.code`process.stdin.setRawMode(true);
|
|
798
3071
|
return new Promise(resolve => process.stdin.once("data", () => {
|
|
799
3072
|
if (timeout >= 0) {
|
|
800
3073
|
setTimeout(() => {
|
|
@@ -805,4 +3078,97 @@ run(); `}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(l.TSDocPara
|
|
|
805
3078
|
|
|
806
3079
|
process.stdin.setRawMode(false);
|
|
807
3080
|
resolve(void 0);
|
|
808
|
-
})); `
|
|
3081
|
+
})); `
|
|
3082
|
+
})];
|
|
3083
|
+
}
|
|
3084
|
+
/**
|
|
3085
|
+
* A built-in prompts module for Shell Shock.
|
|
3086
|
+
*/
|
|
3087
|
+
function PromptsBuiltin(props) {
|
|
3088
|
+
const [{ children }, rest] = (0, _alloy_js_core.splitProps)(props, ["children"]);
|
|
3089
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
3090
|
+
id: "prompts",
|
|
3091
|
+
description: "A collection of prompts that allow for interactive input in command-line applications."
|
|
3092
|
+
}, rest, {
|
|
3093
|
+
get imports() {
|
|
3094
|
+
return (0, defu.default)(rest.imports ?? {}, {
|
|
3095
|
+
"node:events": "EventEmitter",
|
|
3096
|
+
"node:readline": [
|
|
3097
|
+
"Interface",
|
|
3098
|
+
"Key",
|
|
3099
|
+
"createInterface",
|
|
3100
|
+
"emitKeypressEvents"
|
|
3101
|
+
]
|
|
3102
|
+
});
|
|
3103
|
+
},
|
|
3104
|
+
get builtinImports() {
|
|
3105
|
+
return (0, defu.default)(rest.builtinImports ?? {}, {
|
|
3106
|
+
console: [
|
|
3107
|
+
"erase",
|
|
3108
|
+
"beep",
|
|
3109
|
+
"cursor",
|
|
3110
|
+
"textColors",
|
|
3111
|
+
"borderColors",
|
|
3112
|
+
"bold",
|
|
3113
|
+
"italic",
|
|
3114
|
+
"underline",
|
|
3115
|
+
"strikethrough",
|
|
3116
|
+
"clear",
|
|
3117
|
+
"stripAnsi",
|
|
3118
|
+
"splitText",
|
|
3119
|
+
"error"
|
|
3120
|
+
],
|
|
3121
|
+
utils: ["isUnicodeSupported"],
|
|
3122
|
+
env: [
|
|
3123
|
+
"env",
|
|
3124
|
+
"isCI",
|
|
3125
|
+
"isTest",
|
|
3126
|
+
"isWindows",
|
|
3127
|
+
"isDevelopment",
|
|
3128
|
+
"isDebug"
|
|
3129
|
+
]
|
|
3130
|
+
});
|
|
3131
|
+
},
|
|
3132
|
+
get children() {
|
|
3133
|
+
return [
|
|
3134
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3135
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(BasePromptDeclarations, {}),
|
|
3136
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3137
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(TextPromptDeclarations, {}),
|
|
3138
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3139
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(SelectPromptDeclarations, {}),
|
|
3140
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3141
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(MultiSelectPromptDeclarations, {}),
|
|
3142
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3143
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(NumericPromptDeclarations, {}),
|
|
3144
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3145
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(TogglePromptDeclarations, {}),
|
|
3146
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3147
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(PasswordPromptDeclaration, {}),
|
|
3148
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3149
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(ConfirmPromptDeclarations, {}),
|
|
3150
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3151
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(WaitForKeyPressDeclaration, {}),
|
|
3152
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
3153
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
3154
|
+
get when() {
|
|
3155
|
+
return Boolean(children);
|
|
3156
|
+
},
|
|
3157
|
+
children
|
|
3158
|
+
})
|
|
3159
|
+
];
|
|
3160
|
+
}
|
|
3161
|
+
}));
|
|
3162
|
+
}
|
|
3163
|
+
|
|
3164
|
+
//#endregion
|
|
3165
|
+
exports.BasePromptDeclarations = BasePromptDeclarations;
|
|
3166
|
+
exports.ConfirmPromptDeclarations = ConfirmPromptDeclarations;
|
|
3167
|
+
exports.MultiSelectPromptDeclarations = MultiSelectPromptDeclarations;
|
|
3168
|
+
exports.NumericPromptDeclarations = NumericPromptDeclarations;
|
|
3169
|
+
exports.PasswordPromptDeclaration = PasswordPromptDeclaration;
|
|
3170
|
+
exports.PromptsBuiltin = PromptsBuiltin;
|
|
3171
|
+
exports.SelectPromptDeclarations = SelectPromptDeclarations;
|
|
3172
|
+
exports.TextPromptDeclarations = TextPromptDeclarations;
|
|
3173
|
+
exports.TogglePromptDeclarations = TogglePromptDeclarations;
|
|
3174
|
+
exports.WaitForKeyPressDeclaration = WaitForKeyPressDeclaration;
|