@shell-shock/preset-cli 0.5.1 → 0.7.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.
Files changed (49) hide show
  1. package/dist/components/banner-function-declaration.cjs +6 -6
  2. package/dist/components/banner-function-declaration.d.cts +2 -2
  3. package/dist/components/banner-function-declaration.d.cts.map +1 -1
  4. package/dist/components/banner-function-declaration.d.mts +2 -2
  5. package/dist/components/banner-function-declaration.d.mts.map +1 -1
  6. package/dist/components/banner-function-declaration.mjs +6 -6
  7. package/dist/components/banner-function-declaration.mjs.map +1 -1
  8. package/dist/components/command-entry.cjs +178 -120
  9. package/dist/components/command-entry.d.cts +2 -2
  10. package/dist/components/command-entry.d.mts +2 -2
  11. package/dist/components/command-entry.mjs +177 -119
  12. package/dist/components/command-entry.mjs.map +1 -1
  13. package/dist/components/command-router.d.cts +3 -3
  14. package/dist/components/command-router.d.cts.map +1 -1
  15. package/dist/components/index.cjs +1 -0
  16. package/dist/components/index.d.cts +2 -2
  17. package/dist/components/index.d.mts +2 -2
  18. package/dist/components/index.mjs +2 -2
  19. package/dist/components/prompts-builtin.cjs +485 -57
  20. package/dist/components/prompts-builtin.d.cts +13 -9
  21. package/dist/components/prompts-builtin.d.cts.map +1 -1
  22. package/dist/components/prompts-builtin.d.mts +13 -9
  23. package/dist/components/prompts-builtin.d.mts.map +1 -1
  24. package/dist/components/prompts-builtin.mjs +495 -68
  25. package/dist/components/prompts-builtin.mjs.map +1 -1
  26. package/dist/components/virtual-command-entry.cjs +4 -3
  27. package/dist/components/virtual-command-entry.mjs +3 -2
  28. package/dist/components/virtual-command-entry.mjs.map +1 -1
  29. package/dist/index.cjs +3 -0
  30. package/dist/index.d.cts.map +1 -1
  31. package/dist/index.d.mts.map +1 -1
  32. package/dist/index.mjs +3 -0
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/plugin-upgrade/dist/components/index.cjs +2 -0
  35. package/dist/plugin-upgrade/dist/components/index.mjs +4 -0
  36. package/dist/plugin-upgrade/dist/components/upgrade-builtin.cjs +661 -0
  37. package/dist/plugin-upgrade/dist/components/upgrade-builtin.mjs +655 -0
  38. package/dist/plugin-upgrade/dist/components/upgrade-builtin.mjs.map +1 -0
  39. package/dist/plugin-upgrade/dist/components/upgrade-command.cjs +96 -0
  40. package/dist/plugin-upgrade/dist/components/upgrade-command.mjs +96 -0
  41. package/dist/plugin-upgrade/dist/components/upgrade-command.mjs.map +1 -0
  42. package/dist/plugin-upgrade/dist/index.cjs +49 -0
  43. package/dist/plugin-upgrade/dist/index.mjs +49 -0
  44. package/dist/plugin-upgrade/dist/index.mjs.map +1 -0
  45. package/dist/types/plugin.d.cts +6 -10
  46. package/dist/types/plugin.d.cts.map +1 -1
  47. package/dist/types/plugin.d.mts +6 -10
  48. package/dist/types/plugin.d.mts.map +1 -1
  49. package/package.json +10 -10
@@ -2,14 +2,15 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  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
- let __shell_shock_preset_script_contexts_theme = require("@shell-shock/preset-script/contexts/theme");
6
5
  let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
6
+ let __powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
7
7
  let defu = require("defu");
8
8
  defu = require_rolldown_runtime.__toESM(defu);
9
- let __powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
9
+ let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
10
+ let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
11
+ let __shell_shock_preset_script_contexts_theme = require("@shell-shock/preset-script/contexts/theme");
10
12
  let __powerlines_plugin_alloy_typescript_components_class_declaration = require("@powerlines/plugin-alloy/typescript/components/class-declaration");
11
13
  let __powerlines_plugin_alloy_typescript_components_interface_declaration = require("@powerlines/plugin-alloy/typescript/components/interface-declaration");
