@dmsi/wedgekit-react 0.0.44 → 0.0.46

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 (43) hide show
  1. package/dist/{chunk-JIFWUW4M.js → chunk-2BVSUYXU.js} +1 -1
  2. package/dist/{chunk-DVXLTLKP.js → chunk-724LJWFR.js} +5 -3
  3. package/dist/{chunk-IOSLZ3WW.js → chunk-KXUUKAQM.js} +1 -0
  4. package/dist/{chunk-W3K72ORO.js → chunk-SGQWENE2.js} +1 -1
  5. package/dist/{chunk-MUDULZCP.js → chunk-XIEG2XMD.js} +1 -1
  6. package/dist/components/DataGrid.cjs +5 -3
  7. package/dist/components/DataGrid.js +4 -4
  8. package/dist/components/DataGridCell.cjs +5 -3
  9. package/dist/components/DataGridCell.js +3 -3
  10. package/dist/components/DateInput.cjs +5 -3
  11. package/dist/components/DateInput.js +1 -1
  12. package/dist/components/DateRangeInput.cjs +32 -9
  13. package/dist/components/DateRangeInput.js +28 -7
  14. package/dist/components/FilterGroup.cjs +5 -3
  15. package/dist/components/FilterGroup.js +2 -2
  16. package/dist/components/Input.cjs +5 -3
  17. package/dist/components/Input.js +1 -1
  18. package/dist/components/MobileDataGrid.cjs +1 -0
  19. package/dist/components/MobileDataGrid.js +1 -1
  20. package/dist/components/Notification.cjs +1 -0
  21. package/dist/components/Notification.js +1 -1
  22. package/dist/components/Password.cjs +5 -3
  23. package/dist/components/Password.js +1 -1
  24. package/dist/components/Search.cjs +5 -3
  25. package/dist/components/Search.js +2 -2
  26. package/dist/components/Select.cjs +5 -3
  27. package/dist/components/Select.js +2 -2
  28. package/dist/components/SideMenuGroup.cjs +1 -0
  29. package/dist/components/SideMenuGroup.js +1 -1
  30. package/dist/components/SideMenuItem.cjs +1 -0
  31. package/dist/components/SideMenuItem.js +1 -1
  32. package/dist/components/Stack.cjs +1 -0
  33. package/dist/components/Stack.js +1 -1
  34. package/dist/components/Stepper.cjs +5 -3
  35. package/dist/components/Stepper.js +1 -1
  36. package/dist/components/Swatch.cjs +1 -0
  37. package/dist/components/Swatch.js +1 -1
  38. package/dist/components/Time.cjs +6 -3
  39. package/dist/components/Time.js +2 -2
  40. package/package.json +1 -1
  41. package/src/components/DateRangeInput.tsx +136 -91
  42. package/src/components/Input.tsx +3 -1
  43. package/src/components/Stack.tsx +2 -2
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Stack
3
- } from "../chunk-IOSLZ3WW.js";
3
+ } from "../chunk-KXUUKAQM.js";
4
4
  import {
5
5
  Paragraph
6
6
  } from "../chunk-VG4EPHJA.js";
@@ -183,6 +183,7 @@ var Stack = (_a) => {
183
183
  "max-w-screen",
184
184
  width !== "fit" && "w-full",
185
185
  width === "full" && "w-full",
186
+ width === "max" && "w-max",
186
187
  centered && "mx-auto",
187
188
  overflowY == "auto" && "overflow-y-auto",
188
189
  overflowY == "hidden" && "overflow-y-hidden",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Stack
3
- } from "../chunk-IOSLZ3WW.js";
3
+ } from "../chunk-KXUUKAQM.js";
4
4
  import "../chunk-ORMEWXMH.js";
