@shell-shock/preset-cli 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/banner-function-declaration.d.cts +2 -2
- package/dist/components/banner-function-declaration.d.cts.map +1 -1
- package/dist/components/banner-function-declaration.d.mts +2 -2
- package/dist/components/command-entry.cjs +96 -45
- package/dist/components/command-entry.d.cts +2 -2
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +2 -2
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/command-entry.mjs +96 -45
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/components/prompts-builtin.cjs +451 -48
- package/dist/components/prompts-builtin.d.cts +5 -1
- package/dist/components/prompts-builtin.d.cts.map +1 -1
- package/dist/components/prompts-builtin.d.mts +5 -1
- package/dist/components/prompts-builtin.d.mts.map +1 -1
- package/dist/components/prompts-builtin.mjs +452 -50
- package/dist/components/prompts-builtin.mjs.map +1 -1
- package/dist/components/virtual-command-entry.cjs +1 -0
- package/dist/components/virtual-command-entry.d.cts +2 -2
- package/dist/components/virtual-command-entry.mjs +1 -0
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -3,6 +3,7 @@ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
|
3
3
|
let __alloy_js_core = require("@alloy-js/core");
|
|
4
4
|
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
5
5
|
let __shell_shock_preset_script_contexts_theme = require("@shell-shock/preset-script/contexts/theme");
|
|
6
|
+
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
6
7
|
let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
7
8
|
let defu = require("defu");
|
|
8
9
|
defu = require_rolldown_runtime.__toESM(defu);
|
|
@@ -138,7 +139,7 @@ function BasePromptDeclarations() {
|
|
|
138
139
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
139
140
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
140
141
|
name: "PromptConfig",
|
|
141
|
-
doc: "Configuration options for
|
|
142
|
+
doc: "Configuration options for creating a prompt",
|
|
142
143
|
typeParameters: [{
|
|
143
144
|
name: "TValue",
|
|
144
145
|
default: "string"
|
|
@@ -182,7 +183,7 @@ function BasePromptDeclarations() {
|
|
|
182
183
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
183
184
|
name: "validate",
|
|
184
185
|
optional: true,
|
|
185
|
-
type: "(value: TValue) => boolean | string | null | undefined | Promise<boolean | string | null | undefined>",
|
|
186
|
+
type: "(value: TValue) => boolean | string | { type: 'error' | 'warning'; message: string } | null | undefined | Promise<boolean | string | { type: 'error' | 'warning'; message: string } | null | undefined>",
|
|
186
187
|
doc: "A validation function that returns true if the input is valid, false or a string error message if the input is invalid"
|
|
187
188
|
}),
|
|
188
189
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
@@ -301,7 +302,7 @@ function BasePromptDeclarations() {
|
|
|
301
302
|
name: "defaultErrorMessage",
|
|
302
303
|
"protected": true,
|
|
303
304
|
type: "string",
|
|
304
|
-
children: __alloy_js_core.code`"
|
|
305
|
+
children: __alloy_js_core.code`"An invalid value was provided"; `
|
|
305
306
|
}),
|
|
306
307
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
307
308
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
@@ -386,6 +387,13 @@ function BasePromptDeclarations() {
|
|
|
386
387
|
type: "number",
|
|
387
388
|
children: __alloy_js_core.code`0; `
|
|
388
389
|
}),
|
|
390
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
391
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
392
|
+
name: "cursorHidden",
|
|
393
|
+
"protected": true,
|
|
394
|
+
type: "boolean",
|
|
395
|
+
children: __alloy_js_core.code`false; `
|
|
396
|
+
}),
|
|
389
397
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
390
398
|
__alloy_js_core.code`constructor(protected config: PromptConfig<TValue>) {
|
|
391
399
|
super();
|
|
@@ -711,6 +719,8 @@ function BasePromptDeclarations() {
|
|
|
711
719
|
}
|
|
712
720
|
|
|
713
721
|
this.output.write(clear(this.consoleOutput, this.output.columns));
|
|
722
|
+
} else if (this.cursorHidden) {
|
|
723
|
+
this.output.write(cursor.hide);
|
|
714
724
|
}
|
|
715
725
|
|
|
716
726
|
this.consoleOutput = \` \${
|
|
@@ -796,10 +806,10 @@ function BasePromptDeclarations() {
|
|
|
796
806
|
}
|
|
797
807
|
}),
|
|
798
808
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
809
|
+
(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." }),
|
|
799
810
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
800
811
|
"export": true,
|
|
801
812
|
name: "CANCEL_SYMBOL",
|
|
802
|
-
doc: "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.",
|
|
803
813
|
children: __alloy_js_core.code`Symbol("shell-shock:prompts:cancel"); `
|
|
804
814
|
}),
|
|
805
815
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
@@ -832,7 +842,7 @@ function TextPromptDeclarations() {
|
|
|
832
842
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
833
843
|
name: "StringPromptConfig",
|
|
834
844
|
"extends": "PromptConfig<string>",
|
|
835
|
-
doc: "Configuration options for
|
|
845
|
+
doc: "Configuration options for creating a text-based prompt",
|
|
836
846
|
get children() {
|
|
837
847
|
return [
|
|
838
848
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
@@ -882,6 +892,7 @@ function TextPromptDeclarations() {
|
|
|
882
892
|
|
|
883
893
|
this.cursor = 0;
|
|
884
894
|
this.sync();
|
|
895
|
+
this.first();
|
|
885
896
|
} `,
|
|
886
897
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
887
898
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
@@ -1304,6 +1315,14 @@ function SelectPromptDeclarations() {
|
|
|
1304
1315
|
type: "PromptOption<TValue>[]",
|
|
1305
1316
|
children: __alloy_js_core.code`[]; `
|
|
1306
1317
|
}),
|
|
1318
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1319
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1320
|
+
name: "cursorHidden",
|
|
1321
|
+
"protected": true,
|
|
1322
|
+
override: true,
|
|
1323
|
+
type: "boolean",
|
|
1324
|
+
children: __alloy_js_core.code`true; `
|
|
1325
|
+
}),
|
|
1307
1326
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1308
1327
|
__alloy_js_core.code`constructor(config: SelectPromptConfig<TValue>) {
|
|
1309
1328
|
super(config);
|
|
@@ -1478,11 +1497,7 @@ function SelectPromptDeclarations() {
|
|
|
1478
1497
|
name: "render",
|
|
1479
1498
|
override: true,
|
|
1480
1499
|
"protected": true,
|
|
1481
|
-
children: __alloy_js_core.code`
|
|
1482
|
-
this.output.write(cursor.hide);
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
const spacing = Math.max(...this.options.map(option => option.label?.length || 0)) + 2;
|
|
1500
|
+
children: __alloy_js_core.code`const spacing = Math.max(...this.options.map(option => option.label?.length || 0)) + 2;
|
|
1486
1501
|
|
|
1487
1502
|
const startIndex = Math.max(Math.min(this.options.length - this.optionsPerPage, this.cursor - Math.floor(this.optionsPerPage / 2)), 0);
|
|
1488
1503
|
const endIndex = Math.min(startIndex + this.optionsPerPage, this.options.length);
|
|
@@ -1614,7 +1629,7 @@ function NumericPromptDeclarations() {
|
|
|
1614
1629
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
1615
1630
|
name: "NumberPromptConfig",
|
|
1616
1631
|
"extends": "PromptConfig<number>",
|
|
1617
|
-
doc: "Configuration options for
|
|
1632
|
+
doc: "Configuration options for creating a numeric prompt",
|
|
1618
1633
|
get children() {
|
|
1619
1634
|
return [
|
|
1620
1635
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
@@ -1661,6 +1676,13 @@ function NumericPromptDeclarations() {
|
|
|
1661
1676
|
"extends": "Prompt<number>",
|
|
1662
1677
|
get children() {
|
|
1663
1678
|
return [
|
|
1679
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1680
|
+
name: "isInvalid",
|
|
1681
|
+
isPrivateMember: true,
|
|
1682
|
+
type: "boolean",
|
|
1683
|
+
children: __alloy_js_core.code`false; `
|
|
1684
|
+
}),
|
|
1685
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1664
1686
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1665
1687
|
name: "initialValue",
|
|
1666
1688
|
"protected": true,
|
|
@@ -1669,6 +1691,14 @@ function NumericPromptDeclarations() {
|
|
|
1669
1691
|
children: __alloy_js_core.code`0; `
|
|
1670
1692
|
}),
|
|
1671
1693
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1694
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1695
|
+
name: "defaultErrorMessage",
|
|
1696
|
+
"protected": true,
|
|
1697
|
+
override: true,
|
|
1698
|
+
type: "string",
|
|
1699
|
+
children: __alloy_js_core.code`"A valid numeric value must be provided"; `
|
|
1700
|
+
}),
|
|
1701
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1672
1702
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1673
1703
|
name: "isFloat",
|
|
1674
1704
|
"protected": true,
|
|
@@ -1754,6 +1784,7 @@ function NumericPromptDeclarations() {
|
|
|
1754
1784
|
}
|
|
1755
1785
|
|
|
1756
1786
|
this.sync();
|
|
1787
|
+
this.last();
|
|
1757
1788
|
} `,
|
|
1758
1789
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1759
1790
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
@@ -1764,14 +1795,6 @@ function NumericPromptDeclarations() {
|
|
|
1764
1795
|
children: __alloy_js_core.code`super.reset();
|
|
1765
1796
|
this.currentInput = "";
|
|
1766
1797
|
`
|
|
1767
|
-
}),
|
|
1768
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1769
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1770
|
-
doc: "A method to move the cursor to the end of the input",
|
|
1771
|
-
name: "next",
|
|
1772
|
-
"protected": true,
|
|
1773
|
-
children: __alloy_js_core.code`this.changeValue(this.initialValue);
|
|
1774
|
-
this.sync(); `
|
|
1775
1798
|
}),
|
|
1776
1799
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1777
1800
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
@@ -1795,18 +1818,12 @@ function NumericPromptDeclarations() {
|
|
|
1795
1818
|
return this.bell();
|
|
1796
1819
|
}
|
|
1797
1820
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
this.currentInput += char;
|
|
1803
|
-
this.inputTimestamp = Date.now();
|
|
1804
|
-
|
|
1805
|
-
if (char === ".") {
|
|
1821
|
+
this.displayValue += char;
|
|
1822
|
+
if ((char === "-" || char === ".") && this.displayValue.length === 1) {
|
|
1806
1823
|
return this.sync();
|
|
1807
1824
|
}
|
|
1808
1825
|
|
|
1809
|
-
let value = Math.min(this.parser(this.
|
|
1826
|
+
let value = Math.min(this.parser(this.displayValue), this.max);
|
|
1810
1827
|
if (value > this.max) {
|
|
1811
1828
|
value = this.max;
|
|
1812
1829
|
}
|
|
@@ -1815,6 +1832,14 @@ function NumericPromptDeclarations() {
|
|
|
1815
1832
|
}
|
|
1816
1833
|
|
|
1817
1834
|
this.changeValue(value);
|
|
1835
|
+
this.sync(); `
|
|
1836
|
+
}),
|
|
1837
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1838
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1839
|
+
doc: "A method to move the cursor to the end of the input",
|
|
1840
|
+
name: "next",
|
|
1841
|
+
"protected": true,
|
|
1842
|
+
children: __alloy_js_core.code`this.changeValue(this.initialValue);
|
|
1818
1843
|
this.sync(); `
|
|
1819
1844
|
}),
|
|
1820
1845
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
@@ -1822,14 +1847,10 @@ function NumericPromptDeclarations() {
|
|
|
1822
1847
|
doc: "A method to move the cursor to the up",
|
|
1823
1848
|
name: "up",
|
|
1824
1849
|
"protected": true,
|
|
1825
|
-
children: __alloy_js_core.code`
|
|
1826
|
-
|
|
1827
|
-
let value = this.value;
|
|
1850
|
+
children: __alloy_js_core.code`let value = this.value;
|
|
1828
1851
|
if (this.displayValue === "") {
|
|
1829
|
-
value = this.min
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
if (value >= this.max) {
|
|
1852
|
+
value = this.min < 0 ? 0 : this.min;
|
|
1853
|
+
} else if (value >= this.max) {
|
|
1833
1854
|
return this.bell();
|
|
1834
1855
|
}
|
|
1835
1856
|
|
|
@@ -1841,36 +1862,134 @@ function NumericPromptDeclarations() {
|
|
|
1841
1862
|
doc: "A method to move the cursor to the down",
|
|
1842
1863
|
name: "down",
|
|
1843
1864
|
"protected": true,
|
|
1844
|
-
children: __alloy_js_core.code`
|
|
1865
|
+
children: __alloy_js_core.code`let value = this.value;
|
|
1866
|
+
if (this.displayValue === "") {
|
|
1867
|
+
value = this.min < 0 ? 0 : this.min;
|
|
1868
|
+
} else if (value <= this.min) {
|
|
1869
|
+
return this.bell();
|
|
1870
|
+
}
|
|
1845
1871
|
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1872
|
+
this.changeValue(value === this.min ? this.min : value - this.increment);
|
|
1873
|
+
this.sync(); `
|
|
1874
|
+
}),
|
|
1875
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1876
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1877
|
+
doc: "A method to move the cursor to the left",
|
|
1878
|
+
name: "left",
|
|
1879
|
+
"protected": true,
|
|
1880
|
+
children: __alloy_js_core.code`if (this.cursor <= 0 || this.isPlaceholder) {
|
|
1881
|
+
return this.bell();
|
|
1849
1882
|
}
|
|
1850
1883
|
|
|
1851
|
-
|
|
1884
|
+
this.moveCursor(-1);
|
|
1885
|
+
this.sync(); `
|
|
1886
|
+
}),
|
|
1887
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1888
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1889
|
+
doc: "A method to move the cursor to the right",
|
|
1890
|
+
name: "right",
|
|
1891
|
+
"protected": true,
|
|
1892
|
+
children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length || this.isPlaceholder) {
|
|
1852
1893
|
return this.bell();
|
|
1853
1894
|
}
|
|
1854
1895
|
|
|
1855
|
-
this.
|
|
1896
|
+
this.moveCursor(1);
|
|
1856
1897
|
this.sync(); `
|
|
1898
|
+
}),
|
|
1899
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1900
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1901
|
+
doc: "A method to move the cursor to the left or right by a \\`count\\` of positions",
|
|
1902
|
+
name: "moveCursor",
|
|
1903
|
+
parameters: [{
|
|
1904
|
+
name: "count",
|
|
1905
|
+
type: "number"
|
|
1906
|
+
}],
|
|
1907
|
+
"protected": true,
|
|
1908
|
+
children: __alloy_js_core.code`if (this.isPlaceholder) {
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
this.cursor = this.cursor + count;
|
|
1913
|
+
this.cursorOffset += count; `
|
|
1857
1914
|
}),
|
|
1858
1915
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1859
1916
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1860
1917
|
doc: "A method to delete the character backward of the cursor",
|
|
1861
1918
|
name: "delete",
|
|
1862
1919
|
"protected": true,
|
|
1863
|
-
children: __alloy_js_core.code`if (this.
|
|
1920
|
+
children: __alloy_js_core.code`if (this.isCursorAtStart()) {
|
|
1864
1921
|
return this.bell();
|
|
1865
1922
|
}
|
|
1866
1923
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
value = this.min === Number.NEGATIVE_INFINITY ? 0 : this.min;
|
|
1924
|
+
if (this.displayValue === "") {
|
|
1925
|
+
return this.bell();
|
|
1870
1926
|
}
|
|
1871
1927
|
|
|
1872
|
-
this.changeValue(
|
|
1928
|
+
this.changeValue(\`\${this.displayValue.slice(0, this.cursor - 1)}\${this.displayValue.slice(this.cursor)}\`);
|
|
1929
|
+
this.#isInvalid = false;
|
|
1930
|
+
|
|
1931
|
+
if (this.isCursorAtStart()) {
|
|
1932
|
+
this.cursorOffset = 0
|
|
1933
|
+
} else {
|
|
1934
|
+
this.cursorOffset++;
|
|
1935
|
+
this.moveCursor(-1);
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
this.sync(); `
|
|
1939
|
+
}),
|
|
1940
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1941
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1942
|
+
doc: "A method to delete the character forward of the cursor",
|
|
1943
|
+
name: "deleteForward",
|
|
1944
|
+
"protected": true,
|
|
1945
|
+
children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length || this.isPlaceholder) {
|
|
1946
|
+
return this.bell();
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
this.changeValue(\`\${
|
|
1950
|
+
this.displayValue.slice(0, this.cursor)
|
|
1951
|
+
}\${
|
|
1952
|
+
this.displayValue.slice(this.cursor + 1)
|
|
1953
|
+
}\`);
|
|
1954
|
+
this.#isInvalid = false;
|
|
1955
|
+
|
|
1956
|
+
if (this.isCursorAtEnd()) {
|
|
1957
|
+
this.cursorOffset = 0;
|
|
1958
|
+
} else {
|
|
1959
|
+
this.cursorOffset++;
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
this.sync(); `
|
|
1963
|
+
}),
|
|
1964
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1965
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1966
|
+
doc: "A method to move the cursor to the start",
|
|
1967
|
+
name: "first",
|
|
1968
|
+
"protected": true,
|
|
1969
|
+
children: __alloy_js_core.code`this.cursor = 0;
|
|
1970
|
+
this.sync(); `
|
|
1971
|
+
}),
|
|
1972
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1973
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1974
|
+
doc: "A method to move the cursor to the end",
|
|
1975
|
+
name: "last",
|
|
1976
|
+
"protected": true,
|
|
1977
|
+
children: __alloy_js_core.code`this.cursor = this.displayValue.length;
|
|
1873
1978
|
this.sync(); `
|
|
1979
|
+
}),
|
|
1980
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1981
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1982
|
+
doc: "A method to check if the cursor is at the start",
|
|
1983
|
+
name: "isCursorAtStart",
|
|
1984
|
+
"protected": true,
|
|
1985
|
+
children: __alloy_js_core.code`return this.cursor === 0 || (this.isPlaceholder && this.cursor === 1); `
|
|
1986
|
+
}),
|
|
1987
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1988
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1989
|
+
doc: "A method to check if the cursor is at the end",
|
|
1990
|
+
name: "isCursorAtEnd",
|
|
1991
|
+
"protected": true,
|
|
1992
|
+
children: __alloy_js_core.code`return this.cursor === this.displayValue.length || (this.isPlaceholder && this.cursor === this.displayValue.length + 1); `
|
|
1874
1993
|
})
|
|
1875
1994
|
];
|
|
1876
1995
|
}
|
|
@@ -1940,7 +2059,7 @@ function TogglePromptDeclarations() {
|
|
|
1940
2059
|
"export": true,
|
|
1941
2060
|
name: "TogglePromptConfig",
|
|
1942
2061
|
"extends": "PromptConfig<boolean>",
|
|
1943
|
-
doc: "Configuration options for
|
|
2062
|
+
doc: "Configuration options for creating a boolean toggle prompt",
|
|
1944
2063
|
get children() {
|
|
1945
2064
|
return [
|
|
1946
2065
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
@@ -1964,7 +2083,7 @@ function TogglePromptDeclarations() {
|
|
|
1964
2083
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
1965
2084
|
"export": true,
|
|
1966
2085
|
name: "TogglePrompt",
|
|
1967
|
-
doc: "A prompt for
|
|
2086
|
+
doc: "A prompt for toggling a boolean input",
|
|
1968
2087
|
"extends": "Prompt<boolean>",
|
|
1969
2088
|
get children() {
|
|
1970
2089
|
return [
|
|
@@ -1989,6 +2108,14 @@ function TogglePromptDeclarations() {
|
|
|
1989
2108
|
type: "string",
|
|
1990
2109
|
children: __alloy_js_core.code`"No"; `
|
|
1991
2110
|
}),
|
|
2111
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2112
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2113
|
+
name: "cursorHidden",
|
|
2114
|
+
"protected": true,
|
|
2115
|
+
override: true,
|
|
2116
|
+
type: "boolean",
|
|
2117
|
+
children: __alloy_js_core.code`true; `
|
|
2118
|
+
}),
|
|
1992
2119
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1993
2120
|
__alloy_js_core.code`constructor(config: TogglePromptConfig) {
|
|
1994
2121
|
super(config);
|
|
@@ -2102,6 +2229,23 @@ function TogglePromptDeclarations() {
|
|
|
2102
2229
|
"protected": true,
|
|
2103
2230
|
children: __alloy_js_core.code`this.changeValue(!this.value);
|
|
2104
2231
|
this.sync(); `
|
|
2232
|
+
}),
|
|
2233
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2234
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2235
|
+
doc: "A method to render the prompt",
|
|
2236
|
+
name: "render",
|
|
2237
|
+
override: true,
|
|
2238
|
+
"protected": true,
|
|
2239
|
+
returnType: "string",
|
|
2240
|
+
children: __alloy_js_core.code`return this.isSubmitted
|
|
2241
|
+
? colors.text.prompt.input.submitted(this.value ? this.trueMessage : this.falseMessage)
|
|
2242
|
+
: this.isCancelled
|
|
2243
|
+
? colors.text.prompt.input.cancelled(this.value ? this.trueMessage : this.falseMessage)
|
|
2244
|
+
: \`\${
|
|
2245
|
+
this.value ? colors.text.prompt.input.inactive(this.falseMessage) : colors.underline(colors.bold(colors.text.prompt.input.active(this.falseMessage)))
|
|
2246
|
+
} \${colors.border.app.divider.tertiary("/")} \${
|
|
2247
|
+
this.value ? colors.underline(colors.bold(colors.text.prompt.input.active(this.trueMessage))) : colors.text.prompt.input.inactive(this.trueMessage)
|
|
2248
|
+
}\`; `
|
|
2105
2249
|
})
|
|
2106
2250
|
];
|
|
2107
2251
|
}
|
|
@@ -2161,6 +2305,262 @@ run(); ` }),
|
|
|
2161
2305
|
];
|
|
2162
2306
|
}
|
|
2163
2307
|
/**
|
|
2308
|
+
* 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.
|
|
2309
|
+
*/
|
|
2310
|
+
function ConfirmPromptDeclarations() {
|
|
2311
|
+
return [
|
|
2312
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
|
|
2313
|
+
"export": true,
|
|
2314
|
+
name: "ConfirmPromptConfig",
|
|
2315
|
+
"extends": "PromptConfig<boolean>",
|
|
2316
|
+
doc: "Configuration options for creating a boolean confirm prompt",
|
|
2317
|
+
get children() {
|
|
2318
|
+
return [
|
|
2319
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2320
|
+
heading: "The message for the \\`Yes\\` state of the prompt",
|
|
2321
|
+
get children() {
|
|
2322
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2323
|
+
get type() {
|
|
2324
|
+
return __powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
2325
|
+
},
|
|
2326
|
+
defaultValue: "Yes"
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
}),
|
|
2330
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2331
|
+
name: "yesMessage",
|
|
2332
|
+
optional: true,
|
|
2333
|
+
type: "string"
|
|
2334
|
+
}),
|
|
2335
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2336
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2337
|
+
heading: "The \\`Yes\\` option when choosing between yes/no",
|
|
2338
|
+
get children() {
|
|
2339
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2340
|
+
get type() {
|
|
2341
|
+
return __powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
2342
|
+
},
|
|
2343
|
+
defaultValue: "1"
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
}),
|
|
2347
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2348
|
+
name: "yesOption",
|
|
2349
|
+
optional: true,
|
|
2350
|
+
type: "string"
|
|
2351
|
+
}),
|
|
2352
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2353
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2354
|
+
heading: "The message for the \\`No\\` state of the prompt",
|
|
2355
|
+
get children() {
|
|
2356
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2357
|
+
get type() {
|
|
2358
|
+
return __powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
2359
|
+
},
|
|
2360
|
+
defaultValue: "(Y/n)"
|
|
2361
|
+
});
|
|
2362
|
+
}
|
|
2363
|
+
}),
|
|
2364
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2365
|
+
name: "noMessage",
|
|
2366
|
+
optional: true,
|
|
2367
|
+
type: "string"
|
|
2368
|
+
}),
|
|
2369
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2370
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2371
|
+
heading: "The \\`No\\` option when choosing between yes/no",
|
|
2372
|
+
get children() {
|
|
2373
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
2374
|
+
get type() {
|
|
2375
|
+
return __powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
2376
|
+
},
|
|
2377
|
+
defaultValue: "(y/N)"
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
}),
|
|
2381
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
2382
|
+
name: "noOption",
|
|
2383
|
+
optional: true,
|
|
2384
|
+
type: "string"
|
|
2385
|
+
})
|
|
2386
|
+
];
|
|
2387
|
+
}
|
|
2388
|
+
}),
|
|
2389
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2390
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
|
|
2391
|
+
"export": true,
|
|
2392
|
+
name: "ConfirmPrompt",
|
|
2393
|
+
doc: "A prompt for confirming a boolean input",
|
|
2394
|
+
"extends": "Prompt<boolean>",
|
|
2395
|
+
get children() {
|
|
2396
|
+
return [
|
|
2397
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2398
|
+
name: "initialValue",
|
|
2399
|
+
"protected": true,
|
|
2400
|
+
override: true,
|
|
2401
|
+
type: "boolean",
|
|
2402
|
+
children: __alloy_js_core.code`false; `
|
|
2403
|
+
}),
|
|
2404
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2405
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2406
|
+
name: "yesMessage",
|
|
2407
|
+
"protected": true,
|
|
2408
|
+
type: "string",
|
|
2409
|
+
children: __alloy_js_core.code`"Yes"; `
|
|
2410
|
+
}),
|
|
2411
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2412
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2413
|
+
name: "yesOption",
|
|
2414
|
+
"protected": true,
|
|
2415
|
+
type: "string",
|
|
2416
|
+
children: __alloy_js_core.code`"(Y/n)"; `
|
|
2417
|
+
}),
|
|
2418
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2419
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2420
|
+
name: "noMessage",
|
|
2421
|
+
"protected": true,
|
|
2422
|
+
type: "string",
|
|
2423
|
+
children: __alloy_js_core.code`"No"; `
|
|
2424
|
+
}),
|
|
2425
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2426
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2427
|
+
name: "noOption",
|
|
2428
|
+
"protected": true,
|
|
2429
|
+
type: "string",
|
|
2430
|
+
children: __alloy_js_core.code`"(y/N)"; `
|
|
2431
|
+
}),
|
|
2432
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2433
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
2434
|
+
name: "cursorHidden",
|
|
2435
|
+
"protected": true,
|
|
2436
|
+
override: true,
|
|
2437
|
+
type: "boolean",
|
|
2438
|
+
children: __alloy_js_core.code`true; `
|
|
2439
|
+
}),
|
|
2440
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2441
|
+
__alloy_js_core.code`constructor(config: ConfirmPromptConfig) {
|
|
2442
|
+
super(config);
|
|
2443
|
+
|
|
2444
|
+
if (config.initialValue) {
|
|
2445
|
+
this.initialValue = config.initialValue;
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
if (config.yesMessage) {
|
|
2449
|
+
this.yesMessage = config.yesMessage;
|
|
2450
|
+
}
|
|
2451
|
+
if (config.yesOption) {
|
|
2452
|
+
this.yesOption = config.yesOption;
|
|
2453
|
+
}
|
|
2454
|
+
if (config.noMessage) {
|
|
2455
|
+
this.noMessage = config.noMessage;
|
|
2456
|
+
}
|
|
2457
|
+
if (config.noOption) {
|
|
2458
|
+
this.noOption = config.noOption;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
this.sync();
|
|
2462
|
+
} `,
|
|
2463
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2464
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2465
|
+
doc: "A method to handle keypress events and determine the corresponding action",
|
|
2466
|
+
name: "keypress",
|
|
2467
|
+
override: true,
|
|
2468
|
+
"protected": true,
|
|
2469
|
+
parameters: [{
|
|
2470
|
+
name: "char",
|
|
2471
|
+
type: "string"
|
|
2472
|
+
}, {
|
|
2473
|
+
name: "key",
|
|
2474
|
+
type: "readline.Key"
|
|
2475
|
+
}],
|
|
2476
|
+
children: __alloy_js_core.code`const action = this.getAction(key);
|
|
2477
|
+
if (action && typeof (this as any)[action] === "function") {
|
|
2478
|
+
return (this as any)[action]();
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
if (char.toLowerCase() === "y" || char.toLowerCase() === "t" || char.toLowerCase() === "0") {
|
|
2482
|
+
this.value = true;
|
|
2483
|
+
return this.submit();
|
|
2484
|
+
} else if (char.toLowerCase() === "n" || char.toLowerCase() === "f" || char.toLowerCase() === "1") {
|
|
2485
|
+
this.value = false;
|
|
2486
|
+
return this.submit();
|
|
2487
|
+
} else {
|
|
2488
|
+
return this.bell();
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
this.sync(); `
|
|
2492
|
+
}),
|
|
2493
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2494
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2495
|
+
doc: "A method to render the prompt",
|
|
2496
|
+
name: "render",
|
|
2497
|
+
override: true,
|
|
2498
|
+
"protected": true,
|
|
2499
|
+
returnType: "string",
|
|
2500
|
+
children: __alloy_js_core.code`return this.isSubmitted
|
|
2501
|
+
? colors.text.prompt.input.submitted(this.value ? this.yesMessage : this.noMessage)
|
|
2502
|
+
: this.isCancelled
|
|
2503
|
+
? colors.text.prompt.input.cancelled(this.value ? this.yesMessage : this.noMessage)
|
|
2504
|
+
: colors.text.prompt.input.inactive(this.initialValue ? this.yesOption : this.noOption); `
|
|
2505
|
+
})
|
|
2506
|
+
];
|
|
2507
|
+
}
|
|
2508
|
+
}),
|
|
2509
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2510
|
+
(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." }),
|
|
2511
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2512
|
+
name: "ConfirmConfig",
|
|
2513
|
+
"export": true,
|
|
2514
|
+
children: __alloy_js_core.code`PromptFactoryConfig<boolean> & ConfirmPromptConfig; `
|
|
2515
|
+
}),
|
|
2516
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2517
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2518
|
+
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.",
|
|
2519
|
+
get children() {
|
|
2520
|
+
return [
|
|
2521
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { confirm, isCancel } from "shell-shock:prompts";
|
|
2522
|
+
|
|
2523
|
+
async function run() {
|
|
2524
|
+
const likesIceCream = await confirm({
|
|
2525
|
+
message: "Do you like ice cream?"
|
|
2526
|
+
});
|
|
2527
|
+
if (isCancel(likesIceCream)) {
|
|
2528
|
+
console.log("Prompt was cancelled");
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
console.log("You" + (likesIceCream ? " like ice cream" : " don't like ice cream") + "!");
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
run(); ` }),
|
|
2536
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2537
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2538
|
+
name: "config",
|
|
2539
|
+
children: `The configuration options to pass to the confirm prompt, which extends the base PromptFactoryConfig with additional options specific to the confirm prompt`
|
|
2540
|
+
}),
|
|
2541
|
+
(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` })
|
|
2542
|
+
];
|
|
2543
|
+
}
|
|
2544
|
+
}),
|
|
2545
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
2546
|
+
name: "confirm",
|
|
2547
|
+
"export": true,
|
|
2548
|
+
parameters: [{
|
|
2549
|
+
name: "config",
|
|
2550
|
+
type: "ConfirmConfig"
|
|
2551
|
+
}],
|
|
2552
|
+
returnType: "Promise<boolean | symbol>",
|
|
2553
|
+
children: __alloy_js_core.code`return new Promise<boolean | symbol>((response, reject) => {
|
|
2554
|
+
const prompt = new ConfirmPrompt(config);
|
|
2555
|
+
|
|
2556
|
+
prompt.on("state", state => config.onState?.(state));
|
|
2557
|
+
prompt.on("submit", value => response(value));
|
|
2558
|
+
prompt.on("cancel", event => reject(CANCEL_SYMBOL));
|
|
2559
|
+
}); `
|
|
2560
|
+
})
|
|
2561
|
+
];
|
|
2562
|
+
}
|
|
2563
|
+
/**
|
|
2164
2564
|
* 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.
|
|
2165
2565
|
*/
|
|
2166
2566
|
function PasswordPromptDeclaration() {
|
|
@@ -2280,6 +2680,8 @@ function PromptsBuiltin(props) {
|
|
|
2280
2680
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2281
2681
|
(0, __alloy_js_core_jsx_runtime.createComponent)(PasswordPromptDeclaration, {}),
|
|
2282
2682
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2683
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(ConfirmPromptDeclarations, {}),
|
|
2684
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2283
2685
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
2284
2686
|
get when() {
|
|
2285
2687
|
return Boolean(children);
|
|
@@ -2293,6 +2695,7 @@ function PromptsBuiltin(props) {
|
|
|
2293
2695
|
|
|
2294
2696
|
//#endregion
|
|
2295
2697
|
exports.BasePromptDeclarations = BasePromptDeclarations;
|
|
2698
|
+
exports.ConfirmPromptDeclarations = ConfirmPromptDeclarations;
|
|
2296
2699
|
exports.NumericPromptDeclarations = NumericPromptDeclarations;
|
|
2297
2700
|
exports.PasswordPromptDeclaration = PasswordPromptDeclaration;
|
|
2298
2701
|
exports.PromptsBuiltin = PromptsBuiltin;
|