@eifi1/ui-kit 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -23
- package/dist/components/alert-banner.d.ts +57 -5
- package/dist/components/alert-banner.js +63 -17
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/breadcrumbs.d.ts +60 -0
- package/dist/components/breadcrumbs.js +88 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/bulk-action-bar.d.ts +112 -0
- package/dist/components/bulk-action-bar.js +196 -0
- package/dist/components/bulk-action-bar.js.map +1 -0
- package/dist/components/button-group.d.ts +58 -3
- package/dist/components/button-group.js +56 -5
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/calculator.d.ts +6 -0
- package/dist/components/calendar-heatmap.d.ts +124 -0
- package/dist/components/calendar-heatmap.js +295 -0
- package/dist/components/calendar-heatmap.js.map +1 -0
- package/dist/components/chip.d.ts +31 -5
- package/dist/components/chip.js +85 -5
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +34 -2
- package/dist/components/choice-card.js +49 -0
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/copy-button.d.ts +14 -4
- package/dist/components/copy-button.js +17 -4
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table.js +2 -0
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +22 -2
- package/dist/components/date-picker.js +11 -3
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +43 -6
- package/dist/components/description-list.js +91 -11
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +7 -0
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/disclosure.d.ts +57 -2
- package/dist/components/disclosure.js +24 -12
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/field.d.ts +43 -0
- package/dist/components/field.js +52 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/file-button.d.ts +1 -0
- package/dist/components/file-dropzone.d.ts +4 -4
- package/dist/components/file-dropzone.js +2 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/floating-panel.d.ts +147 -4
- package/dist/components/floating-panel.js +188 -28
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/full-bleed-dialog.d.ts +23 -4
- package/dist/components/full-bleed-dialog.js +11 -2
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/list.d.ts +187 -0
- package/dist/components/list.js +221 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/menu-item.d.ts +109 -0
- package/dist/components/menu-item.js +88 -0
- package/dist/components/menu-item.js.map +1 -0
- package/dist/components/mini-calendar.d.ts +70 -5
- package/dist/components/mini-calendar.js +166 -62
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +23 -1
- package/dist/components/modal.js +36 -10
- package/dist/components/modal.js.map +1 -1
- package/dist/components/nav-pills.d.ts +66 -0
- package/dist/components/nav-pills.js +65 -0
- package/dist/components/nav-pills.js.map +1 -0
- package/dist/components/number-field.d.ts +6 -0
- package/dist/components/number-input.d.ts +6 -0
- package/dist/components/numpad-sheet.d.ts +6 -0
- package/dist/components/page-contents.js +1 -2
- package/dist/components/page-contents.js.map +1 -1
- package/dist/components/page-header.d.ts +37 -0
- package/dist/components/page-header.js +36 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/progress-bar.d.ts +31 -2
- package/dist/components/progress-bar.js +73 -7
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +3 -0
- package/dist/components/series-chart-labels.js +2 -1
- package/dist/components/series-chart-labels.js.map +1 -1
- package/dist/components/series-chart.d.ts +32 -0
- package/dist/components/series-chart.js +141 -4
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/settings-fields.d.ts +1 -0
- package/dist/components/status-dot.d.ts +53 -0
- package/dist/components/status-dot.js +57 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/table.d.ts +78 -13
- package/dist/components/table.js +84 -11
- package/dist/components/table.js.map +1 -1
- package/dist/components/text.d.ts +70 -0
- package/dist/components/text.js +24 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/time-input.d.ts +1 -0
- package/dist/components/toast.d.ts +167 -0
- package/dist/components/toast.js +226 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toggle-group.d.ts +44 -1
- package/dist/components/toggle-group.js +73 -4
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/tooltip.d.ts +46 -15
- package/dist/components/tooltip.js +87 -47
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/ui.d.ts +158 -7
- package/dist/components/ui.js +191 -10
- package/dist/components/ui.js.map +1 -1
- package/dist/components/user-avatar.d.ts +25 -3
- package/dist/components/user-avatar.js +32 -3
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/hooks/use-close-transition.d.ts +7 -1
- package/dist/hooks/use-close-transition.js +5 -2
- package/dist/hooks/use-close-transition.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +1 -1
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-file-drop.d.ts +1 -0
- package/dist/i18n/defaults.d.ts +6 -0
- package/dist/i18n/defaults.js +11 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +11 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +6 -0
- package/dist/i18n/locales/de-CH.d.ts +6 -0
- package/dist/i18n/locales/de-informal.d.ts +6 -0
- package/dist/i18n/locales/de.d.ts +6 -0
- package/dist/i18n/locales/de.js +30 -2
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +6 -0
- package/dist/i18n/locales/es.js +30 -2
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +6 -0
- package/dist/i18n/locales/fr.js +30 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +6 -0
- package/dist/i18n/locales/hu.js +30 -2
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +6 -0
- package/dist/i18n/locales/it.js +30 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +6 -0
- package/dist/i18n/locales/zh.js +30 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +27 -15
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/clipping.d.ts +25 -0
- package/dist/lib/clipping.js +17 -0
- package/dist/lib/clipping.js.map +1 -0
- package/dist/lib/dates.d.ts +17 -1
- package/dist/lib/dates.js +19 -0
- package/dist/lib/dates.js.map +1 -1
- package/dist/rhf/form.d.ts +1 -0
- package/dist/rhf/use-rhf-wizard-step.d.ts +22 -0
- package/dist/rhf/use-rhf-wizard-step.js +38 -0
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -0
- package/dist/rhf.d.ts +2 -0
- package/dist/rhf.js +1 -0
- package/dist/rhf.js.map +1 -1
- package/dist/search/command-palette.d.ts +19 -2
- package/dist/search/command-palette.js +16 -5
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search/global-search.d.ts +26 -1
- package/dist/search/global-search.js +29 -13
- package/dist/search/global-search.js.map +1 -1
- package/dist/search.d.ts +1 -1
- package/dist/shell/topbar-action-menu.d.ts +73 -3
- package/dist/shell/topbar-action-menu.js +100 -27
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +2 -1
- package/dist/wizard/stepper-nav.d.ts +1 -0
- package/dist/wizard/stepper-nav.js +1 -1
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.d.ts +2 -2
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +1 -1
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/wizard-context.d.ts +7 -1
- package/dist/wizard/wizard-context.js +4 -0
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-summary.js +3 -3
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/dist/wizard.d.ts +2 -1
- package/package.json +16 -12
- package/src/components/alert-banner.tsx +149 -21
- package/src/components/breadcrumbs.tsx +168 -0
- package/src/components/bulk-action-bar.tsx +362 -0
- package/src/components/button-group.tsx +124 -4
- package/src/components/calendar-heatmap.tsx +504 -0
- package/src/components/chip.tsx +128 -7
- package/src/components/choice-card.tsx +97 -1
- package/src/components/copy-button.tsx +29 -7
- package/src/components/data-table.tsx +7 -0
- package/src/components/date-picker.tsx +49 -1
- package/src/components/description-list.tsx +168 -15
- package/src/components/dialog-frame.tsx +7 -0
- package/src/components/disclosure.tsx +93 -21
- package/src/components/field.tsx +137 -0
- package/src/components/file-dropzone.tsx +9 -10
- package/src/components/floating-panel.tsx +366 -15
- package/src/components/full-bleed-dialog.tsx +42 -5
- package/src/components/list.tsx +443 -0
- package/src/components/menu-item.tsx +235 -0
- package/src/components/mini-calendar.tsx +245 -54
- package/src/components/modal.tsx +80 -17
- package/src/components/nav-pills.tsx +145 -0
- package/src/components/page-contents.tsx +4 -4
- package/src/components/page-header.tsx +68 -0
- package/src/components/progress-bar.tsx +129 -11
- package/src/components/series-chart-labels.ts +4 -0
- package/src/components/series-chart.tsx +274 -3
- package/src/components/status-dot.tsx +107 -0
- package/src/components/table.tsx +176 -17
- package/src/components/text.tsx +97 -0
- package/src/components/toast.tsx +441 -0
- package/src/components/toggle-group.tsx +128 -4
- package/src/components/tooltip.tsx +200 -100
- package/src/components/ui.tsx +381 -14
- package/src/components/user-avatar.tsx +57 -3
- package/src/hooks/use-close-transition.ts +14 -5
- package/src/hooks/use-copy-to-clipboard.ts +1 -1
- package/src/i18n/defaults.ts +10 -0
- package/src/i18n/kit-labels.tsx +10 -0
- package/src/i18n/locales/de.ts +29 -0
- package/src/i18n/locales/es.ts +29 -0
- package/src/i18n/locales/fr.ts +29 -0
- package/src/i18n/locales/hu.ts +29 -0
- package/src/i18n/locales/it.ts +29 -0
- package/src/i18n/locales/zh.ts +29 -0
- package/src/index.ts +31 -0
- package/src/lib/clipping.ts +34 -0
- package/src/lib/dates.ts +37 -0
- package/src/rhf/use-rhf-wizard-step.ts +113 -0
- package/src/rhf.ts +2 -0
- package/src/search/command-palette.tsx +42 -5
- package/src/search/global-search.tsx +59 -18
- package/src/shell/topbar-action-menu.tsx +239 -49
- package/src/wizard/stepper-nav.tsx +2 -1
- package/src/wizard/types.ts +2 -2
- package/src/wizard/use-wizard.ts +3 -3
- package/src/wizard/wizard-context.tsx +9 -0
- package/src/wizard/wizard-summary.tsx +14 -10
- package/tokens.css +97 -0
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
5
5
|
import { cn } from "../lib/cn.js";
|
|
6
6
|
import { horizontalStep } from "../lib/direction.js";
|
|
7
7
|
import { useAnnounce } from "../hooks/use-announce.js";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
addMonthsClamped,
|
|
10
|
+
localeWeekStart,
|
|
11
|
+
monthKey,
|
|
12
|
+
parseIsoDate,
|
|
13
|
+
sameYmd,
|
|
14
|
+
toLocalIso
|
|
15
|
+
} from "../lib/dates.js";
|
|
9
16
|
import { useKitLabels, useKitLocale, useKitWeekStart } from "../i18n/kit-labels.js";
|
|
10
17
|
const DEFAULT_MINI_CALENDAR_LABELS = {
|
|
11
18
|
previousMonth: "Previous month",
|
|
@@ -22,27 +29,17 @@ const DAY_NAME_FORMAT = {
|
|
|
22
29
|
month: "long",
|
|
23
30
|
year: "numeric"
|
|
24
31
|
};
|
|
25
|
-
function localeWeekStart(locale) {
|
|
26
|
-
try {
|
|
27
|
-
const tag = locale ?? new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
28
|
-
const loc = new Intl.Locale(tag);
|
|
29
|
-
const firstDay = (loc.getWeekInfo?.() ?? loc.weekInfo)?.firstDay;
|
|
30
|
-
if (typeof firstDay === "number") return firstDay % 7;
|
|
31
|
-
} catch {
|
|
32
|
-
}
|
|
33
|
-
return 1;
|
|
34
|
-
}
|
|
35
32
|
const weekdayIndex = (d, weekStart) => (d.getDay() - weekStart + 7) % 7;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return
|
|
33
|
+
const stepMonths = addMonthsClamped;
|
|
34
|
+
const LG_CELL_HEIGHT = "min-h-16 md:min-h-24";
|
|
35
|
+
const monthStart = (key) => key ? parseIsoDate(`${key}-01`) : null;
|
|
36
|
+
function sameDayIn(first, day) {
|
|
37
|
+
const last = new Date(first.getFullYear(), first.getMonth() + 1, 0).getDate();
|
|
38
|
+
return new Date(first.getFullYear(), first.getMonth(), Math.min(day.getDate(), last));
|
|
42
39
|
}
|
|
43
40
|
function MiniCalendar({
|
|
44
|
-
from,
|
|
45
|
-
to,
|
|
41
|
+
from = "",
|
|
42
|
+
to = "",
|
|
46
43
|
locale: localeProp,
|
|
47
44
|
weekStartsOn,
|
|
48
45
|
onSelect,
|
|
@@ -51,9 +48,15 @@ function MiniCalendar({
|
|
|
51
48
|
max,
|
|
52
49
|
labels: labelsProp,
|
|
53
50
|
focusOnOpen,
|
|
51
|
+
size = "sm",
|
|
52
|
+
renderDay,
|
|
53
|
+
month,
|
|
54
|
+
onMonthChange,
|
|
55
|
+
hideNavigation,
|
|
54
56
|
className,
|
|
55
57
|
...rest
|
|
56
58
|
}) {
|
|
59
|
+
const lg = size === "lg";
|
|
57
60
|
const labels = useKitLabels("miniCalendar", DEFAULT_MINI_CALENDAR_LABELS, labelsProp);
|
|
58
61
|
const locale = useKitLocale(localeProp);
|
|
59
62
|
const providerWeekStart = useKitWeekStart();
|
|
@@ -73,7 +76,9 @@ function MiniCalendar({
|
|
|
73
76
|
const hintId = `${id}-hint`;
|
|
74
77
|
const { announce, regionProps } = useAnnounce();
|
|
75
78
|
const [activeIso, setActiveIso] = useState(() => {
|
|
76
|
-
|
|
79
|
+
let start = fromDate ?? toDate ?? /* @__PURE__ */ new Date();
|
|
80
|
+
const first = monthStart(month);
|
|
81
|
+
if (first && monthKey(start) !== month) start = first;
|
|
77
82
|
if (minDate && start < minDate) return toLocalIso(minDate);
|
|
78
83
|
if (maxDate && start > maxDate) return toLocalIso(maxDate);
|
|
79
84
|
return toLocalIso(start);
|
|
@@ -85,6 +90,15 @@ function MiniCalendar({
|
|
|
85
90
|
const next = parseIsoDate(changed) ?? fromDate ?? toDate;
|
|
86
91
|
if (next && toLocalIso(next) !== activeIso) setActiveIso(toLocalIso(next));
|
|
87
92
|
}
|
|
93
|
+
const [lastMonth, setLastMonth] = useState(month);
|
|
94
|
+
if (lastMonth !== month) {
|
|
95
|
+
setLastMonth(month);
|
|
96
|
+
const first = monthStart(month);
|
|
97
|
+
const current = parseIsoDate(activeIso) ?? /* @__PURE__ */ new Date();
|
|
98
|
+
if (first && monthKey(current) !== month) {
|
|
99
|
+
setActiveIso(toLocalIso(sameDayIn(first, current)));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
88
102
|
const activeDate = parseIsoDate(activeIso) ?? /* @__PURE__ */ new Date();
|
|
89
103
|
const view = { year: activeDate.getFullYear(), month: activeDate.getMonth() };
|
|
90
104
|
const firstOfMonth = new Date(view.year, view.month, 1);
|
|
@@ -105,6 +119,7 @@ function MiniCalendar({
|
|
|
105
119
|
d.setDate(ref.getDate() + i);
|
|
106
120
|
return {
|
|
107
121
|
narrow: d.toLocaleDateString(locale, { weekday: "narrow" }),
|
|
122
|
+
short: d.toLocaleDateString(locale, { weekday: "short" }),
|
|
108
123
|
long: d.toLocaleDateString(locale, { weekday: "long" })
|
|
109
124
|
};
|
|
110
125
|
});
|
|
@@ -125,6 +140,8 @@ function MiniCalendar({
|
|
|
125
140
|
if (iso === activeIso) return;
|
|
126
141
|
if (focus) pendingFocus.current = iso;
|
|
127
142
|
setActiveIso(iso);
|
|
143
|
+
const key = monthKey(d);
|
|
144
|
+
if (key !== monthKey(activeDate)) onMonthChange?.(key);
|
|
128
145
|
};
|
|
129
146
|
const onDayKeyDown = (e) => {
|
|
130
147
|
const next = new Date(activeDate);
|
|
@@ -199,7 +216,10 @@ function MiniCalendar({
|
|
|
199
216
|
// `className` does everywhere else in the kit; `...rest` first, as in the rest of
|
|
200
217
|
// this wave, so nothing from outside can take the grid's own wiring away.
|
|
201
218
|
/* @__PURE__ */ jsxs("div", { ...rest, className: cn("select-none", className), children: [
|
|
202
|
-
|
|
219
|
+
hideNavigation ? (
|
|
220
|
+
// Still in the tree: the caption is what names the grid.
|
|
221
|
+
/* @__PURE__ */ jsx("div", { id: monthId, className: "sr-only-fixed", children: monthLabel })
|
|
222
|
+
) : /* @__PURE__ */ jsxs("div", { className: cn("flex items-center justify-between", lg ? "pb-2" : "pb-1"), children: [
|
|
203
223
|
/* @__PURE__ */ jsx(
|
|
204
224
|
"button",
|
|
205
225
|
{
|
|
@@ -215,7 +235,10 @@ function MiniCalendar({
|
|
|
215
235
|
{
|
|
216
236
|
id: monthId,
|
|
217
237
|
"aria-live": "polite",
|
|
218
|
-
className:
|
|
238
|
+
className: cn(
|
|
239
|
+
"capitalize",
|
|
240
|
+
lg ? "text-base font-semibold text-[var(--text-primary)]" : "text-xs font-medium text-[var(--text-secondary)]"
|
|
241
|
+
),
|
|
219
242
|
children: monthLabel
|
|
220
243
|
}
|
|
221
244
|
),
|
|
@@ -237,21 +260,47 @@ function MiniCalendar({
|
|
|
237
260
|
role: "grid",
|
|
238
261
|
"aria-labelledby": monthId,
|
|
239
262
|
"aria-describedby": mode === "range" ? hintId : void 0,
|
|
240
|
-
className:
|
|
263
|
+
className: cn(
|
|
264
|
+
"grid",
|
|
265
|
+
// The month view is RULED: a 1px gap over a border-coloured ground draws the
|
|
266
|
+
// lines between the cells, the way a wall calendar does.
|
|
267
|
+
lg ? "gap-px overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--border)]" : "gap-y-0.5"
|
|
268
|
+
),
|
|
241
269
|
children: [
|
|
242
270
|
/* @__PURE__ */ jsx(
|
|
243
271
|
"div",
|
|
244
272
|
{
|
|
245
273
|
role: "row",
|
|
246
|
-
className:
|
|
247
|
-
|
|
274
|
+
className: cn(
|
|
275
|
+
"grid grid-cols-7 text-center font-medium",
|
|
276
|
+
lg ? "gap-px text-xs text-[var(--text-muted)]" : "text-[10px] uppercase text-[var(--text-placeholder)]"
|
|
277
|
+
),
|
|
278
|
+
children: weekdayLabels.map((w, i) => /* @__PURE__ */ jsx(
|
|
279
|
+
"div",
|
|
280
|
+
{
|
|
281
|
+
role: "columnheader",
|
|
282
|
+
"aria-label": w.long,
|
|
283
|
+
className: lg ? "bg-[var(--bg-surface)] py-2" : "py-0.5",
|
|
284
|
+
children: lg ? w.short : w.narrow
|
|
285
|
+
},
|
|
286
|
+
i
|
|
287
|
+
))
|
|
248
288
|
}
|
|
249
289
|
),
|
|
250
290
|
weeks.map((week, wi) => (
|
|
251
291
|
// No column gap: the days of a range join into ONE band. With a gap each day
|
|
252
292
|
// was its own tinted box, and a selected fortnight read as fourteen chips.
|
|
253
|
-
/* @__PURE__ */ jsx("div", { role: "row", className: "grid grid-cols-7", children: week.map((d, di) => {
|
|
254
|
-
if (!d)
|
|
293
|
+
/* @__PURE__ */ jsx("div", { role: "row", className: cn("grid grid-cols-7", lg && "gap-px"), children: week.map((d, di) => {
|
|
294
|
+
if (!d) {
|
|
295
|
+
return /* @__PURE__ */ jsx(
|
|
296
|
+
"div",
|
|
297
|
+
{
|
|
298
|
+
role: "gridcell",
|
|
299
|
+
className: lg ? cn(LG_CELL_HEIGHT, "bg-[var(--bg-surface-2)]") : "h-8"
|
|
300
|
+
},
|
|
301
|
+
di
|
|
302
|
+
);
|
|
303
|
+
}
|
|
255
304
|
const iso = toLocalIso(d);
|
|
256
305
|
const disabled = isDisabled(d);
|
|
257
306
|
const isStart = !disabled && fromDate && sameYmd(d, fromDate);
|
|
@@ -259,7 +308,23 @@ function MiniCalendar({
|
|
|
259
308
|
const isToday = sameYmd(d, today);
|
|
260
309
|
const isInRange = !disabled && inRange(d) && !isStart && !isEnd;
|
|
261
310
|
const isActive = iso === activeIso;
|
|
262
|
-
const
|
|
311
|
+
const isSelected = Boolean(isStart || isEnd || isInRange);
|
|
312
|
+
const label = dayNumber.format(d.getDate());
|
|
313
|
+
const content = renderDay?.(d, {
|
|
314
|
+
iso,
|
|
315
|
+
label,
|
|
316
|
+
today: isToday,
|
|
317
|
+
disabled,
|
|
318
|
+
selected: isSelected,
|
|
319
|
+
rangeStart: Boolean(isStart),
|
|
320
|
+
rangeEnd: Boolean(isEnd),
|
|
321
|
+
inRange: isInRange,
|
|
322
|
+
active: isActive,
|
|
323
|
+
size
|
|
324
|
+
});
|
|
325
|
+
const hasContent = content != null && content !== false && content !== "";
|
|
326
|
+
const contentId = `${id}-day-${iso}`;
|
|
327
|
+
const banded = !lg && hasBand && !disabled && (isStart || isEnd || isInRange);
|
|
263
328
|
const lastOfMonth2 = d.getDate() === daysInMonth(d);
|
|
264
329
|
const band = banded ? cn(
|
|
265
330
|
"pointer-events-none absolute inset-y-0 bg-[var(--brand-bg)]",
|
|
@@ -269,39 +334,78 @@ function MiniCalendar({
|
|
|
269
334
|
isStart && (di === 6 || lastOfMonth2) && "hidden",
|
|
270
335
|
isEnd && (di === 0 || d.getDate() === 1) && "hidden"
|
|
271
336
|
) : null;
|
|
272
|
-
return /* @__PURE__ */ jsxs(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
"
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
"aria-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
337
|
+
return /* @__PURE__ */ jsxs(
|
|
338
|
+
"div",
|
|
339
|
+
{
|
|
340
|
+
role: "none",
|
|
341
|
+
className: cn(
|
|
342
|
+
"relative flex",
|
|
343
|
+
lg ? "min-w-0" : "h-8 items-center justify-center"
|
|
344
|
+
),
|
|
345
|
+
children: [
|
|
346
|
+
band && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: band }),
|
|
347
|
+
/* @__PURE__ */ jsx(
|
|
348
|
+
"button",
|
|
349
|
+
{
|
|
350
|
+
type: "button",
|
|
351
|
+
role: "gridcell",
|
|
352
|
+
"data-iso": iso,
|
|
353
|
+
tabIndex: isActive ? 0 : -1,
|
|
354
|
+
"aria-label": labels.day(formatDay(d)),
|
|
355
|
+
"aria-describedby": hasContent ? contentId : void 0,
|
|
356
|
+
"aria-selected": isSelected,
|
|
357
|
+
"aria-disabled": disabled || void 0,
|
|
358
|
+
"aria-current": isToday ? "date" : void 0,
|
|
359
|
+
onClick: () => handleClick(d),
|
|
360
|
+
onKeyDown: onDayKeyDown,
|
|
361
|
+
className: lg ? cn(
|
|
362
|
+
"flex w-full min-w-0 flex-col items-stretch gap-1 overflow-hidden p-1.5 text-start text-xs transition-colors",
|
|
363
|
+
LG_CELL_HEIGHT,
|
|
364
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--brand)]",
|
|
365
|
+
disabled ? "cursor-not-allowed bg-[var(--bg-surface)] text-[var(--text-placeholder)]" : isSelected ? "bg-[var(--brand-bg)] text-[var(--text-primary)] hover:bg-[var(--brand-bg-hover)]" : "bg-[var(--bg-surface)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"
|
|
366
|
+
) : cn(
|
|
367
|
+
"relative size-8 rounded-full text-xs tabular-nums transition-colors",
|
|
368
|
+
// A grid you can walk with the keyboard needs to show where the
|
|
369
|
+
// keyboard IS. Inset because the cells sit half a pixel apart and
|
|
370
|
+
// an outset ring would be drawn over by its neighbours; the
|
|
371
|
+
// colour flips on the selected days for the reason the numpad's
|
|
372
|
+
// "Done" key does — a --brand ring on a --brand fill is a ring
|
|
373
|
+
// that exists only in the DOM.
|
|
374
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset",
|
|
375
|
+
isStart || isEnd ? "focus-visible:ring-[var(--brand-contrast)]" : "focus-visible:ring-[var(--brand)]",
|
|
376
|
+
disabled ? "cursor-not-allowed text-[var(--text-placeholder)]" : isStart || isEnd ? "bg-[var(--brand)] text-[var(--brand-contrast)] hover:bg-[var(--brand-hover)]" : isInRange ? "font-medium text-[var(--brand-muted)] hover:bg-[var(--brand-bg-hover)]" : "text-[var(--text-primary)] hover:bg-[var(--bg-hover)]",
|
|
377
|
+
isToday && !isStart && !isEnd && !isInRange && !disabled && "ring-1 ring-inset ring-[var(--border-strong)]"
|
|
378
|
+
),
|
|
379
|
+
children: lg ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
380
|
+
/* @__PURE__ */ jsx(
|
|
381
|
+
"span",
|
|
382
|
+
{
|
|
383
|
+
className: cn(
|
|
384
|
+
"inline-flex size-6 shrink-0 items-center justify-center self-start rounded-full tabular-nums",
|
|
385
|
+
isStart || isEnd ? "bg-[var(--brand)] font-semibold text-[var(--brand-contrast)]" : isToday && !disabled ? "font-semibold text-[var(--brand)] ring-1 ring-inset ring-[var(--brand)]" : isInRange && "font-medium text-[var(--brand-muted)]"
|
|
386
|
+
),
|
|
387
|
+
children: label
|
|
388
|
+
}
|
|
389
|
+
),
|
|
390
|
+
hasContent && /* @__PURE__ */ jsx("span", { id: contentId, className: "flex min-w-0 flex-col gap-0.5", children: content })
|
|
391
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
392
|
+
label,
|
|
393
|
+
hasContent && /* @__PURE__ */ jsx(
|
|
394
|
+
"span",
|
|
395
|
+
{
|
|
396
|
+
id: contentId,
|
|
397
|
+
className: "pointer-events-none absolute inset-x-0 bottom-0.5 flex justify-center gap-px leading-none",
|
|
398
|
+
children: content
|
|
399
|
+
}
|
|
400
|
+
)
|
|
401
|
+
] })
|
|
402
|
+
},
|
|
403
|
+
di
|
|
404
|
+
)
|
|
405
|
+
]
|
|
406
|
+
},
|
|
407
|
+
di
|
|
408
|
+
);
|
|
305
409
|
}) }, wi)
|
|
306
410
|
))
|
|
307
411
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/mini-calendar.tsx"],"sourcesContent":["import { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent } from \"react\";\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { parseIsoDate, sameYmd, toLocalIso } from \"../lib/dates\";\nimport { useKitLabels, useKitLocale, useKitWeekStart } from \"../i18n/kit-labels\";\n\n/**\n * Every string this calendar can speak — the `miniCalendar` namespace of\n * `<UiKitProvider labels>`, overridable per instance through the `labels` prop. The\n * package carries no translation catalog (see the README), so the English defaults\n * below are a starting point and not a commitment. `previousMonth`/`nextMonth` were already props for the\n * reason the audit records: a German app reached this component through a bare\n * re-export and announced its two icon-only arrows in English on a page whose\n * `<html lang>` says `de`.\n *\n * The month caption is deliberately NOT here. It is produced by `Intl` from the\n * `locale` prop, so it is already in the user's language, and the grid takes its\n * accessible name from that element rather than from a string someone has to\n * translate a second time.\n *\n * The ones that interpolate a date are FUNCTIONS taking the formatted date, for the\n * reason `DataTableLabels` gives for its counted strings: a value glued into an\n * English template literal is untranslatable, and the grammar around a date moves\n * with it in most languages.\n */\nexport interface MiniCalendarLabels {\n previousMonth: string;\n nextMonth: string;\n /**\n * Accessible name of one day cell, given that day formatted in `locale`\n * (\"Monday, 14 September 2026\").\n *\n * The name has to carry the WHOLE date. The visible text of a cell is the day\n * number alone, and \"14\" on its own tells a screen-reader user nothing — not the\n * month they have arrowed into, not the year, not the weekday they are picking.\n */\n day: (date: string) => string;\n /** Range mode: what the NEXT click will set. Spoken after every click, and the\n * grid's description while the panel is open. */\n chooseStart: string;\n chooseEnd: string;\n /** Range mode: spoken after the click that set the start. */\n startSelected: (date: string) => string;\n /** Range mode: spoken after the click that completed the range. */\n rangeSelected: (from: string, to: string) => string;\n}\n\n/** English defaults. Exported as the `miniCalendar` namespace of `UiKitLabels`\n * (src/i18n), the complete reference a translation is written against. */\nexport const DEFAULT_MINI_CALENDAR_LABELS: MiniCalendarLabels = {\n previousMonth: \"Previous month\",\n nextMonth: \"Next month\",\n day: (date) => date,\n chooseStart: \"Choose a start date\",\n chooseEnd: \"Choose an end date\",\n startSelected: (date) => `${date} selected as the start. Choose an end date.`,\n rangeSelected: (from, to) => `${from} to ${to} selected. Choose a start date to begin again.`,\n};\n\n/**\n * How a day is spoken. The weekday is in there on purpose: picking a date is very\n * often picking a *day of the week* (\"the first Monday\"), and a grid that makes you\n * count columns to find one is a grid you cannot use without sight.\n */\nconst DAY_NAME_FORMAT: Intl.DateTimeFormatOptions = {\n weekday: \"long\",\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n};\n\n/**\n * `onSelect` is omitted from the `<div>` attributes and kept as this component's own:\n * the DOM event of that name is a text-selection event taking one argument, and this one\n * answers with the two ISO dates a range is made of. Everything else a `<div>` takes\n * passes through to the root, so a tour anchor or a test id can find the calendar —\n * before this, a closed prop list dropped both (audit §api-design).\n */\nexport interface MiniCalendarProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> {\n from: string;\n to: string;\n /**\n * BCP 47 tag for the month caption, the weekday heads, the day numbers and the\n * spoken dates. Optional since the kit grew `<UiKitProvider locale>`: a calendar\n * NESTED in another kit component (the data table's date filter) has no call site\n * of its own to pass one at, so it reads the provider's. Without either, `Intl`\n * uses the runtime's default.\n */\n locale?: string;\n /**\n * The weekday the grid starts on, `0` = Sunday … `6` = Saturday (as `Date#getDay`).\n * Defaults to the LOCALE's first day — Monday in most of Europe, Sunday in the US,\n * Saturday in much of the Arab world — which is what the user's own wall calendar\n * does. It was hard-wired to Monday before, which is wrong for most of the people\n * who use a Sunday-first calendar and invisible to the people who wrote this one.\n *\n * Resolved as: this prop, else `<UiKitProvider weekStartsOn>`, else the locale's\n * week info, else Monday.\n */\n weekStartsOn?: WeekDay;\n onSelect: (from: string, to: string) => void;\n /** `\"range\"` (default) = two-click from→to; `\"single\"` = one click selects a\n * single day (emitted as `onSelect(iso, iso)`). */\n mode?: \"single\" | \"range\";\n /** Optional inclusive ISO bounds; days outside `[min, max]` are disabled. */\n min?: string;\n max?: string;\n /** User-facing strings; see {@link MiniCalendarLabels}. */\n labels?: Partial<MiniCalendarLabels>;\n /**\n * Take focus to the day the grid opens on — the selected one, or today — when this\n * calendar mounts. For a panel that opened BECAUSE the user asked to pick a date:\n * landing them on the day they are editing is the difference between one arrow key\n * and a hunt through 42 cells.\n *\n * Off by default, and not called `autoFocus`, because it is not the same promise as\n * the DOM attribute of that name: a calendar rendered INLINE (the data-table's\n * column filter draws one above its from/to inputs) must not take the page's focus\n * merely by existing.\n */\n focusOnOpen?: boolean;\n /** Extra classes for the calendar's root. */\n className?: string;\n}\n\nexport type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * The first day of the week in `locale`, as a `Date#getDay` index.\n *\n * `Intl.Locale#getWeekInfo()` is the standard spelling; V8 shipped it first as the\n * `weekInfo` accessor, and Firefox has neither yet — hence both reads and a Monday\n * fallback, which is ISO 8601 and what this grid did unconditionally before. Its\n * `firstDay` counts 1 = Monday … 7 = Sunday, so `% 7` maps it onto `getDay`.\n */\nfunction localeWeekStart(locale: string | undefined): WeekDay {\n try {\n const tag = locale ?? new Intl.DateTimeFormat().resolvedOptions().locale;\n const loc = new Intl.Locale(tag) as Intl.Locale & {\n getWeekInfo?: () => { firstDay: number };\n weekInfo?: { firstDay: number };\n };\n const firstDay = (loc.getWeekInfo?.() ?? loc.weekInfo)?.firstDay;\n if (typeof firstDay === \"number\") return (firstDay % 7) as WeekDay;\n } catch {\n // A malformed tag throws from `Intl.Locale`; the calendar still has to render.\n }\n return 1;\n}\n\n/** Where `d` sits in a week that starts on `weekStart` (the first column = 0). */\nconst weekdayIndex = (d: Date, weekStart: WeekDay) => (d.getDay() - weekStart + 7) % 7;\n\n/** Move `d` by whole months, keeping the day of the month where the target has one.\n * `setMonth` alone ROLLS OVER — 31 January + 1 month is 3 March — which would skip\n * February entirely for anyone paging through the year with PageDown. */\nfunction stepMonths(d: Date, months: number): Date {\n const day = d.getDate();\n const out = new Date(d.getFullYear(), d.getMonth() + months, 1);\n const lastOfTarget = new Date(out.getFullYear(), out.getMonth() + 1, 0).getDate();\n out.setDate(Math.min(day, lastOfTarget));\n return out;\n}\n\n/**\n * Month-grid range picker used by the data-table date filter. Click once to set\n * the start (and clear the end), click again to set the end; clicking with a\n * full range already selected starts over. The week starts where the locale's does\n * (or at `weekStartsOn`), and every label comes from `Intl` in that locale.\n * In `single` mode each click selects one day. Days outside `min`/`max` (when\n * given) are disabled.\n *\n * **It is a grid, in the APG sense** (audit §a11y, \"MiniCalendar is unusable with a\n * keyboard or screen reader\"). Before this it was 42 buttons in a `grid-cols-7` div:\n * every one of them in the tab order, none of them saying which date it was, and no\n * way to reach next month without a mouse. Now the month is a `role=\"grid\"` of rows\n * and `gridcell`s, exactly one day is tabbable (the roving tabindex), and the arrows\n * walk the calendar the way the pattern says — day, week, month — crossing into the\n * neighbouring month by MOVING the grid rather than stopping at its edge.\n *\n * Out-of-range days are `aria-disabled` rather than `disabled`, which is the APG\n * guidance and not a shortcut: a `disabled` button cannot be focused, so a bounded\n * month would have holes that the roving tabindex falls into. They stay reachable and\n * readable, and the click handler is what refuses them.\n */\nexport function MiniCalendar({\n from,\n to,\n locale: localeProp,\n weekStartsOn,\n onSelect,\n mode = \"range\",\n min,\n max,\n labels: labelsProp,\n focusOnOpen,\n className,\n ...rest\n}: MiniCalendarProps) {\n const labels = useKitLabels(\"miniCalendar\", DEFAULT_MINI_CALENDAR_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const providerWeekStart = useKitWeekStart();\n const weekStart = useMemo(\n () => weekStartsOn ?? providerWeekStart ?? localeWeekStart(locale),\n [weekStartsOn, providerWeekStart, locale],\n );\n // Day numbers through `Intl` too: `getDate()` is always ASCII digits, and a locale\n // that writes its own (Arabic, Persian, Bengali …) would get a grid of foreign\n // numerals under a caption in its own script.\n const dayNumber = useMemo(() => new Intl.NumberFormat(locale), [locale]);\n const fromDate = parseIsoDate(from);\n const toDate = parseIsoDate(to);\n const minDate = min ? parseIsoDate(min) : null;\n const maxDate = max ? parseIsoDate(max) : null;\n const isDisabled = (d: Date) => Boolean((minDate && d < minDate) || (maxDate && d > maxDate));\n\n const gridRef = useRef<HTMLDivElement>(null);\n const id = useId();\n const monthId = `${id}-month`;\n const hintId = `${id}-hint`;\n const { announce, regionProps } = useAnnounce();\n\n /**\n * The day that holds the tab order, and with it the visible month — one piece of\n * state, not two, because they cannot be allowed to disagree: a tabbable cell in a\n * month that is not on screen is a tab stop that focuses nothing.\n *\n * Starts on the selection, or on today when there is none, pulled inside `[min, max]`\n * so a bounded calendar opens on a day it will actually let you pick.\n */\n const [activeIso, setActiveIso] = useState(() => {\n const start = fromDate ?? toDate ?? new Date();\n if (minDate && start < minDate) return toLocalIso(minDate);\n if (maxDate && start > maxDate) return toLocalIso(maxDate);\n return toLocalIso(start);\n });\n\n // Follow the caller's value when it changes from outside (a preset, a cleared\n // filter, a form reset). Written as a render-phase adjustment rather than an effect\n // so the grid never paints one frame on the old month.\n const [lastValue, setLastValue] = useState({ from, to });\n if (lastValue.from !== from || lastValue.to !== to) {\n // Follow the end that actually CHANGED, not `from` unconditionally. Picking the\n // end of a range that spans months used to send the grid back to the start's\n // month — which with a roving tabindex means the cell the user just activated is\n // no longer rendered, and their focus goes with it to `<body>`.\n const changed = lastValue.from !== from ? from : to;\n setLastValue({ from, to });\n const next = parseIsoDate(changed) ?? fromDate ?? toDate;\n if (next && toLocalIso(next) !== activeIso) setActiveIso(toLocalIso(next));\n }\n\n const activeDate = parseIsoDate(activeIso) ?? new Date();\n const view = { year: activeDate.getFullYear(), month: activeDate.getMonth() };\n\n const firstOfMonth = new Date(view.year, view.month, 1);\n const lastOfMonth = new Date(view.year, view.month + 1, 0);\n // Leading blanks up to the first of the month, counted from the week's first day.\n const startWeekday = weekdayIndex(firstOfMonth, weekStart);\n const cells: (Date | null)[] = [];\n for (let i = 0; i < startWeekday; i++) cells.push(null);\n for (let d = 1; d <= lastOfMonth.getDate(); d++) cells.push(new Date(view.year, view.month, d));\n while (cells.length % 7 !== 0) cells.push(null);\n const weeks: (Date | null)[][] = [];\n for (let i = 0; i < cells.length; i += 7) weeks.push(cells.slice(i, i + 7));\n\n const monthLabel = firstOfMonth.toLocaleDateString(locale, { month: \"long\", year: \"numeric\" });\n const formatDay = (d: Date) => d.toLocaleDateString(locale, DAY_NAME_FORMAT);\n\n // Weekday labels via locale, from the week's first day: the narrow one for the\n // column head, the long one as its accessible name — \"M\" is the same letter for\n // Monday, March and May, and a column header is the one place a screen reader\n // reads it on its own.\n const weekdayLabels = useMemo(() => {\n const ref = new Date(2024, 0, 7 + weekStart); // 7 January 2024 was a Sunday\n return Array.from({ length: 7 }, (_, i) => {\n const d = new Date(ref);\n d.setDate(ref.getDate() + i);\n return {\n narrow: d.toLocaleDateString(locale, { weekday: \"narrow\" }),\n long: d.toLocaleDateString(locale, { weekday: \"long\" }),\n };\n });\n }, [locale, weekStart]);\n\n /**\n * A day whose cell has to take focus once it exists. Arrowing off the edge of the\n * month renders a different month, so the element to focus is not in the DOM at the\n * time the key is handled — it is one commit away.\n */\n const pendingFocus = useRef<string | null>(null);\n useEffect(() => {\n const iso = pendingFocus.current;\n if (!iso) return;\n pendingFocus.current = null;\n gridRef.current?.querySelector<HTMLElement>(`[data-iso=\"${iso}\"]`)?.focus();\n });\n\n // The roving tab stop is the day to open on, so there is nothing else to work out\n // here — it is already the selection, or today, pulled inside the bounds.\n useEffect(() => {\n if (!focusOnOpen) return;\n gridRef.current?.querySelector<HTMLElement>('[tabindex=\"0\"]')?.focus();\n }, [focusOnOpen]);\n\n /** Move the roving tabindex, and the month with it when the day lands outside. */\n const moveTo = (d: Date, focus: boolean) => {\n const iso = toLocalIso(d);\n if (iso === activeIso) return;\n if (focus) pendingFocus.current = iso;\n setActiveIso(iso);\n };\n\n /**\n * On each day rather than once on the grid: the cell is where focus is, and a\n * container listening for keys it cannot itself receive is the shape\n * `jsx-a11y/interactive-supports-focus` objects to. One shared function, not a\n * closure per cell — it reads the active day from state, which is always the\n * focused one.\n */\n const onDayKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n const next = new Date(activeDate);\n // ←/→ are \"previous/next day\" along the READING direction: the grid's columns run\n // right-to-left in RTL (it is a CSS grid, so the browser mirrors it), and ArrowLeft\n // there moves to the day that sits to the left — the next one.\n const step = horizontalStep(e.key, e.currentTarget);\n switch (step ? \"horizontal\" : e.key) {\n case \"horizontal\":\n next.setDate(next.getDate() + step);\n break;\n case \"ArrowUp\":\n next.setDate(next.getDate() - 7);\n break;\n case \"ArrowDown\":\n next.setDate(next.getDate() + 7);\n break;\n case \"Home\":\n next.setDate(next.getDate() - weekdayIndex(next, weekStart));\n break;\n case \"End\":\n next.setDate(next.getDate() + (6 - weekdayIndex(next, weekStart)));\n break;\n // Shift+Page is the year step, as in the APG example. It is the only way to\n // reach a birth year without holding PageUp for four hundred keystrokes.\n case \"PageUp\":\n next.setTime(stepMonths(next, e.shiftKey ? -12 : -1).getTime());\n break;\n case \"PageDown\":\n next.setTime(stepMonths(next, e.shiftKey ? 12 : 1).getTime());\n break;\n default:\n return;\n }\n // Before the no-op check: every key above also scrolls the panel this calendar\n // usually sits in, and a day that cannot move still must not move the page.\n e.preventDefault();\n moveTo(next, true);\n };\n\n const moveMonth = (delta: number) => {\n // Focus stays on the arrow button the user is pressing — only the grid moves.\n moveTo(stepMonths(activeDate, delta), false);\n };\n\n const handleClick = (d: Date) => {\n // The guard that `disabled` used to be. Out-of-range days are focusable on\n // purpose (see the component note), so refusing the click is this function's job.\n if (isDisabled(d)) return;\n const iso = toLocalIso(d);\n // Keep the tab order on the day that was just activated even if the caller\n // ignores the selection — a controlled component may reject it, and the roving\n // tabindex is this component's own state, not an echo of the value.\n moveTo(d, false);\n if (mode === \"single\") {\n onSelect(iso, iso);\n return;\n }\n const f = parseIsoDate(from);\n const tt = parseIsoDate(to);\n if (!f || (f && tt)) {\n // start a new selection\n onSelect(iso, \"\");\n announce(labels.startSelected(formatDay(d)));\n return;\n }\n // f set, tt empty\n if (d < f) {\n onSelect(iso, toLocalIso(f));\n announce(labels.rangeSelected(formatDay(d), formatDay(f)));\n } else {\n onSelect(toLocalIso(f), iso);\n announce(labels.rangeSelected(formatDay(f), formatDay(d)));\n }\n };\n\n const today = new Date();\n const hasBand = Boolean(fromDate && toDate && !sameYmd(fromDate, toDate));\n const daysInMonth = (d: Date) => new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();\n const inRange = (d: Date) => {\n if (!fromDate || !toDate) return false;\n return d >= fromDate && d <= toDate;\n };\n\n // What the next click does. A range is two clicks and nothing on screen says which\n // one you are on — sighted users read it off the highlighted start.\n const awaitingEnd = Boolean(fromDate) && !toDate;\n const rangeHint = awaitingEnd ? labels.chooseEnd : labels.chooseStart;\n\n return (\n // The caller's classes come last, so tailwind-merge lets them win the way\n // `className` does everywhere else in the kit; `...rest` first, as in the rest of\n // this wave, so nothing from outside can take the grid's own wiring away.\n <div {...rest} className={cn(\"select-none\", className)}>\n <div className=\"flex items-center justify-between pb-1\">\n <button\n type=\"button\"\n onClick={() => moveMonth(-1)}\n aria-label={labels.previousMonth}\n className=\"rounded p-1 text-[var(--text-muted)] hover:bg-[var(--bg-hover)]\"\n >\n {/* Mirrored in RTL: \"previous\" points to the reading START, which is right. */}\n <ChevronLeft className=\"size-4 rtl:-scale-x-100\" aria-hidden />\n </button>\n {/* Named by this element rather than by a string of its own, and `aria-live`\n so paging months says which month you have landed on — the caption is the\n only thing on screen that changes when the grid moves, and the user\n pressing the arrow is not inside the grid to hear the cells change. */}\n <div\n id={monthId}\n aria-live=\"polite\"\n className=\"text-xs font-medium capitalize text-[var(--text-secondary)]\"\n >\n {monthLabel}\n </div>\n <button\n type=\"button\"\n onClick={() => moveMonth(1)}\n aria-label={labels.nextMonth}\n className=\"rounded p-1 text-[var(--text-muted)] hover:bg-[var(--bg-hover)]\"\n >\n <ChevronRight className=\"size-4 rtl:-scale-x-100\" aria-hidden />\n </button>\n </div>\n <div\n ref={gridRef}\n role=\"grid\"\n aria-labelledby={monthId}\n aria-describedby={mode === \"range\" ? hintId : undefined}\n className=\"grid gap-y-0.5\"\n >\n <div\n role=\"row\"\n className=\"grid grid-cols-7 text-center text-[10px] font-medium uppercase text-[var(--text-placeholder)]\"\n >\n {weekdayLabels.map((w, i) => (\n <div key={i} role=\"columnheader\" aria-label={w.long} className=\"py-0.5\">\n {w.narrow}\n </div>\n ))}\n </div>\n {weeks.map((week, wi) => (\n // No column gap: the days of a range join into ONE band. With a gap each day\n // was its own tinted box, and a selected fortnight read as fourteen chips.\n <div key={wi} role=\"row\" className=\"grid grid-cols-7\">\n {week.map((d, di) => {\n // The padding cells still have to BE cells, or the rows are ragged and\n // a screen reader's \"column 3\" stops meaning Wednesday.\n if (!d) return <div key={di} role=\"gridcell\" className=\"h-8\" />;\n const iso = toLocalIso(d);\n const disabled = isDisabled(d);\n const isStart = !disabled && fromDate && sameYmd(d, fromDate);\n const isEnd = !disabled && toDate && sameYmd(d, toDate);\n const isToday = sameYmd(d, today);\n const isInRange = !disabled && inRange(d) && !isStart && !isEnd;\n const isActive = iso === activeIso;\n // The band behind the day: full width between the ends, half width at an\n // end (so the round endpoint sits ON the band's tip), rounded where a row\n // or the month breaks it. Only when both ends exist and differ — a lone\n // start is a dot, not a band of one.\n const banded =\n hasBand && !disabled && (isStart || isEnd || isInRange);\n const lastOfMonth = d.getDate() === daysInMonth(d);\n const band = banded\n ? cn(\n \"pointer-events-none absolute inset-y-0 bg-[var(--brand-bg)]\",\n isStart ? \"start-1/2 end-0\" : isEnd ? \"start-0 end-1/2\" : \"inset-x-0\",\n isInRange && (di === 0 || d.getDate() === 1) && \"rounded-s-full\",\n isInRange && (di === 6 || lastOfMonth) && \"rounded-e-full\",\n isStart && (di === 6 || lastOfMonth) && \"hidden\",\n isEnd && (di === 0 || d.getDate() === 1) && \"hidden\",\n )\n : null;\n return (\n <div key={di} role=\"none\" className=\"relative flex h-8 items-center justify-center\">\n {band && <span aria-hidden className={band} />}\n <button\n key={di}\n type=\"button\"\n role=\"gridcell\"\n data-iso={iso}\n // The roving tabindex: ONE tab stop for the whole month. Every day\n // being tabbable meant 31 stops between a date field and the next\n // control, which is the same reason the pattern exists.\n tabIndex={isActive ? 0 : -1}\n aria-label={labels.day(formatDay(d))}\n aria-selected={Boolean(isStart || isEnd || isInRange)}\n aria-disabled={disabled || undefined}\n aria-current={isToday ? \"date\" : undefined}\n onClick={() => handleClick(d)}\n onKeyDown={onDayKeyDown}\n className={cn(\n \"relative size-8 rounded-full text-xs tabular-nums transition-colors\",\n // A grid you can walk with the keyboard needs to show where the\n // keyboard IS. Inset because the cells sit half a pixel apart and\n // an outset ring would be drawn over by its neighbours; the\n // colour flips on the selected days for the reason the numpad's\n // \"Done\" key does — a --brand ring on a --brand fill is a ring\n // that exists only in the DOM.\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset\",\n isStart || isEnd\n ? \"focus-visible:ring-[var(--brand-contrast)]\"\n : \"focus-visible:ring-[var(--brand)]\",\n disabled\n ? \"cursor-not-allowed text-[var(--text-placeholder)]\"\n // The two selected states are the BRAND, not a fixed sky: the endpoints\n // are the solid fill and the days between them its soft tint. Hardcoding\n // them left an app that changed `--brand` with a calendar in the old\n // colour (docs/module-audit-2026-09-22.md §theming). Both token pairs\n // flip light/dark themselves, so there is no `dark:` partner to carry —\n // one would override the token and bring the hardcoded hue back.\n : isStart || isEnd\n ? \"bg-[var(--brand)] text-[var(--brand-contrast)] hover:bg-[var(--brand-hover)]\"\n : isInRange\n ? \"font-medium text-[var(--brand-muted)] hover:bg-[var(--brand-bg-hover)]\"\n : \"text-[var(--text-primary)] hover:bg-[var(--bg-hover)]\",\n isToday && !isStart && !isEnd && !isInRange && !disabled && \"ring-1 ring-inset ring-[var(--border-strong)]\",\n )}\n >\n {dayNumber.format(d.getDate())}\n </button>\n </div>\n );\n })}\n </div>\n ))}\n </div>\n {/* `sr-only-fixed`, not `sr-only`: this renders inside whatever panel a consumer\n opens it in, and there is no wrapper we can require to be `relative` — see\n the note on the class in tokens.css. */}\n {mode === \"range\" && (\n <span id={hintId} className=\"sr-only-fixed\">\n {rangeHint}\n </span>\n )}\n <span {...regionProps} />\n </div>\n );\n}\n"],"mappings":";AAgaM,SAQI,KARJ;AAhaN,SAAS,WAAW,OAAO,SAAS,QAAQ,gBAAgB;AAE5D,SAAS,aAAa,oBAAoB;AAC1C,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,cAAc,SAAS,kBAAkB;AAClD,SAAS,cAAc,cAAc,uBAAuB;AA6CrD,MAAM,+BAAmD;AAAA,EAC9D,eAAe;AAAA,EACf,WAAW;AAAA,EACX,KAAK,CAAC,SAAS;AAAA,EACf,aAAa;AAAA,EACb,WAAW;AAAA,EACX,eAAe,CAAC,SAAS,GAAG,IAAI;AAAA,EAChC,eAAe,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;AAC/C;AAOA,MAAM,kBAA8C;AAAA,EAClD,SAAS;AAAA,EACT,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,WAAU,iBACzB,qBACH;AAAA,MAEF,oBAAC,UAAM,GAAG,aAAa;AAAA,OACzB;AAAA;AAEJ;","names":["lastOfMonth"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/mini-calendar.tsx"],"sourcesContent":["import { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { horizontalStep } from \"../lib/direction\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport {\n addMonthsClamped,\n localeWeekStart,\n monthKey,\n parseIsoDate,\n sameYmd,\n toLocalIso,\n} from \"../lib/dates\";\nimport { useKitLabels, useKitLocale, useKitWeekStart } from \"../i18n/kit-labels\";\n\n/**\n * Every string this calendar can speak — the `miniCalendar` namespace of\n * `<UiKitProvider labels>`, overridable per instance through the `labels` prop. The\n * package carries no translation catalog (see the README), so the English defaults\n * below are a starting point and not a commitment. `previousMonth`/`nextMonth` were already props for the\n * reason the audit records: a German app reached this component through a bare\n * re-export and announced its two icon-only arrows in English on a page whose\n * `<html lang>` says `de`.\n *\n * The month caption is deliberately NOT here. It is produced by `Intl` from the\n * `locale` prop, so it is already in the user's language, and the grid takes its\n * accessible name from that element rather than from a string someone has to\n * translate a second time.\n *\n * The ones that interpolate a date are FUNCTIONS taking the formatted date, for the\n * reason `DataTableLabels` gives for its counted strings: a value glued into an\n * English template literal is untranslatable, and the grammar around a date moves\n * with it in most languages.\n */\nexport interface MiniCalendarLabels {\n previousMonth: string;\n nextMonth: string;\n /**\n * Accessible name of one day cell, given that day formatted in `locale`\n * (\"Monday, 14 September 2026\").\n *\n * The name has to carry the WHOLE date. The visible text of a cell is the day\n * number alone, and \"14\" on its own tells a screen-reader user nothing — not the\n * month they have arrowed into, not the year, not the weekday they are picking.\n */\n day: (date: string) => string;\n /** Range mode: what the NEXT click will set. Spoken after every click, and the\n * grid's description while the panel is open. */\n chooseStart: string;\n chooseEnd: string;\n /** Range mode: spoken after the click that set the start. */\n startSelected: (date: string) => string;\n /** Range mode: spoken after the click that completed the range. */\n rangeSelected: (from: string, to: string) => string;\n}\n\n/** English defaults. Exported as the `miniCalendar` namespace of `UiKitLabels`\n * (src/i18n), the complete reference a translation is written against. */\nexport const DEFAULT_MINI_CALENDAR_LABELS: MiniCalendarLabels = {\n previousMonth: \"Previous month\",\n nextMonth: \"Next month\",\n day: (date) => date,\n chooseStart: \"Choose a start date\",\n chooseEnd: \"Choose an end date\",\n startSelected: (date) => `${date} selected as the start. Choose an end date.`,\n rangeSelected: (from, to) => `${from} to ${to} selected. Choose a start date to begin again.`,\n};\n\n/**\n * How a day is spoken. The weekday is in there on purpose: picking a date is very\n * often picking a *day of the week* (\"the first Monday\"), and a grid that makes you\n * count columns to find one is a grid you cannot use without sight.\n */\nconst DAY_NAME_FORMAT: Intl.DateTimeFormatOptions = {\n weekday: \"long\",\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n};\n\n/**\n * `onSelect` is omitted from the `<div>` attributes and kept as this component's own:\n * the DOM event of that name is a text-selection event taking one argument, and this one\n * answers with the two ISO dates a range is made of. Everything else a `<div>` takes\n * passes through to the root, so a tour anchor or a test id can find the calendar —\n * before this, a closed prop list dropped both (audit §api-design).\n */\nexport interface MiniCalendarProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> {\n /** The selection's start as \"YYYY-MM-DD\"; `\"\"` (the default) for none. */\n from?: string;\n /** The selection's end; `\"\"` (the default) for none. */\n to?: string;\n /**\n * BCP 47 tag for the month caption, the weekday heads, the day numbers and the\n * spoken dates. Optional since the kit grew `<UiKitProvider locale>`: a calendar\n * NESTED in another kit component (the data table's date filter) has no call site\n * of its own to pass one at, so it reads the provider's. Without either, `Intl`\n * uses the runtime's default.\n */\n locale?: string;\n /**\n * The weekday the grid starts on, `0` = Sunday … `6` = Saturday (as `Date#getDay`).\n * Defaults to the LOCALE's first day — Monday in most of Europe, Sunday in the US,\n * Saturday in much of the Arab world — which is what the user's own wall calendar\n * does. It was hard-wired to Monday before, which is wrong for most of the people\n * who use a Sunday-first calendar and invisible to the people who wrote this one.\n *\n * Resolved as: this prop, else `<UiKitProvider weekStartsOn>`, else the locale's\n * week info, else Monday.\n */\n weekStartsOn?: WeekDay;\n onSelect: (from: string, to: string) => void;\n /** `\"range\"` (default) = two-click from→to; `\"single\"` = one click selects a\n * single day (emitted as `onSelect(iso, iso)`). */\n mode?: \"single\" | \"range\";\n /** Optional inclusive ISO bounds; days outside `[min, max]` are disabled. */\n min?: string;\n max?: string;\n /** User-facing strings; see {@link MiniCalendarLabels}. */\n labels?: Partial<MiniCalendarLabels>;\n /**\n * Take focus to the day the grid opens on — the selected one, or today — when this\n * calendar mounts. For a panel that opened BECAUSE the user asked to pick a date:\n * landing them on the day they are editing is the difference between one arrow key\n * and a hunt through 42 cells.\n *\n * Off by default, and not called `autoFocus`, because it is not the same promise as\n * the DOM attribute of that name: a calendar rendered INLINE (the data-table's\n * column filter draws one above its from/to inputs) must not take the page's focus\n * merely by existing.\n */\n focusOnOpen?: boolean;\n /**\n * `\"sm\"` (default) is the compact picker: 32px round days, the size the date\n * pickers and the data-table filter draw. `\"lg\"` is a MONTH VIEW for a page — tall\n * cells in a ruled grid, the day number in the top corner and {@link renderDay}'s\n * content under it — the calendar a planner page hand-built before this existed.\n * Both are the same grid underneath: the same roles, roving tabindex, keys, RTL\n * mirroring and week start.\n */\n size?: \"sm\" | \"lg\";\n /**\n * Custom content for one day: events, an amount, a dot. Called for every day of the\n * month on show; return `null` for none.\n *\n * ⚠️ **It renders INSIDE the day's button** — a dot under the number at `\"sm\"`, a\n * column under it at `\"lg\"` — so it must not be interactive: no links, no buttons,\n * no inputs. A control inside a control is invalid HTML, and a screen reader lands\n * on the day and never reaches what is inside it. Events that are themselves\n * clickable are shown here as plain text, and the DAY is what is clicked: pass\n * `mode=\"single\"` and let `onSelect` open a day panel (a drawer, a popover) that\n * lists that day's events as real links.\n *\n * The day's accessible name stays the full date; this content is attached to it as\n * its DESCRIPTION (`aria-describedby`), so \"Monday, 14 September 2026\" is read\n * first and \"Rent due · Plumber\" after it. Anything decorative (a coloured dot)\n * should be `aria-hidden` or carry an `sr-only` word for what it means.\n */\n renderDay?: (day: Date, state: MiniCalendarDayState) => ReactNode;\n /**\n * The month on show, as \"YYYY-MM\". FOLLOWED rather than controlled, exactly like\n * `from`/`to`: when it changes the grid moves there, and in between the user pages\n * freely — every move to another month is reported through {@link onMonthChange}.\n * For a month page whose own header (a month picker, a Today button) drives the\n * calendar. Left out, the grid opens on the selection or today.\n */\n month?: string;\n /** Called with \"YYYY-MM\" whenever the USER moves the grid to another month (the\n * arrows, PageUp/PageDown, arrowing off the edge). */\n onMonthChange?: (month: string) => void;\n /**\n * Hide the built-in previous/next arrows and month caption, for a page that draws\n * its own. The caption is kept for assistive technology (visually hidden), because\n * it is what names the grid.\n */\n hideNavigation?: boolean;\n /** Extra classes for the calendar's root. */\n className?: string;\n}\n\n/** What {@link MiniCalendarProps.renderDay} is told about the day it draws. */\nexport interface MiniCalendarDayState {\n /** The day as \"YYYY-MM-DD\". */\n iso: string;\n /** The day number as drawn, in the calendar's locale. */\n label: string;\n today: boolean;\n /** Outside `min`/`max`. */\n disabled: boolean;\n /** Part of the selection — an end or a day between. */\n selected: boolean;\n rangeStart: boolean;\n rangeEnd: boolean;\n /** Strictly between the two ends of a range. */\n inRange: boolean;\n /** The day that holds the tab stop. */\n active: boolean;\n size: \"sm\" | \"lg\";\n}\n\nexport type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\n/** Where `d` sits in a week that starts on `weekStart` (the first column = 0). */\nconst weekdayIndex = (d: Date, weekStart: WeekDay) => (d.getDay() - weekStart + 7) % 7;\n\n/** Move `d` by whole months without rolling over (see {@link addMonthsClamped}). */\nconst stepMonths = addMonthsClamped;\n\n/** A month-view cell: tall enough for two or three event lines, shorter on a phone. */\nconst LG_CELL_HEIGHT = \"min-h-16 md:min-h-24\";\n\n/** The 1st of a \"YYYY-MM\" month, or null when absent or malformed. */\nconst monthStart = (key: string | undefined) => (key ? parseIsoDate(`${key}-01`) : null);\n\n/** `day`'s day of the month in `first`'s month, clamped to that month's length. */\nfunction sameDayIn(first: Date, day: Date): Date {\n const last = new Date(first.getFullYear(), first.getMonth() + 1, 0).getDate();\n return new Date(first.getFullYear(), first.getMonth(), Math.min(day.getDate(), last));\n}\n\n/**\n * Month-grid range picker used by the data-table date filter. Click once to set\n * the start (and clear the end), click again to set the end; clicking with a\n * full range already selected starts over. The week starts where the locale's does\n * (or at `weekStartsOn`), and every label comes from `Intl` in that locale.\n * In `single` mode each click selects one day. Days outside `min`/`max` (when\n * given) are disabled.\n *\n * **It is a grid, in the APG sense** (audit §a11y, \"MiniCalendar is unusable with a\n * keyboard or screen reader\"). Before this it was 42 buttons in a `grid-cols-7` div:\n * every one of them in the tab order, none of them saying which date it was, and no\n * way to reach next month without a mouse. Now the month is a `role=\"grid\"` of rows\n * and `gridcell`s, exactly one day is tabbable (the roving tabindex), and the arrows\n * walk the calendar the way the pattern says — day, week, month — crossing into the\n * neighbouring month by MOVING the grid rather than stopping at its edge.\n *\n * Out-of-range days are `aria-disabled` rather than `disabled`, which is the APG\n * guidance and not a shortcut: a `disabled` button cannot be focused, so a bounded\n * month would have holes that the roving tabindex falls into. They stay reachable and\n * readable, and the click handler is what refuses them.\n */\nexport function MiniCalendar({\n from = \"\",\n to = \"\",\n locale: localeProp,\n weekStartsOn,\n onSelect,\n mode = \"range\",\n min,\n max,\n labels: labelsProp,\n focusOnOpen,\n size = \"sm\",\n renderDay,\n month,\n onMonthChange,\n hideNavigation,\n className,\n ...rest\n}: MiniCalendarProps) {\n const lg = size === \"lg\";\n const labels = useKitLabels(\"miniCalendar\", DEFAULT_MINI_CALENDAR_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const providerWeekStart = useKitWeekStart();\n const weekStart = useMemo(\n () => weekStartsOn ?? providerWeekStart ?? localeWeekStart(locale),\n [weekStartsOn, providerWeekStart, locale],\n );\n // Day numbers through `Intl` too: `getDate()` is always ASCII digits, and a locale\n // that writes its own (Arabic, Persian, Bengali …) would get a grid of foreign\n // numerals under a caption in its own script.\n const dayNumber = useMemo(() => new Intl.NumberFormat(locale), [locale]);\n const fromDate = parseIsoDate(from);\n const toDate = parseIsoDate(to);\n const minDate = min ? parseIsoDate(min) : null;\n const maxDate = max ? parseIsoDate(max) : null;\n const isDisabled = (d: Date) => Boolean((minDate && d < minDate) || (maxDate && d > maxDate));\n\n const gridRef = useRef<HTMLDivElement>(null);\n const id = useId();\n const monthId = `${id}-month`;\n const hintId = `${id}-hint`;\n const { announce, regionProps } = useAnnounce();\n\n /**\n * The day that holds the tab order, and with it the visible month — one piece of\n * state, not two, because they cannot be allowed to disagree: a tabbable cell in a\n * month that is not on screen is a tab stop that focuses nothing.\n *\n * Starts on the selection, or on today when there is none, pulled inside `[min, max]`\n * so a bounded calendar opens on a day it will actually let you pick.\n */\n const [activeIso, setActiveIso] = useState(() => {\n let start = fromDate ?? toDate ?? new Date();\n // A `month` wins over the selection's month: the page asked for THAT month. The\n // selection (or today) is kept when it falls inside it, else the 1st.\n const first = monthStart(month);\n if (first && monthKey(start) !== month) start = first;\n if (minDate && start < minDate) return toLocalIso(minDate);\n if (maxDate && start > maxDate) return toLocalIso(maxDate);\n return toLocalIso(start);\n });\n\n // Follow the caller's value when it changes from outside (a preset, a cleared\n // filter, a form reset). Written as a render-phase adjustment rather than an effect\n // so the grid never paints one frame on the old month.\n const [lastValue, setLastValue] = useState({ from, to });\n if (lastValue.from !== from || lastValue.to !== to) {\n // Follow the end that actually CHANGED, not `from` unconditionally. Picking the\n // end of a range that spans months used to send the grid back to the start's\n // month — which with a roving tabindex means the cell the user just activated is\n // no longer rendered, and their focus goes with it to `<body>`.\n const changed = lastValue.from !== from ? from : to;\n setLastValue({ from, to });\n const next = parseIsoDate(changed) ?? fromDate ?? toDate;\n if (next && toLocalIso(next) !== activeIso) setActiveIso(toLocalIso(next));\n }\n\n // …and the caller's month, the same way. Only a CHANGE moves the grid, so paging\n // with the arrows is not snapped back by a parent that ignores `onMonthChange`.\n const [lastMonth, setLastMonth] = useState(month);\n if (lastMonth !== month) {\n setLastMonth(month);\n const first = monthStart(month);\n const current = parseIsoDate(activeIso) ?? new Date();\n if (first && monthKey(current) !== month) {\n // Keep the day of the month, clamped: the 31st in a 30-day month is the 30th.\n setActiveIso(toLocalIso(sameDayIn(first, current)));\n }\n }\n\n const activeDate = parseIsoDate(activeIso) ?? new Date();\n const view = { year: activeDate.getFullYear(), month: activeDate.getMonth() };\n\n const firstOfMonth = new Date(view.year, view.month, 1);\n const lastOfMonth = new Date(view.year, view.month + 1, 0);\n // Leading blanks up to the first of the month, counted from the week's first day.\n const startWeekday = weekdayIndex(firstOfMonth, weekStart);\n const cells: (Date | null)[] = [];\n for (let i = 0; i < startWeekday; i++) cells.push(null);\n for (let d = 1; d <= lastOfMonth.getDate(); d++) cells.push(new Date(view.year, view.month, d));\n while (cells.length % 7 !== 0) cells.push(null);\n const weeks: (Date | null)[][] = [];\n for (let i = 0; i < cells.length; i += 7) weeks.push(cells.slice(i, i + 7));\n\n const monthLabel = firstOfMonth.toLocaleDateString(locale, { month: \"long\", year: \"numeric\" });\n const formatDay = (d: Date) => d.toLocaleDateString(locale, DAY_NAME_FORMAT);\n\n // Weekday labels via locale, from the week's first day: the narrow one for the\n // column head, the long one as its accessible name — \"M\" is the same letter for\n // Monday, March and May, and a column header is the one place a screen reader\n // reads it on its own.\n const weekdayLabels = useMemo(() => {\n const ref = new Date(2024, 0, 7 + weekStart); // 7 January 2024 was a Sunday\n return Array.from({ length: 7 }, (_, i) => {\n const d = new Date(ref);\n d.setDate(ref.getDate() + i);\n return {\n narrow: d.toLocaleDateString(locale, { weekday: \"narrow\" }),\n short: d.toLocaleDateString(locale, { weekday: \"short\" }),\n long: d.toLocaleDateString(locale, { weekday: \"long\" }),\n };\n });\n }, [locale, weekStart]);\n\n /**\n * A day whose cell has to take focus once it exists. Arrowing off the edge of the\n * month renders a different month, so the element to focus is not in the DOM at the\n * time the key is handled — it is one commit away.\n */\n const pendingFocus = useRef<string | null>(null);\n useEffect(() => {\n const iso = pendingFocus.current;\n if (!iso) return;\n pendingFocus.current = null;\n gridRef.current?.querySelector<HTMLElement>(`[data-iso=\"${iso}\"]`)?.focus();\n });\n\n // The roving tab stop is the day to open on, so there is nothing else to work out\n // here — it is already the selection, or today, pulled inside the bounds.\n useEffect(() => {\n if (!focusOnOpen) return;\n gridRef.current?.querySelector<HTMLElement>('[tabindex=\"0\"]')?.focus();\n }, [focusOnOpen]);\n\n /** Move the roving tabindex, and the month with it when the day lands outside. */\n const moveTo = (d: Date, focus: boolean) => {\n const iso = toLocalIso(d);\n if (iso === activeIso) return;\n if (focus) pendingFocus.current = iso;\n setActiveIso(iso);\n const key = monthKey(d);\n if (key !== monthKey(activeDate)) onMonthChange?.(key);\n };\n\n /**\n * On each day rather than once on the grid: the cell is where focus is, and a\n * container listening for keys it cannot itself receive is the shape\n * `jsx-a11y/interactive-supports-focus` objects to. One shared function, not a\n * closure per cell — it reads the active day from state, which is always the\n * focused one.\n */\n const onDayKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n const next = new Date(activeDate);\n // ←/→ are \"previous/next day\" along the READING direction: the grid's columns run\n // right-to-left in RTL (it is a CSS grid, so the browser mirrors it), and ArrowLeft\n // there moves to the day that sits to the left — the next one.\n const step = horizontalStep(e.key, e.currentTarget);\n switch (step ? \"horizontal\" : e.key) {\n case \"horizontal\":\n next.setDate(next.getDate() + step);\n break;\n case \"ArrowUp\":\n next.setDate(next.getDate() - 7);\n break;\n case \"ArrowDown\":\n next.setDate(next.getDate() + 7);\n break;\n case \"Home\":\n next.setDate(next.getDate() - weekdayIndex(next, weekStart));\n break;\n case \"End\":\n next.setDate(next.getDate() + (6 - weekdayIndex(next, weekStart)));\n break;\n // Shift+Page is the year step, as in the APG example. It is the only way to\n // reach a birth year without holding PageUp for four hundred keystrokes.\n case \"PageUp\":\n next.setTime(stepMonths(next, e.shiftKey ? -12 : -1).getTime());\n break;\n case \"PageDown\":\n next.setTime(stepMonths(next, e.shiftKey ? 12 : 1).getTime());\n break;\n default:\n return;\n }\n // Before the no-op check: every key above also scrolls the panel this calendar\n // usually sits in, and a day that cannot move still must not move the page.\n e.preventDefault();\n moveTo(next, true);\n };\n\n const moveMonth = (delta: number) => {\n // Focus stays on the arrow button the user is pressing — only the grid moves.\n moveTo(stepMonths(activeDate, delta), false);\n };\n\n const handleClick = (d: Date) => {\n // The guard that `disabled` used to be. Out-of-range days are focusable on\n // purpose (see the component note), so refusing the click is this function's job.\n if (isDisabled(d)) return;\n const iso = toLocalIso(d);\n // Keep the tab order on the day that was just activated even if the caller\n // ignores the selection — a controlled component may reject it, and the roving\n // tabindex is this component's own state, not an echo of the value.\n moveTo(d, false);\n if (mode === \"single\") {\n onSelect(iso, iso);\n return;\n }\n const f = parseIsoDate(from);\n const tt = parseIsoDate(to);\n if (!f || (f && tt)) {\n // start a new selection\n onSelect(iso, \"\");\n announce(labels.startSelected(formatDay(d)));\n return;\n }\n // f set, tt empty\n if (d < f) {\n onSelect(iso, toLocalIso(f));\n announce(labels.rangeSelected(formatDay(d), formatDay(f)));\n } else {\n onSelect(toLocalIso(f), iso);\n announce(labels.rangeSelected(formatDay(f), formatDay(d)));\n }\n };\n\n const today = new Date();\n const hasBand = Boolean(fromDate && toDate && !sameYmd(fromDate, toDate));\n const daysInMonth = (d: Date) => new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();\n const inRange = (d: Date) => {\n if (!fromDate || !toDate) return false;\n return d >= fromDate && d <= toDate;\n };\n\n // What the next click does. A range is two clicks and nothing on screen says which\n // one you are on — sighted users read it off the highlighted start.\n const awaitingEnd = Boolean(fromDate) && !toDate;\n const rangeHint = awaitingEnd ? labels.chooseEnd : labels.chooseStart;\n\n return (\n // The caller's classes come last, so tailwind-merge lets them win the way\n // `className` does everywhere else in the kit; `...rest` first, as in the rest of\n // this wave, so nothing from outside can take the grid's own wiring away.\n <div {...rest} className={cn(\"select-none\", className)}>\n {hideNavigation ? (\n // Still in the tree: the caption is what names the grid.\n <div id={monthId} className=\"sr-only-fixed\">\n {monthLabel}\n </div>\n ) : (\n <div className={cn(\"flex items-center justify-between\", lg ? \"pb-2\" : \"pb-1\")}>\n <button\n type=\"button\"\n onClick={() => moveMonth(-1)}\n aria-label={labels.previousMonth}\n className=\"rounded p-1 text-[var(--text-muted)] hover:bg-[var(--bg-hover)]\"\n >\n {/* Mirrored in RTL: \"previous\" points to the reading START, which is right. */}\n <ChevronLeft className=\"size-4 rtl:-scale-x-100\" aria-hidden />\n </button>\n {/* Named by this element rather than by a string of its own, and `aria-live`\n so paging months says which month you have landed on — the caption is the\n only thing on screen that changes when the grid moves, and the user\n pressing the arrow is not inside the grid to hear the cells change. */}\n <div\n id={monthId}\n aria-live=\"polite\"\n className={cn(\n \"capitalize\",\n lg\n ? \"text-base font-semibold text-[var(--text-primary)]\"\n : \"text-xs font-medium text-[var(--text-secondary)]\",\n )}\n >\n {monthLabel}\n </div>\n <button\n type=\"button\"\n onClick={() => moveMonth(1)}\n aria-label={labels.nextMonth}\n className=\"rounded p-1 text-[var(--text-muted)] hover:bg-[var(--bg-hover)]\"\n >\n <ChevronRight className=\"size-4 rtl:-scale-x-100\" aria-hidden />\n </button>\n </div>\n )}\n <div\n ref={gridRef}\n role=\"grid\"\n aria-labelledby={monthId}\n aria-describedby={mode === \"range\" ? hintId : undefined}\n className={cn(\n \"grid\",\n // The month view is RULED: a 1px gap over a border-coloured ground draws the\n // lines between the cells, the way a wall calendar does.\n lg\n ? \"gap-px overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--border)]\"\n : \"gap-y-0.5\",\n )}\n >\n <div\n role=\"row\"\n className={cn(\n \"grid grid-cols-7 text-center font-medium\",\n lg\n ? \"gap-px text-xs text-[var(--text-muted)]\"\n : \"text-[10px] uppercase text-[var(--text-placeholder)]\",\n )}\n >\n {weekdayLabels.map((w, i) => (\n <div\n key={i}\n role=\"columnheader\"\n aria-label={w.long}\n className={lg ? \"bg-[var(--bg-surface)] py-2\" : \"py-0.5\"}\n >\n {lg ? w.short : w.narrow}\n </div>\n ))}\n </div>\n {weeks.map((week, wi) => (\n // No column gap: the days of a range join into ONE band. With a gap each day\n // was its own tinted box, and a selected fortnight read as fourteen chips.\n <div key={wi} role=\"row\" className={cn(\"grid grid-cols-7\", lg && \"gap-px\")}>\n {week.map((d, di) => {\n // The padding cells still have to BE cells, or the rows are ragged and\n // a screen reader's \"column 3\" stops meaning Wednesday.\n if (!d) {\n return (\n <div\n key={di}\n role=\"gridcell\"\n className={lg ? cn(LG_CELL_HEIGHT, \"bg-[var(--bg-surface-2)]\") : \"h-8\"}\n />\n );\n }\n const iso = toLocalIso(d);\n const disabled = isDisabled(d);\n const isStart = !disabled && fromDate && sameYmd(d, fromDate);\n const isEnd = !disabled && toDate && sameYmd(d, toDate);\n const isToday = sameYmd(d, today);\n const isInRange = !disabled && inRange(d) && !isStart && !isEnd;\n const isActive = iso === activeIso;\n const isSelected = Boolean(isStart || isEnd || isInRange);\n const label = dayNumber.format(d.getDate());\n const content = renderDay?.(d, {\n iso,\n label,\n today: isToday,\n disabled,\n selected: isSelected,\n rangeStart: Boolean(isStart),\n rangeEnd: Boolean(isEnd),\n inRange: isInRange,\n active: isActive,\n size,\n });\n const hasContent = content != null && content !== false && content !== \"\";\n const contentId = `${id}-day-${iso}`;\n // The band behind the day: full width between the ends, half width at an\n // end (so the round endpoint sits ON the band's tip), rounded where a row\n // or the month breaks it. Only when both ends exist and differ — a lone\n // start is a dot, not a band of one. The month view tints whole cells\n // instead, so it has no band.\n const banded =\n !lg && hasBand && !disabled && (isStart || isEnd || isInRange);\n const lastOfMonth = d.getDate() === daysInMonth(d);\n const band = banded\n ? cn(\n \"pointer-events-none absolute inset-y-0 bg-[var(--brand-bg)]\",\n isStart ? \"start-1/2 end-0\" : isEnd ? \"start-0 end-1/2\" : \"inset-x-0\",\n isInRange && (di === 0 || d.getDate() === 1) && \"rounded-s-full\",\n isInRange && (di === 6 || lastOfMonth) && \"rounded-e-full\",\n isStart && (di === 6 || lastOfMonth) && \"hidden\",\n isEnd && (di === 0 || d.getDate() === 1) && \"hidden\",\n )\n : null;\n return (\n <div\n key={di}\n role=\"none\"\n className={cn(\n \"relative flex\",\n lg ? \"min-w-0\" : \"h-8 items-center justify-center\",\n )}\n >\n {band && <span aria-hidden className={band} />}\n <button\n key={di}\n type=\"button\"\n role=\"gridcell\"\n data-iso={iso}\n // The roving tabindex: ONE tab stop for the whole month. Every day\n // being tabbable meant 31 stops between a date field and the next\n // control, which is the same reason the pattern exists.\n tabIndex={isActive ? 0 : -1}\n aria-label={labels.day(formatDay(d))}\n // The custom content is the day's DESCRIPTION: `aria-label` replaces\n // the button's text as its name, so without this link a screen\n // reader would hear the date and never the events drawn under it.\n aria-describedby={hasContent ? contentId : undefined}\n aria-selected={isSelected}\n aria-disabled={disabled || undefined}\n aria-current={isToday ? \"date\" : undefined}\n onClick={() => handleClick(d)}\n onKeyDown={onDayKeyDown}\n className={\n lg\n ? cn(\n \"flex w-full min-w-0 flex-col items-stretch gap-1 overflow-hidden p-1.5 text-start text-xs transition-colors\",\n LG_CELL_HEIGHT,\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--brand)]\",\n disabled\n ? \"cursor-not-allowed bg-[var(--bg-surface)] text-[var(--text-placeholder)]\"\n : isSelected\n ? \"bg-[var(--brand-bg)] text-[var(--text-primary)] hover:bg-[var(--brand-bg-hover)]\"\n : \"bg-[var(--bg-surface)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)]\",\n )\n : cn(\n \"relative size-8 rounded-full text-xs tabular-nums transition-colors\",\n // A grid you can walk with the keyboard needs to show where the\n // keyboard IS. Inset because the cells sit half a pixel apart and\n // an outset ring would be drawn over by its neighbours; the\n // colour flips on the selected days for the reason the numpad's\n // \"Done\" key does — a --brand ring on a --brand fill is a ring\n // that exists only in the DOM.\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset\",\n isStart || isEnd\n ? \"focus-visible:ring-[var(--brand-contrast)]\"\n : \"focus-visible:ring-[var(--brand)]\",\n disabled\n ? \"cursor-not-allowed text-[var(--text-placeholder)]\"\n // The two selected states are the BRAND, not a fixed sky: the endpoints\n // are the solid fill and the days between them its soft tint. Hardcoding\n // them left an app that changed `--brand` with a calendar in the old\n // colour (docs/module-audit-2026-09-22.md §theming). Both token pairs\n // flip light/dark themselves, so there is no `dark:` partner to carry —\n // one would override the token and bring the hardcoded hue back.\n : isStart || isEnd\n ? \"bg-[var(--brand)] text-[var(--brand-contrast)] hover:bg-[var(--brand-hover)]\"\n : isInRange\n ? \"font-medium text-[var(--brand-muted)] hover:bg-[var(--brand-bg-hover)]\"\n : \"text-[var(--text-primary)] hover:bg-[var(--bg-hover)]\",\n isToday && !isStart && !isEnd && !isInRange && !disabled && \"ring-1 ring-inset ring-[var(--border-strong)]\",\n )\n }\n >\n {lg ? (\n <>\n <span\n className={cn(\n \"inline-flex size-6 shrink-0 items-center justify-center self-start rounded-full tabular-nums\",\n isStart || isEnd\n ? \"bg-[var(--brand)] font-semibold text-[var(--brand-contrast)]\"\n : isToday && !disabled\n ? \"font-semibold text-[var(--brand)] ring-1 ring-inset ring-[var(--brand)]\"\n : isInRange && \"font-medium text-[var(--brand-muted)]\",\n )}\n >\n {label}\n </span>\n {hasContent && (\n <span id={contentId} className=\"flex min-w-0 flex-col gap-0.5\">\n {content}\n </span>\n )}\n </>\n ) : (\n <>\n {label}\n {/* Under the number, inside the circle: room for a dot or two. */}\n {hasContent && (\n <span\n id={contentId}\n className=\"pointer-events-none absolute inset-x-0 bottom-0.5 flex justify-center gap-px leading-none\"\n >\n {content}\n </span>\n )}\n </>\n )}\n </button>\n </div>\n );\n })}\n </div>\n ))}\n </div>\n {/* `sr-only-fixed`, not `sr-only`: this renders inside whatever panel a consumer\n opens it in, and there is no wrapper we can require to be `relative` — see\n the note on the class in tokens.css. */}\n {mode === \"range\" && (\n <span id={hintId} className=\"sr-only-fixed\">\n {rangeHint}\n </span>\n )}\n <span {...regionProps} />\n </div>\n );\n}\n"],"mappings":";AAkfQ,SA0MY,UA1MZ,KAIF,YAJE;AAlfR,SAAS,WAAW,OAAO,SAAS,QAAQ,gBAAgB;AAE5D,SAAS,aAAa,oBAAoB;AAC1C,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,cAAc,uBAAuB;AA6CrD,MAAM,+BAAmD;AAAA,EAC9D,eAAe;AAAA,EACf,WAAW;AAAA,EACX,KAAK,CAAC,SAAS;AAAA,EACf,aAAa;AAAA,EACb,WAAW;AAAA,EACX,eAAe,CAAC,SAAS,GAAG,IAAI;AAAA,EAChC,eAAe,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;AAC/C;AAOA,MAAM,kBAA8C;AAAA,EAClD,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AACR;AA6HA,MAAM,eAAe,CAAC,GAAS,eAAwB,EAAE,OAAO,IAAI,YAAY,KAAK;AAGrF,MAAM,aAAa;AAGnB,MAAM,iBAAiB;AAGvB,MAAM,aAAa,CAAC,QAA6B,MAAM,aAAa,GAAG,GAAG,KAAK,IAAI;AAGnF,SAAS,UAAU,OAAa,KAAiB;AAC/C,QAAM,OAAO,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM,SAAS,IAAI,GAAG,CAAC,EAAE,QAAQ;AAC5E,SAAO,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM,SAAS,GAAG,KAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,CAAC;AACtF;AAuBO,SAAS,aAAa;AAAA,EAC3B,OAAO;AAAA,EACP,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AjKO,EAkKV;AAAA,aACD;AAAA;AAAA;AAAA,MACH;AAAA,MAIC,SAAS,WACR,oBAAC,UAAK,IAAI,QAAQ,WAAU,iBACzB,qBACH;AAAA,MAEF,oBAAC,UAAM,GAAG,aAAa;AAAA,OACzB;AAAA;AAEJ;","names":["lastOfMonth"]}
|
|
@@ -28,6 +28,28 @@ declare function useBackdropClose(onClose: () => void): {
|
|
|
28
28
|
interface ModalProps extends Omit<ComponentPropsWithoutRef<"div">, "role"> {
|
|
29
29
|
/** Invoked on backdrop click and on Escape. */
|
|
30
30
|
onClose: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Who decides whether the dialog is up, when the caller wants to keep it MOUNTED.
|
|
33
|
+
*
|
|
34
|
+
* Left out, the dialog is open for as long as it is mounted — `{open && <Modal/>}`,
|
|
35
|
+
* which is every caller before this prop and stays exactly as it was. That idiom has
|
|
36
|
+
* one blind spot: a close the CALLER decides on (a save that succeeded, a
|
|
37
|
+
* `setOpen(false)` from outside) unmounts the panel on the spot, with no exit,
|
|
38
|
+
* because there is nothing left to animate. kastlan's `FormModal` was nothing but an
|
|
39
|
+
* `if (!open) return null` gate in front of this.
|
|
40
|
+
*
|
|
41
|
+
* Passed, the component stays mounted while closed and renders nothing, and a flip
|
|
42
|
+
* to `false` plays the same exit a dismissal does before the panel goes. The focus
|
|
43
|
+
* trap, the scroll lock and the Back-gesture history entry are held only while
|
|
44
|
+
* `open` is true — they are released the moment it turns false, so focus is back on
|
|
45
|
+
* the trigger while the panel is still lowering. A dismissal (Escape, the backdrop,
|
|
46
|
+
* Back, the frame's X) animates first and then calls `onClose`; the `false` that
|
|
47
|
+
* comes back from it is not animated a second time.
|
|
48
|
+
*
|
|
49
|
+
* The body is unmounted once the exit has finished, as it is today, so a form inside
|
|
50
|
+
* still starts fresh on the next open.
|
|
51
|
+
*/
|
|
52
|
+
open?: boolean;
|
|
31
53
|
/** `"alertdialog"` for a dialog that interrupts to ask a question the user must
|
|
32
54
|
* answer (a confirmation) — screen readers announce it with more urgency. Only the
|
|
33
55
|
* two dialog roles are allowed: the panel stays modal either way. */
|
|
@@ -88,6 +110,6 @@ interface ModalProps extends Omit<ComponentPropsWithoutRef<"div">, "role"> {
|
|
|
88
110
|
* into the panel on open and back to the trigger on close, a Tab focus trap, and
|
|
89
111
|
* `role="dialog"`/`aria-modal`.
|
|
90
112
|
*/
|
|
91
|
-
declare function Modal({ onClose, children, size, className, labelledBy, onKeyDown, fullBleed, draggable, style, role, ...rest }: ModalProps): react.ReactPortal;
|
|
113
|
+
declare function Modal({ onClose, open, children, size, className, labelledBy, onKeyDown, fullBleed, draggable, style, role, ...rest }: ModalProps): react.ReactPortal | null;
|
|
92
114
|
|
|
93
115
|
export { Modal, ModalCloseContext, type ModalProps, useBackdropClose };
|