mepcli 2.0.0-beta.2 → 2.0.0-beta.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/ansi.d.ts +36 -0
- package/dist/ansi.js +1 -0
- package/dist/base.d.ts +60 -0
- package/dist/base.js +1 -0
- package/dist/{src/core.js → core.d.ts} +175 -345
- package/dist/core.js +1 -0
- package/dist/data/countries.d.ts +2 -0
- package/dist/data/countries.js +1 -0
- package/dist/data/licenses.d.ts +2 -0
- package/dist/data/licenses.js +1 -0
- package/dist/highlight.d.ts +7 -0
- package/dist/highlight.js +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +1 -0
- package/dist/input.d.ts +14 -0
- package/dist/input.js +1 -0
- package/dist/pipeline.d.ts +90 -0
- package/dist/pipeline.js +1 -0
- package/dist/prompts/autocomplete.d.ts +22 -0
- package/dist/prompts/autocomplete.js +1 -0
- package/dist/prompts/box.d.ts +21 -0
- package/dist/prompts/box.js +4 -0
- package/dist/prompts/breadcrumb-search.d.ts +14 -0
- package/dist/prompts/breadcrumb-search.js +2 -0
- package/dist/prompts/breadcrumb.d.ts +32 -0
- package/dist/prompts/breadcrumb.js +3 -0
- package/dist/prompts/byte.d.ts +13 -0
- package/dist/prompts/byte.js +5 -0
- package/dist/prompts/calculator.d.ts +17 -0
- package/dist/prompts/calculator.js +3 -0
- package/dist/prompts/calendar.d.ts +33 -0
- package/dist/prompts/calendar.js +3 -0
- package/dist/prompts/checkbox.d.ts +13 -0
- package/dist/prompts/checkbox.js +2 -0
- package/dist/prompts/code.d.ts +19 -0
- package/dist/prompts/code.js +4 -0
- package/dist/prompts/color.d.ts +14 -0
- package/dist/prompts/color.js +10 -0
- package/dist/prompts/confirm.d.ts +8 -0
- package/dist/prompts/confirm.js +1 -0
- package/dist/prompts/connection-string.d.ts +18 -0
- package/dist/prompts/connection-string.js +1 -0
- package/dist/prompts/cron.d.ts +13 -0
- package/dist/prompts/cron.js +4 -0
- package/dist/prompts/curl-utils.d.ts +25 -0
- package/dist/prompts/curl-utils.js +1 -0
- package/dist/prompts/curl.d.ts +41 -0
- package/dist/prompts/curl.js +12 -0
- package/dist/prompts/data-inspector.d.ts +22 -0
- package/dist/prompts/data-inspector.js +5 -0
- package/dist/prompts/date.d.ts +12 -0
- package/dist/prompts/date.js +2 -0
- package/dist/prompts/dependency.d.ts +16 -0
- package/dist/prompts/dependency.js +3 -0
- package/dist/prompts/dial.d.ts +10 -0
- package/dist/prompts/dial.js +3 -0
- package/dist/prompts/diff.d.ts +10 -0
- package/dist/prompts/diff.js +10 -0
- package/dist/prompts/draw.d.ts +20 -0
- package/dist/prompts/draw.js +6 -0
- package/dist/prompts/editor.d.ts +14 -0
- package/dist/prompts/editor.js +2 -0
- package/dist/prompts/emoji.d.ts +18 -0
- package/dist/prompts/emoji.js +5 -0
- package/dist/prompts/exec.d.ts +17 -0
- package/dist/prompts/exec.js +1 -0
- package/dist/prompts/file.d.ts +21 -0
- package/dist/prompts/file.js +2 -0
- package/dist/prompts/form.d.ts +18 -0
- package/dist/prompts/form.js +1 -0
- package/dist/prompts/fuzzy-multi-column.d.ts +12 -0
- package/dist/prompts/fuzzy-multi-column.js +2 -0
- package/dist/prompts/fuzzy.d.ts +12 -0
- package/dist/prompts/fuzzy.js +2 -0
- package/dist/prompts/gauge.d.ts +21 -0
- package/dist/prompts/gauge.js +4 -0
- package/dist/prompts/grid.d.ts +14 -0
- package/dist/prompts/grid.js +2 -0
- package/dist/prompts/heatmap.d.ts +13 -0
- package/dist/prompts/heatmap.js +2 -0
- package/dist/prompts/ip.d.ts +11 -0
- package/dist/prompts/ip.js +3 -0
- package/dist/prompts/kanban.d.ts +17 -0
- package/dist/prompts/kanban.js +4 -0
- package/dist/prompts/keypress.d.ts +7 -0
- package/dist/prompts/keypress.js +1 -0
- package/dist/prompts/license.d.ts +9 -0
- package/dist/prompts/license.js +13 -0
- package/dist/prompts/list.d.ts +9 -0
- package/dist/prompts/list.js +1 -0
- package/dist/prompts/map.d.ts +17 -0
- package/dist/prompts/map.js +5 -0
- package/dist/prompts/match.d.ts +19 -0
- package/dist/prompts/match.js +7 -0
- package/dist/prompts/miller.d.ts +15 -0
- package/dist/prompts/miller.js +2 -0
- package/dist/prompts/multi-column-select.d.ts +10 -0
- package/dist/prompts/multi-column-select.js +2 -0
- package/dist/prompts/multi-range.d.ts +9 -0
- package/dist/prompts/multi-range.js +3 -0
- package/dist/prompts/multi-select.d.ts +15 -0
- package/dist/prompts/multi-select.js +4 -0
- package/dist/prompts/number.d.ts +11 -0
- package/dist/prompts/number.js +2 -0
- package/dist/prompts/otp.d.ts +10 -0
- package/dist/prompts/otp.js +2 -0
- package/dist/prompts/pattern.d.ts +22 -0
- package/dist/prompts/pattern.js +4 -0
- package/dist/prompts/phone.d.ts +41 -0
- package/dist/prompts/phone.js +3 -0
- package/dist/prompts/quiz-select.d.ts +10 -0
- package/dist/prompts/quiz-select.js +7 -0
- package/dist/prompts/quiz-text.d.ts +11 -0
- package/dist/prompts/quiz-text.js +8 -0
- package/dist/prompts/range.d.ts +9 -0
- package/dist/prompts/range.js +1 -0
- package/dist/prompts/rating.d.ts +8 -0
- package/dist/prompts/rating.js +1 -0
- package/dist/prompts/regex.d.ts +13 -0
- package/dist/prompts/regex.js +5 -0
- package/dist/prompts/region.d.ts +11 -0
- package/dist/prompts/region.js +5 -0
- package/dist/prompts/schedule.d.ts +20 -0
- package/dist/prompts/schedule.js +5 -0
- package/dist/prompts/scroll.d.ts +13 -0
- package/dist/prompts/scroll.js +1 -0
- package/dist/prompts/seat.d.ts +17 -0
- package/dist/prompts/seat.js +5 -0
- package/dist/prompts/select-range.d.ts +8 -0
- package/dist/prompts/select-range.js +3 -0
- package/dist/prompts/select.d.ts +15 -0
- package/dist/prompts/select.js +2 -0
- package/dist/prompts/semver.d.ts +6 -0
- package/dist/prompts/semver.js +1 -0
- package/dist/prompts/shortcut.d.ts +9 -0
- package/dist/prompts/shortcut.js +1 -0
- package/dist/prompts/slider.d.ts +8 -0
- package/dist/prompts/slider.js +1 -0
- package/dist/prompts/slot.d.ts +16 -0
- package/dist/prompts/slot.js +8 -0
- package/dist/prompts/snippet.d.ts +19 -0
- package/dist/prompts/snippet.js +4 -0
- package/dist/prompts/sort-grid.d.ts +16 -0
- package/dist/prompts/sort-grid.js +2 -0
- package/dist/prompts/sort.d.ts +14 -0
- package/dist/prompts/sort.js +2 -0
- package/dist/prompts/spam.d.ts +17 -0
- package/dist/prompts/spam.js +2 -0
- package/dist/prompts/spreadsheet.d.ts +21 -0
- package/dist/prompts/spreadsheet.js +7 -0
- package/dist/prompts/table.d.ts +14 -0
- package/dist/prompts/table.js +3 -0
- package/dist/prompts/text.d.ts +17 -0
- package/dist/prompts/text.js +2 -0
- package/dist/prompts/time.d.ts +12 -0
- package/dist/prompts/time.js +2 -0
- package/dist/prompts/toggle.d.ts +8 -0
- package/dist/prompts/toggle.js +1 -0
- package/dist/prompts/transfer.d.ts +18 -0
- package/dist/prompts/transfer.js +5 -0
- package/dist/prompts/tree-select.d.ts +31 -0
- package/dist/prompts/tree-select.js +3 -0
- package/dist/prompts/tree.d.ts +20 -0
- package/dist/prompts/tree.js +3 -0
- package/dist/prompts/wait.d.ts +18 -0
- package/dist/prompts/wait.js +1 -0
- package/dist/spinner.d.ts +33 -0
- package/dist/spinner.js +3 -0
- package/dist/symbols.d.ts +33 -0
- package/dist/symbols.js +1 -0
- package/dist/tasks.d.ts +57 -0
- package/dist/tasks.js +1 -0
- package/dist/theme.d.ts +2 -0
- package/dist/theme.js +1 -0
- package/dist/types.d.ts +503 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +81 -0
- package/dist/utils.js +1 -0
- package/package.json +8 -9
- package/dist/src/ansi.js +0 -50
- package/dist/src/ansi.js.map +0 -1
- package/dist/src/base.js +0 -258
- package/dist/src/base.js.map +0 -1
- package/dist/src/core.js.map +0 -1
- package/dist/src/data/countries.js +0 -569
- package/dist/src/data/countries.js.map +0 -1
- package/dist/src/data/licenses.js +0 -480
- package/dist/src/data/licenses.js.map +0 -1
- package/dist/src/highlight.js +0 -185
- package/dist/src/highlight.js.map +0 -1
- package/dist/src/index.js +0 -66
- package/dist/src/index.js.map +0 -1
- package/dist/src/input.js +0 -158
- package/dist/src/input.js.map +0 -1
- package/dist/src/pipeline.js +0 -273
- package/dist/src/pipeline.js.map +0 -1
- package/dist/src/prompts/autocomplete.js +0 -171
- package/dist/src/prompts/autocomplete.js.map +0 -1
- package/dist/src/prompts/box.js +0 -225
- package/dist/src/prompts/box.js.map +0 -1
- package/dist/src/prompts/breadcrumb-search.js +0 -260
- package/dist/src/prompts/breadcrumb-search.js.map +0 -1
- package/dist/src/prompts/breadcrumb.js +0 -307
- package/dist/src/prompts/breadcrumb.js.map +0 -1
- package/dist/src/prompts/byte.js +0 -176
- package/dist/src/prompts/byte.js.map +0 -1
- package/dist/src/prompts/calculator.js +0 -243
- package/dist/src/prompts/calculator.js.map +0 -1
- package/dist/src/prompts/calendar.js +0 -430
- package/dist/src/prompts/calendar.js.map +0 -1
- package/dist/src/prompts/checkbox.js +0 -159
- package/dist/src/prompts/checkbox.js.map +0 -1
- package/dist/src/prompts/code.js +0 -271
- package/dist/src/prompts/code.js.map +0 -1
- package/dist/src/prompts/color.js +0 -165
- package/dist/src/prompts/color.js.map +0 -1
- package/dist/src/prompts/confirm.js +0 -55
- package/dist/src/prompts/confirm.js.map +0 -1
- package/dist/src/prompts/connection-string.js +0 -120
- package/dist/src/prompts/connection-string.js.map +0 -1
- package/dist/src/prompts/cron.js +0 -207
- package/dist/src/prompts/cron.js.map +0 -1
- package/dist/src/prompts/curl-utils.js +0 -71
- package/dist/src/prompts/curl-utils.js.map +0 -1
- package/dist/src/prompts/curl.js +0 -431
- package/dist/src/prompts/curl.js.map +0 -1
- package/dist/src/prompts/data-inspector.js +0 -261
- package/dist/src/prompts/data-inspector.js.map +0 -1
- package/dist/src/prompts/date.js +0 -185
- package/dist/src/prompts/date.js.map +0 -1
- package/dist/src/prompts/dependency.js +0 -283
- package/dist/src/prompts/dependency.js.map +0 -1
- package/dist/src/prompts/dial.js +0 -124
- package/dist/src/prompts/dial.js.map +0 -1
- package/dist/src/prompts/diff.js +0 -118
- package/dist/src/prompts/diff.js.map +0 -1
- package/dist/src/prompts/draw.js +0 -191
- package/dist/src/prompts/draw.js.map +0 -1
- package/dist/src/prompts/editor.js +0 -234
- package/dist/src/prompts/editor.js.map +0 -1
- package/dist/src/prompts/emoji.js +0 -226
- package/dist/src/prompts/emoji.js.map +0 -1
- package/dist/src/prompts/exec.js +0 -151
- package/dist/src/prompts/exec.js.map +0 -1
- package/dist/src/prompts/file.js +0 -217
- package/dist/src/prompts/file.js.map +0 -1
- package/dist/src/prompts/form.js +0 -241
- package/dist/src/prompts/form.js.map +0 -1
- package/dist/src/prompts/fuzzy-multi-column.js +0 -161
- package/dist/src/prompts/fuzzy-multi-column.js.map +0 -1
- package/dist/src/prompts/fuzzy.js +0 -147
- package/dist/src/prompts/fuzzy.js.map +0 -1
- package/dist/src/prompts/gauge.js +0 -137
- package/dist/src/prompts/gauge.js.map +0 -1
- package/dist/src/prompts/grid.js +0 -191
- package/dist/src/prompts/grid.js.map +0 -1
- package/dist/src/prompts/heatmap.js +0 -147
- package/dist/src/prompts/heatmap.js.map +0 -1
- package/dist/src/prompts/ip.js +0 -138
- package/dist/src/prompts/ip.js.map +0 -1
- package/dist/src/prompts/kanban.js +0 -233
- package/dist/src/prompts/kanban.js.map +0 -1
- package/dist/src/prompts/keypress.js +0 -54
- package/dist/src/prompts/keypress.js.map +0 -1
- package/dist/src/prompts/license.js +0 -144
- package/dist/src/prompts/license.js.map +0 -1
- package/dist/src/prompts/list.js +0 -124
- package/dist/src/prompts/list.js.map +0 -1
- package/dist/src/prompts/map.js +0 -262
- package/dist/src/prompts/map.js.map +0 -1
- package/dist/src/prompts/match.js +0 -271
- package/dist/src/prompts/match.js.map +0 -1
- package/dist/src/prompts/miller.js +0 -228
- package/dist/src/prompts/miller.js.map +0 -1
- package/dist/src/prompts/multi-column-select.js +0 -176
- package/dist/src/prompts/multi-column-select.js.map +0 -1
- package/dist/src/prompts/multi-range.js +0 -189
- package/dist/src/prompts/multi-range.js.map +0 -1
- package/dist/src/prompts/multi-select.js +0 -183
- package/dist/src/prompts/multi-select.js.map +0 -1
- package/dist/src/prompts/number.js +0 -166
- package/dist/src/prompts/number.js.map +0 -1
- package/dist/src/prompts/otp.js +0 -107
- package/dist/src/prompts/otp.js.map +0 -1
- package/dist/src/prompts/pattern.js +0 -252
- package/dist/src/prompts/pattern.js.map +0 -1
- package/dist/src/prompts/phone.js +0 -398
- package/dist/src/prompts/phone.js.map +0 -1
- package/dist/src/prompts/quiz-select.js +0 -114
- package/dist/src/prompts/quiz-select.js.map +0 -1
- package/dist/src/prompts/quiz-text.js +0 -98
- package/dist/src/prompts/quiz-text.js.map +0 -1
- package/dist/src/prompts/range.js +0 -164
- package/dist/src/prompts/range.js.map +0 -1
- package/dist/src/prompts/rating.js +0 -83
- package/dist/src/prompts/rating.js.map +0 -1
- package/dist/src/prompts/regex.js +0 -145
- package/dist/src/prompts/regex.js.map +0 -1
- package/dist/src/prompts/region.js +0 -170
- package/dist/src/prompts/region.js.map +0 -1
- package/dist/src/prompts/schedule.js +0 -270
- package/dist/src/prompts/schedule.js.map +0 -1
- package/dist/src/prompts/scroll.js +0 -155
- package/dist/src/prompts/scroll.js.map +0 -1
- package/dist/src/prompts/seat.js +0 -164
- package/dist/src/prompts/seat.js.map +0 -1
- package/dist/src/prompts/select-range.js +0 -148
- package/dist/src/prompts/select-range.js.map +0 -1
- package/dist/src/prompts/select.js +0 -163
- package/dist/src/prompts/select.js.map +0 -1
- package/dist/src/prompts/semver.js +0 -43
- package/dist/src/prompts/semver.js.map +0 -1
- package/dist/src/prompts/shortcut.js +0 -133
- package/dist/src/prompts/shortcut.js.map +0 -1
- package/dist/src/prompts/slider.js +0 -69
- package/dist/src/prompts/slider.js.map +0 -1
- package/dist/src/prompts/slot.js +0 -117
- package/dist/src/prompts/slot.js.map +0 -1
- package/dist/src/prompts/snippet.js +0 -228
- package/dist/src/prompts/snippet.js.map +0 -1
- package/dist/src/prompts/sort-grid.js +0 -151
- package/dist/src/prompts/sort-grid.js.map +0 -1
- package/dist/src/prompts/sort.js +0 -166
- package/dist/src/prompts/sort.js.map +0 -1
- package/dist/src/prompts/spam.js +0 -80
- package/dist/src/prompts/spam.js.map +0 -1
- package/dist/src/prompts/spreadsheet.js +0 -240
- package/dist/src/prompts/spreadsheet.js.map +0 -1
- package/dist/src/prompts/table.js +0 -120
- package/dist/src/prompts/table.js.map +0 -1
- package/dist/src/prompts/text.js +0 -317
- package/dist/src/prompts/text.js.map +0 -1
- package/dist/src/prompts/time.js +0 -211
- package/dist/src/prompts/time.js.map +0 -1
- package/dist/src/prompts/toggle.js +0 -53
- package/dist/src/prompts/toggle.js.map +0 -1
- package/dist/src/prompts/transfer.js +0 -207
- package/dist/src/prompts/transfer.js.map +0 -1
- package/dist/src/prompts/tree-select.js +0 -270
- package/dist/src/prompts/tree-select.js.map +0 -1
- package/dist/src/prompts/tree.js +0 -233
- package/dist/src/prompts/tree.js.map +0 -1
- package/dist/src/prompts/wait.js +0 -79
- package/dist/src/prompts/wait.js.map +0 -1
- package/dist/src/spinner.js +0 -105
- package/dist/src/spinner.js.map +0 -1
- package/dist/src/symbols.js +0 -66
- package/dist/src/symbols.js.map +0 -1
- package/dist/src/tasks.js +0 -231
- package/dist/src/tasks.js.map +0 -1
- package/dist/src/theme.js +0 -29
- package/dist/src/theme.js.map +0 -1
- package/dist/src/types.js +0 -8
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils.js +0 -480
- package/dist/src/utils.js.map +0 -1
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "NumberPrompt", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return NumberPrompt;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _ansi = require("../ansi");
|
|
12
|
-
const _base = require("../base");
|
|
13
|
-
const _theme = require("../theme");
|
|
14
|
-
const _symbols = require("../symbols");
|
|
15
|
-
function _define_property(obj, key, value) {
|
|
16
|
-
if (key in obj) {
|
|
17
|
-
Object.defineProperty(obj, key, {
|
|
18
|
-
value: value,
|
|
19
|
-
enumerable: true,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true
|
|
22
|
-
});
|
|
23
|
-
} else {
|
|
24
|
-
obj[key] = value;
|
|
25
|
-
}
|
|
26
|
-
return obj;
|
|
27
|
-
}
|
|
28
|
-
let NumberPrompt = class NumberPrompt extends _base.Prompt {
|
|
29
|
-
render(_firstRender) {
|
|
30
|
-
// Prepare content
|
|
31
|
-
const icon = this.errorMsg ? `${_theme.theme.error}${_symbols.symbols.cross}` : `${_theme.theme.success}?`;
|
|
32
|
-
// Prefix
|
|
33
|
-
let output = `${icon} ${_ansi.ANSI.BOLD}${_theme.theme.title}${this.options.message}${_ansi.ANSI.RESET} `;
|
|
34
|
-
// Value
|
|
35
|
-
output += `${_theme.theme.main}${this.stringValue}${_ansi.ANSI.RESET}`;
|
|
36
|
-
if (this.errorMsg) {
|
|
37
|
-
output += `\n${_theme.theme.error}>> ${this.errorMsg}${_ansi.ANSI.RESET}`;
|
|
38
|
-
}
|
|
39
|
-
this.renderFrame(output);
|
|
40
|
-
this.print(_ansi.ANSI.SHOW_CURSOR);
|
|
41
|
-
// Restore cursor position
|
|
42
|
-
// If errorMsg, we are on the line below the input.
|
|
43
|
-
if (this.errorMsg) {
|
|
44
|
-
this.print(_ansi.ANSI.UP);
|
|
45
|
-
}
|
|
46
|
-
// Calculate visual offset
|
|
47
|
-
const prefix = `${icon} ${_theme.theme.title}${this.options.message} `;
|
|
48
|
-
const prefixLen = this.stripAnsi(prefix).length;
|
|
49
|
-
const targetCol = prefixLen + this.cursor;
|
|
50
|
-
this.print(_ansi.ANSI.CURSOR_LEFT);
|
|
51
|
-
if (targetCol > 0) {
|
|
52
|
-
this.print(`\x1b[${targetCol}C`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
handleInput(char) {
|
|
56
|
-
// Enter
|
|
57
|
-
if (char === '\r' || char === '\n') {
|
|
58
|
-
const num = parseFloat(this.stringValue);
|
|
59
|
-
if (this.stringValue.trim() === '' || isNaN(num)) {
|
|
60
|
-
this.errorMsg = 'Please enter a valid number.';
|
|
61
|
-
this.render(false);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (this.options.min !== undefined && num < this.options.min) {
|
|
65
|
-
this.errorMsg = `Minimum value is ${this.options.min}`;
|
|
66
|
-
this.render(false);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (this.options.max !== undefined && num > this.options.max) {
|
|
70
|
-
this.errorMsg = `Maximum value is ${this.options.max}`;
|
|
71
|
-
this.render(false);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
this.submit(num);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
// Up Arrow (Increment)
|
|
78
|
-
if (this.isUp(char)) {
|
|
79
|
-
let num = parseFloat(this.stringValue) || 0;
|
|
80
|
-
num += this.options.step ?? 1;
|
|
81
|
-
if (this.options.max !== undefined && num > this.options.max) num = this.options.max;
|
|
82
|
-
// Round to avoid float errors
|
|
83
|
-
num = Math.round(num * 10000) / 10000;
|
|
84
|
-
this.stringValue = num.toString();
|
|
85
|
-
this.cursor = this.stringValue.length;
|
|
86
|
-
this.errorMsg = '';
|
|
87
|
-
this.render(false);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
// Down Arrow (Decrement)
|
|
91
|
-
if (this.isDown(char)) {
|
|
92
|
-
let num = parseFloat(this.stringValue) || 0;
|
|
93
|
-
num -= this.options.step ?? 1;
|
|
94
|
-
if (this.options.min !== undefined && num < this.options.min) num = this.options.min;
|
|
95
|
-
// Round to avoid float errors
|
|
96
|
-
num = Math.round(num * 10000) / 10000;
|
|
97
|
-
this.stringValue = num.toString();
|
|
98
|
-
this.cursor = this.stringValue.length;
|
|
99
|
-
this.errorMsg = '';
|
|
100
|
-
this.render(false);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
// Backspace
|
|
104
|
-
if (char === '\u0008' || char === '\x7f') {
|
|
105
|
-
if (this.cursor > 0) {
|
|
106
|
-
this.stringValue = this.stringValue.slice(0, this.cursor - 1) + this.stringValue.slice(this.cursor);
|
|
107
|
-
this.cursor--;
|
|
108
|
-
this.errorMsg = '';
|
|
109
|
-
this.render(false);
|
|
110
|
-
}
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
// Arrow Left
|
|
114
|
-
if (this.isLeft(char)) {
|
|
115
|
-
if (this.cursor > 0) {
|
|
116
|
-
this.cursor--;
|
|
117
|
-
this.render(false);
|
|
118
|
-
}
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
// Arrow Right
|
|
122
|
-
if (this.isRight(char)) {
|
|
123
|
-
if (this.cursor < this.stringValue.length) {
|
|
124
|
-
this.cursor++;
|
|
125
|
-
this.render(false);
|
|
126
|
-
}
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
// Numeric Input (and . and -)
|
|
130
|
-
if (/^[0-9.-]+$/.test(char)) {
|
|
131
|
-
// Allow if it looks like a number part
|
|
132
|
-
this.stringValue = this.stringValue.slice(0, this.cursor) + char + this.stringValue.slice(this.cursor);
|
|
133
|
-
this.cursor += char.length;
|
|
134
|
-
this.errorMsg = '';
|
|
135
|
-
this.render(false);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
handleMouse(event) {
|
|
139
|
-
if (event.action === 'scroll') {
|
|
140
|
-
let num = parseFloat(this.stringValue) || 0;
|
|
141
|
-
const step = this.options.step ?? 1;
|
|
142
|
-
if (event.scroll === 'up') {
|
|
143
|
-
num += step;
|
|
144
|
-
if (this.options.max !== undefined && num > this.options.max) num = this.options.max;
|
|
145
|
-
} else if (event.scroll === 'down') {
|
|
146
|
-
num -= step;
|
|
147
|
-
if (this.options.min !== undefined && num < this.options.min) num = this.options.min;
|
|
148
|
-
}
|
|
149
|
-
// Round to avoid float errors
|
|
150
|
-
num = Math.round(num * 10000) / 10000;
|
|
151
|
-
this.stringValue = num.toString();
|
|
152
|
-
this.cursor = this.stringValue.length;
|
|
153
|
-
this.errorMsg = '';
|
|
154
|
-
this.render(false);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
constructor(options){
|
|
158
|
-
super(options), _define_property(this, "stringValue", ''), _define_property(this, "cursor", 0), _define_property(this, "errorMsg", '');
|
|
159
|
-
// We work with string for editing, but value property stores the parsed number ultimately
|
|
160
|
-
// Initialize stringValue from initial
|
|
161
|
-
this.stringValue = options.initial !== undefined ? options.initial.toString() : '';
|
|
162
|
-
this.cursor = this.stringValue.length;
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
//# sourceMappingURL=number.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prompts/number.ts"],"sourcesContent":["import { ANSI } from '../ansi';\nimport { Prompt } from '../base';\nimport { theme } from '../theme';\nimport { symbols } from '../symbols';\nimport { NumberOptions, MouseEvent } from '../types';\n\n// --- Implementation: Number Prompt ---\nexport class NumberPrompt extends Prompt<number, NumberOptions> {\n private stringValue: string = '';\n private cursor: number = 0;\n private errorMsg: string = '';\n\n constructor(options: NumberOptions) {\n super(options);\n // We work with string for editing, but value property stores the parsed number ultimately\n // Initialize stringValue from initial\n this.stringValue = options.initial !== undefined ? options.initial.toString() : '';\n this.cursor = this.stringValue.length;\n }\n\n protected render(_firstRender: boolean) {\n // Prepare content\n const icon = this.errorMsg ? `${theme.error}${symbols.cross}` : `${theme.success}?`;\n // Prefix\n let output = `${icon} ${ANSI.BOLD}${theme.title}${this.options.message}${ANSI.RESET} `;\n // Value\n output += `${theme.main}${this.stringValue}${ANSI.RESET}`;\n\n if (this.errorMsg) {\n output += `\\n${theme.error}>> ${this.errorMsg}${ANSI.RESET}`;\n }\n\n this.renderFrame(output);\n this.print(ANSI.SHOW_CURSOR);\n\n // Restore cursor position\n // If errorMsg, we are on the line below the input.\n if (this.errorMsg) {\n this.print(ANSI.UP);\n }\n\n // Calculate visual offset\n const prefix = `${icon} ${theme.title}${this.options.message} `;\n const prefixLen = this.stripAnsi(prefix).length;\n const targetCol = prefixLen + this.cursor;\n\n this.print(ANSI.CURSOR_LEFT);\n if (targetCol > 0) {\n this.print(`\\x1b[${targetCol}C`);\n }\n }\n\n protected handleInput(char: string) {\n // Enter\n if (char === '\\r' || char === '\\n') {\n const num = parseFloat(this.stringValue);\n if (this.stringValue.trim() === '' || isNaN(num)) {\n this.errorMsg = 'Please enter a valid number.';\n this.render(false);\n return;\n }\n if (this.options.min !== undefined && num < this.options.min) {\n this.errorMsg = `Minimum value is ${this.options.min}`;\n this.render(false);\n return;\n }\n if (this.options.max !== undefined && num > this.options.max) {\n this.errorMsg = `Maximum value is ${this.options.max}`;\n this.render(false);\n return;\n }\n\n this.submit(num);\n return;\n }\n\n // Up Arrow (Increment)\n if (this.isUp(char)) {\n let num = parseFloat(this.stringValue) || 0;\n num += (this.options.step ?? 1);\n if (this.options.max !== undefined && num > this.options.max) num = this.options.max;\n // Round to avoid float errors\n num = Math.round(num * 10000) / 10000;\n\n this.stringValue = num.toString();\n this.cursor = this.stringValue.length;\n this.errorMsg = '';\n this.render(false);\n return;\n }\n\n // Down Arrow (Decrement)\n if (this.isDown(char)) {\n let num = parseFloat(this.stringValue) || 0;\n num -= (this.options.step ?? 1);\n if (this.options.min !== undefined && num < this.options.min) num = this.options.min;\n // Round to avoid float errors\n num = Math.round(num * 10000) / 10000;\n\n this.stringValue = num.toString();\n this.cursor = this.stringValue.length;\n this.errorMsg = '';\n this.render(false);\n return;\n }\n\n // Backspace\n if (char === '\\u0008' || char === '\\x7f') {\n if (this.cursor > 0) {\n this.stringValue = this.stringValue.slice(0, this.cursor - 1) + this.stringValue.slice(this.cursor);\n this.cursor--;\n this.errorMsg = '';\n this.render(false);\n }\n return;\n }\n\n // Arrow Left\n if (this.isLeft(char)) {\n if (this.cursor > 0) {\n this.cursor--;\n this.render(false);\n }\n return;\n }\n\n // Arrow Right\n if (this.isRight(char)) {\n if (this.cursor < this.stringValue.length) {\n this.cursor++;\n this.render(false);\n }\n return;\n }\n\n // Numeric Input (and . and -)\n if (/^[0-9.-]+$/.test(char)) {\n // Allow if it looks like a number part\n this.stringValue = this.stringValue.slice(0, this.cursor) + char + this.stringValue.slice(this.cursor);\n this.cursor += char.length;\n this.errorMsg = '';\n this.render(false);\n }\n }\n\n protected handleMouse(event: MouseEvent) {\n if (event.action === 'scroll') {\n let num = parseFloat(this.stringValue) || 0;\n const step = this.options.step ?? 1;\n\n if (event.scroll === 'up') {\n num += step;\n if (this.options.max !== undefined && num > this.options.max) num = this.options.max;\n } else if (event.scroll === 'down') {\n num -= step;\n if (this.options.min !== undefined && num < this.options.min) num = this.options.min;\n }\n\n // Round to avoid float errors\n num = Math.round(num * 10000) / 10000;\n\n this.stringValue = num.toString();\n this.cursor = this.stringValue.length;\n this.errorMsg = '';\n this.render(false);\n }\n }\n}\n"],"names":["NumberPrompt","Prompt","render","_firstRender","icon","errorMsg","theme","error","symbols","cross","success","output","ANSI","BOLD","title","options","message","RESET","main","stringValue","renderFrame","print","SHOW_CURSOR","UP","prefix","prefixLen","stripAnsi","length","targetCol","cursor","CURSOR_LEFT","handleInput","char","num","parseFloat","trim","isNaN","min","undefined","max","submit","isUp","step","Math","round","toString","isDown","slice","isLeft","isRight","test","handleMouse","event","action","scroll","initial"],"mappings":";;;;+BAOaA;;;eAAAA;;;sBAPQ;sBACE;uBACD;yBACE;;;;;;;;;;;;;;AAIjB,IAAA,AAAMA,eAAN,MAAMA,qBAAqBC,YAAM;IAa1BC,OAAOC,YAAqB,EAAE;QACpC,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,IAAI,CAAChB,MAAM,GAAG,IAAI,CAACV,WAAW,CAACQ,MAAM;YACrC,IAAI,CAACtB,QAAQ,GAAG;YAChB,IAAI,CAACH,MAAM,CAAC;QAChB;IACJ;IA1JA,YAAYa,OAAsB,CAAE;QAChC,KAAK,CAACA,UALV,uBAAQI,eAAsB,KAC9B,uBAAQU,UAAiB,IACzB,uBAAQxB,YAAmB;QAIvB,0FAA0F;QAC1F,sCAAsC;QACtC,IAAI,CAACc,WAAW,GAAGJ,QAAQwC,OAAO,KAAKjB,YAAYvB,QAAQwC,OAAO,CAACV,QAAQ,KAAK;QAChF,IAAI,CAAChB,MAAM,GAAG,IAAI,CAACV,WAAW,CAACQ,MAAM;IACzC;AAqJJ"}
|
package/dist/src/prompts/otp.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "OTPPrompt", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return OTPPrompt;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _ansi = require("../ansi");
|
|
12
|
-
const _base = require("../base");
|
|
13
|
-
const _theme = require("../theme");
|
|
14
|
-
function _define_property(obj, key, value) {
|
|
15
|
-
if (key in obj) {
|
|
16
|
-
Object.defineProperty(obj, key, {
|
|
17
|
-
value: value,
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
obj[key] = value;
|
|
24
|
-
}
|
|
25
|
-
return obj;
|
|
26
|
-
}
|
|
27
|
-
let OTPPrompt = class OTPPrompt extends _base.Prompt {
|
|
28
|
-
render(_firstRender) {
|
|
29
|
-
const mask = this.options.mask || '_';
|
|
30
|
-
let output = `${_theme.theme.success}?${_ansi.ANSI.RESET} ${_ansi.ANSI.BOLD}${_theme.theme.title}${this.options.message}${_ansi.ANSI.RESET}\n`;
|
|
31
|
-
output += ' '; // Indent
|
|
32
|
-
for(let i = 0; i < this.length; i++){
|
|
33
|
-
const val = this.slots[i];
|
|
34
|
-
let charToDisplay = mask;
|
|
35
|
-
if (val) {
|
|
36
|
-
charToDisplay = this.options.secure ? '*' : val;
|
|
37
|
-
} else {
|
|
38
|
-
// Use placeholder char if available at this index
|
|
39
|
-
if (this.options.placeholder && i < this.options.placeholder.length) {
|
|
40
|
-
charToDisplay = this.options.placeholder[i];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (i === this.cursor) {
|
|
44
|
-
output += `${_ansi.ANSI.REVERSE}${charToDisplay}${_ansi.ANSI.RESET} `;
|
|
45
|
-
} else {
|
|
46
|
-
if (!val) {
|
|
47
|
-
output += `${_theme.theme.muted}${charToDisplay}${_ansi.ANSI.RESET} `;
|
|
48
|
-
} else {
|
|
49
|
-
output += `${_theme.theme.main}${charToDisplay}${_ansi.ANSI.RESET} `;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
this.renderFrame(output);
|
|
54
|
-
}
|
|
55
|
-
handleInput(char) {
|
|
56
|
-
// Digits
|
|
57
|
-
if (/^\d$/.test(char)) {
|
|
58
|
-
this.slots[this.cursor] = char;
|
|
59
|
-
// If we are at the last slot
|
|
60
|
-
if (this.cursor === this.length - 1) {
|
|
61
|
-
// Only submit if all slots are filled
|
|
62
|
-
if (this.slots.every((s)=>s !== '')) {
|
|
63
|
-
this.render(false); // Update view first
|
|
64
|
-
this.submit(this.slots.join(''));
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
this.cursor++;
|
|
69
|
-
this.render(false);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
// Backspace
|
|
73
|
-
if (char === '\u0008' || char === '\x7f') {
|
|
74
|
-
if (this.slots[this.cursor] !== '') {
|
|
75
|
-
this.slots[this.cursor] = '';
|
|
76
|
-
} else if (this.cursor > 0) {
|
|
77
|
-
this.cursor--;
|
|
78
|
-
this.slots[this.cursor] = '';
|
|
79
|
-
}
|
|
80
|
-
this.render(false);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
// Left Arrow
|
|
84
|
-
if (this.isLeft(char)) {
|
|
85
|
-
if (this.cursor > 0) {
|
|
86
|
-
this.cursor--;
|
|
87
|
-
this.render(false);
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
// Right Arrow
|
|
92
|
-
if (this.isRight(char)) {
|
|
93
|
-
if (this.cursor < this.length - 1) {
|
|
94
|
-
this.cursor++;
|
|
95
|
-
this.render(false);
|
|
96
|
-
}
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
constructor(options){
|
|
101
|
-
super(options), _define_property(this, "slots", void 0), _define_property(this, "cursor", 0), _define_property(this, "length", void 0);
|
|
102
|
-
this.length = options.length || 6;
|
|
103
|
-
this.slots = new Array(this.length).fill('');
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
//# sourceMappingURL=otp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prompts/otp.ts"],"sourcesContent":["import { ANSI } from '../ansi';\nimport { Prompt } from '../base';\nimport { theme } from '../theme';\nimport { OTPOptions } from '../types';\n\nexport class OTPPrompt extends Prompt<string, OTPOptions> {\n private slots: string[];\n private cursor: number = 0;\n private readonly length: number;\n\n constructor(options: OTPOptions) {\n super(options);\n this.length = options.length || 6;\n this.slots = new Array(this.length).fill('');\n }\n\n protected render(_firstRender: boolean) {\n const mask = this.options.mask || '_';\n\n let output = `${theme.success}?${ANSI.RESET} ${ANSI.BOLD}${theme.title}${this.options.message}${ANSI.RESET}\\n`;\n output += ' '; // Indent\n\n for (let i = 0; i < this.length; i++) {\n const val = this.slots[i];\n let charToDisplay = mask;\n\n if (val) {\n charToDisplay = this.options.secure ? '*' : val;\n } else {\n // Use placeholder char if available at this index\n if (this.options.placeholder && i < this.options.placeholder.length) {\n charToDisplay = this.options.placeholder[i];\n }\n }\n\n if (i === this.cursor) {\n output += `${ANSI.REVERSE}${charToDisplay}${ANSI.RESET} `;\n } else {\n if (!val) {\n output += `${theme.muted}${charToDisplay}${ANSI.RESET} `;\n } else {\n output += `${theme.main}${charToDisplay}${ANSI.RESET} `;\n }\n }\n }\n\n this.renderFrame(output);\n }\n\n protected handleInput(char: string) {\n // Digits\n if (/^\\d$/.test(char)) {\n this.slots[this.cursor] = char;\n\n // If we are at the last slot\n if (this.cursor === this.length - 1) {\n // Only submit if all slots are filled\n if (this.slots.every(s => s !== '')) {\n this.render(false); // Update view first\n this.submit(this.slots.join(''));\n return;\n }\n }\n\n this.cursor++;\n this.render(false);\n return;\n }\n\n // Backspace\n if (char === '\\u0008' || char === '\\x7f') {\n if (this.slots[this.cursor] !== '') {\n this.slots[this.cursor] = '';\n } else if (this.cursor > 0) {\n this.cursor--;\n this.slots[this.cursor] = '';\n }\n this.render(false);\n return;\n }\n\n // Left Arrow\n if (this.isLeft(char)) {\n if (this.cursor > 0) {\n this.cursor--;\n this.render(false);\n }\n return;\n }\n\n // Right Arrow\n if (this.isRight(char)) {\n if (this.cursor < this.length - 1) {\n this.cursor++;\n this.render(false);\n }\n return;\n }\n }\n}\n"],"names":["OTPPrompt","Prompt","render","_firstRender","mask","options","output","theme","success","ANSI","RESET","BOLD","title","message","i","length","val","slots","charToDisplay","secure","placeholder","cursor","REVERSE","muted","main","renderFrame","handleInput","char","test","every","s","submit","join","isLeft","isRight","Array","fill"],"mappings":";;;;+BAKaA;;;eAAAA;;;sBALQ;sBACE;uBACD;;;;;;;;;;;;;;AAGf,IAAA,AAAMA,YAAN,MAAMA,kBAAkBC,YAAM;IAWvBC,OAAOC,YAAqB,EAAE;QACpC,MAAMC,OAAO,IAAI,CAACC,OAAO,CAACD,IAAI,IAAI;QAElC,IAAIE,SAA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N,UAAjB,KAAA;QAII,IAAI,CAACA,MAAM,GAAGV,QAAQU,MAAM,IAAI;QAChC,IAAI,CAACE,KAAK,GAAG,IAAIkB,MAAM,IAAI,CAACpB,MAAM,EAAEqB,IAAI,CAAC;IAC7C;AAqFJ"}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "PatternPrompt", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return PatternPrompt;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _ansi = require("../ansi");
|
|
12
|
-
const _base = require("../base");
|
|
13
|
-
const _theme = require("../theme");
|
|
14
|
-
function _define_property(obj, key, value) {
|
|
15
|
-
if (key in obj) {
|
|
16
|
-
Object.defineProperty(obj, key, {
|
|
17
|
-
value: value,
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
obj[key] = value;
|
|
24
|
-
}
|
|
25
|
-
return obj;
|
|
26
|
-
}
|
|
27
|
-
let PatternPrompt = class PatternPrompt extends _base.Prompt {
|
|
28
|
-
getIndex(r, c) {
|
|
29
|
-
return r * this.cols + c;
|
|
30
|
-
}
|
|
31
|
-
getPoint(index) {
|
|
32
|
-
return {
|
|
33
|
-
r: Math.floor(index / this.cols),
|
|
34
|
-
c: index % this.cols
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
render(firstRender) {
|
|
38
|
-
let output = '';
|
|
39
|
-
// Title
|
|
40
|
-
const icon = this.errorMsg ? `${_theme.theme.error}✖` : `${_theme.theme.success}?`;
|
|
41
|
-
output += `${icon} ${_ansi.ANSI.BOLD}${_theme.theme.title}${this.options.message}${_ansi.ANSI.RESET}\n`;
|
|
42
|
-
// Instructions
|
|
43
|
-
if (firstRender) {
|
|
44
|
-
output += `${_ansi.ANSI.DIM}(Draw pattern with mouse or use Arrows + Space)${_ansi.ANSI.RESET}\n`;
|
|
45
|
-
}
|
|
46
|
-
// Render Grid
|
|
47
|
-
// Initialize buffer with spaces
|
|
48
|
-
// Adjust height/width slightly to ensure we cover full lines
|
|
49
|
-
const bufferHeight = this.rows * this.nodeSpacingY + 1;
|
|
50
|
-
const bufferWidth = this.cols * this.nodeSpacingX + 1;
|
|
51
|
-
const buffer = Array(bufferHeight).fill(null).map(()=>Array(bufferWidth).fill(' '));
|
|
52
|
-
// Draw connections
|
|
53
|
-
for(let i = 0; i < this.path.length - 1; i++){
|
|
54
|
-
this.drawLine(buffer, this.path[i], this.path[i + 1]);
|
|
55
|
-
}
|
|
56
|
-
// Draw nodes
|
|
57
|
-
for(let r = 0; r < this.rows; r++){
|
|
58
|
-
for(let c = 0; c < this.cols; c++){
|
|
59
|
-
const index = this.getIndex(r, c);
|
|
60
|
-
const isSelected = this.path.includes(index);
|
|
61
|
-
// Calculate buffer position
|
|
62
|
-
const by = r * this.nodeSpacingY;
|
|
63
|
-
const bx = c * this.nodeSpacingX;
|
|
64
|
-
// Mark node in buffer (will be stylized later)
|
|
65
|
-
buffer[by][bx] = isSelected ? '●' : '○';
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// Build string from buffer
|
|
69
|
-
// Limit loop to actual grid dimensions to avoid trailing empty lines
|
|
70
|
-
const displayHeight = (this.rows - 1) * this.nodeSpacingY + 1;
|
|
71
|
-
const displayWidth = (this.cols - 1) * this.nodeSpacingX + 1;
|
|
72
|
-
for(let y = 0; y < displayHeight; y++){
|
|
73
|
-
output += ' '; // Indent
|
|
74
|
-
for(let x = 0; x < displayWidth; x++){
|
|
75
|
-
const char = buffer[y][x];
|
|
76
|
-
// Determine coloring context
|
|
77
|
-
const isNodeRow = y % this.nodeSpacingY === 0;
|
|
78
|
-
const isNodeCol = x % this.nodeSpacingX === 0;
|
|
79
|
-
if (isNodeRow && isNodeCol) {
|
|
80
|
-
const r = y / this.nodeSpacingY;
|
|
81
|
-
const c = x / this.nodeSpacingX;
|
|
82
|
-
const idx = this.getIndex(r, c);
|
|
83
|
-
const isSelected = this.path.includes(idx);
|
|
84
|
-
const isLast = this.path.length > 0 && this.path[this.path.length - 1] === idx;
|
|
85
|
-
const isCursor = this.cursor.r === r && this.cursor.c === c;
|
|
86
|
-
let styledChar = this.nodeChar;
|
|
87
|
-
if (isSelected) styledChar = _theme.theme.main + this.nodeChar + _ansi.ANSI.RESET;
|
|
88
|
-
if (isLast) styledChar = _theme.theme.success + this.nodeChar + _ansi.ANSI.RESET;
|
|
89
|
-
if (isCursor) {
|
|
90
|
-
styledChar = _ansi.ANSI.REVERSE + styledChar + _ansi.ANSI.RESET;
|
|
91
|
-
} else if (!isSelected) {
|
|
92
|
-
styledChar = _theme.theme.muted + '○' + _ansi.ANSI.RESET;
|
|
93
|
-
}
|
|
94
|
-
output += styledChar;
|
|
95
|
-
} else {
|
|
96
|
-
// It's a line or space
|
|
97
|
-
if (char !== ' ' && char !== '○' && char !== '●') {
|
|
98
|
-
output += _theme.theme.main + char + _ansi.ANSI.RESET;
|
|
99
|
-
} else {
|
|
100
|
-
output += ' ';
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
output += '\n';
|
|
105
|
-
}
|
|
106
|
-
if (this.errorMsg) {
|
|
107
|
-
output += `\n${_theme.theme.error}>> ${this.errorMsg}${_ansi.ANSI.RESET}`;
|
|
108
|
-
}
|
|
109
|
-
this.renderFrame(output);
|
|
110
|
-
}
|
|
111
|
-
drawLine(buffer, fromIdx, toIdx) {
|
|
112
|
-
const p1 = this.getPoint(fromIdx);
|
|
113
|
-
const p2 = this.getPoint(toIdx);
|
|
114
|
-
const y1 = p1.r * this.nodeSpacingY;
|
|
115
|
-
const x1 = p1.c * this.nodeSpacingX;
|
|
116
|
-
const y2 = p2.r * this.nodeSpacingY;
|
|
117
|
-
const x2 = p2.c * this.nodeSpacingX;
|
|
118
|
-
const dy = y2 - y1;
|
|
119
|
-
const dx = x2 - x1;
|
|
120
|
-
const steps = Math.max(Math.abs(dx), Math.abs(dy));
|
|
121
|
-
if (steps === 0) return;
|
|
122
|
-
const yInc = dy / steps;
|
|
123
|
-
const xInc = dx / steps;
|
|
124
|
-
let y = y1;
|
|
125
|
-
let x = x1;
|
|
126
|
-
for(let i = 0; i <= steps; i++){
|
|
127
|
-
const ry = Math.round(y);
|
|
128
|
-
const rx = Math.round(x);
|
|
129
|
-
// Check bounds
|
|
130
|
-
if (ry >= 0 && ry < buffer.length && rx >= 0 && rx < buffer[0].length) {
|
|
131
|
-
const isNode = ry % this.nodeSpacingY === 0 && rx % this.nodeSpacingX === 0;
|
|
132
|
-
if (!isNode) {
|
|
133
|
-
// Determine char based on slope
|
|
134
|
-
// Flat horizontal
|
|
135
|
-
if (dy === 0) buffer[ry][rx] = '─';
|
|
136
|
-
else if (dx === 0) buffer[ry][rx] = '│';
|
|
137
|
-
else if (dx > 0 && dy > 0 || dx < 0 && dy < 0) buffer[ry][rx] = '╲';
|
|
138
|
-
else buffer[ry][rx] = '╱';
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
y += yInc;
|
|
142
|
-
x += xInc;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
handleInput(char, _key) {
|
|
146
|
-
// Navigation
|
|
147
|
-
if (this.isUp(char)) {
|
|
148
|
-
this.cursor.r = Math.max(0, this.cursor.r - 1);
|
|
149
|
-
this.render(false);
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (this.isDown(char)) {
|
|
153
|
-
this.cursor.r = Math.min(this.rows - 1, this.cursor.r + 1);
|
|
154
|
-
this.render(false);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (this.isLeft(char)) {
|
|
158
|
-
this.cursor.c = Math.max(0, this.cursor.c - 1);
|
|
159
|
-
this.render(false);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
if (this.isRight(char)) {
|
|
163
|
-
this.cursor.c = Math.min(this.cols - 1, this.cursor.c + 1);
|
|
164
|
-
this.render(false);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
// Selection (Space)
|
|
168
|
-
if (char === ' ') {
|
|
169
|
-
const index = this.getIndex(this.cursor.r, this.cursor.c);
|
|
170
|
-
this.addToPath(index);
|
|
171
|
-
this.render(false);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
// Submit (Enter)
|
|
175
|
-
if (char === '\r' || char === '\n') {
|
|
176
|
-
if (this.path.length < 2) {
|
|
177
|
-
this.errorMsg = 'Pattern too short';
|
|
178
|
-
this.render(false);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
this.submit(this.path);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
// Backspace / Reset
|
|
185
|
-
if (char === '\x7f' || char === '\b') {
|
|
186
|
-
this.path.pop();
|
|
187
|
-
this.render(false);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
addToPath(index) {
|
|
192
|
-
if (this.path.includes(index)) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
this.path.push(index);
|
|
196
|
-
}
|
|
197
|
-
handleMouse(event) {
|
|
198
|
-
if (event.action === 'release') {
|
|
199
|
-
this.isDragging = false;
|
|
200
|
-
this.lastMouse = null;
|
|
201
|
-
if (this.path.length >= 2) {
|
|
202
|
-
this.submit(this.path);
|
|
203
|
-
}
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (this.lastMouse) {
|
|
207
|
-
const dx = event.x - this.lastMouse.x;
|
|
208
|
-
const dy = event.y - this.lastMouse.y;
|
|
209
|
-
// Sensitivity threshold
|
|
210
|
-
if (dx !== 0 || dy !== 0) {
|
|
211
|
-
if (Math.abs(dx) > Math.abs(dy)) {
|
|
212
|
-
if (dx > 0) this.cursor.c = Math.min(this.cols - 1, this.cursor.c + 1);
|
|
213
|
-
else if (dx < 0) this.cursor.c = Math.max(0, this.cursor.c - 1);
|
|
214
|
-
} else {
|
|
215
|
-
if (dy > 0) this.cursor.r = Math.min(this.rows - 1, this.cursor.r + 1);
|
|
216
|
-
else if (dy < 0) this.cursor.r = Math.max(0, this.cursor.r - 1);
|
|
217
|
-
}
|
|
218
|
-
if (this.isDragging) {
|
|
219
|
-
const idx = this.getIndex(this.cursor.r, this.cursor.c);
|
|
220
|
-
this.addToPath(idx);
|
|
221
|
-
}
|
|
222
|
-
this.render(false);
|
|
223
|
-
}
|
|
224
|
-
} else {
|
|
225
|
-
// Mouse Down
|
|
226
|
-
if (event.action === 'press' && event.button === 0) {
|
|
227
|
-
this.isDragging = true;
|
|
228
|
-
this.path = []; // Reset
|
|
229
|
-
const idx = this.getIndex(this.cursor.r, this.cursor.c);
|
|
230
|
-
this.addToPath(idx);
|
|
231
|
-
this.render(false);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
this.lastMouse = {
|
|
235
|
-
x: event.x,
|
|
236
|
-
y: event.y
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
constructor(options){
|
|
240
|
-
super(options), _define_property(this, "path", []), _define_property(this, "cursor", {
|
|
241
|
-
r: 0,
|
|
242
|
-
c: 0
|
|
243
|
-
}), _define_property(this, "isDragging", false), _define_property(this, "errorMsg", ''), // Grid configuration
|
|
244
|
-
_define_property(this, "rows", void 0), _define_property(this, "cols", void 0), _define_property(this, "nodeChar", void 0), // Layout
|
|
245
|
-
_define_property(this, "nodeSpacingX", 4), _define_property(this, "nodeSpacingY", 2), _define_property(this, "lastMouse", null);
|
|
246
|
-
this.rows = options.rows || 3;
|
|
247
|
-
this.cols = options.cols || 3;
|
|
248
|
-
this.nodeChar = options.nodeChar || '●';
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
//# sourceMappingURL=pattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prompts/pattern.ts"],"sourcesContent":["import { ANSI } from '../ansi';\nimport { Prompt } from '../base';\nimport { theme } from '../theme';\nimport { PatternOptions, MouseEvent } from '../types';\n\ninterface Point {\n r: number;\n c: number;\n}\n\nexport class PatternPrompt extends Prompt<number[], PatternOptions> {\n private path: number[] = [];\n private cursor: Point = { r: 0, c: 0 };\n private isDragging: boolean = false;\n private errorMsg: string = '';\n\n // Grid configuration\n private rows: number;\n private cols: number;\n private nodeChar: string;\n\n // Layout\n private nodeSpacingX: number = 4;\n private nodeSpacingY: number = 2;\n\n private lastMouse: { x: number, y: number } | null = null;\n\n constructor(options: PatternOptions) {\n super(options);\n this.rows = options.rows || 3;\n this.cols = options.cols || 3;\n this.nodeChar = options.nodeChar || '●';\n }\n\n private getIndex(r: number, c: number): number {\n return r * this.cols + c;\n }\n\n private getPoint(index: number): Point {\n return {\n r: Math.floor(index / this.cols),\n c: index % this.cols\n };\n }\n\n protected render(firstRender: boolean) {\n let output = '';\n\n // Title\n const icon = this.errorMsg ? `${theme.error}✖` : `${theme.success}?`;\n output += `${icon} ${ANSI.BOLD}${theme.title}${this.options.message}${ANSI.RESET}\\n`;\n\n // Instructions\n if (firstRender) {\n output += `${ANSI.DIM}(Draw pattern with mouse or use Arrows + Space)${ANSI.RESET}\\n`;\n }\n\n // Render Grid\n // Initialize buffer with spaces\n // Adjust height/width slightly to ensure we cover full lines\n const bufferHeight = this.rows * this.nodeSpacingY + 1;\n const bufferWidth = this.cols * this.nodeSpacingX + 1;\n const buffer: string[][] = Array(bufferHeight).fill(null).map(() => Array(bufferWidth).fill(' '));\n\n // Draw connections\n for (let i = 0; i < this.path.length - 1; i++) {\n this.drawLine(buffer, this.path[i], this.path[i + 1]);\n }\n\n // Draw nodes\n for (let r = 0; r < this.rows; r++) {\n for (let c = 0; c < this.cols; c++) {\n const index = this.getIndex(r, c);\n const isSelected = this.path.includes(index);\n\n // Calculate buffer position\n const by = r * this.nodeSpacingY;\n const bx = c * this.nodeSpacingX;\n\n // Mark node in buffer (will be stylized later)\n buffer[by][bx] = isSelected ? '●' : '○';\n }\n }\n\n // Build string from buffer\n // Limit loop to actual grid dimensions to avoid trailing empty lines\n const displayHeight = (this.rows - 1) * this.nodeSpacingY + 1;\n const displayWidth = (this.cols - 1) * this.nodeSpacingX + 1;\n\n for (let y = 0; y < displayHeight; y++) {\n output += ' '; // Indent\n for (let x = 0; x < displayWidth; x++) {\n const char = buffer[y][x];\n\n // Determine coloring context\n const isNodeRow = y % this.nodeSpacingY === 0;\n const isNodeCol = x % this.nodeSpacingX === 0;\n\n if (isNodeRow && isNodeCol) {\n const r = y / this.nodeSpacingY;\n const c = x / this.nodeSpacingX;\n const idx = this.getIndex(r, c);\n\n const isSelected = this.path.includes(idx);\n const isLast = this.path.length > 0 && this.path[this.path.length - 1] === idx;\n const isCursor = this.cursor.r === r && this.cursor.c === c;\n\n let styledChar = this.nodeChar;\n if (isSelected) styledChar = theme.main + this.nodeChar + ANSI.RESET;\n if (isLast) styledChar = theme.success + this.nodeChar + ANSI.RESET;\n\n if (isCursor) {\n styledChar = ANSI.REVERSE + styledChar + ANSI.RESET;\n } else if (!isSelected) {\n styledChar = theme.muted + '○' + ANSI.RESET;\n }\n output += styledChar;\n } else {\n // It's a line or space\n if (char !== ' ' && char !== '○' && char !== '●') {\n output += theme.main + char + ANSI.RESET;\n } else {\n output += ' ';\n }\n }\n }\n output += '\\n';\n }\n\n if (this.errorMsg) {\n output += `\\n${theme.error}>> ${this.errorMsg}${ANSI.RESET}`;\n }\n\n this.renderFrame(output);\n }\n\n private drawLine(buffer: string[][], fromIdx: number, toIdx: number) {\n const p1 = this.getPoint(fromIdx);\n const p2 = this.getPoint(toIdx);\n\n const y1 = p1.r * this.nodeSpacingY;\n const x1 = p1.c * this.nodeSpacingX;\n const y2 = p2.r * this.nodeSpacingY;\n const x2 = p2.c * this.nodeSpacingX;\n\n const dy = y2 - y1;\n const dx = x2 - x1;\n\n const steps = Math.max(Math.abs(dx), Math.abs(dy));\n if (steps === 0) return;\n\n const yInc = dy / steps;\n const xInc = dx / steps;\n\n let y = y1;\n let x = x1;\n\n for (let i = 0; i <= steps; i++) {\n const ry = Math.round(y);\n const rx = Math.round(x);\n\n // Check bounds\n if (ry >= 0 && ry < buffer.length && rx >= 0 && rx < buffer[0].length) {\n const isNode = (ry % this.nodeSpacingY === 0) && (rx % this.nodeSpacingX === 0);\n\n if (!isNode) {\n // Determine char based on slope\n // Flat horizontal\n if (dy === 0) buffer[ry][rx] = '─';\n // Flat vertical\n else if (dx === 0) buffer[ry][rx] = '│';\n // Diagonal\n else if ((dx > 0 && dy > 0) || (dx < 0 && dy < 0)) buffer[ry][rx] = '╲';\n else buffer[ry][rx] = '╱';\n }\n }\n\n y += yInc;\n x += xInc;\n }\n }\n\n protected handleInput(char: string, _key: Buffer) {\n // Navigation\n if (this.isUp(char)) {\n this.cursor.r = Math.max(0, this.cursor.r - 1);\n this.render(false);\n return;\n }\n if (this.isDown(char)) {\n this.cursor.r = Math.min(this.rows - 1, this.cursor.r + 1);\n this.render(false);\n return;\n }\n if (this.isLeft(char)) {\n this.cursor.c = Math.max(0, this.cursor.c - 1);\n this.render(false);\n return;\n }\n if (this.isRight(char)) {\n this.cursor.c = Math.min(this.cols - 1, this.cursor.c + 1);\n this.render(false);\n return;\n }\n\n // Selection (Space)\n if (char === ' ') {\n const index = this.getIndex(this.cursor.r, this.cursor.c);\n this.addToPath(index);\n this.render(false);\n return;\n }\n\n // Submit (Enter)\n if (char === '\\r' || char === '\\n') {\n if (this.path.length < 2) {\n this.errorMsg = 'Pattern too short';\n this.render(false);\n return;\n }\n this.submit(this.path);\n return;\n }\n\n // Backspace / Reset\n if (char === '\\x7f' || char === '\\b') {\n this.path.pop();\n this.render(false);\n return;\n }\n }\n\n private addToPath(index: number) {\n if (this.path.includes(index)) {\n return;\n }\n this.path.push(index);\n }\n\n protected handleMouse(event: MouseEvent) {\n if (event.action === 'release') {\n this.isDragging = false;\n this.lastMouse = null;\n if (this.path.length >= 2) {\n this.submit(this.path);\n }\n return;\n }\n\n if (this.lastMouse) {\n const dx = event.x - this.lastMouse.x;\n const dy = event.y - this.lastMouse.y;\n\n // Sensitivity threshold\n if (dx !== 0 || dy !== 0) {\n if (Math.abs(dx) > Math.abs(dy)) {\n if (dx > 0) this.cursor.c = Math.min(this.cols - 1, this.cursor.c + 1);\n else if (dx < 0) this.cursor.c = Math.max(0, this.cursor.c - 1);\n } else {\n if (dy > 0) this.cursor.r = Math.min(this.rows - 1, this.cursor.r + 1);\n else if (dy < 0) this.cursor.r = Math.max(0, this.cursor.r - 1);\n }\n\n if (this.isDragging) {\n const idx = this.getIndex(this.cursor.r, this.cursor.c);\n this.addToPath(idx);\n }\n\n this.render(false);\n }\n } else {\n // Mouse Down\n if (event.action === 'press' && event.button === 0) {\n this.isDragging = true;\n this.path = []; // Reset\n const idx = this.getIndex(this.cursor.r, this.cursor.c);\n this.addToPath(idx);\n this.render(false);\n }\n }\n\n this.lastMouse = { x: event.x, y: event.y };\n }\n}\n"],"names":["PatternPrompt","Prompt","getIndex","r","c","cols","getPoint","index","Math","floor","render","firstRender","output","icon","errorMsg","theme","error","success","ANSI","BOLD","title","options","message","RESET","DIM","bufferHeight","rows","nodeSpacingY","bufferWidth","nodeSpacingX","buffer","Array","fill","map","i","path","length","drawLine","isSelected","includes","by","bx","displayHeight","displayWidth","y","x","char","isNodeRow","isNodeCol","idx","isLast","isCursor","cursor","styledChar","nodeChar","main","REVERSE","muted","renderFrame","fromIdx","toIdx","p1","p2","y1","x1","y2","x2","dy","dx","steps","max","abs","yInc","xInc","ry","round","rx","isNode","handleInput","_key","isUp","isDown","min","isLeft","isRight","addToPath","submit","pop","push","handleMouse","event","action","isDragging","lastMouse","button"],"mappings":";;;;+BAUaA;;;eAAAA;;;sBAVQ;sBACE;uBACD;;;;;;;;;;;;;;AAQf,IAAA,AAAMA,gBAAN,MAAMA,sBAAsBC,YAAM;IAwB7BC,SAASC,CAAS,EAAEC,CA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