12
- let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
13
14
  let __powerlines_plugin_alloy_typescript_components_type_declaration = require("@powerlines/plugin-alloy/typescript/components/type-declaration");
14
15
 
15
16
  //#region src/components/prompts-builtin.tsx
@@ -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 configuring a prompt",
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, {}),
@@ -204,7 +205,14 @@ function BasePromptDeclarations() {
204
205
  name: "mask",
205
206
  optional: true,
206
207
  type: "(input: string) => string",
207
- doc: "A function that masks the input value and returns the masked result or throws an error if the input is invalid"
208
+ 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."
209
+ }),
210
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
211
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
212
+ name: "maskSubmitted",
213
+ optional: true,
214
+ type: "(input: string) => string",
215
+ 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."
208
216
  }),
209
217
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
210
218
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
@@ -301,7 +309,7 @@ function BasePromptDeclarations() {
301
309
  name: "defaultErrorMessage",
302
310
  "protected": true,
303
311
  type: "string",
304
- children: __alloy_js_core.code`"Invalid value provided"; `
312
+ children: __alloy_js_core.code`"An invalid value was provided"; `
305
313
  }),
306
314
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
307
315
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
@@ -320,6 +328,7 @@ function BasePromptDeclarations() {
320
328
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
321
329
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
322
330
  name: "isInitial",
331
+ "protected": true,
323
332
  type: "boolean",
324
333
  children: __alloy_js_core.code`true; `
325
334
  }),
@@ -373,6 +382,12 @@ function BasePromptDeclarations() {
373
382
  children: __alloy_js_core.code`noMask; `
374
383
  }),
375
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: "maskSubmitted",
387
+ "protected": true,
388
+ type: "(input: string) => string"
389
+ }),
390
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
376
391
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
377
392
  name: "cursor",
378
393
  "protected": true,
@@ -386,6 +401,13 @@ function BasePromptDeclarations() {
386
401
  type: "number",
387
402
  children: __alloy_js_core.code`0; `
388
403
  }),
404
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
405
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
406
+ name: "cursorHidden",
407
+ "protected": true,
408
+ type: "boolean",
409
+ children: __alloy_js_core.code`false; `
410
+ }),
389
411
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
390
412
  __alloy_js_core.code`constructor(protected config: PromptConfig<TValue>) {
391
413
  super();
@@ -412,6 +434,16 @@ function BasePromptDeclarations() {
412
434
  this.formatter = config.format.bind(this);
413
435
  }
414
436
 
437
+ if (config.maskSubmitted) {
438
+ this.maskSubmitted = config.maskSubmitted;
439
+ }
440
+ if (config.mask) {
441
+ this.mask = config.mask;
442
+ }
443
+ if (!this.maskSubmitted) {
444
+ this.maskSubmitted = this.mask;
445
+ }
446
+
415
447
  if (config.timeout !== undefined && !Number.isNaN(config.timeout)) {
416
448
  setTimeout(() => {
417
449
  if (!this.isCompleted) {
@@ -501,7 +533,7 @@ function BasePromptDeclarations() {
501
533
  updatedValue = value;
502
534
  }
503
535
 
504
- this.displayValue = this.formatter(updatedValue);
536
+ this.displayValue = this.mask(this.formatter(updatedValue));
505
537
  this.#value = updatedValue;
506
538
  setTimeout(() => {
507
539
  Promise.resolve(this.validate(updatedValue)).then(() => this.sync());
@@ -711,6 +743,8 @@ function BasePromptDeclarations() {
711
743
  }
712
744
 
713
745
  this.output.write(clear(this.consoleOutput, this.output.columns));
746
+ } else if (this.cursorHidden) {
747
+ this.output.write(cursor.hide);
714
748
  }
715
749
 
716
750
  this.consoleOutput = \` \${
@@ -753,7 +787,7 @@ function BasePromptDeclarations() {
753
787
  : this.isError
754
788
  ? colors.text.prompt.input.error(this.displayValue)
755
789
  : this.isSubmitted
756
- ? colors.text.prompt.input.submitted(this.displayValue)
790
+ ? colors.text.prompt.input.submitted(this.maskSubmitted(this.displayValue))
757
791
  : this.isCancelled
758
792
  ? colors.text.prompt.input.cancelled(this.displayValue)
759
793
  : colors.bold(colors.text.prompt.input.active(this.displayValue)); `
