@eifi1/ui-kit 0.11.0 → 0.12.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 +57 -32
- package/dist/chart.d.ts +3 -1
- package/dist/chart.js +2 -0
- package/dist/chart.js.map +1 -1
- package/dist/components/account-settings-labels.d.ts +105 -0
- package/dist/components/account-settings-labels.js +81 -0
- package/dist/components/account-settings-labels.js.map +1 -0
- package/dist/components/account-settings.d.ts +36 -52
- package/dist/components/account-settings.js +44 -8
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +24 -4
- package/dist/components/amount-input.js +5 -2
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/authed-image.d.ts +68 -0
- package/dist/components/authed-image.js +117 -0
- package/dist/components/authed-image.js.map +1 -0
- package/dist/components/breadcrumbs.d.ts +2 -1
- package/dist/components/breadcrumbs.js +5 -2
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/button-group.d.ts +51 -2
- package/dist/components/button-group.js +5 -1
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/calculator.d.ts +15 -4
- package/dist/components/calendar-heatmap.d.ts +41 -3
- package/dist/components/calendar-heatmap.js +48 -7
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/chip.d.ts +2 -1
- package/dist/components/chip.js +6 -3
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +35 -3
- package/dist/components/choice-card.js +83 -25
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/combobox-core.js +2 -0
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +2 -2
- package/dist/components/combobox.js +31 -9
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +51 -70
- package/dist/components/copy-button.js +1 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table-cells.d.ts +63 -0
- package/dist/components/data-table-cells.js +64 -0
- package/dist/components/data-table-cells.js.map +1 -0
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table-filters.js +31 -1
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +13 -0
- package/dist/components/data-table-labels.js +8 -1
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +102 -12
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +3 -1
- package/dist/components/date-picker.js +15 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +23 -3
- package/dist/components/description-list.js +23 -3
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +1 -0
- package/dist/components/entity-combobox.d.ts +1 -1
- package/dist/components/entity-combobox.js +18 -3
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/error-boundary.d.ts +92 -0
- package/dist/components/error-boundary.js +111 -0
- package/dist/components/error-boundary.js.map +1 -0
- package/dist/components/field.d.ts +30 -4
- package/dist/components/field.js +40 -17
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-button.d.ts +50 -208
- package/dist/components/file-dropzone.d.ts +49 -2
- package/dist/components/floating-panel.d.ts +13 -4
- package/dist/components/floating-panel.js +7 -3
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +53 -0
- package/dist/components/form-actions.js +98 -0
- package/dist/components/form-actions.js.map +1 -0
- package/dist/components/image-grid.d.ts +67 -0
- package/dist/components/image-grid.js +112 -0
- package/dist/components/image-grid.js.map +1 -0
- package/dist/components/lightbox.d.ts +104 -0
- package/dist/components/lightbox.js +229 -0
- package/dist/components/lightbox.js.map +1 -0
- package/dist/components/line-items.d.ts +114 -0
- package/dist/components/line-items.js +238 -0
- package/dist/components/line-items.js.map +1 -0
- package/dist/components/list.d.ts +23 -2
- package/dist/components/list.js +32 -13
- package/dist/components/list.js.map +1 -1
- package/dist/components/loading-state.d.ts +24 -0
- package/dist/components/loading-state.js +32 -0
- package/dist/components/loading-state.js.map +1 -0
- package/dist/components/menu-item.d.ts +2 -1
- package/dist/components/menu-item.js +5 -1
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/mini-calendar.d.ts +13 -1
- package/dist/components/mini-calendar.js +46 -2
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +20 -1
- package/dist/components/modal.js +26 -2
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +21 -1
- package/dist/components/month-picker.js +139 -26
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +1 -1
- package/dist/components/multi-entity-combobox.js +19 -3
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/nav-pills.d.ts +2 -1
- package/dist/components/nav-pills.js +5 -1
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/number-field.d.ts +24 -5
- package/dist/components/number-field.js +5 -7
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +25 -5
- package/dist/components/number-input.js +7 -1
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +15 -4
- package/dist/components/passkeys-setting.d.ts +67 -0
- package/dist/components/passkeys-setting.js +214 -0
- package/dist/components/passkeys-setting.js.map +1 -0
- package/dist/components/picker-sheet.js +2 -1
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/pie-chart-labels.d.ts +20 -0
- package/dist/components/pie-chart-labels.js +12 -0
- package/dist/components/pie-chart-labels.js.map +1 -0
- package/dist/components/pie-chart.d.ts +101 -0
- package/dist/components/pie-chart.js +283 -0
- package/dist/components/pie-chart.js.map +1 -0
- package/dist/components/progress-bar.d.ts +44 -3
- package/dist/components/progress-bar.js +58 -22
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/qr-code.d.ts +34 -0
- package/dist/components/qr-code.js +57 -0
- package/dist/components/qr-code.js.map +1 -0
- package/dist/components/search-field.d.ts +15 -3
- package/dist/components/search-field.js +5 -1
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/settings-fields.d.ts +49 -1
- package/dist/components/signed-amount.d.ts +121 -0
- package/dist/components/signed-amount.js +152 -0
- package/dist/components/signed-amount.js.map +1 -0
- package/dist/components/skeleton.d.ts +10 -3
- package/dist/components/skeleton.js +12 -2
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/stat-tile.d.ts +2 -1
- package/dist/components/stat-tile.js +5 -2
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/table.d.ts +39 -5
- package/dist/components/table.js +45 -11
- package/dist/components/table.js.map +1 -1
- package/dist/components/text-link.d.ts +176 -0
- package/dist/components/text-link.js +109 -0
- package/dist/components/text-link.js.map +1 -0
- package/dist/components/time-input.d.ts +49 -1
- package/dist/components/toggle-group.d.ts +13 -0
- package/dist/components/toggle-group.js +35 -6
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.d.ts +36 -3
- package/dist/components/toggle-legend.js +49 -0
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/ui.d.ts +51 -779
- package/dist/components/ui.js +215 -23
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +3 -52
- package/dist/components/use-table-state.js +128 -30
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/{data-table-filters-Dh9uF_S-.d.ts → data-table-Drun8Fk9.d.ts} +305 -61
- package/dist/data-table.d.ts +2 -1
- package/dist/data-table.js +5 -1
- package/dist/data-table.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +26 -3
- package/dist/feedback/feedback-dialog.js +16 -2
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +133 -0
- package/dist/feedback/feedback-thread.js +237 -0
- package/dist/feedback/feedback-thread.js.map +1 -0
- package/dist/feedback.d.ts +2 -1
- package/dist/feedback.js +1 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-authed-src.d.ts +71 -0
- package/dist/hooks/use-authed-src.js +63 -0
- package/dist/hooks/use-authed-src.js.map +1 -0
- package/dist/hooks/use-file-drop.d.ts +49 -2
- package/dist/hooks/use-hotkey.d.ts +59 -0
- package/dist/hooks/use-hotkey.js +105 -0
- package/dist/hooks/use-hotkey.js.map +1 -0
- package/dist/hooks/use-search-param-state.d.ts +83 -0
- package/dist/hooks/use-search-param-state.js +94 -0
- package/dist/hooks/use-search-param-state.js.map +1 -0
- package/dist/i18n/defaults.d.ts +15 -4
- package/dist/i18n/defaults.js +31 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +46 -312
- package/dist/i18n/kit-labels.js +20 -5
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +15 -4
- package/dist/i18n/locales/de-CH.d.ts +15 -4
- package/dist/i18n/locales/de-informal.d.ts +15 -4
- package/dist/i18n/locales/de.d.ts +15 -4
- package/dist/i18n/locales/de.js +156 -3
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +15 -4
- package/dist/i18n/locales/es.js +153 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +15 -4
- package/dist/i18n/locales/fr.js +153 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +15 -4
- package/dist/i18n/locales/hu.js +153 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +15 -4
- package/dist/i18n/locales/it.js +153 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +15 -4
- package/dist/i18n/locales/zh.js +153 -3
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +37 -17
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/dist/kit-labels-v3biUF1L.d.ts +1645 -0
- package/dist/lib/format.d.ts +144 -0
- package/dist/lib/format.js +149 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/qr-encode.d.ts +44 -0
- package/dist/lib/qr-encode.js +338 -0
- package/dist/lib/qr-encode.js.map +1 -0
- package/dist/rhf/fields.d.ts +241 -0
- package/dist/rhf/fields.js +601 -0
- package/dist/rhf/fields.js.map +1 -0
- package/dist/rhf/form.d.ts +49 -1
- package/dist/rhf/line-items.d.ts +31 -0
- package/dist/rhf/line-items.js +59 -0
- package/dist/rhf/line-items.js.map +1 -0
- package/dist/rhf.d.ts +61 -1
- package/dist/rhf.js +2 -0
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +99 -2
- package/dist/shell/app-shell.js +58 -3
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/auth-layout.d.ts +74 -0
- package/dist/shell/auth-layout.js +97 -0
- package/dist/shell/auth-layout.js.map +1 -0
- package/dist/shell/top-bar-brand.d.ts +81 -0
- package/dist/shell/top-bar-brand.js +47 -0
- package/dist/shell/top-bar-brand.js.map +1 -0
- package/dist/shell/topbar-action-menu.d.ts +12 -1
- package/dist/shell/topbar-action-menu.js +16 -1
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +56 -1
- package/dist/shell.js +2 -0
- package/dist/shell.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +48 -1
- package/dist/wizard/wizard-context.d.ts +24 -1
- package/dist/wizard/wizard-context.js +19 -2
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-step.d.ts +20 -5
- package/dist/wizard/wizard-step.js +16 -3
- package/dist/wizard/wizard-step.js.map +1 -1
- package/dist/wizard.d.ts +50 -3
- package/package.json +1 -1
- package/src/chart.ts +4 -0
- package/src/components/account-settings-labels.ts +190 -0
- package/src/components/account-settings.tsx +110 -63
- package/src/components/amount-input.tsx +13 -1
- package/src/components/authed-image.tsx +190 -0
- package/src/components/breadcrumbs.tsx +8 -2
- package/src/components/button-group.tsx +7 -2
- package/src/components/calendar-heatmap.tsx +105 -10
- package/src/components/chip.tsx +8 -4
- package/src/components/choice-card.tsx +136 -25
- package/src/components/combobox-core.tsx +5 -0
- package/src/components/combobox.tsx +31 -9
- package/src/components/copy-button.tsx +3 -2
- package/src/components/data-table-cells.tsx +119 -0
- package/src/components/data-table-filters.ts +77 -0
- package/src/components/data-table-labels.ts +23 -0
- package/src/components/data-table.tsx +224 -13
- package/src/components/date-picker.tsx +19 -3
- package/src/components/description-list.tsx +52 -3
- package/src/components/entity-combobox.tsx +18 -3
- package/src/components/error-boundary.tsx +216 -0
- package/src/components/field.tsx +56 -5
- package/src/components/floating-panel.tsx +20 -7
- package/src/components/form-actions.tsx +191 -0
- package/src/components/image-grid.tsx +181 -0
- package/src/components/lightbox.tsx +374 -0
- package/src/components/line-items.tsx +385 -0
- package/src/components/list.tsx +65 -16
- package/src/components/loading-state.tsx +47 -0
- package/src/components/menu-item.tsx +7 -2
- package/src/components/mini-calendar.tsx +72 -3
- package/src/components/modal.tsx +61 -3
- package/src/components/month-picker.tsx +181 -26
- package/src/components/multi-entity-combobox.tsx +19 -3
- package/src/components/nav-pills.tsx +8 -1
- package/src/components/number-field.tsx +15 -10
- package/src/components/number-input.tsx +16 -1
- package/src/components/passkeys-setting.tsx +331 -0
- package/src/components/picker-sheet.tsx +7 -1
- package/src/components/pie-chart-labels.ts +32 -0
- package/src/components/pie-chart.tsx +479 -0
- package/src/components/progress-bar.tsx +129 -19
- package/src/components/qr-code.tsx +83 -0
- package/src/components/search-field.tsx +20 -4
- package/src/components/signed-amount.tsx +286 -0
- package/src/components/skeleton.tsx +21 -3
- package/src/components/stat-tile.tsx +8 -2
- package/src/components/table.tsx +102 -13
- package/src/components/text-link.tsx +248 -0
- package/src/components/toggle-group.tsx +58 -10
- package/src/components/toggle-legend.tsx +87 -2
- package/src/components/ui.tsx +426 -36
- package/src/components/use-table-state.ts +265 -33
- package/src/data-table.ts +10 -0
- package/src/feedback/feedback-dialog.tsx +42 -3
- package/src/feedback/feedback-thread.tsx +434 -0
- package/src/feedback.ts +1 -0
- package/src/hooks/use-authed-src.ts +161 -0
- package/src/hooks/use-hotkey.ts +172 -0
- package/src/hooks/use-search-param-state.ts +187 -0
- package/src/i18n/defaults.ts +30 -0
- package/src/i18n/kit-labels.tsx +102 -8
- package/src/i18n/locales/de.ts +153 -0
- package/src/i18n/locales/es.ts +150 -0
- package/src/i18n/locales/fr.ts +153 -0
- package/src/i18n/locales/hu.ts +151 -0
- package/src/i18n/locales/it.ts +151 -0
- package/src/i18n/locales/zh.ts +150 -0
- package/src/index.ts +59 -0
- package/src/lib/format.ts +325 -0
- package/src/lib/qr-encode.ts +420 -0
- package/src/rhf/fields.tsx +1054 -0
- package/src/rhf/line-items.tsx +130 -0
- package/src/rhf.ts +6 -0
- package/src/shell/app-shell.tsx +147 -2
- package/src/shell/auth-layout.tsx +190 -0
- package/src/shell/top-bar-brand.tsx +76 -0
- package/src/shell/topbar-action-menu.tsx +21 -0
- package/src/shell.ts +2 -0
- package/src/wizard/wizard-context.tsx +41 -1
- package/src/wizard/wizard-step.tsx +43 -6
- package/tokens.css +12 -0
|
@@ -1 +1 @@
|
|
|
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,O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ACT,iFACA,YACE,2EACA;AAAA,4BACR,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,YAAY;AAAA,0BAC9D;AAAA,0BAGC,eACC,iCACE;AAAA;AAAA,8BAAC;AAAA;AAAA,gCACC,WAAW;AAAA,kCACT;AAAA,kCACA,WAAW,QACP,iEACA,WAAW,CAAC,WACV,4EACA,aAAa;AAAA,gCACrB;AAAA,gCAEC;AAAA;AAAA,4BACH;AAAA,4BACC,cACC,oBAAC,UAAK,IAAI,WAAW,WAAU,iCAC5B,mBACH;AAAA,6BAEJ,IAEA,iCACG;AAAA;AAAA,4BAEA,cACC;AAAA,8BAAC;AAAA;AAAA,gCACC,IAAI;AAAA,gCACJ,WAAU;AAAA,gCAET;AAAA;AAAA,4BACH;AAAA,6BAEJ;AAAA;AAAA,wBA3FG;AAAA,sBA6FP;AAAA;AAAA;AAAA,kBAtGO;AAAA,gBAuGP;AAAA,cAEJ,CAAC,KAjKO,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"]}
|
|
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 /**\n * Fill the leading and trailing cells with the neighbouring months' days, muted —\n * the wall-calendar look, where the first row does not start on a hole.\n *\n * They are real days, not decoration: each is named with its whole date, honours\n * `min`/`max`, and a click selects it and moves the grid to its month (focus goes\n * with it). They are NOT stops of the roving tabindex — the keyboard already reaches\n * them by arrowing off the month's edge, which moves the grid the same way — and\n * `renderDay` is not called for them, so a day's events are drawn once, in its own\n * month. Default `false`: the cells stay empty.\n */\n showOutsideDays?: 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 showOutsideDays = false,\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 // or the previous month's last days, with `showOutsideDays` (and the next month's\n // first ones at the end). `new Date(y, m, 0)` is the day before the 1st, so the\n // offsets below roll into the neighbouring month by themselves.\n const startWeekday = weekdayIndex(firstOfMonth, weekStart);\n const cells: (Date | null)[] = [];\n for (let i = 0; i < startWeekday; i++) {\n cells.push(showOutsideDays ? new Date(view.year, view.month, i - startWeekday + 1) : null);\n }\n for (let d = 1; d <= lastOfMonth.getDate(); d++) cells.push(new Date(view.year, view.month, d));\n for (let extra = 1; cells.length % 7 !== 0; extra++) {\n cells.push(showOutsideDays ? new Date(view.year, view.month + 1, extra) : null);\n }\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 // A neighbouring month's day (`showOutsideDays`): a muted, selectable\n // cell outside the tab order — see the prop.\n if (d.getMonth() !== view.month) {\n return (\n <div\n key={di}\n role=\"none\"\n className={cn(\n \"relative flex\",\n lg ? cn(\"min-w-0\", LG_CELL_HEIGHT) : \"h-8 items-center justify-center\",\n )}\n >\n <button\n type=\"button\"\n role=\"gridcell\"\n data-iso={iso}\n data-outside=\"\"\n tabIndex={-1}\n aria-label={labels.day(formatDay(d))}\n aria-selected={!disabled && inRange(d)}\n aria-disabled={disabled || undefined}\n onClick={() => {\n if (disabled) return;\n // Focus follows into the month the click moves the grid to:\n // this button is gone after the next commit.\n pendingFocus.current = iso;\n handleClick(d);\n }}\n onKeyDown={onDayKeyDown}\n className={cn(\n \"text-xs tabular-nums text-[var(--text-placeholder)] transition-colors\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--brand)]\",\n disabled ? \"cursor-not-allowed opacity-60\" : \"hover:bg-[var(--bg-hover)]\",\n lg\n ? cn(\"flex w-full min-w-0 items-start bg-[var(--bg-surface-2)] p-1.5\", LG_CELL_HEIGHT)\n : \"size-8 rounded-full\",\n )}\n >\n {lg ? (\n <span className=\"inline-flex size-6 items-center justify-center\">\n {dayNumber.format(d.getDate())}\n </span>\n ) : (\n dayNumber.format(d.getDate())\n )}\n </button>\n </div>\n );\n }\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":";AAsgBQ,SA2PY,UA3PZ,KAIF,YAJE;AAtgBR,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,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P,+CACA;AAAA,4BACJ,WACI,sDAOA,WAAW,QACT,iFACA,YACE,2EACA;AAAA,4BACR,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,YAAY;AAAA,0BAC9D;AAAA,0BAGC,eACC,iCACE;AAAA;AAAA,8BAAC;AAAA;AAAA,gCACC,WAAW;AAAA,kCACT;AAAA,kCACA,WAAW,QACP,iEACA,WAAW,CAAC,WACV,4EACA,aAAa;AAAA,gCACrB;AAAA,gCAEC;AAAA;AAAA,4BACH;AAAA,4BACC,cACC,oBAAC,UAAK,IAAI,WAAW,WAAU,iCAC5B,mBACH;AAAA,6BAEJ,IAEA,iCACG;AAAA;AAAA,4BAEA,cACC;AAAA,8BAAC;AAAA;AAAA,gCACC,IAAI;AAAA,gCACJ,WAAU;AAAA,gCAET;AAAA;AAAA,4BACH;AAAA,6BAEJ;AAAA;AAAA,wBA3FG;AAAA,sBA6FP;AAAA;AAAA;AAAA,kBAtGO;AAAA,gBAuGP;AAAA,cAEJ,CAAC,KAlNO,EAmNV;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"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef, ReactNode, KeyboardEvent, MouseEvent } from 'react';
|
|
3
|
+
import { DialogParam } from '../hooks/use-search-param-state.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The panel's own ANIMATED dismissal, for chrome rendered inside it. `DialogFrame`'s X
|
|
@@ -101,6 +102,24 @@ interface ModalProps extends Omit<ComponentPropsWithoutRef<"div">, "role"> {
|
|
|
101
102
|
* suppressed there — there is nothing beside it to see.
|
|
102
103
|
*/
|
|
103
104
|
draggable?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Bind the open state to a URL search param (0.12.0): `"edit"` is open while
|
|
107
|
+
* `?edit` is in the query, `{ key: "dialog", value: "create-lease" }` while
|
|
108
|
+
* `?dialog=create-lease` is. The URL is then the only state — `open` is ignored —
|
|
109
|
+
* and the dialog opens from anywhere that sets the param: {@link useDialogParam}'s
|
|
110
|
+
* setter, a `<Link>`, a shared link, a reload.
|
|
111
|
+
*
|
|
112
|
+
* kastlan's `useDialogParam` did this beside the dialog, so its open state could be
|
|
113
|
+
* deep-linked and captured in a feedback report. Here it also owns the history:
|
|
114
|
+
* opening through `useDialogParam` pushes an entry, so the Back gesture closes the
|
|
115
|
+
* dialog by leaving it, and a close (Escape, the backdrop, the X) goes back over
|
|
116
|
+
* that entry rather than stacking a second one. The dialog's own Back handling
|
|
117
|
+
* ({@link useOverlayHistory}'s throwaway entry) stays off in this mode — the param's
|
|
118
|
+
* entry already is one, and two would take two Back presses to close one dialog.
|
|
119
|
+
*
|
|
120
|
+
* `onClose` still runs, after the param is cleared. Requires a react-router Router.
|
|
121
|
+
*/
|
|
122
|
+
urlParam?: DialogParam;
|
|
104
123
|
}
|
|
105
124
|
/**
|
|
106
125
|
* Centered (bottom-sheet on mobile) modal dialog: dimmed backdrop, single
|
|
@@ -110,6 +129,6 @@ interface ModalProps extends Omit<ComponentPropsWithoutRef<"div">, "role"> {
|
|
|
110
129
|
* into the panel on open and back to the trigger on close, a Tab focus trap, and
|
|
111
130
|
* `role="dialog"`/`aria-modal`.
|
|
112
131
|
*/
|
|
113
|
-
declare function Modal(
|
|
132
|
+
declare function Modal(props: ModalProps): react.JSX.Element;
|
|
114
133
|
|
|
115
134
|
export { Modal, ModalCloseContext, type ModalProps, useBackdropClose };
|
package/dist/components/modal.js
CHANGED
|
@@ -6,6 +6,7 @@ import { cn } from "../lib/cn.js";
|
|
|
6
6
|
import { useFocusTrap } from "../hooks/use-focus-trap.js";
|
|
7
7
|
import { useBodyScrollLock } from "../hooks/use-body-scroll-lock.js";
|
|
8
8
|
import { useOverlayHistory } from "../hooks/use-overlay-history.js";
|
|
9
|
+
import { useDialogParam } from "../hooks/use-search-param-state.js";
|
|
9
10
|
import { OVERLAY_EXIT_MS, prefersReducedMotion, useCloseTransition } from "../hooks/use-close-transition.js";
|
|
10
11
|
function useDragOffset(enabled) {
|
|
11
12
|
const [offset, setOffset] = useState(null);
|
|
@@ -57,7 +58,28 @@ function useBackdropClose(onClose) {
|
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
+
function UrlParamModal({ urlParam, onClose, ...rest }) {
|
|
62
|
+
const [open, setOpen] = useDialogParam(urlParam);
|
|
63
|
+
const [leaving, setLeaving] = useState(false);
|
|
64
|
+
if (leaving && !open) setLeaving(false);
|
|
65
|
+
return /* @__PURE__ */ jsx(
|
|
66
|
+
ModalPanel,
|
|
67
|
+
{
|
|
68
|
+
...rest,
|
|
69
|
+
open: open && !leaving,
|
|
70
|
+
ownHistoryEntry: false,
|
|
71
|
+
onClose: () => {
|
|
72
|
+
setLeaving(true);
|
|
73
|
+
setOpen(false);
|
|
74
|
+
onClose();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
function Modal(props) {
|
|
80
|
+
return props.urlParam !== void 0 ? /* @__PURE__ */ jsx(UrlParamModal, { ...props, urlParam: props.urlParam }) : /* @__PURE__ */ jsx(ModalPanel, { ...props });
|
|
81
|
+
}
|
|
82
|
+
function ModalPanel({
|
|
61
83
|
onClose,
|
|
62
84
|
open,
|
|
63
85
|
children,
|
|
@@ -69,6 +91,8 @@ function Modal({
|
|
|
69
91
|
draggable,
|
|
70
92
|
style,
|
|
71
93
|
role = "dialog",
|
|
94
|
+
urlParam: _urlParam,
|
|
95
|
+
ownHistoryEntry = true,
|
|
72
96
|
...rest
|
|
73
97
|
}) {
|
|
74
98
|
const panelRef = useRef(null);
|
|
@@ -94,7 +118,7 @@ function Modal({
|
|
|
94
118
|
});
|
|
95
119
|
const backdropClose = useBackdropClose(active ? requestClose : () => {
|
|
96
120
|
});
|
|
97
|
-
useOverlayHistory(active, requestClose);
|
|
121
|
+
useOverlayHistory(active && ownHistoryEntry, requestClose);
|
|
98
122
|
useBodyScrollLock(active);
|
|
99
123
|
useFocusTrap(panelRef, { active, initialFocus: "container" });
|
|
100
124
|
const leaving = closing || exiting;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/modal.tsx"],"sourcesContent":["import { createContext, useEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type {\n ComponentPropsWithoutRef,\n KeyboardEvent,\n MouseEvent as ReactMouseEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n} from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useFocusTrap } from \"../hooks/use-focus-trap\";\nimport { useBodyScrollLock } from \"../hooks/use-body-scroll-lock\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { OVERLAY_EXIT_MS, prefersReducedMotion, useCloseTransition } from \"../hooks/use-close-transition\";\n\n/**\n * Drag the panel by its top strip, in pointer space (dev#460).\n *\n * Deliberately not a library and not persisted: the offset is component state that\n * dies with the dialog. It starts only on a press that lands on the panel's own\n * chrome — never on a field, a button or a link, which is what keeps \"drag to select\n * text in the textarea\" working. Above `md` only: below it the panel is a\n * full-width bottom sheet with nothing beside it to uncover.\n *\n * The whole gesture stays on the PANEL — captured pointer, React handlers — rather than\n * on `window`. The first shape of this added `pointermove`/`pointerup` to `window` from\n * inside the `pointerdown` handler and took them off again from the `pointerup` handler,\n * so the teardown ran only if the gesture ended: React never sees a listener added from\n * an event handler, and an unmount mid-drag left a live `pointermove` on `window` for\n * the life of the page, pinning this hook's state with it. The one caller that enables\n * dragging is the feedback composer, which closes ITSELF on submit — a Ctrl+Enter sent\n * with the pointer still down is exactly that order of events, once per drag.\n */\nfunction useDragOffset(enabled: boolean) {\n const [offset, setOffset] = useState<{ x: number; y: number } | null>(null);\n const from = useRef<{ x: number; y: number; ox: number; oy: number } | null>(null);\n\n const endDrag = () => {\n from.current = null;\n };\n\n return {\n /** Back to where the panel opens. A `Modal` with an `open` prop outlives its own\n * closes, so \"the position resets when the dialog closes\" needs saying. */\n reset: () => setOffset(null),\n style: offset ? { transform: `translate(${offset.x}px, ${offset.y}px)` } : undefined,\n handlers: !enabled\n ? undefined\n : {\n onPointerDown: (e: ReactPointerEvent<HTMLDivElement>) => {\n if (e.button !== 0 || window.innerWidth < 768) return;\n const target = e.target as HTMLElement;\n // Only the panel itself and its non-interactive chrome start a drag; a\n // press inside any control belongs to that control.\n if (target.closest(\"input,textarea,select,button,a,[role='button']\")) return;\n from.current = { x: e.clientX, y: e.clientY, ox: offset?.x ?? 0, oy: offset?.y ?? 0 };\n try {\n // Capture is what lets the handlers live on the panel: every later\n // pointer event for this pointer retargets here, so the drag keeps\n // working once the pointer outruns the panel's own box — which it always\n // does, since the panel moves out from under it.\n e.currentTarget.setPointerCapture(e.pointerId);\n } catch {\n // jsdom implements no pointer capture, and a browser throws\n // NotFoundError for a pointerId that is already gone. Neither is worth\n // refusing the drag: uncaptured, the panel still gets the moves that\n // land on it.\n }\n },\n onPointerMove: (e: ReactPointerEvent<HTMLDivElement>) => {\n const start = from.current;\n if (!start) return;\n setOffset({ x: start.ox + e.clientX - start.x, y: start.oy + e.clientY - start.y });\n },\n onPointerUp: endDrag,\n // A cancel (the browser taking the pointer for a scroll or a gesture) and a\n // lost capture both mean no `pointerup` is coming. Without them the drag would\n // stay \"live\" and the next move over the panel would jump it.\n onPointerCancel: endDrag,\n onLostPointerCapture: endDrag,\n },\n };\n}\n\n/**\n * The panel's own ANIMATED dismissal, for chrome rendered inside it. `DialogFrame`'s X\n * and its `actions(close)` read this, so a Cancel or an X lowers the panel exactly the\n * way Escape does — calling `onClose` from inside unmounts with no exit, which is the\n * documented limit of {@link useCloseTransition}. `null` outside a `Modal`.\n */\nexport const ModalCloseContext = createContext<(() => void) | null>(null);\n\n/**\n * Backdrop handlers that close only when a press starts AND ends on the\n * backdrop itself. A plain onClick fires on mouseup, so dragging a text\n * selection that starts inside the panel and releases over the backdrop would\n * dismiss the dialog (feedback #254) — and the reverse drag would too, since\n * click targets the common ancestor of the down/up elements.\n */\nexport function useBackdropClose(onClose: () => void) {\n const pressStartedOnBackdrop = useRef(false);\n return {\n onMouseDown: (e: ReactMouseEvent<HTMLDivElement>) => {\n pressStartedOnBackdrop.current = e.target === e.currentTarget;\n },\n onMouseUp: (e: ReactMouseEvent<HTMLDivElement>) => {\n const started = pressStartedOnBackdrop.current;\n pressStartedOnBackdrop.current = false;\n if (started && e.target === e.currentTarget) onClose();\n },\n };\n}\n\n// Tab-cycle target set: the interactive descendants the focus trap rotates\n// through. Querying live (per keystroke) means dynamically rendered fields are\n// included automatically.\n/**\n * `extends ComponentPropsWithoutRef<\"div\">` so anything a `<div>` takes reaches the\n * PANEL — the element with `role=\"dialog\"`, which is the one a consumer means. That is\n * where a `data-tour` anchor, a test id, an `aria-describedby` or an `aria-label` has\n * to land; before this, a closed prop list dropped all four silently (audit §api-design).\n */\nexport interface ModalProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"role\"> {\n /** Invoked on backdrop click and on Escape. */\n onClose: () => void;\n /**\n * Who decides whether the dialog is up, when the caller wants to keep it MOUNTED.\n *\n * Left out, the dialog is open for as long as it is mounted — `{open && <Modal/>}`,\n * which is every caller before this prop and stays exactly as it was. That idiom has\n * one blind spot: a close the CALLER decides on (a save that succeeded, a\n * `setOpen(false)` from outside) unmounts the panel on the spot, with no exit,\n * because there is nothing left to animate. kastlan's `FormModal` was nothing but an\n * `if (!open) return null` gate in front of this.\n *\n * Passed, the component stays mounted while closed and renders nothing, and a flip\n * to `false` plays the same exit a dismissal does before the panel goes. The focus\n * trap, the scroll lock and the Back-gesture history entry are held only while\n * `open` is true — they are released the moment it turns false, so focus is back on\n * the trigger while the panel is still lowering. A dismissal (Escape, the backdrop,\n * Back, the frame's X) animates first and then calls `onClose`; the `false` that\n * comes back from it is not animated a second time.\n *\n * The body is unmounted once the exit has finished, as it is today, so a form inside\n * still starts fresh on the next open.\n */\n open?: boolean;\n /** `\"alertdialog\"` for a dialog that interrupts to ask a question the user must\n * answer (a confirmation) — screen readers announce it with more urgency. Only the\n * two dialog roles are allowed: the panel stays modal either way. */\n role?: \"dialog\" | \"alertdialog\";\n children: ReactNode;\n /**\n * Panel max-width: `md` (28rem), `lg` (32rem), `xl` (48rem).\n *\n * `xl` exists because two callers had already written `className=\"max-w-3xl\"` to\n * reach it — the payee backfill's preview table and the price-merge dialog, both\n * of which hold a list and several fields rather than one question. A caller\n * patching a missing size IS the signal that the size is missing, and a\n * hand-written width in a `className` is a width nothing else can line up with.\n *\n * The panel is `w-full` under every one of them, so the cap only bites once the\n * viewport is wider than it: on a phone all three are the same full-width bottom\n * sheet. Nothing here may introduce a `min-w-*`, which is what would break that.\n */\n size?: \"md\" | \"lg\" | \"xl\";\n /** Extra classes for the panel (e.g. `space-y-3` for form content spacing). */\n className?: string;\n /** id of the heading element, wired to `aria-labelledby`. */\n labelledBy?: string;\n /**\n * Extra key handling on the panel (e.g. Ctrl/Cmd+Enter to submit). Runs first;\n * if it calls `preventDefault()` the built-in Escape/Tab handling is skipped\n * for that event.\n */\n onKeyDown?: (e: KeyboardEvent<HTMLDivElement>) => void;\n /**\n * Drop the backdrop's mobile margin so the panel can reach the screen edges\n * (a full-screen sheet on phones). The panel still needs its own\n * `h-[100dvh] max-w-full rounded-none` classes via `className` to fill it; the\n * desktop `md:p-4` margin is kept. Defaults to false (padded on all sizes).\n */\n fullBleed?: boolean;\n /**\n * Let the user drag the panel out of the way by its top edge (Keksdose feedback\n * dev#460: *\"Make the feedback dialog draggable so I can see behind it if it\n * blocks something.\"*).\n *\n * Opt-in, because it only makes sense for a dialog whose content is ABOUT the page\n * behind it — the feedback composer is the case, an ordinary form is not, and a\n * draggable panel that has nothing to reveal is a control that can only get lost.\n *\n * Pointer-only by design: it is a \"move this out of the way\" gesture, not a layout\n * choice worth persisting, and the position resets when the dialog closes. On a\n * phone the panel is a bottom sheet the width of the screen, so dragging is\n * suppressed there — there is nothing beside it to see.\n */\n draggable?: boolean;\n}\n\n/**\n * Centered (bottom-sheet on mobile) modal dialog: dimmed backdrop, single\n * rounded panel. Owns the overlay mechanics that the hand-rolled dialogs each\n * re-implemented or lacked — backdrop-click + Escape to close, the platform Back\n * gesture (Keksdose feedback #172), background scroll lock (feedback #204), focus\n * into the panel on open and back to the trigger on close, a Tab focus trap, and\n * `role=\"dialog\"`/`aria-modal`.\n */\nexport function Modal({\n onClose,\n open,\n children,\n size = \"md\",\n className,\n labelledBy,\n onKeyDown,\n fullBleed,\n draggable,\n style,\n role = \"dialog\",\n ...rest\n}: ModalProps) {\n const panelRef = useRef<HTMLDivElement>(null);\n const drag = useDragOffset(Boolean(draggable));\n // Without `open`, mounted means open — the constant `true` every hook below used to\n // be given. With it, `open` itself.\n const active = open ?? true;\n\n // Whether the last close came through `requestClose`, i.e. has ALREADY been\n // animated. Set in the same batch as the caller's `onClose`, so the render that sees\n // `open` turn false also sees this and does not lower the panel a second time.\n const [dismissed, setDismissed] = useState(false);\n // The exit of a close the caller decided on (only reachable with `open`). Adjusted\n // during render when `open` flips — `Collapse`'s pattern — so the very render that\n // closes it already paints the `-out` classes rather than a frame of nothing.\n const [exiting, setExiting] = useState(false);\n const [prevOpen, setPrevOpen] = useState(open);\n if (open !== prevOpen) {\n setPrevOpen(open);\n setDismissed(false);\n setExiting(open === false && prevOpen === true && !dismissed && !prefersReducedMotion());\n if (open) drag.reset();\n }\n useEffect(() => {\n if (!exiting) return;\n const timer = setTimeout(() => setExiting(false), OVERLAY_EXIT_MS);\n return () => clearTimeout(timer);\n }, [exiting]);\n\n // The panel lowers itself before the caller unmounts it (live #320 rework). Every\n // dismissal below goes through `requestClose`; `onClose` still does the closing, one\n // animation later. A caller that closes the dialog ITSELF — after a save, say —\n // unmounts with no exit unless it passes `open`, which is what that prop is for.\n const { closing, requestClose } = useCloseTransition(() => {\n setDismissed(true);\n onClose();\n });\n // A panel on its way out after `open` turned false is already closed: a press on\n // its fading backdrop must not report a second close.\n const backdropClose = useBackdropClose(active ? requestClose : () => {});\n // Back means the same as Escape here. On a phone Escape doesn't exist, so without\n // this the only way out of a dialog is finding its close button — and Back, the\n // gesture everyone reaches for, navigated the page underneath instead (#172).\n // Held only while open: a closed `open={false}` dialog must not own a history entry.\n useOverlayHistory(active, requestClose);\n\n // Through the shared hook and not by hand: this component's own save/restore copy\n // was one half of the pair that left the page permanently unscrollable when a dialog\n // containing an open sheet was closed — see the note in use-body-scroll-lock.ts.\n useBodyScrollLock(active);\n\n // Focus the panel itself (not the first field) so opening doesn't pop the mobile\n // keyboard, while still moving focus into the dialog for keyboard and screen-reader\n // users. Through the shared hook since this component is where it came from — the\n // hook adds per-keystroke recomputation, a guard on restoring to a detached node,\n // and nesting, none of which this copy had. Released when `open` turns false, which\n // hands focus back to the trigger while the panel is still on its way out.\n useFocusTrap(panelRef, { active, initialFocus: \"container\" });\n const leaving = closing || exiting;\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (e.key === \"Escape\") {\n e.stopPropagation();\n if (active) requestClose();\n return;\n }\n // Tab containment lives in useFocusTrap, which listens on the panel itself.\n };\n\n // Portal to <body> so the `fixed inset-0 z-50` overlay escapes whatever stacking\n // context its caller sits in. Rendered inline, a modal opened from e.g. the top\n // bar (a z-30 context) could paint BELOW a sibling z-30 sticky element like the\n // expanded transaction editor (feedback #320). The tour/command-palette overlays\n // already portal for the same reason.\n if (!active && !exiting) return null;\n return createPortal(\n <div\n // Out of the accessibility tree for the length of a caller-driven exit: focus is\n // already back on the page, and an `aria-modal` panel that is leaving would hide\n // that page from a screen reader for 220ms. Not `inert` — that would let a tap\n // fall through the fading backdrop to the row underneath.\n aria-hidden={exiting || undefined}\n className={cn(\n // Live #320. The panel below rises only where it is bottom-anchored: from md up\n // it is centred, and a centred box sliding up from off-screen reads as a\n // different component arriving rather than as the same one settling.\n leaving ? \"animate-overlay-out\" : \"animate-overlay\",\n \"fixed inset-0 z-50 flex items-end justify-center bg-black/40 md:items-center\",\n fullBleed ? \"p-0 md:p-4\" : \"p-4\",\n )}\n {...backdropClose}\n >\n <div\n // `...rest` FIRST, everything the dialog needs to be a dialog after it. A\n // wrapper that spreads its own props through to this one cannot then take away\n // the role, the modality or the `tabIndex={-1}` that `useFocusTrap` needs —\n // losing any of the three is silent, and the symptom (a dialog a screen reader\n // walks straight out of) shows up nowhere near the call site that caused it.\n {...rest}\n ref={panelRef}\n // Normalised at runtime too: an untyped caller's `role=\"presentation\"` must not\n // take the dialog role away (props-passthrough pins that).\n role={role === \"alertdialog\" ? \"alertdialog\" : \"dialog\"}\n aria-modal=\"true\"\n aria-labelledby={labelledBy}\n tabIndex={-1}\n onKeyDown={handleKeyDown}\n {...drag.handlers}\n // MERGED, not replaced: `drag.style` is undefined until a drag starts, so\n // assigning it outright would drop a caller's own `style` on every render but\n // the ones where the panel is being dragged.\n style={{ ...style, ...drag.style }}\n className={cn(\n leaving ? \"animate-sheet-out md:animate-none\" : \"animate-sheet md:animate-none\",\n \"w-full rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] shadow-sm outline-none\",\n { md: \"max-w-md\", lg: \"max-w-lg\", xl: \"max-w-3xl\" }[size],\n // A panel taller than the screen has to scroll ITSELF. The backdrop is\n // `fixed inset-0` and the body is scroll-locked while a dialog is open, so\n // without this the overflow simply had nowhere to go: on a phone the panel\n // is bottom-anchored, so it grew UPWARD past the top edge and the part that\n // went past it could not be reached by any gesture (Keksdose live #254, on\n // the price-merge dialog — but it was every dialog with more than a screen\n // of content). `max-h-full` resolves against the backdrop's content box,\n // which is the viewport minus its own padding, so the panel stops exactly\n // where the screen does; `overscroll-contain` keeps the fling inside it.\n //\n // Three callers had already patched themselves with `max-h-[90vh]` +\n // an inner scroller. Those still win — `cn` is tailwind-merge — and this is\n // the default they should not have needed.\n \"max-h-full overflow-y-auto overscroll-contain\",\n \"p-4\",\n // The grab affordance sits on the panel's own top strip: a drag handle of\n // its own would be one more control in a dialog that is mostly one field.\n draggable && \"md:[&>*:first-child]:cursor-grab\",\n className,\n )}\n >\n <ModalCloseContext.Provider value={requestClose}>{children}</ModalCloseContext.Provider>\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";AAuWQ;AAvWR,SAAS,eAAe,WAAW,QAAQ,gBAAgB;AAC3D,SAAS,oBAAoB;AAQ7B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,iBAAiB,sBAAsB,0BAA0B;AAoB1E,SAAS,cAAc,SAAkB;AACvC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA0C,IAAI;AAC1E,QAAM,OAAO,OAAgE,IAAI;AAEjF,QAAM,UAAU,MAAM;AACpB,SAAK,UAAU;AAAA,EACjB;AAEA,SAAO;AAAA;AAAA;AAAA,IAGL,OAAO,MAAM,UAAU,IAAI;AAAA,IAC3B,OAAO,SAAS,EAAE,WAAW,aAAa,OAAO,CAAC,OAAO,OAAO,CAAC,MAAM,IAAI;AAAA,IAC3E,UAAU,CAAC,UACP,SACA;AAAA,MACE,eAAe,CAAC,MAAyC;AACvD,YAAI,EAAE,WAAW,KAAK,OAAO,aAAa,IAAK;AAC/C,cAAM,SAAS,EAAE;AAGjB,YAAI,OAAO,QAAQ,gDAAgD,EAAG;AACtE,aAAK,UAAU,EAAE,GAAG,EAAE,SAAS,GAAG,EAAE,SAAS,IAAI,QAAQ,KAAK,GAAG,IAAI,QAAQ,KAAK,EAAE;AACpF,YAAI;AAKF,YAAE,cAAc,kBAAkB,EAAE,SAAS;AAAA,QAC/C,QAAQ;AAAA,QAKR;AAAA,MACF;AAAA,MACA,eAAe,CAAC,MAAyC;AACvD,cAAM,QAAQ,KAAK;AACnB,YAAI,CAAC,MAAO;AACZ,kB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AA;AAAA;AAAA;AAAA;AAAA;AAAA,cAcxD;AAAA,cACA;AAAA;AAAA;AAAA,cAGA,aAAa;AAAA,cACb;AAAA,YACF;AAAA,YAEA,8BAAC,kBAAkB,UAAlB,EAA2B,OAAO,cAAe,UAAS;AAAA;AAAA,QAC7D;AAAA;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EACX;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/modal.tsx"],"sourcesContent":["import { createContext, useEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type {\n ComponentPropsWithoutRef,\n KeyboardEvent,\n MouseEvent as ReactMouseEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n} from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useFocusTrap } from \"../hooks/use-focus-trap\";\nimport { useBodyScrollLock } from \"../hooks/use-body-scroll-lock\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { useDialogParam, type DialogParam } from \"../hooks/use-search-param-state\";\nimport { OVERLAY_EXIT_MS, prefersReducedMotion, useCloseTransition } from \"../hooks/use-close-transition\";\n\n/**\n * Drag the panel by its top strip, in pointer space (dev#460).\n *\n * Deliberately not a library and not persisted: the offset is component state that\n * dies with the dialog. It starts only on a press that lands on the panel's own\n * chrome — never on a field, a button or a link, which is what keeps \"drag to select\n * text in the textarea\" working. Above `md` only: below it the panel is a\n * full-width bottom sheet with nothing beside it to uncover.\n *\n * The whole gesture stays on the PANEL — captured pointer, React handlers — rather than\n * on `window`. The first shape of this added `pointermove`/`pointerup` to `window` from\n * inside the `pointerdown` handler and took them off again from the `pointerup` handler,\n * so the teardown ran only if the gesture ended: React never sees a listener added from\n * an event handler, and an unmount mid-drag left a live `pointermove` on `window` for\n * the life of the page, pinning this hook's state with it. The one caller that enables\n * dragging is the feedback composer, which closes ITSELF on submit — a Ctrl+Enter sent\n * with the pointer still down is exactly that order of events, once per drag.\n */\nfunction useDragOffset(enabled: boolean) {\n const [offset, setOffset] = useState<{ x: number; y: number } | null>(null);\n const from = useRef<{ x: number; y: number; ox: number; oy: number } | null>(null);\n\n const endDrag = () => {\n from.current = null;\n };\n\n return {\n /** Back to where the panel opens. A `Modal` with an `open` prop outlives its own\n * closes, so \"the position resets when the dialog closes\" needs saying. */\n reset: () => setOffset(null),\n style: offset ? { transform: `translate(${offset.x}px, ${offset.y}px)` } : undefined,\n handlers: !enabled\n ? undefined\n : {\n onPointerDown: (e: ReactPointerEvent<HTMLDivElement>) => {\n if (e.button !== 0 || window.innerWidth < 768) return;\n const target = e.target as HTMLElement;\n // Only the panel itself and its non-interactive chrome start a drag; a\n // press inside any control belongs to that control.\n if (target.closest(\"input,textarea,select,button,a,[role='button']\")) return;\n from.current = { x: e.clientX, y: e.clientY, ox: offset?.x ?? 0, oy: offset?.y ?? 0 };\n try {\n // Capture is what lets the handlers live on the panel: every later\n // pointer event for this pointer retargets here, so the drag keeps\n // working once the pointer outruns the panel's own box — which it always\n // does, since the panel moves out from under it.\n e.currentTarget.setPointerCapture(e.pointerId);\n } catch {\n // jsdom implements no pointer capture, and a browser throws\n // NotFoundError for a pointerId that is already gone. Neither is worth\n // refusing the drag: uncaptured, the panel still gets the moves that\n // land on it.\n }\n },\n onPointerMove: (e: ReactPointerEvent<HTMLDivElement>) => {\n const start = from.current;\n if (!start) return;\n setOffset({ x: start.ox + e.clientX - start.x, y: start.oy + e.clientY - start.y });\n },\n onPointerUp: endDrag,\n // A cancel (the browser taking the pointer for a scroll or a gesture) and a\n // lost capture both mean no `pointerup` is coming. Without them the drag would\n // stay \"live\" and the next move over the panel would jump it.\n onPointerCancel: endDrag,\n onLostPointerCapture: endDrag,\n },\n };\n}\n\n/**\n * The panel's own ANIMATED dismissal, for chrome rendered inside it. `DialogFrame`'s X\n * and its `actions(close)` read this, so a Cancel or an X lowers the panel exactly the\n * way Escape does — calling `onClose` from inside unmounts with no exit, which is the\n * documented limit of {@link useCloseTransition}. `null` outside a `Modal`.\n */\nexport const ModalCloseContext = createContext<(() => void) | null>(null);\n\n/**\n * Backdrop handlers that close only when a press starts AND ends on the\n * backdrop itself. A plain onClick fires on mouseup, so dragging a text\n * selection that starts inside the panel and releases over the backdrop would\n * dismiss the dialog (feedback #254) — and the reverse drag would too, since\n * click targets the common ancestor of the down/up elements.\n */\nexport function useBackdropClose(onClose: () => void) {\n const pressStartedOnBackdrop = useRef(false);\n return {\n onMouseDown: (e: ReactMouseEvent<HTMLDivElement>) => {\n pressStartedOnBackdrop.current = e.target === e.currentTarget;\n },\n onMouseUp: (e: ReactMouseEvent<HTMLDivElement>) => {\n const started = pressStartedOnBackdrop.current;\n pressStartedOnBackdrop.current = false;\n if (started && e.target === e.currentTarget) onClose();\n },\n };\n}\n\n// Tab-cycle target set: the interactive descendants the focus trap rotates\n// through. Querying live (per keystroke) means dynamically rendered fields are\n// included automatically.\n/**\n * `extends ComponentPropsWithoutRef<\"div\">` so anything a `<div>` takes reaches the\n * PANEL — the element with `role=\"dialog\"`, which is the one a consumer means. That is\n * where a `data-tour` anchor, a test id, an `aria-describedby` or an `aria-label` has\n * to land; before this, a closed prop list dropped all four silently (audit §api-design).\n */\nexport interface ModalProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"role\"> {\n /** Invoked on backdrop click and on Escape. */\n onClose: () => void;\n /**\n * Who decides whether the dialog is up, when the caller wants to keep it MOUNTED.\n *\n * Left out, the dialog is open for as long as it is mounted — `{open && <Modal/>}`,\n * which is every caller before this prop and stays exactly as it was. That idiom has\n * one blind spot: a close the CALLER decides on (a save that succeeded, a\n * `setOpen(false)` from outside) unmounts the panel on the spot, with no exit,\n * because there is nothing left to animate. kastlan's `FormModal` was nothing but an\n * `if (!open) return null` gate in front of this.\n *\n * Passed, the component stays mounted while closed and renders nothing, and a flip\n * to `false` plays the same exit a dismissal does before the panel goes. The focus\n * trap, the scroll lock and the Back-gesture history entry are held only while\n * `open` is true — they are released the moment it turns false, so focus is back on\n * the trigger while the panel is still lowering. A dismissal (Escape, the backdrop,\n * Back, the frame's X) animates first and then calls `onClose`; the `false` that\n * comes back from it is not animated a second time.\n *\n * The body is unmounted once the exit has finished, as it is today, so a form inside\n * still starts fresh on the next open.\n */\n open?: boolean;\n /** `\"alertdialog\"` for a dialog that interrupts to ask a question the user must\n * answer (a confirmation) — screen readers announce it with more urgency. Only the\n * two dialog roles are allowed: the panel stays modal either way. */\n role?: \"dialog\" | \"alertdialog\";\n children: ReactNode;\n /**\n * Panel max-width: `md` (28rem), `lg` (32rem), `xl` (48rem).\n *\n * `xl` exists because two callers had already written `className=\"max-w-3xl\"` to\n * reach it — the payee backfill's preview table and the price-merge dialog, both\n * of which hold a list and several fields rather than one question. A caller\n * patching a missing size IS the signal that the size is missing, and a\n * hand-written width in a `className` is a width nothing else can line up with.\n *\n * The panel is `w-full` under every one of them, so the cap only bites once the\n * viewport is wider than it: on a phone all three are the same full-width bottom\n * sheet. Nothing here may introduce a `min-w-*`, which is what would break that.\n */\n size?: \"md\" | \"lg\" | \"xl\";\n /** Extra classes for the panel (e.g. `space-y-3` for form content spacing). */\n className?: string;\n /** id of the heading element, wired to `aria-labelledby`. */\n labelledBy?: string;\n /**\n * Extra key handling on the panel (e.g. Ctrl/Cmd+Enter to submit). Runs first;\n * if it calls `preventDefault()` the built-in Escape/Tab handling is skipped\n * for that event.\n */\n onKeyDown?: (e: KeyboardEvent<HTMLDivElement>) => void;\n /**\n * Drop the backdrop's mobile margin so the panel can reach the screen edges\n * (a full-screen sheet on phones). The panel still needs its own\n * `h-[100dvh] max-w-full rounded-none` classes via `className` to fill it; the\n * desktop `md:p-4` margin is kept. Defaults to false (padded on all sizes).\n */\n fullBleed?: boolean;\n /**\n * Let the user drag the panel out of the way by its top edge (Keksdose feedback\n * dev#460: *\"Make the feedback dialog draggable so I can see behind it if it\n * blocks something.\"*).\n *\n * Opt-in, because it only makes sense for a dialog whose content is ABOUT the page\n * behind it — the feedback composer is the case, an ordinary form is not, and a\n * draggable panel that has nothing to reveal is a control that can only get lost.\n *\n * Pointer-only by design: it is a \"move this out of the way\" gesture, not a layout\n * choice worth persisting, and the position resets when the dialog closes. On a\n * phone the panel is a bottom sheet the width of the screen, so dragging is\n * suppressed there — there is nothing beside it to see.\n */\n draggable?: boolean;\n /**\n * Bind the open state to a URL search param (0.12.0): `\"edit\"` is open while\n * `?edit` is in the query, `{ key: \"dialog\", value: \"create-lease\" }` while\n * `?dialog=create-lease` is. The URL is then the only state — `open` is ignored —\n * and the dialog opens from anywhere that sets the param: {@link useDialogParam}'s\n * setter, a `<Link>`, a shared link, a reload.\n *\n * kastlan's `useDialogParam` did this beside the dialog, so its open state could be\n * deep-linked and captured in a feedback report. Here it also owns the history:\n * opening through `useDialogParam` pushes an entry, so the Back gesture closes the\n * dialog by leaving it, and a close (Escape, the backdrop, the X) goes back over\n * that entry rather than stacking a second one. The dialog's own Back handling\n * ({@link useOverlayHistory}'s throwaway entry) stays off in this mode — the param's\n * entry already is one, and two would take two Back presses to close one dialog.\n *\n * `onClose` still runs, after the param is cleared. Requires a react-router Router.\n */\n urlParam?: DialogParam;\n}\n\n/**\n * The URL-bound dialog: the param is the open state, and closing clears it. A\n * component of its own so the router hook is only called by a `Modal` that asked for\n * it — a plain `Modal` must keep working with no Router above it.\n */\nfunction UrlParamModal({ urlParam, onClose, ...rest }: ModalProps & { urlParam: DialogParam }) {\n const [open, setOpen] = useDialogParam(urlParam);\n // Closed from here the moment the dismissal is decided. Going back is a traversal\n // the browser lands a task later, and between the two the param still says \"open\":\n // without this the panel, already lowered, would pop back up for that task.\n const [leaving, setLeaving] = useState(false);\n if (leaving && !open) setLeaving(false);\n return (\n <ModalPanel\n {...rest}\n open={open && !leaving}\n ownHistoryEntry={false}\n onClose={() => {\n setLeaving(true);\n setOpen(false);\n onClose();\n }}\n />\n );\n}\n\n/**\n * Centered (bottom-sheet on mobile) modal dialog: dimmed backdrop, single\n * rounded panel. Owns the overlay mechanics that the hand-rolled dialogs each\n * re-implemented or lacked — backdrop-click + Escape to close, the platform Back\n * gesture (Keksdose feedback #172), background scroll lock (feedback #204), focus\n * into the panel on open and back to the trigger on close, a Tab focus trap, and\n * `role=\"dialog\"`/`aria-modal`.\n */\nexport function Modal(props: ModalProps) {\n return props.urlParam !== undefined ? (\n <UrlParamModal {...props} urlParam={props.urlParam} />\n ) : (\n <ModalPanel {...props} />\n );\n}\n\nfunction ModalPanel({\n onClose,\n open,\n children,\n size = \"md\",\n className,\n labelledBy,\n onKeyDown,\n fullBleed,\n draggable,\n style,\n role = \"dialog\",\n urlParam: _urlParam,\n ownHistoryEntry = true,\n ...rest\n}: ModalProps & {\n /** False when the URL already holds an entry for this dialog — see `urlParam`. */\n ownHistoryEntry?: boolean;\n}) {\n const panelRef = useRef<HTMLDivElement>(null);\n const drag = useDragOffset(Boolean(draggable));\n // Without `open`, mounted means open — the constant `true` every hook below used to\n // be given. With it, `open` itself.\n const active = open ?? true;\n\n // Whether the last close came through `requestClose`, i.e. has ALREADY been\n // animated. Set in the same batch as the caller's `onClose`, so the render that sees\n // `open` turn false also sees this and does not lower the panel a second time.\n const [dismissed, setDismissed] = useState(false);\n // The exit of a close the caller decided on (only reachable with `open`). Adjusted\n // during render when `open` flips — `Collapse`'s pattern — so the very render that\n // closes it already paints the `-out` classes rather than a frame of nothing.\n const [exiting, setExiting] = useState(false);\n const [prevOpen, setPrevOpen] = useState(open);\n if (open !== prevOpen) {\n setPrevOpen(open);\n setDismissed(false);\n setExiting(open === false && prevOpen === true && !dismissed && !prefersReducedMotion());\n if (open) drag.reset();\n }\n useEffect(() => {\n if (!exiting) return;\n const timer = setTimeout(() => setExiting(false), OVERLAY_EXIT_MS);\n return () => clearTimeout(timer);\n }, [exiting]);\n\n // The panel lowers itself before the caller unmounts it (live #320 rework). Every\n // dismissal below goes through `requestClose`; `onClose` still does the closing, one\n // animation later. A caller that closes the dialog ITSELF — after a save, say —\n // unmounts with no exit unless it passes `open`, which is what that prop is for.\n const { closing, requestClose } = useCloseTransition(() => {\n setDismissed(true);\n onClose();\n });\n // A panel on its way out after `open` turned false is already closed: a press on\n // its fading backdrop must not report a second close.\n const backdropClose = useBackdropClose(active ? requestClose : () => {});\n // Back means the same as Escape here. On a phone Escape doesn't exist, so without\n // this the only way out of a dialog is finding its close button — and Back, the\n // gesture everyone reaches for, navigated the page underneath instead (#172).\n // Held only while open: a closed `open={false}` dialog must not own a history entry.\n useOverlayHistory(active && ownHistoryEntry, requestClose);\n\n // Through the shared hook and not by hand: this component's own save/restore copy\n // was one half of the pair that left the page permanently unscrollable when a dialog\n // containing an open sheet was closed — see the note in use-body-scroll-lock.ts.\n useBodyScrollLock(active);\n\n // Focus the panel itself (not the first field) so opening doesn't pop the mobile\n // keyboard, while still moving focus into the dialog for keyboard and screen-reader\n // users. Through the shared hook since this component is where it came from — the\n // hook adds per-keystroke recomputation, a guard on restoring to a detached node,\n // and nesting, none of which this copy had. Released when `open` turns false, which\n // hands focus back to the trigger while the panel is still on its way out.\n useFocusTrap(panelRef, { active, initialFocus: \"container\" });\n const leaving = closing || exiting;\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (e.key === \"Escape\") {\n e.stopPropagation();\n if (active) requestClose();\n return;\n }\n // Tab containment lives in useFocusTrap, which listens on the panel itself.\n };\n\n // Portal to <body> so the `fixed inset-0 z-50` overlay escapes whatever stacking\n // context its caller sits in. Rendered inline, a modal opened from e.g. the top\n // bar (a z-30 context) could paint BELOW a sibling z-30 sticky element like the\n // expanded transaction editor (feedback #320). The tour/command-palette overlays\n // already portal for the same reason.\n if (!active && !exiting) return null;\n return createPortal(\n <div\n // Out of the accessibility tree for the length of a caller-driven exit: focus is\n // already back on the page, and an `aria-modal` panel that is leaving would hide\n // that page from a screen reader for 220ms. Not `inert` — that would let a tap\n // fall through the fading backdrop to the row underneath.\n aria-hidden={exiting || undefined}\n className={cn(\n // Live #320. The panel below rises only where it is bottom-anchored: from md up\n // it is centred, and a centred box sliding up from off-screen reads as a\n // different component arriving rather than as the same one settling.\n leaving ? \"animate-overlay-out\" : \"animate-overlay\",\n \"fixed inset-0 z-50 flex items-end justify-center bg-black/40 md:items-center\",\n fullBleed ? \"p-0 md:p-4\" : \"p-4\",\n )}\n {...backdropClose}\n >\n <div\n // `...rest` FIRST, everything the dialog needs to be a dialog after it. A\n // wrapper that spreads its own props through to this one cannot then take away\n // the role, the modality or the `tabIndex={-1}` that `useFocusTrap` needs —\n // losing any of the three is silent, and the symptom (a dialog a screen reader\n // walks straight out of) shows up nowhere near the call site that caused it.\n {...rest}\n ref={panelRef}\n // Normalised at runtime too: an untyped caller's `role=\"presentation\"` must not\n // take the dialog role away (props-passthrough pins that).\n role={role === \"alertdialog\" ? \"alertdialog\" : \"dialog\"}\n aria-modal=\"true\"\n aria-labelledby={labelledBy}\n tabIndex={-1}\n onKeyDown={handleKeyDown}\n {...drag.handlers}\n // MERGED, not replaced: `drag.style` is undefined until a drag starts, so\n // assigning it outright would drop a caller's own `style` on every render but\n // the ones where the panel is being dragged.\n style={{ ...style, ...drag.style }}\n className={cn(\n leaving ? \"animate-sheet-out md:animate-none\" : \"animate-sheet md:animate-none\",\n \"w-full rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] shadow-sm outline-none\",\n { md: \"max-w-md\", lg: \"max-w-lg\", xl: \"max-w-3xl\" }[size],\n // A panel taller than the screen has to scroll ITSELF. The backdrop is\n // `fixed inset-0` and the body is scroll-locked while a dialog is open, so\n // without this the overflow simply had nowhere to go: on a phone the panel\n // is bottom-anchored, so it grew UPWARD past the top edge and the part that\n // went past it could not be reached by any gesture (Keksdose live #254, on\n // the price-merge dialog — but it was every dialog with more than a screen\n // of content). `max-h-full` resolves against the backdrop's content box,\n // which is the viewport minus its own padding, so the panel stops exactly\n // where the screen does; `overscroll-contain` keeps the fling inside it.\n //\n // Three callers had already patched themselves with `max-h-[90vh]` +\n // an inner scroller. Those still win — `cn` is tailwind-merge — and this is\n // the default they should not have needed.\n \"max-h-full overflow-y-auto overscroll-contain\",\n \"p-4\",\n // The grab affordance sits on the panel's own top strip: a drag handle of\n // its own would be one more control in a dialog that is mostly one field.\n draggable && \"md:[&>*:first-child]:cursor-grab\",\n className,\n )}\n >\n <ModalCloseContext.Provider value={requestClose}>{children}</ModalCloseContext.Provider>\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";AAwOI;AAxOJ,SAAS,eAAe,WAAW,QAAQ,gBAAgB;AAC3D,SAAS,oBAAoB;AAQ7B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,sBAAwC;AACjD,SAAS,iBAAiB,sBAAsB,0BAA0B;AAoB1E,SAAS,cAAc,SAAkB;AACvC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA0C,IAAI;AAC1E,QAAM,OAAO,OAAgE,IAAI;AAEjF,QAAM,UAAU,MAAM;AACpB,SAAK,UAAU;AAAA,EACjB;AAEA,SAAO;AAAA;AAAA;AAAA,IAGL,OAAO,MAAM,UAAU,IAAI;AAAA,IAC3B,OAAO,SAAS,EAAE,WAAW,aAAa,OAAO,CAAC,OAAO,OAAO,CAAC,MAAM,IAAI;AAAA,IAC3E,UAAU,CAAC,UACP,SACA;AAAA,MACE,eAAe,CAAC,MAAyC;AACvD,YAAI,EAAE,WAAW,KAAK,OAAO,aAAa,IAAK;AAC/C,cAAM,SAAS,EAAE;AAGjB,YAAI,OAAO,QAAQ,gDAAgD,EAAG;AACtE,aAAK,UAAU,EAAE,GAAG,EAAE,SAAS,GAAG,EAAE,SAAS,IAAI,QAAQ,KAAK,GAAG,IAAI,QAAQ,KAAK,EAAE;AACpF,YAAI;AAKF,YAAE,cAAc,kBAAkB,EAAE,SAAS;AAAA,QAC/C,QAAQ;AAAA,QAKR;AAAA,MACF;AAAA,MACA,eAAe,CAAC,MAAyC;AACvD,cAAM,QAAQ,KAAK;AACnB,YAAI,CAAC,MAAO;AACZ,kBAAU,EAAE,GAAG,MAA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eAAa,WAAW;AAAA,QACxB,WAAW;AAAA;AAAA;AAAA;AAAA,UAIT,UAAU,wBAAwB;AAAA,UAClC;AAAA,UACA,YAAY,eAAe;AAAA,QAC7B;AAAA,QACC,GAAG;AAAA,QAEJ;AAAA,UAAC;AAAA;AAAA,YAME,GAAG;AAAA,YACJ,KAAK;AAAA,YAGL,MAAM,SAAS,gBAAgB,gBAAgB;AAAA,YAC/C,cAAW;AAAA,YACX,mBAAiB;AAAA,YACjB,UAAU;AAAA,YACV,WAAW;AAAA,YACV,GAAG,KAAK;AAAA,YAIT,OAAO,EAAE,GAAG,OAAO,GAAG,KAAK,MAAM;AAAA,YACjC,WAAW;AAAA,cACT,UAAU,sCAAsC;AAAA,cAChD;AAAA,cACA,EAAE,IAAI,YAAY,IAAI,YAAY,IAAI,YAAY,EAAE,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAcxD;AAAA,cACA;AAAA;AAAA;AAAA,cAGA,aAAa;AAAA,cACb;AAAA,YACF;AAAA,YAEA,8BAAC,kBAAkB,UAAlB,EAA2B,OAAO,cAAe,UAAS;AAAA;AAAA,QAC7D;AAAA;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EACX;AACF;","names":[]}
|
|
@@ -18,6 +18,11 @@ interface MonthPickerLabels {
|
|
|
18
18
|
* "Aug" read out on its own does not say which year the grid is on.
|
|
19
19
|
*/
|
|
20
20
|
month: (monthYear: string) => string;
|
|
21
|
+
/** `variant="stepper"`: the icon-only arrows that step the value by one month. */
|
|
22
|
+
previousMonth: string;
|
|
23
|
+
nextMonth: string;
|
|
24
|
+
/** `variant="stepper"`: the button that jumps to the current month. Visible text. */
|
|
25
|
+
today: string;
|
|
21
26
|
}
|
|
22
27
|
/** The English starting point every override is merged onto. Exported (unlike the
|
|
23
28
|
* calendar's) because it is asked for by name: a host building its own translation
|
|
@@ -73,7 +78,22 @@ interface MonthPickerProps extends Omit<ComponentPropsWithoutRef<"div">, "onChan
|
|
|
73
78
|
/** Extra classes for the trigger button — e.g. a compact `h-9 w-auto` trigger
|
|
74
79
|
* sitting between two icon buttons in a toolbar. */
|
|
75
80
|
triggerClassName?: string;
|
|
81
|
+
/**
|
|
82
|
+
* `"field"` (default): the field-shaped trigger, for a form.
|
|
83
|
+
*
|
|
84
|
+
* `"stepper"`: the header of a month PAGE — the month as a heading that opens the
|
|
85
|
+
* grid, then Today and ‹ › stepping the value by one month. What a calendar page
|
|
86
|
+
* assembled by hand around the field (overriding its trigger to look like a
|
|
87
|
+
* heading). `label`, `placeholder`, `invalid` and `triggerClassName` are the field's
|
|
88
|
+
* and are not drawn here; with no `value` the arrows step from the current month.
|
|
89
|
+
*/
|
|
90
|
+
variant?: "field" | "stepper";
|
|
91
|
+
/** `variant="stepper"`: the heading level the month is set in (`<h2>` by default), or
|
|
92
|
+
* `false` for no heading element — the page already has one for the month. */
|
|
93
|
+
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6 | false;
|
|
94
|
+
/** `variant="stepper"`: draw the Today button. Default `true`. */
|
|
95
|
+
showToday?: boolean;
|
|
76
96
|
}
|
|
77
|
-
declare function MonthPicker({ value, onChange, locale: localeProp, min, max, label, placeholder, disabled, invalid, formatOptions, currentMonth, labels: labelsProp, className, triggerClassName, ...rest }: MonthPickerProps): react.JSX.Element;
|
|
97
|
+
declare function MonthPicker({ value, onChange, locale: localeProp, min, max, label, placeholder, disabled, invalid, formatOptions, currentMonth, labels: labelsProp, className, triggerClassName, variant, headingLevel, showToday, ...rest }: MonthPickerProps): react.JSX.Element;
|
|
78
98
|
|
|
79
99
|
export { DEFAULT_MONTH_PICKER_LABELS, MonthPicker, type MonthPickerLabels, type MonthPickerProps };
|