@shell-shock/plugin-prompts 0.2.1 → 0.2.3
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/prompts-builtin.cjs +279 -279
- package/dist/components/prompts-builtin.d.cts.map +1 -1
- package/dist/components/prompts-builtin.d.mts.map +1 -1
- package/dist/components/prompts-builtin.mjs +279 -279
- package/dist/components/prompts-builtin.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -209,7 +209,7 @@ function BasePromptDeclarations() {
|
|
|
209
209
|
}),
|
|
210
210
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
211
211
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_interface_declaration.InterfaceMember, {
|
|
212
|
-
name: "
|
|
212
|
+
name: "maskCompleted",
|
|
213
213
|
optional: true,
|
|
214
214
|
type: "(input: string) => string",
|
|
215
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."
|
|
@@ -256,6 +256,20 @@ function BasePromptDeclarations() {
|
|
|
256
256
|
type: "TValue"
|
|
257
257
|
}),
|
|
258
258
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
259
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
260
|
+
name: "isKeyPressed",
|
|
261
|
+
isPrivateMember: true,
|
|
262
|
+
type: "boolean",
|
|
263
|
+
children: __alloy_js_core.code`false; `
|
|
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: "isDirty",
|
|
268
|
+
isPrivateMember: true,
|
|
269
|
+
type: "boolean",
|
|
270
|
+
children: __alloy_js_core.code`false; `
|
|
271
|
+
}),
|
|
272
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
259
273
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
260
274
|
name: "isClosed",
|
|
261
275
|
isPrivateMember: true,
|
|
@@ -383,7 +397,7 @@ function BasePromptDeclarations() {
|
|
|
383
397
|
}),
|
|
384
398
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
385
399
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
386
|
-
name: "
|
|
400
|
+
name: "maskCompleted",
|
|
387
401
|
"protected": true,
|
|
388
402
|
type: "(input: string) => string"
|
|
389
403
|
}),
|
|
@@ -434,14 +448,14 @@ function BasePromptDeclarations() {
|
|
|
434
448
|
this.formatter = config.format.bind(this);
|
|
435
449
|
}
|
|
436
450
|
|
|
437
|
-
if (config.
|
|
438
|
-
this.
|
|
451
|
+
if (config.maskCompleted) {
|
|
452
|
+
this.maskCompleted = config.maskCompleted;
|
|
439
453
|
}
|
|
440
454
|
if (config.mask) {
|
|
441
455
|
this.mask = config.mask;
|
|
442
456
|
}
|
|
443
|
-
if (!this.
|
|
444
|
-
this.
|
|
457
|
+
if (!this.maskCompleted) {
|
|
458
|
+
this.maskCompleted = this.mask;
|
|
445
459
|
}
|
|
446
460
|
|
|
447
461
|
if (config.timeout !== undefined && !Number.isNaN(config.timeout)) {
|
|
@@ -464,7 +478,11 @@ function BasePromptDeclarations() {
|
|
|
464
478
|
this.input.setRawMode(true);
|
|
465
479
|
}
|
|
466
480
|
|
|
467
|
-
this.input.on("keypress", this.
|
|
481
|
+
this.input.on("keypress", this.keypress.bind(this));
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
[Symbol.dispose]() {
|
|
485
|
+
this.close();
|
|
468
486
|
} `,
|
|
469
487
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
470
488
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
@@ -500,24 +518,42 @@ function BasePromptDeclarations() {
|
|
|
500
518
|
"protected": true,
|
|
501
519
|
name: "isPlaceholder",
|
|
502
520
|
type: "boolean",
|
|
503
|
-
children: __alloy_js_core.code`return this.
|
|
521
|
+
children: __alloy_js_core.code`return (this.displayValue === this.formatter(this.parser(this.initialValue)) && !this.#isDirty) || !this.#isKeyPressed; `
|
|
504
522
|
}),
|
|
505
523
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
506
524
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
507
525
|
"protected": true,
|
|
508
526
|
name: "status",
|
|
509
527
|
type: "string",
|
|
510
|
-
children: __alloy_js_core.code`return this.
|
|
528
|
+
children: __alloy_js_core.code`return this.isSubmitted ? "" : \` \\n \${
|
|
511
529
|
colors.italic(
|
|
512
530
|
this.isError
|
|
513
531
|
? colors.text.prompt.description.error(splitText(this.errorMessage, "3/4").join("\\n"))
|
|
514
|
-
: this.
|
|
515
|
-
? colors.text.prompt.description.
|
|
516
|
-
:
|
|
532
|
+
: this.isCancelled
|
|
533
|
+
? colors.text.prompt.description.cancelled(splitText("Input was cancelled by user", "3/4").join("\\n"))
|
|
534
|
+
: this.description
|
|
535
|
+
? colors.text.prompt.description.active(splitText(this.description, "3/4").join("\\n"))
|
|
536
|
+
: ""
|
|
517
537
|
)
|
|
518
538
|
}\`; `
|
|
519
539
|
}),
|
|
520
540
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
541
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
542
|
+
doc: "A property to check if the cursor is at the start",
|
|
543
|
+
name: "isCursorAtStart",
|
|
544
|
+
"protected": true,
|
|
545
|
+
type: "boolean",
|
|
546
|
+
children: __alloy_js_core.code`return this.cursor === 0 || (this.isPlaceholder && this.cursor === 1); `
|
|
547
|
+
}),
|
|
548
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
549
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassPropertyGet, {
|
|
550
|
+
doc: "A property to check if the cursor is at the end",
|
|
551
|
+
name: "isCursorAtEnd",
|
|
552
|
+
"protected": true,
|
|
553
|
+
type: "boolean",
|
|
554
|
+
children: __alloy_js_core.code`return this.cursor === this.displayValue.length || (this.isPlaceholder && this.cursor === this.displayValue.length - 1); `
|
|
555
|
+
}),
|
|
556
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
521
557
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
522
558
|
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.",
|
|
523
559
|
name: "changeValue",
|
|
@@ -526,7 +562,9 @@ function BasePromptDeclarations() {
|
|
|
526
562
|
name: "value",
|
|
527
563
|
type: "TValue"
|
|
528
564
|
}],
|
|
529
|
-
children: __alloy_js_core.code`
|
|
565
|
+
children: __alloy_js_core.code`const previousValue = this.value;
|
|
566
|
+
|
|
567
|
+
let updatedValue = value;
|
|
530
568
|
if (value === undefined || value === "") {
|
|
531
569
|
updatedValue = this.initialValue;
|
|
532
570
|
} else {
|
|
@@ -535,6 +573,12 @@ function BasePromptDeclarations() {
|
|
|
535
573
|
|
|
536
574
|
this.displayValue = this.mask(this.formatter(updatedValue));
|
|
537
575
|
this.#value = updatedValue;
|
|
576
|
+
|
|
577
|
+
if (!this.#isDirty && this.#value !== this.initialValue) {
|
|
578
|
+
this.#isDirty = true;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
this.onChange(previousValue);
|
|
538
582
|
setTimeout(() => {
|
|
539
583
|
Promise.resolve(this.validate(updatedValue)).then(() => this.sync());
|
|
540
584
|
}, 0);
|
|
@@ -554,7 +598,7 @@ function BasePromptDeclarations() {
|
|
|
554
598
|
isCancelled: this.isCancelled,
|
|
555
599
|
isCompleted: this.isCompleted
|
|
556
600
|
});
|
|
557
|
-
this.
|
|
601
|
+
this.render(); `
|
|
558
602
|
}),
|
|
559
603
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
560
604
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
@@ -565,26 +609,35 @@ function BasePromptDeclarations() {
|
|
|
565
609
|
}),
|
|
566
610
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
567
611
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
568
|
-
doc: "A method to
|
|
569
|
-
name: "
|
|
612
|
+
doc: "A method to render the prompt",
|
|
613
|
+
name: "onRender",
|
|
614
|
+
"protected": true,
|
|
615
|
+
returnType: "string",
|
|
616
|
+
children: __alloy_js_core.code`return this.isPlaceholder
|
|
617
|
+
? colors.text.prompt.input.disabled(this.displayValue)
|
|
618
|
+
: this.isError
|
|
619
|
+
? colors.text.prompt.input.error(this.displayValue)
|
|
620
|
+
: this.isSubmitted
|
|
621
|
+
? colors.text.prompt.input.submitted(this.maskCompleted(this.displayValue))
|
|
622
|
+
: this.isCancelled
|
|
623
|
+
? colors.text.prompt.input.cancelled(this.maskCompleted(this.displayValue))
|
|
624
|
+
: colors.bold(colors.text.prompt.input.active(this.displayValue)); `
|
|
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 handle changes in the prompt value",
|
|
629
|
+
name: "onChange",
|
|
570
630
|
"protected": true,
|
|
571
631
|
parameters: [{
|
|
572
|
-
name: "
|
|
573
|
-
type: "
|
|
574
|
-
}, {
|
|
575
|
-
name: "key",
|
|
576
|
-
type: "readline.Key"
|
|
632
|
+
name: "previousValue",
|
|
633
|
+
type: "TValue"
|
|
577
634
|
}],
|
|
578
|
-
children: __alloy_js_core.code`if
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
return this.keypress(char, key); `
|
|
635
|
+
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`
|
|
583
636
|
}),
|
|
584
637
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
585
638
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
586
|
-
doc: "A method to handle
|
|
587
|
-
name: "
|
|
639
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
640
|
+
name: "onKeyPress",
|
|
588
641
|
"protected": true,
|
|
589
642
|
parameters: [{
|
|
590
643
|
name: "char",
|
|
@@ -594,11 +647,11 @@ function BasePromptDeclarations() {
|
|
|
594
647
|
type: "readline.Key"
|
|
595
648
|
}],
|
|
596
649
|
children: __alloy_js_core.code`const action = this.getAction(key);
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
650
|
+
if (!action) {
|
|
651
|
+
this.bell();
|
|
652
|
+
} else if (typeof (this as any)[action] === "function") {
|
|
653
|
+
(this as any)[action](key);
|
|
654
|
+
} `
|
|
602
655
|
}),
|
|
603
656
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
604
657
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
@@ -606,8 +659,12 @@ function BasePromptDeclarations() {
|
|
|
606
659
|
name: "close",
|
|
607
660
|
async: true,
|
|
608
661
|
"protected": true,
|
|
609
|
-
children: __alloy_js_core.code`this
|
|
610
|
-
|
|
662
|
+
children: __alloy_js_core.code`if (this.#isClosed) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
this.output.write(cursor.show);
|
|
667
|
+
this.input.removeListener("keypress", this.keypress);
|
|
611
668
|
|
|
612
669
|
if (this.input.isTTY) {
|
|
613
670
|
this.input.setRawMode(false);
|
|
@@ -638,7 +695,7 @@ function BasePromptDeclarations() {
|
|
|
638
695
|
}),
|
|
639
696
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
640
697
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
641
|
-
doc: "A method to route
|
|
698
|
+
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.",
|
|
642
699
|
name: "getAction",
|
|
643
700
|
"protected": true,
|
|
644
701
|
parameters: [{
|
|
@@ -677,6 +734,70 @@ function BasePromptDeclarations() {
|
|
|
677
734
|
if (key.name === "left") action = "left";
|
|
678
735
|
|
|
679
736
|
return action || false; `
|
|
737
|
+
}),
|
|
738
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
739
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
740
|
+
doc: "A method to move the cursor to the left or right by a \\`count\\` of positions",
|
|
741
|
+
name: "moveCursor",
|
|
742
|
+
parameters: [{
|
|
743
|
+
name: "count",
|
|
744
|
+
type: "number"
|
|
745
|
+
}],
|
|
746
|
+
"protected": true,
|
|
747
|
+
children: __alloy_js_core.code`
|
|
748
|
+
this.cursor += count;
|
|
749
|
+
this.cursorOffset += count; `
|
|
750
|
+
}),
|
|
751
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
752
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
753
|
+
doc: "A method to delete the character backward of the cursor",
|
|
754
|
+
name: "delete",
|
|
755
|
+
"protected": true,
|
|
756
|
+
children: __alloy_js_core.code`if (this.isCursorAtStart) {
|
|
757
|
+
return this.bell();
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
if (this.displayValue === "") {
|
|
761
|
+
return this.bell();
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
this.changeValue(\`\${
|
|
765
|
+
this.displayValue.slice(0, this.cursor - 1)
|
|
766
|
+
}\${
|
|
767
|
+
this.displayValue.slice(this.cursor)
|
|
768
|
+
}\`);
|
|
769
|
+
|
|
770
|
+
if (this.isCursorAtStart) {
|
|
771
|
+
this.cursorOffset = 0;
|
|
772
|
+
} else {
|
|
773
|
+
this.cursorOffset++;
|
|
774
|
+
this.moveCursor(-1);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
this.sync(); `
|
|
778
|
+
}),
|
|
779
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
780
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
781
|
+
doc: "A method to delete the character forward of the cursor",
|
|
782
|
+
name: "deleteForward",
|
|
783
|
+
"protected": true,
|
|
784
|
+
children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length) {
|
|
785
|
+
return this.bell();
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
this.changeValue(\`\${
|
|
789
|
+
this.displayValue.slice(0, this.cursor)
|
|
790
|
+
}\${
|
|
791
|
+
this.displayValue.slice(this.cursor + 1)
|
|
792
|
+
}\`);
|
|
793
|
+
|
|
794
|
+
if (this.isCursorAtEnd) {
|
|
795
|
+
this.cursorOffset = 0;
|
|
796
|
+
} else {
|
|
797
|
+
this.cursorOffset++;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
this.sync(); `
|
|
680
801
|
}),
|
|
681
802
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
682
803
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
@@ -730,8 +851,8 @@ function BasePromptDeclarations() {
|
|
|
730
851
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
731
852
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
732
853
|
doc: "A method to render the prompt",
|
|
733
|
-
name: "
|
|
734
|
-
"
|
|
854
|
+
name: "render",
|
|
855
|
+
"private": true,
|
|
735
856
|
get children() {
|
|
736
857
|
return __alloy_js_core.code`if (this.#isClosed) {
|
|
737
858
|
return;
|
|
@@ -766,7 +887,7 @@ function BasePromptDeclarations() {
|
|
|
766
887
|
: (process.platform === "win32" ? "»" : "›")
|
|
767
888
|
)
|
|
768
889
|
} \`;
|
|
769
|
-
this.consoleOutput += this.
|
|
890
|
+
this.consoleOutput += this.onRender();
|
|
770
891
|
|
|
771
892
|
if (this.isInitial) {
|
|
772
893
|
this.isInitial = false;
|
|
@@ -778,19 +899,25 @@ function BasePromptDeclarations() {
|
|
|
778
899
|
}),
|
|
779
900
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
780
901
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
781
|
-
doc: "A method to
|
|
782
|
-
name: "
|
|
783
|
-
"
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
902
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
903
|
+
name: "keypress",
|
|
904
|
+
"private": true,
|
|
905
|
+
parameters: [{
|
|
906
|
+
name: "char",
|
|
907
|
+
type: "string"
|
|
908
|
+
}, {
|
|
909
|
+
name: "key",
|
|
910
|
+
type: "readline.Key"
|
|
911
|
+
}],
|
|
912
|
+
children: __alloy_js_core.code`if (this.#isClosed) {
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
if (!this.#isKeyPressed) {
|
|
917
|
+
this.#isKeyPressed = true;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
return this.onKeyPress(char, key); `
|
|
794
921
|
})
|
|
795
922
|
];
|
|
796
923
|
}
|
|
@@ -920,8 +1047,8 @@ function TextPromptDeclarations() {
|
|
|
920
1047
|
} `,
|
|
921
1048
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
922
1049
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
923
|
-
doc: "A method to handle
|
|
924
|
-
name: "
|
|
1050
|
+
doc: "A method to handle onKeyPress events and determine the corresponding action",
|
|
1051
|
+
name: "onKeyPress",
|
|
925
1052
|
override: true,
|
|
926
1053
|
"protected": true,
|
|
927
1054
|
parameters: [{
|
|
@@ -940,31 +1067,38 @@ function TextPromptDeclarations() {
|
|
|
940
1067
|
return this.bell();
|
|
941
1068
|
}
|
|
942
1069
|
|
|
943
|
-
const value = \`\${
|
|
944
|
-
|
|
945
|
-
|
|
1070
|
+
const value = \`\${
|
|
1071
|
+
this.value.slice(0, this.cursor)
|
|
1072
|
+
}\${
|
|
1073
|
+
char
|
|
1074
|
+
}\${
|
|
1075
|
+
this.value.slice(this.cursor)
|
|
1076
|
+
}\`;
|
|
946
1077
|
|
|
947
1078
|
this.changeValue(value);
|
|
948
1079
|
this.sync(); `
|
|
949
1080
|
}),
|
|
950
1081
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
951
1082
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
952
|
-
doc: "A method to
|
|
953
|
-
name: "
|
|
1083
|
+
doc: "A method to handle changes in the prompt value",
|
|
1084
|
+
name: "onChange",
|
|
954
1085
|
override: true,
|
|
955
1086
|
"protected": true,
|
|
1087
|
+
parameters: [{
|
|
1088
|
+
name: "previousValue",
|
|
1089
|
+
type: "TValue"
|
|
1090
|
+
}],
|
|
956
1091
|
children: __alloy_js_core.code`this.#isInvalid = false;
|
|
957
|
-
this.cursor =
|
|
958
|
-
super.reset(); `
|
|
1092
|
+
this.cursor = this.displayValue.slice(0, this.cursor).length + 1; `
|
|
959
1093
|
}),
|
|
960
1094
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
961
1095
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
962
|
-
doc: "A method to
|
|
963
|
-
name: "
|
|
1096
|
+
doc: "A method to reset the prompt input",
|
|
1097
|
+
name: "reset",
|
|
964
1098
|
override: true,
|
|
965
1099
|
"protected": true,
|
|
966
|
-
children: __alloy_js_core.code`this
|
|
967
|
-
super.
|
|
1100
|
+
children: __alloy_js_core.code`this.cursor = Number(!!this.initialValue);
|
|
1101
|
+
super.reset(); `
|
|
968
1102
|
}),
|
|
969
1103
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
970
1104
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
@@ -981,73 +1115,8 @@ function TextPromptDeclarations() {
|
|
|
981
1115
|
doc: "A method to move the cursor to the end of the input",
|
|
982
1116
|
name: "next",
|
|
983
1117
|
"protected": true,
|
|
984
|
-
children: __alloy_js_core.code`
|
|
985
|
-
return this.bell();
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
this.changeValue(this.initialValue);
|
|
1118
|
+
children: __alloy_js_core.code`this.changeValue(this.initialValue);
|
|
989
1119
|
this.cursor = this.displayValue.length;
|
|
990
|
-
this.sync(); `
|
|
991
|
-
}),
|
|
992
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
993
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
994
|
-
doc: "A method to move the cursor to the left or right by a \\`count\\` of positions",
|
|
995
|
-
name: "moveCursor",
|
|
996
|
-
parameters: [{
|
|
997
|
-
name: "count",
|
|
998
|
-
type: "number"
|
|
999
|
-
}],
|
|
1000
|
-
"protected": true,
|
|
1001
|
-
children: __alloy_js_core.code`if (this.isPlaceholder) {
|
|
1002
|
-
return;
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
this.cursor = this.cursor + count;
|
|
1006
|
-
this.cursorOffset += count; `
|
|
1007
|
-
}),
|
|
1008
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1009
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1010
|
-
doc: "A method to delete the character backward of the cursor",
|
|
1011
|
-
name: "delete",
|
|
1012
|
-
"protected": true,
|
|
1013
|
-
children: __alloy_js_core.code`if (this.isCursorAtStart()) {
|
|
1014
|
-
return this.bell();
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
this.changeValue(\`\${this.value.slice(0, this.cursor - 1)}\${this.value.slice(this.cursor)}\`);
|
|
1018
|
-
this.#isInvalid = false;
|
|
1019
|
-
|
|
1020
|
-
if (this.isCursorAtStart()) {
|
|
1021
|
-
this.cursorOffset = 0
|
|
1022
|
-
} else {
|
|
1023
|
-
this.cursorOffset++;
|
|
1024
|
-
this.moveCursor(-1);
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
this.sync(); `
|
|
1028
|
-
}),
|
|
1029
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1030
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1031
|
-
doc: "A method to delete the character forward of the cursor",
|
|
1032
|
-
name: "deleteForward",
|
|
1033
|
-
"protected": true,
|
|
1034
|
-
children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length || this.isPlaceholder) {
|
|
1035
|
-
return this.bell();
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
this.changeValue(\`\${
|
|
1039
|
-
this.value.slice(0, this.cursor)
|
|
1040
|
-
}\${
|
|
1041
|
-
this.value.slice(this.cursor + 1)
|
|
1042
|
-
}\`);
|
|
1043
|
-
this.#isInvalid = false;
|
|
1044
|
-
|
|
1045
|
-
if (this.isCursorAtEnd()) {
|
|
1046
|
-
this.cursorOffset = 0;
|
|
1047
|
-
} else {
|
|
1048
|
-
this.cursorOffset++;
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
1120
|
this.sync(); `
|
|
1052
1121
|
}),
|
|
1053
1122
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
@@ -1071,7 +1140,7 @@ function TextPromptDeclarations() {
|
|
|
1071
1140
|
doc: "A method to move the cursor to the left",
|
|
1072
1141
|
name: "left",
|
|
1073
1142
|
"protected": true,
|
|
1074
|
-
children: __alloy_js_core.code`if (this.cursor <= 0
|
|
1143
|
+
children: __alloy_js_core.code`if (this.cursor <= 0) {
|
|
1075
1144
|
return this.bell();
|
|
1076
1145
|
}
|
|
1077
1146
|
|
|
@@ -1083,7 +1152,7 @@ function TextPromptDeclarations() {
|
|
|
1083
1152
|
doc: "A method to move the cursor to the right",
|
|
1084
1153
|
name: "right",
|
|
1085
1154
|
"protected": true,
|
|
1086
|
-
children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length
|
|
1155
|
+
children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length) {
|
|
1087
1156
|
return this.bell();
|
|
1088
1157
|
}
|
|
1089
1158
|
|
|
@@ -1091,23 +1160,9 @@ function TextPromptDeclarations() {
|
|
|
1091
1160
|
this.sync(); `
|
|
1092
1161
|
}),
|
|
1093
1162
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1094
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1095
|
-
doc: "A method to check if the cursor is at the start",
|
|
1096
|
-
name: "isCursorAtStart",
|
|
1097
|
-
"protected": true,
|
|
1098
|
-
children: __alloy_js_core.code`return this.cursor === 0 || (this.isPlaceholder && this.cursor === 1); `
|
|
1099
|
-
}),
|
|
1100
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1101
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1102
|
-
doc: "A method to check if the cursor is at the end",
|
|
1103
|
-
name: "isCursorAtEnd",
|
|
1104
|
-
"protected": true,
|
|
1105
|
-
children: __alloy_js_core.code`return this.cursor === this.displayValue.length || (this.isPlaceholder && this.cursor === this.displayValue.length + 1); `
|
|
1106
|
-
}),
|
|
1107
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1108
1163
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1109
1164
|
doc: "A method to render the prompt",
|
|
1110
|
-
name: "
|
|
1165
|
+
name: "onRender",
|
|
1111
1166
|
override: true,
|
|
1112
1167
|
"protected": true,
|
|
1113
1168
|
returnType: "string",
|
|
@@ -1176,7 +1231,7 @@ run(); ` }),
|
|
|
1176
1231
|
|
|
1177
1232
|
prompt.on("state", state => config.onState?.(state));
|
|
1178
1233
|
prompt.on("submit", value => response(value));
|
|
1179
|
-
prompt.on("cancel", event =>
|
|
1234
|
+
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
1180
1235
|
});`
|
|
1181
1236
|
})
|
|
1182
1237
|
];
|
|
@@ -1404,7 +1459,7 @@ function SelectPromptDeclarations() {
|
|
|
1404
1459
|
}),
|
|
1405
1460
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1406
1461
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1407
|
-
doc: "A method to route
|
|
1462
|
+
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.",
|
|
1408
1463
|
name: "getAction",
|
|
1409
1464
|
override: true,
|
|
1410
1465
|
"protected": true,
|
|
@@ -1459,6 +1514,7 @@ function SelectPromptDeclarations() {
|
|
|
1459
1514
|
name: "count",
|
|
1460
1515
|
type: "number"
|
|
1461
1516
|
}],
|
|
1517
|
+
override: true,
|
|
1462
1518
|
"protected": true,
|
|
1463
1519
|
children: __alloy_js_core.code`this.cursor = count;
|
|
1464
1520
|
|
|
@@ -1518,7 +1574,7 @@ function SelectPromptDeclarations() {
|
|
|
1518
1574
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1519
1575
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1520
1576
|
doc: "A method to render the prompt",
|
|
1521
|
-
name: "
|
|
1577
|
+
name: "onRender",
|
|
1522
1578
|
override: true,
|
|
1523
1579
|
"protected": true,
|
|
1524
1580
|
children: __alloy_js_core.code`const spacing = Math.max(...this.options.map(option => option.label?.length || 0)) + 2;
|
|
@@ -1570,7 +1626,7 @@ function SelectPromptDeclarations() {
|
|
|
1570
1626
|
}
|
|
1571
1627
|
} else {
|
|
1572
1628
|
this.displayValue = this.selectedOption?.label || String(this.value);
|
|
1573
|
-
output += super.
|
|
1629
|
+
output += super.onRender();
|
|
1574
1630
|
}
|
|
1575
1631
|
|
|
1576
1632
|
return output; `
|
|
@@ -1640,7 +1696,7 @@ run(); ` }),
|
|
|
1640
1696
|
|
|
1641
1697
|
prompt.on("state", state => config.onState?.(state));
|
|
1642
1698
|
prompt.on("submit", value => response(value));
|
|
1643
|
-
prompt.on("cancel", event =>
|
|
1699
|
+
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
1644
1700
|
});`
|
|
1645
1701
|
})
|
|
1646
1702
|
];
|
|
@@ -1757,20 +1813,6 @@ function NumericPromptDeclarations() {
|
|
|
1757
1813
|
type: "number",
|
|
1758
1814
|
children: __alloy_js_core.code`Number.POSITIVE_INFINITY; `
|
|
1759
1815
|
}),
|
|
1760
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1761
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1762
|
-
name: "currentInput",
|
|
1763
|
-
"protected": true,
|
|
1764
|
-
type: "string",
|
|
1765
|
-
children: __alloy_js_core.code`""; `
|
|
1766
|
-
}),
|
|
1767
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1768
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassField, {
|
|
1769
|
-
name: "inputTimestamp",
|
|
1770
|
-
"protected": true,
|
|
1771
|
-
type: "number",
|
|
1772
|
-
children: __alloy_js_core.code`0; `
|
|
1773
|
-
}),
|
|
1774
1816
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1775
1817
|
__alloy_js_core.code`constructor(config: NumberPromptConfig) {
|
|
1776
1818
|
super(config);
|
|
@@ -1807,23 +1849,13 @@ function NumericPromptDeclarations() {
|
|
|
1807
1849
|
this.validator = validator.bind(this);
|
|
1808
1850
|
}
|
|
1809
1851
|
|
|
1852
|
+
this.changeValue(this.initialValue);
|
|
1810
1853
|
this.sync();
|
|
1811
|
-
this.last();
|
|
1812
1854
|
} `,
|
|
1813
1855
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1814
1856
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1815
|
-
doc: "A method to
|
|
1816
|
-
name: "
|
|
1817
|
-
override: true,
|
|
1818
|
-
"protected": true,
|
|
1819
|
-
children: __alloy_js_core.code`super.reset();
|
|
1820
|
-
this.currentInput = "";
|
|
1821
|
-
`
|
|
1822
|
-
}),
|
|
1823
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1824
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1825
|
-
doc: "A method to handle keypress events and determine the corresponding action",
|
|
1826
|
-
name: "keypress",
|
|
1857
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
1858
|
+
name: "onKeyPress",
|
|
1827
1859
|
override: true,
|
|
1828
1860
|
"protected": true,
|
|
1829
1861
|
parameters: [{
|
|
@@ -1838,25 +1870,55 @@ function NumericPromptDeclarations() {
|
|
|
1838
1870
|
return (this as any)[action]();
|
|
1839
1871
|
}
|
|
1840
1872
|
|
|
1841
|
-
if (char !== "-" && !(char === "." && this.isFloat) && !/[0-9]/.test(char)) {
|
|
1873
|
+
if ((char !== "-" || (char === "-" && this.cursor !== 0)) && !(char === "." && this.isFloat) && !/[0-9]/.test(char)) {
|
|
1842
1874
|
return this.bell();
|
|
1843
1875
|
}
|
|
1844
1876
|
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1877
|
+
const displayValue = \`\${
|
|
1878
|
+
this.displayValue.slice(0, this.cursor)
|
|
1879
|
+
}\${
|
|
1880
|
+
char
|
|
1881
|
+
}\${
|
|
1882
|
+
this.displayValue.slice(this.cursor)
|
|
1883
|
+
}\`;
|
|
1849
1884
|
|
|
1850
|
-
let value =
|
|
1851
|
-
if (value
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1885
|
+
let value = this.parser(displayValue);
|
|
1886
|
+
if (!Number.isNaN(value)) {
|
|
1887
|
+
|
|
1888
|
+
value = Math.min(value, this.max);
|
|
1889
|
+
if (value > this.max) {
|
|
1890
|
+
value = this.max;
|
|
1891
|
+
}
|
|
1892
|
+
if (value < this.min) {
|
|
1893
|
+
value = this.min;
|
|
1894
|
+
}
|
|
1856
1895
|
}
|
|
1857
1896
|
|
|
1858
1897
|
this.changeValue(value);
|
|
1859
1898
|
this.sync(); `
|
|
1899
|
+
}),
|
|
1900
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1901
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1902
|
+
doc: "A method to handle changes in the prompt value",
|
|
1903
|
+
name: "onChange",
|
|
1904
|
+
override: true,
|
|
1905
|
+
"protected": true,
|
|
1906
|
+
parameters: [{
|
|
1907
|
+
name: "previousValue",
|
|
1908
|
+
type: "TValue"
|
|
1909
|
+
}],
|
|
1910
|
+
children: __alloy_js_core.code`this.#isInvalid = false;
|
|
1911
|
+
this.cursor = this.displayValue.slice(0, this.cursor).length + 1; `
|
|
1912
|
+
}),
|
|
1913
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1914
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1915
|
+
doc: "A method to validate the prompt input",
|
|
1916
|
+
name: "validate",
|
|
1917
|
+
override: true,
|
|
1918
|
+
async: true,
|
|
1919
|
+
"protected": true,
|
|
1920
|
+
children: __alloy_js_core.code`await super.validate(this.value);
|
|
1921
|
+
this.#isInvalid = this.isError; `
|
|
1860
1922
|
}),
|
|
1861
1923
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1862
1924
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
@@ -1901,7 +1963,7 @@ function NumericPromptDeclarations() {
|
|
|
1901
1963
|
doc: "A method to move the cursor to the left",
|
|
1902
1964
|
name: "left",
|
|
1903
1965
|
"protected": true,
|
|
1904
|
-
children: __alloy_js_core.code`if (this.cursor <= 0
|
|
1966
|
+
children: __alloy_js_core.code`if (this.cursor <= 0) {
|
|
1905
1967
|
return this.bell();
|
|
1906
1968
|
}
|
|
1907
1969
|
|
|
@@ -1913,76 +1975,11 @@ function NumericPromptDeclarations() {
|
|
|
1913
1975
|
doc: "A method to move the cursor to the right",
|
|
1914
1976
|
name: "right",
|
|
1915
1977
|
"protected": true,
|
|
1916
|
-
children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length
|
|
1978
|
+
children: __alloy_js_core.code`if (this.cursor >= this.displayValue.length) {
|
|
1917
1979
|
return this.bell();
|
|
1918
1980
|
}
|
|
1919
1981
|
|
|
1920
1982
|
this.moveCursor(1);
|
|
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; `
|
|
1938
|
-
}),
|
|
1939
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1940
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
1941
|
-
doc: "A method to delete the character backward of the cursor",
|
|
1942
|
-
name: "delete",
|
|
1943
|
-
"protected": true,
|
|
1944
|
-
children: __alloy_js_core.code`if (this.isCursorAtStart()) {
|
|
1945
|
-
return this.bell();
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
if (this.displayValue === "") {
|
|
1949
|
-
return this.bell();
|
|
1950
|
-
}
|
|
1951
|
-
|
|
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
1983
|
this.sync(); `
|
|
1987
1984
|
}),
|
|
1988
1985
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
@@ -2003,17 +2000,20 @@ function NumericPromptDeclarations() {
|
|
|
2003
2000
|
}),
|
|
2004
2001
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2005
2002
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2006
|
-
doc: "A method to
|
|
2007
|
-
name: "
|
|
2008
|
-
|
|
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",
|
|
2003
|
+
doc: "A method to render the prompt",
|
|
2004
|
+
name: "onRender",
|
|
2005
|
+
override: true,
|
|
2015
2006
|
"protected": true,
|
|
2016
|
-
|
|
2007
|
+
returnType: "string",
|
|
2008
|
+
children: __alloy_js_core.code`return this.isPlaceholder
|
|
2009
|
+
? colors.text.prompt.input.disabled(this.displayValue)
|
|
2010
|
+
: this.#isInvalid
|
|
2011
|
+
? colors.text.prompt.input.error(this.displayValue)
|
|
2012
|
+
: this.isSubmitted
|
|
2013
|
+
? colors.text.prompt.input.submitted(this.displayValue)
|
|
2014
|
+
: this.isCancelled
|
|
2015
|
+
? colors.text.prompt.input.cancelled(this.displayValue)
|
|
2016
|
+
: colors.bold(colors.text.prompt.input.active(this.displayValue)); `
|
|
2017
2017
|
})
|
|
2018
2018
|
];
|
|
2019
2019
|
}
|
|
@@ -2069,7 +2069,7 @@ run(); ` }),
|
|
|
2069
2069
|
|
|
2070
2070
|
prompt.on("state", state => config.onState?.(state));
|
|
2071
2071
|
prompt.on("submit", value => response(value));
|
|
2072
|
-
prompt.on("cancel", event =>
|
|
2072
|
+
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
2073
2073
|
});`
|
|
2074
2074
|
})
|
|
2075
2075
|
];
|
|
@@ -2183,8 +2183,8 @@ function TogglePromptDeclarations() {
|
|
|
2183
2183
|
}),
|
|
2184
2184
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2185
2185
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2186
|
-
doc: "A method to handle
|
|
2187
|
-
name: "
|
|
2186
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
2187
|
+
name: "onKeyPress",
|
|
2188
2188
|
override: true,
|
|
2189
2189
|
"protected": true,
|
|
2190
2190
|
parameters: [{
|
|
@@ -2257,7 +2257,7 @@ function TogglePromptDeclarations() {
|
|
|
2257
2257
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2258
2258
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2259
2259
|
doc: "A method to render the prompt",
|
|
2260
|
-
name: "
|
|
2260
|
+
name: "onRender",
|
|
2261
2261
|
override: true,
|
|
2262
2262
|
"protected": true,
|
|
2263
2263
|
returnType: "string",
|
|
@@ -2323,7 +2323,7 @@ run(); ` }),
|
|
|
2323
2323
|
|
|
2324
2324
|
prompt.on("state", state => config.onState?.(state));
|
|
2325
2325
|
prompt.on("submit", value => response(value));
|
|
2326
|
-
prompt.on("cancel", event =>
|
|
2326
|
+
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
2327
2327
|
});`
|
|
2328
2328
|
})
|
|
2329
2329
|
];
|
|
@@ -2486,8 +2486,8 @@ function ConfirmPromptDeclarations() {
|
|
|
2486
2486
|
} `,
|
|
2487
2487
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2488
2488
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2489
|
-
doc: "A method to handle
|
|
2490
|
-
name: "
|
|
2489
|
+
doc: "A method to handle key press events and determine the corresponding action",
|
|
2490
|
+
name: "onKeyPress",
|
|
2491
2491
|
override: true,
|
|
2492
2492
|
"protected": true,
|
|
2493
2493
|
parameters: [{
|
|
@@ -2517,7 +2517,7 @@ function ConfirmPromptDeclarations() {
|
|
|
2517
2517
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2518
2518
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_class_declaration.ClassMethod, {
|
|
2519
2519
|
doc: "A method to render the prompt",
|
|
2520
|
-
name: "
|
|
2520
|
+
name: "onRender",
|
|
2521
2521
|
override: true,
|
|
2522
2522
|
"protected": true,
|
|
2523
2523
|
returnType: "string",
|
|
@@ -2579,7 +2579,7 @@ run(); ` }),
|
|
|
2579
2579
|
|
|
2580
2580
|
prompt.on("state", state => config.onState?.(state));
|
|
2581
2581
|
prompt.on("submit", value => response(value));
|
|
2582
|
-
prompt.on("cancel", event =>
|
|
2582
|
+
prompt.on("cancel", event => response(CANCEL_SYMBOL));
|
|
2583
2583
|
}); `
|
|
2584
2584
|
})
|
|
2585
2585
|
];
|
|
@@ -2605,7 +2605,7 @@ function PasswordPromptDeclaration() {
|
|
|
2605
2605
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_type_declaration.TypeDeclaration, {
|
|
2606
2606
|
name: "PasswordConfig",
|
|
2607
2607
|
"export": true,
|
|
2608
|
-
children: __alloy_js_core.code`Omit<TextConfig, "mask" | "
|
|
2608
|
+
children: __alloy_js_core.code`Omit<TextConfig, "mask" | "maskCompleted">; `
|
|
2609
2609
|
}),
|
|
2610
2610
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2611
2611
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
@@ -2649,7 +2649,7 @@ run(); ` }),
|
|
|
2649
2649
|
children: __alloy_js_core.code`return text({
|
|
2650
2650
|
...config,
|
|
2651
2651
|
mask: passwordMask,
|
|
2652
|
-
|
|
2652
|
+
maskCompleted: () => "*******"
|
|
2653
2653
|
});`
|
|
2654
2654
|
})
|
|
2655
2655
|
];
|