@@ -796,10 +830,10 @@ function BasePromptDeclarations() {
796
830
  }
797
831
  }),
798
832
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
833
+ (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
834
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
800
835
  "export": true,
801
836
  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
837
  children: __alloy_js_core.code`Symbol("shell-shock:prompts:cancel"); `
804
838
  }),
805
839
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
@@ -832,7 +866,7 @@ function TextPromptDeclarations() {
832
866
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
833
867
  name: "StringPromptConfig",
834
868
  "extends": "PromptConfig<string>",
835
- doc: "Configuration options for configuring a text-based prompt",
869
+ doc: "Configuration options for creating a text-based prompt",
836
870
  get children() {
837
871
  return [
838
872
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
@@ -882,6 +916,7 @@ function TextPromptDeclarations() {
882
916
 
883
917
  this.cursor = 0;
884
918
  this.sync();
919
+ this.first();
885
920
  } `,
886
921
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
887
922
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
@@ -1304,6 +1339,14 @@ function SelectPromptDeclarations() {
1304
1339
  type: "PromptOption<TValue>[]",
1305
1340
  children: __alloy_js_core.code`[]; `
1306
1341
  }),
1342
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
1343
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
1344
+ name: "cursorHidden",
1345
+ "protected": true,
1346
+ override: true,
1347
+ type: "boolean",
1348
+ children: __alloy_js_core.code`true; `
1349
+ }),
1307
1350
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1308
1351
  __alloy_js_core.code`constructor(config: SelectPromptConfig<TValue>) {
1309
1352
  super(config);
@@ -1478,11 +1521,7 @@ function SelectPromptDeclarations() {
1478
1521
  name: "render",
1479
1522
  override: true,
1480
1523
  "protected": true,
1481
- children: __alloy_js_core.code`if (this.isInitial) {
1482
- this.output.write(cursor.hide);
1483
- }
1484
-
1485
- const spacing = Math.max(...this.options.map(option => option.label?.length || 0)) + 2;
1524
+ children: __alloy_js_core.code`const spacing = Math.max(...this.options.map(option => option.label?.length || 0)) + 2;
1486
1525
 
1487
1526
  const startIndex = Math.max(Math.min(this.options.length - this.optionsPerPage, this.cursor - Math.floor(this.optionsPerPage / 2)), 0);
1488
1527
  const endIndex = Math.min(startIndex + this.optionsPerPage, this.options.length);
@@ -1614,7 +1653,7 @@ function NumericPromptDeclarations() {
1614
1653
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
1615
1654
  name: "NumberPromptConfig",
1616
1655
  "extends": "PromptConfig<number>",
1617
- doc: "Configuration options for configuring a numeric prompt",
1656
+ doc: "Configuration options for creating a numeric prompt",
1618
1657
  get children() {
1619
1658
  return [
1620
1659
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
@@ -1661,6 +1700,13 @@ function NumericPromptDeclarations() {
1661
1700
  "extends": "Prompt<number>",
1662
1701
  get children() {
1663
1702
  return [
1703
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
1704
+ name: "isInvalid",
1705
+ isPrivateMember: true,
1706
+ type: "boolean",
1707
+ children: __alloy_js_core.code`false; `
1708
+ }),
1709
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1664
1710
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
1665
1711
  name: "initialValue",
1666
1712
  "protected": true,
@@ -1669,6 +1715,14 @@ function NumericPromptDeclarations() {
1669
1715
  children: __alloy_js_core.code`0; `
1670
1716
  }),
1671
1717
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
1718
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
1719
+ name: "defaultErrorMessage",
1720
+ "protected": true,
1721
+ override: true,
1722
+ type: "string",
1723
+ children: __alloy_js_core.code`"A valid numeric value must be provided"; `
1724
+ }),
1725
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
1672
1726
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
1673
1727
  name: "isFloat",
1674
1728
  "protected": true,
@@ -1754,6 +1808,7 @@ function NumericPromptDeclarations() {
1754
1808
  }
1755
1809
 
1756
1810
  this.sync();
1811
+ this.last();
1757
1812
  } `,
1758
1813
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1759
1814
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
@@ -1764,14 +1819,6 @@ function NumericPromptDeclarations() {
1764
1819
  children: __alloy_js_core.code`super.reset();
1765
1820
  this.currentInput = "";
1766
1821
  `
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
1822
  }),
1776
1823
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1777
1824
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
@@ -1795,18 +1842,12 @@ function NumericPromptDeclarations() {
1795
1842
  return this.bell();
1796
1843
  }
1797
1844
 
1798
- if (Date.now() - this.inputTimestamp > 1000) {
1799
- this.currentInput = "";
1800
- }
1801
-
1802
- this.currentInput += char;
1803
- this.inputTimestamp = Date.now();
1804
-
1805
- if (char === ".") {
1845
+ this.displayValue += char;
1846
+ if ((char === "-" || char === ".") && this.displayValue.length === 1) {
1806
1847
  return this.sync();
1807
1848
  }
1808
1849
 
1809
- let value = Math.min(this.parser(this.currentInput), this.max);
1850
+ let value = Math.min(this.parser(this.displayValue), this.max);
1810
1851
  if (value > this.max) {
1811
1852
  value = this.max;
1812
1853
  }
@@ -1815,6 +1856,14 @@ function NumericPromptDeclarations() {
1815
1856
  }
1816
1857
 
1817
1858
  this.changeValue(value);
1859
+ this.sync(); `
1860
+ }),
1861
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1862
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
1863
+ doc: "A method to move the cursor to the end of the input",
1864
+ name: "next",
1865
+ "protected": true,
1866
+ children: __alloy_js_core.code`this.changeValue(this.initialValue);
1818
1867
  this.sync(); `
1819
1868
  }),
1820
1869
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
@@ -1822,14 +1871,10 @@ function NumericPromptDeclarations() {
1822
1871
  doc: "A method to move the cursor to the up",
1823
1872
  name: "up",
1824
1873
  "protected": true,
1825
- children: __alloy_js_core.code`this.currentInput = "";
1826
-
1827
- let value = this.value;
1874
+ children: __alloy_js_core.code`let value = this.value;
1828
1875
  if (this.displayValue === "") {
1829
- value = this.min === Number.NEGATIVE_INFINITY ? 0 - this.increment : this.min - this.increment;
1830
- }
1831
-
1832
- if (value >= this.max) {
1876
+ value = this.min < 0 ? 0 : this.min;
1877
+ } else if (value >= this.max) {
1833
1878
  return this.bell();
1834
1879
  }
1835
1880
 
@@ -1841,36 +1886,134 @@ function NumericPromptDeclarations() {
1841
1886
  doc: "A method to move the cursor to the down",
1842
1887
  name: "down",
1843
1888
  "protected": true,
1844
- children: __alloy_js_core.code`this.currentInput = "";
1889
+ children: __alloy_js_core.code`let value = this.value;
1890
+ if (this.displayValue === "") {
1891
+ value = this.min < 0 ? 0 : this.min;
1892
+ } else if (value <= this.min) {
1893
+ return this.bell();
1894
+ }
1845
1895
 
1846
- let value = this.value;
1847
- if(this.displayValue === "") {
1848
- value = this.min === Number.NEGATIVE_INFINITY ? 0 + this.increment : this.min + this.increment;
1896
+ this.changeValue(value === this.min ? this.min : value - this.increment);
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",
1902
+ name: "left",
1903
+ "protected": true,
1904
+ children: __alloy_js_core.code`if (this.cursor <= 0 || this.isPlaceholder) {
1905
+ return this.bell();
1849
1906
  }
1850
1907
 
1851
- if (value <= this.min) {
1908
+ this.moveCursor(-1);
1909
+ this.sync(); `
1910
+ }),
1911
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1912
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
1913
+ doc: "A method to move the cursor to the right",
1914
+ name: "right",
1915
+ "protected": true,
1916
+ children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length || this.isPlaceholder) {
1852
1917
  return this.bell();
1853
1918
  }
1854
1919
 
1855
- this.changeValue(value - this.increment);
1920
+ this.moveCursor(1);
1856
1921
  this.sync(); `
1922
+ }),
1923
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1924
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
1925
+ doc: "A method to move the cursor to the left or right by a \\`count\\` of positions",
1926
+ name: "moveCursor",
1927
+ parameters: [{
1928
+ name: "count",
1929
+ type: "number"
1930
+ }],
1931
+ "protected": true,
1932
+ children: __alloy_js_core.code`if (this.isPlaceholder) {
1933
+ return;
1934
+ }
1935
+
1936
+ this.cursor = this.cursor + count;
1937
+ this.cursorOffset += count; `
1857
1938
  }),
1858
1939
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1859
1940
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
1860
1941
  doc: "A method to delete the character backward of the cursor",
1861
1942
  name: "delete",
1862
1943
  "protected": true,
1863
- children: __alloy_js_core.code`if (this.displayValue === "") {
1944
+ children: __alloy_js_core.code`if (this.isCursorAtStart()) {
1864
1945
  return this.bell();
1865
1946
  }
1866
1947
 
1867
- let value = this.parser(this.displayValue.slice(0, -1));
1868
- if (value < this.min) {
1869
- value = this.min === Number.NEGATIVE_INFINITY ? 0 : this.min;
1948
+ if (this.displayValue === "") {
1949
+ return this.bell();
1870
1950
  }
1871
1951
 
1872
- this.changeValue(value);
1952
+ this.changeValue(\`\${this.displayValue.slice(0, this.cursor - 1)}\${this.displayValue.slice(this.cursor)}\`);
1953
+ this.#isInvalid = false;
1954
+
1955
+ if (this.isCursorAtStart()) {
1956
+ this.cursorOffset = 0
1957
+ } else {
1958
+ this.cursorOffset++;
1959
+ this.moveCursor(-1);
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 delete the character forward of the cursor",
1967
+ name: "deleteForward",
1968
+ "protected": true,
1969
+ children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length || this.isPlaceholder) {
1970
+ return this.bell();
1971
+ }
1972
+
1973
+ this.changeValue(\`\${
1974
+ this.displayValue.slice(0, this.cursor)
1975
+ }\${
1976
+ this.displayValue.slice(this.cursor + 1)
1977
+ }\`);
1978
+ this.#isInvalid = false;
1979
+
1980
+ if (this.isCursorAtEnd()) {
1981
+ this.cursorOffset = 0;
1982
+ } else {
1983
+ this.cursorOffset++;
1984
+ }
1985
+
1986
+ this.sync(); `
1987
+ }),
1988
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1989
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
1990
+ doc: "A method to move the cursor to the start",
1991
+ name: "first",
1992
+ "protected": true,
1993
+ children: __alloy_js_core.code`this.cursor = 0;
1994
+ this.sync(); `
1995
+ }),
1996
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1997
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
1998
+ doc: "A method to move the cursor to the end",
1999
+ name: "last",
2000
+ "protected": true,
2001
+ children: __alloy_js_core.code`this.cursor = this.displayValue.length;
1873
2002
  this.sync(); `
