@yamada-ui/react 2.2.11-dev-20261013044619 → 2.2.11-dev-20261013064254

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.
@@ -1 +1 @@
1
- {"version":3,"file":"use-date-picker.cjs","names":["DEFAULT_MAX_DATE","DEFAULT_MIN_DATE","useEnvironment","useI18n","useFieldProps","useDateTimeFormat","useMemo","useCalendarProps","useRef","useState","useControllableState","getAdjustedMonth","useCallback","isBeforeDate","isAfterDate","useCombobox","updateMaybeDateValue","isValidElement","cloneElement","isComposing","isIncludeDates","mergeRefs","visuallyHiddenAttributes","runKeyAction"],"sources":["../../../../src/components/date-picker/use-date-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type {\n CalendarFormat,\n MaybeDateValue,\n UseCalendarProps,\n} from \"../calendar\"\nimport type { FieldProps } from \"../field\"\nimport dayjs from \"dayjs\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useEnvironment } from \"../../core\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n dataAttr,\n focusTransfer,\n handlerAll,\n isActiveElement,\n isArray,\n isComposing,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport {\n DEFAULT_MAX_DATE,\n DEFAULT_MIN_DATE,\n getAdjustedMonth,\n isAfterDate,\n isBeforeDate,\n isIncludeDates,\n updateMaybeDateValue,\n useCalendarProps,\n} from \"../calendar\"\nimport { useFieldProps } from \"../field\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport interface DatePickerFormat extends CalendarFormat {\n input?: Intl.DateTimeFormatOptions | null\n}\n\ntype InputAlign = \"end\" | \"start\"\ntype MaybeInputValue<Range extends boolean = false> = Range extends true\n ? { end?: string; start?: string }\n : string | undefined\n\ninterface DatePickerRenderProps {\n count: number\n date: Date\n focused: boolean\n index: number\n separator: string\n value: string\n onClear: () => void\n max?: number\n}\n\nexport interface DatePickerRender {\n (props: DatePickerRenderProps): ReactNode\n}\n\nconst defaultRender: DatePickerRender = ({\n count,\n focused,\n index,\n max,\n separator,\n value,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {value}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nexport interface UseDatePickerProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<UseCalendarProps<Multiple, Range>, \"format\" | \"ref\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, allows input of dates beyond the `minDate` and `maxDate` restrictions.\n *\n * @default true\n */\n allowInputBeyond?: boolean\n /**\n * If `true`, the date picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: MaybeInputValue<Range>\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The format used for conversion.\n * Check the docs to see the format of possible modifiers you can pass.\n *\n * @see https://day.js.org/docs/en/display/format#list-of-localized-formats\n */\n format?: DatePickerFormat\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: MaybeInputValue<Range>\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the date picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the date picker will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for date picker.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: MaybeInputValue<Range>) => void\n /**\n * Function that converts the input value to Date type.\n */\n parseDate?: (value: string) => Date | undefined\n /**\n * The function to render the selected date.\n */\n render?: (props: DatePickerRenderProps) => ReactNode\n}\n\nexport const useDatePicker = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n ...props\n}: UseDatePickerProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { getDocument } = useEnvironment()\n const { locale: defaultLocale, t } = useI18n(\"datePicker\")\n const {\n props: {\n id,\n ref,\n name,\n allowInput = true,\n allowInputBeyond = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultMonth = new Date(),\n range = false,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled,\n focusOnClear = true,\n format,\n inputValue: inputValueProp,\n locale = defaultLocale,\n max,\n month: monthProp,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n parseDate,\n pattern,\n placeholder: placeholderProp,\n placement = \"end-start\",\n readOnly,\n render = defaultRender,\n required,\n separator = range ? \"-\" : \",\",\n value: valueProp,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n onInputChange: onInputChangeProp,\n ...computedProps\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const dateTimeFormat = useDateTimeFormat({ locale })\n const { calendarFormat, inputFormat } = useMemo(() => {\n const { input: inputFormat, ...calendarFormat } = format ?? {}\n const defaultInputFormat: Intl.DateTimeFormatOptions = {\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n }\n\n return {\n calendarFormat,\n inputFormat:\n inputFormat !== null ? (inputFormat ?? defaultInputFormat) : undefined,\n }\n }, [format])\n const [calendarProps, rest] = useCalendarProps<Multiple, Range>(computedProps)\n const { excludeDate } = calendarProps\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const startInputRef = useRef<HTMLInputElement>(null)\n const endInputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue as MaybeDateValue<Multiple, Range>,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n let value = defaultMonth\n\n if (dayjs(minDate).isAfter(dayjs(defaultMonth)))\n value = dayjs(minDate).set(\"date\", 1).toDate()\n\n if (valueProp) value = getAdjustedMonth(valueProp, value)\n else if (defaultValue) value = getAdjustedMonth(defaultValue, value)\n\n return value\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const stringToDate = useCallback(\n (value: string, start: Date = minDate, end: Date = maxDate) => {\n let date = parseDate?.(value)\n\n if (!date && dayjs(value).isValid())\n date = dayjs(value).locale(locale).toDate()\n\n if (date == null) return undefined\n if (excludeDate?.(date)) return undefined\n\n if (!allowInputBeyond) {\n if (isBeforeDate(date, start)) date = start\n if (isAfterDate(date, end)) date = end\n }\n\n return date\n },\n [allowInputBeyond, excludeDate, locale, maxDate, minDate, parseDate],\n )\n const dateToString = useCallback(\n (date?: Date) => {\n if (date == null) return \"\"\n\n return dateTimeFormat(date, inputFormat)\n },\n [dateTimeFormat, inputFormat],\n )\n const [inputValue, setInputValue] = useControllableState({\n defaultValue: () => {\n if (defaultInputValue)\n if (isObject(defaultInputValue)) {\n if (dayjs(defaultInputValue.start).isValid())\n defaultInputValue.start = dateTimeFormat(\n dayjs(defaultInputValue.start).toDate(),\n inputFormat,\n )\n\n if (dayjs(defaultInputValue.end).isValid())\n defaultInputValue.end = dateTimeFormat(\n dayjs(defaultInputValue.end).toDate(),\n inputFormat,\n )\n\n return defaultInputValue\n } else {\n if (dayjs(defaultInputValue).isValid())\n return dateTimeFormat(\n dayjs(defaultInputValue).toDate(),\n inputFormat,\n ) as MaybeInputValue<Range>\n else return defaultInputValue\n }\n else if (isDate(value))\n return dateToString(value) as MaybeInputValue<Range>\n else if (isObject(value) && !isArray(value))\n return {\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>\n else return \"\" as MaybeInputValue<Range>\n },\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n matchWidth: false,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement,\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((date, index) => {\n const value = dateToString(date)\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n }\n\n const component = render({\n count,\n date,\n focused,\n index,\n max,\n separator,\n value,\n onClear,\n })\n\n if (isValidElement<Dict>(component))\n return cloneElement(component, { ...component.props, key: index })\n else return component\n })\n }, [dateToString, focused, max, render, separator, setValue, value])\n const { endPlaceholder, startPlaceholder } = useMemo(() => {\n if (range) {\n const startPlaceholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n const endPlaceholder =\n placeholderProp ??\n dateTimeFormat(dayjs().add(1, \"day\").toDate(), inputFormat)\n\n return { endPlaceholder, startPlaceholder }\n } else {\n const placeholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n\n return { endPlaceholder: placeholder, startPlaceholder: placeholder }\n }\n }, [dateTimeFormat, inputFormat, placeholderProp, range])\n\n const onChange = useCallback(\n (value: MaybeDateValue<Multiple, Range>) => {\n setValue(value)\n\n if (isArray(value)) setInputValue(\"\" as MaybeInputValue<Range>)\n else if (isObject(value) && !isDate(value))\n setInputValue({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n else setInputValue(dateToString(value) as MaybeInputValue<Range>)\n\n if (!closeOnSelect) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (value.end && value.start) onClose()\n } else {\n onClose()\n }\n },\n [setValue, closeOnSelect, setInputValue, dateToString, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) onClose()\n else if (runIfFn(openOnChange, ev)) onOpen()\n\n let inputValue = ev.target.value\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n if (isArray(value)) {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n\n if (date) setMonth(dayjs(date).set(\"date\", 1).toDate())\n } else if (isObject(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target) ? \"end\" : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n setInputValue((prev) =>\n isObject(prev)\n ? Object.assign({}, prev, { [align]: inputValue })\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev) ? { ...prev, [align]: date } : prev,\n )\n } else {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n },\n [\n allowInput,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n pattern,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (isArray(value)) {\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) =>\n isArray(prev)\n ? (prev.slice(0, -1) as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else if (isObject(value) && !isDate(value)) {\n if (inputValue.length) return\n if (!contains(endInputRef.current, ev.target)) return\n\n ev.preventDefault()\n\n setInputValue({ end: \"\", start: \"\" } as MaybeInputValue<Range>)\n setValue({ end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >)\n\n startInputRef.current?.focus()\n }\n },\n Enter: (ev) => {\n if (!open || !inputValue.length) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target)\n ? \"end\"\n : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n if (!date) return\n\n ev.preventDefault()\n\n setInputValue((prev) =>\n isObject(prev)\n ? Object.assign({}, prev, { [align]: dateToString(date) })\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? { ...prev, [align]: date }\n : prev,\n )\n\n if (align === \"start\") endInputRef.current?.focus()\n } else {\n const date = stringToDate(inputValue)\n\n if (!date) return\n\n ev.preventDefault()\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n\n setValue((prev) =>\n isArray(prev) &&\n !isIncludeDates(date, prev) &&\n (!isNumber(max) || prev.length < max)\n ? ([...prev, date] as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else {\n setInputValue(dateToString(date) as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n dateToString,\n disabled,\n max,\n open,\n setInputValue,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput)\n if (isObject(value) && !isArray(value) && !isDate(value))\n if (\n startInputRef.current &&\n contains(startInputRef.current, ev.target)\n ) {\n if (!isActiveElement(startInputRef.current, getDocument()!))\n ev.defaultPrevented = true\n\n startInputRef.current.focus()\n } else if (\n endInputRef.current &&\n contains(endInputRef.current, ev.target)\n ) {\n if (!isActiveElement(endInputRef.current, getDocument()!))\n ev.defaultPrevented = true\n\n endInputRef.current.focus()\n } else {\n startInputRef.current?.focus()\n }\n else startInputRef.current?.focus()\n\n if (openOnClick) onOpen()\n },\n [allowInput, interactive, onOpen, openOnClick, value, getDocument],\n )\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n )\n ev.preventDefault()\n else if (isArray(value)) setInputValue(\"\" as MaybeInputValue<Range>)\n else if (isObject(value) && !isDate(value))\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n : prev,\n )\n else setInputValue(dateToString(value) as MaybeInputValue<Range>)\n },\n [dateToString, setInputValue, value],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => {\n if (isDate(prev)) return undefined as MaybeDateValue<Multiple, Range>\n else if (isArray(prev))\n return [] as unknown as MaybeDateValue<Multiple, Range>\n else if (isObject(prev))\n return { end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >\n else return prev\n })\n\n setInputValue(\n (range ? { end: \"\", start: \"\" } : \"\") as MaybeInputValue<Range>,\n )\n\n if (focusOnClear)\n if (allowInput) startInputRef.current?.focus()\n else fieldRef.current?.focus()\n }, [allowInput, focusOnClear, interactive, range, setInputValue, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? startInputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value, range])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n if (isObject(valueProp) && !isDate(valueProp))\n setInputValue({\n end: dateToString(valueProp.end),\n start: dateToString(valueProp.start),\n } as MaybeInputValue<Range>)\n else setInputValue(dateToString(valueProp) as MaybeInputValue<Range>)\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n \"data-range\": dataAttr(range),\n ...dataProps,\n ...props,\n }),\n [dataProps, range],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\", { align?: InputAlign }> =\n useCallback(\n ({ align = \"start\", ...props } = {}) => {\n const inputProps: HTMLProps<\"input\"> = {\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n autoComplete: \"off\",\n disabled,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }\n\n if (isObject(inputValue)) {\n if (align === \"start\") {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue.start\n inputProps.placeholder = startPlaceholder\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, endInputRef)\n inputProps.value = inputValue.end\n inputProps.placeholder = endPlaceholder\n }\n\n if (!inputValue.start && align === \"start\") {\n inputProps.id = id\n inputProps.name = name\n }\n\n if (!!inputValue.start && align === \"end\") {\n inputProps.id = id\n inputProps.name = name\n }\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue\n inputProps.id = id\n inputProps.name = name\n\n if (isArray(value)) {\n inputProps.style = {\n ...(!focused && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...inputProps.style,\n }\n inputProps.placeholder = !value.length\n ? startPlaceholder\n : undefined\n inputProps[\"data-max\"] = dataAttr(\n isNumber(max) && value.length >= max,\n )\n } else {\n inputProps.placeholder = startPlaceholder\n }\n }\n\n return inputProps\n },\n [\n allowInput,\n dataProps,\n disabled,\n endPlaceholder,\n focused,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onInputFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n readOnly,\n ref,\n required,\n startPlaceholder,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>> =\n useCallback(\n (props) =>\n ({\n disabled: !interactive,\n format: calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n onChangeMonth: setMonth,\n ...calendarProps,\n ...props,\n }) as UseCalendarProps<Multiple, Range>,\n [\n interactive,\n calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n setMonth,\n calendarProps,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n dateToString,\n inputValue,\n interactive,\n month,\n open,\n range,\n separator,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n getCalendarProps,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n popoverProps,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n }\n}\n\nexport type UseDatePickerReturn = ReturnType<typeof useDatePicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwFA,MAAM,iBAAmC,EACvC,OACA,SACA,OACA,KACA,WACA,YACI;CACJ,MAAM,OAAO,QAAQ,MAAM;CAE3B,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;EAAM,OAAO,EAAE,iBAAiB,aAAa;EAA7C,UAAA,CACG,QACE,EAAA,GAAA,oBAAA,cAAC,SAAA,CAAS,GAAG,KAAK,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY,IACjE;;AAEV;AAqGA,MAAa,iBAGX,EACA,UAAUA,qBAAAA,kBACV,UAAUC,qBAAAA,kBACV,GAAG,UACoC,CAAC,MAAM;CAC9C,KAAA,GAAI,MAAA,QAAA,CAAM,OAAO,CAAC,CAAC,SAAA,GAAQ,MAAA,QAAA,CAAM,OAAO,CAAC,GAAG,UAAU;CAEtD,MAAM,EAAE,gBAAgBC,6BAAAA,eAAe;CACvC,MAAM,EAAE,QAAQ,eAAe,MAAMC,sBAAAA,QAAQ,YAAY;CACzD,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,aAAa,MACb,mBAAmB,OACnB,gBAAgB,OAChB,WAAW,OACX,gBAAgB,CAAC,UACjB,mBACA,+BAAe,IAAI,KAAK,GACxB,QAAQ,OACR,eAAgB,QACZ;EAAE,KAAK,KAAA;EAAW,OAAO,KAAA;CAAU,IACnC,WACE,CAAC,IACD,KAAA,GACN,UACA,eAAe,MACf,QACA,YAAY,gBACZ,SAAS,eACT,KACA,OAAO,WACP,eAAe,MACf,cAAc,MACd,cAAc,MACd,WACA,SACA,aAAa,iBACb,YAAY,aACZ,UACA,SAAS,eACT,UACA,YAAY,QAAQ,MAAM,KAC1B,OAAO,WACP,UAAU,cACV,eAAe,mBACf,eAAe,mBACf,GAAG,iBAEL,WACA,WACA,eACEC,wBAAAA,cA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kBAAA,GAAA,oBAAA,cAAiB,SAAA,CAAS,CAAC,WAAW;GACtC,cAAc,EAAE,aAAa;GAC7B,MAAM;GACN,UAAU,cAAc,IAAI;GAC5B,GAAG;GACH,UAAA,GAAA,oBAAA,cAAS,WAAA,CAAW,MAAM,SAAS,OAAO;GAC1C,YAAA,GAAA,oBAAA,cAAW,WAAA,CAAW,MAAM,YAAY,OACtCW,YAAAA,aAAa,IAAI;IAAE,OAAO;IAAS,OAAO;GAAQ,CAAC,CACrD;EACF,CAAC,GACH;GAAC;GAAc;GAAa;GAAS;EAAC,CAkBtB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"use-date-picker.cjs","names":["DEFAULT_MAX_DATE","DEFAULT_MIN_DATE","useEnvironment","useI18n","useFieldProps","useDateTimeFormat","useMemo","useCalendarProps","useRef","useState","useControllableState","getAdjustedMonth","useCallback","isBeforeDate","isAfterDate","useCombobox","updateMaybeDateValue","isValidElement","cloneElement","isComposing","isIncludeDates","mergeRefs","visuallyHiddenAttributes","runKeyAction"],"sources":["../../../../src/components/date-picker/use-date-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type {\n CalendarFormat,\n MaybeDateValue,\n UseCalendarProps,\n} from \"../calendar\"\nimport type { FieldProps } from \"../field\"\nimport dayjs from \"dayjs\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useEnvironment } from \"../../core\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n dataAttr,\n focusTransfer,\n handlerAll,\n isActiveElement,\n isArray,\n isComposing,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport {\n DEFAULT_MAX_DATE,\n DEFAULT_MIN_DATE,\n getAdjustedMonth,\n isAfterDate,\n isBeforeDate,\n isIncludeDates,\n updateMaybeDateValue,\n useCalendarProps,\n} from \"../calendar\"\nimport { useFieldProps } from \"../field\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport interface DatePickerFormat extends CalendarFormat {\n input?: Intl.DateTimeFormatOptions | null\n}\n\ntype InputAlign = \"end\" | \"start\"\ntype MaybeInputValue<Range extends boolean = false> = Range extends true\n ? { end?: string; start?: string }\n : string | undefined\n\ninterface DatePickerRenderProps {\n count: number\n date: Date\n focused: boolean\n index: number\n separator: string\n value: string\n onClear: () => void\n max?: number\n}\n\nexport interface DatePickerRender {\n (props: DatePickerRenderProps): ReactNode\n}\n\nconst defaultRender: DatePickerRender = ({\n count,\n focused,\n index,\n max,\n separator,\n value,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {value}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nexport interface UseDatePickerProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<UseCalendarProps<Multiple, Range>, \"format\" | \"ref\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, allows input of dates beyond the `minDate` and `maxDate` restrictions.\n *\n * @default true\n */\n allowInputBeyond?: boolean\n /**\n * If `true`, the date picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: MaybeInputValue<Range>\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The format used for conversion.\n * Check the docs to see the format of possible modifiers you can pass.\n *\n * @see https://day.js.org/docs/en/display/format#list-of-localized-formats\n */\n format?: DatePickerFormat\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: MaybeInputValue<Range>\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the date picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the date picker will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for date picker.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: MaybeInputValue<Range>) => void\n /**\n * Function that converts the input value to Date type.\n */\n parseDate?: (value: string) => Date | undefined\n /**\n * The function to render the selected date.\n */\n render?: (props: DatePickerRenderProps) => ReactNode\n}\n\nexport const useDatePicker = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n ...props\n}: UseDatePickerProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { getDocument } = useEnvironment()\n const { locale: defaultLocale, t } = useI18n(\"datePicker\")\n const {\n props: {\n id,\n ref,\n name,\n allowInput = true,\n allowInputBeyond = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultMonth = () => new Date(),\n range = false,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled,\n focusOnClear = true,\n format,\n inputValue: inputValueProp,\n locale = defaultLocale,\n max,\n month: monthProp,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n parseDate,\n pattern,\n placeholder: placeholderProp,\n placement = \"end-start\",\n readOnly,\n render = defaultRender,\n required,\n separator = range ? \"-\" : \",\",\n value: valueProp,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n onInputChange: onInputChangeProp,\n ...computedProps\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const dateTimeFormat = useDateTimeFormat({ locale })\n const { calendarFormat, inputFormat } = useMemo(() => {\n const { input: inputFormat, ...calendarFormat } = format ?? {}\n const defaultInputFormat: Intl.DateTimeFormatOptions = {\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n }\n\n return {\n calendarFormat,\n inputFormat:\n inputFormat !== null ? (inputFormat ?? defaultInputFormat) : undefined,\n }\n }, [format])\n const [calendarProps, rest] = useCalendarProps<Multiple, Range>(computedProps)\n const { excludeDate } = calendarProps\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const startInputRef = useRef<HTMLInputElement>(null)\n const endInputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [currentDate] = useState<Date>(() => new Date())\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue as MaybeDateValue<Multiple, Range>,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n let defaultValue = runIfFn(defaultMonth)\n\n if (dayjs(minDate).isAfter(dayjs(defaultValue)))\n defaultValue = dayjs(minDate).set(\"date\", 1).toDate()\n\n return getAdjustedMonth(value, defaultValue)\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const stringToDate = useCallback(\n (value: string, start: Date = minDate, end: Date = maxDate) => {\n let date = parseDate?.(value)\n\n if (!date && dayjs(value).isValid())\n date = dayjs(value).locale(locale).toDate()\n\n if (date == null) return undefined\n if (excludeDate?.(date)) return undefined\n\n if (!allowInputBeyond) {\n if (isBeforeDate(date, start)) date = start\n if (isAfterDate(date, end)) date = end\n }\n\n return date\n },\n [allowInputBeyond, excludeDate, locale, maxDate, minDate, parseDate],\n )\n const dateToString = useCallback(\n (date?: Date) => {\n if (date == null) return \"\"\n\n return dateTimeFormat(date, inputFormat)\n },\n [dateTimeFormat, inputFormat],\n )\n const [inputValue, setInputValue] = useControllableState({\n defaultValue: () => {\n if (defaultInputValue)\n if (isObject(defaultInputValue)) {\n if (dayjs(defaultInputValue.start).isValid())\n defaultInputValue.start = dateTimeFormat(\n dayjs(defaultInputValue.start).toDate(),\n inputFormat,\n )\n\n if (dayjs(defaultInputValue.end).isValid())\n defaultInputValue.end = dateTimeFormat(\n dayjs(defaultInputValue.end).toDate(),\n inputFormat,\n )\n\n return defaultInputValue\n } else {\n if (dayjs(defaultInputValue).isValid())\n return dateTimeFormat(\n dayjs(defaultInputValue).toDate(),\n inputFormat,\n ) as MaybeInputValue<Range>\n else return defaultInputValue\n }\n else if (isDate(value))\n return dateToString(value) as MaybeInputValue<Range>\n else if (isObject(value) && !isArray(value))\n return {\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>\n else return \"\" as MaybeInputValue<Range>\n },\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n matchWidth: false,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement,\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((date, index) => {\n const value = dateToString(date)\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n }\n\n const component = render({\n count,\n date,\n focused,\n index,\n max,\n separator,\n value,\n onClear,\n })\n\n if (isValidElement<Dict>(component))\n return cloneElement(component, { ...component.props, key: index })\n else return component\n })\n }, [dateToString, focused, max, render, separator, setValue, value])\n const { endPlaceholder, startPlaceholder } = useMemo(() => {\n if (range) {\n const startPlaceholder =\n placeholderProp ?? dateTimeFormat(currentDate, inputFormat)\n const endPlaceholder =\n placeholderProp ??\n dateTimeFormat(dayjs(currentDate).add(1, \"day\").toDate(), inputFormat)\n\n return { endPlaceholder, startPlaceholder }\n } else {\n const placeholder =\n placeholderProp ?? dateTimeFormat(currentDate, inputFormat)\n\n return { endPlaceholder: placeholder, startPlaceholder: placeholder }\n }\n }, [dateTimeFormat, inputFormat, placeholderProp, range, currentDate])\n\n const onChange = useCallback(\n (value: MaybeDateValue<Multiple, Range>) => {\n setValue(value)\n\n if (isArray(value)) setInputValue(\"\" as MaybeInputValue<Range>)\n else if (isObject(value) && !isDate(value))\n setInputValue({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n else setInputValue(dateToString(value) as MaybeInputValue<Range>)\n\n if (!closeOnSelect) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (value.end && value.start) onClose()\n } else {\n onClose()\n }\n },\n [setValue, closeOnSelect, setInputValue, dateToString, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) onClose()\n else if (runIfFn(openOnChange, ev)) onOpen()\n\n let inputValue = ev.target.value\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n if (isArray(value)) {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n\n if (date) setMonth(dayjs(date).set(\"date\", 1).toDate())\n } else if (isObject(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target) ? \"end\" : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n setInputValue((prev) =>\n isObject(prev)\n ? Object.assign({}, prev, { [align]: inputValue })\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev) ? { ...prev, [align]: date } : prev,\n )\n } else {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n },\n [\n allowInput,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n pattern,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (isArray(value)) {\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) =>\n isArray(prev)\n ? (prev.slice(0, -1) as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else if (isObject(value) && !isDate(value)) {\n if (inputValue.length) return\n if (!contains(endInputRef.current, ev.target)) return\n\n ev.preventDefault()\n\n setInputValue({ end: \"\", start: \"\" } as MaybeInputValue<Range>)\n setValue({ end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >)\n\n startInputRef.current?.focus()\n }\n },\n Enter: (ev) => {\n if (!open || !inputValue.length) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target)\n ? \"end\"\n : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n if (!date) return\n\n ev.preventDefault()\n\n setInputValue((prev) =>\n isObject(prev)\n ? Object.assign({}, prev, { [align]: dateToString(date) })\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? { ...prev, [align]: date }\n : prev,\n )\n\n if (align === \"start\") endInputRef.current?.focus()\n } else {\n const date = stringToDate(inputValue)\n\n if (!date) return\n\n ev.preventDefault()\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n\n setValue((prev) =>\n isArray(prev) &&\n !isIncludeDates(date, prev) &&\n (!isNumber(max) || prev.length < max)\n ? ([...prev, date] as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else {\n setInputValue(dateToString(date) as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n dateToString,\n disabled,\n max,\n open,\n setInputValue,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput)\n if (isObject(value) && !isArray(value) && !isDate(value))\n if (\n startInputRef.current &&\n contains(startInputRef.current, ev.target)\n ) {\n if (!isActiveElement(startInputRef.current, getDocument()!))\n ev.defaultPrevented = true\n\n startInputRef.current.focus()\n } else if (\n endInputRef.current &&\n contains(endInputRef.current, ev.target)\n ) {\n if (!isActiveElement(endInputRef.current, getDocument()!))\n ev.defaultPrevented = true\n\n endInputRef.current.focus()\n } else {\n startInputRef.current?.focus()\n }\n else startInputRef.current?.focus()\n\n if (openOnClick) onOpen()\n },\n [allowInput, interactive, onOpen, openOnClick, value, getDocument],\n )\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n )\n ev.preventDefault()\n else if (isArray(value)) setInputValue(\"\" as MaybeInputValue<Range>)\n else if (isObject(value) && !isDate(value))\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n : prev,\n )\n else setInputValue(dateToString(value) as MaybeInputValue<Range>)\n },\n [dateToString, setInputValue, value],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => {\n if (isDate(prev)) return undefined as MaybeDateValue<Multiple, Range>\n else if (isArray(prev))\n return [] as unknown as MaybeDateValue<Multiple, Range>\n else if (isObject(prev))\n return { end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >\n else return prev\n })\n\n setInputValue(\n (range ? { end: \"\", start: \"\" } : \"\") as MaybeInputValue<Range>,\n )\n\n if (focusOnClear)\n if (allowInput) startInputRef.current?.focus()\n else fieldRef.current?.focus()\n }, [allowInput, focusOnClear, interactive, range, setInputValue, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? startInputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value, range])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n if (isObject(valueProp) && !isDate(valueProp))\n setInputValue({\n end: dateToString(valueProp.end),\n start: dateToString(valueProp.start),\n } as MaybeInputValue<Range>)\n else setInputValue(dateToString(valueProp) as MaybeInputValue<Range>)\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n \"data-range\": dataAttr(range),\n ...dataProps,\n ...props,\n }),\n [dataProps, range],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\", { align?: InputAlign }> =\n useCallback(\n ({ align = \"start\", ...props } = {}) => {\n const inputProps: HTMLProps<\"input\"> = {\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n autoComplete: \"off\",\n disabled,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }\n\n if (isObject(inputValue)) {\n if (align === \"start\") {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue.start\n inputProps.placeholder = startPlaceholder\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, endInputRef)\n inputProps.value = inputValue.end\n inputProps.placeholder = endPlaceholder\n }\n\n if (!inputValue.start && align === \"start\") {\n inputProps.id = id\n inputProps.name = name\n }\n\n if (!!inputValue.start && align === \"end\") {\n inputProps.id = id\n inputProps.name = name\n }\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue\n inputProps.id = id\n inputProps.name = name\n\n if (isArray(value)) {\n inputProps.style = {\n ...(!focused && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...inputProps.style,\n }\n inputProps.placeholder = !value.length\n ? startPlaceholder\n : undefined\n inputProps[\"data-max\"] = dataAttr(\n isNumber(max) && value.length >= max,\n )\n } else {\n inputProps.placeholder = startPlaceholder\n }\n }\n\n return inputProps\n },\n [\n allowInput,\n dataProps,\n disabled,\n endPlaceholder,\n focused,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onInputFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n readOnly,\n ref,\n required,\n startPlaceholder,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>> =\n useCallback(\n (props) =>\n ({\n disabled: !interactive,\n format: calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n onChangeMonth: setMonth,\n ...calendarProps,\n ...props,\n }) as UseCalendarProps<Multiple, Range>,\n [\n interactive,\n calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n setMonth,\n calendarProps,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n dateToString,\n inputValue,\n interactive,\n month,\n open,\n range,\n separator,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n getCalendarProps,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n popoverProps,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n }\n}\n\nexport type UseDatePickerReturn = ReturnType<typeof useDatePicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwFA,MAAM,iBAAmC,EACvC,OACA,SACA,OACA,KACA,WACA,YACI;CACJ,MAAM,OAAO,QAAQ,MAAM;CAE3B,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;EAAM,OAAO,EAAE,iBAAiB,aAAa;EAA7C,UAAA,CACG,QACE,EAAA,GAAA,oBAAA,cAAC,SAAA,CAAS,GAAG,KAAK,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY,IACjE;;AAEV;AAqGA,MAAa,iBAGX,EACA,UAAUA,qBAAAA,kBACV,UAAUC,qBAAAA,kBACV,GAAG,UACoC,CAAC,MAAM;CAC9C,KAAA,GAAI,MAAA,QAAA,CAAM,OAAO,CAAC,CAAC,SAAA,GAAQ,MAAA,QAAA,CAAM,OAAO,CAAC,GAAG,UAAU;CAEtD,MAAM,EAAE,gBAAgBC,6BAAAA,eAAe;CACvC,MAAM,EAAE,QAAQ,eAAe,MAAMC,sBAAAA,QAAQ,YAAY;CACzD,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,aAAa,MACb,mBAAmB,OACnB,gBAAgB,OAChB,WAAW,OACX,gBAAgB,CAAC,UACjB,mBACA,qCAAqB,IAAI,KAAK,GAC9B,QAAQ,OACR,eAAgB,QACZ;EAAE,KAAK,KAAA;EAAW,OAAO,KAAA;CAAU,IAC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EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEF,MAAM,gBAAA,GAA2BA,MAAAA,YAAAA,EAC9B,WAAW;EAAE,GAAG;EAAW,GAAG;CAAM,IACrC,CAAC,SAAS,CACZ;CAkBA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBAAA,GA/BoCA,MAAAA,YAAAA,EACnC,QAAQ,CAAC,MACR,aAAa;GACX,kBAAA,GAAA,oBAAA,cAAiB,SAAA,CAAS,CAAC,WAAW;GACtC,cAAc,EAAE,aAAa;GAC7B,MAAM;GACN,UAAU,cAAc,IAAI;GAC5B,GAAG;GACH,UAAA,GAAA,oBAAA,cAAS,WAAA,CAAW,MAAM,SAAS,OAAO;GAC1C,YAAA,GAAA,oBAAA,cAAW,WAAA,CAAW,MAAM,YAAY,OACtCW,YAAAA,aAAa,IAAI;IAAE,OAAO;IAAS,OAAO;GAAQ,CAAC,CACrD;EACF,CAAC,GACH;GAAC;GAAc;GAAa;GAAS;EAAC,CAkBtB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -19,8 +19,9 @@ const { ComponentContext, PropsContext: CalendarPropsContext, useComponentContex
19
19
  * @see https://yamada-ui.com/docs/components/calendar
20
20
  */
21
21
  const CalendarRoot = withProvider(({ children, day, buttonProps, controlProps, dayProps, monthProps, monthSelectProps, navigationProps, nextButtonProps, prevButtonProps, selectProps, weekdayProps, weekdaysProps, weekProps, weeksProps, yearSelectProps, ...props }) => {
22
- const { descendants, disabled, endOfMonth, excludeDate, holidays, locale, max, maxDate, minDate, month, monthDays, monthItems, multiple, range, startDayOfWeek, startOfMonth, today, value, weekdays, weekendDays, yearItems, getMonthProps, getMonthSelectProps, getNavigationProps, getNextButtonProps, getPrevButtonProps, getRootProps, getStatusProps, getWeekdayProps, getYearSelectProps, onChange, onMonthChange, onNextMonth, onPrevMonth } = useCalendar(props);
22
+ const { currentDate, descendants, disabled, endOfMonth, excludeDate, holidays, locale, max, maxDate, minDate, month, monthDays, monthItems, multiple, range, startDayOfWeek, startOfMonth, today, value, weekdays, weekendDays, yearItems, getMonthProps, getMonthSelectProps, getNavigationProps, getNextButtonProps, getPrevButtonProps, getRootProps, getStatusProps, getWeekdayProps, getYearSelectProps, onChange, onMonthChange, onNextMonth, onPrevMonth } = useCalendar(props);
23
23
  const calendarContext = useMemo(() => ({
24
+ currentDate,
24
25
  disabled,
25
26
  endOfMonth,
26
27
  excludeDate,
@@ -42,6 +43,7 @@ const CalendarRoot = withProvider(({ children, day, buttonProps, controlProps, d
42
43
  onNextMonth,
43
44
  onPrevMonth
44
45
  }), [
46
+ currentDate,
45
47
  disabled,
46
48
  endOfMonth,
47
49
  excludeDate,
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.js","names":["runIfFn","Select.Root"],"sources":["../../../../src/components/calendar/calendar.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement } from \"react\"\nimport type { GenericsComponent, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport type { CalendarStyle } from \"./calendar.style\"\nimport type {\n UseCalendarDayProps,\n UseCalendarProps,\n UseCalendarReturn,\n} from \"./use-calendar\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, mergeProps, styled } from \"../../core\"\nimport { runIfFn } from \"../../utils\"\nimport { resetFieldProps } from \"../field\"\nimport { ChevronLeftIcon, ChevronRightIcon } from \"../icon\"\nimport { Select } from \"../select\"\nimport { calendarStyle } from \"./calendar.style\"\nimport {\n CalendarContext,\n CalendarDescendantsContext,\n useCalendar,\n useCalendarContext,\n useCalendarDay,\n} from \"./use-calendar\"\n\ninterface ComponentContext\n extends\n Pick<\n UseCalendarReturn,\n | \"getMonthProps\"\n | \"getMonthSelectProps\"\n | \"getNavigationProps\"\n | \"getNextButtonProps\"\n | \"getPrevButtonProps\"\n | \"getStatusProps\"\n | \"getWeekdayProps\"\n | \"getYearSelectProps\"\n | \"monthDays\"\n | \"monthItems\"\n | \"weekdays\"\n | \"yearItems\"\n >,\n Pick<\n CalendarRootProps,\n | \"buttonProps\"\n | \"controlProps\"\n | \"day\"\n | \"dayProps\"\n | \"monthProps\"\n | \"monthSelectProps\"\n | \"navigationProps\"\n | \"nextButtonProps\"\n | \"prevButtonProps\"\n | \"selectProps\"\n | \"weekdayProps\"\n | \"weekdaysProps\"\n | \"weekProps\"\n | \"weeksProps\"\n | \"yearSelectProps\"\n > {}\n\nexport interface CalendarRootProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<HTMLStyledProps, \"defaultValue\" | \"onChange\">,\n ThemeProps<CalendarStyle>,\n UseCalendarProps<Multiple, Range>,\n Pick<CalendarMonthProps, \"day\"> {\n /**\n * Props for the button component.\n */\n buttonProps?: HTMLStyledProps<\"button\">\n /**\n * Props for the control component.\n */\n controlProps?: CalendarControlProps\n /**\n * Props for the day component.\n */\n dayProps?: Omit<CalendarDayProps, \"value\">\n /**\n * Props for the month component.\n */\n monthProps?: CalendarMonthProps\n /**\n * Props for the month select component.\n */\n monthSelectProps?: CalendarMonthSelectProps\n /**\n * Props for the navigation component.\n */\n navigationProps?: Omit<CalendarNavigationProps, \"children\">\n /**\n * Props for the next button component.\n */\n nextButtonProps?: CalendarNextButtonProps\n /**\n * Props for the prev button component.\n */\n prevButtonProps?: CalendarPrevButtonProps\n /**\n * Props for the select component.\n */\n selectProps?: Select.RootProps\n /**\n * Props for the weekday component.\n */\n weekdayProps?: HTMLStyledProps<\"th\">\n /**\n * Props for the weekdays component.\n */\n weekdaysProps?: HTMLStyledProps<\"tr\">\n /**\n * Props for the week component.\n */\n weekProps?: HTMLStyledProps<\"tr\">\n /**\n * Props for the weeks component.\n */\n weeksProps?: HTMLStyledProps<\"tbody\">\n /**\n * Props for the year select component.\n */\n yearSelectProps?: CalendarYearSelectProps\n}\n\nconst {\n ComponentContext,\n PropsContext: CalendarPropsContext,\n useComponentContext,\n usePropsContext: useCalendarPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<CalendarRootProps, CalendarStyle, ComponentContext>(\n \"calendar\",\n calendarStyle,\n)\n\nexport { CalendarPropsContext, useCalendarPropsContext }\n\n/**\n * `Calendar` is a component for displaying or selecting dates in a calendar.\n *\n * @see https://yamada-ui.com/docs/components/calendar\n */\nexport const CalendarRoot = withProvider(\n <Multiple extends boolean = false, Range extends boolean = false>({\n children,\n day,\n buttonProps,\n controlProps,\n dayProps,\n monthProps,\n monthSelectProps,\n navigationProps,\n nextButtonProps,\n prevButtonProps,\n selectProps,\n weekdayProps,\n weekdaysProps,\n weekProps,\n weeksProps,\n yearSelectProps,\n ...props\n }: CalendarRootProps<Multiple, Range>) => {\n const {\n descendants,\n disabled,\n endOfMonth,\n excludeDate,\n holidays,\n locale,\n max,\n maxDate,\n minDate,\n month,\n monthDays,\n monthItems,\n multiple,\n range,\n startDayOfWeek,\n startOfMonth,\n today,\n value,\n weekdays,\n weekendDays,\n yearItems,\n getMonthProps,\n getMonthSelectProps,\n getNavigationProps,\n getNextButtonProps,\n getPrevButtonProps,\n getRootProps,\n getStatusProps,\n getWeekdayProps,\n getYearSelectProps,\n onChange,\n onMonthChange,\n onNextMonth,\n onPrevMonth,\n } = useCalendar(props)\n const calendarContext = useMemo(\n () => ({\n disabled,\n endOfMonth,\n excludeDate,\n holidays,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n startDayOfWeek,\n startOfMonth,\n today,\n value,\n weekendDays,\n onChange,\n onMonthChange,\n onNextMonth,\n onPrevMonth,\n }),\n [\n disabled,\n endOfMonth,\n excludeDate,\n holidays,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n startDayOfWeek,\n startOfMonth,\n today,\n value,\n weekendDays,\n onChange,\n onMonthChange,\n onNextMonth,\n onPrevMonth,\n ],\n )\n const componentContext = useMemo(\n () => ({\n day,\n monthDays,\n monthItems,\n weekdays,\n yearItems,\n buttonProps,\n controlProps,\n dayProps,\n getMonthProps,\n getMonthSelectProps,\n getNavigationProps,\n getNextButtonProps,\n getPrevButtonProps,\n getStatusProps,\n getWeekdayProps,\n getYearSelectProps,\n monthProps,\n monthSelectProps,\n navigationProps,\n nextButtonProps,\n prevButtonProps,\n selectProps,\n weekdayProps,\n weekdaysProps,\n weekProps,\n weeksProps,\n yearSelectProps,\n }),\n [\n day,\n monthDays,\n monthItems,\n weekdays,\n yearItems,\n buttonProps,\n controlProps,\n dayProps,\n getMonthProps,\n getMonthSelectProps,\n getNavigationProps,\n getNextButtonProps,\n getPrevButtonProps,\n getStatusProps,\n getWeekdayProps,\n getYearSelectProps,\n monthProps,\n monthSelectProps,\n navigationProps,\n nextButtonProps,\n prevButtonProps,\n selectProps,\n weekdayProps,\n weekdaysProps,\n weekProps,\n weeksProps,\n yearSelectProps,\n ],\n )\n\n return (\n <CalendarDescendantsContext value={descendants}>\n <CalendarContext value={calendarContext}>\n <ComponentContext value={componentContext}>\n <styled.div {...getRootProps()}>\n {children ?? (\n <>\n <CalendarNavigation />\n <CalendarMonth />\n </>\n )}\n </styled.div>\n </ComponentContext>\n </CalendarContext>\n </CalendarDescendantsContext>\n )\n },\n \"root\",\n)() as GenericsComponent<{\n <Multiple extends boolean = false, Range extends boolean = false>(\n props: CalendarRootProps<Multiple, Range>,\n ): ReactElement\n}>\n\nexport interface CalendarNavigationProps extends HTMLStyledProps {}\n\nexport const CalendarNavigation = withContext<\"div\", CalendarNavigationProps>(\n \"div\",\n [\"row\", \"navigation\"],\n)(undefined, ({ children, ...rest }) => {\n const { getNavigationProps, navigationProps } = useComponentContext()\n\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return (\n <>\n <CalendarPrevButton />\n <CalendarControl />\n <CalendarNextButton />\n </>\n )\n }, [children])\n\n return {\n ...getNavigationProps(mergeProps(navigationProps, rest)()),\n children: computedChildren,\n }\n})\n\nexport interface CalendarControlProps extends Omit<\n HTMLStyledProps,\n \"children\"\n> {\n /**\n * The control children to use.\n */\n children?: ReactNodeOrFunction<{ month: Date }>\n}\n\nexport const CalendarControl = withContext<\"div\", CalendarControlProps>(\n \"div\",\n \"control\",\n)(undefined, ({ children, ...rest }) => {\n const { month } = useCalendarContext()\n const { controlProps, getStatusProps } = useComponentContext()\n\n const computedChildren = useMemo(() => {\n if (children) return runIfFn(children, { month })\n\n return (\n <>\n <CalendarMonthSelect />\n <CalendarYearSelect />\n </>\n )\n }, [children, month])\n\n return {\n ...mergeProps(controlProps, rest)(),\n children: (\n <>\n {computedChildren}\n <styled.div {...getStatusProps()} />\n </>\n ),\n }\n})\n\nexport interface CalendarPrevButtonProps extends HTMLStyledProps<\"button\"> {}\n\nexport const CalendarPrevButton = withContext<\n \"button\",\n CalendarPrevButtonProps\n>(\"button\", [\"button\", \"prev\"])(\n undefined,\n ({ children = <ChevronLeftIcon />, ...rest }) => {\n const { buttonProps, getPrevButtonProps, prevButtonProps } =\n useComponentContext()\n\n return {\n children,\n ...getPrevButtonProps(mergeProps(buttonProps, prevButtonProps, rest)()),\n }\n },\n)\n\nexport interface CalendarNextButtonProps extends HTMLStyledProps<\"button\"> {}\n\nexport const CalendarNextButton = withContext<\n \"button\",\n CalendarNextButtonProps\n>(\"button\", [\"button\", \"next\"])(\n undefined,\n ({ children = <ChevronRightIcon />, ...rest }) => {\n const { buttonProps, getNextButtonProps, nextButtonProps } =\n useComponentContext()\n\n return {\n children,\n ...getNextButtonProps(mergeProps(buttonProps, nextButtonProps, rest)()),\n }\n },\n)\n\nexport interface CalendarSeparatorProps extends HTMLStyledProps<\"span\"> {}\n\nexport const CalendarSeparator = withContext<\"span\", CalendarSeparatorProps>(\n \"span\",\n \"separator\",\n)({ children: \"/\", role: \"separator\" })\n\nexport interface CalendarYearSelectProps extends Select.RootProps {}\n\nexport const CalendarYearSelect = withContext<\"div\", CalendarYearSelectProps>(\n (props) => {\n const { yearItems, getYearSelectProps, selectProps, yearSelectProps } =\n useComponentContext()\n const { contentProps, rootProps, ...rest } = mergeProps(\n selectProps,\n yearSelectProps,\n props,\n )()\n\n return (\n <Select.Root\n variant=\"plain\"\n items={yearItems}\n minH=\"{cell-size}\"\n contentProps={{ minW: \"{select-content-size}\", ...contentProps }}\n rootProps={{\n fontSize: \"{select-font-size}\",\n w: \"{select-root-size}\",\n ...rootProps,\n }}\n {...resetFieldProps}\n {...getYearSelectProps(rest)}\n />\n )\n },\n [\"select\", \"years\"],\n)()\n\nexport interface CalendarMonthSelectProps extends Select.RootProps {}\n\nexport const CalendarMonthSelect = withContext<\"div\", CalendarMonthSelectProps>(\n (props) => {\n const { monthItems, getMonthSelectProps, monthSelectProps, selectProps } =\n useComponentContext()\n const { contentProps, rootProps, ...rest } = mergeProps(\n selectProps,\n monthSelectProps,\n props,\n )()\n\n return (\n <Select.Root\n variant=\"plain\"\n items={monthItems}\n minH=\"{cell-size}\"\n contentProps={{ minW: \"{select-content-size}\", ...contentProps }}\n rootProps={{\n fontSize: \"{select-font-size}\",\n w: \"{select-root-size}\",\n ...rootProps,\n }}\n {...resetFieldProps}\n {...getMonthSelectProps(rest)}\n />\n )\n },\n [\"select\", \"months\"],\n)()\n\nexport interface CalendarMonthProps extends Omit<\n HTMLStyledProps<\"table\">,\n \"children\"\n> {\n /**\n * The day component to use.\n */\n day?: ReactNodeOrFunction<{ value: Date }>\n}\n\nexport const CalendarMonth = withContext<\"table\", CalendarMonthProps>(\n \"table\",\n \"month\",\n)(undefined, ({ day: dayProp, ...rest }) => {\n const {\n day,\n monthDays,\n weekdays,\n dayProps,\n getMonthProps,\n getWeekdayProps,\n monthProps,\n weekdayProps,\n weekdaysProps,\n weekProps,\n weeksProps,\n } = useComponentContext()\n\n dayProp ??= day\n\n const children = (\n <>\n <styled.thead aria-hidden>\n <CalendarWeekDays {...weekdaysProps}>\n {weekdays.map(({ label, value }, index) => (\n <CalendarWeekday\n key={index}\n {...getWeekdayProps({ ...weekdayProps, value })}\n >\n {label}\n </CalendarWeekday>\n ))}\n </CalendarWeekDays>\n </styled.thead>\n\n <CalendarWeeks {...weeksProps}>\n {monthDays.map((week, index) => (\n <CalendarWeek key={index} {...weekProps}>\n {week.map(({ label, value }) => (\n <CalendarDay\n key={value.toDateString()}\n {...{ ...dayProps, value }}\n >\n {runIfFn(dayProp, { value }) ?? (\n <styled.span>{label}</styled.span>\n )}\n </CalendarDay>\n ))}\n </CalendarWeek>\n ))}\n </CalendarWeeks>\n </>\n )\n\n return {\n ...getMonthProps(mergeProps(monthProps, rest)()),\n children,\n }\n})\n\nconst CalendarWeekDays = withContext(\"tr\", [\"row\", \"weekdays\"])()\n\nconst CalendarWeekday = withContext(\"th\", [\"cell\", \"weekday\"])()\n\nconst CalendarWeeks = withContext(\"tbody\", \"weeks\")()\n\nconst CalendarWeek = withContext(\"tr\", [\"row\", \"week\"])()\n\ninterface CalendarDayProps\n extends Omit<HTMLStyledProps<\"td\">, \"value\">, UseCalendarDayProps {}\n\nconst CalendarDay = withContext<\"td\", CalendarDayProps>(\"td\", [\"cell\", \"day\"])(\n undefined,\n (props) => {\n const { getDayProps } = useCalendarDay(props)\n\n return getDayProps()\n },\n)\n"],"mappings":";;;;;;;;;;;;;;AAiIA,MAAM,EACJ,kBACA,cAAc,sBACd,qBACA,iBAAiB,yBACjB,aACA,iBACE,oBACF,YACA,aACF;;;;;;AASA,MAAa,eAAe,cACwC,EAChE,UACA,KACA,aACA,cACA,UACA,YACA,kBACA,iBACA,iBACA,iBACA,aACA,cACA,eACA,WACA,YACA,iBACA,GAAG,YACqC;CACxC,MAAM,EACJ,aACA,UACA,YACA,aACA,UACA,QACA,KACA,SACA,SACA,OACA,WACA,YACA,UACA,OACA,gBACA,cACA,OACA,OACA,UACA,aACA,WACA,eACA,qBACA,oBACA,oBACA,oBACA,cACA,gBACA,iBACA,oBACA,UACA,eACA,aACA,gBACE,YAAY,KAAK;CACrB,MAAM,kBAAkB,eACf;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,MAAM,mBAAmB,eAChB;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,oBAAC,4BAAD;EAA4B,OAAO;EACjC,UAAA,oBAAC,iBAAD;GAAiB,OAAO;GACtB,UAAA,oBAAC,kBAAD;IAAkB,OAAO;IACvB,UAAA,oBAAC,OAAO,KAAR;KAAY,GAAI,aAAa;KAC1B,UAAA,YACC,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,oBAAD,CAAqB,CAAA,GACrB,oBAAC,eAAD,CAAgB,CAAA,CAChB,EAAA,CAAA;IAEM,CAAA;GACI,CAAA;EACH,CAAA;CACS,CAAA;AAEhC,GACA,MACF,CAAC,CAAC;AAQF,MAAa,qBAAqB,YAChC,OACA,CAAC,OAAO,YAAY,CACtB,CAAC,CAAC,KAAA,IAAY,EAAE,UAAU,GAAG,WAAW;CACtC,MAAM,EAAE,oBAAoB,oBAAoB,oBAAoB;CAEpE,MAAM,mBAAmB,cAAc;EACrC,IAAI,UAAU,OAAO;EAErB,OACE,qBAAA,YAAA,EAAA,UAAA;GACE,oBAAC,oBAAD,CAAqB,CAAA;GACrB,oBAAC,iBAAD,CAAkB,CAAA;GAClB,oBAAC,oBAAD,CAAqB,CAAA;EACrB,EAAA,CAAA;CAEN,GAAG,CAAC,QAAQ,CAAC;CAEb,OAAO;EACL,GAAG,m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A,SAAS,KAAK,EAAE,OAAO,SAAS,UAC/B,oBAAC,iBAAD;IAEE,GAAI,gBAAgB;KAAE,GAAG;KAAc;IAAM,CAAC;IAE7C,UAAA;GACc,GAJV,KAIU,CAClB;EACe,CAAA;CACN,CAAA,GAEd,oBAAC,eAAD;EAAe,GAAI;EAChB,UAAA,UAAU,KAAK,MAAM,UACpB,oBAAC,cAAD;GAA0B,GAAI;GAC3B,UAAA,KAAK,KAAK,EAAE,OAAO,YAClB,oBAAC,aAAD;IAEQ,GAAG;IAAU;IAElBD,WAAAA,GAAAA,cAAAA,QAAAA,CAAQ,SAAS,EAAE,MAAM,CAAC,KACzB,oBAAC,OAAO,MAAR,EAAA,UAAc,MAAmB,CAAA;GAExB,GANN,MAAM,aAAa,CAMb,CACd;EACW,GAXK,KAWL,CACf;CACY,CAAA,CACf,EAAA,CAAA;CAGJ,OAAO;EACL,GAAG,cAAc,WAAW,YAAY,IAAI,CAAC,CAAC,CAAC;EAC/C;CACF;AACF,CAAC;AAED,MAAM,mBAAmB,YAAY,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC;AAEhE,MAAM,kBAAkB,YAAY,MAAM,CAAC,QAAQ,SAAS,CAAC,CAAC,CAAC;AAE/D,MAAM,gBAAgB,YAAY,SAAS,OAAO,CAAC,CAAC;AAEpD,MAAM,eAAe,YAAY,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC;AAKxD,MAAM,cAAc,YAAoC,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAC5E,KAAA,IACC,UAAU;CACT,MAAM,EAAE,gBAAgB,eAAe,KAAK;CAE5C,OAAO,YAAY;AACrB,CACF"}
1
+ {"version":3,"file":"calendar.js","names":["runIfFn","Select.Root"],"sources":["../../../../src/components/calendar/calendar.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement } from \"react\"\nimport type { GenericsComponent, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport type { CalendarStyle } from \"./calendar.style\"\nimport type {\n UseCalendarDayProps,\n UseCalendarProps,\n UseCalendarReturn,\n} from \"./use-calendar\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, mergeProps, styled } from \"../../core\"\nimport { runIfFn } from \"../../utils\"\nimport { resetFieldProps } from \"../field\"\nimport { ChevronLeftIcon, ChevronRightIcon } from \"../icon\"\nimport { Select } from \"../select\"\nimport { calendarStyle } from \"./calendar.style\"\nimport {\n CalendarContext,\n CalendarDescendantsContext,\n useCalendar,\n useCalendarContext,\n useCalendarDay,\n} from \"./use-calendar\"\n\ninterface ComponentContext\n extends\n Pick<\n UseCalendarReturn,\n | \"getMonthProps\"\n | \"getMonthSelectProps\"\n | \"getNavigationProps\"\n | \"getNextButtonProps\"\n | \"getPrevButtonProps\"\n | \"getStatusProps\"\n | \"getWeekdayProps\"\n | \"getYearSelectProps\"\n | \"monthDays\"\n | \"monthItems\"\n | \"weekdays\"\n | \"yearItems\"\n >,\n Pick<\n CalendarRootProps,\n | \"buttonProps\"\n | \"controlProps\"\n | \"day\"\n | \"dayProps\"\n | \"monthProps\"\n | \"monthSelectProps\"\n | \"navigationProps\"\n | \"nextButtonProps\"\n | \"prevButtonProps\"\n | \"selectProps\"\n | \"weekdayProps\"\n | \"weekdaysProps\"\n | \"weekProps\"\n | \"weeksProps\"\n | \"yearSelectProps\"\n > {}\n\nexport interface CalendarRootProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<HTMLStyledProps, \"defaultValue\" | \"onChange\">,\n ThemeProps<CalendarStyle>,\n UseCalendarProps<Multiple, Range>,\n Pick<CalendarMonthProps, \"day\"> {\n /**\n * Props for the button component.\n */\n buttonProps?: HTMLStyledProps<\"button\">\n /**\n * Props for the control component.\n */\n controlProps?: CalendarControlProps\n /**\n * Props for the day component.\n */\n dayProps?: Omit<CalendarDayProps, \"value\">\n /**\n * Props for the month component.\n */\n monthProps?: CalendarMonthProps\n /**\n * Props for the month select component.\n */\n monthSelectProps?: CalendarMonthSelectProps\n /**\n * Props for the navigation component.\n */\n navigationProps?: Omit<CalendarNavigationProps, \"children\">\n /**\n * Props for the next button component.\n */\n nextButtonProps?: CalendarNextButtonProps\n /**\n * Props for the prev button component.\n */\n prevButtonProps?: CalendarPrevButtonProps\n /**\n * Props for the select component.\n */\n selectProps?: Select.RootProps\n /**\n * Props for the weekday component.\n */\n weekdayProps?: HTMLStyledProps<\"th\">\n /**\n * Props for the weekdays component.\n */\n weekdaysProps?: HTMLStyledProps<\"tr\">\n /**\n * Props for the week component.\n */\n weekProps?: HTMLStyledProps<\"tr\">\n /**\n * Props for the weeks component.\n */\n weeksProps?: HTMLStyledProps<\"tbody\">\n /**\n * Props for the year select component.\n */\n yearSelectProps?: CalendarYearSelectProps\n}\n\nconst {\n ComponentContext,\n PropsContext: CalendarPropsContext,\n useComponentContext,\n usePropsContext: useCalendarPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<CalendarRootProps, CalendarStyle, ComponentContext>(\n \"calendar\",\n calendarStyle,\n)\n\nexport { CalendarPropsContext, useCalendarPropsContext }\n\n/**\n * `Calendar` is a component for displaying or selecting dates in a calendar.\n *\n * @see https://yamada-ui.com/docs/components/calendar\n */\nexport const CalendarRoot = withProvider(\n <Multiple extends boolean = false, Range extends boolean = false>({\n children,\n day,\n buttonProps,\n controlProps,\n dayProps,\n monthProps,\n monthSelectProps,\n navigationProps,\n nextButtonProps,\n prevButtonProps,\n selectProps,\n weekdayProps,\n weekdaysProps,\n weekProps,\n weeksProps,\n yearSelectProps,\n ...props\n }: CalendarRootProps<Multiple, Range>) => {\n const {\n currentDate,\n descendants,\n disabled,\n endOfMonth,\n excludeDate,\n holidays,\n locale,\n max,\n maxDate,\n minDate,\n month,\n monthDays,\n monthItems,\n multiple,\n range,\n startDayOfWeek,\n startOfMonth,\n today,\n value,\n weekdays,\n weekendDays,\n yearItems,\n getMonthProps,\n getMonthSelectProps,\n getNavigationProps,\n getNextButtonProps,\n getPrevButtonProps,\n getRootProps,\n getStatusProps,\n getWeekdayProps,\n getYearSelectProps,\n onChange,\n onMonthChange,\n onNextMonth,\n onPrevMonth,\n } = useCalendar(props)\n const calendarContext = useMemo(\n () => ({\n currentDate,\n disabled,\n endOfMonth,\n excludeDate,\n holidays,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n startDayOfWeek,\n startOfMonth,\n today,\n value,\n weekendDays,\n onChange,\n onMonthChange,\n onNextMonth,\n onPrevMonth,\n }),\n [\n currentDate,\n disabled,\n endOfMonth,\n excludeDate,\n holidays,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n startDayOfWeek,\n startOfMonth,\n today,\n value,\n weekendDays,\n onChange,\n onMonthChange,\n onNextMonth,\n onPrevMonth,\n ],\n )\n const componentContext = useMemo(\n () => ({\n day,\n monthDays,\n monthItems,\n weekdays,\n yearItems,\n buttonProps,\n controlProps,\n dayProps,\n getMonthProps,\n getMonthSelectProps,\n getNavigationProps,\n getNextButtonProps,\n getPrevButtonProps,\n getStatusProps,\n getWeekdayProps,\n getYearSelectProps,\n monthProps,\n monthSelectProps,\n navigationProps,\n nextButtonProps,\n prevButtonProps,\n selectProps,\n weekdayProps,\n weekdaysProps,\n weekProps,\n weeksProps,\n yearSelectProps,\n }),\n [\n day,\n monthDays,\n monthItems,\n weekdays,\n yearItems,\n buttonProps,\n controlProps,\n dayProps,\n getMonthProps,\n getMonthSelectProps,\n getNavigationProps,\n getNextButtonProps,\n getPrevButtonProps,\n getStatusProps,\n getWeekdayProps,\n getYearSelectProps,\n monthProps,\n monthSelectProps,\n navigationProps,\n nextButtonProps,\n prevButtonProps,\n selectProps,\n weekdayProps,\n weekdaysProps,\n weekProps,\n weeksProps,\n yearSelectProps,\n ],\n )\n\n return (\n <CalendarDescendantsContext value={descendants}>\n <CalendarContext value={calendarContext}>\n <ComponentContext value={componentContext}>\n <styled.div {...getRootProps()}>\n {children ?? (\n <>\n <CalendarNavigation />\n <CalendarMonth />\n </>\n )}\n </styled.div>\n </ComponentContext>\n </CalendarContext>\n </CalendarDescendantsContext>\n )\n },\n \"root\",\n)() as GenericsComponent<{\n <Multiple extends boolean = false, Range extends boolean = false>(\n props: CalendarRootProps<Multiple, Range>,\n ): ReactElement\n}>\n\nexport interface CalendarNavigationProps extends HTMLStyledProps {}\n\nexport const CalendarNavigation = withContext<\"div\", CalendarNavigationProps>(\n \"div\",\n [\"row\", \"navigation\"],\n)(undefined, ({ children, ...rest }) => {\n const { getNavigationProps, navigationProps } = useComponentContext()\n\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return (\n <>\n <CalendarPrevButton />\n <CalendarControl />\n <CalendarNextButton />\n </>\n )\n }, [children])\n\n return {\n ...getNavigationProps(mergeProps(navigationProps, rest)()),\n children: computedChildren,\n }\n})\n\nexport interface CalendarControlProps extends Omit<\n HTMLStyledProps,\n \"children\"\n> {\n /**\n * The control children to use.\n */\n children?: ReactNodeOrFunction<{ month: Date }>\n}\n\nexport const CalendarControl = withContext<\"div\", CalendarControlProps>(\n \"div\",\n \"control\",\n)(undefined, ({ children, ...rest }) => {\n const { month } = useCalendarContext()\n const { controlProps, getStatusProps } = useComponentContext()\n\n const computedChildren = useMemo(() => {\n if (children) return runIfFn(children, { month })\n\n return (\n <>\n <CalendarMonthSelect />\n <CalendarYearSelect />\n </>\n )\n }, [children, month])\n\n return {\n ...mergeProps(controlProps, rest)(),\n children: (\n <>\n {computedChildren}\n <styled.div {...getStatusProps()} />\n </>\n ),\n }\n})\n\nexport interface CalendarPrevButtonProps extends HTMLStyledProps<\"button\"> {}\n\nexport const CalendarPrevButton = withContext<\n \"button\",\n CalendarPrevButtonProps\n>(\"button\", [\"button\", \"prev\"])(\n undefined,\n ({ children = <ChevronLeftIcon />, ...rest }) => {\n const { buttonProps, getPrevButtonProps, prevButtonProps } =\n useComponentContext()\n\n return {\n children,\n ...getPrevButtonProps(mergeProps(buttonProps, prevButtonProps, rest)()),\n }\n },\n)\n\nexport interface CalendarNextButtonProps extends HTMLStyledProps<\"button\"> {}\n\nexport const CalendarNextButton = withContext<\n \"button\",\n CalendarNextButtonProps\n>(\"button\", [\"button\", \"next\"])(\n undefined,\n ({ children = <ChevronRightIcon />, ...rest }) => {\n const { buttonProps, getNextButtonProps, nextButtonProps } =\n useComponentContext()\n\n return {\n children,\n ...getNextButtonProps(mergeProps(buttonProps, nextButtonProps, rest)()),\n }\n },\n)\n\nexport interface CalendarSeparatorProps extends HTMLStyledProps<\"span\"> {}\n\nexport const CalendarSeparator = withContext<\"span\", CalendarSeparatorProps>(\n \"span\",\n \"separator\",\n)({ children: \"/\", role: \"separator\" })\n\nexport interface CalendarYearSelectProps extends Select.RootProps {}\n\nexport const CalendarYearSelect = withContext<\"div\", CalendarYearSelectProps>(\n (props) => {\n const { yearItems, getYearSelectProps, selectProps, yearSelectProps } =\n useComponentContext()\n const { contentProps, rootProps, ...rest } = mergeProps(\n selectProps,\n yearSelectProps,\n props,\n )()\n\n return (\n <Select.Root\n variant=\"plain\"\n items={yearItems}\n minH=\"{cell-size}\"\n contentProps={{ minW: \"{select-content-size}\", ...contentProps }}\n rootProps={{\n fontSize: \"{select-font-size}\",\n w: \"{select-root-size}\",\n ...rootProps,\n }}\n {...resetFieldProps}\n {...getYearSelectProps(rest)}\n />\n )\n },\n [\"select\", \"years\"],\n)()\n\nexport interface CalendarMonthSelectProps extends Select.RootProps {}\n\nexport const CalendarMonthSelect = withContext<\"div\", CalendarMonthSelectProps>(\n (props) => {\n const { monthItems, getMonthSelectProps, monthSelectProps, selectProps } =\n useComponentContext()\n const { contentProps, rootProps, ...rest } = mergeProps(\n selectProps,\n monthSelectProps,\n props,\n )()\n\n return (\n <Select.Root\n variant=\"plain\"\n items={monthItems}\n minH=\"{cell-size}\"\n contentProps={{ minW: \"{select-content-size}\", ...contentProps }}\n rootProps={{\n fontSize: \"{select-font-size}\",\n w: \"{select-root-size}\",\n ...rootProps,\n }}\n {...resetFieldProps}\n {...getMonthSelectProps(rest)}\n />\n )\n },\n [\"select\", \"months\"],\n)()\n\nexport interface CalendarMonthProps extends Omit<\n HTMLStyledProps<\"table\">,\n \"children\"\n> {\n /**\n * The day component to use.\n */\n day?: ReactNodeOrFunction<{ value: Date }>\n}\n\nexport const CalendarMonth = withContext<\"table\", CalendarMonthProps>(\n \"table\",\n \"month\",\n)(undefined, ({ day: dayProp, ...rest }) => {\n const {\n day,\n monthDays,\n weekdays,\n dayProps,\n getMonthProps,\n getWeekdayProps,\n monthProps,\n weekdayProps,\n weekdaysProps,\n weekProps,\n weeksProps,\n } = useComponentContext()\n\n dayProp ??= day\n\n const children = (\n <>\n <styled.thead aria-hidden>\n <CalendarWeekDays {...weekdaysProps}>\n {weekdays.map(({ label, value }, index) => (\n <CalendarWeekday\n key={index}\n {...getWeekdayProps({ ...weekdayProps, value })}\n >\n {label}\n </CalendarWeekday>\n ))}\n </CalendarWeekDays>\n </styled.thead>\n\n <CalendarWeeks {...weeksProps}>\n {monthDays.map((week, index) => (\n <CalendarWeek key={index} {...weekProps}>\n {week.map(({ label, value }) => (\n <CalendarDay\n key={value.toDateString()}\n {...{ ...dayProps, value }}\n >\n {runIfFn(dayProp, { value }) ?? (\n <styled.span>{label}</styled.span>\n )}\n </CalendarDay>\n ))}\n </CalendarWeek>\n ))}\n </CalendarWeeks>\n </>\n )\n\n return {\n ...getMonthProps(mergeProps(monthProps, rest)()),\n children,\n }\n})\n\nconst CalendarWeekDays = withContext(\"tr\", [\"row\", \"weekdays\"])()\n\nconst CalendarWeekday = withContext(\"th\", [\"cell\", \"weekday\"])()\n\nconst CalendarWeeks = withContext(\"tbody\", \"weeks\")()\n\nconst CalendarWeek = withContext(\"tr\", [\"row\", \"week\"])()\n\ninterface CalendarDayProps\n extends Omit<HTMLStyledProps<\"td\">, \"value\">, UseCalendarDayProps {}\n\nconst CalendarDay = withContext<\"td\", CalendarDayProps>(\"td\", [\"cell\", \"day\"])(\n undefined,\n (props) => {\n const { getDayProps } = useCalendarDay(props)\n\n return getDayProps()\n },\n)\n"],"mappings":";;;;;;;;;;;;;;AAiIA,MAAM,EACJ,kBACA,cAAc,sBACd,qBACA,iBAAiB,yBACjB,aACA,iBACE,oBACF,YACA,aACF;;;;;;AASA,MAAa,eAAe,cACwC,EAChE,UACA,KACA,aACA,cACA,UACA,YACA,kBACA,iBACA,iBACA,iBACA,aACA,cACA,eACA,WACA,YACA,iBACA,GAAG,YACqC;CACxC,MAAM,EACJ,aACA,aACA,UACA,YACA,aACA,UACA,QACA,KACA,SACA,SACA,OACA,WACA,YACA,UACA,OACA,gBACA,cACA,OACA,OACA,UACA,aACA,WACA,eACA,qBACA,oBACA,oBACA,oBACA,cACA,gBACA,iBACA,oBACA,UACA,eACA,aACA,gBACE,YAAY,KAAK;CACrB,MAAM,kBAAkB,eACf;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,MAAM,mBAAmB,eAChB;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,oBAAC,4BAAD;EAA4B,OAAO;EACjC,UAAA,oBAAC,iBAAD;GAAiB,OAAO;GACtB,UAAA,oBAAC,kBAAD;IAAkB,OAAO;IACvB,UAAA,oBAAC,OAAO,KAAR;KAAY,GAAI,aAAa;KAC1B,UAAA,YACC,qBAAA,YAAA,EAAA,UAAA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AAU,CAAC,CAAC,CAAC;AAEhE,MAAM,kBAAkB,YAAY,MAAM,CAAC,QAAQ,SAAS,CAAC,CAAC,CAAC;AAE/D,MAAM,gBAAgB,YAAY,SAAS,OAAO,CAAC,CAAC;AAEpD,MAAM,eAAe,YAAY,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC;AAKxD,MAAM,cAAc,YAAoC,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAC5E,KAAA,IACC,UAAU;CACT,MAAM,EAAE,gBAAgB,eAAe,KAAK;CAE5C,OAAO,YAAY;AACrB,CACF"}
@@ -9,7 +9,7 @@ import { useControllableState } from "../../hooks/use-controllable-state/index.j
9
9
  import { createDescendants } from "../../hooks/use-descendants/index.js";
10
10
  import { useI18n } from "../../providers/i18n-provider/i18n-provider.js";
11
11
  import { useDateTimeFormat } from "../format/use-format-date-time.js";
12
- import { useCallback, useMemo, useRef } from "react";
12
+ import { useCallback, useMemo, useRef, useState } from "react";
13
13
  import dayjs from "dayjs";
14
14
  //#region src/components/calendar/use-calendar.ts
15
15
  const DEFAULT_HOLIDAYS = [];
@@ -122,7 +122,7 @@ const getAdjustedMonth = (value, month) => {
122
122
  };
123
123
  const { DescendantsContext: CalendarDescendantsContext, useDescendant: useCalendarDescendant, useDescendants: useCalendarDescendants } = createDescendants();
124
124
  const [CalendarContext, useCalendarContext] = createContext$1({ name: "CalendarContext" });
125
- const useCalendar = ({ defaultMonth = /* @__PURE__ */ new Date(), multiple = false, range = false, defaultValue = range ? {
125
+ const useCalendar = ({ defaultMonth = () => /* @__PURE__ */ new Date(), multiple = false, range = false, defaultValue = range ? {
126
126
  end: void 0,
127
127
  start: void 0
128
128
  } : multiple ? [] : void 0, disabled = false, excludeDate, format = {}, holidays = DEFAULT_HOLIDAYS, locale: localeProp, max, maxDate = DEFAULT_MAX_DATE, minDate = DEFAULT_MIN_DATE, month: monthProp, startDayOfWeek = DEFAULT_FIRST_DAY_OF_WEEK, today = true, value: valueProp, weekendDays = DEFAULT_WEEKEND_DAYS, onChange: onChangeProp, onChangeMonth: onChangeMonthProp, ...rest } = {}) => {
@@ -153,6 +153,7 @@ const useCalendar = ({ defaultMonth = /* @__PURE__ */ new Date(), multiple = fal
153
153
  }, [dateTimeFormat, format.day]);
154
154
  const descendants = useCalendarDescendants();
155
155
  const monthRef = useRef(null);
156
+ const [currentDate] = useState(() => /* @__PURE__ */ new Date());
156
157
  const [value, setValue] = useControllableState({
157
158
  defaultValue,
158
159
  value: valueProp,
@@ -160,10 +161,9 @@ const useCalendar = ({ defaultMonth = /* @__PURE__ */ new Date(), multiple = fal
160
161
  });
161
162
  const [month, setMonth] = useControllableState({
162
163
  defaultValue: () => {
164
+ defaultMonth = (0, utils_exports.runIfFn)(defaultMonth);
163
165
  if (dayjs(minDate).isAfter(dayjs(defaultMonth))) defaultMonth = dayjs(minDate).set("date", 1).toDate();
164
- if (valueProp) defaultMonth = getAdjustedMonth(valueProp, defaultMonth);
165
- else if (defaultValue) defaultMonth = getAdjustedMonth(defaultValue, defaultMonth);
166
- return defaultMonth;
166
+ return getAdjustedMonth(value, defaultMonth);
167
167
  },
168
168
  value: monthProp,
169
169
  onChange: onChangeMonthProp
@@ -383,6 +383,7 @@ const useCalendar = ({ defaultMonth = /* @__PURE__ */ new Date(), multiple = fal
383
383
  t
384
384
  ]);
385
385
  return {
386
+ currentDate,
386
387
  descendants,
387
388
  disabled,
388
389
  endOfMonth,
@@ -421,13 +422,17 @@ const useCalendar = ({ defaultMonth = /* @__PURE__ */ new Date(), multiple = fal
421
422
  };
422
423
  const useCalendarDay = ({ value, ...rest }) => {
423
424
  const { t } = useI18n("calendar");
424
- const { disabled: rootDisabled, excludeDate, holidays, locale, max, maxDate, minDate, month, startDayOfWeek, today: highlightToday, value: selectedValue, weekendDays, onChange, onMonthChange, onNextMonth, onPrevMonth } = useCalendarContext();
425
+ const { currentDate, disabled: rootDisabled, excludeDate, holidays, locale, max, maxDate, minDate, month, startDayOfWeek, today: highlightToday, value: selectedValue, weekendDays, onChange, onMonthChange, onNextMonth, onPrevMonth } = useCalendarContext();
425
426
  const dateTimeFormat = useDateTimeFormat({ locale });
426
427
  const cellRef = useRef(null);
427
428
  const outside = useMemo(() => !isSameMonth(month, value), [month, value]);
428
429
  const holiday = useMemo(() => holidays.some((holiday) => isSameDate(holiday, value)), [holidays, value]);
429
430
  const weekend = useMemo(() => weekendDays.includes(value.getDay()), [weekendDays, value]);
430
- const today = useMemo(() => highlightToday && isSameDate(value, /* @__PURE__ */ new Date()), [highlightToday, value]);
431
+ const today = useMemo(() => highlightToday && isSameDate(value, currentDate), [
432
+ highlightToday,
433
+ value,
434
+ currentDate
435
+ ]);
431
436
  const selected = useMemo(() => {
432
437
  if ((0, utils_exports.isDate)(selectedValue)) return isSameDate(selectedValue, value);
433
438
  else if ((0, utils_exports.isArray)(selectedValue)) return selectedValue.some((selectedValue) => isSameDate(selectedValue, value));