@yamada-ui/react 2.3.0-next-20260411064049 → 2.3.0-next-20260412042747
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/accordion/accordion.cjs +1 -5
- package/dist/cjs/components/accordion/accordion.cjs.map +1 -1
- package/dist/cjs/components/tree/tree.cjs +21 -48
- package/dist/cjs/components/tree/tree.cjs.map +1 -1
- package/dist/esm/components/accordion/accordion.js +1 -5
- package/dist/esm/components/accordion/accordion.js.map +1 -1
- package/dist/esm/components/tree/tree.js +21 -48
- package/dist/esm/components/tree/tree.js.map +1 -1
- package/dist/types/components/accordion/accordion.d.ts +2 -2
- package/dist/types/components/accordion/accordion.style.d.ts +1 -1
- package/dist/types/components/accordion/use-accordion.d.ts +11 -11
- package/dist/types/components/action-bar/action-bar.d.ts +2 -2
- package/dist/types/components/airy/airy.d.ts +2 -2
- package/dist/types/components/alert/alert.d.ts +2 -2
- package/dist/types/components/alert/alert.style.d.ts +1 -1
- package/dist/types/components/alpha-slider/alpha-slider.d.ts +2 -2
- package/dist/types/components/aspect-ratio/aspect-ratio.d.ts +2 -2
- package/dist/types/components/autocomplete/autocomplete.d.ts +2 -2
- package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
- package/dist/types/components/autocomplete/use-autocomplete.d.ts +5 -5
- package/dist/types/components/avatar/avatar.d.ts +3 -3
- package/dist/types/components/avatar/use-avatar-group.d.ts +2 -2
- package/dist/types/components/badge/badge.d.ts +2 -2
- package/dist/types/components/bleed/bleed.d.ts +2 -2
- package/dist/types/components/blockquote/blockquote.d.ts +2 -2
- package/dist/types/components/breadcrumb/breadcrumb.d.ts +2 -2
- package/dist/types/components/breadcrumb/breadcrumb.style.d.ts +1 -1
- package/dist/types/components/breadcrumb/use-breadcrumb.d.ts +2 -2
- package/dist/types/components/button/button.d.ts +2 -2
- package/dist/types/components/button/icon-button.d.ts +2 -2
- package/dist/types/components/calendar/calendar.d.ts +2 -2
- package/dist/types/components/calendar/calendar.style.d.ts +2 -2
- package/dist/types/components/calendar/use-calendar.d.ts +8 -8
- package/dist/types/components/card/card.d.ts +2 -2
- package/dist/types/components/carousel/carousel.d.ts +2 -2
- package/dist/types/components/carousel/carousel.style.d.ts +2 -2
- package/dist/types/components/carousel/use-carousel.d.ts +3 -3
- package/dist/types/components/center/center.d.ts +2 -2
- package/dist/types/components/chart/area-chart.d.ts +2 -2
- package/dist/types/components/chart/bar-chart.d.ts +2 -2
- package/dist/types/components/chart/chart.d.ts +5 -5
- package/dist/types/components/chart/composed-chart.d.ts +2 -2
- package/dist/types/components/chart/donut-chart.d.ts +2 -2
- package/dist/types/components/chart/line-chart.d.ts +2 -2
- package/dist/types/components/chart/pie-chart.d.ts +2 -2
- package/dist/types/components/chart/radar-chart.d.ts +2 -2
- package/dist/types/components/chart/radial-chart.d.ts +2 -2
- package/dist/types/components/chart/use-chart.d.ts +2 -2
- package/dist/types/components/checkbox/checkbox.d.ts +4 -4
- package/dist/types/components/checkbox/use-checkbox-group.d.ts +2 -2
- package/dist/types/components/checkbox-card/checkbox-card.d.ts +5 -5
- package/dist/types/components/checkbox-card/checkbox-card.style.d.ts +1 -1
- package/dist/types/components/circle-progress/circle-progress.d.ts +2 -2
- package/dist/types/components/close-button/close-button.d.ts +2 -2
- package/dist/types/components/code/code.d.ts +2 -2
- package/dist/types/components/collapse/collapse.d.ts +2 -2
- package/dist/types/components/color-picker/color-picker.d.ts +2 -2
- package/dist/types/components/color-picker/color-picker.style.d.ts +1 -1
- package/dist/types/components/color-picker/use-color-picker.d.ts +2 -2
- package/dist/types/components/color-selector/color-selector.d.ts +2 -2
- package/dist/types/components/color-selector/color-selector.style.d.ts +2 -2
- package/dist/types/components/color-selector/use-color-selector.d.ts +3 -3
- package/dist/types/components/color-swatch/color-swatch.d.ts +2 -2
- package/dist/types/components/container/container.d.ts +2 -2
- package/dist/types/components/data-list/data-list.d.ts +2 -2
- package/dist/types/components/data-list/data-list.style.d.ts +1 -1
- package/dist/types/components/date-picker/date-picker.d.ts +2 -2
- package/dist/types/components/date-picker/date-picker.style.d.ts +1 -1
- package/dist/types/components/date-picker/use-date-picker.d.ts +4 -4
- package/dist/types/components/drawer/drawer.d.ts +2 -2
- package/dist/types/components/dropzone/dropzone.d.ts +5 -5
- package/dist/types/components/dropzone/dropzone.style.d.ts +1 -1
- package/dist/types/components/editable/editable.d.ts +4 -4
- package/dist/types/components/editable/use-editable.d.ts +2 -2
- package/dist/types/components/em/em.d.ts +2 -2
- package/dist/types/components/empty-state/empty-state.d.ts +2 -2
- package/dist/types/components/empty-state/empty-state.style.d.ts +2 -2
- package/dist/types/components/fade/fade.d.ts +2 -2
- package/dist/types/components/field/field.d.ts +3 -3
- package/dist/types/components/field/field.style.d.ts +2 -2
- package/dist/types/components/field/use-field-props.d.ts +8 -8
- package/dist/types/components/fieldset/fieldset.d.ts +3 -3
- package/dist/types/components/fieldset/fieldset.style.d.ts +1 -1
- package/dist/types/components/file-button/file-button.d.ts +2 -2
- package/dist/types/components/file-button/use-file-button.d.ts +18 -18
- package/dist/types/components/file-input/file-input.d.ts +2 -2
- package/dist/types/components/file-input/use-file-input.d.ts +17 -17
- package/dist/types/components/flex/flex.d.ts +2 -2
- package/dist/types/components/flip/flip.d.ts +4 -4
- package/dist/types/components/flip/flip.style.d.ts +1 -1
- package/dist/types/components/float/float.d.ts +2 -2
- package/dist/types/components/form/form.d.ts +3 -3
- package/dist/types/components/format/format-byte.d.ts +4 -4
- package/dist/types/components/format/format-date-time.d.ts +4 -4
- package/dist/types/components/format/format-number.d.ts +2 -2
- package/dist/types/components/grid/grid-item.d.ts +2 -2
- package/dist/types/components/grid/grid.d.ts +2 -2
- package/dist/types/components/group/group.d.ts +2 -2
- package/dist/types/components/group/use-group.d.ts +2 -2
- package/dist/types/components/heading/heading.d.ts +2 -2
- package/dist/types/components/hue-slider/hue-slider.d.ts +3 -3
- package/dist/types/components/icon/icon.d.ts +5 -5
- package/dist/types/components/image/image.d.ts +2 -2
- package/dist/types/components/indicator/indicator.d.ts +4 -4
- package/dist/types/components/infinite-scroll-area/infinite-scroll-area.d.ts +2 -2
- package/dist/types/components/input/input-addon.d.ts +2 -2
- package/dist/types/components/input/input-element.d.ts +2 -2
- package/dist/types/components/input/input.d.ts +2 -2
- package/dist/types/components/kbd/kbd.d.ts +2 -2
- package/dist/types/components/link/link.d.ts +2 -2
- package/dist/types/components/link-box/link-box.d.ts +2 -2
- package/dist/types/components/list/list.d.ts +2 -2
- package/dist/types/components/list/list.style.d.ts +2 -2
- package/dist/types/components/loading/loading-provider.d.ts +2 -2
- package/dist/types/components/loading/loading.d.ts +3 -3
- package/dist/types/components/mark/mark.d.ts +2 -2
- package/dist/types/components/menu/menu.d.ts +2 -2
- package/dist/types/components/menu/menu.style.d.ts +2 -2
- package/dist/types/components/menu/use-menu.d.ts +11 -11
- package/dist/types/components/modal/modal.d.ts +2 -2
- package/dist/types/components/native-accordion/native-accordion.d.ts +2 -2
- package/dist/types/components/native-accordion/native-accordion.style.d.ts +2 -2
- package/dist/types/components/native-accordion/use-native-accordion.d.ts +2 -2
- package/dist/types/components/native-popover/native-popover.d.ts +2 -2
- package/dist/types/components/native-select/native-select.d.ts +2 -2
- package/dist/types/components/native-table/native-table.d.ts +4 -4
- package/dist/types/components/notice/notice.style.d.ts +1 -1
- package/dist/types/components/number-input/number-input.d.ts +2 -2
- package/dist/types/components/pagination/pagination.d.ts +2 -2
- package/dist/types/components/pagination/pagination.style.d.ts +1 -1
- package/dist/types/components/pagination/use-pagination.d.ts +2 -2
- package/dist/types/components/password-input/password-input.d.ts +2 -2
- package/dist/types/components/password-input/strength-meter.d.ts +2 -2
- package/dist/types/components/password-input/use-password-input.d.ts +2 -2
- package/dist/types/components/pin-input/pin-input.d.ts +2 -2
- package/dist/types/components/pin-input/use-pin-input.d.ts +7 -7
- package/dist/types/components/popover/popover.d.ts +2 -2
- package/dist/types/components/progress/progress.d.ts +4 -4
- package/dist/types/components/progress/use-progress.d.ts +706 -706
- package/dist/types/components/qr-code/qr-code.d.ts +2 -2
- package/dist/types/components/radio/radio.d.ts +4 -4
- package/dist/types/components/radio/use-radio-group.d.ts +2 -2
- package/dist/types/components/radio-card/radio-card.d.ts +5 -5
- package/dist/types/components/radio-card/radio-card.style.d.ts +1 -1
- package/dist/types/components/rating/rating.style.d.ts +2 -2
- package/dist/types/components/rating/use-rating.d.ts +11 -11
- package/dist/types/components/reorder/reorder.d.ts +2 -2
- package/dist/types/components/reorder/reorder.style.d.ts +1 -1
- package/dist/types/components/reorder/use-reorder.d.ts +3 -3
- package/dist/types/components/resizable/resizable.d.ts +2 -2
- package/dist/types/components/resizable/resizable.style.d.ts +2 -2
- package/dist/types/components/resizable/use-resizable.d.ts +2 -2
- package/dist/types/components/ripple/ripple.d.ts +2 -2
- package/dist/types/components/ripple/use-ripple.d.ts +2 -2
- package/dist/types/components/rotate/rotate.d.ts +2 -2
- package/dist/types/components/saturation-slider/saturation-slider.d.ts +2 -2
- package/dist/types/components/saturation-slider/use-saturation-slider.d.ts +2 -2
- package/dist/types/components/scroll-area/scroll-area.d.ts +2 -2
- package/dist/types/components/segmented-control/segmented-control.d.ts +2 -2
- package/dist/types/components/segmented-control/segmented-control.style.d.ts +2 -2
- package/dist/types/components/segmented-control/use-segmented-control.d.ts +9 -9
- package/dist/types/components/select/select.d.ts +2 -2
- package/dist/types/components/select/select.style.d.ts +1 -1
- package/dist/types/components/select/use-select.d.ts +4 -4
- package/dist/types/components/separator/separator.d.ts +2 -2
- package/dist/types/components/sidebar/sidebar.d.ts +2 -2
- package/dist/types/components/sidebar/use-sidebar.d.ts +9 -9
- package/dist/types/components/simple-grid/simple-grid.d.ts +2 -2
- package/dist/types/components/skeleton/skeleton.d.ts +2 -2
- package/dist/types/components/slide/slide.d.ts +2 -2
- package/dist/types/components/slide-fade/slide-fade.d.ts +2 -2
- package/dist/types/components/slider/slider.d.ts +2 -2
- package/dist/types/components/slider/use-slider.d.ts +2 -2
- package/dist/types/components/stack/h-stack.d.ts +2 -2
- package/dist/types/components/stack/stack.d.ts +2 -2
- package/dist/types/components/stack/v-stack.d.ts +2 -2
- package/dist/types/components/stack/z-stack.d.ts +2 -2
- package/dist/types/components/stat/stat.d.ts +2 -2
- package/dist/types/components/stat/stat.style.d.ts +2 -2
- package/dist/types/components/status/status.d.ts +2 -2
- package/dist/types/components/steps/steps.d.ts +2 -2
- package/dist/types/components/steps/steps.style.d.ts +1 -1
- package/dist/types/components/steps/use-steps.d.ts +10 -10
- package/dist/types/components/switch/switch.d.ts +2 -2
- package/dist/types/components/table/table.d.ts +2 -2
- package/dist/types/components/tabs/tabs.d.ts +2 -2
- package/dist/types/components/tabs/tabs.style.d.ts +1 -1
- package/dist/types/components/tabs/use-tabs.d.ts +16 -16
- package/dist/types/components/tag/tag.d.ts +2 -2
- package/dist/types/components/text/text.d.ts +2 -2
- package/dist/types/components/textarea/textarea.d.ts +2 -2
- package/dist/types/components/textarea/use-autosize.d.ts +2 -2
- package/dist/types/components/timeline/timeline.d.ts +3 -3
- package/dist/types/components/timeline/timeline.style.d.ts +1 -1
- package/dist/types/components/toggle/toggle.d.ts +5 -5
- package/dist/types/components/toggle/use-toggle-group.d.ts +2 -2
- package/dist/types/components/toggle/use-toggle.d.ts +2 -2
- package/dist/types/components/tooltip/tooltip.d.ts +2 -2
- package/dist/types/components/tree/tree.d.ts +2 -2
- package/dist/types/components/tree/tree.style.d.ts +1 -1
- package/dist/types/components/tree/use-tree.d.ts +237 -237
- package/dist/types/components/visually-hidden/visually-hidden.d.ts +2 -2
- package/dist/types/components/wrap/wrap.d.ts +2 -2
- package/dist/types/core/components/create-component.d.ts +9 -9
- package/dist/types/core/system/color-mode-provider.d.ts +2 -2
- package/dist/types/core/system/storage-script.d.ts +3 -3
- package/dist/types/core/system/styled.d.ts +2 -2
- package/dist/types/core/system/system-provider.d.ts +2 -2
- package/dist/types/hooks/use-breakpoint/use-breakpoint-state.d.ts +2 -2
- package/dist/types/hooks/use-clickable/index.d.ts +9 -9
- package/dist/types/hooks/use-clipboard/index.d.ts +2 -2
- package/dist/types/hooks/use-combobox/index.d.ts +12 -12
- package/dist/types/hooks/use-counter/index.d.ts +2 -2
- package/dist/types/hooks/use-descendants/index.d.ts +2 -2
- package/dist/types/hooks/use-field-sizing/index.d.ts +2 -2
- package/dist/types/hooks/use-hover/index.d.ts +2 -2
- package/dist/types/hooks/use-popper/index.d.ts +2 -2
- package/dist/types/providers/i18n-provider/i18n-provider.d.ts +3 -3
- package/dist/types/providers/ui-provider/ui-provider.d.ts +2 -2
- package/dist/types/utils/children.d.ts +2 -2
- package/package.json +1 -1
|
@@ -111,7 +111,6 @@ const AccordionButton = withContext(({ children, icon: customIcon, suppressHydra
|
|
|
111
111
|
expanded: open
|
|
112
112
|
};
|
|
113
113
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.styled.h3, {
|
|
114
|
-
suppressHydrationWarning,
|
|
115
114
|
...containerProps,
|
|
116
115
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_factory.styled.button, {
|
|
117
116
|
...getButtonProps({
|
|
@@ -149,10 +148,7 @@ const AccordionPanel = withContext(({ animationOpacity, children, delay, duratio
|
|
|
149
148
|
suppressHydrationWarning,
|
|
150
149
|
...rest
|
|
151
150
|
}),
|
|
152
|
-
children: (0, require_utils_index.utils_exports.isString)(children) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.styled.p, {
|
|
153
|
-
suppressHydrationWarning,
|
|
154
|
-
children
|
|
155
|
-
}) : children
|
|
151
|
+
children: (0, require_utils_index.utils_exports.isString)(children) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.styled.p, { children }) : children
|
|
156
152
|
})
|
|
157
153
|
});
|
|
158
154
|
}, "panel")();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.cjs","names":["createContext","createSlotComponent","accordionStyle","useAccordion","index","props","AccordionDescendantsContext","AccordionContext","styled","useAccordionItem","useSplitChildren","AccordionItemContext","useAccordionItemContext","ChevronDownIcon","Children","Collapse"],"sources":["../../../../src/components/accordion/accordion.tsx"],"sourcesContent":["\"use client\"\n\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport type { CollapseProps } from \"../collapse\"\nimport type { WithTransitionProps } from \"../motion\"\nimport type { AccordionStyle } from \"./accordion.style\"\nimport type { UseAccordionItemProps, UseAccordionProps } from \"./use-accordion\"\nimport { Children, cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { createContext, isString, runIfFn, useSplitChildren } from \"../../utils\"\nimport { Collapse } from \"../collapse\"\nimport { ChevronDownIcon } from \"../icon\"\nimport { accordionStyle } from \"./accordion.style\"\nimport {\n AccordionContext,\n AccordionDescendantsContext,\n AccordionItemContext,\n useAccordion,\n useAccordionItem,\n useAccordionItemContext,\n} from \"./use-accordion\"\n\ninterface AccordionCallBackProps {\n disabled?: boolean\n expanded?: boolean\n}\n\nexport interface AccordionItem extends Omit<AccordionItemProps, \"index\"> {}\n\ninterface ComponentContext extends Pick<\n AccordionRootProps,\n \"icon\" | \"iconHidden\"\n> {}\n\nexport interface AccordionRootProps\n extends\n Omit<HTMLStyledProps, \"onChange\">,\n ThemeProps<AccordionStyle>,\n UseAccordionProps {\n /**\n * The accordion icon for all items to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * If `true`, hide the accordion icon for all items.\n *\n * @default false\n */\n iconHidden?: boolean\n /**\n * If provided, generate elements based on items.\n */\n items?: AccordionItem[]\n}\n\ninterface ItemComponentContext extends Pick<AccordionItemProps, \"icon\"> {}\n\nconst [ItemComponentContext, useItemComponentContext] =\n createContext<ItemComponentContext>({\n name: \"ItemComponentContext\",\n })\n\nconst {\n ComponentContext,\n PropsContext: AccordionPropsContext,\n useComponentContext,\n usePropsContext: useAccordionPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<AccordionRootProps, AccordionStyle, ComponentContext>(\n \"accordion\",\n accordionStyle,\n)\n\nexport { AccordionPropsContext, useAccordionPropsContext }\n\n/**\n * `Accordion` is a component for a list that displays information in an expandable or collapsible manner.\n *\n * @see https://yamada-ui.com/docs/components/accordion\n */\nexport const AccordionRoot = withProvider<\"div\", AccordionRootProps>(\n ({ children, icon, iconHidden, items, ...props }) => {\n const {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n } = useAccordion(props)\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return items?.map((props, index) => (\n <AccordionItem key={index} index={index} {...props} />\n ))\n }, [children, items])\n const context = useMemo(\n () => ({\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n }),\n [focusedIndex, index, multiple, setFocusedIndex, setIndex, toggle],\n )\n const componentContext = useMemo(\n () => ({ icon, iconHidden }),\n [icon, iconHidden],\n )\n\n return (\n <AccordionDescendantsContext value={descendants}>\n <AccordionContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.div {...getRootProps()}>{computedChildren}</styled.div>\n </ComponentContext>\n </AccordionContext>\n </AccordionDescendantsContext>\n )\n },\n \"root\",\n)()\n\nexport interface AccordionItemProps\n extends\n Omit<HTMLStyledProps, \"children\">,\n Omit<UseAccordionItemProps, \"children\"> {\n /**\n * The accordion button to use.\n */\n button?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * The accordion children to use.\n */\n children?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * The accordion icon to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n}\n\nexport const AccordionItem = withContext<\"div\", AccordionItemProps>(\n ({ button, children, icon, ...rest }) => {\n const {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n } = useAccordionItem(rest)\n const computedChildren = useMemo(\n () => runIfFn(children, { disabled, expanded: open }),\n [children, disabled, open],\n )\n const [omittedChildren, customAccordionButton, customAccordionPanel] =\n useSplitChildren(computedChildren, AccordionButton, AccordionPanel)\n const context = useMemo(\n () => ({\n disabled,\n icon,\n open,\n getButtonProps,\n getIconProps,\n getPanelProps,\n }),\n [disabled, getButtonProps, getPanelProps, getIconProps, icon, open],\n )\n const componentContext = useMemo(() => ({ icon }), [icon])\n\n return (\n <AccordionItemContext value={context}>\n <ItemComponentContext value={componentContext}>\n <styled.div {...getItemProps()}>\n {customAccordionButton ?? (\n <AccordionButton>\n {runIfFn(button, { disabled, expanded: open })}\n </AccordionButton>\n )}\n {customAccordionPanel ?? (\n <AccordionPanel>{omittedChildren}</AccordionPanel>\n )}\n </styled.div>\n </ItemComponentContext>\n </AccordionItemContext>\n )\n },\n \"item\",\n)()\n\nexport interface AccordionButtonProps extends HTMLStyledProps<\"button\"> {\n /**\n * The accordion icon to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * Props the container element.\n */\n containerProps?: HTMLStyledProps\n}\n\nexport const AccordionButton = withContext<\"button\", AccordionButtonProps>(\n ({\n children,\n icon: customIcon,\n suppressHydrationWarning,\n containerProps,\n ...rest\n }) => {\n const { icon: rootIcon } = useComponentContext()\n const { icon: itemIcon } = useItemComponentContext()\n const { disabled, open, getButtonProps } = useAccordionItemContext()\n const props = { disabled, expanded: open }\n\n return (\n <styled.h3\n suppressHydrationWarning={suppressHydrationWarning}\n {...containerProps}\n >\n <styled.button\n {...getButtonProps({ suppressHydrationWarning, ...rest })}\n >\n {children}\n\n <AccordionIcon>\n {runIfFn(customIcon, props) ??\n runIfFn(itemIcon, props) ??\n runIfFn(rootIcon, props)}\n </AccordionIcon>\n </styled.button>\n </styled.h3>\n )\n },\n \"button\",\n)()\n\ninterface AccordionIconProps extends HTMLStyledProps<\"svg\"> {}\n\nexport const AccordionIcon = withContext<\"svg\", AccordionIconProps>(\n ({ children = <ChevronDownIcon />, ...rest }) => {\n const { iconHidden } = useComponentContext()\n const { getIconProps } = useAccordionItemContext()\n\n if (iconHidden) return null\n\n if (isValidElement<HTMLProps<\"svg\">>(children))\n return cloneElement(\n children,\n getIconProps({\n ...rest,\n ...children.props,\n }),\n )\n\n return Children.count(children) > 1 ? Children.only(null) : null\n },\n \"icon\",\n)()\n\nexport interface AccordionPanelProps\n extends\n Omit<HTMLStyledProps, \"transition\">,\n Pick<\n CollapseProps,\n | \"animationOpacity\"\n | \"endingHeight\"\n | \"startingHeight\"\n | keyof WithTransitionProps\n > {}\n\nexport const AccordionPanel = withContext<\"div\", AccordionPanelProps>(\n ({\n animationOpacity,\n children,\n delay,\n duration,\n endingHeight,\n startingHeight,\n suppressHydrationWarning,\n transition,\n transitionEnd,\n unmountOnExit,\n ...rest\n }) => {\n const { open, getPanelProps } = useAccordionItemContext()\n\n return (\n <Collapse\n {...{\n animationOpacity,\n delay,\n duration,\n endingHeight,\n open,\n startingHeight,\n transition,\n transitionEnd,\n unmountOnExit,\n }}\n >\n <styled.div {...getPanelProps({ suppressHydrationWarning, ...rest })}>\n {isString(children) ? (\n <styled.p suppressHydrationWarning={suppressHydrationWarning}>\n {children}\n </styled.p>\n ) : (\n children\n )}\n </styled.div>\n </Collapse>\n )\n },\n \"panel\",\n)()\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0DA,MAAM,CAAC,sBAAsB,2BAC3BA,8BAAoC,EAClC,MAAM,wBACP,CAAC;AAEJ,MAAM,EACJ,kBACA,cAAc,uBACd,qBACA,iBAAiB,0BACjB,aACA,iBACEC,6CACF,aACAC,uCACD;;;;;;AASD,MAAa,gBAAgB,cAC1B,EAAE,UAAU,MAAM,YAAY,OAAO,GAAG,YAAY;CACnD,MAAM,EACJ,aACA,cACA,OACA,UACA,iBACA,UACA,QACA,iBACEC,mCAAa,MAAM;CACvB,MAAM,4CAAiC;AACrC,MAAI,SAAU,QAAO;AAErB,SAAO,OAAO,KAAK,SAAO,YACxB,2CAAC;GAA0B,OAAOC;GAAO,GAAIC;KAAzBD,QAAkC,CACtD;IACD,CAAC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2CAACJ,uBAAO;EACoB;EAC1B,GAAI;YAEJ,4CAACA,uBAAO;GACN,GAAI,eAAe;IAAE;IAA0B,GAAG;IAAM,CAAC;cAExD,UAED,2CAAC,0EACU,YAAY,MAAM,mDACjB,UAAU,MAAM,mDAChB,UAAU,MAAM,GACZ;IACF;GACN;GAGhB,SACD,EAAE;AAIH,MAAa,gBAAgB,aAC1B,EAAE,WAAW,2CAACK,8CAAkB,EAAE,GAAG,WAAW;CAC/C,MAAM,EAAE,eAAe,qBAAqB;CAC5C,MAAM,EAAE,iBAAiBD,+CAAyB;AAElD,KAAI,WAAY,QAAO;AAEvB,+BAAqC,SAAS,CAC5C,gCACE,UACA,aAAa;EACX,GAAG;EACH,GAAG,SAAS;EACb,CAAC,CACH;AAEH,QAAOE,eAAS,MAAM,SAAS,GAAG,IAAIA,eAAS,KAAK,KAAK,GAAG;GAE9D,OACD,EAAE;AAaH,MAAa,iBAAiB,aAC3B,EACC,kBACA,UACA,OACA,UACA,cACA,gBACA,0BACA,YACA,eACA,eACA,GAAG,WACC;CACJ,MAAM,EAAE,MAAM,kBAAkBF,+CAAyB;AAEzD,QACE,2CAACG;EAEG;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;YAGF,2CAACP,uBAAO;GAAI,GAAI,cAAc;IAAE;IAA0B,GAAG;IAAM,CAAC;6DACxD,SAAS,GACjB,2CAACA,uBAAO;IAA4B;IACjC;KACQ,GAEX;IAES;GACJ;GAGf,QACD,EAAE"}
|
|
1
|
+
{"version":3,"file":"accordion.cjs","names":["createContext","createSlotComponent","accordionStyle","useAccordion","index","props","AccordionDescendantsContext","AccordionContext","styled","useAccordionItem","useSplitChildren","AccordionItemContext","useAccordionItemContext","ChevronDownIcon","Children","Collapse"],"sources":["../../../../src/components/accordion/accordion.tsx"],"sourcesContent":["\"use client\"\n\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport type { CollapseProps } from \"../collapse\"\nimport type { WithTransitionProps } from \"../motion\"\nimport type { AccordionStyle } from \"./accordion.style\"\nimport type { UseAccordionItemProps, UseAccordionProps } from \"./use-accordion\"\nimport { Children, cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { createContext, isString, runIfFn, useSplitChildren } from \"../../utils\"\nimport { Collapse } from \"../collapse\"\nimport { ChevronDownIcon } from \"../icon\"\nimport { accordionStyle } from \"./accordion.style\"\nimport {\n AccordionContext,\n AccordionDescendantsContext,\n AccordionItemContext,\n useAccordion,\n useAccordionItem,\n useAccordionItemContext,\n} from \"./use-accordion\"\n\ninterface AccordionCallBackProps {\n disabled?: boolean\n expanded?: boolean\n}\n\nexport interface AccordionItem extends Omit<AccordionItemProps, \"index\"> {}\n\ninterface ComponentContext extends Pick<\n AccordionRootProps,\n \"icon\" | \"iconHidden\"\n> {}\n\nexport interface AccordionRootProps\n extends\n Omit<HTMLStyledProps, \"onChange\">,\n ThemeProps<AccordionStyle>,\n UseAccordionProps {\n /**\n * The accordion icon for all items to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * If `true`, hide the accordion icon for all items.\n *\n * @default false\n */\n iconHidden?: boolean\n /**\n * If provided, generate elements based on items.\n */\n items?: AccordionItem[]\n}\n\ninterface ItemComponentContext extends Pick<AccordionItemProps, \"icon\"> {}\n\nconst [ItemComponentContext, useItemComponentContext] =\n createContext<ItemComponentContext>({\n name: \"ItemComponentContext\",\n })\n\nconst {\n ComponentContext,\n PropsContext: AccordionPropsContext,\n useComponentContext,\n usePropsContext: useAccordionPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<AccordionRootProps, AccordionStyle, ComponentContext>(\n \"accordion\",\n accordionStyle,\n)\n\nexport { AccordionPropsContext, useAccordionPropsContext }\n\n/**\n * `Accordion` is a component for a list that displays information in an expandable or collapsible manner.\n *\n * @see https://yamada-ui.com/docs/components/accordion\n */\nexport const AccordionRoot = withProvider<\"div\", AccordionRootProps>(\n ({ children, icon, iconHidden, items, ...props }) => {\n const {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n } = useAccordion(props)\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return items?.map((props, index) => (\n <AccordionItem key={index} index={index} {...props} />\n ))\n }, [children, items])\n const context = useMemo(\n () => ({\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n }),\n [focusedIndex, index, multiple, setFocusedIndex, setIndex, toggle],\n )\n const componentContext = useMemo(\n () => ({ icon, iconHidden }),\n [icon, iconHidden],\n )\n\n return (\n <AccordionDescendantsContext value={descendants}>\n <AccordionContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.div {...getRootProps()}>{computedChildren}</styled.div>\n </ComponentContext>\n </AccordionContext>\n </AccordionDescendantsContext>\n )\n },\n \"root\",\n)()\n\nexport interface AccordionItemProps\n extends\n Omit<HTMLStyledProps, \"children\">,\n Omit<UseAccordionItemProps, \"children\"> {\n /**\n * The accordion button to use.\n */\n button?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * The accordion children to use.\n */\n children?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * The accordion icon to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n}\n\nexport const AccordionItem = withContext<\"div\", AccordionItemProps>(\n ({ button, children, icon, ...rest }) => {\n const {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n } = useAccordionItem(rest)\n const computedChildren = useMemo(\n () => runIfFn(children, { disabled, expanded: open }),\n [children, disabled, open],\n )\n const [omittedChildren, customAccordionButton, customAccordionPanel] =\n useSplitChildren(computedChildren, AccordionButton, AccordionPanel)\n const context = useMemo(\n () => ({\n disabled,\n icon,\n open,\n getButtonProps,\n getIconProps,\n getPanelProps,\n }),\n [disabled, getButtonProps, getPanelProps, getIconProps, icon, open],\n )\n const componentContext = useMemo(() => ({ icon }), [icon])\n\n return (\n <AccordionItemContext value={context}>\n <ItemComponentContext value={componentContext}>\n <styled.div {...getItemProps()}>\n {customAccordionButton ?? (\n <AccordionButton>\n {runIfFn(button, { disabled, expanded: open })}\n </AccordionButton>\n )}\n {customAccordionPanel ?? (\n <AccordionPanel>{omittedChildren}</AccordionPanel>\n )}\n </styled.div>\n </ItemComponentContext>\n </AccordionItemContext>\n )\n },\n \"item\",\n)()\n\nexport interface AccordionButtonProps extends HTMLStyledProps<\"button\"> {\n /**\n * The accordion icon to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * Props the container element.\n */\n containerProps?: HTMLStyledProps\n}\n\nexport const AccordionButton = withContext<\"button\", AccordionButtonProps>(\n ({\n children,\n icon: customIcon,\n suppressHydrationWarning,\n containerProps,\n ...rest\n }) => {\n const { icon: rootIcon } = useComponentContext()\n const { icon: itemIcon } = useItemComponentContext()\n const { disabled, open, getButtonProps } = useAccordionItemContext()\n const props = { disabled, expanded: open }\n\n return (\n <styled.h3 {...containerProps}>\n <styled.button\n {...getButtonProps({ suppressHydrationWarning, ...rest })}\n >\n {children}\n\n <AccordionIcon>\n {runIfFn(customIcon, props) ??\n runIfFn(itemIcon, props) ??\n runIfFn(rootIcon, props)}\n </AccordionIcon>\n </styled.button>\n </styled.h3>\n )\n },\n \"button\",\n)()\n\ninterface AccordionIconProps extends HTMLStyledProps<\"svg\"> {}\n\nexport const AccordionIcon = withContext<\"svg\", AccordionIconProps>(\n ({ children = <ChevronDownIcon />, ...rest }) => {\n const { iconHidden } = useComponentContext()\n const { getIconProps } = useAccordionItemContext()\n\n if (iconHidden) return null\n\n if (isValidElement<HTMLProps<\"svg\">>(children))\n return cloneElement(\n children,\n getIconProps({\n ...rest,\n ...children.props,\n }),\n )\n\n return Children.count(children) > 1 ? Children.only(null) : null\n },\n \"icon\",\n)()\n\nexport interface AccordionPanelProps\n extends\n Omit<HTMLStyledProps, \"transition\">,\n Pick<\n CollapseProps,\n | \"animationOpacity\"\n | \"endingHeight\"\n | \"startingHeight\"\n | keyof WithTransitionProps\n > {}\n\nexport const AccordionPanel = withContext<\"div\", AccordionPanelProps>(\n ({\n animationOpacity,\n children,\n delay,\n duration,\n endingHeight,\n startingHeight,\n suppressHydrationWarning,\n transition,\n transitionEnd,\n unmountOnExit,\n ...rest\n }) => {\n const { open, getPanelProps } = useAccordionItemContext()\n\n return (\n <Collapse\n {...{\n animationOpacity,\n delay,\n duration,\n endingHeight,\n open,\n startingHeight,\n transition,\n transitionEnd,\n unmountOnExit,\n }}\n >\n <styled.div {...getPanelProps({ suppressHydrationWarning, ...rest })}>\n {isString(children) ? <styled.p>{children}</styled.p> : children}\n </styled.div>\n </Collapse>\n )\n },\n \"panel\",\n)()\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0DA,MAAM,CAAC,sBAAsB,2BAC3BA,8BAAoC,EAClC,MAAM,wBACP,CAAC;AAEJ,MAAM,EACJ,kBACA,cAAc,uBACd,qBACA,iBAAiB,0BACjB,aACA,iBACEC,6CACF,aACAC,uCACD;;;;;;AASD,MAAa,gBAAgB,cAC1B,EAAE,UAAU,MAAM,YAAY,OAAO,GAAG,YAAY;CACnD,MAAM,EACJ,aACA,cACA,OACA,UACA,iBACA,UACA,QACA,iBACEC,mCAAa,MAAM;CACvB,MAAM,4CAAiC;AACrC,MAAI,SAAU,QAAO;AAErB,SAAO,OAAO,KAAK,SAAO,YACxB,2CAAC;GAA0B,OAAOC;GAAO,GAAIC;KAAzBD,QAAkC,CACtD;IACD,CAAC,UAAU,MAAM,CAAC;AAiBrB,QACE,2CAACE;EAA4B,OAAO;YAClC,2CAACC;GAAiB,iCAjBb;IACL;IACA;IACA;IACA;IACA;IACA;IACD,GACD;IAAC;IAAc;IAAO;IAAU;IAAiB;IAAU;IAAO,CACnE;aASK,2CAAC;IAAiB,iCAPf;KAAE;KAAM;KAAY,GAC3B,CAAC,MAAM,WAAW,CACnB;cAMO,2CAACC,uBAAO;KAAI,GAAI,cAAc;eAAG;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EAAE,eAAe,qBAAqB;CAC5C,MAAM,EAAE,iBAAiBD,+CAAyB;AAElD,KAAI,WAAY,QAAO;AAEvB,+BAAqC,SAAS,CAC5C,gCACE,UACA,aAAa;EACX,GAAG;EACH,GAAG,SAAS;EACb,CAAC,CACH;AAEH,QAAOE,eAAS,MAAM,SAAS,GAAG,IAAIA,eAAS,KAAK,KAAK,GAAG;GAE9D,OACD,EAAE;AAaH,MAAa,iBAAiB,aAC3B,EACC,kBACA,UACA,OACA,UACA,cACA,gBACA,0BACA,YACA,eACA,eACA,GAAG,WACC;CACJ,MAAM,EAAE,MAAM,kBAAkBF,+CAAyB;AAEzD,QACE,2CAACG;EAEG;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;YAGF,2CAACP,uBAAO;GAAI,GAAI,cAAc;IAAE;IAA0B,GAAG;IAAM,CAAC;6DACxD,SAAS,GAAG,2CAACA,uBAAO,KAAG,WAAoB,GAAG;IAC7C;GACJ;GAGf,QACD,EAAE"}
|
|
@@ -4,6 +4,7 @@ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
|
4
4
|
const require_context = require('../../utils/context.cjs');
|
|
5
5
|
const require_utils_index = require('../../utils/index.cjs');
|
|
6
6
|
const require_factory = require('../../core/system/factory.cjs');
|
|
7
|
+
const require_props = require('../../core/components/props.cjs');
|
|
7
8
|
const require_create_component = require('../../core/components/create-component.cjs');
|
|
8
9
|
require('../../core/index.cjs');
|
|
9
10
|
const require_chevron_right_icon = require('../icon/icons/chevron-right-icon.cjs');
|
|
@@ -143,13 +144,18 @@ const TreeItem = withContext(({ className, css, colorScheme, animated: animatedP
|
|
|
143
144
|
query: query ?? ((0, require_utils_index.utils_exports.isString)(label) ? label : void 0),
|
|
144
145
|
value: valueProp
|
|
145
146
|
});
|
|
146
|
-
const itemProps = {
|
|
147
|
+
const itemProps = (0, react.useMemo)(() => require_props.mergeProps({
|
|
147
148
|
className,
|
|
148
149
|
css,
|
|
149
150
|
colorScheme,
|
|
150
|
-
"--level": level.toString()
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
"--level": level.toString()
|
|
152
|
+
}, rootProps)(), [
|
|
153
|
+
className,
|
|
154
|
+
css,
|
|
155
|
+
colorScheme,
|
|
156
|
+
level,
|
|
157
|
+
rootProps
|
|
158
|
+
]);
|
|
153
159
|
const callbackProps = {
|
|
154
160
|
disabled,
|
|
155
161
|
expanded: groupOpen
|
|
@@ -176,27 +182,12 @@ const TreeItem = withContext(({ className, css, colorScheme, animated: animatedP
|
|
|
176
182
|
value: (0, react.useMemo)(() => ({
|
|
177
183
|
checkboxProps: {
|
|
178
184
|
size: componentContext.size,
|
|
179
|
-
...getCheckboxProps(
|
|
180
|
-
...componentContext.checkboxProps,
|
|
181
|
-
...checkboxProps
|
|
182
|
-
})
|
|
183
|
-
},
|
|
184
|
-
endElementProps: {
|
|
185
|
-
...componentContext.endElementProps,
|
|
186
|
-
...endElementProps
|
|
185
|
+
...getCheckboxProps(require_props.mergeProps(componentContext.checkboxProps, checkboxProps)())
|
|
187
186
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
labelProps: { ...getLabelProps({
|
|
193
|
-
...componentContext.labelProps,
|
|
194
|
-
...labelProps
|
|
195
|
-
}) },
|
|
196
|
-
startElementProps: {
|
|
197
|
-
...componentContext.startElementProps,
|
|
198
|
-
...startElementProps
|
|
199
|
-
}
|
|
187
|
+
endElementProps: require_props.mergeProps(componentContext.endElementProps, endElementProps)(),
|
|
188
|
+
indicatorProps: { ...getIndicatorProps(require_props.mergeProps(componentContext.indicatorProps, indicatorProps)()) },
|
|
189
|
+
labelProps: { ...getLabelProps(require_props.mergeProps(componentContext.labelProps, labelProps)()) },
|
|
190
|
+
startElementProps: require_props.mergeProps(componentContext.startElementProps, startElementProps)()
|
|
200
191
|
}), [
|
|
201
192
|
checkboxProps,
|
|
202
193
|
componentContext.checkboxProps,
|
|
@@ -231,10 +222,7 @@ const TreeItem = withContext(({ className, css, colorScheme, animated: animatedP
|
|
|
231
222
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TreeGroup, {
|
|
232
223
|
duration: !animated ? 0 : void 0,
|
|
233
224
|
open: groupOpen,
|
|
234
|
-
...getGroupProps(
|
|
235
|
-
...componentContext.groupProps,
|
|
236
|
-
...groupProps
|
|
237
|
-
}),
|
|
225
|
+
...getGroupProps(require_props.mergeProps(componentContext.groupProps, groupProps)()),
|
|
238
226
|
children
|
|
239
227
|
})]
|
|
240
228
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.styled.li, {
|
|
@@ -270,44 +258,29 @@ const TreeIndicator = withContext(({ children = /* @__PURE__ */ (0, react_jsx_ru
|
|
|
270
258
|
return react.Children.count(children) > 1 ? react.Children.only(null) : null;
|
|
271
259
|
}, "indicator")(void 0, (props) => {
|
|
272
260
|
const { indicatorProps } = useItemComponentContext();
|
|
273
|
-
return
|
|
274
|
-
...indicatorProps,
|
|
275
|
-
...props
|
|
276
|
-
};
|
|
261
|
+
return require_props.mergeProps(indicatorProps, props)();
|
|
277
262
|
});
|
|
278
263
|
const TreeCheckbox = withContext(require_checkbox.Checkbox, "checkbox")(void 0, (props) => {
|
|
279
264
|
const { checkboxProps } = useItemComponentContext();
|
|
280
|
-
return
|
|
281
|
-
...checkboxProps,
|
|
282
|
-
...props
|
|
283
|
-
};
|
|
265
|
+
return require_props.mergeProps(checkboxProps, props)();
|
|
284
266
|
});
|
|
285
267
|
const TreeStartElement = withContext("div", {
|
|
286
268
|
name: "StartElement",
|
|
287
269
|
slot: ["element", "start"]
|
|
288
270
|
})(void 0, (props) => {
|
|
289
271
|
const { startElementProps } = useItemComponentContext();
|
|
290
|
-
return
|
|
291
|
-
...startElementProps,
|
|
292
|
-
...props
|
|
293
|
-
};
|
|
272
|
+
return require_props.mergeProps(startElementProps, props)();
|
|
294
273
|
});
|
|
295
274
|
const TreeEndElement = withContext("div", {
|
|
296
275
|
name: "EndElement",
|
|
297
276
|
slot: ["element", "end"]
|
|
298
277
|
})(void 0, (props) => {
|
|
299
278
|
const { endElementProps } = useItemComponentContext();
|
|
300
|
-
return
|
|
301
|
-
...endElementProps,
|
|
302
|
-
...props
|
|
303
|
-
};
|
|
279
|
+
return require_props.mergeProps(endElementProps, props)();
|
|
304
280
|
});
|
|
305
281
|
const TreeLabel = withContext("span", "label")(void 0, (props) => {
|
|
306
282
|
const { labelProps } = useItemComponentContext();
|
|
307
|
-
return
|
|
308
|
-
...labelProps,
|
|
309
|
-
...props
|
|
310
|
-
};
|
|
283
|
+
return require_props.mergeProps(labelProps, props)();
|
|
311
284
|
});
|
|
312
285
|
|
|
313
286
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.cjs","names":["createContext","createSlotComponent","treeStyle","useTree","TreeDescendantsContext","TreeContext","styled","useTreeContext","useLoadingComponent","useTreeItem","TreeItemContext","Collapse","ChevronRightIcon","Children","Checkbox"],"sources":["../../../../src/components/tree/tree.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement, ReactNode } from \"react\"\nimport type {\n GenericsComponent,\n HTMLProps,\n HTMLStyledProps,\n ThemeProps,\n} from \"../../core\"\nimport type { CheckboxProps } from \"../checkbox\"\nimport type { CollapseProps } from \"../collapse\"\nimport type { Loading } from \"../loading\"\nimport type { WithTransitionProps } from \"../motion\"\nimport type { TreeStyle } from \"./tree.style\"\nimport type { UseTreeItemProps, UseTreeProps } from \"./use-tree\"\nimport {\n Children,\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n} from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport {\n cast,\n createContext,\n dataAttr,\n isObject,\n isString,\n type ReactNodeOrFunction,\n runIfFn,\n} from \"../../utils\"\nimport { Checkbox } from \"../checkbox\"\nimport { Collapse } from \"../collapse\"\nimport { ChevronRightIcon } from \"../icon\"\nimport { useLoadingComponent } from \"../loading\"\nimport { treeStyle } from \"./tree.style\"\nimport {\n TreeContext,\n TreeDescendantsContext,\n TreeItemContext,\n useTree,\n useTreeContext,\n useTreeItem,\n} from \"./use-tree\"\n\ninterface TreeCallBackProps {\n disabled?: boolean\n expanded?: boolean\n}\n\ntype TreeItemReactNode =\n | ReactNodeOrFunction<TreeCallBackProps>\n | {\n group: ReactNodeOrFunction<TreeCallBackProps>\n item?: ReactNodeOrFunction<TreeCallBackProps>\n }\n | {\n item: ReactNodeOrFunction<TreeCallBackProps>\n group?: ReactNodeOrFunction<TreeCallBackProps>\n }\n\ninterface TreeItemWithValue extends Omit<TreeItemProps, \"children\"> {}\n\ninterface TreeItemWithChildren extends TreeItemWithValue {\n children: TreeItem[]\n}\n\nexport type TreeItem = TreeItemWithChildren | TreeItemWithValue\n\nconst recursiveTreeItem = (items?: TreeItem[]) => {\n return items?.map((props, index) => {\n const key =\n props.value || (isString(props.label) ? `${props.label}-${index}` : index)\n\n if (\"children\" in props) {\n const { children, ...rest } = props\n\n return (\n <TreeItem key={key} {...rest}>\n {recursiveTreeItem(children)}\n </TreeItem>\n )\n } else {\n return <TreeItem key={key} {...props} />\n }\n })\n}\n\nconst getReactNodeOrFunction = (\n type: \"group\" | \"item\",\n custom?: TreeItemReactNode,\n root?: TreeItemReactNode,\n): ReactNodeOrFunction<TreeCallBackProps> => {\n if (isObject(custom) && (\"group\" in custom || \"item\" in custom)) {\n return custom[type]\n } else if (custom) {\n return custom\n } else if (isObject(root) && (\"group\" in root || \"item\" in root)) {\n return root[type]\n } else {\n return root\n }\n}\n\ninterface ComponentContext extends Pick<\n TreeRootProps,\n | \"animated\"\n | \"checkboxProps\"\n | \"endElement\"\n | \"endElementProps\"\n | \"groupProps\"\n | \"indicator\"\n | \"indicatorHidden\"\n | \"indicatorProps\"\n | \"itemProps\"\n | \"labelProps\"\n | \"loadingScheme\"\n | \"size\"\n | \"startElement\"\n | \"startElementProps\"\n> {}\n\ninterface ItemComponentContext {\n checkboxProps: TreeCheckboxProps\n endElementProps: TreeEndElementProps\n indicatorProps: TreeIndicatorProps\n labelProps: TreeLabelProps\n startElementProps: TreeStartElementProps\n}\n\nconst [ItemComponentContext, useItemComponentContext] =\n createContext<ItemComponentContext>({ name: \"ItemComponentContext\" })\n\nexport interface TreeRootProps<Multiple extends boolean = false>\n extends\n HTMLStyledProps<\"ul\">,\n ThemeProps<TreeStyle>,\n UseTreeProps<Multiple>,\n Pick<\n TreeItemProps,\n | \"animated\"\n | \"checkboxProps\"\n | \"endElement\"\n | \"endElementProps\"\n | \"groupProps\"\n | \"indicator\"\n | \"indicatorProps\"\n | \"labelProps\"\n | \"loadingScheme\"\n | \"startElement\"\n | \"startElementProps\"\n > {\n /**\n * If `true`, hide the tree indicator icon for all items.\n *\n * @default false\n */\n indicatorHidden?: boolean\n /**\n * If provided, generate elements based on items.\n */\n items?: TreeItem[]\n /**\n * Props for the item component.\n */\n itemProps?: Omit<\n TreeItemProps,\n \"children\" | \"label\" | \"open\" | \"query\" | \"value\"\n >\n}\n\nconst {\n ComponentContext,\n PropsContext: TreePropsContext,\n useComponentContext,\n usePropsContext: useTreePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<TreeRootProps, TreeStyle, ComponentContext>(\n \"tree\",\n treeStyle,\n)\n\nexport { TreePropsContext, useTreePropsContext }\n\n/**\n * `Tree` is a component used to display hierarchical data structures in an expandable tree format.\n *\n * @see https://yamada-ui.com/docs/components/tree\n */\nexport const TreeRoot = withProvider<\"ul\", TreeRootProps, \"size\">(\n <Multiple extends boolean = false>({\n size,\n animated,\n children,\n endElement,\n indicator,\n indicatorHidden,\n items,\n loadingScheme,\n startElement,\n checkboxProps,\n endElementProps,\n groupProps,\n indicatorProps,\n itemProps,\n labelProps,\n startElementProps,\n ...rest\n }: TreeRootProps<Multiple>) => {\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return recursiveTreeItem(items)\n }, [children, items])\n const {\n activeDescendant,\n checkable,\n checkedValue,\n descendants,\n expandedValue,\n multiple,\n selectedValue,\n getRootProps,\n onActiveDescendant,\n onCheckedChange,\n onCollapseAll,\n onExpandAll,\n onExpandedChange,\n onSearch,\n onSelectedChange,\n } = useTree({ ...rest, children: computedChildren })\n const context = useMemo(\n () => ({\n activeDescendant,\n checkable,\n checkedValue,\n expandedValue,\n multiple,\n selectedValue,\n onActiveDescendant,\n onCheckedChange,\n onCollapseAll,\n onExpandAll,\n onExpandedChange,\n onSearch,\n onSelectedChange,\n }),\n [\n activeDescendant,\n checkable,\n checkedValue,\n expandedValue,\n multiple,\n selectedValue,\n onActiveDescendant,\n onCheckedChange,\n onSearch,\n onCollapseAll,\n onExpandAll,\n onExpandedChange,\n onSelectedChange,\n ],\n )\n const componentContext = useMemo(\n () => ({\n size,\n animated,\n endElement,\n indicator,\n indicatorHidden,\n loadingScheme,\n startElement,\n checkboxProps,\n endElementProps,\n groupProps,\n indicatorProps,\n itemProps,\n labelProps,\n startElementProps,\n }),\n [\n size,\n animated,\n endElement,\n indicator,\n indicatorHidden,\n startElement,\n endElementProps,\n groupProps,\n indicatorProps,\n itemProps,\n labelProps,\n startElementProps,\n checkboxProps,\n loadingScheme,\n ],\n )\n\n return (\n <TreeDescendantsContext value={descendants}>\n <TreeContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.ul {...getRootProps()} />\n </ComponentContext>\n </TreeContext>\n </TreeDescendantsContext>\n )\n },\n \"root\",\n { transferProps: [\"size\"] },\n)() as GenericsComponent<{\n <Multiple extends boolean = false>(\n props: TreeRootProps<Multiple>,\n ): ReactElement\n}>\n\nexport interface TreeItemProps\n extends HTMLStyledProps<\"div\">, Omit<UseTreeItemProps, \"asyncChildren\"> {\n /**\n * The label to display in the item.\n */\n label: ReactNode\n /**\n * If `true`, the tree item will be animated.\n *\n * @default false\n */\n animated?: boolean\n /**\n * The element to display at the end of the item.\n */\n endElement?: TreeItemReactNode\n /**\n * The tree indicator icon to use.\n */\n indicator?: ReactNodeOrFunction<TreeCallBackProps>\n /**\n * The loading scheme.\n *\n * @default 'oval'\n */\n loadingScheme?: Loading.Scheme\n /**\n * The element to display at the start of the item.\n */\n startElement?: TreeItemReactNode\n /**\n * Props for the checkbox component.\n */\n checkboxProps?: Omit<CheckboxProps, \"checked\" | \"defaultChecked\" | \"value\">\n /**\n * Props for the end component.\n */\n endElementProps?: TreeEndElementProps\n /**\n * Props for the group component.\n */\n groupProps?: Omit<TreeGroupProps, \"children\">\n /**\n * Props for the indicator component.\n */\n indicatorProps?: TreeIndicatorProps\n /**\n * Props for the label component.\n */\n labelProps?: TreeLabelProps\n /**\n * Props for the root element.\n */\n rootProps?: HTMLStyledProps<\"li\">\n /**\n * Props for the start component.\n */\n startElementProps?: TreeStartElementProps\n /**\n * If provided, the tree item will be rendered as an async tree item.\n */\n asyncChildren?: () => Promise<TreeItem[]>\n}\n\nexport const TreeItem = withContext<\"div\", TreeItemProps>(\n ({\n className,\n css,\n colorScheme,\n animated: animatedProp,\n asyncChildren: asyncChildrenProp,\n endElement,\n indicator: indicatorProp,\n label,\n loadingScheme,\n query,\n startElement,\n value: valueProp = isString(label) ? label : undefined,\n checkboxProps,\n endElementProps,\n groupProps,\n indicatorProps,\n labelProps,\n rootProps,\n startElementProps,\n ...rest\n }) => {\n const { checkable } = useTreeContext()\n const componentContext = useComponentContext()\n const Loading = useLoadingComponent(\n loadingScheme ?? componentContext.loadingScheme ?? \"oval\",\n )\n const animated = animatedProp ?? componentContext.animated\n const indicator = indicatorProp ?? componentContext.indicator\n const groupStartElement = getReactNodeOrFunction(\n \"group\",\n startElement,\n componentContext.startElement,\n )\n const groupEndElement = getReactNodeOrFunction(\n \"group\",\n endElement,\n componentContext.endElement,\n )\n const itemStartElement = getReactNodeOrFunction(\n \"item\",\n startElement,\n componentContext.startElement,\n )\n const itemEndElement = getReactNodeOrFunction(\n \"item\",\n endElement,\n componentContext.endElement,\n )\n const asyncChildren = useCallback(async () => {\n const items = await asyncChildrenProp?.()\n\n return recursiveTreeItem(items)\n }, [asyncChildrenProp])\n const {\n branchOpen,\n children,\n disabled,\n group,\n groupLoading,\n groupOpen,\n level,\n props,\n value,\n getCheckboxProps,\n getGroupItemProps,\n getGroupProps,\n getIndicatorProps,\n getItemProps,\n getLabelProps,\n onGroupClose,\n onGroupOpen,\n onGroupToggle,\n } = useTreeItem({\n ...componentContext.itemProps,\n ...rest,\n asyncChildren: asyncChildrenProp ? asyncChildren : undefined,\n query: query ?? (isString(label) ? label : undefined),\n value: valueProp,\n })\n const itemProps = {\n className,\n css,\n colorScheme,\n \"--level\": level.toString(),\n ...rootProps,\n }\n const callbackProps = { disabled, expanded: groupOpen }\n const context = useMemo(\n () => ({\n branchOpen,\n groupOpen,\n level,\n value,\n onGroupClose,\n onGroupOpen,\n onGroupToggle,\n }),\n [\n branchOpen,\n groupOpen,\n level,\n value,\n onGroupClose,\n onGroupOpen,\n onGroupToggle,\n ],\n )\n const itemComponentContext = useMemo(\n () => ({\n checkboxProps: {\n size: componentContext.size,\n ...getCheckboxProps({\n ...componentContext.checkboxProps,\n ...checkboxProps,\n }),\n },\n endElementProps: {\n ...componentContext.endElementProps,\n ...endElementProps,\n },\n indicatorProps: {\n ...getIndicatorProps({\n ...componentContext.indicatorProps,\n ...indicatorProps,\n }),\n },\n labelProps: {\n ...getLabelProps({\n ...componentContext.labelProps,\n ...labelProps,\n }),\n },\n startElementProps: {\n ...componentContext.startElementProps,\n ...startElementProps,\n },\n }),\n [\n checkboxProps,\n componentContext.checkboxProps,\n componentContext.endElementProps,\n componentContext.indicatorProps,\n componentContext.labelProps,\n componentContext.size,\n componentContext.startElementProps,\n endElementProps,\n getCheckboxProps,\n getIndicatorProps,\n getLabelProps,\n indicatorProps,\n labelProps,\n startElementProps,\n ],\n )\n\n return (\n <TreeItemContext value={context}>\n <ItemComponentContext value={itemComponentContext}>\n {group ? (\n <styled.li {...getGroupItemProps(itemProps)}>\n <styled.div data-content {...props}>\n <TreeIndicator data-animated={dataAttr(animated)}>\n {groupLoading ? (\n <Loading />\n ) : (\n runIfFn(indicator, callbackProps)\n )}\n </TreeIndicator>\n {checkable ? <TreeCheckbox /> : null}\n {groupStartElement ? (\n <TreeStartElement>\n {runIfFn(groupStartElement, callbackProps)}\n </TreeStartElement>\n ) : null}\n {label ? <TreeLabel>{label}</TreeLabel> : null}\n {groupEndElement ? (\n <TreeEndElement>\n {runIfFn(groupEndElement, callbackProps)}\n </TreeEndElement>\n ) : null}\n </styled.div>\n\n <TreeGroup\n duration={!animated ? 0 : undefined}\n open={groupOpen}\n {...getGroupProps({\n ...componentContext.groupProps,\n ...groupProps,\n })}\n >\n {children}\n </TreeGroup>\n </styled.li>\n ) : (\n <styled.li {...getItemProps(itemProps)}>\n <styled.div data-content {...props}>\n <TreeIndicator data-hidden />\n {checkable ? <TreeCheckbox /> : null}\n {itemStartElement ? (\n <TreeStartElement>\n {runIfFn(itemStartElement, callbackProps)}\n </TreeStartElement>\n ) : null}\n {label ? <TreeLabel>{label}</TreeLabel> : null}\n {itemEndElement ? (\n <TreeEndElement>\n {runIfFn(itemEndElement, callbackProps)}\n </TreeEndElement>\n ) : null}\n </styled.div>\n </styled.li>\n )}\n </ItemComponentContext>\n </TreeItemContext>\n )\n },\n \"item\",\n)()\n\ninterface TreeGroupProps\n extends\n Omit<HTMLStyledProps<\"ul\">, \"transition\">,\n Pick<CollapseProps, \"animationOpacity\" | keyof WithTransitionProps> {}\n\nconst TreeGroup = withContext<\"ul\", TreeGroupProps>((props) => {\n return <Collapse as=\"ul\" {...cast<CollapseProps>(props)} />\n}, \"group\")()\n\ninterface TreeIndicatorProps extends HTMLStyledProps<\"svg\"> {}\n\nconst TreeIndicator = withContext<\"svg\", TreeIndicatorProps>(\n ({ children = <ChevronRightIcon />, ...rest }) => {\n const { indicatorHidden } = useComponentContext()\n\n if (indicatorHidden) return null\n\n if (isValidElement<HTMLProps<\"svg\">>(children))\n return cloneElement(children, { ...rest, ...children.props })\n\n return Children.count(children) > 1 ? Children.only(null) : null\n },\n \"indicator\",\n)(undefined, (props) => {\n const { indicatorProps } = useItemComponentContext()\n\n return { ...indicatorProps, ...props }\n})\n\ninterface TreeCheckboxProps extends CheckboxProps {}\n\nconst TreeCheckbox = withContext<\"input\", TreeCheckboxProps>(\n Checkbox,\n \"checkbox\",\n)(undefined, (props) => {\n const { checkboxProps } = useItemComponentContext()\n\n return { ...checkboxProps, ...props }\n})\n\ninterface TreeStartElementProps extends HTMLStyledProps {}\n\nconst TreeStartElement = withContext<\"div\", TreeStartElementProps>(\"div\", {\n name: \"StartElement\",\n slot: [\"element\", \"start\"],\n})(undefined, (props) => {\n const { startElementProps } = useItemComponentContext()\n\n return { ...startElementProps, ...props }\n})\n\ninterface TreeEndElementProps extends HTMLStyledProps {}\n\nconst TreeEndElement = withContext<\"div\", TreeEndElementProps>(\"div\", {\n name: \"EndElement\",\n slot: [\"element\", \"end\"],\n})(undefined, (props) => {\n const { endElementProps } = useItemComponentContext()\n\n return { ...endElementProps, ...props }\n})\n\ninterface TreeLabelProps extends HTMLStyledProps<\"span\"> {}\n\nconst TreeLabel = withContext<\"span\", TreeLabelProps>(\"span\", \"label\")(\n undefined,\n (props) => {\n const { labelProps } = useItemComponentContext()\n\n return { ...labelProps, ...props }\n },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsEA,MAAM,qBAAqB,UAAuB;AAChD,QAAO,OAAO,KAAK,OAAO,UAAU;EAClC,MAAM,MACJ,MAAM,0DAAmB,MAAM,MAAM,GAAG,GAAG,MAAM,MAAM,GAAG,UAAU;AAEtE,MAAI,cAAc,OAAO;GACvB,MAAM,EAAE,UAAU,GAAG,SAAS;AAE9B,UACE,2CAAC;IAAmB,GAAI;cACrB,kBAAkB,SAAS;MADf,IAEJ;QAGb,QAAO,2CAAC,YAAmB,GAAI,SAAT,IAAkB;GAE1C;;AAGJ,MAAM,0BACJ,MACA,QACA,SAC2C;AAC3C,qDAAa,OAAO,KAAK,WAAW,UAAU,UAAU,QACtD,QAAO,OAAO;UACL,OACT,QAAO;0DACW,KAAK,KAAK,WAAW,QAAQ,UAAU,MACzD,QAAO,KAAK;KAEZ,QAAO;;AA8BX,MAAM,CAAC,sBAAsB,2BAC3BA,8BAAoC,EAAE,MAAM,wBAAwB,CAAC;AAwCvE,MAAM,EACJ,kBACA,cAAc,kBACd,qBACA,iBAAiB,qBACjB,aACA,iBACEC,6CACF,QACAC,6BACD;;;;;;AASD,MAAa,WAAW,cACa,EACjC,MACA,UACA,UACA,YACA,WACA,iBACA,OACA,eACA,cACA,eACA,iBACA,YACA,gBACA,WACA,YACA,mBACA,GAAG,WAC0B;CAC7B,MAAM,4CAAiC;AACrC,MAAI,SAAU,QAAO;AAErB,SAAO,kBAAkB,MAAM;IAC9B,CAAC,UAAU,MAAM,CAAC;CACrB,MAAM,EACJ,kBACA,WACA,cACA,aACA,eACA,UACA,eACA,cACA,oBACA,iBACA,eACA,aACA,kBACA,UACA,qBACEC,yBAAQ;EAAE,GAAG;EAAM,UAAU;EAAkB,CAAC;AAoEpD,QACE,2CAACC;EAAuB,OAAO;YAC7B,2CAACC;GAAY,iCApER;IACL;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD,GACD;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD,CACF;aAuCK,2CAAC;IAAiB,iCArCf;KACL;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD,GACD;KACE;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD,CACF;cAMO,2CAACC,uBAAO,MAAG,GAAI,cAAc,GAAI;KAChB;IACP;GACS;GAG7B,QACA,EAAE,eAAe,CAAC,OAAO,EAAE,CAC5B,EAAE;AAsEH,MAAa,WAAW,aACrB,EACC,WACA,KACA,aACA,UAAU,cACV,eAAe,mBACf,YACA,WAAW,eACX,OACA,eACA,OACA,cACA,OAAO,4DAAqB,MAAM,GAAG,QAAQ,QAC7C,eACA,iBACA,YACA,gBACA,YACA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AAM,gBAAgB,aACnB,EAAE,WAAW,2CAACC,gDAAmB,EAAE,GAAG,WAAW;CAChD,MAAM,EAAE,oBAAoB,qBAAqB;AAEjD,KAAI,gBAAiB,QAAO;AAE5B,+BAAqC,SAAS,CAC5C,gCAAoB,UAAU;EAAE,GAAG;EAAM,GAAG,SAAS;EAAO,CAAC;AAE/D,QAAOC,eAAS,MAAM,SAAS,GAAG,IAAIA,eAAS,KAAK,KAAK,GAAG;GAE9D,YACD,CAAC,SAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,yBAAyB;AAEpD,QAAO;EAAE,GAAG;EAAgB,GAAG;EAAO;EACtC;AAIF,MAAM,eAAe,YACnBC,2BACA,WACD,CAAC,SAAY,UAAU;CACtB,MAAM,EAAE,kBAAkB,yBAAyB;AAEnD,QAAO;EAAE,GAAG;EAAe,GAAG;EAAO;EACrC;AAIF,MAAM,mBAAmB,YAA0C,OAAO;CACxE,MAAM;CACN,MAAM,CAAC,WAAW,QAAQ;CAC3B,CAAC,CAAC,SAAY,UAAU;CACvB,MAAM,EAAE,sBAAsB,yBAAyB;AAEvD,QAAO;EAAE,GAAG;EAAmB,GAAG;EAAO;EACzC;AAIF,MAAM,iBAAiB,YAAwC,OAAO;CACpE,MAAM;CACN,MAAM,CAAC,WAAW,MAAM;CACzB,CAAC,CAAC,SAAY,UAAU;CACvB,MAAM,EAAE,oBAAoB,yBAAyB;AAErD,QAAO;EAAE,GAAG;EAAiB,GAAG;EAAO;EACvC;AAIF,MAAM,YAAY,YAAoC,QAAQ,QAAQ,CACpE,SACC,UAAU;CACT,MAAM,EAAE,eAAe,yBAAyB;AAEhD,QAAO;EAAE,GAAG;EAAY,GAAG;EAAO;EAErC"}
|
|
1
|
+
{"version":3,"file":"tree.cjs","names":["createContext","createSlotComponent","treeStyle","useTree","TreeDescendantsContext","TreeContext","styled","useTreeContext","useLoadingComponent","useTreeItem","mergeProps","TreeItemContext","Collapse","ChevronRightIcon","Children","Checkbox"],"sources":["../../../../src/components/tree/tree.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement, ReactNode } from \"react\"\nimport type {\n GenericsComponent,\n HTMLProps,\n HTMLStyledProps,\n ThemeProps,\n} from \"../../core\"\nimport type { CheckboxProps } from \"../checkbox\"\nimport type { CollapseProps } from \"../collapse\"\nimport type { Loading } from \"../loading\"\nimport type { WithTransitionProps } from \"../motion\"\nimport type { TreeStyle } from \"./tree.style\"\nimport type { UseTreeItemProps, UseTreeProps } from \"./use-tree\"\nimport {\n Children,\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n} from \"react\"\nimport { createSlotComponent, mergeProps, styled } from \"../../core\"\nimport {\n cast,\n createContext,\n dataAttr,\n isObject,\n isString,\n type ReactNodeOrFunction,\n runIfFn,\n} from \"../../utils\"\nimport { Checkbox } from \"../checkbox\"\nimport { Collapse } from \"../collapse\"\nimport { ChevronRightIcon } from \"../icon\"\nimport { useLoadingComponent } from \"../loading\"\nimport { treeStyle } from \"./tree.style\"\nimport {\n TreeContext,\n TreeDescendantsContext,\n TreeItemContext,\n useTree,\n useTreeContext,\n useTreeItem,\n} from \"./use-tree\"\n\ninterface TreeCallBackProps {\n disabled?: boolean\n expanded?: boolean\n}\n\ntype TreeItemReactNode =\n | ReactNodeOrFunction<TreeCallBackProps>\n | {\n group: ReactNodeOrFunction<TreeCallBackProps>\n item?: ReactNodeOrFunction<TreeCallBackProps>\n }\n | {\n item: ReactNodeOrFunction<TreeCallBackProps>\n group?: ReactNodeOrFunction<TreeCallBackProps>\n }\n\ninterface TreeItemWithValue extends Omit<TreeItemProps, \"children\"> {}\n\ninterface TreeItemWithChildren extends TreeItemWithValue {\n children: TreeItem[]\n}\n\nexport type TreeItem = TreeItemWithChildren | TreeItemWithValue\n\nconst recursiveTreeItem = (items?: TreeItem[]) => {\n return items?.map((props, index) => {\n const key =\n props.value || (isString(props.label) ? `${props.label}-${index}` : index)\n\n if (\"children\" in props) {\n const { children, ...rest } = props\n\n return (\n <TreeItem key={key} {...rest}>\n {recursiveTreeItem(children)}\n </TreeItem>\n )\n } else {\n return <TreeItem key={key} {...props} />\n }\n })\n}\n\nconst getReactNodeOrFunction = (\n type: \"group\" | \"item\",\n custom?: TreeItemReactNode,\n root?: TreeItemReactNode,\n): ReactNodeOrFunction<TreeCallBackProps> => {\n if (isObject(custom) && (\"group\" in custom || \"item\" in custom)) {\n return custom[type]\n } else if (custom) {\n return custom\n } else if (isObject(root) && (\"group\" in root || \"item\" in root)) {\n return root[type]\n } else {\n return root\n }\n}\n\ninterface ComponentContext extends Pick<\n TreeRootProps,\n | \"animated\"\n | \"checkboxProps\"\n | \"endElement\"\n | \"endElementProps\"\n | \"groupProps\"\n | \"indicator\"\n | \"indicatorHidden\"\n | \"indicatorProps\"\n | \"itemProps\"\n | \"labelProps\"\n | \"loadingScheme\"\n | \"size\"\n | \"startElement\"\n | \"startElementProps\"\n> {}\n\ninterface ItemComponentContext {\n checkboxProps: TreeCheckboxProps\n endElementProps: TreeEndElementProps\n indicatorProps: TreeIndicatorProps\n labelProps: TreeLabelProps\n startElementProps: TreeStartElementProps\n}\n\nconst [ItemComponentContext, useItemComponentContext] =\n createContext<ItemComponentContext>({ name: \"ItemComponentContext\" })\n\nexport interface TreeRootProps<Multiple extends boolean = false>\n extends\n HTMLStyledProps<\"ul\">,\n ThemeProps<TreeStyle>,\n UseTreeProps<Multiple>,\n Pick<\n TreeItemProps,\n | \"animated\"\n | \"checkboxProps\"\n | \"endElement\"\n | \"endElementProps\"\n | \"groupProps\"\n | \"indicator\"\n | \"indicatorProps\"\n | \"labelProps\"\n | \"loadingScheme\"\n | \"startElement\"\n | \"startElementProps\"\n > {\n /**\n * If `true`, hide the tree indicator icon for all items.\n *\n * @default false\n */\n indicatorHidden?: boolean\n /**\n * If provided, generate elements based on items.\n */\n items?: TreeItem[]\n /**\n * Props for the item component.\n */\n itemProps?: Omit<\n TreeItemProps,\n \"children\" | \"label\" | \"open\" | \"query\" | \"value\"\n >\n}\n\nconst {\n ComponentContext,\n PropsContext: TreePropsContext,\n useComponentContext,\n usePropsContext: useTreePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<TreeRootProps, TreeStyle, ComponentContext>(\n \"tree\",\n treeStyle,\n)\n\nexport { TreePropsContext, useTreePropsContext }\n\n/**\n * `Tree` is a component used to display hierarchical data structures in an expandable tree format.\n *\n * @see https://yamada-ui.com/docs/components/tree\n */\nexport const TreeRoot = withProvider<\"ul\", TreeRootProps, \"size\">(\n <Multiple extends boolean = false>({\n size,\n animated,\n children,\n endElement,\n indicator,\n indicatorHidden,\n items,\n loadingScheme,\n startElement,\n checkboxProps,\n endElementProps,\n groupProps,\n indicatorProps,\n itemProps,\n labelProps,\n startElementProps,\n ...rest\n }: TreeRootProps<Multiple>) => {\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return recursiveTreeItem(items)\n }, [children, items])\n const {\n activeDescendant,\n checkable,\n checkedValue,\n descendants,\n expandedValue,\n multiple,\n selectedValue,\n getRootProps,\n onActiveDescendant,\n onCheckedChange,\n onCollapseAll,\n onExpandAll,\n onExpandedChange,\n onSearch,\n onSelectedChange,\n } = useTree({ ...rest, children: computedChildren })\n const context = useMemo(\n () => ({\n activeDescendant,\n checkable,\n checkedValue,\n expandedValue,\n multiple,\n selectedValue,\n onActiveDescendant,\n onCheckedChange,\n onCollapseAll,\n onExpandAll,\n onExpandedChange,\n onSearch,\n onSelectedChange,\n }),\n [\n activeDescendant,\n checkable,\n checkedValue,\n expandedValue,\n multiple,\n selectedValue,\n onActiveDescendant,\n onCheckedChange,\n onSearch,\n onCollapseAll,\n onExpandAll,\n onExpandedChange,\n onSelectedChange,\n ],\n )\n const componentContext = useMemo(\n () => ({\n size,\n animated,\n endElement,\n indicator,\n indicatorHidden,\n loadingScheme,\n startElement,\n checkboxProps,\n endElementProps,\n groupProps,\n indicatorProps,\n itemProps,\n labelProps,\n startElementProps,\n }),\n [\n size,\n animated,\n endElement,\n indicator,\n indicatorHidden,\n startElement,\n endElementProps,\n groupProps,\n indicatorProps,\n itemProps,\n labelProps,\n startElementProps,\n checkboxProps,\n loadingScheme,\n ],\n )\n\n return (\n <TreeDescendantsContext value={descendants}>\n <TreeContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.ul {...getRootProps()} />\n </ComponentContext>\n </TreeContext>\n </TreeDescendantsContext>\n )\n },\n \"root\",\n { transferProps: [\"size\"] },\n)() as GenericsComponent<{\n <Multiple extends boolean = false>(\n props: TreeRootProps<Multiple>,\n ): ReactElement\n}>\n\nexport interface TreeItemProps\n extends HTMLStyledProps<\"div\">, Omit<UseTreeItemProps, \"asyncChildren\"> {\n /**\n * The label to display in the item.\n */\n label: ReactNode\n /**\n * If `true`, the tree item will be animated.\n *\n * @default false\n */\n animated?: boolean\n /**\n * The element to display at the end of the item.\n */\n endElement?: TreeItemReactNode\n /**\n * The tree indicator icon to use.\n */\n indicator?: ReactNodeOrFunction<TreeCallBackProps>\n /**\n * The loading scheme.\n *\n * @default 'oval'\n */\n loadingScheme?: Loading.Scheme\n /**\n * The element to display at the start of the item.\n */\n startElement?: TreeItemReactNode\n /**\n * Props for the checkbox component.\n */\n checkboxProps?: Omit<CheckboxProps, \"checked\" | \"defaultChecked\" | \"value\">\n /**\n * Props for the end component.\n */\n endElementProps?: TreeEndElementProps\n /**\n * Props for the group component.\n */\n groupProps?: Omit<TreeGroupProps, \"children\">\n /**\n * Props for the indicator component.\n */\n indicatorProps?: TreeIndicatorProps\n /**\n * Props for the label component.\n */\n labelProps?: TreeLabelProps\n /**\n * Props for the root element.\n */\n rootProps?: HTMLStyledProps<\"li\">\n /**\n * Props for the start component.\n */\n startElementProps?: TreeStartElementProps\n /**\n * If provided, the tree item will be rendered as an async tree item.\n */\n asyncChildren?: () => Promise<TreeItem[]>\n}\n\nexport const TreeItem = withContext<\"div\", TreeItemProps>(\n ({\n className,\n css,\n colorScheme,\n animated: animatedProp,\n asyncChildren: asyncChildrenProp,\n endElement,\n indicator: indicatorProp,\n label,\n loadingScheme,\n query,\n startElement,\n value: valueProp = isString(label) ? label : undefined,\n checkboxProps,\n endElementProps,\n groupProps,\n indicatorProps,\n labelProps,\n rootProps,\n startElementProps,\n ...rest\n }) => {\n const { checkable } = useTreeContext()\n const componentContext = useComponentContext()\n const Loading = useLoadingComponent(\n loadingScheme ?? componentContext.loadingScheme ?? \"oval\",\n )\n const animated = animatedProp ?? componentContext.animated\n const indicator = indicatorProp ?? componentContext.indicator\n const groupStartElement = getReactNodeOrFunction(\n \"group\",\n startElement,\n componentContext.startElement,\n )\n const groupEndElement = getReactNodeOrFunction(\n \"group\",\n endElement,\n componentContext.endElement,\n )\n const itemStartElement = getReactNodeOrFunction(\n \"item\",\n startElement,\n componentContext.startElement,\n )\n const itemEndElement = getReactNodeOrFunction(\n \"item\",\n endElement,\n componentContext.endElement,\n )\n const asyncChildren = useCallback(async () => {\n const items = await asyncChildrenProp?.()\n\n return recursiveTreeItem(items)\n }, [asyncChildrenProp])\n const {\n branchOpen,\n children,\n disabled,\n group,\n groupLoading,\n groupOpen,\n level,\n props,\n value,\n getCheckboxProps,\n getGroupItemProps,\n getGroupProps,\n getIndicatorProps,\n getItemProps,\n getLabelProps,\n onGroupClose,\n onGroupOpen,\n onGroupToggle,\n } = useTreeItem({\n ...componentContext.itemProps,\n ...rest,\n asyncChildren: asyncChildrenProp ? asyncChildren : undefined,\n query: query ?? (isString(label) ? label : undefined),\n value: valueProp,\n })\n const itemProps = useMemo(\n () =>\n mergeProps(\n {\n className,\n css,\n colorScheme,\n \"--level\": level.toString(),\n },\n rootProps,\n )(),\n [className, css, colorScheme, level, rootProps],\n )\n const callbackProps = { disabled, expanded: groupOpen }\n const context = useMemo(\n () => ({\n branchOpen,\n groupOpen,\n level,\n value,\n onGroupClose,\n onGroupOpen,\n onGroupToggle,\n }),\n [\n branchOpen,\n groupOpen,\n level,\n value,\n onGroupClose,\n onGroupOpen,\n onGroupToggle,\n ],\n )\n const itemComponentContext = useMemo(\n () => ({\n checkboxProps: {\n size: componentContext.size,\n ...getCheckboxProps(\n mergeProps(componentContext.checkboxProps, checkboxProps)(),\n ),\n },\n endElementProps: mergeProps(\n componentContext.endElementProps,\n endElementProps,\n )(),\n indicatorProps: {\n ...getIndicatorProps(\n mergeProps(componentContext.indicatorProps, indicatorProps)(),\n ),\n },\n labelProps: {\n ...getLabelProps(\n mergeProps(componentContext.labelProps, labelProps)(),\n ),\n },\n startElementProps: mergeProps(\n componentContext.startElementProps,\n startElementProps,\n )(),\n }),\n [\n checkboxProps,\n componentContext.checkboxProps,\n componentContext.endElementProps,\n componentContext.indicatorProps,\n componentContext.labelProps,\n componentContext.size,\n componentContext.startElementProps,\n endElementProps,\n getCheckboxProps,\n getIndicatorProps,\n getLabelProps,\n indicatorProps,\n labelProps,\n startElementProps,\n ],\n )\n\n return (\n <TreeItemContext value={context}>\n <ItemComponentContext value={itemComponentContext}>\n {group ? (\n <styled.li {...getGroupItemProps(itemProps)}>\n <styled.div data-content {...props}>\n <TreeIndicator data-animated={dataAttr(animated)}>\n {groupLoading ? (\n <Loading />\n ) : (\n runIfFn(indicator, callbackProps)\n )}\n </TreeIndicator>\n {checkable ? <TreeCheckbox /> : null}\n {groupStartElement ? (\n <TreeStartElement>\n {runIfFn(groupStartElement, callbackProps)}\n </TreeStartElement>\n ) : null}\n {label ? <TreeLabel>{label}</TreeLabel> : null}\n {groupEndElement ? (\n <TreeEndElement>\n {runIfFn(groupEndElement, callbackProps)}\n </TreeEndElement>\n ) : null}\n </styled.div>\n\n <TreeGroup\n duration={!animated ? 0 : undefined}\n open={groupOpen}\n {...getGroupProps(\n mergeProps(componentContext.groupProps, groupProps)(),\n )}\n >\n {children}\n </TreeGroup>\n </styled.li>\n ) : (\n <styled.li {...getItemProps(itemProps)}>\n <styled.div data-content {...props}>\n <TreeIndicator data-hidden />\n {checkable ? <TreeCheckbox /> : null}\n {itemStartElement ? (\n <TreeStartElement>\n {runIfFn(itemStartElement, callbackProps)}\n </TreeStartElement>\n ) : null}\n {label ? <TreeLabel>{label}</TreeLabel> : null}\n {itemEndElement ? (\n <TreeEndElement>\n {runIfFn(itemEndElement, callbackProps)}\n </TreeEndElement>\n ) : null}\n </styled.div>\n </styled.li>\n )}\n </ItemComponentContext>\n </TreeItemContext>\n )\n },\n \"item\",\n)()\n\ninterface TreeGroupProps\n extends\n Omit<HTMLStyledProps<\"ul\">, \"transition\">,\n Pick<CollapseProps, \"animationOpacity\" | keyof WithTransitionProps> {}\n\nconst TreeGroup = withContext<\"ul\", TreeGroupProps>((props) => {\n return <Collapse as=\"ul\" {...cast<CollapseProps>(props)} />\n}, \"group\")()\n\ninterface TreeIndicatorProps extends HTMLStyledProps<\"svg\"> {}\n\nconst TreeIndicator = withContext<\"svg\", TreeIndicatorProps>(\n ({ children = <ChevronRightIcon />, ...rest }) => {\n const { indicatorHidden } = useComponentContext()\n\n if (indicatorHidden) return null\n\n if (isValidElement<HTMLProps<\"svg\">>(children))\n return cloneElement(children, { ...rest, ...children.props })\n\n return Children.count(children) > 1 ? Children.only(null) : null\n },\n \"indicator\",\n)(undefined, (props) => {\n const { indicatorProps } = useItemComponentContext()\n\n return mergeProps(indicatorProps, props)()\n})\n\ninterface TreeCheckboxProps extends CheckboxProps {}\n\nconst TreeCheckbox = withContext<\"input\", TreeCheckboxProps>(\n Checkbox,\n \"checkbox\",\n)(undefined, (props) => {\n const { checkboxProps } = useItemComponentContext()\n\n return mergeProps(checkboxProps, props)()\n})\n\ninterface TreeStartElementProps extends HTMLStyledProps {}\n\nconst TreeStartElement = withContext<\"div\", TreeStartElementProps>(\"div\", {\n name: \"StartElement\",\n slot: [\"element\", \"start\"],\n})(undefined, (props) => {\n const { startElementProps } = useItemComponentContext()\n\n return mergeProps(startElementProps, props)()\n})\n\ninterface TreeEndElementProps extends HTMLStyledProps {}\n\nconst TreeEndElement = withContext<\"div\", TreeEndElementProps>(\"div\", {\n name: \"EndElement\",\n slot: [\"element\", \"end\"],\n})(undefined, (props) => {\n const { endElementProps } = useItemComponentContext()\n\n return mergeProps(endElementProps, props)()\n})\n\ninterface TreeLabelProps extends HTMLStyledProps<\"span\"> {}\n\nconst TreeLabel = withContext<\"span\", TreeLabelProps>(\"span\", \"label\")(\n undefined,\n (props) => {\n const { labelProps } = useItemComponentContext()\n\n return mergeProps(labelProps, props)()\n },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsEA,MAAM,qBAAqB,UAAuB;AAChD,QAAO,OAAO,KAAK,OAAO,UAAU;EAClC,MAAM,MACJ,MAAM,0DAAmB,MAAM,MAAM,GAAG,GAAG,MAAM,MAAM,GAAG,UAAU;AAEtE,MAAI,cAAc,OAAO;GACvB,MAAM,EAAE,UAAU,GAAG,SAAS;AAE9B,UACE,2CAAC;IAAmB,GAAI;cACrB,kBAAkB,SAAS;MADf,IAEJ;QAGb,QAAO,2CAAC,YAAmB,GAAI,SAAT,IAAkB;GAE1C;;AAGJ,MAAM,0BACJ,MACA,QACA,SAC2C;AAC3C,qDAAa,OAAO,KAAK,WAAW,UAAU,UAAU,QACtD,QAAO,OAAO;UACL,OACT,QAAO;0DACW,KAAK,KAAK,WAAW,QAAQ,UAAU,MACzD,QAAO,KAAK;KAEZ,QAAO;;AA8BX,MAAM,CAAC,sBAAsB,2BAC3BA,8BAAoC,EAAE,MAAM,wBAAwB,CAAC;AAwCvE,MAAM,EACJ,kBACA,cAAc,kBACd,qBACA,iBAAiB,qBACjB,aACA,iBACEC,6CACF,QACAC,6BACD;;;;;;AASD,MAAa,WAAW,cACa,EACjC,MACA,UACA,UACA,YACA,WACA,iBACA,OACA,eACA,cACA,eACA,iBACA,YACA,gBACA,WACA,YACA,mBACA,GAAG,WAC0B;CAC7B,MAAM,4CAAiC;AACrC,MAAI,SAAU,QAAO;AAErB,SAAO,kBAAkB,MAAM;IAC9B,CAAC,UAAU,MAAM,CAAC;CACrB,MAAM,EACJ,kBACA,WACA,cACA,aACA,eACA,UACA,eACA,cACA,oBACA,iBACA,eACA,aACA,kBACA,UACA,qBACEC,yBAAQ;EAAE,GAAG;EAAM,UAAU;EAAkB,CAAC;AAoEpD,QACE,2CAACC;EAAuB,OAAO;YAC7B,2CAACC;GAAY,iCApER;IACL;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD,GACD;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD,CACF;aAuCK,2CAAC;IAAiB,iCArCf;KACL;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD,GACD;KACE;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD,CACF;cAMO,2CAACC,uBAAO,MAAG,GAAI,cAAc,GAAI;KAChB;IACP;GACS;GAG7B,QACA,EAAE,eAAe,CAAC,OAAO,EAAE,CAC5B,EAAE;AAsEH,MAAa,WAAW,aACrB,EACC,WACA,KACA,aACA,UAAU,cACV,eAAe,mBACf,YACA,WAAW,eACX,OACA,eACA,OACA,cACA,OAAO,4DAAqB,MAAM,GAAG,QAAQ,QAC7C,eACA,iBACA,YACA,gBACA,YACA,WACA,mBACA,GAAG,WACC;CACJ,MAAM,EAAE,cAAcC,iCAAgB;CACtC,MAAM,mBAAmB,qBAAqB;CAC9C,MAAM,UAAUC,kDACd,iBAAiB,iBAAiB,iBAAiB,OACpD;CACD,MAAM,WAAW,gBAAgB,iBAAiB;CAClD,MAAM,YAAY,iBAAiB,iBAAiB;CACpD,MAAM,oBAAoB,uBACxB,SACA,cACA,iBAAiB,aAClB;CACD,MAAM,kBAAkB,uBACtB,SACA,YACA,iBAAiB,WAClB;CACD,MAAM,mBAAmB,uBACvB,QACA,cACA,iBAAiB,aAClB;CACD,MAAM,iBAAiB,uBACrB,QACA,YACA,iBAAiB,WAClB;CACD,MAAM,uCAA4B,YAAY;AAG5C,SAAO,kBAFO,MAAM,qBAAqB,CAEV;IAC9B,CAAC,kBAAkB,CAAC;CACvB,MAAM,EACJ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yB;AAEnD,QAAOL,yBAAW,eAAe,MAAM,EAAE;EACzC;AAIF,MAAM,mBAAmB,YAA0C,OAAO;CACxE,MAAM;CACN,MAAM,CAAC,WAAW,QAAQ;CAC3B,CAAC,CAAC,SAAY,UAAU;CACvB,MAAM,EAAE,sBAAsB,yBAAyB;AAEvD,QAAOA,yBAAW,mBAAmB,MAAM,EAAE;EAC7C;AAIF,MAAM,iBAAiB,YAAwC,OAAO;CACpE,MAAM;CACN,MAAM,CAAC,WAAW,MAAM;CACzB,CAAC,CAAC,SAAY,UAAU;CACvB,MAAM,EAAE,oBAAoB,yBAAyB;AAErD,QAAOA,yBAAW,iBAAiB,MAAM,EAAE;EAC3C;AAIF,MAAM,YAAY,YAAoC,QAAQ,QAAQ,CACpE,SACC,UAAU;CACT,MAAM,EAAE,eAAe,yBAAyB;AAEhD,QAAOA,yBAAW,YAAY,MAAM,EAAE;EAEzC"}
|
|
@@ -110,7 +110,6 @@ const AccordionButton = withContext(({ children, icon: customIcon, suppressHydra
|
|
|
110
110
|
expanded: open
|
|
111
111
|
};
|
|
112
112
|
return /* @__PURE__ */ jsx(styled.h3, {
|
|
113
|
-
suppressHydrationWarning,
|
|
114
113
|
...containerProps,
|
|
115
114
|
children: /* @__PURE__ */ jsxs(styled.button, {
|
|
116
115
|
...getButtonProps({
|
|
@@ -148,10 +147,7 @@ const AccordionPanel = withContext(({ animationOpacity, children, delay, duratio
|
|
|
148
147
|
suppressHydrationWarning,
|
|
149
148
|
...rest
|
|
150
149
|
}),
|
|
151
|
-
children: (0, utils_exports.isString)(children) ? /* @__PURE__ */ jsx(styled.p, {
|
|
152
|
-
suppressHydrationWarning,
|
|
153
|
-
children
|
|
154
|
-
}) : children
|
|
150
|
+
children: (0, utils_exports.isString)(children) ? /* @__PURE__ */ jsx(styled.p, { children }) : children
|
|
155
151
|
})
|
|
156
152
|
});
|
|
157
153
|
}, "panel")();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.js","names":["createContext","index","props"],"sources":["../../../../src/components/accordion/accordion.tsx"],"sourcesContent":["\"use client\"\n\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport type { CollapseProps } from \"../collapse\"\nimport type { WithTransitionProps } from \"../motion\"\nimport type { AccordionStyle } from \"./accordion.style\"\nimport type { UseAccordionItemProps, UseAccordionProps } from \"./use-accordion\"\nimport { Children, cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { createContext, isString, runIfFn, useSplitChildren } from \"../../utils\"\nimport { Collapse } from \"../collapse\"\nimport { ChevronDownIcon } from \"../icon\"\nimport { accordionStyle } from \"./accordion.style\"\nimport {\n AccordionContext,\n AccordionDescendantsContext,\n AccordionItemContext,\n useAccordion,\n useAccordionItem,\n useAccordionItemContext,\n} from \"./use-accordion\"\n\ninterface AccordionCallBackProps {\n disabled?: boolean\n expanded?: boolean\n}\n\nexport interface AccordionItem extends Omit<AccordionItemProps, \"index\"> {}\n\ninterface ComponentContext extends Pick<\n AccordionRootProps,\n \"icon\" | \"iconHidden\"\n> {}\n\nexport interface AccordionRootProps\n extends\n Omit<HTMLStyledProps, \"onChange\">,\n ThemeProps<AccordionStyle>,\n UseAccordionProps {\n /**\n * The accordion icon for all items to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * If `true`, hide the accordion icon for all items.\n *\n * @default false\n */\n iconHidden?: boolean\n /**\n * If provided, generate elements based on items.\n */\n items?: AccordionItem[]\n}\n\ninterface ItemComponentContext extends Pick<AccordionItemProps, \"icon\"> {}\n\nconst [ItemComponentContext, useItemComponentContext] =\n createContext<ItemComponentContext>({\n name: \"ItemComponentContext\",\n })\n\nconst {\n ComponentContext,\n PropsContext: AccordionPropsContext,\n useComponentContext,\n usePropsContext: useAccordionPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<AccordionRootProps, AccordionStyle, ComponentContext>(\n \"accordion\",\n accordionStyle,\n)\n\nexport { AccordionPropsContext, useAccordionPropsContext }\n\n/**\n * `Accordion` is a component for a list that displays information in an expandable or collapsible manner.\n *\n * @see https://yamada-ui.com/docs/components/accordion\n */\nexport const AccordionRoot = withProvider<\"div\", AccordionRootProps>(\n ({ children, icon, iconHidden, items, ...props }) => {\n const {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n } = useAccordion(props)\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return items?.map((props, index) => (\n <AccordionItem key={index} index={index} {...props} />\n ))\n }, [children, items])\n const context = useMemo(\n () => ({\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n }),\n [focusedIndex, index, multiple, setFocusedIndex, setIndex, toggle],\n )\n const componentContext = useMemo(\n () => ({ icon, iconHidden }),\n [icon, iconHidden],\n )\n\n return (\n <AccordionDescendantsContext value={descendants}>\n <AccordionContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.div {...getRootProps()}>{computedChildren}</styled.div>\n </ComponentContext>\n </AccordionContext>\n </AccordionDescendantsContext>\n )\n },\n \"root\",\n)()\n\nexport interface AccordionItemProps\n extends\n Omit<HTMLStyledProps, \"children\">,\n Omit<UseAccordionItemProps, \"children\"> {\n /**\n * The accordion button to use.\n */\n button?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * The accordion children to use.\n */\n children?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * The accordion icon to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n}\n\nexport const AccordionItem = withContext<\"div\", AccordionItemProps>(\n ({ button, children, icon, ...rest }) => {\n const {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n } = useAccordionItem(rest)\n const computedChildren = useMemo(\n () => runIfFn(children, { disabled, expanded: open }),\n [children, disabled, open],\n )\n const [omittedChildren, customAccordionButton, customAccordionPanel] =\n useSplitChildren(computedChildren, AccordionButton, AccordionPanel)\n const context = useMemo(\n () => ({\n disabled,\n icon,\n open,\n getButtonProps,\n getIconProps,\n getPanelProps,\n }),\n [disabled, getButtonProps, getPanelProps, getIconProps, icon, open],\n )\n const componentContext = useMemo(() => ({ icon }), [icon])\n\n return (\n <AccordionItemContext value={context}>\n <ItemComponentContext value={componentContext}>\n <styled.div {...getItemProps()}>\n {customAccordionButton ?? (\n <AccordionButton>\n {runIfFn(button, { disabled, expanded: open })}\n </AccordionButton>\n )}\n {customAccordionPanel ?? (\n <AccordionPanel>{omittedChildren}</AccordionPanel>\n )}\n </styled.div>\n </ItemComponentContext>\n </AccordionItemContext>\n )\n },\n \"item\",\n)()\n\nexport interface AccordionButtonProps extends HTMLStyledProps<\"button\"> {\n /**\n * The accordion icon to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * Props the container element.\n */\n containerProps?: HTMLStyledProps\n}\n\nexport const AccordionButton = withContext<\"button\", AccordionButtonProps>(\n ({\n children,\n icon: customIcon,\n suppressHydrationWarning,\n containerProps,\n ...rest\n }) => {\n const { icon: rootIcon } = useComponentContext()\n const { icon: itemIcon } = useItemComponentContext()\n const { disabled, open, getButtonProps } = useAccordionItemContext()\n const props = { disabled, expanded: open }\n\n return (\n <styled.h3\n suppressHydrationWarning={suppressHydrationWarning}\n {...containerProps}\n >\n <styled.button\n {...getButtonProps({ suppressHydrationWarning, ...rest })}\n >\n {children}\n\n <AccordionIcon>\n {runIfFn(customIcon, props) ??\n runIfFn(itemIcon, props) ??\n runIfFn(rootIcon, props)}\n </AccordionIcon>\n </styled.button>\n </styled.h3>\n )\n },\n \"button\",\n)()\n\ninterface AccordionIconProps extends HTMLStyledProps<\"svg\"> {}\n\nexport const AccordionIcon = withContext<\"svg\", AccordionIconProps>(\n ({ children = <ChevronDownIcon />, ...rest }) => {\n const { iconHidden } = useComponentContext()\n const { getIconProps } = useAccordionItemContext()\n\n if (iconHidden) return null\n\n if (isValidElement<HTMLProps<\"svg\">>(children))\n return cloneElement(\n children,\n getIconProps({\n ...rest,\n ...children.props,\n }),\n )\n\n return Children.count(children) > 1 ? Children.only(null) : null\n },\n \"icon\",\n)()\n\nexport interface AccordionPanelProps\n extends\n Omit<HTMLStyledProps, \"transition\">,\n Pick<\n CollapseProps,\n | \"animationOpacity\"\n | \"endingHeight\"\n | \"startingHeight\"\n | keyof WithTransitionProps\n > {}\n\nexport const AccordionPanel = withContext<\"div\", AccordionPanelProps>(\n ({\n animationOpacity,\n children,\n delay,\n duration,\n endingHeight,\n startingHeight,\n suppressHydrationWarning,\n transition,\n transitionEnd,\n unmountOnExit,\n ...rest\n }) => {\n const { open, getPanelProps } = useAccordionItemContext()\n\n return (\n <Collapse\n {...{\n animationOpacity,\n delay,\n duration,\n endingHeight,\n open,\n startingHeight,\n transition,\n transitionEnd,\n unmountOnExit,\n }}\n >\n <styled.div {...getPanelProps({ suppressHydrationWarning, ...rest })}>\n {isString(children) ? (\n <styled.p suppressHydrationWarning={suppressHydrationWarning}>\n {children}\n </styled.p>\n ) : (\n children\n )}\n </styled.div>\n </Collapse>\n )\n },\n \"panel\",\n)()\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0DA,MAAM,CAAC,sBAAsB,2BAC3BA,gBAAoC,EAClC,MAAM,wBACP,CAAC;AAEJ,MAAM,EACJ,kBACA,cAAc,uBACd,qBACA,iBAAiB,0BACjB,aACA,iBACE,oBACF,aACA,eACD;;;;;;AASD,MAAa,gBAAgB,cAC1B,EAAE,UAAU,MAAM,YAAY,OAAO,GAAG,YAAY;CACnD,MAAM,EACJ,aACA,cACA,OACA,UACA,iBACA,UACA,QACA,iBACE,aAAa,MAAM;CACvB,MAAM,mBAAmB,cAAc;AACrC,MAAI,SAAU,QAAO;AAErB,SAAO,OAAO,KAAK,SAAO,YACxB,oBAAC;GAA0B,OAAOC;GAAO,GAAIC;KAAzBD,QAAkC,CACtD;IACD,CAAC,UAAU,MAAM,CAAC;AAiBrB,QACE,oBAAC;EAA4B,O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YAEJ,qBAAC,OAAO;GACN,GAAI,eAAe;IAAE;IAA0B,GAAG;IAAM,CAAC;cAExD,UAED,oBAAC,sDACU,YAAY,MAAM,+BACjB,UAAU,MAAM,+BAChB,UAAU,MAAM,GACZ;IACF;GACN;GAGhB,SACD,EAAE;AAIH,MAAa,gBAAgB,aAC1B,EAAE,WAAW,oBAAC,oBAAkB,EAAE,GAAG,WAAW;CAC/C,MAAM,EAAE,eAAe,qBAAqB;CAC5C,MAAM,EAAE,iBAAiB,yBAAyB;AAElD,KAAI,WAAY,QAAO;AAEvB,KAAI,eAAiC,SAAS,CAC5C,QAAO,aACL,UACA,aAAa;EACX,GAAG;EACH,GAAG,SAAS;EACb,CAAC,CACH;AAEH,QAAO,SAAS,MAAM,SAAS,GAAG,IAAI,SAAS,KAAK,KAAK,GAAG;GAE9D,OACD,EAAE;AAaH,MAAa,iBAAiB,aAC3B,EACC,kBACA,UACA,OACA,UACA,cACA,gBACA,0BACA,YACA,eACA,eACA,GAAG,WACC;CACJ,MAAM,EAAE,MAAM,kBAAkB,yBAAyB;AAEzD,QACE,oBAAC;EAEG;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;YAGF,oBAAC,OAAO;GAAI,GAAI,cAAc;IAAE;IAA0B,GAAG;IAAM,CAAC;yCACxD,SAAS,GACjB,oBAAC,OAAO;IAA4B;IACjC;KACQ,GAEX;IAES;GACJ;GAGf,QACD,EAAE"}
|
|
1
|
+
{"version":3,"file":"accordion.js","names":["createContext","index","props"],"sources":["../../../../src/components/accordion/accordion.tsx"],"sourcesContent":["\"use client\"\n\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ReactNodeOrFunction } from \"../../utils\"\nimport type { CollapseProps } from \"../collapse\"\nimport type { WithTransitionProps } from \"../motion\"\nimport type { AccordionStyle } from \"./accordion.style\"\nimport type { UseAccordionItemProps, UseAccordionProps } from \"./use-accordion\"\nimport { Children, cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { createContext, isString, runIfFn, useSplitChildren } from \"../../utils\"\nimport { Collapse } from \"../collapse\"\nimport { ChevronDownIcon } from \"../icon\"\nimport { accordionStyle } from \"./accordion.style\"\nimport {\n AccordionContext,\n AccordionDescendantsContext,\n AccordionItemContext,\n useAccordion,\n useAccordionItem,\n useAccordionItemContext,\n} from \"./use-accordion\"\n\ninterface AccordionCallBackProps {\n disabled?: boolean\n expanded?: boolean\n}\n\nexport interface AccordionItem extends Omit<AccordionItemProps, \"index\"> {}\n\ninterface ComponentContext extends Pick<\n AccordionRootProps,\n \"icon\" | \"iconHidden\"\n> {}\n\nexport interface AccordionRootProps\n extends\n Omit<HTMLStyledProps, \"onChange\">,\n ThemeProps<AccordionStyle>,\n UseAccordionProps {\n /**\n * The accordion icon for all items to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * If `true`, hide the accordion icon for all items.\n *\n * @default false\n */\n iconHidden?: boolean\n /**\n * If provided, generate elements based on items.\n */\n items?: AccordionItem[]\n}\n\ninterface ItemComponentContext extends Pick<AccordionItemProps, \"icon\"> {}\n\nconst [ItemComponentContext, useItemComponentContext] =\n createContext<ItemComponentContext>({\n name: \"ItemComponentContext\",\n })\n\nconst {\n ComponentContext,\n PropsContext: AccordionPropsContext,\n useComponentContext,\n usePropsContext: useAccordionPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<AccordionRootProps, AccordionStyle, ComponentContext>(\n \"accordion\",\n accordionStyle,\n)\n\nexport { AccordionPropsContext, useAccordionPropsContext }\n\n/**\n * `Accordion` is a component for a list that displays information in an expandable or collapsible manner.\n *\n * @see https://yamada-ui.com/docs/components/accordion\n */\nexport const AccordionRoot = withProvider<\"div\", AccordionRootProps>(\n ({ children, icon, iconHidden, items, ...props }) => {\n const {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n } = useAccordion(props)\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return items?.map((props, index) => (\n <AccordionItem key={index} index={index} {...props} />\n ))\n }, [children, items])\n const context = useMemo(\n () => ({\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n }),\n [focusedIndex, index, multiple, setFocusedIndex, setIndex, toggle],\n )\n const componentContext = useMemo(\n () => ({ icon, iconHidden }),\n [icon, iconHidden],\n )\n\n return (\n <AccordionDescendantsContext value={descendants}>\n <AccordionContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.div {...getRootProps()}>{computedChildren}</styled.div>\n </ComponentContext>\n </AccordionContext>\n </AccordionDescendantsContext>\n )\n },\n \"root\",\n)()\n\nexport interface AccordionItemProps\n extends\n Omit<HTMLStyledProps, \"children\">,\n Omit<UseAccordionItemProps, \"children\"> {\n /**\n * The accordion button to use.\n */\n button?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * The accordion children to use.\n */\n children?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * The accordion icon to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n}\n\nexport const AccordionItem = withContext<\"div\", AccordionItemProps>(\n ({ button, children, icon, ...rest }) => {\n const {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n } = useAccordionItem(rest)\n const computedChildren = useMemo(\n () => runIfFn(children, { disabled, expanded: open }),\n [children, disabled, open],\n )\n const [omittedChildren, customAccordionButton, customAccordionPanel] =\n useSplitChildren(computedChildren, AccordionButton, AccordionPanel)\n const context = useMemo(\n () => ({\n disabled,\n icon,\n open,\n getButtonProps,\n getIconProps,\n getPanelProps,\n }),\n [disabled, getButtonProps, getPanelProps, getIconProps, icon, open],\n )\n const componentContext = useMemo(() => ({ icon }), [icon])\n\n return (\n <AccordionItemContext value={context}>\n <ItemComponentContext value={componentContext}>\n <styled.div {...getItemProps()}>\n {customAccordionButton ?? (\n <AccordionButton>\n {runIfFn(button, { disabled, expanded: open })}\n </AccordionButton>\n )}\n {customAccordionPanel ?? (\n <AccordionPanel>{omittedChildren}</AccordionPanel>\n )}\n </styled.div>\n </ItemComponentContext>\n </AccordionItemContext>\n )\n },\n \"item\",\n)()\n\nexport interface AccordionButtonProps extends HTMLStyledProps<\"button\"> {\n /**\n * The accordion icon to use.\n */\n icon?: ReactNodeOrFunction<AccordionCallBackProps>\n /**\n * Props the container element.\n */\n containerProps?: HTMLStyledProps\n}\n\nexport const AccordionButton = withContext<\"button\", AccordionButtonProps>(\n ({\n children,\n icon: customIcon,\n suppressHydrationWarning,\n containerProps,\n ...rest\n }) => {\n const { icon: rootIcon } = useComponentContext()\n const { icon: itemIcon } = useItemComponentContext()\n const { disabled, open, getButtonProps } = useAccordionItemContext()\n const props = { disabled, expanded: open }\n\n return (\n <styled.h3 {...containerProps}>\n <styled.button\n {...getButtonProps({ suppressHydrationWarning, ...rest })}\n >\n {children}\n\n <AccordionIcon>\n {runIfFn(customIcon, props) ??\n runIfFn(itemIcon, props) ??\n runIfFn(rootIcon, props)}\n </AccordionIcon>\n </styled.button>\n </styled.h3>\n )\n },\n \"button\",\n)()\n\ninterface AccordionIconProps extends HTMLStyledProps<\"svg\"> {}\n\nexport const AccordionIcon = withContext<\"svg\", AccordionIconProps>(\n ({ children = <ChevronDownIcon />, ...rest }) => {\n const { iconHidden } = useComponentContext()\n const { getIconProps } = useAccordionItemContext()\n\n if (iconHidden) return null\n\n if (isValidElement<HTMLProps<\"svg\">>(children))\n return cloneElement(\n children,\n getIconProps({\n ...rest,\n ...children.props,\n }),\n )\n\n return Children.count(children) > 1 ? Children.only(null) : null\n },\n \"icon\",\n)()\n\nexport interface AccordionPanelProps\n extends\n Omit<HTMLStyledProps, \"transition\">,\n Pick<\n CollapseProps,\n | \"animationOpacity\"\n | \"endingHeight\"\n | \"startingHeight\"\n | keyof WithTransitionProps\n > {}\n\nexport const AccordionPanel = withContext<\"div\", AccordionPanelProps>(\n ({\n animationOpacity,\n children,\n delay,\n duration,\n endingHeight,\n startingHeight,\n suppressHydrationWarning,\n transition,\n transitionEnd,\n unmountOnExit,\n ...rest\n }) => {\n const { open, getPanelProps } = useAccordionItemContext()\n\n return (\n <Collapse\n {...{\n animationOpacity,\n delay,\n duration,\n endingHeight,\n open,\n startingHeight,\n transition,\n transitionEnd,\n unmountOnExit,\n }}\n >\n <styled.div {...getPanelProps({ suppressHydrationWarning, ...rest })}>\n {isString(children) ? <styled.p>{children}</styled.p> : children}\n </styled.div>\n </Collapse>\n )\n },\n \"panel\",\n)()\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0DA,MAAM,CAAC,sBAAsB,2BAC3BA,gBAAoC,EAClC,MAAM,wBACP,CAAC;AAEJ,MAAM,EACJ,kBACA,cAAc,uBACd,qBACA,iBAAiB,0BACjB,aACA,iBACE,oBACF,aACA,eACD;;;;;;AASD,MAAa,gBAAgB,cAC1B,EAAE,UAAU,MAAM,YAAY,OAAO,GAAG,YAAY;CACnD,MAAM,EACJ,aACA,cACA,OACA,UACA,iBACA,UACA,QACA,iBACE,aAAa,MAAM;CACvB,MAAM,mBAAmB,cAAc;AACrC,MAAI,SAAU,QAAO;AAErB,SAAO,OAAO,KAAK,SAAO,YACxB,oBAAC;GAA0B,OAAOC;GAAO,GAAIC;KAAzBD,QAAkC,CACtD;IACD,CAAC,UAAU,MAAM,CAAC;AAiBrB,QACE,oBAAC;EAA4B,OAAO;YAClC,oBAAC;GAAiB,OAlBN,eACP;IACL;IACA;IACA;IACA;IACA;IACA;IACD,GACD;IAAC;IAAc;IAAO;IAAU;IAAiB;IAAU;IAAO,CACnE;aASK,oBAAC;IAAiB,OARC,eAChB;KAAE;KAAM;KAAY,GAC3B,CAAC,MAAM,WAAW,CACnB;cAMO,oBAAC,OAAO;KAAI,GAAI,cAAc;eAAG;MAA8B;KAC9C;IACF;GACS;GAGlC,OACD,EAAE;AAoBH,MAAa,gBAAgB,aAC1B,EAAE,QAAQ,UAAU,MAAM,GAAG,WAAW;CACvC,MAAM,EACJ,UACA,MACA,gBACA,cACA,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GAAG;EACH,GAAG,SAAS;EACb,CAAC,CACH;AAEH,QAAO,SAAS,MAAM,SAAS,GAAG,IAAI,SAAS,KAAK,KAAK,GAAG;GAE9D,OACD,EAAE;AAaH,MAAa,iBAAiB,aAC3B,EACC,kBACA,UACA,OACA,UACA,cACA,gBACA,0BACA,YACA,eACA,eACA,GAAG,WACC;CACJ,MAAM,EAAE,MAAM,kBAAkB,yBAAyB;AAEzD,QACE,oBAAC;EAEG;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;YAGF,oBAAC,OAAO;GAAI,GAAI,cAAc;IAAE;IAA0B,GAAG;IAAM,CAAC;yCACxD,SAAS,GAAG,oBAAC,OAAO,KAAG,WAAoB,GAAG;IAC7C;GACJ;GAGf,QACD,EAAE"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { createContext as createContext$1 } from "../../utils/context.js";
|
|
4
4
|
import { utils_exports } from "../../utils/index.js";
|
|
5
5
|
import { styled } from "../../core/system/factory.js";
|
|
6
|
+
import { mergeProps } from "../../core/components/props.js";
|
|
6
7
|
import { createSlotComponent } from "../../core/components/create-component.js";
|
|
7
8
|
import "../../core/index.js";
|
|
8
9
|
import { ChevronRightIcon } from "../icon/icons/chevron-right-icon.js";
|
|
@@ -142,13 +143,18 @@ const TreeItem = withContext(({ className, css, colorScheme, animated: animatedP
|
|
|
142
143
|
query: query ?? ((0, utils_exports.isString)(label) ? label : void 0),
|
|
143
144
|
value: valueProp
|
|
144
145
|
});
|
|
145
|
-
const itemProps = {
|
|
146
|
+
const itemProps = useMemo(() => mergeProps({
|
|
146
147
|
className,
|
|
147
148
|
css,
|
|
148
149
|
colorScheme,
|
|
149
|
-
"--level": level.toString()
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
"--level": level.toString()
|
|
151
|
+
}, rootProps)(), [
|
|
152
|
+
className,
|
|
153
|
+
css,
|
|
154
|
+
colorScheme,
|
|
155
|
+
level,
|
|
156
|
+
rootProps
|
|
157
|
+
]);
|
|
152
158
|
const callbackProps = {
|
|
153
159
|
disabled,
|
|
154
160
|
expanded: groupOpen
|
|
@@ -175,27 +181,12 @@ const TreeItem = withContext(({ className, css, colorScheme, animated: animatedP
|
|
|
175
181
|
value: useMemo(() => ({
|
|
176
182
|
checkboxProps: {
|
|
177
183
|
size: componentContext.size,
|
|
178
|
-
...getCheckboxProps(
|
|
179
|
-
...componentContext.checkboxProps,
|
|
180
|
-
...checkboxProps
|
|
181
|
-
})
|
|
182
|
-
},
|
|
183
|
-
endElementProps: {
|
|
184
|
-
...componentContext.endElementProps,
|
|
185
|
-
...endElementProps
|
|
184
|
+
...getCheckboxProps(mergeProps(componentContext.checkboxProps, checkboxProps)())
|
|
186
185
|
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
labelProps: { ...getLabelProps({
|
|
192
|
-
...componentContext.labelProps,
|
|
193
|
-
...labelProps
|
|
194
|
-
}) },
|
|
195
|
-
startElementProps: {
|
|
196
|
-
...componentContext.startElementProps,
|
|
197
|
-
...startElementProps
|
|
198
|
-
}
|
|
186
|
+
endElementProps: mergeProps(componentContext.endElementProps, endElementProps)(),
|
|
187
|
+
indicatorProps: { ...getIndicatorProps(mergeProps(componentContext.indicatorProps, indicatorProps)()) },
|
|
188
|
+
labelProps: { ...getLabelProps(mergeProps(componentContext.labelProps, labelProps)()) },
|
|
189
|
+
startElementProps: mergeProps(componentContext.startElementProps, startElementProps)()
|
|
199
190
|
}), [
|
|
200
191
|
checkboxProps,
|
|
201
192
|
componentContext.checkboxProps,
|
|
@@ -230,10 +221,7 @@ const TreeItem = withContext(({ className, css, colorScheme, animated: animatedP
|
|
|
230
221
|
}), /* @__PURE__ */ jsx(TreeGroup, {
|
|
231
222
|
duration: !animated ? 0 : void 0,
|
|
232
223
|
open: groupOpen,
|
|
233
|
-
...getGroupProps(
|
|
234
|
-
...componentContext.groupProps,
|
|
235
|
-
...groupProps
|
|
236
|
-
}),
|
|
224
|
+
...getGroupProps(mergeProps(componentContext.groupProps, groupProps)()),
|
|
237
225
|
children
|
|
238
226
|
})]
|
|
239
227
|
}) : /* @__PURE__ */ jsx(styled.li, {
|
|
@@ -269,44 +257,29 @@ const TreeIndicator = withContext(({ children = /* @__PURE__ */ jsx(ChevronRight
|
|
|
269
257
|
return Children.count(children) > 1 ? Children.only(null) : null;
|
|
270
258
|
}, "indicator")(void 0, (props) => {
|
|
271
259
|
const { indicatorProps } = useItemComponentContext();
|
|
272
|
-
return
|
|
273
|
-
...indicatorProps,
|
|
274
|
-
...props
|
|
275
|
-
};
|
|
260
|
+
return mergeProps(indicatorProps, props)();
|
|
276
261
|
});
|
|
277
262
|
const TreeCheckbox = withContext(Checkbox, "checkbox")(void 0, (props) => {
|
|
278
263
|
const { checkboxProps } = useItemComponentContext();
|
|
279
|
-
return
|
|
280
|
-
...checkboxProps,
|
|
281
|
-
...props
|
|
282
|
-
};
|
|
264
|
+
return mergeProps(checkboxProps, props)();
|
|
283
265
|
});
|
|
284
266
|
const TreeStartElement = withContext("div", {
|
|
285
267
|
name: "StartElement",
|
|
286
268
|
slot: ["element", "start"]
|
|
287
269
|
})(void 0, (props) => {
|
|
288
270
|
const { startElementProps } = useItemComponentContext();
|
|
289
|
-
return
|
|
290
|
-
...startElementProps,
|
|
291
|
-
...props
|
|
292
|
-
};
|
|
271
|
+
return mergeProps(startElementProps, props)();
|
|
293
272
|
});
|
|
294
273
|
const TreeEndElement = withContext("div", {
|
|
295
274
|
name: "EndElement",
|
|
296
275
|
slot: ["element", "end"]
|
|
297
276
|
})(void 0, (props) => {
|
|
298
277
|
const { endElementProps } = useItemComponentContext();
|
|
299
|
-
return
|
|
300
|
-
...endElementProps,
|
|
301
|
-
...props
|
|
302
|
-
};
|
|
278
|
+
return mergeProps(endElementProps, props)();
|
|
303
279
|
});
|
|
304
280
|
const TreeLabel = withContext("span", "label")(void 0, (props) => {
|
|
305
281
|
const { labelProps } = useItemComponentContext();
|
|
306
|
-
return
|
|
307
|
-
...labelProps,
|
|
308
|
-
...props
|
|
309
|
-
};
|
|
282
|
+
return mergeProps(labelProps, props)();
|
|
310
283
|
});
|
|
311
284
|
|
|
312
285
|
//#endregion
|