mepcli 0.5.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +173 -6
  2. package/dist/ansi.d.ts +1 -0
  3. package/dist/ansi.js +1 -0
  4. package/dist/base.d.ts +1 -1
  5. package/dist/base.js +1 -10
  6. package/dist/core.d.ts +23 -1
  7. package/dist/core.js +60 -0
  8. package/dist/highlight.d.ts +1 -0
  9. package/dist/highlight.js +40 -0
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/input.js +26 -14
  13. package/dist/prompts/autocomplete.d.ts +1 -1
  14. package/dist/prompts/autocomplete.js +2 -7
  15. package/dist/prompts/calendar.d.ts +20 -0
  16. package/dist/prompts/calendar.js +329 -0
  17. package/dist/prompts/checkbox.d.ts +1 -1
  18. package/dist/prompts/checkbox.js +38 -8
  19. package/dist/prompts/code.d.ts +17 -0
  20. package/dist/prompts/code.js +210 -0
  21. package/dist/prompts/color.d.ts +14 -0
  22. package/dist/prompts/color.js +147 -0
  23. package/dist/prompts/confirm.d.ts +1 -1
  24. package/dist/prompts/confirm.js +1 -1
  25. package/dist/prompts/cron.d.ts +13 -0
  26. package/dist/prompts/cron.js +176 -0
  27. package/dist/prompts/date.d.ts +1 -1
  28. package/dist/prompts/date.js +15 -5
  29. package/dist/prompts/editor.js +2 -2
  30. package/dist/prompts/file.d.ts +7 -0
  31. package/dist/prompts/file.js +56 -60
  32. package/dist/prompts/form.d.ts +17 -0
  33. package/dist/prompts/form.js +225 -0
  34. package/dist/prompts/grid.d.ts +14 -0
  35. package/dist/prompts/grid.js +178 -0
  36. package/dist/prompts/keypress.d.ts +2 -2
  37. package/dist/prompts/keypress.js +2 -2
  38. package/dist/prompts/list.d.ts +1 -1
  39. package/dist/prompts/list.js +42 -22
  40. package/dist/prompts/multi-select.d.ts +1 -1
  41. package/dist/prompts/multi-select.js +39 -4
  42. package/dist/prompts/number.d.ts +1 -1
  43. package/dist/prompts/number.js +2 -2
  44. package/dist/prompts/range.d.ts +9 -0
  45. package/dist/prompts/range.js +140 -0
  46. package/dist/prompts/rating.d.ts +1 -1
  47. package/dist/prompts/rating.js +1 -1
  48. package/dist/prompts/select.d.ts +1 -1
  49. package/dist/prompts/select.js +1 -1
  50. package/dist/prompts/slider.d.ts +1 -1
  51. package/dist/prompts/slider.js +1 -1
  52. package/dist/prompts/snippet.d.ts +18 -0
  53. package/dist/prompts/snippet.js +203 -0
  54. package/dist/prompts/sort.d.ts +1 -1
  55. package/dist/prompts/sort.js +1 -4
  56. package/dist/prompts/spam.d.ts +17 -0
  57. package/dist/prompts/spam.js +62 -0
  58. package/dist/prompts/table.d.ts +1 -1
  59. package/dist/prompts/table.js +1 -1
  60. package/dist/prompts/text.d.ts +1 -0
  61. package/dist/prompts/text.js +13 -31
  62. package/dist/prompts/toggle.d.ts +1 -1
  63. package/dist/prompts/toggle.js +1 -1
  64. package/dist/prompts/transfer.d.ts +18 -0
  65. package/dist/prompts/transfer.js +203 -0
  66. package/dist/prompts/tree-select.d.ts +32 -0
  67. package/dist/prompts/tree-select.js +277 -0
  68. package/dist/prompts/tree.d.ts +3 -3
  69. package/dist/prompts/tree.js +27 -19
  70. package/dist/prompts/wait.d.ts +18 -0
  71. package/dist/prompts/wait.js +62 -0
  72. package/dist/types.d.ts +84 -0
  73. package/dist/utils.js +1 -1
  74. package/example.ts +150 -15
  75. package/package.json +2 -2
package/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # Mep
2
2
 