2003
+ }),
2004
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2005
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
2006
+ doc: "A method to check if the cursor is at the start",
2007
+ name: "isCursorAtStart",
2008
+ "protected": true,
2009
+ children: __alloy_js_core.code`return this.cursor === 0 || (this.isPlaceholder && this.cursor === 1); `
2010
+ }),
2011
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2012
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
2013
+ doc: "A method to check if the cursor is at the end",
2014
+ name: "isCursorAtEnd",
2015
+ "protected": true,
2016
+ children: __alloy_js_core.code`return this.cursor === this.displayValue.length || (this.isPlaceholder && this.cursor === this.displayValue.length + 1); `
1874
2017
  })
1875
2018
  ];
1876
2019
  }
@@ -1940,7 +2083,7 @@ function TogglePromptDeclarations() {
1940
2083
  "export": true,
1941
2084
  name: "TogglePromptConfig",
1942
2085
  "extends": "PromptConfig<boolean>",
1943
- doc: "Configuration options for configuring a boolean toggle prompt",
2086
+ doc: "Configuration options for creating a boolean toggle prompt",
1944
2087
  get children() {
1945
2088
  return [
1946
2089
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
@@ -1964,7 +2107,7 @@ function TogglePromptDeclarations() {
1964
2107
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
1965
2108
  "export": true,
1966
2109
  name: "TogglePrompt",
1967
- doc: "A prompt for selecting a boolean input",
2110
+ doc: "A prompt for toggling a boolean input",
1968
2111
  "extends": "Prompt<boolean>",
1969
2112
  get children() {
1970
2113
  return [
@@ -1989,6 +2132,14 @@ function TogglePromptDeclarations() {
1989
2132
  type: "string",
1990
2133
  children: __alloy_js_core.code`"No"; `
1991
2134
  }),
2135
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2136
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
2137
+ name: "cursorHidden",
2138
+ "protected": true,
2139
+ override: true,
2140
+ type: "boolean",
2141
+ children: __alloy_js_core.code`true; `
2142
+ }),
1992
2143
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
1993
2144
  __alloy_js_core.code`constructor(config: TogglePromptConfig) {
1994
2145
  super(config);
@@ -2102,6 +2253,23 @@ function TogglePromptDeclarations() {
2102
2253
  "protected": true,
2103
2254
  children: __alloy_js_core.code`this.changeValue(!this.value);
2104
2255
  this.sync(); `
2256
+ }),
2257
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2258
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
2259
+ doc: "A method to render the prompt",
2260
+ name: "render",
2261
+ override: true,
2262
+ "protected": true,
2263
+ returnType: "string",
2264
+ children: __alloy_js_core.code`return this.isSubmitted
2265
+ ? colors.text.prompt.input.submitted(this.value ? this.trueMessage : this.falseMessage)
2266
+ : this.isCancelled
2267
+ ? colors.text.prompt.input.cancelled(this.value ? this.trueMessage : this.falseMessage)
2268
+ : \`\${
2269
+ this.value ? colors.text.prompt.input.inactive(this.falseMessage) : colors.underline(colors.bold(colors.text.prompt.input.active(this.falseMessage)))
2270
+ } \${colors.border.app.divider.tertiary("/")} \${
2271
+ this.value ? colors.underline(colors.bold(colors.text.prompt.input.active(this.trueMessage))) : colors.text.prompt.input.inactive(this.trueMessage)
2272
+ }\`; `
2105
2273
  })
2106
2274
  ];
