@yamada-ui/react 2.1.3-dev-20260312041045 → 2.1.3-dev-20260312162557

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/cjs/components/accordion/accordion.cjs +0 -4
  2. package/dist/cjs/components/accordion/accordion.cjs.map +1 -1
  3. package/dist/cjs/components/accordion/use-accordion.cjs.map +1 -1
  4. package/dist/cjs/components/native-accordion/use-native-accordion.cjs +1 -1
  5. package/dist/cjs/components/native-accordion/use-native-accordion.cjs.map +1 -1
  6. package/dist/esm/components/accordion/accordion.js +0 -4
  7. package/dist/esm/components/accordion/accordion.js.map +1 -1
  8. package/dist/esm/components/accordion/use-accordion.js.map +1 -1
  9. package/dist/esm/components/native-accordion/use-native-accordion.js +1 -1
  10. package/dist/esm/components/native-accordion/use-native-accordion.js.map +1 -1
  11. package/dist/types/components/accordion/accordion.d.ts +2 -2
  12. package/dist/types/components/accordion/use-accordion.d.ts +11 -11
  13. package/dist/types/components/airy/airy.d.ts +2 -2
  14. package/dist/types/components/alert/alert.d.ts +2 -2
  15. package/dist/types/components/alpha-slider/alpha-slider.d.ts +2 -2
  16. package/dist/types/components/aspect-ratio/aspect-ratio.d.ts +2 -2
  17. package/dist/types/components/autocomplete/autocomplete.d.ts +2 -2
  18. package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
  19. package/dist/types/components/autocomplete/use-autocomplete.d.ts +5 -5
  20. package/dist/types/components/avatar/avatar.d.ts +5 -5
  21. package/dist/types/components/avatar/use-avatar-group.d.ts +2 -2
  22. package/dist/types/components/badge/badge.d.ts +2 -2
  23. package/dist/types/components/bleed/bleed.d.ts +2 -2
  24. package/dist/types/components/blockquote/blockquote.d.ts +2 -2
  25. package/dist/types/components/breadcrumb/breadcrumb.d.ts +2 -2
  26. package/dist/types/components/breadcrumb/use-breadcrumb.d.ts +2 -2
  27. package/dist/types/components/button/button.d.ts +2 -2
  28. package/dist/types/components/button/icon-button.d.ts +2 -2
  29. package/dist/types/components/calendar/calendar.d.ts +2 -2
  30. package/dist/types/components/calendar/calendar.style.d.ts +2 -2
  31. package/dist/types/components/calendar/use-calendar.d.ts +8 -8
  32. package/dist/types/components/card/card.d.ts +2 -2
  33. package/dist/types/components/carousel/carousel.d.ts +2 -2
  34. package/dist/types/components/carousel/carousel.style.d.ts +2 -2
  35. package/dist/types/components/carousel/use-carousel.d.ts +3 -3
  36. package/dist/types/components/center/center.d.ts +2 -2
  37. package/dist/types/components/chart/chart.d.ts +5 -5
  38. package/dist/types/components/chart/pie-chart.d.ts +2 -2
  39. package/dist/types/components/chart/radar-chart.d.ts +2 -2
  40. package/dist/types/components/chart/radial-chart.d.ts +2 -2
  41. package/dist/types/components/chart/use-chart.d.ts +2 -2
  42. package/dist/types/components/checkbox/checkbox.d.ts +5 -5
  43. package/dist/types/components/checkbox/checkbox.style.d.ts +1 -1
  44. package/dist/types/components/checkbox/use-checkbox-group.d.ts +2 -2
  45. package/dist/types/components/checkbox-card/checkbox-card.d.ts +5 -5
  46. package/dist/types/components/checkbox-card/checkbox-card.style.d.ts +1 -1
  47. package/dist/types/components/circle-progress/circle-progress.d.ts +2 -2
  48. package/dist/types/components/close-button/close-button.d.ts +2 -2
  49. package/dist/types/components/code/code.d.ts +2 -2
  50. package/dist/types/components/collapse/collapse.d.ts +2 -2
  51. package/dist/types/components/color-picker/color-picker.d.ts +2 -2
  52. package/dist/types/components/color-picker/color-picker.style.d.ts +1 -1
  53. package/dist/types/components/color-picker/use-color-picker.d.ts +2 -2
  54. package/dist/types/components/color-selector/color-selector.d.ts +2 -2
  55. package/dist/types/components/color-selector/color-selector.style.d.ts +2 -2
  56. package/dist/types/components/color-selector/use-color-selector.d.ts +3 -3
  57. package/dist/types/components/color-swatch/color-swatch.d.ts +2 -2
  58. package/dist/types/components/container/container.d.ts +2 -2
  59. package/dist/types/components/data-list/data-list.d.ts +2 -2
  60. package/dist/types/components/date-picker/date-picker.d.ts +2 -2
  61. package/dist/types/components/date-picker/use-date-picker.d.ts +4 -4
  62. package/dist/types/components/drawer/drawer.d.ts +2 -2
  63. package/dist/types/components/drawer/drawer.style.d.ts +2 -2
  64. package/dist/types/components/dropzone/dropzone.d.ts +4 -4
  65. package/dist/types/components/editable/editable.d.ts +4 -4
  66. package/dist/types/components/editable/use-editable.d.ts +2 -2
  67. package/dist/types/components/em/em.d.ts +2 -2
  68. package/dist/types/components/empty-state/empty-state.d.ts +2 -2
  69. package/dist/types/components/empty-state/empty-state.style.d.ts +2 -2
  70. package/dist/types/components/fade/fade.d.ts +2 -2
  71. package/dist/types/components/field/field.d.ts +3 -3
  72. package/dist/types/components/field/field.style.d.ts +2 -2
  73. package/dist/types/components/field/use-field-props.d.ts +4 -4
  74. package/dist/types/components/fieldset/fieldset.d.ts +3 -3
  75. package/dist/types/components/fieldset/fieldset.style.d.ts +1 -1
  76. package/dist/types/components/file-button/file-button.d.ts +2 -2
  77. package/dist/types/components/file-button/use-file-button.d.ts +18 -18
  78. package/dist/types/components/file-input/file-input.d.ts +2 -2
  79. package/dist/types/components/file-input/use-file-input.d.ts +15 -15
  80. package/dist/types/components/flex/flex.d.ts +2 -2
  81. package/dist/types/components/flip/flip.d.ts +4 -4
  82. package/dist/types/components/float/float.d.ts +2 -2
  83. package/dist/types/components/form/form.d.ts +3 -3
  84. package/dist/types/components/format/format-byte.d.ts +4 -4
  85. package/dist/types/components/format/format-date-time.d.ts +4 -4
  86. package/dist/types/components/format/format-number.d.ts +2 -2
  87. package/dist/types/components/grid/grid-item.d.ts +2 -2
  88. package/dist/types/components/grid/grid.d.ts +2 -2
  89. package/dist/types/components/group/group.d.ts +2 -2
  90. package/dist/types/components/group/use-group.d.ts +2 -2
  91. package/dist/types/components/heading/heading.d.ts +2 -2
  92. package/dist/types/components/hue-slider/hue-slider.d.ts +3 -3
  93. package/dist/types/components/icon/icon.d.ts +5 -5
  94. package/dist/types/components/image/image.d.ts +2 -2
  95. package/dist/types/components/indicator/indicator.d.ts +4 -4
  96. package/dist/types/components/infinite-scroll-area/infinite-scroll-area.d.ts +2 -2
  97. package/dist/types/components/input/input-addon.d.ts +2 -2
  98. package/dist/types/components/input/input-element.d.ts +2 -2
  99. package/dist/types/components/input/input.d.ts +2 -2
  100. package/dist/types/components/kbd/kbd.d.ts +2 -2
  101. package/dist/types/components/link/link.d.ts +2 -2
  102. package/dist/types/components/link-box/link-box.d.ts +2 -2
  103. package/dist/types/components/list/list.d.ts +2 -2
  104. package/dist/types/components/loading/loading-provider.d.ts +2 -2
  105. package/dist/types/components/loading/loading.d.ts +3 -3
  106. package/dist/types/components/mark/mark.d.ts +2 -2
  107. package/dist/types/components/menu/menu.d.ts +2 -2
  108. package/dist/types/components/menu/menu.style.d.ts +2 -2
  109. package/dist/types/components/menu/use-menu.d.ts +11 -11
  110. package/dist/types/components/modal/modal.d.ts +2 -2
  111. package/dist/types/components/modal/modal.style.d.ts +2 -2
  112. package/dist/types/components/native-accordion/native-accordion.d.ts +2 -2
  113. package/dist/types/components/native-accordion/use-native-accordion.d.ts +2 -2
  114. package/dist/types/components/native-popover/native-popover.d.ts +2 -2
  115. package/dist/types/components/native-select/native-select.d.ts +2 -2
  116. package/dist/types/components/native-table/native-table.d.ts +4 -4
  117. package/dist/types/components/notice/notice.style.d.ts +1 -1
  118. package/dist/types/components/number-input/number-input.d.ts +2 -2
  119. package/dist/types/components/pagination/pagination.d.ts +2 -2
  120. package/dist/types/components/pagination/use-pagination.d.ts +2 -2
  121. package/dist/types/components/password-input/password-input.d.ts +2 -2
  122. package/dist/types/components/password-input/strength-meter.d.ts +2 -2
  123. package/dist/types/components/password-input/strength-meter.style.d.ts +1 -1
  124. package/dist/types/components/password-input/use-password-input.d.ts +2 -2
  125. package/dist/types/components/pin-input/pin-input.d.ts +2 -2
  126. package/dist/types/components/pin-input/use-pin-input.d.ts +7 -7
  127. package/dist/types/components/popover/popover.d.ts +2 -2
  128. package/dist/types/components/progress/progress.d.ts +2 -2
  129. package/dist/types/components/progress/use-progress.d.ts +706 -706
  130. package/dist/types/components/qr-code/qr-code.d.ts +2 -2
  131. package/dist/types/components/radio/radio.d.ts +5 -5
  132. package/dist/types/components/radio/radio.style.d.ts +1 -1
  133. package/dist/types/components/radio/use-radio-group.d.ts +2 -2
  134. package/dist/types/components/radio-card/radio-card.d.ts +5 -5
  135. package/dist/types/components/radio-card/radio-card.style.d.ts +1 -1
  136. package/dist/types/components/rating/use-rating.d.ts +7 -7
  137. package/dist/types/components/reorder/reorder.d.ts +2 -2
  138. package/dist/types/components/reorder/reorder.style.d.ts +1 -1
  139. package/dist/types/components/reorder/use-reorder.d.ts +3 -3
  140. package/dist/types/components/resizable/resizable.d.ts +2 -2
  141. package/dist/types/components/resizable/resizable.style.d.ts +2 -2
  142. package/dist/types/components/resizable/use-resizable.d.ts +2 -2
  143. package/dist/types/components/ripple/ripple.d.ts +2 -2
  144. package/dist/types/components/ripple/use-ripple.d.ts +2 -2
  145. package/dist/types/components/rotate/rotate.d.ts +2 -2
  146. package/dist/types/components/saturation-slider/saturation-slider.d.ts +2 -2
  147. package/dist/types/components/saturation-slider/use-saturation-slider.d.ts +2 -2
  148. package/dist/types/components/scroll-area/scroll-area.d.ts +2 -2
  149. package/dist/types/components/segmented-control/segmented-control.d.ts +2 -2
  150. package/dist/types/components/segmented-control/segmented-control.style.d.ts +2 -2
  151. package/dist/types/components/segmented-control/use-segmented-control.d.ts +9 -9
  152. package/dist/types/components/select/select.d.ts +2 -2
  153. package/dist/types/components/select/select.style.d.ts +1 -1
  154. package/dist/types/components/select/use-select.d.ts +4 -4
  155. package/dist/types/components/separator/separator.d.ts +2 -2
  156. package/dist/types/components/simple-grid/simple-grid.d.ts +2 -2
  157. package/dist/types/components/skeleton/skeleton.d.ts +2 -2
  158. package/dist/types/components/slide/slide.d.ts +2 -2
  159. package/dist/types/components/slide-fade/slide-fade.d.ts +2 -2
  160. package/dist/types/components/slider/slider.d.ts +2 -2
  161. package/dist/types/components/slider/use-slider.d.ts +2 -2
  162. package/dist/types/components/stack/h-stack.d.ts +2 -2
  163. package/dist/types/components/stack/stack.d.ts +2 -2
  164. package/dist/types/components/stack/v-stack.d.ts +2 -2
  165. package/dist/types/components/stack/z-stack.d.ts +2 -2
  166. package/dist/types/components/stat/stat.d.ts +2 -2
  167. package/dist/types/components/status/status.d.ts +2 -2
  168. package/dist/types/components/status/status.style.d.ts +2 -2
  169. package/dist/types/components/steps/steps.d.ts +2 -2
  170. package/dist/types/components/steps/steps.style.d.ts +1 -1
  171. package/dist/types/components/steps/use-steps.d.ts +10 -10
  172. package/dist/types/components/switch/switch.d.ts +2 -2
  173. package/dist/types/components/table/table.d.ts +2 -2
  174. package/dist/types/components/tabs/tabs.d.ts +2 -2
  175. package/dist/types/components/tabs/use-tabs.d.ts +16 -16
  176. package/dist/types/components/tag/tag.d.ts +2 -2
  177. package/dist/types/components/tag/tag.style.d.ts +1 -1
  178. package/dist/types/components/text/text.d.ts +2 -2
  179. package/dist/types/components/textarea/textarea.d.ts +2 -2
  180. package/dist/types/components/textarea/use-autosize.d.ts +2 -2
  181. package/dist/types/components/timeline/timeline.d.ts +5 -5
  182. package/dist/types/components/timeline/timeline.style.d.ts +2 -2
  183. package/dist/types/components/toggle/toggle.d.ts +5 -5
  184. package/dist/types/components/toggle/use-toggle-group.d.ts +2 -2
  185. package/dist/types/components/toggle/use-toggle.d.ts +2 -2
  186. package/dist/types/components/tooltip/tooltip.d.ts +2 -2
  187. package/dist/types/components/visually-hidden/visually-hidden.d.ts +2 -2
  188. package/dist/types/components/wrap/wrap.d.ts +2 -2
  189. package/dist/types/core/components/create-component.d.ts +7 -7
  190. package/dist/types/core/system/color-mode-provider.d.ts +2 -2
  191. package/dist/types/core/system/storage-script.d.ts +3 -3
  192. package/dist/types/core/system/styled.d.ts +2 -2
  193. package/dist/types/core/system/system-provider.d.ts +2 -2
  194. package/dist/types/hooks/use-breakpoint/use-breakpoint-state.d.ts +2 -2
  195. package/dist/types/hooks/use-clickable/index.d.ts +7 -7
  196. package/dist/types/hooks/use-clipboard/index.d.ts +2 -2
  197. package/dist/types/hooks/use-combobox/index.d.ts +12 -12
  198. package/dist/types/hooks/use-counter/index.d.ts +2 -2
  199. package/dist/types/hooks/use-descendants/index.d.ts +2 -2
  200. package/dist/types/providers/i18n-provider/i18n-provider.d.ts +3 -3
  201. package/dist/types/providers/ui-provider/ui-provider.d.ts +2 -2
  202. package/dist/types/utils/children.d.ts +2 -2
  203. package/package.json +1 -1