5
5
  export {
6
6
  Stack
@@ -458,7 +458,8 @@ var InputBase = (_a) => {
458
458
  inputContainerRef,
459
459
  removeBorder,
460
460
  wrapperClassName,
461
- focus
461
+ focus,
462
+ fullWidth = true
462
463
  } = _b, props = __objRest(_b, [
463
464
  "id",
464
465
  "before",
@@ -475,7 +476,8 @@ var InputBase = (_a) => {
475
476
  "inputContainerRef",
476
477
  "removeBorder",
477
478
  "wrapperClassName",
478
- "focus"
479
+ "focus",
480
+ "fullWidth"
479
481
  ]);
480
482
  const attributes = {
481
483
  "data-error": error && !focus || null,
@@ -497,7 +499,7 @@ var InputBase = (_a) => {
497
499
  }
498
500
  }, [selectOnFocus]);
499
501
  const inputBaseClass = (0, import_clsx5.default)(
500
- "w-full",
502
+ fullWidth ? "w-full" : "w-fit",
501
503
  "flex flex-row items-center",
502
504
  "bg-background-action-secondary-normal caret-icon-on-action-secondary-normal",
503
505
  componentGap,
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  InputBase
4
- } from "../chunk-DVXLTLKP.js";
4
+ } from "../chunk-724LJWFR.js";
5
5
  import "../chunk-S5K22XTH.js";
6
6
  import {
7
7
  Button
@@ -362,6 +362,7 @@ var Stack = (_a) => {
362
362
  "max-w-screen",
363
363
  width !== "fit" && "w-full",
364
364
  width === "full" && "w-full",
365
+ width === "max" && "w-max",
365
366
  centered && "mx-auto",
366
367
  overflowY == "auto" && "overflow-y-auto",
367
368
  overflowY == "hidden" && "overflow-y-hidden",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Stack
3
- } from "../chunk-IOSLZ3WW.js";
3
+ } from "../chunk-KXUUKAQM.js";
4
4
  import {
5
5
  Display1
6
6
  } from "../chunk-AY7ELVQY.js";
@@ -319,7 +319,8 @@ var InputBase = (_a) => {
319
319
  inputContainerRef,
320
320
  removeBorder,
321
321
  wrapperClassName,
322
- focus
322
+ focus,
323
+ fullWidth = true
323
324
  } = _b, props = __objRest(_b, [
324
325
  "id",
325
326
  "before",
@@ -336,7 +337,8 @@ var InputBase = (_a) => {
336
337
  "inputContainerRef",
337
338
  "removeBorder",
338
339
  "wrapperClassName",
339
- "focus"
340
+ "focus",
341
+ "fullWidth"
340
342
  ]);
341
343
  const attributes = {
342
344
  "data-error": error && !focus || null,
@@ -358,7 +360,7 @@ var InputBase = (_a) => {
358
360
  }
359
361
  }, [selectOnFocus]);
360
362
  const inputBaseClass = (0, import_clsx4.default)(
361
- "w-full",
363
+ fullWidth ? "w-full" : "w-fit",
362
364
  "flex flex-row items-center",
363
365
  "bg-background-action-secondary-normal caret-icon-on-action-secondary-normal",
364
366
  componentGap,
@@ -831,6 +833,7 @@ var Stack = (_a) => {
831
833
  "max-w-screen",
832
834
  width !== "fit" && "w-full",
833
835
  width === "full" && "w-full",
836
+ width === "max" && "w-max",
834
837
  centered && "mx-auto",
835
838
  overflowY == "auto" && "overflow-y-auto",
836
839
  overflowY == "hidden" && "overflow-y-hidden",
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  Stack
3
- } from "../chunk-IOSLZ3WW.js";
3
+ } from "../chunk-KXUUKAQM.js";
4
4
  import {
5
5
  findDocumentRoot
6
6
  } from "../chunk-4T7F5BZZ.js";
7
7
  import {
8
8
  InputBase
9
- } from "../chunk-DVXLTLKP.js";
9
+ } from "../chunk-724LJWFR.js";
10
10
  import "../chunk-S5K22XTH.js";
