@ttt-productions/ui-core 0.11.33 → 0.11.35
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/README.md +1 -1
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +1 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/reload-recovery-watch.d.ts +2 -6
- package/dist/browser/reload-recovery-watch.d.ts.map +1 -1
- package/dist/browser/reload-recovery-watch.js +5 -10
- package/dist/browser/reload-recovery-watch.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/format-numbers.d.ts +0 -6
- package/dist/lib/format-numbers.d.ts.map +1 -1
- package/dist/lib/format-numbers.js +2 -8
- package/dist/lib/format-numbers.js.map +1 -1
- package/dist/lib/reload-recovery.d.ts +1 -9
- package/dist/lib/reload-recovery.d.ts.map +1 -1
- package/dist/lib/reload-recovery.js +14 -24
- package/dist/lib/reload-recovery.js.map +1 -1
- package/dist/lib/utils.d.ts +0 -3
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +0 -3
- package/dist/lib/utils.js.map +1 -1
- package/dist/react/components/accordion.d.ts +2 -2
- package/dist/react/components/accordion.d.ts.map +1 -1
- package/dist/react/components/accordion.js +8 -8
- package/dist/react/components/accordion.js.map +1 -1
- package/dist/react/components/action-row.d.ts +2 -9
- package/dist/react/components/action-row.d.ts.map +1 -1
- package/dist/react/components/action-row.js +7 -11
- package/dist/react/components/action-row.js.map +1 -1
- package/dist/react/components/alert-dialog.d.ts +2 -2
- package/dist/react/components/alert-dialog.d.ts.map +1 -1
- package/dist/react/components/alert-dialog.js +15 -15
- package/dist/react/components/alert-dialog.js.map +1 -1
- package/dist/react/components/alert.d.ts +2 -2
- package/dist/react/components/alert.d.ts.map +1 -1
- package/dist/react/components/alert.js +12 -12
- package/dist/react/components/alert.js.map +1 -1
- package/dist/react/components/avatar.d.ts +2 -2
- package/dist/react/components/avatar.d.ts.map +1 -1
- package/dist/react/components/avatar.js +7 -7
- package/dist/react/components/avatar.js.map +1 -1
- package/dist/react/components/badge.d.ts +2 -2
- package/dist/react/components/badge.d.ts.map +1 -1
- package/dist/react/components/badge.js +9 -9
- package/dist/react/components/badge.js.map +1 -1
- package/dist/react/components/button.d.ts +2 -12
- package/dist/react/components/button.d.ts.map +1 -1
- package/dist/react/components/button.js +30 -35
- package/dist/react/components/button.js.map +1 -1
- package/dist/react/components/card.d.ts +1 -1
- package/dist/react/components/card.d.ts.map +1 -1
- package/dist/react/components/card.js +15 -15
- package/dist/react/components/card.js.map +1 -1
- package/dist/react/components/checkbox.d.ts +2 -2
- package/dist/react/components/checkbox.d.ts.map +1 -1
- package/dist/react/components/checkbox.js +6 -6
- package/dist/react/components/checkbox.js.map +1 -1
- package/dist/react/components/collapsible.d.ts +1 -1
- package/dist/react/components/collapsible.d.ts.map +1 -1
- package/dist/react/components/collapsible.js +2 -2
- package/dist/react/components/collapsible.js.map +1 -1
- package/dist/react/components/consequence-dialog.d.ts +1 -48
- package/dist/react/components/consequence-dialog.d.ts.map +1 -1
- package/dist/react/components/consequence-dialog.js +7 -23
- package/dist/react/components/consequence-dialog.js.map +1 -1
- package/dist/react/components/date-picker.d.ts +1 -18
- package/dist/react/components/date-picker.d.ts.map +1 -1
- package/dist/react/components/date-picker.js +102 -98
- package/dist/react/components/date-picker.js.map +1 -1
- package/dist/react/components/date-time-picker.d.ts +1 -24
- package/dist/react/components/date-time-picker.d.ts.map +1 -1
- package/dist/react/components/date-time-picker.js +20 -37
- package/dist/react/components/date-time-picker.js.map +1 -1
- package/dist/react/components/dialog.d.ts +2 -2
- package/dist/react/components/dialog.d.ts.map +1 -1
- package/dist/react/components/dialog.js +14 -14
- package/dist/react/components/dialog.js.map +1 -1
- package/dist/react/components/dropdown-menu.d.ts +2 -10
- package/dist/react/components/dropdown-menu.d.ts.map +1 -1
- package/dist/react/components/dropdown-menu.js +24 -20
- package/dist/react/components/dropdown-menu.js.map +1 -1
- package/dist/react/components/end-of-list-indicator.d.ts +1 -1
- package/dist/react/components/end-of-list-indicator.js +3 -3
- package/dist/react/components/end-of-list-indicator.js.map +1 -1
- package/dist/react/components/form.d.ts +3 -3
- package/dist/react/components/form.d.ts.map +1 -1
- package/dist/react/components/form.js +17 -17
- package/dist/react/components/form.js.map +1 -1
- package/dist/react/components/format-control.d.ts +7 -20
- package/dist/react/components/format-control.d.ts.map +1 -1
- package/dist/react/components/format-control.js +18 -22
- package/dist/react/components/format-control.js.map +1 -1
- package/dist/react/components/input.d.ts +10 -27
- package/dist/react/components/input.d.ts.map +1 -1
- package/dist/react/components/input.js +11 -9
- package/dist/react/components/input.js.map +1 -1
- package/dist/react/components/label.d.ts +3 -3
- package/dist/react/components/label.d.ts.map +1 -1
- package/dist/react/components/label.js +6 -6
- package/dist/react/components/label.js.map +1 -1
- package/dist/react/components/layout/screen-adaptive-view.d.ts +2 -9
- package/dist/react/components/layout/screen-adaptive-view.d.ts.map +1 -1
- package/dist/react/components/layout/screen-adaptive-view.js +40 -37
- package/dist/react/components/layout/screen-adaptive-view.js.map +1 -1
- package/dist/react/components/list-pagination.d.ts +1 -31
- package/dist/react/components/list-pagination.d.ts.map +1 -1
- package/dist/react/components/list-pagination.js +10 -37
- package/dist/react/components/list-pagination.js.map +1 -1
- package/dist/react/components/menubar.d.ts +2 -2
- package/dist/react/components/menubar.d.ts.map +1 -1
- package/dist/react/components/menubar.js +17 -17
- package/dist/react/components/menubar.js.map +1 -1
- package/dist/react/components/opener-focus.d.ts +2 -8
- package/dist/react/components/opener-focus.d.ts.map +1 -1
- package/dist/react/components/opener-focus.js +4 -10
- package/dist/react/components/opener-focus.js.map +1 -1
- package/dist/react/components/pending-guard.d.ts +1 -7
- package/dist/react/components/pending-guard.d.ts.map +1 -1
- package/dist/react/components/pending-guard.js +1 -7
- package/dist/react/components/pending-guard.js.map +1 -1
- package/dist/react/components/popover.d.ts +2 -2
- package/dist/react/components/popover.d.ts.map +1 -1
- package/dist/react/components/popover.js +5 -5
- package/dist/react/components/popover.js.map +1 -1
- package/dist/react/components/progress.d.ts +2 -2
- package/dist/react/components/progress.d.ts.map +1 -1
- package/dist/react/components/progress.js +5 -5
- package/dist/react/components/progress.js.map +1 -1
- package/dist/react/components/radio-group.d.ts +2 -2
- package/dist/react/components/radio-group.d.ts.map +1 -1
- package/dist/react/components/radio-group.js +7 -7
- package/dist/react/components/radio-group.js.map +1 -1
- package/dist/react/components/relative-time.d.ts +1 -9
- package/dist/react/components/relative-time.d.ts.map +1 -1
- package/dist/react/components/relative-time.js +8 -11
- package/dist/react/components/relative-time.js.map +1 -1
- package/dist/react/components/reload-recovery-notice.d.ts +3 -17
- package/dist/react/components/reload-recovery-notice.d.ts.map +1 -1
- package/dist/react/components/reload-recovery-notice.js +7 -12
- package/dist/react/components/reload-recovery-notice.js.map +1 -1
- package/dist/react/components/scroll-area.d.ts +2 -2
- package/dist/react/components/scroll-area.d.ts.map +1 -1
- package/dist/react/components/scroll-area.js +6 -8
- package/dist/react/components/scroll-area.js.map +1 -1
- package/dist/react/components/scroll-to-top-button.d.ts +6 -30
- package/dist/react/components/scroll-to-top-button.d.ts.map +1 -1
- package/dist/react/components/scroll-to-top-button.js +9 -9
- package/dist/react/components/scroll-to-top-button.js.map +1 -1
- package/dist/react/components/search-dropdown.d.ts +0 -53
- package/dist/react/components/search-dropdown.d.ts.map +1 -1
- package/dist/react/components/search-dropdown.js +10 -39
- package/dist/react/components/search-dropdown.js.map +1 -1
- package/dist/react/components/select.d.ts +2 -9
- package/dist/react/components/select.d.ts.map +1 -1
- package/dist/react/components/select.js +19 -21
- package/dist/react/components/select.js.map +1 -1
- package/dist/react/components/separator.d.ts +2 -2
- package/dist/react/components/separator.d.ts.map +1 -1
- package/dist/react/components/separator.js +5 -5
- package/dist/react/components/separator.js.map +1 -1
- package/dist/react/components/sheet.d.ts +3 -3
- package/dist/react/components/sheet.d.ts.map +1 -1
- package/dist/react/components/sheet.js +21 -21
- package/dist/react/components/sheet.js.map +1 -1
- package/dist/react/components/show-more-toggle.d.ts +2 -18
- package/dist/react/components/show-more-toggle.d.ts.map +1 -1
- package/dist/react/components/show-more-toggle.js +6 -11
- package/dist/react/components/show-more-toggle.js.map +1 -1
- package/dist/react/components/skeleton.d.ts +1 -1
- package/dist/react/components/skeleton.d.ts.map +1 -1
- package/dist/react/components/skeleton.js +3 -3
- package/dist/react/components/skeleton.js.map +1 -1
- package/dist/react/components/slider.d.ts +2 -2
- package/dist/react/components/slider.d.ts.map +1 -1
- package/dist/react/components/slider.js +5 -5
- package/dist/react/components/slider.js.map +1 -1
- package/dist/react/components/spinner.d.ts +1 -15
- package/dist/react/components/spinner.d.ts.map +1 -1
- package/dist/react/components/spinner.js +10 -18
- package/dist/react/components/spinner.js.map +1 -1
- package/dist/react/components/switch.d.ts +2 -9
- package/dist/react/components/switch.d.ts.map +1 -1
- package/dist/react/components/switch.js +13 -10
- package/dist/react/components/switch.js.map +1 -1
- package/dist/react/components/table.d.ts +2 -12
- package/dist/react/components/table.d.ts.map +1 -1
- package/dist/react/components/table.js +24 -30
- package/dist/react/components/table.js.map +1 -1
- package/dist/react/components/tabs.d.ts +2 -2
- package/dist/react/components/tabs.d.ts.map +1 -1
- package/dist/react/components/tabs.js +7 -7
- package/dist/react/components/tabs.js.map +1 -1
- package/dist/react/components/textarea.d.ts +5 -16
- package/dist/react/components/textarea.d.ts.map +1 -1
- package/dist/react/components/textarea.js +11 -9
- package/dist/react/components/textarea.js.map +1 -1
- package/dist/react/components/toast.d.ts +4 -8
- package/dist/react/components/toast.d.ts.map +1 -1
- package/dist/react/components/toast.js +26 -47
- package/dist/react/components/toast.js.map +1 -1
- package/dist/react/components/toaster.d.ts.map +1 -1
- package/dist/react/components/toaster.js +5 -5
- package/dist/react/components/toaster.js.map +1 -1
- package/dist/react/components/tooltip.d.ts +2 -2
- package/dist/react/components/tooltip.d.ts.map +1 -1
- package/dist/react/components/tooltip.js +5 -5
- package/dist/react/components/tooltip.js.map +1 -1
- package/dist/react/hooks/use-async-action.d.ts +1 -21
- package/dist/react/hooks/use-async-action.d.ts.map +1 -1
- package/dist/react/hooks/use-async-action.js +3 -11
- package/dist/react/hooks/use-async-action.js.map +1 -1
- package/dist/react/hooks/use-cursor-page.d.ts +1 -63
- package/dist/react/hooks/use-cursor-page.d.ts.map +1 -1
- package/dist/react/hooks/use-cursor-page.js +3 -39
- package/dist/react/hooks/use-cursor-page.js.map +1 -1
- package/dist/react/hooks/use-media-query.js +5 -5
- package/dist/react/hooks/use-media-query.js.map +1 -1
- package/dist/react/hooks/use-paged-list.d.ts +0 -43
- package/dist/react/hooks/use-paged-list.d.ts.map +1 -1
- package/dist/react/hooks/use-paged-list.js +2 -17
- package/dist/react/hooks/use-paged-list.js.map +1 -1
- package/dist/react/hooks/use-return-scroll.d.ts +1 -10
- package/dist/react/hooks/use-return-scroll.d.ts.map +1 -1
- package/dist/react/hooks/use-return-scroll.js +13 -45
- package/dist/react/hooks/use-return-scroll.js.map +1 -1
- package/dist/react/hooks/use-toast.d.ts +3 -11
- package/dist/react/hooks/use-toast.d.ts.map +1 -1
- package/dist/react/hooks/use-toast.js +18 -21
- package/dist/react/hooks/use-toast.js.map +1 -1
- package/dist/react/index.d.ts +74 -74
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +51 -57
- package/dist/react/index.js.map +1 -1
- package/package.json +8 -6
|
@@ -1,23 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from
|
|
4
|
-
import { ChevronLeft, ChevronRight } from
|
|
5
|
-
import { Button } from
|
|
6
|
-
import { cn } from
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
5
|
+
import { Button } from './button.js';
|
|
6
|
+
import { cn } from '../../lib/utils.js';
|
|
7
7
|
const MONTHS = [
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
'January',
|
|
9
|
+
'February',
|
|
10
|
+
'March',
|
|
11
|
+
'April',
|
|
12
|
+
'May',
|
|
13
|
+
'June',
|
|
14
|
+
'July',
|
|
15
|
+
'August',
|
|
16
|
+
'September',
|
|
17
|
+
'October',
|
|
18
|
+
'November',
|
|
19
|
+
'December',
|
|
10
20
|
];
|
|
11
21
|
const MONTHS_SHORT = [
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
'Jan',
|
|
23
|
+
'Feb',
|
|
24
|
+
'Mar',
|
|
25
|
+
'Apr',
|
|
26
|
+
'May',
|
|
27
|
+
'Jun',
|
|
28
|
+
'Jul',
|
|
29
|
+
'Aug',
|
|
30
|
+
'Sep',
|
|
31
|
+
'Oct',
|
|
32
|
+
'Nov',
|
|
33
|
+
'Dec',
|
|
34
|
+
];
|
|
35
|
+
const DAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
36
|
+
const DAY_NAMES_LONG = [
|
|
37
|
+
'Sunday',
|
|
38
|
+
'Monday',
|
|
39
|
+
'Tuesday',
|
|
40
|
+
'Wednesday',
|
|
41
|
+
'Thursday',
|
|
42
|
+
'Friday',
|
|
43
|
+
'Saturday',
|
|
14
44
|
];
|
|
15
|
-
const DAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
16
|
-
const DAY_NAMES_LONG = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
17
45
|
const YEARS_PER_PAGE = 12;
|
|
18
|
-
/** Six rows × seven columns — a calendar month never spans more, and always
|
|
19
|
-
* filling six rows keeps the day grid (and therefore the whole popover
|
|
20
|
-
* footprint) the same height for every month. */
|
|
21
46
|
const CALENDAR_CELLS = 42;
|
|
22
47
|
const startOfDay = (d) => {
|
|
23
48
|
const x = new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
@@ -26,30 +51,15 @@ const startOfDay = (d) => {
|
|
|
26
51
|
const monthStart = (year, month) => new Date(year, month, 1);
|
|
27
52
|
const addMonths = (d, n) => new Date(d.getFullYear(), d.getMonth() + n, 1);
|
|
28
53
|
const daysInMonth = (year, month) => new Date(year, month + 1, 0).getDate();
|
|
29
|
-
const isSameDay = (a, b) => a.getFullYear() === b.getFullYear() &&
|
|
54
|
+
const isSameDay = (a, b) => a.getFullYear() === b.getFullYear() &&
|
|
55
|
+
a.getMonth() === b.getMonth() &&
|
|
56
|
+
a.getDate() === b.getDate();
|
|
30
57
|
const isSameMonth = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
|
|
31
58
|
const fullDateLabel = (date) => `${MONTHS[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
|
|
32
|
-
/**
|
|
33
|
-
* Generic date-of-birth-friendly calendar.
|
|
34
|
-
*
|
|
35
|
-
* Stable footprint: the six-row day grid is always rendered, so the outer width
|
|
36
|
-
* and content height never change; the month and year choosers render as an
|
|
37
|
-
* overlay ON TOP of that grid rather than replacing it, so a Radix popover never
|
|
38
|
-
* flips sides just because the internal view changed.
|
|
39
|
-
*
|
|
40
|
-
* Month and year are INDEPENDENT pickers: choosing a month keeps the current
|
|
41
|
-
* year and returns to the day grid; choosing a year keeps the current month and
|
|
42
|
-
* returns DIRECTLY to the day grid (it never opens the month grid). Only
|
|
43
|
-
* choosing a day calls `onSelect` (which commits and, in a popover, closes).
|
|
44
|
-
*
|
|
45
|
-
* Keyboard: roving day focus with Arrow (±1 day / ±7 days), Home/End (within the
|
|
46
|
-
* week), PageUp/PageDown (±1 month), and Enter/Space to select — no extra
|
|
47
|
-
* dependency. Exactly one day sits in the tab order at a time.
|
|
48
|
-
*/
|
|
49
59
|
function DatePicker({ selected, onSelect, disabled, disablePast = false, disableFuture = false, className, }) {
|
|
50
60
|
const today = React.useMemo(() => startOfDay(new Date()), []);
|
|
51
61
|
const [viewDate, setViewDate] = React.useState(() => monthStart((selected ?? today).getFullYear(), (selected ?? today).getMonth()));
|
|
52
|
-
const [view, setView] = React.useState(
|
|
62
|
+
const [view, setView] = React.useState('days');
|
|
53
63
|
const [yearPageStart, setYearPageStart] = React.useState(() => Math.floor((selected ?? today).getFullYear() / YEARS_PER_PAGE) * YEARS_PER_PAGE);
|
|
54
64
|
const [focusedDate, setFocusedDate] = React.useState(() => startOfDay(selected ?? today));
|
|
55
65
|
const monthTriggerRef = React.useRef(null);
|
|
@@ -67,7 +77,6 @@ function DatePicker({ selected, onSelect, disabled, disablePast = false, disable
|
|
|
67
77
|
return true;
|
|
68
78
|
return false;
|
|
69
79
|
};
|
|
70
|
-
/** A whole month is unpickable only when every day in it is out of range. */
|
|
71
80
|
const isMonthDisabled = (year, month) => {
|
|
72
81
|
if (disableFuture && new Date(year, month, 1) > today)
|
|
73
82
|
return true;
|
|
@@ -88,10 +97,8 @@ function DatePicker({ selected, onSelect, disabled, disablePast = false, disable
|
|
|
88
97
|
return false;
|
|
89
98
|
return true;
|
|
90
99
|
};
|
|
91
|
-
const isSelectedDay = (date) =>
|
|
100
|
+
const isSelectedDay = (date) => selected ? isSameDay(startOfDay(selected), startOfDay(date)) : false;
|
|
92
101
|
const isTodayDate = (date) => isSameDay(startOfDay(date), today);
|
|
93
|
-
/** The best in-month day to seed roving focus: the selected day, then today,
|
|
94
|
-
* then the first available day, then the 1st. */
|
|
95
102
|
const pickInMonthFocus = (vd) => {
|
|
96
103
|
const year = vd.getFullYear();
|
|
97
104
|
const month = vd.getMonth();
|
|
@@ -110,8 +117,6 @@ function DatePicker({ selected, onSelect, disabled, disablePast = false, disable
|
|
|
110
117
|
}
|
|
111
118
|
return new Date(year, month, 1);
|
|
112
119
|
};
|
|
113
|
-
// Resynchronize the visible month/year (and roving focus) when the controlled
|
|
114
|
-
// `selected` prop changes — e.g. the consumer's typed MM/DD/YYYY fields.
|
|
115
120
|
const selectedTime = selected ? startOfDay(selected).getTime() : undefined;
|
|
116
121
|
React.useEffect(() => {
|
|
117
122
|
if (selectedTime === undefined)
|
|
@@ -120,24 +125,23 @@ function DatePicker({ selected, onSelect, disabled, disablePast = false, disable
|
|
|
120
125
|
setViewDate(monthStart(d.getFullYear(), d.getMonth()));
|
|
121
126
|
setFocusedDate(startOfDay(d));
|
|
122
127
|
}, [selectedTime]);
|
|
123
|
-
// Deliberate focus after every view transition — never left on document.body.
|
|
124
128
|
React.useLayoutEffect(() => {
|
|
125
129
|
const target = pendingFocusRef.current;
|
|
126
130
|
if (!target)
|
|
127
131
|
return;
|
|
128
132
|
pendingFocusRef.current = null;
|
|
129
|
-
if (target ===
|
|
133
|
+
if (target === 'monthTrigger') {
|
|
130
134
|
monthTriggerRef.current?.focus();
|
|
131
135
|
}
|
|
132
|
-
else if (target ===
|
|
136
|
+
else if (target === 'yearTrigger') {
|
|
133
137
|
yearTriggerRef.current?.focus();
|
|
134
138
|
}
|
|
135
|
-
else if (target ===
|
|
139
|
+
else if (target === 'day') {
|
|
136
140
|
daysGridRef.current?.querySelector('[data-roving="true"]')?.focus();
|
|
137
141
|
}
|
|
138
|
-
else if (target ===
|
|
142
|
+
else if (target === 'monthGrid' || target === 'yearGrid') {
|
|
139
143
|
const active = overlayRef.current?.querySelector('[data-active="true"]:not([disabled])');
|
|
140
|
-
const fallback = overlayRef.current?.querySelector(
|
|
144
|
+
const fallback = overlayRef.current?.querySelector('button:not([disabled])');
|
|
141
145
|
(active ?? fallback)?.focus();
|
|
142
146
|
}
|
|
143
147
|
});
|
|
@@ -167,10 +171,8 @@ function DatePicker({ selected, onSelect, disabled, disablePast = false, disable
|
|
|
167
171
|
setFocusedDate(d);
|
|
168
172
|
if (!isSameMonth(d, viewDate))
|
|
169
173
|
setViewDate(monthStart(d.getFullYear(), d.getMonth()));
|
|
170
|
-
pendingFocusRef.current =
|
|
174
|
+
pendingFocusRef.current = 'day';
|
|
171
175
|
};
|
|
172
|
-
/** From `origin`, walk `step` days at a time until an available day is found
|
|
173
|
-
* (inclusive of `origin`). Returns null if none within `maxSteps`. */
|
|
174
176
|
const firstAvailableFrom = (origin, step, maxSteps) => {
|
|
175
177
|
let d = startOfDay(origin);
|
|
176
178
|
for (let i = 0; i < maxSteps; i++) {
|
|
@@ -185,44 +187,44 @@ function DatePicker({ selected, onSelect, disabled, disablePast = false, disable
|
|
|
185
187
|
let candidate;
|
|
186
188
|
let probeStep;
|
|
187
189
|
switch (e.key) {
|
|
188
|
-
case
|
|
190
|
+
case 'ArrowLeft':
|
|
189
191
|
candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() - 1);
|
|
190
192
|
probeStep = -1;
|
|
191
193
|
break;
|
|
192
|
-
case
|
|
194
|
+
case 'ArrowRight':
|
|
193
195
|
candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 1);
|
|
194
196
|
probeStep = 1;
|
|
195
197
|
break;
|
|
196
|
-
case
|
|
198
|
+
case 'ArrowUp':
|
|
197
199
|
candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() - 7);
|
|
198
200
|
probeStep = -1;
|
|
199
201
|
break;
|
|
200
|
-
case
|
|
202
|
+
case 'ArrowDown':
|
|
201
203
|
candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 7);
|
|
202
204
|
probeStep = 1;
|
|
203
205
|
break;
|
|
204
|
-
case
|
|
206
|
+
case 'Home':
|
|
205
207
|
candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() - base.getDay());
|
|
206
208
|
probeStep = 1;
|
|
207
209
|
break;
|
|
208
|
-
case
|
|
210
|
+
case 'End':
|
|
209
211
|
candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + (6 - base.getDay()));
|
|
210
212
|
probeStep = -1;
|
|
211
213
|
break;
|
|
212
|
-
case
|
|
214
|
+
case 'PageUp': {
|
|
213
215
|
const prev = addMonths(base, -1);
|
|
214
216
|
candidate = new Date(prev.getFullYear(), prev.getMonth(), Math.min(base.getDate(), daysInMonth(prev.getFullYear(), prev.getMonth())));
|
|
215
217
|
probeStep = 1;
|
|
216
218
|
break;
|
|
217
219
|
}
|
|
218
|
-
case
|
|
220
|
+
case 'PageDown': {
|
|
219
221
|
const next = addMonths(base, 1);
|
|
220
222
|
candidate = new Date(next.getFullYear(), next.getMonth(), Math.min(base.getDate(), daysInMonth(next.getFullYear(), next.getMonth())));
|
|
221
223
|
probeStep = 1;
|
|
222
224
|
break;
|
|
223
225
|
}
|
|
224
|
-
case
|
|
225
|
-
case
|
|
226
|
+
case 'Enter':
|
|
227
|
+
case ' ':
|
|
226
228
|
e.preventDefault();
|
|
227
229
|
commitDay(base);
|
|
228
230
|
return;
|
|
@@ -236,25 +238,23 @@ function DatePicker({ selected, onSelect, disabled, disablePast = false, disable
|
|
|
236
238
|
if (target)
|
|
237
239
|
moveFocusTo(target);
|
|
238
240
|
};
|
|
239
|
-
// Header prev/next adapt to the active view; disabled when the whole target
|
|
240
|
-
// range is unavailable so navigation never lands on a dead page.
|
|
241
241
|
const prevMonthDate = addMonths(viewDate, -1);
|
|
242
242
|
const nextMonthDate = addMonths(viewDate, 1);
|
|
243
243
|
let prevDisabled;
|
|
244
244
|
let nextDisabled;
|
|
245
245
|
let prevLabel;
|
|
246
246
|
let nextLabel;
|
|
247
|
-
if (view ===
|
|
247
|
+
if (view === 'days') {
|
|
248
248
|
prevDisabled = isMonthDisabled(prevMonthDate.getFullYear(), prevMonthDate.getMonth());
|
|
249
249
|
nextDisabled = isMonthDisabled(nextMonthDate.getFullYear(), nextMonthDate.getMonth());
|
|
250
|
-
prevLabel =
|
|
251
|
-
nextLabel =
|
|
250
|
+
prevLabel = 'Previous month';
|
|
251
|
+
nextLabel = 'Next month';
|
|
252
252
|
}
|
|
253
|
-
else if (view ===
|
|
253
|
+
else if (view === 'months') {
|
|
254
254
|
prevDisabled = isYearDisabled(viewDate.getFullYear() - 1);
|
|
255
255
|
nextDisabled = isYearDisabled(viewDate.getFullYear() + 1);
|
|
256
|
-
prevLabel =
|
|
257
|
-
nextLabel =
|
|
256
|
+
prevLabel = 'Previous year';
|
|
257
|
+
nextLabel = 'Next year';
|
|
258
258
|
}
|
|
259
259
|
else {
|
|
260
260
|
prevDisabled = rangeAllYearsDisabled(yearPageStart - YEARS_PER_PAGE, yearPageStart - 1);
|
|
@@ -263,62 +263,60 @@ function DatePicker({ selected, onSelect, disabled, disablePast = false, disable
|
|
|
263
263
|
nextLabel = `Next ${YEARS_PER_PAGE} years`;
|
|
264
264
|
}
|
|
265
265
|
const handlePrev = () => {
|
|
266
|
-
if (view ===
|
|
266
|
+
if (view === 'days')
|
|
267
267
|
setViewDate(prevMonthDate);
|
|
268
|
-
else if (view ===
|
|
268
|
+
else if (view === 'months')
|
|
269
269
|
setViewDate(monthStart(viewDate.getFullYear() - 1, viewDate.getMonth()));
|
|
270
270
|
else
|
|
271
271
|
setYearPageStart((s) => s - YEARS_PER_PAGE);
|
|
272
272
|
};
|
|
273
273
|
const handleNext = () => {
|
|
274
|
-
if (view ===
|
|
274
|
+
if (view === 'days')
|
|
275
275
|
setViewDate(nextMonthDate);
|
|
276
|
-
else if (view ===
|
|
276
|
+
else if (view === 'months')
|
|
277
277
|
setViewDate(monthStart(viewDate.getFullYear() + 1, viewDate.getMonth()));
|
|
278
278
|
else
|
|
279
279
|
setYearPageStart((s) => s + YEARS_PER_PAGE);
|
|
280
280
|
};
|
|
281
281
|
const openMonths = () => {
|
|
282
|
-
if (view ===
|
|
283
|
-
setView(
|
|
284
|
-
pendingFocusRef.current =
|
|
282
|
+
if (view === 'months') {
|
|
283
|
+
setView('days');
|
|
284
|
+
pendingFocusRef.current = 'monthTrigger';
|
|
285
285
|
}
|
|
286
286
|
else {
|
|
287
|
-
setView(
|
|
288
|
-
pendingFocusRef.current =
|
|
287
|
+
setView('months');
|
|
288
|
+
pendingFocusRef.current = 'monthGrid';
|
|
289
289
|
}
|
|
290
290
|
};
|
|
291
291
|
const openYears = () => {
|
|
292
|
-
if (view ===
|
|
293
|
-
setView(
|
|
294
|
-
pendingFocusRef.current =
|
|
292
|
+
if (view === 'years') {
|
|
293
|
+
setView('days');
|
|
294
|
+
pendingFocusRef.current = 'yearTrigger';
|
|
295
295
|
}
|
|
296
296
|
else {
|
|
297
297
|
setYearPageStart(Math.floor(viewDate.getFullYear() / YEARS_PER_PAGE) * YEARS_PER_PAGE);
|
|
298
|
-
setView(
|
|
299
|
-
pendingFocusRef.current =
|
|
298
|
+
setView('years');
|
|
299
|
+
pendingFocusRef.current = 'yearGrid';
|
|
300
300
|
}
|
|
301
301
|
};
|
|
302
|
-
// Month selection: keep the year, return to days, focus the Month trigger.
|
|
303
302
|
const handleMonthPick = (month) => {
|
|
304
303
|
setViewDate(monthStart(viewDate.getFullYear(), month));
|
|
305
|
-
setView(
|
|
306
|
-
pendingFocusRef.current =
|
|
304
|
+
setView('days');
|
|
305
|
+
pendingFocusRef.current = 'monthTrigger';
|
|
307
306
|
};
|
|
308
|
-
// Year selection: keep the month, return to days (never months), focus Year.
|
|
309
307
|
const handleYearPick = (year) => {
|
|
310
308
|
setViewDate(monthStart(year, viewDate.getMonth()));
|
|
311
|
-
setView(
|
|
312
|
-
pendingFocusRef.current =
|
|
309
|
+
setView('days');
|
|
310
|
+
pendingFocusRef.current = 'yearTrigger';
|
|
313
311
|
};
|
|
314
312
|
const calendarDays = generateCalendarDays();
|
|
315
313
|
const yearPage = Array.from({ length: YEARS_PER_PAGE }, (_, i) => yearPageStart + i);
|
|
316
|
-
const overlayActive = view !==
|
|
317
|
-
const triggerClass =
|
|
318
|
-
|
|
319
|
-
const gridCellClass =
|
|
320
|
-
|
|
321
|
-
return (_jsxs("div", { className: cn(
|
|
314
|
+
const overlayActive = view !== 'days';
|
|
315
|
+
const triggerClass = 'min-h-[1.5rem] px-1 text-base font-bold text-foreground underline decoration-1 underline-offset-4 decoration-border rounded-sm ' +
|
|
316
|
+
'hover:opacity-80 transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background';
|
|
317
|
+
const gridCellClass = 'h-10 rounded-lg text-sm font-semibold transition-transform flex items-center justify-center ' +
|
|
318
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background';
|
|
319
|
+
return (_jsxs("div", { className: cn('p-4 bg-card rounded-lg', className), children: [_jsxs("div", { className: "flex items-center justify-between mb-4", children: [_jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 p-0", "aria-label": prevLabel, disabled: prevDisabled, onClick: handlePrev, children: _jsx(ChevronLeft, { className: "h-4 w-4", "aria-hidden": "true" }) }), _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx("button", { ref: monthTriggerRef, type: "button", onClick: openMonths, "aria-expanded": view === 'months', "aria-label": `Choose month, currently ${MONTHS[viewDate.getMonth()]}`, className: triggerClass, children: MONTHS[viewDate.getMonth()] }), _jsx("button", { ref: yearTriggerRef, type: "button", onClick: openYears, "aria-expanded": view === 'years', "aria-label": `Choose year, currently ${viewDate.getFullYear()}`, className: triggerClass, children: viewDate.getFullYear() })] }), _jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 p-0", "aria-label": nextLabel, disabled: nextDisabled, onClick: handleNext, children: _jsx(ChevronRight, { className: "h-4 w-4", "aria-hidden": "true" }) })] }), _jsxs("div", { "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: [MONTHS[viewDate.getMonth()], " ", viewDate.getFullYear()] }), _jsxs("div", { className: "relative", children: [_jsxs("div", { "aria-hidden": overlayActive ? true : undefined, children: [_jsx("div", { className: "grid grid-cols-7 gap-1 mb-2", children: DAYS.map((day, i) => (_jsxs("div", { className: "text-center text-sm font-bold py-2 text-foreground", "aria-hidden": "true", children: [_jsx("span", { className: "sr-only", children: DAY_NAMES_LONG[i] }), _jsx("span", { "aria-hidden": "true", children: day })] }, day))) }), _jsx("div", { ref: daysGridRef, className: "grid grid-cols-7 gap-1", role: "group", "aria-label": "Calendar", onKeyDown: overlayActive ? undefined : handleDaysKeyDown, children: calendarDays.map((date, index) => {
|
|
322
320
|
if (!date)
|
|
323
321
|
return _jsx("div", { className: "h-9", "aria-hidden": "true" }, `empty-${index}`);
|
|
324
322
|
const dateDisabled = isDateDisabled(date);
|
|
@@ -326,17 +324,23 @@ function DatePicker({ selected, onSelect, disabled, disablePast = false, disable
|
|
|
326
324
|
const todayDate = isTodayDate(date);
|
|
327
325
|
const roving = isSameDay(date, rovingDate);
|
|
328
326
|
const tabIndex = !overlayActive && roving ? 0 : -1;
|
|
329
|
-
return (_jsxs("button", { type: "button", onClick: () => commitDay(date), disabled: dateDisabled, tabIndex: tabIndex, "data-roving": roving ?
|
|
330
|
-
|
|
327
|
+
return (_jsxs("button", { type: "button", onClick: () => commitDay(date), disabled: dateDisabled, tabIndex: tabIndex, "data-roving": roving ? 'true' : undefined, "aria-label": fullDateLabel(date), "aria-pressed": dateSelected, "aria-current": todayDate ? 'date' : undefined, className: cn('h-9 w-9 rounded-lg text-sm font-semibold transition-transform', 'motion-safe:hover:scale-105 motion-safe:active:scale-95', 'flex items-center justify-center', 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background', !dateDisabled &&
|
|
328
|
+
!dateSelected &&
|
|
329
|
+
!todayDate &&
|
|
330
|
+
'text-foreground hover:bg-primary/10', todayDate &&
|
|
331
|
+
!dateSelected &&
|
|
332
|
+
'bg-accent text-accent-foreground font-bold ring-2 ring-border', dateSelected && 'bg-primary text-primary-foreground font-bold', dateDisabled &&
|
|
333
|
+
'opacity-30 cursor-not-allowed motion-safe:hover:scale-100 hover:bg-transparent relative'), children: [date.getDate(), dateDisabled && (_jsx("span", { className: "absolute inset-0 flex items-center justify-center", "aria-hidden": "true", children: _jsx("span", { className: "w-px h-full bg-current transform rotate-45" }) }))] }, date.toISOString()));
|
|
334
|
+
}) }), _jsxs("div", { className: "mt-4 pt-3 border-t border-border text-xs space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "h-3 w-3 rounded-sm bg-primary", "aria-hidden": "true" }), _jsx("span", { className: "text-muted-foreground", children: "Selected" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "h-3 w-3 rounded-sm bg-accent ring-2 ring-border", "aria-hidden": "true" }), _jsx("span", { className: "text-muted-foreground", children: "Today" })] }), (disablePast || disableFuture || disabled) && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "h-3 w-3 rounded-sm bg-muted opacity-30 relative", "aria-hidden": "true", children: _jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: _jsx("div", { className: "w-px h-full bg-foreground transform rotate-45" }) }) }), _jsx("span", { className: "text-muted-foreground", children: "Unavailable" })] }))] })] }), overlayActive && (_jsxs("div", { ref: overlayRef, className: "absolute inset-0 bg-card rounded-lg flex flex-col justify-center", children: [view === 'years' && (_jsxs("div", { className: "mb-2 text-center text-sm font-semibold text-muted-foreground", "aria-hidden": "true", children: [yearPageStart, " \u2013 ", yearPageStart + YEARS_PER_PAGE - 1] })), view === 'months' && (_jsx("div", { className: "grid grid-cols-3 gap-1", children: MONTHS_SHORT.map((label, month) => {
|
|
331
335
|
const monthDisabled = isMonthDisabled(viewDate.getFullYear(), month);
|
|
332
336
|
const isViewMonth = month === viewDate.getMonth();
|
|
333
|
-
return (_jsx("button", { type: "button", disabled: monthDisabled, "data-active": isViewMonth ?
|
|
334
|
-
}) })), view ===
|
|
337
|
+
return (_jsx("button", { type: "button", disabled: monthDisabled, "data-active": isViewMonth ? 'true' : undefined, "aria-pressed": isViewMonth, "aria-label": `${MONTHS[month]} ${viewDate.getFullYear()}`, onClick: () => handleMonthPick(month), className: cn(gridCellClass, !monthDisabled && !isViewMonth && 'text-foreground hover:bg-primary/10', isViewMonth && 'bg-primary text-primary-foreground font-bold', monthDisabled && 'opacity-30 cursor-not-allowed'), children: label }, label));
|
|
338
|
+
}) })), view === 'years' && (_jsx("div", { className: "grid grid-cols-3 gap-1", children: yearPage.map((year) => {
|
|
335
339
|
const yearDisabled = isYearDisabled(year);
|
|
336
340
|
const isViewYear = year === viewDate.getFullYear();
|
|
337
|
-
return (_jsx("button", { type: "button", disabled: yearDisabled, "data-active": isViewYear ?
|
|
341
|
+
return (_jsx("button", { type: "button", disabled: yearDisabled, "data-active": isViewYear ? 'true' : undefined, "aria-pressed": isViewYear, "aria-label": `Year ${year}`, onClick: () => handleYearPick(year), className: cn(gridCellClass, !yearDisabled && !isViewYear && 'text-foreground hover:bg-primary/10', isViewYear && 'bg-primary text-primary-foreground font-bold', yearDisabled && 'opacity-30 cursor-not-allowed'), children: year }, year));
|
|
338
342
|
}) }))] }))] })] }));
|
|
339
343
|
}
|
|
340
|
-
DatePicker.displayName =
|
|
344
|
+
DatePicker.displayName = 'DatePicker';
|
|
341
345
|
export { DatePicker };
|
|
342
346
|
//# sourceMappingURL=date-picker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.js","sourceRoot":"","sources":["../../../src/react/components/date-picker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AAWvC,MAAM,MAAM,GAAG;IACb,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM;IACtD,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU;CACjE,CAAA;AAED,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;IACxC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EA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AAY,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;oCACzC,MAAM,UAAU,GAAG,IAAI,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAA;oCAClD,OAAO,CACL,iBAEE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,YAAY,iBACT,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,kBAC9B,UAAU,gBACZ,QAAQ,IAAI,EAAE,EAC1B,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EACnC,SAAS,EAAE,EAAE,CACX,aAAa,EACb,CAAC,YAAY,IAAI,CAAC,UAAU,IAAI,qCAAqC,EACrE,UAAU,IAAI,8CAA8C,EAC5D,YAAY,IAAI,+BAA+B,CAChD,YAEA,IAAI,IAdA,IAAI,CAeF,CACV,CAAA;gCACH,CAAC,CAAC,GACE,CACP,IACG,CACP,IACG,IACF,CACP,CAAA;AACH,CAAC;AAED,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,CAAA","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronLeft, ChevronRight } from \"lucide-react\"\nimport { Button } from \"./button.js\"\nimport { cn } from \"../../lib/utils.js\"\n\nexport interface DatePickerProps {\n selected?: Date\n onSelect?: (date: Date | undefined) => void\n disabled?: (date: Date) => boolean\n disablePast?: boolean\n disableFuture?: boolean\n className?: string\n}\n\nconst MONTHS = [\n \"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n \"July\", \"August\", \"September\", \"October\", \"November\", \"December\",\n]\n\nconst MONTHS_SHORT = [\n \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\",\n]\n\nconst DAYS = [\"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\"]\nconst DAY_NAMES_LONG = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"]\n\nconst YEARS_PER_PAGE = 12\n/** Six rows × seven columns — a calendar month never spans more, and always\n * filling six rows keeps the day grid (and therefore the whole popover\n * footprint) the same height for every month. */\nconst CALENDAR_CELLS = 42\n\ntype View = \"days\" | \"months\" | \"years\"\ntype PendingFocus = \"day\" | \"monthTrigger\" | \"yearTrigger\" | \"monthGrid\" | \"yearGrid\"\n\nconst startOfDay = (d: Date) => {\n const x = new Date(d.getFullYear(), d.getMonth(), d.getDate())\n return x\n}\nconst monthStart = (year: number, month: number) => new Date(year, month, 1)\nconst addMonths = (d: Date, n: number) => new Date(d.getFullYear(), d.getMonth() + n, 1)\nconst daysInMonth = (year: number, month: number) => new Date(year, month + 1, 0).getDate()\nconst isSameDay = (a: Date, b: Date) =>\n a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate()\nconst isSameMonth = (a: Date, b: Date) =>\n a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth()\nconst fullDateLabel = (date: Date) => `${MONTHS[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`\n\n/**\n * Generic date-of-birth-friendly calendar.\n *\n * Stable footprint: the six-row day grid is always rendered, so the outer width\n * and content height never change; the month and year choosers render as an\n * overlay ON TOP of that grid rather than replacing it, so a Radix popover never\n * flips sides just because the internal view changed.\n *\n * Month and year are INDEPENDENT pickers: choosing a month keeps the current\n * year and returns to the day grid; choosing a year keeps the current month and\n * returns DIRECTLY to the day grid (it never opens the month grid). Only\n * choosing a day calls `onSelect` (which commits and, in a popover, closes).\n *\n * Keyboard: roving day focus with Arrow (±1 day / ±7 days), Home/End (within the\n * week), PageUp/PageDown (±1 month), and Enter/Space to select — no extra\n * dependency. Exactly one day sits in the tab order at a time.\n */\nfunction DatePicker({\n selected,\n onSelect,\n disabled,\n disablePast = false,\n disableFuture = false,\n className,\n}: DatePickerProps) {\n const today = React.useMemo(() => startOfDay(new Date()), [])\n\n const [viewDate, setViewDate] = React.useState(() =>\n monthStart((selected ?? today).getFullYear(), (selected ?? today).getMonth()),\n )\n const [view, setView] = React.useState<View>(\"days\")\n const [yearPageStart, setYearPageStart] = React.useState(\n () => Math.floor((selected ?? today).getFullYear() / YEARS_PER_PAGE) * YEARS_PER_PAGE,\n )\n const [focusedDate, setFocusedDate] = React.useState(() => startOfDay(selected ?? today))\n\n const monthTriggerRef = React.useRef<HTMLButtonElement | null>(null)\n const yearTriggerRef = React.useRef<HTMLButtonElement | null>(null)\n const daysGridRef = React.useRef<HTMLDivElement | null>(null)\n const overlayRef = React.useRef<HTMLDivElement | null>(null)\n const pendingFocusRef = React.useRef<PendingFocus | null>(null)\n\n const isDateDisabled = (date: Date) => {\n const checkDate = startOfDay(date)\n if (disablePast && checkDate < today) return true\n if (disableFuture && checkDate > today) return true\n if (disabled && disabled(checkDate)) return true\n return false\n }\n\n /** A whole month is unpickable only when every day in it is out of range. */\n const isMonthDisabled = (year: number, month: number) => {\n if (disableFuture && new Date(year, month, 1) > today) return true\n if (disablePast && new Date(year, month + 1, 0) < today) return true\n return false\n }\n\n const isYearDisabled = (year: number) => {\n if (disableFuture && year > today.getFullYear()) return true\n if (disablePast && year < today.getFullYear()) return true\n return false\n }\n\n const rangeAllYearsDisabled = (from: number, to: number) => {\n for (let y = from; y <= to; y++) if (!isYearDisabled(y)) return false\n return true\n }\n\n const isSelectedDay = (date: Date) => (selected ? isSameDay(startOfDay(selected), startOfDay(date)) : false)\n const isTodayDate = (date: Date) => isSameDay(startOfDay(date), today)\n\n /** The best in-month day to seed roving focus: the selected day, then today,\n * then the first available day, then the 1st. */\n const pickInMonthFocus = (vd: Date): Date => {\n const year = vd.getFullYear()\n const month = vd.getMonth()\n if (selected) {\n const s = startOfDay(selected)\n if (isSameMonth(s, vd) && !isDateDisabled(s)) return s\n }\n if (isSameMonth(today, vd) && !isDateDisabled(today)) return new Date(today)\n const dim = daysInMonth(year, month)\n for (let d = 1; d <= dim; d++) {\n const cand = new Date(year, month, d)\n if (!isDateDisabled(cand)) return cand\n }\n return new Date(year, month, 1)\n }\n\n // Resynchronize the visible month/year (and roving focus) when the controlled\n // `selected` prop changes — e.g. the consumer's typed MM/DD/YYYY fields.\n const selectedTime = selected ? startOfDay(selected).getTime() : undefined\n React.useEffect(() => {\n if (selectedTime === undefined) return\n const d = new Date(selectedTime)\n setViewDate(monthStart(d.getFullYear(), d.getMonth()))\n setFocusedDate(startOfDay(d))\n }, [selectedTime])\n\n // Deliberate focus after every view transition — never left on document.body.\n React.useLayoutEffect(() => {\n const target = pendingFocusRef.current\n if (!target) return\n pendingFocusRef.current = null\n if (target === \"monthTrigger\") {\n monthTriggerRef.current?.focus()\n } else if (target === \"yearTrigger\") {\n yearTriggerRef.current?.focus()\n } else if (target === \"day\") {\n daysGridRef.current?.querySelector<HTMLButtonElement>('[data-roving=\"true\"]')?.focus()\n } else if (target === \"monthGrid\" || target === \"yearGrid\") {\n const active = overlayRef.current?.querySelector<HTMLButtonElement>('[data-active=\"true\"]:not([disabled])')\n const fallback = overlayRef.current?.querySelector<HTMLButtonElement>(\"button:not([disabled])\")\n ;(active ?? fallback)?.focus()\n }\n })\n\n const generateCalendarDays = (): (Date | null)[] => {\n const year = viewDate.getFullYear()\n const month = viewDate.getMonth()\n const dim = daysInMonth(year, month)\n const firstDay = new Date(year, month, 1).getDay()\n const days: (Date | null)[] = []\n for (let i = 0; i < firstDay; i++) days.push(null)\n for (let day = 1; day <= dim; day++) days.push(new Date(year, month, day))\n while (days.length < CALENDAR_CELLS) days.push(null)\n return days\n }\n\n const inViewMonth = isSameMonth(focusedDate, viewDate)\n const rovingDate = inViewMonth ? focusedDate : pickInMonthFocus(viewDate)\n\n const commitDay = (date: Date) => {\n if (isDateDisabled(date)) return\n onSelect?.(date)\n }\n\n const moveFocusTo = (date: Date) => {\n const d = startOfDay(date)\n setFocusedDate(d)\n if (!isSameMonth(d, viewDate)) setViewDate(monthStart(d.getFullYear(), d.getMonth()))\n pendingFocusRef.current = \"day\"\n }\n\n /** From `origin`, walk `step` days at a time until an available day is found\n * (inclusive of `origin`). Returns null if none within `maxSteps`. */\n const firstAvailableFrom = (origin: Date, step: number, maxSteps: number): Date | null => {\n let d = startOfDay(origin)\n for (let i = 0; i < maxSteps; i++) {\n if (!isDateDisabled(d)) return d\n d = new Date(d.getFullYear(), d.getMonth(), d.getDate() + step)\n }\n return null\n }\n\n const handleDaysKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n const base = rovingDate\n let candidate: Date\n let probeStep: number\n\n switch (e.key) {\n case \"ArrowLeft\":\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() - 1)\n probeStep = -1\n break\n case \"ArrowRight\":\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 1)\n probeStep = 1\n break\n case \"ArrowUp\":\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() - 7)\n probeStep = -1\n break\n case \"ArrowDown\":\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 7)\n probeStep = 1\n break\n case \"Home\":\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() - base.getDay())\n probeStep = 1\n break\n case \"End\":\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + (6 - base.getDay()))\n probeStep = -1\n break\n case \"PageUp\": {\n const prev = addMonths(base, -1)\n candidate = new Date(\n prev.getFullYear(),\n prev.getMonth(),\n Math.min(base.getDate(), daysInMonth(prev.getFullYear(), prev.getMonth())),\n )\n probeStep = 1\n break\n }\n case \"PageDown\": {\n const next = addMonths(base, 1)\n candidate = new Date(\n next.getFullYear(),\n next.getMonth(),\n Math.min(base.getDate(), daysInMonth(next.getFullYear(), next.getMonth())),\n )\n probeStep = 1\n break\n }\n case \"Enter\":\n case \" \":\n e.preventDefault()\n commitDay(base)\n return\n default:\n return\n }\n\n e.preventDefault()\n let target = firstAvailableFrom(candidate, probeStep, 62)\n if (!target && probeStep !== -1) target = firstAvailableFrom(candidate, -1, 62)\n if (target) moveFocusTo(target)\n }\n\n // Header prev/next adapt to the active view; disabled when the whole target\n // range is unavailable so navigation never lands on a dead page.\n const prevMonthDate = addMonths(viewDate, -1)\n const nextMonthDate = addMonths(viewDate, 1)\n\n let prevDisabled: boolean\n let nextDisabled: boolean\n let prevLabel: string\n let nextLabel: string\n\n if (view === \"days\") {\n prevDisabled = isMonthDisabled(prevMonthDate.getFullYear(), prevMonthDate.getMonth())\n nextDisabled = isMonthDisabled(nextMonthDate.getFullYear(), nextMonthDate.getMonth())\n prevLabel = \"Previous month\"\n nextLabel = \"Next month\"\n } else if (view === \"months\") {\n prevDisabled = isYearDisabled(viewDate.getFullYear() - 1)\n nextDisabled = isYearDisabled(viewDate.getFullYear() + 1)\n prevLabel = \"Previous year\"\n nextLabel = \"Next year\"\n } else {\n prevDisabled = rangeAllYearsDisabled(yearPageStart - YEARS_PER_PAGE, yearPageStart - 1)\n nextDisabled = rangeAllYearsDisabled(yearPageStart + YEARS_PER_PAGE, yearPageStart + YEARS_PER_PAGE * 2 - 1)\n prevLabel = `Previous ${YEARS_PER_PAGE} years`\n nextLabel = `Next ${YEARS_PER_PAGE} years`\n }\n\n const handlePrev = () => {\n if (view === \"days\") setViewDate(prevMonthDate)\n else if (view === \"months\") setViewDate(monthStart(viewDate.getFullYear() - 1, viewDate.getMonth()))\n else setYearPageStart((s) => s - YEARS_PER_PAGE)\n }\n const handleNext = () => {\n if (view === \"days\") setViewDate(nextMonthDate)\n else if (view === \"months\") setViewDate(monthStart(viewDate.getFullYear() + 1, viewDate.getMonth()))\n else setYearPageStart((s) => s + YEARS_PER_PAGE)\n }\n\n const openMonths = () => {\n if (view === \"months\") {\n setView(\"days\")\n pendingFocusRef.current = \"monthTrigger\"\n } else {\n setView(\"months\")\n pendingFocusRef.current = \"monthGrid\"\n }\n }\n const openYears = () => {\n if (view === \"years\") {\n setView(\"days\")\n pendingFocusRef.current = \"yearTrigger\"\n } else {\n setYearPageStart(Math.floor(viewDate.getFullYear() / YEARS_PER_PAGE) * YEARS_PER_PAGE)\n setView(\"years\")\n pendingFocusRef.current = \"yearGrid\"\n }\n }\n\n // Month selection: keep the year, return to days, focus the Month trigger.\n const handleMonthPick = (month: number) => {\n setViewDate(monthStart(viewDate.getFullYear(), month))\n setView(\"days\")\n pendingFocusRef.current = \"monthTrigger\"\n }\n // Year selection: keep the month, return to days (never months), focus Year.\n const handleYearPick = (year: number) => {\n setViewDate(monthStart(year, viewDate.getMonth()))\n setView(\"days\")\n pendingFocusRef.current = \"yearTrigger\"\n }\n\n const calendarDays = generateCalendarDays()\n const yearPage = Array.from({ length: YEARS_PER_PAGE }, (_, i) => yearPageStart + i)\n const overlayActive = view !== \"days\"\n\n const triggerClass =\n \"min-h-[1.5rem] px-1 text-base font-bold text-foreground underline decoration-1 underline-offset-4 decoration-border rounded-sm \" +\n \"hover:opacity-80 transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\"\n\n const gridCellClass =\n \"h-10 rounded-lg text-sm font-semibold transition-transform flex items-center justify-center \" +\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\"\n\n return (\n <div className={cn(\"p-4 bg-card rounded-lg\", className)}>\n {/* Header — same footprint in every view. */}\n <div className=\"flex items-center justify-between mb-4\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-9 w-9 p-0\"\n aria-label={prevLabel}\n disabled={prevDisabled}\n onClick={handlePrev}\n >\n <ChevronLeft className=\"h-4 w-4\" aria-hidden=\"true\" />\n </Button>\n\n <div className=\"flex items-center gap-1.5\">\n <button\n ref={monthTriggerRef}\n type=\"button\"\n onClick={openMonths}\n aria-expanded={view === \"months\"}\n aria-label={`Choose month, currently ${MONTHS[viewDate.getMonth()]}`}\n className={triggerClass}\n >\n {MONTHS[viewDate.getMonth()]}\n </button>\n <button\n ref={yearTriggerRef}\n type=\"button\"\n onClick={openYears}\n aria-expanded={view === \"years\"}\n aria-label={`Choose year, currently ${viewDate.getFullYear()}`}\n className={triggerClass}\n >\n {viewDate.getFullYear()}\n </button>\n </div>\n\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-9 w-9 p-0\"\n aria-label={nextLabel}\n disabled={nextDisabled}\n onClick={handleNext}\n >\n <ChevronRight className=\"h-4 w-4\" aria-hidden=\"true\" />\n </Button>\n </div>\n\n {/* One polite live region for the displayed month/year. */}\n <div aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {MONTHS[viewDate.getMonth()]} {viewDate.getFullYear()}\n </div>\n\n <div className=\"relative\">\n {/* Day grid — ALWAYS rendered so width and height stay stable; inert\n while a chooser overlay covers it. */}\n <div aria-hidden={overlayActive ? true : undefined}>\n <div className=\"grid grid-cols-7 gap-1 mb-2\">\n {DAYS.map((day, i) => (\n <div key={day} className=\"text-center text-sm font-bold py-2 text-foreground\" aria-hidden=\"true\">\n <span className=\"sr-only\">{DAY_NAMES_LONG[i]}</span>\n <span aria-hidden=\"true\">{day}</span>\n </div>\n ))}\n </div>\n\n <div\n ref={daysGridRef}\n className=\"grid grid-cols-7 gap-1\"\n role=\"group\"\n aria-label=\"Calendar\"\n onKeyDown={overlayActive ? undefined : handleDaysKeyDown}\n >\n {calendarDays.map((date, index) => {\n if (!date) return <div key={`empty-${index}`} className=\"h-9\" aria-hidden=\"true\" />\n\n const dateDisabled = isDateDisabled(date)\n const dateSelected = isSelectedDay(date)\n const todayDate = isTodayDate(date)\n const roving = isSameDay(date, rovingDate)\n const tabIndex = !overlayActive && roving ? 0 : -1\n\n return (\n <button\n key={date.toISOString()}\n type=\"button\"\n onClick={() => commitDay(date)}\n disabled={dateDisabled}\n tabIndex={tabIndex}\n data-roving={roving ? \"true\" : undefined}\n aria-label={fullDateLabel(date)}\n aria-pressed={dateSelected}\n aria-current={todayDate ? \"date\" : undefined}\n className={cn(\n \"h-9 w-9 rounded-lg text-sm font-semibold transition-transform\",\n \"motion-safe:hover:scale-105 motion-safe:active:scale-95\",\n \"flex items-center justify-center\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n !dateDisabled && !dateSelected && !todayDate && \"text-foreground hover:bg-primary/10\",\n todayDate && !dateSelected && \"bg-accent text-accent-foreground font-bold ring-2 ring-border\",\n dateSelected && \"bg-primary text-primary-foreground font-bold\",\n dateDisabled && \"opacity-30 cursor-not-allowed motion-safe:hover:scale-100 hover:bg-transparent relative\",\n )}\n >\n {date.getDate()}\n {dateDisabled && (\n <span className=\"absolute inset-0 flex items-center justify-center\" aria-hidden=\"true\">\n <span className=\"w-px h-full bg-current transform rotate-45\" />\n </span>\n )}\n </button>\n )\n })}\n </div>\n\n <div className=\"mt-4 pt-3 border-t border-border text-xs space-y-1\">\n <div className=\"flex items-center gap-2\">\n <div className=\"h-3 w-3 rounded-sm bg-primary\" aria-hidden=\"true\" />\n <span className=\"text-muted-foreground\">Selected</span>\n </div>\n <div className=\"flex items-center gap-2\">\n <div className=\"h-3 w-3 rounded-sm bg-accent ring-2 ring-border\" aria-hidden=\"true\" />\n <span className=\"text-muted-foreground\">Today</span>\n </div>\n {(disablePast || disableFuture || disabled) && (\n <div className=\"flex items-center gap-2\">\n <div className=\"h-3 w-3 rounded-sm bg-muted opacity-30 relative\" aria-hidden=\"true\">\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <div className=\"w-px h-full bg-foreground transform rotate-45\" />\n </div>\n </div>\n <span className=\"text-muted-foreground\">Unavailable</span>\n </div>\n )}\n </div>\n </div>\n\n {/* Month / year choosers overlay the day grid — same footprint. */}\n {overlayActive && (\n <div ref={overlayRef} className=\"absolute inset-0 bg-card rounded-lg flex flex-col justify-center\">\n {view === \"years\" && (\n <div className=\"mb-2 text-center text-sm font-semibold text-muted-foreground\" aria-hidden=\"true\">\n {yearPageStart} – {yearPageStart + YEARS_PER_PAGE - 1}\n </div>\n )}\n\n {view === \"months\" && (\n <div className=\"grid grid-cols-3 gap-1\">\n {MONTHS_SHORT.map((label, month) => {\n const monthDisabled = isMonthDisabled(viewDate.getFullYear(), month)\n const isViewMonth = month === viewDate.getMonth()\n return (\n <button\n key={label}\n type=\"button\"\n disabled={monthDisabled}\n data-active={isViewMonth ? \"true\" : undefined}\n aria-pressed={isViewMonth}\n aria-label={`${MONTHS[month]} ${viewDate.getFullYear()}`}\n onClick={() => handleMonthPick(month)}\n className={cn(\n gridCellClass,\n !monthDisabled && !isViewMonth && \"text-foreground hover:bg-primary/10\",\n isViewMonth && \"bg-primary text-primary-foreground font-bold\",\n monthDisabled && \"opacity-30 cursor-not-allowed\",\n )}\n >\n {label}\n </button>\n )\n })}\n </div>\n )}\n\n {view === \"years\" && (\n <div className=\"grid grid-cols-3 gap-1\">\n {yearPage.map((year) => {\n const yearDisabled = isYearDisabled(year)\n const isViewYear = year === viewDate.getFullYear()\n return (\n <button\n key={year}\n type=\"button\"\n disabled={yearDisabled}\n data-active={isViewYear ? \"true\" : undefined}\n aria-pressed={isViewYear}\n aria-label={`Year ${year}`}\n onClick={() => handleYearPick(year)}\n className={cn(\n gridCellClass,\n !yearDisabled && !isViewYear && \"text-foreground hover:bg-primary/10\",\n isViewYear && \"bg-primary text-primary-foreground font-bold\",\n yearDisabled && \"opacity-30 cursor-not-allowed\",\n )}\n >\n {year}\n </button>\n )\n })}\n </div>\n )}\n </div>\n )}\n </div>\n </div>\n )\n}\n\nDatePicker.displayName = \"DatePicker\"\n\nexport { DatePicker }\n"]}
|
|
1
|
+
{"version":3,"file":"date-picker.js","sourceRoot":"","sources":["../../../src/react/components/date-picker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,E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,CAAC,GACE,CACP,EAEA,IAAI,KAAK,OAAO,IAAI,CACnB,cAAK,SAAS,EAAC,wBAAwB,YACpC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;oCACrB,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;oCAC1C,MAAM,UAAU,GAAG,IAAI,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC;oCACnD,OAAO,CACL,iBAEE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,YAAY,iBACT,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,kBAC9B,UAAU,gBACZ,QAAQ,IAAI,EAAE,EAC1B,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EACnC,SAAS,EAAE,EAAE,CACX,aAAa,EACb,CAAC,YAAY,IAAI,CAAC,UAAU,IAAI,qCAAqC,EACrE,UAAU,IAAI,8CAA8C,EAC5D,YAAY,IAAI,+BAA+B,CAChD,YAEA,IAAI,IAdA,IAAI,CAeF,CACV,CAAC;gCACJ,CAAC,CAAC,GACE,CACP,IACG,CACP,IACG,IACF,CACP,CAAC;AACJ,CAAC;AAED,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\nimport { Button } from './button.js';\nimport { cn } from '../../lib/utils.js';\n\nexport interface DatePickerProps {\n selected?: Date;\n onSelect?: (date: Date | undefined) => void;\n disabled?: (date: Date) => boolean;\n disablePast?: boolean;\n disableFuture?: boolean;\n className?: string;\n}\n\nconst MONTHS = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n];\n\nconst MONTHS_SHORT = [\n 'Jan',\n 'Feb',\n 'Mar',\n 'Apr',\n 'May',\n 'Jun',\n 'Jul',\n 'Aug',\n 'Sep',\n 'Oct',\n 'Nov',\n 'Dec',\n];\n\nconst DAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];\nconst DAY_NAMES_LONG = [\n 'Sunday',\n 'Monday',\n 'Tuesday',\n 'Wednesday',\n 'Thursday',\n 'Friday',\n 'Saturday',\n];\n\nconst YEARS_PER_PAGE = 12;\nconst CALENDAR_CELLS = 42;\n\ntype View = 'days' | 'months' | 'years';\ntype PendingFocus = 'day' | 'monthTrigger' | 'yearTrigger' | 'monthGrid' | 'yearGrid';\n\nconst startOfDay = (d: Date) => {\n const x = new Date(d.getFullYear(), d.getMonth(), d.getDate());\n return x;\n};\nconst monthStart = (year: number, month: number) => new Date(year, month, 1);\nconst addMonths = (d: Date, n: number) => new Date(d.getFullYear(), d.getMonth() + n, 1);\nconst daysInMonth = (year: number, month: number) => new Date(year, month + 1, 0).getDate();\nconst isSameDay = (a: Date, b: Date) =>\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate();\nconst isSameMonth = (a: Date, b: Date) =>\n a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();\nconst fullDateLabel = (date: Date) =>\n `${MONTHS[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;\n\nfunction DatePicker({\n selected,\n onSelect,\n disabled,\n disablePast = false,\n disableFuture = false,\n className,\n}: DatePickerProps) {\n const today = React.useMemo(() => startOfDay(new Date()), []);\n\n const [viewDate, setViewDate] = React.useState(() =>\n monthStart((selected ?? today).getFullYear(), (selected ?? today).getMonth()),\n );\n const [view, setView] = React.useState<View>('days');\n const [yearPageStart, setYearPageStart] = React.useState(\n () => Math.floor((selected ?? today).getFullYear() / YEARS_PER_PAGE) * YEARS_PER_PAGE,\n );\n const [focusedDate, setFocusedDate] = React.useState(() => startOfDay(selected ?? today));\n\n const monthTriggerRef = React.useRef<HTMLButtonElement | null>(null);\n const yearTriggerRef = React.useRef<HTMLButtonElement | null>(null);\n const daysGridRef = React.useRef<HTMLDivElement | null>(null);\n const overlayRef = React.useRef<HTMLDivElement | null>(null);\n const pendingFocusRef = React.useRef<PendingFocus | null>(null);\n\n const isDateDisabled = (date: Date) => {\n const checkDate = startOfDay(date);\n if (disablePast && checkDate < today) return true;\n if (disableFuture && checkDate > today) return true;\n if (disabled && disabled(checkDate)) return true;\n return false;\n };\n\n const isMonthDisabled = (year: number, month: number) => {\n if (disableFuture && new Date(year, month, 1) > today) return true;\n if (disablePast && new Date(year, month + 1, 0) < today) return true;\n return false;\n };\n\n const isYearDisabled = (year: number) => {\n if (disableFuture && year > today.getFullYear()) return true;\n if (disablePast && year < today.getFullYear()) return true;\n return false;\n };\n\n const rangeAllYearsDisabled = (from: number, to: number) => {\n for (let y = from; y <= to; y++) if (!isYearDisabled(y)) return false;\n return true;\n };\n\n const isSelectedDay = (date: Date) =>\n selected ? isSameDay(startOfDay(selected), startOfDay(date)) : false;\n const isTodayDate = (date: Date) => isSameDay(startOfDay(date), today);\n\n const pickInMonthFocus = (vd: Date): Date => {\n const year = vd.getFullYear();\n const month = vd.getMonth();\n if (selected) {\n const s = startOfDay(selected);\n if (isSameMonth(s, vd) && !isDateDisabled(s)) return s;\n }\n if (isSameMonth(today, vd) && !isDateDisabled(today)) return new Date(today);\n const dim = daysInMonth(year, month);\n for (let d = 1; d <= dim; d++) {\n const cand = new Date(year, month, d);\n if (!isDateDisabled(cand)) return cand;\n }\n return new Date(year, month, 1);\n };\n\n const selectedTime = selected ? startOfDay(selected).getTime() : undefined;\n React.useEffect(() => {\n if (selectedTime === undefined) return;\n const d = new Date(selectedTime);\n setViewDate(monthStart(d.getFullYear(), d.getMonth()));\n setFocusedDate(startOfDay(d));\n }, [selectedTime]);\n\n React.useLayoutEffect(() => {\n const target = pendingFocusRef.current;\n if (!target) return;\n pendingFocusRef.current = null;\n if (target === 'monthTrigger') {\n monthTriggerRef.current?.focus();\n } else if (target === 'yearTrigger') {\n yearTriggerRef.current?.focus();\n } else if (target === 'day') {\n daysGridRef.current?.querySelector<HTMLButtonElement>('[data-roving=\"true\"]')?.focus();\n } else if (target === 'monthGrid' || target === 'yearGrid') {\n const active = overlayRef.current?.querySelector<HTMLButtonElement>(\n '[data-active=\"true\"]:not([disabled])',\n );\n const fallback =\n overlayRef.current?.querySelector<HTMLButtonElement>('button:not([disabled])');\n (active ?? fallback)?.focus();\n }\n });\n\n const generateCalendarDays = (): (Date | null)[] => {\n const year = viewDate.getFullYear();\n const month = viewDate.getMonth();\n const dim = daysInMonth(year, month);\n const firstDay = new Date(year, month, 1).getDay();\n const days: (Date | null)[] = [];\n for (let i = 0; i < firstDay; i++) days.push(null);\n for (let day = 1; day <= dim; day++) days.push(new Date(year, month, day));\n while (days.length < CALENDAR_CELLS) days.push(null);\n return days;\n };\n\n const inViewMonth = isSameMonth(focusedDate, viewDate);\n const rovingDate = inViewMonth ? focusedDate : pickInMonthFocus(viewDate);\n\n const commitDay = (date: Date) => {\n if (isDateDisabled(date)) return;\n onSelect?.(date);\n };\n\n const moveFocusTo = (date: Date) => {\n const d = startOfDay(date);\n setFocusedDate(d);\n if (!isSameMonth(d, viewDate)) setViewDate(monthStart(d.getFullYear(), d.getMonth()));\n pendingFocusRef.current = 'day';\n };\n\n const firstAvailableFrom = (origin: Date, step: number, maxSteps: number): Date | null => {\n let d = startOfDay(origin);\n for (let i = 0; i < maxSteps; i++) {\n if (!isDateDisabled(d)) return d;\n d = new Date(d.getFullYear(), d.getMonth(), d.getDate() + step);\n }\n return null;\n };\n\n const handleDaysKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n const base = rovingDate;\n let candidate: Date;\n let probeStep: number;\n\n switch (e.key) {\n case 'ArrowLeft':\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() - 1);\n probeStep = -1;\n break;\n case 'ArrowRight':\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 1);\n probeStep = 1;\n break;\n case 'ArrowUp':\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() - 7);\n probeStep = -1;\n break;\n case 'ArrowDown':\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 7);\n probeStep = 1;\n break;\n case 'Home':\n candidate = new Date(base.getFullYear(), base.getMonth(), base.getDate() - base.getDay());\n probeStep = 1;\n break;\n case 'End':\n candidate = new Date(\n base.getFullYear(),\n base.getMonth(),\n base.getDate() + (6 - base.getDay()),\n );\n probeStep = -1;\n break;\n case 'PageUp': {\n const prev = addMonths(base, -1);\n candidate = new Date(\n prev.getFullYear(),\n prev.getMonth(),\n Math.min(base.getDate(), daysInMonth(prev.getFullYear(), prev.getMonth())),\n );\n probeStep = 1;\n break;\n }\n case 'PageDown': {\n const next = addMonths(base, 1);\n candidate = new Date(\n next.getFullYear(),\n next.getMonth(),\n Math.min(base.getDate(), daysInMonth(next.getFullYear(), next.getMonth())),\n );\n probeStep = 1;\n break;\n }\n case 'Enter':\n case ' ':\n e.preventDefault();\n commitDay(base);\n return;\n default:\n return;\n }\n\n e.preventDefault();\n let target = firstAvailableFrom(candidate, probeStep, 62);\n if (!target && probeStep !== -1) target = firstAvailableFrom(candidate, -1, 62);\n if (target) moveFocusTo(target);\n };\n\n const prevMonthDate = addMonths(viewDate, -1);\n const nextMonthDate = addMonths(viewDate, 1);\n\n let prevDisabled: boolean;\n let nextDisabled: boolean;\n let prevLabel: string;\n let nextLabel: string;\n\n if (view === 'days') {\n prevDisabled = isMonthDisabled(prevMonthDate.getFullYear(), prevMonthDate.getMonth());\n nextDisabled = isMonthDisabled(nextMonthDate.getFullYear(), nextMonthDate.getMonth());\n prevLabel = 'Previous month';\n nextLabel = 'Next month';\n } else if (view === 'months') {\n prevDisabled = isYearDisabled(viewDate.getFullYear() - 1);\n nextDisabled = isYearDisabled(viewDate.getFullYear() + 1);\n prevLabel = 'Previous year';\n nextLabel = 'Next year';\n } else {\n prevDisabled = rangeAllYearsDisabled(yearPageStart - YEARS_PER_PAGE, yearPageStart - 1);\n nextDisabled = rangeAllYearsDisabled(\n yearPageStart + YEARS_PER_PAGE,\n yearPageStart + YEARS_PER_PAGE * 2 - 1,\n );\n prevLabel = `Previous ${YEARS_PER_PAGE} years`;\n nextLabel = `Next ${YEARS_PER_PAGE} years`;\n }\n\n const handlePrev = () => {\n if (view === 'days') setViewDate(prevMonthDate);\n else if (view === 'months')\n setViewDate(monthStart(viewDate.getFullYear() - 1, viewDate.getMonth()));\n else setYearPageStart((s) => s - YEARS_PER_PAGE);\n };\n const handleNext = () => {\n if (view === 'days') setViewDate(nextMonthDate);\n else if (view === 'months')\n setViewDate(monthStart(viewDate.getFullYear() + 1, viewDate.getMonth()));\n else setYearPageStart((s) => s + YEARS_PER_PAGE);\n };\n\n const openMonths = () => {\n if (view === 'months') {\n setView('days');\n pendingFocusRef.current = 'monthTrigger';\n } else {\n setView('months');\n pendingFocusRef.current = 'monthGrid';\n }\n };\n const openYears = () => {\n if (view === 'years') {\n setView('days');\n pendingFocusRef.current = 'yearTrigger';\n } else {\n setYearPageStart(Math.floor(viewDate.getFullYear() / YEARS_PER_PAGE) * YEARS_PER_PAGE);\n setView('years');\n pendingFocusRef.current = 'yearGrid';\n }\n };\n\n const handleMonthPick = (month: number) => {\n setViewDate(monthStart(viewDate.getFullYear(), month));\n setView('days');\n pendingFocusRef.current = 'monthTrigger';\n };\n const handleYearPick = (year: number) => {\n setViewDate(monthStart(year, viewDate.getMonth()));\n setView('days');\n pendingFocusRef.current = 'yearTrigger';\n };\n\n const calendarDays = generateCalendarDays();\n const yearPage = Array.from({ length: YEARS_PER_PAGE }, (_, i) => yearPageStart + i);\n const overlayActive = view !== 'days';\n\n const triggerClass =\n 'min-h-[1.5rem] px-1 text-base font-bold text-foreground underline decoration-1 underline-offset-4 decoration-border rounded-sm ' +\n 'hover:opacity-80 transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background';\n\n const gridCellClass =\n 'h-10 rounded-lg text-sm font-semibold transition-transform flex items-center justify-center ' +\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background';\n\n return (\n <div className={cn('p-4 bg-card rounded-lg', className)}>\n <div className=\"flex items-center justify-between mb-4\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-9 w-9 p-0\"\n aria-label={prevLabel}\n disabled={prevDisabled}\n onClick={handlePrev}\n >\n <ChevronLeft className=\"h-4 w-4\" aria-hidden=\"true\" />\n </Button>\n\n <div className=\"flex items-center gap-1.5\">\n <button\n ref={monthTriggerRef}\n type=\"button\"\n onClick={openMonths}\n aria-expanded={view === 'months'}\n aria-label={`Choose month, currently ${MONTHS[viewDate.getMonth()]}`}\n className={triggerClass}\n >\n {MONTHS[viewDate.getMonth()]}\n </button>\n <button\n ref={yearTriggerRef}\n type=\"button\"\n onClick={openYears}\n aria-expanded={view === 'years'}\n aria-label={`Choose year, currently ${viewDate.getFullYear()}`}\n className={triggerClass}\n >\n {viewDate.getFullYear()}\n </button>\n </div>\n\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-9 w-9 p-0\"\n aria-label={nextLabel}\n disabled={nextDisabled}\n onClick={handleNext}\n >\n <ChevronRight className=\"h-4 w-4\" aria-hidden=\"true\" />\n </Button>\n </div>\n\n <div aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {MONTHS[viewDate.getMonth()]} {viewDate.getFullYear()}\n </div>\n\n <div className=\"relative\">\n <div aria-hidden={overlayActive ? true : undefined}>\n <div className=\"grid grid-cols-7 gap-1 mb-2\">\n {DAYS.map((day, i) => (\n <div\n key={day}\n className=\"text-center text-sm font-bold py-2 text-foreground\"\n aria-hidden=\"true\"\n >\n <span className=\"sr-only\">{DAY_NAMES_LONG[i]}</span>\n <span aria-hidden=\"true\">{day}</span>\n </div>\n ))}\n </div>\n\n <div\n ref={daysGridRef}\n className=\"grid grid-cols-7 gap-1\"\n role=\"group\"\n aria-label=\"Calendar\"\n onKeyDown={overlayActive ? undefined : handleDaysKeyDown}\n >\n {calendarDays.map((date, index) => {\n if (!date) return <div key={`empty-${index}`} className=\"h-9\" aria-hidden=\"true\" />;\n\n const dateDisabled = isDateDisabled(date);\n const dateSelected = isSelectedDay(date);\n const todayDate = isTodayDate(date);\n const roving = isSameDay(date, rovingDate);\n const tabIndex = !overlayActive && roving ? 0 : -1;\n\n return (\n <button\n key={date.toISOString()}\n type=\"button\"\n onClick={() => commitDay(date)}\n disabled={dateDisabled}\n tabIndex={tabIndex}\n data-roving={roving ? 'true' : undefined}\n aria-label={fullDateLabel(date)}\n aria-pressed={dateSelected}\n aria-current={todayDate ? 'date' : undefined}\n className={cn(\n 'h-9 w-9 rounded-lg text-sm font-semibold transition-transform',\n 'motion-safe:hover:scale-105 motion-safe:active:scale-95',\n 'flex items-center justify-center',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n !dateDisabled &&\n !dateSelected &&\n !todayDate &&\n 'text-foreground hover:bg-primary/10',\n todayDate &&\n !dateSelected &&\n 'bg-accent text-accent-foreground font-bold ring-2 ring-border',\n dateSelected && 'bg-primary text-primary-foreground font-bold',\n dateDisabled &&\n 'opacity-30 cursor-not-allowed motion-safe:hover:scale-100 hover:bg-transparent relative',\n )}\n >\n {date.getDate()}\n {dateDisabled && (\n <span\n className=\"absolute inset-0 flex items-center justify-center\"\n aria-hidden=\"true\"\n >\n <span className=\"w-px h-full bg-current transform rotate-45\" />\n </span>\n )}\n </button>\n );\n })}\n </div>\n\n <div className=\"mt-4 pt-3 border-t border-border text-xs space-y-1\">\n <div className=\"flex items-center gap-2\">\n <div className=\"h-3 w-3 rounded-sm bg-primary\" aria-hidden=\"true\" />\n <span className=\"text-muted-foreground\">Selected</span>\n </div>\n <div className=\"flex items-center gap-2\">\n <div className=\"h-3 w-3 rounded-sm bg-accent ring-2 ring-border\" aria-hidden=\"true\" />\n <span className=\"text-muted-foreground\">Today</span>\n </div>\n {(disablePast || disableFuture || disabled) && (\n <div className=\"flex items-center gap-2\">\n <div className=\"h-3 w-3 rounded-sm bg-muted opacity-30 relative\" aria-hidden=\"true\">\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <div className=\"w-px h-full bg-foreground transform rotate-45\" />\n </div>\n </div>\n <span className=\"text-muted-foreground\">Unavailable</span>\n </div>\n )}\n </div>\n </div>\n\n {/* The choosers overlay the day grid so the popover keeps one footprint and Radix never flips its side. */}\n {overlayActive && (\n <div\n ref={overlayRef}\n className=\"absolute inset-0 bg-card rounded-lg flex flex-col justify-center\"\n >\n {view === 'years' && (\n <div\n className=\"mb-2 text-center text-sm font-semibold text-muted-foreground\"\n aria-hidden=\"true\"\n >\n {yearPageStart} – {yearPageStart + YEARS_PER_PAGE - 1}\n </div>\n )}\n\n {view === 'months' && (\n <div className=\"grid grid-cols-3 gap-1\">\n {MONTHS_SHORT.map((label, month) => {\n const monthDisabled = isMonthDisabled(viewDate.getFullYear(), month);\n const isViewMonth = month === viewDate.getMonth();\n return (\n <button\n key={label}\n type=\"button\"\n disabled={monthDisabled}\n data-active={isViewMonth ? 'true' : undefined}\n aria-pressed={isViewMonth}\n aria-label={`${MONTHS[month]} ${viewDate.getFullYear()}`}\n onClick={() => handleMonthPick(month)}\n className={cn(\n gridCellClass,\n !monthDisabled && !isViewMonth && 'text-foreground hover:bg-primary/10',\n isViewMonth && 'bg-primary text-primary-foreground font-bold',\n monthDisabled && 'opacity-30 cursor-not-allowed',\n )}\n >\n {label}\n </button>\n );\n })}\n </div>\n )}\n\n {view === 'years' && (\n <div className=\"grid grid-cols-3 gap-1\">\n {yearPage.map((year) => {\n const yearDisabled = isYearDisabled(year);\n const isViewYear = year === viewDate.getFullYear();\n return (\n <button\n key={year}\n type=\"button\"\n disabled={yearDisabled}\n data-active={isViewYear ? 'true' : undefined}\n aria-pressed={isViewYear}\n aria-label={`Year ${year}`}\n onClick={() => handleYearPick(year)}\n className={cn(\n gridCellClass,\n !yearDisabled && !isViewYear && 'text-foreground hover:bg-primary/10',\n isViewYear && 'bg-primary text-primary-foreground font-bold',\n yearDisabled && 'opacity-30 cursor-not-allowed',\n )}\n >\n {year}\n </button>\n );\n })}\n </div>\n )}\n </div>\n )}\n </div>\n </div>\n );\n}\n\nDatePicker.displayName = 'DatePicker';\n\nexport { DatePicker };\n"]}
|