@yamada-ui/react 2.2.3-dev-20260622141401 → 2.2.3-dev-20260624122859
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/cjs/components/accordion/use-accordion.cjs.map +1 -1
- package/dist/cjs/components/autocomplete/use-autocomplete.cjs.map +1 -1
- package/dist/cjs/components/calendar/use-calendar.cjs +1 -1
- package/dist/cjs/components/calendar/use-calendar.cjs.map +1 -1
- package/dist/cjs/components/carousel/carousel.cjs.map +1 -1
- package/dist/cjs/components/chart/chart.cjs.map +1 -1
- package/dist/cjs/components/chart/use-polar-chart.cjs.map +1 -1
- package/dist/cjs/components/checkbox/checkbox.cjs.map +1 -1
- package/dist/cjs/components/checkbox/use-checkbox-group.cjs.map +1 -1
- package/dist/cjs/components/checkbox-card/checkbox-card.cjs.map +1 -1
- package/dist/cjs/components/collapse/collapse.cjs.map +1 -1
- package/dist/cjs/components/color-picker/use-color-picker.cjs.map +1 -1
- package/dist/cjs/components/color-swatch/color-swatch-group.cjs.map +1 -1
- package/dist/cjs/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/cjs/components/date-picker/use-date-picker.cjs +1 -1
- package/dist/cjs/components/date-picker/use-date-picker.cjs.map +1 -1
- package/dist/cjs/components/editable/use-editable.cjs.map +1 -1
- package/dist/cjs/components/field/field.cjs.map +1 -1
- package/dist/cjs/components/file-input/file-input.cjs.map +1 -1
- package/dist/cjs/components/flip/flip.cjs.map +1 -1
- package/dist/cjs/components/highlight/highlight.cjs.map +1 -1
- package/dist/cjs/components/indicator/indicator.cjs.map +1 -1
- package/dist/cjs/components/infinite-scroll-area/use-infinite-scroll.cjs.map +1 -1
- package/dist/cjs/components/input/input-group.cjs.map +1 -1
- package/dist/cjs/components/list/list.cjs.map +1 -1
- package/dist/cjs/components/menu/use-menu.cjs.map +1 -1
- package/dist/cjs/components/native-select/use-native-select.cjs.map +1 -1
- package/dist/cjs/components/native-table/native-table.cjs.map +1 -1
- package/dist/cjs/components/notice/notice.cjs.map +1 -1
- package/dist/cjs/components/number-input/use-number-input.cjs.map +1 -1
- package/dist/cjs/components/pagination/pagination.cjs.map +1 -1
- package/dist/cjs/components/pagination/use-pagination.cjs.map +1 -1
- package/dist/cjs/components/picture/picture.cjs.map +1 -1
- package/dist/cjs/components/pin-input/pin-input.cjs.map +1 -1
- package/dist/cjs/components/pin-input/use-pin-input.cjs.map +1 -1
- package/dist/cjs/components/qr-code/use-qr-code.cjs.map +1 -1
- package/dist/cjs/components/radio/use-radio-group.cjs.map +1 -1
- package/dist/cjs/components/segmented-control/segmented-control.cjs.map +1 -1
- package/dist/cjs/components/select/use-select.cjs.map +1 -1
- package/dist/cjs/components/show/show.cjs.map +1 -1
- package/dist/cjs/components/sidebar/sidebar.cjs.map +1 -1
- package/dist/cjs/components/sidebar/use-sidebar.cjs.map +1 -1
- package/dist/cjs/components/simple-grid/simple-grid.cjs.map +1 -1
- package/dist/cjs/components/stack/z-stack.cjs.map +1 -1
- package/dist/cjs/components/steps/steps.cjs.map +1 -1
- package/dist/cjs/components/steps/use-steps.cjs.map +1 -1
- package/dist/cjs/components/table/table.cjs.map +1 -1
- package/dist/cjs/components/tabs/tabs.cjs.map +1 -1
- package/dist/cjs/components/toggle/use-toggle-group.cjs.map +1 -1
- package/dist/cjs/components/toggle/use-toggle.cjs.map +1 -1
- package/dist/cjs/components/tree/tree.cjs.map +1 -1
- package/dist/cjs/components/tree/use-tree.cjs.map +1 -1
- package/dist/cjs/core/components/create-component.cjs.map +1 -1
- package/dist/cjs/core/components/props.cjs.map +1 -1
- package/dist/cjs/core/components/use-component-style.cjs.map +1 -1
- package/dist/cjs/core/css/animation.cjs.map +1 -1
- package/dist/cjs/core/css/at-rule.cjs.map +1 -1
- package/dist/cjs/core/css/calc.cjs.map +1 -1
- package/dist/cjs/core/css/color-mix.cjs.map +1 -1
- package/dist/cjs/core/css/config.cjs.map +1 -1
- package/dist/cjs/core/css/css.cjs.map +1 -1
- package/dist/cjs/core/css/gradient.cjs.map +1 -1
- package/dist/cjs/core/css/grid.cjs.map +1 -1
- package/dist/cjs/core/css/transition.cjs.map +1 -1
- package/dist/cjs/core/css/utils.cjs.map +1 -1
- package/dist/cjs/core/system/breakpoint.cjs.map +1 -1
- package/dist/cjs/core/system/color-mode-provider.cjs.map +1 -1
- package/dist/cjs/core/system/create-system.cjs.map +1 -1
- package/dist/cjs/core/system/environment-provider.cjs.map +1 -1
- package/dist/cjs/core/system/storage-manager.cjs.map +1 -1
- package/dist/cjs/core/system/storage-script.cjs.map +1 -1
- package/dist/cjs/core/system/use-system-color-mode.cjs.map +1 -1
- package/dist/cjs/core/system/var.cjs.map +1 -1
- package/dist/cjs/hooks/use-animation/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-breakpoint/use-breakpoint-value.cjs.map +1 -1
- package/dist/cjs/hooks/use-breakpoint/use-breakpoint.cjs.map +1 -1
- package/dist/cjs/hooks/use-clickable/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-clipboard/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-controllable-state/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-counter/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-descendants/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-focus/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-local-storage/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-mounted/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-outside-click/index.cjs.map +1 -1
- package/dist/cjs/providers/i18n-provider/i18n-provider.cjs.map +1 -1
- package/dist/cjs/utils/children.cjs.map +1 -1
- package/dist/cjs/utils/dom.cjs.map +1 -1
- package/dist/cjs/utils/store.cjs.map +1 -1
- package/dist/esm/components/accordion/use-accordion.js.map +1 -1
- package/dist/esm/components/autocomplete/use-autocomplete.js.map +1 -1
- package/dist/esm/components/calendar/use-calendar.js +1 -1
- package/dist/esm/components/calendar/use-calendar.js.map +1 -1
- package/dist/esm/components/carousel/carousel.js.map +1 -1
- package/dist/esm/components/chart/chart.js.map +1 -1
- package/dist/esm/components/chart/use-polar-chart.js.map +1 -1
- package/dist/esm/components/checkbox/checkbox.js.map +1 -1
- package/dist/esm/components/checkbox/use-checkbox-group.js.map +1 -1
- package/dist/esm/components/checkbox-card/checkbox-card.js.map +1 -1
- package/dist/esm/components/collapse/collapse.js.map +1 -1
- package/dist/esm/components/color-picker/use-color-picker.js.map +1 -1
- package/dist/esm/components/color-swatch/color-swatch-group.js.map +1 -1
- package/dist/esm/components/date-picker/date-picker.js.map +1 -1
- package/dist/esm/components/date-picker/use-date-picker.js +1 -1
- package/dist/esm/components/date-picker/use-date-picker.js.map +1 -1
- package/dist/esm/components/editable/use-editable.js.map +1 -1
- package/dist/esm/components/field/field.js.map +1 -1
- package/dist/esm/components/file-input/file-input.js.map +1 -1
- package/dist/esm/components/flip/flip.js.map +1 -1
- package/dist/esm/components/highlight/highlight.js.map +1 -1
- package/dist/esm/components/indicator/indicator.js.map +1 -1
- package/dist/esm/components/infinite-scroll-area/use-infinite-scroll.js.map +1 -1
- package/dist/esm/components/input/input-group.js.map +1 -1
- package/dist/esm/components/list/list.js.map +1 -1
- package/dist/esm/components/menu/use-menu.js.map +1 -1
- package/dist/esm/components/native-select/use-native-select.js.map +1 -1
- package/dist/esm/components/native-table/native-table.js.map +1 -1
- package/dist/esm/components/notice/notice.js.map +1 -1
- package/dist/esm/components/number-input/use-number-input.js.map +1 -1
- package/dist/esm/components/pagination/pagination.js.map +1 -1
- package/dist/esm/components/pagination/use-pagination.js.map +1 -1
- package/dist/esm/components/picture/picture.js.map +1 -1
- package/dist/esm/components/pin-input/pin-input.js.map +1 -1
- package/dist/esm/components/pin-input/use-pin-input.js.map +1 -1
- package/dist/esm/components/qr-code/use-qr-code.js.map +1 -1
- package/dist/esm/components/radio/use-radio-group.js.map +1 -1
- package/dist/esm/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/esm/components/select/use-select.js.map +1 -1
- package/dist/esm/components/show/show.js.map +1 -1
- package/dist/esm/components/sidebar/sidebar.js.map +1 -1
- package/dist/esm/components/sidebar/use-sidebar.js.map +1 -1
- package/dist/esm/components/simple-grid/simple-grid.js.map +1 -1
- package/dist/esm/components/stack/z-stack.js.map +1 -1
- package/dist/esm/components/steps/steps.js.map +1 -1
- package/dist/esm/components/steps/use-steps.js.map +1 -1
- package/dist/esm/components/table/table.js.map +1 -1
- package/dist/esm/components/tabs/tabs.js.map +1 -1
- package/dist/esm/components/toggle/use-toggle-group.js.map +1 -1
- package/dist/esm/components/toggle/use-toggle.js.map +1 -1
- package/dist/esm/components/tree/tree.js.map +1 -1
- package/dist/esm/components/tree/use-tree.js.map +1 -1
- package/dist/esm/core/components/create-component.js.map +1 -1
- package/dist/esm/core/components/props.js.map +1 -1
- package/dist/esm/core/components/use-component-style.js.map +1 -1
- package/dist/esm/core/css/animation.js.map +1 -1
- package/dist/esm/core/css/at-rule.js.map +1 -1
- package/dist/esm/core/css/calc.js.map +1 -1
- package/dist/esm/core/css/color-mix.js.map +1 -1
- package/dist/esm/core/css/config.js.map +1 -1
- package/dist/esm/core/css/css.js.map +1 -1
- package/dist/esm/core/css/gradient.js.map +1 -1
- package/dist/esm/core/css/grid.js.map +1 -1
- package/dist/esm/core/css/transition.js.map +1 -1
- package/dist/esm/core/css/utils.js.map +1 -1
- package/dist/esm/core/system/breakpoint.js.map +1 -1
- package/dist/esm/core/system/color-mode-provider.js.map +1 -1
- package/dist/esm/core/system/create-system.js.map +1 -1
- package/dist/esm/core/system/environment-provider.js.map +1 -1
- package/dist/esm/core/system/storage-manager.js.map +1 -1
- package/dist/esm/core/system/storage-script.js.map +1 -1
- package/dist/esm/core/system/use-system-color-mode.js.map +1 -1
- package/dist/esm/core/system/var.js.map +1 -1
- package/dist/esm/hooks/use-animation/index.js.map +1 -1
- package/dist/esm/hooks/use-breakpoint/use-breakpoint-value.js.map +1 -1
- package/dist/esm/hooks/use-breakpoint/use-breakpoint.js.map +1 -1
- package/dist/esm/hooks/use-clickable/index.js.map +1 -1
- package/dist/esm/hooks/use-clipboard/index.js.map +1 -1
- package/dist/esm/hooks/use-controllable-state/index.js.map +1 -1
- package/dist/esm/hooks/use-counter/index.js.map +1 -1
- package/dist/esm/hooks/use-descendants/index.js.map +1 -1
- package/dist/esm/hooks/use-focus/index.js.map +1 -1
- package/dist/esm/hooks/use-local-storage/index.js.map +1 -1
- package/dist/esm/hooks/use-mounted/index.js.map +1 -1
- package/dist/esm/hooks/use-outside-click/index.js.map +1 -1
- package/dist/esm/providers/i18n-provider/i18n-provider.js.map +1 -1
- package/dist/esm/utils/children.js.map +1 -1
- package/dist/esm/utils/dom.js.map +1 -1
- package/dist/esm/utils/store.js.map +1 -1
- package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
- package/dist/types/components/breadcrumb/breadcrumb.style.d.ts +1 -1
- package/dist/types/components/calendar/calendar.style.d.ts +2 -2
- package/dist/types/components/carousel/carousel.style.d.ts +2 -2
- package/dist/types/components/date-picker/date-picker.style.d.ts +1 -1
- package/dist/types/components/field/use-field-props.d.ts +1 -1
- package/dist/types/components/file-button/use-file-button.d.ts +2 -2
- package/dist/types/components/file-input/use-file-input.d.ts +2 -2
- package/dist/types/components/menu/menu.style.d.ts +2 -2
- package/dist/types/components/progress/use-progress.d.ts +6 -6
- package/dist/types/components/rating/rating.style.d.ts +2 -2
- package/dist/types/components/select/select.style.d.ts +1 -1
- package/dist/types/components/steps/steps.style.d.ts +1 -1
- package/dist/types/components/tabs/tabs.style.d.ts +1 -1
- package/dist/types/components/tree/tree.style.d.ts +1 -1
- package/dist/types/components/tree/use-tree.d.ts +2 -2
- package/dist/types/hooks/use-clickable/index.d.ts +2 -2
- package/dist/types/providers/i18n-provider/i18n-provider.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-autocomplete.js","names":["createContext","match"],"sources":["../../../../src/components/autocomplete/use-autocomplete.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 {\n ComboboxItem,\n ComboboxItemWithValue,\n UseComboboxItemProps,\n UseComboboxProps,\n} from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox, useComboboxItem } 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 createContext,\n dataAttr,\n handlerAll,\n isArray,\n isComposing,\n isNumber,\n isString,\n isUndefined,\n match,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface AutocompleteRenderProps extends ComboboxItemWithValue {\n count: number\n focused: boolean\n index: number\n separator: string\n onClear: () => void\n max?: number\n}\n\nexport interface AutocompleteItemRender {\n (props: AutocompleteRenderProps): ReactNode\n}\n\nconst defaultRender: AutocompleteItemRender = ({\n count,\n focused,\n index,\n label,\n max,\n separator,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {label}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nconst getInputValue = (item?: ComboboxItemWithValue) =>\n isString(item?.label) ? item.label : (item?.query ?? \"\")\n\nexport interface AutocompleteFilter {\n (\n inputValue: string,\n items: ComboboxItem[],\n matcher: AutocompleteMatcher,\n ): ComboboxItem[]\n}\n\nconst defaultFilter: AutocompleteFilter = (inputValue, items, match) => {\n if (!inputValue.length) return items\n\n return items\n .map((item) => {\n if (\"items\" in item) {\n const items = item.items.filter((item) => {\n if (\"query\" in item) {\n return isString(item.query) && match(item.query, inputValue)\n } else if (isString(item.label)) {\n return isString(item.label) && match(item.label, inputValue)\n }\n })\n\n if (items.length) return { ...item, items }\n } else if (\"query\" in item) {\n if (isString(item.query) && match(item.query, inputValue)) return item\n } else if (isString(item.label)) {\n if (isString(item.label) && match(item.label, inputValue)) return item\n }\n })\n .filter(Boolean) as ComboboxItem[]\n}\n\nexport type AutocompleteMatcher = typeof match\n\ninterface AutocompleteContext extends Pick<\n UseAutocompleteReturn,\n \"max\" | \"value\"\n> {}\n\nconst [AutocompleteContext, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n })\n\nexport { AutocompleteContext, useAutocompleteContext }\n\nexport interface UseAutocompleteProps<Multiple extends boolean = false>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\" | \"value\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, the autocomplete will allow custom value.\n *\n * @default false\n */\n allowCustomValue?: boolean\n /**\n * If `true`, the autocomplete 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?: string\n /**\n * The initial value of the autocomplete.\n */\n defaultValue?: Multiple extends true ? string[] : string\n /**\n * The message displayed when the search yields no hits.\n *\n * @default 'No results found'\n */\n emptyMessage?: ReactNode\n /**\n * The function to filter the items.\n */\n filter?: AutocompleteFilter\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 `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: string\n /**\n * If provided, generate options based on items.\n *\n * @default []\n */\n items?: ComboboxItem[]\n /**\n * The function to match the items.\n */\n matcher?: AutocompleteMatcher\n /**\n * The maximum selectable value.\n */\n max?: number\n /**\n * If `true`, the autocomplete will be multiple.\n *\n * @default false\n */\n multiple?: Multiple\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the autocomplete 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 autocomplete will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The placeholder for autocomplete.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The value of the autocomplete.\n */\n value?: Multiple extends true ? string[] : string\n /**\n * The callback invoked when value state changes.\n */\n onChange?: (value: Multiple extends true ? string[] : string) => void\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: string) => void\n /**\n * The function to render the selected items.\n */\n render?: (props: AutocompleteRenderProps) => ReactNode\n}\n\nexport const useAutocomplete = <Multiple extends boolean = false>(\n props: UseAutocompleteProps<Multiple> = {},\n) => {\n type MaybeValue = Multiple extends true ? string[] : string\n\n const { t } = useI18n(\"autocomplete\")\n const {\n props: {\n id,\n ref,\n name,\n allowCustomValue = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultValue = (multiple ? [] : \"\") as MaybeValue,\n disabled,\n emptyMessage = t(\"No results found\"),\n filter = defaultFilter,\n focusOnClear = true,\n inputValue: inputValueProp,\n items = [],\n matcher = match,\n max,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n placeholder,\n readOnly,\n render = defaultRender,\n required,\n separator = \",\",\n value: valueProp,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const valueMap = useMemo<{ [key: string]: ComboboxItemWithValue }>(() => {\n const valueMap: { [key: string]: ComboboxItemWithValue } = {}\n\n items.forEach((item) => {\n if (\"items\" in item) {\n item.items.forEach((item) => {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n })\n } else {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n }\n })\n\n return valueMap\n }, [items])\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [inputValue, setInputValue] = useControllableState({\n defaultValue:\n defaultInputValue ??\n getInputValue(isString(value) ? valueMap[value] : undefined),\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const onChange = useCallback(\n (selectedValue: string) => {\n setValue((prev) => {\n if (isArray(prev)) {\n if (prev.includes(selectedValue)) {\n return prev.filter(\n (prevValue) => prevValue !== selectedValue,\n ) as MaybeValue\n } else if (!isNumber(max) || prev.length < max) {\n return [...prev, selectedValue] as MaybeValue\n } else {\n return prev\n }\n } else {\n return selectedValue as MaybeValue\n }\n })\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n const item = valueMap[selectedValue]\n\n setInputValue(getInputValue(item))\n }\n },\n [max, setInputValue, setValue, value, valueMap],\n )\n const {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onSelect,\n } = useCombobox({\n closeOnSelect,\n disabled,\n initialFocusValue: isArray(value) ? value[0] : value,\n openOnClick: false,\n openOnEnter: false,\n openOnSpace: false,\n readOnly,\n selectFocusRef: inputRef,\n selectOnSpace: false,\n onChange,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const filteredItems = useMemo<ComboboxItem[]>(() => {\n if (!items.length) return []\n\n return filter(inputValue, items, matcher)\n }, [filter, inputValue, items, matcher])\n const resolvedItems = useMemo<ComboboxItem[]>(() => {\n return filteredItems.length\n ? filteredItems\n : [{ \"data-empty\": \"\", label: emptyMessage }]\n }, [filteredItems, emptyMessage])\n const empty = useMemo(\n () => !resolvedItems.filter(({ hidden }) => !hidden).length,\n [resolvedItems],\n )\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((value, index) => {\n const item = valueMap[value] ?? { label: value, value }\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n if (item.value) onChange(item.value)\n }\n\n const component = render({\n count,\n focused,\n index,\n max,\n separator,\n onClear,\n ...item,\n })\n\n if (isValidElement<Dict>(component)) {\n return cloneElement(component, { ...component.props, key: index })\n } else {\n return component\n }\n })\n }, [focused, max, onChange, render, separator, value, valueMap])\n const hasValues = isArray(value) && !!value.length\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n activeDescendant.current = null\n\n const inputValue = ev.target.value\n\n setInputValue(inputValue)\n\n if (inputValue.length || isArray(value)) return\n\n setValue(\"\" as MaybeValue)\n },\n [\n activeDescendant,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n setInputValue,\n setValue,\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)) return\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) => prev.slice(0, -1) as MaybeValue)\n },\n Enter: (ev) => {\n if (!open || !inputValue.length || activeDescendant.current) return\n\n const item = filteredItems[0]\n\n if (!item) {\n if (!allowCustomValue || !isArray(value)) return\n\n ev.preventDefault()\n\n onSelect(inputValue)\n } else {\n ev.preventDefault()\n\n if (\"items\" in item) {\n onSelect(item.items[0]?.value)\n } else {\n onSelect(item.value)\n }\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n activeDescendant,\n allowCustomValue,\n disabled,\n filteredItems,\n onSelect,\n open,\n setValue,\n value,\n ],\n )\n\n const onClick = useCallback(() => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n inputRef.current?.focus()\n\n if (openOnClick) onOpenWithActiveDescendant(descendants.enabledFirstValue)\n }, [descendants, interactive, onOpenWithActiveDescendant, openOnClick])\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n\n focusByClickRef.current = false\n },\n [openOnFocus, onOpenWithActiveDescendant, descendants.enabledFirstValue],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n setFocused(false)\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n if (allowCustomValue) {\n if (inputValue) setValue(inputValue as MaybeValue)\n } else {\n const item = isString(value) ? valueMap[value] : undefined\n\n setInputValue(getInputValue(item))\n }\n }\n }\n },\n [allowCustomValue, inputValue, setInputValue, setValue, value, valueMap],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => (isArray(prev) ? [] : \"\") as MaybeValue)\n setInputValue(\"\")\n\n if (focusOnClear) inputRef.current?.focus()\n }, [focusOnClear, interactive, setInputValue, setValue])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n setInputValue(\n getInputValue(isString(valueProp) ? valueMap[valueProp] : undefined),\n )\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n ...props,\n }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n tabIndex: -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n }),\n\n [getTriggerProps, onClick],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n id,\n ref: mergeRefs(props.ref, ref, inputRef),\n name,\n style: {\n ...(!focused && isArray(value) && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...props.style,\n },\n \"data-max\": dataAttr(\n isArray(value) && isNumber(max) && value.length >= max,\n ),\n autoCapitalize: \"off\",\n autoComplete: \"off\",\n autoCorrect: \"off\",\n disabled,\n placeholder: hasValues ? undefined : placeholder,\n readOnly,\n required,\n spellCheck: false,\n value: inputValue,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n [\n dataProps,\n disabled,\n focused,\n hasValues,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n placeholder,\n readOnly,\n ref,\n required,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n hidden: empty,\n ...props,\n }),\n [empty, getComboboxContentProps],\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 descendants,\n inputValue,\n interactive,\n items: resolvedItems,\n max,\n open,\n setInputValue,\n setValue,\n value,\n valueMap,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n getSeparatorProps,\n popoverProps,\n onActiveDescendant,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n onSelect,\n }\n}\n\nexport type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>\n\nexport interface UseAutocompleteOptionProps extends UseComboboxItemProps {}\n\nexport const useAutocompleteOption = ({\n children,\n closeOnSelect,\n disabled,\n hidden,\n value,\n ...rest\n}: UseAutocompleteOptionProps = {}) => {\n const { max, value: selectedValue } = useAutocompleteContext()\n\n value ??= isString(children) ? children : undefined\n\n const selected = isArray(selectedValue)\n ? !isUndefined(value) && selectedValue.includes(value)\n : selectedValue === value\n const completed =\n isNumber(max) && isArray(selectedValue) && selectedValue.length >= max\n const { getIndicatorProps, getItemProps } = useComboboxItem({\n children,\n closeOnSelect,\n disabled: disabled || hidden || (completed && !selected),\n hidden,\n selected,\n value,\n ...rest,\n })\n\n const getOptionProps: PropGetter = useCallback(\n (props = {}) => getItemProps(props),\n [getItemProps],\n )\n\n return { getIndicatorProps, getOptionProps }\n}\n\nexport type UseAutocompleteOptionReturn = ReturnType<\n typeof useAutocompleteOption\n>\n"],"mappings":";;;;;;;;;;;;;AA+DA,MAAM,iBAAyC,EAC7C,OACA,SACA,OACA,OACA,KACA,gBACI;CACJ,MAAM,OAAO,QAAQ,MAAM;CAE3B,OACE,qBAAC,QAAD;EAAM,OAAO,EAA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O;IAAS,OAAO;GAAQ,CAAC,CACrD;EACF,CAAC,GACH;GAAC;GAAc;GAAa;GAAS;EAAC,CAetB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AAMA,MAAa,yBAAyB,EACpC,UACA,eACA,UACA,QACA,OACA,GAAG,SAC2B,CAAC,MAAM;CACrC,MAAM,EAAE,KAAK,OAAO,kBAAkB,uBAAuB;CAE7D,WAAA,GAAA,cAAA,SAAA,CAAmB,QAAQ,IAAI,WAAW,KAAA;CAE1C,MAAM,YAAA,GAAA,cAAA,QAAA,CAAmB,aAAa,IAClC,EAAA,GAAA,cAAA,YAAA,CAAa,KAAK,KAAK,cAAc,SAAS,KAAK,IACnD,kBAAkB;CACtB,MAAM,aAAA,GAAA,cAAA,SAAA,CACK,GAAG,MAAA,GAAA,cAAA,QAAA,CAAa,aAAa,KAAK,cAAc,UAAU;CACrE,MAAM,EAAE,mBAAmB,iBAAiB,gBAAgB;EAC1D;EACA;EACA,UAAU,YAAY,UAAW,aAAa,CAAC;EAC/C;EACA;EACA;EACA,GAAG;CACL,CAAC;CAOD,OAAO;EAAE;EAAmB,gBALO,aAChC,QAAQ,CAAC,MAAM,aAAa,KAAK,GAClC,CAAC,YAAY,CAG0B;CAAE;AAC7C"}
|
|
1
|
+
{"version":3,"file":"use-autocomplete.js","names":["createContext","match"],"sources":["../../../../src/components/autocomplete/use-autocomplete.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 {\n ComboboxItem,\n ComboboxItemWithValue,\n UseComboboxItemProps,\n UseComboboxProps,\n} from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox, useComboboxItem } 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 createContext,\n dataAttr,\n handlerAll,\n isArray,\n isComposing,\n isNumber,\n isString,\n isUndefined,\n match,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface AutocompleteRenderProps extends ComboboxItemWithValue {\n count: number\n focused: boolean\n index: number\n separator: string\n onClear: () => void\n max?: number\n}\n\nexport interface AutocompleteItemRender {\n (props: AutocompleteRenderProps): ReactNode\n}\n\nconst defaultRender: AutocompleteItemRender = ({\n count,\n focused,\n index,\n label,\n max,\n separator,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {label}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nconst getInputValue = (item?: ComboboxItemWithValue) =>\n isString(item?.label) ? item.label : (item?.query ?? \"\")\n\nexport interface AutocompleteFilter {\n (\n inputValue: string,\n items: ComboboxItem[],\n matcher: AutocompleteMatcher,\n ): ComboboxItem[]\n}\n\nconst defaultFilter: AutocompleteFilter = (inputValue, items, match) => {\n if (!inputValue.length) return items\n\n return items\n .map((item) => {\n if (\"items\" in item) {\n const items = item.items.filter((item) => {\n if (\"query\" in item)\n return isString(item.query) && match(item.query, inputValue)\n else if (isString(item.label))\n return isString(item.label) && match(item.label, inputValue)\n })\n\n if (items.length) return { ...item, items }\n } else if (\"query\" in item) {\n if (isString(item.query) && match(item.query, inputValue)) return item\n } else if (isString(item.label)) {\n if (isString(item.label) && match(item.label, inputValue)) return item\n }\n })\n .filter(Boolean) as ComboboxItem[]\n}\n\nexport type AutocompleteMatcher = typeof match\n\ninterface AutocompleteContext extends Pick<\n UseAutocompleteReturn,\n \"max\" | \"value\"\n> {}\n\nconst [AutocompleteContext, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n })\n\nexport { AutocompleteContext, useAutocompleteContext }\n\nexport interface UseAutocompleteProps<Multiple extends boolean = false>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\" | \"value\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, the autocomplete will allow custom value.\n *\n * @default false\n */\n allowCustomValue?: boolean\n /**\n * If `true`, the autocomplete 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?: string\n /**\n * The initial value of the autocomplete.\n */\n defaultValue?: Multiple extends true ? string[] : string\n /**\n * The message displayed when the search yields no hits.\n *\n * @default 'No results found'\n */\n emptyMessage?: ReactNode\n /**\n * The function to filter the items.\n */\n filter?: AutocompleteFilter\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 `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: string\n /**\n * If provided, generate options based on items.\n *\n * @default []\n */\n items?: ComboboxItem[]\n /**\n * The function to match the items.\n */\n matcher?: AutocompleteMatcher\n /**\n * The maximum selectable value.\n */\n max?: number\n /**\n * If `true`, the autocomplete will be multiple.\n *\n * @default false\n */\n multiple?: Multiple\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the autocomplete 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 autocomplete will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The placeholder for autocomplete.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The value of the autocomplete.\n */\n value?: Multiple extends true ? string[] : string\n /**\n * The callback invoked when value state changes.\n */\n onChange?: (value: Multiple extends true ? string[] : string) => void\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: string) => void\n /**\n * The function to render the selected items.\n */\n render?: (props: AutocompleteRenderProps) => ReactNode\n}\n\nexport const useAutocomplete = <Multiple extends boolean = false>(\n props: UseAutocompleteProps<Multiple> = {},\n) => {\n type MaybeValue = Multiple extends true ? string[] : string\n\n const { t } = useI18n(\"autocomplete\")\n const {\n props: {\n id,\n ref,\n name,\n allowCustomValue = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultValue = (multiple ? [] : \"\") as MaybeValue,\n disabled,\n emptyMessage = t(\"No results found\"),\n filter = defaultFilter,\n focusOnClear = true,\n inputValue: inputValueProp,\n items = [],\n matcher = match,\n max,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n placeholder,\n readOnly,\n render = defaultRender,\n required,\n separator = \",\",\n value: valueProp,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const valueMap = useMemo<{ [key: string]: ComboboxItemWithValue }>(() => {\n const valueMap: { [key: string]: ComboboxItemWithValue } = {}\n\n items.forEach((item) => {\n if (\"items\" in item) {\n item.items.forEach((item) => {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n })\n } else {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n }\n })\n\n return valueMap\n }, [items])\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [inputValue, setInputValue] = useControllableState({\n defaultValue:\n defaultInputValue ??\n getInputValue(isString(value) ? valueMap[value] : undefined),\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const onChange = useCallback(\n (selectedValue: string) => {\n setValue((prev) => {\n if (isArray(prev))\n if (prev.includes(selectedValue))\n return prev.filter(\n (prevValue) => prevValue !== selectedValue,\n ) as MaybeValue\n else if (!isNumber(max) || prev.length < max)\n return [...prev, selectedValue] as MaybeValue\n else return prev\n else return selectedValue as MaybeValue\n })\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n const item = valueMap[selectedValue]\n\n setInputValue(getInputValue(item))\n }\n },\n [max, setInputValue, setValue, value, valueMap],\n )\n const {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onSelect,\n } = useCombobox({\n closeOnSelect,\n disabled,\n initialFocusValue: isArray(value) ? value[0] : value,\n openOnClick: false,\n openOnEnter: false,\n openOnSpace: false,\n readOnly,\n selectFocusRef: inputRef,\n selectOnSpace: false,\n onChange,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const filteredItems = useMemo<ComboboxItem[]>(() => {\n if (!items.length) return []\n\n return filter(inputValue, items, matcher)\n }, [filter, inputValue, items, matcher])\n const resolvedItems = useMemo<ComboboxItem[]>(() => {\n return filteredItems.length\n ? filteredItems\n : [{ \"data-empty\": \"\", label: emptyMessage }]\n }, [filteredItems, emptyMessage])\n const empty = useMemo(\n () => !resolvedItems.filter(({ hidden }) => !hidden).length,\n [resolvedItems],\n )\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((value, index) => {\n const item = valueMap[value] ?? { label: value, value }\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n if (item.value) onChange(item.value)\n }\n\n const component = render({\n count,\n focused,\n index,\n max,\n separator,\n onClear,\n ...item,\n })\n\n if (isValidElement<Dict>(component))\n return cloneElement(component, { ...component.props, key: index })\n else return component\n })\n }, [focused, max, onChange, render, separator, value, valueMap])\n const hasValues = isArray(value) && !!value.length\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) onClose()\n else if (runIfFn(openOnChange, ev)) onOpen()\n\n activeDescendant.current = null\n\n const inputValue = ev.target.value\n\n setInputValue(inputValue)\n\n if (inputValue.length || isArray(value)) return\n\n setValue(\"\" as MaybeValue)\n },\n [\n activeDescendant,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n setInputValue,\n setValue,\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)) return\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) => prev.slice(0, -1) as MaybeValue)\n },\n Enter: (ev) => {\n if (!open || !inputValue.length || activeDescendant.current) return\n\n const item = filteredItems[0]\n\n if (!item) {\n if (!allowCustomValue || !isArray(value)) return\n\n ev.preventDefault()\n\n onSelect(inputValue)\n } else {\n ev.preventDefault()\n\n if (\"items\" in item) onSelect(item.items[0]?.value)\n else onSelect(item.value)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n activeDescendant,\n allowCustomValue,\n disabled,\n filteredItems,\n onSelect,\n open,\n setValue,\n value,\n ],\n )\n\n const onClick = useCallback(() => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n inputRef.current?.focus()\n\n if (openOnClick) onOpenWithActiveDescendant(descendants.enabledFirstValue)\n }, [descendants, interactive, onOpenWithActiveDescendant, openOnClick])\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n\n focusByClickRef.current = false\n },\n [openOnFocus, onOpenWithActiveDescendant, descendants.enabledFirstValue],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n setFocused(false)\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else if (allowCustomValue) {\n if (inputValue) setValue(inputValue as MaybeValue)\n } else {\n const item = isString(value) ? valueMap[value] : undefined\n\n setInputValue(getInputValue(item))\n }\n }\n },\n [allowCustomValue, inputValue, setInputValue, setValue, value, valueMap],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => (isArray(prev) ? [] : \"\") as MaybeValue)\n setInputValue(\"\")\n\n if (focusOnClear) inputRef.current?.focus()\n }, [focusOnClear, interactive, setInputValue, setValue])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n setInputValue(\n getInputValue(isString(valueProp) ? valueMap[valueProp] : undefined),\n )\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n ...props,\n }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n tabIndex: -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n }),\n\n [getTriggerProps, onClick],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n id,\n ref: mergeRefs(props.ref, ref, inputRef),\n name,\n style: {\n ...(!focused && isArray(value) && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...props.style,\n },\n \"data-max\": dataAttr(\n isArray(value) && isNumber(max) && value.length >= max,\n ),\n autoCapitalize: \"off\",\n autoComplete: \"off\",\n autoCorrect: \"off\",\n disabled,\n placeholder: hasValues ? undefined : placeholder,\n readOnly,\n required,\n spellCheck: false,\n value: inputValue,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n [\n dataProps,\n disabled,\n focused,\n hasValues,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n placeholder,\n readOnly,\n ref,\n required,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n hidden: empty,\n ...props,\n }),\n [empty, getComboboxContentProps],\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 descendants,\n inputValue,\n interactive,\n items: resolvedItems,\n max,\n open,\n setInputValue,\n setValue,\n value,\n valueMap,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n getSeparatorProps,\n popoverProps,\n onActiveDescendant,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n onSelect,\n }\n}\n\nexport type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>\n\nexport interface UseAutocompleteOptionProps extends UseComboboxItemProps {}\n\nexport const useAutocompleteOption = ({\n children,\n closeOnSelect,\n disabled,\n hidden,\n value,\n ...rest\n}: UseAutocompleteOptionProps = {}) => {\n const { max, value: selectedValue } = useAutocompleteContext()\n\n value ??= isString(children) ? children : undefined\n\n const selected = isArray(selectedValue)\n ? !isUndefined(value) && selectedValue.includes(value)\n : selectedValue === value\n const completed =\n isNumber(max) && isArray(selectedValue) && selectedValue.length >= max\n const { getIndicatorProps, getItemProps } = useComboboxItem({\n children,\n closeOnSelect,\n disabled: disabled || hidden || (completed && !selected),\n hidden,\n selected,\n value,\n ...rest,\n })\n\n const getOptionProps: PropGetter = useCallback(\n (props = {}) => getItemProps(props),\n [getItemProps],\n )\n\n return { getIndicatorProps, getOptionProps }\n}\n\nexport type UseAutocompleteOptionReturn = ReturnType<\n typeof useAutocompleteOption\n>\n"],"mappings":";;;;;;;;;;;;;AA+DA,MAAM,iBAAyC,EAC7C,OACA,SACA,OACA,OACA,KACA,gBACI;CACJ,MAAM,OAAO,QAAQ,MAAM;CAE3B,OACE,qBAAC,QAAD;EAAM,OAAO,EAAE,iBAAiB,aAAa;YAA7C,CACG,QACE,EAAA,GAAA,cAAA,SAAA,CAAU,GAAG,KAAK,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY,IACjE;;AAEV;AAEA,MAAM,iBAAiB,UAAA,GAAA,cAAA,SAAA,CACZ,MAAM,KAAK,IAAI,KAAK,QAAS,MAAM,SAAS;AAUvD,MAAM,iBAAqC,YAAY,OAAO,UAAU;CACtE,IAAI,CAAC,WAAW,QAAQ,OAAO;CAE/B,OAAO,MACJ,KAAK,SAAS;EACb,IAAI,WAAW,MAAM;GACnB,MAAM,QAAQ,KAAK,MAAM,QAAQ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a,IAClC,EAAA,GAAA,cAAA,YAAA,CAAa,KAAK,KAAK,cAAc,SAAS,KAAK,IACnD,kBAAkB;CACtB,MAAM,aAAA,GAAA,cAAA,SAAA,CACK,GAAG,MAAA,GAAA,cAAA,QAAA,CAAa,aAAa,KAAK,cAAc,UAAU;CACrE,MAAM,EAAE,mBAAmB,iBAAiB,gBAAgB;EAC1D;EACA;EACA,UAAU,YAAY,UAAW,aAAa,CAAC;EAC/C;EACA;EACA;EACA,GAAG;CACL,CAAC;CAOD,OAAO;EAAE;EAAmB,gBALO,aAChC,QAAQ,CAAC,MAAM,aAAa,KAAK,GAClC,CAAC,YAAY,CAG0B;CAAE;AAC7C"}
|
|
@@ -104,7 +104,7 @@ const updateMaybeDateValue = (value, max) => (prev) => {
|
|
|
104
104
|
end: value,
|
|
105
105
|
start
|
|
106
106
|
};
|
|
107
|
-
} else if (isSameDate(prev, value)) return;
|
|
107
|
+
} else if (isSameDate(prev, value)) return void 0;
|
|
108
108
|
else return value;
|
|
109
109
|
};
|
|
110
110
|
const getAdjustedMonth = (value, month) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-calendar.js","names":["createContext"],"sources":["../../../../src/components/calendar/use-calendar.ts"],"sourcesContent":["\"use client\"\n\nimport type { FocusEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { Descendant } from \"../../hooks/use-descendants\"\nimport type { Locale } from \"../../providers/i18n-provider\"\nimport type { AnyString, Dict } from \"../../utils\"\nimport dayjs from \"dayjs\"\nimport { useCallback, useMemo, useRef } from \"react\"\nimport { mergeProps, useSplitProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n contains,\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport const DEFAULT_HOLIDAYS: Date[] = []\nexport const DEFAULT_WEEKEND_DAYS: number[] = [0, 6]\nexport const DEFAULT_FIRST_DAY_OF_WEEK: StartDayOfWeek = \"sunday\"\nexport const DEFAULT_MAX_DATE: Date = new Date(\"2099-12-31\")\nexport const DEFAULT_MIN_DATE: Date = new Date(\"1900-01-01\")\n\nexport type MaybeDate = Date | Date[] | undefined | { end?: Date; start?: Date }\nexport type MaybeDateValue<\n Multiple extends boolean = false,\n Range extends boolean = false,\n> = Range extends true\n ? { end?: Date; start?: Date }\n : Multiple extends true\n ? Date[]\n : Date | undefined\nexport type StartDayOfWeek = \"monday\" | \"sunday\"\nexport interface CalendarFormat {\n day?: Intl.DateTimeFormatOptions[\"day\"] | null\n month?: Intl.DateTimeFormatOptions[\"month\"] | null\n weekday?: Intl.DateTimeFormatOptions[\"weekday\"] | null\n year?: Intl.DateTimeFormatOptions[\"year\"] | null\n}\n\nexport const getStartOfWeek = (\n date: Date,\n startDayOfWeek: StartDayOfWeek,\n): Date =>\n dayjs(date)\n .subtract(startDayOfWeek === \"monday\" ? 1 : 0, \"day\")\n .startOf(\"week\")\n .add(startDayOfWeek === \"monday\" ? 1 : 0, \"day\")\n .toDate()\n\nexport const getEndOfWeek = (\n date: Date,\n startDayOfWeek: StartDayOfWeek,\n): Date =>\n dayjs(date)\n .subtract(startDayOfWeek === \"monday\" ? 1 : 0, \"day\")\n .endOf(\"week\")\n .add(startDayOfWeek === \"monday\" ? 1 : 0, \"day\")\n .toDate()\n\nexport const getWeekdays = (\n startDayOfWeek: StartDayOfWeek,\n format: (value: Date) => string,\n): { label: string; value: number }[] => {\n let weekdays: { label: string; value: number }[] = []\n\n const date = getStartOfWeek(new Date(), startDayOfWeek)\n\n for (let i = 0; i < 7; i += 1) {\n const label = format(date)\n const value = date.getDay()\n\n weekdays = [...weekdays, { label, value }]\n\n date.setDate(date.getDate() + 1)\n }\n\n return weekdays\n}\n\nexport const getMonthDays = (\n date: Date,\n startDayOfWeek: StartDayOfWeek,\n format: (value: Date) => string,\n): { label: string; value: Date }[][] => {\n const currentMonth = date.getMonth()\n const startOfMonth = new Date(date.getFullYear(), currentMonth, 1)\n const endOfMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0)\n const startDate = getStartOfWeek(startOfMonth, startDayOfWeek)\n const endDate = getEndOfWeek(endOfMonth, startDayOfWeek)\n\n const weeks: { label: string; value: Date }[][] = []\n\n while (startDate <= endDate) {\n const days: { label: string; value: Date }[] = []\n\n for (let i = 0; i < 7; i += 1) {\n const value = new Date(startDate)\n const label = format(value)\n\n days.push({ label, value })\n\n startDate.setDate(startDate.getDate() + 1)\n }\n\n weeks.push(days)\n }\n\n return weeks\n}\n\nexport const isSameYear = (\n date: Date | undefined,\n comparison: Date | undefined,\n): boolean =>\n date instanceof Date &&\n comparison instanceof Date &&\n dayjs(date).isSame(comparison, \"year\")\n\nexport const isSameMonth = (\n date: Date | undefined,\n comparison: Date | undefined,\n): boolean =>\n date instanceof Date &&\n comparison instanceof Date &&\n dayjs(date).isSame(comparison, \"month\")\n\nexport const isSameDate = (\n date: Date | undefined,\n comparison: Date | undefined,\n) =>\n date instanceof Date &&\n comparison instanceof Date &&\n dayjs(date).isSame(comparison, \"date\")\n\nexport const isAfterDate = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isAfter(date, \"date\")\n\nexport const isBeforeDate = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isBefore(date, \"date\")\n\nexport const isSameAfterDate = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"date\") || dayjs(value).isAfter(date, \"date\"))\n\nexport const isSameBeforeDate = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"date\") || dayjs(value).isBefore(date, \"date\"))\n\nexport const isAfterMonth = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isAfter(date, \"month\")\n\nexport const isBeforeMonth = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isBefore(date, \"month\")\n\nexport const isSameAfterMonth = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"month\") || dayjs(value).isAfter(date, \"month\"))\n\nexport const isSameBeforeMonth = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"month\") || dayjs(value).isBefore(date, \"month\"))\n\nexport const isAfterYear = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isAfter(date, \"year\")\n\nexport const isBeforeYear = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isBefore(date, \"year\")\n\nexport const isSameAfterYear = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"year\") || dayjs(value).isAfter(date, \"year\"))\n\nexport const isSameBeforeYear = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"year\") || dayjs(value).isBefore(date, \"year\"))\n\nexport const isIncludeDates = (comparison: Date, dates: Date[]) =>\n dates.some((date) => dayjs(date).isSame(comparison, \"date\"))\n\nexport const isInRange = (date: Date, minDate?: Date, maxDate?: Date) => {\n const hasMinDate = minDate instanceof Date\n const hasMaxDate = maxDate instanceof Date\n\n if (!hasMaxDate && !hasMinDate) return false\n\n const minInRange = hasMinDate ? isAfterDate(date, minDate) : false\n const maxInRange = hasMaxDate ? isBeforeDate(date, maxDate) : false\n\n return maxInRange && minInRange\n}\n\nexport const sortDates = (dates: Date[], type: \"asc\" | \"desc\" = \"asc\") => {\n if (type === \"asc\") {\n return dates.sort((a, b) => (dayjs(a).isAfter(b, \"date\") ? 1 : -1))\n } else {\n return dates.sort((a, b) => (dayjs(a).isBefore(b, \"date\") ? 1 : -1))\n }\n}\n\nexport const updateMaybeDateValue =\n (value: Date, max?: number) =>\n (prev: MaybeDate): MaybeDate => {\n if (isArray(prev)) {\n if (isIncludeDates(value, prev)) {\n return prev.filter((prevValue) => !isSameDate(prevValue, value))\n } else if (!isNumber(max) || prev.length < max) {\n return [...prev, value]\n } else {\n return prev\n }\n } else if (isObject(prev) && !isDate(prev)) {\n const { end, start } = prev\n\n if ((start && end) || !start) {\n return { end: undefined, start: value }\n } else {\n if (isSameDate(start, value)) {\n return { end: undefined, start: undefined }\n } else if (isBeforeDate(value, start)) {\n return { end: start, start: value }\n } else {\n return { end: value, start }\n }\n }\n } else {\n if (isSameDate(prev, value)) {\n return undefined\n } else {\n return value\n }\n }\n }\n\nexport const getAdjustedMonth = (value: MaybeDate, month: Date) => {\n if (isDate(value)) {\n if (!isSameMonth(value, month)) month = dayjs(value).set(\"date\", 1).toDate()\n } else if (isArray(value)) {\n const lastValue = value.at(-1)\n\n if (lastValue && !isSameMonth(lastValue, month))\n month = dayjs(lastValue).set(\"date\", 1).toDate()\n } else if (isObject(value)) {\n if (value.end) {\n month = dayjs(value.end).set(\"date\", 1).toDate()\n } else if (value.start) {\n month = dayjs(value.start).set(\"date\", 1).toDate()\n }\n }\n\n return month\n}\n\nconst {\n DescendantsContext: CalendarDescendantsContext,\n useDescendant: useCalendarDescendant,\n useDescendants: useCalendarDescendants,\n} = createDescendants<HTMLTableCellElement>()\n\nexport {\n CalendarDescendantsContext,\n useCalendarDescendant,\n useCalendarDescendants,\n}\n\ninterface CalendarContext extends Omit<\n UseCalendarReturn,\n | \"descendants\"\n | \"getMonthProps\"\n | \"getMonthSelectProps\"\n | \"getNavigationProps\"\n | \"getNextButtonProps\"\n | \"getPrevButtonProps\"\n | \"getRootProps\"\n | \"getStatusProps\"\n | \"getWeekdayProps\"\n | \"getYearSelectProps\"\n | \"monthDays\"\n | \"monthItems\"\n | \"weekdays\"\n | \"yearItems\"\n> {}\n\nconst [CalendarContext, useCalendarContext] = createContext<CalendarContext>({\n name: \"CalendarContext\",\n})\n\nexport { CalendarContext, useCalendarContext }\n\nexport interface UseCalendarProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n> extends Omit<HTMLProps, \"defaultValue\" | \"onChange\"> {\n /**\n * The initial month of the calendar.\n *\n * @default new Date()\n */\n defaultMonth?: Date\n /**\n * The initial value of the calendar.\n */\n defaultValue?: MaybeDateValue<Multiple, Range>\n /**\n * If `true`, disables the calendar.\n *\n * @default false\n */\n disabled?: 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?: CalendarFormat\n /**\n * Define holidays.\n */\n holidays?: Date[]\n /**\n * The locale of the calendar.\n *\n * @default 'en-US'\n */\n locale?: AnyString | Locale\n /**\n * The maximum selectable value.\n */\n max?: number\n /**\n * The maximum possible date.\n *\n * @default new Date(2099, 11, 31)\n */\n maxDate?: Date\n /**\n * The minimum possible date.\n *\n * @default new Date(1900, 0, 1)\n */\n minDate?: Date\n /**\n * The month of the calendar.\n */\n month?: Date\n /**\n * If `true`, the calendar will be multiple.\n *\n * @default false\n */\n multiple?: Multiple\n /**\n * If `true`, enables date range selection.\n *\n * @default false\n */\n range?: Range\n /**\n * Define the start day of the week.\n *\n * @default 'monday'\n */\n startDayOfWeek?: StartDayOfWeek\n /**\n * If `true`, highlight today.\n *\n * @default true\n */\n today?: boolean\n /**\n * The value of the calendar.\n */\n value?: MaybeDateValue<Multiple, Range>\n /**\n * Define weekend days.\n *\n * @default [0, 6]\n */\n weekendDays?: number[]\n /**\n * Callback function to determine whether the day should be disabled.\n */\n excludeDate?: (date: Date) => boolean\n /**\n * The callback invoked when value state changes.\n */\n onChange?: (value: MaybeDateValue<Multiple, Range>) => void\n /**\n * The callback invoked when month state changes.\n */\n onChangeMonth?: (value: Date) => void\n}\n\nexport const useCalendar = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n defaultMonth = new Date(),\n multiple = false as Multiple,\n range = false as Range,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled = false,\n excludeDate,\n format = {},\n holidays = DEFAULT_HOLIDAYS,\n locale: localeProp,\n max,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n month: monthProp,\n startDayOfWeek = DEFAULT_FIRST_DAY_OF_WEEK,\n today = true,\n value: valueProp,\n weekendDays = DEFAULT_WEEKEND_DAYS,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n ...rest\n}: UseCalendarProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { locale: defaultLocale, t } = useI18n(\"calendar\")\n const locale = localeProp ?? defaultLocale\n const dateTimeFormat = useDateTimeFormat({ locale })\n const yearFormat = useCallback(\n (value: Date) => {\n if (format.year === null) {\n return value.getFullYear().toString()\n } else {\n const year = format.year ?? \"numeric\"\n\n return dateTimeFormat(value, { year })\n }\n },\n [dateTimeFormat, format.year],\n )\n const monthFormat = useCallback(\n (value: Date) => {\n if (format.month === null) {\n return (value.getMonth() + 1).toString()\n } else {\n const month = format.month ?? \"short\"\n\n return dateTimeFormat(value, { month })\n }\n },\n [dateTimeFormat, format.month],\n )\n const weekdayFormat = useCallback(\n (value: Date) => {\n return dateTimeFormat(value, {\n weekday: format.weekday ?? \"short\",\n })\n },\n [dateTimeFormat, format.weekday],\n )\n const dayFormat = useCallback(\n (value: Date) => {\n if (format.day) {\n return dateTimeFormat(value, {\n day: format.day,\n })\n } else {\n return value.getDate().toString()\n }\n },\n [dateTimeFormat, format.day],\n )\n const descendants = useCalendarDescendants()\n const monthRef = useRef<HTMLTableElement>(null)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n if (dayjs(minDate).isAfter(dayjs(defaultMonth)))\n defaultMonth = dayjs(minDate).set(\"date\", 1).toDate()\n\n if (valueProp) {\n defaultMonth = getAdjustedMonth(valueProp, defaultMonth)\n } else if (defaultValue) {\n defaultMonth = getAdjustedMonth(defaultValue, defaultMonth)\n }\n\n return defaultMonth\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const { endOfMonth, startOfMonth } = useMemo(() => {\n const startOfMonth = dayjs(month).startOf(\"month\").toDate()\n const endOfMonth = dayjs(month).endOf(\"month\").toDate()\n\n return { endOfMonth, startOfMonth }\n }, [month])\n const weekdays = useMemo(\n () => getWeekdays(startDayOfWeek, weekdayFormat),\n [startDayOfWeek, weekdayFormat],\n )\n const monthDays = useMemo(\n () => getMonthDays(month, startDayOfWeek, dayFormat),\n [month, startDayOfWeek, dayFormat],\n )\n const yearItems = useMemo(() => {\n const minYear = dayjs(minDate).year()\n const maxYear = dayjs(maxDate).year()\n const yearItems: { label: string; value: string }[] = []\n\n for (let year = minYear; year <= maxYear; year++) {\n const label = yearFormat(dayjs().set(\"year\", year).toDate())\n const value = year.toString()\n\n yearItems.push({ label, value })\n }\n\n return yearItems\n }, [maxDate, minDate, yearFormat])\n const monthItems = useMemo(() => {\n const monthItems: { label: string; value: string }[] = []\n const date = dayjs(month).toDate()\n\n for (let month = 0; month < 12; month++) {\n date.setMonth(month)\n\n if (isAfterMonth(date, maxDate)) continue\n if (isBeforeMonth(date, minDate)) continue\n\n const label = monthFormat(dayjs().set(\"month\", month).toDate())\n const value = month.toString()\n\n monthItems.push({ label, value })\n }\n\n return monthItems\n }, [month, maxDate, minDate, monthFormat])\n\n const onChange = useCallback(\n (value: Date) => {\n if (isBeforeDate(value, minDate)) return\n if (isAfterDate(value, maxDate)) return\n\n setValue(\n (prev) =>\n updateMaybeDateValue(value, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n },\n [max, maxDate, minDate, setValue],\n )\n\n const onMonthChange = useCallback(\n (month: Date) => {\n if (isAfterMonth(month, maxDate)) {\n setMonth(dayjs(maxDate).set(\"date\", 1).toDate())\n } else if (isBeforeMonth(month, minDate)) {\n setMonth(dayjs(minDate).set(\"date\", 1).toDate())\n } else {\n setMonth((prev) => {\n if (isSameMonth(prev, month)) return prev\n\n return month\n })\n }\n },\n [maxDate, minDate, setMonth],\n )\n\n const onPrevMonth = useCallback(() => {\n setMonth((prev) => {\n if (isSameMonth(prev, minDate)) return prev\n\n return dayjs(prev).subtract(1, \"month\").toDate()\n })\n }, [minDate, setMonth])\n\n const onNextMonth = useCallback(() => {\n setMonth((prev) => {\n if (isSameMonth(prev, maxDate)) return prev\n\n return dayjs(prev).add(1, \"month\").toDate()\n })\n }, [maxDate, setMonth])\n\n const onFocus = useCallback(() => {\n let index: null | number = null\n let descendant: Descendant<HTMLTableCellElement> | undefined\n\n if (value) {\n if (isDate(value)) {\n if (isSameMonth(month, new Date())) index = new Date().getDate() - 1\n } else if (isArray(value)) {\n const firstValue = value[0]\n\n if (firstValue && isSameMonth(month, firstValue))\n index = firstValue.getDate() - 1\n } else if (isObject(value)) {\n if (value.start && isSameMonth(month, value.start)) {\n index = value.start.getDate() - 1\n } else if (value.end && isSameMonth(month, value.end)) {\n index = value.end.getDate() - 1\n }\n }\n } else if (isSameMonth(month, new Date())) {\n index = new Date().getDate() - 1\n }\n\n descendant = descendants.value(index)\n\n if (!descendant) descendant = descendants.enabledFirstValue()\n\n if (!descendant) return\n\n descendant.node.focus()\n descendant.node.tabIndex = 0\n\n if (monthRef.current) monthRef.current.tabIndex = -1\n }, [descendants, month, value])\n\n const onBlur = useCallback((ev: FocusEvent<HTMLTableElement>) => {\n if (contains(monthRef.current, ev.relatedTarget)) return\n\n if (monthRef.current) monthRef.current.tabIndex = 0\n }, [])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value])\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ \"data-disabled\": dataAttr(disabled) }, rest, props)(),\n [disabled, rest],\n )\n\n const getNavigationProps: PropGetter<\"nav\"> = useCallback(\n (props = {}) => ({ \"data-disabled\": dataAttr(disabled), ...props }),\n [disabled],\n )\n\n const getYearSelectProps: PropGetter<\n \"div\",\n { value?: string; onChange?: (value: string) => void },\n { value?: string; onChange?: (value: string) => void }\n > = useCallback(\n (props = {}) => ({\n \"aria-label\": t(\"Choose the year\"),\n disabled,\n value: dayjs(month).get(\"year\").toString(),\n ...props,\n onChange: handlerAll(props.onChange, (value) =>\n onMonthChange(dayjs(month).set(\"year\", parseInt(value)).toDate()),\n ),\n }),\n [disabled, month, onMonthChange, t],\n )\n\n const getMonthSelectProps: PropGetter<\n \"div\",\n { value?: string; onChange?: (value: string) => void },\n { value?: string; onChange?: (value: string) => void }\n > = useCallback(\n (props = {}) => ({\n \"aria-label\": t(\"Choose the month\"),\n disabled,\n value: dayjs(month).get(\"month\").toString(),\n ...props,\n onChange: handlerAll(props.onChange, (value) =>\n onMonthChange(dayjs(month).set(\"month\", parseInt(value)).toDate()),\n ),\n }),\n [disabled, month, onMonthChange, t],\n )\n\n const getStatusProps: PropGetter = useCallback(\n (props = {}) => ({\n style: visuallyHiddenAttributes.style,\n \"aria-live\": \"polite\",\n children: dateTimeFormat(dayjs(month).toDate(), {\n month: \"long\",\n year: \"numeric\",\n }),\n role: \"status\",\n ...props,\n }),\n [dateTimeFormat, month],\n )\n\n const getMonthProps: PropGetter<\"table\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ref: mergeRefs(ref, monthRef),\n \"aria-label\": dateTimeFormat(dayjs(month).toDate(), {\n month: \"long\",\n year: \"numeric\",\n }),\n \"aria-multiselectable\": ariaAttr(multiple || range),\n \"data-disabled\": dataAttr(disabled),\n role: \"grid\",\n tabIndex: disabled ? -1 : 0,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onFocus: handlerAll(props.onFocus, onFocus),\n }),\n [dateTimeFormat, disabled, month, multiple, onBlur, onFocus, range],\n )\n\n const getWeekdayProps: RequiredPropGetter<\"th\", { value: number }> =\n useCallback(\n ({ value, ...props }) => ({\n \"data-disabled\": dataAttr(disabled),\n \"data-value\": value.toString(),\n abbr: dateTimeFormat(dayjs().set(\"day\", value).toDate(), {\n weekday: \"long\",\n }),\n ...props,\n }),\n [dateTimeFormat, disabled],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n (props) => ({\n type: \"button\",\n \"data-disabled\": dataAttr(disabled),\n ...props,\n }),\n [disabled],\n )\n\n const getPrevButtonProps: PropGetter<\"button\"> = useCallback(\n (props = {}) =>\n getButtonProps({\n \"aria-label\": t(\"Go to the previous month\"),\n disabled: isSameBeforeMonth(month, minDate),\n ...props,\n onClick: handlerAll(props.onClick, onPrevMonth),\n }),\n [getButtonProps, minDate, month, onPrevMonth, t],\n )\n\n const getNextButtonProps: PropGetter<\"button\"> = useCallback(\n (props = {}) =>\n getButtonProps({\n \"aria-label\": t(\"Go to the next month\"),\n disabled: isSameAfterMonth(month, maxDate),\n ...props,\n onClick: handlerAll(props.onClick, onNextMonth),\n }),\n [getButtonProps, maxDate, month, onNextMonth, t],\n )\n\n return {\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 }\n}\n\nexport type UseCalendarReturn = ReturnType<typeof useCalendar>\n\nexport interface UseCalendarDayProps extends Omit<HTMLProps<\"td\">, \"value\"> {\n value: Date\n}\n\nexport const useCalendarDay = ({ value, ...rest }: UseCalendarDayProps) => {\n const { t } = useI18n(\"calendar\")\n const {\n disabled: rootDisabled,\n excludeDate,\n holidays,\n locale,\n max,\n maxDate,\n minDate,\n month,\n startDayOfWeek,\n today: highlightToday,\n value: selectedValue,\n weekendDays,\n onChange,\n onMonthChange,\n onNextMonth,\n onPrevMonth,\n } = useCalendarContext()\n const dateTimeFormat = useDateTimeFormat({ locale })\n const cellRef = useRef<HTMLTableCellElement>(null)\n const outside = useMemo(() => !isSameMonth(month, value), [month, value])\n const holiday = useMemo(\n () => holidays.some((holiday) => isSameDate(holiday, value)),\n [holidays, value],\n )\n const weekend = useMemo(\n () => weekendDays.includes(value.getDay()),\n [weekendDays, value],\n )\n const today = useMemo(\n () => highlightToday && isSameDate(value, new Date()),\n [highlightToday, value],\n )\n const selected = useMemo(() => {\n if (isDate(selectedValue)) {\n return isSameDate(selectedValue, value)\n } else if (isArray(selectedValue)) {\n return selectedValue.some((selectedValue) =>\n isSameDate(selectedValue, value),\n )\n } else if (isObject(selectedValue)) {\n return (\n isSameDate(selectedValue.start, value) ||\n isSameDate(selectedValue.end, value)\n )\n }\n }, [selectedValue, value])\n const disabled = useMemo(() => {\n if (rootDisabled) return true\n if (isAfterDate(value, maxDate)) return true\n if (isBeforeDate(value, minDate)) return true\n if (excludeDate?.(value)) return true\n if (\n isArray(selectedValue) &&\n isNumber(max) &&\n selectedValue.length >= max &&\n !isIncludeDates(value, selectedValue)\n )\n return true\n\n return false\n }, [excludeDate, max, maxDate, minDate, rootDisabled, selectedValue, value])\n const between = useMemo(() => {\n if (isDate(selectedValue) || isArray(selectedValue)) return false\n\n return isInRange(value, selectedValue?.start, selectedValue?.end)\n }, [selectedValue, value])\n const startValue = useMemo(() => {\n if (isDate(selectedValue) || isArray(selectedValue)) return false\n\n const { end, start } = selectedValue ?? {}\n\n return start && end && isSameDate(value, start)\n }, [selectedValue, value])\n const endValue = useMemo(() => {\n if (isDate(selectedValue) || isArray(selectedValue)) return false\n\n const { end, start } = selectedValue ?? {}\n\n return start && end && isSameDate(value, end)\n }, [selectedValue, value])\n const { descendants, register } = useCalendarDescendant({\n disabled: disabled,\n })\n\n const onFocusDescendant = useCallback(\n (descendant?: Descendant<HTMLTableCellElement>) => {\n if (!descendant) return\n\n descendant.node.focus()\n descendant.node.tabIndex = 0\n },\n [],\n )\n\n const onBlur = useCallback(() => {\n if (cellRef.current) cellRef.current.tabIndex = -1\n }, [])\n\n const onClick = useCallback(() => {\n if (disabled) return\n\n onChange(value)\n }, [disabled, onChange, value])\n\n const onPrevDate = useCallback(() => {\n const descendant = descendants.enabledPrevValue(cellRef.current, false)\n\n if (descendant) {\n onFocusDescendant(descendant)\n } else if (!isSameBeforeDate(value, minDate)) {\n onPrevMonth()\n\n setTimeout(() => onFocusDescendant(descendants.enabledLastValue()))\n }\n }, [descendants, minDate, onFocusDescendant, onPrevMonth, value])\n\n const onNextDate = useCallback(() => {\n const descendant = descendants.enabledNextValue(cellRef.current, false)\n\n if (descendant) {\n onFocusDescendant(descendant)\n } else if (!isSameAfterDate(value, maxDate)) {\n onNextMonth()\n\n setTimeout(() => onFocusDescendant(descendants.enabledFirstValue()))\n }\n }, [descendants, maxDate, onFocusDescendant, onNextMonth, value])\n\n const onPrevTraverseDate = useCallback(\n (date: Date) => {\n onMonthChange(dayjs(date).set(\"date\", 1).toDate())\n\n setTimeout(() => {\n const descendant = isBeforeDate(date, minDate)\n ? descendants.enabledFirstValue()\n : descendants.value(date.getDate() - 1)\n\n if (!descendant) return\n\n if (descendant.disabled) {\n onFocusDescendant(descendants.enabledNextValue(descendant, false))\n } else {\n onFocusDescendant(descendant)\n }\n })\n },\n [descendants, minDate, onFocusDescendant, onMonthChange],\n )\n\n const onNextTraverseDate = useCallback(\n (date: Date) => {\n onMonthChange(dayjs(date).set(\"date\", 1).toDate())\n\n setTimeout(() => {\n const descendant = isAfterDate(date, maxDate)\n ? descendants.enabledLastValue()\n : descendants.value(date.getDate() - 1)\n\n if (!descendant) return\n\n if (descendant.disabled) {\n onFocusDescendant(descendants.enabledPrevValue(descendant, false))\n } else {\n onFocusDescendant(descendant)\n }\n })\n },\n [descendants, maxDate, onFocusDescendant, onMonthChange],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLTableCellElement>) => {\n runKeyAction(ev, {\n ArrowDown: () =>\n onNextTraverseDate(dayjs(value).add(1, \"week\").toDate()),\n ArrowLeft: onPrevDate,\n ArrowRight: onNextDate,\n ArrowUp: () =>\n onPrevTraverseDate(dayjs(value).subtract(1, \"week\").toDate()),\n End: () => onNextTraverseDate(getEndOfWeek(value, startDayOfWeek)),\n Enter: onClick,\n Home: () => onPrevTraverseDate(getStartOfWeek(value, startDayOfWeek)),\n PageDown: (ev) => {\n if (ev.shiftKey) {\n onNextTraverseDate(dayjs(value).add(1, \"year\").toDate())\n } else {\n onNextTraverseDate(dayjs(value).add(1, \"month\").toDate())\n }\n },\n PageUp: (ev) => {\n if (ev.shiftKey) {\n onPrevTraverseDate(dayjs(value).subtract(1, \"year\").toDate())\n } else {\n onPrevTraverseDate(dayjs(value).subtract(1, \"month\").toDate())\n }\n },\n Space: onClick,\n })\n },\n [\n onClick,\n onNextDate,\n onNextTraverseDate,\n onPrevDate,\n onPrevTraverseDate,\n startDayOfWeek,\n value,\n ],\n )\n\n const getDayProps: PropGetter<\"td\"> = useCallback(\n ({ \"aria-label\": ariaLabel, ...props } = {}) => {\n let resolvedAriaLabel = ariaLabel\n if (!resolvedAriaLabel) {\n resolvedAriaLabel = dateTimeFormat(dayjs(value).toDate(), {\n day: \"numeric\",\n month: \"long\",\n weekday: \"long\",\n year: \"numeric\",\n })\n\n if (today) resolvedAriaLabel = `${t(\"Today\")}, ${resolvedAriaLabel}`\n }\n\n return mergeProps(\n {\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-label\": resolvedAriaLabel,\n \"aria-selected\": ariaAttr(selected),\n \"data-between\": dataAttr(between),\n \"data-disabled\": dataAttr(disabled),\n \"data-end\": dataAttr(endValue),\n \"data-holiday\": dataAttr(holiday),\n \"data-outside\": dataAttr(outside),\n \"data-selected\": dataAttr(selected),\n \"data-start\": dataAttr(startValue),\n \"data-today\": dataAttr(today),\n \"data-value\": dayjs(value).format(\"YYYY-MM-DD\"),\n \"data-weekend\": dataAttr(weekend),\n tabIndex: -1,\n },\n rest,\n props,\n {\n ref: mergeRefs(cellRef, outside ? null : register),\n onBlur,\n onClick,\n onFocus: (ev) => ev.preventDefault(),\n onKeyDown,\n },\n )()\n },\n [\n between,\n dateTimeFormat,\n disabled,\n endValue,\n holiday,\n onBlur,\n onClick,\n onKeyDown,\n outside,\n register,\n rest,\n selected,\n startValue,\n t,\n today,\n value,\n weekend,\n ],\n )\n\n return { outside, getDayProps }\n}\n\nexport type UseCalendarDayReturn = ReturnType<typeof useCalendarDay>\n\nconst calendarProps: (keyof UseCalendarProps)[] = [\n \"defaultMonth\",\n \"defaultValue\",\n \"disabled\",\n \"excludeDate\",\n \"format\",\n \"holidays\",\n \"locale\",\n \"max\",\n \"maxDate\",\n \"minDate\",\n \"month\",\n \"range\",\n \"startDayOfWeek\",\n \"today\",\n \"value\",\n \"weekendDays\",\n \"onChange\",\n \"onChangeMonth\",\n]\n\nexport const useCalendarProps = <\n Y extends boolean = false,\n M extends boolean = false,\n D extends Dict = Dict,\n H extends keyof UseCalendarProps<Y, M> = keyof UseCalendarProps<Y, M>,\n>(\n props: D,\n omitKeys?: H[],\n) => {\n return useSplitProps(\n props,\n calendarProps.filter((key) => !omitKeys?.includes(key as H)),\n ) as unknown as [\n keyof UseCalendarProps<Y, M> extends H\n ? UseCalendarProps<Y, M>\n : Omit<UseCalendarProps<Y, M>, H>,\n Omit<\n M,\n keyof UseCalendarProps<Y, M> extends H\n ? keyof UseCalendarProps<Y, M>\n : Exclude<keyof UseCalendarProps<Y, M>, H>\n >,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAa,mBAA2B,CAAC;AACzC,MAAa,uBAAiC,CAAC,GAAG,CAAC;AACnD,MAAa,4BAA4C;AACzD,MAAa,mCAAyB,IAAI,KAAK,YAAY;AAC3D,MAAa,mCAAyB,IAAI,KAAK,YAAY;AAmB3D,MAAa,kBACX,MACA,mBAEA,MAAM,IAAI,CAAC,CACR,SAAS,mBAAmB,WAAW,IAAI,GAAG,KAA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AAY;IAC9C,iBAAA,GAAA,cAAA,SAAA,CAAyB,OAAO;IAChC,UAAU;GACZ,GACA,MACA,OACA;IACE,KAAK,UAAU,SAAS,UAAU,OAAO,QAAQ;IACjD;IACA;IACA,UAAU,OAAO,GAAG,eAAe;IACnC;GACF,CACF,CAAC,CAAC;EACJ,GACA;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAG0B;CAAE;AAChC;AAIA,MAAM,gBAA4C;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,oBAMX,OACA,aACG;CACH,OAAO,cACL,OACA,cAAc,QAAQ,QAAQ,CAAC,UAAU,SAAS,GAAQ,CAAC,CAC7D;AAWF"}
|
|
1
|
+
{"version":3,"file":"use-calendar.js","names":["createContext"],"sources":["../../../../src/components/calendar/use-calendar.ts"],"sourcesContent":["\"use client\"\n\nimport type { FocusEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { Descendant } from \"../../hooks/use-descendants\"\nimport type { Locale } from \"../../providers/i18n-provider\"\nimport type { AnyString, Dict } from \"../../utils\"\nimport dayjs from \"dayjs\"\nimport { useCallback, useMemo, useRef } from \"react\"\nimport { mergeProps, useSplitProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n contains,\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport const DEFAULT_HOLIDAYS: Date[] = []\nexport const DEFAULT_WEEKEND_DAYS: number[] = [0, 6]\nexport const DEFAULT_FIRST_DAY_OF_WEEK: StartDayOfWeek = \"sunday\"\nexport const DEFAULT_MAX_DATE: Date = new Date(\"2099-12-31\")\nexport const DEFAULT_MIN_DATE: Date = new Date(\"1900-01-01\")\n\nexport type MaybeDate = Date | Date[] | undefined | { end?: Date; start?: Date }\nexport type MaybeDateValue<\n Multiple extends boolean = false,\n Range extends boolean = false,\n> = Range extends true\n ? { end?: Date; start?: Date }\n : Multiple extends true\n ? Date[]\n : Date | undefined\nexport type StartDayOfWeek = \"monday\" | \"sunday\"\nexport interface CalendarFormat {\n day?: Intl.DateTimeFormatOptions[\"day\"] | null\n month?: Intl.DateTimeFormatOptions[\"month\"] | null\n weekday?: Intl.DateTimeFormatOptions[\"weekday\"] | null\n year?: Intl.DateTimeFormatOptions[\"year\"] | null\n}\n\nexport const getStartOfWeek = (\n date: Date,\n startDayOfWeek: StartDayOfWeek,\n): Date =>\n dayjs(date)\n .subtract(startDayOfWeek === \"monday\" ? 1 : 0, \"day\")\n .startOf(\"week\")\n .add(startDayOfWeek === \"monday\" ? 1 : 0, \"day\")\n .toDate()\n\nexport const getEndOfWeek = (\n date: Date,\n startDayOfWeek: StartDayOfWeek,\n): Date =>\n dayjs(date)\n .subtract(startDayOfWeek === \"monday\" ? 1 : 0, \"day\")\n .endOf(\"week\")\n .add(startDayOfWeek === \"monday\" ? 1 : 0, \"day\")\n .toDate()\n\nexport const getWeekdays = (\n startDayOfWeek: StartDayOfWeek,\n format: (value: Date) => string,\n): { label: string; value: number }[] => {\n let weekdays: { label: string; value: number }[] = []\n\n const date = getStartOfWeek(new Date(), startDayOfWeek)\n\n for (let i = 0; i < 7; i += 1) {\n const label = format(date)\n const value = date.getDay()\n\n weekdays = [...weekdays, { label, value }]\n\n date.setDate(date.getDate() + 1)\n }\n\n return weekdays\n}\n\nexport const getMonthDays = (\n date: Date,\n startDayOfWeek: StartDayOfWeek,\n format: (value: Date) => string,\n): { label: string; value: Date }[][] => {\n const currentMonth = date.getMonth()\n const startOfMonth = new Date(date.getFullYear(), currentMonth, 1)\n const endOfMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0)\n const startDate = getStartOfWeek(startOfMonth, startDayOfWeek)\n const endDate = getEndOfWeek(endOfMonth, startDayOfWeek)\n\n const weeks: { label: string; value: Date }[][] = []\n\n while (startDate <= endDate) {\n const days: { label: string; value: Date }[] = []\n\n for (let i = 0; i < 7; i += 1) {\n const value = new Date(startDate)\n const label = format(value)\n\n days.push({ label, value })\n\n startDate.setDate(startDate.getDate() + 1)\n }\n\n weeks.push(days)\n }\n\n return weeks\n}\n\nexport const isSameYear = (\n date: Date | undefined,\n comparison: Date | undefined,\n): boolean =>\n date instanceof Date &&\n comparison instanceof Date &&\n dayjs(date).isSame(comparison, \"year\")\n\nexport const isSameMonth = (\n date: Date | undefined,\n comparison: Date | undefined,\n): boolean =>\n date instanceof Date &&\n comparison instanceof Date &&\n dayjs(date).isSame(comparison, \"month\")\n\nexport const isSameDate = (\n date: Date | undefined,\n comparison: Date | undefined,\n) =>\n date instanceof Date &&\n comparison instanceof Date &&\n dayjs(date).isSame(comparison, \"date\")\n\nexport const isAfterDate = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isAfter(date, \"date\")\n\nexport const isBeforeDate = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isBefore(date, \"date\")\n\nexport const isSameAfterDate = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"date\") || dayjs(value).isAfter(date, \"date\"))\n\nexport const isSameBeforeDate = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"date\") || dayjs(value).isBefore(date, \"date\"))\n\nexport const isAfterMonth = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isAfter(date, \"month\")\n\nexport const isBeforeMonth = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isBefore(date, \"month\")\n\nexport const isSameAfterMonth = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"month\") || dayjs(value).isAfter(date, \"month\"))\n\nexport const isSameBeforeMonth = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"month\") || dayjs(value).isBefore(date, \"month\"))\n\nexport const isAfterYear = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isAfter(date, \"year\")\n\nexport const isBeforeYear = (value: Date, date: Date | undefined) =>\n date instanceof Date && dayjs(value).isBefore(date, \"year\")\n\nexport const isSameAfterYear = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"year\") || dayjs(value).isAfter(date, \"year\"))\n\nexport const isSameBeforeYear = (value: Date, date: Date | undefined) =>\n date instanceof Date &&\n (dayjs(date).isSame(value, \"year\") || dayjs(value).isBefore(date, \"year\"))\n\nexport const isIncludeDates = (comparison: Date, dates: Date[]) =>\n dates.some((date) => dayjs(date).isSame(comparison, \"date\"))\n\nexport const isInRange = (date: Date, minDate?: Date, maxDate?: Date) => {\n const hasMinDate = minDate instanceof Date\n const hasMaxDate = maxDate instanceof Date\n\n if (!hasMaxDate && !hasMinDate) return false\n\n const minInRange = hasMinDate ? isAfterDate(date, minDate) : false\n const maxInRange = hasMaxDate ? isBeforeDate(date, maxDate) : false\n\n return maxInRange && minInRange\n}\n\nexport const sortDates = (dates: Date[], type: \"asc\" | \"desc\" = \"asc\") => {\n if (type === \"asc\")\n return dates.sort((a, b) => (dayjs(a).isAfter(b, \"date\") ? 1 : -1))\n else return dates.sort((a, b) => (dayjs(a).isBefore(b, \"date\") ? 1 : -1))\n}\n\nexport const updateMaybeDateValue =\n (value: Date, max?: number) =>\n (prev: MaybeDate): MaybeDate => {\n if (isArray(prev)) {\n if (isIncludeDates(value, prev))\n return prev.filter((prevValue) => !isSameDate(prevValue, value))\n else if (!isNumber(max) || prev.length < max) return [...prev, value]\n else return prev\n } else if (isObject(prev) && !isDate(prev)) {\n const { end, start } = prev\n\n if ((start && end) || !start) return { end: undefined, start: value }\n else if (isSameDate(start, value))\n return { end: undefined, start: undefined }\n else if (isBeforeDate(value, start)) return { end: start, start: value }\n else return { end: value, start }\n } else {\n if (isSameDate(prev, value)) return undefined\n else return value\n }\n }\n\nexport const getAdjustedMonth = (value: MaybeDate, month: Date) => {\n if (isDate(value)) {\n if (!isSameMonth(value, month)) month = dayjs(value).set(\"date\", 1).toDate()\n } else if (isArray(value)) {\n const lastValue = value.at(-1)\n\n if (lastValue && !isSameMonth(lastValue, month))\n month = dayjs(lastValue).set(\"date\", 1).toDate()\n } else if (isObject(value)) {\n if (value.end) month = dayjs(value.end).set(\"date\", 1).toDate()\n else if (value.start) month = dayjs(value.start).set(\"date\", 1).toDate()\n }\n\n return month\n}\n\nconst {\n DescendantsContext: CalendarDescendantsContext,\n useDescendant: useCalendarDescendant,\n useDescendants: useCalendarDescendants,\n} = createDescendants<HTMLTableCellElement>()\n\nexport {\n CalendarDescendantsContext,\n useCalendarDescendant,\n useCalendarDescendants,\n}\n\ninterface CalendarContext extends Omit<\n UseCalendarReturn,\n | \"descendants\"\n | \"getMonthProps\"\n | \"getMonthSelectProps\"\n | \"getNavigationProps\"\n | \"getNextButtonProps\"\n | \"getPrevButtonProps\"\n | \"getRootProps\"\n | \"getStatusProps\"\n | \"getWeekdayProps\"\n | \"getYearSelectProps\"\n | \"monthDays\"\n | \"monthItems\"\n | \"weekdays\"\n | \"yearItems\"\n> {}\n\nconst [CalendarContext, useCalendarContext] = createContext<CalendarContext>({\n name: \"CalendarContext\",\n})\n\nexport { CalendarContext, useCalendarContext }\n\nexport interface UseCalendarProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n> extends Omit<HTMLProps, \"defaultValue\" | \"onChange\"> {\n /**\n * The initial month of the calendar.\n *\n * @default new Date()\n */\n defaultMonth?: Date\n /**\n * The initial value of the calendar.\n */\n defaultValue?: MaybeDateValue<Multiple, Range>\n /**\n * If `true`, disables the calendar.\n *\n * @default false\n */\n disabled?: 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?: CalendarFormat\n /**\n * Define holidays.\n */\n holidays?: Date[]\n /**\n * The locale of the calendar.\n *\n * @default 'en-US'\n */\n locale?: AnyString | Locale\n /**\n * The maximum selectable value.\n */\n max?: number\n /**\n * The maximum possible date.\n *\n * @default new Date(2099, 11, 31)\n */\n maxDate?: Date\n /**\n * The minimum possible date.\n *\n * @default new Date(1900, 0, 1)\n */\n minDate?: Date\n /**\n * The month of the calendar.\n */\n month?: Date\n /**\n * If `true`, the calendar will be multiple.\n *\n * @default false\n */\n multiple?: Multiple\n /**\n * If `true`, enables date range selection.\n *\n * @default false\n */\n range?: Range\n /**\n * Define the start day of the week.\n *\n * @default 'monday'\n */\n startDayOfWeek?: StartDayOfWeek\n /**\n * If `true`, highlight today.\n *\n * @default true\n */\n today?: boolean\n /**\n * The value of the calendar.\n */\n value?: MaybeDateValue<Multiple, Range>\n /**\n * Define weekend days.\n *\n * @default [0, 6]\n */\n weekendDays?: number[]\n /**\n * Callback function to determine whether the day should be disabled.\n */\n excludeDate?: (date: Date) => boolean\n /**\n * The callback invoked when value state changes.\n */\n onChange?: (value: MaybeDateValue<Multiple, Range>) => void\n /**\n * The callback invoked when month state changes.\n */\n onChangeMonth?: (value: Date) => void\n}\n\nexport const useCalendar = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n defaultMonth = new Date(),\n multiple = false as Multiple,\n range = false as Range,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled = false,\n excludeDate,\n format = {},\n holidays = DEFAULT_HOLIDAYS,\n locale: localeProp,\n max,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n month: monthProp,\n startDayOfWeek = DEFAULT_FIRST_DAY_OF_WEEK,\n today = true,\n value: valueProp,\n weekendDays = DEFAULT_WEEKEND_DAYS,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n ...rest\n}: UseCalendarProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { locale: defaultLocale, t } = useI18n(\"calendar\")\n const locale = localeProp ?? defaultLocale\n const dateTimeFormat = useDateTimeFormat({ locale })\n const yearFormat = useCallback(\n (value: Date) => {\n if (format.year === null) {\n return value.getFullYear().toString()\n } else {\n const year = format.year ?? \"numeric\"\n\n return dateTimeFormat(value, { year })\n }\n },\n [dateTimeFormat, format.year],\n )\n const monthFormat = useCallback(\n (value: Date) => {\n if (format.month === null) {\n return (value.getMonth() + 1).toString()\n } else {\n const month = format.month ?? \"short\"\n\n return dateTimeFormat(value, { month })\n }\n },\n [dateTimeFormat, format.month],\n )\n const weekdayFormat = useCallback(\n (value: Date) => {\n return dateTimeFormat(value, {\n weekday: format.weekday ?? \"short\",\n })\n },\n [dateTimeFormat, format.weekday],\n )\n const dayFormat = useCallback(\n (value: Date) => {\n if (format.day)\n return dateTimeFormat(value, {\n day: format.day,\n })\n else return value.getDate().toString()\n },\n [dateTimeFormat, format.day],\n )\n const descendants = useCalendarDescendants()\n const monthRef = useRef<HTMLTableElement>(null)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n if (dayjs(minDate).isAfter(dayjs(defaultMonth)))\n defaultMonth = dayjs(minDate).set(\"date\", 1).toDate()\n\n if (valueProp) defaultMonth = getAdjustedMonth(valueProp, defaultMonth)\n else if (defaultValue)\n defaultMonth = getAdjustedMonth(defaultValue, defaultMonth)\n\n return defaultMonth\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const { endOfMonth, startOfMonth } = useMemo(() => {\n const startOfMonth = dayjs(month).startOf(\"month\").toDate()\n const endOfMonth = dayjs(month).endOf(\"month\").toDate()\n\n return { endOfMonth, startOfMonth }\n }, [month])\n const weekdays = useMemo(\n () => getWeekdays(startDayOfWeek, weekdayFormat),\n [startDayOfWeek, weekdayFormat],\n )\n const monthDays = useMemo(\n () => getMonthDays(month, startDayOfWeek, dayFormat),\n [month, startDayOfWeek, dayFormat],\n )\n const yearItems = useMemo(() => {\n const minYear = dayjs(minDate).year()\n const maxYear = dayjs(maxDate).year()\n const yearItems: { label: string; value: string }[] = []\n\n for (let year = minYear; year <= maxYear; year++) {\n const label = yearFormat(dayjs().set(\"year\", year).toDate())\n const value = year.toString()\n\n yearItems.push({ label, value })\n }\n\n return yearItems\n }, [maxDate, minDate, yearFormat])\n const monthItems = useMemo(() => {\n const monthItems: { label: string; value: string }[] = []\n const date = dayjs(month).toDate()\n\n for (let month = 0; month < 12; month++) {\n date.setMonth(month)\n\n if (isAfterMonth(date, maxDate)) continue\n if (isBeforeMonth(date, minDate)) continue\n\n const label = monthFormat(dayjs().set(\"month\", month).toDate())\n const value = month.toString()\n\n monthItems.push({ label, value })\n }\n\n return monthItems\n }, [month, maxDate, minDate, monthFormat])\n\n const onChange = useCallback(\n (value: Date) => {\n if (isBeforeDate(value, minDate)) return\n if (isAfterDate(value, maxDate)) return\n\n setValue(\n (prev) =>\n updateMaybeDateValue(value, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n },\n [max, maxDate, minDate, setValue],\n )\n\n const onMonthChange = useCallback(\n (month: Date) => {\n if (isAfterMonth(month, maxDate))\n setMonth(dayjs(maxDate).set(\"date\", 1).toDate())\n else if (isBeforeMonth(month, minDate))\n setMonth(dayjs(minDate).set(\"date\", 1).toDate())\n else\n setMonth((prev) => {\n if (isSameMonth(prev, month)) return prev\n\n return month\n })\n },\n [maxDate, minDate, setMonth],\n )\n\n const onPrevMonth = useCallback(() => {\n setMonth((prev) => {\n if (isSameMonth(prev, minDate)) return prev\n\n return dayjs(prev).subtract(1, \"month\").toDate()\n })\n }, [minDate, setMonth])\n\n const onNextMonth = useCallback(() => {\n setMonth((prev) => {\n if (isSameMonth(prev, maxDate)) return prev\n\n return dayjs(prev).add(1, \"month\").toDate()\n })\n }, [maxDate, setMonth])\n\n const onFocus = useCallback(() => {\n let index: null | number = null\n let descendant: Descendant<HTMLTableCellElement> | undefined\n\n if (value) {\n if (isDate(value)) {\n if (isSameMonth(month, new Date())) index = new Date().getDate() - 1\n } else if (isArray(value)) {\n const firstValue = value[0]\n\n if (firstValue && isSameMonth(month, firstValue))\n index = firstValue.getDate() - 1\n } else if (isObject(value)) {\n if (value.start && isSameMonth(month, value.start))\n index = value.start.getDate() - 1\n else if (value.end && isSameMonth(month, value.end))\n index = value.end.getDate() - 1\n }\n } else if (isSameMonth(month, new Date())) {\n index = new Date().getDate() - 1\n }\n\n descendant = descendants.value(index)\n\n if (!descendant) descendant = descendants.enabledFirstValue()\n\n if (!descendant) return\n\n descendant.node.focus()\n descendant.node.tabIndex = 0\n\n if (monthRef.current) monthRef.current.tabIndex = -1\n }, [descendants, month, value])\n\n const onBlur = useCallback((ev: FocusEvent<HTMLTableElement>) => {\n if (contains(monthRef.current, ev.relatedTarget)) return\n\n if (monthRef.current) monthRef.current.tabIndex = 0\n }, [])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value])\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ \"data-disabled\": dataAttr(disabled) }, rest, props)(),\n [disabled, rest],\n )\n\n const getNavigationProps: PropGetter<\"nav\"> = useCallback(\n (props = {}) => ({ \"data-disabled\": dataAttr(disabled), ...props }),\n [disabled],\n )\n\n const getYearSelectProps: PropGetter<\n \"div\",\n { value?: string; onChange?: (value: string) => void },\n { value?: string; onChange?: (value: string) => void }\n > = useCallback(\n (props = {}) => ({\n \"aria-label\": t(\"Choose the year\"),\n disabled,\n value: dayjs(month).get(\"year\").toString(),\n ...props,\n onChange: handlerAll(props.onChange, (value) =>\n onMonthChange(dayjs(month).set(\"year\", parseInt(value)).toDate()),\n ),\n }),\n [disabled, month, onMonthChange, t],\n )\n\n const getMonthSelectProps: PropGetter<\n \"div\",\n { value?: string; onChange?: (value: string) => void },\n { value?: string; onChange?: (value: string) => void }\n > = useCallback(\n (props = {}) => ({\n \"aria-label\": t(\"Choose the month\"),\n disabled,\n value: dayjs(month).get(\"month\").toString(),\n ...props,\n onChange: handlerAll(props.onChange, (value) =>\n onMonthChange(dayjs(month).set(\"month\", parseInt(value)).toDate()),\n ),\n }),\n [disabled, month, onMonthChange, t],\n )\n\n const getStatusProps: PropGetter = useCallback(\n (props = {}) => ({\n style: visuallyHiddenAttributes.style,\n \"aria-live\": \"polite\",\n children: dateTimeFormat(dayjs(month).toDate(), {\n month: \"long\",\n year: \"numeric\",\n }),\n role: \"status\",\n ...props,\n }),\n [dateTimeFormat, month],\n )\n\n const getMonthProps: PropGetter<\"table\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ref: mergeRefs(ref, monthRef),\n \"aria-label\": dateTimeFormat(dayjs(month).toDate(), {\n month: \"long\",\n year: \"numeric\",\n }),\n \"aria-multiselectable\": ariaAttr(multiple || range),\n \"data-disabled\": dataAttr(disabled),\n role: \"grid\",\n tabIndex: disabled ? -1 : 0,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onFocus: handlerAll(props.onFocus, onFocus),\n }),\n [dateTimeFormat, disabled, month, multiple, onBlur, onFocus, range],\n )\n\n const getWeekdayProps: RequiredPropGetter<\"th\", { value: number }> =\n useCallback(\n ({ value, ...props }) => ({\n \"data-disabled\": dataAttr(disabled),\n \"data-value\": value.toString(),\n abbr: dateTimeFormat(dayjs().set(\"day\", value).toDate(), {\n weekday: \"long\",\n }),\n ...props,\n }),\n [dateTimeFormat, disabled],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n (props) => ({\n type: \"button\",\n \"data-disabled\": dataAttr(disabled),\n ...props,\n }),\n [disabled],\n )\n\n const getPrevButtonProps: PropGetter<\"button\"> = useCallback(\n (props = {}) =>\n getButtonProps({\n \"aria-label\": t(\"Go to the previous month\"),\n disabled: isSameBeforeMonth(month, minDate),\n ...props,\n onClick: handlerAll(props.onClick, onPrevMonth),\n }),\n [getButtonProps, minDate, month, onPrevMonth, t],\n )\n\n const getNextButtonProps: PropGetter<\"button\"> = useCallback(\n (props = {}) =>\n getButtonProps({\n \"aria-label\": t(\"Go to the next month\"),\n disabled: isSameAfterMonth(month, maxDate),\n ...props,\n onClick: handlerAll(props.onClick, onNextMonth),\n }),\n [getButtonProps, maxDate, month, onNextMonth, t],\n )\n\n return {\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 }\n}\n\nexport type UseCalendarReturn = ReturnType<typeof useCalendar>\n\nexport interface UseCalendarDayProps extends Omit<HTMLProps<\"td\">, \"value\"> {\n value: Date\n}\n\nexport const useCalendarDay = ({ value, ...rest }: UseCalendarDayProps) => {\n const { t } = useI18n(\"calendar\")\n const {\n disabled: rootDisabled,\n excludeDate,\n holidays,\n locale,\n max,\n maxDate,\n minDate,\n month,\n startDayOfWeek,\n today: highlightToday,\n value: selectedValue,\n weekendDays,\n onChange,\n onMonthChange,\n onNextMonth,\n onPrevMonth,\n } = useCalendarContext()\n const dateTimeFormat = useDateTimeFormat({ locale })\n const cellRef = useRef<HTMLTableCellElement>(null)\n const outside = useMemo(() => !isSameMonth(month, value), [month, value])\n const holiday = useMemo(\n () => holidays.some((holiday) => isSameDate(holiday, value)),\n [holidays, value],\n )\n const weekend = useMemo(\n () => weekendDays.includes(value.getDay()),\n [weekendDays, value],\n )\n const today = useMemo(\n () => highlightToday && isSameDate(value, new Date()),\n [highlightToday, value],\n )\n const selected = useMemo(() => {\n if (isDate(selectedValue)) return isSameDate(selectedValue, value)\n else if (isArray(selectedValue))\n return selectedValue.some((selectedValue) =>\n isSameDate(selectedValue, value),\n )\n else if (isObject(selectedValue))\n return (\n isSameDate(selectedValue.start, value) ||\n isSameDate(selectedValue.end, value)\n )\n }, [selectedValue, value])\n const disabled = useMemo(() => {\n if (rootDisabled) return true\n if (isAfterDate(value, maxDate)) return true\n if (isBeforeDate(value, minDate)) return true\n if (excludeDate?.(value)) return true\n if (\n isArray(selectedValue) &&\n isNumber(max) &&\n selectedValue.length >= max &&\n !isIncludeDates(value, selectedValue)\n )\n return true\n\n return false\n }, [excludeDate, max, maxDate, minDate, rootDisabled, selectedValue, value])\n const between = useMemo(() => {\n if (isDate(selectedValue) || isArray(selectedValue)) return false\n\n return isInRange(value, selectedValue?.start, selectedValue?.end)\n }, [selectedValue, value])\n const startValue = useMemo(() => {\n if (isDate(selectedValue) || isArray(selectedValue)) return false\n\n const { end, start } = selectedValue ?? {}\n\n return start && end && isSameDate(value, start)\n }, [selectedValue, value])\n const endValue = useMemo(() => {\n if (isDate(selectedValue) || isArray(selectedValue)) return false\n\n const { end, start } = selectedValue ?? {}\n\n return start && end && isSameDate(value, end)\n }, [selectedValue, value])\n const { descendants, register } = useCalendarDescendant({\n disabled: disabled,\n })\n\n const onFocusDescendant = useCallback(\n (descendant?: Descendant<HTMLTableCellElement>) => {\n if (!descendant) return\n\n descendant.node.focus()\n descendant.node.tabIndex = 0\n },\n [],\n )\n\n const onBlur = useCallback(() => {\n if (cellRef.current) cellRef.current.tabIndex = -1\n }, [])\n\n const onClick = useCallback(() => {\n if (disabled) return\n\n onChange(value)\n }, [disabled, onChange, value])\n\n const onPrevDate = useCallback(() => {\n const descendant = descendants.enabledPrevValue(cellRef.current, false)\n\n if (descendant) {\n onFocusDescendant(descendant)\n } else if (!isSameBeforeDate(value, minDate)) {\n onPrevMonth()\n\n setTimeout(() => onFocusDescendant(descendants.enabledLastValue()))\n }\n }, [descendants, minDate, onFocusDescendant, onPrevMonth, value])\n\n const onNextDate = useCallback(() => {\n const descendant = descendants.enabledNextValue(cellRef.current, false)\n\n if (descendant) {\n onFocusDescendant(descendant)\n } else if (!isSameAfterDate(value, maxDate)) {\n onNextMonth()\n\n setTimeout(() => onFocusDescendant(descendants.enabledFirstValue()))\n }\n }, [descendants, maxDate, onFocusDescendant, onNextMonth, value])\n\n const onPrevTraverseDate = useCallback(\n (date: Date) => {\n onMonthChange(dayjs(date).set(\"date\", 1).toDate())\n\n setTimeout(() => {\n const descendant = isBeforeDate(date, minDate)\n ? descendants.enabledFirstValue()\n : descendants.value(date.getDate() - 1)\n\n if (!descendant) return\n\n if (descendant.disabled)\n onFocusDescendant(descendants.enabledNextValue(descendant, false))\n else onFocusDescendant(descendant)\n })\n },\n [descendants, minDate, onFocusDescendant, onMonthChange],\n )\n\n const onNextTraverseDate = useCallback(\n (date: Date) => {\n onMonthChange(dayjs(date).set(\"date\", 1).toDate())\n\n setTimeout(() => {\n const descendant = isAfterDate(date, maxDate)\n ? descendants.enabledLastValue()\n : descendants.value(date.getDate() - 1)\n\n if (!descendant) return\n\n if (descendant.disabled)\n onFocusDescendant(descendants.enabledPrevValue(descendant, false))\n else onFocusDescendant(descendant)\n })\n },\n [descendants, maxDate, onFocusDescendant, onMonthChange],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLTableCellElement>) => {\n runKeyAction(ev, {\n ArrowDown: () =>\n onNextTraverseDate(dayjs(value).add(1, \"week\").toDate()),\n ArrowLeft: onPrevDate,\n ArrowRight: onNextDate,\n ArrowUp: () =>\n onPrevTraverseDate(dayjs(value).subtract(1, \"week\").toDate()),\n End: () => onNextTraverseDate(getEndOfWeek(value, startDayOfWeek)),\n Enter: onClick,\n Home: () => onPrevTraverseDate(getStartOfWeek(value, startDayOfWeek)),\n PageDown: (ev) => {\n if (ev.shiftKey)\n onNextTraverseDate(dayjs(value).add(1, \"year\").toDate())\n else onNextTraverseDate(dayjs(value).add(1, \"month\").toDate())\n },\n PageUp: (ev) => {\n if (ev.shiftKey)\n onPrevTraverseDate(dayjs(value).subtract(1, \"year\").toDate())\n else onPrevTraverseDate(dayjs(value).subtract(1, \"month\").toDate())\n },\n Space: onClick,\n })\n },\n [\n onClick,\n onNextDate,\n onNextTraverseDate,\n onPrevDate,\n onPrevTraverseDate,\n startDayOfWeek,\n value,\n ],\n )\n\n const getDayProps: PropGetter<\"td\"> = useCallback(\n ({ \"aria-label\": ariaLabel, ...props } = {}) => {\n let resolvedAriaLabel = ariaLabel\n if (!resolvedAriaLabel) {\n resolvedAriaLabel = dateTimeFormat(dayjs(value).toDate(), {\n day: \"numeric\",\n month: \"long\",\n weekday: \"long\",\n year: \"numeric\",\n })\n\n if (today) resolvedAriaLabel = `${t(\"Today\")}, ${resolvedAriaLabel}`\n }\n\n return mergeProps(\n {\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-label\": resolvedAriaLabel,\n \"aria-selected\": ariaAttr(selected),\n \"data-between\": dataAttr(between),\n \"data-disabled\": dataAttr(disabled),\n \"data-end\": dataAttr(endValue),\n \"data-holiday\": dataAttr(holiday),\n \"data-outside\": dataAttr(outside),\n \"data-selected\": dataAttr(selected),\n \"data-start\": dataAttr(startValue),\n \"data-today\": dataAttr(today),\n \"data-value\": dayjs(value).format(\"YYYY-MM-DD\"),\n \"data-weekend\": dataAttr(weekend),\n tabIndex: -1,\n },\n rest,\n props,\n {\n ref: mergeRefs(cellRef, outside ? null : register),\n onBlur,\n onClick,\n onFocus: (ev) => ev.preventDefault(),\n onKeyDown,\n },\n )()\n },\n [\n between,\n dateTimeFormat,\n disabled,\n endValue,\n holiday,\n onBlur,\n onClick,\n onKeyDown,\n outside,\n register,\n rest,\n selected,\n startValue,\n t,\n today,\n value,\n weekend,\n ],\n )\n\n return { outside, getDayProps }\n}\n\nexport type UseCalendarDayReturn = ReturnType<typeof useCalendarDay>\n\nconst calendarProps: (keyof UseCalendarProps)[] = [\n \"defaultMonth\",\n \"defaultValue\",\n \"disabled\",\n \"excludeDate\",\n \"format\",\n \"holidays\",\n \"locale\",\n \"max\",\n \"maxDate\",\n \"minDate\",\n \"month\",\n \"range\",\n \"startDayOfWeek\",\n \"today\",\n \"value\",\n \"weekendDays\",\n \"onChange\",\n \"onChangeMonth\",\n]\n\nexport const useCalendarProps = <\n Y extends boolean = false,\n M extends boolean = false,\n D extends Dict = Dict,\n H extends keyof UseCalendarProps<Y, M> = keyof UseCalendarProps<Y, M>,\n>(\n props: D,\n omitKeys?: H[],\n) => {\n return useSplitProps(\n props,\n calendarProps.filter((key) => !omitKeys?.includes(key as H)),\n ) as unknown as [\n keyof UseCalendarProps<Y, M> extends H\n ? UseCalendarProps<Y, M>\n : Omit<UseCalendarProps<Y, M>, H>,\n Omit<\n M,\n keyof UseCalendarProps<Y, M> extends H\n ? keyof UseCalendarProps<Y, M>\n : Exclude<keyof UseCalendarProps<Y, M>, H>\n >,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAa,mBAA2B,CAAC;AACzC,MAAa,uBAAiC,CAAC,GAAG,CAAC;AACnD,MAAa,4BAA4C;AACzD,MAAa,mCAAyB,IAAI,KAAK,YAAY;AAC3D,MAAa,mCAAyB,IAAI,KAAK,YAAY;AAmB3D,MAAa,kBACX,MACA,mBAEA,MAAM,IAAI,CAAC,CACR,SAAS,mBAAmB,WAAW,IAAI,GAAG,KAAK,CAAC,CACpD,QAAQ,MAAM,CAAC,CACf,IAAI,mBAAmB,WAAW,IAAI,GAAG,KAAK,CAAC,CAC/C,OAAO;AAEZ,MAAa,gBACX,MACA,mBAEA,MAAM,IAAI,CAAC,CACR,SAAS,mBAAmB,WAAW,IAAI,GAAG,KAAK,CAAC,CACpD,MAAM,MAAM,CAAC,CACb,IAAI,mBAAmB,WAAW,IAAI,GAAG,KAAK,CAAC,CAC/C,OAAO;AAEZ,MAAa,eACX,gBACA,WACuC;CACvC,IA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AAM,gBAA4C;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,oBAMX,OACA,aACG;CACH,OAAO,cACL,OACA,cAAc,QAAQ,QAAQ,CAAC,UAAU,SAAS,GAAQ,CAAC,CAC7D;AAWF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","names":[],"sources":["../../../../src/components/carousel/carousel.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type {\n CSSProps,\n HTMLProps,\n HTMLStyledProps,\n Orientation,\n ThemeProps,\n} from \"../../core\"\nimport type { IconButtonProps } from \"../button\"\nimport type { CarouselStyle } from \"./carousel.style\"\nimport type {\n CarouselAlign,\n CarouselContainScroll,\n CarouselInViewThreshold,\n UseCarouselProps,\n} from \"./use-carousel\"\nimport { cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled, varAttr } from \"../../core\"\nimport { dataAttr } from \"../../utils\"\nimport { IconButton } from \"../button\"\nimport { ChevronLeftIcon, ChevronRightIcon } from \"../icon\"\nimport { carouselStyle } from \"./carousel.style\"\nimport {\n CarouselContext,\n useCarousel,\n useCarouselContext,\n} from \"./use-carousel\"\n\ninterface ComponentContext extends Pick<\n CarouselRootProps,\n \"includeGapInSize\"\n> {}\n\nexport interface CarouselRootProps\n extends\n Omit<HTMLStyledProps<\"section\">, \"draggable\" | \"onChange\">,\n Omit<\n UseCarouselProps,\n | \"align\"\n | \"autoplay\"\n | \"containScroll\"\n | \"delay\"\n | \"dragFree\"\n | \"draggable\"\n | \"duration\"\n | \"inViewThreshold\"\n | \"loop\"\n | \"orientation\"\n | \"skipSnaps\"\n | \"slidesToScroll\"\n | \"stopMouseEnterAutoplay\"\n >,\n ThemeProps<CarouselStyle> {\n /**\n * The alignment of the carousel.\n *\n * @default 'center'\n */\n align?: CarouselAlign\n /**\n * If `true`, the carousel will be autoplay.\n *\n * @default false\n */\n autoplay?: boolean\n /**\n * Clear leading and trailing empty space that causes excessive scrolling.\n * Use trimSnaps to only use snap points that trigger scrolling or keepSnaps to keep them.\n *\n * @default false\n */\n containScroll?: CarouselContainScroll\n /**\n * The number for the autoplay interval of the carousel.\n *\n * @default 4000\n */\n delay?: number\n /**\n * If `true`, momentum scrolling will be enabled.\n *\n * @default false\n */\n dragFree?: boolean\n /**\n * If `true`, carousel can be scrolled with mouse and touch interactions.\n *\n * @default true\n */\n draggable?: boolean\n /**\n * Set scroll duration when triggered by any of the API methods.\n * Higher numbers enables slower scrolling.\n * Drag interactions are not affected because duration is then determined by the drag force.\n *\n * @default 25\n */\n duration?: number\n /**\n * If `true`, gap will be treated as part of the carousel slide size.\n *\n * @default true\n */\n includeGapInSize?: boolean\n /**\n * Choose a fraction representing the percentage portion of a slide that needs to be visible in order to be considered in view.\n *\n * @default 0\n */\n inViewThreshold?: CarouselInViewThreshold\n /**\n * If `true`, infinite looping.\n * Automatically falls back to false if slide content isn't enough to loop.\n *\n * @default true\n */\n loop?: boolean\n /**\n * The orientation of the carousel.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * If `true`, allow the carousel to skip scroll snaps if it's dragged vigorously.\n * Note that this option will be ignored if the dragFree option is set to true.\n *\n * @default false\n */\n skipSnaps?: boolean\n /**\n * The size of the carousel item.\n */\n slideSize?: CSSProps[\"width\"]\n /**\n * The number of slides that should be scrolled with next or previous buttons.\n *\n * @default 1\n */\n slidesToScroll?: number\n /**\n * If `true`, autoplay will pause when the mouse entries over.\n *\n * @default true\n */\n stopMouseEnterAutoplay?: boolean\n}\n\nconst {\n ComponentContext,\n PropsContext: CarouselPropsContext,\n useComponentContext,\n usePropsContext: useCarouselPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<CarouselRootProps, CarouselStyle>(\n \"carousel\",\n carouselStyle,\n)\n\nexport { CarouselPropsContext, useCarouselPropsContext }\n\n/**\n * `Carousel` is a component that displays multiple elements like a slideshow.\n *\n * @see https://yamada-ui.com/docs/components/carousel\n */\nexport const CarouselRoot = withProvider<\"section\", CarouselRootProps>(\n ({ includeGapInSize = true, ...rest }) => {\n const {\n carousel,\n index,\n setIndex,\n snapCount,\n total,\n getIndicatorProps,\n getIndicatorsProps,\n getItemProps,\n getListProps,\n getNextTriggerProps,\n getPrevTriggerProps,\n getRootProps,\n } = useCarousel(rest)\n const componentContext = useMemo(\n () => ({ includeGapInSize }),\n [includeGapInSize],\n )\n const carouselContext = useMemo(\n () => ({\n carousel,\n index,\n setIndex,\n snapCount,\n total,\n getIndicatorProps,\n getIndicatorsProps,\n getItemProps,\n getListProps,\n getNextTriggerProps,\n getPrevTriggerProps,\n }),\n [\n carousel,\n total,\n index,\n setIndex,\n snapCount,\n getIndicatorProps,\n getIndicatorsProps,\n getItemProps,\n getListProps,\n getNextTriggerProps,\n getPrevTriggerProps,\n ],\n )\n\n return (\n <CarouselContext value={carouselContext}>\n <ComponentContext value={componentContext}>\n <styled.section {...getRootProps()} />\n </ComponentContext>\n </CarouselContext>\n )\n },\n \"root\",\n)(undefined, ({ gap, slideSize, ...rest }) => {\n return {\n ...rest,\n \"--slide-gap\": varAttr(gap, \"spaces\"),\n \"--slide-size\": varAttr(slideSize, \"sizes\"),\n }\n})\n\nexport interface CarouselListProps extends HTMLStyledProps {}\n\nexport const CarouselList = withContext<\"div\", CarouselListProps>(\n \"div\",\n \"list\",\n)(undefined, (props) => {\n const { includeGapInSize } = useComponentContext()\n const { getListProps } = useCarouselContext()\n\n return {\n \"data-include-gap-in-size\": dataAttr(includeGapInSize),\n ...getListProps(props),\n }\n})\n\nexport interface CarouselItemProps extends HTMLStyledProps {\n /**\n * The index of the carousel item.\n */\n index: number\n /**\n * The size of the carousel item.\n */\n slideSize?: CSSProps[\"width\"]\n}\n\nexport const CarouselItem = withContext<\"div\", CarouselItemProps>(\n \"div\",\n \"item\",\n)(undefined, ({ slideSize, ...rest }) => {\n const { includeGapInSize } = useComponentContext()\n const { getItemProps } = useCarouselContext()\n\n return {\n \"data-include-gap-in-size\": dataAttr(includeGapInSize),\n \"--slide-size\": varAttr(slideSize, \"sizes\"),\n ...getItemProps(rest),\n }\n})\n\nexport interface CarouselPrevTriggerProps extends IconButtonProps {}\n\nexport const CarouselPrevTrigger = withContext<\n \"button\",\n CarouselPrevTriggerProps\n>(IconButton, { name: \"PrevTrigger\", slot: [\"trigger\", \"prev\"] })(\n undefined,\n (props) => {\n const { getPrevTriggerProps } = useCarouselContext()\n\n return {\n fullRounded: true,\n icon: <ChevronLeftIcon />,\n ...getPrevTriggerProps(props),\n }\n },\n)\n\nexport interface CarouselNextTriggerProps extends IconButtonProps {}\n\nexport const CarouselNextTrigger = withContext<\n \"button\",\n CarouselNextTriggerProps\n>(IconButton, { name: \"NextTrigger\", slot: [\"trigger\", \"next\"] })(\n undefined,\n (props) => {\n const { getNextTriggerProps } = useCarouselContext()\n\n return {\n fullRounded: true,\n icon: <ChevronRightIcon />,\n ...getNextTriggerProps(props),\n }\n },\n)\n\nexport interface CarouselIndicatorsProps extends HTMLStyledProps {\n /**\n * The function used to generate children.\n * it will be called with `{ index: number; selected: boolean }`.\n */\n render?: (props: { index: number; selected: boolean }) => ReactNode\n}\n\nexport const CarouselIndicators = withContext<\"div\", CarouselIndicatorsProps>(\n \"div\",\n \"indicators\",\n)(undefined, ({ children, render, ...rest }) => {\n const {\n index: selectedIndex,\n snapCount,\n getIndicatorProps,\n getIndicatorsProps,\n } = useCarouselContext()\n const computedChildren = useMemo(() => {\n if (children) {\n return children\n } else {\n return Array.from({ length: snapCount }, (_, index) => {\n if (render) {\n const component = render({ index, selected: index === selectedIndex })\n\n if (isValidElement<HTMLProps<\"button\">>(component)) {\n return cloneElement(component, {\n ...getIndicatorProps({ key: index, index }),\n })\n } else {\n return component\n }\n } else {\n return <CarouselIndicator key={index} index={index} />\n }\n })\n }\n }, [children, getIndicatorProps, render, selectedIndex, snapCount])\n\n return {\n children: computedChildren,\n ...getIndicatorsProps(rest),\n }\n})\n\nexport interface CarouselIndicatorProps extends HTMLStyledProps<\"button\"> {\n /**\n * The index of the carousel indicator.\n */\n index: number\n}\n\nexport const CarouselIndicator = withContext<\"button\", CarouselIndicatorProps>(\n \"button\",\n \"indicator\",\n)(undefined, (props) => {\n const { getIndicatorProps } = useCarouselContext()\n\n return getIndicatorProps(props)\n})\n"],"mappings":";;;;;;;;;;;;;AAsJA,MAAM,EACJ,kBACA,cAAc,sBACd,qBACA,iBAAiB,yBACjB,aACA,iBACE,oBACF,YACA,aACF;;;;;;AASA,MAAa,eAAe,cACzB,EAAE,mBAAmB,MAAM,GAAG,WAAW;CACxC,MAAM,EACJ,UACA,OACA,UACA,WACA,OACA,mBACA,oBACA,cACA,cACA,qBACA,qBACA,iBACE,YAAY,IAAI;CACpB,MAAM,mBAAmB,eAChB,EAAE,iBAAiB,IAC1B,CAAC,gBAAgB,CACnB;CA8BA,OACE,oBAAC,iBAAD;EAAiB,OA9BK,eACf;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,IACA;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAIsC;YACpC,oBAAC,kBAAD;GAAkB,OAAO;aACvB,oBAAC,OAAO,SAAR,EAAgB,GAAI,aAAa,EAAI,CAAA;EACrB,CAAA;CACH,CAAA;AAErB,GACA,MACF,CAAC,CAAC,KAAA,IAAY,EAAE,KAAK,WAAW,GAAG,WAAW;CAC5C,OAAO;EACL,GAAG;EACH,eAAe,QAAQ,KAAK,QAAQ;EACpC,gBAAgB,QAAQ,WAAW,OAAO;CAC5C;AACF,CAAC;AAID,MAAa,eAAe,YAC1B,OACA,MACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,qBAAqB,oBAAoB;CACjD,MAAM,EAAE,iBAAiB,mBAAmB;CAE5C,OAAO;EACL,6BAAA,GAAA,cAAA,SAAA,CAAqC,gBAAgB;EACrD,GAAG,aAAa,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BAAkB;MAAE,KAAK;MAAO;KAAM,CAAC,EAC5C,CAAC;UAED,OAAO;IAEX,OACE,OAAO,oBAAC,mBAAD,EAAsC,MAAQ,GAAtB,KAAsB;GAEzD,CAAC;EAEL,GAAG;GAAC;GAAU;GAAmB;GAAQ;GAAe;EAAS,CAGtC;EACzB,GAAG,mBAAmB,IAAI;CAC5B;AACF,CAAC;AASD,MAAa,oBAAoB,YAC/B,UACA,WACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,sBAAsB,mBAAmB;CAEjD,OAAO,kBAAkB,KAAK;AAChC,CAAC"}
|
|
1
|
+
{"version":3,"file":"carousel.js","names":[],"sources":["../../../../src/components/carousel/carousel.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type {\n CSSProps,\n HTMLProps,\n HTMLStyledProps,\n Orientation,\n ThemeProps,\n} from \"../../core\"\nimport type { IconButtonProps } from \"../button\"\nimport type { CarouselStyle } from \"./carousel.style\"\nimport type {\n CarouselAlign,\n CarouselContainScroll,\n CarouselInViewThreshold,\n UseCarouselProps,\n} from \"./use-carousel\"\nimport { cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled, varAttr } from \"../../core\"\nimport { dataAttr } from \"../../utils\"\nimport { IconButton } from \"../button\"\nimport { ChevronLeftIcon, ChevronRightIcon } from \"../icon\"\nimport { carouselStyle } from \"./carousel.style\"\nimport {\n CarouselContext,\n useCarousel,\n useCarouselContext,\n} from \"./use-carousel\"\n\ninterface ComponentContext extends Pick<\n CarouselRootProps,\n \"includeGapInSize\"\n> {}\n\nexport interface CarouselRootProps\n extends\n Omit<HTMLStyledProps<\"section\">, \"draggable\" | \"onChange\">,\n Omit<\n UseCarouselProps,\n | \"align\"\n | \"autoplay\"\n | \"containScroll\"\n | \"delay\"\n | \"dragFree\"\n | \"draggable\"\n | \"duration\"\n | \"inViewThreshold\"\n | \"loop\"\n | \"orientation\"\n | \"skipSnaps\"\n | \"slidesToScroll\"\n | \"stopMouseEnterAutoplay\"\n >,\n ThemeProps<CarouselStyle> {\n /**\n * The alignment of the carousel.\n *\n * @default 'center'\n */\n align?: CarouselAlign\n /**\n * If `true`, the carousel will be autoplay.\n *\n * @default false\n */\n autoplay?: boolean\n /**\n * Clear leading and trailing empty space that causes excessive scrolling.\n * Use trimSnaps to only use snap points that trigger scrolling or keepSnaps to keep them.\n *\n * @default false\n */\n containScroll?: CarouselContainScroll\n /**\n * The number for the autoplay interval of the carousel.\n *\n * @default 4000\n */\n delay?: number\n /**\n * If `true`, momentum scrolling will be enabled.\n *\n * @default false\n */\n dragFree?: boolean\n /**\n * If `true`, carousel can be scrolled with mouse and touch interactions.\n *\n * @default true\n */\n draggable?: boolean\n /**\n * Set scroll duration when triggered by any of the API methods.\n * Higher numbers enables slower scrolling.\n * Drag interactions are not affected because duration is then determined by the drag force.\n *\n * @default 25\n */\n duration?: number\n /**\n * If `true`, gap will be treated as part of the carousel slide size.\n *\n * @default true\n */\n includeGapInSize?: boolean\n /**\n * Choose a fraction representing the percentage portion of a slide that needs to be visible in order to be considered in view.\n *\n * @default 0\n */\n inViewThreshold?: CarouselInViewThreshold\n /**\n * If `true`, infinite looping.\n * Automatically falls back to false if slide content isn't enough to loop.\n *\n * @default true\n */\n loop?: boolean\n /**\n * The orientation of the carousel.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * If `true`, allow the carousel to skip scroll snaps if it's dragged vigorously.\n * Note that this option will be ignored if the dragFree option is set to true.\n *\n * @default false\n */\n skipSnaps?: boolean\n /**\n * The size of the carousel item.\n */\n slideSize?: CSSProps[\"width\"]\n /**\n * The number of slides that should be scrolled with next or previous buttons.\n *\n * @default 1\n */\n slidesToScroll?: number\n /**\n * If `true`, autoplay will pause when the mouse entries over.\n *\n * @default true\n */\n stopMouseEnterAutoplay?: boolean\n}\n\nconst {\n ComponentContext,\n PropsContext: CarouselPropsContext,\n useComponentContext,\n usePropsContext: useCarouselPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<CarouselRootProps, CarouselStyle>(\n \"carousel\",\n carouselStyle,\n)\n\nexport { CarouselPropsContext, useCarouselPropsContext }\n\n/**\n * `Carousel` is a component that displays multiple elements like a slideshow.\n *\n * @see https://yamada-ui.com/docs/components/carousel\n */\nexport const CarouselRoot = withProvider<\"section\", CarouselRootProps>(\n ({ includeGapInSize = true, ...rest }) => {\n const {\n carousel,\n index,\n setIndex,\n snapCount,\n total,\n getIndicatorProps,\n getIndicatorsProps,\n getItemProps,\n getListProps,\n getNextTriggerProps,\n getPrevTriggerProps,\n getRootProps,\n } = useCarousel(rest)\n const componentContext = useMemo(\n () => ({ includeGapInSize }),\n [includeGapInSize],\n )\n const carouselContext = useMemo(\n () => ({\n carousel,\n index,\n setIndex,\n snapCount,\n total,\n getIndicatorProps,\n getIndicatorsProps,\n getItemProps,\n getListProps,\n getNextTriggerProps,\n getPrevTriggerProps,\n }),\n [\n carousel,\n total,\n index,\n setIndex,\n snapCount,\n getIndicatorProps,\n getIndicatorsProps,\n getItemProps,\n getListProps,\n getNextTriggerProps,\n getPrevTriggerProps,\n ],\n )\n\n return (\n <CarouselContext value={carouselContext}>\n <ComponentContext value={componentContext}>\n <styled.section {...getRootProps()} />\n </ComponentContext>\n </CarouselContext>\n )\n },\n \"root\",\n)(undefined, ({ gap, slideSize, ...rest }) => {\n return {\n ...rest,\n \"--slide-gap\": varAttr(gap, \"spaces\"),\n \"--slide-size\": varAttr(slideSize, \"sizes\"),\n }\n})\n\nexport interface CarouselListProps extends HTMLStyledProps {}\n\nexport const CarouselList = withContext<\"div\", CarouselListProps>(\n \"div\",\n \"list\",\n)(undefined, (props) => {\n const { includeGapInSize } = useComponentContext()\n const { getListProps } = useCarouselContext()\n\n return {\n \"data-include-gap-in-size\": dataAttr(includeGapInSize),\n ...getListProps(props),\n }\n})\n\nexport interface CarouselItemProps extends HTMLStyledProps {\n /**\n * The index of the carousel item.\n */\n index: number\n /**\n * The size of the carousel item.\n */\n slideSize?: CSSProps[\"width\"]\n}\n\nexport const CarouselItem = withContext<\"div\", CarouselItemProps>(\n \"div\",\n \"item\",\n)(undefined, ({ slideSize, ...rest }) => {\n const { includeGapInSize } = useComponentContext()\n const { getItemProps } = useCarouselContext()\n\n return {\n \"data-include-gap-in-size\": dataAttr(includeGapInSize),\n \"--slide-size\": varAttr(slideSize, \"sizes\"),\n ...getItemProps(rest),\n }\n})\n\nexport interface CarouselPrevTriggerProps extends IconButtonProps {}\n\nexport const CarouselPrevTrigger = withContext<\n \"button\",\n CarouselPrevTriggerProps\n>(IconButton, { name: \"PrevTrigger\", slot: [\"trigger\", \"prev\"] })(\n undefined,\n (props) => {\n const { getPrevTriggerProps } = useCarouselContext()\n\n return {\n fullRounded: true,\n icon: <ChevronLeftIcon />,\n ...getPrevTriggerProps(props),\n }\n },\n)\n\nexport interface CarouselNextTriggerProps extends IconButtonProps {}\n\nexport const CarouselNextTrigger = withContext<\n \"button\",\n CarouselNextTriggerProps\n>(IconButton, { name: \"NextTrigger\", slot: [\"trigger\", \"next\"] })(\n undefined,\n (props) => {\n const { getNextTriggerProps } = useCarouselContext()\n\n return {\n fullRounded: true,\n icon: <ChevronRightIcon />,\n ...getNextTriggerProps(props),\n }\n },\n)\n\nexport interface CarouselIndicatorsProps extends HTMLStyledProps {\n /**\n * The function used to generate children.\n * it will be called with `{ index: number; selected: boolean }`.\n */\n render?: (props: { index: number; selected: boolean }) => ReactNode\n}\n\nexport const CarouselIndicators = withContext<\"div\", CarouselIndicatorsProps>(\n \"div\",\n \"indicators\",\n)(undefined, ({ children, render, ...rest }) => {\n const {\n index: selectedIndex,\n snapCount,\n getIndicatorProps,\n getIndicatorsProps,\n } = useCarouselContext()\n const computedChildren = useMemo(() => {\n if (children) return children\n else\n return Array.from({ length: snapCount }, (_, index) => {\n if (render) {\n const component = render({ index, selected: index === selectedIndex })\n\n if (isValidElement<HTMLProps<\"button\">>(component))\n return cloneElement(component, {\n ...getIndicatorProps({ key: index, index }),\n })\n else return component\n } else {\n return <CarouselIndicator key={index} index={index} />\n }\n })\n }, [children, getIndicatorProps, render, selectedIndex, snapCount])\n\n return {\n children: computedChildren,\n ...getIndicatorsProps(rest),\n }\n})\n\nexport interface CarouselIndicatorProps extends HTMLStyledProps<\"button\"> {\n /**\n * The index of the carousel indicator.\n */\n index: number\n}\n\nexport const CarouselIndicator = withContext<\"button\", CarouselIndicatorProps>(\n \"button\",\n \"indicator\",\n)(undefined, (props) => {\n const { getIndicatorProps } = useCarouselContext()\n\n return getIndicatorProps(props)\n})\n"],"mappings":";;;;;;;;;;;;;AAsJA,MAAM,EACJ,kBACA,cAAc,sBACd,qBACA,iBAAiB,yBACjB,aACA,iBACE,oBACF,YACA,aACF;;;;;;AASA,MAAa,eAAe,cACzB,EAAE,mBAAmB,MAAM,GAAG,WAAW;CACxC,MAAM,EACJ,UACA,OACA,UACA,WACA,OACA,mBACA,oBACA,cACA,cACA,qBACA,qBACA,iBACE,YAAY,IAAI;CACpB,MAAM,mBAAmB,eAChB,EAAE,iBAAiB,IAC1B,CAAC,gBAAgB,CACnB;CA8BA,OACE,oBAAC,iBAAD;EAAiB,OA9BK,eACf;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,IACA;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAIsC;YACpC,oBAAC,kBAAD;GAAkB,OAAO;aACvB,oBAAC,OAAO,SAAR,EAAgB,GAAI,aAAa,EAAI,CAAA;EACrB,CAAA;CACH,CAAA;AAErB,GACA,MACF,CAAC,CAAC,KAAA,IAAY,EAAE,KAAK,WAAW,GAAG,WAAW;CAC5C,OAAO;EACL,GAAG;EACH,eAAe,QAAQ,KAAK,QAAQ;EACpC,gBAAgB,QAAQ,WAAW,OAAO;CAC5C;AACF,CAAC;AAID,MAAa,eAAe,YAC1B,OACA,MACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,qBAAqB,oBAA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AAM,YAAY,OAAO;MAAE;MAAO,UAAU,UAAU;KAAc,CAAC;KAErE,IAAI,eAAoC,SAAS,GAC/C,OAAO,aAAa,WAAW,EAC7B,GAAG,kBAAkB;MAAE,KAAK;MAAO;KAAM,CAAC,EAC5C,CAAC;UACE,OAAO;IACd,OACE,OAAO,oBAAC,mBAAD,EAAsC,MAAQ,GAAtB,KAAsB;GAEzD,CAAC;EACL,GAAG;GAAC;GAAU;GAAmB;GAAQ;GAAe;EAAS,CAGtC;EACzB,GAAG,mBAAmB,IAAI;CAC5B;AACF,CAAC;AASD,MAAa,oBAAoB,YAC/B,UACA,WACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,sBAAsB,mBAAmB;CAEjD,OAAO,kBAAkB,KAAK;AAChC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.js","names":["createContext"],"sources":["../../../../src/components/chart/chart.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n JSXElementConstructor,\n PropsWithChildren,\n ReactElement,\n ReactNode,\n RefObject,\n} from \"react\"\nimport type {\n ActiveDotProps,\n DataKey,\n DefaultLegendContentProps,\n DotItemDotProps,\n DotProps,\n LabelProps,\n RenderableText,\n ResponsiveContainerProps,\n TooltipContentProps,\n TooltipProps,\n} from \"recharts\"\nimport type {\n CSSProps,\n ExtractStyleValueWithCondition,\n HTMLStyledProps,\n ThemeProps,\n} from \"../../core\"\nimport type { Dict, Merge } from \"../../utils\"\nimport type { ChartStyle } from \"./chart.style\"\nimport type {\n UseChartLabelListProps,\n UseChartLabelProps,\n UseChartLegendProps,\n UseChartLegendReturn,\n UseChartTooltipProps,\n} from \"./use-chart\"\nimport { Fragment, isValidElement, useMemo, useRef } from \"react\"\nimport {\n Label,\n LabelList,\n Legend,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\"\nimport { createSlotComponent, mergeProps, styled, varAttr } from \"../../core\"\nimport {\n cast,\n createContext,\n isArray,\n isNull,\n isNumber,\n isObject,\n isString,\n isUndefined,\n useSplitChildren,\n} from \"../../utils\"\nimport { chartStyle } from \"./chart.style\"\nimport {\n ChartContext,\n useChart,\n useChartLabel,\n useChartLabelList,\n useChartLegend,\n useChartTooltip,\n} from \"./use-chart\"\n\nexport type ChartDot =\n | ((props: DotItemDotProps) => ReactNode)\n | boolean\n | Merge<Partial<DotProps>, HTMLStyledProps<\"circle\">>\n | ReactElement\n\nexport type ChartActiveDot =\n | ((props: ActiveDotProps) => ReactNode)\n | boolean\n | Merge<Partial<ActiveDotProps>, HTMLStyledProps<\"circle\">>\n | ReactElement\n\nexport type ChartLabel =\n | ((props: any) => ReactElement | RenderableText)\n | boolean\n | (Merge<\n HTMLStyledProps<\"text\">,\n Pick<\n LabelProps,\n | \"angle\"\n | \"content\"\n | \"formatter\"\n | \"index\"\n | \"labelRef\"\n | \"offset\"\n | \"parentViewBox\"\n | \"position\"\n | \"textBreakAll\"\n | \"value\"\n | \"viewBox\"\n | \"zIndex\"\n >\n > & { dataKey?: DataKey<any> })\n | number\n | ReactElement\n | string\n\nexport type ChartLabelList =\n | ((props: LabelProps) => ReactElement | RenderableText)\n | boolean\n | ChartLabelListProps\n | ReactElement\n\nexport type ChartTickLine = boolean | HTMLStyledProps<\"line\">\n\nexport type GradientStrategy = \"invert\" | \"shade\" | \"tint\"\n\nexport function mergeSeries<Y>(\n series: Y[],\n color: CSSProps[\"color\"] = \"mono\",\n strategy: GradientStrategy = \"invert\",\n): (Y & { color: CSSProps[\"color\"] })[] {\n const colors = gradients(series.length, color, strategy)\n\n return series.map((item, index) => ({ ...item, color: colors[index] }))\n}\n\nexport function mergeData<Y>(\n data: Y[],\n color: ExtractStyleValueWithCondition<CSSProps[\"fill\"]> = \"mono\",\n strategy: GradientStrategy = \"invert\",\n): (Y & { fill: CSSProps[\"fill\"] })[] {\n const colors = gradients(data.length, color, strategy)\n\n return data.map((item, index) => ({ ...item, fill: colors[index] }))\n}\n\nexport function gradients(\n length: number,\n color: ExtractStyleValueWithCondition<CSSProps[\"color\"]> = \"mono\",\n strategy: GradientStrategy = \"invert\",\n): CSSProps[\"color\"][] {\n return Array.from({ length }, (_, index) => {\n const value = Math.floor(100 - (100 / length) * index)\n const percent = `${value}%`\n\n if (strategy === \"invert\") {\n return [\n `tint(colors.${color as string}, ${percent})`,\n `shade(colors.${color as string}, ${percent})`,\n ]\n } else {\n return `${strategy}(colors.${color as string}, ${percent})`\n }\n })\n}\n\nfunction parseJSON(value: any) {\n try {\n return JSON.parse(value)\n } catch {\n return value\n }\n}\n\ninterface ComponentContext extends Pick<\n ChartProps,\n \"legendProps\" | \"tooltipProps\"\n> {\n nameKeyRef: RefObject<string | undefined>\n}\n\nexport interface ChartProps extends HTMLStyledProps, ThemeProps<ChartStyle> {\n /**\n * The components to render the chart components.\n */\n components: {\n component: JSXElementConstructor<any>\n fallback: ReactNode\n }[]\n /**\n * The function to render the chart.\n */\n render: (props: PropsWithChildren) => ReactNode\n /**\n * The color of the label list.\n */\n labelListColor?: CSSProps[\"color\"]\n /**\n * The fill of the label list.\n */\n labelListFill?: CSSProps[\"fill\"]\n /**\n * The fill of the tooltip cursor.\n */\n tooltipCursorFill?: CSSProps[\"fill\"]\n /**\n * The fill opacity of the tooltip cursor.\n */\n tooltipCursorFillOpacity?: CSSProps[\"fillOpacity\"]\n /**\n * The stroke of the tooltip cursor.\n */\n tooltipCursorStroke?: CSSProps[\"stroke\"]\n /**\n * If `true`, legend is visible.\n *\n * @default false\n */\n withLegend?: boolean\n /**\n * If `true`, tooltip is visible.\n *\n * @default true\n */\n withTooltip?: boolean\n /**\n * Props for the legend component.\n */\n legendProps?: ChartLegendProps\n /**\n * Props for the responsive container component.\n */\n responsiveContainerProps?: ResponsiveContainerProps\n /**\n * Props for the tooltip component.\n */\n tooltipProps?: ChartTooltipProps\n}\n\nconst {\n ComponentContext,\n PropsContext: ChartPropsContext,\n useComponentContext: useChartComponentContext,\n usePropsContext: useChartPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<ChartProps, ChartStyle, ComponentContext>(\n \"chart\",\n chartStyle,\n)\n\nexport { ChartPropsContext, useChartComponentContext, useChartPropsContext }\n\nexport const Chart = withProvider(\n ({\n children,\n components: componentsProp,\n render,\n withLegend = false,\n withTooltip = true,\n legendProps,\n responsiveContainerProps,\n tooltipProps,\n ...rest\n }: ChartProps) => {\n const { highlightedDataKey, onHighlight } = useChart()\n const nameKeyRef = useRef<string | undefined>(undefined)\n const components = useMemo(\n () => [\n ...componentsProp,\n {\n component: ChartLegend,\n fallback: withLegend ? <ChartLegend /> : null,\n },\n {\n component: ChartTooltip,\n fallback: withTooltip ? <ChartTooltip /> : null,\n },\n ],\n [componentsProp, withLegend, withTooltip],\n )\n const [omittedChildren, ...customComponents] = useSplitChildren(\n children,\n ...components.map(({ component }) => component),\n )\n const context = useMemo(\n () => ({\n highlightedDataKey,\n onHighlight,\n }),\n [highlightedDataKey, onHighlight],\n )\n const componentContext = useMemo(\n () => ({\n nameKeyRef,\n legendProps,\n tooltipProps,\n }),\n [legendProps, tooltipProps],\n )\n\n return (\n <ChartContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.div {...rest}>\n <ResponsiveContainer {...responsiveContainerProps}>\n {render({\n children: (\n <>\n {components.map(({ fallback }, index) => (\n <Fragment key={index}>\n {customComponents[index] ?? fallback}\n </Fragment>\n ))}\n\n {omittedChildren}\n </>\n ),\n })}\n </ResponsiveContainer>\n </styled.div>\n </ComponentContext>\n </ChartContext>\n )\n },\n \"root\",\n)(\n undefined,\n ({\n labelListColor,\n labelListFill,\n tooltipCursorFill,\n tooltipCursorFillOpacity,\n tooltipCursorStroke,\n ...rest\n }) => ({\n \"--label-list-color\": varAttr(labelListColor, \"colors\"),\n \"--label-list-fill\": varAttr(labelListFill, \"colors\"),\n \"--tooltip-cursor-fill\": varAttr(tooltipCursorFill, \"colors\"),\n \"--tooltip-cursor-fill-opacity\": tooltipCursorFillOpacity,\n \"--tooltip-cursor-stroke\": varAttr(tooltipCursorStroke, \"colors\"),\n ...rest,\n }),\n)\n\ninterface ChartLegendContext extends Pick<\n UseChartLegendReturn,\n \"getLegendItemProps\"\n> {}\n\nconst [ChartLegendContext, useChartLegendContext] =\n createContext<ChartLegendContext>({\n name: \"ChartLegendContext\",\n })\n\nexport interface ChartLegendProps extends Merge<\n HTMLStyledProps,\n UseChartLegendProps\n> {\n /**\n * Props for the content component.\n */\n contentProps?: Omit<ChartLegendContentProps, \"formatter\" | \"payload\">\n}\n\nexport const ChartLegend = withContext<\"div\", ChartLegendProps>((props) => {\n const { legendProps } = useChartComponentContext()\n const { contentProps, ...rest } = mergeProps(legendProps, props)()\n const {\n getLegendContentProps,\n getLegendItemProps,\n getLegendProps,\n getRootProps,\n } = useChartLegend({\n content: ({ formatter, payload }) => (\n <ChartLegendContent\n formatter={formatter}\n payload={payload}\n {...getLegendContentProps(contentProps)}\n />\n ),\n ...rest,\n })\n const context = useMemo(() => ({ getLegendItemProps }), [getLegendItemProps])\n\n return (\n <ChartLegendContext value={context}>\n <styled.div asChild {...getRootProps()}>\n <Legend {...getLegendProps()} />\n </styled.div>\n </ChartLegendContext>\n )\n}, \"legend\")()\n\ninterface ChartLegendContentProps\n extends\n HTMLStyledProps,\n Pick<DefaultLegendContentProps, \"formatter\" | \"payload\"> {\n /**\n * If `true`, swatch is visible.\n */\n withSwatch?: boolean\n}\n\nconst ChartLegendContent = withContext<\"div\", ChartLegendContentProps>(\n ({ formatter, payload, withSwatch = true, ...rest }) => {\n const { nameKeyRef } = useChartComponentContext()\n const { getLegendItemProps } = useChartLegendContext()\n\n return (\n <styled.div {...rest}>\n {payload?.map((data, index) => {\n let value = data.value\n\n if (nameKeyRef.current)\n value = (data.payload as any)?.[nameKeyRef.current]\n\n const dataKey =\n isString(data.dataKey) || isNumber(data.dataKey)\n ? data.dataKey\n : value\n const color = parseJSON(data.color)\n const formattedValue = formatter?.(value, data, index) ?? value\n\n return (\n <ChartLegendItem key={index} {...getLegendItemProps({ dataKey })}>\n {withSwatch ? <ChartLegendSwatch bg={color} /> : null}\n <ChartLegendValue>{formattedValue}</ChartLegendValue>\n </ChartLegendItem>\n )\n })}\n </styled.div>\n )\n },\n \"legendContent\",\n)()\n\ninterface ChartLegendItemProps extends HTMLStyledProps {}\n\nconst ChartLegendItem = withContext<\"div\", ChartLegendItemProps>(\n \"div\",\n \"legendItem\",\n)()\n\ninterface ChartLegendSwatchProps extends HTMLStyledProps {}\n\nconst ChartLegendSwatch = withContext<\"div\", ChartLegendSwatchProps>(\n \"div\",\n \"legendSwatch\",\n)()\n\ninterface ChartLegendValueProps extends HTMLStyledProps<\"span\"> {}\n\nconst ChartLegendValue = withContext<\"span\", ChartLegendValueProps>(\n \"span\",\n \"legendValue\",\n)()\n\nexport interface ChartTooltipProps<\n Y extends (number | string)[] | number | string = number,\n M extends number | string = string,\n> extends Omit<Merge<HTMLStyledProps, UseChartTooltipProps<Y, M>>, \"cursor\"> {\n /**\n * Props for the cursor component.\n */\n cursor?: boolean | ChartTooltipCursorProps | ReactElement\n /**\n * Props for the content component.\n */\n contentProps?: Omit<\n ChartTooltipContentProps,\n \"formatter\" | \"label\" | \"labelFormatter\" | \"payload\"\n >\n}\n\nexport const ChartTooltip = <\n Y extends (number | string)[] | number | string,\n M extends number | string,\n>(\n props: ChartTooltipProps<Y, M>,\n) => {\n const { tooltipProps } = useChartComponentContext()\n const {\n cursor = false,\n contentProps,\n ...rest\n } = {\n ...tooltipProps,\n ...props,\n } as ChartTooltipProps<Y, M>\n const { getContentProps, getRootProps } = useChartTooltip<Y, M>({\n content: ({ formatter, label, labelFormatter, payload }) => (\n <ChartTooltipContent\n formatter={formatter}\n label={label}\n labelFormatter={labelFormatter}\n payload={payload}\n {...getContentProps(contentProps)}\n />\n ),\n cursor:\n isValidElement(cursor) || !cursor ? (\n cursor\n ) : (\n <ChartTooltipCursor {...(isObject(cursor) ? cursor : {})} />\n ),\n ...rest,\n })\n\n return <Tooltip {...cast<TooltipProps>(getRootProps())} />\n}\n\ninterface ChartTooltipCursorProps extends Omit<\n HTMLStyledProps<\"path\">,\n \"height\" | \"points\" | \"width\" | \"x\" | \"y\"\n> {\n brushBottom?: number\n height?: number\n payload?: Dict[]\n payloadIndex?: number\n points?: { x: number; y: number }[]\n width?: number\n x?: number\n y?: number\n}\n\nconst ChartTooltipCursor = withContext<\"path\", ChartTooltipCursorProps>(\n \"path\",\n \"tooltipCursor\",\n)(\n undefined,\n ({\n bottom: _bottom,\n brushBottom: _brushBottom,\n fill,\n height,\n left: _left,\n payload: _payload,\n payloadIndex: _payloadIndex,\n points,\n right: _right,\n stroke,\n top: _top,\n width,\n x,\n y,\n ...rest\n }) => {\n const d = points\n ? `M${points[0]?.x},${points[0]?.y}L${points[1]?.x},${points[1]?.y}`\n : `M ${x},${y} h ${width} v ${height} h -${width} Z`\n return {\n asChild: true,\n children: <path d={d} height={height} width={width} />,\n fill: fill === \"#ccc\" ? undefined : fill,\n stroke: stroke === \"#ccc\" ? undefined : stroke,\n ...rest,\n }\n },\n)\n\ninterface ChartTooltipContentProps\n extends\n HTMLStyledProps,\n Pick<\n TooltipContentProps<any, any>,\n \"formatter\" | \"label\" | \"labelFormatter\" | \"payload\"\n > {\n /**\n * If `true`, swatch is visible.\n */\n withSwatch?: boolean\n}\n\nconst ChartTooltipContent = withContext<\"div\", ChartTooltipContentProps>(\n ({\n formatter,\n label: labelProp,\n labelFormatter,\n payload,\n withSwatch = true,\n ...rest\n }) => {\n const { nameKeyRef } = useChartComponentContext()\n const label = labelFormatter\n ? labelFormatter(labelProp, payload)\n : labelProp\n\n return (\n <styled.div {...rest}>\n {!isUndefined(label) && !isNull(label) ? (\n <ChartTooltipLabel>{label}</ChartTooltipLabel>\n ) : null}\n\n <ChartTooltipList>\n {payload.map((data, index) => {\n if (nameKeyRef.current) data.name = data.payload[nameKeyRef.current]\n\n const color = parseJSON(data.color) || data.payload.fill\n const result =\n formatter?.(data.value, data.name, data, index, payload) ??\n (isArray(data.value) ? data.value.join(\", \") : data.value)\n const [value, name] = isArray(result) ? result : [result, data.name]\n\n return (\n <ChartTooltipItem key={index}>\n {withSwatch ? <ChartTooltipSwatch bg={color} /> : null}\n <ChartTooltipName>{name}</ChartTooltipName>\n <ChartTooltipValue>{value}</ChartTooltipValue>\n </ChartTooltipItem>\n )\n })}\n </ChartTooltipList>\n </styled.div>\n )\n },\n \"tooltipContent\",\n)()\n\ninterface ChartTooltipLabel extends HTMLStyledProps<\"p\"> {}\n\nconst ChartTooltipLabel = withContext<\"p\", ChartTooltipLabel>(\n \"p\",\n \"tooltipLabel\",\n)()\n\ninterface ChartTooltipList extends HTMLStyledProps {}\n\nconst ChartTooltipList = withContext<\"div\", ChartTooltipList>(\n \"div\",\n \"tooltipList\",\n)()\n\ninterface ChartTooltipItem extends HTMLStyledProps {}\n\nconst ChartTooltipItem = withContext<\"div\", ChartTooltipItem>(\n \"div\",\n \"tooltipItem\",\n)()\n\ninterface ChartTooltipSwatch extends HTMLStyledProps {}\n\nconst ChartTooltipSwatch = withContext<\"div\", ChartTooltipSwatch>(\n \"div\",\n \"tooltipSwatch\",\n)()\n\ninterface ChartTooltipName extends HTMLStyledProps<\"span\"> {}\n\nconst ChartTooltipName = withContext<\"span\", ChartTooltipName>(\n \"span\",\n \"tooltipName\",\n)()\n\ninterface ChartTooltipValue extends HTMLStyledProps<\"span\"> {}\n\nconst ChartTooltipValue = withContext<\"span\", ChartTooltipValue>(\n \"span\",\n \"tooltipValue\",\n)()\n\nexport interface ChartLabelListProps extends Merge<\n HTMLStyledProps<\"text\">,\n UseChartLabelListProps\n> {}\n\nexport const ChartLabelList = withContext<\"text\", ChartLabelListProps>(\n (props) => {\n const { getLabelListProps, getRootProps } = useChartLabelList(props)\n\n return (\n <styled.text asChild {...getRootProps()}>\n <LabelList {...getLabelListProps()} />\n </styled.text>\n )\n },\n \"labelList\",\n)()\n\nexport interface ChartLabelProps extends Merge<\n HTMLStyledProps<\"text\">,\n UseChartLabelProps\n> {}\n\nexport const ChartLabel = withContext<\"text\", ChartLabelProps>((props) => {\n const { getLabelProps, getRootProps } = useChartLabel(props)\n\n return (\n <styled.text asChild {...getRootProps()}>\n <Label {...getLabelProps()} />\n </styled.text>\n )\n}, \"label\")()\n"],"mappings":";;;;;;;;;;;;;;AAiHA,SAAgB,YACd,QACA,QAA2B,QAC3B,WAA6B,UACS;CACtC,MAAM,SAAS,UAAU,OAAO,QAAQ,OAAO,QAAQ;CAEvD,OAAO,OAAO,KAAK,MAAM,WAAW;EAAE,GAAG;EAAM,OAAO,OAAO;CAAO,EAAE;AACxE;AAEA,SAAgB,UACd,MACA,QAA0D,QAC1D,WAA6B,UACO;CACpC,MAAM,SAAS,UAAU,KAAK,QAAQ,OAAO,QAAQ;CAErD,OAAO,KAAK,KAAK,MAAM,WAAW;EAAE,GAAG;EAAM,MAAM,OAAO;CAAO,EAAE;AACrE;AAEA,SAAgB,UACd,QACA,QAA2D,QAC3D,WAA6B,UACR;CACrB,OAAO,MAAM,KAAK,EAAE,OAAO,IAAI,GAAG,UAAU;EAE1C,MAAM,UAAU,GADF,KAAK,MAAM,MAAO,MAAM,SAAU,KACzB,EAAE;EAEzB,IAAI,aAAa,UACf,OAAO,CACL,eAAe,MAAgB,IAAI,QAAQ,IAC3C,gBAAgB,MAAgB,IAAI,QAAQ,EAC9C;OAEA,OAAO,GAAG,SAAS,UAAU,MAAgB,IAAI,QAAQ;CAE7D,CAAC;AACH;AAEA,SAAS,UAAU,OAAY;CAC7B,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN,OAAO;CACT;AACF;AAmEA,MAAM,EACJ,kBACA,cAAc,mBACd,qBAAqB,0BACrB,iBAAiB,sBACjB,aACA,iBACE,oBACF,SACA,UACF;AAIA,MAAa,QAAQ,cAClB,EACC,UACA,YAAY,gBACZ,QACA,aAAa,OACb,cAAc,MACd,aACA,0BACA,cACA,GAAG,WACa;CAChB,MAAM,EAAE,oBAAoB,gBAAgB,SAAS;CACrD,MAAM,aAAa,OAA2B,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F,CAAC,CAAC;AAIF,MAAM,oBAAoB,YACxB,QACA,cACF,CAAC,CAAC;AAOF,MAAa,iBAAiB,aAC3B,UAAU;CACT,MAAM,EAAE,mBAAmB,iBAAiB,kBAAkB,KAAK;CAEnE,OACE,oBAAC,OAAO,MAAR;EAAa,SAAA;EAAQ,GAAI,aAAa;YACpC,oBAAC,WAAD,EAAW,GAAI,kBAAkB,EAAI,CAAA;CAC1B,CAAA;AAEjB,GACA,WACF,CAAC,CAAC;AAOF,MAAa,aAAa,aAAsC,UAAU;CACxE,MAAM,EAAE,eAAe,iBAAiB,cAAc,KAAK;CAE3D,OACE,oBAAC,OAAO,MAAR;EAAa,SAAA;EAAQ,GAAI,aAAa;YACpC,oBAAC,OAAD,EAAO,GAAI,cAAc,EAAI,CAAA;CAClB,CAAA;AAEjB,GAAG,OAAO,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"chart.js","names":["createContext"],"sources":["../../../../src/components/chart/chart.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n JSXElementConstructor,\n PropsWithChildren,\n ReactElement,\n ReactNode,\n RefObject,\n} from \"react\"\nimport type {\n ActiveDotProps,\n DataKey,\n DefaultLegendContentProps,\n DotItemDotProps,\n DotProps,\n LabelProps,\n RenderableText,\n ResponsiveContainerProps,\n TooltipContentProps,\n TooltipProps,\n} from \"recharts\"\nimport type {\n CSSProps,\n ExtractStyleValueWithCondition,\n HTMLStyledProps,\n ThemeProps,\n} from \"../../core\"\nimport type { Dict, Merge } from \"../../utils\"\nimport type { ChartStyle } from \"./chart.style\"\nimport type {\n UseChartLabelListProps,\n UseChartLabelProps,\n UseChartLegendProps,\n UseChartLegendReturn,\n UseChartTooltipProps,\n} from \"./use-chart\"\nimport { Fragment, isValidElement, useMemo, useRef } from \"react\"\nimport {\n Label,\n LabelList,\n Legend,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\"\nimport { createSlotComponent, mergeProps, styled, varAttr } from \"../../core\"\nimport {\n cast,\n createContext,\n isArray,\n isNull,\n isNumber,\n isObject,\n isString,\n isUndefined,\n useSplitChildren,\n} from \"../../utils\"\nimport { chartStyle } from \"./chart.style\"\nimport {\n ChartContext,\n useChart,\n useChartLabel,\n useChartLabelList,\n useChartLegend,\n useChartTooltip,\n} from \"./use-chart\"\n\nexport type ChartDot =\n | ((props: DotItemDotProps) => ReactNode)\n | boolean\n | Merge<Partial<DotProps>, HTMLStyledProps<\"circle\">>\n | ReactElement\n\nexport type ChartActiveDot =\n | ((props: ActiveDotProps) => ReactNode)\n | boolean\n | Merge<Partial<ActiveDotProps>, HTMLStyledProps<\"circle\">>\n | ReactElement\n\nexport type ChartLabel =\n | ((props: any) => ReactElement | RenderableText)\n | boolean\n | (Merge<\n HTMLStyledProps<\"text\">,\n Pick<\n LabelProps,\n | \"angle\"\n | \"content\"\n | \"formatter\"\n | \"index\"\n | \"labelRef\"\n | \"offset\"\n | \"parentViewBox\"\n | \"position\"\n | \"textBreakAll\"\n | \"value\"\n | \"viewBox\"\n | \"zIndex\"\n >\n > & { dataKey?: DataKey<any> })\n | number\n | ReactElement\n | string\n\nexport type ChartLabelList =\n | ((props: LabelProps) => ReactElement | RenderableText)\n | boolean\n | ChartLabelListProps\n | ReactElement\n\nexport type ChartTickLine = boolean | HTMLStyledProps<\"line\">\n\nexport type GradientStrategy = \"invert\" | \"shade\" | \"tint\"\n\nexport function mergeSeries<Y>(\n series: Y[],\n color: CSSProps[\"color\"] = \"mono\",\n strategy: GradientStrategy = \"invert\",\n): (Y & { color: CSSProps[\"color\"] })[] {\n const colors = gradients(series.length, color, strategy)\n\n return series.map((item, index) => ({ ...item, color: colors[index] }))\n}\n\nexport function mergeData<Y>(\n data: Y[],\n color: ExtractStyleValueWithCondition<CSSProps[\"fill\"]> = \"mono\",\n strategy: GradientStrategy = \"invert\",\n): (Y & { fill: CSSProps[\"fill\"] })[] {\n const colors = gradients(data.length, color, strategy)\n\n return data.map((item, index) => ({ ...item, fill: colors[index] }))\n}\n\nexport function gradients(\n length: number,\n color: ExtractStyleValueWithCondition<CSSProps[\"color\"]> = \"mono\",\n strategy: GradientStrategy = \"invert\",\n): CSSProps[\"color\"][] {\n return Array.from({ length }, (_, index) => {\n const value = Math.floor(100 - (100 / length) * index)\n const percent = `${value}%`\n\n if (strategy === \"invert\")\n return [\n `tint(colors.${color as string}, ${percent})`,\n `shade(colors.${color as string}, ${percent})`,\n ]\n else return `${strategy}(colors.${color as string}, ${percent})`\n })\n}\n\nfunction parseJSON(value: any) {\n try {\n return JSON.parse(value)\n } catch {\n return value\n }\n}\n\ninterface ComponentContext extends Pick<\n ChartProps,\n \"legendProps\" | \"tooltipProps\"\n> {\n nameKeyRef: RefObject<string | undefined>\n}\n\nexport interface ChartProps extends HTMLStyledProps, ThemeProps<ChartStyle> {\n /**\n * The components to render the chart components.\n */\n components: {\n component: JSXElementConstructor<any>\n fallback: ReactNode\n }[]\n /**\n * The function to render the chart.\n */\n render: (props: PropsWithChildren) => ReactNode\n /**\n * The color of the label list.\n */\n labelListColor?: CSSProps[\"color\"]\n /**\n * The fill of the label list.\n */\n labelListFill?: CSSProps[\"fill\"]\n /**\n * The fill of the tooltip cursor.\n */\n tooltipCursorFill?: CSSProps[\"fill\"]\n /**\n * The fill opacity of the tooltip cursor.\n */\n tooltipCursorFillOpacity?: CSSProps[\"fillOpacity\"]\n /**\n * The stroke of the tooltip cursor.\n */\n tooltipCursorStroke?: CSSProps[\"stroke\"]\n /**\n * If `true`, legend is visible.\n *\n * @default false\n */\n withLegend?: boolean\n /**\n * If `true`, tooltip is visible.\n *\n * @default true\n */\n withTooltip?: boolean\n /**\n * Props for the legend component.\n */\n legendProps?: ChartLegendProps\n /**\n * Props for the responsive container component.\n */\n responsiveContainerProps?: ResponsiveContainerProps\n /**\n * Props for the tooltip component.\n */\n tooltipProps?: ChartTooltipProps\n}\n\nconst {\n ComponentContext,\n PropsContext: ChartPropsContext,\n useComponentContext: useChartComponentContext,\n usePropsContext: useChartPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<ChartProps, ChartStyle, ComponentContext>(\n \"chart\",\n chartStyle,\n)\n\nexport { ChartPropsContext, useChartComponentContext, useChartPropsContext }\n\nexport const Chart = withProvider(\n ({\n children,\n components: componentsProp,\n render,\n withLegend = false,\n withTooltip = true,\n legendProps,\n responsiveContainerProps,\n tooltipProps,\n ...rest\n }: ChartProps) => {\n const { highlightedDataKey, onHighlight } = useChart()\n const nameKeyRef = useRef<string | undefined>(undefined)\n const components = useMemo(\n () => [\n ...componentsProp,\n {\n component: ChartLegend,\n fallback: withLegend ? <ChartLegend /> : null,\n },\n {\n component: ChartTooltip,\n fallback: withTooltip ? <ChartTooltip /> : null,\n },\n ],\n [componentsProp, withLegend, withTooltip],\n )\n const [omittedChildren, ...customComponents] = useSplitChildren(\n children,\n ...components.map(({ component }) => component),\n )\n const context = useMemo(\n () => ({\n highlightedDataKey,\n onHighlight,\n }),\n [highlightedDataKey, onHighlight],\n )\n const componentContext = useMemo(\n () => ({\n nameKeyRef,\n legendProps,\n tooltipProps,\n }),\n [legendProps, tooltipProps],\n )\n\n return (\n <ChartContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.div {...rest}>\n <ResponsiveContainer {...responsiveContainerProps}>\n {render({\n children: (\n <>\n {components.map(({ fallback }, index) => (\n <Fragment key={index}>\n {customComponents[index] ?? fallback}\n </Fragment>\n ))}\n\n {omittedChildren}\n </>\n ),\n })}\n </ResponsiveContainer>\n </styled.div>\n </ComponentContext>\n </ChartContext>\n )\n },\n \"root\",\n)(\n undefined,\n ({\n labelListColor,\n labelListFill,\n tooltipCursorFill,\n tooltipCursorFillOpacity,\n tooltipCursorStroke,\n ...rest\n }) => ({\n \"--label-list-color\": varAttr(labelListColor, \"colors\"),\n \"--label-list-fill\": varAttr(labelListFill, \"colors\"),\n \"--tooltip-cursor-fill\": varAttr(tooltipCursorFill, \"colors\"),\n \"--tooltip-cursor-fill-opacity\": tooltipCursorFillOpacity,\n \"--tooltip-cursor-stroke\": varAttr(tooltipCursorStroke, \"colors\"),\n ...rest,\n }),\n)\n\ninterface ChartLegendContext extends Pick<\n UseChartLegendReturn,\n \"getLegendItemProps\"\n> {}\n\nconst [ChartLegendContext, useChartLegendContext] =\n createContext<ChartLegendContext>({\n name: \"ChartLegendContext\",\n })\n\nexport interface ChartLegendProps extends Merge<\n HTMLStyledProps,\n UseChartLegendProps\n> {\n /**\n * Props for the content component.\n */\n contentProps?: Omit<ChartLegendContentProps, \"formatter\" | \"payload\">\n}\n\nexport const ChartLegend = withContext<\"div\", ChartLegendProps>((props) => {\n const { legendProps } = useChartComponentContext()\n const { contentProps, ...rest } = mergeProps(legendProps, props)()\n const {\n getLegendContentProps,\n getLegendItemProps,\n getLegendProps,\n getRootProps,\n } = useChartLegend({\n content: ({ formatter, payload }) => (\n <ChartLegendContent\n formatter={formatter}\n payload={payload}\n {...getLegendContentProps(contentProps)}\n />\n ),\n ...rest,\n })\n const context = useMemo(() => ({ getLegendItemProps }), [getLegendItemProps])\n\n return (\n <ChartLegendContext value={context}>\n <styled.div asChild {...getRootProps()}>\n <Legend {...getLegendProps()} />\n </styled.div>\n </ChartLegendContext>\n )\n}, \"legend\")()\n\ninterface ChartLegendContentProps\n extends\n HTMLStyledProps,\n Pick<DefaultLegendContentProps, \"formatter\" | \"payload\"> {\n /**\n * If `true`, swatch is visible.\n */\n withSwatch?: boolean\n}\n\nconst ChartLegendContent = withContext<\"div\", ChartLegendContentProps>(\n ({ formatter, payload, withSwatch = true, ...rest }) => {\n const { nameKeyRef } = useChartComponentContext()\n const { getLegendItemProps } = useChartLegendContext()\n\n return (\n <styled.div {...rest}>\n {payload?.map((data, index) => {\n let value = data.value\n\n if (nameKeyRef.current)\n value = (data.payload as any)?.[nameKeyRef.current]\n\n const dataKey =\n isString(data.dataKey) || isNumber(data.dataKey)\n ? data.dataKey\n : value\n const color = parseJSON(data.color)\n const formattedValue = formatter?.(value, data, index) ?? value\n\n return (\n <ChartLegendItem key={index} {...getLegendItemProps({ dataKey })}>\n {withSwatch ? <ChartLegendSwatch bg={color} /> : null}\n <ChartLegendValue>{formattedValue}</ChartLegendValue>\n </ChartLegendItem>\n )\n })}\n </styled.div>\n )\n },\n \"legendContent\",\n)()\n\ninterface ChartLegendItemProps extends HTMLStyledProps {}\n\nconst ChartLegendItem = withContext<\"div\", ChartLegendItemProps>(\n \"div\",\n \"legendItem\",\n)()\n\ninterface ChartLegendSwatchProps extends HTMLStyledProps {}\n\nconst ChartLegendSwatch = withContext<\"div\", ChartLegendSwatchProps>(\n \"div\",\n \"legendSwatch\",\n)()\n\ninterface ChartLegendValueProps extends HTMLStyledProps<\"span\"> {}\n\nconst ChartLegendValue = withContext<\"span\", ChartLegendValueProps>(\n \"span\",\n \"legendValue\",\n)()\n\nexport interface ChartTooltipProps<\n Y extends (number | string)[] | number | string = number,\n M extends number | string = string,\n> extends Omit<Merge<HTMLStyledProps, UseChartTooltipProps<Y, M>>, \"cursor\"> {\n /**\n * Props for the cursor component.\n */\n cursor?: boolean | ChartTooltipCursorProps | ReactElement\n /**\n * Props for the content component.\n */\n contentProps?: Omit<\n ChartTooltipContentProps,\n \"formatter\" | \"label\" | \"labelFormatter\" | \"payload\"\n >\n}\n\nexport const ChartTooltip = <\n Y extends (number | string)[] | number | string,\n M extends number | string,\n>(\n props: ChartTooltipProps<Y, M>,\n) => {\n const { tooltipProps } = useChartComponentContext()\n const {\n cursor = false,\n contentProps,\n ...rest\n } = {\n ...tooltipProps,\n ...props,\n } as ChartTooltipProps<Y, M>\n const { getContentProps, getRootProps } = useChartTooltip<Y, M>({\n content: ({ formatter, label, labelFormatter, payload }) => (\n <ChartTooltipContent\n formatter={formatter}\n label={label}\n labelFormatter={labelFormatter}\n payload={payload}\n {...getContentProps(contentProps)}\n />\n ),\n cursor:\n isValidElement(cursor) || !cursor ? (\n cursor\n ) : (\n <ChartTooltipCursor {...(isObject(cursor) ? cursor : {})} />\n ),\n ...rest,\n })\n\n return <Tooltip {...cast<TooltipProps>(getRootProps())} />\n}\n\ninterface ChartTooltipCursorProps extends Omit<\n HTMLStyledProps<\"path\">,\n \"height\" | \"points\" | \"width\" | \"x\" | \"y\"\n> {\n brushBottom?: number\n height?: number\n payload?: Dict[]\n payloadIndex?: number\n points?: { x: number; y: number }[]\n width?: number\n x?: number\n y?: number\n}\n\nconst ChartTooltipCursor = withContext<\"path\", ChartTooltipCursorProps>(\n \"path\",\n \"tooltipCursor\",\n)(\n undefined,\n ({\n bottom: _bottom,\n brushBottom: _brushBottom,\n fill,\n height,\n left: _left,\n payload: _payload,\n payloadIndex: _payloadIndex,\n points,\n right: _right,\n stroke,\n top: _top,\n width,\n x,\n y,\n ...rest\n }) => {\n const d = points\n ? `M${points[0]?.x},${points[0]?.y}L${points[1]?.x},${points[1]?.y}`\n : `M ${x},${y} h ${width} v ${height} h -${width} Z`\n return {\n asChild: true,\n children: <path d={d} height={height} width={width} />,\n fill: fill === \"#ccc\" ? undefined : fill,\n stroke: stroke === \"#ccc\" ? undefined : stroke,\n ...rest,\n }\n },\n)\n\ninterface ChartTooltipContentProps\n extends\n HTMLStyledProps,\n Pick<\n TooltipContentProps<any, any>,\n \"formatter\" | \"label\" | \"labelFormatter\" | \"payload\"\n > {\n /**\n * If `true`, swatch is visible.\n */\n withSwatch?: boolean\n}\n\nconst ChartTooltipContent = withContext<\"div\", ChartTooltipContentProps>(\n ({\n formatter,\n label: labelProp,\n labelFormatter,\n payload,\n withSwatch = true,\n ...rest\n }) => {\n const { nameKeyRef } = useChartComponentContext()\n const label = labelFormatter\n ? labelFormatter(labelProp, payload)\n : labelProp\n\n return (\n <styled.div {...rest}>\n {!isUndefined(label) && !isNull(label) ? (\n <ChartTooltipLabel>{label}</ChartTooltipLabel>\n ) : null}\n\n <ChartTooltipList>\n {payload.map((data, index) => {\n if (nameKeyRef.current) data.name = data.payload[nameKeyRef.current]\n\n const color = parseJSON(data.color) || data.payload.fill\n const result =\n formatter?.(data.value, data.name, data, index, payload) ??\n (isArray(data.value) ? data.value.join(\", \") : data.value)\n const [value, name] = isArray(result) ? result : [result, data.name]\n\n return (\n <ChartTooltipItem key={index}>\n {withSwatch ? <ChartTooltipSwatch bg={color} /> : null}\n <ChartTooltipName>{name}</ChartTooltipName>\n <ChartTooltipValue>{value}</ChartTooltipValue>\n </ChartTooltipItem>\n )\n })}\n </ChartTooltipList>\n </styled.div>\n )\n },\n \"tooltipContent\",\n)()\n\ninterface ChartTooltipLabel extends HTMLStyledProps<\"p\"> {}\n\nconst ChartTooltipLabel = withContext<\"p\", ChartTooltipLabel>(\n \"p\",\n \"tooltipLabel\",\n)()\n\ninterface ChartTooltipList extends HTMLStyledProps {}\n\nconst ChartTooltipList = withContext<\"div\", ChartTooltipList>(\n \"div\",\n \"tooltipList\",\n)()\n\ninterface ChartTooltipItem extends HTMLStyledProps {}\n\nconst ChartTooltipItem = withContext<\"div\", ChartTooltipItem>(\n \"div\",\n \"tooltipItem\",\n)()\n\ninterface ChartTooltipSwatch extends HTMLStyledProps {}\n\nconst ChartTooltipSwatch = withContext<\"div\", ChartTooltipSwatch>(\n \"div\",\n \"tooltipSwatch\",\n)()\n\ninterface ChartTooltipName extends HTMLStyledProps<\"span\"> {}\n\nconst ChartTooltipName = withContext<\"span\", ChartTooltipName>(\n \"span\",\n \"tooltipName\",\n)()\n\ninterface ChartTooltipValue extends HTMLStyledProps<\"span\"> {}\n\nconst ChartTooltipValue = withContext<\"span\", ChartTooltipValue>(\n \"span\",\n \"tooltipValue\",\n)()\n\nexport interface ChartLabelListProps extends Merge<\n HTMLStyledProps<\"text\">,\n UseChartLabelListProps\n> {}\n\nexport const ChartLabelList = withContext<\"text\", ChartLabelListProps>(\n (props) => {\n const { getLabelListProps, getRootProps } = useChartLabelList(props)\n\n return (\n <styled.text asChild {...getRootProps()}>\n <LabelList {...getLabelListProps()} />\n </styled.text>\n )\n },\n \"labelList\",\n)()\n\nexport interface ChartLabelProps extends Merge<\n HTMLStyledProps<\"text\">,\n UseChartLabelProps\n> {}\n\nexport const ChartLabel = withContext<\"text\", ChartLabelProps>((props) => {\n const { getLabelProps, getRootProps } = useChartLabel(props)\n\n return (\n <styled.text asChild {...getRootProps()}>\n <Label {...getLabelProps()} />\n </styled.text>\n )\n}, \"label\")()\n"],"mappings":";;;;;;;;;;;;;;AAiHA,SAAgB,YACd,QACA,QAA2B,QAC3B,WAA6B,UACS;CACtC,MAAM,SAAS,UAAU,OAAO,QAAQ,OAAO,QAAQ;CAEvD,OAAO,OAAO,KAAK,MAAM,WAAW;EAAE,GAAG;EAAM,OAAO,OAAO;CAAO,EAAE;AACxE;AAEA,SAAgB,UACd,MACA,QAA0D,QAC1D,WAA6B,UACO;CACpC,MAAM,SAAS,UAAU,KAAK,QAAQ,OAAO,QAAQ;CAErD,OAAO,KAAK,KAAK,MAAM,WAAW;EAAE,GAAG;EAAM,MAAM,OAAO;CAAO,EAAE;AACrE;AAEA,SAAgB,UACd,QACA,QAA2D,QAC3D,WAA6B,UACR;CACrB,OAAO,MAAM,KAAK,EAAE,OAAO,IAAI,GAAG,UAAU;EAE1C,MAAM,UAAU,GADF,KAAK,MAAM,MAAO,MAAM,SAAU,KACzB,EAAE;EAEzB,IAAI,aAAa,UACf,OAAO,CACL,eAAe,MAAgB,IAAI,QAAQ,IAC3C,gBAAgB,MAAgB,IAAI,QAAQ,EAC9C;OACG,OAAO,GAAG,SAAS,UAAU,MAAgB,IAAI,QAAQ;CAChE,CAAC;AACH;AAEA,SAAS,UAAU,OAAY;CAC7B,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN,OAAO;CACT;AACF;AAmEA,MAAM,EACJ,kBACA,cAAc,mBACd,qBAAqB,0BACrB,iBAAiB,sBACjB,aACA,iBACE,oBACF,SACA,UACF;AAIA,MAAa,QAAQ,cAClB,EACC,UACA,YAAY,gBACZ,QACA,aAAa,OACb,cAAc,MACd,aACA,0BACA,cACA,GAAG,WACa;CAChB,MAAM,EAAE,oBAAoB,gBAAgB,SAAS;CACrD,MAAM,aAAa,OA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