@yamada-ui/react 2.2.1-dev-20260511135752 → 2.2.1-dev-20260511183442

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.
Files changed (48) hide show
  1. package/dist/cjs/components/chart/use-cartesian-chart.cjs +7 -28
  2. package/dist/cjs/components/chart/use-cartesian-chart.cjs.map +1 -1
  3. package/dist/cjs/components/chart/use-polar-chart.cjs +9 -36
  4. package/dist/cjs/components/chart/use-polar-chart.cjs.map +1 -1
  5. package/dist/cjs/components/popover/use-popover.cjs +14 -4
  6. package/dist/cjs/components/popover/use-popover.cjs.map +1 -1
  7. package/dist/cjs/hooks/use-combobox/index.cjs +32 -31
  8. package/dist/cjs/hooks/use-combobox/index.cjs.map +1 -1
  9. package/dist/esm/components/chart/use-cartesian-chart.js +7 -28
  10. package/dist/esm/components/chart/use-cartesian-chart.js.map +1 -1
  11. package/dist/esm/components/chart/use-polar-chart.js +9 -36
  12. package/dist/esm/components/chart/use-polar-chart.js.map +1 -1
  13. package/dist/esm/components/popover/use-popover.js +14 -4
  14. package/dist/esm/components/popover/use-popover.js.map +1 -1
  15. package/dist/esm/hooks/use-combobox/index.js +32 -31
  16. package/dist/esm/hooks/use-combobox/index.js.map +1 -1
  17. package/dist/types/components/accordion/accordion.style.d.ts +1 -1
  18. package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
  19. package/dist/types/components/breadcrumb/breadcrumb.style.d.ts +1 -1
  20. package/dist/types/components/calendar/calendar.style.d.ts +2 -2
  21. package/dist/types/components/carousel/carousel.style.d.ts +2 -2
  22. package/dist/types/components/chart/cartesian-chart.style.d.ts +1 -1
  23. package/dist/types/components/chart/polar-chart.style.d.ts +1 -1
  24. package/dist/types/components/checkbox-card/checkbox-card.d.ts +3 -3
  25. package/dist/types/components/checkbox-card/checkbox-card.style.d.ts +1 -1
  26. package/dist/types/components/color-picker/color-picker.style.d.ts +1 -1
  27. package/dist/types/components/data-list/data-list.style.d.ts +1 -1
  28. package/dist/types/components/empty-state/empty-state.style.d.ts +2 -2
  29. package/dist/types/components/flip/flip.d.ts +1 -1
  30. package/dist/types/components/flip/flip.style.d.ts +1 -1
  31. package/dist/types/components/list/list.style.d.ts +2 -2
  32. package/dist/types/components/menu/menu.style.d.ts +2 -2
  33. package/dist/types/components/native-accordion/native-accordion.style.d.ts +2 -2
  34. package/dist/types/components/notice/notice.style.d.ts +1 -1
  35. package/dist/types/components/number-input/number-input.style.d.ts +1 -1
  36. package/dist/types/components/pagination/pagination.style.d.ts +1 -1
  37. package/dist/types/components/radio-card/radio-card.d.ts +3 -3
  38. package/dist/types/components/radio-card/radio-card.style.d.ts +1 -1
  39. package/dist/types/components/rating/rating.style.d.ts +2 -2
  40. package/dist/types/components/reorder/reorder.style.d.ts +1 -1
  41. package/dist/types/components/resizable/resizable.style.d.ts +2 -2
  42. package/dist/types/components/segmented-control/segmented-control.style.d.ts +2 -2
  43. package/dist/types/components/steps/steps.style.d.ts +1 -1
  44. package/dist/types/components/timeline/timeline.d.ts +1 -1
  45. package/dist/types/components/timeline/timeline.style.d.ts +1 -1
  46. package/dist/types/components/tree/tree.style.d.ts +1 -1
  47. package/dist/types/providers/i18n-provider/i18n-provider.d.ts +1 -1
  48. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"use-popover.cjs","names":["useEnvironment","useDisclosure","usePopper","getEventRelatedTarget","mergeRefs","popperProps","useSplitProps"],"sources":["../../../../src/components/popover/use-popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FocusEvent, KeyboardEvent, RefObject } from \"react\"\nimport type { Direction, PropGetter } from \"../../core\"\nimport type { UseDisclosureProps } from \"../../hooks/use-disclosure\"\nimport type { UsePopperProps } from \"../../hooks/use-popper\"\nimport type { Dict } from \"../../utils\"\nimport type { UsePopupAnimationProps } from \"./popover\"\nimport { useCallback, useEffect, useId, useRef } from \"react\"\nimport { useEnvironment, useSplitProps } from \"../../core\"\nimport { useDisclosure } from \"../../hooks/use-disclosure\"\nimport { useEventListener } from \"../../hooks/use-event-listener\"\nimport { useFocusOnShow } from \"../../hooks/use-focus\"\nimport { useOutsideClick } from \"../../hooks/use-outside-click\"\nimport { popperProps, usePopper } from \"../../hooks/use-popper\"\nimport {\n ariaAttr,\n assignRef,\n contains,\n dataAttr,\n focusTransfer,\n focusTrap,\n getEventRelatedTarget,\n handlerAll,\n mergeRefs,\n runKeyAction,\n scrollLock,\n setAttribute,\n useSafeLayoutEffect,\n useUnmountEffect,\n} from \"../../utils\"\n\nexport interface UsePopoverProps\n extends Omit<UseDisclosureProps, \"timing\">, UsePopperProps<\"button\"> {\n /**\n * If `true`, focus will be transferred to the first interactive element when the popover opens.\n *\n * @default true\n */\n autoFocus?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default false\n */\n blockScrollOnMount?: boolean\n /**\n * If `true`, the popover will close when you blur out it by clicking outside or tabbing out.\n *\n * @default true\n */\n closeOnBlur?: boolean\n /**\n * If `true`, the popover will hide on pressing Esc key.\n *\n * @default true\n */\n closeOnEsc?: boolean\n /**\n * If `true`, the popover will hide on scroll.\n *\n * @default false\n */\n closeOnScroll?: boolean\n /**\n * If `true`, the popover will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The `ref` of the element that should receive focus when the popover opens.\n */\n initialFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the popover will be modal.\n *\n * - scrolling is blocked.\n * - focus is trapped within the popover.\n *\n * @default false\n */\n modal?: boolean\n /**\n * If `true`, the popover will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end'\n */\n placement?: Direction\n /**\n * If `true`, the focus will be transferred to the popover content when the tab key is pressed.\n *\n * @default true\n */\n transferFocus?: boolean\n /**\n * Update the position of the floating element, re-rendering the component if required.\n */\n updateRef?: RefObject<() => void>\n}\n\nexport const usePopover = ({\n autoFocus = true,\n autoUpdate,\n modal = false,\n blockScrollOnMount = modal,\n closeOnBlur = true,\n closeOnEsc = true,\n closeOnScroll,\n defaultOpen,\n disabled,\n elements,\n flip,\n gutter,\n initialFocusRef,\n matchWidth,\n middleware,\n offset,\n open: openProp,\n openOnClick = true,\n placement = \"end\",\n platform,\n preventOverflow,\n strategy,\n transferFocus = true,\n transform,\n updateRef,\n whileElementsMounted,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n}: UsePopoverProps = {}) => {\n const { getDocument } = useEnvironment()\n const headerId = useId()\n const bodyId = useId()\n const contentId = useId()\n const anchorRef = useRef<HTMLElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const contentRef = useRef<HTMLElement>(null)\n const openTimeout = useRef<NodeJS.Timeout>(undefined)\n const closeTimeout = useRef<NodeJS.Timeout>(undefined)\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const { refs, update, getPopperProps } = usePopper<\"button\">({\n autoUpdate,\n elements,\n flip,\n gutter,\n matchWidth,\n middleware,\n offset,\n open,\n placement,\n platform,\n preventOverflow,\n strategy,\n transform,\n whileElementsMounted,\n })\n\n assignRef(updateRef, update)\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n runKeyAction(ev, {\n Escape: () => {\n if (!closeOnEsc) return\n\n onClose()\n\n triggerRef.current?.focus()\n },\n })\n },\n [closeOnEsc, onClose],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLDivElement>) => {\n const relatedTarget = getEventRelatedTarget(ev)\n const popup = relatedTarget?.hasAttribute(\"data-popup\")\n\n if (contains(triggerRef.current, relatedTarget)) return\n if (contains(contentRef.current, relatedTarget)) return\n if (contains(contentRef.current, ev.target) && popup) return\n\n if (closeOnBlur) onClose()\n },\n [closeOnBlur, onClose],\n )\n\n useEventListener(getDocument(), \"scroll\", () => {\n if (open && closeOnScroll) onClose()\n })\n\n useFocusOnShow(contentRef, {\n focusTarget: initialFocusRef,\n shouldFocus: autoFocus,\n visible: open,\n })\n\n useOutsideClick({\n ref: [contentRef, triggerRef],\n enabled: open && closeOnBlur,\n handler: onClose,\n })\n\n useSafeLayoutEffect(() => {\n const el = contentRef.current\n const hasHeader = !!getDocument()?.getElementById(headerId)\n const hasBody = !!getDocument()?.getElementById(bodyId)\n\n if (el && hasHeader) setAttribute(el, \"aria-labelledby\", headerId)\n if (el && hasBody) setAttribute(el, \"aria-describedby\", bodyId)\n }, [open, headerId, bodyId])\n\n useEffect(() => {\n if (!open || !modal) return\n\n return focusTrap(contentRef.current)\n }, [open, modal])\n\n useEffect(() => {\n if (!open || !blockScrollOnMount) return\n\n return scrollLock(contentRef.current)\n }, [open, modal, blockScrollOnMount])\n\n useEffect(() => {\n if (!open || modal || !transferFocus) return\n\n return focusTransfer(contentRef.current, triggerRef.current)\n }, [open, modal, transferFocus])\n\n useUnmountEffect(() => {\n clearTimeout(openTimeout.current)\n clearTimeout(closeTimeout.current)\n })\n\n const getTriggerProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"dialog\",\n role: \"button\",\n ...props,\n ref: mergeRefs(ref, triggerRef, (node) => {\n if (anchorRef.current == null) refs.setReference(node)\n }),\n onBlur: handlerAll(props.onBlur, (ev) =>\n !contains(contentRef.current, getEventRelatedTarget(ev)) && closeOnBlur\n ? onClose()\n : void 0,\n ),\n onClick: handlerAll(\n props.onClick,\n !open ? (!disabled && openOnClick ? onOpen : undefined) : onClose,\n ),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n closeOnBlur,\n contentId,\n disabled,\n onClose,\n onKeyDown,\n onOpen,\n open,\n openOnClick,\n refs,\n ],\n )\n\n const getAnchorProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ref: mergeRefs(ref, anchorRef, refs.setReference),\n }),\n [refs.setReference],\n )\n\n const getPositionerProps: PropGetter = useCallback(\n (props) => getPopperProps(props),\n [getPopperProps],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n \"aria-hidden\": !open,\n \"aria-modal\": modal ? \"true\" : undefined,\n \"data-close\": dataAttr(!open),\n \"data-open\": dataAttr(open),\n \"data-popup\": dataAttr(true),\n role: \"dialog\",\n tabIndex: -1,\n ...props,\n ref: mergeRefs(ref, contentRef),\n onBlur: handlerAll(props.onBlur, onBlur),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [contentId, open, modal, onBlur, onKeyDown],\n )\n\n const getHeaderProps: PropGetter = useCallback(\n (props) => ({ id: headerId, ...props }),\n [headerId],\n )\n\n const getBodyProps: PropGetter = useCallback(\n (props) => ({ id: bodyId, ...props }),\n [bodyId],\n )\n\n const getFooterProps: PropGetter = useCallback((props) => ({ ...props }), [])\n\n const getCloseTriggerProps: PropGetter<\"button\"> = useCallback(\n (props = {}) => ({\n ...props,\n onClick: handlerAll(props.onClick, () => {\n onClose()\n\n triggerRef.current?.focus()\n }),\n }),\n [onClose],\n )\n\n return {\n open,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n onClose,\n onOpen,\n }\n}\n\nexport type UsePopoverReturn = ReturnType<typeof usePopover>\n\nexport const popoverProps: (\n | keyof UsePopoverProps\n | keyof UsePopupAnimationProps\n)[] = [\n ...popperProps,\n \"autoFocus\",\n \"transferFocus\",\n \"blockScrollOnMount\",\n \"closeOnBlur\",\n \"closeOnEsc\",\n \"closeOnScroll\",\n \"openOnClick\",\n \"disabled\",\n \"initialFocusRef\",\n \"modal\",\n \"updateRef\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"animationScheme\",\n \"duration\",\n]\n\nexport const usePopoverProps = <\n Y extends Dict = Dict,\n M extends keyof UsePopoverProps | keyof UsePopupAnimationProps =\n | keyof UsePopoverProps\n | keyof UsePopupAnimationProps,\n>(\n props: Y,\n omitKeys?: M[],\n) => {\n return useSplitProps(\n props,\n popoverProps.filter((key) => !omitKeys?.includes(key as M)),\n ) as unknown as [\n keyof UsePopoverProps | keyof UsePopupAnimationProps extends M\n ? UsePopoverProps & UsePopupAnimationProps\n : Omit<UsePopoverProps & UsePopupAnimationProps, M>,\n Omit<\n Y,\n keyof UsePopoverProps | keyof UsePopupAnimationProps extends M\n ? keyof UsePopoverProps | keyof UsePopupAnimationProps\n : Exclude<keyof UsePopoverProps | keyof UsePopupAnimationProps, M>\n >,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2GA,MAAa,cAAc,EACzB,YAAY,MACZ,YACA,QAAQ,OACR,qBAAqB,OACrB,cAAc,MACd,aAAa,MACb,eACA,aACA,UACA,UACA,MACA,QACA,iBACA,YACA,YACA,QACA,MAAM,UACN,cAAc,MACd,YAAY,OACZ,UACA,iBACA,UACA,gBAAgB,MAChB,WACA,WACA,sBACA,SAAS,aACT,QAAQ,eACW,EAAE,KAAK;CAC1B,MAAM,EAAE,gBAAgBA,6BAAAA,gBAAgB;CACxC,MAAM,YAAA,GAAA,MAAA,QAAkB;CACxB,MAAM,UAAA,GAAA,MAAA,QAAgB;CACtB,MAAM,aAAA,GAAA,MAAA,QAAmB;CACzB,MAAM,aAAA,GAAA,MAAA,QAAgC,KAAK;CAC3C,MAAM,cAAA,GAAA,MAAA,QAAuC,KAAK;CAClD,MAAM,cAAA,GAAA,MAAA,QAAiC,KAAK;CAC5C,MAAM,eAAA,GAAA,MAAA,QAAqC,KAAA,EAAU;CACrD,MAAM,gBAAA,GAAA,MAAA,QAAsC,KAAA,EAAU;CACtD,MAAM,EAAE,MAAM,SAAS,WAAWC,uBAAAA,cAAc;EAC9C;EACA,MAAM;EACN,SAAS;EACT,QAAQ;EACT,CAAC;CACF,MAAM,EAAE,MAAM,QAAQ,mBAAmBC,+BAA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,SAAS;IAET,WAAW,SAAS,OAAO;KAC3B;GACH,GACD,CAAC,QAAQ,CAOW;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;AAKH,MAAa,eAGP;CACJ,GAAGC,+BAAAA;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,mBAMX,OACA,aACG;CACH,OAAOC,cAAAA,cACL,OACA,aAAa,QAAQ,QAAQ,CAAC,UAAU,SAAS,IAAS,CAAC,CAC5D"}