2107
2275
  }
@@ -2161,6 +2329,262 @@ run(); ` }),
2161
2329
  ];
2162
2330
  }
2163
2331
  /**
2332
+ * 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.
2333
+ */
2334
+ function ConfirmPromptDeclarations() {
2335
+ return [
2336
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceDeclaration, {
2337
+ "export": true,
2338
+ name: "ConfirmPromptConfig",
2339
+ "extends": "PromptConfig<boolean>",
2340
+ doc: "Configuration options for creating a boolean confirm prompt",
2341
+ get children() {
2342
+ return [
2343
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
2344
+ heading: "The message for the \\`Yes\\` state of the prompt",
2345
+ get children() {
2346
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
2347
+ get type() {
2348
+ return __powerlines_deepkit_vendor_type.ReflectionKind.string;
2349
+ },
2350
+ defaultValue: "Yes"
2351
+ });
2352
+ }
2353
+ }),
2354
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
2355
+ name: "yesMessage",
2356
+ optional: true,
2357
+ type: "string"
2358
+ }),
2359
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2360
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
2361
+ heading: "The \\`Yes\\` option when choosing between yes/no",
2362
+ get children() {
2363
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
2364
+ get type() {
2365
+ return __powerlines_deepkit_vendor_type.ReflectionKind.string;
2366
+ },
2367
+ defaultValue: "1"
2368
+ });
2369
+ }
2370
+ }),
2371
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
2372
+ name: "yesOption",
2373
+ optional: true,
2374
+ type: "string"
2375
+ }),
2376
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2377
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
2378
+ heading: "The message for the \\`No\\` state of the prompt",
2379
+ get children() {
2380
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
2381
+ get type() {
2382
+ return __powerlines_deepkit_vendor_type.ReflectionKind.string;
2383
+ },
2384
+ defaultValue: "(Y/n)"
2385
+ });
2386
+ }
2387
+ }),
2388
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
2389
+ name: "noMessage",
2390
+ optional: true,
2391
+ type: "string"
2392
+ }),
2393
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2394
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
2395
+ heading: "The \\`No\\` option when choosing between yes/no",
2396
+ get children() {
2397
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
2398
+ get type() {
2399
+ return __powerlines_deepkit_vendor_type.ReflectionKind.string;
2400
+ },
2401
+ defaultValue: "(y/N)"
2402
+ });
2403
+ }
2404
+ }),
2405
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
2406
+ name: "noOption",
2407
+ optional: true,
2408
+ type: "string"
2409
+ })
2410
+ ];
2411
+ }
2412
+ }),
2413
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2414
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassDeclaration, {
2415
+ "export": true,
2416
+ name: "ConfirmPrompt",
2417
+ doc: "A prompt for confirming a boolean input",
2418
+ "extends": "Prompt<boolean>",
2419
+ get children() {
2420
+ return [
2421
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
2422
+ name: "initialValue",
2423
+ "protected": true,
2424
+ override: true,
2425
+ type: "boolean",
2426
+ children: __alloy_js_core.code`false; `
2427
+ }),
2428
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2429
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
2430
+ name: "yesMessage",
2431
+ "protected": true,
2432
+ type: "string",
2433
+ children: __alloy_js_core.code`"Yes"; `
2434
+ }),
2435
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2436
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
2437
+ name: "yesOption",
2438
+ "protected": true,
2439
+ type: "string",
2440
+ children: __alloy_js_core.code`"(Y/n)"; `
2441
+ }),
2442
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2443
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
2444
+ name: "noMessage",
2445
+ "protected": true,
2446
+ type: "string",
2447
+ children: __alloy_js_core.code`"No"; `
2448
+ }),
2449
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2450
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
2451
+ name: "noOption",
2452
+ "protected": true,
2453
+ type: "string",
2454
+ children: __alloy_js_core.code`"(y/N)"; `
2455
+ }),
2456
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2457
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
2458
+ name: "cursorHidden",
2459
+ "protected": true,
2460
+ override: true,
2461
+ type: "boolean",
2462
+ children: __alloy_js_core.code`true; `
2463
+ }),
2464
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2465
+ __alloy_js_core.code`constructor(config: ConfirmPromptConfig) {
2466
+ super(config);
2467
+
2468
+ if (config.initialValue) {
2469
+ this.initialValue = config.initialValue;
2470
+ }
2471
+
2472
+ if (config.yesMessage) {
2473
+ this.yesMessage = config.yesMessage;
2474
+ }
2475
+ if (config.yesOption) {
2476
+ this.yesOption = config.yesOption;
2477
+ }
2478
+ if (config.noMessage) {
2479
+ this.noMessage = config.noMessage;
2480
+ }
2481
+ if (config.noOption) {
2482
+ this.noOption = config.noOption;
2483
+ }
2484
+
2485
+ this.sync();
2486
+ } `,
2487
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2488
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
2489
+ doc: "A method to handle keypress events and determine the corresponding action",
2490
+ name: "keypress",
2491
+ override: true,
2492
+ "protected": true,
2493
+ parameters: [{
2494
+ name: "char",
2495
+ type: "string"
2496
+ }, {
2497
+ name: "key",
2498
+ type: "readline.Key"
2499
+ }],
2500
+ children: __alloy_js_core.code`const action = this.getAction(key);
2501
+ if (action && typeof (this as any)[action] === "function") {
2502
+ return (this as any)[action]();
2503
+ }
2504
+
2505
+ if (char.toLowerCase() === "y" || char.toLowerCase() === "t" || char.toLowerCase() === "0") {
2506
+ this.value = true;
2507
+ return this.submit();
2508
+ } else if (char.toLowerCase() === "n" || char.toLowerCase() === "f" || char.toLowerCase() === "1") {
2509
+ this.value = false;
2510
+ return this.submit();
2511
+ } else {
2512
+ return this.bell();
2513
+ }
2514
+
2515
+ this.sync(); `
2516
+ }),
2517
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2518
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
2519
+ doc: "A method to render the prompt",
2520
+ name: "render",
2521
+ override: true,
2522
+ "protected": true,
2523
+ returnType: "string",
2524
+ children: __alloy_js_core.code`return this.isSubmitted
2525
+ ? colors.text.prompt.input.submitted(this.value ? this.yesMessage : this.noMessage)
2526
+ : this.isCancelled
2527
+ ? colors.text.prompt.input.cancelled(this.value ? this.yesMessage : this.noMessage)
2528
+ : colors.text.prompt.input.inactive(this.initialValue ? this.yesOption : this.noOption); `
2529
+ })
2530
+ ];
2531
+ }
2532
+ }),
2533
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2534
+ (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." }),
2535
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
2536
+ name: "ConfirmConfig",
2537
+ "export": true,
2538
+ children: __alloy_js_core.code`PromptFactoryConfig<boolean> & ConfirmPromptConfig; `
2539
+ }),
2540
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2541
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
2542
+ 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.",
2543
+ get children() {
2544
+ return [
2545
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `import { confirm, isCancel } from "shell-shock:prompts";
2546
+
2547
+ async function run() {
2548
+ const likesIceCream = await confirm({
2549
+ message: "Do you like ice cream?"
2550
+ });
2551
+ if (isCancel(likesIceCream)) {
2552
+ console.log("Prompt was cancelled");
2553
+ return;
2554
+ }
2555
+
2556
+ console.log("You" + (likesIceCream ? " like ice cream" : " don't like ice cream") + "!");
2557
+ }
2558
+
2559
+ run(); ` }),
2560
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2561
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
2562
+ name: "config",
2563
+ children: `The configuration options to pass to the confirm prompt, which extends the base PromptFactoryConfig with additional options specific to the confirm prompt`
2564
+ }),
2565
+ (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` })
2566
+ ];
2567
+ }
2568
+ }),
2569
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
2570
+ name: "confirm",
2571
+ "export": true,
2572
+ parameters: [{
2573
+ name: "config",
2574
+ type: "ConfirmConfig"
2575
+ }],
2576
+ returnType: "Promise<boolean | symbol>",
2577
+ children: __alloy_js_core.code`return new Promise<boolean | symbol>((response, reject) => {
2578
+ const prompt = new ConfirmPrompt(config);
2579
+
2580
+ prompt.on("state", state => config.onState?.(state));
2581
+ prompt.on("submit", value => response(value));
2582
+ prompt.on("cancel", event => reject(CANCEL_SYMBOL));
2583
+ }); `
2584
+ })
2585
+ ];
2586
+ }
2587
+ /**
2164
2588
  * 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
2589
  */