3
- **Mep** is a minimalist and zero-dependency library for creating interactive command-line prompts in Node.js. It focuses on simplicity, modern design, and robust input handling, including support for cursor movement and input validation.
3
+ **Mep** is a lightweight and zero-dependency library for creating interactive command-line prompts in Node.js. It focuses on simplicity, modern design, and robust input handling, including support for cursor movement and input validation.
4
+
5
+ A **CodeTease** project.
4
6
 
5
7
  ## Features
6
8
 
7
9
  - **Zero Dependency:** Keeps your project clean and fast.
8
- - **Comprehensive Prompts:** Includes `text`, `password`, `select`, `checkbox`, `confirm`, `number`, `toggle`, `list`, `slider`, `date`, `file`, `multiSelect`, `autocomplete`, `sort`, `table`, `rating`, `editor`, `tree`, and `keypress`.
9
- - **Mouse Support:** Built-in support for mouse interaction (SGR 1006 protocol). Scroll to navigate lists or change values; click to select.
10
+ - **Comprehensive Prompts:** Includes `text`, `password`, `secret`, `select`, `checkbox`, `confirm`, `number`, `toggle`, `list`, `slider`, `range`, `date`, `file`, `multiSelect`, `autocomplete`, `sort`, `transfer`, `cron`, `table`, `rating`, `editor`, `tree`, `keypress`, `color`, `grid`, and `calendar`.
11
+ - **Mouse Support:** Built-in support for mouse interaction (SGR 1006 protocol). Scroll to navigate lists or change values.
10
12
  - **Responsive Input:** Supports cursor movement (Left/Right) and character insertion/deletion in text-based prompts.
11
13
  - **Validation:** Built-in support for input validation (sync and async) with custom error messages.
12
14
  - **Elegant Look:** Uses ANSI colors for a clean, modern CLI experience.
@@ -104,13 +106,79 @@ async function main() {
104
106
  ]
105
107
  });
106
108
 
109
+ // Color (RGB Picker)
110
+ const color = await MepCLI.color({
111
+ message: "Choose theme color:",
112
+ initial: "#3B82F6"
113
+ });
114
+
115
+ // Grid (Matrix Selection)
116
+ const permissions = await MepCLI.grid({
117
+ message: "Manage Permissions:",
118
+ rows: ["Admin", "User", "Guest"],
119
+ columns: ["Read", "Write", "Delete"]
120
+ });
121
+
122
+ // Calendar (Date/Range Picker)
123
+ const booking = await MepCLI.calendar({
124
+ message: "Select dates:",
125
+ mode: "range"
126
+ });
127
+
107
128
  // Editor (External text editor)
108
129
  const bio = await MepCLI.editor({
109
130
  message: "Write your biography:",
110
131
  extension: ".md"
111
132
  });
112
133
 
113
- console.log({ name, age, newsletter, lang, tools, stars, city, priorities, user, bio });
134
+ // Form (Multi-field input)
135
+ const userDetails = await MepCLI.form({
136
+ message: "User Details:",
137
+ fields: [
138
+ { name: "firstname", message: "First Name", initial: "John" },
139
+ { name: "lastname", message: "Last Name", validate: (v) => v.length > 0 ? true : "Required" },
140
+ { name: "email", message: "Email", validate: (v) => v.includes("@") || "Invalid email" }
141
+ ]
142
+ });
143
+
144
+ // Snippet (Template filling)
145
+ const commitMsg = await MepCLI.snippet({
146
+ message: "Commit Message:",
147
+ template: "feat(${scope}): ${message}",
148
+ values: {
149
+ scope: "core"
150
+ }
151
+ });
152
+
153
+ // Code Prompt (JSON/YAML Editing)
154
+ const config = await MepCLI.code({
155
+ message: "Configure Server:",
156
+ language: "json",
157
+ template: `
158
+ {
159
+ "host": "\${host}",
160
+ "port": \${port},
161
+ "debug": \${debug}
162
+ }
163
+ `
164
+ });
165
+
166
+ // Tree Select (Hierarchical Multi-Select)
167
+ const selectedFiles = await MepCLI.treeSelect({
168
+ message: "Select files to backup:",
169
+ data: [
170
+ {
171
+ title: "src",
172
+ value: "src",
173
+ children: [
174
+ { title: "index.ts", value: "src/index.ts" },
175
+ { title: "utils.ts", value: "src/utils.ts" }
176
+ ]
177
+ }
178
+ ]
179
+ });
180
+
181
+ console.log({ name, age, newsletter, lang, tools, stars, city, priorities, user, color, permissions, booking, bio, userDetails, commitMsg, config, selectedFiles });
114
182
  }