1
+ {"version":3,"file":"use-popover.cjs","names":["useEnvironment","useDisclosure","usePopper","getEventRelatedTarget","mergeRefs","popperProps","useSplitProps"],"sources":["../../../../src/components/popover/use-popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FocusEvent, KeyboardEvent, RefObject } from \"react\"\nimport type { Direction, PropGetter } from \"../../core\"\nimport type { UseDisclosureProps } from \"../../hooks/use-disclosure\"\nimport type { UsePopperProps } from \"../../hooks/use-popper\"\nimport type { Dict } from \"../../utils\"\nimport type { UsePopupAnimationProps } from \"./popover\"\nimport { useCallback, useEffect, useId, useRef } from \"react\"\nimport { useEnvironment, useSplitProps } from \"../../core\"\nimport { useDisclosure } from \"../../hooks/use-disclosure\"\nimport { useEventListener } from \"../../hooks/use-event-listener\"\nimport { useFocusOnShow } from \"../../hooks/use-focus\"\nimport { useOutsideClick } from \"../../hooks/use-outside-click\"\nimport { popperProps, usePopper } from \"../../hooks/use-popper\"\nimport {\n ariaAttr,\n assignRef,\n contains,\n dataAttr,\n focusTransfer,\n focusTrap,\n getEventRelatedTarget,\n handlerAll,\n mergeRefs,\n runKeyAction,\n scrollLock,\n setAttribute,\n useSafeLayoutEffect,\n useUnmountEffect,\n} from \"../../utils\"\n\nexport interface UsePopoverProps\n extends Omit<UseDisclosureProps, \"timing\">, UsePopperProps<\"button\"> {\n /**\n * If `true`, focus will be transferred to the first interactive element when the popover opens.\n *\n * @default true\n */\n autoFocus?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default false\n */\n blockScrollOnMount?: boolean\n /**\n * If `true`, the popover will close when you blur out it by clicking outside or tabbing out.\n *\n * @default true\n */\n closeOnBlur?: boolean\n /**\n * If `true`, the popover will hide on pressing Esc key.\n *\n * @default true\n */\n closeOnEsc?: boolean\n /**\n * If `true`, the popover will hide on scroll.\n *\n * @default false\n */\n closeOnScroll?: boolean\n /**\n * If `true`, the popover will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The `ref` of the element that should receive focus when the popover opens.\n */\n initialFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the popover will be modal.\n *\n * - scrolling is blocked.\n * - focus is trapped within the popover.\n *\n * @default false\n */\n modal?: boolean\n /**\n * If `true`, the popover will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end'\n */\n placement?: Direction\n /**\n * If `true`, the focus will be transferred to the popover content when the tab key is pressed.\n *\n * @default true\n */\n transferFocus?: boolean\n /**\n * Update the position of the floating element, re-rendering the component if required.\n */\n updateRef?: RefObject<() => void>\n}\n\nexport const usePopover = ({\n autoFocus = true,\n autoUpdate,\n modal = false,\n blockScrollOnMount = modal,\n closeOnBlur = true,\n closeOnEsc = true,\n closeOnScroll,\n defaultOpen,\n disabled,\n elements,\n flip,\n gutter,\n initialFocusRef,\n matchWidth,\n middleware,\n offset,\n open: openProp,\n openOnClick = true,\n placement = \"end\",\n platform,\n preventOverflow,\n strategy,\n transferFocus = true,\n transform,\n updateRef,\n whileElementsMounted,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n}: UsePopoverProps = {}) => {\n const { getDocument } = useEnvironment()\n const headerId = useId()\n const bodyId = useId()\n const contentId = useId()\n const anchorRef = useRef<HTMLElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const contentRef = useRef<HTMLElement>(null)\n const openTimeout = useRef<NodeJS.Timeout>(undefined)\n const closeTimeout = useRef<NodeJS.Timeout>(undefined)\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const { refs, update, getPopperProps } = usePopper<\"button\">({\n autoUpdate,\n elements,\n flip,\n gutter,\n matchWidth,\n middleware,\n offset,\n open,\n placement,\n platform,\n preventOverflow,\n strategy,\n transform,\n whileElementsMounted,\n })\n\n assignRef(updateRef, update)\n\n const onRestoreFocus = useCallback(() => {\n clearTimeout(closeTimeout.current)\n closeTimeout.current = setTimeout(() => {\n triggerRef.current?.focus()\n })\n }, [])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n runKeyAction(ev, {\n Escape: () => {\n if (!closeOnEsc) return\n\n onClose()\n onRestoreFocus()\n },\n })\n },\n [closeOnEsc, onClose, onRestoreFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLDivElement>) => {\n const relatedTarget = getEventRelatedTarget(ev)\n const popup = relatedTarget?.hasAttribute(\"data-popup\")\n\n if (contains(triggerRef.current, relatedTarget)) return\n if (contains(contentRef.current, relatedTarget)) return\n if (contains(contentRef.current, ev.target) && popup) return\n\n if (closeOnBlur) onClose()\n },\n [closeOnBlur, onClose],\n )\n\n useEventListener(getDocument(), \"scroll\", () => {\n if (open && closeOnScroll) onClose()\n })\n\n useFocusOnShow(contentRef, {\n focusTarget: initialFocusRef,\n shouldFocus: autoFocus,\n visible: open,\n })\n\n useOutsideClick({\n ref: [contentRef, triggerRef],\n enabled: open && closeOnBlur,\n handler: onClose,\n })\n\n useSafeLayoutEffect(() => {\n const el = contentRef.current\n const hasHeader = !!getDocument()?.getElementById(headerId)\n const hasBody = !!getDocument()?.getElementById(bodyId)\n\n if (el && hasHeader) setAttribute(el, \"aria-labelledby\", headerId)\n if (el && hasBody) setAttribute(el, \"aria-describedby\", bodyId)\n }, [open, headerId, bodyId])\n\n useEffect(() => {\n if (!open || !modal) return\n\n return focusTrap(contentRef.current)\n }, [open, modal])\n\n useEffect(() => {\n if (!open || !blockScrollOnMount) return\n\n return scrollLock(contentRef.current)\n }, [open, modal, blockScrollOnMount])\n\n useEffect(() => {\n if (!open || modal || !transferFocus) return\n\n return focusTransfer(contentRef.current, triggerRef.current)\n }, [open, modal, transferFocus])\n\n useUnmountEffect(() => {\n clearTimeout(openTimeout.current)\n clearTimeout(closeTimeout.current)\n })\n\n const getTriggerProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"dialog\",\n role: \"button\",\n ...props,\n ref: mergeRefs(ref, triggerRef, (node) => {\n if (anchorRef.current == null) refs.setReference(node)\n }),\n onBlur: handlerAll(props.onBlur, (ev) =>\n !contains(contentRef.current, getEventRelatedTarget(ev)) && closeOnBlur\n ? onClose()\n : void 0,\n ),\n onClick: handlerAll(\n props.onClick,\n !open ? (!disabled && openOnClick ? onOpen : undefined) : onClose,\n ),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n closeOnBlur,\n contentId,\n disabled,\n onClose,\n onKeyDown,\n onOpen,\n open,\n openOnClick,\n refs,\n ],\n )\n\n const getAnchorProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ref: mergeRefs(ref, anchorRef, refs.setReference),\n }),\n [refs.setReference],\n )\n\n const getPositionerProps: PropGetter = useCallback(\n (props) => getPopperProps(props),\n [getPopperProps],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n \"aria-hidden\": !open,\n \"aria-modal\": modal ? \"true\" : undefined,\n \"data-close\": dataAttr(!open),\n \"data-open\": dataAttr(open),\n \"data-popup\": dataAttr(true),\n role: \"dialog\",\n tabIndex: -1,\n ...props,\n ref: mergeRefs(ref, contentRef),\n onBlur: handlerAll(props.onBlur, onBlur),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [contentId, open, modal, onBlur, onKeyDown],\n )\n\n const getHeaderProps: PropGetter = useCallback(\n (props) => ({ id: headerId, ...props }),\n [headerId],\n )\n\n const getBodyProps: PropGetter = useCallback(\n (props) => ({ id: bodyId, ...props }),\n [bodyId],\n )\n\n const getFooterProps: PropGetter = useCallback((props) => ({ ...props }), [])\n\n const getCloseTriggerProps: PropGetter<\"button\"> = useCallback(\n (props = {}) => ({\n ...props,\n onClick: handlerAll(props.onClick, () => {\n onClose()\n onRestoreFocus()\n }),\n }),\n [onClose, onRestoreFocus],\n )\n\n return {\n open,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n onClose,\n onOpen,\n }\n}\n\nexport type UsePopoverReturn = ReturnType<typeof usePopover>\n\nexport const popoverProps: (\n | keyof UsePopoverProps\n | keyof UsePopupAnimationProps\n)[] = [\n ...popperProps,\n \"autoFocus\",\n \"transferFocus\",\n \"blockScrollOnMount\",\n \"closeOnBlur\",\n \"closeOnEsc\",\n \"closeOnScroll\",\n \"openOnClick\",\n \"disabled\",\n \"initialFocusRef\",\n \"modal\",\n \"updateRef\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"animationScheme\",\n \"duration\",\n]\n\nexport const usePopoverProps = <\n Y extends Dict = Dict,\n M extends keyof UsePopoverProps | keyof UsePopupAnimationProps =\n | keyof UsePopoverProps\n | keyof UsePopupAnimationProps,\n>(\n props: Y,\n omitKeys?: M[],\n) => {\n return useSplitProps(\n props,\n popoverProps.filter((key) => !omitKeys?.includes(key as M)),\n ) as unknown as [\n keyof UsePopoverProps | keyof UsePopupAnimationProps extends M\n ? UsePopoverProps & UsePopupAnimationProps\n : Omit<UsePopoverProps & UsePopupAnimationProps, M>,\n Omit<\n Y,\n keyof UsePopoverProps | keyof UsePopupAnimationProps extends M\n ? keyof UsePopoverProps | keyof UsePopupAnimationProps\n : Exclude<keyof UsePopoverProps | keyof UsePopupAnimationProps, M>\n >,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2GA,MAAa,cAAc,EACzB,YAAY,MACZ,YACA,QAAQ,OACR,qBAAqB,OACrB,cAAc,MACd,aAAa,MACb,eACA,aACA,UACA,UACA,MACA,QACA,iBACA,YACA,YACA,QACA,MAAM,UACN,cAAc,MACd,YAAY,OACZ,UACA,iBACA,UACA,gBAAgB,MAChB,WACA,WACA,sBACA,SAAS,aACT,QAAQ,eACW,EAAE,KAAK;CAC1B,MAAM,EAAE,gBAAgBA,6BAAAA,gBAAgB;CACxC,MAAM,YAAA,GAAA,MAAA,QAAkB;CACxB,MAAM,UAAA,GAAA,MAAA,QAAgB;CACtB,MAAM,aAAA,GAAA,MAAA,QAAmB;CACzB,MAAM,aAAA,GAAA,MAAA,QAAgC,KAAK;CAC3C,MAAM,cAAA,GAAA,MAAA,QAAuC,KAAK;CAClD,MAAM,cAAA,GAAA,MAAA,QAAiC,KAAK;CAC5C,MAAM,eAAA,GAAA,MAAA,QAAqC,KAAA,EAAU;CACrD,MAAM,gBAAA,GAAA,MAAA,QAAsC,KAAA,EAAU;CACtD,MAAM,EAAE,MAAM,SAAS,WAAWC,uBAAAA,cAAc;EAC9C;EACA,MAAM;EACN,SAAS;EACT,QAAQ;EACT,CAAC;CACF,MAAM,EAAE,MAAM,QAAQ,mBAAmBC,+BAAAA,UAAoB;EAC3D;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,YAAA,UAAU,WAAW,OAAO;CAE5B,MAAM,kBAAA,GAAA,MAAA,mBAAmC;EACvC,aAAa,aAAa,QAAQ;EAClC,aAAa,UAAU,iBAAiB;GACtC,WAAW,SAAS,OAAO;IAC3B;IACD,EAAE,CAAC;CAEN,MAAM,aAAA,GAAA,MAAA,cACH,OAAmC;EAClC,YAAA,aAAa,IAAI,EACf,cAAc;GACZ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ACA;CACA;CACD;AAED,MAAa,mBAMX,OACA,aACG;CACH,OAAOC,cAAAA,cACL,OACA,aAAa,QAAQ,QAAQ,CAAC,UAAU,SAAS,IAAS,CAAC,CAC5D"}
@@ -258,22 +258,23 @@ const useCombobox = (props = {}) => {
258
258
  if (open) return;
259
259
  activeDescendant.current = null;
260
260
  }, [open]);