@@ -38,8 +38,6 @@ const AccordionRoot = withProvider(({ children, icon, iconHidden, items, ...prop
38
38
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_use_accordion.AccordionContext, {
39
39
  value: (0, react.useMemo)(() => ({
40
40
  focusedIndex,
41
- icon,
42
- iconHidden,
43
41
  index,
44
42
  multiple,
45
43
  setFocusedIndex,
@@ -47,8 +45,6 @@ const AccordionRoot = withProvider(({ children, icon, iconHidden, items, ...prop
47
45
  toggle
48
46
  }), [
49
47
  focusedIndex,
50
- icon,
51
- iconHidden,
52
48
  index,
53
49
  multiple,
54
50
  setFocusedIndex,
@@ -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 icon,\n iconHidden,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n }),\n [\n focusedIndex,\n icon,\n iconHidden,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n ],\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 ({ children, icon: customIcon, containerProps, ...rest }) => {\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 {...getButtonProps(rest)}>\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 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(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;AA4BrB,QACE,2CAACE;EAA4B,OAAO;YAClC,2CAACC;GAAiB,iCA5Bb;IACL;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD,GACD;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD,CACF;aASK,2CAAC;IAAiB,iCAPf;KAAE;KAAM;KAAY,GAC3B,CAAC,MAAM,WAAW,CACnB;cAMO,2CAACC,uBAAO;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,cACA,kBACEC,uCAAiB,KAAK;CAK1B,MAAM,CAAC,iBAAiB,uBAAuB,wBAC7CC,0GAJc,UAAU;EAAE;EAAU,UAAU;EAAM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,aAC3B,EACC,kBACA,UACA,OACA,UACA,cACA,gBACA,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,KAAK;6DACvB,SAAS,GAAG,2CAACA,uBAAO,KAAG,WAAoB,GAAG;IAC7C;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 ({ children, icon: customIcon, containerProps, ...rest }) => {\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 {...getButtonProps(rest)}>\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 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(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,Y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Aa,kBAAkB,aAC5B,EAAE,UAAU,MAAM,YAAY,gBAAgB,GAAG,WAAW;CAC3D,MAAM,EAAE,MAAM,aAAa,qBAAqB;CAChD,MAAM,EAAE,MAAM,aAAa,yBAAyB;CACpD,MAAM,EAAE,UAAU,MAAM,mBAAmBI,+CAAyB;CACpE,MAAM,QAAQ;EAAE;EAAU,UAAU;EAAM;AAE1C,QACE,2CAACJ,uBAAO;EAAG,GAAI;YACb,4CAACA,uBAAO;GAAO,GAAI,eAAe,KAAK;cACpC,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,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,KAAK;6DACvB,SAAS,GAAG,2CAACA,uBAAO,KAAG,WAAoB,GAAG;IAC7C;GACJ;GAGf,QACD,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-accordion.cjs","names":["createDescendants","createContext","useControllableState","getRootProps: PropGetter","mergeRefs","open","getItemProps: PropGetter","getButtonProps: PropGetter<\"button\">","getPanelProps: PropGetter"],"sources":["../../../../src/components/accordion/use-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n handlerAll,\n isArray,\n mergeRefs,\n runKeyAction,\n} from \"../../utils\"\n\nconst {\n DescendantsContext: AccordionDescendantsContext,\n useDescendant: useAccordionDescendant,\n useDescendants: useAccordionDescendants,\n} = createDescendants<HTMLButtonElement>()\n\nexport {\n AccordionDescendantsContext,\n useAccordionDescendant,\n useAccordionDescendants,\n}\n\ninterface AccordionContext extends Omit<\n UseAccordionReturn,\n \"descendants\" | \"getRootProps\"\n> {}\n\nconst [AccordionContext, useAccordionContext] = createContext<AccordionContext>(\n {\n name: \"AccordionContext\",\n },\n)\n\nexport { AccordionContext, useAccordionContext }\n\ninterface AccordionItemContext extends Omit<\n UseAccordionItemReturn,\n \"getItemProps\"\n> {}\n\nconst [AccordionItemContext, useAccordionItemContext] =\n createContext<AccordionItemContext>({\n name: \"AccordionItemContext\",\n })\n\nexport { AccordionItemContext, useAccordionItemContext }\n\nexport interface UseAccordionProps extends Omit<HTMLProps, \"onChange\"> {\n /**\n * The initial index(es) of the accordion item to expand.\n */\n defaultIndex?: number | number[]\n /**\n * The index(es) of the accordion item to expand.\n */\n index?: number | number[]\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * If `true`, any expanded accordion item can be collapsed again.\n *\n * @default false\n */\n toggle?: boolean\n /**\n * The callback invoked when accordion items are expanded or collapsed.\n */\n onChange?: (index: number | number[]) => void\n}\n\nexport const useAccordion = ({\n defaultIndex: defaultIndexProp,\n index: indexProp,\n multiple,\n toggle,\n onChange,\n ...rest\n}: UseAccordionProps = {}) => {\n if (\n (indexProp || defaultIndexProp) != null &&\n !isArray(indexProp || defaultIndexProp) &&\n multiple\n ) {\n console.warn(\n `Accordion: If 'multiple' is passed, then 'index' or 'defaultIndex' must be an array.`,\n )\n }\n\n if (multiple && toggle) {\n console.warn(\n `Accordion: If 'multiple' is passed, 'toggle' will be ignored. Either remove 'toggle' or 'multiple' depending on whether you want multiple accordions visible or not`,\n )\n }\n\n const descendants = useAccordionDescendants()\n\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n\n const [index, setIndex] = useControllableState({\n defaultValue: () =>\n multiple ? (defaultIndexProp ?? []) : (defaultIndexProp ?? -1),\n value: indexProp,\n onChange,\n })\n\n const getRootProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n }),\n [rest],\n )\n\n useEffect(() => {\n return () => setFocusedIndex(-1)\n }, [])\n\n return {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n }\n}\n\nexport type UseAccordionReturn = ReturnType<typeof useAccordion>\n\nexport interface UseAccordionItemProps extends HTMLProps {\n /**\n * The index of the accordion item.\n */\n index: number\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useAccordionItem = ({\n disabled,\n index,\n ...rest\n}: UseAccordionItemProps) => {\n const itemId = useId()\n const panelId = useId()\n const {\n index: selectedIndex,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n } = useAccordionContext()\n const { descendants, register } = useAccordionDescendant({ disabled })\n const open =\n index !== -1\n ? isArray(selectedIndex)\n ? selectedIndex.includes(index)\n : selectedIndex === index\n : false\n\n if (open && disabled)\n console.warn(`Accordion: Cannot open a disabled accordion item`)\n\n const onChange = useCallback(\n (open: boolean) => {\n if (index === -1) return\n\n if (multiple && isArray(selectedIndex)) {\n setIndex(\n open\n ? selectedIndex.concat(index)\n : selectedIndex.filter((i) => i !== index),\n )\n } else if (open) {\n setIndex(index)\n } else if (toggle) {\n setIndex(-1)\n }\n },\n [multiple, toggle, index, selectedIndex, setIndex],\n )\n\n const onFocus = useCallback(() => {\n setFocusedIndex(index)\n }, [setFocusedIndex, index])\n\n const onClick = useCallback(() => {\n onChange(!open)\n setFocusedIndex(index)\n }, [index, setFocusedIndex, open, onChange])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLButtonElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => {\n const next = descendants.enabledNextValue(index)\n\n next?.node.focus()\n },\n ArrowUp: () => {\n const prev = descendants.enabledPrevValue(index)\n\n prev?.node.focus()\n },\n End: () => {\n const last = descendants.enabledLastValue()\n\n last?.node.focus()\n },\n Home: () => {\n const first = descendants.enabledFirstValue()\n\n first?.node.focus()\n },\n })\n },\n [descendants, index],\n )\n\n const getItemProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n \"data-expanded\": dataAttr(open),\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n }),\n [open, rest],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n id: itemId,\n type: \"button\",\n \"aria-controls\": panelId,\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n ...props,\n ref: mergeRefs(register, ref),\n disabled,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n itemId,\n open,\n panelId,\n multiple,\n toggle,\n disabled,\n register,\n onClick,\n onFocus,\n onKeyDown,\n ],\n )\n\n const getPanelProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) => ({\n id: panelId,\n \"aria-labelledby\": cx(ariaLabelledby, itemId),\n role: \"region\",\n ...props,\n }),\n [itemId, panelId],\n )\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [multiple, toggle, open, disabled],\n )\n\n return {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseAccordionItemReturn = ReturnType<typeof useAccordionItem>\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAM,EACJ,oBAAoB,6BACpB,eAAe,wBACf,gBAAgB,4BACdA,uDAAsC;AAa1C,MAAM,CAAC,kBAAkB,uBAAuBC,8BAC9C,EACE,MAAM,oBACP,CACF;AASD,MAAM,CAAC,sBAAsB,2BAC3BA,8BAAoC,EAClC,MAAM,wBACP,CAAC;AA+BJ,MAAa,gBAAgB,EAC3B,cAAc,kBACd,OAAO,WACP,UACA,QACA,UACA,GAAG,SACkB,EAAE,KAAK;AAC5B,MACG,aAAa,qBAAqB,QACnC,gDAAS,aAAa,iBAAiB,IACvC,SAEA,SAAQ,KACN,uFACD;AAGH,KAAI,YAAY,OACd,SAAQ,KACN,sKACD;CAGH,MAAM,cAAc,yBAAyB;CAE7C,MAAM,CAAC,cAAc,uCAAoC,GAAG;CAE5D,MAAM,CAAC,OAAO,YAAYC,gEAAqB;EAC7C,oBACE,WAAY,oBAAoB,EAAE,GAAK,oBAAoB;EAC7D,OAAO;EACP;EACD,CAAC;CAEF,MAAMC,uCACH,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EAC3B,GAAG;EACH,GAAG;EACH,KAAKC,sBAAU,KAAK,KAAK,IAAI;EAC9B,GACD,CAAC,KAAK,CACP;AAED,4BAAgB;AACd,eAAa,gBAAgB,GAAG;IAC/B,EAAE,CAAC;AAEN,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;AAkBH,MAAa,oBAAoB,EAC/B,UACA,OACA,GAAG,WACwB;CAC3B,MAAM,2BAAgB;CACtB,MAAM,4BAAiB;CACvB,MAAM,EACJ,OAAO,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ACJ,MAAM;EACN,iBAAiB;EACjB,iEAA2B,CAAC,YAAY,CAAC,UAAU,QAAS,SAAS;EACrE,iBAAiB;EACjB,GAAG;EACH,KAAKH,sBAAU,UAAU,IAAI;EAC7B;EACA,2DAAoB,MAAM,SAAS,QAAQ;EAC3C,2DAAoB,MAAM,SAAS,QAAQ;EAC3C,6DAAsB,MAAM,WAAW,UAAU;EAClD,GACD;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;CAED,MAAMI,wCACH,EAAE,mBAAmB,gBAAgB,GAAG,UAAU,EAAE,MAAM;EACzD,IAAI;EACJ,6DAAsB,gBAAgB,OAAO;EAC7C,MAAM;EACN,GAAG;EACJ,GACD,CAAC,QAAQ,QAAQ,CAClB;AAaD,QAAO;EACL;EACA;EACA;EACA,sCAdC,WAAW;GACV,iEAA2B,CAAC,YAAY,CAAC,UAAU,QAAS,SAAS;GACrE,iBAAiB;GACjB,eAAe;GACf,MAAM;GACN,GAAG;GACJ,GACD;GAAC;GAAU;GAAQ;GAAM;GAAS,CACnC;EAOC;EACA;EACD"}
1
+ {"version":3,"file":"use-accordion.cjs","names":["createDescendants","createContext","useControllableState","getRootProps: PropGetter","mergeRefs","open","getItemProps: PropGetter","getButtonProps: PropGetter<\"button\">","getPanelProps: PropGetter"],"sources":["../../../../src/components/accordion/use-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n handlerAll,\n isArray,\n mergeRefs,\n runKeyAction,\n} from \"../../utils\"\n\nconst {\n DescendantsContext: AccordionDescendantsContext,\n useDescendant: useAccordionDescendant,\n useDescendants: useAccordionDescendants,\n} = createDescendants<HTMLButtonElement>()\n\nexport {\n AccordionDescendantsContext,\n useAccordionDescendant,\n useAccordionDescendants,\n}\n\ninterface AccordionContext extends Omit<\n UseAccordionReturn,\n \"descendants\" | \"getRootProps\"\n> {}\n\nconst [AccordionContext, useAccordionContext] = createContext<AccordionContext>(\n { name: \"AccordionContext\" },\n)\n\nexport { AccordionContext, useAccordionContext }\n\ninterface AccordionItemContext extends Omit<\n UseAccordionItemReturn,\n \"getItemProps\"\n> {}\n\nconst [AccordionItemContext, useAccordionItemContext] =\n createContext<AccordionItemContext>({\n name: \"AccordionItemContext\",\n })\n\nexport { AccordionItemContext, useAccordionItemContext }\n\nexport interface UseAccordionProps extends Omit<HTMLProps, \"onChange\"> {\n /**\n * The initial index(es) of the accordion item to expand.\n */\n defaultIndex?: number | number[]\n /**\n * The index(es) of the accordion item to expand.\n */\n index?: number | number[]\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * If `true`, any expanded accordion item can be collapsed again.\n *\n * @default false\n */\n toggle?: boolean\n /**\n * The callback invoked when accordion items are expanded or collapsed.\n */\n onChange?: (index: number | number[]) => void\n}\n\nexport const useAccordion = ({\n defaultIndex: defaultIndexProp,\n index: indexProp,\n multiple,\n toggle,\n onChange,\n ...rest\n}: UseAccordionProps = {}) => {\n if (\n (indexProp || defaultIndexProp) != null &&\n !isArray(indexProp || defaultIndexProp) &&\n multiple\n ) {\n console.warn(\n `Accordion: If 'multiple' is passed, then 'index' or 'defaultIndex' must be an array.`,\n )\n }\n\n if (multiple && toggle) {\n console.warn(\n `Accordion: If 'multiple' is passed, 'toggle' will be ignored. Either remove 'toggle' or 'multiple' depending on whether you want multiple accordions visible or not`,\n )\n }\n\n const descendants = useAccordionDescendants()\n\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n\n const [index, setIndex] = useControllableState({\n defaultValue: () =>\n multiple ? (defaultIndexProp ?? []) : (defaultIndexProp ?? -1),\n value: indexProp,\n onChange,\n })\n\n const getRootProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n }),\n [rest],\n )\n\n useEffect(() => {\n return () => setFocusedIndex(-1)\n }, [])\n\n return {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n }\n}\n\nexport type UseAccordionReturn = ReturnType<typeof useAccordion>\n\nexport interface UseAccordionItemProps extends HTMLProps {\n /**\n * The index of the accordion item.\n */\n index: number\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useAccordionItem = ({\n disabled,\n index,\n ...rest\n}: UseAccordionItemProps) => {\n const itemId = useId()\n const panelId = useId()\n const {\n index: selectedIndex,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n } = useAccordionContext()\n const { descendants, register } = useAccordionDescendant({ disabled })\n const open =\n index !== -1\n ? isArray(selectedIndex)\n ? selectedIndex.includes(index)\n : selectedIndex === index\n : false\n\n if (open && disabled)\n console.warn(`Accordion: Cannot open a disabled accordion item`)\n\n const onChange = useCallback(\n (open: boolean) => {\n if (index === -1) return\n\n if (multiple && isArray(selectedIndex)) {\n setIndex(\n open\n ? selectedIndex.concat(index)\n : selectedIndex.filter((i) => i !== index),\n )\n } else if (open) {\n setIndex(index)\n } else if (toggle) {\n setIndex(-1)\n }\n },\n [multiple, toggle, index, selectedIndex, setIndex],\n )\n\n const onFocus = useCallback(() => {\n setFocusedIndex(index)\n }, [setFocusedIndex, index])\n\n const onClick = useCallback(() => {\n onChange(!open)\n setFocusedIndex(index)\n }, [index, setFocusedIndex, open, onChange])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLButtonElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => {\n const next = descendants.enabledNextValue(index)\n\n next?.node.focus()\n },\n ArrowUp: () => {\n const prev = descendants.enabledPrevValue(index)\n\n prev?.node.focus()\n },\n End: () => {\n const last = descendants.enabledLastValue()\n\n last?.node.focus()\n },\n Home: () => {\n const first = descendants.enabledFirstValue()\n\n first?.node.focus()\n },\n })\n },\n [descendants, index],\n )\n\n const getItemProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n \"data-expanded\": dataAttr(open),\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n }),\n [open, rest],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n id: itemId,\n type: \"button\",\n \"aria-controls\": panelId,\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n ...props,\n ref: mergeRefs(register, ref),\n disabled,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n itemId,\n open,\n panelId,\n multiple,\n toggle,\n disabled,\n register,\n onClick,\n onFocus,\n onKeyDown,\n ],\n )\n\n const getPanelProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) => ({\n id: panelId,\n \"aria-labelledby\": cx(ariaLabelledby, itemId),\n role: \"region\",\n ...props,\n }),\n [itemId, panelId],\n )\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [multiple, toggle, open, disabled],\n )\n\n return {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseAccordionItemReturn = ReturnType<typeof useAccordionItem>\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAM,EACJ,oBAAoB,6BACpB,eAAe,wBACf,gBAAgB,4BACdA,uDAAsC;AAa1C,MAAM,CAAC,kBAAkB,uBAAuBC,8BAC9C,EAAE,MAAM,oBAAoB,CAC7B;AASD,MAAM,CAAC,sBAAsB,2BAC3BA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,MAAM;EACN,GAAG;EACJ,GACD,CAAC,QAAQ,QAAQ,CAClB;AAaD,QAAO;EACL;EACA;EACA;EACA,sCAdC,WAAW;GACV,iEAA2B,CAAC,YAAY,CAAC,UAAU,QAAS,SAAS;GACrE,iBAAiB;GACjB,eAAe;GACf,MAAM;GACN,GAAG;GACJ,GACD;GAAC;GAAU;GAAQ;GAAM;GAAS,CACnC;EAOC;EACA;EACD"}
@@ -25,7 +25,7 @@ const useNativeAccordionItem = ({ disabled, ...rest }) => {
25
25
  const getItemProps = ({ ref, ...props } = {}) => ({
26
26
  ref: require_ref.mergeRefs(ref, rest.ref),
27
27
  name: props.name ?? rest.name ?? name,
28
- role: "group",
28
+ "data-group": "",
29
29
  ...rest,
30
30
  ...props
31
31
  });
@@ -1 +1 @@
1
- {"version":3,"file":"use-native-accordion.cjs","names":["createContext","getRootProps: PropGetter","mergeRefs","getItemProps: PropGetter<\"details\">","getButtonProps: PropGetter<\"summary\">","getPanelProps: PropGetter"],"sources":["../../../../src/components/native-accordion/use-native-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useId } from \"react\"\nimport {\n ariaAttr,\n createContext,\n dataAttr,\n handlerAll,\n mergeRefs,\n} from \"../../utils\"\n\ninterface NativeAccordionContext extends Pick<\n UseNativeAccordionReturn,\n \"name\"\n> {}\n\nconst [NativeAccordionContext, useNativeAccordionContext] =\n createContext<NativeAccordionContext>({\n name: \"NativeAccordionContext\",\n })\n\nexport { NativeAccordionContext, useNativeAccordionContext }\n\nexport interface UseNativeAccordionProps extends HTMLProps {\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * The HTML `name` attribute used for forms.\n */\n name?: string\n}\n\nexport const useNativeAccordion = ({\n name,\n multiple = false,\n ...rest\n}: UseNativeAccordionProps = {}) => {\n const generatedName = useId()\n\n const getRootProps: PropGetter = ({ ref, ...props } = {}) => ({\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n })\n\n return {\n name: multiple ? undefined : (name ?? generatedName),\n getRootProps,\n }\n}\n\nexport type UseNativeAccordionReturn = ReturnType<typeof useNativeAccordion>\n\nexport interface UseNativeAccordionItemProps extends HTMLProps<\"details\"> {\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useNativeAccordionItem = ({\n disabled,\n ...rest\n}: UseNativeAccordionItemProps) => {\n const { name } = useNativeAccordionContext()\n\n const getItemProps: PropGetter<\"details\"> = ({ ref, ...props } = {}) => ({\n ref: mergeRefs(ref, rest.ref),\n name: props.name ?? rest.name ?? name,\n role: \"group\",\n ...rest,\n ...props,\n })\n\n const getButtonProps: PropGetter<\"summary\"> = useCallback(\n (props = {}) => ({\n \"aria-disabled\": ariaAttr(disabled),\n \"data-disabled\": dataAttr(disabled),\n ...props,\n onClick: handlerAll(props.onClick, (ev) => {\n if (!disabled) return\n\n ev.preventDefault()\n }),\n }),\n [disabled],\n )\n\n const getPanelProps: PropGetter = useCallback((props = {}) => props, [])\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props = {}) => ({\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [disabled],\n )\n\n return {\n disabled,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseNativeAccordionItemReturn = ReturnType<\n typeof useNativeAccordionItem\n>\n"],"mappings":";;;;;;;;;AAiBA,MAAM,CAAC,wBAAwB,6BAC7BA,8BAAsC,EACpC,MAAM,0BACP,CAAC;AAiBJ,MAAa,sBAAsB,EACjC,MACA,WAAW,OACX,GAAG,SACwB,EAAE,KAAK;CAClC,MAAM,kCAAuB;CAE7B,MAAMC,gBAA4B,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EAC5D,GAAG;EACH,GAAG;EACH,KAAKC,sBAAU,KAAK,KAAK,IAAI;EAC9B;AAED,QAAO;EACL,MAAM,WAAW,SAAa,QAAQ;EACtC;EACD;;AAcH,MAAa,0BAA0B,EACrC,UACA,GAAG,WAC8B;CACjC,MAAM,EAAE,SAAS,2BAA2B;CAE5C,MAAMC,gBAAuC,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EACvE,KAAKD,sBAAU,KAAK,KAAK,IAAI;EAC7B,MAAM,MAAM,QAAQ,KAAK,QAAQ;EACjC,MAAM;EACN,GAAG;EACH,GAAG;EACJ;CAED,MAAME,yCACH,QAAQ,EAAE,MAAM;EACf,iEAA0B,SAAS;EACnC,iEAA0B,SAAS;EACnC,GAAG;EACH,2DAAoB,MAAM,UAAU,OAAO;AACzC,OAAI,CAAC,SAAU;AAEf,MAAG,gBAAgB;IACnB;EACH,GACD,CAAC,SAAS,CACX;CAED,MAAMC,wCAAyC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;AAYxE,QAAO;EACL;EACA;EACA,sCAZC,QAAQ,EAAE,MAAM;GACf,iEAA0B,SAAS;GACnC,eAAe;GACf,MAAM;GACN,GAAG;GACJ,GACD,CAAC,SAAS,CACX;EAMC;EACA;EACD"}
1
+ {"version":3,"file":"use-native-accordion.cjs","names":["createContext","getRootProps: PropGetter","mergeRefs","getItemProps: PropGetter<\"details\">","getButtonProps: PropGetter<\"summary\">","getPanelProps: PropGetter"],"sources":["../../../../src/components/native-accordion/use-native-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useId } from \"react\"\nimport {\n ariaAttr,\n createContext,\n dataAttr,\n handlerAll,\n mergeRefs,\n} from \"../../utils\"\n\ninterface NativeAccordionContext extends Pick<\n UseNativeAccordionReturn,\n \"name\"\n> {}\n\nconst [NativeAccordionContext, useNativeAccordionContext] =\n createContext<NativeAccordionContext>({\n name: \"NativeAccordionContext\",\n })\n\nexport { NativeAccordionContext, useNativeAccordionContext }\n\nexport interface UseNativeAccordionProps extends HTMLProps {\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * The HTML `name` attribute used for forms.\n */\n name?: string\n}\n\nexport const useNativeAccordion = ({\n name,\n multiple = false,\n ...rest\n}: UseNativeAccordionProps = {}) => {\n const generatedName = useId()\n\n const getRootProps: PropGetter = ({ ref, ...props } = {}) => ({\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n })\n\n return {\n name: multiple ? undefined : (name ?? generatedName),\n getRootProps,\n }\n}\n\nexport type UseNativeAccordionReturn = ReturnType<typeof useNativeAccordion>\n\nexport interface UseNativeAccordionItemProps extends HTMLProps<\"details\"> {\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useNativeAccordionItem = ({\n disabled,\n ...rest\n}: UseNativeAccordionItemProps) => {\n const { name } = useNativeAccordionContext()\n\n const getItemProps: PropGetter<\"details\"> = ({ ref, ...props } = {}) => ({\n ref: mergeRefs(ref, rest.ref),\n name: props.name ?? rest.name ?? name,\n \"data-group\": \"\",\n ...rest,\n ...props,\n })\n\n const getButtonProps: PropGetter<\"summary\"> = useCallback(\n (props = {}) => ({\n \"aria-disabled\": ariaAttr(disabled),\n \"data-disabled\": dataAttr(disabled),\n ...props,\n onClick: handlerAll(props.onClick, (ev) => {\n if (!disabled) return\n\n ev.preventDefault()\n }),\n }),\n [disabled],\n )\n\n const getPanelProps: PropGetter = useCallback((props = {}) => props, [])\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props = {}) => ({\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [disabled],\n )\n\n return {\n disabled,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseNativeAccordionItemReturn = ReturnType<\n typeof useNativeAccordionItem\n>\n"],"mappings":";;;;;;;;;AAiBA,MAAM,CAAC,wBAAwB,6BAC7BA,8BAAsC,EACpC,MAAM,0BACP,CAAC;AAiBJ,MAAa,sBAAsB,EACjC,MACA,WAAW,OACX,GAAG,SACwB,EAAE,KAAK;CAClC,MAAM,kCAAuB;CAE7B,MAAMC,gBAA4B,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EAC5D,GAAG;EACH,GAAG;EACH,KAAKC,sBAAU,KAAK,KAAK,IAAI;EAC9B;AAED,QAAO;EACL,MAAM,WAAW,SAAa,QAAQ;EACtC;EACD;;AAcH,MAAa,0BAA0B,EACrC,UACA,GAAG,WAC8B;CACjC,MAAM,EAAE,SAAS,2BAA2B;CAE5C,MAAMC,gBAAuC,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EACvE,KAAKD,sBAAU,KAAK,KAAK,IAAI;EAC7B,MAAM,MAAM,QAAQ,KAAK,QAAQ;EACjC,cAAc;EACd,GAAG;EACH,GAAG;EACJ;CAED,MAAME,yCACH,QAAQ,EAAE,MAAM;EACf,iEAA0B,SAAS;EACnC,iEAA0B,SAAS;EACnC,GAAG;EACH,2DAAoB,MAAM,UAAU,OAAO;AACzC,OAAI,CAAC,SAAU;AAEf,MAAG,gBAAgB;IACnB;EACH,GACD,CAAC,SAAS,CACX;CAED,MAAMC,wCAAyC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;AAYxE,QAAO;EACL;EACA;EACA,sCAZC,QAAQ,EAAE,MAAM;GACf,iEAA0B,SAAS;GACnC,eAAe;GACf,MAAM;GACN,GAAG;GACJ,GACD,CAAC,SAAS,CACX;EAMC;EACA;EACD"}
@@ -37,8 +37,6 @@ const AccordionRoot = withProvider(({ children, icon, iconHidden, items, ...prop
37
37
  children: /* @__PURE__ */ jsx(AccordionContext, {
38
38
  value: useMemo(() => ({
39
39
  focusedIndex,
40
- icon,
41
- iconHidden,
42
40
  index,
43
41
  multiple,
44
42
  setFocusedIndex,
@@ -46,8 +44,6 @@ const AccordionRoot = withProvider(({ children, icon, iconHidden, items, ...prop
46
44
  toggle
47
45
  }), [
48
46
  focusedIndex,
49
- icon,
50
- iconHidden,
51
47
  index,
52
48
  multiple,
53
49
  setFocusedIndex,
@@ -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 icon,\n iconHidden,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n }),\n [\n focusedIndex,\n icon,\n iconHidden,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n ],\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 ({ children, icon: customIcon, containerProps, ...rest }) => {\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 {...getButtonProps(rest)}>\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 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(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;AA4BrB,QACE,oBAAC;EAA4B,OAAO;Y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b,qBAAC,OAAO;GAAO,GAAI,eAAe,KAAK;cACpC,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,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,KAAK;yCACvB,SAAS,GAAG,oBAAC,OAAO,KAAG,WAAoB,GAAG;IAC7C;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 ({ children, icon: customIcon, containerProps, ...rest }) => {\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 {...getButtonProps(rest)}>\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 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(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,cACA,kBACE,iBAAiB,KAAK;CAK1B,MAAM,CAAC,iBAAiB,uBAAuB,wBAC7C,iBALuB,yCACT,UAAU;EAAE;EAAU,UAAU;EAAM,CAAC,EACrD;EAAC;EAAU;EAAU;EAAK,CA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A,cACA,gBACA,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,KAAK;yCACvB,SAAS,GAAG,oBAAC,OAAO,KAAG,WAAoB,GAAG;IAC7C;GACJ;GAGf,QACD,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-accordion.js","names":["createContext","getRootProps: PropGetter","open","getItemProps: PropGetter","getButtonProps: PropGetter<\"button\">","getPanelProps: PropGetter"],"sources":["../../../../src/components/accordion/use-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n handlerAll,\n isArray,\n mergeRefs,\n runKeyAction,\n} from \"../../utils\"\n\nconst {\n DescendantsContext: AccordionDescendantsContext,\n useDescendant: useAccordionDescendant,\n useDescendants: useAccordionDescendants,\n} = createDescendants<HTMLButtonElement>()\n\nexport {\n AccordionDescendantsContext,\n useAccordionDescendant,\n useAccordionDescendants,\n}\n\ninterface AccordionContext extends Omit<\n UseAccordionReturn,\n \"descendants\" | \"getRootProps\"\n> {}\n\nconst [AccordionContext, useAccordionContext] = createContext<AccordionContext>(\n {\n name: \"AccordionContext\",\n },\n)\n\nexport { AccordionContext, useAccordionContext }\n\ninterface AccordionItemContext extends Omit<\n UseAccordionItemReturn,\n \"getItemProps\"\n> {}\n\nconst [AccordionItemContext, useAccordionItemContext] =\n createContext<AccordionItemContext>({\n name: \"AccordionItemContext\",\n })\n\nexport { AccordionItemContext, useAccordionItemContext }\n\nexport interface UseAccordionProps extends Omit<HTMLProps, \"onChange\"> {\n /**\n * The initial index(es) of the accordion item to expand.\n */\n defaultIndex?: number | number[]\n /**\n * The index(es) of the accordion item to expand.\n */\n index?: number | number[]\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * If `true`, any expanded accordion item can be collapsed again.\n *\n * @default false\n */\n toggle?: boolean\n /**\n * The callback invoked when accordion items are expanded or collapsed.\n */\n onChange?: (index: number | number[]) => void\n}\n\nexport const useAccordion = ({\n defaultIndex: defaultIndexProp,\n index: indexProp,\n multiple,\n toggle,\n onChange,\n ...rest\n}: UseAccordionProps = {}) => {\n if (\n (indexProp || defaultIndexProp) != null &&\n !isArray(indexProp || defaultIndexProp) &&\n multiple\n ) {\n console.warn(\n `Accordion: If 'multiple' is passed, then 'index' or 'defaultIndex' must be an array.`,\n )\n }\n\n if (multiple && toggle) {\n console.warn(\n `Accordion: If 'multiple' is passed, 'toggle' will be ignored. Either remove 'toggle' or 'multiple' depending on whether you want multiple accordions visible or not`,\n )\n }\n\n const descendants = useAccordionDescendants()\n\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n\n const [index, setIndex] = useControllableState({\n defaultValue: () =>\n multiple ? (defaultIndexProp ?? []) : (defaultIndexProp ?? -1),\n value: indexProp,\n onChange,\n })\n\n const getRootProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n }),\n [rest],\n )\n\n useEffect(() => {\n return () => setFocusedIndex(-1)\n }, [])\n\n return {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n }\n}\n\nexport type UseAccordionReturn = ReturnType<typeof useAccordion>\n\nexport interface UseAccordionItemProps extends HTMLProps {\n /**\n * The index of the accordion item.\n */\n index: number\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useAccordionItem = ({\n disabled,\n index,\n ...rest\n}: UseAccordionItemProps) => {\n const itemId = useId()\n const panelId = useId()\n const {\n index: selectedIndex,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n } = useAccordionContext()\n const { descendants, register } = useAccordionDescendant({ disabled })\n const open =\n index !== -1\n ? isArray(selectedIndex)\n ? selectedIndex.includes(index)\n : selectedIndex === index\n : false\n\n if (open && disabled)\n console.warn(`Accordion: Cannot open a disabled accordion item`)\n\n const onChange = useCallback(\n (open: boolean) => {\n if (index === -1) return\n\n if (multiple && isArray(selectedIndex)) {\n setIndex(\n open\n ? selectedIndex.concat(index)\n : selectedIndex.filter((i) => i !== index),\n )\n } else if (open) {\n setIndex(index)\n } else if (toggle) {\n setIndex(-1)\n }\n },\n [multiple, toggle, index, selectedIndex, setIndex],\n )\n\n const onFocus = useCallback(() => {\n setFocusedIndex(index)\n }, [setFocusedIndex, index])\n\n const onClick = useCallback(() => {\n onChange(!open)\n setFocusedIndex(index)\n }, [index, setFocusedIndex, open, onChange])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLButtonElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => {\n const next = descendants.enabledNextValue(index)\n\n next?.node.focus()\n },\n ArrowUp: () => {\n const prev = descendants.enabledPrevValue(index)\n\n prev?.node.focus()\n },\n End: () => {\n const last = descendants.enabledLastValue()\n\n last?.node.focus()\n },\n Home: () => {\n const first = descendants.enabledFirstValue()\n\n first?.node.focus()\n },\n })\n },\n [descendants, index],\n )\n\n const getItemProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n \"data-expanded\": dataAttr(open),\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n }),\n [open, rest],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n id: itemId,\n type: \"button\",\n \"aria-controls\": panelId,\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n ...props,\n ref: mergeRefs(register, ref),\n disabled,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n itemId,\n open,\n panelId,\n multiple,\n toggle,\n disabled,\n register,\n onClick,\n onFocus,\n onKeyDown,\n ],\n )\n\n const getPanelProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) => ({\n id: panelId,\n \"aria-labelledby\": cx(ariaLabelledby, itemId),\n role: \"region\",\n ...props,\n }),\n [itemId, panelId],\n )\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [multiple, toggle, open, disabled],\n )\n\n return {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseAccordionItemReturn = ReturnType<typeof useAccordionItem>\n"],"mappings":";;;;;;;;;;;AAkBA,MAAM,EACJ,oBAAoB,6BACpB,eAAe,wBACf,gBAAgB,4BACd,mBAAsC;AAa1C,MAAM,CAAC,kBAAkB,uBAAuBA,gBAC9C,EACE,MAAM,oBACP,CACF;AASD,MAAM,CAAC,sBAAsB,2BAC3BA,gBAAoC,EAClC,MAAM,wBACP,CAAC;AA+BJ,MAAa,gBAAgB,EAC3B,cAAc,kBACd,OAAO,WACP,UACA,QACA,UACA,GAAG,SACkB,EAAE,KAAK;AAC5B,MACG,aAAa,qBAAqB,QACnC,4BAAS,aAAa,iBAAiB,IACvC,SAEA,SAAQ,KACN,uFACD;AAGH,KAAI,YAAY,OACd,SAAQ,KACN,sKACD;CAGH,MAAM,cAAc,yBAAyB;CAE7C,MAAM,CAAC,cAAc,mBAAmB,SAAiB,GAAG;CAE5D,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7C,oBACE,WAAY,oBAAoB,EAAE,GAAK,oBAAoB;EAC7D,OAAO;EACP;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1C,KAAK,OAAO;;GAEpB,WAAW;AAGT,IAFa,YAAY,kBAAkB,EAErC,KAAK,OAAO;;GAEpB,YAAY;AAGV,IAFc,YAAY,mBAAmB,EAEtC,KAAK,OAAO;;GAEtB,CAAC;IAEJ,CAAC,aAAa,MAAM,CACrB;CAED,MAAMC,eAA2B,aAC9B,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EAC3B,6CAA0B,KAAK;EAC/B,GAAG;EACH,GAAG;EACH,KAAK,UAAU,KAAK,KAAK,IAAI;EAC9B,GACD,CAAC,MAAM,KAAK,CACb;CAED,MAAMC,iBAAuC,aAC1C,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EAC3B,IAAI;EACJ,MAAM;EACN,iBAAiB;EACjB,6CAA2B,CAAC,YAAY,CAAC,UAAU,QAAS,SAAS;EACrE,iBAAiB;EACjB,GAAG;EACH,KAAK,UAAU,UAAU,IAAI;EAC7B;EACA,uCAAoB,MAAM,SAAS,QAAQ;EAC3C,uCAAoB,MAAM,SAAS,QAAQ;EAC3C,yCAAsB,MAAM,WAAW,UAAU;EAClD,GACD;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;CAED,MAAMC,gBAA4B,aAC/B,EAAE,mBAAmB,gBAAgB,GAAG,UAAU,EAAE,MAAM;EACzD,IAAI;EACJ,yCAAsB,gBAAgB,OAAO;EAC7C,MAAM;EACN,GAAG;EACJ,GACD,CAAC,QAAQ,QAAQ,CAClB;AAaD,QAAO;EACL;EACA;EACA;EACA,cAfsC,aACrC,WAAW;GACV,6CAA2B,CAAC,YAAY,CAAC,UAAU,QAAS,SAAS;GACrE,iBAAiB;GACjB,eAAe;GACf,MAAM;GACN,GAAG;GACJ,GACD;GAAC;GAAU;GAAQ;GAAM;GAAS,CACnC;EAOC;EACA;EACD"}
1
+ {"version":3,"file":"use-accordion.js","names":["createContext","getRootProps: PropGetter","open","getItemProps: PropGetter","getButtonProps: PropGetter<\"button\">","getPanelProps: PropGetter"],"sources":["../../../../src/components/accordion/use-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n handlerAll,\n isArray,\n mergeRefs,\n runKeyAction,\n} from \"../../utils\"\n\nconst {\n DescendantsContext: AccordionDescendantsContext,\n useDescendant: useAccordionDescendant,\n useDescendants: useAccordionDescendants,\n} = createDescendants<HTMLButtonElement>()\n\nexport {\n AccordionDescendantsContext,\n useAccordionDescendant,\n useAccordionDescendants,\n}\n\ninterface AccordionContext extends Omit<\n UseAccordionReturn,\n \"descendants\" | \"getRootProps\"\n> {}\n\nconst [AccordionContext, useAccordionContext] = createContext<AccordionContext>(\n { name: \"AccordionContext\" },\n)\n\nexport { AccordionContext, useAccordionContext }\n\ninterface AccordionItemContext extends Omit<\n UseAccordionItemReturn,\n \"getItemProps\"\n> {}\n\nconst [AccordionItemContext, useAccordionItemContext] =\n createContext<AccordionItemContext>({\n name: \"AccordionItemContext\",\n })\n\nexport { AccordionItemContext, useAccordionItemContext }\n\nexport interface UseAccordionProps extends Omit<HTMLProps, \"onChange\"> {\n /**\n * The initial index(es) of the accordion item to expand.\n */\n defaultIndex?: number | number[]\n /**\n * The index(es) of the accordion item to expand.\n */\n index?: number | number[]\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * If `true`, any expanded accordion item can be collapsed again.\n *\n * @default false\n */\n toggle?: boolean\n /**\n * The callback invoked when accordion items are expanded or collapsed.\n */\n onChange?: (index: number | number[]) => void\n}\n\nexport const useAccordion = ({\n defaultIndex: defaultIndexProp,\n index: indexProp,\n multiple,\n toggle,\n onChange,\n ...rest\n}: UseAccordionProps = {}) => {\n if (\n (indexProp || defaultIndexProp) != null &&\n !isArray(indexProp || defaultIndexProp) &&\n multiple\n ) {\n console.warn(\n `Accordion: If 'multiple' is passed, then 'index' or 'defaultIndex' must be an array.`,\n )\n }\n\n if (multiple && toggle) {\n console.warn(\n `Accordion: If 'multiple' is passed, 'toggle' will be ignored. Either remove 'toggle' or 'multiple' depending on whether you want multiple accordions visible or not`,\n )\n }\n\n const descendants = useAccordionDescendants()\n\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n\n const [index, setIndex] = useControllableState({\n defaultValue: () =>\n multiple ? (defaultIndexProp ?? []) : (defaultIndexProp ?? -1),\n value: indexProp,\n onChange,\n })\n\n const getRootProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n }),\n [rest],\n )\n\n useEffect(() => {\n return () => setFocusedIndex(-1)\n }, [])\n\n return {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n }\n}\n\nexport type UseAccordionReturn = ReturnType<typeof useAccordion>\n\nexport interface UseAccordionItemProps extends HTMLProps {\n /**\n * The index of the accordion item.\n */\n index: number\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useAccordionItem = ({\n disabled,\n index,\n ...rest\n}: UseAccordionItemProps) => {\n const itemId = useId()\n const panelId = useId()\n const {\n index: selectedIndex,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n } = useAccordionContext()\n const { descendants, register } = useAccordionDescendant({ disabled })\n const open =\n index !== -1\n ? isArray(selectedIndex)\n ? selectedIndex.includes(index)\n : selectedIndex === index\n : false\n\n if (open && disabled)\n console.warn(`Accordion: Cannot open a disabled accordion item`)\n\n const onChange = useCallback(\n (open: boolean) => {\n if (index === -1) return\n\n if (multiple && isArray(selectedIndex)) {\n setIndex(\n open\n ? selectedIndex.concat(index)\n : selectedIndex.filter((i) => i !== index),\n )\n } else if (open) {\n setIndex(index)\n } else if (toggle) {\n setIndex(-1)\n }\n },\n [multiple, toggle, index, selectedIndex, setIndex],\n )\n\n const onFocus = useCallback(() => {\n setFocusedIndex(index)\n }, [setFocusedIndex, index])\n\n const onClick = useCallback(() => {\n onChange(!open)\n setFocusedIndex(index)\n }, [index, setFocusedIndex, open, onChange])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLButtonElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => {\n const next = descendants.enabledNextValue(index)\n\n next?.node.focus()\n },\n ArrowUp: () => {\n const prev = descendants.enabledPrevValue(index)\n\n prev?.node.focus()\n },\n End: () => {\n const last = descendants.enabledLastValue()\n\n last?.node.focus()\n },\n Home: () => {\n const first = descendants.enabledFirstValue()\n\n first?.node.focus()\n },\n })\n },\n [descendants, index],\n )\n\n const getItemProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n \"data-expanded\": dataAttr(open),\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n }),\n [open, rest],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n id: itemId,\n type: \"button\",\n \"aria-controls\": panelId,\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n ...props,\n ref: mergeRefs(register, ref),\n disabled,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n itemId,\n open,\n panelId,\n multiple,\n toggle,\n disabled,\n register,\n onClick,\n onFocus,\n onKeyDown,\n ],\n )\n\n const getPanelProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) => ({\n id: panelId,\n \"aria-labelledby\": cx(ariaLabelledby, itemId),\n role: \"region\",\n ...props,\n }),\n [itemId, panelId],\n )\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [multiple, toggle, open, disabled],\n )\n\n return {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseAccordionItemReturn = ReturnType<typeof useAccordionItem>\n"],"mappings":";;;;;;;;;;;AAkBA,MAAM,EACJ,oBAAoB,6BACpB,eAAe,wBACf,gBAAgB,4BACd,mBAAsC;AAa1C,MAAM,CAAC,kBAAkB,uBAAuBA,gBAC9C,EAAE,MAAM,oBAAoB,CAC7B;AASD,MAAM,CAAC,sBAAsB,2BAC3BA,gBAAoC,EAClC,MAAM,wBACP,CAAC;AA+BJ,MAAa,gBAAgB,EAC3B,cAAc,kBACd,OAAO,WACP,UACA,QACA,UACA,GAAG,SACkB,EAAE,KAAK;AAC5B,MACG,aAAa,qBAAqB,QACnC,4BAAS,aAAa,iBAAiB,IACvC,SAEA,SAAQ,KACN,uFACD;AAGH,KAAI,YAAY,OACd,SAAQ,KACN,sKACD;CAGH,MAAM,cAAc,yBAAyB;CAE7C,MAAM,CAAC,cAAc,mBAAmB,SAAiB,GAAG;CAE5D,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7C,oBACE,WAAY,oBAAoB,EAAE,GAAK,oBAAoB;EAC7D,OAAO;EACP;EACD,CAAC;CAEF,MAAMC,eAA2B,aAC9B,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EAC3B,GAAG;EACH,GAAG;EACH,KAAK,UAAU,KAAK,KAAK,IAAI;EAC9B,GACD,CAAC,KAAK,CACP;AAED,iBAAgB;AACd,eAAa,gBAAgB,GAAG;IAC/B,EAAE,CAAC;AAEN,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;AAkBH,MAAa,oBAAoB,EAC/B,UACA,OACA,GAAG,WACwB;CAC3B,MAAM,SAAS,OAAO;CACtB,MAAM,UAAU,OAAO;CACv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AC1C,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EAC3B,IAAI;EACJ,MAAM;EACN,iBAAiB;EACjB,6CAA2B,CAAC,YAAY,CAAC,UAAU,QAAS,SAAS;EACrE,iBAAiB;EACjB,GAAG;EACH,KAAK,UAAU,UAAU,IAAI;EAC7B;EACA,uCAAoB,MAAM,SAAS,QAAQ;EAC3C,uCAAoB,MAAM,SAAS,QAAQ;EAC3C,yCAAsB,MAAM,WAAW,UAAU;EAClD,GACD;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;CAED,MAAMC,gBAA4B,aAC/B,EAAE,mBAAmB,gBAAgB,GAAG,UAAU,EAAE,MAAM;EACzD,IAAI;EACJ,yCAAsB,gBAAgB,OAAO;EAC7C,MAAM;EACN,GAAG;EACJ,GACD,CAAC,QAAQ,QAAQ,CAClB;AAaD,QAAO;EACL;EACA;EACA;EACA,cAfsC,aACrC,WAAW;GACV,6CAA2B,CAAC,YAAY,CAAC,UAAU,QAAS,SAAS;GACrE,iBAAiB;GACjB,eAAe;GACf,MAAM;GACN,GAAG;GACJ,GACD;GAAC;GAAU;GAAQ;GAAM;GAAS,CACnC;EAOC;EACA;EACD"}
@@ -24,7 +24,7 @@ const useNativeAccordionItem = ({ disabled, ...rest }) => {
24
24
  const getItemProps = ({ ref, ...props } = {}) => ({
25
25
  ref: mergeRefs(ref, rest.ref),
26
26
  name: props.name ?? rest.name ?? name,
27
- role: "group",
27
+ "data-group": "",
28
28
  ...rest,
29
29
  ...props
30
30
  });
@@ -1 +1 @@
1
- {"version":3,"file":"use-native-accordion.js","names":["createContext","getRootProps: PropGetter","getItemProps: PropGetter<\"details\">","getButtonProps: PropGetter<\"summary\">","getPanelProps: PropGetter"],"sources":["../../../../src/components/native-accordion/use-native-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useId } from \"react\"\nimport {\n ariaAttr,\n createContext,\n dataAttr,\n handlerAll,\n mergeRefs,\n} from \"../../utils\"\n\ninterface NativeAccordionContext extends Pick<\n UseNativeAccordionReturn,\n \"name\"\n> {}\n\nconst [NativeAccordionContext, useNativeAccordionContext] =\n createContext<NativeAccordionContext>({\n name: \"NativeAccordionContext\",\n })\n\nexport { NativeAccordionContext, useNativeAccordionContext }\n\nexport interface UseNativeAccordionProps extends HTMLProps {\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * The HTML `name` attribute used for forms.\n */\n name?: string\n}\n\nexport const useNativeAccordion = ({\n name,\n multiple = false,\n ...rest\n}: UseNativeAccordionProps = {}) => {\n const generatedName = useId()\n\n const getRootProps: PropGetter = ({ ref, ...props } = {}) => ({\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n })\n\n return {\n name: multiple ? undefined : (name ?? generatedName),\n getRootProps,\n }\n}\n\nexport type UseNativeAccordionReturn = ReturnType<typeof useNativeAccordion>\n\nexport interface UseNativeAccordionItemProps extends HTMLProps<\"details\"> {\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useNativeAccordionItem = ({\n disabled,\n ...rest\n}: UseNativeAccordionItemProps) => {\n const { name } = useNativeAccordionContext()\n\n const getItemProps: PropGetter<\"details\"> = ({ ref, ...props } = {}) => ({\n ref: mergeRefs(ref, rest.ref),\n name: props.name ?? rest.name ?? name,\n role: \"group\",\n ...rest,\n ...props,\n })\n\n const getButtonProps: PropGetter<\"summary\"> = useCallback(\n (props = {}) => ({\n \"aria-disabled\": ariaAttr(disabled),\n \"data-disabled\": dataAttr(disabled),\n ...props,\n onClick: handlerAll(props.onClick, (ev) => {\n if (!disabled) return\n\n ev.preventDefault()\n }),\n }),\n [disabled],\n )\n\n const getPanelProps: PropGetter = useCallback((props = {}) => props, [])\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props = {}) => ({\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [disabled],\n )\n\n return {\n disabled,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseNativeAccordionItemReturn = ReturnType<\n typeof useNativeAccordionItem\n>\n"],"mappings":";;;;;;;;AAiBA,MAAM,CAAC,wBAAwB,6BAC7BA,gBAAsC,EACpC,MAAM,0BACP,CAAC;AAiBJ,MAAa,sBAAsB,EACjC,MACA,WAAW,OACX,GAAG,SACwB,EAAE,KAAK;CAClC,MAAM,gBAAgB,OAAO;CAE7B,MAAMC,gBAA4B,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EAC5D,GAAG;EACH,GAAG;EACH,KAAK,UAAU,KAAK,KAAK,IAAI;EAC9B;AAED,QAAO;EACL,MAAM,WAAW,SAAa,QAAQ;EACtC;EACD;;AAcH,MAAa,0BAA0B,EACrC,UACA,GAAG,WAC8B;CACjC,MAAM,EAAE,SAAS,2BAA2B;CAE5C,MAAMC,gBAAuC,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EACvE,KAAK,UAAU,KAAK,KAAK,IAAI;EAC7B,MAAM,MAAM,QAAQ,KAAK,QAAQ;EACjC,MAAM;EACN,GAAG;EACH,GAAG;EACJ;CAED,MAAMC,iBAAwC,aAC3C,QAAQ,EAAE,MAAM;EACf,6CAA0B,SAAS;EACnC,6CAA0B,SAAS;EACnC,GAAG;EACH,uCAAoB,MAAM,UAAU,OAAO;AACzC,OAAI,CAAC,SAAU;AAEf,MAAG,gBAAgB;IACnB;EACH,GACD,CAAC,SAAS,CACX;CAED,MAAMC,gBAA4B,aAAa,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;AAYxE,QAAO;EACL;EACA;EACA,cAbsC,aACrC,QAAQ,EAAE,MAAM;GACf,6CAA0B,SAAS;GACnC,eAAe;GACf,MAAM;GACN,GAAG;GACJ,GACD,CAAC,SAAS,CACX;EAMC;EACA;EACD"}
1
+ {"version":3,"file":"use-native-accordion.js","names":["createContext","getRootProps: PropGetter","getItemProps: PropGetter<\"details\">","getButtonProps: PropGetter<\"summary\">","getPanelProps: PropGetter"],"sources":["../../../../src/components/native-accordion/use-native-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useId } from \"react\"\nimport {\n ariaAttr,\n createContext,\n dataAttr,\n handlerAll,\n mergeRefs,\n} from \"../../utils\"\n\ninterface NativeAccordionContext extends Pick<\n UseNativeAccordionReturn,\n \"name\"\n> {}\n\nconst [NativeAccordionContext, useNativeAccordionContext] =\n createContext<NativeAccordionContext>({\n name: \"NativeAccordionContext\",\n })\n\nexport { NativeAccordionContext, useNativeAccordionContext }\n\nexport interface UseNativeAccordionProps extends HTMLProps {\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * The HTML `name` attribute used for forms.\n */\n name?: string\n}\n\nexport const useNativeAccordion = ({\n name,\n multiple = false,\n ...rest\n}: UseNativeAccordionProps = {}) => {\n const generatedName = useId()\n\n const getRootProps: PropGetter = ({ ref, ...props } = {}) => ({\n ...props,\n ...rest,\n ref: mergeRefs(ref, rest.ref),\n })\n\n return {\n name: multiple ? undefined : (name ?? generatedName),\n getRootProps,\n }\n}\n\nexport type UseNativeAccordionReturn = ReturnType<typeof useNativeAccordion>\n\nexport interface UseNativeAccordionItemProps extends HTMLProps<\"details\"> {\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useNativeAccordionItem = ({\n disabled,\n ...rest\n}: UseNativeAccordionItemProps) => {\n const { name } = useNativeAccordionContext()\n\n const getItemProps: PropGetter<\"details\"> = ({ ref, ...props } = {}) => ({\n ref: mergeRefs(ref, rest.ref),\n name: props.name ?? rest.name ?? name,\n \"data-group\": \"\",\n ...rest,\n ...props,\n })\n\n const getButtonProps: PropGetter<\"summary\"> = useCallback(\n (props = {}) => ({\n \"aria-disabled\": ariaAttr(disabled),\n \"data-disabled\": dataAttr(disabled),\n ...props,\n onClick: handlerAll(props.onClick, (ev) => {\n if (!disabled) return\n\n ev.preventDefault()\n }),\n }),\n [disabled],\n )\n\n const getPanelProps: PropGetter = useCallback((props = {}) => props, [])\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props = {}) => ({\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [disabled],\n )\n\n return {\n disabled,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseNativeAccordionItemReturn = ReturnType<\n typeof useNativeAccordionItem\n>\n"],"mappings":";;;;;;;;AAiBA,MAAM,CAAC,wBAAwB,6BAC7BA,gBAAsC,EACpC,MAAM,0BACP,CAAC;AAiBJ,MAAa,sBAAsB,EACjC,MACA,WAAW,OACX,GAAG,SACwB,EAAE,KAAK;CAClC,MAAM,gBAAgB,OAAO;CAE7B,MAAMC,gBAA4B,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EAC5D,GAAG;EACH,GAAG;EACH,KAAK,UAAU,KAAK,KAAK,IAAI;EAC9B;AAED,QAAO;EACL,MAAM,WAAW,SAAa,QAAQ;EACtC;EACD;;AAcH,MAAa,0BAA0B,EACrC,UACA,GAAG,WAC8B;CACjC,MAAM,EAAE,SAAS,2BAA2B;CAE5C,MAAMC,gBAAuC,EAAE,KAAK,GAAG,UAAU,EAAE,MAAM;EACvE,KAAK,UAAU,KAAK,KAAK,IAAI;EAC7B,MAAM,MAAM,QAAQ,KAAK,QAAQ;EACjC,cAAc;EACd,GAAG;EACH,GAAG;EACJ;CAED,MAAMC,iBAAwC,aAC3C,QAAQ,EAAE,MAAM;EACf,6CAA0B,SAAS;EACnC,6CAA0B,SAAS;EACnC,GAAG;EACH,uCAAoB,MAAM,UAAU,OAAO;AACzC,OAAI,CAAC,SAAU;AAEf,MAAG,gBAAgB;IACnB;EACH,GACD,CAAC,SAAS,CACX;CAED,MAAMC,gBAA4B,aAAa,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;AAYxE,QAAO;EACL;EACA;EACA,cAbsC,aACrC,QAAQ,EAAE,MAAM;GACf,6CAA0B,SAAS;GACnC,eAAe;GACf,MAAM;GACN,GAAG;GACJ,GACD,CAAC,SAAS,CACX;EAMC;EACA;EACD"}
@@ -9,7 +9,7 @@ import "../collapse/index.js";
9
9
  import "../../index.js";
10
10
  import { AccordionStyle } from "./accordion.style.js";
11
11
  import { UseAccordionItemProps, UseAccordionProps } from "./use-accordion.js";
12
- import * as react225 from "react";
12
+ import * as react180 from "react";
13
13
 
14
14
  //#region src/components/accordion/accordion.d.ts
15
15
  interface AccordionCallBackProps {
@@ -33,7 +33,7 @@ interface AccordionRootProps extends Omit<HTMLStyledProps, "onChange">, ThemePro
33
33
  */
34
34
  items?: AccordionItem[];
35
35
  }
36
- declare const AccordionPropsContext: react225.Context<Partial<AccordionRootProps> | undefined>, useAccordionPropsContext: () => Partial<AccordionRootProps> | undefined;
36
+ declare const AccordionPropsContext: react180.Context<Partial<AccordionRootProps> | undefined>, useAccordionPropsContext: () => Partial<AccordionRootProps> | undefined;
37
37
  /**
38
38
  * `Accordion` is a component for a list that displays information in an expandable or collapsible manner.
39
39
  *
@@ -2,10 +2,10 @@ import { HTMLProps, PropGetter } from "../../core/components/index.types.js";
2
2
  import "../../core/index.js";
3
3
  import { Descendant } from "../../hooks/use-descendants/index.js";
4
4
  import "../../index.js";
5
- import * as react213 from "react";
5
+ import * as react168 from "react";
6
6
 
7
7
  //#region src/components/accordion/use-accordion.d.ts
8
- declare const AccordionDescendantsContext: react213.Context<{
8
+ declare const AccordionDescendantsContext: react168.Context<{
9
9
  active: (target?: HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null | undefined, options?: FocusOptions) => void;
10
10
  count: () => number;
11
11
  destroy: () => void;
@@ -24,7 +24,7 @@ declare const AccordionDescendantsContext: react213.Context<{
24
24
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean) => Descendant<HTMLButtonElement, {}> | undefined;
25
25
  register: (props?: {
26
26
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
27
- } | undefined) => react213.RefCallback<HTMLButtonElement>;
27
+ } | undefined) => react168.RefCallback<HTMLButtonElement>;
28
28
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
29
29
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
30
30
  values: () => Descendant<HTMLButtonElement, {}>[];
@@ -50,12 +50,12 @@ declare const AccordionDescendantsContext: react213.Context<{
50
50
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean) => Descendant<HTMLButtonElement, {}> | undefined;
51
51
  register: (props?: {
52
52
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
53
- } | undefined) => react213.RefCallback<HTMLButtonElement>;
53
+ } | undefined) => react168.RefCallback<HTMLButtonElement>;
54
54
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
55
55
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
56
56
  values: () => Descendant<HTMLButtonElement, {}>[];
57
57
  };
58
- register: react213.RefCallback<HTMLButtonElement>;
58
+ register: react168.RefCallback<HTMLButtonElement>;
59
59
  }, useAccordionDescendants: () => {
60
60
  active: (target?: HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null | undefined, options?: FocusOptions) => void;
61
61
  count: () => number;
@@ -75,15 +75,15 @@ declare const AccordionDescendantsContext: react213.Context<{
75
75
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean) => Descendant<HTMLButtonElement, {}> | undefined;
76
76
  register: (props?: {
77
77
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
78
- } | undefined) => react213.RefCallback<HTMLButtonElement>;
78
+ } | undefined) => react168.RefCallback<HTMLButtonElement>;
79
79
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
80
80
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
81
81
  values: () => Descendant<HTMLButtonElement, {}>[];
82
82
  };
83
83
  interface AccordionContext extends Omit<UseAccordionReturn, "descendants" | "getRootProps"> {}
84
- declare const AccordionContext: react213.Context<AccordionContext>, useAccordionContext: () => AccordionContext;
84
+ declare const AccordionContext: react168.Context<AccordionContext>, useAccordionContext: () => AccordionContext;
85
85
  interface AccordionItemContext extends Omit<UseAccordionItemReturn, "getItemProps"> {}
86
- declare const AccordionItemContext: react213.Context<AccordionItemContext>, useAccordionItemContext: () => AccordionItemContext;
86
+ declare const AccordionItemContext: react168.Context<AccordionItemContext>, useAccordionItemContext: () => AccordionItemContext;
87
87
  interface UseAccordionProps extends Omit<HTMLProps, "onChange"> {
88
88
  /**
89
89
  * The initial index(es) of the accordion item to expand.
@@ -137,7 +137,7 @@ declare const useAccordion: ({
137
137
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean) => Descendant<HTMLButtonElement, {}> | undefined;
138
138
  register: (props?: {
139
139
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
140
- } | undefined) => react213.RefCallback<HTMLButtonElement>;
140
+ } | undefined) => react168.RefCallback<HTMLButtonElement>;
141
141
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
142
142
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
143
143
  values: () => Descendant<HTMLButtonElement, {}>[];
@@ -145,8 +145,8 @@ declare const useAccordion: ({
145
145
  focusedIndex: number;
146
146
  index: number | number[];
147
147
  multiple: boolean | undefined;
148
- setFocusedIndex: react213.Dispatch<react213.SetStateAction<number>>;
149
- setIndex: react213.Dispatch<react213.SetStateAction<number | number[]>>;
148
+ setFocusedIndex: react168.Dispatch<react168.SetStateAction<number>>;
149
+ setIndex: react168.Dispatch<react168.SetStateAction<number | number[]>>;
150
150
  toggle: boolean | undefined;
151
151
  getRootProps: PropGetter<"div", undefined, undefined>;
152
152
  };
@@ -5,7 +5,7 @@ import { AiryStyle } from "./airy.style.js";
5
5
  import { HTMLMotionProps } from "../motion/index.types.js";
6
6
  import "../motion/index.js";
7
7
  import "../../index.js";
8
- import * as react212 from "react";
8
+ import * as react181 from "react";
9
9
  import { ReactNode } from "react";
10
10
 
11
11
  //#region src/components/airy/airy.d.ts
@@ -57,7 +57,7 @@ interface AiryProps extends Omit<HTMLMotionProps<"button">, "onChange">, ThemePr
57
57
  */
58
58
  onChange?: (value: KeyframeIdent) => void;
59
59
  }
60
- declare const AiryPropsContext: react212.Context<Partial<AiryProps> | undefined>, useAiryPropsContext: () => Partial<AiryProps> | undefined;
60
+ declare const AiryPropsContext: react181.Context<Partial<AiryProps> | undefined>, useAiryPropsContext: () => Partial<AiryProps> | undefined;
61
61
  /**
62
62
  * `Airy` is a component that creates an airy animation, switching between two elements when one is clicked.
63
63
  *
@@ -9,7 +9,7 @@ import "../loading/index.js";
9
9
  import { StatusScheme } from "../status/status.js";
10
10
  import "../status/index.js";
11
11
  import "../../index.js";
12
- import * as react194 from "react";
12
+ import * as react167 from "react";
13
13
 
14
14
  //#region src/components/alert/alert.d.ts
15
15
  interface AlertRootProps extends HTMLStyledProps, ThemeProps<AlertStyle> {
@@ -20,7 +20,7 @@ interface AlertRootProps extends HTMLStyledProps, ThemeProps<AlertStyle> {
20
20
  */
21
21
  status?: StatusScheme;
22
22
  }
23
- declare const AlertPropsContext: react194.Context<Partial<AlertRootProps> | undefined>, useAlertPropsContext: () => Partial<AlertRootProps> | undefined;
23
+ declare const AlertPropsContext: react167.Context<Partial<AlertRootProps> | undefined>, useAlertPropsContext: () => Partial<AlertRootProps> | undefined;
24
24
  /**
25
25
  * `Alert` is a component that conveys information to the user.
26
26
  *
@@ -5,7 +5,7 @@ import { AlphaSliderStyle } from "./alpha-slider.style.js";
5
5
  import { HueSliderOverlayProps, HueSliderRootProps, HueSliderThumbProps, HueSliderTrackProps } from "../hue-slider/hue-slider.js";
6
6
  import "../hue-slider/index.js";
7
7
  import "../../index.js";
8
- import * as react193 from "react";
8
+ import * as react1038 from "react";
9
9
 
10
10
  //#region src/components/alpha-slider/alpha-slider.d.ts
11
11
  interface AlphaSliderRootProps extends WithoutThemeProps<Omit<HueSliderRootProps, "color" | "max" | "step" | "thumbProps" | "trackProps">, AlphaSliderStyle> {
@@ -38,7 +38,7 @@ interface AlphaSliderRootProps extends WithoutThemeProps<Omit<HueSliderRootProps
38
38
  */
39
39
  trackProps?: AlphaSliderTrackProps;
40
40
  }
41
- declare const AlphaSliderPropsContext: react193.Context<Partial<AlphaSliderRootProps> | undefined>, useAlphaSliderPropsContext: () => Partial<AlphaSliderRootProps> | undefined;
41
+ declare const AlphaSliderPropsContext: react1038.Context<Partial<AlphaSliderRootProps> | undefined>, useAlphaSliderPropsContext: () => Partial<AlphaSliderRootProps> | undefined;
42
42
  /**
43
43
  * `AlphaSlider` is a component used to allow the user to select color transparency.
44
44
  *
@@ -2,7 +2,7 @@ import { StyleValue } from "../../core/css/index.types.js";
2
2
  import { Component, HTMLStyledProps } from "../../core/components/index.types.js";
3
3
  import "../../core/index.js";
4
4
  import "../../index.js";
5
- import * as react192 from "react";
5
+ import * as react165 from "react";
6
6
 
7
7
  //#region src/components/aspect-ratio/aspect-ratio.d.ts
8
8
  interface AspectRatioProps extends HTMLStyledProps {
@@ -13,7 +13,7 @@ interface AspectRatioProps extends HTMLStyledProps {
13
13
  */
14
14
  ratio?: StyleValue<number>;
15
15
  }
16
- declare const AspectRatioPropsContext: react192.Context<Partial<AspectRatioProps> | undefined>, useAspectRatioPropsContext: () => Partial<AspectRatioProps> | undefined;
16
+ declare const AspectRatioPropsContext: react165.Context<Partial<AspectRatioProps> | undefined>, useAspectRatioPropsContext: () => Partial<AspectRatioProps> | undefined;
17
17
  /**
18
18
  * `AspectRatio` is a component for embedding things like videos and maps while maintaining the aspect ratio.
19
19
  *
@@ -11,7 +11,7 @@ import { InputGroupRootProps } from "../input/input-group.js";
11
11
  import "../input/index.js";
12
12
  import { UseAutocompleteOptionProps, UseAutocompleteProps } from "./use-autocomplete.js";
13
13
  import "../../index.js";
14
- import * as react190 from "react";
14
+ import * as react159 from "react";
15
15
  import { ReactElement, ReactNode } from "react";
16
16
 
17
17
  //#region src/components/autocomplete/autocomplete.d.ts
@@ -67,7 +67,7 @@ interface AutocompleteRootProps<Multiple extends boolean = false> extends Omit<H
67
67
  */
68
68
  rootProps?: InputGroupRootProps;
69
69
  }
70
- declare const AutocompletePropsContext: react190.Context<Partial<AutocompleteRootProps<false>> | undefined>, useAutocompletePropsContext: () => Partial<AutocompleteRootProps<false>> | undefined;
70
+ declare const AutocompletePropsContext: react159.Context<Partial<AutocompleteRootProps<false>> | undefined>, useAutocompletePropsContext: () => Partial<AutocompleteRootProps<false>> | undefined;
71
71
  /**
72
72
  * `Autocomplete` is a component used to display suggestions in response to user text input.
73
73
  *
@@ -3,7 +3,7 @@ import { CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
3
3
  import "../../index.js";
4
4
 
5
5
  //#region src/components/autocomplete/autocomplete.style.d.ts
6
- declare const autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "empty" | "valueText", CSSPropObject<CSSSlotObject<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "empty" | "valueText">>, {
6
+ declare const autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "indicator" | "root" | "field" | "empty" | "valueText", CSSPropObject<CSSSlotObject<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "indicator" | "root" | "field" | "empty" | "valueText">>, {
7
7
  xs: {
8
8
  empty: {
9
9
  gap: "1.5";
@@ -7,7 +7,7 @@ import { UsePopoverProps } from "../popover/use-popover.js";
7
7
  import "../popover/index.js";
8
8
  import { ComboboxDescendant, ComboboxDescendantProps, ComboboxItem, ComboboxItemWithValue, UseComboboxItemProps, UseComboboxProps } from "../../hooks/use-combobox/index.js";
9
9
  import "../../index.js";
10
- import * as react184 from "react";
10
+ import * as react153 from "react";
11
11
  import { ChangeEvent, ReactNode } from "react";
12
12
 
13
13
  //#region src/components/autocomplete/use-autocomplete.d.ts
@@ -29,7 +29,7 @@ interface AutocompleteMatcher {
29
29
  (input: string, target?: string): boolean;
30
30
  }
31
31
  interface AutocompleteContext extends Pick<UseAutocompleteReturn, "max" | "value"> {}
32
- declare const AutocompleteContext: react184.Context<AutocompleteContext>, useAutocompleteContext: () => AutocompleteContext;
32
+ declare const AutocompleteContext: react153.Context<AutocompleteContext>, useAutocompleteContext: () => AutocompleteContext;
33
33
  interface UseAutocompleteProps<Multiple extends boolean = false> extends Omit<HTMLProps, "defaultValue" | "onChange" | "ref" | "value">, Omit<UseComboboxProps, "defaultValue" | "initialFocusValue" | "onChange" | "ref" | "value">, HTMLRefAttributes<"input">, FieldProps {
34
34
  /**
35
35
  * If `true`, the autocomplete will allow custom value.
@@ -157,7 +157,7 @@ declare const useAutocomplete: <Multiple extends boolean = false>(props?: UseAut
157
157
  lastValue: () => Descendant<HTMLDivElement, ComboboxDescendantProps> | undefined;
158
158
  nextValue: (indexOrNode: number | HTMLDivElement | Descendant<HTMLDivElement, ComboboxDescendantProps> | null, loop?: boolean) => Descendant<HTMLDivElement, ComboboxDescendantProps> | undefined;
159
159
  prevValue: (indexOrNode: number | HTMLDivElement | Descendant<HTMLDivElement, ComboboxDescendantProps> | null, loop?: boolean) => Descendant<HTMLDivElement, ComboboxDescendantProps> | undefined;
160
- register: (props?: DescendantProps<HTMLDivElement, ComboboxDescendantProps> | undefined) => react184.RefCallback<HTMLDivElement>;
160
+ register: (props?: DescendantProps<HTMLDivElement, ComboboxDescendantProps> | undefined) => react153.RefCallback<HTMLDivElement>;
161
161
  unregister: (node?: HTMLDivElement | null | undefined) => void;
162
162
  value: (indexOrNode: number | HTMLDivElement | null) => Descendant<HTMLDivElement, ComboboxDescendantProps> | undefined;
163
163
  values: () => Descendant<HTMLDivElement, ComboboxDescendantProps>[];
@@ -167,8 +167,8 @@ declare const useAutocomplete: <Multiple extends boolean = false>(props?: UseAut
167
167
  items: ComboboxItem[];
168
168
  max: number | undefined;
169
169
  open: boolean;
170
- setInputValue: react184.Dispatch<react184.SetStateAction<string>>;
171
- setValue: react184.Dispatch<react184.SetStateAction<Multiple extends true ? string[] : string>>;
170
+ setInputValue: react153.Dispatch<react153.SetStateAction<string>>;
171
+ setValue: react153.Dispatch<react153.SetStateAction<Multiple extends true ? string[] : string>>;
172
172
  value: Multiple extends true ? string[] : string;
173
173
  valueMap: {
174
174
  [key: string]: ComboboxItemWithValue;