115
183
 
116
184
  main();
@@ -122,6 +190,7 @@ main();
122
190
 
123
191
  * `text(options)` - Single line or multiline text input.
124
192
  * `password(options)` - Masked text input.
193
+ * `secret(options)` - Completely hidden text input.
125
194
  * `number(options)` - Numeric input with increment/decrement support.
126
195
  * `confirm(options)` - Yes/No question.
127
196
  * `toggle(options)` - On/Off switch.
@@ -130,15 +199,27 @@ main();
130
199
  * `checkbox(options)` - Classic checkbox selection.
131
200
  * `list(options)` - Enter a list of tags/strings.
132
201
  * `slider(options)` - Select a number within a range using a visual slider.
202
+ * `range(options)` - Select a numerical range (min/max) using a dual-handle slider.
133
203
  * `rating(options)` - Star rating input.
134
204
  * `date(options)` - Date and time picker.
205
+ * `color(options)` - RGB color picker with hex output and TrueColor preview.
206
+ * `grid(options)` - 2D matrix selection (rows x columns).
207
+ * `calendar(options)` - Interactive monthly calendar for single dates or ranges.
135
208
  * `file(options)` - File system navigator and selector.
136
209
  * `autocomplete(options)` - Searchable selection with async suggestions.
137
210
  * `sort(options)` - Reorder a list of items.
211
+ * `transfer(options)` - Move items between two lists (Source/Target).
212
+ * `cron(options)` - Visually build a cron schedule (Minute, Hour, Day, Month, Weekday).
138
213
  * `table(options)` - Display data in columns and select rows.
139
214
  * `tree(options)` - Navigate and select from a hierarchical tree structure.
140
215
  * `keypress(options)` - Wait for a specific key press or any key.
141
216
  * `editor(options)` - Launch an external editor (Vim, Nano, Notepad, etc.) to capture multi-line content.
217
+ * `form(options)` - Multi-field input form with navigation.
218
+ * `snippet(options)` - Template string filling with variable navigation.
219
+ * `code(options)` - Edit variables within a code block (JSON/YAML). Syntax highlighting is supported (Experimental).
220
+ * `treeSelect(options)` - Hierarchical multi-selection with cascading checkboxes.
221
+ * `spam(options)` - Confirm a dangerous action or fun.
222
+ * `wait(options)` - Wait for a specified number of seconds.
142
223
  * `spinner(message)` - Returns a `Spinner` instance for manual control (`start`, `stop`, `update`, `success`, `error`).
143
224
 
144
225
  ## Mouse Support
@@ -146,14 +227,100 @@ main();
146
227
  MepCLI automatically detects modern terminals and enables **Mouse Tracking** (using SGR 1006 protocol).
147
228
 
148
229
  * **Scrolling:**
149
- * `select`, `multiSelect`, `checkbox`, `autocomplete`, `table`, `tree`: Scroll to navigate the list.
150
- * `number`, `slider`, `rating`, `date`: Scroll to increment/decrement values or fields.
230
+ * `select`, `multiSelect`, `checkbox`, `autocomplete`, `table`, `tree`, `transfer`: Scroll to navigate the list.
231
+ * `form`, `snippet`, `cron`: Scroll to navigate between fields or values.
232
+ * `number`, `slider`, `range`, `rating`, `date`: Scroll to increment/decrement values or fields.
151
233
  * `sort`: Scroll to navigate or reorder items (when grabbed).
152
234
  * `toggle`, `confirm`: Scroll to toggle the state.
235
+ * `calendar`: Scroll to switch months.
236
+ * `color`: Scroll to adjust RGB channels.
237
+ * `grid`: Scroll to move selection.
153
238
  * **Configuration:**
154
239
  * Mouse support is enabled by default if the terminal supports it.
155
240
  * You can explicitly disable it per prompt by setting `mouse: false` in the options.
156
241
 
