@nocoo/basalt 2.1.7 → 2.2.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/ai/INTEGRATION.md +66 -28
- package/ai/RECIPES.md +46 -1
- package/ai/USAGE.md +2 -2
- package/ai/registry.json +65 -23
- package/dist/assets/brand-mark.js.map +1 -1
- package/dist/charts/area.js.map +1 -1
- package/dist/charts/bar.js.map +1 -1
- package/dist/charts/bullet.js.map +1 -1
- package/dist/charts/charts.js.map +1 -1
- package/dist/charts/config.js.map +1 -1
- package/dist/charts/custom-chart.js.map +1 -1
- package/dist/charts/date-navigation.js.map +1 -1
- package/dist/charts/donut.js.map +1 -1
- package/dist/charts/frame.js.map +1 -1
- package/dist/charts/funnel.js.map +1 -1
- package/dist/charts/gauge.js.map +1 -1
- package/dist/charts/grouped-bar.js.map +1 -1
- package/dist/charts/heatmap-calendar.js.map +1 -1
- package/dist/charts/heatmap-matrix.js.map +1 -1
- package/dist/charts/item-list.js.map +1 -1
- package/dist/charts/legend.js.map +1 -1
- package/dist/charts/line.js.map +1 -1
- package/dist/charts/palette.js.map +1 -1
- package/dist/charts/radar.js.map +1 -1
- package/dist/charts/sample.js.map +1 -1
- package/dist/charts/sankey.js.map +1 -1
- package/dist/charts/series.js.map +1 -1
- package/dist/charts/slot-bar.js.map +1 -1
- package/dist/charts/sparkline.js.map +1 -1
- package/dist/charts/stacked-bar.js.map +1 -1
- package/dist/charts/stat-card.js.map +1 -1
- package/dist/charts/timeline.js.map +1 -1
- package/dist/charts/timeseries.js.map +1 -1
- package/dist/charts/tooltip.js.map +1 -1
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/app-header.d.ts +5 -1
- package/dist/components/app-header.js +12 -4
- package/dist/components/app-header.js.map +1 -1
- package/dist/components/app-shell.d.ts +4 -1
- package/dist/components/app-shell.js +7 -4
- package/dist/components/app-shell.js.map +1 -1
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/banner.js.map +1 -1
- package/dist/components/basalt-mark.js.map +1 -1
- package/dist/components/battery-meter.js.map +1 -1
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/button.js +2 -2
- package/dist/components/button.js.map +1 -1
- package/dist/components/chat-bubble.js.map +1 -1
- package/dist/components/chat-composer.js.map +1 -1
- package/dist/components/chat-header.js.map +1 -1
- package/dist/components/chat-inbox.js.map +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/clipboard-text.js.map +1 -1
- package/dist/components/code.js.map +1 -1
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command-palette.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +4 -1
- package/dist/components/confirm-dialog.js +20 -18
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/context-menu.js.map +1 -1
- package/dist/components/data-table.js +1 -1
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/delete-resource.js +1 -1
- package/dist/components/delete-resource.js.map +1 -1
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dock.js.map +1 -1
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/editable-nav-item.js.map +1 -1
- package/dist/components/empty.js.map +1 -1
- package/dist/components/fab.js.map +1 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/filter-bar.js.map +1 -1
- package/dist/components/flow.js.map +1 -1
- package/dist/components/grid.js.map +1 -1
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/inline-editable.js.map +1 -1
- package/dist/components/input-area.js.map +1 -1
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/layer-card.js.map +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/loader.js.map +1 -1
- package/dist/components/loading-screen.js.map +1 -1
- package/dist/components/menu-bar.js.map +1 -1
- package/dist/components/meter.js.map +1 -1
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/overlay.js.map +1 -1
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/radio.js.map +1 -1
- package/dist/components/resource-list.js.map +1 -1
- package/dist/components/responsive-master-detail.js +5 -5
- package/dist/components/responsive-master-detail.js.map +1 -1
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/section-rule.js.map +1 -1
- package/dist/components/segment-control.js.map +1 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/sensitive-input.js.map +1 -1
- package/dist/components/separator.js.map +1 -1
- package/dist/components/sheet.js +1 -0
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.d.ts +3 -1
- package/dist/components/sidebar.js +8 -5
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/skeleton-line.js.map +1 -1
- package/dist/components/slider.js.map +1 -1
- package/dist/components/stat-strip.js.map +1 -1
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table-of-contents.js.map +1 -1
- package/dist/components/table-pager.js.map +1 -1
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tag-badge.js.map +1 -1
- package/dist/components/tag-color-picker.js.map +1 -1
- package/dist/components/text.js.map +1 -1
- package/dist/components/theme-toggle.js.map +1 -1
- package/dist/components/toast.js.map +1 -1
- package/dist/components/toggle-group.js +2 -2
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/toolbar.js.map +1 -1
- package/dist/components/tooltip.js +14 -13
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/typeahead-field.js.map +1 -1
- package/dist/components/upload-queue.js.map +1 -1
- package/dist/providers/accent.js +1 -1
- package/dist/providers/accent.js.map +1 -1
- package/dist/providers/link.js.map +1 -1
- package/dist/providers/theme.js +1 -1
- package/dist/providers/theme.js.map +1 -1
- package/dist/styles/base.css +116 -0
- package/dist/styles/standalone.css +161 -16
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/control-surface.js.map +1 -1
- package/dist/utils/preference-store.js +1 -1
- package/dist/utils/preference-store.js.map +1 -1
- package/dist/utils/selection-indicator.js +1 -1
- package/dist/utils/selection-indicator.js.map +1 -1
- package/dist/utils/use-checkable-group.js.map +1 -1
- package/package.json +2 -2
|
@@ -82,7 +82,7 @@ function b({ data: g, columns: b, filter: ae = "", loading: x = !1, empty: oe =
|
|
|
82
82
|
let t = v(e.row) ? e.row : null;
|
|
83
83
|
if (!t) continue;
|
|
84
84
|
let r = B.current.get(t)?.[e.occurrence];
|
|
85
|
-
|
|
85
|
+
r && !n.has(r) && V.current.get(r) === t && (e.key = r, n.add(r));
|
|
86
86
|
}
|
|
87
87
|
let u = l.map(({ row: r, index: i, occurrence: a, key: o }) => {
|
|
88
88
|
let c = v(r) ? r : null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.js","names":[],"sources":["../../src/components/data-table.tsx"],"sourcesContent":["import {\n\ttype CSSProperties,\n\ttype ReactNode,\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Button } from \"./button\";\nimport { Pagination } from \"./pagination\";\nimport { SkeletonLine } from \"./skeleton-line\";\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from \"./table\";\n\nexport type DataTableColumn<T> = {\n\tid: string;\n\theader: string;\n\taccessor: (row: T) => ReactNode;\n\tsortValue?: (row: T) => string | number | bigint;\n\tfilterValue?: (row: T) => string | number | bigint;\n\t/** Rich header content; header remains the plain text accessible name. */\n\theaderContent?: ReactNode;\n\t/** Whether the header changes sorting. @default true */\n\tsortable?: boolean;\n\t/** Width of the header and its column. */\n\twidth?: CSSProperties[\"width\"];\n\t/** Classes applied to the header cell. */\n\theaderClassName?: string;\n\t/** Classes applied to each data cell. */\n\tcellClassName?: string;\n};\n\nexport type DataTableSort = { id: string; dir: \"asc\" | \"desc\" };\n\nfunction rank(value: unknown): number {\n\tif (value === Number.NEGATIVE_INFINITY) {\n\t\treturn 0;\n\t}\n\tif (typeof value === \"bigint\" || (typeof value === \"number\" && Number.isFinite(value))) {\n\t\treturn 1;\n\t}\n\tif (value === Number.POSITIVE_INFINITY) {\n\t\treturn 2;\n\t}\n\tif (typeof value === \"number\") {\n\t\treturn 3;\n\t}\n\tif (typeof value === \"string\") {\n\t\treturn 4;\n\t}\n\treturn 5;\n}\n\nfunction compareUnknown(left: unknown, right: unknown): number {\n\tconst leftRank = rank(left);\n\tconst rightRank = rank(right);\n\tif (leftRank !== rightRank) {\n\t\treturn leftRank - rightRank;\n\t}\n\tif (leftRank === 1) {\n\t\tconst a = left as number | bigint;\n\t\tconst b = right as number | bigint;\n\t\treturn a < b ? -1 : a > b ? 1 : 0;\n\t}\n\tconst leftStr = String(left);\n\tconst rightStr = String(right);\n\treturn leftStr < rightStr ? -1 : leftStr > rightStr ? 1 : 0;\n}\n\nfunction primitiveKey(\n\trow: unknown,\n\tindex: number,\n\tsymbols: Map<symbol, string>,\n\tseq: { current: number },\n): string {\n\tif (row === null) {\n\t\treturn \"prim:null\";\n\t}\n\tif (row === undefined) {\n\t\treturn \"prim:undefined\";\n\t}\n\tif (typeof row === \"symbol\") {\n\t\tlet key = symbols.get(row);\n\t\tif (!key) {\n\t\t\tkey = `prim:symbol:${seq.current++}`;\n\t\t\tsymbols.set(row, key);\n\t\t}\n\t\treturn key;\n\t}\n\tconst type = typeof row;\n\tif (type === \"number\") {\n\t\tif (Object.is(row, -0)) {\n\t\t\treturn \"prim:number:-0\";\n\t\t}\n\t\treturn `prim:number:${String(row)}`;\n\t}\n\tif (type === \"string\" || type === \"bigint\" || type === \"boolean\") {\n\t\treturn `prim:${type}:${String(row)}`;\n\t}\n\treturn `prim:${index}`;\n}\n\nfunction isInstanceKey(key: string) {\n\treturn key.startsWith(\"dup:\") || key.startsWith(\"gen:\");\n}\n\nfunction isRefRow(row: unknown): row is object {\n\treturn typeof row === \"function\" || (typeof row === \"object\" && row !== null);\n}\n\nfunction filterSource<T>(column: DataTableColumn<T>, row: T): string {\n\tif (column.filterValue) {\n\t\treturn String(column.filterValue(row));\n\t}\n\tif (column.sortValue) {\n\t\treturn String(column.sortValue(row));\n\t}\n\tconst rendered = column.accessor(row);\n\tif (\n\t\ttypeof rendered === \"string\" ||\n\t\ttypeof rendered === \"number\" ||\n\t\ttypeof rendered === \"bigint\"\n\t) {\n\t\treturn String(rendered);\n\t}\n\treturn \"\";\n}\n\nfunction publicSelectId<T>(\n\trow: T,\n\tindex: number,\n\tkey: string,\n\tgetRowId?: (row: T, index: number) => string,\n): string {\n\tconst requested = getRowId?.(row, index);\n\tif (requested !== undefined) {\n\t\treturn requested;\n\t}\n\tif (isRefRow(row) && \"id\" in row && row.id != null) {\n\t\treturn String(row.id);\n\t}\n\treturn key;\n}\n\nexport type DataTableProps<T = unknown> = {\n\t/**\n\t * Rows to render.\n\t */\n\tdata: T[];\n\t/**\n\t * Column descriptors.\n\t */\n\tcolumns: DataTableColumn<T>[];\n\t/**\n\t * Filter query matched against column values.\n\t * @default \"\"\n\t */\n\tfilter?: string;\n\t/**\n\t * Replace rows with a loading placeholder.\n\t * @default false\n\t */\n\tloading?: boolean;\n\t/**\n\t * Copy shown when no rows remain after filtering.\n\t * @default \"No results\"\n\t */\n\tempty?: ReactNode;\n\t/**\n\t * Controlled selected row ids.\n\t */\n\tselected?: string[];\n\t/**\n\t * Uncontrolled initial selected row ids.\n\t */\n\tdefaultSelected?: string[];\n\t/**\n\t * Called when selected row ids change.\n\t */\n\tonSelectedChange?: (ids: string[]) => void;\n\t/**\n\t * Allow more than one selected row.\n\t * @default false\n\t */\n\tmultiple?: boolean;\n\t/**\n\t * Controlled 1-based page. Used with pageSize.\n\t */\n\tpage?: number;\n\t/**\n\t * Uncontrolled initial page.\n\t * @default 1\n\t */\n\tdefaultPage?: number;\n\t/**\n\t * Rows per page. Omit to show every row.\n\t */\n\tpageSize?: number;\n\t/**\n\t * Called when the page changes.\n\t */\n\tonPageChange?: (page: number) => void;\n\t/**\n\t * Stable id for a row.\n\t */\n\tgetRowId?: (row: T, index: number) => string;\n\t/**\n\t * Additional classes for the table.\n\t */\n\tclassName?: string;\n\t/** Controlled sorting. null explicitly disables sorting. */\n\tsort?: DataTableSort | null;\n\t/** Initial sorting for uncontrolled usage. @default null */\n\tdefaultSort?: DataTableSort | null;\n\t/** Reports header sorting requests. Controlled values change only when the caller accepts. */\n\tonSortChange?: (sort: DataTableSort | null) => void;\n\t/** Caller supplies sorted rows; headers only report requests. @default false */\n\tmanualSorting?: boolean;\n\t/** Caller supplies the current page; rows are never sliced again. Use stable row IDs across pages. @default false */\n\tmanualPagination?: boolean;\n\t/** Caller supplies filtered rows; filter is not applied locally. @default false */\n\tmanualFiltering?: boolean;\n\t/** Total matching row count in manualPagination mode; defaults to data.length. */\n\ttotal?: number;\n\t/** Error content replacing rows after loading finishes. */\n\terror?: ReactNode;\n\t/** Optional retry action for an error. The caller owns the request. */\n\tonRetry?: () => void;\n\t/** Retry button text. @default \"Try again\" */\n\tretryLabel?: string;\n\t/** Accessible table name. @default \"Data table\" */\n\t\"aria-label\"?: string;\n\t/** ID of additional table instructions or summary. */\n\t\"aria-describedby\"?: string;\n};\n\nexport function DataTable<T>({\n\tdata,\n\tcolumns,\n\tfilter = \"\",\n\tloading = false,\n\tempty = \"No results\",\n\tselected,\n\tdefaultSelected,\n\tonSelectedChange,\n\tmultiple = false,\n\tpage,\n\tdefaultPage = 1,\n\tpageSize,\n\tonPageChange,\n\tgetRowId,\n\tclassName,\n\tsort: controlledSort,\n\tdefaultSort = null,\n\tonSortChange,\n\tmanualSorting = false,\n\tmanualPagination = false,\n\tmanualFiltering = false,\n\ttotal,\n\terror,\n\tonRetry,\n\tretryLabel = \"Try again\",\n\t\"aria-label\": ariaLabel = \"Data table\",\n\t\"aria-describedby\": ariaDescribedBy,\n}: DataTableProps<T>) {\n\tconst [uncontrolledSort, setUncontrolledSort] = useState<DataTableSort | null>(defaultSort);\n\tconst sort = controlledSort === undefined ? uncontrolledSort : controlledSort;\n\tconst requestSort = (next: DataTableSort) => {\n\t\tif (controlledSort === undefined) setUncontrolledSort(next);\n\t\tonSortChange?.(next);\n\t};\n\tconst [uncontrolledSelected, setUncontrolledSelected] = useState<string[]>(defaultSelected ?? []);\n\tconst [uncontrolledPage, setUncontrolledPage] = useState(defaultPage);\n\tconst rowIds = useRef(new WeakMap<object, string>());\n\tconst rowSeq = useRef(0);\n\tconst assignedKeys = useRef(new WeakMap<object, string[]>());\n\tconst lastOwner = useRef(new Map<string, object>());\n\tconst lastKeyByCanonical = useRef(new Map<string, string>());\n\tconst lastDupsByCanonical = useRef(new Map<string, string[]>());\n\tconst symbolKeys = useRef(new Map<symbol, string>());\n\tconst query = filter.trim().toLowerCase();\n\n\tconst rows = useMemo(() => {\n\t\tconst identityOf = (row: object) => {\n\t\t\tlet stored = rowIds.current.get(row);\n\t\t\tif (!stored) {\n\t\t\t\tstored = `basalt-row-${rowSeq.current++}`;\n\t\t\t\trowIds.current.set(row, stored);\n\t\t\t}\n\t\t\treturn stored;\n\t\t};\n\t\tconst canonicalOf = (row: T, index: number) => {\n\t\t\tconst requested = getRowId?.(row, index);\n\t\t\tif (requested !== undefined) {\n\t\t\t\treturn `get:${requested}`;\n\t\t\t}\n\t\t\tif (isRefRow(row) && \"id\" in row) {\n\t\t\t\tconst raw = (row as { id: unknown }).id;\n\t\t\t\tif (raw != null) {\n\t\t\t\t\treturn `id:${String(raw)}`;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tconst used = new Set<string>();\n\t\tconst nextLastKey = new Map<string, string>();\n\t\tconst nextDups = new Map<string, string[]>();\n\t\tconst nextAssigned = new Map<object, string[]>();\n\t\tconst nextOwner = new Map<string, object>();\n\t\tconst rememberKey = (row: T, index: number, key: string, objectRow: object | null) => {\n\t\t\tif (!objectRow) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst list = nextAssigned.get(objectRow) ?? [];\n\t\t\tlist.push(key);\n\t\t\tnextAssigned.set(objectRow, list);\n\t\t\tnextOwner.set(key, objectRow);\n\t\t\tconst canonical = canonicalOf(row, index);\n\t\t\tif (!canonical) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnextLastKey.set(canonical, key);\n\t\t\tif (isInstanceKey(key)) {\n\t\t\t\tconst dups = nextDups.get(canonical) ?? [];\n\t\t\t\tdups.push(key);\n\t\t\t\tnextDups.set(canonical, dups);\n\t\t\t}\n\t\t};\n\t\tconst counts = new WeakMap<object, number>();\n\t\tconst pending = data.map((row, index) => {\n\t\t\tconst objectRow = isRefRow(row) ? row : null;\n\t\t\tconst occurrence = objectRow ? (counts.get(objectRow) ?? 0) : 0;\n\t\t\tif (objectRow) {\n\t\t\t\tcounts.set(objectRow, occurrence + 1);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\trow,\n\t\t\t\tindex,\n\t\t\t\toccurrence,\n\t\t\t\tkey: undefined as string | undefined,\n\t\t\t};\n\t\t});\n\t\tfor (const item of pending) {\n\t\t\tconst objectRow = isRefRow(item.row) ? item.row : null;\n\t\t\tif (!objectRow) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst previous = assignedKeys.current.get(objectRow)?.[item.occurrence];\n\t\t\tif (!previous || used.has(previous)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (lastOwner.current.get(previous) === objectRow) {\n\t\t\t\titem.key = previous;\n\t\t\t\tused.add(previous);\n\t\t\t}\n\t\t}\n\t\tconst keyed = pending.map(({ row, index, occurrence, key: reserved }) => {\n\t\t\tconst objectRow = isRefRow(row) ? row : null;\n\t\t\tif (reserved) {\n\t\t\t\trememberKey(row, index, reserved, objectRow);\n\t\t\t\treturn {\n\t\t\t\t\trow,\n\t\t\t\t\tkey: reserved,\n\t\t\t\t\tselectId: publicSelectId(row, index, reserved, getRowId),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst isRepeat = occurrence > 0;\n\t\t\tlet key: string | undefined;\n\t\t\tconst requested = canonicalOf(row, index);\n\t\t\tif (requested) {\n\t\t\t\tkey = requested;\n\t\t\t}\n\t\t\tif (objectRow) {\n\t\t\t\tconst stored = identityOf(objectRow);\n\t\t\t\tif (!key) {\n\t\t\t\t\tkey = isRepeat ? `gen:${stored}#${occurrence}` : `gen:${stored}`;\n\t\t\t\t} else if (used.has(key) || isRepeat) {\n\t\t\t\t\tconst reused = (lastDupsByCanonical.current.get(key) ?? []).find(\n\t\t\t\t\t\t(candidate) => !used.has(candidate),\n\t\t\t\t\t);\n\t\t\t\t\tkey = reused ?? (isRepeat ? `dup:${stored}#${occurrence}` : `dup:${stored}`);\n\t\t\t\t} else {\n\t\t\t\t\tconst inherited = lastKeyByCanonical.current.get(key);\n\t\t\t\t\tif (inherited && !used.has(inherited) && isInstanceKey(inherited)) {\n\t\t\t\t\t\tkey = inherited;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tkey = key ?? primitiveKey(row, index, symbolKeys.current, rowSeq);\n\t\t\tif (used.has(key)) {\n\t\t\t\tlet n = 0;\n\t\t\t\tlet candidate = `occ:${key}#${n}`;\n\t\t\t\twhile (used.has(candidate)) {\n\t\t\t\t\tn += 1;\n\t\t\t\t\tcandidate = `occ:${key}#${n}`;\n\t\t\t\t}\n\t\t\t\tkey = candidate;\n\t\t\t}\n\t\t\tused.add(key);\n\t\t\trememberKey(row, index, key, objectRow);\n\t\t\treturn { row, key, selectId: publicSelectId(row, index, key, getRowId) };\n\t\t});\n\t\tconst filtered =\n\t\t\tquery && !manualFiltering\n\t\t\t\t? keyed.filter(({ row }) =>\n\t\t\t\t\t\tcolumns.some((column) => filterSource(column, row).toLowerCase().includes(query)),\n\t\t\t\t\t)\n\t\t\t\t: keyed;\n\t\tconst sorted = (() => {\n\t\t\tif (!sort || manualSorting) {\n\t\t\t\treturn filtered;\n\t\t\t}\n\t\t\tconst column = columns.find((item) => item.id === sort.id);\n\t\t\tif (!column) {\n\t\t\t\treturn filtered;\n\t\t\t}\n\t\t\treturn [...filtered].sort((a, b) => {\n\t\t\t\tconst left = column.sortValue?.(a.row) ?? column.accessor(a.row);\n\t\t\t\tconst right = column.sortValue?.(b.row) ?? column.accessor(b.row);\n\t\t\t\tconst cmp = compareUnknown(left, right);\n\t\t\t\treturn sort.dir === \"asc\" ? cmp : -cmp;\n\t\t\t});\n\t\t})();\n\t\treturn {\n\t\t\trows: sorted,\n\t\t\tassigned: nextAssigned,\n\t\t\towner: nextOwner,\n\t\t\tlastKey: nextLastKey,\n\t\t\tdups: nextDups,\n\t\t};\n\t}, [columns, data, getRowId, query, sort, manualFiltering, manualSorting]);\n\n\tuseLayoutEffect(() => {\n\t\tfor (const [objectRow, keys] of rows.assigned) {\n\t\t\tassignedKeys.current.set(objectRow, keys);\n\t\t}\n\t\tlastOwner.current = rows.owner;\n\t\tlastKeyByCanonical.current = rows.lastKey;\n\t\tlastDupsByCanonical.current = rows.dups;\n\t}, [rows]);\n\n\tconst selectable =\n\t\tselected !== undefined || defaultSelected !== undefined || onSelectedChange !== undefined;\n\tconst selectedIds = selected ?? uncontrolledSelected;\n\tconst setSelectedIds = useCallback(\n\t\t(next: string[]) => {\n\t\t\tif (selected === undefined) {\n\t\t\t\tsetUncontrolledSelected(next);\n\t\t\t}\n\t\t\tonSelectedChange?.(next);\n\t\t},\n\t\t[onSelectedChange, selected],\n\t);\n\tconst rowCount = manualPagination && total !== undefined ? Math.max(0, total) : rows.rows.length;\n\tconst pageCount = pageSize && pageSize > 0 ? Math.max(1, Math.ceil(rowCount / pageSize)) : 1;\n\tconst resolvedPage = Math.min(pageCount, Math.max(1, page ?? uncontrolledPage));\n\tconst setResolvedPage = useCallback(\n\t\t(next: number) => {\n\t\t\tif (page === undefined) {\n\t\t\t\tsetUncontrolledPage(next);\n\t\t\t}\n\t\t\tonPageChange?.(next);\n\t\t},\n\t\t[onPageChange, page],\n\t);\n\tconst lastCorrection = useRef<string | null>(null);\n\tuseEffect(() => {\n\t\tconst requested = page ?? uncontrolledPage;\n\t\tif (requested === resolvedPage || loading) {\n\t\t\tlastCorrection.current = null;\n\t\t\treturn;\n\t\t}\n\t\tconst correction = `${requested}:${resolvedPage}`;\n\t\tif (lastCorrection.current !== correction) {\n\t\t\tlastCorrection.current = correction;\n\t\t\tsetResolvedPage(resolvedPage);\n\t\t}\n\t}, [page, uncontrolledPage, resolvedPage, loading, setResolvedPage]);\n\tconst paged =\n\t\t!manualPagination && pageSize && pageSize > 0\n\t\t\t? rows.rows.slice((resolvedPage - 1) * pageSize, resolvedPage * pageSize)\n\t\t\t: rows.rows;\n\tconst colCount = columns.length + (selectable ? 1 : 0);\n\tconst toggleSelected = (id: string) => {\n\t\tif (multiple) {\n\t\t\tsetSelectedIds(\n\t\t\t\tselectedIds.includes(id) ? selectedIds.filter((item) => item !== id) : [...selectedIds, id],\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tsetSelectedIds(selectedIds.includes(id) ? [] : [id]);\n\t};\n\n\treturn (\n\t\t<div className=\"flex min-w-0 flex-col gap-3\">\n\t\t\t<div\n\t\t\t\trole=\"region\"\n\t\t\t\taria-label={`${ariaLabel} scroll area`}\n\t\t\t\t// biome-ignore lint/a11y/noNoninteractiveTabindex: Named overflow regions need keyboard scrolling.\n\t\t\t\ttabIndex={0}\n\t\t\t\tclassName=\"min-w-0 overflow-x-auto rounded-basalt-md focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-basalt-primary\"\n\t\t\t>\n\t\t\t\t<Table\n\t\t\t\t\tclassName={cn(\"w-full\", className)}\n\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\taria-describedby={ariaDescribedBy}\n\t\t\t\t\taria-busy={loading || undefined}\n\t\t\t\t>\n\t\t\t\t\t<TableHeader>\n\t\t\t\t\t\t<TableRow>\n\t\t\t\t\t\t\t{selectable ? (\n\t\t\t\t\t\t\t\t<TableHead>\n\t\t\t\t\t\t\t\t\t<span className=\"sr-only\">Select</span>\n\t\t\t\t\t\t\t\t</TableHead>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t{columns.map((column) => (\n\t\t\t\t\t\t\t\t<TableHead\n\t\t\t\t\t\t\t\t\tkey={column.id}\n\t\t\t\t\t\t\t\t\tclassName={column.headerClassName}\n\t\t\t\t\t\t\t\t\tstyle={{ width: column.width }}\n\t\t\t\t\t\t\t\t\tscope=\"col\"\n\t\t\t\t\t\t\t\t\taria-sort={\n\t\t\t\t\t\t\t\t\t\tcolumn.sortable === false\n\t\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t\t: sort?.id === column.id\n\t\t\t\t\t\t\t\t\t\t\t\t? sort.dir === \"asc\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t? \"ascending\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t: \"descending\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"none\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{column.sortable === false ? (\n\t\t\t\t\t\t\t\t\t\t(column.headerContent ?? column.header)\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\taria-label={column.header}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"appearance-none border-0 bg-transparent p-0 font-inherit text-inherit font-medium cursor-pointer rounded-sm focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-basalt-primary\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\t\t\t\t\trequestSort(\n\t\t\t\t\t\t\t\t\t\t\t\t\tsort?.id === column.id && sort.dir === \"asc\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? { id: column.id, dir: \"desc\" }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: { id: column.id, dir: \"asc\" },\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{column.headerContent ?? column.header}\n\t\t\t\t\t\t\t\t\t\t\t{sort?.id === column.id ? (sort.dir === \"asc\" ? \" ↑\" : \" ↓\") : \"\"}\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</TableHead>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t</TableHeader>\n\t\t\t\t\t<TableBody>\n\t\t\t\t\t\t{loading ? (\n\t\t\t\t\t\t\t<TableRow>\n\t\t\t\t\t\t\t\t<TableCell colSpan={colCount}>\n\t\t\t\t\t\t\t\t\t<div role=\"status\" className=\"flex flex-col gap-2 py-2\">\n\t\t\t\t\t\t\t\t\t\t<span className=\"sr-only\">Loading</span>\n\t\t\t\t\t\t\t\t\t\t<SkeletonLine />\n\t\t\t\t\t\t\t\t\t\t<SkeletonLine />\n\t\t\t\t\t\t\t\t\t\t<SkeletonLine />\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t\t) : error != null && error !== false ? (\n\t\t\t\t\t\t\t<TableRow>\n\t\t\t\t\t\t\t\t<TableCell colSpan={colCount}>\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\trole=\"alert\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"flex flex-wrap items-center justify-between gap-3 py-6\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<div>{error}</div>\n\t\t\t\t\t\t\t\t\t\t{onRetry ? (\n\t\t\t\t\t\t\t\t\t\t\t<Button variant=\"outline\" size=\"sm\" onClick={onRetry}>\n\t\t\t\t\t\t\t\t\t\t\t\t{retryLabel}\n\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t\t) : paged.length === 0 ? (\n\t\t\t\t\t\t\t<TableRow>\n\t\t\t\t\t\t\t\t<TableCell colSpan={colCount}>\n\t\t\t\t\t\t\t\t\t<div role=\"status\">{empty}</div>\n\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tpaged.map(({ row, key, selectId }) => {\n\t\t\t\t\t\t\t\tconst isSelected = selectedIds.includes(selectId);\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<TableRow\n\t\t\t\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\t\t\t\tvariant={isSelected ? \"selected\" : \"default\"}\n\t\t\t\t\t\t\t\t\t\taria-selected={selectable ? isSelected : undefined}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{selectable ? (\n\t\t\t\t\t\t\t\t\t\t\t<TableCell>\n\t\t\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tchecked={isSelected}\n\t\t\t\t\t\t\t\t\t\t\t\t\taria-label={`Select ${selectId}`}\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={() => toggleSelected(selectId)}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t\t{columns.map((column) => {\n\t\t\t\t\t\t\t\t\t\t\tconst cell = column.accessor(row);\n\t\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t\t<TableCell key={column.id} className={column.cellClassName}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{typeof cell === \"bigint\" ? String(cell) : cell}\n\t\t\t\t\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t)}\n\t\t\t\t\t</TableBody>\n\t\t\t\t</Table>\n\t\t\t</div>\n\t\t\t{pageSize && pageSize > 0 ? (\n\t\t\t\t<Pagination\n\t\t\t\t\tpage={resolvedPage}\n\t\t\t\t\tpageCount={pageCount}\n\t\t\t\t\tdisabled={loading}\n\t\t\t\t\tonPageChange={setResolvedPage}\n\t\t\t\t/>\n\t\t\t) : null}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;AAoCA,SAAS,EAAK,GAAwB;CAgBrC,OAfI,MAAU,YACN,IAEJ,OAAO,KAAU,YAAa,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK,IAC5E,IAEJ,MAAU,WACN,IAEJ,OAAO,KAAU,WACb,IAEJ,OAAO,KAAU,WACb,IAED;AACR;AAEA,SAAS,GAAe,GAAe,GAAwB;CAC9D,IAAM,IAAW,EAAK,CAAI,GACpB,IAAY,EAAK,CAAK;CAC5B,IAAI,MAAa,GAChB,OAAO,IAAW;CAEnB,IAAI,MAAa,GAAG;EACnB,IAAM,IAAI,GACJ,IAAI;EACV,OAAO,IAAI,IAAI,KAAK,MAAI;CACzB;CACA,IAAM,IAAU,OAAO,CAAI,GACrB,IAAW,OAAO,CAAK;CAC7B,OAAO,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C,UAAA,CAKE,IACA,kBAAC,GAAD,EAAA,UACC,kBAAC,SAAD;OACC,MAAK;OACL,SAAS;OACT,cAAY,UAAU;OACtB,gBAAgB,GAAe,CAAQ;MACvC,CAAA,EACS,CAAA,IACR,MACH,EAAQ,KAAK,MAAW;OACxB,IAAM,IAAO,EAAO,SAAS,CAAG;OAChC,OACC,kBAAC,GAAD;QAA2B,WAAW,EAAO;QAC3C,UAAA,OAAO,KAAS,WAAW,OAAO,CAAI,IAAI;OACjC,GAFK,EAAO,EAEZ;MAEb,CAAC,CACQ;KAtBJ,GAAA,CAsBI;IAEZ,CAAC,EAEQ,CAAA,CACL;;EACH,CAAA,GACJ,KAAY,IAAW,IACvB,kBAAC,GAAD;GACC,MAAM;GACK;GACX,UAAU;GACV,cAAc;EACd,CAAA,IACE,IACA;;AAEP"}
|
|
1
|
+
{"version":3,"file":"data-table.js","names":["rank","value","compareUnknown","leftRank","left","rightRank","right","a","b","leftStr","rightStr","primitiveKey","row","key","symbols","type","index","isInstanceKey","isRefRow","filterSource","column","rendered","publicSelectId","requested","getRowId","DataTable","controlledSort","ariaLabel","ariaDescribedBy","uncontrolledSort","setUncontrolledSort","useState","defaultSort","sort","requestSort","next","onSortChange","uncontrolledSelected","setUncontrolledSelected","defaultSelected","uncontrolledPage","setUncontrolledPage","defaultPage","rowIds","useRef","rowSeq","assignedKeys","lastOwner","lastKeyByCanonical","lastDupsByCanonical","symbolKeys","query","filter","rows","useMemo","identityOf","stored","canonicalOf","raw","used","nextLastKey","nextDups","nextAssigned","nextOwner","rememberKey","objectRow","list","canonical","dups","counts","pending","data","occurrence","item","previous","keyed","reserved","isRepeat","candidate","inherited","n","filtered","manualFiltering","columns","manualSorting","cmp","keys","selectable","selected","onSelectedChange","selectedIds","setSelectedIds","useCallback","rowCount","manualPagination","total","pageCount","pageSize","resolvedPage","page","setResolvedPage","onPageChange","lastCorrection","loading","correction","paged","colCount","toggleSelected","multiple","id","Table","cn","className","TableHeader","TableRow","TableHead","TableBody","TableCell","SkeletonLine","error","onRetry","Button","retryLabel","empty","isSelected","selectId","cell","Pagination"],"sources":["../../src/components/data-table.tsx"],"sourcesContent":["import {\n\ttype CSSProperties,\n\ttype ReactNode,\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Button } from \"./button\";\nimport { Pagination } from \"./pagination\";\nimport { SkeletonLine } from \"./skeleton-line\";\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from \"./table\";\n\nexport type DataTableColumn<T> = {\n\tid: string;\n\theader: string;\n\taccessor: (row: T) => ReactNode;\n\tsortValue?: (row: T) => string | number | bigint;\n\tfilterValue?: (row: T) => string | number | bigint;\n\t/** Rich header content; header remains the plain text accessible name. */\n\theaderContent?: ReactNode;\n\t/** Whether the header changes sorting. @default true */\n\tsortable?: boolean;\n\t/** Width of the header and its column. */\n\twidth?: CSSProperties[\"width\"];\n\t/** Classes applied to the header cell. */\n\theaderClassName?: string;\n\t/** Classes applied to each data cell. */\n\tcellClassName?: string;\n};\n\nexport type DataTableSort = { id: string; dir: \"asc\" | \"desc\" };\n\nfunction rank(value: unknown): number {\n\tif (value === Number.NEGATIVE_INFINITY) {\n\t\treturn 0;\n\t}\n\tif (typeof value === \"bigint\" || (typeof value === \"number\" && Number.isFinite(value))) {\n\t\treturn 1;\n\t}\n\tif (value === Number.POSITIVE_INFINITY) {\n\t\treturn 2;\n\t}\n\tif (typeof value === \"number\") {\n\t\treturn 3;\n\t}\n\tif (typeof value === \"string\") {\n\t\treturn 4;\n\t}\n\treturn 5;\n}\n\nfunction compareUnknown(left: unknown, right: unknown): number {\n\tconst leftRank = rank(left);\n\tconst rightRank = rank(right);\n\tif (leftRank !== rightRank) {\n\t\treturn leftRank - rightRank;\n\t}\n\tif (leftRank === 1) {\n\t\tconst a = left as number | bigint;\n\t\tconst b = right as number | bigint;\n\t\treturn a < b ? -1 : a > b ? 1 : 0;\n\t}\n\tconst leftStr = String(left);\n\tconst rightStr = String(right);\n\treturn leftStr < rightStr ? -1 : leftStr > rightStr ? 1 : 0;\n}\n\nfunction primitiveKey(\n\trow: unknown,\n\tindex: number,\n\tsymbols: Map<symbol, string>,\n\tseq: { current: number },\n): string {\n\tif (row === null) {\n\t\treturn \"prim:null\";\n\t}\n\tif (row === undefined) {\n\t\treturn \"prim:undefined\";\n\t}\n\tif (typeof row === \"symbol\") {\n\t\tlet key = symbols.get(row);\n\t\tif (!key) {\n\t\t\tkey = `prim:symbol:${seq.current++}`;\n\t\t\tsymbols.set(row, key);\n\t\t}\n\t\treturn key;\n\t}\n\tconst type = typeof row;\n\tif (type === \"number\") {\n\t\tif (Object.is(row, -0)) {\n\t\t\treturn \"prim:number:-0\";\n\t\t}\n\t\treturn `prim:number:${String(row)}`;\n\t}\n\tif (type === \"string\" || type === \"bigint\" || type === \"boolean\") {\n\t\treturn `prim:${type}:${String(row)}`;\n\t}\n\treturn `prim:${index}`;\n}\n\nfunction isInstanceKey(key: string) {\n\treturn key.startsWith(\"dup:\") || key.startsWith(\"gen:\");\n}\n\nfunction isRefRow(row: unknown): row is object {\n\treturn typeof row === \"function\" || (typeof row === \"object\" && row !== null);\n}\n\nfunction filterSource<T>(column: DataTableColumn<T>, row: T): string {\n\tif (column.filterValue) {\n\t\treturn String(column.filterValue(row));\n\t}\n\tif (column.sortValue) {\n\t\treturn String(column.sortValue(row));\n\t}\n\tconst rendered = column.accessor(row);\n\tif (\n\t\ttypeof rendered === \"string\" ||\n\t\ttypeof rendered === \"number\" ||\n\t\ttypeof rendered === \"bigint\"\n\t) {\n\t\treturn String(rendered);\n\t}\n\treturn \"\";\n}\n\nfunction publicSelectId<T>(\n\trow: T,\n\tindex: number,\n\tkey: string,\n\tgetRowId?: (row: T, index: number) => string,\n): string {\n\tconst requested = getRowId?.(row, index);\n\tif (requested !== undefined) {\n\t\treturn requested;\n\t}\n\tif (isRefRow(row) && \"id\" in row && row.id != null) {\n\t\treturn String(row.id);\n\t}\n\treturn key;\n}\n\nexport type DataTableProps<T = unknown> = {\n\t/**\n\t * Rows to render.\n\t */\n\tdata: T[];\n\t/**\n\t * Column descriptors.\n\t */\n\tcolumns: DataTableColumn<T>[];\n\t/**\n\t * Filter query matched against column values.\n\t * @default \"\"\n\t */\n\tfilter?: string;\n\t/**\n\t * Replace rows with a loading placeholder.\n\t * @default false\n\t */\n\tloading?: boolean;\n\t/**\n\t * Copy shown when no rows remain after filtering.\n\t * @default \"No results\"\n\t */\n\tempty?: ReactNode;\n\t/**\n\t * Controlled selected row ids.\n\t */\n\tselected?: string[];\n\t/**\n\t * Uncontrolled initial selected row ids.\n\t */\n\tdefaultSelected?: string[];\n\t/**\n\t * Called when selected row ids change.\n\t */\n\tonSelectedChange?: (ids: string[]) => void;\n\t/**\n\t * Allow more than one selected row.\n\t * @default false\n\t */\n\tmultiple?: boolean;\n\t/**\n\t * Controlled 1-based page. Used with pageSize.\n\t */\n\tpage?: number;\n\t/**\n\t * Uncontrolled initial page.\n\t * @default 1\n\t */\n\tdefaultPage?: number;\n\t/**\n\t * Rows per page. Omit to show every row.\n\t */\n\tpageSize?: number;\n\t/**\n\t * Called when the page changes.\n\t */\n\tonPageChange?: (page: number) => void;\n\t/**\n\t * Stable id for a row.\n\t */\n\tgetRowId?: (row: T, index: number) => string;\n\t/**\n\t * Additional classes for the table.\n\t */\n\tclassName?: string;\n\t/** Controlled sorting. null explicitly disables sorting. */\n\tsort?: DataTableSort | null;\n\t/** Initial sorting for uncontrolled usage. @default null */\n\tdefaultSort?: DataTableSort | null;\n\t/** Reports header sorting requests. Controlled values change only when the caller accepts. */\n\tonSortChange?: (sort: DataTableSort | null) => void;\n\t/** Caller supplies sorted rows; headers only report requests. @default false */\n\tmanualSorting?: boolean;\n\t/** Caller supplies the current page; rows are never sliced again. Use stable row IDs across pages. @default false */\n\tmanualPagination?: boolean;\n\t/** Caller supplies filtered rows; filter is not applied locally. @default false */\n\tmanualFiltering?: boolean;\n\t/** Total matching row count in manualPagination mode; defaults to data.length. */\n\ttotal?: number;\n\t/** Error content replacing rows after loading finishes. */\n\terror?: ReactNode;\n\t/** Optional retry action for an error. The caller owns the request. */\n\tonRetry?: () => void;\n\t/** Retry button text. @default \"Try again\" */\n\tretryLabel?: string;\n\t/** Accessible table name. @default \"Data table\" */\n\t\"aria-label\"?: string;\n\t/** ID of additional table instructions or summary. */\n\t\"aria-describedby\"?: string;\n};\n\nexport function DataTable<T>({\n\tdata,\n\tcolumns,\n\tfilter = \"\",\n\tloading = false,\n\tempty = \"No results\",\n\tselected,\n\tdefaultSelected,\n\tonSelectedChange,\n\tmultiple = false,\n\tpage,\n\tdefaultPage = 1,\n\tpageSize,\n\tonPageChange,\n\tgetRowId,\n\tclassName,\n\tsort: controlledSort,\n\tdefaultSort = null,\n\tonSortChange,\n\tmanualSorting = false,\n\tmanualPagination = false,\n\tmanualFiltering = false,\n\ttotal,\n\terror,\n\tonRetry,\n\tretryLabel = \"Try again\",\n\t\"aria-label\": ariaLabel = \"Data table\",\n\t\"aria-describedby\": ariaDescribedBy,\n}: DataTableProps<T>) {\n\tconst [uncontrolledSort, setUncontrolledSort] = useState<DataTableSort | null>(defaultSort);\n\tconst sort = controlledSort === undefined ? uncontrolledSort : controlledSort;\n\tconst requestSort = (next: DataTableSort) => {\n\t\tif (controlledSort === undefined) setUncontrolledSort(next);\n\t\tonSortChange?.(next);\n\t};\n\tconst [uncontrolledSelected, setUncontrolledSelected] = useState<string[]>(defaultSelected ?? []);\n\tconst [uncontrolledPage, setUncontrolledPage] = useState(defaultPage);\n\tconst rowIds = useRef(new WeakMap<object, string>());\n\tconst rowSeq = useRef(0);\n\tconst assignedKeys = useRef(new WeakMap<object, string[]>());\n\tconst lastOwner = useRef(new Map<string, object>());\n\tconst lastKeyByCanonical = useRef(new Map<string, string>());\n\tconst lastDupsByCanonical = useRef(new Map<string, string[]>());\n\tconst symbolKeys = useRef(new Map<symbol, string>());\n\tconst query = filter.trim().toLowerCase();\n\n\tconst rows = useMemo(() => {\n\t\tconst identityOf = (row: object) => {\n\t\t\tlet stored = rowIds.current.get(row);\n\t\t\tif (!stored) {\n\t\t\t\tstored = `basalt-row-${rowSeq.current++}`;\n\t\t\t\trowIds.current.set(row, stored);\n\t\t\t}\n\t\t\treturn stored;\n\t\t};\n\t\tconst canonicalOf = (row: T, index: number) => {\n\t\t\tconst requested = getRowId?.(row, index);\n\t\t\tif (requested !== undefined) {\n\t\t\t\treturn `get:${requested}`;\n\t\t\t}\n\t\t\tif (isRefRow(row) && \"id\" in row) {\n\t\t\t\tconst raw = (row as { id: unknown }).id;\n\t\t\t\tif (raw != null) {\n\t\t\t\t\treturn `id:${String(raw)}`;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tconst used = new Set<string>();\n\t\tconst nextLastKey = new Map<string, string>();\n\t\tconst nextDups = new Map<string, string[]>();\n\t\tconst nextAssigned = new Map<object, string[]>();\n\t\tconst nextOwner = new Map<string, object>();\n\t\tconst rememberKey = (row: T, index: number, key: string, objectRow: object | null) => {\n\t\t\tif (!objectRow) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst list = nextAssigned.get(objectRow) ?? [];\n\t\t\tlist.push(key);\n\t\t\tnextAssigned.set(objectRow, list);\n\t\t\tnextOwner.set(key, objectRow);\n\t\t\tconst canonical = canonicalOf(row, index);\n\t\t\tif (!canonical) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnextLastKey.set(canonical, key);\n\t\t\tif (isInstanceKey(key)) {\n\t\t\t\tconst dups = nextDups.get(canonical) ?? [];\n\t\t\t\tdups.push(key);\n\t\t\t\tnextDups.set(canonical, dups);\n\t\t\t}\n\t\t};\n\t\tconst counts = new WeakMap<object, number>();\n\t\tconst pending = data.map((row, index) => {\n\t\t\tconst objectRow = isRefRow(row) ? row : null;\n\t\t\tconst occurrence = objectRow ? (counts.get(objectRow) ?? 0) : 0;\n\t\t\tif (objectRow) {\n\t\t\t\tcounts.set(objectRow, occurrence + 1);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\trow,\n\t\t\t\tindex,\n\t\t\t\toccurrence,\n\t\t\t\tkey: undefined as string | undefined,\n\t\t\t};\n\t\t});\n\t\tfor (const item of pending) {\n\t\t\tconst objectRow = isRefRow(item.row) ? item.row : null;\n\t\t\tif (!objectRow) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst previous = assignedKeys.current.get(objectRow)?.[item.occurrence];\n\t\t\tif (!previous || used.has(previous)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (lastOwner.current.get(previous) === objectRow) {\n\t\t\t\titem.key = previous;\n\t\t\t\tused.add(previous);\n\t\t\t}\n\t\t}\n\t\tconst keyed = pending.map(({ row, index, occurrence, key: reserved }) => {\n\t\t\tconst objectRow = isRefRow(row) ? row : null;\n\t\t\tif (reserved) {\n\t\t\t\trememberKey(row, index, reserved, objectRow);\n\t\t\t\treturn {\n\t\t\t\t\trow,\n\t\t\t\t\tkey: reserved,\n\t\t\t\t\tselectId: publicSelectId(row, index, reserved, getRowId),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst isRepeat = occurrence > 0;\n\t\t\tlet key: string | undefined;\n\t\t\tconst requested = canonicalOf(row, index);\n\t\t\tif (requested) {\n\t\t\t\tkey = requested;\n\t\t\t}\n\t\t\tif (objectRow) {\n\t\t\t\tconst stored = identityOf(objectRow);\n\t\t\t\tif (!key) {\n\t\t\t\t\tkey = isRepeat ? `gen:${stored}#${occurrence}` : `gen:${stored}`;\n\t\t\t\t} else if (used.has(key) || isRepeat) {\n\t\t\t\t\tconst reused = (lastDupsByCanonical.current.get(key) ?? []).find(\n\t\t\t\t\t\t(candidate) => !used.has(candidate),\n\t\t\t\t\t);\n\t\t\t\t\tkey = reused ?? (isRepeat ? `dup:${stored}#${occurrence}` : `dup:${stored}`);\n\t\t\t\t} else {\n\t\t\t\t\tconst inherited = lastKeyByCanonical.current.get(key);\n\t\t\t\t\tif (inherited && !used.has(inherited) && isInstanceKey(inherited)) {\n\t\t\t\t\t\tkey = inherited;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tkey = key ?? primitiveKey(row, index, symbolKeys.current, rowSeq);\n\t\t\tif (used.has(key)) {\n\t\t\t\tlet n = 0;\n\t\t\t\tlet candidate = `occ:${key}#${n}`;\n\t\t\t\twhile (used.has(candidate)) {\n\t\t\t\t\tn += 1;\n\t\t\t\t\tcandidate = `occ:${key}#${n}`;\n\t\t\t\t}\n\t\t\t\tkey = candidate;\n\t\t\t}\n\t\t\tused.add(key);\n\t\t\trememberKey(row, index, key, objectRow);\n\t\t\treturn { row, key, selectId: publicSelectId(row, index, key, getRowId) };\n\t\t});\n\t\tconst filtered =\n\t\t\tquery && !manualFiltering\n\t\t\t\t? keyed.filter(({ row }) =>\n\t\t\t\t\t\tcolumns.some((column) => filterSource(column, row).toLowerCase().includes(query)),\n\t\t\t\t\t)\n\t\t\t\t: keyed;\n\t\tconst sorted = (() => {\n\t\t\tif (!sort || manualSorting) {\n\t\t\t\treturn filtered;\n\t\t\t}\n\t\t\tconst column = columns.find((item) => item.id === sort.id);\n\t\t\tif (!column) {\n\t\t\t\treturn filtered;\n\t\t\t}\n\t\t\treturn [...filtered].sort((a, b) => {\n\t\t\t\tconst left = column.sortValue?.(a.row) ?? column.accessor(a.row);\n\t\t\t\tconst right = column.sortValue?.(b.row) ?? column.accessor(b.row);\n\t\t\t\tconst cmp = compareUnknown(left, right);\n\t\t\t\treturn sort.dir === \"asc\" ? cmp : -cmp;\n\t\t\t});\n\t\t})();\n\t\treturn {\n\t\t\trows: sorted,\n\t\t\tassigned: nextAssigned,\n\t\t\towner: nextOwner,\n\t\t\tlastKey: nextLastKey,\n\t\t\tdups: nextDups,\n\t\t};\n\t}, [columns, data, getRowId, query, sort, manualFiltering, manualSorting]);\n\n\tuseLayoutEffect(() => {\n\t\tfor (const [objectRow, keys] of rows.assigned) {\n\t\t\tassignedKeys.current.set(objectRow, keys);\n\t\t}\n\t\tlastOwner.current = rows.owner;\n\t\tlastKeyByCanonical.current = rows.lastKey;\n\t\tlastDupsByCanonical.current = rows.dups;\n\t}, [rows]);\n\n\tconst selectable =\n\t\tselected !== undefined || defaultSelected !== undefined || onSelectedChange !== undefined;\n\tconst selectedIds = selected ?? uncontrolledSelected;\n\tconst setSelectedIds = useCallback(\n\t\t(next: string[]) => {\n\t\t\tif (selected === undefined) {\n\t\t\t\tsetUncontrolledSelected(next);\n\t\t\t}\n\t\t\tonSelectedChange?.(next);\n\t\t},\n\t\t[onSelectedChange, selected],\n\t);\n\tconst rowCount = manualPagination && total !== undefined ? Math.max(0, total) : rows.rows.length;\n\tconst pageCount = pageSize && pageSize > 0 ? Math.max(1, Math.ceil(rowCount / pageSize)) : 1;\n\tconst resolvedPage = Math.min(pageCount, Math.max(1, page ?? uncontrolledPage));\n\tconst setResolvedPage = useCallback(\n\t\t(next: number) => {\n\t\t\tif (page === undefined) {\n\t\t\t\tsetUncontrolledPage(next);\n\t\t\t}\n\t\t\tonPageChange?.(next);\n\t\t},\n\t\t[onPageChange, page],\n\t);\n\tconst lastCorrection = useRef<string | null>(null);\n\tuseEffect(() => {\n\t\tconst requested = page ?? uncontrolledPage;\n\t\tif (requested === resolvedPage || loading) {\n\t\t\tlastCorrection.current = null;\n\t\t\treturn;\n\t\t}\n\t\tconst correction = `${requested}:${resolvedPage}`;\n\t\tif (lastCorrection.current !== correction) {\n\t\t\tlastCorrection.current = correction;\n\t\t\tsetResolvedPage(resolvedPage);\n\t\t}\n\t}, [page, uncontrolledPage, resolvedPage, loading, setResolvedPage]);\n\tconst paged =\n\t\t!manualPagination && pageSize && pageSize > 0\n\t\t\t? rows.rows.slice((resolvedPage - 1) * pageSize, resolvedPage * pageSize)\n\t\t\t: rows.rows;\n\tconst colCount = columns.length + (selectable ? 1 : 0);\n\tconst toggleSelected = (id: string) => {\n\t\tif (multiple) {\n\t\t\tsetSelectedIds(\n\t\t\t\tselectedIds.includes(id) ? selectedIds.filter((item) => item !== id) : [...selectedIds, id],\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tsetSelectedIds(selectedIds.includes(id) ? [] : [id]);\n\t};\n\n\treturn (\n\t\t<div className=\"flex min-w-0 flex-col gap-3\">\n\t\t\t<div\n\t\t\t\trole=\"region\"\n\t\t\t\taria-label={`${ariaLabel} scroll area`}\n\t\t\t\t// biome-ignore lint/a11y/noNoninteractiveTabindex: Named overflow regions need keyboard scrolling.\n\t\t\t\ttabIndex={0}\n\t\t\t\tclassName=\"min-w-0 overflow-x-auto rounded-basalt-md focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-basalt-primary\"\n\t\t\t>\n\t\t\t\t<Table\n\t\t\t\t\tclassName={cn(\"w-full\", className)}\n\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\taria-describedby={ariaDescribedBy}\n\t\t\t\t\taria-busy={loading || undefined}\n\t\t\t\t>\n\t\t\t\t\t<TableHeader>\n\t\t\t\t\t\t<TableRow>\n\t\t\t\t\t\t\t{selectable ? (\n\t\t\t\t\t\t\t\t<TableHead>\n\t\t\t\t\t\t\t\t\t<span className=\"sr-only\">Select</span>\n\t\t\t\t\t\t\t\t</TableHead>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t{columns.map((column) => (\n\t\t\t\t\t\t\t\t<TableHead\n\t\t\t\t\t\t\t\t\tkey={column.id}\n\t\t\t\t\t\t\t\t\tclassName={column.headerClassName}\n\t\t\t\t\t\t\t\t\tstyle={{ width: column.width }}\n\t\t\t\t\t\t\t\t\tscope=\"col\"\n\t\t\t\t\t\t\t\t\taria-sort={\n\t\t\t\t\t\t\t\t\t\tcolumn.sortable === false\n\t\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t\t: sort?.id === column.id\n\t\t\t\t\t\t\t\t\t\t\t\t? sort.dir === \"asc\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t? \"ascending\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t: \"descending\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"none\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{column.sortable === false ? (\n\t\t\t\t\t\t\t\t\t\t(column.headerContent ?? column.header)\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\taria-label={column.header}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"appearance-none border-0 bg-transparent p-0 font-inherit text-inherit font-medium cursor-pointer rounded-sm focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-basalt-primary\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\t\t\t\t\trequestSort(\n\t\t\t\t\t\t\t\t\t\t\t\t\tsort?.id === column.id && sort.dir === \"asc\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? { id: column.id, dir: \"desc\" }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: { id: column.id, dir: \"asc\" },\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{column.headerContent ?? column.header}\n\t\t\t\t\t\t\t\t\t\t\t{sort?.id === column.id ? (sort.dir === \"asc\" ? \" ↑\" : \" ↓\") : \"\"}\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</TableHead>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t</TableHeader>\n\t\t\t\t\t<TableBody>\n\t\t\t\t\t\t{loading ? (\n\t\t\t\t\t\t\t<TableRow>\n\t\t\t\t\t\t\t\t<TableCell colSpan={colCount}>\n\t\t\t\t\t\t\t\t\t<div role=\"status\" className=\"flex flex-col gap-2 py-2\">\n\t\t\t\t\t\t\t\t\t\t<span className=\"sr-only\">Loading</span>\n\t\t\t\t\t\t\t\t\t\t<SkeletonLine />\n\t\t\t\t\t\t\t\t\t\t<SkeletonLine />\n\t\t\t\t\t\t\t\t\t\t<SkeletonLine />\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t\t) : error != null && error !== false ? (\n\t\t\t\t\t\t\t<TableRow>\n\t\t\t\t\t\t\t\t<TableCell colSpan={colCount}>\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\trole=\"alert\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"flex flex-wrap items-center justify-between gap-3 py-6\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<div>{error}</div>\n\t\t\t\t\t\t\t\t\t\t{onRetry ? (\n\t\t\t\t\t\t\t\t\t\t\t<Button variant=\"outline\" size=\"sm\" onClick={onRetry}>\n\t\t\t\t\t\t\t\t\t\t\t\t{retryLabel}\n\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t\t) : paged.length === 0 ? (\n\t\t\t\t\t\t\t<TableRow>\n\t\t\t\t\t\t\t\t<TableCell colSpan={colCount}>\n\t\t\t\t\t\t\t\t\t<div role=\"status\">{empty}</div>\n\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tpaged.map(({ row, key, selectId }) => {\n\t\t\t\t\t\t\t\tconst isSelected = selectedIds.includes(selectId);\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<TableRow\n\t\t\t\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\t\t\t\tvariant={isSelected ? \"selected\" : \"default\"}\n\t\t\t\t\t\t\t\t\t\taria-selected={selectable ? isSelected : undefined}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{selectable ? (\n\t\t\t\t\t\t\t\t\t\t\t<TableCell>\n\t\t\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tchecked={isSelected}\n\t\t\t\t\t\t\t\t\t\t\t\t\taria-label={`Select ${selectId}`}\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={() => toggleSelected(selectId)}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t\t{columns.map((column) => {\n\t\t\t\t\t\t\t\t\t\t\tconst cell = column.accessor(row);\n\t\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t\t<TableCell key={column.id} className={column.cellClassName}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{typeof cell === \"bigint\" ? String(cell) : cell}\n\t\t\t\t\t\t\t\t\t\t\t\t</TableCell>\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t</TableRow>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t)}\n\t\t\t\t\t</TableBody>\n\t\t\t\t</Table>\n\t\t\t</div>\n\t\t\t{pageSize && pageSize > 0 ? (\n\t\t\t\t<Pagination\n\t\t\t\t\tpage={resolvedPage}\n\t\t\t\t\tpageCount={pageCount}\n\t\t\t\t\tdisabled={loading}\n\t\t\t\t\tonPageChange={setResolvedPage}\n\t\t\t\t/>\n\t\t\t) : null}\n\t\t</div>\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AA;MAH1C,UAAA,CAKErC,IACA,kBAAC8B,GAAD,EAAA,UACC,kBAAC,SAAD;OACC,MAAK;OACL,SAASO;OACT,cAAY,UAAUC;OACtB,gBAAgBlB,GAAekB,CAAQ;MACvC,CAAA,EACS,CAAA,IACR,MACH1C,EAAQ,KAAK,MAAW;OACxB,IAAM2C,IAAO1G,EAAO,SAASR,CAAG;OAChC,OACC,kBAACyG,GAAD;QAA2B,WAAWjG,EAAO;QAC3C,UAAA,OAAO0G,KAAS,WAAW,OAAOA,CAAI,IAAIA;OACjC,GAFK1G,EAAO,EAEZ;MAEb,CAAC,CACQ;KAtBJ,GAAAP,CAsBI;IAEZ,CAAC,EAEQ,CAAA,CACL;;EACH,CAAA,GACJoF,KAAYA,IAAW,IACvB,kBAAC8B,GAAD;GACC,MAAM7B;GACK;GACX,UAAUK;GACV,cAAcH;EACd,CAAA,IACE,IACA;;AAEP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.js","names":[],"sources":["../../src/components/date-picker.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport * as React from \"react\";\nimport { type ComponentProps, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Button } from \"./button\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\n\ntype Civil = { y: number; m: number; d: number };\n\nfunction pad(value: number) {\n\treturn String(value).padStart(2, \"0\");\n}\n\nfunction formatIso(date: Civil) {\n\treturn `${String(date.y).padStart(4, \"0\")}-${pad(date.m)}-${pad(date.d)}`;\n}\n\nfunction utcDate(date: Civil) {\n\tconst next = new Date(Date.UTC(date.y, date.m - 1, date.d));\n\tnext.setUTCFullYear(date.y);\n\treturn next;\n}\n\nfunction civilDate(date: Civil) {\n\tconst next = new Date(date.y, date.m - 1, date.d);\n\tnext.setFullYear(date.y);\n\treturn next;\n}\n\nfunction parseIso(value: string): Civil | null {\n\tconst match = /^(\\d{4,})-(\\d{2})-(\\d{2})$/.exec(value);\n\tif (!match) {\n\t\treturn null;\n\t}\n\tconst year = Number(match[1]);\n\tconst month = Number(match[2]);\n\tconst day = Number(match[3]);\n\tif (year < 1) {\n\t\treturn null;\n\t}\n\tconst utc = utcDate({ y: year, m: month, d: day });\n\tif (\n\t\tutc.getUTCFullYear() !== year ||\n\t\tutc.getUTCMonth() + 1 !== month ||\n\t\tutc.getUTCDate() !== day\n\t) {\n\t\treturn null;\n\t}\n\treturn { y: year, m: month, d: day };\n}\n\nfunction parseIsoMonth(value: string | undefined): Civil | null {\n\tif (!value) {\n\t\treturn null;\n\t}\n\tconst match = /^(\\d{4,})-(\\d{2})$/.exec(value);\n\tif (!match) {\n\t\treturn null;\n\t}\n\tconst year = Number(match[1]);\n\tconst month = Number(match[2]);\n\tif (year < 1 || month < 1 || month > 12) {\n\t\treturn null;\n\t}\n\tconst civil = { y: year, m: month, d: 1 };\n\treturn isValidCivil(civil) ? civil : null;\n}\n\nfunction formatIsoMonth(date: Civil): string {\n\treturn `${String(date.y).padStart(4, \"0\")}-${pad(date.m)}`;\n}\n\nconst CALENDAR_BUTTON =\n\t\"appearance-none border-0 bg-transparent p-0 font-inherit text-inherit cursor-pointer\";\n\nfunction todayCivil(timeZone?: string): Civil {\n\tconst parts = new Intl.DateTimeFormat(\"en-CA\", {\n\t\ttimeZone,\n\t\tyear: \"numeric\",\n\t\tmonth: \"2-digit\",\n\t\tday: \"2-digit\",\n\t}).formatToParts(new Date());\n\tconst read = (type: Intl.DateTimeFormatPartTypes) =>\n\t\tNumber(parts.find((part) => part.type === type)?.value);\n\treturn { y: read(\"year\"), m: read(\"month\"), d: read(\"day\") };\n}\n\nfunction formatCivil(date: Civil, locale: string, options: Intl.DateTimeFormatOptions) {\n\treturn new Intl.DateTimeFormat(locale, {\n\t\t...options,\n\t\ttimeZone: \"UTC\",\n\t\tcalendar: \"gregory\",\n\t}).format(utcDate(date));\n}\n\nfunction isLeapYear(y: number): boolean {\n\treturn (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0;\n}\n\nfunction daysInCivilMonth(y: number, m: number): number {\n\tif (m === 2) {\n\t\treturn isLeapYear(y) ? 29 : 28;\n\t}\n\tif (m === 4 || m === 6 || m === 9 || m === 11) {\n\t\treturn 30;\n\t}\n\treturn 31;\n}\n\nfunction shiftCivilMonthClamped(current: Civil, deltaMonths: number): Civil | null {\n\tconst total = current.y * 12 + (current.m - 1) + deltaMonths;\n\tconst targetY = Math.floor(total / 12);\n\tif (targetY < 1) {\n\t\treturn null;\n\t}\n\tconst targetM = (((total % 12) + 12) % 12) + 1;\n\tconst maxD = daysInCivilMonth(targetY, targetM);\n\tconst target = { y: targetY, m: targetM, d: Math.min(current.d, maxD) };\n\treturn isValidCivil(target) ? target : null;\n}\n\nfunction formatTriggerLabel({\n\tmode,\n\tselectedDate,\n\trangeFrom,\n\trangeTo,\n\tlocale,\n\tformatDate,\n\tplaceholder = \"Pick a date\",\n}: {\n\tmode: \"single\" | \"range\";\n\tselectedDate: Civil | null;\n\trangeFrom: string;\n\trangeTo?: string;\n\tlocale: string;\n\tformatDate?: (date: Date) => string;\n\tplaceholder?: string;\n}) {\n\tfunction one(iso: string) {\n\t\tconst date = parseIso(iso);\n\t\tif (!date) {\n\t\t\treturn iso;\n\t\t}\n\t\treturn formatDate?.(civilDate(date)) ?? formatCivil(date, locale, { dateStyle: \"medium\" });\n\t}\n\tif (mode === \"range\") {\n\t\tif (!rangeFrom) {\n\t\t\treturn placeholder;\n\t\t}\n\t\tif (!rangeTo) {\n\t\t\treturn `${one(rangeFrom)} – …`;\n\t\t}\n\t\treturn `${one(rangeFrom)} – ${one(rangeTo)}`;\n\t}\n\treturn selectedDate\n\t\t? (formatDate?.(civilDate(selectedDate)) ??\n\t\t\t\tformatCivil(selectedDate, locale, { dateStyle: \"medium\" }))\n\t\t: placeholder;\n}\n\nfunction compareCivil(left: Civil, right: Civil) {\n\tif (left.y !== right.y) {\n\t\treturn left.y - right.y;\n\t}\n\tif (left.m !== right.m) {\n\t\treturn left.m - right.m;\n\t}\n\treturn left.d - right.d;\n}\n\nfunction withinBounds(iso: string, min?: string, max?: string) {\n\tconst date = parseIso(iso);\n\tconst minDate = min ? parseIso(min) : null;\n\tconst maxDate = max ? parseIso(max) : null;\n\tif (!date) {\n\t\treturn false;\n\t}\n\tif (minDate && compareCivil(date, minDate) < 0) {\n\t\treturn false;\n\t}\n\tif (maxDate && compareCivil(date, maxDate) > 0) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nfunction dateSelectable(\n\tiso: string,\n\tmin?: string,\n\tmax?: string,\n\tisDisabledDate?: (iso: string) => boolean,\n) {\n\treturn withinBounds(iso, min, max) && !isDisabledDate?.(iso);\n}\n\nexport type DatePickerRange = { from: string; to?: string };\n\nexport type DatePickerPreset = {\n\tlabel: string;\n\tvalue: string | { from: string; to: string };\n};\n\nexport type DatePickerLabels = {\n\t/**\n\t * Accessible label for the calendar popup container.\n\t * @default \"Date calendar\" (or derived from `aria-label`)\n\t */\n\tcalendar?: string;\n\t/**\n\t * Accessible label for previous month button.\n\t * @default \"Prev\"\n\t */\n\tpreviousMonth?: string;\n\t/**\n\t * Accessible label for next month button.\n\t * @default \"Next\"\n\t */\n\tnextMonth?: string;\n\t/**\n\t * Fallback label for the trigger when no date is chosen.\n\t * @default \"Pick a date\"\n\t */\n\tplaceholder?: string;\n\t/**\n\t * Custom validation error message displayed when form validation fails.\n\t */\n\tvalidationMessage?: string;\n\t/**\n\t * Accessible keyboard navigation instructions announced for the calendar grid.\n\t */\n\tkeyboardInstructions?: string;\n};\n\nexport type DatePickerProps = Omit<\n\tComponentProps<\"input\">,\n\t| \"value\"\n\t| \"defaultValue\"\n\t| \"onChange\"\n\t| \"type\"\n\t| \"children\"\n\t| \"disabled\"\n\t| \"name\"\n\t| \"required\"\n\t| \"min\"\n\t| \"max\"\n> & {\n\t/**\n\t * The controlled ISO date in single mode.\n\t */\n\tvalue?: string;\n\t/**\n\t * The uncontrolled initial ISO date in single mode.\n\t */\n\tdefaultValue?: string;\n\t/**\n\t * Called with the ISO date in single mode.\n\t */\n\tonChange?: (value: string) => void;\n\t/**\n\t * Selection mode.\n\t * @default single\n\t */\n\tmode?: \"single\" | \"range\";\n\t/**\n\t * The controlled displayed month in `YYYY-MM` format (at least 4-digit positive year).\n\t * If omitted or invalid, falls back smoothly to `defaultMonth`, selected date, or today.\n\t */\n\tmonth?: string;\n\t/**\n\t * The uncontrolled initial displayed month in `YYYY-MM` format (at least 4-digit positive year).\n\t * If omitted or invalid, falls back smoothly to selected date or today.\n\t */\n\tdefaultMonth?: string;\n\t/**\n\t * Called only when calendar navigation requests a month change (`YYYY-MM`).\n\t * Not invoked during component render or synchronous prop synchronization.\n\t */\n\tonMonthChange?: (month: string) => void;\n\t/**\n\t * The controlled range in range mode.\n\t */\n\trangeValue?: DatePickerRange;\n\t/**\n\t * The uncontrolled initial range in range mode.\n\t */\n\tdefaultRangeValue?: DatePickerRange;\n\t/**\n\t * Called when the range changes.\n\t */\n\tonRangeChange?: (value: DatePickerRange) => void;\n\t/**\n\t * Additional dates that cannot be selected.\n\t */\n\tisDisabledDate?: (iso: string) => boolean;\n\t/**\n\t * Shortcut values shown above the calendar.\n\t */\n\tpresets?: DatePickerPreset[];\n\t/**\n\t * Locale used to format the trigger and weekday labels.\n\t * @default en-US\n\t */\n\tlocale?: string;\n\t/**\n\t * First day of the week. 0 is Sunday.\n\t * @default 0\n\t */\n\tweekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\t/**\n\t * IANA time zone used to resolve today.\n\t */\n\ttimeZone?: string;\n\t/**\n\t * Custom formatter for the trigger label.\n\t */\n\tformatDate?: (date: Date) => string;\n\t/**\n\t * Optional localized labels for calendar dialog, navigation, and trigger placeholder.\n\t */\n\tlabels?: DatePickerLabels;\n\t/**\n\t * Native form field name.\n\t */\n\tname?: string;\n\t/**\n\t * Native required constraint. When readOnly is set, native required validation is disabled.\n\t * When an empty required DatePicker submits, the visible trigger receives focus and invalid state.\n\t */\n\trequired?: boolean;\n\t/**\n\t * Inclusive lower ISO bound.\n\t */\n\tmin?: string;\n\t/**\n\t * Inclusive upper ISO bound.\n\t */\n\tmax?: string;\n\t/**\n\t * Disable the trigger and calendar.\n\t */\n\tdisabled?: boolean;\n};\n\nfunction clampCivil(date: Civil, min?: string, max?: string) {\n\tconst minDate = min ? parseIso(min) : null;\n\tconst maxDate = max ? parseIso(max) : null;\n\tif (minDate && compareCivil(date, minDate) < 0) {\n\t\treturn minDate;\n\t}\n\tif (maxDate && compareCivil(date, maxDate) > 0) {\n\t\treturn maxDate;\n\t}\n\treturn date;\n}\n\nfunction isValidCivil(date: Civil): boolean {\n\tif (!Number.isFinite(date.y) || date.m < 1 || date.m > 12 || date.d < 1 || date.d > 31) {\n\t\treturn false;\n\t}\n\tconst utc = utcDate(date);\n\treturn (\n\t\t!Number.isNaN(utc.getTime()) &&\n\t\tutc.getUTCFullYear() === date.y &&\n\t\tutc.getUTCMonth() + 1 === date.m &&\n\t\tutc.getUTCDate() === date.d\n\t);\n}\n\nfunction isoOf(date: Civil | null) {\n\treturn date ? formatIso(date) : \"\";\n}\n\nfunction addDays(date: Civil, days: number): Civil | null {\n\tconst next = utcDate(date);\n\tif (Number.isNaN(next.getTime())) {\n\t\treturn null;\n\t}\n\tnext.setUTCDate(next.getUTCDate() + days);\n\tif (Number.isNaN(next.getTime())) {\n\t\treturn null;\n\t}\n\tconst civil = { y: next.getUTCFullYear(), m: next.getUTCMonth() + 1, d: next.getUTCDate() };\n\treturn isValidCivil(civil) ? civil : null;\n}\n\nfunction shiftMonth(month: Civil, delta: number): Civil | null {\n\tconst total = month.y * 12 + (month.m - 1) + delta;\n\tconst next = { y: Math.floor(total / 12), m: (total % 12) + 1, d: 1 };\n\treturn isValidCivil(next) ? next : null;\n}\n\nexport function DatePicker({\n\tvalue,\n\tdefaultValue = \"\",\n\tonChange,\n\tmode = \"single\",\n\tmonth: controlledMonthProp,\n\tdefaultMonth: defaultMonthProp,\n\tonMonthChange,\n\trangeValue,\n\tdefaultRangeValue,\n\tonRangeChange,\n\tisDisabledDate,\n\tpresets,\n\tlocale = \"en-US\",\n\tweekStartsOn = 0,\n\ttimeZone,\n\tformatDate,\n\tname,\n\trequired,\n\tmin,\n\tmax,\n\tdisabled,\n\tclassName,\n\tid,\n\t\"aria-label\": ariaLabel,\n\t\"aria-describedby\": ariaDescribedBy,\n\t\"aria-invalid\": ariaInvalid,\n\tlabels,\n\t...inputRest\n}: DatePickerProps) {\n\tconst {\n\t\tref: externalRef,\n\t\treadOnly,\n\t\tautoFocus,\n\t\tonFocus,\n\t\tonBlur,\n\t\tonInvalid: externalOnInvalid,\n\t\t\"aria-labelledby\": ariaLabelledBy,\n\t\t...formRest\n\t} = inputRest;\n\tconst [uncontrolled, setUncontrolled] = useState(defaultValue);\n\tconst [uncontrolledRange, setUncontrolledRange] = useState<DatePickerRange>(\n\t\tdefaultRangeValue ?? { from: \"\", to: undefined },\n\t);\n\tconst [open, setOpen] = useState(false);\n\tconst [isInvalid, setIsInvalid] = useState(false);\n\tconst [validationMessage, setValidationMessage] = useState(\"\");\n\tconst [focusIndex, setFocusIndex] = useState(0);\n\tconst dayRefs = useRef<Array<HTMLButtonElement | null>>([]);\n\tconst pendingFocus = useRef<{ targetMonthKey: string; iso: string } | null>(null);\n\tconst focusDay = useRef(false);\n\tconst hiddenRef = useRef<HTMLInputElement>(null);\n\tconst triggerRef = useRef<HTMLButtonElement>(null);\n\tconst generatedErrorId = React.useId();\n\tconst errorId = id ? `${id}-error` : generatedErrorId;\n\tconst generatedMonthLiveId = React.useId();\n\tconst monthLiveId = id ? `${id}-month-live` : generatedMonthLiveId;\n\tconst generatedKeyboardInstructionsId = React.useId();\n\tconst keyboardInstructionsId = id\n\t\t? `${id}-keyboard-instructions`\n\t\t: generatedKeyboardInstructionsId;\n\n\tconst selected = value ?? uncontrolled;\n\tconst selectedRange = rangeValue ?? uncontrolledRange;\n\tconst selectedDate = parseIso(\n\t\tmode === \"range\" ? selectedRange.to || selectedRange.from || \"\" : selected,\n\t);\n\tconst cursorIso = selectedDate ? formatIso(selectedDate) : \"\";\n\n\tuseEffect(() => {\n\t\tif (cursorIso) {\n\t\t\tsetIsInvalid(false);\n\t\t\tsetValidationMessage(\"\");\n\t\t}\n\t}, [cursorIso]);\n\tconst submitted = mode === \"range\" ? \"\" : cursorIso;\n\n\tconst controlledParsed = useMemo(() => parseIsoMonth(controlledMonthProp), [controlledMonthProp]);\n\tconst isMonthControlled = controlledParsed !== null;\n\n\tconst [uncontrolledMonth, setUncontrolledMonth] = useState<Civil>(() => {\n\t\tconst parsedDef = parseIsoMonth(defaultMonthProp);\n\t\tif (parsedDef) {\n\t\t\treturn parsedDef;\n\t\t}\n\t\tconst initialCursor = selectedDate ?? todayCivil(timeZone);\n\t\tconst clampedInitial = clampCivil(initialCursor, min, max);\n\t\treturn { y: clampedInitial.y, m: clampedInitial.m, d: 1 };\n\t});\n\n\tconst activeMonth = controlledParsed ?? uncontrolledMonth;\n\tconst activeMonthKey = formatIsoMonth(activeMonth);\n\n\tconst requestMonth = (target: Civil) => {\n\t\tconst monthKey = formatIsoMonth(target);\n\t\tif (!isMonthControlled) {\n\t\t\tsetUncontrolledMonth(target);\n\t\t}\n\t\tonMonthChange?.(monthKey);\n\t};\n\n\tconst prevSelected = useRef(cursorIso);\n\tif (open && prevSelected.current !== cursorIso) {\n\t\tfocusDay.current = true;\n\t\tif (controlledMonthProp === undefined && defaultMonthProp === undefined) {\n\t\t\tconst next = selectedDate ?? todayCivil(timeZone);\n\t\t\tif (activeMonth.y !== next.y || activeMonth.m !== next.m) {\n\t\t\t\tsetUncontrolledMonth({ y: next.y, m: next.m, d: 1 });\n\t\t\t}\n\t\t}\n\t}\n\tprevSelected.current = cursorIso;\n\n\tconst hasExplicitMonthConfig =\n\t\tcontrolledMonthProp !== undefined || defaultMonthProp !== undefined;\n\n\tuseEffect(() => {\n\t\tif (!open) {\n\t\t\treturn;\n\t\t}\n\t\tif (!hasExplicitMonthConfig) {\n\t\t\tconst next = clampCivil(\n\t\t\t\t(cursorIso ? parseIso(cursorIso) : null) ?? todayCivil(timeZone),\n\t\t\t\tmin,\n\t\t\t\tmax,\n\t\t\t);\n\t\t\tsetUncontrolledMonth({ y: next.y, m: next.m, d: 1 });\n\t\t\tif (!cursorIso) {\n\t\t\t\tfocusDay.current = true;\n\t\t\t}\n\t\t}\n\t}, [open, cursorIso, timeZone, min, max, hasExplicitMonthConfig]);\n\n\tuseEffect(() => {\n\t\tif (disabled) {\n\t\t\tsetOpen(false);\n\t\t}\n\t}, [disabled]);\n\n\tuseEffect(() => {\n\t\tif (autoFocus) {\n\t\t\ttriggerRef.current?.focus();\n\t\t}\n\t}, [autoFocus]);\n\n\tconst latestConfigRef = useRef({\n\t\tdefaultValue,\n\t\tdefaultRangeValue,\n\t\tmode,\n\t\trangeValue,\n\t\tvalue,\n\t});\n\tuseEffect(() => {\n\t\tlatestConfigRef.current = {\n\t\t\tdefaultValue,\n\t\t\tdefaultRangeValue,\n\t\t\tmode,\n\t\t\trangeValue,\n\t\t\tvalue,\n\t\t};\n\t});\n\n\tconst formAttr = formRest.form;\n\tuseEffect(() => {\n\t\tconst form = hiddenRef.current?.form;\n\t\tif (!form || (formAttr && form.id !== formAttr)) {\n\t\t\treturn;\n\t\t}\n\t\tlet disposed = false;\n\t\tconst timers = new Set<ReturnType<typeof setTimeout>>();\n\t\tconst onReset = (event: Event) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\ttimers.delete(timer);\n\t\t\t\tif (disposed || event.defaultPrevented) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst cfg = latestConfigRef.current;\n\t\t\t\tif (cfg.mode === \"range\" ? cfg.rangeValue === undefined : cfg.value === undefined) {\n\t\t\t\t\tsetUncontrolled(cfg.defaultValue);\n\t\t\t\t\tsetUncontrolledRange(cfg.defaultRangeValue ?? { from: \"\", to: undefined });\n\t\t\t\t}\n\t\t\t\tsetIsInvalid(false);\n\t\t\t\tsetValidationMessage(\"\");\n\t\t\t\tsetOpen(false);\n\t\t\t}, 0);\n\t\t\ttimers.add(timer);\n\t\t};\n\t\tform.addEventListener(\"reset\", onReset);\n\t\treturn () => {\n\t\t\tdisposed = true;\n\t\t\tfor (const timer of timers) {\n\t\t\t\tclearTimeout(timer);\n\t\t\t}\n\t\t\ttimers.clear();\n\t\t\tform.removeEventListener(\"reset\", onReset);\n\t\t};\n\t}, [formAttr]);\n\n\tconst weekdayLabels = useMemo(() => {\n\t\tconst formatter = new Intl.DateTimeFormat(locale, { weekday: \"short\", timeZone: \"UTC\" });\n\t\treturn Array.from({ length: 7 }, (_, index) => {\n\t\t\tconst day = new Date(Date.UTC(2024, 0, 7 + ((index + weekStartsOn) % 7)));\n\t\t\treturn formatter.format(day);\n\t\t});\n\t}, [locale, weekStartsOn]);\n\n\tconst days = useMemo(() => {\n\t\tconst first = { y: activeMonth.y, m: activeMonth.m, d: 1 };\n\t\tif (!isValidCivil(first)) {\n\t\t\treturn Array.from({ length: 42 }, () => null);\n\t\t}\n\t\tconst startOffset = (utcDate(first).getUTCDay() - weekStartsOn + 7) % 7;\n\t\tconst start = addDays(first, -startOffset);\n\t\tif (!start) {\n\t\t\treturn Array.from({ length: 42 }, (_, index) => addDays(first, index - startOffset));\n\t\t}\n\t\treturn Array.from({ length: 42 }, (_, index) => addDays(start, index));\n\t}, [activeMonth, weekStartsOn]);\n\n\tuseLayoutEffect(() => {\n\t\tif (!open) {\n\t\t\treturn;\n\t\t}\n\t\tconst pending = pendingFocus.current;\n\t\tlet index = 0;\n\t\tif (pending) {\n\t\t\tif (pending.targetMonthKey === activeMonthKey) {\n\t\t\t\tpendingFocus.current = null;\n\t\t\t\tindex = days.findIndex((date) => isoOf(date) === pending.iso);\n\t\t\t\tif (index < 0) {\n\t\t\t\t\tindex = 0;\n\t\t\t\t}\n\t\t\t\tfocusDay.current = true;\n\t\t\t} else {\n\t\t\t\tconst focused = document.activeElement;\n\t\t\t\tconst focusedIso =\n\t\t\t\t\tfocused instanceof HTMLElement && dayRefs.current.some((node) => node === focused)\n\t\t\t\t\t\t? focused.getAttribute(\"aria-label\")\n\t\t\t\t\t\t: null;\n\t\t\t\tconst focusedIndex = focusedIso ? days.findIndex((date) => isoOf(date) === focusedIso) : -1;\n\t\t\t\tif (focusedIndex >= 0) {\n\t\t\t\t\tindex = focusedIndex;\n\t\t\t\t} else {\n\t\t\t\t\tindex = focusIndex;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst focused = document.activeElement;\n\t\t\tconst focusedIso =\n\t\t\t\t!focusDay.current &&\n\t\t\t\tfocused instanceof HTMLElement &&\n\t\t\t\tdayRefs.current.some((node) => node === focused)\n\t\t\t\t\t? focused.getAttribute(\"aria-label\")\n\t\t\t\t\t: null;\n\t\t\tconst focusedIndex = focusedIso ? days.findIndex((date) => isoOf(date) === focusedIso) : -1;\n\t\t\tif (focusedIndex >= 0) {\n\t\t\t\tindex = focusedIndex;\n\t\t\t} else {\n\t\t\t\tconst iso = cursorIso || submitted || formatIso(todayCivil(timeZone));\n\t\t\t\tconst selectedIndex = days.findIndex((date) => isoOf(date) === iso);\n\t\t\t\tif (selectedIndex >= 0 && days[selectedIndex]?.m === activeMonth.m) {\n\t\t\t\t\tindex = selectedIndex;\n\t\t\t\t} else {\n\t\t\t\t\tconst firstInMonth = days.findIndex((date) => date?.m === activeMonth.m);\n\t\t\t\t\tindex = firstInMonth >= 0 ? firstInMonth : 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst enabled = (date: Civil | null) =>\n\t\t\tBoolean(date && date.y >= 1 && dateSelectable(formatIso(date), min, max, isDisabledDate));\n\t\tif (!enabled(days[index] ?? null)) {\n\t\t\tconst inMonth = days.findIndex((date) => date?.m === activeMonth.m && enabled(date));\n\t\t\tconst any = days.findIndex((date) => enabled(date));\n\t\t\tindex = inMonth >= 0 ? inMonth : any >= 0 ? any : index;\n\t\t}\n\t\tsetFocusIndex(index);\n\t\tif (focusDay.current) {\n\t\t\tfocusDay.current = false;\n\t\t\tdayRefs.current[index]?.focus();\n\t\t}\n\t}, [\n\t\topen,\n\t\tcursorIso,\n\t\tsubmitted,\n\t\ttimeZone,\n\t\tdays,\n\t\tactiveMonth.m,\n\t\tactiveMonthKey,\n\t\tfocusIndex,\n\t\tmin,\n\t\tmax,\n\t\tisDisabledDate,\n\t]);\n\n\tconst previousMonth = shiftMonth(activeMonth, -1);\n\tconst followingMonth = shiftMonth(activeMonth, 1);\n\tconst rangeFrom = mode === \"range\" ? selectedRange.from : \"\";\n\tconst rangeTo = mode === \"range\" ? selectedRange.to : undefined;\n\tconst label = formatTriggerLabel({\n\t\tmode,\n\t\tselectedDate,\n\t\trangeFrom,\n\t\trangeTo,\n\t\tlocale,\n\t\tformatDate,\n\t\tplaceholder: labels?.placeholder,\n\t});\n\tconst calendarLabel = labels?.calendar ?? (ariaLabel ? `${ariaLabel} calendar` : \"Date calendar\");\n\tconst prevMonthLabel = labels?.previousMonth ?? \"Prev\";\n\tconst nextMonthLabel = labels?.nextMonth ?? \"Next\";\n\n\tfunction selectable(iso: string) {\n\t\treturn dateSelectable(iso, min, max, isDisabledDate);\n\t}\n\n\tfunction focusCalendarDay(next: Civil) {\n\t\tif (next.y !== activeMonth.y || next.m !== activeMonth.m) {\n\t\t\tpendingFocus.current = {\n\t\t\t\ttargetMonthKey: formatIsoMonth(next),\n\t\t\t\tiso: formatIso(next),\n\t\t\t};\n\t\t\trequestMonth({ y: next.y, m: next.m, d: 1 });\n\t\t\treturn;\n\t\t}\n\t\tconst index = days.findIndex((date) => isoOf(date) === formatIso(next));\n\t\tif (index >= 0) {\n\t\t\tsetFocusIndex(index);\n\t\t\tdayRefs.current[index]?.focus();\n\t\t}\n\t}\n\n\tfunction commit(next: string) {\n\t\tif (disabled || readOnly || !selectable(next)) {\n\t\t\treturn;\n\t\t}\n\t\tif (next) {\n\t\t\tsetIsInvalid(false);\n\t\t\tsetValidationMessage(\"\");\n\t\t}\n\t\tif (mode === \"range\") {\n\t\t\tconst current = rangeValue ?? uncontrolledRange;\n\t\t\tconst nextRange =\n\t\t\t\t!current.from || current.to\n\t\t\t\t\t? { from: next }\n\t\t\t\t\t: compareCivil(\n\t\t\t\t\t\t\t\tparseIso(next) ?? { y: 1, m: 1, d: 1 },\n\t\t\t\t\t\t\t\tparseIso(current.from) ?? { y: 1, m: 1, d: 1 },\n\t\t\t\t\t\t\t) < 0\n\t\t\t\t\t\t? { from: next, to: current.from }\n\t\t\t\t\t\t: { from: current.from, to: next };\n\t\t\tif (rangeValue === undefined) {\n\t\t\t\tsetUncontrolledRange(nextRange);\n\t\t\t}\n\t\t\tonRangeChange?.(nextRange);\n\t\t\tif (nextRange.to) {\n\t\t\t\tsetOpen(false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (value === undefined) {\n\t\t\tsetUncontrolled(next);\n\t\t}\n\t\tsetOpen(false);\n\t\tonChange?.(next);\n\t}\n\n\tfunction applyPreset(preset: DatePickerPreset) {\n\t\tif (disabled || readOnly) {\n\t\t\treturn;\n\t\t}\n\t\tif (typeof preset.value === \"string\") {\n\t\t\tif (mode === \"range\") {\n\t\t\t\tif (!selectable(preset.value)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst nextRange = { from: preset.value, to: preset.value };\n\t\t\t\tif (rangeValue === undefined) {\n\t\t\t\t\tsetUncontrolledRange(nextRange);\n\t\t\t\t}\n\t\t\t\tonRangeChange?.(nextRange);\n\t\t\t\tsetOpen(false);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcommit(preset.value);\n\t\t\treturn;\n\t\t}\n\t\tif (mode === \"range\") {\n\t\t\tif (!selectable(preset.value.from) || !selectable(preset.value.to)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (rangeValue === undefined) {\n\t\t\t\tsetUncontrolledRange(preset.value);\n\t\t\t}\n\t\t\tonRangeChange?.(preset.value);\n\t\t\tsetOpen(false);\n\t\t}\n\t}\n\n\tconst handleHiddenRef = React.useCallback(\n\t\t(node: HTMLInputElement | null) => {\n\t\t\thiddenRef.current = node;\n\t\t\tif (!externalRef) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (typeof externalRef === \"function\") {\n\t\t\t\tconst cleanup = externalRef(node);\n\t\t\t\tif (typeof cleanup === \"function\") {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\thiddenRef.current = null;\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn () => {\n\t\t\t\t\thiddenRef.current = null;\n\t\t\t\t\texternalRef(null);\n\t\t\t\t};\n\t\t\t}\n\t\t\t(externalRef as React.RefObject<HTMLInputElement | null>).current = node;\n\t\t\treturn () => {\n\t\t\t\thiddenRef.current = null;\n\t\t\t\t(externalRef as React.RefObject<HTMLInputElement | null>).current = null;\n\t\t\t};\n\t\t},\n\t\t[externalRef],\n\t);\n\n\tconst invalidState = ariaInvalid ?? (isInvalid || undefined);\n\tconst hasDestructiveStyle =\n\t\tinvalidState === true ||\n\t\tinvalidState === \"true\" ||\n\t\tinvalidState === \"grammar\" ||\n\t\tinvalidState === \"spelling\";\n\n\tconst describedBy =\n\t\t[ariaDescribedBy, isInvalid && errorId ? errorId : undefined].filter(Boolean).join(\" \") ||\n\t\tundefined;\n\n\treturn (\n\t\t<Popover\n\t\t\topen={open}\n\t\t\tonOpenChange={(next) => {\n\t\t\t\tif (next && disabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (next) {\n\t\t\t\t\tpendingFocus.current = null;\n\t\t\t\t\tif (controlledMonthProp === undefined && defaultMonthProp === undefined) {\n\t\t\t\t\t\tconst synced = (cursorIso ? parseIso(cursorIso) : null) ?? todayCivil(timeZone);\n\t\t\t\t\t\tsetUncontrolledMonth({ y: synced.y, m: synced.m, d: 1 });\n\t\t\t\t\t}\n\t\t\t\t\tfocusDay.current = true;\n\t\t\t\t} else {\n\t\t\t\t\tpendingFocus.current = null;\n\t\t\t\t}\n\t\t\t\tsetOpen(next);\n\t\t\t}}\n\t\t>\n\t\t\t<input\n\t\t\t\tref={handleHiddenRef}\n\t\t\t\ttype={mode === \"range\" ? \"text\" : \"date\"}\n\t\t\t\tname={name}\n\t\t\t\trequired={required}\n\t\t\t\treadOnly={readOnly}\n\t\t\t\tmin={mode === \"range\" ? undefined : min}\n\t\t\t\tmax={mode === \"range\" ? undefined : max}\n\t\t\t\tclassName=\"sr-only mb-2 h-7\"\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\twidth: 1,\n\t\t\t\t\theight: 1,\n\t\t\t\t\toverflow: \"hidden\",\n\t\t\t\t\tclip: \"rect(0, 0, 0, 0)\",\n\t\t\t\t}}\n\t\t\t\tvalue={\n\t\t\t\t\tmode === \"range\" ? (rangeFrom && rangeTo ? `${rangeFrom}/${rangeTo}` : \"\") : submitted\n\t\t\t\t}\n\t\t\t\tonChange={() => undefined}\n\t\t\t\tonInvalid={(event) => {\n\t\t\t\t\texternalOnInvalid?.(event);\n\t\t\t\t\tif (!event.defaultPrevented) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tsetIsInvalid(true);\n\t\t\t\t\t\tsetValidationMessage(\n\t\t\t\t\t\t\tlabels?.validationMessage ||\n\t\t\t\t\t\t\t\t(event.target as HTMLInputElement).validationMessage ||\n\t\t\t\t\t\t\t\t\"Please fill out this field.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttriggerRef.current?.focus();\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tdisabled={disabled}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\ttabIndex={-1}\n\t\t\t\t{...formRest}\n\t\t\t/>\n\t\t\t<PopoverTrigger asChild>\n\t\t\t\t<Button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tref={triggerRef}\n\t\t\t\t\tid={id}\n\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonFocus={onFocus as ComponentProps<\"button\">[\"onFocus\"]}\n\t\t\t\t\tonBlur={onBlur as ComponentProps<\"button\">[\"onBlur\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tariaLabel ? (label === \"Pick a date\" ? ariaLabel : `${ariaLabel}: ${label}`) : undefined\n\t\t\t\t\t}\n\t\t\t\t\taria-describedby={describedBy}\n\t\t\t\t\taria-invalid={invalidState}\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\"justify-start font-normal\",\n\t\t\t\t\t\thasDestructiveStyle && \"border-basalt-destructive text-basalt-destructive\",\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</Button>\n\t\t\t</PopoverTrigger>\n\t\t\t{isInvalid && validationMessage ? (\n\t\t\t\t<span id={errorId} role=\"alert\" className=\"mt-1 block text-xs text-basalt-destructive\">\n\t\t\t\t\t{validationMessage}\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t\t<PopoverContent\n\t\t\t\tarrow={false}\n\t\t\t\tclassName=\"w-64 p-3\"\n\t\t\t\taria-label={calendarLabel}\n\t\t\t\taria-describedby={keyboardInstructionsId}\n\t\t\t\tonOpenAutoFocus={(event) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tconst iso = cursorIso || submitted || formatIso(todayCivil(timeZone));\n\t\t\t\t\tconst selectedIndex = days.findIndex((date) => isoOf(date) === iso);\n\t\t\t\t\tconst enabled = (date: Civil | null) =>\n\t\t\t\t\t\tBoolean(\n\t\t\t\t\t\t\tdate && date.y >= 1 && dateSelectable(formatIso(date), min, max, isDisabledDate),\n\t\t\t\t\t\t);\n\t\t\t\t\tlet index =\n\t\t\t\t\t\tselectedIndex >= 0 && days[selectedIndex]?.m === activeMonth.m\n\t\t\t\t\t\t\t? selectedIndex\n\t\t\t\t\t\t\t: Math.max(\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\tdays.findIndex((date) => date?.m === activeMonth.m),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\tif (!enabled(days[index] ?? null)) {\n\t\t\t\t\t\tconst inMonth = days.findIndex((date) => date?.m === activeMonth.m && enabled(date));\n\t\t\t\t\t\tconst any = days.findIndex((date) => enabled(date));\n\t\t\t\t\t\tindex = inMonth >= 0 ? inMonth : any >= 0 ? any : index;\n\t\t\t\t\t}\n\t\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t\tdayRefs.current[index]?.focus();\n\t\t\t\t\t});\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{presets && presets.length > 0 ? (\n\t\t\t\t\t<div className=\"mb-2 flex flex-wrap gap-1\">\n\t\t\t\t\t\t{presets.map((preset) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tkey={preset.label}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t\t\tclassName=\"h-7 px-2 text-xs\"\n\t\t\t\t\t\t\t\tdisabled={disabled || readOnly}\n\t\t\t\t\t\t\t\tonClick={() => applyPreset(preset)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{preset.label}\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t\t<div className=\"mb-2 flex items-center justify-between gap-2\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\ticon={<ChevronLeft />}\n\t\t\t\t\t\taria-label={prevMonthLabel}\n\t\t\t\t\t\tclassName=\"size-8\"\n\t\t\t\t\t\tdisabled={disabled || !previousMonth || previousMonth.y < 1}\n\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\tif (!previousMonth || previousMonth.y < 1) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingFocus.current = null;\n\t\t\t\t\t\t\tfocusDay.current = false;\n\t\t\t\t\t\t\trequestMonth(previousMonth);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t<span\n\t\t\t\t\t\tid={monthLiveId}\n\t\t\t\t\t\taria-live=\"polite\"\n\t\t\t\t\t\taria-atomic=\"true\"\n\t\t\t\t\t\tclassName=\"text-sm font-medium\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{formatCivil(activeMonth, locale, { month: \"long\", year: \"numeric\" })}\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\ticon={<ChevronRight />}\n\t\t\t\t\t\taria-label={nextMonthLabel}\n\t\t\t\t\t\tclassName=\"size-8\"\n\t\t\t\t\t\tdisabled={disabled || !followingMonth}\n\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\tif (!followingMonth) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingFocus.current = null;\n\t\t\t\t\t\t\tfocusDay.current = false;\n\t\t\t\t\t\t\trequestMonth(followingMonth);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<p id={keyboardInstructionsId} className=\"sr-only\">\n\t\t\t\t\t{labels?.keyboardInstructions ??\n\t\t\t\t\t\t\"Use arrow keys to navigate dates, PageUp and PageDown to change months, and Enter or Space to select.\"}\n\t\t\t\t</p>\n\t\t\t\t{/* Biome override: WAI-ARIA APG Date Picker pattern uses a semantic table with role=\"grid\" and role=\"gridcell\" on cells while roving tabindex focuses the child button */}\n\t\t\t\t<table\n\t\t\t\t\trole=\"grid\"\n\t\t\t\t\taria-labelledby={monthLiveId}\n\t\t\t\t\taria-multiselectable={mode === \"range\" ? \"true\" : undefined}\n\t\t\t\t\tclassName=\"w-full border-collapse text-center\"\n\t\t\t\t\tonKeyDown={(event) => {\n\t\t\t\t\t\tconst current = days[focusIndex];\n\t\t\t\t\t\tif (!current) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tevent.key === \"ArrowRight\" ||\n\t\t\t\t\t\t\tevent.key === \"ArrowLeft\" ||\n\t\t\t\t\t\t\tevent.key === \"ArrowDown\" ||\n\t\t\t\t\t\t\tevent.key === \"ArrowUp\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tconst delta =\n\t\t\t\t\t\t\t\tevent.key === \"ArrowRight\"\n\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t: event.key === \"ArrowLeft\"\n\t\t\t\t\t\t\t\t\t\t? -1\n\t\t\t\t\t\t\t\t\t\t: event.key === \"ArrowDown\"\n\t\t\t\t\t\t\t\t\t\t\t? 7\n\t\t\t\t\t\t\t\t\t\t\t: -7;\n\t\t\t\t\t\t\tlet next = addDays(current, delta);\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tlet step = 0;\n\t\t\t\t\t\t\t\tnext && next.y >= 1 && !selectable(formatIso(next)) && step < 42;\n\t\t\t\t\t\t\t\tstep += 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnext = addDays(next, delta);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!next || next.y < 1 || !selectable(formatIso(next))) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusCalendarDay(next);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (event.key === \"Home\" || event.key === \"End\") {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tconst dayOfWeek = utcDate(current).getUTCDay();\n\t\t\t\t\t\t\tconst col = (dayOfWeek - weekStartsOn + 7) % 7;\n\t\t\t\t\t\t\tconst deltaToEdge = event.key === \"Home\" ? -col : 6 - col;\n\t\t\t\t\t\t\tlet next: Civil | null = addDays(current, deltaToEdge);\n\t\t\t\t\t\t\tconst stepDir = event.key === \"Home\" ? 1 : -1;\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tlet step = 0;\n\t\t\t\t\t\t\t\tnext && next.y >= 1 && !selectable(formatIso(next)) && step < 7;\n\t\t\t\t\t\t\t\tstep += 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnext = addDays(next, stepDir);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!next || next.y < 1 || !selectable(formatIso(next))) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusCalendarDay(next);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (event.key === \"PageDown\" || event.key === \"PageUp\") {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tconst deltaMonths = event.shiftKey\n\t\t\t\t\t\t\t\t? event.key === \"PageDown\"\n\t\t\t\t\t\t\t\t\t? 12\n\t\t\t\t\t\t\t\t\t: -12\n\t\t\t\t\t\t\t\t: event.key === \"PageDown\"\n\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t: -1;\n\t\t\t\t\t\t\tconst target = shiftCivilMonthClamped(current, deltaMonths);\n\t\t\t\t\t\t\tif (!target) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlet next: Civil | null = target;\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tlet step = 0;\n\t\t\t\t\t\t\t\tnext && next.y >= 1 && !selectable(formatIso(next)) && step < 42;\n\t\t\t\t\t\t\t\tstep += 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnext = addDays(next, 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!next || next.y < 1 || !selectable(formatIso(next))) {\n\t\t\t\t\t\t\t\tnext = target;\n\t\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\t\tlet step = 0;\n\t\t\t\t\t\t\t\t\tnext && next.y >= 1 && !selectable(formatIso(next)) && step < 42;\n\t\t\t\t\t\t\t\t\tstep += 1\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnext = addDays(next, -1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!next || next.y < 1 || !selectable(formatIso(next))) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingFocus.current = {\n\t\t\t\t\t\t\t\ttargetMonthKey: formatIsoMonth(next),\n\t\t\t\t\t\t\t\tiso: formatIso(next),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\trequestMonth({ y: next.y, m: next.m, d: 1 });\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (event.key === \"Enter\" || event.key === \" \") {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tconst iso = formatIso(current);\n\t\t\t\t\t\t\tif (current.y >= 1 && selectable(iso)) {\n\t\t\t\t\t\t\t\tcommit(iso);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t{weekdayLabels.map((day, index) => (\n\t\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\t\tkey={`${day}-${index}`}\n\t\t\t\t\t\t\t\t\tscope=\"col\"\n\t\t\t\t\t\t\t\t\tclassName=\"h-8 text-center text-xs font-medium text-basalt-muted-foreground\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{day}\n\t\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t{Array.from({ length: 6 }, (_, weekIndex) => (\n\t\t\t\t\t\t\t<tr key={`week-${weekIndex}`}>\n\t\t\t\t\t\t\t\t{days.slice(weekIndex * 7, weekIndex * 7 + 7).map((date, colIndex) => {\n\t\t\t\t\t\t\t\t\tconst index = weekIndex * 7 + colIndex;\n\t\t\t\t\t\t\t\t\tif (!date) {\n\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<td\n\t\t\t\t\t\t\t\t\t\t\t\tkey={`empty-${index}`}\n\t\t\t\t\t\t\t\t\t\t\t\trole=\"gridcell\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"h-8 p-0 text-center\"\n\t\t\t\t\t\t\t\t\t\t\t\tref={() => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tdayRefs.current[index] = null;\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst iso = formatIso(date);\n\t\t\t\t\t\t\t\t\tconst inMonth = date.m === activeMonth.m;\n\t\t\t\t\t\t\t\t\tconst inRange = date.y >= 1 && selectable(iso);\n\t\t\t\t\t\t\t\t\tconst fromDate = rangeFrom ? parseIso(rangeFrom) : null;\n\t\t\t\t\t\t\t\t\tconst toDate = rangeTo ? parseIso(rangeTo) : null;\n\t\t\t\t\t\t\t\t\tconst thisDate = parseIso(iso);\n\t\t\t\t\t\t\t\t\tconst inSelectedRange = Boolean(\n\t\t\t\t\t\t\t\t\t\tfromDate &&\n\t\t\t\t\t\t\t\t\t\t\ttoDate &&\n\t\t\t\t\t\t\t\t\t\t\tthisDate &&\n\t\t\t\t\t\t\t\t\t\t\tcompareCivil(thisDate, fromDate) >= 0 &&\n\t\t\t\t\t\t\t\t\t\t\tcompareCivil(thisDate, toDate) <= 0,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst isRangeEdge = iso === rangeFrom || iso === rangeTo;\n\t\t\t\t\t\t\t\t\tconst isSelected =\n\t\t\t\t\t\t\t\t\t\tmode === \"range\"\n\t\t\t\t\t\t\t\t\t\t\t? inSelectedRange || isRangeEdge\n\t\t\t\t\t\t\t\t\t\t\t: Boolean(submitted) && iso === submitted;\n\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<td\n\t\t\t\t\t\t\t\t\t\t\tkey={iso}\n\t\t\t\t\t\t\t\t\t\t\trole=\"gridcell\"\n\t\t\t\t\t\t\t\t\t\t\taria-selected={isSelected ? \"true\" : undefined}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"h-8 p-0 text-center\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\t\tref={(node) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tdayRefs.current[index] = node;\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\ttabIndex={index === focusIndex ? 0 : -1}\n\t\t\t\t\t\t\t\t\t\t\t\tdata-date={iso}\n\t\t\t\t\t\t\t\t\t\t\t\taria-label={iso}\n\t\t\t\t\t\t\t\t\t\t\t\taria-pressed={mode === \"range\" ? isRangeEdge : isSelected}\n\t\t\t\t\t\t\t\t\t\t\t\tdisabled={disabled || readOnly || !inRange}\n\t\t\t\t\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t\t\t\t\tCALENDAR_BUTTON,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"mx-auto flex h-8 w-8 items-center justify-center rounded-basalt-md text-sm\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tinMonth ? \"text-basalt-foreground\" : \"text-basalt-muted-foreground\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tinRange && \"hover:bg-basalt-accent\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tinSelectedRange && !isRangeEdge && \"bg-basalt-accent\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tinRange &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(mode === \"range\" ? isRangeEdge : isSelected) &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"bg-basalt-primary text-basalt-primary-foreground hover:bg-basalt-primary/90\",\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={() => inRange && commit(iso)}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{date.d}\n\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";;;;;;;;;AASA,SAAS,EAAI,GAAe;CAC3B,OAAO,OAAO,CAAK,CAAC,CAAC,SAAS,GAAG,GAAG;AACrC;AAEA,SAAS,EAAU,GAAa;CAC/B,OAAO,GAAG,OAAO,EAAK,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,EAAI,EAAK,CAAC,EAAE,GAAG,EAAI,EAAK,CAAC;AACvE;AAEA,SAAS,EAAQ,GAAa;CAC7B,IAAM,IAAO,IAAI,KAAK,KAAK,IAAI,EAAK,GAAG,EAAK,IAAI,GAAG,EAAK,CAAC,CAAC;CAE1D,OADA,EAAK,e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AAI,MAC7C,IAAS,IAAU,EAAS,CAAO,IAAI,MACvC,IAAW,EAAS,CAAG,GACvB,KAAkB,GACvB,KACC,KACA,KACA,EAAa,GAAU,CAAQ,KAAK,KACpC,EAAa,GAAU,CAAM,KAAK,IAE9B,IAAc,MAAQ,KAAa,MAAQ,GAC3C,IACL,MAAS,UACN,MAAmB,IACnB,EAAQ,KAAc,MAAQ;OAElC,OACC,kBAAC,MAAD;QAEC,MAAK;QACL,iBAAe,IAAa,SAAS,KAAA;QACrC,WAAU;QAEV,UAAA,kBAAC,UAAD;SACC,MAAK;SACL,MAAM,MAAS;UACd,EAAQ,QAAQ,KAAS;SAC1B;SACA,UAAU,MAAU,KAAa,IAAI;SACrC,aAAW;SACX,cAAY;SACZ,gBAAc,MAAS,UAAU,IAAc;SAC/C,UAAU,KAAY,KAAY,CAAC;SACnC,WAAW,EACV,IACA,8EACA,IAAU,2BAA2B,gCACrC,KAAW,0BACX,MAAmB,CAAC,KAAe,oBACnC,MACE,MAAS,UAAU,IAAc,MAClC,6EACF;SACA,eAAe,KAAW,GAAO,CAAG;SAEnC,UAAA,EAAK;QACC,CAAA;OACL,GA7BE,CA6BF;MAEN,CAAC,EACE,GApEK,QAAQ,GAoEb,CACJ,EACK,CAAA,CACD;;IACQ;;EACR;;AAEX"}
|
|
1
|
+
{"version":3,"file":"date-picker.js","names":["React","pad","value","formatIso","date","utcDate","next","civilDate","parseIso","match","year","month","day","utc","parseIsoMonth","civil","isValidCivil","formatIsoMonth","CALENDAR_BUTTON","todayCivil","parts","read","part","type","formatCivil","locale","options","isLeapYear","y","daysInCivilMonth","m","shiftCivilMonthClamped","total","current","deltaMonths","targetY","targetM","maxD","target","formatTriggerLabel","one","iso","formatDate","mode","rangeFrom","rangeTo","placeholder","selectedDate","compareCivil","left","right","withinBounds","minDate","min","maxDate","max","dateSelectable","isDisabledDate","clampCivil","isoOf","addDays","days","shiftMonth","delta","DatePicker","controlledMonthProp","defaultMonthProp","ariaLabel","ariaDescribedBy","ariaInvalid","inputRest","externalRef","externalOnInvalid","ariaLabelledBy","formRest","uncontrolled","setUncontrolled","useState","defaultValue","uncontrolledRange","setUncontrolledRange","defaultRangeValue","open","setOpen","isInvalid","setIsInvalid","validationMessage","setValidationMessage","focusIndex","setFocusIndex","dayRefs","useRef","pendingFocus","focusDay","hiddenRef","triggerRef","generatedErrorId","errorId","id","generatedMonthLiveId","monthLiveId","generatedKeyboardInstructionsId","keyboardInstructionsId","selected","selectedRange","rangeValue","cursorIso","submitted","controlledParsed","useMemo","isMonthControlled","uncontrolledMonth","setUncontrolledMonth","parsedDef","clampedInitial","timeZone","activeMonth","activeMonthKey","requestMonth","monthKey","onMonthChange","prevSelected","hasExplicitMonthConfig","useEffect","disabled","autoFocus","latestConfigRef","formAttr","form","disposed","timers","onReset","timer","event","cfg","weekdayLabels","formatter","index","weekStartsOn","first","startOffset","start","pending","focused","focusedIso","node","focusedIndex","selectedIndex","firstInMonth","enabled","inMonth","any","previousMonth","followingMonth","label","labels","calendarLabel","prevMonthLabel","nextMonthLabel","selectable","focusCalendarDay","commit","readOnly","nextRange","onRangeChange","onChange","applyPreset","preset","handleHiddenRef","cleanup","invalidState","hasDestructiveStyle","describedBy","Popover","synced","PopoverTrigger","Button","cn","className","PopoverContent","presets","ChevronLeft","ChevronRight","step","col","stepDir","weekIndex","colIndex","inRange","fromDate","toDate","thisDate","inSelectedRange","isRangeEdge","isSelected"],"sources":["../../src/components/date-picker.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport * as React from \"react\";\nimport { type ComponentProps, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Button } from \"./button\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\n\ntype Civil = { y: number; m: number; d: number };\n\nfunction pad(value: number) {\n\treturn String(value).padStart(2, \"0\");\n}\n\nfunction formatIso(date: Civil) {\n\treturn `${String(date.y).padStart(4, \"0\")}-${pad(date.m)}-${pad(date.d)}`;\n}\n\nfunction utcDate(date: Civil) {\n\tconst next = new Date(Date.UTC(date.y, date.m - 1, date.d));\n\tnext.setUTCFullYear(date.y);\n\treturn next;\n}\n\nfunction civilDate(date: Civil) {\n\tconst next = new Date(date.y, date.m - 1, date.d);\n\tnext.setFullYear(date.y);\n\treturn next;\n}\n\nfunction parseIso(value: string): Civil | null {\n\tconst match = /^(\\d{4,})-(\\d{2})-(\\d{2})$/.exec(value);\n\tif (!match) {\n\t\treturn null;\n\t}\n\tconst year = Number(match[1]);\n\tconst month = Number(match[2]);\n\tconst day = Number(match[3]);\n\tif (year < 1) {\n\t\treturn null;\n\t}\n\tconst utc = utcDate({ y: year, m: month, d: day });\n\tif (\n\t\tutc.getUTCFullYear() !== year ||\n\t\tutc.getUTCMonth() + 1 !== month ||\n\t\tutc.getUTCDate() !== day\n\t) {\n\t\treturn null;\n\t}\n\treturn { y: year, m: month, d: day };\n}\n\nfunction parseIsoMonth(value: string | undefined): Civil | null {\n\tif (!value) {\n\t\treturn null;\n\t}\n\tconst match = /^(\\d{4,})-(\\d{2})$/.exec(value);\n\tif (!match) {\n\t\treturn null;\n\t}\n\tconst year = Number(match[1]);\n\tconst month = Number(match[2]);\n\tif (year < 1 || month < 1 || month > 12) {\n\t\treturn null;\n\t}\n\tconst civil = { y: year, m: month, d: 1 };\n\treturn isValidCivil(civil) ? civil : null;\n}\n\nfunction formatIsoMonth(date: Civil): string {\n\treturn `${String(date.y).padStart(4, \"0\")}-${pad(date.m)}`;\n}\n\nconst CALENDAR_BUTTON =\n\t\"appearance-none border-0 bg-transparent p-0 font-inherit text-inherit cursor-pointer\";\n\nfunction todayCivil(timeZone?: string): Civil {\n\tconst parts = new Intl.DateTimeFormat(\"en-CA\", {\n\t\ttimeZone,\n\t\tyear: \"numeric\",\n\t\tmonth: \"2-digit\",\n\t\tday: \"2-digit\",\n\t}).formatToParts(new Date());\n\tconst read = (type: Intl.DateTimeFormatPartTypes) =>\n\t\tNumber(parts.find((part) => part.type === type)?.value);\n\treturn { y: read(\"year\"), m: read(\"month\"), d: read(\"day\") };\n}\n\nfunction formatCivil(date: Civil, locale: string, options: Intl.DateTimeFormatOptions) {\n\treturn new Intl.DateTimeFormat(locale, {\n\t\t...options,\n\t\ttimeZone: \"UTC\",\n\t\tcalendar: \"gregory\",\n\t}).format(utcDate(date));\n}\n\nfunction isLeapYear(y: number): boolean {\n\treturn (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0;\n}\n\nfunction daysInCivilMonth(y: number, m: number): number {\n\tif (m === 2) {\n\t\treturn isLeapYear(y) ? 29 : 28;\n\t}\n\tif (m === 4 || m === 6 || m === 9 || m === 11) {\n\t\treturn 30;\n\t}\n\treturn 31;\n}\n\nfunction shiftCivilMonthClamped(current: Civil, deltaMonths: number): Civil | null {\n\tconst total = current.y * 12 + (current.m - 1) + deltaMonths;\n\tconst targetY = Math.floor(total / 12);\n\tif (targetY < 1) {\n\t\treturn null;\n\t}\n\tconst targetM = (((total % 12) + 12) % 12) + 1;\n\tconst maxD = daysInCivilMonth(targetY, targetM);\n\tconst target = { y: targetY, m: targetM, d: Math.min(current.d, maxD) };\n\treturn isValidCivil(target) ? target : null;\n}\n\nfunction formatTriggerLabel({\n\tmode,\n\tselectedDate,\n\trangeFrom,\n\trangeTo,\n\tlocale,\n\tformatDate,\n\tplaceholder = \"Pick a date\",\n}: {\n\tmode: \"single\" | \"range\";\n\tselectedDate: Civil | null;\n\trangeFrom: string;\n\trangeTo?: string;\n\tlocale: string;\n\tformatDate?: (date: Date) => string;\n\tplaceholder?: string;\n}) {\n\tfunction one(iso: string) {\n\t\tconst date = parseIso(iso);\n\t\tif (!date) {\n\t\t\treturn iso;\n\t\t}\n\t\treturn formatDate?.(civilDate(date)) ?? formatCivil(date, locale, { dateStyle: \"medium\" });\n\t}\n\tif (mode === \"range\") {\n\t\tif (!rangeFrom) {\n\t\t\treturn placeholder;\n\t\t}\n\t\tif (!rangeTo) {\n\t\t\treturn `${one(rangeFrom)} – …`;\n\t\t}\n\t\treturn `${one(rangeFrom)} – ${one(rangeTo)}`;\n\t}\n\treturn selectedDate\n\t\t? (formatDate?.(civilDate(selectedDate)) ??\n\t\t\t\tformatCivil(selectedDate, locale, { dateStyle: \"medium\" }))\n\t\t: placeholder;\n}\n\nfunction compareCivil(left: Civil, right: Civil) {\n\tif (left.y !== right.y) {\n\t\treturn left.y - right.y;\n\t}\n\tif (left.m !== right.m) {\n\t\treturn left.m - right.m;\n\t}\n\treturn left.d - right.d;\n}\n\nfunction withinBounds(iso: string, min?: string, max?: string) {\n\tconst date = parseIso(iso);\n\tconst minDate = min ? parseIso(min) : null;\n\tconst maxDate = max ? parseIso(max) : null;\n\tif (!date) {\n\t\treturn false;\n\t}\n\tif (minDate && compareCivil(date, minDate) < 0) {\n\t\treturn false;\n\t}\n\tif (maxDate && compareCivil(date, maxDate) > 0) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nfunction dateSelectable(\n\tiso: string,\n\tmin?: string,\n\tmax?: string,\n\tisDisabledDate?: (iso: string) => boolean,\n) {\n\treturn withinBounds(iso, min, max) && !isDisabledDate?.(iso);\n}\n\nexport type DatePickerRange = { from: string; to?: string };\n\nexport type DatePickerPreset = {\n\tlabel: string;\n\tvalue: string | { from: string; to: string };\n};\n\nexport type DatePickerLabels = {\n\t/**\n\t * Accessible label for the calendar popup container.\n\t * @default \"Date calendar\" (or derived from `aria-label`)\n\t */\n\tcalendar?: string;\n\t/**\n\t * Accessible label for previous month button.\n\t * @default \"Prev\"\n\t */\n\tpreviousMonth?: string;\n\t/**\n\t * Accessible label for next month button.\n\t * @default \"Next\"\n\t */\n\tnextMonth?: string;\n\t/**\n\t * Fallback label for the trigger when no date is chosen.\n\t * @default \"Pick a date\"\n\t */\n\tplaceholder?: string;\n\t/**\n\t * Custom validation error message displayed when form validation fails.\n\t */\n\tvalidationMessage?: string;\n\t/**\n\t * Accessible keyboard navigation instructions announced for the calendar grid.\n\t */\n\tkeyboardInstructions?: string;\n};\n\nexport type DatePickerProps = Omit<\n\tComponentProps<\"input\">,\n\t| \"value\"\n\t| \"defaultValue\"\n\t| \"onChange\"\n\t| \"type\"\n\t| \"children\"\n\t| \"disabled\"\n\t| \"name\"\n\t| \"required\"\n\t| \"min\"\n\t| \"max\"\n> & {\n\t/**\n\t * The controlled ISO date in single mode.\n\t */\n\tvalue?: string;\n\t/**\n\t * The uncontrolled initial ISO date in single mode.\n\t */\n\tdefaultValue?: string;\n\t/**\n\t * Called with the ISO date in single mode.\n\t */\n\tonChange?: (value: string) => void;\n\t/**\n\t * Selection mode.\n\t * @default single\n\t */\n\tmode?: \"single\" | \"range\";\n\t/**\n\t * The controlled displayed month in `YYYY-MM` format (at least 4-digit positive year).\n\t * If omitted or invalid, falls back smoothly to `defaultMonth`, selected date, or today.\n\t */\n\tmonth?: string;\n\t/**\n\t * The uncontrolled initial displayed month in `YYYY-MM` format (at least 4-digit positive year).\n\t * If omitted or invalid, falls back smoothly to selected date or today.\n\t */\n\tdefaultMonth?: string;\n\t/**\n\t * Called only when calendar navigation requests a month change (`YYYY-MM`).\n\t * Not invoked during component render or synchronous prop synchronization.\n\t */\n\tonMonthChange?: (month: string) => void;\n\t/**\n\t * The controlled range in range mode.\n\t */\n\trangeValue?: DatePickerRange;\n\t/**\n\t * The uncontrolled initial range in range mode.\n\t */\n\tdefaultRangeValue?: DatePickerRange;\n\t/**\n\t * Called when the range changes.\n\t */\n\tonRangeChange?: (value: DatePickerRange) => void;\n\t/**\n\t * Additional dates that cannot be selected.\n\t */\n\tisDisabledDate?: (iso: string) => boolean;\n\t/**\n\t * Shortcut values shown above the calendar.\n\t */\n\tpresets?: DatePickerPreset[];\n\t/**\n\t * Locale used to format the trigger and weekday labels.\n\t * @default en-US\n\t */\n\tlocale?: string;\n\t/**\n\t * First day of the week. 0 is Sunday.\n\t * @default 0\n\t */\n\tweekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\t/**\n\t * IANA time zone used to resolve today.\n\t */\n\ttimeZone?: string;\n\t/**\n\t * Custom formatter for the trigger label.\n\t */\n\tformatDate?: (date: Date) => string;\n\t/**\n\t * Optional localized labels for calendar dialog, navigation, and trigger placeholder.\n\t */\n\tlabels?: DatePickerLabels;\n\t/**\n\t * Native form field name.\n\t */\n\tname?: string;\n\t/**\n\t * Native required constraint. When readOnly is set, native required validation is disabled.\n\t * When an empty required DatePicker submits, the visible trigger receives focus and invalid state.\n\t */\n\trequired?: boolean;\n\t/**\n\t * Inclusive lower ISO bound.\n\t */\n\tmin?: string;\n\t/**\n\t * Inclusive upper ISO bound.\n\t */\n\tmax?: string;\n\t/**\n\t * Disable the trigger and calendar.\n\t */\n\tdisabled?: boolean;\n};\n\nfunction clampCivil(date: Civil, min?: string, max?: string) {\n\tconst minDate = min ? parseIso(min) : null;\n\tconst maxDate = max ? parseIso(max) : null;\n\tif (minDate && compareCivil(date, minDate) < 0) {\n\t\treturn minDate;\n\t}\n\tif (maxDate && compareCivil(date, maxDate) > 0) {\n\t\treturn maxDate;\n\t}\n\treturn date;\n}\n\nfunction isValidCivil(date: Civil): boolean {\n\tif (!Number.isFinite(date.y) || date.m < 1 || date.m > 12 || date.d < 1 || date.d > 31) {\n\t\treturn false;\n\t}\n\tconst utc = utcDate(date);\n\treturn (\n\t\t!Number.isNaN(utc.getTime()) &&\n\t\tutc.getUTCFullYear() === date.y &&\n\t\tutc.getUTCMonth() + 1 === date.m &&\n\t\tutc.getUTCDate() === date.d\n\t);\n}\n\nfunction isoOf(date: Civil | null) {\n\treturn date ? formatIso(date) : \"\";\n}\n\nfunction addDays(date: Civil, days: number): Civil | null {\n\tconst next = utcDate(date);\n\tif (Number.isNaN(next.getTime())) {\n\t\treturn null;\n\t}\n\tnext.setUTCDate(next.getUTCDate() + days);\n\tif (Number.isNaN(next.getTime())) {\n\t\treturn null;\n\t}\n\tconst civil = { y: next.getUTCFullYear(), m: next.getUTCMonth() + 1, d: next.getUTCDate() };\n\treturn isValidCivil(civil) ? civil : null;\n}\n\nfunction shiftMonth(month: Civil, delta: number): Civil | null {\n\tconst total = month.y * 12 + (month.m - 1) + delta;\n\tconst next = { y: Math.floor(total / 12), m: (total % 12) + 1, d: 1 };\n\treturn isValidCivil(next) ? next : null;\n}\n\nexport function DatePicker({\n\tvalue,\n\tdefaultValue = \"\",\n\tonChange,\n\tmode = \"single\",\n\tmonth: controlledMonthProp,\n\tdefaultMonth: defaultMonthProp,\n\tonMonthChange,\n\trangeValue,\n\tdefaultRangeValue,\n\tonRangeChange,\n\tisDisabledDate,\n\tpresets,\n\tlocale = \"en-US\",\n\tweekStartsOn = 0,\n\ttimeZone,\n\tformatDate,\n\tname,\n\trequired,\n\tmin,\n\tmax,\n\tdisabled,\n\tclassName,\n\tid,\n\t\"aria-label\": ariaLabel,\n\t\"aria-describedby\": ariaDescribedBy,\n\t\"aria-invalid\": ariaInvalid,\n\tlabels,\n\t...inputRest\n}: DatePickerProps) {\n\tconst {\n\t\tref: externalRef,\n\t\treadOnly,\n\t\tautoFocus,\n\t\tonFocus,\n\t\tonBlur,\n\t\tonInvalid: externalOnInvalid,\n\t\t\"aria-labelledby\": ariaLabelledBy,\n\t\t...formRest\n\t} = inputRest;\n\tconst [uncontrolled, setUncontrolled] = useState(defaultValue);\n\tconst [uncontrolledRange, setUncontrolledRange] = useState<DatePickerRange>(\n\t\tdefaultRangeValue ?? { from: \"\", to: undefined },\n\t);\n\tconst [open, setOpen] = useState(false);\n\tconst [isInvalid, setIsInvalid] = useState(false);\n\tconst [validationMessage, setValidationMessage] = useState(\"\");\n\tconst [focusIndex, setFocusIndex] = useState(0);\n\tconst dayRefs = useRef<Array<HTMLButtonElement | null>>([]);\n\tconst pendingFocus = useRef<{ targetMonthKey: string; iso: string } | null>(null);\n\tconst focusDay = useRef(false);\n\tconst hiddenRef = useRef<HTMLInputElement>(null);\n\tconst triggerRef = useRef<HTMLButtonElement>(null);\n\tconst generatedErrorId = React.useId();\n\tconst errorId = id ? `${id}-error` : generatedErrorId;\n\tconst generatedMonthLiveId = React.useId();\n\tconst monthLiveId = id ? `${id}-month-live` : generatedMonthLiveId;\n\tconst generatedKeyboardInstructionsId = React.useId();\n\tconst keyboardInstructionsId = id\n\t\t? `${id}-keyboard-instructions`\n\t\t: generatedKeyboardInstructionsId;\n\n\tconst selected = value ?? uncontrolled;\n\tconst selectedRange = rangeValue ?? uncontrolledRange;\n\tconst selectedDate = parseIso(\n\t\tmode === \"range\" ? selectedRange.to || selectedRange.from || \"\" : selected,\n\t);\n\tconst cursorIso = selectedDate ? formatIso(selectedDate) : \"\";\n\n\tuseEffect(() => {\n\t\tif (cursorIso) {\n\t\t\tsetIsInvalid(false);\n\t\t\tsetValidationMessage(\"\");\n\t\t}\n\t}, [cursorIso]);\n\tconst submitted = mode === \"range\" ? \"\" : cursorIso;\n\n\tconst controlledParsed = useMemo(() => parseIsoMonth(controlledMonthProp), [controlledMonthProp]);\n\tconst isMonthControlled = controlledParsed !== null;\n\n\tconst [uncontrolledMonth, setUncontrolledMonth] = useState<Civil>(() => {\n\t\tconst parsedDef = parseIsoMonth(defaultMonthProp);\n\t\tif (parsedDef) {\n\t\t\treturn parsedDef;\n\t\t}\n\t\tconst initialCursor = selectedDate ?? todayCivil(timeZone);\n\t\tconst clampedInitial = clampCivil(initialCursor, min, max);\n\t\treturn { y: clampedInitial.y, m: clampedInitial.m, d: 1 };\n\t});\n\n\tconst activeMonth = controlledParsed ?? uncontrolledMonth;\n\tconst activeMonthKey = formatIsoMonth(activeMonth);\n\n\tconst requestMonth = (target: Civil) => {\n\t\tconst monthKey = formatIsoMonth(target);\n\t\tif (!isMonthControlled) {\n\t\t\tsetUncontrolledMonth(target);\n\t\t}\n\t\tonMonthChange?.(monthKey);\n\t};\n\n\tconst prevSelected = useRef(cursorIso);\n\tif (open && prevSelected.current !== cursorIso) {\n\t\tfocusDay.current = true;\n\t\tif (controlledMonthProp === undefined && defaultMonthProp === undefined) {\n\t\t\tconst next = selectedDate ?? todayCivil(timeZone);\n\t\t\tif (activeMonth.y !== next.y || activeMonth.m !== next.m) {\n\t\t\t\tsetUncontrolledMonth({ y: next.y, m: next.m, d: 1 });\n\t\t\t}\n\t\t}\n\t}\n\tprevSelected.current = cursorIso;\n\n\tconst hasExplicitMonthConfig =\n\t\tcontrolledMonthProp !== undefined || defaultMonthProp !== undefined;\n\n\tuseEffect(() => {\n\t\tif (!open) {\n\t\t\treturn;\n\t\t}\n\t\tif (!hasExplicitMonthConfig) {\n\t\t\tconst next = clampCivil(\n\t\t\t\t(cursorIso ? parseIso(cursorIso) : null) ?? todayCivil(timeZone),\n\t\t\t\tmin,\n\t\t\t\tmax,\n\t\t\t);\n\t\t\tsetUncontrolledMonth({ y: next.y, m: next.m, d: 1 });\n\t\t\tif (!cursorIso) {\n\t\t\t\tfocusDay.current = true;\n\t\t\t}\n\t\t}\n\t}, [open, cursorIso, timeZone, min, max, hasExplicitMonthConfig]);\n\n\tuseEffect(() => {\n\t\tif (disabled) {\n\t\t\tsetOpen(false);\n\t\t}\n\t}, [disabled]);\n\n\tuseEffect(() => {\n\t\tif (autoFocus) {\n\t\t\ttriggerRef.current?.focus();\n\t\t}\n\t}, [autoFocus]);\n\n\tconst latestConfigRef = useRef({\n\t\tdefaultValue,\n\t\tdefaultRangeValue,\n\t\tmode,\n\t\trangeValue,\n\t\tvalue,\n\t});\n\tuseEffect(() => {\n\t\tlatestConfigRef.current = {\n\t\t\tdefaultValue,\n\t\t\tdefaultRangeValue,\n\t\t\tmode,\n\t\t\trangeValue,\n\t\t\tvalue,\n\t\t};\n\t});\n\n\tconst formAttr = formRest.form;\n\tuseEffect(() => {\n\t\tconst form = hiddenRef.current?.form;\n\t\tif (!form || (formAttr && form.id !== formAttr)) {\n\t\t\treturn;\n\t\t}\n\t\tlet disposed = false;\n\t\tconst timers = new Set<ReturnType<typeof setTimeout>>();\n\t\tconst onReset = (event: Event) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\ttimers.delete(timer);\n\t\t\t\tif (disposed || event.defaultPrevented) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst cfg = latestConfigRef.current;\n\t\t\t\tif (cfg.mode === \"range\" ? cfg.rangeValue === undefined : cfg.value === undefined) {\n\t\t\t\t\tsetUncontrolled(cfg.defaultValue);\n\t\t\t\t\tsetUncontrolledRange(cfg.defaultRangeValue ?? { from: \"\", to: undefined });\n\t\t\t\t}\n\t\t\t\tsetIsInvalid(false);\n\t\t\t\tsetValidationMessage(\"\");\n\t\t\t\tsetOpen(false);\n\t\t\t}, 0);\n\t\t\ttimers.add(timer);\n\t\t};\n\t\tform.addEventListener(\"reset\", onReset);\n\t\treturn () => {\n\t\t\tdisposed = true;\n\t\t\tfor (const timer of timers) {\n\t\t\t\tclearTimeout(timer);\n\t\t\t}\n\t\t\ttimers.clear();\n\t\t\tform.removeEventListener(\"reset\", onReset);\n\t\t};\n\t}, [formAttr]);\n\n\tconst weekdayLabels = useMemo(() => {\n\t\tconst formatter = new Intl.DateTimeFormat(locale, { weekday: \"short\", timeZone: \"UTC\" });\n\t\treturn Array.from({ length: 7 }, (_, index) => {\n\t\t\tconst day = new Date(Date.UTC(2024, 0, 7 + ((index + weekStartsOn) % 7)));\n\t\t\treturn formatter.format(day);\n\t\t});\n\t}, [locale, weekStartsOn]);\n\n\tconst days = useMemo(() => {\n\t\tconst first = { y: activeMonth.y, m: activeMonth.m, d: 1 };\n\t\tif (!isValidCivil(first)) {\n\t\t\treturn Array.from({ length: 42 }, () => null);\n\t\t}\n\t\tconst startOffset = (utcDate(first).getUTCDay() - weekStartsOn + 7) % 7;\n\t\tconst start = addDays(first, -startOffset);\n\t\tif (!start) {\n\t\t\treturn Array.from({ length: 42 }, (_, index) => addDays(first, index - startOffset));\n\t\t}\n\t\treturn Array.from({ length: 42 }, (_, index) => addDays(start, index));\n\t}, [activeMonth, weekStartsOn]);\n\n\tuseLayoutEffect(() => {\n\t\tif (!open) {\n\t\t\treturn;\n\t\t}\n\t\tconst pending = pendingFocus.current;\n\t\tlet index = 0;\n\t\tif (pending) {\n\t\t\tif (pending.targetMonthKey === activeMonthKey) {\n\t\t\t\tpendingFocus.current = null;\n\t\t\t\tindex = days.findIndex((date) => isoOf(date) === pending.iso);\n\t\t\t\tif (index < 0) {\n\t\t\t\t\tindex = 0;\n\t\t\t\t}\n\t\t\t\tfocusDay.current = true;\n\t\t\t} else {\n\t\t\t\tconst focused = document.activeElement;\n\t\t\t\tconst focusedIso =\n\t\t\t\t\tfocused instanceof HTMLElement && dayRefs.current.some((node) => node === focused)\n\t\t\t\t\t\t? focused.getAttribute(\"aria-label\")\n\t\t\t\t\t\t: null;\n\t\t\t\tconst focusedIndex = focusedIso ? days.findIndex((date) => isoOf(date) === focusedIso) : -1;\n\t\t\t\tif (focusedIndex >= 0) {\n\t\t\t\t\tindex = focusedIndex;\n\t\t\t\t} else {\n\t\t\t\t\tindex = focusIndex;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst focused = document.activeElement;\n\t\t\tconst focusedIso =\n\t\t\t\t!focusDay.current &&\n\t\t\t\tfocused instanceof HTMLElement &&\n\t\t\t\tdayRefs.current.some((node) => node === focused)\n\t\t\t\t\t? focused.getAttribute(\"aria-label\")\n\t\t\t\t\t: null;\n\t\t\tconst focusedIndex = focusedIso ? days.findIndex((date) => isoOf(date) === focusedIso) : -1;\n\t\t\tif (focusedIndex >= 0) {\n\t\t\t\tindex = focusedIndex;\n\t\t\t} else {\n\t\t\t\tconst iso = cursorIso || submitted || formatIso(todayCivil(timeZone));\n\t\t\t\tconst selectedIndex = days.findIndex((date) => isoOf(date) === iso);\n\t\t\t\tif (selectedIndex >= 0 && days[selectedIndex]?.m === activeMonth.m) {\n\t\t\t\t\tindex = selectedIndex;\n\t\t\t\t} else {\n\t\t\t\t\tconst firstInMonth = days.findIndex((date) => date?.m === activeMonth.m);\n\t\t\t\t\tindex = firstInMonth >= 0 ? firstInMonth : 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst enabled = (date: Civil | null) =>\n\t\t\tBoolean(date && date.y >= 1 && dateSelectable(formatIso(date), min, max, isDisabledDate));\n\t\tif (!enabled(days[index] ?? null)) {\n\t\t\tconst inMonth = days.findIndex((date) => date?.m === activeMonth.m && enabled(date));\n\t\t\tconst any = days.findIndex((date) => enabled(date));\n\t\t\tindex = inMonth >= 0 ? inMonth : any >= 0 ? any : index;\n\t\t}\n\t\tsetFocusIndex(index);\n\t\tif (focusDay.current) {\n\t\t\tfocusDay.current = false;\n\t\t\tdayRefs.current[index]?.focus();\n\t\t}\n\t}, [\n\t\topen,\n\t\tcursorIso,\n\t\tsubmitted,\n\t\ttimeZone,\n\t\tdays,\n\t\tactiveMonth.m,\n\t\tactiveMonthKey,\n\t\tfocusIndex,\n\t\tmin,\n\t\tmax,\n\t\tisDisabledDate,\n\t]);\n\n\tconst previousMonth = shiftMonth(activeMonth, -1);\n\tconst followingMonth = shiftMonth(activeMonth, 1);\n\tconst rangeFrom = mode === \"range\" ? selectedRange.from : \"\";\n\tconst rangeTo = mode === \"range\" ? selectedRange.to : undefined;\n\tconst label = formatTriggerLabel({\n\t\tmode,\n\t\tselectedDate,\n\t\trangeFrom,\n\t\trangeTo,\n\t\tlocale,\n\t\tformatDate,\n\t\tplaceholder: labels?.placeholder,\n\t});\n\tconst calendarLabel = labels?.calendar ?? (ariaLabel ? `${ariaLabel} calendar` : \"Date calendar\");\n\tconst prevMonthLabel = labels?.previousMonth ?? \"Prev\";\n\tconst nextMonthLabel = labels?.nextMonth ?? \"Next\";\n\n\tfunction selectable(iso: string) {\n\t\treturn dateSelectable(iso, min, max, isDisabledDate);\n\t}\n\n\tfunction focusCalendarDay(next: Civil) {\n\t\tif (next.y !== activeMonth.y || next.m !== activeMonth.m) {\n\t\t\tpendingFocus.current = {\n\t\t\t\ttargetMonthKey: formatIsoMonth(next),\n\t\t\t\tiso: formatIso(next),\n\t\t\t};\n\t\t\trequestMonth({ y: next.y, m: next.m, d: 1 });\n\t\t\treturn;\n\t\t}\n\t\tconst index = days.findIndex((date) => isoOf(date) === formatIso(next));\n\t\tif (index >= 0) {\n\t\t\tsetFocusIndex(index);\n\t\t\tdayRefs.current[index]?.focus();\n\t\t}\n\t}\n\n\tfunction commit(next: string) {\n\t\tif (disabled || readOnly || !selectable(next)) {\n\t\t\treturn;\n\t\t}\n\t\tif (next) {\n\t\t\tsetIsInvalid(false);\n\t\t\tsetValidationMessage(\"\");\n\t\t}\n\t\tif (mode === \"range\") {\n\t\t\tconst current = rangeValue ?? uncontrolledRange;\n\t\t\tconst nextRange =\n\t\t\t\t!current.from || current.to\n\t\t\t\t\t? { from: next }\n\t\t\t\t\t: compareCivil(\n\t\t\t\t\t\t\t\tparseIso(next) ?? { y: 1, m: 1, d: 1 },\n\t\t\t\t\t\t\t\tparseIso(current.from) ?? { y: 1, m: 1, d: 1 },\n\t\t\t\t\t\t\t) < 0\n\t\t\t\t\t\t? { from: next, to: current.from }\n\t\t\t\t\t\t: { from: current.from, to: next };\n\t\t\tif (rangeValue === undefined) {\n\t\t\t\tsetUncontrolledRange(nextRange);\n\t\t\t}\n\t\t\tonRangeChange?.(nextRange);\n\t\t\tif (nextRange.to) {\n\t\t\t\tsetOpen(false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (value === undefined) {\n\t\t\tsetUncontrolled(next);\n\t\t}\n\t\tsetOpen(false);\n\t\tonChange?.(next);\n\t}\n\n\tfunction applyPreset(preset: DatePickerPreset) {\n\t\tif (disabled || readOnly) {\n\t\t\treturn;\n\t\t}\n\t\tif (typeof preset.value === \"string\") {\n\t\t\tif (mode === \"range\") {\n\t\t\t\tif (!selectable(preset.value)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst nextRange = { from: preset.value, to: preset.value };\n\t\t\t\tif (rangeValue === undefined) {\n\t\t\t\t\tsetUncontrolledRange(nextRange);\n\t\t\t\t}\n\t\t\t\tonRangeChange?.(nextRange);\n\t\t\t\tsetOpen(false);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcommit(preset.value);\n\t\t\treturn;\n\t\t}\n\t\tif (mode === \"range\") {\n\t\t\tif (!selectable(preset.value.from) || !selectable(preset.value.to)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (rangeValue === undefined) {\n\t\t\t\tsetUncontrolledRange(preset.value);\n\t\t\t}\n\t\t\tonRangeChange?.(preset.value);\n\t\t\tsetOpen(false);\n\t\t}\n\t}\n\n\tconst handleHiddenRef = React.useCallback(\n\t\t(node: HTMLInputElement | null) => {\n\t\t\thiddenRef.current = node;\n\t\t\tif (!externalRef) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (typeof externalRef === \"function\") {\n\t\t\t\tconst cleanup = externalRef(node);\n\t\t\t\tif (typeof cleanup === \"function\") {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\thiddenRef.current = null;\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn () => {\n\t\t\t\t\thiddenRef.current = null;\n\t\t\t\t\texternalRef(null);\n\t\t\t\t};\n\t\t\t}\n\t\t\t(externalRef as React.RefObject<HTMLInputElement | null>).current = node;\n\t\t\treturn () => {\n\t\t\t\thiddenRef.current = null;\n\t\t\t\t(externalRef as React.RefObject<HTMLInputElement | null>).current = null;\n\t\t\t};\n\t\t},\n\t\t[externalRef],\n\t);\n\n\tconst invalidState = ariaInvalid ?? (isInvalid || undefined);\n\tconst hasDestructiveStyle =\n\t\tinvalidState === true ||\n\t\tinvalidState === \"true\" ||\n\t\tinvalidState === \"grammar\" ||\n\t\tinvalidState === \"spelling\";\n\n\tconst describedBy =\n\t\t[ariaDescribedBy, isInvalid && errorId ? errorId : undefined].filter(Boolean).join(\" \") ||\n\t\tundefined;\n\n\treturn (\n\t\t<Popover\n\t\t\topen={open}\n\t\t\tonOpenChange={(next) => {\n\t\t\t\tif (next && disabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (next) {\n\t\t\t\t\tpendingFocus.current = null;\n\t\t\t\t\tif (controlledMonthProp === undefined && defaultMonthProp === undefined) {\n\t\t\t\t\t\tconst synced = (cursorIso ? parseIso(cursorIso) : null) ?? todayCivil(timeZone);\n\t\t\t\t\t\tsetUncontrolledMonth({ y: synced.y, m: synced.m, d: 1 });\n\t\t\t\t\t}\n\t\t\t\t\tfocusDay.current = true;\n\t\t\t\t} else {\n\t\t\t\t\tpendingFocus.current = null;\n\t\t\t\t}\n\t\t\t\tsetOpen(next);\n\t\t\t}}\n\t\t>\n\t\t\t<input\n\t\t\t\tref={handleHiddenRef}\n\t\t\t\ttype={mode === \"range\" ? \"text\" : \"date\"}\n\t\t\t\tname={name}\n\t\t\t\trequired={required}\n\t\t\t\treadOnly={readOnly}\n\t\t\t\tmin={mode === \"range\" ? undefined : min}\n\t\t\t\tmax={mode === \"range\" ? undefined : max}\n\t\t\t\tclassName=\"sr-only mb-2 h-7\"\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\twidth: 1,\n\t\t\t\t\theight: 1,\n\t\t\t\t\toverflow: \"hidden\",\n\t\t\t\t\tclip: \"rect(0, 0, 0, 0)\",\n\t\t\t\t}}\n\t\t\t\tvalue={\n\t\t\t\t\tmode === \"range\" ? (rangeFrom && rangeTo ? `${rangeFrom}/${rangeTo}` : \"\") : submitted\n\t\t\t\t}\n\t\t\t\tonChange={() => undefined}\n\t\t\t\tonInvalid={(event) => {\n\t\t\t\t\texternalOnInvalid?.(event);\n\t\t\t\t\tif (!event.defaultPrevented) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tsetIsInvalid(true);\n\t\t\t\t\t\tsetValidationMessage(\n\t\t\t\t\t\t\tlabels?.validationMessage ||\n\t\t\t\t\t\t\t\t(event.target as HTMLInputElement).validationMessage ||\n\t\t\t\t\t\t\t\t\"Please fill out this field.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttriggerRef.current?.focus();\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tdisabled={disabled}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\ttabIndex={-1}\n\t\t\t\t{...formRest}\n\t\t\t/>\n\t\t\t<PopoverTrigger asChild>\n\t\t\t\t<Button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tref={triggerRef}\n\t\t\t\t\tid={id}\n\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonFocus={onFocus as ComponentProps<\"button\">[\"onFocus\"]}\n\t\t\t\t\tonBlur={onBlur as ComponentProps<\"button\">[\"onBlur\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tariaLabel ? (label === \"Pick a date\" ? ariaLabel : `${ariaLabel}: ${label}`) : undefined\n\t\t\t\t\t}\n\t\t\t\t\taria-describedby={describedBy}\n\t\t\t\t\taria-invalid={invalidState}\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\"justify-start font-normal\",\n\t\t\t\t\t\thasDestructiveStyle && \"border-basalt-destructive text-basalt-destructive\",\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</Button>\n\t\t\t</PopoverTrigger>\n\t\t\t{isInvalid && validationMessage ? (\n\t\t\t\t<span id={errorId} role=\"alert\" className=\"mt-1 block text-xs text-basalt-destructive\">\n\t\t\t\t\t{validationMessage}\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t\t<PopoverContent\n\t\t\t\tarrow={false}\n\t\t\t\tclassName=\"w-64 p-3\"\n\t\t\t\taria-label={calendarLabel}\n\t\t\t\taria-describedby={keyboardInstructionsId}\n\t\t\t\tonOpenAutoFocus={(event) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tconst iso = cursorIso || submitted || formatIso(todayCivil(timeZone));\n\t\t\t\t\tconst selectedIndex = days.findIndex((date) => isoOf(date) === iso);\n\t\t\t\t\tconst enabled = (date: Civil | null) =>\n\t\t\t\t\t\tBoolean(\n\t\t\t\t\t\t\tdate && date.y >= 1 && dateSelectable(formatIso(date), min, max, isDisabledDate),\n\t\t\t\t\t\t);\n\t\t\t\t\tlet index =\n\t\t\t\t\t\tselectedIndex >= 0 && days[selectedIndex]?.m === activeMonth.m\n\t\t\t\t\t\t\t? selectedIndex\n\t\t\t\t\t\t\t: Math.max(\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\tdays.findIndex((date) => date?.m === activeMonth.m),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\tif (!enabled(days[index] ?? null)) {\n\t\t\t\t\t\tconst inMonth = days.findIndex((date) => date?.m === activeMonth.m && enabled(date));\n\t\t\t\t\t\tconst any = days.findIndex((date) => enabled(date));\n\t\t\t\t\t\tindex = inMonth >= 0 ? inMonth : any >= 0 ? any : index;\n\t\t\t\t\t}\n\t\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t\tdayRefs.current[index]?.focus();\n\t\t\t\t\t});\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{presets && presets.length > 0 ? (\n\t\t\t\t\t<div className=\"mb-2 flex flex-wrap gap-1\">\n\t\t\t\t\t\t{presets.map((preset) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tkey={preset.label}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t\t\tclassName=\"h-7 px-2 text-xs\"\n\t\t\t\t\t\t\t\tdisabled={disabled || readOnly}\n\t\t\t\t\t\t\t\tonClick={() => applyPreset(preset)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{preset.label}\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t\t<div className=\"mb-2 flex items-center justify-between gap-2\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\ticon={<ChevronLeft />}\n\t\t\t\t\t\taria-label={prevMonthLabel}\n\t\t\t\t\t\tclassName=\"size-8\"\n\t\t\t\t\t\tdisabled={disabled || !previousMonth || previousMonth.y < 1}\n\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\tif (!previousMonth || previousMonth.y < 1) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingFocus.current = null;\n\t\t\t\t\t\t\tfocusDay.current = false;\n\t\t\t\t\t\t\trequestMonth(previousMonth);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t<span\n\t\t\t\t\t\tid={monthLiveId}\n\t\t\t\t\t\taria-live=\"polite\"\n\t\t\t\t\t\taria-atomic=\"true\"\n\t\t\t\t\t\tclassName=\"text-sm font-medium\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{formatCivil(activeMonth, locale, { month: \"long\", year: \"numeric\" })}\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\ticon={<ChevronRight />}\n\t\t\t\t\t\taria-label={nextMonthLabel}\n\t\t\t\t\t\tclassName=\"size-8\"\n\t\t\t\t\t\tdisabled={disabled || !followingMonth}\n\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\tif (!followingMonth) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingFocus.current = null;\n\t\t\t\t\t\t\tfocusDay.current = false;\n\t\t\t\t\t\t\trequestMonth(followingMonth);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<p id={keyboardInstructionsId} className=\"sr-only\">\n\t\t\t\t\t{labels?.keyboardInstructions ??\n\t\t\t\t\t\t\"Use arrow keys to navigate dates, PageUp and PageDown to change months, and Enter or Space to select.\"}\n\t\t\t\t</p>\n\t\t\t\t{/* Biome override: WAI-ARIA APG Date Picker pattern uses a semantic table with role=\"grid\" and role=\"gridcell\" on cells while roving tabindex focuses the child button */}\n\t\t\t\t<table\n\t\t\t\t\trole=\"grid\"\n\t\t\t\t\taria-labelledby={monthLiveId}\n\t\t\t\t\taria-multiselectable={mode === \"range\" ? \"true\" : undefined}\n\t\t\t\t\tclassName=\"w-full border-collapse text-center\"\n\t\t\t\t\tonKeyDown={(event) => {\n\t\t\t\t\t\tconst current = days[focusIndex];\n\t\t\t\t\t\tif (!current) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tevent.key === \"ArrowRight\" ||\n\t\t\t\t\t\t\tevent.key === \"ArrowLeft\" ||\n\t\t\t\t\t\t\tevent.key === \"ArrowDown\" ||\n\t\t\t\t\t\t\tevent.key === \"ArrowUp\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tconst delta =\n\t\t\t\t\t\t\t\tevent.key === \"ArrowRight\"\n\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t: event.key === \"ArrowLeft\"\n\t\t\t\t\t\t\t\t\t\t? -1\n\t\t\t\t\t\t\t\t\t\t: event.key === \"ArrowDown\"\n\t\t\t\t\t\t\t\t\t\t\t? 7\n\t\t\t\t\t\t\t\t\t\t\t: -7;\n\t\t\t\t\t\t\tlet next = addDays(current, delta);\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tlet step = 0;\n\t\t\t\t\t\t\t\tnext && next.y >= 1 && !selectable(formatIso(next)) && step < 42;\n\t\t\t\t\t\t\t\tstep += 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnext = addDays(next, delta);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!next || next.y < 1 || !selectable(formatIso(next))) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusCalendarDay(next);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (event.key === \"Home\" || event.key === \"End\") {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tconst dayOfWeek = utcDate(current).getUTCDay();\n\t\t\t\t\t\t\tconst col = (dayOfWeek - weekStartsOn + 7) % 7;\n\t\t\t\t\t\t\tconst deltaToEdge = event.key === \"Home\" ? -col : 6 - col;\n\t\t\t\t\t\t\tlet next: Civil | null = addDays(current, deltaToEdge);\n\t\t\t\t\t\t\tconst stepDir = event.key === \"Home\" ? 1 : -1;\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tlet step = 0;\n\t\t\t\t\t\t\t\tnext && next.y >= 1 && !selectable(formatIso(next)) && step < 7;\n\t\t\t\t\t\t\t\tstep += 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnext = addDays(next, stepDir);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!next || next.y < 1 || !selectable(formatIso(next))) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusCalendarDay(next);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (event.key === \"PageDown\" || event.key === \"PageUp\") {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tconst deltaMonths = event.shiftKey\n\t\t\t\t\t\t\t\t? event.key === \"PageDown\"\n\t\t\t\t\t\t\t\t\t? 12\n\t\t\t\t\t\t\t\t\t: -12\n\t\t\t\t\t\t\t\t: event.key === \"PageDown\"\n\t\t\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t\t\t: -1;\n\t\t\t\t\t\t\tconst target = shiftCivilMonthClamped(current, deltaMonths);\n\t\t\t\t\t\t\tif (!target) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlet next: Civil | null = target;\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tlet step = 0;\n\t\t\t\t\t\t\t\tnext && next.y >= 1 && !selectable(formatIso(next)) && step < 42;\n\t\t\t\t\t\t\t\tstep += 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnext = addDays(next, 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!next || next.y < 1 || !selectable(formatIso(next))) {\n\t\t\t\t\t\t\t\tnext = target;\n\t\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\t\tlet step = 0;\n\t\t\t\t\t\t\t\t\tnext && next.y >= 1 && !selectable(formatIso(next)) && step < 42;\n\t\t\t\t\t\t\t\t\tstep += 1\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnext = addDays(next, -1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!next || next.y < 1 || !selectable(formatIso(next))) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingFocus.current = {\n\t\t\t\t\t\t\t\ttargetMonthKey: formatIsoMonth(next),\n\t\t\t\t\t\t\t\tiso: formatIso(next),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\trequestMonth({ y: next.y, m: next.m, d: 1 });\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (event.key === \"Enter\" || event.key === \" \") {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tconst iso = formatIso(current);\n\t\t\t\t\t\t\tif (current.y >= 1 && selectable(iso)) {\n\t\t\t\t\t\t\t\tcommit(iso);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t{weekdayLabels.map((day, index) => (\n\t\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\t\tkey={`${day}-${index}`}\n\t\t\t\t\t\t\t\t\tscope=\"col\"\n\t\t\t\t\t\t\t\t\tclassName=\"h-8 text-center text-xs font-medium text-basalt-muted-foreground\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{day}\n\t\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t{Array.from({ length: 6 }, (_, weekIndex) => (\n\t\t\t\t\t\t\t<tr key={`week-${weekIndex}`}>\n\t\t\t\t\t\t\t\t{days.slice(weekIndex * 7, weekIndex * 7 + 7).map((date, colIndex) => {\n\t\t\t\t\t\t\t\t\tconst index = weekIndex * 7 + colIndex;\n\t\t\t\t\t\t\t\t\tif (!date) {\n\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<td\n\t\t\t\t\t\t\t\t\t\t\t\tkey={`empty-${index}`}\n\t\t\t\t\t\t\t\t\t\t\t\trole=\"gridcell\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"h-8 p-0 text-center\"\n\t\t\t\t\t\t\t\t\t\t\t\tref={() => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tdayRefs.current[index] = null;\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst iso = formatIso(date);\n\t\t\t\t\t\t\t\t\tconst inMonth = date.m === activeMonth.m;\n\t\t\t\t\t\t\t\t\tconst inRange = date.y >= 1 && selectable(iso);\n\t\t\t\t\t\t\t\t\tconst fromDate = rangeFrom ? parseIso(rangeFrom) : null;\n\t\t\t\t\t\t\t\t\tconst toDate = rangeTo ? parseIso(rangeTo) : null;\n\t\t\t\t\t\t\t\t\tconst thisDate = parseIso(iso);\n\t\t\t\t\t\t\t\t\tconst inSelectedRange = Boolean(\n\t\t\t\t\t\t\t\t\t\tfromDate &&\n\t\t\t\t\t\t\t\t\t\t\ttoDate &&\n\t\t\t\t\t\t\t\t\t\t\tthisDate &&\n\t\t\t\t\t\t\t\t\t\t\tcompareCivil(thisDate, fromDate) >= 0 &&\n\t\t\t\t\t\t\t\t\t\t\tcompareCivil(thisDate, toDate) <= 0,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst isRangeEdge = iso === rangeFrom || iso === rangeTo;\n\t\t\t\t\t\t\t\t\tconst isSelected =\n\t\t\t\t\t\t\t\t\t\tmode === \"range\"\n\t\t\t\t\t\t\t\t\t\t\t? inSelectedRange || isRangeEdge\n\t\t\t\t\t\t\t\t\t\t\t: Boolean(submitted) && iso === submitted;\n\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<td\n\t\t\t\t\t\t\t\t\t\t\tkey={iso}\n\t\t\t\t\t\t\t\t\t\t\trole=\"gridcell\"\n\t\t\t\t\t\t\t\t\t\t\taria-selected={isSelected ? \"true\" : undefined}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"h-8 p-0 text-center\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\t\tref={(node) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tdayRefs.current[index] = node;\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\ttabIndex={index === focusIndex ? 0 : -1}\n\t\t\t\t\t\t\t\t\t\t\t\tdata-date={iso}\n\t\t\t\t\t\t\t\t\t\t\t\taria-label={iso}\n\t\t\t\t\t\t\t\t\t\t\t\taria-pressed={mode === \"range\" ? isRangeEdge : isSelected}\n\t\t\t\t\t\t\t\t\t\t\t\tdisabled={disabled || readOnly || !inRange}\n\t\t\t\t\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t\t\t\t\tCALENDAR_BUTTON,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"mx-auto flex h-8 w-8 items-center justify-center rounded-basalt-md text-sm\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tinMonth ? \"text-basalt-foreground\" : \"text-basalt-muted-foreground\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tinRange && \"hover:bg-basalt-accent\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tinSelectedRange && !isRangeEdge && \"bg-basalt-accent\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tinRange &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(mode === \"range\" ? isRangeEdge : isSelected) &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"bg-basalt-primary text-basalt-primary-foreground hover:bg-basalt-primary/90\",\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={() => inRange && commit(iso)}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{date.d}\n\t\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";;;;;;;;;AASA,SAASC,EAAI,GAAe;CAC3B,OAAO,OAAOC,CAAK,CAAC,CAAC,SAAS,GAAG,GAAG;AACrC;AAEA,SAASC,EAAU,GAAa;CAC/B,O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AQzD,KAASQ;SAC1B;SACA,UAAUR,MAAUjD,KAAa,IAAI;SACrC,aAAW/C;SACX,cAAYA;SACZ,gBAAcE,MAAS,UAAUsJ,IAAcC;SAC/C,UAAUtE,KAAYsC,KAAY,CAAC0B;SACnC,WAAWX,EACV/J,IACA,8EACAoI,IAAU,2BAA2B,gCACrCsC,KAAW,0BACXI,MAAmB,CAACC,KAAe,oBACnCL,MACEjJ,MAAS,UAAUsJ,IAAcC,MAClC,6EACF;SACA,eAAeN,KAAW3B,GAAOxH,CAAG;SAEnC,UAAArC,EAAK;QACC,CAAA;OACL,GA7BEqC,CA6BF;MAEN,CAAC,EACE,GApEK,QAAQiJ,GAoEb,CACJ,EACK,CAAA,CACD;;IACQ;;EACR;;AAEX"}
|
|
@@ -22,7 +22,7 @@ function o({ name: o, onDelete: s, errorMessage: c }) {
|
|
|
22
22
|
}) : null] }),
|
|
23
23
|
confirmLabel: "Delete",
|
|
24
24
|
onOpenChange: (e) => {
|
|
25
|
-
d
|
|
25
|
+
(!d || e) && (u(e), e || (f(!1), m(null)));
|
|
26
26
|
},
|
|
27
27
|
onConfirm: async () => {
|
|
28
28
|
f(!0), m(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-resource.js","names":[],"sources":["../../src/components/delete-resource.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Button } from \"./button\";\nimport { ConfirmDialog } from \"./confirm-dialog\";\n\nexport type DeleteResourceErrorFormatter = (error: unknown) => React.ReactNode;\n\nexport type DeleteResourceProps = {\n\t/** Name of the resource being deleted, interpolated into dialog title and trigger label. */\n\tname: string;\n\t/** Called when deletion is confirmed. When this throws or rejects, an error alert is shown and the dialog remains open for retry. */\n\tonDelete: () => void | Promise<void>;\n\t/** Custom error message or renderer when onDelete fails. Accepts a ReactNode or an (error: unknown) => ReactNode formatter. Defaults to the caught Error message or 'Failed to delete resource. Please try again.' */\n\terrorMessage?: React.ReactNode | DeleteResourceErrorFormatter;\n};\n\nexport function DeleteResource({ name, onDelete, errorMessage }: DeleteResourceProps) {\n\tconst [open, setOpen] = React.useState(false);\n\tconst [loading, setLoading] = React.useState(false);\n\tconst [error, setError] = React.useState<React.ReactNode | null>(null);\n\n\tconst resolveErrorMessage = (err: unknown): React.ReactNode => {\n\t\tif (typeof errorMessage === \"function\") {\n\t\t\treturn errorMessage(err);\n\t\t}\n\t\tif (errorMessage != null) {\n\t\t\treturn errorMessage;\n\t\t}\n\t\tif (err instanceof Error && err.message) {\n\t\t\treturn err.message;\n\t\t}\n\t\treturn \"Failed to delete resource. Please try again.\";\n\t};\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\ttrigger={<Button variant=\"destructive\">Delete {name}</Button>}\n\t\t\topen={open}\n\t\t\tloading={loading}\n\t\t\tvariant=\"destructive\"\n\t\t\ttitle={`Delete ${name}?`}\n\t\t\tdescription={\n\t\t\t\t<>\n\t\t\t\t\t<span>This cannot be undone.</span>\n\t\t\t\t\t{error ? (\n\t\t\t\t\t\t<span role=\"alert\" className=\"mt-2 block text-xs text-basalt-destructive\">\n\t\t\t\t\t\t\t{error}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null}\n\t\t\t\t</>\n\t\t\t}\n\t\t\tconfirmLabel=\"Delete\"\n\t\t\tonOpenChange={(next) => {\n\t\t\t\tif (loading && !next) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetOpen(next);\n\t\t\t\tif (!next) {\n\t\t\t\t\tsetLoading(false);\n\t\t\t\t\tsetError(null);\n\t\t\t\t}\n\t\t\t}}\n\t\t\tonConfirm={async () => {\n\t\t\t\tsetLoading(true);\n\t\t\t\tsetError(null);\n\t\t\t\ttry {\n\t\t\t\t\tawait onDelete();\n\t\t\t\t\tsetOpen(false);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tsetError(resolveErrorMessage(err));\n\t\t\t\t\tsetOpen(true);\n\t\t\t\t} finally {\n\t\t\t\t\tsetLoading(false);\n\t\t\t\t}\n\t\t\t}}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAeA,
|
|
1
|
+
{"version":3,"file":"delete-resource.js","names":["_Fragment","React","Fragment$1","DeleteResource","open","setOpen","loading","setLoading","error","setError","resolveErrorMessage","errorMessage","err","ConfirmDialog","Button","name","next","onDelete"],"sources":["../../src/components/delete-resource.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Button } from \"./button\";\nimport { ConfirmDialog } from \"./confirm-dialog\";\n\nexport type DeleteResourceErrorFormatter = (error: unknown) => React.ReactNode;\n\nexport type DeleteResourceProps = {\n\t/** Name of the resource being deleted, interpolated into dialog title and trigger label. */\n\tname: string;\n\t/** Called when deletion is confirmed. When this throws or rejects, an error alert is shown and the dialog remains open for retry. */\n\tonDelete: () => void | Promise<void>;\n\t/** Custom error message or renderer when onDelete fails. Accepts a ReactNode or an (error: unknown) => ReactNode formatter. Defaults to the caught Error message or 'Failed to delete resource. Please try again.' */\n\terrorMessage?: React.ReactNode | DeleteResourceErrorFormatter;\n};\n\nexport function DeleteResource({ name, onDelete, errorMessage }: DeleteResourceProps) {\n\tconst [open, setOpen] = React.useState(false);\n\tconst [loading, setLoading] = React.useState(false);\n\tconst [error, setError] = React.useState<React.ReactNode | null>(null);\n\n\tconst resolveErrorMessage = (err: unknown): React.ReactNode => {\n\t\tif (typeof errorMessage === \"function\") {\n\t\t\treturn errorMessage(err);\n\t\t}\n\t\tif (errorMessage != null) {\n\t\t\treturn errorMessage;\n\t\t}\n\t\tif (err instanceof Error && err.message) {\n\t\t\treturn err.message;\n\t\t}\n\t\treturn \"Failed to delete resource. Please try again.\";\n\t};\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\ttrigger={<Button variant=\"destructive\">Delete {name}</Button>}\n\t\t\topen={open}\n\t\t\tloading={loading}\n\t\t\tvariant=\"destructive\"\n\t\t\ttitle={`Delete ${name}?`}\n\t\t\tdescription={\n\t\t\t\t<>\n\t\t\t\t\t<span>This cannot be undone.</span>\n\t\t\t\t\t{error ? (\n\t\t\t\t\t\t<span role=\"alert\" className=\"mt-2 block text-xs text-basalt-destructive\">\n\t\t\t\t\t\t\t{error}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null}\n\t\t\t\t</>\n\t\t\t}\n\t\t\tconfirmLabel=\"Delete\"\n\t\t\tonOpenChange={(next) => {\n\t\t\t\tif (loading && !next) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetOpen(next);\n\t\t\t\tif (!next) {\n\t\t\t\t\tsetLoading(false);\n\t\t\t\t\tsetError(null);\n\t\t\t\t}\n\t\t\t}}\n\t\t\tonConfirm={async () => {\n\t\t\t\tsetLoading(true);\n\t\t\t\tsetError(null);\n\t\t\t\ttry {\n\t\t\t\t\tawait onDelete();\n\t\t\t\t\tsetOpen(false);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tsetError(resolveErrorMessage(err));\n\t\t\t\t\tsetOpen(true);\n\t\t\t\t} finally {\n\t\t\t\t\tsetLoading(false);\n\t\t\t\t}\n\t\t\t}}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAeA,SAAgBG,EAAe,EAAE,SAAM,aAAU,mBAAqC;CACrF,IAAM,CAACC,GAAMC,KAAWJ,EAAM,SAAS,EAAK,GACtC,CAACK,GAASC,KAAcN,EAAM,SAAS,EAAK,GAC5C,CAACO,GAAOC,KAAYR,EAAM,SAAiC,IAAI,GAE/DS,KAAuB,MACxB,OAAOC,KAAiB,aACpBA,EAAaC,CAAG,IAEpBD,MAGAC,aAAe,SAASA,EAAI,UACxBA,EAAI,UAEL;CAGR,OACC,kBAACC,GAAD;EACC,SAAS,kBAACC,GAAD;GAAQ,SAAQ;GAAhB,UAAA,CAA8B,WAAQC,CAAa;;EACtD;EACG;EACT,SAAQ;EACR,OAAO,UAAUA,EAAK;EACtB,aACC,kBAAAf,GAAA,EAAA,UAAA,CACC,kBAAC,QAAD,EAAA,UAAM,yBAA4B,CAAA,GACjCQ,IACA,kBAAC,QAAD;GAAM,MAAK;GAAQ,WAAU;GAC3B,UAAAA;EACI,CAAA,IACH,IACH,EAAA,CAAA;EAEH,cAAa;EACb,eAAe,MAAS;GACvB,CAAI,MAAYQ,OAGhBX,EAAQW,CAAI,GACPA,MACJT,EAAW,EAAK,GAChBE,EAAS,IAAI;EAEf;EACA,WAAW,YAAY;GAEtB,AADAF,EAAW,EAAI,GACfE,EAAS,IAAI;GACb,IAAI;IAEH,AADA,MAAMQ,EAAS,GACfZ,EAAQ,EAAK;GACd,SAASO,GAAK;IAEb,AADAH,EAASC,EAAoBE,CAAG,CAAC,GACjCP,EAAQ,EAAI;GACb,UAAU;IACT,EAAW,EAAK;GACjB;EACD;CACA,CAAA;AAEH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"description-list.js","names":[],"sources":["../../src/components/description-list.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { BASALT_UI_CLASS } from \"../utils/control-surface\";\n\nexport type DescriptionListColumns = 1 | 2 | 3;\n\nexport type DescriptionListProps = HTMLAttributes<HTMLDListElement> & {\n\t/**\n\t * Number of term/value columns from the small breakpoint up.\n\t * @default 2\n\t */\n\tcolumns?: DescriptionListColumns;\n};\n\nconst COLUMN_CLASS: Record<DescriptionListColumns, string> = {\n\t1: \"sm:grid-cols-1\",\n\t2: \"sm:grid-cols-2\",\n\t3: \"sm:grid-cols-3\",\n};\n\nfunction DescriptionListRoot({ className, columns = 2, ...props }: DescriptionListProps) {\n\treturn (\n\t\t<dl\n\t\t\tclassName={cn(\n\t\t\t\tBASALT_UI_CLASS,\n\t\t\t\t\"grid gap-x-8 gap-y-3 text-sm\",\n\t\t\t\tCOLUMN_CLASS[columns],\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nDescriptionListRoot.displayName = \"DescriptionList\";\n\nexport type DescriptionListItemProps = HTMLAttributes<HTMLDivElement> & {\n\t/**\n\t * Term shown above the value.\n\t */\n\tterm: ReactNode;\n};\n\nfunction DescriptionListItem({ term, className, children, ...props }: DescriptionListItemProps) {\n\treturn (\n\t\t<div className={cn(\"min-w-0\", className)} {...props}>\n\t\t\t<dt className=\"text-xs text-basalt-muted-foreground\">{term}</dt>\n\t\t\t<dd className=\"mt-0.5 wrap-break-word text-basalt-foreground\">{children}</dd>\n\t\t</div>\n\t);\n}\nDescriptionListItem.displayName = \"DescriptionList.Item\";\n\nexport const DescriptionList = Object.assign(DescriptionListRoot, {\n\tItem: DescriptionListItem,\n});\n"],"mappings":";;;;;AAcA,
|
|
1
|
+
{"version":3,"file":"description-list.js","names":["COLUMN_CLASS","DescriptionListRoot","props","cn","BASALT_UI_CLASS","columns","className","DescriptionListItem","term","DescriptionList"],"sources":["../../src/components/description-list.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { BASALT_UI_CLASS } from \"../utils/control-surface\";\n\nexport type DescriptionListColumns = 1 | 2 | 3;\n\nexport type DescriptionListProps = HTMLAttributes<HTMLDListElement> & {\n\t/**\n\t * Number of term/value columns from the small breakpoint up.\n\t * @default 2\n\t */\n\tcolumns?: DescriptionListColumns;\n};\n\nconst COLUMN_CLASS: Record<DescriptionListColumns, string> = {\n\t1: \"sm:grid-cols-1\",\n\t2: \"sm:grid-cols-2\",\n\t3: \"sm:grid-cols-3\",\n};\n\nfunction DescriptionListRoot({ className, columns = 2, ...props }: DescriptionListProps) {\n\treturn (\n\t\t<dl\n\t\t\tclassName={cn(\n\t\t\t\tBASALT_UI_CLASS,\n\t\t\t\t\"grid gap-x-8 gap-y-3 text-sm\",\n\t\t\t\tCOLUMN_CLASS[columns],\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nDescriptionListRoot.displayName = \"DescriptionList\";\n\nexport type DescriptionListItemProps = HTMLAttributes<HTMLDivElement> & {\n\t/**\n\t * Term shown above the value.\n\t */\n\tterm: ReactNode;\n};\n\nfunction DescriptionListItem({ term, className, children, ...props }: DescriptionListItemProps) {\n\treturn (\n\t\t<div className={cn(\"min-w-0\", className)} {...props}>\n\t\t\t<dt className=\"text-xs text-basalt-muted-foreground\">{term}</dt>\n\t\t\t<dd className=\"mt-0.5 wrap-break-word text-basalt-foreground\">{children}</dd>\n\t\t</div>\n\t);\n}\nDescriptionListItem.displayName = \"DescriptionList.Item\";\n\nexport const DescriptionList = Object.assign(DescriptionListRoot, {\n\tItem: DescriptionListItem,\n});\n"],"mappings":";;;;;AAcA,IAAMA,IAAuD;CAC5D,GAAG;CACH,GAAG;CACH,GAAG;AACJ;AAEA,SAASC,EAAoB,EAAE,cAAW,aAAU,GAAG,GAAGC,KAA+B;CACxF,OACC,kBAAC,MAAD;EACC,WAAWC,EACVC,GACA,gCACAJ,EAAaK,IACbC,CACD;EACA,GAAIJ;CACJ,CAAA;AAEH;AACA,EAAoB,cAAc;AASlC,SAASK,EAAoB,EAAE,SAAM,cAAW,aAAU,GAAGL,KAAmC;CAC/F,OACC,kBAAC,OAAD;EAAK,WAAWC,EAAG,WAAWG,CAAS;EAAG,GAAIJ;EAA9C,UAAA,CACC,kBAAC,MAAD;GAAI,WAAU;GAAwC,UAAAM;EAAS,CAAA,GAC/D,kBAAC,MAAD;GAAI,WAAU;GAAiD;EAAa,CAAA,CACxE;;AAEP;AACA,EAAoB,cAAc;AAElC,IAAaC,IAAkB,OAAO,OAAOR,GAAqB,EACjE,MAAMM,EACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","names":[],"sources":["../../src/components/dialog.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { BASALT_UI_CLASS } from \"../utils/control-surface\";\nimport { OVERLAY_LAYER, OVERLAY_MOTION } from \"./overlay\";\n\nexport const DIALOG_SIZES = {\n\tsm: \"sm:w-72\",\n\tbase: \"sm:w-96\",\n\tlg: \"sm:w-[32rem]\",\n\txl: \"sm:w-[48rem]\",\n} as const;\n\nexport type DialogSize = keyof typeof DIALOG_SIZES;\n\nexport function dialogOverlayClass(className?: string) {\n\treturn cn(\n\t\t\"fixed inset-0 bg-black/40 backdrop-blur-md\",\n\t\tOVERLAY_LAYER,\n\t\t\"data-[state=open]:animate-basalt-overlay-in data-[state=closed]:animate-basalt-overlay-out\",\n\t\tOVERLAY_MOTION,\n\t\tclassName,\n\t);\n}\n\nexport function dialogPanelClass({\n\tsize = \"base\",\n\tclassName,\n}: {\n\tsize?: DialogSize;\n\tclassName?: string;\n} = {}) {\n\treturn cn(\n\t\tBASALT_UI_CLASS,\n\t\t\"fixed top-1/2 left-1/2 w-full max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] origin-center -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-basalt-lg p-6 text-basalt-foreground shadow-lg ring-1 ring-basalt-border\",\n\t\tOVERLAY_LAYER,\n\t\t\"data-[state=open]:animate-basalt-dialog-in data-[state=closed]:animate-basalt-dialog-out\",\n\t\tOVERLAY_MOTION,\n\t\tDIALOG_SIZES[size],\n\t\tclassName,\n\t);\n}\n\ntype RadixDialogProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>;\ntype RadixDialogTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\ntype RadixDialogPortalProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Portal>;\ntype RadixDialogOverlayProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>;\ntype RadixDialogContentProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>;\ntype RadixDialogTitleProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>;\ntype RadixDialogDescriptionProps = React.ComponentPropsWithoutRef<\n\ttypeof DialogPrimitive.Description\n>;\ntype RadixDialogCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\nexport interface DialogProps\n\textends Omit<RadixDialogProps, \"open\" | \"defaultOpen\" | \"onOpenChange\" | \"modal\"> {\n\t/**\n\t * Controlled open state of the dialog.\n\t */\n\topen?: RadixDialogProps[\"open\"];\n\t/**\n\t * Uncontrolled default open state of the dialog on initial render.\n\t * @default false\n\t */\n\tdefaultOpen?: RadixDialogProps[\"defaultOpen\"];\n\t/**\n\t * Callback invoked when the open state changes.\n\t */\n\tonOpenChange?: RadixDialogProps[\"onOpenChange\"];\n\t/**\n\t * Whether the dialog renders modally, preventing outside interaction and hiding background content from screen readers.\n\t * @default true\n\t */\n\tmodal?: RadixDialogProps[\"modal\"];\n}\n\nexport const Dialog: React.FC<DialogProps> = DialogPrimitive.Root;\n\nexport interface DialogTriggerProps extends Omit<RadixDialogTriggerProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered button element to the child element, merging props and behavior.\n\t * Trigger forwards ref to HTMLButtonElement and inherits native button attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogTriggerProps[\"asChild\"];\n}\n\nexport const DialogTrigger = DialogPrimitive.Trigger;\n\nexport interface DialogCloseProps extends Omit<RadixDialogCloseProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered button element to the child element, merging props and behavior.\n\t * Close forwards ref to HTMLButtonElement and inherits native button attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogCloseProps[\"asChild\"];\n}\n\nexport const DialogClose = DialogPrimitive.Close;\n\nexport interface DialogPortalProps\n\textends Omit<RadixDialogPortalProps, \"container\" | \"forceMount\"> {\n\t/**\n\t * Target container element where the dialog overlay and content portal should mount.\n\t */\n\tcontainer?: RadixDialogPortalProps[\"container\"];\n\t/**\n\t * Used to force mounting when controlling transition animations externally.\n\t */\n\tforceMount?: RadixDialogPortalProps[\"forceMount\"];\n}\n\nexport const DialogPortal = DialogPrimitive.Portal;\n\nexport interface DialogOverlayProps\n\textends Omit<RadixDialogOverlayProps, \"asChild\" | \"forceMount\"> {\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * Overlay forwards ref to HTMLDivElement and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogOverlayProps[\"asChild\"];\n\t/**\n\t * Used to force mounting when controlling transition animations externally.\n\t */\n\tforceMount?: RadixDialogOverlayProps[\"forceMount\"];\n}\n\nexport const DialogOverlay = React.forwardRef<\n\tReact.ElementRef<typeof DialogPrimitive.Overlay>,\n\tDialogOverlayProps\n>(({ className, ...props }, ref) => (\n\t<DialogPrimitive.Overlay ref={ref} className={dialogOverlayClass(className)} {...props} />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nexport interface DialogContentProps\n\textends Omit<\n\t\tRadixDialogContentProps,\n\t\t| \"size\"\n\t\t| \"disablePointerDismissal\"\n\t\t| \"asChild\"\n\t\t| \"forceMount\"\n\t\t| \"trapFocus\"\n\t\t| \"onOpenAutoFocus\"\n\t\t| \"onCloseAutoFocus\"\n\t\t| \"onEscapeKeyDown\"\n\t\t| \"onPointerDownOutside\"\n\t\t| \"onFocusOutside\"\n\t\t| \"onInteractOutside\"\n\t> {\n\t/**\n\t * Fixed desktop width preset. Dialog panel scrolls vertically when content overflows available viewport height.\n\t * @default \"base\"\n\t */\n\tsize?: DialogSize;\n\t/**\n\t * When true, pointer interactions outside the dialog panel are prevented from dismissing the dialog.\n\t * @default false\n\t */\n\tdisablePointerDismissal?: boolean;\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * Content forwards ref to HTMLDivElement and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogContentProps[\"asChild\"];\n\t/**\n\t * Force mounting content in DOM for external animation controls.\n\t * When forceMount is true, the content remains mounted even when closed.\n\t * The caller is responsible for visibility transitions and unmounting after animation completes.\n\t * Note: Keeping modal content forceMounted may isolate background interactions until unmounted.\n\t */\n\tforceMount?: RadixDialogContentProps[\"forceMount\"];\n\t/**\n\t * Event handler called when auto-focusing the first element on open. Can be prevented with event.preventDefault().\n\t */\n\tonOpenAutoFocus?: RadixDialogContentProps[\"onOpenAutoFocus\"];\n\t/**\n\t * Event handler called when restoring focus on close. Can be prevented with event.preventDefault().\n\t */\n\tonCloseAutoFocus?: RadixDialogContentProps[\"onCloseAutoFocus\"];\n\t/**\n\t * Event handler called when the Escape key is pressed. Can be prevented with event.preventDefault().\n\t */\n\tonEscapeKeyDown?: RadixDialogContentProps[\"onEscapeKeyDown\"];\n\t/**\n\t * Event handler called when a pointer event occurs outside the dialog bounds.\n\t */\n\tonPointerDownOutside?: RadixDialogContentProps[\"onPointerDownOutside\"];\n\t/**\n\t * Event handler called when focus moves outside the dialog bounds.\n\t */\n\tonFocusOutside?: RadixDialogContentProps[\"onFocusOutside\"];\n\t/**\n\t * Event handler called when any interaction (pointer or focus) occurs outside the dialog bounds.\n\t */\n\tonInteractOutside?: RadixDialogContentProps[\"onInteractOutside\"];\n}\n\nexport const DialogContent = React.forwardRef<\n\tReact.ElementRef<typeof DialogPrimitive.Content>,\n\tDialogContentProps\n>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tchildren,\n\t\t\tsize = \"base\",\n\t\t\tdisablePointerDismissal = false,\n\t\t\tonPointerDownOutside,\n\t\t\tonInteractOutside,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => (\n\t\t<DialogPortal forceMount={props.forceMount}>\n\t\t\t<DialogOverlay forceMount={props.forceMount} />\n\t\t\t<DialogPrimitive.Content\n\t\t\t\tref={ref}\n\t\t\t\tdata-basalt-surface-root=\"\"\n\t\t\t\tclassName={dialogPanelClass({ size, className })}\n\t\t\t\tonPointerDownOutside={(event) => {\n\t\t\t\t\tif (disablePointerDismissal) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t\tonPointerDownOutside?.(event);\n\t\t\t\t}}\n\t\t\t\tonInteractOutside={(event) => {\n\t\t\t\t\tif (disablePointerDismissal) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t\tonInteractOutside?.(event);\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</DialogPrimitive.Content>\n\t\t</DialogPortal>\n\t),\n);\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nexport interface DialogTitleProps extends Omit<RadixDialogTitleProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered heading element to the child element, merging props and behavior.\n\t * Title forwards ref to HTMLHeadingElement and inherits native h2 attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogTitleProps[\"asChild\"];\n}\n\nexport const DialogTitle = React.forwardRef<\n\tReact.ElementRef<typeof DialogPrimitive.Title>,\n\tDialogTitleProps\n>(({ className, ...props }, ref) => (\n\t<DialogPrimitive.Title\n\t\tref={ref}\n\t\tclassName={cn(\"text-2xl font-semibold tracking-tight\", className)}\n\t\t{...props}\n\t/>\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nexport interface DialogDescriptionProps extends Omit<RadixDialogDescriptionProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered paragraph element to the child element, merging props and behavior.\n\t * Description forwards ref to HTMLParagraphElement and inherits native p attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogDescriptionProps[\"asChild\"];\n}\n\nexport const DialogDescription = React.forwardRef<\n\tReact.ElementRef<typeof DialogPrimitive.Description>,\n\tDialogDescriptionProps\n>(({ className, ...props }, ref) => (\n\t<DialogPrimitive.Description\n\t\tref={ref}\n\t\tclassName={cn(\"text-base text-basalt-muted-foreground\", className)}\n\t\t{...props}\n\t/>\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport interface DialogHeaderProps extends React.HTMLAttributes<HTMLDivElement> {}\n\nexport const DialogHeader = ({ className, ...props }: DialogHeaderProps) => (\n\t<div className={cn(\"flex flex-col space-y-1.5 text-left\", className)} {...props} />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nexport interface DialogFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\nexport const DialogFooter = ({ className, ...props }: DialogFooterProps) => (\n\t<div\n\t\tclassName={cn(\"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\", className)}\n\t\t{...props}\n\t/>\n);\nDialogFooter.displayName = \"DialogFooter\";\n"],"mappings":";;;;;;;;AAMA,IAAa,IAAe;CAC3B,IAAI;CACJ,MAAM;CACN,IAAI;CACJ,IAAI;AACL;AAIA,SAAgB,EAAmB,GAAoB;CACtD,OAAO,EACN,8CACA,GACA,8FACA,GACA,CACD;AACD;AAEA,SAAgB,EAAiB,EAChC,UAAO,QACP,iBAIG,CAAC,GAAG;CACP,OAAO,EACN,GACA,oOACA,GACA,4FACA,GACA,EAAa,IACb,CACD;AACD;AAmCA,IAAa,IAAgC,EAAgB,MAWhD,IAAgB,EAAgB,SAWhC,IAAc,EAAgB,OAc9B,IAAe,EAAgB,QAgB/B,IAAgB,EAAM,YAGhC,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAgB,SAAjB;CAA8B;CAAK,WAAW,EAAmB,CAAS;CAAG,GAAI;AAAQ,CAAA,CACzF;AACD,EAAc,cAAc,EAAgB,QAAQ;AAkEpD,IAAa,IAAgB,EAAM,YAKjC,EACC,cACA,aACA,UAAO,QACP,6BAA0B,IAC1B,yBACA,sBACA,GAAG,KAEJ,MAEA,kBAAC,GAAD;CAAc,YAAY,EAAM;CAAhC,UAAA,CACC,kBAAC,GAAD,EAAe,YAAY,EAAM,WAAa,CAAA,GAC9C,kBAAC,EAAgB,SAAjB;EACM;EACL,4BAAyB;EACzB,WAAW,EAAiB;GAAE;GAAM;EAAU,CAAC;EAC/C,uBAAuB,MAAU;GAIhC,AAHI,KACH,EAAM,eAAe,GAEtB,IAAuB,CAAK;EAC7B;EACA,oBAAoB,MAAU;GAI7B,AAHI,KACH,EAAM,eAAe,GAEtB,IAAoB,CAAK;EAC1B;EACA,GAAI;EAEH;CACuB,CAAA,CACZ;AAEhB,CAAA,CAAA;AACA,EAAc,cAAc,EAAgB,QAAQ;AAWpD,IAAa,IAAc,EAAM,YAG9B,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAgB,OAAjB;CACM;CACL,WAAW,EAAG,yCAAyC,CAAS;CAChE,GAAI;AACJ,CAAA,CACD;AACD,EAAY,cAAc,EAAgB,MAAM;AAWhD,IAAa,IAAoB,EAAM,YAGpC,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAgB,aAAjB;CACM;CACL,WAAW,EAAG,0CAA0C,CAAS;CACjE,GAAI;AACJ,CAAA,CACD;AACD,EAAkB,cAAc,EAAgB,YAAY;AAI5D,IAAa,KAAgB,EAAE,cAAW,GAAG,QAC5C,kBAAC,OAAD;CAAK,WAAW,EAAG,uCAAuC,CAAS;CAAG,GAAI;AAAQ,CAAA;AAEnF,EAAa,cAAc;AAI3B,IAAa,KAAgB,EAAE,cAAW,GAAG,QAC5C,kBAAC,OAAD;CACC,WAAW,EAAG,+DAA+D,CAAS;CACtF,GAAI;AACJ,CAAA;AAEF,EAAa,cAAc"}
|
|
1
|
+
{"version":3,"file":"dialog.js","names":["React","DialogPrimitive","DIALOG_SIZES","dialogOverlayClass","cn","OVERLAY_LAYER","OVERLAY_MOTION","className","dialogPanelClass","BASALT_UI_CLASS","size","Dialog","DialogTrigger","DialogClose","DialogPortal","DialogOverlay","props","DialogContent","disablePointerDismissal","event","onPointerDownOutside","onInteractOutside","DialogTitle","DialogDescription","DialogHeader","DialogFooter"],"sources":["../../src/components/dialog.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { BASALT_UI_CLASS } from \"../utils/control-surface\";\nimport { OVERLAY_LAYER, OVERLAY_MOTION } from \"./overlay\";\n\nexport const DIALOG_SIZES = {\n\tsm: \"sm:w-72\",\n\tbase: \"sm:w-96\",\n\tlg: \"sm:w-[32rem]\",\n\txl: \"sm:w-[48rem]\",\n} as const;\n\nexport type DialogSize = keyof typeof DIALOG_SIZES;\n\nexport function dialogOverlayClass(className?: string) {\n\treturn cn(\n\t\t\"fixed inset-0 bg-black/40 backdrop-blur-md\",\n\t\tOVERLAY_LAYER,\n\t\t\"data-[state=open]:animate-basalt-overlay-in data-[state=closed]:animate-basalt-overlay-out\",\n\t\tOVERLAY_MOTION,\n\t\tclassName,\n\t);\n}\n\nexport function dialogPanelClass({\n\tsize = \"base\",\n\tclassName,\n}: {\n\tsize?: DialogSize;\n\tclassName?: string;\n} = {}) {\n\treturn cn(\n\t\tBASALT_UI_CLASS,\n\t\t\"fixed top-1/2 left-1/2 w-full max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] origin-center -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-basalt-lg p-6 text-basalt-foreground shadow-lg ring-1 ring-basalt-border\",\n\t\tOVERLAY_LAYER,\n\t\t\"data-[state=open]:animate-basalt-dialog-in data-[state=closed]:animate-basalt-dialog-out\",\n\t\tOVERLAY_MOTION,\n\t\tDIALOG_SIZES[size],\n\t\tclassName,\n\t);\n}\n\ntype RadixDialogProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>;\ntype RadixDialogTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\ntype RadixDialogPortalProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Portal>;\ntype RadixDialogOverlayProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>;\ntype RadixDialogContentProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>;\ntype RadixDialogTitleProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>;\ntype RadixDialogDescriptionProps = React.ComponentPropsWithoutRef<\n\ttypeof DialogPrimitive.Description\n>;\ntype RadixDialogCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\nexport interface DialogProps\n\textends Omit<RadixDialogProps, \"open\" | \"defaultOpen\" | \"onOpenChange\" | \"modal\"> {\n\t/**\n\t * Controlled open state of the dialog.\n\t */\n\topen?: RadixDialogProps[\"open\"];\n\t/**\n\t * Uncontrolled default open state of the dialog on initial render.\n\t * @default false\n\t */\n\tdefaultOpen?: RadixDialogProps[\"defaultOpen\"];\n\t/**\n\t * Callback invoked when the open state changes.\n\t */\n\tonOpenChange?: RadixDialogProps[\"onOpenChange\"];\n\t/**\n\t * Whether the dialog renders modally, preventing outside interaction and hiding background content from screen readers.\n\t * @default true\n\t */\n\tmodal?: RadixDialogProps[\"modal\"];\n}\n\nexport const Dialog: React.FC<DialogProps> = DialogPrimitive.Root;\n\nexport interface DialogTriggerProps extends Omit<RadixDialogTriggerProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered button element to the child element, merging props and behavior.\n\t * Trigger forwards ref to HTMLButtonElement and inherits native button attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogTriggerProps[\"asChild\"];\n}\n\nexport const DialogTrigger = DialogPrimitive.Trigger;\n\nexport interface DialogCloseProps extends Omit<RadixDialogCloseProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered button element to the child element, merging props and behavior.\n\t * Close forwards ref to HTMLButtonElement and inherits native button attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogCloseProps[\"asChild\"];\n}\n\nexport const DialogClose = DialogPrimitive.Close;\n\nexport interface DialogPortalProps\n\textends Omit<RadixDialogPortalProps, \"container\" | \"forceMount\"> {\n\t/**\n\t * Target container element where the dialog overlay and content portal should mount.\n\t */\n\tcontainer?: RadixDialogPortalProps[\"container\"];\n\t/**\n\t * Used to force mounting when controlling transition animations externally.\n\t */\n\tforceMount?: RadixDialogPortalProps[\"forceMount\"];\n}\n\nexport const DialogPortal = DialogPrimitive.Portal;\n\nexport interface DialogOverlayProps\n\textends Omit<RadixDialogOverlayProps, \"asChild\" | \"forceMount\"> {\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * Overlay forwards ref to HTMLDivElement and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogOverlayProps[\"asChild\"];\n\t/**\n\t * Used to force mounting when controlling transition animations externally.\n\t */\n\tforceMount?: RadixDialogOverlayProps[\"forceMount\"];\n}\n\nexport const DialogOverlay = React.forwardRef<\n\tReact.ElementRef<typeof DialogPrimitive.Overlay>,\n\tDialogOverlayProps\n>(({ className, ...props }, ref) => (\n\t<DialogPrimitive.Overlay ref={ref} className={dialogOverlayClass(className)} {...props} />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nexport interface DialogContentProps\n\textends Omit<\n\t\tRadixDialogContentProps,\n\t\t| \"size\"\n\t\t| \"disablePointerDismissal\"\n\t\t| \"asChild\"\n\t\t| \"forceMount\"\n\t\t| \"trapFocus\"\n\t\t| \"onOpenAutoFocus\"\n\t\t| \"onCloseAutoFocus\"\n\t\t| \"onEscapeKeyDown\"\n\t\t| \"onPointerDownOutside\"\n\t\t| \"onFocusOutside\"\n\t\t| \"onInteractOutside\"\n\t> {\n\t/**\n\t * Fixed desktop width preset. Dialog panel scrolls vertically when content overflows available viewport height.\n\t * @default \"base\"\n\t */\n\tsize?: DialogSize;\n\t/**\n\t * When true, pointer interactions outside the dialog panel are prevented from dismissing the dialog.\n\t * @default false\n\t */\n\tdisablePointerDismissal?: boolean;\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * Content forwards ref to HTMLDivElement and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogContentProps[\"asChild\"];\n\t/**\n\t * Force mounting content in DOM for external animation controls.\n\t * When forceMount is true, the content remains mounted even when closed.\n\t * The caller is responsible for visibility transitions and unmounting after animation completes.\n\t * Note: Keeping modal content forceMounted may isolate background interactions until unmounted.\n\t */\n\tforceMount?: RadixDialogContentProps[\"forceMount\"];\n\t/**\n\t * Event handler called when auto-focusing the first element on open. Can be prevented with event.preventDefault().\n\t */\n\tonOpenAutoFocus?: RadixDialogContentProps[\"onOpenAutoFocus\"];\n\t/**\n\t * Event handler called when restoring focus on close. Can be prevented with event.preventDefault().\n\t */\n\tonCloseAutoFocus?: RadixDialogContentProps[\"onCloseAutoFocus\"];\n\t/**\n\t * Event handler called when the Escape key is pressed. Can be prevented with event.preventDefault().\n\t */\n\tonEscapeKeyDown?: RadixDialogContentProps[\"onEscapeKeyDown\"];\n\t/**\n\t * Event handler called when a pointer event occurs outside the dialog bounds.\n\t */\n\tonPointerDownOutside?: RadixDialogContentProps[\"onPointerDownOutside\"];\n\t/**\n\t * Event handler called when focus moves outside the dialog bounds.\n\t */\n\tonFocusOutside?: RadixDialogContentProps[\"onFocusOutside\"];\n\t/**\n\t * Event handler called when any interaction (pointer or focus) occurs outside the dialog bounds.\n\t */\n\tonInteractOutside?: RadixDialogContentProps[\"onInteractOutside\"];\n}\n\nexport const DialogContent = React.forwardRef<\n\tReact.ElementRef<typeof DialogPrimitive.Content>,\n\tDialogContentProps\n>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tchildren,\n\t\t\tsize = \"base\",\n\t\t\tdisablePointerDismissal = false,\n\t\t\tonPointerDownOutside,\n\t\t\tonInteractOutside,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => (\n\t\t<DialogPortal forceMount={props.forceMount}>\n\t\t\t<DialogOverlay forceMount={props.forceMount} />\n\t\t\t<DialogPrimitive.Content\n\t\t\t\tref={ref}\n\t\t\t\tdata-basalt-surface-root=\"\"\n\t\t\t\tclassName={dialogPanelClass({ size, className })}\n\t\t\t\tonPointerDownOutside={(event) => {\n\t\t\t\t\tif (disablePointerDismissal) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t\tonPointerDownOutside?.(event);\n\t\t\t\t}}\n\t\t\t\tonInteractOutside={(event) => {\n\t\t\t\t\tif (disablePointerDismissal) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t\tonInteractOutside?.(event);\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</DialogPrimitive.Content>\n\t\t</DialogPortal>\n\t),\n);\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nexport interface DialogTitleProps extends Omit<RadixDialogTitleProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered heading element to the child element, merging props and behavior.\n\t * Title forwards ref to HTMLHeadingElement and inherits native h2 attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogTitleProps[\"asChild\"];\n}\n\nexport const DialogTitle = React.forwardRef<\n\tReact.ElementRef<typeof DialogPrimitive.Title>,\n\tDialogTitleProps\n>(({ className, ...props }, ref) => (\n\t<DialogPrimitive.Title\n\t\tref={ref}\n\t\tclassName={cn(\"text-2xl font-semibold tracking-tight\", className)}\n\t\t{...props}\n\t/>\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nexport interface DialogDescriptionProps extends Omit<RadixDialogDescriptionProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered paragraph element to the child element, merging props and behavior.\n\t * Description forwards ref to HTMLParagraphElement and inherits native p attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogDescriptionProps[\"asChild\"];\n}\n\nexport const DialogDescription = React.forwardRef<\n\tReact.ElementRef<typeof DialogPrimitive.Description>,\n\tDialogDescriptionProps\n>(({ className, ...props }, ref) => (\n\t<DialogPrimitive.Description\n\t\tref={ref}\n\t\tclassName={cn(\"text-base text-basalt-muted-foreground\", className)}\n\t\t{...props}\n\t/>\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport interface DialogHeaderProps extends React.HTMLAttributes<HTMLDivElement> {}\n\nexport const DialogHeader = ({ className, ...props }: DialogHeaderProps) => (\n\t<div className={cn(\"flex flex-col space-y-1.5 text-left\", className)} {...props} />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nexport interface DialogFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\nexport const DialogFooter = ({ className, ...props }: DialogFooterProps) => (\n\t<div\n\t\tclassName={cn(\"mt-6 flex flex-col-reverse gap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