@bigbinary/neeto-atoms 1.1.9 → 1.1.11
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/{DatePicker-DUx9Qggg.js → DatePicker-DYsyV9BJ.js} +120 -280
- package/dist/DatePicker-DYsyV9BJ.js.map +1 -0
- package/dist/{TranslationProvider-DKdbPweu.js → TranslationProvider-CQyQt55W.js} +2 -4
- package/dist/{TranslationProvider-DKdbPweu.js.map → TranslationProvider-CQyQt55W.js.map} +1 -1
- package/dist/cjs/{DatePicker-DRNGTBHW.js → DatePicker-D6a3J1WA.js} +118 -279
- package/dist/cjs/DatePicker-D6a3J1WA.js.map +1 -0
- package/dist/cjs/{TranslationProvider-Cao2ugzJ.js → TranslationProvider-CJlcb83b.js} +2 -4
- package/dist/cjs/{TranslationProvider-Cao2ugzJ.js.map → TranslationProvider-CJlcb83b.js.map} +1 -1
- package/dist/cjs/components/DatePicker.js +1 -1
- package/dist/cjs/components/TranslationProvider.js +1 -1
- package/dist/cjs/components/index.js +2 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/primitives/AlertDialog.js +7 -39
- package/dist/cjs/primitives/AlertDialog.js.map +1 -1
- package/dist/cjs/primitives/index.js +1 -1
- package/dist/components/DatePicker/RangeTimeSection.d.ts +2 -2
- package/dist/components/DatePicker/TimeInput.d.ts +27 -0
- package/dist/components/DatePicker/TimeSection.d.ts +2 -2
- package/dist/components/DatePicker/timeText.d.ts +32 -0
- package/dist/components/DatePicker.js +1 -1
- package/dist/components/TranslationProvider.js +1 -1
- package/dist/components/index.js +2 -2
- package/dist/index.js +2 -2
- package/dist/translations/index.d.ts +1 -3
- package/package.json +1 -1
- package/dist/DatePicker-DUx9Qggg.js.map +0 -1
- package/dist/cjs/DatePicker-DRNGTBHW.js.map +0 -1
- package/dist/components/DatePicker/SegmentedTimeInput.d.ts +0 -23
- package/dist/components/DatePicker/segmentedTime.d.ts +0 -58
|
@@ -22,7 +22,6 @@ var chevronRight = require('./chevron-right-0jNdwX2Q.js');
|
|
|
22
22
|
|
|
23
23
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
24
|
|
|
25
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
26
25
|
var pureDayjs__default = /*#__PURE__*/_interopDefault(pureDayjs);
|
|
27
26
|
var customParseFormat__default = /*#__PURE__*/_interopDefault(customParseFormat);
|
|
28
27
|
|
|
@@ -501,172 +500,56 @@ const DatePickerTrigger = React.forwardRef(
|
|
|
501
500
|
);
|
|
502
501
|
DatePickerTrigger.displayName = "DatePickerTrigger";
|
|
503
502
|
|
|
504
|
-
const
|
|
505
|
-
const
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
});
|
|
511
|
-
const clampIndex = (index) => Math.max(0, Math.min(2, index));
|
|
512
|
-
const withSegment = (state, key, value) => ({ ...state, [key]: value });
|
|
513
|
-
const snapMinute = (minutes, step = 1) => utils$2.padNumber(Math.min(60 - step, Math.round(Number(minutes) / step) * step));
|
|
514
|
-
const emptySegmentedTime = () => ({
|
|
515
|
-
hour: EMPTY_SEGMENT,
|
|
516
|
-
minute: EMPTY_SEGMENT,
|
|
517
|
-
period: EMPTY_SEGMENT,
|
|
518
|
-
active: 0
|
|
503
|
+
const MINUTES_IN_DAY = 24 * 60;
|
|
504
|
+
const snapMinute = (minutes, step = 1) => Math.min(60 - step, Math.round(minutes / step) * step);
|
|
505
|
+
const snapTimeValue = (value, step = 1) => ({
|
|
506
|
+
hours: value.hours,
|
|
507
|
+
minutes: snapMinute(value.minutes, step),
|
|
508
|
+
seconds: 0
|
|
519
509
|
});
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
minute: segment(snapMinute(value.minutes, step), true),
|
|
525
|
-
period: segment(period, true),
|
|
526
|
-
active: 0
|
|
527
|
-
};
|
|
528
|
-
};
|
|
529
|
-
const isSegmentedTimeEmpty = (state) => SEGMENT_KEYS.every((key) => state[key].text === "");
|
|
530
|
-
const getSegmentedTimeError = (state) => {
|
|
531
|
-
if (isSegmentedTimeEmpty(state)) return "timeRequired";
|
|
532
|
-
if (!state.hour.text) return "hourRequired";
|
|
533
|
-
if (!state.minute.text) return "minuteRequired";
|
|
534
|
-
if (!state.period.text) return "periodRequired";
|
|
535
|
-
return null;
|
|
536
|
-
};
|
|
537
|
-
const segmentedTimeToValue = (state) => {
|
|
538
|
-
if (getSegmentedTimeError(state)) return null;
|
|
539
|
-
return {
|
|
540
|
-
hours: utils$2.to24Hour(Number(state.hour.text), state.period.text),
|
|
541
|
-
minutes: Number(state.minute.text),
|
|
542
|
-
seconds: 0
|
|
543
|
-
};
|
|
544
|
-
};
|
|
545
|
-
const finishSegment = (state, key, step) => {
|
|
546
|
-
const { text } = state[key];
|
|
547
|
-
if (!text) return state;
|
|
548
|
-
if (key === "hour" && text === "0") {
|
|
549
|
-
return withSegment(state, "hour", EMPTY_SEGMENT);
|
|
550
|
-
}
|
|
551
|
-
if (key === "minute" && text.length === 1) {
|
|
552
|
-
return withSegment(
|
|
553
|
-
state,
|
|
554
|
-
"minute",
|
|
555
|
-
segment(snapMinute(text, step), true, true)
|
|
556
|
-
);
|
|
557
|
-
}
|
|
558
|
-
return withSegment(state, key, { ...state[key], done: true });
|
|
510
|
+
const toMinutes = (value) => value.hours * 60 + value.minutes;
|
|
511
|
+
const fromMinutes = (minutes) => {
|
|
512
|
+
const clamped = Math.max(0, Math.min(MINUTES_IN_DAY - 1, minutes));
|
|
513
|
+
return { hours: Math.floor(clamped / 60), minutes: clamped % 60, seconds: 0 };
|
|
559
514
|
};
|
|
560
|
-
const
|
|
561
|
-
const
|
|
562
|
-
const
|
|
563
|
-
|
|
564
|
-
return { ...finished, active: next };
|
|
565
|
-
};
|
|
566
|
-
const focusFirstEmptySegment = (state) => {
|
|
567
|
-
const index = SEGMENT_KEYS.findIndex((key) => !state[key].text);
|
|
568
|
-
return { ...state, active: index === -1 ? 2 : index };
|
|
569
|
-
};
|
|
570
|
-
const nextSegment = (state, step = 1) => state[SEGMENT_KEYS[state.active]].text ? focusSegment(state, state.active + 1, step) : state;
|
|
571
|
-
const previousSegment = (state) => focusSegment(state, state.active - 1);
|
|
572
|
-
const typeDigit = (state, digit, step = 1) => {
|
|
573
|
-
const advance = (next, index) => focusSegment(next, index, step);
|
|
574
|
-
const key = SEGMENT_KEYS[state.active];
|
|
575
|
-
if (key === "period") return state;
|
|
576
|
-
const current = state[key];
|
|
577
|
-
const text = current.done ? "" : current.text;
|
|
578
|
-
if (key === "hour") {
|
|
579
|
-
if (text === "") {
|
|
580
|
-
if (digit === "0" || digit === "1") {
|
|
581
|
-
return withSegment(state, "hour", segment(digit, false));
|
|
582
|
-
}
|
|
583
|
-
return advance(withSegment(state, "hour", segment(digit, true)), 1);
|
|
584
|
-
}
|
|
585
|
-
if (text === "1") {
|
|
586
|
-
if ("012".includes(digit)) {
|
|
587
|
-
return advance(
|
|
588
|
-
withSegment(state, "hour", segment(`1${digit}`, true)),
|
|
589
|
-
1
|
|
590
|
-
);
|
|
591
|
-
}
|
|
592
|
-
const moved = advance(withSegment(state, "hour", segment("1", true)), 1);
|
|
593
|
-
return typeDigit(moved, digit, step);
|
|
594
|
-
}
|
|
595
|
-
if (digit === "0") return state;
|
|
596
|
-
return advance(withSegment(state, "hour", segment(digit, true)), 1);
|
|
597
|
-
}
|
|
598
|
-
if (text === "") {
|
|
599
|
-
if (digit >= "6") {
|
|
600
|
-
return advance(
|
|
601
|
-
withSegment(
|
|
602
|
-
state,
|
|
603
|
-
"minute",
|
|
604
|
-
segment(snapMinute(digit, step), true, true)
|
|
605
|
-
),
|
|
606
|
-
2
|
|
607
|
-
);
|
|
608
|
-
}
|
|
609
|
-
return withSegment(state, "minute", segment(digit, false));
|
|
610
|
-
}
|
|
611
|
-
return advance(
|
|
612
|
-
withSegment(state, "minute", segment(snapMinute(text + digit, step), true)),
|
|
613
|
-
2
|
|
614
|
-
);
|
|
515
|
+
const lastMinuteOfDay = (step = 1) => 23 * 60 + Math.floor(59 / step) * step;
|
|
516
|
+
const formatTimeText = (value) => {
|
|
517
|
+
const { hour12, period } = utils$2.to12Hour(value.hours);
|
|
518
|
+
return `${hour12}:${utils$2.padNumber(value.minutes)} ${period}`;
|
|
615
519
|
};
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
);
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
);
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
const minute = state.minute.text === "" ? direction > 0 ? -step : 0 : Number(state.minute.text);
|
|
635
|
-
const stepped = direction > 0 ? Math.floor(minute / step) * step + step : Math.ceil(minute / step) * step - step;
|
|
636
|
-
return withSegment(
|
|
637
|
-
state,
|
|
638
|
-
"minute",
|
|
639
|
-
segment(utils$2.padNumber((stepped + 60) % 60), true)
|
|
640
|
-
);
|
|
520
|
+
const parseTimeText = (text, step = 1) => {
|
|
521
|
+
const normalized = text.toLowerCase().trim().replace(/(\d)\s+(?=\d)/g, "$1:").replace(/\s+/g, "").replace(/([ap])\.?m?\.?$/, "$1");
|
|
522
|
+
if (!normalized) return null;
|
|
523
|
+
const match = normalized.match(/^(\d{1,4})(?:[:.](\d{0,2}))?([ap])?$/);
|
|
524
|
+
if (!match) return "invalid";
|
|
525
|
+
const [, digits, minuteText, period] = match;
|
|
526
|
+
let hourText = digits;
|
|
527
|
+
let minutes = 0;
|
|
528
|
+
if (minuteText !== void 0) {
|
|
529
|
+
if (digits.length > 2) return "invalid";
|
|
530
|
+
minutes = Number(minuteText.padEnd(2, "0"));
|
|
531
|
+
} else if (digits.length === 4) {
|
|
532
|
+
hourText = digits.slice(0, 2);
|
|
533
|
+
minutes = Number(digits.slice(2));
|
|
534
|
+
} else if (digits.length === 3) {
|
|
535
|
+
const isTwoDigitHour = /^1[0-2][0-5]$/.test(digits);
|
|
536
|
+
hourText = isTwoDigitHour ? digits.slice(0, 2) : digits.slice(0, 1);
|
|
537
|
+
minutes = isTwoDigitHour ? Number(digits[2]) * 10 : Number(digits.slice(1));
|
|
641
538
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
const backspace = (state) => {
|
|
645
|
-
const moveBack = state[SEGMENT_KEYS[state.active]].text === "" && state.active > 0;
|
|
646
|
-
const active = moveBack ? clampIndex(state.active - 1) : state.active;
|
|
647
|
-
const key = SEGMENT_KEYS[active];
|
|
648
|
-
const current = state[key];
|
|
649
|
-
const text = key === "period" || current.auto ? "" : current.text.slice(0, -1);
|
|
650
|
-
return { ...withSegment(state, key, segment(text, false)), active };
|
|
651
|
-
};
|
|
652
|
-
const parsePastedTime = (text, step = 1) => {
|
|
653
|
-
const match = text.trim().toLowerCase().match(/^(\d{1,2}):?(\d{2})?\s*([ap])?\.?m?\.?$/);
|
|
654
|
-
if (!match) return null;
|
|
655
|
-
let hours = Number(match[1]);
|
|
656
|
-
const minutes = Number(match[2] ?? 0);
|
|
657
|
-
const period = match[3];
|
|
658
|
-
if (minutes > 59) return null;
|
|
539
|
+
let hours = Number(hourText);
|
|
540
|
+
if (minutes > 59) return "invalid";
|
|
659
541
|
if (period) {
|
|
660
|
-
if (hours < 1 || hours > 12) return
|
|
661
|
-
hours = hours
|
|
542
|
+
if (hours < 1 || hours > 12) return "invalid";
|
|
543
|
+
hours = utils$2.to24Hour(hours, period === "a" ? "AM" : "PM");
|
|
662
544
|
} else if (hours > 23) {
|
|
663
|
-
return
|
|
545
|
+
return "invalid";
|
|
664
546
|
}
|
|
665
|
-
return { hours, minutes
|
|
547
|
+
return snapTimeValue({ hours, minutes}, step);
|
|
666
548
|
};
|
|
549
|
+
const getTimeTextError = (parsed) => parsed === null ? "timeRequired" : null;
|
|
667
550
|
|
|
668
|
-
const
|
|
669
|
-
const
|
|
551
|
+
const FALLBACK_TIME = { hours: 12, minutes: 0, seconds: 0 };
|
|
552
|
+
const TimeInput = React.forwardRef(
|
|
670
553
|
({
|
|
671
554
|
value,
|
|
672
555
|
minuteStep,
|
|
@@ -680,153 +563,98 @@ const SegmentedTimeInput = React.forwardRef(
|
|
|
680
563
|
"data-testid": dataTestId = "datepicker-time-input"
|
|
681
564
|
}, ref) => {
|
|
682
565
|
const { t } = reactI18next.useTranslation();
|
|
683
|
-
const fieldRef = React.useRef(null);
|
|
684
566
|
const step = minuteStep ?? 1;
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
);
|
|
567
|
+
const inputRef = React.useRef(null);
|
|
568
|
+
const isPointerFocusRef = React.useRef(false);
|
|
688
569
|
const lastEmittedRef = React.useRef(value);
|
|
570
|
+
const [text, setText] = React.useState(
|
|
571
|
+
() => formatTimeText(snapTimeValue(value, step))
|
|
572
|
+
);
|
|
573
|
+
const emit = (next) => {
|
|
574
|
+
if (utils$2.timeValueEquals(next, lastEmittedRef.current)) return;
|
|
575
|
+
lastEmittedRef.current = next;
|
|
576
|
+
onChange(next);
|
|
577
|
+
};
|
|
689
578
|
React.useEffect(() => {
|
|
690
579
|
if (utils$2.timeValueEquals(value, lastEmittedRef.current)) return;
|
|
691
580
|
lastEmittedRef.current = value;
|
|
692
|
-
|
|
581
|
+
setText(formatTimeText(value));
|
|
582
|
+
onErrorChange(null);
|
|
693
583
|
}, [value]);
|
|
694
|
-
const error = getSegmentedTimeError(time);
|
|
695
584
|
React.useEffect(() => {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
React.useEffect(() => {
|
|
699
|
-
const snapped = segmentedTimeToValue(time);
|
|
700
|
-
if (snapped && !utils$2.timeValueEquals(snapped, value)) {
|
|
701
|
-
lastEmittedRef.current = snapped;
|
|
702
|
-
onChange(snapped);
|
|
703
|
-
}
|
|
585
|
+
const snapped = snapTimeValue(value, step);
|
|
586
|
+
if (!utils$2.timeValueEquals(snapped, value)) emit(snapped);
|
|
704
587
|
}, []);
|
|
588
|
+
const focusAndSelect = () => {
|
|
589
|
+
inputRef.current?.focus();
|
|
590
|
+
inputRef.current?.select();
|
|
591
|
+
};
|
|
705
592
|
React.useEffect(() => {
|
|
706
|
-
if (autoFocus)
|
|
593
|
+
if (autoFocus) focusAndSelect();
|
|
707
594
|
}, [autoFocus]);
|
|
708
|
-
React.useImperativeHandle(ref, () => ({
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
setTime(next);
|
|
716
|
-
const nextValue = segmentedTimeToValue(next);
|
|
717
|
-
if (!nextValue || utils$2.timeValueEquals(nextValue, lastEmittedRef.current)) {
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
lastEmittedRef.current = nextValue;
|
|
721
|
-
onChange(nextValue);
|
|
595
|
+
React.useImperativeHandle(ref, () => ({ focus: focusAndSelect }));
|
|
596
|
+
const handleChange = (event) => {
|
|
597
|
+
const nextText = event.target.value;
|
|
598
|
+
setText(nextText);
|
|
599
|
+
const parsed = parseTimeText(nextText, step);
|
|
600
|
+
onErrorChange(getTimeTextError(parsed));
|
|
601
|
+
if (parsed !== null && parsed !== "invalid") emit(parsed);
|
|
722
602
|
};
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
|
|
603
|
+
const tidy = () => {
|
|
604
|
+
const parsed = parseTimeText(text, step);
|
|
605
|
+
if (parsed === null) return;
|
|
606
|
+
const next = parsed === "invalid" ? FALLBACK_TIME : parsed;
|
|
607
|
+
setText(formatTimeText(next));
|
|
608
|
+
onErrorChange(null);
|
|
609
|
+
emit(next);
|
|
726
610
|
};
|
|
727
611
|
const handleKeyDown = (event) => {
|
|
728
|
-
|
|
729
|
-
if (key === "Tab") {
|
|
730
|
-
if (!event.shiftKey || time.active !== 2) return;
|
|
731
|
-
consume(event);
|
|
732
|
-
update(togglePeriod(time));
|
|
733
|
-
return;
|
|
734
|
-
}
|
|
735
|
-
if ((event.metaKey || event.ctrlKey) && key === "Backspace") {
|
|
736
|
-
consume(event);
|
|
737
|
-
update(emptySegmentedTime());
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
if (event.metaKey || event.ctrlKey || event.altKey) return;
|
|
741
|
-
let next = null;
|
|
742
|
-
if (/^[0-9]$/.test(key)) next = typeDigit(time, key, step);
|
|
743
|
-
else if (/^[ap]$/i.test(key)) {
|
|
744
|
-
next = typePeriod(time, key.toLowerCase(), step);
|
|
745
|
-
} else if (/^m$/i.test(key))
|
|
746
|
-
next = time;
|
|
747
|
-
else if (key === ":" || key === " " || key === "ArrowRight") {
|
|
748
|
-
next = nextSegment(time, step);
|
|
749
|
-
} else if (key === "ArrowLeft") next = previousSegment(time);
|
|
750
|
-
else if (key === "ArrowUp") next = stepSegment(time, 1, step);
|
|
751
|
-
else if (key === "ArrowDown") next = stepSegment(time, -1, step);
|
|
752
|
-
else if (key === "Backspace" || key === "Delete") next = backspace(time);
|
|
753
|
-
if (!next) return;
|
|
754
|
-
consume(event);
|
|
755
|
-
update(next);
|
|
756
|
-
};
|
|
757
|
-
const handlePaste = (event) => {
|
|
612
|
+
if (event.key !== "Enter") return;
|
|
758
613
|
event.preventDefault();
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
update({ ...segmentedTimeFromValue(pasted, step), active: 2 });
|
|
762
|
-
};
|
|
763
|
-
const handleMouseDown = (event) => {
|
|
764
|
-
if (disabled) return;
|
|
765
|
-
const segmentEl = event.target.closest(
|
|
766
|
-
"[data-segment]"
|
|
767
|
-
);
|
|
768
|
-
if (segmentEl) {
|
|
769
|
-
event.preventDefault();
|
|
770
|
-
fieldRef.current?.focus();
|
|
771
|
-
update(focusSegment(time, Number(segmentEl.dataset.segment), step));
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
update(focusFirstEmptySegment(time));
|
|
614
|
+
event.stopPropagation();
|
|
615
|
+
tidy();
|
|
775
616
|
};
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
return index < 2 && !done ? `${text}_` : text;
|
|
617
|
+
const handleFocus = () => {
|
|
618
|
+
if (!isPointerFocusRef.current) inputRef.current?.select();
|
|
619
|
+
isPointerFocusRef.current = false;
|
|
780
620
|
};
|
|
781
621
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
782
|
-
"
|
|
622
|
+
"input",
|
|
783
623
|
{
|
|
784
|
-
ref:
|
|
785
|
-
role: "group",
|
|
786
|
-
tabIndex: disabled ? -1 : 0,
|
|
787
|
-
"aria-label": ariaLabel ?? t("neetoatoms.datePicker.timeField", "Time"),
|
|
624
|
+
ref: inputRef,
|
|
788
625
|
"aria-describedby": ariaDescribedBy,
|
|
789
626
|
"aria-invalid": invalid || void 0,
|
|
790
|
-
"aria-
|
|
627
|
+
"aria-label": ariaLabel ?? t("neetoatoms.datePicker.timeField", "Time"),
|
|
628
|
+
autoComplete: "off",
|
|
791
629
|
"data-testid": dataTestId,
|
|
630
|
+
disabled,
|
|
631
|
+
placeholder: t("neetoatoms.datePicker.timePlaceholder", "Time"),
|
|
632
|
+
spellCheck: false,
|
|
633
|
+
type: "text",
|
|
634
|
+
value: text,
|
|
792
635
|
className: utils$1.cn(
|
|
793
|
-
"
|
|
636
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm tabular-nums outline-none placeholder:text-muted-foreground",
|
|
794
637
|
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
795
638
|
invalid && "border-destructive",
|
|
796
|
-
disabled && "
|
|
639
|
+
disabled && "cursor-not-allowed opacity-50"
|
|
797
640
|
),
|
|
798
|
-
onBlur:
|
|
641
|
+
onBlur: tidy,
|
|
642
|
+
onChange: handleChange,
|
|
643
|
+
onFocus: handleFocus,
|
|
799
644
|
onKeyDown: handleKeyDown,
|
|
800
|
-
onMouseDown:
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
806
|
-
"span",
|
|
807
|
-
{
|
|
808
|
-
"data-segment": index,
|
|
809
|
-
"data-testid": `datepicker-time-${key}`,
|
|
810
|
-
className: utils$1.cn(
|
|
811
|
-
"min-w-[2ch] px-0.5 text-center whitespace-pre",
|
|
812
|
-
!time[key].text && "text-muted-foreground",
|
|
813
|
-
index === time.active && "group-focus/time:shadow-[inset_0_-1.5px_0_var(--color-muted-foreground)]"
|
|
814
|
-
),
|
|
815
|
-
children: segmentText(index)
|
|
816
|
-
}
|
|
817
|
-
)
|
|
818
|
-
] }, key))
|
|
645
|
+
onMouseDown: () => {
|
|
646
|
+
if (document.activeElement !== inputRef.current) {
|
|
647
|
+
isPointerFocusRef.current = true;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
819
650
|
}
|
|
820
651
|
);
|
|
821
652
|
}
|
|
822
653
|
);
|
|
823
|
-
|
|
654
|
+
TimeInput.displayName = "TimeInput";
|
|
824
655
|
|
|
825
656
|
const ERROR_DEFAULTS = {
|
|
826
|
-
timeRequired: "Enter a time, or turn off Add time."
|
|
827
|
-
hourRequired: "Enter an hour.",
|
|
828
|
-
minuteRequired: "Enter minutes.",
|
|
829
|
-
periodRequired: "Type a or p for AM or PM."
|
|
657
|
+
timeRequired: "Enter a time, or turn off Add time."
|
|
830
658
|
};
|
|
831
659
|
const stepExamples = (step) => {
|
|
832
660
|
const pad = (minutes) => `1:${String(minutes).padStart(2, "0")}`;
|
|
@@ -897,7 +725,7 @@ const TimeSection = ({
|
|
|
897
725
|
] }),
|
|
898
726
|
isTimeOn && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
899
727
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
900
|
-
|
|
728
|
+
TimeInput,
|
|
901
729
|
{
|
|
902
730
|
"aria-describedby": [showHint ? hintId : null, errorMessage ? errorId : null].filter(Boolean).join(" ") || void 0,
|
|
903
731
|
autoFocus: focusOnMount,
|
|
@@ -1046,6 +874,7 @@ const RangeCalendar = ({
|
|
|
1046
874
|
}
|
|
1047
875
|
) });
|
|
1048
876
|
|
|
877
|
+
const SAME_DAY_END_GAP = 30;
|
|
1049
878
|
const ENDPOINT_LABELS = {
|
|
1050
879
|
from: "Start",
|
|
1051
880
|
to: "End"
|
|
@@ -1091,12 +920,21 @@ const RangeTimeSection = ({
|
|
|
1091
920
|
[handleErrorChange]
|
|
1092
921
|
);
|
|
1093
922
|
const showHint = (minuteStep ?? 1) > 1;
|
|
923
|
+
const handleFromChange = (value) => {
|
|
924
|
+
onFromChange(value);
|
|
925
|
+
if (!isEndOnStartDay) return;
|
|
926
|
+
const step = minuteStep ?? 1;
|
|
927
|
+
const gap = Math.ceil(SAME_DAY_END_GAP / step) * step;
|
|
928
|
+
onToChange(
|
|
929
|
+
fromMinutes(Math.min(toMinutes(value) + gap, lastMinuteOfDay(step)))
|
|
930
|
+
);
|
|
931
|
+
};
|
|
1094
932
|
const endpoints = [
|
|
1095
933
|
{
|
|
1096
934
|
endpoint: "from",
|
|
1097
935
|
dateLabel: fromDateLabel,
|
|
1098
936
|
value: fromValue,
|
|
1099
|
-
onChange:
|
|
937
|
+
onChange: handleFromChange,
|
|
1100
938
|
onFieldErrorChange: handleFromErrorChange
|
|
1101
939
|
},
|
|
1102
940
|
{
|
|
@@ -1144,7 +982,7 @@ const RangeTimeSection = ({
|
|
|
1144
982
|
}
|
|
1145
983
|
),
|
|
1146
984
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1147
|
-
|
|
985
|
+
TimeInput,
|
|
1148
986
|
{
|
|
1149
987
|
"aria-describedby": [
|
|
1150
988
|
showHint ? hintId : null,
|
|
@@ -1888,7 +1726,7 @@ const DatePicker = React.forwardRef(
|
|
|
1888
1726
|
const handleRangeCalendarKeyDown = (e) => {
|
|
1889
1727
|
if (e.key !== "Tab" || e.shiftKey || !draftRange) return;
|
|
1890
1728
|
e.preventDefault();
|
|
1891
|
-
fromTimeRef.current?.
|
|
1729
|
+
fromTimeRef.current?.focus();
|
|
1892
1730
|
};
|
|
1893
1731
|
const handleGridPickerSelect = (date) => {
|
|
1894
1732
|
commitValue(date);
|
|
@@ -1968,7 +1806,8 @@ const DatePicker = React.forwardRef(
|
|
|
1968
1806
|
primitives_Popover.PopoverContent,
|
|
1969
1807
|
{
|
|
1970
1808
|
id: popoverContentId,
|
|
1971
|
-
className: "w-auto p-0",
|
|
1809
|
+
className: "max-h-(--radix-popover-content-available-height) w-auto overflow-y-auto p-0",
|
|
1810
|
+
collisionPadding: 8,
|
|
1972
1811
|
align,
|
|
1973
1812
|
side,
|
|
1974
1813
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
@@ -2115,4 +1954,4 @@ const DatePicker = React.forwardRef(
|
|
|
2115
1954
|
DatePicker.displayName = "DatePicker";
|
|
2116
1955
|
|
|
2117
1956
|
exports.DatePicker = DatePicker;
|
|
2118
|
-
//# sourceMappingURL=DatePicker-
|
|
1957
|
+
//# sourceMappingURL=DatePicker-D6a3J1WA.js.map
|