242
+ ## Advanced Shortcuts
243
+
244
+ ### Calendar Prompt
245
+
246
+ Mep's Calendar prompt supports advanced navigation and selection shortcuts for power users.
247
+
248
+ * **Keyboard:**
249
+ * `Arrow Keys`: Move cursor day by day.
250
+ * `PageUp` / `PageDown`: Jump to previous/next **Month**.
251
+ * `Ctrl + Up` / `Ctrl + Down`: Jump to previous/next **Year**.
252
+ * `Home` / `End`: Jump to the first/last day of the current month.
253
+ * `t`: Jump immediately to **Today**.
254
+ * `Enter`: Select date (or start/end of range).
255
+
256
+ * **Mouse:**
257
+ * `Scroll`: Navigate **Months**.
258
+ * `Ctrl + Scroll`: Adjust the selected **Day** (cursor movement).
259
+
260
+ ### Color Prompt
261
+
262
+ * **Keyboard:**
263
+ * `Tab`: Switch between RGB channels.
264
+ * `Up` / `Down`: Move between channels.
265
+ * `Left` / `Right`: Adjust current channel value.
266
+ * `Shift + Left` / `Shift + Right`: Fast adjust current channel value.
267
+
268
+ * **Mouse:**
269
+ * `Scroll`: Adjust the current channel value.
270
+ * `Ctrl + Scroll`: Fast adjust.
271
+
272
+ ### Checkbox Prompt
273
+
274
+ * **Keyboard:**
275
+ * `Space`: Toggle selection.
276
+ * `a`: Select **All**.
277
+ * `x` / `n`: Select **None**.
278
+ * `i`: **Invert** selection.
279
+
280
+ ### MultiSelect Prompt
281
+
282
+ * **Keyboard:**
283
+ * `Space`: Toggle selection.
284
+ * `Ctrl + A`: Select **All** (Visible).
285
+ * `Ctrl + X`: Deselect **All** (Visible).
286
+ * `Typing`: Filter list.
287
+
288
+ ### Transfer Prompt
289
+
290
+ * **Keyboard:**
291
+ * `Tab` / `Left` / `Right`: Switch focus between Source and Target.
292
+ * `Space`: Move selected item.
293
+ * `a` / `>`: Move **All** to Target.
294
+ * `r` / `<`: Move **All** to Source (Reset).
295
+
296
+ ### Tree & TreeSelect Prompt
297
+
298
+ * **Keyboard:**
299
+ * `Right`: Expand folder or jump to child.
300
+ * `Left`: Collapse folder or jump to parent.
301
+ * `Space`: Toggle expansion (Tree) or Checkbox (TreeSelect).
302
+ * `e`: **Expand** all recursively.
303
+ * `c`: **Collapse** all recursively.
304
+
305
+ ### Grid Prompt
306
+
307
+ The Grid prompt (Matrix selection) includes robust shortcuts for bulk actions.
308
+
309
+ * **Keyboard:**
310
+ * `Arrow Keys`: Move cursor.
311
+ * `PageUp` / `PageDown`: Jump to the first/last **Row**.
312
+ * `Home` / `End`: Jump to the first/last **Column**.
313
+ * `Space`: Toggle current cell.
314
+ * `r`: Toggle entire **Row**.
315
+ * `c`: Toggle entire **Column**.
316
+ * `a`: Select **All**.
317
+ * `x`: Deselect **All** (None).
318
+ * `i`: **Invert** selection.
319
+
320
+ * **Mouse:**
321
+ * `Scroll`: Vertical navigation (Rows).
322
+ * `Shift + Scroll`: Horizontal navigation (Columns).
323
+
157
324
  ## License
158
325
 
159
326
  This project is under the **MIT License**.
