@nocoo/basalt 2.1.2 → 2.1.7
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 +17 -1
- package/ai/USAGE.md +1 -1
- package/ai/registry.json +75 -75
- package/dist/charts/charts.d.ts +1 -1
- package/dist/charts/charts.js +3 -16
- package/dist/charts/charts.js.map +1 -1
- package/dist/charts/custom-chart.d.ts +1 -1
- package/dist/charts/custom-chart.js +3 -16
- package/dist/charts/custom-chart.js.map +1 -1
- package/dist/charts/grouped-bar.d.ts +1 -1
- package/dist/charts/grouped-bar.js +11 -48
- package/dist/charts/grouped-bar.js.map +1 -1
- package/dist/charts/heatmap-calendar.js +80 -136
- package/dist/charts/heatmap-calendar.js.map +1 -1
- package/dist/charts/slot-bar.js +2 -12
- package/dist/charts/slot-bar.js.map +1 -1
- package/dist/charts/stat-card.js +2 -7
- package/dist/charts/stat-card.js.map +1 -1
- package/dist/charts/timeseries.d.ts +1 -1
- package/dist/charts/timeseries.js +3 -16
- package/dist/charts/timeseries.js.map +1 -1
- package/dist/charts/tooltip.js +13 -51
- package/dist/charts/tooltip.js.map +1 -1
- package/dist/components/autocomplete.d.ts +1 -1
- package/dist/components/autocomplete.js +3 -16
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/banner.js +28 -28
- package/dist/components/banner.js.map +1 -1
- package/dist/components/button.js +6 -7
- package/dist/components/button.js.map +1 -1
- package/dist/components/chat-composer.js +1 -2
- package/dist/components/chat-composer.js.map +1 -1
- package/dist/components/checkbox.js +50 -82
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/code.js +1 -1
- package/dist/components/code.js.map +1 -1
- package/dist/components/combobox.d.ts +1 -1
- package/dist/components/combobox.js +3 -16
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/context-menu.d.ts +1 -67
- package/dist/components/context-menu.js.map +1 -1
- package/dist/components/data-table.js +111 -123
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.js +236 -245
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/dock.js +15 -16
- package/dist/components/dock.js.map +1 -1
- package/dist/components/field.js +20 -23
- package/dist/components/field.js.map +1 -1
- package/dist/components/layer-card.d.ts +1 -1
- package/dist/components/layer-card.js +44 -51
- package/dist/components/layer-card.js.map +1 -1
- package/dist/components/skeleton-line.d.ts +2 -2
- package/dist/components/skeleton-line.js +1 -1
- package/dist/components/skeleton-line.js.map +1 -1
- package/dist/components/switch.js +46 -78
- package/dist/components/switch.js.map +1 -1
- package/dist/providers/accent.js +89 -198
- package/dist/providers/accent.js.map +1 -1
- package/dist/providers/theme.js +46 -144
- package/dist/providers/theme.js.map +1 -1
- package/dist/utils/preference-store.d.ts +16 -0
- package/dist/utils/preference-store.js +106 -0
- package/dist/utils/preference-store.js.map +1 -0
- package/dist/utils/use-checkable-group.d.ts +19 -0
- package/dist/utils/use-checkable-group.js +61 -0
- package/dist/utils/use-checkable-group.js.map +1 -0
- package/package.json +1 -2
|
@@ -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 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\tif (next.y !== activeMonth.y || next.m !== activeMonth.m) {\n\t\t\t\t\t\t\t\tpendingFocus.current = {\n\t\t\t\t\t\t\t\t\ttargetMonthKey: formatIsoMonth(next),\n\t\t\t\t\t\t\t\t\tiso: formatIso(next),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\trequestMonth({ y: next.y, m: next.m, d: 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\tconst index = days.findIndex((date) => isoOf(date) === formatIso(next));\n\t\t\t\t\t\t\tif (index >= 0) {\n\t\t\t\t\t\t\t\tsetFocusIndex(index);\n\t\t\t\t\t\t\t\tdayRefs.current[index]?.focus();\n\t\t\t\t\t\t\t}\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\tif (next.y !== activeMonth.y || next.m !== activeMonth.m) {\n\t\t\t\t\t\t\t\tpendingFocus.current = {\n\t\t\t\t\t\t\t\t\ttargetMonthKey: formatIsoMonth(next),\n\t\t\t\t\t\t\t\t\tiso: formatIso(next),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\trequestMonth({ y: next.y, m: next.m, d: 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\tconst index = days.findIndex((date) => isoOf(date) === formatIso(next));\n\t\t\t\t\t\t\tif (index >= 0) {\n\t\t\t\t\t\t\t\tsetFocusIndex(index);\n\t\t\t\t\t\t\t\tdayRefs.current[index]?.focus();\n\t\t\t\t\t\t\t}\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\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AAC,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":[],"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,eAAe,EAAK,CAAC,GACnB;AACR;AAEA,SAAS,EAAU,GAAa;CAC/B,IAAM,IAAO,IAAI,KAAK,EAAK,GAAG,EAAK,IAAI,GAAG,EA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Q,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"}
|
package/dist/components/dock.js
CHANGED
|
@@ -21,20 +21,20 @@ function d({ className: t, children: n }) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
function f({ open: l, mode: d = "push", width: f = "clamp(300px, 32.5vw, 546px)", onDismiss: p, dismissLabel: m = "Dismiss", className: h, children: g, "aria-label": _ }) {
|
|
24
|
-
let v = d === "overlay", y = o(null), b =
|
|
24
|
+
let v = d === "overlay", y = o(null), b = (e) => {
|
|
25
25
|
y.current = e;
|
|
26
|
-
},
|
|
26
|
+
}, x = o(!v && l), S = o(null);
|
|
27
27
|
a(() => {
|
|
28
28
|
if (l) {
|
|
29
|
-
if (
|
|
30
|
-
|
|
29
|
+
if (x.current) return;
|
|
30
|
+
S.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
31
31
|
let e = window.setTimeout(() => {
|
|
32
32
|
let e = y.current;
|
|
33
|
-
(u(e)[0] ?? e)?.focus(),
|
|
33
|
+
(u(e)[0] ?? e)?.focus(), x.current = !0;
|
|
34
34
|
}, 0);
|
|
35
35
|
return () => window.clearTimeout(e);
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
x.current &&= (S.current?.focus?.(), S.current = null, !1);
|
|
38
38
|
}, [l]), a(() => {
|
|
39
39
|
if (!v || !l) return;
|
|
40
40
|
let e = (e) => {
|
|
@@ -49,13 +49,12 @@ function f({ open: l, mode: d = "push", width: f = "clamp(300px, 32.5vw, 546px)"
|
|
|
49
49
|
l,
|
|
50
50
|
p
|
|
51
51
|
]);
|
|
52
|
-
let
|
|
52
|
+
let C = e("overflow-hidden bg-basalt-background transition-[width] duration-300 ease-in-out", v ? e("absolute top-0 right-0 h-full", n) : "sticky top-0 h-screen shrink-0", r, h), w = { width: l ? f : 0 }, T = /* @__PURE__ */ s("div", {
|
|
53
53
|
className: "flex h-full flex-col bg-basalt-card shadow-lg ring-1 ring-basalt-border/40",
|
|
54
54
|
style: { width: f },
|
|
55
55
|
children: g
|
|
56
56
|
});
|
|
57
57
|
return v ? /* @__PURE__ */ c("div", {
|
|
58
|
-
ref: b,
|
|
59
58
|
className: e("absolute inset-0", n, !l && "pointer-events-none"),
|
|
60
59
|
children: [p ? /* @__PURE__ */ s("button", {
|
|
61
60
|
type: "button",
|
|
@@ -70,25 +69,25 @@ function f({ open: l, mode: d = "push", width: f = "clamp(300px, 32.5vw, 546px)"
|
|
|
70
69
|
"data-state": l ? "open" : "closed",
|
|
71
70
|
className: e(i("absolute"), !l && "opacity-0")
|
|
72
71
|
}), /* @__PURE__ */ s("div", {
|
|
73
|
-
ref:
|
|
72
|
+
ref: b,
|
|
74
73
|
role: "region",
|
|
75
74
|
"aria-label": _,
|
|
76
|
-
className: e(t,
|
|
77
|
-
style:
|
|
75
|
+
className: e(t, C),
|
|
76
|
+
style: w,
|
|
78
77
|
"aria-hidden": !l,
|
|
79
78
|
inert: !l || void 0,
|
|
80
79
|
tabIndex: l ? -1 : void 0,
|
|
81
|
-
children:
|
|
80
|
+
children: T
|
|
82
81
|
})]
|
|
83
82
|
}) : /* @__PURE__ */ s("aside", {
|
|
84
|
-
ref:
|
|
85
|
-
className: e(t,
|
|
86
|
-
style:
|
|
83
|
+
ref: b,
|
|
84
|
+
className: e(t, C),
|
|
85
|
+
style: w,
|
|
87
86
|
"aria-label": _,
|
|
88
87
|
"aria-hidden": !l,
|
|
89
88
|
inert: !l || void 0,
|
|
90
89
|
tabIndex: l ? -1 : void 0,
|
|
91
|
-
children:
|
|
90
|
+
children: T
|
|
92
91
|
});
|
|
93
92
|
}
|
|
94
93
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dock.js","names":[],"sources":["../../src/components/dock.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useRef } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { BASALT_UI_CLASS } from \"../utils/control-surface\";\nimport { dialogOverlayClass } from \"./dialog\";\nimport { OVERLAY_LAYER, OVERLAY_MOTION } from \"./overlay\";\n\nconst FOCUSABLE =\n\t'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\nfunction tabbables(root: HTMLElement | null) {\n\tif (!root) {\n\t\treturn [];\n\t}\n\treturn [...root.querySelectorAll<HTMLElement>(FOCUSABLE)].filter((node) => {\n\t\tif (node.closest(\"[inert], [hidden]\")) {\n\t\t\treturn false;\n\t\t}\n\t\tif (node.tabIndex < 0) {\n\t\t\treturn false;\n\t\t}\n\t\tif (window.getComputedStyle(node).visibility === \"hidden\") {\n\t\t\treturn false;\n\t\t}\n\t\tfor (let current: HTMLElement | null = node; current; current = current.parentElement) {\n\t\t\tif (window.getComputedStyle(current).display === \"none\") {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t});\n}\n\nexport type DockMode = \"overlay\" | \"push\";\n\nexport interface DockProps {\n\t/**\n\t * Whether the dock occupies its width.\n\t */\n\topen: boolean;\n\t/**\n\t * `push` shrinks the main column. `overlay` covers the local region with a non-modal scrim.\n\t * @default \"push\"\n\t */\n\tmode?: DockMode;\n\t/**\n\t * Width when open.\n\t * @default \"clamp(300px, 32.5vw, 546px)\"\n\t */\n\twidth?: string;\n\t/**\n\t * Overlay scrim click. Ignored in push mode.\n\t */\n\tonDismiss?: () => void;\n\t/**\n\t * Overlay scrim accessible name.\n\t * @default \"Dismiss\"\n\t */\n\tdismissLabel?: string;\n\t/**\n\t * Accessible name.\n\t */\n\t\"aria-label\": string;\n\tclassName?: string;\n\tchildren: ReactNode;\n}\n\nexport interface DockBodyProps {\n\tclassName?: string;\n\tchildren: ReactNode;\n}\n\nexport function DockBody({ className, children }: DockBodyProps) {\n\treturn (\n\t\t<div className={cn(\"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 py-3\", className)}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\nexport function Dock({\n\topen,\n\tmode = \"push\",\n\twidth = \"clamp(300px, 32.5vw, 546px)\",\n\tonDismiss,\n\tdismissLabel = \"Dismiss\",\n\tclassName,\n\tchildren,\n\t\"aria-label\": ariaLabel,\n}: DockProps) {\n\tconst overlay = mode === \"overlay\";\n\tconst panelRef = useRef<HTMLElement | null>(null);\n\tconst
|
|
1
|
+
{"version":3,"file":"dock.js","names":[],"sources":["../../src/components/dock.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useRef } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { BASALT_UI_CLASS } from \"../utils/control-surface\";\nimport { dialogOverlayClass } from \"./dialog\";\nimport { OVERLAY_LAYER, OVERLAY_MOTION } from \"./overlay\";\n\nconst FOCUSABLE =\n\t'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\nfunction tabbables(root: HTMLElement | null) {\n\tif (!root) {\n\t\treturn [];\n\t}\n\treturn [...root.querySelectorAll<HTMLElement>(FOCUSABLE)].filter((node) => {\n\t\tif (node.closest(\"[inert], [hidden]\")) {\n\t\t\treturn false;\n\t\t}\n\t\tif (node.tabIndex < 0) {\n\t\t\treturn false;\n\t\t}\n\t\tif (window.getComputedStyle(node).visibility === \"hidden\") {\n\t\t\treturn false;\n\t\t}\n\t\tfor (let current: HTMLElement | null = node; current; current = current.parentElement) {\n\t\t\tif (window.getComputedStyle(current).display === \"none\") {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t});\n}\n\nexport type DockMode = \"overlay\" | \"push\";\n\nexport interface DockProps {\n\t/**\n\t * Whether the dock occupies its width.\n\t */\n\topen: boolean;\n\t/**\n\t * `push` shrinks the main column. `overlay` covers the local region with a non-modal scrim.\n\t * @default \"push\"\n\t */\n\tmode?: DockMode;\n\t/**\n\t * Width when open.\n\t * @default \"clamp(300px, 32.5vw, 546px)\"\n\t */\n\twidth?: string;\n\t/**\n\t * Overlay scrim click. Ignored in push mode.\n\t */\n\tonDismiss?: () => void;\n\t/**\n\t * Overlay scrim accessible name.\n\t * @default \"Dismiss\"\n\t */\n\tdismissLabel?: string;\n\t/**\n\t * Accessible name.\n\t */\n\t\"aria-label\": string;\n\tclassName?: string;\n\tchildren: ReactNode;\n}\n\nexport interface DockBodyProps {\n\tclassName?: string;\n\tchildren: ReactNode;\n}\n\nexport function DockBody({ className, children }: DockBodyProps) {\n\treturn (\n\t\t<div className={cn(\"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 py-3\", className)}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\nexport function Dock({\n\topen,\n\tmode = \"push\",\n\twidth = \"clamp(300px, 32.5vw, 546px)\",\n\tonDismiss,\n\tdismissLabel = \"Dismiss\",\n\tclassName,\n\tchildren,\n\t\"aria-label\": ariaLabel,\n}: DockProps) {\n\tconst overlay = mode === \"overlay\";\n\tconst panelRef = useRef<HTMLElement | null>(null);\n\tconst setPanel = (node: HTMLElement | null) => {\n\t\tpanelRef.current = node;\n\t};\n\tconst wasOpen = useRef(!overlay && open);\n\tconst previousFocus = useRef<HTMLElement | null>(null);\n\n\tuseEffect(() => {\n\t\tif (open) {\n\t\t\tif (wasOpen.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpreviousFocus.current =\n\t\t\t\tdocument.activeElement instanceof HTMLElement ? document.activeElement : null;\n\t\t\tconst timer = window.setTimeout(() => {\n\t\t\t\tconst root = panelRef.current;\n\t\t\t\tconst nodes = tabbables(root);\n\t\t\t\t(nodes[0] ?? root)?.focus();\n\t\t\t\twasOpen.current = true;\n\t\t\t}, 0);\n\t\t\treturn () => window.clearTimeout(timer);\n\t\t}\n\t\tif (wasOpen.current) {\n\t\t\tpreviousFocus.current?.focus?.();\n\t\t\tpreviousFocus.current = null;\n\t\t\twasOpen.current = false;\n\t\t}\n\t}, [open]);\n\n\tuseEffect(() => {\n\t\tif (!overlay || !open) {\n\t\t\treturn;\n\t\t}\n\t\tconst onKeyDown = (event: KeyboardEvent) => {\n\t\t\tif (event.key === \"Escape\") {\n\t\t\t\tif (event.defaultPrevented || !onDismiss) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonDismiss();\n\t\t\t}\n\t\t};\n\t\twindow.addEventListener(\"keydown\", onKeyDown);\n\t\treturn () => window.removeEventListener(\"keydown\", onKeyDown);\n\t}, [overlay, open, onDismiss]);\n\tconst panelClass = cn(\n\t\t\"overflow-hidden bg-basalt-background transition-[width] duration-300 ease-in-out\",\n\t\toverlay ? cn(\"absolute top-0 right-0 h-full\", OVERLAY_LAYER) : \"sticky top-0 h-screen shrink-0\",\n\t\tOVERLAY_MOTION,\n\t\tclassName,\n\t);\n\tconst panelStyle = { width: open ? width : 0 };\n\tconst inner = (\n\t\t<div\n\t\t\tclassName=\"flex h-full flex-col bg-basalt-card shadow-lg ring-1 ring-basalt-border/40\"\n\t\t\tstyle={{ width }}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n\n\tif (!overlay) {\n\t\treturn (\n\t\t\t<aside\n\t\t\t\tref={setPanel}\n\t\t\t\tclassName={cn(BASALT_UI_CLASS, panelClass)}\n\t\t\t\tstyle={panelStyle}\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\taria-hidden={!open}\n\t\t\t\tinert={!open || undefined}\n\t\t\t\ttabIndex={open ? -1 : undefined}\n\t\t\t>\n\t\t\t\t{inner}\n\t\t\t</aside>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className={cn(\"absolute inset-0\", OVERLAY_LAYER, !open && \"pointer-events-none\")}>\n\t\t\t{onDismiss ? (\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\ttabIndex={open ? 0 : -1}\n\t\t\t\t\taria-label={dismissLabel}\n\t\t\t\t\taria-hidden={!open}\n\t\t\t\t\tdata-state={open ? \"open\" : \"closed\"}\n\t\t\t\t\tclassName={cn(dialogOverlayClass(\"absolute\"), !open && \"opacity-0\")}\n\t\t\t\t\tonClick={open ? onDismiss : undefined}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<div\n\t\t\t\t\taria-hidden\n\t\t\t\t\tdata-state={open ? \"open\" : \"closed\"}\n\t\t\t\t\tclassName={cn(dialogOverlayClass(\"absolute\"), !open && \"opacity-0\")}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tref={setPanel}\n\t\t\t\trole=\"region\"\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\tclassName={cn(BASALT_UI_CLASS, panelClass)}\n\t\t\t\tstyle={panelStyle}\n\t\t\t\taria-hidden={!open}\n\t\t\t\tinert={!open || undefined}\n\t\t\t\ttabIndex={open ? -1 : undefined}\n\t\t\t>\n\t\t\t\t{inner}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAMA,IAAM,IACL;AAED,SAAS,EA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
|
package/dist/components/field.js
CHANGED
|
@@ -11,43 +11,40 @@ function o(e) {
|
|
|
11
11
|
function s(e) {
|
|
12
12
|
if (e != null) return o(e) ? e.message : e;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
var l = r.forwardRef(({ label: o, htmlFor: l, hint: u, error: d, required: f, labelTooltip: p, className: m, children: h, ...g }, _) => {
|
|
18
|
-
let v = r.useId(), y = r.isValidElement(h) ? h : null, b = y ? l ?? y.props.id ?? v : l, x = b ? `${b}-hint` : void 0, S = b ? `${b}-error` : void 0, C = s(d), w = c(C), T = [[w ? S : null, !w && u ? x : null].filter(Boolean).join(" "), y?.props["aria-describedby"]].filter(Boolean).join(" ");
|
|
14
|
+
var c = r.forwardRef(({ label: o, htmlFor: c, hint: l, error: u, required: d, labelTooltip: f, className: p, children: m, ...h }, g) => {
|
|
15
|
+
let _ = r.useId(), v = r.isValidElement(m) ? m : null, y = v ? c ?? v.props.id ?? _ : c, b = y ? `${y}-hint` : void 0, x = y ? `${y}-error` : void 0, S = s(u), C = !!S, w = [[C ? x : null, !C && l ? b : null].filter(Boolean).join(" "), v?.props["aria-describedby"]].filter(Boolean).join(" ");
|
|
19
16
|
return /* @__PURE__ */ a("div", {
|
|
20
|
-
ref:
|
|
21
|
-
...
|
|
22
|
-
className: e(t, "flex flex-col gap-1.5",
|
|
17
|
+
ref: g,
|
|
18
|
+
...h,
|
|
19
|
+
className: e(t, "flex flex-col gap-1.5", p),
|
|
23
20
|
children: [
|
|
24
21
|
/* @__PURE__ */ i(n, {
|
|
25
|
-
htmlFor:
|
|
26
|
-
showOptional:
|
|
27
|
-
tooltip:
|
|
22
|
+
htmlFor: y,
|
|
23
|
+
showOptional: d === !1,
|
|
24
|
+
tooltip: f,
|
|
28
25
|
children: o
|
|
29
26
|
}),
|
|
30
|
-
|
|
27
|
+
v ? r.cloneElement(v, {
|
|
28
|
+
id: y,
|
|
29
|
+
"aria-invalid": C ? !0 : v.props["aria-invalid"],
|
|
30
|
+
"aria-describedby": w || void 0
|
|
31
|
+
}) : m,
|
|
32
|
+
l && !C ? /* @__PURE__ */ i("p", {
|
|
31
33
|
id: b,
|
|
32
|
-
"aria-invalid": w ? !0 : y.props["aria-invalid"],
|
|
33
|
-
"aria-describedby": T || void 0
|
|
34
|
-
}) : h,
|
|
35
|
-
u && !w ? /* @__PURE__ */ i("p", {
|
|
36
|
-
id: x,
|
|
37
34
|
className: "text-xs text-basalt-muted-foreground",
|
|
38
|
-
children:
|
|
35
|
+
children: l
|
|
39
36
|
}) : null,
|
|
40
|
-
|
|
41
|
-
id:
|
|
37
|
+
C ? /* @__PURE__ */ i("p", {
|
|
38
|
+
id: x,
|
|
42
39
|
className: "text-xs text-basalt-destructive",
|
|
43
40
|
role: "alert",
|
|
44
|
-
children:
|
|
41
|
+
children: S
|
|
45
42
|
}) : null
|
|
46
43
|
]
|
|
47
44
|
});
|
|
48
45
|
});
|
|
49
|
-
|
|
46
|
+
c.displayName = "Field";
|
|
50
47
|
//#endregion
|
|
51
|
-
export {
|
|
48
|
+
export { c as Field };
|
|
52
49
|
|
|
53
50
|
//# sourceMappingURL=field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","names":[],"sources":["../../src/components/field.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { BASALT_UI_CLASS } from \"../utils/control-surface\";\nimport { Label } from \"./label\";\n\nexport type FieldError = Exclude<React.ReactNode, undefined> | { message: React.ReactNode };\n\ntype FieldControlProps = {\n\tid?: string;\n\t\"aria-describedby\"?: string;\n\t\"aria-invalid\"?: boolean | \"true\" | \"false\";\n};\n\nexport interface FieldProps\n\textends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\" | \"className\"> {\n\t/**\n\t * Visible label.\n\t */\n\tlabel: React.ReactNode;\n\t/**\n\t * Associates the label and described-by ids.\n\t */\n\thtmlFor?: string;\n\t/**\n\t * Supporting text when there is no error.\n\t */\n\thint?: React.ReactNode;\n\t/**\n\t * Replaces the hint and marks the control invalid.\n\t */\n\terror?: FieldError;\n\t/**\n\t * When false, show (optional) after the label.\n\t */\n\trequired?: boolean;\n\t/**\n\t * Info icon with hover text on the label.\n\t */\n\tlabelTooltip?: React.ReactNode;\n\t/**\n\t * Additional classes for the field root.\n\t */\n\tclassName?: string;\n\t/**\n\t * The control or content to render.\n\t */\n\tchildren: React.ReactNode;\n}\n\nfunction isStructuredError(error: FieldError): error is { message: React.ReactNode } {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t!Array.isArray(error) &&\n\t\t!React.isValidElement(error) &&\n\t\t\"message\" in error\n\t);\n}\n\nfunction fieldErrorMessage(error: FieldError | undefined): React.ReactNode | undefined {\n\tif (error == null) {\n\t\treturn undefined;\n\t}\n\treturn isStructuredError(error) ? error.message : error;\n}\n\
|
|
1
|
+
{"version":3,"file":"field.js","names":[],"sources":["../../src/components/field.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { BASALT_UI_CLASS } from \"../utils/control-surface\";\nimport { Label } from \"./label\";\n\nexport type FieldError = Exclude<React.ReactNode, undefined> | { message: React.ReactNode };\n\ntype FieldControlProps = {\n\tid?: string;\n\t\"aria-describedby\"?: string;\n\t\"aria-invalid\"?: boolean | \"true\" | \"false\";\n};\n\nexport interface FieldProps\n\textends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\" | \"className\"> {\n\t/**\n\t * Visible label.\n\t */\n\tlabel: React.ReactNode;\n\t/**\n\t * Associates the label and described-by ids.\n\t */\n\thtmlFor?: string;\n\t/**\n\t * Supporting text when there is no error.\n\t */\n\thint?: React.ReactNode;\n\t/**\n\t * Replaces the hint and marks the control invalid.\n\t */\n\terror?: FieldError;\n\t/**\n\t * When false, show (optional) after the label.\n\t */\n\trequired?: boolean;\n\t/**\n\t * Info icon with hover text on the label.\n\t */\n\tlabelTooltip?: React.ReactNode;\n\t/**\n\t * Additional classes for the field root.\n\t */\n\tclassName?: string;\n\t/**\n\t * The control or content to render.\n\t */\n\tchildren: React.ReactNode;\n}\n\nfunction isStructuredError(error: FieldError): error is { message: React.ReactNode } {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t!Array.isArray(error) &&\n\t\t!React.isValidElement(error) &&\n\t\t\"message\" in error\n\t);\n}\n\nfunction fieldErrorMessage(error: FieldError | undefined): React.ReactNode | undefined {\n\tif (error == null) {\n\t\treturn undefined;\n\t}\n\treturn isStructuredError(error) ? error.message : error;\n}\n\nexport const Field = React.forwardRef<HTMLDivElement, FieldProps>(\n\t({ label, htmlFor, hint, error, required, labelTooltip, className, children, ...props }, ref) => {\n\t\tconst generatedId = React.useId();\n\t\tconst child = React.isValidElement(children)\n\t\t\t? (children as React.ReactElement<FieldControlProps>)\n\t\t\t: null;\n\t\tconst controlId = child ? (htmlFor ?? child.props.id ?? generatedId) : htmlFor;\n\t\tconst hintId = controlId ? `${controlId}-hint` : undefined;\n\t\tconst errorId = controlId ? `${controlId}-error` : undefined;\n\t\tconst errorMessage = fieldErrorMessage(error);\n\t\tconst hasError = Boolean(errorMessage);\n\t\tconst describedBy = [hasError ? errorId : null, !hasError && hint ? hintId : null]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\" \");\n\t\tconst mergedDescribedBy = [describedBy, child?.props[\"aria-describedby\"]]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\" \");\n\t\treturn (\n\t\t\t<div ref={ref} {...props} className={cn(BASALT_UI_CLASS, \"flex flex-col gap-1.5\", className)}>\n\t\t\t\t<Label htmlFor={controlId} showOptional={required === false} tooltip={labelTooltip}>\n\t\t\t\t\t{label}\n\t\t\t\t</Label>\n\t\t\t\t{child\n\t\t\t\t\t? React.cloneElement(child, {\n\t\t\t\t\t\t\tid: controlId,\n\t\t\t\t\t\t\t\"aria-invalid\": hasError ? true : child.props[\"aria-invalid\"],\n\t\t\t\t\t\t\t\"aria-describedby\": mergedDescribedBy || undefined,\n\t\t\t\t\t\t})\n\t\t\t\t\t: children}\n\t\t\t\t{hint && !hasError ? (\n\t\t\t\t\t<p id={hintId} className=\"text-xs text-basalt-muted-foreground\">\n\t\t\t\t\t\t{hint}\n\t\t\t\t\t</p>\n\t\t\t\t) : null}\n\t\t\t\t{hasError ? (\n\t\t\t\t\t<p id={errorId} className=\"text-xs text-basalt-destructive\" role=\"alert\">\n\t\t\t\t\t\t{errorMessage}\n\t\t\t\t\t</p>\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t);\n\t},\n);\nField.displayName = \"Field\";\n"],"mappings":";;;;;;;AAiDA,SAAS,EAAkB,GAA0D;CACpF,OACC,OAAO,KAAU,cACjB,KACA,CAAC,MAAM,QAAQ,CAAK,KACpB,CAAC,EAAM,eAAe,CAAK,KAC3B,aAAa;AAEf;AAEA,SAAS,EAAkB,GAA4D;CAClF,SAAS,MAGb,OAAO,EAAkB,CAAK,IAAI,EAAM,UAAU;AACnD;AAEA,IAAa,IAAQ,EAAM,YACzB,EAAE,UAAO,YAAS,SAAM,UAAO,aAAU,iBAAc,cAAW,aAAU,GAAG,KAAS,MAAQ;CAChG,IAAM,IAAc,EAAM,MAAM,GAC1B,IAAQ,EAAM,eAAe,CAAQ,IACvC,IACD,MACG,IAAY,IAAS,KAAW,EAAM,MAAM,MAAM,IAAe,GACjE,IAAS,IAAY,GAAG,EAAU,SAAS,KAAA,GAC3C,IAAU,IAAY,GAAG,EAAU,UAAU,KAAA,GAC7C,IAAe,EAAkB,CAAK,GACtC,IAAW,EAAQ,GAInB,IAAoB,CAHN,CAAC,IAAW,IAAU,MAAM,CAAC,KAAY,IAAO,IAAS,IAAI,CAAC,CAChF,OAAO,OAAO,CAAC,CACf,KAAK,GACoB,GAAa,GAAO,MAAM,mBAAmB,CAAC,CACvE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;CACV,OACC,kBAAC,OAAD;EAAU;EAAK,GAAI;EAAO,WAAW,EAAG,GAAiB,yBAAyB,CAAS;EAA3F,UAAA;GACC,kBAAC,GAAD;IAAO,SAAS;IAAW,cAAc,MAAa;IAAO,SAAS;IACpE,UAAA;GACK,CAAA;GACN,IACE,EAAM,aAAa,GAAO;IAC1B,IAAI;IACJ,gBAAgB,IAAW,KAAO,EAAM,MAAM;IAC9C,oBAAoB,KAAqB,KAAA;GAC1C,CAAC,IACA;GACF,KAAQ,CAAC,IACT,kBAAC,KAAD;IAAG,IAAI;IAAQ,WAAU;IACvB,UAAA;GACC,CAAA,IACA;GACH,IACA,kBAAC,KAAD;IAAG,IAAI;IAAS,WAAU;IAAkC,MAAK;IAC/D,UAAA;GACC,CAAA,IACA;EACA;;AAEP,CACD;AACA,EAAM,cAAc"}
|
|
@@ -67,7 +67,7 @@ declare function LayerCardPrimary(props: LayerCardWellProps): import("react").JS
|
|
|
67
67
|
declare function LayerCardSecondary(props: LayerCardSectionProps): import("react").JSX.Element;
|
|
68
68
|
declare function LayerCardFooter({ className, ...props }: LayerCardSectionProps): import("react").JSX.Element;
|
|
69
69
|
declare function LayerCardLoading({ label, className, ...props }: LayerCardLoadingProps): import("react").JSX.Element;
|
|
70
|
-
declare function LayerCardEmpty({ title,
|
|
70
|
+
declare function LayerCardEmpty({ title, className, ...props }: LayerCardEmptyProps): import("react").JSX.Element;
|
|
71
71
|
export declare const LayerCard: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "className"> & {
|
|
72
72
|
/**
|
|
73
73
|
* Additional classes for the card root.
|