mepcli 1.0.0-rc.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 CodeTease
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 CodeTease
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,5 +1,5 @@
1
1
  import { BreadcrumbPrompt } from './breadcrumb';
2
- import { BreadcrumbOptions } from '../types';
2
+ import { BreadcrumbOptions, MouseEvent } from '../types';
3
3
  export declare class BreadcrumbSearchPrompt extends BreadcrumbPrompt {
4
4
  private isSearchMode;
5
5
  private searchBuffer;
@@ -8,6 +8,7 @@ export declare class BreadcrumbSearchPrompt extends BreadcrumbPrompt {
8
8
  constructor(options: BreadcrumbOptions);
9
9
  protected handleInput(char: string, key: Buffer): void;
10
10
  private updateSearchResults;
11
+ protected handleMouse(event: MouseEvent): void;
11
12
  protected render(firstRender: boolean): void;
12
13
  private highlight;
13
14
  }
@@ -158,6 +158,28 @@ class BreadcrumbSearchPrompt extends breadcrumb_1.BreadcrumbPrompt {
158
158
  }));
159
159
  this.searchCursor = 0;
160
160
  }
161
+ handleMouse(event) {
162
+ if (!this.isSearchMode) {
163
+ super.handleMouse(event);
164
+ return;
165
+ }
166
+ if (this.isLoading)
167
+ return;
168
+ if (event.action === 'scroll') {
169
+ if (event.scroll === 'up') {
170
+ if (this.searchCursor > 0) {
171
+ this.searchCursor--;
172
+ this.render(false);
173
+ }
174
+ }
175
+ else if (event.scroll === 'down') {
176
+ if (this.searchCursor < this.filteredEntries.length - 1) {
177
+ this.searchCursor++;
178
+ this.render(false);
179
+ }
180
+ }
181
+ }
182
+ }
161
183
  render(firstRender) {
162
184
  if (!this.isSearchMode) {
163
185
  super.render(firstRender);
@@ -1,20 +1,33 @@
1
1
  import { Prompt } from '../base';
2
2
  import { CalendarOptions, MouseEvent } from '../types';
3
- export declare class CalendarPrompt extends Prompt<Date | [Date, Date], CalendarOptions> {
3
+ type SingleSelection = Date;
4
+ type RangeSelection = [Date, Date];
5
+ type CalendarValue = SingleSelection | RangeSelection | SingleSelection[] | RangeSelection[];
6
+ interface ExtendedCalendarOptions extends CalendarOptions {
7
+ multiple?: boolean;
8
+ }
9
+ export declare class CalendarPrompt extends Prompt<CalendarValue, ExtendedCalendarOptions> {
4
10
  private cursor;
5
11
  private viewDate;
6
- private selection;
7
- private selectingRange;
8
- constructor(options: CalendarOptions);
12
+ private selections;
13
+ private tempRangeStart;
14
+ constructor(options: ExtendedCalendarOptions);
9
15
  private getDaysInMonth;
10
- private getDayOfWeek;
11
16
  private generateMonthGrid;
12
17
  private isSameDay;
18
+ /**
19
+ * Check if a date is part of any committed selection
20
+ */
13
21
  private isSelected;
14
- private isRangeStart;
22
+ /**
23
+ * Visual feedback for the range currently being defined (before Enter is pressed the 2nd time)
24
+ */
25
+ private isInTempRange;
15
26
  protected render(_firstRender: boolean): void;
16
27
  private syncViewDate;
17
28
  private alignCursorToViewDate;
18
- protected handleInput(char: string, _key: Buffer): void;
29
+ private submitResult;
30
+ protected handleInput(char: string, _key: any): void;
19
31
  protected handleMouse(event: MouseEvent): void;
20
32
  }
33
+ export {};
@@ -7,46 +7,65 @@ const theme_1 = require("../theme");
7
7
  class CalendarPrompt extends base_1.Prompt {
8
8
  constructor(options) {
9
9
  super(options);
10
- this.selection = null;
11
- this.selectingRange = false; // Internal state for range selection
12
- // Normalize initial value
13
- if (Array.isArray(options.initial)) {
14
- this.selection = [new Date(options.initial[0]), new Date(options.initial[1])];
15
- this.cursor = new Date(options.initial[1]); // Cursor at end of range
16
- }
17
- else if (options.initial) {
18
- this.selection = new Date(options.initial);
19
- this.cursor = new Date(options.initial);
10
+ // Store all selections here. Can be an array of Dates or Ranges.
11
+ this.selections = [];
12
+ // Internal state for dragging/selecting a range before it is finalized
13
+ this.tempRangeStart = null;
14
+ // Initialize cursor
15
+ this.cursor = new Date();
16
+ this.viewDate = new Date();
17
+ this.viewDate.setDate(1);
18
+ // Normalize initial value into selections array
19
+ if (options.initial) {
20
+ // Handle array inputs (Range or Multiple Dates)
21
+ if (Array.isArray(options.initial)) {
22
+ const init = options.initial;
23
+ if (init.length > 0) {
24
+ // Detect if it is [Date, Date] (Single Range)
25
+ if (options.mode === 'range' && !options.multiple && init.length === 2 && init[0] instanceof Date) {
26
+ this.selections = [[init[0], init[1]]];
27
+ this.cursor = new Date(init[1]);
28
+ }
29
+ // Detect [Date, Date][] (Multiple Ranges)
30
+ else if (Array.isArray(init[0])) {
31
+ this.selections = [...init];
32
+ const lastRange = init[init.length - 1];
33
+ this.cursor = new Date(lastRange[1]);
34
+ }
35
+ // Detect Date[] (Multiple Singles)
36
+ else {
37
+ this.selections = [...init];
38
+ this.cursor = new Date(init[init.length - 1]);
39
+ }
40
+ }
41
+ }
42
+ else {
43
+ // Single Date
44
+ this.selections = [options.initial];
45
+ this.cursor = new Date(options.initial);
46
+ }
20
47
  }
21
48
  else {
22
- this.cursor = new Date();
23
- // If range mode but no initial, selection remains null until user picks
24
- if (this.options.mode !== 'range') {
25
- this.selection = new Date();
49
+ // If no initial value, and NOT range mode, we might optionally start with today selected?
50
+ // For now, let's keep it empty or follow original logic behavior if needed.
51
+ if (this.options.mode !== 'range' && !this.options.multiple) {
52
+ this.selections = [new Date()];
26
53
  }
27
54
  }
28
- // Clone cursor to viewDate to track month view independently
55
+ // Sync viewDate to cursor so we see the selected date
29
56
  this.viewDate = new Date(this.cursor);
30
57
  this.viewDate.setDate(1);
31
58
  }
32
59
  getDaysInMonth(year, month) {
33
60
  return new Date(year, month + 1, 0).getDate();
34
61
  }
35
- getDayOfWeek(year, month, day) {
36
- return new Date(year, month, day).getDay();
37
- }
38
62
  generateMonthGrid(year, month) {
39
63
  const days = [];
40
64
  const firstDayOfMonth = new Date(year, month, 1);
41
65
  const startDayOfWeek = firstDayOfMonth.getDay(); // 0 (Sun) to 6 (Sat)
42
66
  const weekStart = this.options.weekStart || 0;
43
67
  // Calculate days from previous month to fill the first row
44
- // If startDayOfWeek is 2 (Tue) and weekStart is 0 (Sun), we need 2 days from prev month.
45
- // If startDayOfWeek is 0 (Sun) and weekStart is 1 (Mon), we need 6 days from prev month.
46
68
  const daysFromPrevMonth = (startDayOfWeek - weekStart + 7) % 7;
47
- if (daysFromPrevMonth === 0 && startDayOfWeek !== weekStart) {
48
- // Logic check: if starts on same day, 0.
49
- }
50
69
  const prevMonthDate = new Date(year, month, 0); // Last day of prev month
51
70
  const prevMonthDaysCount = prevMonthDate.getDate();
52
71
  // Add previous month days
@@ -79,36 +98,36 @@ class CalendarPrompt extends base_1.Prompt {
79
98
  d1.getMonth() === d2.getMonth() &&
80
99
  d1.getDate() === d2.getDate();
81
100
  }
101
+ /**
102
+ * Check if a date is part of any committed selection
103
+ */
82
104
  isSelected(d) {
83
- if (!this.selection)
84
- return false;
85
- if (this.options.mode === 'range') {
86
- if (Array.isArray(this.selection)) {
87
- const [start, end] = this.selection;
88
- const s = start < end ? start : end;
89
- const e = start < end ? end : start;
90
- // Set times to midnight for comparison
91
- const dTime = new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
92
- const sTime = new Date(s.getFullYear(), s.getMonth(), s.getDate()).getTime();
93
- const eTime = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
94
- return dTime >= sTime && dTime <= eTime;
105
+ const dTime = new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
106
+ return this.selections.some(sel => {
107
+ if (Array.isArray(sel)) {
108
+ // Range logic
109
+ const [start, end] = sel;
110
+ const sTime = new Date(start.getFullYear(), start.getMonth(), start.getDate()).getTime();
111
+ const eTime = new Date(end.getFullYear(), end.getMonth(), end.getDate()).getTime();
112
+ return dTime >= Math.min(sTime, eTime) && dTime <= Math.max(sTime, eTime);
95
113
  }
96
114
  else {
97
- return this.isSameDay(d, this.selection);
115
+ // Single date logic
116
+ const sTime = new Date(sel.getFullYear(), sel.getMonth(), sel.getDate()).getTime();
117
+ return dTime === sTime;
98
118
  }
99
- }
100
- else {
101
- return this.isSameDay(d, this.selection);
102
- }
119
+ });
103
120
  }
104
- // Helper to check if selection is 'in progress' (only one end picked) for visual feedback
105
- isRangeStart(d) {
106
- if (this.options.mode !== 'range' || !this.selection)
121
+ /**
122
+ * Visual feedback for the range currently being defined (before Enter is pressed the 2nd time)
123
+ */
124
+ isInTempRange(d) {
125
+ if (!this.tempRangeStart)
107
126
  return false;
108
- if (Array.isArray(this.selection)) {
109
- return this.isSameDay(d, this.selection[0]) || this.isSameDay(d, this.selection[1]);
110
- }
111
- return this.isSameDay(d, this.selection);
127
+ const dTime = new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
128
+ const sTime = new Date(this.tempRangeStart.getFullYear(), this.tempRangeStart.getMonth(), this.tempRangeStart.getDate()).getTime();
129
+ const cTime = new Date(this.cursor.getFullYear(), this.cursor.getMonth(), this.cursor.getDate()).getTime();
130
+ return dTime >= Math.min(sTime, cTime) && dTime <= Math.max(sTime, cTime);
112
131
  }
113
132
  render(_firstRender) {
114
133
  const monthNames = ["January", "February", "March", "April", "May", "June",
@@ -117,20 +136,13 @@ class CalendarPrompt extends base_1.Prompt {
117
136
  const year = this.viewDate.getFullYear();
118
137
  const month = this.viewDate.getMonth();
119
138
  const header = `${ansi_1.ANSI.BOLD}${monthNames[month]} ${year}${ansi_1.ANSI.RESET}`;
120
- // Centered header roughly
121
- // 20 is approx width of calendar (3 chars * 7 cols - 1 space = 20)
122
- // Actually grid width: 7 columns. Each cell is usually "DD ". Last col "DD".
123
- // Let's say cell width is 3 chars (2 digits + 1 space). Total 21 chars.
124
139
  const weekDays = this.options.weekStart === 1
125
140
  ? ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]
126
141
  : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
127
142
  const grid = this.generateMonthGrid(year, month);
128
143
  let output = `${theme_1.theme.title}${this.options.message}${ansi_1.ANSI.RESET}\n`;
129
- // Controls hint
130
144
  output += `${theme_1.theme.muted}< ${header} >${ansi_1.ANSI.RESET}\n`;
131
- // Weekday Header
132
145
  output += weekDays.map(d => `${theme_1.theme.muted}${d}${ansi_1.ANSI.RESET}`).join(' ') + '\n';
133
- // Grid
134
146
  let rowLine = '';
135
147
  for (let i = 0; i < grid.length; i++) {
136
148
  const cell = grid[i];
@@ -138,23 +150,21 @@ class CalendarPrompt extends base_1.Prompt {
138
150
  let style = '';
139
151
  const isCursor = this.isSameDay(cell.date, this.cursor);
140
152
  const isSel = this.isSelected(cell.date);
153
+ const isTemp = this.isInTempRange(cell.date);
141
154
  const isToday = this.isSameDay(cell.date, new Date());
142
- // Base style
143
155
  if (!cell.inMonth) {
144
156
  style = theme_1.theme.muted;
145
157
  }
146
- if (isSel) {
147
- // If it is selected, use main color
158
+ // Priority: Cursor > Temp/Selected > Today
159
+ if (isSel || isTemp) {
148
160
  style = theme_1.theme.main;
149
161
  }
150
- if (isToday && !isSel) {
162
+ if (isToday && !isSel && !isTemp) {
151
163
  style += ansi_1.ANSI.UNDERLINE;
152
164
  }
153
165
  if (isCursor) {
154
166
  style += ansi_1.ANSI.REVERSE; // Invert colors for cursor
155
167
  }
156
- // Apply
157
- // Reset must be applied after each cell to prevent bleeding
158
168
  rowLine += `${style}${dateStr}${ansi_1.ANSI.RESET}`;
159
169
  if ((i + 1) % 7 === 0) {
160
170
  output += rowLine + '\n';
@@ -164,10 +174,27 @@ class CalendarPrompt extends base_1.Prompt {
164
174
  rowLine += ' ';
165
175
  }
166
176
  }
167
- // Helper text
168
- const help = this.options.mode === 'range'
169
- ? 'Enter: Select start/end'
170
- : 'Enter: Select';
177
+ // Helper text logic
178
+ let help = '';
179
+ if (this.options.mode === 'range') {
180
+ if (this.options.multiple) {
181
+ help = 'Enter: Range Points | D: Done';
182
+ }
183
+ else {
184
+ help = 'Enter: Start/End';
185
+ }
186
+ }
187
+ else {
188
+ if (this.options.multiple) {
189
+ help = 'Space/Enter: Toggle | D: Done';
190
+ }
191
+ else {
192
+ help = 'Enter: Select';
193
+ }
194
+ }
195
+ if (this.tempRangeStart) {
196
+ help += ` ${theme_1.theme.muted}(Selecting range...)${ansi_1.ANSI.RESET}`;
197
+ }
171
198
  output += `${theme_1.theme.muted}${help}${ansi_1.ANSI.RESET}`;
172
199
  this.renderFrame(output);
173
200
  }
@@ -188,6 +215,22 @@ class CalendarPrompt extends base_1.Prompt {
188
215
  const newDay = Math.min(day, daysInTarget);
189
216
  this.cursor = new Date(year, month, newDay);
190
217
  }
218
+ submitResult() {
219
+ if (this.options.multiple) {
220
+ if (this.options.mode === 'range') {
221
+ // Only RangeSelection[]
222
+ this.submit(this.selections.filter(Array.isArray));
223
+ }
224
+ else {
225
+ // Only Date[]
226
+ this.submit(this.selections.filter(sel => !Array.isArray(sel)));
227
+ }
228
+ }
229
+ else {
230
+ // Single Mode (Single Date or Single Range)
231
+ this.submit(this.selections[0] || null);
232
+ }
233
+ }
191
234
  handleInput(char, _key) {
192
235
  const isUp = this.isUp(char);
193
236
  const isDown = this.isDown(char);
@@ -270,35 +313,58 @@ class CalendarPrompt extends base_1.Prompt {
270
313
  this.render(false);
271
314
  return;
272
315
  }
273
- // Selection
316
+ // Done key (only for multiple mode)
317
+ if ((char === 'd' || char === 'D') && this.options.multiple) {
318
+ this.submitResult();
319
+ return;
320
+ }
321
+ // Selection Trigger
274
322
  if (char === '\r' || char === '\n' || char === ' ') {
275
323
  if (this.options.mode === 'range') {
276
- if (!this.selectingRange) {
324
+ if (!this.tempRangeStart) {
277
325
  // Start new range selection
278
- this.selection = this.cursor; // First point (single date temporary)
279
- this.selectingRange = true;
326
+ this.tempRangeStart = this.cursor;
327
+ if (!this.options.multiple) {
328
+ this.selections = [];
329
+ }
280
330
  }
281
331
  else {
282
332
  // Finish range selection
283
- const start = this.selection;
333
+ const start = this.tempRangeStart;
284
334
  const end = this.cursor;
285
- // Order them
286
- if (start > end) {
287
- this.selection = [end, start];
335
+ // Normalize order
336
+ const newRange = start < end ? [start, end] : [end, start];
337
+ if (this.options.multiple) {
338
+ this.selections.push(newRange);
339
+ this.tempRangeStart = null; // Reset for next range
288
340
  }
289
341
  else {
290
- this.selection = [start, end];
342
+ // Single Mode: Finish and Submit
343
+ this.selections = [newRange];
344
+ this.submitResult();
345
+ return;
291
346
  }
292
- this.selectingRange = false;
293
- this.submit(this.selection);
294
- return;
295
347
  }
296
348
  }
297
349
  else {
298
- // Single mode
299
- this.selection = this.cursor;
300
- this.submit(this.selection);
301
- return;
350
+ // Single Date Mode
351
+ const date = this.cursor;
352
+ if (this.options.multiple) {
353
+ // Toggle selection
354
+ const idx = this.selections.findIndex(s => !Array.isArray(s) && this.isSameDay(s, date));
355
+ if (idx >= 0) {
356
+ this.selections.splice(idx, 1);
357
+ }
358
+ else {
359
+ this.selections.push(date);
360
+ }
361
+ }
362
+ else {
363
+ // Single Mode: Finish and Submit
364
+ this.selections = [date];
365
+ this.submitResult();
366
+ return;
367
+ }
302
368
  }
303
369
  this.render(false);
304
370
  return;
@@ -7,6 +7,7 @@ export declare class SchedulePrompt extends Prompt<ScheduleTask[], ScheduleOptio
7
7
  private readonly pageSize;
8
8
  private viewStartDate;
9
9
  private msPerChar;
10
+ private minViewDate?;
10
11
  private nameColWidth;
11
12
  constructor(options: ScheduleOptions);
12
13
  private get maxNameWidth();
@@ -15,4 +16,5 @@ export declare class SchedulePrompt extends Prompt<ScheduleTask[], ScheduleOptio
15
16
  private formatDuration;
16
17
  protected handleInput(char: string, key: Buffer): void;
17
18
  protected handleMouse(event: MouseEvent): void;
19
+ private scrollView;
18
20
  }
@@ -20,13 +20,20 @@ class SchedulePrompt extends base_1.Prompt {
20
20
  end: new Date(t.end)
21
21
  }));
22
22
  // Initial Calculations
23
- const minDate = Math.min(...this.tasks.map(t => t.start.getTime()));
24
- const maxDate = Math.max(...this.tasks.map(t => t.end.getTime()));
23
+ const minTaskDate = Math.min(...this.tasks.map(t => t.start.getTime()));
24
+ const maxTaskDate = Math.max(...this.tasks.map(t => t.end.getTime()));
25
+ const opts = options;
26
+ const minDate = opts.startDate ? opts.startDate.getTime() : minTaskDate;
27
+ const maxDate = opts.endDate ? opts.endDate.getTime() : maxTaskDate;
28
+ if (opts.startDate)
29
+ this.minViewDate = minDate;
25
30
  // Default Zoom: Fit the whole range into ~60 chars
26
31
  const range = maxDate - minDate || 86400000; // default 1 day if 0
27
32
  this.msPerChar = range / 60;
28
33
  // Start view slightly before the earliest task
29
- this.viewStartDate = minDate - (this.msPerChar * 5);
34
+ this.viewStartDate = opts.startDate
35
+ ? minDate
36
+ : minDate - (this.msPerChar * 5);
30
37
  }
31
38
  get maxNameWidth() {
32
39
  return Math.max(...this.tasks.map(t => (0, utils_1.stringWidth)(t.name))) + 2;
@@ -107,7 +114,7 @@ class SchedulePrompt extends base_1.Prompt {
107
114
  output += `${prefix}${nameColor}${paddedName}${reset} │${timelineStr}\n`;
108
115
  });
109
116
  // Footer Help
110
- output += `\n${theme_1.theme.muted}(Arrows: Move/Nav, Shift+Arrows: Resize, PgUp/PgDn: Scroll Time)${ansi_1.ANSI.RESET}`;
117
+ output += `\n${theme_1.theme.muted}(Arrows/Scroll: Move Task, Shift+Arrows: Resize, Ctrl+Scroll/PgUp/Dn: Scroll View)${ansi_1.ANSI.RESET}`;
111
118
  this.renderFrame(output);
112
119
  }
113
120
  formatDateCompact(d) {
@@ -133,7 +140,7 @@ class SchedulePrompt extends base_1.Prompt {
133
140
  }
134
141
  handleInput(char, key) {
135
142
  const task = this.tasks[this.cursor];
136
- const step = this.msPerChar; // Move by 1 char equivalent
143
+ const step = Math.max(1, this.msPerChar); // Move by 1 char equivalent
137
144
  // Tab Handling
138
145
  if (char === '\t') {
139
146
  this.cursor = (this.cursor + 1) % this.tasks.length;
@@ -157,12 +164,25 @@ class SchedulePrompt extends base_1.Prompt {
157
164
  }
158
165
  // PageUp/Down: Horizontal Scroll
159
166
  if (key.toString() === '\x1b[5~') { // PageUp
160
- this.viewStartDate -= (this.msPerChar * 10);
167
+ this.scrollView(-10);
161
168
  this.render(false);
162
169
  return;
163
170
  }
164
171
  if (key.toString() === '\x1b[6~') { // PageDown
165
- this.viewStartDate += (this.msPerChar * 10);
172
+ this.scrollView(10);
173
+ this.render(false);
174
+ return;
175
+ }
176
+ // Vim keys for movement (h/l) - Alternative to arrows
177
+ if (char === 'h') {
178
+ task.start = new Date(task.start.getTime() - step);
179
+ task.end = new Date(task.end.getTime() - step);
180
+ this.render(false);
181
+ return;
182
+ }
183
+ if (char === 'l') {
184
+ task.start = new Date(task.start.getTime() + step);
185
+ task.end = new Date(task.end.getTime() + step);
166
186
  this.render(false);
167
187
  return;
168
188
  }
@@ -205,17 +225,39 @@ class SchedulePrompt extends base_1.Prompt {
205
225
  }
206
226
  handleMouse(event) {
207
227
  if (event.action === 'scroll') {
208
- // Scroll timeline horizontally
209
- if (event.scroll === 'up') {
210
- // Move view to earlier (left)
211
- this.viewStartDate -= (this.msPerChar * 5);
228
+ const isCtrl = event.ctrl;
229
+ if (isCtrl) {
230
+ // Scroll View
231
+ if (event.scroll === 'up') {
232
+ this.scrollView(-5);
233
+ }
234
+ else if (event.scroll === 'down') {
235
+ this.scrollView(5);
236
+ }
212
237
  }
213
- else if (event.scroll === 'down') {
214
- // Move view to later (right)
215
- this.viewStartDate += (this.msPerChar * 5);
238
+ else {
239
+ // Move Task
240
+ const task = this.tasks[this.cursor];
241
+ const step = Math.max(1, this.msPerChar);
242
+ if (event.scroll === 'up') {
243
+ task.start = new Date(task.start.getTime() - step);
244
+ task.end = new Date(task.end.getTime() - step);
245
+ }
246
+ else if (event.scroll === 'down') {
247
+ task.start = new Date(task.start.getTime() + step);
248
+ task.end = new Date(task.end.getTime() + step);
249
+ }
216
250
  }
217
251
  this.render(false);
218
252
  }
219
253
  }
254
+ scrollView(chars) {
255
+ let newStart = this.viewStartDate + (chars * this.msPerChar);
256
+ // Clamp if fixed start is provided to prevent scrolling before the start date
257
+ if (this.minViewDate !== undefined && newStart < this.minViewDate) {
258
+ newStart = this.minViewDate;
259
+ }
260
+ this.viewStartDate = newStart;
261
+ }
220
262
  }
221
263
  exports.SchedulePrompt = SchedulePrompt;
package/dist/types.d.ts CHANGED
@@ -228,6 +228,7 @@ export interface SortGridOptions extends BaseOptions {
228
228
  }
229
229
  export interface CalendarOptions extends BaseOptions {
230
230
  mode?: 'single' | 'range';
231
+ multiple?: boolean;
231
232
  initial?: Date | [Date, Date];
232
233
  min?: Date;
233
234
  max?: Date;
package/package.json CHANGED
@@ -1,51 +1,58 @@
1
- {
2
- "name": "mepcli",
3
- "version": "1.0.0-rc.1",
4
- "description": "Zero-dependency, interactive CLI prompt for Node.js",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/CodeTease/mep.git"
8
- },
9
- "main": "dist/index.js",
10
- "types": "dist/index.d.ts",
11
- "files": [
12
- "dist",
13
- "README.md",
14
- "LICENSE"
15
- ],
16
- "scripts": {
17
- "build": "tsc",
18
- "prepublishOnly": "npm run build",
19
- "test": "jest",
20
- "demo": "ts-node example.ts",
21
- "lint": "eslint .",
22
- "lint:fix": "eslint . --fix"
23
- },
24
- "keywords": [
25
- "cli",
26
- "prompt",
27
- "inquirer",
28
- "enquirer",
29
- "interactive",
30
- "zero-dependency",
31
- "codetease",
32
- "command-line",
33
- "typescript",
34
- "color",
35
- "ansi"
36
- ],
37
- "author": "CodeTease",
38
- "license": "MIT",
39
- "devDependencies": {
40
- "@eslint/js": "^9",
41
- "@types/jest": "^30",
42
- "@types/node": "^22",
43
- "eslint": "^9",
44
- "globals": "^17",
45
- "jest": "^30",
46
- "ts-jest": "^29",
47
- "ts-node": "^10",
48
- "typescript": "^5",
49
- "typescript-eslint": "^8"
50
- }
51
- }
1
+ {
2
+ "name": "mepcli",
3
+ "version": "1.0.0",
4
+ "description": "Zero-dependency, interactive CLI prompt",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/CodeTease/mep.git"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "prepublishOnly": "npm run build",
19
+ "test": "jest",
20
+ "demo": "ts-node example.ts",
21
+ "lint": "eslint .",
22
+ "lint:fix": "eslint . --fix"
23
+ },
24
+ "keywords": [
25
+ "cli",
26
+ "prompt",
27
+ "prompts",
28
+ "inquirer",
29
+ "enquirer",
30
+ "interactive",
31
+ "interact",
32
+ "zero-dependency",
33
+ "codetease",
34
+ "command-line",
35
+ "typescript",
36
+ "color",
37
+ "ansi",
38
+ "ui",
39
+ "terminal",
40
+ "command-line",
41
+ "mep",
42
+ "mepcli"
43
+ ],
44
+ "author": "CodeTease",
45
+ "license": "MIT",
46
+ "devDependencies": {
47
+ "@eslint/js": "^9",
48
+ "@types/jest": "^30",
49
+ "@types/node": "^22",
50
+ "eslint": "^9",
51
+ "globals": "^17",
52
+ "jest": "^30",
53
+ "ts-jest": "^29",
54
+ "ts-node": "^10",
55
+ "typescript": "^5",
56
+ "typescript-eslint": "^8"
57
+ }
58
+ }