package/dist/ansi.d.ts CHANGED
@@ -8,6 +8,7 @@ export declare const ANSI: {
8
8
  DIM: string;
9
9
  ITALIC: string;
10
10
  UNDERLINE: string;
11
+ REVERSE: string;
11
12
  FG_GREEN: string;
12
13
  FG_CYAN: string;
13
14
  FG_YELLOW: string;
package/dist/ansi.js CHANGED
@@ -11,6 +11,7 @@ exports.ANSI = {
11
11
  DIM: '\x1b[2m',
12
12
  ITALIC: '\x1b[3m',
13
13
  UNDERLINE: '\x1b[4m',
14
+ REVERSE: '\x1b[7m',
14
15
  // Colors
15
16
  FG_GREEN: '\x1b[32m',
16
17
  FG_CYAN: '\x1b[36m',
package/dist/base.d.ts CHANGED
@@ -34,7 +34,7 @@ export declare abstract class Prompt<T, O> {
34
34
  * Optional method to handle mouse events.
35
35
  * Subclasses can override this to implement mouse interaction.
36
36
  */
37
- protected handleMouse(event: MouseEvent): void;
37
+ protected handleMouse(_event: MouseEvent): void;
38
38
  protected print(text: string): void;
39
39
  /**
40
40
  * Starts the prompt interaction.
package/dist/base.js CHANGED
@@ -24,7 +24,7 @@ class Prompt {
24
24
  * Optional method to handle mouse events.
25
25
  * Subclasses can override this to implement mouse interaction.
26
26
  */
27
- handleMouse(event) { }
27
+ handleMouse(_event) { }
28
28
  print(text) {
29
29
  this.stdout.write(text);
30
30
  }
@@ -88,7 +88,6 @@ class Prompt {
88
88
  if (this._onKeyHandler) {
89
89
  this._inputParser.removeListener('keypress', this._onKeyHandler);
90
90
  }
91
- // Cleanup mouse listener - though InputParser is instance specific, so it's fine.
92
91
  // Disable Mouse Tracking
93
92
  this.print(ansi_1.ANSI.DISABLE_MOUSE);
94
93
  if (typeof this.stdin.setRawMode === 'function') {
@@ -169,11 +168,6 @@ class Prompt {
169
168
  }
170
169
  }
171
170
  else {
172
- // Width check
173
- // Handle surrogates roughly (we don't need perfect width here during loop, just enough to stop)
174
- // But wait, we imported `stringWidth`.
175
- // We can't easily use `stringWidth` incrementally without re-parsing.
176
- // Let's just trust the loop for cut index.
177
171
  // Re-implement basic width logic here for the cut index finding
178
172
  let charWidth = 1;
179
173
  let cp = code;
@@ -185,9 +179,6 @@ class Prompt {
185
179
  // We'll handle i increment in the loop
186
180
  }
187
181
  }
188
- // Check range (simplified or call helper)
189
- // We don't have isWideCodePoint exported.
190
- // But generally, we can just say:
191
182
  if (cp >= 0x1100) { // Quick check for potentially wide
192
183
  // It's acceptable to be slightly aggressive on wide chars for truncation
193
184
  charWidth = 2;
package/dist/core.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TextOptions, SelectOptions, ConfirmOptions, CheckboxOptions, ThemeConfig, NumberOptions, ToggleOptions, ListOptions, SliderOptions, DateOptions, FileOptions, MultiSelectOptions, RatingOptions, AutocompleteOptions, SortOptions, TableOptions, EditorOptions, TreeOptions, KeypressOptions } from './types';
1
+ import { TextOptions, SelectOptions, ConfirmOptions, CheckboxOptions, ThemeConfig, NumberOptions, ToggleOptions, ListOptions, SliderOptions, DateOptions, FileOptions, MultiSelectOptions, RatingOptions, AutocompleteOptions, SortOptions, TableOptions, EditorOptions, TreeOptions, KeypressOptions, FormOptions, SnippetOptions, SpamOptions, WaitOptions, CodeOptions, TreeSelectOptions, RangeOptions, TransferOptions, CronOptions, ColorOptions, GridOptions, CalendarOptions } from './types';
2
2
  import { Spinner } from './spinner';
3
3
  /**
4
4
  * Public Facade for MepCLI
@@ -14,10 +14,14 @@ export declare class MepCLI {
14
14
  static checkbox<const V>(options: CheckboxOptions<V>): Promise<V[]>;
15
15
  static confirm(options: ConfirmOptions): Promise<boolean>;
16
16
  static password(options: TextOptions): Promise<string>;
17
+ static secret(options: TextOptions): Promise<string>;
17
18
  static number(options: NumberOptions): Promise<number>;
18
19
  static toggle(options: ToggleOptions): Promise<boolean>;
19
20
  static list(options: ListOptions): Promise<string[]>;
20
21
  static slider(options: SliderOptions): Promise<number>;
22
+ static range(options: RangeOptions): Promise<[number, number]>;
23
+ static transfer<const V>(options: TransferOptions<V>): Promise<[V[], V[]]>;
24
+ static cron(options: CronOptions): Promise<string>;
21
25
  static date(options: DateOptions): Promise<Date>;
22
26
  static file(options: FileOptions): Promise<string>;
23
27
  static multiSelect<const V>(options: MultiSelectOptions<V>): Promise<V[]>;
@@ -28,4 +32,22 @@ export declare class MepCLI {
28
32
  static editor(options: EditorOptions): Promise<string>;
29
33
  static tree<const V>(options: TreeOptions<V>): Promise<V>;
30
34
  static keypress(options: KeypressOptions): Promise<string>;
35
+ static form(options: FormOptions): Promise<Record<string, string>>;
36
+ static snippet(options: SnippetOptions): Promise<string>;
37
+ static spam(options: SpamOptions): Promise<boolean>;
38
+ static wait(options: WaitOptions): Promise<void>;
39
+ static code(options: CodeOptions): Promise<string>;
40
+ /**
41
+ * Tree Select Prompt (Multi-selection)
42
+ * * @param options Configuration for the tree selection
43
+ * @returns A promise that resolves to an array of selected values
44
+ * * @notice Windows Compatibility:
45
+ * When used in a long sequence of prompts, this component may experience
46
+ * an input delay. If it feels "blocked", simply press 'Enter' once
47
+ * to refresh the TTY stream.
48
+ */
49
+ static treeSelect<const V>(options: TreeSelectOptions<V>): Promise<V[]>;
50
+ static color(options: ColorOptions): Promise<string>;
51
+ static grid(options: GridOptions): Promise<boolean[][]>;
52
+ static calendar(options: CalendarOptions): Promise<Date | [Date, Date]>;
31
53
  }
package/dist/core.js CHANGED
@@ -11,6 +11,9 @@ const toggle_1 = require("./prompts/toggle");
11
11
  const number_1 = require("./prompts/number");
12
12
  const list_1 = require("./prompts/list");
13
13
  const slider_1 = require("./prompts/slider");
14
+ const range_1 = require("./prompts/range");
15
+ const transfer_1 = require("./prompts/transfer");
16
+ const cron_1 = require("./prompts/cron");
14
17
  const date_1 = require("./prompts/date");
15
18
  const file_1 = require("./prompts/file");
16
19
  const multi_select_1 = require("./prompts/multi-select");
@@ -21,6 +24,15 @@ const table_1 = require("./prompts/table");
21
24
  const editor_1 = require("./prompts/editor");
22
25
  const tree_1 = require("./prompts/tree");
23
26
  const keypress_1 = require("./prompts/keypress");
27
+ const form_1 = require("./prompts/form");
28
+ const snippet_1 = require("./prompts/snippet");
29
+ const spam_1 = require("./prompts/spam");
30
+ const wait_1 = require("./prompts/wait");
31
+ const code_1 = require("./prompts/code");
32
+ const tree_select_1 = require("./prompts/tree-select");
33
+ const color_1 = require("./prompts/color");
34
+ const grid_1 = require("./prompts/grid");
35
+ const calendar_1 = require("./prompts/calendar");
24
36
  /**
25
37
  * Public Facade for MepCLI
26
38
  */
@@ -46,6 +58,9 @@ class MepCLI {
46
58
  static password(options) {
47
59
  return new text_1.TextPrompt({ ...options, isPassword: true }).run();
48
60
  }
61
+ static secret(options) {
62
+ return new text_1.TextPrompt({ ...options, mask: '' }).run();
63
+ }
49
64
  static number(options) {
50
65
  return new number_1.NumberPrompt(options).run();
51
66
  }
@@ -58,6 +73,15 @@ class MepCLI {
58
73
  static slider(options) {
59
74
  return new slider_1.SliderPrompt(options).run();
60
75
  }
76
+ static range(options) {
77
+ return new range_1.RangePrompt(options).run();
78
+ }
79
+ static transfer(options) {
80
+ return new transfer_1.TransferPrompt(options).run();
81
+ }
82
+ static cron(options) {
83
+ return new cron_1.CronPrompt(options).run();
84
+ }
61
85
  static date(options) {
62
86
  return new date_1.DatePrompt(options).run();
63
87
  }
@@ -88,6 +112,42 @@ class MepCLI {
88
112
  static keypress(options) {
89
113
  return new keypress_1.KeypressPrompt(options).run();
90
114
  }
115
+ static form(options) {
116
+ return new form_1.FormPrompt(options).run();
117
+ }
118
+ static snippet(options) {
119
+ return new snippet_1.SnippetPrompt(options).run();
120
+ }
121
+ static spam(options) {
122
+ return new spam_1.SpamPrompt(options).run();
123
+ }
124
+ static wait(options) {
125
+ return new wait_1.WaitPrompt(options).run();
126
+ }
127
+ static code(options) {
128
+ return new code_1.CodePrompt(options).run();
129
+ }
130
+ /**
131
+ * Tree Select Prompt (Multi-selection)
132
+ * * @param options Configuration for the tree selection
133
+ * @returns A promise that resolves to an array of selected values
134
+ * * @notice Windows Compatibility:
135
+ * When used in a long sequence of prompts, this component may experience
136
+ * an input delay. If it feels "blocked", simply press 'Enter' once
137
+ * to refresh the TTY stream.
138
+ */
139
+ static treeSelect(options) {
140
+ return new tree_select_1.TreeSelectPrompt(options).run();
141
+ }
142
+ static color(options) {
143
+ return new color_1.ColorPrompt(options).run();
144
+ }
145
+ static grid(options) {
146
+ return new grid_1.GridPrompt(options).run();
147
+ }
148
+ static calendar(options) {
149
+ return new calendar_1.CalendarPrompt(options).run();
150
+ }
91
151
  }
92
152
  exports.MepCLI = MepCLI;
93
153
  MepCLI.theme = theme_1.theme;
@@ -0,0 +1 @@
1
+ export declare function highlightJson(json: string): string;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.highlightJson = highlightJson;
4
+ const ansi_1 = require("./ansi");
5
+ function highlightJson(json) {
6
+ if (!json)
7
+ return '';
8
+ // Regex for JSON tokens
9
+ // Captures:
10
+ // 1. Strings (potentially keys if followed by :)
11
+ // 2. Numbers
12
+ // 3. Booleans/Null
13
+ // 4. Punctuation
14
+ const tokenRegex = /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?)|(-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)|(true|false|null)|([{}[\],:])/g;
15
+ return json.replace(tokenRegex, (match) => {
16
+ // String
17
+ if (match.startsWith('"')) {
18
+ // Check if it's a key (ends with :)
19
+ if (match.trim().endsWith(':')) {
20
+ const colonIndex = match.lastIndexOf(':');
21
+ const keyPart = match.substring(0, colonIndex);
22
+ const colonPart = match.substring(colonIndex);
23
+ // Key in Cyan
24
+ return `${ansi_1.ANSI.FG_CYAN}${keyPart}${ansi_1.ANSI.RESET}${colonPart}`;
25
+ }
26
+ // String value in Green
27
+ return `${ansi_1.ANSI.FG_GREEN}${match}${ansi_1.ANSI.RESET}`;
28
+ }
29
+ // Number in Yellow
30
+ if (/^-?\d/.test(match)) {
31
+ return `${ansi_1.ANSI.FG_YELLOW}${match}${ansi_1.ANSI.RESET}`;
32
+ }
33
+ // Boolean/Null in Red (or Magenta if available, using Red for now)
34
+ if (/^(true|false|null)$/.test(match)) {
35
+ return `${ansi_1.ANSI.FG_RED}${match}${ansi_1.ANSI.RESET}`;
36
+ }
37
+ // Punctuation in White (or default)
38
+ return `${ansi_1.ANSI.FG_WHITE}${match}${ansi_1.ANSI.RESET}`;
39
+ });
40
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Mep (Minimalist Interactive CLI Prompt)
2
+ * Mep (A Interactive CLI Prompt)
3
3
  * Export file
4
4
  */
5
5
  export * from './types';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Mep (Minimalist Interactive CLI Prompt)
3
+ * Mep (A Interactive CLI Prompt)
4
4
  * Export file
5
5
  */
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
package/dist/input.js CHANGED
@@ -92,23 +92,32 @@ class InputParser extends events_1.EventEmitter {
92
92
  if (parts.length >= 3) {
93
93
  const [b, x, y] = parts;
94
94
  let action = 'press';
95
+ // Extract modifiers
96
+ const shift = !!(b & 4);
97
+ const meta = !!(b & 8);
98
+ const ctrl = !!(b & 16);
95
99
  // Interpret button codes
96
100
  // 0: Left, 1: Middle, 2: Right
97
101
  // +32: Motion
98
- // 64: Scroll Up
99
- // 65: Scroll Down
100
- if (b === 64) {
102
+ // 64: Scroll (bit 6)
103
+ if (b & 64) {
101
104
  action = 'scroll';
102
- this.emit('mouse', { name: 'mouse', x, y, button: 0, action, scroll: 'up' });
103
- // Also emit keypress for scroll if needed? No, prompt should listen to mouse.
104
- // But for "Easy Features", we emit standard names
105
- this.emit('scrollup');
106
- return;
107
- }
108
- if (b === 65) {
109
- action = 'scroll';
110
- this.emit('mouse', { name: 'mouse', x, y, button: 0, action, scroll: 'down' });
111
- this.emit('scrolldown');
105
+ const scroll = (b & 1) ? 'down' : 'up';
106
+ this.emit('mouse', {
107
+ name: 'mouse',
108
+ x,
109
+ y,
110
+ button: 0,
111
+ action,
112
+ scroll,
113
+ shift,
114
+ ctrl,
115
+ meta
116
+ });
117
+ if (scroll === 'up')
118
+ this.emit('scrollup');
119
+ else
120
+ this.emit('scrolldown');
112
121
  return;
113
122
  }
114
123
  if (type === 'm') {
@@ -126,7 +135,10 @@ class InputParser extends events_1.EventEmitter {
126
135
  x,
127
136
  y,
128
137
  button: b & 3, // Strip modifiers to get raw button 0-2
129
- action
138
+ action,
139
+ shift,
140
+ ctrl,
141
+ meta
130
142
  });
131
143
  }
132
144
  }
@@ -16,7 +16,7 @@ export declare class AutocompletePrompt<V> extends Prompt<V, AutocompleteOptions
16
16
  private startSpinner;
17
17
  private stopSpinner;
18
18
  protected cleanup(): void;
19
- protected render(firstRender: boolean): void;
19
+ protected render(_firstRender: boolean): void;
20
20
  protected handleInput(char: string): void;
21
21
  protected handleMouse(event: MouseEvent): void;
22
22
  }
@@ -36,7 +36,7 @@ class AutocompletePrompt extends base_1.Prompt {
36
36
  this.scrollTop = 0;
37
37
  this.hasSearched = true;
38
38
  }
39
- catch (err) {
39
+ catch (_err) {
40
40
  this.choices = [];
41
41
  }
42
42
  finally {
@@ -64,15 +64,10 @@ class AutocompletePrompt extends base_1.Prompt {
64
64
  this.stopSpinner();
65
65
  super.cleanup();
66
66
  }
67
- render(firstRender) {
68
- // --- FIX START: Restore cursor position ---
69
- // renderFrame() in Base assumes the cursor is at the bottom of the output.
70
- // Since Autocomplete moves the cursor to the top (for input) after rendering,
71
- // we must manually move it back down before the next render cycle.
67
+ render(_firstRender) {
72
68
  if (this.lastRenderHeight > 1) {
73
69
  this.print(`\x1b[${this.lastRenderHeight - 1}B`); // Move down
74
70
  }
75
- // --- FIX END ---
76
71
  let output = '';
77
72
  // Header
78
73
  const icon = this.loading ? `${theme_1.theme.main}${symbols_1.symbols.spinner[this.spinnerFrame]}${ansi_1.ANSI.RESET}` : `${theme_1.theme.success}?${ansi_1.ANSI.RESET}`;
@@ -0,0 +1,20 @@
1
+ import { Prompt } from '../base';
2
+ import { CalendarOptions, MouseEvent } from '../types';
3
+ export declare class CalendarPrompt extends Prompt<Date | [Date, Date], CalendarOptions> {
4
+ private cursor;
5
+ private viewDate;
6
+ private selection;
7
+ private selectingRange;
8
+ constructor(options: CalendarOptions);
9
+ private getDaysInMonth;
10
+ private getDayOfWeek;
11
+ private generateMonthGrid;
12
+ private isSameDay;
13
+ private isSelected;
14
+ private isRangeStart;
15
+ protected render(_firstRender: boolean): void;
16
+ private syncViewDate;
17
+ private alignCursorToViewDate;
18
+ protected handleInput(char: string, _key: Buffer): void;
19
+ protected handleMouse(event: MouseEvent): void;
20
+ }