@calchemy/date-react 0.1.0 → 0.1.2

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AA0B1F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"sources":["../src/hooks/useCalchemy.ts","../src/inline-completion.ts","../src/hooks/useDebouncedValue.ts","../src/components/calendar/Calendar.tsx","../src/components/calendar/CalendarGrid.tsx","../src/components/calendar/calendar-period-drag.tsx","../src/components/calendar/date-model.ts","../src/components/calendar/CalendarPeriodHeading.tsx","../src/components/calendar/CalendarPeriod.tsx","../src/components/calendar/CalendarPeriodList.tsx","../src/components/calendar/CalendarSelects.tsx","../src/components/Calchemy.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport { resolveExpectedDateValue } from \"@calchemy/date-core\";\nimport {\n composeInlineCompletion,\n formatInlineCompletionDescription,\n} from \"../inline-completion\";\nimport { useDebouncedValue } from \"./useDebouncedValue\";\nimport type {\n Calchemy,\n DateValue,\n ExpectedDateValue,\n ParseDateContext,\n ParseDateResult,\n ResolveExpectedDateValueOptions,\n} from \"@calchemy/date-core\";\n\nexport type CalchemyInputMode = \"field\" | \"calendar\";\n\nexport type UseCalchemyOptions = ResolveExpectedDateValueOptions & {\n calchemy: Calchemy;\n expectedValue: ExpectedDateValue;\n value?: DateValue | null;\n defaultValue?: DateValue | null;\n onValueChange?: (value: DateValue | null, result: ParseDateResult) => void;\n parseContext?: ParseDateContext;\n inputValue?: string;\n defaultInputValue?: string;\n onInputValueChange?: (value: string) => void;\n inputMode?: CalchemyInputMode;\n defaultInputMode?: CalchemyInputMode;\n onInputModeChange?: (mode: CalchemyInputMode) => void;\n};\n\nexport type CalchemyState = {\n calchemy: Calchemy;\n parseContext: ParseDateContext | undefined;\n inputValue: string;\n value: DateValue | null;\n result: ParseDateResult;\n expectedValue: ExpectedDateValue;\n inputMode: CalchemyInputMode;\n valueKindMismatch: boolean;\n inlineCompletion: ReturnType<Calchemy[\"getInlineCompletion\"]>;\n setInputValue(value: string): void;\n setInputMode(mode: CalchemyInputMode): void;\n acceptCompletion(): void;\n selectCandidate(candidateId: string): void;\n selectDate(value: DateValue): void;\n getInputProps(): {\n value: string;\n readOnly: boolean;\n onChange(event: { currentTarget: { value: string } }): void;\n onKeyDown(event: { key: string; preventDefault(): void }): void;\n \"aria-invalid\": boolean;\n \"aria-description\"?: string;\n \"calchemy-status\": ParseDateResult[\"status\"] | \"kind-mismatch\";\n \"calchemy-expected-value\": ExpectedDateValue | undefined;\n \"calchemy-value-kind\": ExpectedDateValue | undefined;\n };\n};\n\nexport function useCalchemy(options: UseCalchemyOptions): CalchemyState {\n const [uncontrolledInputValue, setUncontrolledInputValue] = useState(options.defaultInputValue ?? \"\");\n const [uncontrolledValue, setUncontrolledValue] = useState<DateValue | null>(options.defaultValue ?? null);\n const [uncontrolledInputMode, setUncontrolledInputMode] = useState<CalchemyInputMode>(\n options.defaultInputMode ?? \"field\",\n );\n const inputValue = options.inputValue ?? uncontrolledInputValue;\n const value = options.value ?? uncontrolledValue;\n const inputMode = options.inputMode ?? uncontrolledInputMode;\n const fieldInputActive = inputMode === \"field\";\n const queryValue = useDebouncedValue(inputValue);\n const queryPending = inputValue !== queryValue;\n const result = useMemo(\n () => options.calchemy.parseDate(queryValue, options.parseContext),\n [queryValue, options.calchemy, options.parseContext],\n );\n const expectedValue = options.expectedValue;\n const expectedOptions = {\n ...(options.multipleRangeExpansionLimit === undefined\n ? {}\n : { multipleRangeExpansionLimit: options.multipleRangeExpansionLimit }),\n } satisfies ResolveExpectedDateValueOptions;\n const expectedResult = resolveExpectedDateValue(result, expectedValue, expectedOptions);\n const valueKindMismatch = expectedResult.status === \"invalid\" && result.status === \"valid\";\n const settledInlineCompletion = useMemo(\n () => options.calchemy.getInlineCompletion(queryValue, options.parseContext),\n [queryValue, options.calchemy, options.parseContext],\n );\n const inlineCompletion = queryPending ? null : settledInlineCompletion;\n\n function updateValue(nextValue: DateValue | null, nextResult: ParseDateResult = result) {\n if (options.value === undefined) {\n setUncontrolledValue(nextValue);\n }\n options.onValueChange?.(nextValue, nextResult);\n }\n\n useEffect(() => {\n const nextResult = options.calchemy.parseDate(queryValue, options.parseContext);\n const nextExpectedResult = resolveExpectedDateValue(\n nextResult,\n expectedValue,\n expectedOptions,\n );\n if (nextExpectedResult.status === \"valid\") {\n if (options.value === undefined) {\n setUncontrolledValue(nextExpectedResult.value);\n }\n options.onValueChange?.(nextExpectedResult.value, nextExpectedResult);\n }\n }, [\n queryValue,\n expectedValue,\n expectedOptions.multipleRangeExpansionLimit,\n options.calchemy,\n options.parseContext,\n ]);\n\n function updateInputValue(nextValue: string) {\n if (options.inputValue === undefined) {\n setUncontrolledInputValue(nextValue);\n }\n options.onInputValueChange?.(nextValue);\n }\n\n function getActiveInlineCompletion() {\n if (!fieldInputActive || queryPending) {\n return null;\n }\n\n return settledInlineCompletion;\n }\n\n function setInputMode(nextMode: CalchemyInputMode) {\n if (options.inputMode === undefined) {\n setUncontrolledInputMode(nextMode);\n }\n options.onInputModeChange?.(nextMode);\n }\n\n function acceptCompletion() {\n const activeCompletion = getActiveInlineCompletion();\n if (!activeCompletion) {\n return;\n }\n\n updateInputValue(composeInlineCompletion(inputValue, activeCompletion));\n }\n\n function selectCandidate(candidateId: string) {\n if (!fieldInputActive || result.status !== \"ambiguous\") {\n return;\n }\n\n const candidate = result.candidates.find((item) => item.id === candidateId);\n if (!candidate) {\n return;\n }\n\n const candidateResult = {\n status: \"valid\",\n input: inputValue,\n value: candidate.value,\n candidates: [candidate],\n corrections: result.corrections,\n warnings: result.warnings,\n } satisfies ParseDateResult;\n const resolvedCandidateResult = resolveExpectedDateValue(candidateResult, expectedValue, expectedOptions);\n if (resolvedCandidateResult.status !== \"valid\") {\n return;\n }\n\n updateValue(resolvedCandidateResult.value, resolvedCandidateResult);\n }\n\n function selectDate(nextValue: DateValue) {\n const nextResult = {\n status: \"valid\",\n input: inputValue,\n value: nextValue,\n candidates: [],\n corrections: [],\n warnings: [],\n } satisfies ParseDateResult;\n const resolvedResult = resolveExpectedDateValue(nextResult, expectedValue, expectedOptions);\n if (resolvedResult.status !== \"valid\") {\n return;\n }\n\n updateValue(resolvedResult.value, resolvedResult);\n if (resolvedResult.value.kind === \"single\") {\n updateInputValue(resolvedResult.value.date.toString());\n }\n }\n\n return {\n calchemy: options.calchemy,\n parseContext: options.parseContext,\n inputValue,\n value,\n result: expectedResult,\n expectedValue,\n inputMode,\n valueKindMismatch,\n inlineCompletion,\n setInputValue: updateInputValue,\n setInputMode,\n acceptCompletion,\n selectCandidate,\n selectDate,\n getInputProps() {\n const activeCompletion = getActiveInlineCompletion();\n\n return {\n value: inputValue,\n readOnly: !fieldInputActive,\n onChange(event) {\n if (!fieldInputActive) {\n return;\n }\n\n updateInputValue(event.currentTarget.value);\n },\n onKeyDown(event) {\n if (!fieldInputActive) {\n return;\n }\n\n if (event.key === \"Tab\" && activeCompletion) {\n event.preventDefault();\n acceptCompletion();\n }\n },\n \"aria-invalid\": expectedResult.status === \"invalid\",\n ...(fieldInputActive && inlineCompletion\n ? {\n \"aria-description\": formatInlineCompletionDescription(\n inputValue,\n inlineCompletion,\n ),\n }\n : {}),\n \"calchemy-status\": valueKindMismatch ? \"kind-mismatch\" : expectedResult.status,\n \"calchemy-expected-value\": expectedValue,\n \"calchemy-value-kind\": expectedResult.status === \"valid\" ? expectedResult.value.kind : undefined,\n };\n },\n };\n}\n","import type { InlineCompletion } from \"@calchemy/date-core\";\n\nexport function composeInlineCompletion(\n inputValue: string,\n completion: InlineCompletion,\n): string {\n return `${inputValue}${completion.suffix}`;\n}\n\nexport function formatInlineCompletionDescription(\n inputValue: string,\n completion: InlineCompletion,\n): string {\n return `Suggestion: ${composeInlineCompletion(inputValue, completion)}. Press Tab to accept.`;\n}\n","import { useEffect, useState } from \"react\";\n\nexport const PARSE_QUERY_DEBOUNCE_MS = 150;\n\nexport function useDebouncedValue<T>(value: T, delayMs = PARSE_QUERY_DEBOUNCE_MS): T {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n setDebouncedValue(value);\n }, delayMs);\n\n return () => {\n clearTimeout(timeoutId);\n };\n }, [value, delayMs]);\n\n return debouncedValue;\n}\n","import { useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties, MouseEvent } from \"react\";\nimport type { PlainDate } from \"@calchemy/date-core\";\nimport { CalendarContext, useCalchemyCalendar, useCalchemyContext } from \"./context\";\nimport { CalendarGrid, CalendarWeekdays } from \"./CalendarGrid\";\nimport {\n addCalendarPeriod,\n buildCalendarPeriods,\n clampDateToBounds,\n formatCalendarWindowLabel,\n getCalendarPeriodAtOffset,\n getDateValueAnchor,\n getDateValueKey,\n getInitialPeriodExtensions,\n getSelectedValue,\n getToday,\n isBefore,\n isDateInCalendarViewport,\n parseCalendarDuration,\n periodIntersectsBounds,\n validateCalendarBounds,\n} from \"./date-model\";\nimport type { CalendarBounds, CalendarDuration, CalendarNamedDates, CalendarState } from \"./types\";\n\nconst defaultCalendarPeriod = { months: 1 } satisfies CalendarDuration;\n\nexport type CalchemyCalendarProps = Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> & {\n period?: CalendarDuration;\n bounds?: CalendarBounds;\n isDateDisabled?: CalendarState[\"isDateDisabled\"];\n namedDates?: CalendarNamedDates;\n};\n\nexport function Calendar({\n period = defaultCalendarPeriod,\n bounds,\n isDateDisabled,\n namedDates,\n children,\n ...divProps\n}: CalchemyCalendarProps) {\n const state = useCalchemyContext();\n const editable = state.inputMode === \"calendar\";\n validateCalendarBounds(bounds);\n const parsedPeriod = useMemo(() => parseCalendarDuration(period, \"period\"), [period]);\n const selected = getSelectedValue(state);\n const today = getToday(state);\n const [periodAnchor, setPeriodAnchor] = useState(() =>\n clampDateToBounds(getDateValueAnchor(selected) ?? today, bounds),\n );\n const [navigationAnchor, setNavigationAnchor] = useState<{ date: PlainDate; inputValue: string } | null>(null);\n const [periodExtensions, setPeriodExtensions] = useState(() => getInitialPeriodExtensions(parsedPeriod));\n const [visiblePeriodIndex, setScrolledVisiblePeriodIndex] = useState<{\n anchor: string;\n inputValue: string;\n index: number;\n } | null>(null);\n const prevInputValueRef = useRef(state.inputValue);\n const prevSelectedKeyRef = useRef(getDateValueKey(selected));\n const prevExpectedValueRef = useRef(state.expectedValue);\n useEffect(() => {\n if (prevExpectedValueRef.current === state.expectedValue) {\n return;\n }\n\n prevExpectedValueRef.current = state.expectedValue;\n setScrolledVisiblePeriodIndex(null);\n setNavigationAnchor(null);\n setPeriodAnchor(clampDateToBounds(getDateValueAnchor(selected) ?? today, bounds));\n prevInputValueRef.current = state.inputValue;\n prevSelectedKeyRef.current = getDateValueKey(selected);\n }, [bounds, selected, state.expectedValue, state.inputValue, today]);\n const periodAnchorKey = periodAnchor.toString();\n const activeVisiblePeriodIndex =\n visiblePeriodIndex?.anchor === periodAnchorKey && visiblePeriodIndex.inputValue === state.inputValue\n ? visiblePeriodIndex.index\n : 0;\n const weekStartsOn = state.parseContext?.weekStartsOn ?? 0;\n const locale = state.parseContext?.locale ?? \"en-US\";\n const periods = useMemo(\n () => buildCalendarPeriods(periodAnchor, parsedPeriod, weekStartsOn, locale, periodExtensions, bounds),\n [periodAnchor, parsedPeriod.count, parsedPeriod.unit, weekStartsOn, locale, periodExtensions, bounds],\n );\n const visiblePeriods = useMemo(\n () => {\n const visible = periods.filter(\n (item) =>\n item.index >= activeVisiblePeriodIndex && item.index < activeVisiblePeriodIndex + parsedPeriod.count,\n );\n\n return visible.length > 0 ? visible : periods.slice(0, parsedPeriod.count);\n },\n [periods, activeVisiblePeriodIndex, parsedPeriod.count],\n );\n const visiblePeriodAnchor = visiblePeriods[0]?.start ?? periodAnchor;\n\n useLayoutEffect(() => {\n const inputChanged = prevInputValueRef.current !== state.inputValue;\n prevInputValueRef.current = state.inputValue;\n\n const selectedKey = getDateValueKey(selected);\n const selectionChanged = prevSelectedKeyRef.current !== selectedKey;\n prevSelectedKeyRef.current = selectedKey;\n\n if (!inputChanged && !selectionChanged) {\n return;\n }\n\n if (selectionChanged && editable) {\n return;\n }\n\n const selectionAnchor = clampDateToBounds(getDateValueAnchor(selected) ?? today, bounds);\n const inputReflectsCalendarSelection = state.inputValue === selectionAnchor.toString();\n const shouldRevealSelection = inputChanged && !inputReflectsCalendarSelection;\n\n if (\n !shouldRevealSelection &&\n isDateInCalendarViewport(\n selectionAnchor,\n periods,\n activeVisiblePeriodIndex,\n parsedPeriod.count,\n )\n ) {\n return;\n }\n\n setPeriodAnchor((current) => (current.equals(selectionAnchor) ? current : selectionAnchor));\n setScrolledVisiblePeriodIndex(null);\n }, [\n activeVisiblePeriodIndex,\n bounds,\n editable,\n parsedPeriod.count,\n periods,\n selected,\n state.inputValue,\n today,\n ]);\n\n function setCalendarPeriodAnchor(date: PlainDate) {\n const clamped = clampDateToBounds(date, bounds);\n setPeriodAnchor(clamped);\n setNavigationAnchor({ date: clamped, inputValue: state.inputValue });\n setPeriodExtensions(getInitialPeriodExtensions(parsedPeriod));\n setScrolledVisiblePeriodIndex(null);\n }\n\n function canMoveCalendar(unit: \"month\" | \"week\", count: number) {\n const target = addCalendarPeriod(visiblePeriodAnchor, unit, count);\n return target.equals(clampDateToBounds(target, bounds));\n }\n\n function canExtendCalendarPeriods(direction: \"before\" | \"after\", windows = 1) {\n if (!bounds) {\n return true;\n }\n\n const extendCount = parsedPeriod.count * windows;\n const firstIndex = periods[0]?.index ?? 0;\n const lastIndex = periods.at(-1)?.index ?? parsedPeriod.count - 1;\n const targetIndex = direction === \"before\" ? firstIndex - extendCount : lastIndex + 1;\n const targetPeriod = getCalendarPeriodAtOffset(periodAnchor, parsedPeriod, weekStartsOn, locale, targetIndex);\n\n return periodIntersectsBounds(targetPeriod, bounds);\n }\n\n const calendarState = useMemo(\n () =>\n ({\n calchemy: state,\n period: parsedPeriod,\n periodAnchor,\n visiblePeriodAnchor,\n today,\n selected,\n periods,\n visiblePeriods,\n weekStartsOn,\n locale,\n bounds,\n namedDates,\n editable,\n isDateDisabled,\n setPeriodAnchor: setCalendarPeriodAnchor,\n setVisiblePeriodIndex(index) {\n setScrolledVisiblePeriodIndex((current) => {\n if (\n current?.anchor === periodAnchorKey &&\n current.inputValue === state.inputValue &&\n current.index === index\n ) {\n return current;\n }\n\n return { anchor: periodAnchorKey, inputValue: state.inputValue, index };\n });\n },\n canMove: canMoveCalendar,\n move(unit, count) {\n if (!canMoveCalendar(unit, count)) {\n return;\n }\n\n const clamped = clampDateToBounds(addCalendarPeriod(visiblePeriodAnchor, unit, count), bounds);\n setPeriodAnchor(clamped);\n setNavigationAnchor({\n date: clamped,\n inputValue: state.inputValue,\n });\n setPeriodExtensions(getInitialPeriodExtensions(parsedPeriod));\n setScrolledVisiblePeriodIndex(null);\n },\n canExtendPeriods: canExtendCalendarPeriods,\n extendPeriods(direction, windows = 1) {\n if (!canExtendCalendarPeriods(direction, windows)) {\n return;\n }\n\n setPeriodExtensions((current) => ({\n ...current,\n [direction]: current[direction] + parsedPeriod.count * windows,\n }));\n },\n selectDate(date) {\n if (!editable) {\n return;\n }\n\n if (state.expectedValue === \"range\") {\n const current = selected;\n if (current?.kind === \"range\" && current.start.equals(current.end)) {\n const start = isBefore(current.start, date) ? current.start : date;\n const end = isBefore(current.start, date) ? date : current.start;\n state.selectDate({ kind: \"range\", start, end });\n return;\n }\n\n state.selectDate({ kind: \"range\", start: date, end: date });\n return;\n }\n\n state.selectDate({ kind: \"single\", date });\n },\n selectValue(value) {\n if (!editable) {\n return;\n }\n\n state.selectDate(value);\n },\n }) satisfies CalendarState,\n [\n state,\n parsedPeriod,\n periodAnchor,\n periodAnchorKey,\n visiblePeriodAnchor,\n today,\n selected,\n periods,\n visiblePeriods,\n weekStartsOn,\n locale,\n bounds,\n namedDates,\n editable,\n isDateDisabled,\n ],\n );\n\n const content = children ?? (\n <>\n <CalendarHeader>\n <CalendarPrevious />\n <CalendarHeading />\n <CalendarNext />\n </CalendarHeader>\n <CalendarWeekdays />\n <CalendarGrid />\n </>\n );\n\n return (\n <CalendarContext.Provider value={calendarState}>\n <div\n {...divProps}\n calchemy-calendar=\"\"\n calchemy-editable={editable ? \"\" : undefined}\n style={\n {\n ...divProps.style,\n \"--calchemy-calendar-period-count\": parsedPeriod.count,\n } as CSSProperties\n }\n >\n {content}\n </div>\n </CalendarContext.Provider>\n );\n}\n\nexport type CalchemyCalendarHeaderProps = ComponentPropsWithoutRef<\"div\">;\n\nexport function CalendarHeader(props: CalchemyCalendarHeaderProps) {\n return <div {...props} calchemy-header=\"\" />;\n}\n\nexport type CalchemyCalendarHeadingProps = ComponentPropsWithoutRef<\"h2\">;\n\nexport function CalendarHeading(props: CalchemyCalendarHeadingProps) {\n const calendar = useCalchemyCalendar();\n\n return (\n <h2 {...props} calchemy-heading=\"\">\n {props.children ?? formatCalendarWindowLabel(calendar.visiblePeriods, calendar.locale)}\n </h2>\n );\n}\n\nexport type CalchemyCalendarNavigationProps = Omit<ComponentPropsWithoutRef<\"button\">, \"onClick\"> & {\n onClick?: ComponentPropsWithoutRef<\"button\">[\"onClick\"];\n};\n\nexport function CalendarPrevious({\n onClick,\n children,\n ...props\n}: CalchemyCalendarNavigationProps) {\n return (\n <CalendarNavigationButton\n {...props}\n direction={-1}\n calchemy-previous=\"\"\n onClick={onClick}\n >\n {children ?? \"Previous\"}\n </CalendarNavigationButton>\n );\n}\n\nexport function CalendarNext({\n onClick,\n children,\n ...props\n}: CalchemyCalendarNavigationProps) {\n return (\n <CalendarNavigationButton\n {...props}\n direction={1}\n calchemy-next=\"\"\n onClick={onClick}\n >\n {children ?? \"Next\"}\n </CalendarNavigationButton>\n );\n}\n\ntype CalendarNavigationButtonProps = CalchemyCalendarNavigationProps & {\n direction: -1 | 1;\n};\n\nfunction CalendarNavigationButton({\n direction,\n onClick,\n type = \"button\",\n ...props\n}: CalendarNavigationButtonProps) {\n const calendar = useCalchemyCalendar();\n const disabled =\n props.disabled ?? !calendar.canMove(calendar.period.unit, calendar.period.count * direction);\n\n function handleClick(event: MouseEvent<HTMLButtonElement>) {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n\n calendar.move(calendar.period.unit, calendar.period.count * direction);\n }\n\n return <button {...props} type={type} disabled={disabled} onClick={handleClick} />;\n}\n","import { useMemo } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport { useCalchemyCalendar, useCalendarPeriod } from \"./context\";\nimport {\n CalendarDragRectangleOverlay,\n getMultipleDates,\n getSelectedDateKeys,\n mergeCalendarDragPointerProps,\n multipleDragSurfaceStyle,\n toggleDateKeys,\n useCalendarPeriodDragSurface,\n useOptionalCalendarPeriodDrag,\n} from \"./calendar-period-drag\";\nimport type { CalendarWeekdayFormat } from \"./types\";\nimport {\n buildCalendarWeeks,\n buildWeekdays,\n getCalendarDayState,\n getFirstVisibleCalendarPeriod,\n} from \"./date-model\";\n\nconst defaultCalendarWeekdayFormat = \"short\" satisfies CalendarWeekdayFormat;\n\nexport type CalchemyCalendarWeekdaysProps = ComponentPropsWithoutRef<\"div\"> & {\n weekdayFormat?: CalendarWeekdayFormat;\n};\n\nexport function CalendarWeekdays({\n weekdayFormat = defaultCalendarWeekdayFormat,\n ...props\n}: CalchemyCalendarWeekdaysProps) {\n const calendar = useCalchemyCalendar();\n const weekdays = buildWeekdays(calendar, weekdayFormat);\n\n return (\n <div {...props} calchemy-days=\"\">\n {weekdays.map((weekday) => (\n <div\n key={weekday.index}\n calchemy-weekday=\"\"\n calchemy-weekend={weekday.weekend ? \"\" : undefined}\n >\n {weekday.label}\n </div>\n ))}\n </div>\n );\n}\n\nexport type CalchemyCalendarGridProps = Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> & {\n showBookends?: boolean;\n dragSelection?: boolean;\n};\n\nexport function CalendarGrid({\n showBookends = false,\n dragSelection = true,\n style,\n onPointerDownCapture,\n onPointerMove,\n onPointerUp,\n onPointerCancel,\n onDragStart,\n ...props\n}: CalchemyCalendarGridProps) {\n const calendar = useCalchemyCalendar();\n const period = useCalendarPeriod() ?? getFirstVisibleCalendarPeriod(calendar);\n const weeks = buildCalendarWeeks(period, calendar.weekStartsOn);\n const parentDrag = useOptionalCalendarPeriodDrag();\n const localDrag = useCalendarPeriodDragSurface(\n calendar.editable && dragSelection && parentDrag === null,\n );\n const drag = parentDrag ?? localDrag;\n const multipleSelection = Boolean(drag?.multipleSelection);\n const useLocalDragHandlers = Boolean(drag && parentDrag === null);\n const committedSelectedKeys = useMemo(() => new Set(getSelectedDateKeys(calendar.selected)), [calendar.selected]);\n const previewSelectedKeys = drag?.previewSelectedKeys ?? new Set<string>();\n const dragState = drag?.dragState ?? null;\n const dragPointerProps = mergeCalendarDragPointerProps(useLocalDragHandlers, drag, {\n onPointerDownCapture,\n onPointerMove,\n onPointerUp,\n onPointerCancel,\n onDragStart,\n });\n\n return (\n <div\n {...props}\n calchemy-grid=\"\"\n calchemy-multiple-drag={useLocalDragHandlers ? \"\" : undefined}\n calchemy-dragging={useLocalDragHandlers && dragState ? \"\" : undefined}\n style={useLocalDragHandlers ? { ...multipleDragSurfaceStyle, ...style } : style}\n {...dragPointerProps}\n >\n {useLocalDragHandlers && drag?.dragRectangle ? (\n <CalendarDragRectangleOverlay dragRectangle={drag.dragRectangle} surfaceRef={drag.surfaceRef} />\n ) : null}\n {weeks.map((week) => (\n <div key={week[0]?.toString()} calchemy-week=\"\">\n {week.map((date) => {\n const dayState = getCalendarDayState(calendar, period, date);\n const namedDateLabels = dayState.namedDates.map((item) => item.value).join(\", \");\n const dateKey = date.toString();\n const selected = multipleSelection\n ? dragState\n ? previewSelectedKeys.has(dateKey)\n : committedSelectedKeys.has(dateKey)\n : dayState.selected;\n const dragPreview = Boolean(dragState && selected !== dayState.selected);\n if (dayState.outside && !showBookends) {\n return (\n <div\n key={date.toString()}\n aria-hidden=\"true\"\n calchemy-cell=\"\"\n calchemy-blank=\"\"\n />\n );\n }\n\n return (\n <button\n type=\"button\"\n key={date.toString()}\n ref={(element) =>\n drag?.registerDay(element, date, dayState.disabled || !calendar.editable)\n }\n calchemy-date=\"\"\n calchemy-selected={selected ? \"\" : undefined}\n calchemy-drag-preview={dragPreview ? \"\" : undefined}\n calchemy-drag-preview-selected={dragPreview && selected ? \"\" : undefined}\n calchemy-drag-preview-deselected={dragPreview && !selected ? \"\" : undefined}\n calchemy-today={dayState.today ? \"\" : undefined}\n calchemy-weekend={dayState.weekend ? \"\" : undefined}\n calchemy-outside={dayState.outside ? \"\" : undefined}\n calchemy-first-of-period={dayState.firstOfPeriod ? \"\" : undefined}\n calchemy-last-of-period={dayState.lastOfPeriod ? \"\" : undefined}\n calchemy-disabled={dayState.disabled ? \"\" : undefined}\n calchemy-out-of-bounds={!dayState.bounded ? \"\" : undefined}\n calchemy-named-date={dayState.namedDates.length > 0 ? \"\" : undefined}\n calchemy-holiday={dayState.namedDates.some((item) => item.isHoliday) ? \"\" : undefined}\n calchemy-named-date-labels={namedDateLabels || undefined}\n aria-disabled={!calendar.editable && !dayState.disabled ? true : undefined}\n disabled={dayState.disabled}\n onClick={() => {\n if (!calendar.editable) {\n return;\n }\n\n if (drag?.suppressClickRef.current) {\n drag.suppressClickRef.current = false;\n return;\n }\n if (!dayState.disabled) {\n if (multipleSelection) {\n const selectedDates = getMultipleDates(calendar.selected);\n const nextKeys = toggleDateKeys(\n selectedDates.map((selectedDate) => selectedDate.toString()),\n [dateKey],\n );\n const nextDates = nextKeys.flatMap((key) => {\n if (key === dateKey) {\n return [date];\n }\n\n const existing = selectedDates.find((selectedDate) => selectedDate.toString() === key);\n return existing ? [existing] : [];\n });\n calendar.selectValue({\n kind: \"multiple\",\n dates: nextDates,\n });\n } else {\n calendar.selectDate(date);\n }\n }\n }}\n >\n {date.day}\n </button>\n );\n })}\n </div>\n ))}\n </div>\n );\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n type PointerEvent,\n type RefObject,\n} from \"react\";\nimport type { DateValue, PlainDate } from \"@calchemy/date-core\";\nimport { useCalchemyCalendar } from \"./context\";\n\ntype Point = {\n x: number;\n y: number;\n};\n\ntype CellBounds = {\n left: number;\n right: number;\n top: number;\n bottom: number;\n};\n\ntype DragState = {\n pointerId: number;\n start: Point;\n current: Point;\n baseDates: PlainDate[];\n previewKeys: string[];\n hasMoved: boolean;\n startDayCell: DayCell | null;\n cellBounds: ReadonlyMap<string, CellBounds>;\n};\n\ntype DayCell = {\n date: PlainDate;\n disabled: boolean;\n element: HTMLButtonElement;\n};\n\ntype DragRectangle = {\n start: Point;\n current: Point;\n};\n\nexport type CalendarPeriodDragContextValue = {\n multipleSelection: boolean;\n dragState: DragState | null;\n dragRectangle: DragRectangle | null;\n previewSelectedKeys: ReadonlySet<string>;\n suppressClickRef: RefObject<boolean>;\n surfaceRef: RefObject<HTMLElement | null>;\n registerDay(element: HTMLButtonElement | null, date: PlainDate, disabled: boolean): void;\n handlePointerDownCapture(event: PointerEvent<HTMLElement>): void;\n handlePointerMove(event: PointerEvent<HTMLElement>): void;\n handlePointerUp(event: PointerEvent<HTMLElement>): void;\n handlePointerCancel(event: PointerEvent<HTMLElement>): void;\n};\n\nconst CalendarPeriodDragContext = createContext<CalendarPeriodDragContextValue | null>(null);\n\nexport const multipleDragSurfaceStyle = {\n position: \"relative\",\n userSelect: \"none\",\n WebkitUserSelect: \"none\",\n touchAction: \"none\",\n} as const;\n\nexport const multiplePeriodListDragSurfaceStyle = {\n ...multipleDragSurfaceStyle,\n position: \"relative\",\n background: \"transparent\",\n} as const;\n\nexport type CalendarDragPointerHandlerProps = Pick<\n ComponentPropsWithoutRef<\"div\">,\n \"onPointerDownCapture\" | \"onPointerMove\" | \"onPointerUp\" | \"onPointerCancel\" | \"onDragStart\"\n>;\n\n// Example: `mergeCalendarDragPointerProps(true, drag, handlers)` chains drag surface handlers with caller props.\nexport function mergeCalendarDragPointerProps(\n enabled: boolean,\n drag: CalendarPeriodDragContextValue | null | undefined,\n handlers: CalendarDragPointerHandlerProps,\n): CalendarDragPointerHandlerProps {\n if (!enabled || !drag) {\n return handlers;\n }\n\n const { onPointerDownCapture, onPointerMove, onPointerUp, onPointerCancel, onDragStart } = handlers;\n\n return {\n onPointerDownCapture: (event) => {\n drag.handlePointerDownCapture(event);\n onPointerDownCapture?.(event);\n },\n onPointerMove: (event) => {\n drag.handlePointerMove(event);\n onPointerMove?.(event);\n },\n onPointerUp: (event) => {\n drag.handlePointerUp(event);\n onPointerUp?.(event);\n },\n onPointerCancel: (event) => {\n drag.handlePointerCancel(event);\n onPointerCancel?.(event);\n },\n onDragStart: (event) => {\n event.preventDefault();\n onDragStart?.(event);\n },\n };\n}\n\nexport function useOptionalCalendarPeriodDrag(): CalendarPeriodDragContextValue | null {\n return useContext(CalendarPeriodDragContext);\n}\n\nexport function useCalendarPeriodDragSurface(\n dragSelection = true,\n surfaceElementRef?: RefObject<HTMLElement | null>,\n): CalendarPeriodDragContextValue | null {\n const calendar = useCalchemyCalendar();\n const multipleSelection = dragSelection && calendar.calchemy.expectedValue === \"multiple\";\n const surfaceRef = useRef<HTMLElement | null>(null);\n const dayCells = useRef(new Map<string, DayCell>());\n const suppressClickRef = useRef(false);\n const dragStateRef = useRef<DragState | null>(null);\n const dragPreviewFrameRef = useRef<number | null>(null);\n const dragGestureCleanupRef = useRef<(() => void) | null>(null);\n const [dragState, setDragState] = useState<DragState | null>(null);\n const [dragRectangle, setDragRectangle] = useState<DragRectangle | null>(null);\n const previewSelectedKeys = useMemo(\n () => new Set(dragState?.previewKeys ?? []),\n [dragState],\n );\n\n const acquireDragGestureLock = useCallback(() => {\n if (dragGestureCleanupRef.current || typeof document === \"undefined\") {\n return;\n }\n\n const preventGestureDefault = (event: Event) => {\n event.preventDefault();\n };\n\n const clearDocumentSelection = () => {\n document.getSelection()?.removeAllRanges();\n };\n\n const previousBodyUserSelect = document.body.style.userSelect;\n const previousDocumentUserSelect = document.documentElement.style.userSelect;\n document.body.style.userSelect = \"none\";\n document.documentElement.style.userSelect = \"none\";\n\n document.addEventListener(\"pointermove\", preventGestureDefault, { capture: true, passive: false });\n document.addEventListener(\"touchmove\", preventGestureDefault, { capture: true, passive: false });\n document.addEventListener(\"wheel\", preventGestureDefault, { capture: true, passive: false });\n document.addEventListener(\"selectstart\", preventGestureDefault, { capture: true });\n document.addEventListener(\"dragstart\", preventGestureDefault, { capture: true });\n clearDocumentSelection();\n\n dragGestureCleanupRef.current = () => {\n document.removeEventListener(\"pointermove\", preventGestureDefault, { capture: true });\n document.removeEventListener(\"touchmove\", preventGestureDefault, { capture: true });\n document.removeEventListener(\"wheel\", preventGestureDefault, { capture: true });\n document.removeEventListener(\"selectstart\", preventGestureDefault, { capture: true });\n document.removeEventListener(\"dragstart\", preventGestureDefault, { capture: true });\n document.body.style.userSelect = previousBodyUserSelect;\n document.documentElement.style.userSelect = previousDocumentUserSelect;\n clearDocumentSelection();\n dragGestureCleanupRef.current = null;\n };\n }, []);\n\n const releaseDragGestureLock = useCallback(() => {\n dragGestureCleanupRef.current?.();\n if (dragPreviewFrameRef.current !== null) {\n cancelAnimationFrame(dragPreviewFrameRef.current);\n dragPreviewFrameRef.current = null;\n }\n }, []);\n\n const scheduleDragPreviewUpdate = useCallback((nextDragState: DragState) => {\n dragStateRef.current = nextDragState;\n if (dragPreviewFrameRef.current !== null) {\n return;\n }\n\n dragPreviewFrameRef.current = requestAnimationFrame(() => {\n setDragState(dragStateRef.current);\n dragPreviewFrameRef.current = null;\n });\n }, []);\n\n const registerDay = useCallback((element: HTMLButtonElement | null, date: PlainDate, disabled: boolean) => {\n const key = date.toString();\n if (element) {\n dayCells.current.set(key, { date, disabled, element });\n return;\n }\n\n dayCells.current.delete(key);\n }, []);\n\n const getDayCellFromTarget = useCallback((target: EventTarget | null): DayCell | null => {\n if (!(target instanceof Element)) {\n return null;\n }\n\n const button = target.closest(\"[calchemy-date]\");\n if (!(button instanceof HTMLButtonElement)) {\n return null;\n }\n\n for (const cell of dayCells.current.values()) {\n if (cell.element === button) {\n return cell;\n }\n }\n\n return null;\n }, []);\n\n const commitMultipleSelection = useCallback(\n (keys: Iterable<string>, fallbackDates: readonly PlainDate[] = []) => {\n const dates = resolveDateKeys(keys, dayCells.current, fallbackDates);\n calendar.selectValue({\n kind: \"multiple\",\n dates,\n });\n },\n [calendar],\n );\n\n const endDragGesture = useCallback(\n (pointerId?: number) => {\n if (pointerId !== undefined) {\n surfaceRef.current?.releasePointerCapture?.(pointerId);\n }\n\n releaseDragGestureLock();\n dragStateRef.current = null;\n setDragState(null);\n setDragRectangle(null);\n },\n [releaseDragGestureLock],\n );\n\n const handlePointerMove = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n const activeDrag = dragStateRef.current;\n if (!multipleSelection || !activeDrag || event.pointerId !== activeDrag.pointerId) {\n return;\n }\n\n event.preventDefault();\n const current = getPointerPoint(event);\n setDragRectangle({ start: activeDrag.start, current });\n const dragRect = getDragRect(activeDrag.start, current);\n const clipRect = getDragClipRect(surfaceRef.current);\n const gestureKeys = getIntersectingDateKeys(\n dayCells.current,\n dragRect,\n activeDrag.cellBounds,\n clipRect,\n );\n const baseKeys = activeDrag.baseDates.map((date) => date.toString());\n const previewKeys = toggleDateKeys(baseKeys, gestureKeys);\n const hasMoved = activeDrag.hasMoved || hasPointerMoved(activeDrag.start, current);\n scheduleDragPreviewUpdate({\n ...activeDrag,\n current,\n previewKeys,\n hasMoved,\n });\n },\n [multipleSelection, scheduleDragPreviewUpdate],\n );\n\n const handlePointerDownCapture = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n if (!multipleSelection || event.button !== 0 || !event.isPrimary) {\n return;\n }\n\n const baseDates = getMultipleDates(calendar.selected);\n event.preventDefault();\n\n if (typeof document !== \"undefined\") {\n document.getSelection()?.removeAllRanges();\n }\n\n surfaceRef.current = surfaceElementRef?.current ?? event.currentTarget;\n surfaceRef.current?.setPointerCapture?.(event.pointerId);\n acquireDragGestureLock();\n const nextDragState: DragState = {\n pointerId: event.pointerId,\n start: getPointerPoint(event),\n current: getPointerPoint(event),\n baseDates,\n previewKeys: baseDates.map((selectedDate) => selectedDate.toString()),\n hasMoved: false,\n startDayCell: getDayCellFromTarget(event.target),\n cellBounds: snapshotCellBounds(dayCells.current),\n };\n dragStateRef.current = nextDragState;\n setDragState(nextDragState);\n setDragRectangle({\n start: nextDragState.start,\n current: nextDragState.current,\n });\n },\n [acquireDragGestureLock, calendar.selected, getDayCellFromTarget, multipleSelection, surfaceElementRef],\n );\n\n const handlePointerUp = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n const activeDrag = dragStateRef.current;\n if (!multipleSelection || !activeDrag || event.pointerId !== activeDrag.pointerId) {\n return;\n }\n\n if (dragPreviewFrameRef.current !== null) {\n cancelAnimationFrame(dragPreviewFrameRef.current);\n dragPreviewFrameRef.current = null;\n setDragState(activeDrag);\n }\n\n event.preventDefault();\n\n suppressClickRef.current = true;\n setTimeout(() => {\n suppressClickRef.current = false;\n }, 0);\n\n if (activeDrag.hasMoved) {\n commitMultipleSelection(activeDrag.previewKeys, activeDrag.baseDates);\n } else {\n const dayCell = activeDrag.startDayCell;\n if (dayCell && !dayCell.disabled) {\n const selectedDates = getMultipleDates(calendar.selected);\n const nextKeys = toggleDateKeys(\n selectedDates.map((selectedDate) => selectedDate.toString()),\n [dayCell.date.toString()],\n );\n commitMultipleSelection(nextKeys, selectedDates.concat(dayCell.date));\n }\n }\n\n endDragGesture(event.pointerId);\n\n const focused = document.activeElement;\n if (focused instanceof HTMLElement && event.currentTarget.contains(focused)) {\n focused.blur();\n }\n },\n [calendar.selected, commitMultipleSelection, endDragGesture, getDayCellFromTarget, multipleSelection],\n );\n\n const handlePointerCancel = useCallback(\n (event: PointerEvent<HTMLElement>) => {\n const activeDrag = dragStateRef.current;\n if (!activeDrag || event.pointerId !== activeDrag.pointerId) {\n return;\n }\n\n endDragGesture(event.pointerId);\n },\n [endDragGesture],\n );\n\n return useMemo(() => {\n if (!multipleSelection) {\n return null;\n }\n\n return {\n multipleSelection,\n dragState,\n dragRectangle,\n previewSelectedKeys,\n suppressClickRef,\n surfaceRef,\n registerDay,\n handlePointerDownCapture,\n handlePointerMove,\n handlePointerUp,\n handlePointerCancel,\n };\n }, [\n dragRectangle,\n dragState,\n handlePointerCancel,\n handlePointerDownCapture,\n handlePointerMove,\n handlePointerUp,\n multipleSelection,\n previewSelectedKeys,\n registerDay,\n ]);\n}\n\nexport type CalendarDragRectangleOverlayProps = {\n dragRectangle?: DragRectangle | null;\n surfaceRef?: RefObject<HTMLElement | null>;\n};\n\nexport function CalendarDragRectangleOverlay({\n dragRectangle: dragRectangleProp,\n surfaceRef: surfaceRefProp,\n}: CalendarDragRectangleOverlayProps = {}) {\n const drag = useOptionalCalendarPeriodDrag();\n const dragRectangle = dragRectangleProp ?? drag?.dragRectangle ?? null;\n const surfaceRef = surfaceRefProp ?? drag?.surfaceRef;\n\n if (!dragRectangle) {\n return null;\n }\n\n const surface = surfaceRef?.current;\n if (!surface) {\n return null;\n }\n\n const surfaceRect = surface.getBoundingClientRect();\n const left = Math.min(dragRectangle.start.x, dragRectangle.current.x) - surfaceRect.left;\n const top = Math.min(dragRectangle.start.y, dragRectangle.current.y) - surfaceRect.top;\n const width = Math.abs(dragRectangle.current.x - dragRectangle.start.x);\n const height = Math.abs(dragRectangle.current.y - dragRectangle.start.y);\n\n return (\n <div\n aria-hidden=\"true\"\n calchemy-drag-rect=\"\"\n style={{\n position: \"absolute\",\n left,\n top,\n width,\n height,\n pointerEvents: \"none\",\n boxSizing: \"border-box\",\n }}\n />\n );\n}\n\nexport type CalendarPeriodDragProviderProps = {\n value: CalendarPeriodDragContextValue;\n children: React.ReactNode;\n};\n\nexport function CalendarPeriodDragProvider({ value, children }: CalendarPeriodDragProviderProps) {\n return (\n <CalendarPeriodDragContext.Provider value={value}>{children}</CalendarPeriodDragContext.Provider>\n );\n}\n\nexport function getMultipleDates(value: DateValue | null): PlainDate[] {\n return value?.kind === \"multiple\" ? value.dates : [];\n}\n\nexport function getSelectedDateKeys(value: DateValue | null): string[] {\n return getMultipleDates(value).map((date) => date.toString());\n}\n\nexport function toggleDateKeys(baseKeys: readonly string[], toggledKeys: readonly string[]): string[] {\n const next = new Set(baseKeys);\n for (const key of toggledKeys) {\n if (next.has(key)) {\n next.delete(key);\n } else {\n next.add(key);\n }\n }\n\n return Array.from(next).sort();\n}\n\nfunction getPointerPoint(event: Pick<PointerEvent, \"clientX\" | \"clientY\">): Point {\n return { x: event.clientX, y: event.clientY };\n}\n\nfunction hasPointerMoved(start: Point, current: Point): boolean {\n return Math.abs(start.x - current.x) > 2 || Math.abs(start.y - current.y) > 2;\n}\n\nfunction getDragRect(start: Point, current: Point): DOMRect {\n const left = Math.min(start.x, current.x);\n const right = Math.max(start.x, current.x);\n const top = Math.min(start.y, current.y);\n const bottom = Math.max(start.y, current.y);\n\n return {\n left,\n right,\n top,\n bottom,\n x: left,\n y: top,\n width: right - left,\n height: bottom - top,\n toJSON: () => ({}),\n } as DOMRect;\n}\n\nfunction snapshotCellBounds(cells: ReadonlyMap<string, DayCell>): Map<string, CellBounds> {\n const bounds = new Map<string, CellBounds>();\n for (const [key, cell] of cells) {\n const rect = cell.element.getBoundingClientRect();\n bounds.set(key, {\n left: rect.left,\n right: rect.right,\n top: rect.top,\n bottom: rect.bottom,\n });\n }\n\n return bounds;\n}\n\nfunction getDragClipRect(surface: HTMLElement | null): CellBounds | null {\n if (!surface) {\n return null;\n }\n\n const scrollContainer = surface.closest(\"[calchemy-scroll]\");\n if (!(scrollContainer instanceof HTMLElement)) {\n return null;\n }\n\n const rect = scrollContainer.getBoundingClientRect();\n\n return {\n left: rect.left,\n right: rect.right,\n top: rect.top,\n bottom: rect.bottom,\n };\n}\n\nfunction clipBoundsToRect(\n bounds: Pick<CellBounds, \"left\" | \"right\" | \"top\" | \"bottom\">,\n clip: CellBounds,\n): CellBounds | null {\n const left = Math.max(bounds.left, clip.left);\n const right = Math.min(bounds.right, clip.right);\n const top = Math.max(bounds.top, clip.top);\n const bottom = Math.min(bounds.bottom, clip.bottom);\n\n if (left > right || top > bottom) {\n return null;\n }\n\n return { left, right, top, bottom };\n}\n\nfunction getIntersectingDateKeys(\n cells: ReadonlyMap<string, DayCell>,\n dragRect: DOMRect,\n cellBounds: ReadonlyMap<string, CellBounds>,\n clipRect: CellBounds | null = null,\n): string[] {\n const clippedDragRect = clipRect ? clipBoundsToRect(dragRect, clipRect) : dragRect;\n if (!clippedDragRect) {\n return [];\n }\n\n return Array.from(cells.entries())\n .filter(([key, cell]) => {\n const bounds = cellBounds.get(key);\n if (!bounds || cell.disabled) {\n return false;\n }\n\n const visibleBounds = clipRect ? clipBoundsToRect(bounds, clipRect) : bounds;\n return visibleBounds && rectsIntersect(clippedDragRect, visibleBounds);\n })\n .map(([key]) => key);\n}\n\nfunction rectsIntersect(\n left: Pick<CellBounds, \"left\" | \"right\" | \"top\" | \"bottom\">,\n right: CellBounds,\n): boolean {\n return left.left <= right.right && left.right >= right.left && left.top <= right.bottom && left.bottom >= right.top;\n}\n\nfunction resolveDateKeys(\n keys: Iterable<string>,\n cells: ReadonlyMap<string, DayCell>,\n fallbackDates: readonly PlainDate[],\n): PlainDate[] {\n const fallbackByKey = new Map(fallbackDates.map((date) => [date.toString(), date]));\n return Array.from(keys)\n .sort()\n .flatMap((key) => {\n const date = cells.get(key)?.date ?? fallbackByKey.get(key);\n return date ? [date] : [];\n });\n}\n","import type {\n DateOrder,\n DateValue,\n NamedDatesVocabularyEntry,\n PlainDate,\n WeekdayIndex,\n} from \"@calchemy/date-core\";\nimport type { CalchemyState } from \"../../hooks/useCalchemy\";\nimport type {\n CalendarBounds,\n CalendarDayState,\n CalendarDuration,\n CalendarPeriodModel,\n CalendarPeriodUnit,\n CalendarState,\n CalendarWeekdayFormat,\n ParsedCalendarPeriod,\n} from \"./types\";\n\nconst defaultDateOrderPreference: DateOrder[] = [\"DMY\", \"MDY\", \"YMD\"];\ntype NamedDateResolveContext = Parameters<NamedDatesVocabularyEntry[\"resolveDate\"]>[0][\"context\"];\n\nexport function getFirstVisibleCalendarPeriod(calendar: CalendarState): CalendarPeriodModel {\n const period = calendar.visiblePeriods[0];\n if (!period) {\n throw new Error(\"Calchemy.Calendar requires at least one visible generated period.\");\n }\n\n return period;\n}\n\nexport function getCalendarDayState(\n calendar: CalendarState,\n period: CalendarPeriodModel,\n date: PlainDate,\n): CalendarDayState {\n const bounded = isDateWithinBounds(date, calendar.bounds);\n const namedDates = getNamedDatesForDate(calendar, date);\n const disabled =\n !bounded || (calendar.isDateDisabled?.(date, calendar) ?? false);\n\n return {\n outside: isBefore(date, period.start) || isAfter(date, period.end),\n selected: isSelectedDate(calendar.selected, date),\n today: calendar.today.equals(date),\n weekend: isWeekend(date),\n firstOfPeriod: date.equals(period.start),\n lastOfPeriod: date.equals(period.end),\n bounded,\n disabled,\n namedDates,\n };\n}\n\nexport function parseCalendarDuration(value: CalendarDuration, propName: string): ParsedCalendarPeriod {\n const hasMonths = \"months\" in value;\n const hasWeeks = \"weeks\" in value;\n if (hasMonths === hasWeeks) {\n throw new Error(`Calchemy.Calendar ${propName} must include exactly one of months or weeks.`);\n }\n\n const count = hasMonths ? value.months : value.weeks;\n if (!Number.isInteger(count) || count < 1) {\n throw new Error(`Calchemy.Calendar ${propName} must be a positive integer duration.`);\n }\n\n return {\n unit: hasMonths ? \"month\" : \"week\",\n count,\n };\n}\n\nexport function validateCalendarBounds(bounds: CalendarBounds | undefined): void {\n if (bounds?.start && bounds.end && isAfter(bounds.start, bounds.end)) {\n throw new Error(\"Calchemy.Calendar bounds.start must be on or before bounds.end.\");\n }\n}\n\nexport function clampDateToBounds(date: PlainDate, bounds: CalendarBounds | undefined): PlainDate {\n if (bounds?.start && isBefore(date, bounds.start)) {\n return bounds.start;\n }\n if (bounds?.end && isAfter(date, bounds.end)) {\n return bounds.end;\n }\n\n return date;\n}\n\nfunction isDateWithinBounds(date: PlainDate, bounds: CalendarBounds | undefined): boolean {\n return (!bounds?.start || !isBefore(date, bounds.start)) && (!bounds?.end || !isAfter(date, bounds.end));\n}\n\nexport function periodIntersectsBounds(period: CalendarPeriodModel, bounds: CalendarBounds | undefined): boolean {\n return (!bounds?.start || !isBefore(period.end, bounds.start)) && (!bounds?.end || !isAfter(period.start, bounds.end));\n}\n\nexport function getCalendarPeriodAtOffset(\n anchor: PlainDate,\n period: ParsedCalendarPeriod,\n weekStartsOn: WeekdayIndex,\n locale: string,\n offset: number,\n): CalendarPeriodModel {\n const firstStart = period.unit === \"month\" ? startOfMonth(anchor) : startOfWeek(anchor, weekStartsOn);\n const start = addCalendarPeriod(firstStart, period.unit, offset);\n const end = period.unit === \"month\" ? endOfMonth(start) : start.add({ days: 6 });\n\n return {\n id: `${period.unit}-${start.toString()}`,\n unit: period.unit,\n index: offset,\n start,\n end,\n label: formatPeriodLabel(start, end, period.unit, locale),\n };\n}\n\nexport function getInitialPeriodExtensions(period: ParsedCalendarPeriod): { before: number; after: number } {\n return {\n before: period.count * 6,\n after: period.count * 3,\n };\n}\n\nexport function getSelectedValue(state: CalchemyState): DateValue | null {\n const resultValue = getResultValue(state);\n return state.value ?? resultValue;\n}\n\nexport function getDateValueAnchor(value: DateValue | null): PlainDate | null {\n if (!value) {\n return null;\n }\n\n switch (value.kind) {\n case \"single\":\n return value.date;\n case \"range\":\n return value.start;\n case \"multiple\":\n return value.dates[0] ?? null;\n }\n}\n\nexport function getDateValueKey(value: DateValue | null): string {\n if (!value) {\n return \"\";\n }\n\n switch (value.kind) {\n case \"single\":\n return `single:${value.date.toString()}`;\n case \"range\":\n return `range:${value.start.toString()}:${value.end.toString()}`;\n case \"multiple\":\n return `multiple:${value.dates.map((date) => date.toString()).join(\",\")}`;\n }\n}\n\nexport function isDateInCalendarViewport(\n date: PlainDate,\n periods: readonly CalendarPeriodModel[],\n visiblePeriodIndex: number,\n windowCount: number,\n): boolean {\n return periods\n .filter(\n (period) =>\n period.index >= visiblePeriodIndex && period.index < visiblePeriodIndex + windowCount,\n )\n .some((period) => !isBefore(date, period.start) && !isAfter(date, period.end));\n}\n\nfunction getResultValue(state: CalchemyState): DateValue | null {\n return state.result.status === \"valid\" ? state.result.value : null;\n}\n\nexport function getToday(state: CalchemyState): PlainDate {\n if (state.parseContext?.referenceDate) {\n return state.parseContext.referenceDate;\n }\n\n const todayResult = state.calchemy.parseDate(\"today\", state.parseContext);\n if (todayResult.status === \"valid\" && todayResult.value.kind === \"single\") {\n return todayResult.value.date;\n }\n\n return state.calchemy.Temporal.Now.plainDateISO(state.parseContext?.timeZone);\n}\n\nexport function buildCalendarPeriods(\n anchor: PlainDate,\n period: ParsedCalendarPeriod,\n weekStartsOn: WeekdayIndex,\n locale: string,\n extensions: { before: number; after: number },\n bounds?: CalendarBounds,\n): CalendarPeriodModel[] {\n const total = extensions.before + period.count + extensions.after;\n\n return Array.from({ length: total }, (_, index) => {\n const offset = index - extensions.before;\n return getCalendarPeriodAtOffset(anchor, period, weekStartsOn, locale, offset);\n }).filter((item) => periodIntersectsBounds(item, bounds));\n}\n\nexport function buildCalendarWeeks(period: CalendarPeriodModel, weekStartsOn: WeekdayIndex): PlainDate[][] {\n const start = startOfWeek(period.start, weekStartsOn);\n const end = endOfWeek(period.end, weekStartsOn);\n const weeks: PlainDate[][] = [];\n let cursor = start;\n\n while (!isAfter(cursor, end)) {\n const week = Array.from({ length: 7 }, (_, index) => cursor.add({ days: index }));\n weeks.push(week);\n cursor = cursor.add({ days: 7 });\n }\n\n return weeks;\n}\n\nexport function buildWeekdays(\n calendar: CalendarState,\n weekdayFormat: CalendarWeekdayFormat = \"short\",\n): Array<{ index: number; label: string; weekend: boolean }> {\n const sunday = startOfWeek(calendar.today, 0);\n const first = startOfWeek(calendar.today, calendar.weekStartsOn);\n\n return Array.from({ length: 7 }, (_, index) => {\n const date = first.add({ days: index });\n const weekdayIndex = sunday.until(date).days % 7;\n return {\n index: weekdayIndex,\n label: date.toLocaleString(calendar.locale, { weekday: weekdayFormat }),\n weekend: isWeekend(date),\n };\n });\n}\n\nexport function addCalendarPeriod(date: PlainDate, unit: CalendarPeriodUnit, count: number): PlainDate {\n return unit === \"month\" ? date.add({ months: count }) : date.add({ weeks: count });\n}\n\nexport function formatCalendarWindowLabel(periods: CalendarPeriodModel[], locale: string): string {\n const first = periods[0];\n const last = periods.at(-1);\n if (!first || !last) {\n return \"\";\n }\n if (first.start.equals(last.start) && first.end.equals(last.end)) {\n return first.label;\n }\n\n return `${formatDateLabel(first.start, locale)} - ${formatDateLabel(last.end, locale)}`;\n}\n\nexport function formatMonthLabel(date: PlainDate, locale: string): string {\n return date.toLocaleString(locale, { month: \"long\" });\n}\n\nfunction startOfMonth(date: PlainDate): PlainDate {\n return date.with({ day: 1 });\n}\n\nfunction endOfMonth(date: PlainDate): PlainDate {\n return startOfMonth(date).add({ months: 1 }).subtract({ days: 1 });\n}\n\nfunction startOfWeek(date: PlainDate, weekStartsOn: WeekdayIndex): PlainDate {\n const temporalWeekday = weekStartsOn === 0 ? 7 : weekStartsOn;\n let cursor = date;\n\n while (cursor.dayOfWeek !== temporalWeekday) {\n cursor = cursor.subtract({ days: 1 });\n }\n\n return cursor;\n}\n\nfunction endOfWeek(date: PlainDate, weekStartsOn: WeekdayIndex): PlainDate {\n return startOfWeek(date, weekStartsOn).add({ days: 6 });\n}\n\nexport function isBefore(left: PlainDate, right: PlainDate): boolean {\n return left.toString() < right.toString();\n}\n\nexport function isAfter(left: PlainDate, right: PlainDate): boolean {\n return left.toString() > right.toString();\n}\n\nfunction isSelectedDate(value: DateValue | null, date: PlainDate): boolean {\n if (!value) {\n return false;\n }\n\n switch (value.kind) {\n case \"single\":\n return value.date.equals(date);\n case \"range\":\n return !isBefore(date, value.start) && !isAfter(date, value.end);\n case \"multiple\":\n return value.dates.some((selectedDate) => selectedDate.equals(date));\n }\n}\n\nfunction isWeekend(date: PlainDate): boolean {\n return date.dayOfWeek === 6 || date.dayOfWeek === 7;\n}\n\nfunction getNamedDatesForDate(calendar: CalendarState, date: PlainDate) {\n if (!calendar.namedDates) {\n return [];\n }\n\n const context = getResolvedNamedDateContext(calendar);\n return calendar.calchemy.calchemy.namedDatesVocabulary.filter((entry) => {\n if (calendar.namedDates === \"holidays\" && !entry.isHoliday) {\n return false;\n }\n\n return entry.resolveDate({ year: date.year, context })?.equals(date) ?? false;\n });\n}\n\nfunction getResolvedNamedDateContext(calendar: CalendarState): NamedDateResolveContext {\n const context = calendar.calchemy.parseContext;\n\n return {\n referenceDate:\n context?.referenceDate ??\n calendar.calchemy.calchemy.Temporal.Now.plainDateISO(context?.timeZone),\n locale: context?.locale ?? \"en-US\",\n weekStartsOn: context?.weekStartsOn ?? 0,\n dateOrderPreference: normalizeDateOrderPreference(context?.dateOrderPreference),\n lastNDaysIncludesToday: context?.lastNDaysIncludesToday ?? true,\n };\n}\n\nfunction normalizeDateOrderPreference(value: DateOrder[] | undefined): DateOrder[] {\n if (!value || value.length === 0) {\n return defaultDateOrderPreference;\n }\n\n return Array.from(new Set(value));\n}\n\nfunction formatPeriodLabel(start: PlainDate, end: PlainDate, unit: CalendarPeriodUnit, locale: string): string {\n if (unit === \"month\") {\n return formatDateLabel(start, locale);\n }\n\n return `${start.toLocaleString(locale, { month: \"short\", day: \"numeric\" })} - ${end.toLocaleString(locale, {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n })}`;\n}\n\nfunction formatDateLabel(date: PlainDate, locale: string): string {\n return date.toLocaleString(locale, { month: \"long\", year: \"numeric\" });\n}\n","import type { ComponentPropsWithoutRef } from \"react\";\nimport { useCalchemyCalendar, useCalendarPeriod } from \"./context\";\nimport { getFirstVisibleCalendarPeriod } from \"./date-model\";\n\nexport type CalchemyCalendarPeriodHeadingProps = ComponentPropsWithoutRef<\"h3\">;\n\nexport function CalendarPeriodHeading(props: CalchemyCalendarPeriodHeadingProps) {\n const calendar = useCalchemyCalendar();\n const period = useCalendarPeriod() ?? getFirstVisibleCalendarPeriod(calendar);\n\n return (\n <h3 {...props} calchemy-period-heading=\"\">\n {props.children ?? period.label}\n </h3>\n );\n}\n","import { useContext } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport { CalendarPeriodContext, useCalchemyCalendar } from \"./context\";\nimport {\n CalendarDragRectangleOverlay,\n CalendarPeriodDragProvider,\n mergeCalendarDragPointerProps,\n multipleDragSurfaceStyle,\n useCalendarPeriodDragSurface,\n useOptionalCalendarPeriodDrag,\n} from \"./calendar-period-drag\";\n\nexport type CalchemyCalendarPeriodProps = ComponentPropsWithoutRef<\"section\"> & {\n dragSelection?: boolean;\n};\n\nexport function CalendarPeriod({\n dragSelection = true,\n style,\n children,\n onPointerDownCapture,\n onPointerMove,\n onPointerUp,\n onPointerCancel,\n onDragStart,\n ...props\n}: CalchemyCalendarPeriodProps) {\n const period = useContext(CalendarPeriodContext);\n const calendar = useCalchemyCalendar();\n const parentDrag = useOptionalCalendarPeriodDrag();\n const drag = useCalendarPeriodDragSurface(\n calendar.editable && dragSelection && parentDrag === null,\n );\n\n const content = drag ? (\n <CalendarPeriodDragProvider value={drag}>\n <CalendarDragRectangleOverlay />\n {children}\n </CalendarPeriodDragProvider>\n ) : (\n children\n );\n const dragPointerProps = mergeCalendarDragPointerProps(Boolean(drag), drag, {\n onPointerDownCapture,\n onPointerMove,\n onPointerUp,\n onPointerCancel,\n onDragStart,\n });\n\n return (\n <section\n {...props}\n calchemy-period=\"\"\n calchemy-period-id={period?.id}\n calchemy-period-index={period?.index}\n calchemy-multiple-drag={drag ? \"\" : undefined}\n calchemy-dragging={drag?.dragState ? \"\" : undefined}\n style={\n drag\n ? { ...multipleDragSurfaceStyle, ...style }\n : parentDrag\n ? { touchAction: \"none\", ...style }\n : style\n }\n {...dragPointerProps}\n >\n {content}\n </section>\n );\n}\n","import { useContext, useLayoutEffect, useRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport { CalendarPeriodContext, CalendarScrollContext, useCalchemyCalendar } from \"./context\";\nimport { CalendarGrid, CalendarWeekdays } from \"./CalendarGrid\";\nimport { CalendarPeriodHeading } from \"./CalendarPeriodHeading\";\nimport { CalendarPeriod } from \"./CalendarPeriod\";\nimport {\n CalendarDragRectangleOverlay,\n CalendarPeriodDragProvider,\n mergeCalendarDragPointerProps,\n multiplePeriodListDragSurfaceStyle,\n useCalendarPeriodDragSurface,\n useOptionalCalendarPeriodDrag,\n} from \"./calendar-period-drag\";\n\nexport type CalchemyCalendarPeriodListProps = ComponentPropsWithoutRef<\"div\"> & {\n dragSelection?: boolean;\n};\n\nexport function CalendarPeriodList({\n children,\n dragSelection = true,\n style,\n onPointerDownCapture,\n onPointerMove,\n onPointerUp,\n onPointerCancel,\n onDragStart,\n ...props\n}: CalchemyCalendarPeriodListProps) {\n const calendar = useCalchemyCalendar();\n const scrollContext = useContext(CalendarScrollContext);\n const parentDrag = useOptionalCalendarPeriodDrag();\n const surfaceRef = useRef<HTMLDivElement | null>(null);\n const hitCaptureRef = useRef<HTMLDivElement | null>(null);\n const drag = useCalendarPeriodDragSurface(\n calendar.editable && dragSelection && parentDrag === null,\n surfaceRef,\n );\n const periods = scrollContext ? calendar.periods : calendar.visiblePeriods;\n\n useLayoutEffect(() => {\n if (!drag) {\n return;\n }\n\n const surface = surfaceRef.current;\n const hitCapture = hitCaptureRef.current;\n if (!surface || !hitCapture) {\n return;\n }\n\n const updateDragHitBounds = () => {\n const periodElements = surface.querySelectorAll<HTMLElement>(\"[calchemy-period]\");\n if (periodElements.length === 0) {\n hitCapture.style.removeProperty(\"inline-size\");\n hitCapture.style.removeProperty(\"block-size\");\n return;\n }\n\n let maxInlineEnd = 0;\n let maxBlockEnd = 0;\n for (const periodElement of periodElements) {\n maxInlineEnd = Math.max(maxInlineEnd, periodElement.offsetLeft + periodElement.offsetWidth);\n maxBlockEnd = Math.max(maxBlockEnd, periodElement.offsetTop + periodElement.offsetHeight);\n }\n\n hitCapture.style.inlineSize = `${maxInlineEnd}px`;\n hitCapture.style.blockSize = `${maxBlockEnd}px`;\n };\n\n updateDragHitBounds();\n\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n\n const resizeObserver = new ResizeObserver(updateDragHitBounds);\n resizeObserver.observe(surface);\n for (const periodElement of surface.querySelectorAll<HTMLElement>(\"[calchemy-period]\")) {\n resizeObserver.observe(periodElement);\n }\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [drag, periods]);\n\n const spacerStyle =\n scrollContext?.direction === \"horizontal\"\n ? { gridColumn: `span ${scrollContext.leadingSpacerPeriodCount}` }\n : { blockSize: `${scrollContext?.leadingSpacerPixelSize ?? 0}px` };\n\n const periodContent = (\n <>\n {scrollContext && scrollContext.leadingSpacerPeriodCount > 0 ? (\n <div\n aria-hidden=\"true\"\n calchemy-scroll-spacer=\"\"\n style={spacerStyle}\n />\n ) : null}\n {periods.map((period) => (\n <CalendarPeriodContext.Provider key={period.id} value={period}>\n {children ?? (\n <CalendarPeriod>\n <CalendarPeriodHeading />\n <CalendarWeekdays />\n <CalendarGrid />\n </CalendarPeriod>\n )}\n </CalendarPeriodContext.Provider>\n ))}\n </>\n );\n\n const content = drag ? (\n <CalendarPeriodDragProvider value={drag}>\n <div\n ref={hitCaptureRef}\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n zIndex: 0,\n pointerEvents: \"auto\",\n touchAction: \"none\",\n }}\n />\n <CalendarDragRectangleOverlay />\n {periodContent}\n </CalendarPeriodDragProvider>\n ) : (\n periodContent\n );\n const dragPointerProps = mergeCalendarDragPointerProps(Boolean(drag), drag, {\n onPointerDownCapture,\n onPointerMove,\n onPointerUp,\n onPointerCancel,\n onDragStart,\n });\n\n return (\n <div\n {...props}\n ref={surfaceRef}\n calchemy-period-list=\"\"\n calchemy-multiple-drag={drag ? \"\" : undefined}\n calchemy-dragging={drag?.dragState ? \"\" : undefined}\n style={drag ? { ...multiplePeriodListDragSurfaceStyle, ...style } : style}\n {...dragPointerProps}\n >\n {content}\n </div>\n );\n}\n","import type { ComponentPropsWithoutRef, ChangeEvent } from \"react\";\nimport { useCalchemyCalendar } from \"./context\";\nimport { formatMonthLabel, isAfter, isBefore } from \"./date-model\";\n\nexport type CalchemyCalendarMonthSelectProps = Omit<ComponentPropsWithoutRef<\"select\">, \"value\" | \"onChange\"> & {\n onChange?: ComponentPropsWithoutRef<\"select\">[\"onChange\"];\n};\n\nexport function CalendarMonthSelect({ onChange, ...props }: CalchemyCalendarMonthSelectProps) {\n const calendar = useCalchemyCalendar();\n const months = Array.from({ length: 12 }, (_, index) => index + 1).filter((month) =>\n isMonthWithinBounds(calendar.visiblePeriodAnchor.with({ month, day: 1 }), calendar),\n );\n\n return (\n <select\n {...props}\n calchemy-month-select=\"\"\n value={String(calendar.visiblePeriodAnchor.month)}\n onChange={(event) =>\n handleCalendarSelectChange(event, onChange, (value) =>\n calendar.setPeriodAnchor(calendar.visiblePeriodAnchor.with({ month: value, day: 1 })),\n )\n }\n >\n {months.map((month) => {\n const date = calendar.visiblePeriodAnchor.with({ month, day: 1 });\n return (\n <option key={month} value={String(month)}>\n {formatMonthLabel(date, calendar.locale)}\n </option>\n );\n })}\n </select>\n );\n}\n\nexport type CalchemyCalendarYearSelectProps = Omit<ComponentPropsWithoutRef<\"select\">, \"value\" | \"onChange\"> & {\n startYear?: number;\n endYear?: number;\n onChange?: ComponentPropsWithoutRef<\"select\">[\"onChange\"];\n};\n\nexport function CalendarYearSelect({ startYear, endYear, onChange, ...props }: CalchemyCalendarYearSelectProps) {\n const calendar = useCalchemyCalendar();\n const visibleYear = calendar.visiblePeriodAnchor.year;\n const firstYear = Math.min(calendar.bounds?.start?.year ?? startYear ?? visibleYear - 100, visibleYear);\n const lastYear = Math.max(calendar.bounds?.end?.year ?? endYear ?? visibleYear + 100, visibleYear);\n\n return (\n <select\n {...props}\n calchemy-year-select=\"\"\n value={String(visibleYear)}\n onChange={(event) =>\n handleCalendarSelectChange(event, onChange, (value) =>\n calendar.setPeriodAnchor(calendar.visiblePeriodAnchor.with({ year: value, day: 1 })),\n )\n }\n >\n {Array.from({ length: lastYear - firstYear + 1 }, (_, index) => firstYear + index).map((year) => (\n <option key={year} value={String(year)}>\n {year}\n </option>\n ))}\n </select>\n );\n}\n\nfunction handleCalendarSelectChange(\n event: ChangeEvent<HTMLSelectElement>,\n onChange: ComponentPropsWithoutRef<\"select\">[\"onChange\"] | undefined,\n updatePeriodAnchor: (value: number) => void,\n): void {\n onChange?.(event);\n if (event.defaultPrevented) {\n return;\n }\n\n updatePeriodAnchor(Number(event.currentTarget.value));\n}\n\nfunction isMonthWithinBounds(\n monthStart: ReturnType<typeof useCalchemyCalendar>[\"visiblePeriodAnchor\"],\n calendar: ReturnType<typeof useCalchemyCalendar>,\n): boolean {\n const monthEnd = monthStart.add({ months: 1 }).subtract({ days: 1 });\n\n return (\n (!calendar.bounds?.start || !isBefore(monthEnd, calendar.bounds.start)) &&\n (!calendar.bounds?.end || !isAfter(monthStart, calendar.bounds.end))\n );\n}\n","import type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { CalchemyContext, useCalchemyContext } from \"./calendar/context\";\nimport { useCalchemy, type UseCalchemyOptions } from \"../hooks/useCalchemy\";\nimport {\n Calendar,\n CalendarHeader,\n CalendarHeading,\n CalendarNext,\n CalendarPrevious,\n} from \"./calendar/Calendar\";\nimport { CalendarGrid, CalendarWeekdays } from \"./calendar/CalendarGrid\";\nimport { CalendarPeriodHeading } from \"./calendar/CalendarPeriodHeading\";\nimport { CalendarPeriod } from \"./calendar/CalendarPeriod\";\nimport { CalendarPeriodList } from \"./calendar/CalendarPeriodList\";\nimport {\n CalendarMonthSelect,\n CalendarYearSelect,\n} from \"./calendar/CalendarSelects\";\n\nexport type CalchemyRootProps = UseCalchemyOptions & {\n children: ReactNode;\n};\n\nfunction Root(props: CalchemyRootProps) {\n const { children, ...options } = props;\n const state = useCalchemy(options);\n\n return (\n <CalchemyContext.Provider value={state}>\n {children}\n </CalchemyContext.Provider>\n );\n}\n\nexport type CalchemyFieldProps = Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"value\" | \"onChange\" | \"onKeyDown\"\n> & {\n renderInlineCompletion?: boolean;\n};\n\nfunction Field({\n renderInlineCompletion = true,\n readOnly,\n ...props\n}: CalchemyFieldProps) {\n const state = useCalchemyContext();\n const inputProps = state.getInputProps();\n const completion =\n state.inputMode === \"field\" ? state.inlineCompletion : null;\n\n return (\n <span\n calchemy-field=\"\"\n calchemy-input-mode={state.inputMode}\n calchemy-has-completion={completion ? \"\" : undefined}\n >\n {renderInlineCompletion && completion ? (\n <span calchemy-field-backdrop=\"\" aria-hidden=\"true\">\n <span calchemy-field-typed=\"\">{state.inputValue}</span>\n <span calchemy-completions=\"\">{completion.suffix}</span>\n </span>\n ) : null}\n <input {...props} {...inputProps} readOnly={readOnly ?? inputProps.readOnly} />\n </span>\n );\n}\n\nexport type CalchemyInputModeProps = ComponentPropsWithoutRef<\"div\"> & {\n fieldLabel?: ReactNode;\n calendarLabel?: ReactNode;\n};\n\nfunction InputMode({\n fieldLabel = \"Type\",\n calendarLabel = \"Pick\",\n ...props\n}: CalchemyInputModeProps) {\n const state = useCalchemyContext();\n\n return (\n <div {...props} calchemy-mode=\"\" calchemy-active={state.inputMode} role=\"group\">\n <button\n type=\"button\"\n calchemy-value=\"field\"\n aria-pressed={state.inputMode === \"field\"}\n onClick={() => state.setInputMode(\"field\")}\n >\n {fieldLabel}\n </button>\n <button\n type=\"button\"\n calchemy-value=\"calendar\"\n aria-pressed={state.inputMode === \"calendar\"}\n onClick={() => state.setInputMode(\"calendar\")}\n >\n {calendarLabel}\n </button>\n </div>\n );\n}\n\nexport type CalchemyCandidatesProps = ComponentPropsWithoutRef<\"div\">;\n\nfunction Candidates(props: CalchemyCandidatesProps) {\n const state = useCalchemyContext();\n\n if (state.inputMode !== \"field\" || state.result.status !== \"ambiguous\") {\n return null;\n }\n\n const candidates =\n state.expectedValue && state.expectedValue !== \"multiple\"\n ? state.result.candidates.filter(\n (candidate) => candidate.value.kind === state.expectedValue,\n )\n : state.result.candidates;\n\n if (candidates.length === 0) {\n return null;\n }\n\n return (\n <div {...props} calchemy-candidates=\"\">\n {candidates.map((candidate) => (\n <button\n type=\"button\"\n key={candidate.id}\n calchemy-candidate=\"\"\n onClick={() => state.selectCandidate(candidate.id)}\n >\n {candidate.label}\n </button>\n ))}\n </div>\n );\n}\n\nexport { useCalchemyCalendar, useCalchemyContext } from \"./calendar/context\";\n\nexport type {\n CalendarBounds,\n CalendarDuration,\n CalendarNamedDates,\n CalendarPeriodModel,\n CalendarPeriodUnit,\n CalendarState,\n CalendarWeekdayFormat,\n ParsedCalendarPeriod,\n} from \"./calendar/types\";\nexport type {\n CalchemyCalendarHeaderProps,\n CalchemyCalendarHeadingProps,\n CalchemyCalendarNavigationProps,\n CalchemyCalendarProps,\n} from \"./calendar/Calendar\";\nexport type {\n CalchemyCalendarGridProps,\n CalchemyCalendarWeekdaysProps,\n} from \"./calendar/CalendarGrid\";\nexport type { CalchemyCalendarPeriodHeadingProps } from \"./calendar/CalendarPeriodHeading\";\nexport type { CalchemyCalendarPeriodListProps } from \"./calendar/CalendarPeriodList\";\nexport type { CalchemyCalendarPeriodProps } from \"./calendar/CalendarPeriod\";\nexport type {\n CalchemyCalendarMonthSelectProps,\n CalchemyCalendarYearSelectProps,\n} from \"./calendar/CalendarSelects\";\n\nexport const Calchemy = {\n Root,\n Field,\n InputMode,\n Candidates,\n Calendar,\n CalendarHeader,\n CalendarHeading,\n CalendarPrevious,\n CalendarNext,\n CalendarPeriodList,\n CalendarPeriod,\n CalendarPeriodHeading,\n CalendarWeekdays,\n CalendarGrid,\n CalendarMonthSelect,\n CalendarYearSelect,\n};\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,aAAAA,YAAW,SAAS,YAAAC,iBAAgB;A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AAA,QACL,kBAAe;AAAA,QACf,gBAAc,MAAM,cAAc;AAAA,QAClC,SAAS,MAAM,MAAM,aAAa,UAAU;AAAA,QAE3C;AAAA;AAAA,IACH;AAAA,KACF;AAEJ;AAIA,SAAS,WAAW,OAAgC;AAClD,QAAM,QAAQ,mBAAmB;AAEjC,MAAI,MAAM,cAAc,WAAW,MAAM,OAAO,WAAW,aAAa;AACtE,WAAO;AAAA,EACT;AAEA,QAAM,aACJ,MAAM,iBAAiB,MAAM,kBAAkB,aAC3C,MAAM,OAAO,WAAW;AAAA,IACtB,CAAC,cAAc,UAAU,MAAM,SAAS,MAAM;AAAA,EAChD,IACA,MAAM,OAAO;AAEnB,MAAI,WAAW,WAAW,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,SACE,gBAAAA,KAAC,SAAK,GAAG,OAAO,uBAAoB,IACjC,qBAAW,IAAI,CAAC,cACf,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MAEL,sBAAmB;AAAA,MACnB,SAAS,MAAM,MAAM,gBAAgB,UAAU,EAAE;AAAA,MAEhD,oBAAU;AAAA;AAAA,IAJN,UAAU;AAAA,EAKjB,CACD,GACH;AAEJ;AAgCO,IAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["useEffect","useState","useState","useEffect","useEffect","useMemo","useRef","useState","useMemo","useMemo","useState","useState","useMemo","jsx","useMemo","jsx","jsxs","useMemo","useState","useRef","useEffect","jsx","useContext","jsx","jsxs","useContext","useContext","useLayoutEffect","useRef","Fragment","jsx","jsxs","useContext","useRef","useLayoutEffect","jsx","jsx","jsxs"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calchemy/date-react",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Headless React primitives for Calchemy date input.",
6
6
  "license": "MIT",
@@ -23,18 +23,20 @@
23
23
  "exports": {
24
24
  ".": {
25
25
  "types": "./dist/index.d.ts",
26
- "import": "./dist/index.js"
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs"
27
28
  },
28
29
  "./calendar-scroll": {
29
30
  "types": "./dist/calendar-scroll.d.ts",
30
- "import": "./dist/calendar-scroll.js"
31
+ "import": "./dist/calendar-scroll.js",
32
+ "require": "./dist/calendar-scroll.cjs"
31
33
  }
32
34
  },
33
35
  "files": [
34
36
  "dist"
35
37
  ],
36
38
  "dependencies": {
37
- "@calchemy/date-core": "0.1.0"
39
+ "@calchemy/date-core": "0.1.2"
38
40
  },
39
41
  "peerDependencies": {
40
42
  "react": ">=18.3.0 || >=19.0.0",
@@ -47,7 +49,7 @@
47
49
  },
48
50
  "devDependencies": {},
49
51
  "scripts": {
50
- "build": "tsup src/index.ts src/calendar-scroll.ts --format esm --sourcemap --tsconfig tsconfig.build.json --external react --external react-dom --external react/jsx-runtime --external @calchemy/date-core && tsc -p tsconfig.build.json --emitDeclarationOnly",
52
+ "build": "tsup src/index.ts src/calendar-scroll.ts --format esm,cjs --sourcemap --tsconfig tsconfig.build.json --external react --external react-dom --external react/jsx-runtime --external @calchemy/date-core && tsc -p tsconfig.build.json --emitDeclarationOnly",
51
53
  "test": "pnpm run build && vitest run --root ../.. --config vitest.config.ts packages/date-react/tests --environment jsdom",
52
54
  "typecheck": "tsc -b && tsc -p tsconfig.test.json --noEmit",
53
55
  "clean": "rm -rf dist tsconfig.tsbuildinfo"