261
- const getTriggerProps = (0, react.useCallback)(({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...props } = {}) => require_props.mergeProps({
262
- ref: triggerRef,
263
- "aria-controls": open ? contentId : void 0,
264
- "aria-disabled": (0, require_utils_index.utils_exports.ariaAttr)(!interactive),
265
- "aria-expanded": open,
266
- "aria-haspopup": "listbox",
267
- "aria-label": ariaLabel || ariaLabelProp,
268
- "aria-labelledby": (0, require_utils_index.utils_exports.cx)(ariaLabelledby, ariaLabelledbyProp),
269
- "data-disabled": (0, require_utils_index.utils_exports.dataAttr)(disabled),
270
- "data-readonly": (0, require_utils_index.utils_exports.dataAttr)(readOnly),
271
- role: "combobox",
272
- tabIndex: interactive ? 0 : -1
273
- }, rest, props, {
274
- onClick,
275
- onKeyDown
276
- })(), [
261
+ const getTriggerProps = (0, react.useCallback)(({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...props } = {}) => ({
262
+ ...require_props.mergeProps({
263
+ ref: triggerRef,
264
+ "aria-controls": open ? contentId : void 0,
265
+ "aria-disabled": (0, require_utils_index.utils_exports.ariaAttr)(!interactive),
266
+ "aria-expanded": open,
267
+ "aria-haspopup": "listbox",
268
+ "aria-label": ariaLabel || ariaLabelProp,
269
+ "aria-labelledby": (0, require_utils_index.utils_exports.cx)(ariaLabelledby, ariaLabelledbyProp),
270
+ "data-disabled": (0, require_utils_index.utils_exports.dataAttr)(disabled),
271
+ "data-readonly": (0, require_utils_index.utils_exports.dataAttr)(readOnly),
272
+ role: "combobox",
273
+ tabIndex: interactive ? 0 : -1
274
+ }, rest, props)({ mergeEvent: false }),
275
+ onClick: (0, require_utils_index.utils_exports.handlerAll)(props.onClick, rest.onClick, onClick),
276
+ onKeyDown: (0, require_utils_index.utils_exports.handlerAll)(props.onKeyDown, rest.onKeyDown, onKeyDown)
277
+ }), [
277
278
  open,
278
279
  contentId,
279
280
  interactive,
@@ -358,21 +359,21 @@ const useComboboxItem = ({ id, "aria-disabled": ariaDisabled, "data-disabled": d
358
359
  onSelect,
359
360
  value
360
361
  ]);
361
- const getItemProps = (0, react.useCallback)((props = {}) => require_props.mergeProps({
362
- id,
363
- ref: itemRef,
364
- "aria-disabled": ariaDisabled ?? (0, require_utils_index.utils_exports.ariaAttr)(disabled),
365
- "aria-selected": selected,
366
- "data-disabled": dataDisabled ?? (0, require_utils_index.utils_exports.dataAttr)(disabled),
367
- "data-selected": (0, require_utils_index.utils_exports.dataAttr)(selected),
368
- "data-value": value,
369
- role: "option",
370
- tabIndex: -1
371
- }, rest, props, {
372
- ref: register,
373
- onClick,
374
- onMouseMove: onActive
375
- })(), [
362
+ const getItemProps = (0, react.useCallback)((props = {}) => ({
363
+ ...require_props.mergeProps({
364
+ id,
365
+ ref: itemRef,
366
+ "aria-disabled": ariaDisabled ?? (0, require_utils_index.utils_exports.ariaAttr)(disabled),
367
+ "aria-selected": selected,
368
+ "data-disabled": dataDisabled ?? (0, require_utils_index.utils_exports.dataAttr)(disabled),
369
+ "data-selected": (0, require_utils_index.utils_exports.dataAttr)(selected),
370
+ "data-value": value,
371
+ role: "option",
372
+ tabIndex: -1
373
+ }, rest, props, { ref: register })({ mergeEvent: false }),
374
+ onClick: (0, require_utils_index.utils_exports.handlerAll)(props.onClick, rest.onClick, onClick),
375
+ onMouseMove: (0, require_utils_index.utils_exports.handlerAll)(props.onMouseMove, rest.onMouseMove, onActive)
376
+ }), [
376
377
  id,
377
378
  ariaDisabled,
378
379
  disabled,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["getValidChildren","isSomeElement","findChild","createDescendants","createContext","usePopoverProps","useEnvironment","useDisclosure","isComposing","mergeProps","mergeRefs"],"sources":["../../../../src/hooks/use-combobox/index.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n JSXElementConstructor,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n RefObject,\n} from \"react\"\nimport type { UsePopoverProps } from \"../../components/popover\"\nimport type { HTMLProps, PropGetter, SimpleDirection } from \"../../core\"\nimport type { Descendant } from \"../use-descendants\"\nimport type { UseDisclosureProps } from \"../use-disclosure\"\nimport { useCallback, useId, useMemo, useRef } from \"react\"\nimport scrollIntoView from \"scroll-into-view-if-needed\"\nimport { usePopoverProps } from \"../../components/popover\"\nimport { mergeProps, useEnvironment } from \"../../core\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n findChild,\n getValidChildren,\n handlerAll,\n isComposing,\n isSomeElement,\n isUndefined,\n mergeRefs,\n runKeyAction,\n useUpdateEffect,\n} from \"../../utils\"\nimport { createDescendants } from \"../use-descendants\"\nimport { useDisclosure } from \"../use-disclosure\"\n\ninterface ComboboxSharedItem extends Omit<HTMLProps, \"children\" | \"value\"> {\n label: ReactNode\n}\n\nexport interface ComboboxItemWithValue extends ComboboxSharedItem {\n query?: string\n value?: string\n}\n\nexport interface ComboboxItemWithItems extends ComboboxSharedItem {\n items: ComboboxItemWithValue[]\n}\n\nexport type ComboboxItem = ComboboxItemWithItems | ComboboxItemWithValue\n\nexport interface CreateComboboxItemOptions {\n Group: JSXElementConstructor<any>\n Label: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n}\n\nexport const createComboboxItem = (\n children: ReactNode,\n { Group, Label, Option }: CreateComboboxItemOptions,\n) => {\n const validChildren = getValidChildren(children)\n\n return validChildren\n .filter(\n ({ type }) => isSomeElement(type, Option) || isSomeElement(type, Group),\n )\n .map(({ type, props }) => {\n if (isSomeElement(type, Option)) {\n return { ...props, label: props.children }\n } else {\n const validChildren = getValidChildren(props.children)\n const label = findChild(validChildren, Label)\n\n return {\n ...props,\n items: validChildren\n .filter(({ type }) => isSomeElement(type, Option))\n .map(({ props }) => ({ ...props, label: props.children })),\n label: label?.props.children ?? props.label,\n }\n }\n })\n}\n\nexport interface CreateComboboxChildrenOptions {\n Group: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n Empty?: JSXElementConstructor<any>\n}\n\nexport const createComboboxChildren = (\n items: ComboboxItem[],\n { Empty, Group, Option }: CreateComboboxChildrenOptions,\n) => {\n return items.map((item, index) => {\n if (\"data-empty\" in item && Empty) {\n const { label, ...rest } = item\n\n return (\n <Empty key={index} {...rest}>\n {label}\n </Empty>\n )\n } else if (\"items\" in item) {\n const { items, label, ...rest } = item\n\n return (\n <Group key={index} label={label} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <Option key={index} {...rest}>\n {label}\n </Option>\n ))}\n </Group>\n )\n } else {\n const { label, ...rest } = item\n\n return (\n <Option key={index} {...rest}>\n {label}\n </Option>\n )\n }\n })\n}\n\nexport interface ComboboxDescendantProps {\n id: string\n closeOnSelect?: boolean\n value?: string\n}\nexport type ComboboxDescendant = Descendant<\n HTMLDivElement,\n ComboboxDescendantProps\n>\n\nconst {\n DescendantsContext: ComboboxDescendantsContext,\n useDescendant: useComboboxDescendant,\n useDescendantRegister: useComboboxDescendantRegister,\n useDescendants: useComboboxDescendants,\n} = createDescendants<HTMLDivElement, ComboboxDescendantProps>()\n\nexport {\n ComboboxDescendantsContext,\n useComboboxDescendant,\n useComboboxDescendantRegister,\n useComboboxDescendants,\n}\n\ninterface ComboboxContext extends Pick<\n UseComboboxReturn,\n \"onActiveDescendant\" | \"onClose\" | \"onSelect\"\n> {}\n\nconst [ComboboxContext, useComboboxContext] = createContext<ComboboxContext>({\n name: \"ComboboxContext\",\n})\n\ninterface ComboboxGroupContext extends Pick<\n UseComboboxGroupReturn,\n \"getLabelProps\"\n> {}\n\nconst [ComboboxGroupContext, useComboboxGroupContext] =\n createContext<ComboboxGroupContext>({\n name: \"ComboboxGroupContext\",\n })\n\nexport {\n ComboboxContext,\n ComboboxGroupContext,\n useComboboxContext,\n useComboboxGroupContext,\n}\n\nexport interface UseComboboxProps\n extends\n Omit<HTMLProps, \"onChange\">,\n Omit<UseDisclosureProps, \"timing\">,\n Omit<\n UsePopoverProps,\n \"autoFocus\" | \"initialFocusRef\" | \"modal\" | \"transform\" | \"updateRef\"\n > {\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the combobox will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The value to focus on when the combobox is opened.\n */\n initialFocusValue?: string\n /**\n * If `true`, the combobox will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * If `true`, the combobox will be opened when enter is pressed.\n *\n * @default true\n */\n openOnEnter?: boolean\n /**\n * If `true`, the combobox will be opened when space is pressed.\n *\n * @default true\n */\n openOnSpace?: boolean\n /**\n * If `true`, the combobox will be readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * The `ref` of the element that should receive focus when selected.\n */\n selectFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the item will be selected when space is pressed.\n *\n * @default true\n */\n selectOnSpace?: boolean\n /**\n * The callback invoked when value is selected.\n */\n onChange?: (value: string) => void\n}\n\nexport const useCombobox = (props: UseComboboxProps = {}) => {\n const [\n { matchWidth = true, ...popoverProps },\n {\n \"aria-label\": ariaLabelProp,\n \"aria-labelledby\": ariaLabelledbyProp,\n closeOnSelect: closeOnSelectProp = true,\n defaultOpen,\n disabled,\n initialFocusValue,\n open: openProp,\n openOnClick = true,\n openOnEnter = true,\n openOnSpace = true,\n readOnly,\n selectFocusRef,\n selectOnSpace = true,\n onChange: onChangeProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n ...rest\n },\n ] = usePopoverProps(props, [\n \"disabled\",\n \"open\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"openOnClick\",\n ])\n const { getWindow } = useEnvironment()\n const interactive = !(readOnly || disabled)\n const triggerRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const contentId = useId()\n const descendants = useComboboxDescendants()\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const activeDescendant = useRef<ComboboxDescendant | null>(null)\n const mergedPopoverProps = useMemo<UsePopoverProps>(\n () => ({\n autoFocus: false,\n matchWidth,\n openOnClick: false,\n ...popoverProps,\n disabled: !interactive,\n open,\n onClose,\n onOpen,\n }),\n [interactive, matchWidth, onClose, onOpen, open, popoverProps],\n )\n\n const onSelect = useCallback(\n (value?: string, closeOnSelect = closeOnSelectProp) => {\n const ref = selectFocusRef ?? triggerRef\n\n ref.current?.focus()\n\n if (!interactive || isUndefined(value)) return\n\n onChangeProp?.(value)\n\n if (!closeOnSelect) return\n\n onClose()\n },\n [closeOnSelectProp, interactive, onChangeProp, onClose, selectFocusRef],\n )\n\n const onScrollIntoView = useCallback(\n (descendant?: ComboboxDescendant, block: SimpleDirection = \"start\") => {\n if (!contentRef.current || !descendant) return\n\n const style = getWindow()?.getComputedStyle(contentRef.current)\n const padding =\n block === \"start\" ? style?.paddingBlockStart : style?.paddingBlockEnd\n const value = parseInt(padding ?? \"0px\")\n\n scrollIntoView(descendant.node, {\n behavior: (actions) =>\n actions.forEach(({ el, top }) => {\n el.scrollTop = block === \"start\" ? top - value : top + value\n }),\n block,\n boundary: contentRef.current,\n inline: \"nearest\",\n scrollMode: \"if-needed\",\n })\n },\n [getWindow],\n )\n\n const onActiveDescendant = useCallback(\n (descendant?: ComboboxDescendant) => {\n if (!triggerRef.current || !descendant || disabled) return\n\n triggerRef.current.setAttribute(\"aria-activedescendant\", descendant.id)\n\n activeDescendant.current = descendant\n\n descendants.active(descendant)\n },\n [descendants, disabled],\n )\n\n const onOpenWithActiveDescendant = useCallback(\n (\n getFallbackDescendant: () => ComboboxDescendant | undefined,\n block: SimpleDirection = \"start\",\n ) => {\n onOpen()\n\n setTimeout(() => {\n if (!initialFocusValue) {\n const descendant = getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n } else {\n const values = descendants.values()\n const descendant =\n values.find(({ value }) => initialFocusValue === value) ??\n getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n }\n })\n },\n [\n descendants,\n initialFocusValue,\n onActiveDescendant,\n onOpen,\n onScrollIntoView,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n\n if (!open) {\n if (openOnClick)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n onClose()\n }\n },\n [\n descendants,\n disabled,\n onClose,\n onOpenWithActiveDescendant,\n open,\n openOnClick,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (disabled || isComposing(ev)) return\n\n runKeyAction(\n ev,\n {\n ArrowDown: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledNextValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"start\" : \"end\",\n )\n } else {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n }\n },\n ArrowUp: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledLastValue, \"end\")\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledPrevValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"end\" : \"start\",\n )\n } else {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n }\n },\n End: (ev) => {\n ev.preventDefault()\n\n if (!open) return\n\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n },\n Enter: (ev) => {\n if (!open) {\n if (!openOnEnter) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n Home: (ev) => {\n if (!open) return\n\n ev.preventDefault()\n\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n },\n Space: (ev) => {\n if (!open) {\n if (!openOnSpace) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current || !selectOnSpace) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n disabled,\n open,\n onOpenWithActiveDescendant,\n descendants,\n onActiveDescendant,\n onScrollIntoView,\n openOnEnter,\n onSelect,\n openOnSpace,\n selectOnSpace,\n ],\n )\n\n useUpdateEffect(() => {\n if (open) return\n\n activeDescendant.current = null\n }, [open])\n\n const getTriggerProps: PropGetter = useCallback(\n ({\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n } = {}) =>\n mergeProps(\n {\n ref: triggerRef,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"listbox\",\n \"aria-label\": ariaLabel || ariaLabelProp,\n \"aria-labelledby\": cx(ariaLabelledby, ariaLabelledbyProp),\n \"data-disabled\": dataAttr(disabled),\n \"data-readonly\": dataAttr(readOnly),\n role: \"combobox\",\n tabIndex: interactive ? 0 : -1,\n },\n rest,\n props,\n { onClick, onKeyDown },\n )(),\n [\n open,\n contentId,\n interactive,\n ariaLabelledbyProp,\n disabled,\n readOnly,\n ariaLabelProp,\n rest,\n onClick,\n onKeyDown,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n role: \"listbox\",\n ...props,\n ref: mergeRefs(ref, contentRef),\n onKeyDown: handlerAll(props.onKeyDown),\n }),\n [contentId],\n )\n\n const getSeparatorProps: PropGetter = useCallback(\n (props) => ({ role: \"separator\", ...props }),\n [],\n )\n\n return {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps: mergedPopoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onScrollIntoView,\n onSelect,\n }\n}\n\nexport type UseComboboxReturn = ReturnType<typeof useCombobox>\n\nexport interface UseComboboxGroupProps extends HTMLProps {}\n\nexport const useComboboxGroup = ({\n \"aria-labelledby\": ariaLabelledbyProp,\n ...rest\n}: UseComboboxGroupProps = {}) => {\n const labelId = useId()\n\n const getGroupProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) =>\n mergeProps(\n {\n \"aria-labelledby\": cx(ariaLabelledbyProp, ariaLabelledby, labelId),\n role: \"group\",\n },\n rest,\n props,\n )(),\n [ariaLabelledbyProp, labelId, rest],\n )\n\n const getLabelProps: PropGetter<\"span\"> = useCallback(\n (props) => ({ id: labelId, role: \"presentation\", ...props }),\n [labelId],\n )\n\n return { getGroupProps, getLabelProps }\n}\n\nexport type UseComboboxGroupReturn = ReturnType<typeof useComboboxGroup>\n\nexport interface UseComboboxItemProps extends HTMLProps {\n /**\n * If `true`, the item will be closed when selected.\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the item will be selected.\n */\n selected?: boolean\n /**\n * The value of the item.\n */\n value?: string\n}\n\nexport const useComboboxItem = ({\n id,\n \"aria-disabled\": ariaDisabled,\n \"data-disabled\": dataDisabled,\n closeOnSelect,\n disabled = false,\n selected = false,\n value,\n ...rest\n}: UseComboboxItemProps = {}) => {\n const uuid = useId()\n const itemRef = useRef<HTMLDivElement>(null)\n const { onActiveDescendant, onClose, onSelect } = useComboboxContext()\n\n id ??= uuid\n\n const { descendants, register } = useComboboxDescendant({\n id,\n closeOnSelect,\n disabled,\n value,\n })\n\n const onActive = useCallback(() => {\n if (disabled) return\n\n const current = descendants.value(itemRef.current)\n\n onActiveDescendant(current)\n }, [descendants, disabled, onActiveDescendant])\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n ev.preventDefault()\n\n if (disabled) return\n\n onSelect(value, closeOnSelect)\n },\n [closeOnSelect, disabled, onSelect, value],\n )\n\n const getItemProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n {\n id,\n ref: itemRef,\n \"aria-disabled\": ariaDisabled ?? ariaAttr(disabled),\n \"aria-selected\": selected,\n \"data-disabled\": dataDisabled ?? dataAttr(disabled),\n \"data-selected\": dataAttr(selected),\n \"data-value\": value,\n role: \"option\",\n tabIndex: -1,\n },\n rest,\n props,\n { ref: register, onClick, onMouseMove: onActive },\n )(),\n [\n id,\n ariaDisabled,\n disabled,\n selected,\n dataDisabled,\n value,\n rest,\n register,\n onClick,\n onActive,\n ],\n )\n\n const getIndicatorProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ style: { opacity: selected ? 1 : 0 } }, props)(),\n [selected],\n )\n\n return {\n descendants,\n disabled,\n selected,\n getIndicatorProps,\n getItemProps,\n onActiveDescendant,\n onClose,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,MAAa,sBACX,UACA,EAAE,OAAO,OAAO,aACb;CAGH,OAFsBA,iBAAAA,iBAAiB,SAEnB,CACjB,QACE,EAAE,WAAWC,iBAAAA,cAAc,MAAM,OAAO,IAAIA,iBAAAA,cAAc,MAAM,MAAM,CACxE,CACA,KAAK,EAAE,MAAM,YAAY;EACxB,IAAIA,iBAAAA,cAAc,MAAM,OAAO,E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TA,cAAAA,WACE;EACE;EACA,KAAK;EACL,iBAAiB,iBAAA,GAAA,oBAAA,cAAA,UAAyB,SAAS;EACnD,iBAAiB;EACjB,iBAAiB,iBAAA,GAAA,oBAAA,cAAA,UAAyB,SAAS;EACnD,kBAAA,GAAA,oBAAA,cAAA,UAA0B,SAAS;EACnC,cAAc;EACd,MAAM;EACN,UAAU;EACX,EACD,MACA,OACA;EAAE,KAAK;EAAU;EAAS,aAAa;EAAU,CAClD,EAAE,EACL;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;CAQD,OAAO;EACL;EACA;EACA;EACA,oBAAA,GAAA,MAAA,cATC,QAAQ,EAAE,KACTA,cAAAA,WAAW,EAAE,OAAO,EAAE,SAAS,WAAW,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,EAC/D,CAAC,SAAS,CAOO;EACjB;EACA;EACA;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["getValidChildren","isSomeElement","findChild","createDescendants","createContext","usePopoverProps","useEnvironment","useDisclosure","isComposing","mergeProps","mergeRefs"],"sources":["../../../../src/hooks/use-combobox/index.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n JSXElementConstructor,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n RefObject,\n} from \"react\"\nimport type { UsePopoverProps } from \"../../components/popover\"\nimport type { HTMLProps, PropGetter, SimpleDirection } from \"../../core\"\nimport type { Descendant } from \"../use-descendants\"\nimport type { UseDisclosureProps } from \"../use-disclosure\"\nimport { useCallback, useId, useMemo, useRef } from \"react\"\nimport scrollIntoView from \"scroll-into-view-if-needed\"\nimport { usePopoverProps } from \"../../components/popover\"\nimport { mergeProps, useEnvironment } from \"../../core\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n findChild,\n getValidChildren,\n handlerAll,\n isComposing,\n isSomeElement,\n isUndefined,\n mergeRefs,\n runKeyAction,\n useUpdateEffect,\n} from \"../../utils\"\nimport { createDescendants } from \"../use-descendants\"\nimport { useDisclosure } from \"../use-disclosure\"\n\ninterface ComboboxSharedItem extends Omit<HTMLProps, \"children\" | \"value\"> {\n label: ReactNode\n}\n\nexport interface ComboboxItemWithValue extends ComboboxSharedItem {\n query?: string\n value?: string\n}\n\nexport interface ComboboxItemWithItems extends ComboboxSharedItem {\n items: ComboboxItemWithValue[]\n}\n\nexport type ComboboxItem = ComboboxItemWithItems | ComboboxItemWithValue\n\nexport interface CreateComboboxItemOptions {\n Group: JSXElementConstructor<any>\n Label: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n}\n\nexport const createComboboxItem = (\n children: ReactNode,\n { Group, Label, Option }: CreateComboboxItemOptions,\n) => {\n const validChildren = getValidChildren(children)\n\n return validChildren\n .filter(\n ({ type }) => isSomeElement(type, Option) || isSomeElement(type, Group),\n )\n .map(({ type, props }) => {\n if (isSomeElement(type, Option)) {\n return { ...props, label: props.children }\n } else {\n const validChildren = getValidChildren(props.children)\n const label = findChild(validChildren, Label)\n\n return {\n ...props,\n items: validChildren\n .filter(({ type }) => isSomeElement(type, Option))\n .map(({ props }) => ({ ...props, label: props.children })),\n label: label?.props.children ?? props.label,\n }\n }\n })\n}\n\nexport interface CreateComboboxChildrenOptions {\n Group: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n Empty?: JSXElementConstructor<any>\n}\n\nexport const createComboboxChildren = (\n items: ComboboxItem[],\n { Empty, Group, Option }: CreateComboboxChildrenOptions,\n) => {\n return items.map((item, index) => {\n if (\"data-empty\" in item && Empty) {\n const { label, ...rest } = item\n\n return (\n <Empty key={index} {...rest}>\n {label}\n </Empty>\n )\n } else if (\"items\" in item) {\n const { items, label, ...rest } = item\n\n return (\n <Group key={index} label={label} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <Option key={index} {...rest}>\n {label}\n </Option>\n ))}\n </Group>\n )\n } else {\n const { label, ...rest } = item\n\n return (\n <Option key={index} {...rest}>\n {label}\n </Option>\n )\n }\n })\n}\n\nexport interface ComboboxDescendantProps {\n id: string\n closeOnSelect?: boolean\n value?: string\n}\nexport type ComboboxDescendant = Descendant<\n HTMLDivElement,\n ComboboxDescendantProps\n>\n\nconst {\n DescendantsContext: ComboboxDescendantsContext,\n useDescendant: useComboboxDescendant,\n useDescendantRegister: useComboboxDescendantRegister,\n useDescendants: useComboboxDescendants,\n} = createDescendants<HTMLDivElement, ComboboxDescendantProps>()\n\nexport {\n ComboboxDescendantsContext,\n useComboboxDescendant,\n useComboboxDescendantRegister,\n useComboboxDescendants,\n}\n\ninterface ComboboxContext extends Pick<\n UseComboboxReturn,\n \"onActiveDescendant\" | \"onClose\" | \"onSelect\"\n> {}\n\nconst [ComboboxContext, useComboboxContext] = createContext<ComboboxContext>({\n name: \"ComboboxContext\",\n})\n\ninterface ComboboxGroupContext extends Pick<\n UseComboboxGroupReturn,\n \"getLabelProps\"\n> {}\n\nconst [ComboboxGroupContext, useComboboxGroupContext] =\n createContext<ComboboxGroupContext>({\n name: \"ComboboxGroupContext\",\n })\n\nexport {\n ComboboxContext,\n ComboboxGroupContext,\n useComboboxContext,\n useComboboxGroupContext,\n}\n\nexport interface UseComboboxProps\n extends\n Omit<HTMLProps, \"onChange\">,\n Omit<UseDisclosureProps, \"timing\">,\n Omit<\n UsePopoverProps,\n \"autoFocus\" | \"initialFocusRef\" | \"modal\" | \"transform\" | \"updateRef\"\n > {\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the combobox will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The value to focus on when the combobox is opened.\n */\n initialFocusValue?: string\n /**\n * If `true`, the combobox will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * If `true`, the combobox will be opened when enter is pressed.\n *\n * @default true\n */\n openOnEnter?: boolean\n /**\n * If `true`, the combobox will be opened when space is pressed.\n *\n * @default true\n */\n openOnSpace?: boolean\n /**\n * If `true`, the combobox will be readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * The `ref` of the element that should receive focus when selected.\n */\n selectFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the item will be selected when space is pressed.\n *\n * @default true\n */\n selectOnSpace?: boolean\n /**\n * The callback invoked when value is selected.\n */\n onChange?: (value: string) => void\n}\n\nexport const useCombobox = (props: UseComboboxProps = {}) => {\n const [\n { matchWidth = true, ...popoverProps },\n {\n \"aria-label\": ariaLabelProp,\n \"aria-labelledby\": ariaLabelledbyProp,\n closeOnSelect: closeOnSelectProp = true,\n defaultOpen,\n disabled,\n initialFocusValue,\n open: openProp,\n openOnClick = true,\n openOnEnter = true,\n openOnSpace = true,\n readOnly,\n selectFocusRef,\n selectOnSpace = true,\n onChange: onChangeProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n ...rest\n },\n ] = usePopoverProps(props, [\n \"disabled\",\n \"open\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"openOnClick\",\n ])\n const { getWindow } = useEnvironment()\n const interactive = !(readOnly || disabled)\n const triggerRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const contentId = useId()\n const descendants = useComboboxDescendants()\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const activeDescendant = useRef<ComboboxDescendant | null>(null)\n const mergedPopoverProps = useMemo<UsePopoverProps>(\n () => ({\n autoFocus: false,\n matchWidth,\n openOnClick: false,\n ...popoverProps,\n disabled: !interactive,\n open,\n onClose,\n onOpen,\n }),\n [interactive, matchWidth, onClose, onOpen, open, popoverProps],\n )\n\n const onSelect = useCallback(\n (value?: string, closeOnSelect = closeOnSelectProp) => {\n const ref = selectFocusRef ?? triggerRef\n\n ref.current?.focus()\n\n if (!interactive || isUndefined(value)) return\n\n onChangeProp?.(value)\n\n if (!closeOnSelect) return\n\n onClose()\n },\n [closeOnSelectProp, interactive, onChangeProp, onClose, selectFocusRef],\n )\n\n const onScrollIntoView = useCallback(\n (descendant?: ComboboxDescendant, block: SimpleDirection = \"start\") => {\n if (!contentRef.current || !descendant) return\n\n const style = getWindow()?.getComputedStyle(contentRef.current)\n const padding =\n block === \"start\" ? style?.paddingBlockStart : style?.paddingBlockEnd\n const value = parseInt(padding ?? \"0px\")\n\n scrollIntoView(descendant.node, {\n behavior: (actions) =>\n actions.forEach(({ el, top }) => {\n el.scrollTop = block === \"start\" ? top - value : top + value\n }),\n block,\n boundary: contentRef.current,\n inline: \"nearest\",\n scrollMode: \"if-needed\",\n })\n },\n [getWindow],\n )\n\n const onActiveDescendant = useCallback(\n (descendant?: ComboboxDescendant) => {\n if (!triggerRef.current || !descendant || disabled) return\n\n triggerRef.current.setAttribute(\"aria-activedescendant\", descendant.id)\n\n activeDescendant.current = descendant\n\n descendants.active(descendant)\n },\n [descendants, disabled],\n )\n\n const onOpenWithActiveDescendant = useCallback(\n (\n getFallbackDescendant: () => ComboboxDescendant | undefined,\n block: SimpleDirection = \"start\",\n ) => {\n onOpen()\n\n setTimeout(() => {\n if (!initialFocusValue) {\n const descendant = getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n } else {\n const values = descendants.values()\n const descendant =\n values.find(({ value }) => initialFocusValue === value) ??\n getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n }\n })\n },\n [\n descendants,\n initialFocusValue,\n onActiveDescendant,\n onOpen,\n onScrollIntoView,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n\n if (!open) {\n if (openOnClick)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n onClose()\n }\n },\n [\n descendants,\n disabled,\n onClose,\n onOpenWithActiveDescendant,\n open,\n openOnClick,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (disabled || isComposing(ev)) return\n\n runKeyAction(\n ev,\n {\n ArrowDown: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledNextValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"start\" : \"end\",\n )\n } else {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n }\n },\n ArrowUp: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledLastValue, \"end\")\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledPrevValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"end\" : \"start\",\n )\n } else {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n }\n },\n End: (ev) => {\n ev.preventDefault()\n\n if (!open) return\n\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n },\n Enter: (ev) => {\n if (!open) {\n if (!openOnEnter) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n Home: (ev) => {\n if (!open) return\n\n ev.preventDefault()\n\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n },\n Space: (ev) => {\n if (!open) {\n if (!openOnSpace) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current || !selectOnSpace) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n disabled,\n open,\n onOpenWithActiveDescendant,\n descendants,\n onActiveDescendant,\n onScrollIntoView,\n openOnEnter,\n onSelect,\n openOnSpace,\n selectOnSpace,\n ],\n )\n\n useUpdateEffect(() => {\n if (open) return\n\n activeDescendant.current = null\n }, [open])\n\n const getTriggerProps: PropGetter = useCallback(\n ({\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n } = {}) => ({\n ...mergeProps(\n {\n ref: triggerRef,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"listbox\",\n \"aria-label\": ariaLabel || ariaLabelProp,\n \"aria-labelledby\": cx(ariaLabelledby, ariaLabelledbyProp),\n \"data-disabled\": dataAttr(disabled),\n \"data-readonly\": dataAttr(readOnly),\n role: \"combobox\",\n tabIndex: interactive ? 0 : -1,\n },\n rest,\n props,\n )({ mergeEvent: false }),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n onKeyDown: handlerAll(props.onKeyDown, rest.onKeyDown, onKeyDown),\n }),\n [\n open,\n contentId,\n interactive,\n ariaLabelledbyProp,\n disabled,\n readOnly,\n ariaLabelProp,\n rest,\n onClick,\n onKeyDown,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n role: \"listbox\",\n ...props,\n ref: mergeRefs(ref, contentRef),\n onKeyDown: handlerAll(props.onKeyDown),\n }),\n [contentId],\n )\n\n const getSeparatorProps: PropGetter = useCallback(\n (props) => ({ role: \"separator\", ...props }),\n [],\n )\n\n return {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps: mergedPopoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onScrollIntoView,\n onSelect,\n }\n}\n\nexport type UseComboboxReturn = ReturnType<typeof useCombobox>\n\nexport interface UseComboboxGroupProps extends HTMLProps {}\n\nexport const useComboboxGroup = ({\n \"aria-labelledby\": ariaLabelledbyProp,\n ...rest\n}: UseComboboxGroupProps = {}) => {\n const labelId = useId()\n\n const getGroupProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) =>\n mergeProps(\n {\n \"aria-labelledby\": cx(ariaLabelledbyProp, ariaLabelledby, labelId),\n role: \"group\",\n },\n rest,\n props,\n )(),\n [ariaLabelledbyProp, labelId, rest],\n )\n\n const getLabelProps: PropGetter<\"span\"> = useCallback(\n (props) => ({ id: labelId, role: \"presentation\", ...props }),\n [labelId],\n )\n\n return { getGroupProps, getLabelProps }\n}\n\nexport type UseComboboxGroupReturn = ReturnType<typeof useComboboxGroup>\n\nexport interface UseComboboxItemProps extends HTMLProps {\n /**\n * If `true`, the item will be closed when selected.\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the item will be selected.\n */\n selected?: boolean\n /**\n * The value of the item.\n */\n value?: string\n}\n\nexport const useComboboxItem = ({\n id,\n \"aria-disabled\": ariaDisabled,\n \"data-disabled\": dataDisabled,\n closeOnSelect,\n disabled = false,\n selected = false,\n value,\n ...rest\n}: UseComboboxItemProps = {}) => {\n const uuid = useId()\n const itemRef = useRef<HTMLDivElement>(null)\n const { onActiveDescendant, onClose, onSelect } = useComboboxContext()\n\n id ??= uuid\n\n const { descendants, register } = useComboboxDescendant({\n id,\n closeOnSelect,\n disabled,\n value,\n })\n\n const onActive = useCallback(() => {\n if (disabled) return\n\n const current = descendants.value(itemRef.current)\n\n onActiveDescendant(current)\n }, [descendants, disabled, onActiveDescendant])\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n ev.preventDefault()\n\n if (disabled) return\n\n onSelect(value, closeOnSelect)\n },\n [closeOnSelect, disabled, onSelect, value],\n )\n\n const getItemProps: PropGetter = useCallback(\n (props = {}) => ({\n ...mergeProps(\n {\n id,\n ref: itemRef,\n \"aria-disabled\": ariaDisabled ?? ariaAttr(disabled),\n \"aria-selected\": selected,\n \"data-disabled\": dataDisabled ?? dataAttr(disabled),\n \"data-selected\": dataAttr(selected),\n \"data-value\": value,\n role: \"option\",\n tabIndex: -1,\n },\n rest,\n props,\n { ref: register },\n )({ mergeEvent: false }),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n onMouseMove: handlerAll(props.onMouseMove, rest.onMouseMove, onActive),\n }),\n [\n id,\n ariaDisabled,\n disabled,\n selected,\n dataDisabled,\n value,\n rest,\n register,\n onClick,\n onActive,\n ],\n )\n\n const getIndicatorProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ style: { opacity: selected ? 1 : 0 } }, props)(),\n [selected],\n )\n\n return {\n descendants,\n disabled,\n selected,\n getIndicatorProps,\n getItemProps,\n onActiveDescendant,\n onClose,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,MAAa,sBACX,UACA,EAAE,OAAO,OAAO,aACb;CAGH,OAFsBA,iBAAAA,iBAAiB,SAEnB,CACjB,QACE,EAAE,WAAWC,iBAAAA,cAAc,MAAM,OAAO,IAAIA,iBAAAA,cAAc,MAAM,MAAM,CACxE,CACA,KAAK,EAAE,MAAM,YAAY;EACxB,IAAIA,iBAAAA,cAAc,MAAM,OAAO,EAC7B,OAAO;GAAE,GAAG;GAAO,OAAO,MAAM;GAAU;OACrC;GACL,MAAM,gBAAgBD,iBAAAA,iBAAiB,MAAM,SAAS;GACtD,MAAM,QAAQE,iBAAAA,UAAU,eAAe,MAAM;GAE7C,OAAO;IACL,GAAG;IACH,OAAO,cACJ,QAAQ,EAAE,WAAWD,iBAAAA,cAAc,MAAM,OAAO,CAAC,CACjD,KAAK,EAAE,aAAa;KAAE,GAAG;KAAO,OAAO,MAAM;KAAU,EAAE;IAC5D,OAAO,OAAO,MAAM,YAAY,MAAM;IACvC;;GAEH;;AASN,MAAa,0BACX,OACA,EAAE,OAAO,OAA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U;GACX,EACD,MACA,OACA,EAAE,KAAK,UAAU,CAClB,CAAC,EAAE,YAAY,OAAO,CAAC;EACxB,UAAA,GAAA,oBAAA,cAAA,YAAoB,MAAM,SAAS,KAAK,SAAS,QAAQ;EACzD,cAAA,GAAA,oBAAA,cAAA,YAAwB,MAAM,aAAa,KAAK,aAAa,SAAS;EACvE,GACD;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;CAQD,OAAO;EACL;EACA;EACA;EACA,oBAAA,GAAA,MAAA,cATC,QAAQ,EAAE,KACTA,cAAAA,WAAW,EAAE,OAAO,EAAE,SAAS,WAAW,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,EAC/D,CAAC,SAAS,CAOO;EACjB;EACA;EACA;EACD"}
@@ -60,10 +60,7 @@ const useChartXAxis = ({ type, name, allowDataOverflow, allowDecimals, allowDupl
60
60
  };
61
61
  }, [labelProp]);
62
62
  return {
63
- getRootProps: useCallback((props) => ({
64
- ...rest,
65
- ...props
66
- }), [rest]),
63
+ getRootProps: useCallback((props) => mergeProps(rest, props)(), [rest]),
67
64
  getXAxisProps: useCallback((props) => ({
68
65
  type,
69
66
  name,
@@ -164,10 +161,7 @@ const useChartYAxis = ({ type, name, allowDataOverflow, allowDecimals = true, al
164
161
  };
165
162
  }, [labelProp, orientation]);
166
163
  return {
167
- getRootProps: useCallback((props) => ({
168
- ...rest,
169
- ...props
170
- }), [rest]),
164
+ getRootProps: useCallback((props) => mergeProps(rest, props)(), [rest]),
171
165
  getYAxisProps: useCallback((props = {}) => ({
172
166
  type,
173
167
  name,
@@ -268,10 +262,7 @@ const useChartLine = ({ type = "monotone", name, activeDot: activeDotProp, anima
268
262
  ...(0, utils_exports.isObject)(activeDotProp) ? activeDotProp : {}
269
263
  };
270
264
  }, [activeDotProp]);
271
- const getRootProps = useCallback((props) => ({
272
- ...rest,
273
- ...props
274
- }), [rest]);
265
+ const getRootProps = useCallback((props) => mergeProps(rest, props)(), [rest]);
275
266
  return {
276
267
  getLineProps: useCallback(({ dataKey = dataKeyProp, ...props } = {}) => ({
277
268
  type,
@@ -364,10 +355,7 @@ const useChartArea = ({ type = "monotone", name, activeDot: activeDotProp, anima
364
355
  ...(0, utils_exports.isObject)(activeDotProp) ? activeDotProp : {}
365
356
  };
366
357
  }, [activeDotProp]);
367
- const getRootProps = useCallback((props) => ({
368
- ...rest,
369
- ...props
370
- }), [rest]);
358
+ const getRootProps = useCallback((props) => mergeProps(rest, props)(), [rest]);
371
359
  return {
372
360
  getAreaProps: useCallback(({ dataKey = dataKeyProp, ...props } = {}) => ({
373
361
  type,
@@ -446,10 +434,7 @@ const useChartBar = ({ name, activeBar, animationBegin, animationDuration, anima
446
434
  ...(0, utils_exports.isObject)(labelProp) ? labelProp : {}
447
435
  };
448
436
  }, [labelProp]);
449
- const getRootProps = useCallback((props) => ({
450
- ...rest,
451
- ...props
452
- }), [rest]);
437
+ const getRootProps = useCallback((props) => mergeProps(rest, props)(), [rest]);
453
438
  return {
454
439
  getBarProps: useCallback(({ dataKey = dataKeyProp, ...props } = {}) => ({
455
440
  name,
@@ -528,10 +513,7 @@ const useChartReferenceLine = ({ children, ifOverflow, label: labelProp = false,
528
513
  ...(0, utils_exports.isObject)(labelProp) ? labelProp : {}
529
514
  };
530
515
  }, [labelProp]);
531
- const getRootProps = useCallback((props) => ({
532
- ...rest,
533
- ...props
534
- }), [rest]);
516
+ const getRootProps = useCallback((props) => mergeProps(rest, props)(), [rest]);
535
517
  return {
536
518
  getReferenceLineProps: useCallback((props) => ({
537
519
  children,
@@ -569,10 +551,7 @@ const useChartReferenceLine = ({ children, ifOverflow, label: labelProp = false,
569
551
  };
570
552
  };
571
553
  const useChartGrid = ({ horizontal, horizontalCoordinatesGenerator, horizontalFill, horizontalPoints, horizontalValues, syncWithTicks, vertical = false, verticalCoordinatesGenerator, verticalFill, verticalPoints, verticalValues, x, xAxisId, y, yAxisId, zIndex, ...rest } = {}) => {
572
- const getRootProps = useCallback((props) => ({
573
- ...rest,
574
- ...props
575
- }), [rest]);
554
+ const getRootProps = useCallback((props) => mergeProps(rest, props)(), [rest]);
576
555
  return {
577
556
  getGridProps: useCallback((props) => ({
578
557
  horizontal,
@@ -1 +1 @@
1
- {"version":3,"file":"use-cartesian-chart.js","names":[],"sources":["../../../../src/components/chart/use-cartesian-chart.ts"],"sourcesContent":["\"use client\"\n\nimport type {\n AreaProps,\n BarProps,\n CartesianGridProps,\n LineProps,\n ReferenceLineProps,\n XAxisProps,\n YAxisProps,\n} from \"recharts\"\nimport type { CartesianChartProps } from \"recharts/types/util/types\"\nimport type { Dict, Merge } from \"../../utils\"\nimport { isValidElement, useCallback, useMemo } from \"react\"\nimport {\n type HTMLProps,\n mergeProps,\n type PropGetter,\n type SimpleDirection,\n} from \"../../core\"\nimport { dataAttr, isFunction, isObject, isUndefined } from \"../../utils\"\nimport { useChartContext } from \"./use-chart\"\n\nexport interface UseCartesianChartProps<Y extends Dict>\n extends\n HTMLProps,\n Pick<\n CartesianChartProps,\n | \"accessibilityLayer\"\n | \"compact\"\n | \"layout\"\n | \"responsive\"\n | \"syncId\"\n | \"syncMethod\"\n > {\n /**\n * Chart data.\n */\n data?: Y[]\n}\n\nexport const useCartesianChart = <Y extends Dict>({\n accessibilityLayer = true,\n compact,\n data,\n layout = \"horizontal\",\n responsive,\n syncId,\n syncMethod,\n ...rest\n}: UseCartesianChartProps<Y>) => {\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps(rest, props)(),\n [rest],\n )\n\n const getChartProps: PropGetter<CartesianChartProps> = useCallback(\n (props) => ({\n accessibilityLayer,\n compact,\n data,\n layout,\n margin: { left: 16, right: 16 },\n responsive,\n syncId,\n syncMethod,\n ...props,\n }),\n [accessibilityLayer, compact, data, layout, responsive, syncId, syncMethod],\n )\n\n return {\n getChartProps,\n getRootProps,\n }\n}\n\nexport type UseCartesianChartReturn<Y extends Dict> = ReturnType<\n typeof useCartesianChart<Y>\n>\n\nexport interface UseChartXAxisProps extends Merge<\n HTMLProps<\"svg\">,\n Pick<\n XAxisProps,\n | \"allowDataOverflow\"\n | \"allowDecimals\"\n | \"allowDuplicatedCategory\"\n | \"angle\"\n | \"axisLine\"\n | \"dataKey\"\n | \"domain\"\n | \"height\"\n | \"hide\"\n | \"includeHidden\"\n | \"interval\"\n | \"label\"\n | \"minTickGap\"\n | \"mirror\"\n | \"name\"\n | \"niceTicks\"\n | \"orientation\"\n | \"padding\"\n | \"range\"\n | \"reversed\"\n | \"scale\"\n | \"tick\"\n | \"tickCount\"\n | \"tickFormatter\"\n | \"tickLine\"\n | \"tickMargin\"\n | \"ticks\"\n | \"tickSize\"\n | \"type\"\n | \"unit\"\n | \"xAxisId\"\n >\n> {}\n\nexport const useChartXAxis = ({\n type,\n name,\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine = false,\n children,\n dataKey,\n domain,\n height,\n hide,\n includeHidden,\n interval,\n label: labelProp = false,\n minTickGap = 8,\n mirror,\n niceTicks,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick: tickProp = true,\n tickCount,\n tickFormatter,\n tickLine: tickLineProp = false,\n tickMargin = 8,\n ticks,\n tickSize,\n unit,\n xAxisId,\n ...rest\n}: UseChartXAxisProps = {}) => {\n const tick = useMemo<UseChartXAxisProps[\"tick\"]>(() => {\n if (!tickProp) return tickProp\n if (isFunction(tickProp) || isValidElement(tickProp)) return tickProp\n\n return { ...(isObject(tickProp) ? tickProp : {}), fill: \"\" }\n }, [tickProp])\n const tickLine = useMemo<UseChartXAxisProps[\"tickLine\"]>(() => {\n if (!tickLineProp) return tickLineProp\n\n return {\n fill: \"\",\n stroke: \"\",\n ...(isObject(tickLineProp) ? tickLineProp : {}),\n }\n }, [tickLineProp])\n const label = useMemo<UseChartXAxisProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 0,\n position: \"insideBottom\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n\n const getRootProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({ ...rest, ...props }),\n [rest],\n )\n\n const getXAxisProps: PropGetter<XAxisProps> = useCallback(\n (props) => ({\n type,\n name,\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine,\n children,\n dataKey,\n domain,\n height: height ?? (label ? 52 : undefined),\n hide,\n includeHidden,\n interval,\n label,\n minTickGap,\n mirror,\n niceTicks,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick,\n tickCount,\n tickFormatter,\n tickLine,\n tickMargin,\n ticks,\n tickSize,\n unit,\n xAxisId,\n ...props,\n }),\n [\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine,\n children,\n dataKey,\n domain,\n niceTicks,\n height,\n hide,\n includeHidden,\n interval,\n label,\n minTickGap,\n mirror,\n name,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick,\n tickCount,\n tickFormatter,\n tickLine,\n tickMargin,\n tickSize,\n ticks,\n type,\n unit,\n xAxisId,\n ],\n )\n\n return { getRootProps, getXAxisProps }\n}\n\nexport type UseChartXAxisReturn = ReturnType<typeof useChartXAxis>\n\nexport interface UseChartYAxisProps extends Merge<\n HTMLProps<\"svg\">,\n Pick<\n YAxisProps,\n | \"allowDataOverflow\"\n | \"allowDecimals\"\n | \"allowDuplicatedCategory\"\n | \"angle\"\n | \"axisLine\"\n | \"dataKey\"\n | \"domain\"\n | \"hide\"\n | \"includeHidden\"\n | \"interval\"\n | \"label\"\n | \"minTickGap\"\n | \"mirror\"\n | \"name\"\n | \"niceTicks\"\n | \"padding\"\n | \"range\"\n | \"reversed\"\n | \"scale\"\n | \"tick\"\n | \"tickCount\"\n | \"tickFormatter\"\n | \"tickLine\"\n | \"tickMargin\"\n | \"ticks\"\n | \"tickSize\"\n | \"type\"\n | \"unit\"\n | \"width\"\n | \"yAxisId\"\n >\n> {\n /**\n * The orientation of axis.\n *\n * @defaultValue \"start\"\n */\n orientation?: SimpleDirection\n}\n\nexport const useChartYAxis = ({\n type,\n name,\n allowDataOverflow,\n allowDecimals = true,\n allowDuplicatedCategory,\n angle,\n axisLine = false,\n children,\n dataKey,\n domain,\n hide,\n includeHidden,\n interval,\n label: labelProp = false,\n minTickGap,\n mirror,\n niceTicks,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick: tickProp = true,\n tickCount,\n tickFormatter,\n tickLine: tickLineProp = false,\n tickMargin,\n ticks,\n tickSize,\n unit,\n width,\n yAxisId,\n ...rest\n}: UseChartYAxisProps = {}) => {\n const tick = useMemo<UseChartYAxisProps[\"tick\"]>(() => {\n if (!tickProp) return tickProp\n if (isFunction(tickProp) || isValidElement(tickProp)) return tickProp\n\n return { fill: \"\", ...(isObject(tickProp) ? tickProp : {}) }\n }, [tickProp])\n const tickLine = useMemo<UseChartYAxisProps[\"tickLine\"]>(() => {\n if (!tickLineProp) return tickLineProp\n\n return {\n fill: \"\",\n stroke: \"\",\n ...(isObject(tickLineProp) ? tickLineProp : {}),\n }\n }, [tickLineProp])\n const label = useMemo<UseChartYAxisProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n angle: -90,\n fill: \"\",\n offset: 4,\n position: \"insideLeft\",\n transform:\n orientation === \"end\" ? \"translate(10, 0)\" : \"translate(-10, 0)\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp, orientation])\n\n const getRootProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({ ...rest, ...props }),\n [rest],\n )\n\n const getYAxisProps: PropGetter<YAxisProps> = useCallback(\n (props = {}) => ({\n type,\n name,\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine,\n children,\n dataKey,\n domain,\n hide,\n includeHidden,\n interval,\n label,\n minTickGap,\n mirror,\n niceTicks,\n orientation:\n orientation === \"end\"\n ? \"right\"\n : orientation === \"start\"\n ? \"left\"\n : undefined,\n padding,\n range,\n reversed,\n scale,\n tick,\n tickCount,\n tickFormatter,\n tickLine,\n tickMargin,\n ticks,\n tickSize,\n unit,\n width: width ?? (label ? 64 : undefined),\n yAxisId,\n ...props,\n }),\n [\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine,\n children,\n dataKey,\n domain,\n hide,\n includeHidden,\n interval,\n label,\n minTickGap,\n mirror,\n niceTicks,\n name,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick,\n tickCount,\n tickFormatter,\n tickLine,\n tickMargin,\n tickSize,\n ticks,\n type,\n unit,\n width,\n yAxisId,\n ],\n )\n\n return { getRootProps, getYAxisProps }\n}\n\nexport type UseChartYAxisReturn = ReturnType<typeof useChartYAxis>\n\nexport interface UseChartLineProps extends Merge<\n HTMLProps<\"line\">,\n Pick<\n LineProps,\n | \"activeDot\"\n | \"animateNewValues\"\n | \"animationBegin\"\n | \"animationDuration\"\n | \"animationEasing\"\n | \"connectNulls\"\n | \"data\"\n | \"dataKey\"\n | \"dot\"\n | \"hide\"\n | \"isAnimationActive\"\n | \"label\"\n | \"legendType\"\n | \"name\"\n | \"onAnimationEnd\"\n | \"onAnimationStart\"\n | \"shape\"\n | \"stroke\"\n | \"tooltipType\"\n | \"type\"\n | \"unit\"\n | \"xAxisId\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartLine = ({\n type = \"monotone\",\n name,\n activeDot: activeDotProp,\n animateNewValues,\n animationBegin,\n animationDuration,\n animationEasing,\n children,\n connectNulls,\n data,\n dataKey: dataKeyProp,\n dot: dotProp,\n hide,\n isAnimationActive = false,\n label: labelProp = false,\n legendType,\n shape,\n stroke = \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...rest\n}: UseChartLineProps = {}) => {\n const { highlightedDataKey } = useChartContext()\n const label = useMemo<UseChartLineProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 12,\n position: \"top\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n const dot = useMemo<UseChartLineProps[\"dot\"]>(() => {\n if (!dotProp) return dotProp\n if (isFunction(dotProp) || isValidElement(dotProp)) return dotProp\n\n return { fill: \"\", stroke: \"\", ...(isObject(dotProp) ? dotProp : {}) }\n }, [dotProp])\n const activeDot = useMemo<UseChartLineProps[\"activeDot\"]>(() => {\n if (!activeDotProp) return activeDotProp\n if (isFunction(activeDotProp) || isValidElement(activeDotProp))\n return activeDotProp\n\n return {\n fill: \"\",\n stroke: \"\",\n ...(isObject(activeDotProp) ? activeDotProp : {}),\n }\n }, [activeDotProp])\n\n const getRootProps: PropGetter<\"line\"> = useCallback(\n (props) => ({ ...rest, ...props }),\n [rest],\n )\n\n const getLineProps: PropGetter<LineProps> = useCallback(\n ({ dataKey = dataKeyProp, ...props } = {}) => ({\n type,\n name,\n \"data-active\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey === dataKey,\n ),\n \"data-inactive\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey !== dataKey,\n ),\n activeDot,\n animateNewValues,\n animationBegin,\n animationDuration,\n animationEasing,\n children,\n connectNulls,\n data,\n dataKey,\n dot,\n hide,\n isAnimationActive,\n label,\n legendType,\n shape,\n stroke,\n strokeWidth: \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...props,\n }),\n [\n activeDot,\n animateNewValues,\n animationBegin,\n animationDuration,\n animationEasing,\n children,\n connectNulls,\n data,\n dataKeyProp,\n dot,\n hide,\n highlightedDataKey,\n isAnimationActive,\n label,\n legendType,\n name,\n onAnimationEnd,\n onAnimationStart,\n shape,\n stroke,\n tooltipType,\n type,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getLineProps, getRootProps }\n}\n\nexport type UseChartLineReturn = ReturnType<typeof useChartLine>\n\nexport interface UseChartAreaProps extends Merge<\n HTMLProps<\"line\">,\n Pick<\n AreaProps<any, any>,\n | \"activeDot\"\n | \"animationBegin\"\n | \"animationDuration\"\n | \"animationEasing\"\n | \"baseLine\"\n | \"baseValue\"\n | \"connectNulls\"\n | \"data\"\n | \"dataKey\"\n | \"dot\"\n | \"hide\"\n | \"isAnimationActive\"\n | \"isRange\"\n | \"label\"\n | \"legendType\"\n | \"name\"\n | \"onAnimationEnd\"\n | \"onAnimationStart\"\n | \"stackId\"\n | \"stroke\"\n | \"tooltipType\"\n | \"type\"\n | \"unit\"\n | \"xAxisId\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartArea = ({\n type = \"monotone\",\n name,\n activeDot: activeDotProp,\n animationBegin,\n animationDuration,\n animationEasing,\n baseLine,\n baseValue,\n children,\n connectNulls,\n data,\n dataKey: dataKeyProp,\n dot: dotProp,\n hide,\n isAnimationActive = false,\n label: labelProp = false,\n legendType,\n stackId,\n stroke = \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...rest\n}: UseChartAreaProps) => {\n const { highlightedDataKey } = useChartContext()\n const label = useMemo<UseChartAreaProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 12,\n position: \"top\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n const dot = useMemo<UseChartAreaProps[\"dot\"]>(() => {\n if (!dotProp) return dotProp\n if (isFunction(dotProp) || isValidElement(dotProp)) return dotProp\n\n return { fill: \"\", stroke: \"\", ...(isObject(dotProp) ? dotProp : {}) }\n }, [dotProp])\n const activeDot = useMemo<UseChartAreaProps[\"activeDot\"]>(() => {\n if (!activeDotProp) return activeDotProp\n if (isFunction(activeDotProp) || isValidElement(activeDotProp))\n return activeDotProp\n\n return {\n fill: \"\",\n stroke: \"\",\n ...(isObject(activeDotProp) ? activeDotProp : {}),\n }\n }, [activeDotProp])\n\n const getRootProps: PropGetter<\"line\"> = useCallback(\n (props) => ({ ...rest, ...props }),\n [rest],\n )\n\n const getAreaProps: PropGetter<\n Partial<AreaProps<any, any>>,\n undefined,\n AreaProps<any, any>\n > = useCallback(\n ({ dataKey = dataKeyProp, ...props } = {}) => ({\n type,\n name,\n \"data-active\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey === dataKey,\n ),\n \"data-inactive\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey !== dataKey,\n ),\n activeDot,\n animationBegin,\n animationDuration,\n animationEasing,\n baseLine,\n baseValue,\n children,\n connectNulls,\n data,\n dataKey,\n dot,\n fill: \"\",\n fillOpacity: \"\",\n hide,\n isAnimationActive,\n label,\n legendType,\n stackId,\n stroke,\n strokeWidth: \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...props,\n }),\n [\n activeDot,\n animationBegin,\n animationDuration,\n animationEasing,\n baseLine,\n baseValue,\n children,\n connectNulls,\n data,\n dataKeyProp,\n dot,\n hide,\n highlightedDataKey,\n isAnimationActive,\n label,\n legendType,\n name,\n onAnimationEnd,\n onAnimationStart,\n stackId,\n stroke,\n tooltipType,\n type,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getAreaProps, getRootProps }\n}\n\nexport type UseChartAreaReturn = ReturnType<typeof useChartArea>\n\nexport interface UseChartBarProps extends Merge<\n HTMLProps<\"path\">,\n Pick<\n BarProps,\n | \"activeBar\"\n | \"animationBegin\"\n | \"animationDuration\"\n | \"animationEasing\"\n | \"background\"\n | \"barSize\"\n | \"dangerouslySetInnerHTML\"\n | \"dataKey\"\n | \"fill\"\n | \"hide\"\n | \"index\"\n | \"isAnimationActive\"\n | \"label\"\n | \"legendType\"\n | \"maxBarSize\"\n | \"minPointSize\"\n | \"name\"\n | \"onAnimationEnd\"\n | \"onAnimationStart\"\n | \"radius\"\n | \"shape\"\n | \"stackId\"\n | \"tooltipType\"\n | \"unit\"\n | \"xAxisId\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartBar = ({\n name,\n activeBar,\n animationBegin,\n animationDuration,\n animationEasing,\n background,\n barSize,\n children,\n dangerouslySetInnerHTML,\n dataKey: dataKeyProp,\n fill,\n hide,\n index,\n isAnimationActive = false,\n label: labelProp = false,\n legendType,\n maxBarSize,\n minPointSize,\n radius = 4,\n shape,\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...rest\n}: UseChartBarProps = {}) => {\n const { highlightedDataKey } = useChartContext()\n\n const label = useMemo<UseChartBarProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 12,\n position: \"top\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n\n const getRootProps: PropGetter<\"path\"> = useCallback(\n (props) => ({ ...rest, ...props }),\n [rest],\n )\n\n const getBarProps: PropGetter<BarProps> = useCallback(\n ({ dataKey = dataKeyProp, ...props } = {}) => ({\n name,\n \"data-active\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey === dataKey,\n ),\n \"data-inactive\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey !== dataKey,\n ),\n activeBar,\n animationBegin,\n animationDuration,\n animationEasing,\n background,\n barSize,\n children,\n dangerouslySetInnerHTML,\n dataKey,\n fill,\n hide,\n index,\n isAnimationActive,\n label,\n legendType,\n maxBarSize,\n minPointSize,\n radius,\n shape,\n stroke: \"\",\n strokeWidth: \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...props,\n }),\n [\n activeBar,\n animationBegin,\n animationDuration,\n animationEasing,\n background,\n barSize,\n children,\n dangerouslySetInnerHTML,\n dataKeyProp,\n fill,\n hide,\n highlightedDataKey,\n index,\n isAnimationActive,\n label,\n legendType,\n maxBarSize,\n minPointSize,\n name,\n onAnimationEnd,\n onAnimationStart,\n radius,\n shape,\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getBarProps, getRootProps }\n}\n\nexport type UseChartBarReturn = ReturnType<typeof useChartBar>\n\nexport interface UseChartReferenceLineProps extends Merge<\n HTMLProps<\"line\">,\n Pick<\n ReferenceLineProps,\n | \"ifOverflow\"\n | \"label\"\n | \"position\"\n | \"segment\"\n | \"shape\"\n | \"x\"\n | \"xAxisId\"\n | \"y\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartReferenceLine = ({\n children,\n ifOverflow,\n label: labelProp = false,\n position,\n segment,\n shape,\n viewBox,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ...rest\n}: UseChartReferenceLineProps = {}) => {\n const label = useMemo<UseChartReferenceLineProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 8,\n position: \"insideBottomLeft\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n\n const getRootProps: PropGetter<\"line\"> = useCallback(\n (props) => ({ ...rest, ...props }),\n [rest],\n )\n\n const getReferenceLineProps: PropGetter<Omit<ReferenceLineProps, \"ref\">> =\n useCallback(\n (props) => ({\n children,\n fill: \"\",\n fillOpacity: \"\",\n ifOverflow,\n label,\n position,\n segment,\n shape,\n stroke: \"\",\n strokeWidth: \"\",\n viewBox,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ...props,\n }),\n [\n children,\n ifOverflow,\n label,\n position,\n segment,\n shape,\n viewBox,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getReferenceLineProps, getRootProps }\n}\n\nexport type UseChartReferenceLineReturn = ReturnType<\n typeof useChartReferenceLine\n>\n\nexport interface UseChartGridProps extends Merge<\n HTMLProps<\"line\">,\n Pick<\n CartesianGridProps,\n | \"horizontal\"\n | \"horizontalCoordinatesGenerator\"\n | \"horizontalFill\"\n | \"horizontalPoints\"\n | \"horizontalValues\"\n | \"syncWithTicks\"\n | \"vertical\"\n | \"verticalCoordinatesGenerator\"\n | \"verticalFill\"\n | \"verticalPoints\"\n | \"verticalValues\"\n | \"x\"\n | \"xAxisId\"\n | \"y\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartGrid = ({\n horizontal,\n horizontalCoordinatesGenerator,\n horizontalFill,\n horizontalPoints,\n horizontalValues,\n syncWithTicks,\n vertical = false,\n verticalCoordinatesGenerator,\n verticalFill,\n verticalPoints,\n verticalValues,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ...rest\n}: UseChartGridProps = {}) => {\n const getRootProps: PropGetter<\"line\"> = useCallback(\n (props) => ({ ...rest, ...props }),\n [rest],\n )\n\n const getGridProps: PropGetter<CartesianGridProps> = useCallback(\n (props) => ({\n horizontal,\n horizontalCoordinatesGenerator,\n horizontalFill,\n horizontalPoints,\n horizontalValues,\n stroke: \"\",\n syncWithTicks,\n vertical,\n verticalCoordinatesGenerator,\n verticalFill,\n verticalPoints,\n verticalValues,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ...props,\n }),\n [\n horizontal,\n horizontalCoordinatesGenerator,\n horizontalFill,\n horizontalPoints,\n horizontalValues,\n syncWithTicks,\n vertical,\n verticalCoordinatesGenerator,\n verticalFill,\n verticalPoints,\n verticalValues,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getGridProps, getRootProps }\n}\n\nexport type UseChartGridReturn = ReturnType<typeof useChartGrid>\n"],"mappings":";;;;;;AAyCA,MAAa,qBAAqC,EAChD,qBAAqB,MACrB,SACA,MAC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;IACA,CAAC,UAAU,CAAC;CA+Ef,OAAO;EAAE,cA7E+B,aACrC,WAAW;GAAE,GAAG;GAAM,GAAG;GAAO,GACjC,CAAC,KAAK,CA2Ea;EAAE,eAxEuB,aAC3C,WAAW;GACV;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,QAAQ,WAAW,QAAQ,KAAK,KAAA;GAChC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;GACJ,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAGiC;EAAE;;AAiDxC,MAAa,iBAAiB,EAC5B,MACA,MACA,mBACA,gBAAgB,MAChB,yBACA,OACA,WAAW,OACX,UACA,SACA,QACA,MACA,eACA,UACA,OAAO,YAAY,OACnB,YACA,QACA,WACA,aACA,SACA,OACA,UACA,OACA,MAAM,WAAW,MACjB,WACA,eACA,UAAU,eAAe,OACzB,YACA,OACA,UACA,MACA,OACA,SACA,GAAG,SACmB,EAAE,KAAK;CAC7B,MAAM,OAAO,cAA0C;EACrD,IAAI,CAAC,UAAU,OAAO;EACtB,KAAA,GAAA,cAAA,YAAe,SAAS,IAAI,eAAe,SAAS,EAAE,OAAO;EAE7D,OAAO;GAAE,MAAM;GAAI,IAAA,GAAA,cAAA,UAAa,SAAS,GAAG,WAAW,EAAE;GAAG;IAC3D,CAAC,SAAS,CAAC;CACd,MAAM,WAAW,cAA8C;EAC7D,IAAI,CAAC,cAAc,OAAO;EAE1B,OAAO;GACL,MAAM;GACN,QAAQ;GACR,IAAA,GAAA,cAAA,UAAa,aAAa,GAAG,eAAe,EAAE;GAC/C;IACA,CAAC,aAAa,CAAC;CAClB,MAAM,QAAQ,cAA2C;EACvD,IAAI,CAAC,WAAW,OAAO;EACvB,KAAA,GAAA,cAAA,YAAe,UAAU,IAAI,eAAe,UAAU,EAAE,OAAO;EAE/D,OAAO;GACL,OAAO;GACP,MAAM;GACN,QAAQ;GACR,UAAU;GACV,WACE,gBAAgB,QAAQ,qBAAqB;GAC/C,IAAA,GAAA,cAAA,UAAa,UAAU,GAAG,YAAY,EAAE;GACzC;IACA,CAAC,WAAW,YAAY,CAAC;CAoF5B,OAAO;EAAE,cAlF+B,aACrC,WAAW;GAAE,GAAG;GAAM,GAAG;GAAO,GACjC,CAAC,KAAK,CAgFa;EAAE,eA7EuB,aAC3C,QAAQ,EAAE,MAAM;GACf;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,aACE,gBAAgB,QACZ,UACA,gBAAgB,UACd,SACA,KAAA;GACR;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,OAAO,UAAU,QAAQ,KAAK,KAAA;GAC9B;GACA,GAAG;GACJ,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAGiC;EAAE;;AAoCxC,MAAa,gBAAgB,EAC3B,OAAO,YACP,MACA,WAAW,eACX,kBACA,gBACA,mBACA,iBACA,UACA,cACA,MACA,SAAS,aACT,KAAK,SACL,MACA,oBAAoB,OACpB,OAAO,YAAY,OACnB,YACA,OACA,SAAS,IACT,aACA,MACA,SACA,SACA,QACA,gBACA,kBACA,GAAG,SACkB,EAAE,KAAK;CAC5B,MAAM,EAAE,uBAAuB,iBAAiB;CAChD,MAAM,QAAQ,cAA0C;EACtD,IAAI,CAAC,WAAW,OAAO;EACvB,KAAA,GAAA,cAAA,YAAe,UAAU,IAAI,eAAe,UAAU,EAAE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AAA,cAAA,UACE,EAAA,GAAA,cAAA,aAAa,mBAAmB,IAAI,uBAAuB,QAC5D;GACD;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,QAAQ;GACR,aAAa;GACb;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;GACJ,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAGiB;EAAE;EAAc;;AAsBtC,MAAa,yBAAyB,EACpC,UACA,YACA,OAAO,YAAY,OACnB,UACA,SACA,OACA,SACA,GACA,SACA,GACA,SACA,QACA,GAAG,SAC2B,EAAE,KAAK;CACrC,MAAM,QAAQ,cAAmD;EAC/D,IAAI,CAAC,WAAW,OAAO;EACvB,KAAA,GAAA,cAAA,YAAe,UAAU,IAAI,eAAe,UAAU,EAAE,OAAO;EAE/D,OAAO;GACL,MAAM;GACN,QAAQ;GACR,UAAU;GACV,IAAA,GAAA,cAAA,UAAa,UAAU,GAAG,YAAY,EAAE;GACzC;IACA,CAAC,UAAU,CAAC;CAEf,MAAM,eAAmC,aACtC,WAAW;EAAE,GAAG;EAAM,GAAG;EAAO,GACjC,CAAC,KAAK,CACP;CAuCD,OAAO;EAAE,uBApCP,aACG,WAAW;GACV;GACA,MAAM;GACN,aAAa;GACb;GACA;GACA;GACA;GACA;GACA,QAAQ;GACR,aAAa;GACb;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;GACJ,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAGyB;EAAE;EAAc;;AA8BhD,MAAa,gBAAgB,EAC3B,YACA,gCACA,gBACA,kBACA,kBACA,eACA,WAAW,OACX,8BACA,cACA,gBACA,gBACA,GACA,SACA,GACA,SACA,QACA,GAAG,SACkB,EAAE,KAAK;CAC5B,MAAM,eAAmC,aACtC,WAAW;EAAE,GAAG;EAAM,GAAG;EAAO,GACjC,CAAC,KAAK,CACP;CA2CD,OAAO;EAAE,cAzC4C,aAClD,WAAW;GACV;GACA;GACA;GACA;GACA;GACA,QAAQ;GACR;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;GACJ,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAGkB;EAAE;EAAc"}
1
+ {"version":3,"file":"use-cartesian-chart.js","names":[],"sources":["../../../../src/components/chart/use-cartesian-chart.ts"],"sourcesContent":["\"use client\"\n\nimport type {\n AreaProps,\n BarProps,\n CartesianGridProps,\n LineProps,\n ReferenceLineProps,\n XAxisProps,\n YAxisProps,\n} from \"recharts\"\nimport type { CartesianChartProps } from \"recharts/types/util/types\"\nimport type { Dict, Merge } from \"../../utils\"\nimport { isValidElement, useCallback, useMemo } from \"react\"\nimport {\n type HTMLProps,\n mergeProps,\n type PropGetter,\n type SimpleDirection,\n} from \"../../core\"\nimport { dataAttr, isFunction, isObject, isUndefined } from \"../../utils\"\nimport { useChartContext } from \"./use-chart\"\n\nexport interface UseCartesianChartProps<Y extends Dict>\n extends\n HTMLProps,\n Pick<\n CartesianChartProps,\n | \"accessibilityLayer\"\n | \"compact\"\n | \"layout\"\n | \"responsive\"\n | \"syncId\"\n | \"syncMethod\"\n > {\n /**\n * Chart data.\n */\n data?: Y[]\n}\n\nexport const useCartesianChart = <Y extends Dict>({\n accessibilityLayer = true,\n compact,\n data,\n layout = \"horizontal\",\n responsive,\n syncId,\n syncMethod,\n ...rest\n}: UseCartesianChartProps<Y>) => {\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps(rest, props)(),\n [rest],\n )\n\n const getChartProps: PropGetter<CartesianChartProps> = useCallback(\n (props) => ({\n accessibilityLayer,\n compact,\n data,\n layout,\n margin: { left: 16, right: 16 },\n responsive,\n syncId,\n syncMethod,\n ...props,\n }),\n [accessibilityLayer, compact, data, layout, responsive, syncId, syncMethod],\n )\n\n return {\n getChartProps,\n getRootProps,\n }\n}\n\nexport type UseCartesianChartReturn<Y extends Dict> = ReturnType<\n typeof useCartesianChart<Y>\n>\n\nexport interface UseChartXAxisProps extends Merge<\n HTMLProps<\"svg\">,\n Pick<\n XAxisProps,\n | \"allowDataOverflow\"\n | \"allowDecimals\"\n | \"allowDuplicatedCategory\"\n | \"angle\"\n | \"axisLine\"\n | \"dataKey\"\n | \"domain\"\n | \"height\"\n | \"hide\"\n | \"includeHidden\"\n | \"interval\"\n | \"label\"\n | \"minTickGap\"\n | \"mirror\"\n | \"name\"\n | \"niceTicks\"\n | \"orientation\"\n | \"padding\"\n | \"range\"\n | \"reversed\"\n | \"scale\"\n | \"tick\"\n | \"tickCount\"\n | \"tickFormatter\"\n | \"tickLine\"\n | \"tickMargin\"\n | \"ticks\"\n | \"tickSize\"\n | \"type\"\n | \"unit\"\n | \"xAxisId\"\n >\n> {}\n\nexport const useChartXAxis = ({\n type,\n name,\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine = false,\n children,\n dataKey,\n domain,\n height,\n hide,\n includeHidden,\n interval,\n label: labelProp = false,\n minTickGap = 8,\n mirror,\n niceTicks,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick: tickProp = true,\n tickCount,\n tickFormatter,\n tickLine: tickLineProp = false,\n tickMargin = 8,\n ticks,\n tickSize,\n unit,\n xAxisId,\n ...rest\n}: UseChartXAxisProps = {}) => {\n const tick = useMemo<UseChartXAxisProps[\"tick\"]>(() => {\n if (!tickProp) return tickProp\n if (isFunction(tickProp) || isValidElement(tickProp)) return tickProp\n\n return { ...(isObject(tickProp) ? tickProp : {}), fill: \"\" }\n }, [tickProp])\n const tickLine = useMemo<UseChartXAxisProps[\"tickLine\"]>(() => {\n if (!tickLineProp) return tickLineProp\n\n return {\n fill: \"\",\n stroke: \"\",\n ...(isObject(tickLineProp) ? tickLineProp : {}),\n }\n }, [tickLineProp])\n const label = useMemo<UseChartXAxisProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 0,\n position: \"insideBottom\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n\n const getRootProps: PropGetter<\"svg\"> = useCallback(\n (props) => mergeProps(rest, props)(),\n [rest],\n )\n\n const getXAxisProps: PropGetter<XAxisProps> = useCallback(\n (props) => ({\n type,\n name,\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine,\n children,\n dataKey,\n domain,\n height: height ?? (label ? 52 : undefined),\n hide,\n includeHidden,\n interval,\n label,\n minTickGap,\n mirror,\n niceTicks,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick,\n tickCount,\n tickFormatter,\n tickLine,\n tickMargin,\n ticks,\n tickSize,\n unit,\n xAxisId,\n ...props,\n }),\n [\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine,\n children,\n dataKey,\n domain,\n niceTicks,\n height,\n hide,\n includeHidden,\n interval,\n label,\n minTickGap,\n mirror,\n name,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick,\n tickCount,\n tickFormatter,\n tickLine,\n tickMargin,\n tickSize,\n ticks,\n type,\n unit,\n xAxisId,\n ],\n )\n\n return { getRootProps, getXAxisProps }\n}\n\nexport type UseChartXAxisReturn = ReturnType<typeof useChartXAxis>\n\nexport interface UseChartYAxisProps extends Merge<\n HTMLProps<\"svg\">,\n Pick<\n YAxisProps,\n | \"allowDataOverflow\"\n | \"allowDecimals\"\n | \"allowDuplicatedCategory\"\n | \"angle\"\n | \"axisLine\"\n | \"dataKey\"\n | \"domain\"\n | \"hide\"\n | \"includeHidden\"\n | \"interval\"\n | \"label\"\n | \"minTickGap\"\n | \"mirror\"\n | \"name\"\n | \"niceTicks\"\n | \"padding\"\n | \"range\"\n | \"reversed\"\n | \"scale\"\n | \"tick\"\n | \"tickCount\"\n | \"tickFormatter\"\n | \"tickLine\"\n | \"tickMargin\"\n | \"ticks\"\n | \"tickSize\"\n | \"type\"\n | \"unit\"\n | \"width\"\n | \"yAxisId\"\n >\n> {\n /**\n * The orientation of axis.\n *\n * @defaultValue \"start\"\n */\n orientation?: SimpleDirection\n}\n\nexport const useChartYAxis = ({\n type,\n name,\n allowDataOverflow,\n allowDecimals = true,\n allowDuplicatedCategory,\n angle,\n axisLine = false,\n children,\n dataKey,\n domain,\n hide,\n includeHidden,\n interval,\n label: labelProp = false,\n minTickGap,\n mirror,\n niceTicks,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick: tickProp = true,\n tickCount,\n tickFormatter,\n tickLine: tickLineProp = false,\n tickMargin,\n ticks,\n tickSize,\n unit,\n width,\n yAxisId,\n ...rest\n}: UseChartYAxisProps = {}) => {\n const tick = useMemo<UseChartYAxisProps[\"tick\"]>(() => {\n if (!tickProp) return tickProp\n if (isFunction(tickProp) || isValidElement(tickProp)) return tickProp\n\n return { fill: \"\", ...(isObject(tickProp) ? tickProp : {}) }\n }, [tickProp])\n const tickLine = useMemo<UseChartYAxisProps[\"tickLine\"]>(() => {\n if (!tickLineProp) return tickLineProp\n\n return {\n fill: \"\",\n stroke: \"\",\n ...(isObject(tickLineProp) ? tickLineProp : {}),\n }\n }, [tickLineProp])\n const label = useMemo<UseChartYAxisProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n angle: -90,\n fill: \"\",\n offset: 4,\n position: \"insideLeft\",\n transform:\n orientation === \"end\" ? \"translate(10, 0)\" : \"translate(-10, 0)\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp, orientation])\n\n const getRootProps: PropGetter<\"svg\"> = useCallback(\n (props) => mergeProps(rest, props)(),\n [rest],\n )\n\n const getYAxisProps: PropGetter<YAxisProps> = useCallback(\n (props = {}) => ({\n type,\n name,\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine,\n children,\n dataKey,\n domain,\n hide,\n includeHidden,\n interval,\n label,\n minTickGap,\n mirror,\n niceTicks,\n orientation:\n orientation === \"end\"\n ? \"right\"\n : orientation === \"start\"\n ? \"left\"\n : undefined,\n padding,\n range,\n reversed,\n scale,\n tick,\n tickCount,\n tickFormatter,\n tickLine,\n tickMargin,\n ticks,\n tickSize,\n unit,\n width: width ?? (label ? 64 : undefined),\n yAxisId,\n ...props,\n }),\n [\n allowDataOverflow,\n allowDecimals,\n allowDuplicatedCategory,\n angle,\n axisLine,\n children,\n dataKey,\n domain,\n hide,\n includeHidden,\n interval,\n label,\n minTickGap,\n mirror,\n niceTicks,\n name,\n orientation,\n padding,\n range,\n reversed,\n scale,\n tick,\n tickCount,\n tickFormatter,\n tickLine,\n tickMargin,\n tickSize,\n ticks,\n type,\n unit,\n width,\n yAxisId,\n ],\n )\n\n return { getRootProps, getYAxisProps }\n}\n\nexport type UseChartYAxisReturn = ReturnType<typeof useChartYAxis>\n\nexport interface UseChartLineProps extends Merge<\n HTMLProps<\"line\">,\n Pick<\n LineProps,\n | \"activeDot\"\n | \"animateNewValues\"\n | \"animationBegin\"\n | \"animationDuration\"\n | \"animationEasing\"\n | \"connectNulls\"\n | \"data\"\n | \"dataKey\"\n | \"dot\"\n | \"hide\"\n | \"isAnimationActive\"\n | \"label\"\n | \"legendType\"\n | \"name\"\n | \"onAnimationEnd\"\n | \"onAnimationStart\"\n | \"shape\"\n | \"stroke\"\n | \"tooltipType\"\n | \"type\"\n | \"unit\"\n | \"xAxisId\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartLine = ({\n type = \"monotone\",\n name,\n activeDot: activeDotProp,\n animateNewValues,\n animationBegin,\n animationDuration,\n animationEasing,\n children,\n connectNulls,\n data,\n dataKey: dataKeyProp,\n dot: dotProp,\n hide,\n isAnimationActive = false,\n label: labelProp = false,\n legendType,\n shape,\n stroke = \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...rest\n}: UseChartLineProps = {}) => {\n const { highlightedDataKey } = useChartContext()\n const label = useMemo<UseChartLineProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 12,\n position: \"top\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n const dot = useMemo<UseChartLineProps[\"dot\"]>(() => {\n if (!dotProp) return dotProp\n if (isFunction(dotProp) || isValidElement(dotProp)) return dotProp\n\n return { fill: \"\", stroke: \"\", ...(isObject(dotProp) ? dotProp : {}) }\n }, [dotProp])\n const activeDot = useMemo<UseChartLineProps[\"activeDot\"]>(() => {\n if (!activeDotProp) return activeDotProp\n if (isFunction(activeDotProp) || isValidElement(activeDotProp))\n return activeDotProp\n\n return {\n fill: \"\",\n stroke: \"\",\n ...(isObject(activeDotProp) ? activeDotProp : {}),\n }\n }, [activeDotProp])\n\n const getRootProps: PropGetter<\"line\"> = useCallback(\n (props) => mergeProps(rest, props)(),\n [rest],\n )\n\n const getLineProps: PropGetter<LineProps> = useCallback(\n ({ dataKey = dataKeyProp, ...props } = {}) => ({\n type,\n name,\n \"data-active\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey === dataKey,\n ),\n \"data-inactive\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey !== dataKey,\n ),\n activeDot,\n animateNewValues,\n animationBegin,\n animationDuration,\n animationEasing,\n children,\n connectNulls,\n data,\n dataKey,\n dot,\n hide,\n isAnimationActive,\n label,\n legendType,\n shape,\n stroke,\n strokeWidth: \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...props,\n }),\n [\n activeDot,\n animateNewValues,\n animationBegin,\n animationDuration,\n animationEasing,\n children,\n connectNulls,\n data,\n dataKeyProp,\n dot,\n hide,\n highlightedDataKey,\n isAnimationActive,\n label,\n legendType,\n name,\n onAnimationEnd,\n onAnimationStart,\n shape,\n stroke,\n tooltipType,\n type,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getLineProps, getRootProps }\n}\n\nexport type UseChartLineReturn = ReturnType<typeof useChartLine>\n\nexport interface UseChartAreaProps extends Merge<\n HTMLProps<\"line\">,\n Pick<\n AreaProps<any, any>,\n | \"activeDot\"\n | \"animationBegin\"\n | \"animationDuration\"\n | \"animationEasing\"\n | \"baseLine\"\n | \"baseValue\"\n | \"connectNulls\"\n | \"data\"\n | \"dataKey\"\n | \"dot\"\n | \"hide\"\n | \"isAnimationActive\"\n | \"isRange\"\n | \"label\"\n | \"legendType\"\n | \"name\"\n | \"onAnimationEnd\"\n | \"onAnimationStart\"\n | \"stackId\"\n | \"stroke\"\n | \"tooltipType\"\n | \"type\"\n | \"unit\"\n | \"xAxisId\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartArea = ({\n type = \"monotone\",\n name,\n activeDot: activeDotProp,\n animationBegin,\n animationDuration,\n animationEasing,\n baseLine,\n baseValue,\n children,\n connectNulls,\n data,\n dataKey: dataKeyProp,\n dot: dotProp,\n hide,\n isAnimationActive = false,\n label: labelProp = false,\n legendType,\n stackId,\n stroke = \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...rest\n}: UseChartAreaProps) => {\n const { highlightedDataKey } = useChartContext()\n const label = useMemo<UseChartAreaProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 12,\n position: \"top\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n const dot = useMemo<UseChartAreaProps[\"dot\"]>(() => {\n if (!dotProp) return dotProp\n if (isFunction(dotProp) || isValidElement(dotProp)) return dotProp\n\n return { fill: \"\", stroke: \"\", ...(isObject(dotProp) ? dotProp : {}) }\n }, [dotProp])\n const activeDot = useMemo<UseChartAreaProps[\"activeDot\"]>(() => {\n if (!activeDotProp) return activeDotProp\n if (isFunction(activeDotProp) || isValidElement(activeDotProp))\n return activeDotProp\n\n return {\n fill: \"\",\n stroke: \"\",\n ...(isObject(activeDotProp) ? activeDotProp : {}),\n }\n }, [activeDotProp])\n\n const getRootProps: PropGetter<\"line\"> = useCallback(\n (props) => mergeProps(rest, props)(),\n [rest],\n )\n\n const getAreaProps: PropGetter<\n Partial<AreaProps<any, any>>,\n undefined,\n AreaProps<any, any>\n > = useCallback(\n ({ dataKey = dataKeyProp, ...props } = {}) => ({\n type,\n name,\n \"data-active\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey === dataKey,\n ),\n \"data-inactive\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey !== dataKey,\n ),\n activeDot,\n animationBegin,\n animationDuration,\n animationEasing,\n baseLine,\n baseValue,\n children,\n connectNulls,\n data,\n dataKey,\n dot,\n fill: \"\",\n fillOpacity: \"\",\n hide,\n isAnimationActive,\n label,\n legendType,\n stackId,\n stroke,\n strokeWidth: \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...props,\n }),\n [\n activeDot,\n animationBegin,\n animationDuration,\n animationEasing,\n baseLine,\n baseValue,\n children,\n connectNulls,\n data,\n dataKeyProp,\n dot,\n hide,\n highlightedDataKey,\n isAnimationActive,\n label,\n legendType,\n name,\n onAnimationEnd,\n onAnimationStart,\n stackId,\n stroke,\n tooltipType,\n type,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getAreaProps, getRootProps }\n}\n\nexport type UseChartAreaReturn = ReturnType<typeof useChartArea>\n\nexport interface UseChartBarProps extends Merge<\n HTMLProps<\"path\">,\n Pick<\n BarProps,\n | \"activeBar\"\n | \"animationBegin\"\n | \"animationDuration\"\n | \"animationEasing\"\n | \"background\"\n | \"barSize\"\n | \"dangerouslySetInnerHTML\"\n | \"dataKey\"\n | \"fill\"\n | \"hide\"\n | \"index\"\n | \"isAnimationActive\"\n | \"label\"\n | \"legendType\"\n | \"maxBarSize\"\n | \"minPointSize\"\n | \"name\"\n | \"onAnimationEnd\"\n | \"onAnimationStart\"\n | \"radius\"\n | \"shape\"\n | \"stackId\"\n | \"tooltipType\"\n | \"unit\"\n | \"xAxisId\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartBar = ({\n name,\n activeBar,\n animationBegin,\n animationDuration,\n animationEasing,\n background,\n barSize,\n children,\n dangerouslySetInnerHTML,\n dataKey: dataKeyProp,\n fill,\n hide,\n index,\n isAnimationActive = false,\n label: labelProp = false,\n legendType,\n maxBarSize,\n minPointSize,\n radius = 4,\n shape,\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...rest\n}: UseChartBarProps = {}) => {\n const { highlightedDataKey } = useChartContext()\n\n const label = useMemo<UseChartBarProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 12,\n position: \"top\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n\n const getRootProps: PropGetter<\"path\"> = useCallback(\n (props) => mergeProps(rest, props)(),\n [rest],\n )\n\n const getBarProps: PropGetter<BarProps> = useCallback(\n ({ dataKey = dataKeyProp, ...props } = {}) => ({\n name,\n \"data-active\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey === dataKey,\n ),\n \"data-inactive\": dataAttr(\n !isUndefined(highlightedDataKey) && highlightedDataKey !== dataKey,\n ),\n activeBar,\n animationBegin,\n animationDuration,\n animationEasing,\n background,\n barSize,\n children,\n dangerouslySetInnerHTML,\n dataKey,\n fill,\n hide,\n index,\n isAnimationActive,\n label,\n legendType,\n maxBarSize,\n minPointSize,\n radius,\n shape,\n stroke: \"\",\n strokeWidth: \"\",\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n onAnimationEnd,\n onAnimationStart,\n ...props,\n }),\n [\n activeBar,\n animationBegin,\n animationDuration,\n animationEasing,\n background,\n barSize,\n children,\n dangerouslySetInnerHTML,\n dataKeyProp,\n fill,\n hide,\n highlightedDataKey,\n index,\n isAnimationActive,\n label,\n legendType,\n maxBarSize,\n minPointSize,\n name,\n onAnimationEnd,\n onAnimationStart,\n radius,\n shape,\n tooltipType,\n unit,\n xAxisId,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getBarProps, getRootProps }\n}\n\nexport type UseChartBarReturn = ReturnType<typeof useChartBar>\n\nexport interface UseChartReferenceLineProps extends Merge<\n HTMLProps<\"line\">,\n Pick<\n ReferenceLineProps,\n | \"ifOverflow\"\n | \"label\"\n | \"position\"\n | \"segment\"\n | \"shape\"\n | \"x\"\n | \"xAxisId\"\n | \"y\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartReferenceLine = ({\n children,\n ifOverflow,\n label: labelProp = false,\n position,\n segment,\n shape,\n viewBox,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ...rest\n}: UseChartReferenceLineProps = {}) => {\n const label = useMemo<UseChartReferenceLineProps[\"label\"]>(() => {\n if (!labelProp) return labelProp\n if (isFunction(labelProp) || isValidElement(labelProp)) return labelProp\n\n return {\n fill: \"\",\n offset: 8,\n position: \"insideBottomLeft\",\n ...(isObject(labelProp) ? labelProp : {}),\n }\n }, [labelProp])\n\n const getRootProps: PropGetter<\"line\"> = useCallback(\n (props) => mergeProps(rest, props)(),\n [rest],\n )\n\n const getReferenceLineProps: PropGetter<Omit<ReferenceLineProps, \"ref\">> =\n useCallback(\n (props) => ({\n children,\n fill: \"\",\n fillOpacity: \"\",\n ifOverflow,\n label,\n position,\n segment,\n shape,\n stroke: \"\",\n strokeWidth: \"\",\n viewBox,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ...props,\n }),\n [\n children,\n ifOverflow,\n label,\n position,\n segment,\n shape,\n viewBox,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getReferenceLineProps, getRootProps }\n}\n\nexport type UseChartReferenceLineReturn = ReturnType<\n typeof useChartReferenceLine\n>\n\nexport interface UseChartGridProps extends Merge<\n HTMLProps<\"line\">,\n Pick<\n CartesianGridProps,\n | \"horizontal\"\n | \"horizontalCoordinatesGenerator\"\n | \"horizontalFill\"\n | \"horizontalPoints\"\n | \"horizontalValues\"\n | \"syncWithTicks\"\n | \"vertical\"\n | \"verticalCoordinatesGenerator\"\n | \"verticalFill\"\n | \"verticalPoints\"\n | \"verticalValues\"\n | \"x\"\n | \"xAxisId\"\n | \"y\"\n | \"yAxisId\"\n | \"zIndex\"\n >\n> {}\n\nexport const useChartGrid = ({\n horizontal,\n horizontalCoordinatesGenerator,\n horizontalFill,\n horizontalPoints,\n horizontalValues,\n syncWithTicks,\n vertical = false,\n verticalCoordinatesGenerator,\n verticalFill,\n verticalPoints,\n verticalValues,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ...rest\n}: UseChartGridProps = {}) => {\n const getRootProps: PropGetter<\"line\"> = useCallback(\n (props) => mergeProps(rest, props)(),\n [rest],\n )\n\n const getGridProps: PropGetter<CartesianGridProps> = useCallback(\n (props) => ({\n horizontal,\n horizontalCoordinatesGenerator,\n horizontalFill,\n horizontalPoints,\n horizontalValues,\n stroke: \"\",\n syncWithTicks,\n vertical,\n verticalCoordinatesGenerator,\n verticalFill,\n verticalPoints,\n verticalValues,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ...props,\n }),\n [\n horizontal,\n horizontalCoordinatesGenerator,\n horizontalFill,\n horizontalPoints,\n horizontalValues,\n syncWithTicks,\n vertical,\n verticalCoordinatesGenerator,\n verticalFill,\n verticalPoints,\n verticalValues,\n x,\n xAxisId,\n y,\n yAxisId,\n zIndex,\n ],\n )\n\n return { getGridProps, getRootProps }\n}\n\nexport type UseChartGridReturn = ReturnType<typeof useChartGrid>\n"],"mappings":";;;;;;AAyCA,MAAa,qBAAqC,EAChD,qBAAqB,MACrB,SACA,MACA,SAAS,cACT,YACA,QACA,YACA,GAAG,WAC4B;CAC/B,MAAM,eAA2B,aAC9B,UAAU,WAAW,MAAM,MAAM,EAAE,EACpC,CAAC,KAAK,CACP;CAiBD,OAAO;EACL,eAhBqD,aACpD,WAAW;GACV;GACA;GACA;GACA;GACA,QAAQ;IAAE,MAAM;IAAI,OAAO;IAAI;GAC/B;GACA;GACA;GACA,GAAG;GACJ,GACD;GAAC;GAAoB;GAAS;GAAM;GAAQ;GAAY;GAAQ;GAAW,CAI9D;EACb;EACD;;AA6CH,MAAa,iBAAiB,EAC5B,MACA,MACA,mBACA,eACA,yBACA,OACA,WAAW,OACX,UACA,SACA,QACA,QACA,MACA,eACA,UACA,OAAO,YAAY,OACnB,aAAa,GACb,QACA,WACA,aACA,SACA,OACA,UACA,OACA,MAAM,WAAW,MACjB,WACA,eACA,UAAU,eAAe,OACzB,aAAa,GACb,OACA,UACA,MACA,SACA,GAAG,SACmB,EAAE,KAAK;CAC7B,MAAM,OAAO,cAA0C;EACrD,IAAI,CAAC,UAAU,OAAO;EACtB,KAAA,GAAA,cAAA,YAAe,SAAS,IAAI,eAAe,SAAS,EAAE,OAAO;EAE7D,OAAO;GAAE,IAAA,GAAA,cAAA,UAAa,SAAS,GAAG,WAAW,EAAE;GAAG,MAAM;GAAI;IAC3D,CAAC,SAAS,CAAC;CACd,MAAM,WAAW,cAA8C;EAC7D,IAAI,CAAC,cAAc,OAAO;EAE1B,OAAO;GACL,MAAM;GACN,QAAQ;GACR,IAAA,GAAA,cAAA,UAAa,aAAa,GAAG,eAAe,EAAE;GAC/C;IACA,CAAC,aAAa,CAAC;CAClB,MAAM,QAAQ,cAA2C;EACvD,IAAI,CAAC,WAAW,OAAO;EACvB,KAAA,GAAA,cAAA,YAAe,UAAU,IAAI,eAAe,UAAU,EAAE,OAAO;EAE/D,OAAO;GACL,MAAM;GACN,QAAQ;GACR,UAAU;GACV,IAAA,GAAA,cAAA,UAAa,UAAU,GAAG,YAAY,EAAE;GACzC;IACA,CAAC,UAAU,CAAC;CA+Ef,OAAO;EAAE,cA7E+B,aACrC,UAAU,WAAW,MAAM,MAAM,EAAE,EACpC,CAAC,KAAK,CA2Ea;EAAE,eAxEuB,aAC3C,WAAW;GACV;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,QAAQ,WAAW,QAAQ,KAAK,KAAA;GAChC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;GACJ,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAGiC;EAAE;;AAiDxC,MAAa,iBAAiB,EAC5B,MACA,MACA,mBACA,gBAAgB,MAChB,yBACA,OACA,WAAW,OACX,UACA,SACA,QACA,MACA,eACA,UACA,OAAO,YAAY,OACnB,YACA,QACA,WACA,aACA,SACA,OACA,UACA,OACA,MAAM,WAAW,MACjB,WACA,eACA,UAAU,eAAe,OACzB,YACA,OACA,UACA,MACA,OACA,SACA,GAAG,SACmB,EAAE,KAAK;CAC7B,MAAM,OAAO,cAA0C;EACrD,IAAI,CAAC,UAAU,OAAO;EACtB,KAAA,GAAA,cAAA,YAAe,SAAS,IAAI,eAAe,SAAS,EAAE,OAAO;EAE7D,OAAO;GAAE,MAAM;GAAI,IAAA,GAAA,cAAA,UAAa,SAAS,GAAG,WAAW,EAAE;GAAG;IAC3D,CAAC,SAAS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,CACP;CAyED,OAAO;EAAE,aAvEiC,aACvC,EAAE,UAAU,aAAa,GAAG,UAAU,EAAE,MAAM;GAC7C;GACA,gBAAA,GAAA,cAAA,UACE,EAAA,GAAA,cAAA,aAAa,mBAAmB,IAAI,uBAAuB,QAC5D;GACD,kBAAA,GAAA,cAAA,UACE,EAAA,GAAA,cAAA,aAAa,mBAAmB,IAAI,uBAAuB,QAC5D;GACD;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,QAAQ;GACR,aAAa;GACb;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;GACJ,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAGiB;EAAE;EAAc;;AAsBtC,MAAa,yBAAyB,EACpC,UACA,YACA,OAAO,YAAY,OACnB,UACA,SACA,OACA,SACA,GACA,SACA,GACA,SACA,QACA,GAAG,SAC2B,EAAE,KAAK;CACrC,MAAM,QAAQ,cAAmD;EAC/D,IAAI,CAAC,WAAW,OAAO;EACvB,KAAA,GAAA,cAAA,YAAe,UAAU,IAAI,eAAe,UAAU,EAAE,OAAO;EAE/D,OAAO;GACL,MAAM;GACN,QAAQ;GACR,UAAU;GACV,IAAA,GAAA,cAAA,UAAa,UAAU,GAAG,YAAY,EAAE;GACzC;IACA,CAAC,UAAU,CAAC;CAEf,MAAM,eAAmC,aACtC,UAAU,WAAW,MAAM,MAAM,EAAE,EACpC,CAAC,KAAK,CACP;CAuCD,OAAO;EAAE,uBApCP,aACG,WAAW;GACV;GACA,MAAM;GACN,aAAa;GACb;GACA;GACA;GACA;GACA;GACA,QAAQ;GACR,aAAa;GACb;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;GACJ,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAGyB;EAAE;EAAc;;AA8BhD,MAAa,gBAAgB,EAC3B,YACA,gCACA,gBACA,kBACA,kBACA,eACA,WAAW,OACX,8BACA,cACA,gBACA,gBACA,GACA,SACA,GACA,SACA,QACA,GAAG,SACkB,EAAE,KAAK;CAC5B,MAAM,eAAmC,aACtC,UAAU,WAAW,MAAM,MAAM,EAAE,EACpC,CAAC,KAAK,CACP;CA2CD,OAAO;EAAE,cAzC4C,aAClD,WAAW;GACV;GACA;GACA;GACA;GACA;GACA,QAAQ;GACR;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;GACJ,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAGkB;EAAE;EAAc"}