11
11
  import {
12
12
  Icon
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.44",
4
+ "version": "0.0.46",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",
@@ -159,67 +159,76 @@ export const DateRangeInput = ({
159
159
 
160
160
  const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
161
161
  if (readOnly) return;
162
-
162
+
163
163
  const rawValue = event.target.value;
164
164
  const cursorPosition = event.target.selectionStart || 0;
165
-
165
+
166
166
  if (shouldPreventManualDash(rawValue)) {
167
167
  handleManualDashRemoval(rawValue, cursorPosition);
168
168
  return;
169
169
  }
170
-
170
+
171
171
  setIsTyping(true);
172
-
172
+
173
173
  const formattedValue = formatInputValue(rawValue);
174
- const finalValue = shouldAutoInsertDash(formattedValue, rawValue)
174
+ const finalValue = shouldAutoInsertDash(formattedValue, rawValue)
175
175
  ? `${formattedValue} - `
176
176
  : formattedValue;
177
-
177
+
178
178
  setInputValue(finalValue);
179
-
179
+
180
180
  const newCursorPosition = calculateNewCursorPosition(
181
181
  rawValue,
182
182
  formattedValue,
183
183
  finalValue,
184
- cursorPosition
184
+ cursorPosition,
185
185
  );
186
-
186
+
187
187
  requestAnimationFrame(() => {
188
188
  setCursorPosition(newCursorPosition);
189
189
  });
190
-
190
+
191
191
  updateParentValue(finalValue);
192
192
  };
193
193
 
194
194
  const shouldPreventManualDash = (value: string): boolean => {
195
- return !disableRange && value.includes('-') && !value.includes(' - ');
195
+ return !disableRange && value.includes("-") && !value.includes(" - ");
196
196
  };
197
197
 
198
- const handleManualDashRemoval = (rawValue: string, cursorPosition: number) => {
199
- const cleanValue = rawValue.replace(/-/g, '');
198
+ const handleManualDashRemoval = (
199
+ rawValue: string,
200
+ cursorPosition: number,
201
+ ) => {
202
+ const cleanValue = rawValue.replace(/-/g, "");
200
203
  const formattedCleanValue = formatInputValue(cleanValue);
201
204
  setInputValue(formattedCleanValue);
202
-
205
+
203
206
  requestAnimationFrame(() => {
204
- const newPosition = Math.min(cursorPosition - 1, formattedCleanValue.length);
207
+ const newPosition = Math.min(
208
+ cursorPosition - 1,
209
+ formattedCleanValue.length,
210
+ );
205
211
  setCursorPosition(newPosition);
206
212
  });
207
213
  };
208
214
 
209
- const shouldAutoInsertDash = (formattedValue: string, rawValue: string): boolean => {
210
- if (disableRange || formattedValue.includes(' - ')) {
215
+ const shouldAutoInsertDash = (
216
+ formattedValue: string,
217
+ rawValue: string,
218
+ ): boolean => {
219
+ if (disableRange || formattedValue.includes(" - ")) {
211
220
  return false;
212
221
  }
213
-
222
+
214
223
  const completeDate = formattedValue.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
215
224
  if (!completeDate || rawValue.length !== formattedValue.length) {
216
225
  return false;
217
226
  }
218
-
227
+
219
228
  // Only add dash if user just completed typing the year
220
229
  const prevLength = rawValue.length - 1;
221
230
  const prevFormatted = formatInputValue(rawValue.slice(0, prevLength));
222
-
231
+
223
232
  return !prevFormatted.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
224
233
  };
225
234
 
@@ -227,13 +236,18 @@ export const DateRangeInput = ({
227
236
  rawValue: string,
228
237
  formattedValue: string,
229
238
  finalValue: string,
230
- originalPosition: number
239
+ originalPosition: number,
231
240
  ): number => {
232
241
  if (finalValue !== formattedValue) {
233
242
  return finalValue.length; // Place cursor after auto-inserted dash
234
243
  }
235
-
236
- return calculateCursorPositionHelper(rawValue, finalValue, originalPosition, disableRange);
244
+
245
+ return calculateCursorPositionHelper(
246
+ rawValue,
247
+ finalValue,
248
+ originalPosition,
249
+ disableRange,
250
+ );
237
251
  };
238
252
 
239
253
  const setCursorPosition = (position: number) => {
@@ -262,7 +276,7 @@ export const DateRangeInput = ({
262
276
  onChange("");
263
277
  return;
264
278
  }
265
-
279
+
266
280
  const rangeMatch = value.match(/^(.+?)\s*-\s*(.+)$/);
267
281
  if (rangeMatch) {
268
282
  updateCompleteRange(rangeMatch);
@@ -275,7 +289,7 @@ export const DateRangeInput = ({
275
289
  const [, fromStr, toStr] = rangeMatch;
276
290
  const fromDate = parseInputDate(fromStr.trim());
277
291
  const toDate = parseInputDate(toStr.trim());
278
-
292
+
279
293
  if (fromDate && toDate && isValidDateRange(fromDate, toDate)) {
280
294
  onChange(`${fromDate}|${toDate}`);
281
295
  }
@@ -290,7 +304,7 @@ export const DateRangeInput = ({
290
304
 
291
305
  const handleBlur = () => {
292
306
  setIsTyping(false);
293
-
307
+
294
308
  // If the input is invalid, revert to the last valid value or empty
295
309
  if (disableRange) {
296
310
  const parsedDate = parseInputDate(inputValue);
@@ -305,7 +319,7 @@ export const DateRangeInput = ({
305
319
  const [, fromStr, toStr] = rangeMatch;
306
320
  const fromDate = parseInputDate(fromStr.trim());
307
321
  const toDate = parseInputDate(toStr.trim());
308
-
322
+
309
323
  // Only accept if both dates are valid AND the range is valid (to >= from)
310
324
  if (!fromDate || !toDate || !isValidDateRange(fromDate, toDate)) {
311
325
  // Invalid range - clear the input
@@ -314,7 +328,7 @@ export const DateRangeInput = ({
314
328
  }
315
329
  } else {
316
330
  // Check if input is just a dash or incomplete second date
317
- if (inputValue.includes(' - ')) {
331
+ if (inputValue.includes(" - ")) {
318
332
  // Has dash but incomplete second date - clear the input
319
333
  setInputValue("");
320
334
  onChange("");
@@ -341,19 +355,20 @@ export const DateRangeInput = ({
341
355
  event.preventDefault();
342
356
  return;
343
357
  }
344
-
358
+
345
359
  if (event.key === "Backspace") {
346
360
  const input = event.target as HTMLInputElement;
347
361
  const cursorPosition = input.selectionStart || 0;
348
362
  const value = input.value;
349
-
363
+
350
364
  // If cursor is right after a slash, move it before the slash
351
365
  if (cursorPosition > 0 && value[cursorPosition - 1] === "/") {
352
366
  event.preventDefault();
353
- const newValue = value.slice(0, cursorPosition - 2) + value.slice(cursorPosition);
367
+ const newValue =
368
+ value.slice(0, cursorPosition - 2) + value.slice(cursorPosition);
354
369
  const formattedValue = formatInputValue(newValue);
355
370
  setInputValue(formattedValue);
356
-
371
+
357
372
  // Set cursor position after the deletion
358
373
  requestAnimationFrame(() => {
359
374
  if (triggerRef.current) {
@@ -361,24 +376,24 @@ export const DateRangeInput = ({
361
376
  triggerRef.current.setSelectionRange(newPosition, newPosition);
362
377
  }
363
378
  });
364
-
379
+
365
380
  setIsTyping(true);
366
381
  return;
367
382
  }
368
-
383
+
369
384
  // Handle deletion when cursor is on or near the dash separator
370
- if (!disableRange && value.includes(' - ')) {
371
- const dashIndex = value.indexOf(' - ');
385
+ if (!disableRange && value.includes(" - ")) {
386
+ const dashIndex = value.indexOf(" - ");
372
387
  const dashStart = dashIndex;
373
388
  const dashEnd = dashIndex + 3; // " - " is 3 characters
374
-
389
+
375
390
  // If cursor is within the dash area (including spaces)
376
391
  if (cursorPosition >= dashStart && cursorPosition <= dashEnd) {
377
392
  event.preventDefault();
378
-
393
+
379
394
  // Remove the entire range and the last digit of the year from the first date
380
395
  const beforeDash = value.slice(0, dashStart).trim();
381
-
396
+
382
397
  // Extract the year part and remove the last digit
383
398
  const yearMatch = beforeDash.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
384
399
  if (yearMatch) {
@@ -387,28 +402,31 @@ export const DateRangeInput = ({
387
402
  const newValue = `${month}/${day}/${truncatedYear}`;
388
403
  const formattedValue = formatInputValue(newValue);
389
404
  setInputValue(formattedValue);
390
-
405
+
391
406
  // Update the value - no valid date yet since year is incomplete
392
407
  onChange("");
393
-
408
+
394
409
  // Position cursor at the end
395
410
  requestAnimationFrame(() => {
396
411
  if (triggerRef.current) {
397
- triggerRef.current.setSelectionRange(formattedValue.length, formattedValue.length);
412
+ triggerRef.current.setSelectionRange(
413
+ formattedValue.length,
414
+ formattedValue.length,
415
+ );
398
416
  }
399
417
  });
400
418
  } else {
401
419
  // Fallback to original behavior
402
420
  const formattedValue = formatInputValue(beforeDash);
403
421
  setInputValue(formattedValue);
404
-
422
+
405
423
  const singleDate = parseInputDate(beforeDash);
406
424
  if (singleDate && isValidDate(singleDate)) {
407
425
  onChange(`${singleDate}|`);
408
426
  } else {
409
427
  onChange("");
410
428
  }
411
-
429
+
412
430
  requestAnimationFrame(() => {
413
431
  if (triggerRef.current) {
414
432
  const newPosition = formattedValue.length;
@@ -416,56 +434,59 @@ export const DateRangeInput = ({
416
434
  }
417
435
  });
418
436
  }
419
-
437
+
420
438
  setIsTyping(true);
421
439
  return;
422
440
  }
423
-
441
+
424
442
  // If cursor is right after the dash, remove the second date
425
443
  if (cursorPosition === dashEnd) {
426
444
  event.preventDefault();
427
-
445
+
428
446
  const beforeDash = value.slice(0, dashStart).trim();
429
447
  const newValue = `${beforeDash} - `;
430
448
  setInputValue(newValue);
431
-
449
+
432
450
  // Update the value to only have the first date as partial range
433
451
  const singleDate = parseInputDate(beforeDash);
434
452
  if (singleDate && isValidDate(singleDate)) {
435
453
  onChange(`${singleDate}|`);
436
454
  }
437
-
455
+
438
456
  // Position cursor after the dash
439
457
  requestAnimationFrame(() => {
440
458
  if (triggerRef.current) {
441
- triggerRef.current.setSelectionRange(newValue.length, newValue.length);
459
+ triggerRef.current.setSelectionRange(
460
+ newValue.length,
461
+ newValue.length,
462
+ );
442
463
  }
443
464
  });
444
-
465
+
445
466
  setIsTyping(true);
446
467
  return;
447
468
  }
448
469
  }
449
470
  }
450
-
471
+
451
472
  if (event.key === "Delete") {
452
473
  const input = event.target as HTMLInputElement;
453
474
  const cursorPosition = input.selectionStart || 0;
454
475
  const value = input.value;
455
-
476
+
456
477
  // Handle deletion when cursor is on or near the dash separator
457
- if (!disableRange && value.includes(' - ')) {
458
- const dashIndex = value.indexOf(' - ');
478
+ if (!disableRange && value.includes(" - ")) {
479
+ const dashIndex = value.indexOf(" - ");
459
480
  const dashStart = dashIndex;
460
481
  const dashEnd = dashIndex + 3; // " - " is 3 characters
461
-
482
+
462
483
  // If cursor is within the dash area or right before it
463
484
  if (cursorPosition >= dashStart && cursorPosition <= dashEnd) {
464
485
  event.preventDefault();
465
-
486
+
466
487
  // Remove the dash and second date, and the last digit of the year from the first date
467
488
  const beforeDash = value.slice(0, dashStart).trim();
468
-
489
+
469
490
  // Extract the year part and remove the last digit
470
491
  const yearMatch = beforeDash.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
471
492
  if (yearMatch) {
@@ -474,28 +495,31 @@ export const DateRangeInput = ({
474
495
  const newValue = `${month}/${day}/${truncatedYear}`;
475
496
  const formattedValue = formatInputValue(newValue);
476
497
  setInputValue(formattedValue);
477
-
498
+
478
499
  // Update the value - no valid date yet since year is incomplete
479
500
  onChange("");
480
-
501
+
481
502
  // Position cursor at the end
482
503
  requestAnimationFrame(() => {
483
504
  if (triggerRef.current) {
484
- triggerRef.current.setSelectionRange(formattedValue.length, formattedValue.length);
505
+ triggerRef.current.setSelectionRange(
506
+ formattedValue.length,
507
+ formattedValue.length,
508
+ );
485
509
  }
486
510
  });
487
511
  } else {
488
512
  // Fallback to original behavior
489
513
  const formattedValue = formatInputValue(beforeDash);
490
514
  setInputValue(formattedValue);
491
-
515
+
492
516
  const singleDate = parseInputDate(beforeDash);
493
517
  if (singleDate && isValidDate(singleDate)) {
494
518
  onChange(`${singleDate}|`);
495
519
  } else {
496
520
  onChange("");
497
521
  }
498
-
522
+
499
523
  requestAnimationFrame(() => {
500
524
  if (triggerRef.current) {
501
525
  const newPosition = formattedValue.length;
@@ -503,13 +527,13 @@ export const DateRangeInput = ({
503
527
  }
504
528
  });
505
529
  }
506
-
530
+
507
531
  setIsTyping(true);
508
532
  return;
509
533
  }
510
534
  }
511
535
  }
512
-
536
+
513
537
  if (event.key === "Enter") {
514
538
  if (disableRange) {
515
539
  const parsedDate = parseInputDate(inputValue);
@@ -525,7 +549,7 @@ export const DateRangeInput = ({
525
549
  const [, fromStr, toStr] = rangeMatch;
526
550
  const fromDate = parseInputDate(fromStr.trim());
527
551
  const toDate = parseInputDate(toStr.trim());
528
-
552
+
529
553
  if (fromDate && toDate && isValidDateRange(fromDate, toDate)) {
530
554
  onChange(`${fromDate}|${toDate}`);
531
555
  setVisible(false);
@@ -617,38 +641,51 @@ function formatInputValueHelper(value: string, disableRange: boolean): string {
617
641
  return formatInputValue(value);
618
642
  }
619
643
 
620
- if (value.includes(' - ')) {
621
- const [from, to] = value.split(' - ');
644
+ if (value.includes(" - ")) {
645
+ const [from, to] = value.split(" - ");
622
646
  const fromFormatted = formatInputValue(from);
623
- const toFormatted = formatInputValue(to || '');
647
+ const toFormatted = formatInputValue(to || "");
624
648
  return `${fromFormatted} - ${toFormatted}`;
625
649
  }
626
-
627
- const cleanValue = value.replace(/-/g, '');
650
+
651
+ const cleanValue = value.replace(/-/g, "");
628
652
  return formatInputValue(cleanValue);
629
653
  }
630
654
 
631
- function calculateCursorPositionHelper(originalValue: string, formattedValue: string, originalPosition: number, disableRange: boolean): number {
655
+ function calculateCursorPositionHelper(
656
+ originalValue: string,
657
+ formattedValue: string,
658
+ originalPosition: number,
659
+ disableRange: boolean,
660
+ ): number {
632
661
  // Handle range input cursor positioning
633
- if (!disableRange && formattedValue.includes(' - ')) {
634
- const dashPosition = formattedValue.indexOf(' - ');
635
- const originalDashPosition = originalValue.indexOf('-');
636
-
662
+ if (!disableRange && formattedValue.includes(" - ")) {
663
+ const dashPosition = formattedValue.indexOf(" - ");
664
+ const originalDashPosition = originalValue.indexOf("-");
665
+
637
666
  // If cursor was after the dash in original, maintain relative position
638
- if (originalDashPosition !== -1 && originalPosition > originalDashPosition) {
639
- const afterDashDigits = originalValue.slice(originalDashPosition + 1).replace(/\D/g, "").length;
667
+ if (
668
+ originalDashPosition !== -1 &&
669
+ originalPosition > originalDashPosition
670
+ ) {
671
+ const afterDashDigits = originalValue
672
+ .slice(originalDashPosition + 1)
673
+ .replace(/\D/g, "").length;
640
674
  const formattedAfterDash = formattedValue.slice(dashPosition + 3);
641
-
675
+
642
676
  let newPosition = dashPosition + 3;
643
677
  let digitCount = 0;
644
-
678
+
645
679
  for (let i = 0; i < formattedAfterDash.length; i++) {
646
680
  if (/\d/.test(formattedAfterDash[i])) {
647
681
  digitCount++;
648
682
  if (digitCount >= afterDashDigits) {
649
683
  // Check if we're at a position where a slash was auto-inserted in the second date
650
684
  // If the next character is a slash, place cursor after it
651
- if (i + 1 < formattedAfterDash.length && formattedAfterDash[i + 1] === '/') {
685
+ if (
686
+ i + 1 < formattedAfterDash.length &&
687
+ formattedAfterDash[i + 1] === "/"
688
+ ) {
652
689
  newPosition = dashPosition + 3 + i + 2;
653
690
  } else {
654
691
  newPosition = dashPosition + 3 + i + 1;
@@ -660,38 +697,46 @@ function calculateCursorPositionHelper(originalValue: string, formattedValue: st
660
697
  newPosition = dashPosition + 3 + i + 1;
661
698
  }
662
699
  }
663
-
700
+
664
701
  return Math.min(newPosition, formattedValue.length);
665
702
  }
666
703
  }
667
-
668
- return calculateCursorPosition(originalValue, formattedValue, originalPosition);
704
+
705
+ return calculateCursorPosition(
706
+ originalValue,
707
+ formattedValue,
708
+ originalPosition,
709
+ );
669
710
  }
670
711
 
671
- function formatDisplayValueHelper(from?: string, to?: string, disableRange?: boolean) {
712
+ function formatDisplayValueHelper(
713
+ from?: string,
714
+ to?: string,
715
+ disableRange?: boolean,
716
+ ) {
672
717
  if (!from && !to) {
673
718
  return "";
674
719
  }
675
-
720
+
676
721
  // Validate dates before displaying
677
722
  const fromValid = from ? isValidDate(from) : false;
678
723
  const toValid = to ? isValidDate(to) : false;
679
-
724
+
680
725
  if (disableRange) {
681
726
  return fromValid && from ? formatDate(from) : "";
682
727
  }
683
-
728
+
684
729
  // Return formatted display if we have a complete, valid range
685
730
  if (fromValid && toValid && from && to && isValidDateRange(from, to)) {
686
731
  return `${formatDate(from)} - ${formatDate(to)}`;
687
732
  }
688
-
733
+
689
734
  // If we have a valid from date but no to date, show the from date only
690
735
  // This preserves the previous valid state during editing
691
736
  if (fromValid && !to && from) {
692
737
  return `${formatDate(from)} - `;
693
738
  }
694
-
739
+
695
740
  // Return empty string if no valid dates or invalid range
696
741
  return "";
697
- }
742
+ }