2166
2590
  function PasswordPromptDeclaration() {
@@ -2181,7 +2605,7 @@ function PasswordPromptDeclaration() {
2181
2605
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
2182
2606
  name: "PasswordConfig",
2183
2607
  "export": true,
2184
- children: __alloy_js_core.code`Omit<TextConfig, "mask">; `
2608
+ children: __alloy_js_core.code`Omit<TextConfig, "mask" | "maskSubmitted">; `
2185
2609
  }),
2186
2610
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2187
2611
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
@@ -2224,7 +2648,8 @@ run(); ` }),
2224
2648
  returnType: "Promise<string | symbol>",
2225
2649
  children: __alloy_js_core.code`return text({
2226
2650
  ...config,
2227
- mask: passwordMask
2651
+ mask: passwordMask,
2652
+ maskSubmitted: () => "*******"
2228
2653
  });`
2229
2654
  })
2230
2655
  ];
@@ -2236,7 +2661,7 @@ function PromptsBuiltin(props) {
2236
2661
  const [{ children }, rest] = (0, __alloy_js_core.splitProps)(props, ["children"]);
2237
2662
  return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, __alloy_js_core_jsx_runtime.mergeProps)({
2238
2663
  id: "prompts",
2239
- description: "A collection of prompts that allow for interactive input in command line applications."
2664
+ description: "A collection of prompts that allow for interactive input in command-line applications."
2240
2665
  }, rest, {
2241
2666
  get imports() {
2242
2667
  return (0, defu.default)(rest.imports ?? {}, {
@@ -2280,6 +2705,8 @@ function PromptsBuiltin(props) {
2280
2705
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2281
2706
  (0, __alloy_js_core_jsx_runtime.createComponent)(PasswordPromptDeclaration, {}),
2282
2707
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2708
+ (0, __alloy_js_core_jsx_runtime.createComponent)(ConfirmPromptDeclarations, {}),
2709
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2283
2710
  (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
2284
2711
  get when() {
2285
2712
  return Boolean(children);
@@ -2293,6 +2720,7 @@ function PromptsBuiltin(props) {
2293
2720
 
2294
2721
  //#endregion
2295
2722
  exports.BasePromptDeclarations = BasePromptDeclarations;
2723
+ exports.ConfirmPromptDeclarations = ConfirmPromptDeclarations;
2296
2724
  exports.NumericPromptDeclarations = NumericPromptDeclarations;
2297
2725
  exports.PasswordPromptDeclaration = PasswordPromptDeclaration;
2298
2726
  exports.PromptsBuiltin = PromptsBuiltin;