tfy-web-components 0.0.34 → 0.0.35

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 (225) hide show
  1. package/README.md +49 -58
  2. package/dist/Button-C77b7jpW.js +284 -0
  3. package/dist/Button-C77b7jpW.js.map +1 -0
  4. package/dist/CompositeItem-BGwD51jI.js +33 -0
  5. package/dist/CompositeItem-BGwD51jI.js.map +1 -0
  6. package/dist/CompositeList-D4xmSZ5V.js +291 -0
  7. package/dist/CompositeList-D4xmSZ5V.js.map +1 -0
  8. package/dist/CompositeRoot-BxrPc7F6.js +351 -0
  9. package/dist/CompositeRoot-BxrPc7F6.js.map +1 -0
  10. package/dist/DirectionContext-Pb9yafF5.js +11 -0
  11. package/dist/DirectionContext-Pb9yafF5.js.map +1 -0
  12. package/dist/FieldItemContext-DRVgx-D1.js +13 -0
  13. package/dist/FieldItemContext-DRVgx-D1.js.map +1 -0
  14. package/dist/{Input-BvwIpntS.js → Input-Dhmo6L2n.js} +100 -78
  15. package/dist/Input-Dhmo6L2n.js.map +1 -0
  16. package/dist/Modal-C4MUy9GD.js +696 -0
  17. package/dist/Modal-C4MUy9GD.js.map +1 -0
  18. package/dist/{MonacoEditorCore-xfpJ6z-E.js → MonacoEditorCore-n-df5f7I.js} +2 -2
  19. package/dist/{MonacoEditorCore-xfpJ6z-E.js.map → MonacoEditorCore-n-df5f7I.js.map} +1 -1
  20. package/dist/Popover-eC_vX5By.js +1074 -0
  21. package/dist/Popover-eC_vX5By.js.map +1 -0
  22. package/dist/ToolbarRootContext-B_HxjkNI.js +11 -0
  23. package/dist/ToolbarRootContext-B_HxjkNI.js.map +1 -0
  24. package/dist/Tooltip-BuGLP-PU.js +4096 -0
  25. package/dist/Tooltip-BuGLP-PU.js.map +1 -0
  26. package/dist/classNames-B1XpQHle.js +44 -0
  27. package/dist/classNames-B1XpQHle.js.map +1 -0
  28. package/dist/components/atoms/Accordion.d.ts +19 -37
  29. package/dist/components/atoms/Accordion.es.js +847 -78
  30. package/dist/components/atoms/Accordion.es.js.map +1 -1
  31. package/dist/components/atoms/AudioPlayer.es.js +9 -9
  32. package/dist/components/atoms/AudioPlayer.es.js.map +1 -1
  33. package/dist/components/atoms/Avatar.d.ts +42 -9
  34. package/dist/components/atoms/Avatar.es.js +491 -36
  35. package/dist/components/atoms/Avatar.es.js.map +1 -1
  36. package/dist/components/atoms/Badge.d.ts +40 -35
  37. package/dist/components/atoms/Badge.es.js +163 -53
  38. package/dist/components/atoms/Badge.es.js.map +1 -1
  39. package/dist/components/atoms/Button.d.ts +37 -16
  40. package/dist/components/atoms/Button.es.js +16 -221
  41. package/dist/components/atoms/Button.es.js.map +1 -1
  42. package/dist/components/atoms/ButtonGroup.d.ts +53 -0
  43. package/dist/components/atoms/ButtonGroup.es.js +349 -0
  44. package/dist/components/atoms/ButtonGroup.es.js.map +1 -0
  45. package/dist/components/atoms/IconButton.d.ts +23 -9
  46. package/dist/components/atoms/IconButton.es.js +82 -16
  47. package/dist/components/atoms/IconButton.es.js.map +1 -1
  48. package/dist/components/atoms/IconProvider.d.ts +1 -1
  49. package/dist/components/atoms/IconProvider.es.js +48 -7
  50. package/dist/components/atoms/IconProvider.es.js.map +1 -1
  51. package/dist/components/atoms/Modal.d.ts +27 -3
  52. package/dist/components/atoms/Modal.es.js +15 -16
  53. package/dist/components/atoms/Modal.es.js.map +1 -1
  54. package/dist/components/atoms/Notification.d.ts +1 -1
  55. package/dist/components/atoms/Notification.es.js +26 -3
  56. package/dist/components/atoms/Notification.es.js.map +1 -1
  57. package/dist/components/atoms/OutlinedRadio.d.ts +6 -2
  58. package/dist/components/atoms/OutlinedRadio.es.js +12 -25
  59. package/dist/components/atoms/OutlinedRadio.es.js.map +1 -1
  60. package/dist/components/atoms/Progress.d.ts +48 -0
  61. package/dist/components/atoms/Progress.es.js +279 -0
  62. package/dist/components/atoms/Progress.es.js.map +1 -0
  63. package/dist/components/atoms/Skeleton.d.ts +9 -3
  64. package/dist/components/atoms/Skeleton.es.js +33 -3
  65. package/dist/components/atoms/Skeleton.es.js.map +1 -1
  66. package/dist/components/atoms/Spinner.d.ts +15 -4
  67. package/dist/components/atoms/Spinner.es.js +86 -22
  68. package/dist/components/atoms/Spinner.es.js.map +1 -1
  69. package/dist/components/atoms/Switch.d.ts +19 -7
  70. package/dist/components/atoms/Switch.es.js +288 -50
  71. package/dist/components/atoms/Switch.es.js.map +1 -1
  72. package/dist/components/atoms/TabButton.d.ts +17 -3
  73. package/dist/components/atoms/TabButton.es.js +647 -25
  74. package/dist/components/atoms/TabButton.es.js.map +1 -1
  75. package/dist/components/atoms/TabPanel.es.js +1 -1
  76. package/dist/components/atoms/Tag.d.ts +43 -0
  77. package/dist/components/atoms/Tag.es.js +219 -0
  78. package/dist/components/atoms/Tag.es.js.map +1 -0
  79. package/dist/components/atoms/Tooltip.d.ts +36 -14
  80. package/dist/components/atoms/Tooltip.es.js +7 -114
  81. package/dist/components/atoms/Tooltip.es.js.map +1 -1
  82. package/dist/components/molecules/Alert.d.ts +1 -1
  83. package/dist/components/molecules/Alert.es.js +13 -9
  84. package/dist/components/molecules/Alert.es.js.map +1 -1
  85. package/dist/components/molecules/CopyField.d.ts +2 -2
  86. package/dist/components/molecules/CopyField.es.js +3 -4
  87. package/dist/components/molecules/CopyField.es.js.map +1 -1
  88. package/dist/components/molecules/CustomDrawer.d.ts +5 -4
  89. package/dist/components/molecules/CustomDrawer.es.js +141 -82
  90. package/dist/components/molecules/CustomDrawer.es.js.map +1 -1
  91. package/dist/components/molecules/Dialog.d.ts +16 -8
  92. package/dist/components/molecules/Dialog.es.js +33 -31
  93. package/dist/components/molecules/Dialog.es.js.map +1 -1
  94. package/dist/components/molecules/ImagesPreview.es.js +15 -11
  95. package/dist/components/molecules/ImagesPreview.es.js.map +1 -1
  96. package/dist/components/molecules/Input.d.ts +1 -1
  97. package/dist/components/molecules/Input.es.js +3 -5
  98. package/dist/components/molecules/Input.es.js.map +1 -1
  99. package/dist/components/molecules/Markdown/ExpandableMarkdown.d.ts +8 -8
  100. package/dist/components/molecules/Markdown/components.d.ts +12 -11
  101. package/dist/components/molecules/Markdown.es.js +26 -49
  102. package/dist/components/molecules/Markdown.es.js.map +1 -1
  103. package/dist/components/molecules/Notify.d.ts +30 -1
  104. package/dist/components/molecules/Notify.es.js +91 -36
  105. package/dist/components/molecules/Notify.es.js.map +1 -1
  106. package/dist/components/molecules/SimpleCodeEditor.es.js +32 -19
  107. package/dist/components/molecules/SimpleCodeEditor.es.js.map +1 -1
  108. package/dist/components/molecules/ToggleButton.d.ts +3 -2
  109. package/dist/components/molecules/ToggleButton.es.js +155 -57
  110. package/dist/components/molecules/ToggleButton.es.js.map +1 -1
  111. package/dist/components/molecules/agent-chat/UserMessage.es.js +2 -2
  112. package/dist/components/molecules/agent-chat/UserMessage.es.js.map +1 -1
  113. package/dist/components/molecules/agent-chat/UserMessageEdit.es.js +5 -5
  114. package/dist/components/molecules/agent-chat/UserMessageEdit.es.js.map +1 -1
  115. package/dist/components/molecules/agent-chat/index.d.ts +0 -6
  116. package/dist/components/molecules/agent-chat.es.js +76 -407
  117. package/dist/components/molecules/agent-chat.es.js.map +1 -1
  118. package/dist/components/molecules/monacoEditorCore/MonacoEditorCore.d.ts +0 -1
  119. package/dist/components/theme/colors.d.ts +17 -53
  120. package/dist/components/theme/colors.es.js +384 -180
  121. package/dist/components/theme/colors.es.js.map +1 -1
  122. package/dist/components/theme/theme.d.ts +14 -11
  123. package/dist/components/theme/theme.es.js +3 -64
  124. package/dist/components/theme/theme.es.js.map +1 -1
  125. package/dist/components/theme/useTheme.es.js +1 -4
  126. package/dist/components/theme/useTheme.es.js.map +1 -1
  127. package/dist/composite-CrCQWAKA.js +108 -0
  128. package/dist/composite-CrCQWAKA.js.map +1 -0
  129. package/dist/composite-DCpXNxz9.js +66 -0
  130. package/dist/composite-DCpXNxz9.js.map +1 -0
  131. package/dist/conversions-CbWPvHRE.js +14 -0
  132. package/dist/conversions-CbWPvHRE.js.map +1 -0
  133. package/dist/error-FX4R42W-.js +6 -0
  134. package/dist/error-FX4R42W-.js.map +1 -0
  135. package/dist/fonts.css +7 -0
  136. package/dist/hooks/useContainerDimensions.d.ts +1 -1
  137. package/dist/index-B806bfA-.js +257 -0
  138. package/dist/index-B806bfA-.js.map +1 -0
  139. package/dist/index-DSVg79g-.js +45 -0
  140. package/dist/index-DSVg79g-.js.map +1 -0
  141. package/dist/index.d.ts +19 -4
  142. package/dist/index.es.js +56 -9
  143. package/dist/index.es.js.map +1 -1
  144. package/dist/inertValue-IJM5NA30.js +11 -0
  145. package/dist/inertValue-IJM5NA30.js.map +1 -0
  146. package/dist/lib/utils.d.ts +1 -0
  147. package/dist/markdown.css +13 -14
  148. package/dist/new-components/atoms/Checkbox.d.ts +6 -0
  149. package/dist/new-components/atoms/Checkbox.es.js +423 -0
  150. package/dist/new-components/atoms/Checkbox.es.js.map +1 -0
  151. package/dist/new-components/atoms/Chip.d.ts +38 -0
  152. package/dist/new-components/atoms/Chip.es.js +269 -0
  153. package/dist/new-components/atoms/Chip.es.js.map +1 -0
  154. package/dist/new-components/atoms/Popover.d.ts +87 -0
  155. package/dist/new-components/atoms/Popover.es.js +21 -0
  156. package/dist/new-components/atoms/Popover.es.js.map +1 -0
  157. package/dist/new-components/atoms/Radio.d.ts +14 -0
  158. package/dist/new-components/atoms/Radio.es.js +536 -0
  159. package/dist/new-components/atoms/Radio.es.js.map +1 -0
  160. package/dist/new-components/atoms/SegmentedControl.d.ts +28 -0
  161. package/dist/new-components/atoms/SegmentedControl.es.js +326 -0
  162. package/dist/new-components/atoms/SegmentedControl.es.js.map +1 -0
  163. package/dist/new-components/atoms/Slider.d.ts +8 -0
  164. package/dist/new-components/atoms/Slider.es.js +1415 -0
  165. package/dist/new-components/atoms/Slider.es.js.map +1 -0
  166. package/dist/new-components/atoms/Toggletip.d.ts +43 -0
  167. package/dist/new-components/atoms/Toggletip.es.js +216 -0
  168. package/dist/new-components/atoms/Toggletip.es.js.map +1 -0
  169. package/dist/new-components/atoms/stories/ThemeComparison.d.ts +8 -0
  170. package/dist/shadowDom-Bq4g0Qeu.js +52 -0
  171. package/dist/shadowDom-Bq4g0Qeu.js.map +1 -0
  172. package/dist/style.css +1 -1
  173. package/dist/theme.css +9 -154
  174. package/dist/tokens.css +1136 -0
  175. package/dist/useAnimationFrame-DwhymJoW.js +108 -0
  176. package/dist/useAnimationFrame-DwhymJoW.js.map +1 -0
  177. package/dist/useAriaLabelledBy-B6n92QBS.js +49 -0
  178. package/dist/useAriaLabelledBy-B6n92QBS.js.map +1 -0
  179. package/dist/useBaseUiId-Ch7ujXpo.js +281 -0
  180. package/dist/useBaseUiId-Ch7ujXpo.js.map +1 -0
  181. package/dist/useButton-PUBhT4Vo.js +235 -0
  182. package/dist/useButton-PUBhT4Vo.js.map +1 -0
  183. package/dist/useControlled-BSyYkg5C.js +65 -0
  184. package/dist/useControlled-BSyYkg5C.js.map +1 -0
  185. package/dist/useIsoLayoutEffect-e9VA-ICd.js +499 -0
  186. package/dist/useIsoLayoutEffect-e9VA-ICd.js.map +1 -0
  187. package/dist/useLabelableId-DCLzrdD-.js +241 -0
  188. package/dist/useLabelableId-DCLzrdD-.js.map +1 -0
  189. package/dist/useOpenInteractionType-DGWLoAqp.js +1086 -0
  190. package/dist/useOpenInteractionType-DGWLoAqp.js.map +1 -0
  191. package/dist/usePopupHandleStore-BdS-xYID.js +2372 -0
  192. package/dist/usePopupHandleStore-BdS-xYID.js.map +1 -0
  193. package/dist/useTimeout-BXf1hDIL.js +46 -0
  194. package/dist/useTimeout-BXf1hDIL.js.map +1 -0
  195. package/dist/useTransitionStatus-C9gg_XJ-.js +202 -0
  196. package/dist/useTransitionStatus-C9gg_XJ-.js.map +1 -0
  197. package/dist/useValueAsRef-BfFRcMg6.js +28 -0
  198. package/dist/useValueAsRef-BfFRcMg6.js.map +1 -0
  199. package/dist/utils/classNames.d.ts +3 -2
  200. package/dist/visuallyHidden-B6H2X3_Y.js +26 -0
  201. package/dist/visuallyHidden-B6H2X3_Y.js.map +1 -0
  202. package/dist/vite-env.d.ts +18 -0
  203. package/package.json +30 -22
  204. package/dist/Input-BvwIpntS.js.map +0 -1
  205. package/dist/Notification-BT4CZ69U.js +0 -39
  206. package/dist/Notification-BT4CZ69U.js.map +0 -1
  207. package/dist/RootFontSizeContext-7vgn7Y_k.js +0 -22
  208. package/dist/RootFontSizeContext-7vgn7Y_k.js.map +0 -1
  209. package/dist/classNames-Dy-RXSjS.js +0 -9
  210. package/dist/classNames-Dy-RXSjS.js.map +0 -1
  211. package/dist/components/molecules/DropdownMenu.d.ts +0 -18
  212. package/dist/components/molecules/DropdownMenu.es.js +0 -104
  213. package/dist/components/molecules/DropdownMenu.es.js.map +0 -1
  214. package/dist/components/molecules/ThumbsFeedback.d.ts +0 -13
  215. package/dist/components/molecules/ThumbsFeedback.es.js +0 -98
  216. package/dist/components/molecules/ThumbsFeedback.es.js.map +0 -1
  217. package/dist/components/molecules/agent-chat/SandboxToolCall.d.ts +0 -15
  218. package/dist/components/molecules/agent-chat/ToolCallCard.d.ts +0 -26
  219. package/dist/components/molecules/agent-chat/ToolCallContentBlock.d.ts +0 -17
  220. package/dist/components/theme/lightColorPlugin.d.ts +0 -1
  221. package/dist/components/theme/lightColorPlugin.es.js +0 -92
  222. package/dist/components/theme/lightColorPlugin.es.js.map +0 -1
  223. package/dist/tailwindPreset.d.ts +0 -144
  224. package/dist/tailwindPreset.es.js +0 -100
  225. package/dist/tailwindPreset.es.js.map +0 -1
@@ -1,100 +1,869 @@
1
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import React__default from "react";
3
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4
- import MuiAccordion from "@mui/material/Accordion";
5
- import MuiAccordionDetails from "@mui/material/AccordionDetails";
6
- import MuiAccordionSummary from "@mui/material/AccordionSummary";
7
- import { styled } from "@mui/material/styles";
8
- import { colors } from "../theme/theme.es.js";
9
- import { c as classNames } from "../../classNames-Dy-RXSjS.js";
10
- const Accordion = styled((props) => {
11
- const { background, borderColor, ...restProps } = props;
12
- return /* @__PURE__ */ jsx(MuiAccordion, { disableGutters: true, elevation: 0, square: true, ...restProps });
13
- })(({ background, borderColor }) => ({
14
- border: `0.0625rem solid ${borderColor ?? colors.gray[250]}`,
15
- borderRadius: "0.5rem",
16
- backgroundColor: background ?? colors.gray[250],
17
- marginBottom: "0.75rem",
18
- "&:before": {
19
- display: "none"
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useState } from "react";
4
+ import IconProvider from "./IconProvider.es.js";
5
+ import { c as classNames } from "../../classNames-B1XpQHle.js";
6
+ import { u as useControlled } from "../../useControlled-BSyYkg5C.js";
7
+ import { f as formatErrorMessage, w as warn, a as useStableCallback, b as useRenderElement, E as EMPTY_ARRAY, u as useIsoLayoutEffect, c as useMergedRefs, r as resolveStyle } from "../../useIsoLayoutEffect-e9VA-ICd.js";
8
+ import { C as CompositeList, u as useCompositeListItem } from "../../CompositeList-D4xmSZ5V.js";
9
+ import { u as useValueAsRef, a as addEventListener } from "../../useValueAsRef-BfFRcMg6.js";
10
+ import { A as AnimationFrame } from "../../useAnimationFrame-DwhymJoW.js";
11
+ import { T as Timeout } from "../../useTimeout-BXf1hDIL.js";
12
+ import { u as useBaseUiId, c as createChangeEventDetails, e as triggerPress, g as getWindow, n as none } from "../../useBaseUiId-Ch7ujXpo.js";
13
+ import { u as useTransitionStatus, s as startingStyle$1, t as transitionStatusMapping, b as useAnimationsFinished, a as useOpenChangeComplete } from "../../useTransitionStatus-C9gg_XJ-.js";
14
+ import { a as useButton } from "../../useButton-PUBhT4Vo.js";
15
+ const AccordionRootContext = /* @__PURE__ */ React.createContext(void 0);
16
+ if (process.env.NODE_ENV !== "production") AccordionRootContext.displayName = "AccordionRootContext";
17
+ function useAccordionRootContext() {
18
+ const context = React.useContext(AccordionRootContext);
19
+ if (context === void 0) {
20
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: AccordionRootContext is missing. Accordion parts must be placed within <Accordion.Root>." : formatErrorMessage(10));
20
21
  }
21
- }));
22
- const AccordionSummary = styled((props) => {
23
- const { hideIcon, chevronDown, rightIcon, iconClasses, ...restProps } = props;
22
+ return context;
23
+ }
24
+ const rootStateAttributesMapping = {
25
+ value: () => null
26
+ };
27
+ const AccordionRoot = /* @__PURE__ */ React.forwardRef(function AccordionRoot2(componentProps, forwardedRef) {
28
+ const {
29
+ render,
30
+ className,
31
+ disabled = false,
32
+ hiddenUntilFound: hiddenUntilFoundProp,
33
+ keepMounted: keepMountedProp,
34
+ loopFocus,
35
+ onValueChange,
36
+ multiple = false,
37
+ orientation = "vertical",
38
+ value: valueProp,
39
+ defaultValue: defaultValueProp,
40
+ style,
41
+ ...elementProps
42
+ } = componentProps;
43
+ const defaultValue = defaultValueProp ?? EMPTY_ARRAY;
44
+ if (process.env.NODE_ENV !== "production") {
45
+ React.useEffect(() => {
46
+ if (hiddenUntilFoundProp && keepMountedProp === false) {
47
+ warn("The `keepMounted={false}` prop on `Accordion.Root` is ignored when `hiddenUntilFound` is enabled, since panels must remain mounted while closed.");
48
+ }
49
+ }, [hiddenUntilFoundProp, keepMountedProp]);
50
+ }
51
+ const accordionItemRefs = React.useRef([]);
52
+ const [value, setValue] = useControlled({
53
+ controlled: valueProp,
54
+ default: defaultValue,
55
+ name: "Accordion",
56
+ state: "value"
57
+ });
58
+ const handleValueChange = useStableCallback((newValue, nextOpen, details) => {
59
+ let nextValue;
60
+ if (!multiple) {
61
+ nextValue = value[0] === newValue ? [] : [newValue];
62
+ } else if (nextOpen) {
63
+ nextValue = [...value, newValue];
64
+ } else {
65
+ nextValue = value.filter((v) => v !== newValue);
66
+ }
67
+ onValueChange == null ? void 0 : onValueChange(nextValue, details);
68
+ if (details.isCanceled) {
69
+ return;
70
+ }
71
+ setValue(nextValue);
72
+ });
73
+ const state = React.useMemo(() => ({
74
+ value,
75
+ disabled,
76
+ orientation
77
+ }), [value, disabled, orientation]);
78
+ const contextValue = React.useMemo(() => ({
79
+ disabled,
80
+ handleValueChange,
81
+ hiddenUntilFound: hiddenUntilFoundProp ?? false,
82
+ keepMounted: keepMountedProp ?? false,
83
+ state,
84
+ value
85
+ }), [disabled, handleValueChange, hiddenUntilFoundProp, keepMountedProp, state, value]);
86
+ const element = useRenderElement("div", componentProps, {
87
+ state,
88
+ ref: forwardedRef,
89
+ props: elementProps,
90
+ stateAttributesMapping: rootStateAttributesMapping
91
+ });
92
+ return /* @__PURE__ */ jsx(AccordionRootContext.Provider, {
93
+ value: contextValue,
94
+ children: /* @__PURE__ */ jsx(CompositeList, {
95
+ elementsRef: accordionItemRefs,
96
+ children: element
97
+ })
98
+ });
99
+ });
100
+ if (process.env.NODE_ENV !== "production") AccordionRoot.displayName = "AccordionRoot";
101
+ function useCollapsibleRoot(parameters) {
102
+ const {
103
+ open: openParam,
104
+ defaultOpen = false,
105
+ onOpenChange,
106
+ disabled
107
+ } = parameters;
108
+ const [open2, setOpen] = useControlled({
109
+ controlled: openParam,
110
+ default: defaultOpen,
111
+ name: "Collapsible",
112
+ state: "open"
113
+ });
114
+ const {
115
+ mounted,
116
+ setMounted,
117
+ transitionStatus
118
+ } = useTransitionStatus(open2, true, true);
119
+ const defaultPanelId = useBaseUiId();
120
+ const [registeredPanelId, setPanelIdState] = React.useState();
121
+ const panelId = registeredPanelId === null ? void 0 : registeredPanelId ?? defaultPanelId;
122
+ const handleTrigger = useStableCallback((event) => {
123
+ const nextOpen = !open2;
124
+ const eventDetails = createChangeEventDetails(triggerPress, event.nativeEvent);
125
+ onOpenChange(nextOpen, eventDetails);
126
+ if (eventDetails.isCanceled) {
127
+ return;
128
+ }
129
+ setOpen(nextOpen);
130
+ });
131
+ return React.useMemo(() => ({
132
+ defaultPanelId,
133
+ disabled,
134
+ handleTrigger,
135
+ mounted,
136
+ open: open2,
137
+ panelId,
138
+ setMounted,
139
+ setOpen,
140
+ setPanelIdState,
141
+ transitionStatus
142
+ }), [defaultPanelId, disabled, handleTrigger, mounted, open2, panelId, setMounted, setOpen, setPanelIdState, transitionStatus]);
143
+ }
144
+ const CollapsibleRootContext = /* @__PURE__ */ React.createContext(void 0);
145
+ if (process.env.NODE_ENV !== "production") CollapsibleRootContext.displayName = "CollapsibleRootContext";
146
+ function useCollapsibleRootContext() {
147
+ const context = React.useContext(CollapsibleRootContext);
148
+ if (context === void 0) {
149
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage(15));
150
+ }
151
+ return context;
152
+ }
153
+ const AccordionItemContext = /* @__PURE__ */ React.createContext(void 0);
154
+ if (process.env.NODE_ENV !== "production") AccordionItemContext.displayName = "AccordionItemContext";
155
+ function useAccordionItemContext() {
156
+ const context = React.useContext(AccordionItemContext);
157
+ if (context === void 0) {
158
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: AccordionItemContext is missing. Accordion parts must be placed within <Accordion.Item>." : formatErrorMessage(9));
159
+ }
160
+ return context;
161
+ }
162
+ const open = "data-open";
163
+ const closed = "data-closed";
164
+ const startingStyle = startingStyle$1;
165
+ const panelOpen = "data-panel-open";
166
+ const PANEL_OPEN_HOOK = {
167
+ [open]: ""
168
+ };
169
+ const PANEL_CLOSED_HOOK = {
170
+ [closed]: ""
171
+ };
172
+ const triggerOpenStateMapping = {
173
+ open(value) {
174
+ if (value) {
175
+ return {
176
+ [panelOpen]: ""
177
+ };
178
+ }
179
+ return null;
180
+ }
181
+ };
182
+ const collapsibleOpenStateMapping = {
183
+ open(value) {
184
+ if (value) {
185
+ return PANEL_OPEN_HOOK;
186
+ }
187
+ return PANEL_CLOSED_HOOK;
188
+ }
189
+ };
190
+ const index = "data-index";
191
+ const accordionStateAttributesMapping = {
192
+ ...collapsibleOpenStateMapping,
193
+ index: (value) => ({
194
+ [index]: String(value)
195
+ }),
196
+ ...transitionStatusMapping,
197
+ value: () => null
198
+ };
199
+ const AccordionItem$1 = /* @__PURE__ */ React.forwardRef(function AccordionItem(componentProps, forwardedRef) {
200
+ const {
201
+ className,
202
+ disabled: disabledProp = false,
203
+ onOpenChange: onOpenChangeProp,
204
+ render,
205
+ value: valueProp,
206
+ style,
207
+ ...elementProps
208
+ } = componentProps;
209
+ const {
210
+ ref: listItemRef,
211
+ index: index2
212
+ } = useCompositeListItem();
213
+ const {
214
+ disabled: contextDisabled,
215
+ handleValueChange,
216
+ state: rootState,
217
+ value: openValues
218
+ } = useAccordionRootContext();
219
+ const fallbackValue = useBaseUiId();
220
+ const value = valueProp ?? fallbackValue;
221
+ const disabled = disabledProp || contextDisabled;
222
+ const isOpen = openValues.includes(value);
223
+ const onOpenChange = useStableCallback((nextOpen, eventDetails) => {
224
+ onOpenChangeProp == null ? void 0 : onOpenChangeProp(nextOpen, eventDetails);
225
+ if (eventDetails.isCanceled) {
226
+ return;
227
+ }
228
+ handleValueChange(value, nextOpen, eventDetails);
229
+ });
230
+ const collapsible = useCollapsibleRoot({
231
+ open: isOpen,
232
+ onOpenChange,
233
+ disabled
234
+ });
235
+ const collapsibleContext = React.useMemo(() => ({
236
+ ...collapsible,
237
+ onOpenChange,
238
+ state: {
239
+ open: collapsible.open,
240
+ disabled: collapsible.disabled,
241
+ transitionStatus: collapsible.transitionStatus
242
+ }
243
+ }), [collapsible, onOpenChange]);
244
+ const state = React.useMemo(() => ({
245
+ ...rootState,
246
+ hidden: !isOpen && !collapsible.mounted,
247
+ index: index2,
248
+ disabled,
249
+ open: isOpen
250
+ }), [collapsible.mounted, disabled, index2, isOpen, rootState]);
251
+ const defaultTriggerId = useBaseUiId();
252
+ const [registeredTriggerId, setTriggerId] = React.useState();
253
+ const triggerId = registeredTriggerId === null ? void 0 : registeredTriggerId ?? defaultTriggerId;
254
+ const accordionItemContext = React.useMemo(() => ({
255
+ defaultTriggerId,
256
+ open: isOpen,
257
+ state,
258
+ setTriggerId,
259
+ triggerId
260
+ }), [defaultTriggerId, isOpen, state, setTriggerId, triggerId]);
261
+ const element = useRenderElement("div", componentProps, {
262
+ state,
263
+ ref: [forwardedRef, listItemRef],
264
+ props: elementProps,
265
+ stateAttributesMapping: accordionStateAttributesMapping
266
+ });
267
+ return /* @__PURE__ */ jsx(CollapsibleRootContext.Provider, {
268
+ value: collapsibleContext,
269
+ children: /* @__PURE__ */ jsx(AccordionItemContext.Provider, {
270
+ value: accordionItemContext,
271
+ children: element
272
+ })
273
+ });
274
+ });
275
+ if (process.env.NODE_ENV !== "production") AccordionItem$1.displayName = "AccordionItem";
276
+ const AccordionHeader = /* @__PURE__ */ React.forwardRef(function AccordionHeader2(componentProps, forwardedRef) {
277
+ const {
278
+ render,
279
+ className,
280
+ style,
281
+ ...elementProps
282
+ } = componentProps;
283
+ const {
284
+ state
285
+ } = useAccordionItemContext();
286
+ const element = useRenderElement("h3", componentProps, {
287
+ state,
288
+ ref: forwardedRef,
289
+ props: elementProps,
290
+ stateAttributesMapping: accordionStateAttributesMapping
291
+ });
292
+ return element;
293
+ });
294
+ if (process.env.NODE_ENV !== "production") AccordionHeader.displayName = "AccordionHeader";
295
+ const stateAttributesMapping = {
296
+ ...accordionStateAttributesMapping,
297
+ ...triggerOpenStateMapping
298
+ };
299
+ const AccordionTrigger$1 = /* @__PURE__ */ React.forwardRef(function AccordionTrigger(componentProps, forwardedRef) {
300
+ const {
301
+ disabled: disabledProp,
302
+ className,
303
+ id: idProp,
304
+ render,
305
+ nativeButton = true,
306
+ style,
307
+ ...elementProps
308
+ } = componentProps;
309
+ const {
310
+ panelId,
311
+ open: open2,
312
+ handleTrigger,
313
+ disabled: contextDisabled
314
+ } = useCollapsibleRootContext();
315
+ const disabled = disabledProp || contextDisabled;
316
+ const {
317
+ getButtonProps,
318
+ buttonRef
319
+ } = useButton({
320
+ disabled,
321
+ native: nativeButton
322
+ });
323
+ const {
324
+ defaultTriggerId,
325
+ state,
326
+ setTriggerId
327
+ } = useAccordionItemContext();
328
+ const registeredId = idProp || void 0;
329
+ const id = registeredId ?? defaultTriggerId;
330
+ useIsoLayoutEffect(() => {
331
+ setTriggerId((currentId) => registeredId ?? (currentId === null ? void 0 : currentId));
332
+ return () => {
333
+ setTriggerId((currentId) => currentId === registeredId ? null : currentId);
334
+ };
335
+ }, [registeredId, setTriggerId]);
336
+ const props = {
337
+ "aria-controls": open2 ? panelId : void 0,
338
+ "aria-expanded": open2,
339
+ id,
340
+ onClick: handleTrigger
341
+ };
342
+ const element = useRenderElement("button", componentProps, {
343
+ state,
344
+ ref: [forwardedRef, buttonRef],
345
+ props: [props, elementProps, getButtonProps],
346
+ stateAttributesMapping
347
+ });
348
+ return element;
349
+ });
350
+ if (process.env.NODE_ENV !== "production") AccordionTrigger$1.displayName = "AccordionTrigger";
351
+ const EMPTY_DIMENSIONS = {
352
+ height: void 0,
353
+ width: void 0
354
+ };
355
+ function useCollapsiblePanel(parameters) {
356
+ const {
357
+ externalRef,
358
+ hiddenUntilFound,
359
+ id: idParam,
360
+ keepMounted,
361
+ mounted,
362
+ onOpenChange,
363
+ open: open2,
364
+ setMounted,
365
+ setOpen,
366
+ transitionStatus
367
+ } = parameters;
368
+ const panelRef = React.useRef(null);
369
+ const animationTypeRef = React.useRef(null);
370
+ const [dimensions, setDimensionsUnwrapped] = React.useState(EMPTY_DIMENSIONS);
371
+ const lastMeasuredDimensionsRef = React.useRef(EMPTY_DIMENSIONS);
372
+ const shouldSkipNextOpenRef = React.useRef(false);
373
+ const shouldPreventMountAnimationRef = React.useRef(open2);
374
+ const shouldPreventActivityResumeAnimationRef = React.useRef(false);
375
+ const [forcePanelIdle, setForcePanelIdle] = React.useState(false);
376
+ const pendingTemporaryStyleRestoreRef = React.useRef(null);
377
+ const mergedPanelRef = useMergedRefs(externalRef, panelRef);
378
+ const latestOpenRef = useValueAsRef(open2);
379
+ const runOnceCloseAnimationsFinish = useAnimationsFinished(panelRef);
380
+ const hidden = !open2 && !mounted;
381
+ const panelTransitionStatus = forcePanelIdle ? "idle" : transitionStatus;
382
+ const shouldPreventOpenAnimation = open2 && // These 2 refs are safe to read in render, they are only written from committed
383
+ // layout/effect paths and gate one-shot motion suppression for the next open
384
+ // lifecycle. They intentionally expose the last committed motion snapshot.
385
+ (shouldPreventMountAnimationRef.current || shouldPreventActivityResumeAnimationRef.current);
386
+ const renderedDimensions = !open2 && mounted && // These 2 refs are also safe to read in render, both hold the last committed
387
+ // animation mode and measurement. This fallback only restores a previously
388
+ // measured pixel size after the live dimensions state has been reset back to `auto`.
389
+ animationTypeRef.current === "css-animation" && dimensions.height === void 0 && dimensions.width === void 0 ? lastMeasuredDimensionsRef.current : dimensions;
390
+ const shouldPersistHiddenTransitionStyles = hiddenUntilFound && hidden && animationTypeRef.current !== "css-animation";
391
+ const setDimensions = useStableCallback((nextDimensions, shouldCacheMeasurement = true) => {
392
+ if (shouldCacheMeasurement) {
393
+ lastMeasuredDimensionsRef.current = nextDimensions;
394
+ }
395
+ setDimensionsUnwrapped(nextDimensions);
396
+ });
397
+ const restorePendingTemporaryStyle = useStableCallback(() => {
398
+ var _a;
399
+ (_a = pendingTemporaryStyleRestoreRef.current) == null ? void 0 : _a.call(pendingTemporaryStyleRestoreRef);
400
+ pendingTemporaryStyleRestoreRef.current = null;
401
+ });
402
+ const setPendingTemporaryStyleRestore = useStableCallback((restore) => {
403
+ restorePendingTemporaryStyle();
404
+ pendingTemporaryStyleRestoreRef.current = () => {
405
+ pendingTemporaryStyleRestoreRef.current = null;
406
+ restore();
407
+ };
408
+ });
409
+ const markActivityResumeAnimationSuppressed = useStableCallback(() => {
410
+ if (open2 && mounted && animationTypeRef.current === "css-animation") {
411
+ shouldPreventActivityResumeAnimationRef.current = true;
412
+ }
413
+ });
414
+ useIsoLayoutEffect(() => {
415
+ if (!forcePanelIdle || transitionStatus === "starting") {
416
+ return;
417
+ }
418
+ setForcePanelIdle(false);
419
+ }, [forcePanelIdle, transitionStatus]);
420
+ React.useEffect(() => {
421
+ return () => {
422
+ markActivityResumeAnimationSuppressed();
423
+ restorePendingTemporaryStyle();
424
+ };
425
+ }, [markActivityResumeAnimationSuppressed, restorePendingTemporaryStyle]);
426
+ useIsoLayoutEffect(() => {
427
+ if (!open2) {
428
+ shouldPreventMountAnimationRef.current = false;
429
+ shouldPreventActivityResumeAnimationRef.current = false;
430
+ }
431
+ const panel = panelRef.current;
432
+ if (!panel) {
433
+ return void 0;
434
+ }
435
+ if (!open2 && pendingTemporaryStyleRestoreRef.current) {
436
+ restorePendingTemporaryStyle();
437
+ }
438
+ const animationType = getAnimationType(panel, shouldPreventOpenAnimation);
439
+ animationTypeRef.current = animationType;
440
+ if (open2 && transitionStatus === "idle" && shouldPreventMountAnimationRef.current && animationType === "css-animation") {
441
+ lastMeasuredDimensionsRef.current = getDimensions(panel);
442
+ return void 0;
443
+ }
444
+ if (open2 && transitionStatus === "starting") {
445
+ const skipNextOpen = shouldSkipNextOpenRef.current;
446
+ shouldSkipNextOpenRef.current = false;
447
+ if (animationType === "none") {
448
+ setDimensions(getDimensions(panel));
449
+ setForcePanelIdle(true);
450
+ return void 0;
451
+ }
452
+ if (animationType === "css-transition") {
453
+ const restoreLayoutStyles = resetLayoutStyles(panel);
454
+ setDimensions(getDimensions(panel));
455
+ if (!skipNextOpen) {
456
+ return restoreLayoutStyles;
457
+ }
458
+ const restoreTransitionDuration = setTemporaryStyle(panel, "transition-duration", "0s");
459
+ setPendingTemporaryStyleRestore(restoreTransitionDuration);
460
+ setForcePanelIdle(true);
461
+ return restoreLayoutStyles;
462
+ }
463
+ setDimensions(getDimensions(panel));
464
+ const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
465
+ if (!skipNextOpen) {
466
+ restoreAnimationName();
467
+ return void 0;
468
+ }
469
+ const restoreAnimationDuration = setTemporaryStyle(panel, "animation-duration", "0s");
470
+ restoreAnimationName();
471
+ setPendingTemporaryStyleRestore(restoreAnimationDuration);
472
+ setForcePanelIdle(true);
473
+ return void 0;
474
+ }
475
+ if (!open2 && mounted && (transitionStatus === "idle" || transitionStatus === "starting")) {
476
+ if (animationType === "none") {
477
+ setDimensions(EMPTY_DIMENSIONS, false);
478
+ setMounted(false);
479
+ return void 0;
480
+ }
481
+ setDimensions(getDimensions(panel));
482
+ return void 0;
483
+ }
484
+ if (transitionStatus !== "ending") {
485
+ return void 0;
486
+ }
487
+ if (animationType === "none") {
488
+ setMounted(false);
489
+ return void 0;
490
+ }
491
+ const nextDimensions = getDimensions(panel);
492
+ const hasMeasuredSize = nextDimensions.height > 0 || nextDimensions.width > 0;
493
+ if (!hasMeasuredSize) {
494
+ setMounted(false);
495
+ return void 0;
496
+ }
497
+ setDimensions(nextDimensions);
498
+ if (animationType === "css-animation") {
499
+ const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
500
+ restoreAnimationName();
501
+ }
502
+ return void 0;
503
+ }, [mounted, open2, restorePendingTemporaryStyle, setDimensions, setMounted, setPendingTemporaryStyleRestore, shouldPreventOpenAnimation, transitionStatus]);
504
+ useOpenChangeComplete({
505
+ enabled: open2 && mounted && panelTransitionStatus === "idle",
506
+ open: true,
507
+ ref: panelRef,
508
+ onComplete() {
509
+ if (!open2) {
510
+ return;
511
+ }
512
+ setDimensions(EMPTY_DIMENSIONS, false);
513
+ }
514
+ });
515
+ React.useEffect(() => {
516
+ if (open2 || !mounted || panelTransitionStatus !== "ending") {
517
+ return void 0;
518
+ }
519
+ const panel = panelRef.current;
520
+ if (!panel) {
521
+ setMounted(false);
522
+ setDimensions(EMPTY_DIMENSIONS, false);
523
+ return void 0;
524
+ }
525
+ const abortController = new AbortController();
526
+ let endingStyleFrame = -1;
527
+ function handleComplete() {
528
+ if (latestOpenRef.current) {
529
+ return;
530
+ }
531
+ setMounted(false);
532
+ setDimensions(EMPTY_DIMENSIONS, false);
533
+ }
534
+ endingStyleFrame = AnimationFrame.request(() => {
535
+ runOnceCloseAnimationsFinish(handleComplete, abortController.signal);
536
+ });
537
+ return () => {
538
+ AnimationFrame.cancel(endingStyleFrame);
539
+ abortController.abort();
540
+ };
541
+ }, [latestOpenRef, mounted, open2, panelTransitionStatus, runOnceCloseAnimationsFinish, setDimensions, setMounted]);
542
+ useIsoLayoutEffect(() => {
543
+ const panel = panelRef.current;
544
+ if (!panel || !hiddenUntilFound || !hidden) {
545
+ return;
546
+ }
547
+ panel.setAttribute("hidden", "until-found");
548
+ }, [hidden, hiddenUntilFound]);
549
+ React.useEffect(function registerBeforeMatchListener() {
550
+ const panel = panelRef.current;
551
+ if (!panel) {
552
+ return void 0;
553
+ }
554
+ const revealDecisionTimeout = Timeout.create();
555
+ let revertRevealFrame = -1;
556
+ const scheduleRevealRevert = (revertSkippedMotion, restoreStartingStyle) => {
557
+ revealDecisionTimeout.start(0, () => {
558
+ if (latestOpenRef.current) {
559
+ return;
560
+ }
561
+ revertRevealFrame = AnimationFrame.request(() => {
562
+ if (latestOpenRef.current) {
563
+ return;
564
+ }
565
+ if (revertSkippedMotion) {
566
+ shouldSkipNextOpenRef.current = false;
567
+ }
568
+ if (restoreStartingStyle) {
569
+ panel.setAttribute(startingStyle, "");
570
+ }
571
+ panel.setAttribute("hidden", "until-found");
572
+ });
573
+ });
574
+ };
575
+ const handleBeforeMatch = (event) => {
576
+ const eventDetails = createChangeEventDetails(none, event);
577
+ onOpenChange(true, eventDetails);
578
+ if (eventDetails.isCanceled) {
579
+ scheduleRevealRevert(false, false);
580
+ return;
581
+ }
582
+ shouldSkipNextOpenRef.current = true;
583
+ const hadStartingStyle = panel.hasAttribute(startingStyle);
584
+ panel.removeAttribute(startingStyle);
585
+ setOpen(true);
586
+ scheduleRevealRevert(true, hadStartingStyle);
587
+ };
588
+ const cleanupBeforeMatchListener = addEventListener(panel, "beforematch", handleBeforeMatch);
589
+ return () => {
590
+ revealDecisionTimeout.clear();
591
+ AnimationFrame.cancel(revertRevealFrame);
592
+ cleanupBeforeMatchListener();
593
+ };
594
+ }, [latestOpenRef, onOpenChange, setOpen]);
595
+ const shouldRender = keepMounted || hiddenUntilFound || mounted || open2;
596
+ return {
597
+ height: renderedDimensions.height,
598
+ props: {
599
+ ...shouldPersistHiddenTransitionStyles ? {
600
+ [startingStyle]: ""
601
+ } : void 0,
602
+ hidden,
603
+ id: idParam
604
+ },
605
+ ref: mergedPanelRef,
606
+ shouldPreventOpenAnimation,
607
+ shouldRender,
608
+ transitionStatus: panelTransitionStatus,
609
+ width: renderedDimensions.width
610
+ };
611
+ }
612
+ function getDimensions(element) {
613
+ return {
614
+ height: element.scrollHeight,
615
+ width: element.scrollWidth
616
+ };
617
+ }
618
+ function getAnimationType(element, hasSuppressedMountAnimation) {
619
+ const panelStyles = getWindow(element).getComputedStyle(element);
620
+ const hasAnimation = (panelStyles.animationName.split(",").map((name) => name.trim()).some((name) => name !== "" && name !== "none") || hasSuppressedMountAnimation) && hasNonZeroDuration(panelStyles.animationDuration);
621
+ const hasTransition = hasNonZeroDuration(panelStyles.transitionDuration);
622
+ if (hasAnimation && hasTransition) {
623
+ if (process.env.NODE_ENV !== "production") {
624
+ warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
625
+ }
626
+ return "css-transition";
627
+ }
628
+ if (hasTransition) {
629
+ return "css-transition";
630
+ }
631
+ if (hasAnimation) {
632
+ return "css-animation";
633
+ }
634
+ return "none";
635
+ }
636
+ function hasNonZeroDuration(value) {
637
+ return value.split(",").map((part) => part.trim()).some((part) => part !== "" && Number.parseFloat(part) > 0);
638
+ }
639
+ function setTemporaryStyle(element, property, value) {
640
+ const previousValue = element.style.getPropertyValue(property);
641
+ const previousPriority = element.style.getPropertyPriority(property);
642
+ element.style.setProperty(property, value);
643
+ return () => {
644
+ if (previousValue === "") {
645
+ element.style.removeProperty(property);
646
+ return;
647
+ }
648
+ element.style.setProperty(property, previousValue, previousPriority);
649
+ };
650
+ }
651
+ function resetLayoutStyles(element) {
652
+ const originalLayoutStyles = {
653
+ "justify-content": element.style.justifyContent,
654
+ "align-items": element.style.alignItems,
655
+ "align-content": element.style.alignContent,
656
+ "justify-items": element.style.justifyItems
657
+ };
658
+ Object.keys(originalLayoutStyles).forEach((key) => {
659
+ element.style.setProperty(key, "initial", "important");
660
+ });
661
+ function restoreLayoutStyles() {
662
+ Object.entries(originalLayoutStyles).forEach(([key, value]) => {
663
+ if (value === "") {
664
+ element.style.removeProperty(key);
665
+ return;
666
+ }
667
+ element.style.setProperty(key, value);
668
+ });
669
+ }
670
+ const frame = AnimationFrame.request(restoreLayoutStyles);
671
+ return () => {
672
+ AnimationFrame.cancel(frame);
673
+ restoreLayoutStyles();
674
+ };
675
+ }
676
+ const accordionPanelHeight = "--accordion-panel-height";
677
+ const accordionPanelWidth = "--accordion-panel-width";
678
+ const AccordionPanel = /* @__PURE__ */ React.forwardRef(function AccordionPanel2(componentProps, forwardedRef) {
679
+ const {
680
+ className,
681
+ hiddenUntilFound: hiddenUntilFoundProp,
682
+ keepMounted: keepMountedProp,
683
+ id: idProp,
684
+ render,
685
+ style,
686
+ ...elementProps
687
+ } = componentProps;
688
+ const {
689
+ hiddenUntilFound: contextHiddenUntilFound,
690
+ keepMounted: contextKeepMounted
691
+ } = useAccordionRootContext();
692
+ const {
693
+ defaultPanelId,
694
+ mounted,
695
+ onOpenChange,
696
+ open: open2,
697
+ setMounted,
698
+ setOpen,
699
+ setPanelIdState,
700
+ transitionStatus
701
+ } = useCollapsibleRootContext();
702
+ const hiddenUntilFound = hiddenUntilFoundProp ?? contextHiddenUntilFound;
703
+ const keepMounted = keepMountedProp ?? contextKeepMounted;
704
+ const registeredId = idProp || void 0;
705
+ const id = idProp ?? defaultPanelId;
706
+ if (process.env.NODE_ENV !== "production") {
707
+ React.useEffect(() => {
708
+ if (keepMountedProp === false && hiddenUntilFound) {
709
+ warn("The `keepMounted={false}` prop on an `Accordion.Panel` is ignored when `hiddenUntilFound` is enabled on the panel or root, since the panel must remain mounted while closed.");
710
+ }
711
+ }, [hiddenUntilFound, keepMountedProp]);
712
+ }
713
+ useIsoLayoutEffect(() => {
714
+ setPanelIdState((currentId) => registeredId ?? (currentId === null ? void 0 : currentId));
715
+ return () => {
716
+ setPanelIdState((currentId) => currentId === registeredId ? null : currentId);
717
+ };
718
+ }, [registeredId, setPanelIdState]);
719
+ const {
720
+ height,
721
+ props,
722
+ ref,
723
+ shouldPreventOpenAnimation,
724
+ shouldRender,
725
+ transitionStatus: panelTransitionStatus,
726
+ width
727
+ } = useCollapsiblePanel({
728
+ externalRef: forwardedRef,
729
+ hiddenUntilFound,
730
+ id,
731
+ keepMounted,
732
+ mounted,
733
+ onOpenChange,
734
+ open: open2,
735
+ setMounted,
736
+ setOpen,
737
+ transitionStatus
738
+ });
739
+ const {
740
+ state,
741
+ triggerId
742
+ } = useAccordionItemContext();
743
+ const panelState = {
744
+ ...state,
745
+ transitionStatus: panelTransitionStatus
746
+ };
747
+ const resolvedStyle = resolveStyle(style, panelState);
748
+ const element = useRenderElement("div", {
749
+ ...componentProps,
750
+ style: void 0
751
+ }, {
752
+ state: panelState,
753
+ ref,
754
+ props: [
755
+ props,
756
+ {
757
+ "aria-labelledby": triggerId,
758
+ role: "region",
759
+ style: {
760
+ [accordionPanelHeight]: height === void 0 ? "auto" : `${height}px`,
761
+ [accordionPanelWidth]: width === void 0 ? "auto" : `${width}px`
762
+ }
763
+ },
764
+ elementProps,
765
+ resolvedStyle ? {
766
+ style: resolvedStyle
767
+ } : void 0,
768
+ // Resolve the public `style` prop so temporary `animationName: 'none'`
769
+ // can still win after user's inline styles have been merged.
770
+ shouldPreventOpenAnimation ? {
771
+ style: {
772
+ animationName: "none"
773
+ }
774
+ } : void 0
775
+ ],
776
+ stateAttributesMapping: accordionStateAttributesMapping
777
+ });
778
+ if (!shouldRender) {
779
+ return null;
780
+ }
781
+ return element;
782
+ });
783
+ if (process.env.NODE_ENV !== "production") AccordionPanel.displayName = "AccordionPanel";
784
+ function Accordion(props) {
785
+ return /* @__PURE__ */ jsx(AccordionRoot, { "data-slot": "accordion", ...props });
786
+ }
787
+ function AccordionItem2({ className, ...props }) {
24
788
  return /* @__PURE__ */ jsx(
25
- MuiAccordionSummary,
789
+ AccordionItem$1,
26
790
  {
27
- expandIcon: hideIcon ? /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx(
28
- FontAwesomeIcon,
29
- {
30
- icon: chevronDown ? "chevron-down" : "chevron-right",
31
- className: classNames("text-xs text-gray-400", iconClasses)
32
- }
791
+ "data-slot": "accordion-item",
792
+ className: classNames("border-b border-border-default", className),
793
+ ...props
794
+ }
795
+ );
796
+ }
797
+ function AccordionTrigger2({ className, children, ...props }) {
798
+ return /* @__PURE__ */ jsx(AccordionHeader, { className: "flex flex-1", children: /* @__PURE__ */ jsxs(
799
+ AccordionTrigger$1,
800
+ {
801
+ "data-slot": "accordion-trigger",
802
+ className: classNames(
803
+ "focus-ring flex flex-1 items-center justify-between py-3 text-left text-label-sm text-text-primary transition-all hover:text-text-secondary data-panel-open:[&>svg]:rotate-180",
804
+ className
33
805
  ),
34
- ...restProps
806
+ ...props,
807
+ children: [
808
+ children,
809
+ /* @__PURE__ */ jsx(
810
+ IconProvider,
811
+ {
812
+ icon: "chevron-down",
813
+ className: "size-4 shrink-0 text-icon-secondary transition-transform duration-200"
814
+ }
815
+ )
816
+ ]
817
+ }
818
+ ) });
819
+ }
820
+ function AccordionContent({ className, children, ...props }) {
821
+ return /* @__PURE__ */ jsx(
822
+ AccordionPanel,
823
+ {
824
+ "data-slot": "accordion-content",
825
+ className: "h-[var(--accordion-panel-height)] overflow-hidden text-body-sm text-text-secondary transition-[height] ease-out data-ending-style:h-0 data-starting-style:h-0",
826
+ ...props,
827
+ children: /* @__PURE__ */ jsx("div", { className: classNames("pt-0 pb-3", className), children })
35
828
  }
36
829
  );
37
- })(({ theme, chevronDown, rightIcon }) => ({
38
- flexDirection: rightIcon ? "row" : "row-reverse",
39
- "& .MuiAccordionSummary-expandIconWrapper.Mui-expanded": {
40
- transform: chevronDown ? "rotate(-180deg)" : "rotate(90deg)"
41
- },
42
- "& .MuiAccordionSummary-content": {
43
- marginLeft: theme.spacing(1)
44
- }
45
- }));
46
- const AccordionDetails = styled(MuiAccordionDetails)(({ theme }) => ({
47
- padding: `0 ${theme.spacing(2)}`
48
- }));
830
+ }
49
831
  function CustomizedAccordions({
50
832
  children,
51
833
  btn,
52
834
  id,
53
835
  discription,
54
- sx,
55
- tools
836
+ tools,
837
+ className
56
838
  }) {
57
- const [expanded, setExpanded] = React__default.useState(false);
58
- const [showTools, setShowTools] = React__default.useState(false);
59
- const handleChange = () => {
60
- if (!expanded && tools) {
61
- setShowTools(true);
62
- }
63
- setExpanded(!expanded);
64
- };
65
- return /* @__PURE__ */ jsxs(
839
+ const [expanded, setExpanded] = useState(false);
840
+ return /* @__PURE__ */ jsx(
66
841
  Accordion,
67
842
  {
68
- expanded,
69
- onChange: handleChange,
70
- sx,
71
- slotProps: {
72
- transition: tools ? {
73
- onExited: (node) => {
74
- if (tools) {
75
- setShowTools(false);
76
- }
77
- }
78
- } : void 0
79
- },
80
- children: [
81
- /* @__PURE__ */ jsx(AccordionSummary, { "aria-controls": "panel", id, children: /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
82
- /* @__PURE__ */ jsxs("div", { className: "flex w-full", children: [
83
- /* @__PURE__ */ jsx("div", { className: "font-base text-gray-1000 font-medium ml-1", children: btn }),
84
- /* @__PURE__ */ jsx("div", { className: "flex items-center w-full px-3 pr-4", children: /* @__PURE__ */ jsx("div", { className: "w-full border-y border-gray-200" }) }),
85
- showTools && tools
86
- ] }),
87
- discription && /* @__PURE__ */ jsx("div", { className: "font-sans text-gray-600 text-xs font-medium ml-1.5", children: discription })
88
- ] }) }),
89
- /* @__PURE__ */ jsx(AccordionDetails, { children })
90
- ]
843
+ value: expanded ? [id] : [],
844
+ onValueChange: (val) => setExpanded(val.includes(id)),
845
+ className: classNames("mb-3", className),
846
+ children: /* @__PURE__ */ jsxs(AccordionItem2, { value: id, className: "border border-border-default rounded-lg bg-background-surface-page", children: [
847
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center pr-3", children: [
848
+ /* @__PURE__ */ jsx(AccordionTrigger2, { className: "px-3 py-2 hover:no-underline", children: /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
849
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center", children: [
850
+ /* @__PURE__ */ jsx("div", { className: "text-text-primary font-medium ml-1", children: btn }),
851
+ /* @__PURE__ */ jsx("div", { className: "flex items-center flex-1 px-3 pr-4", children: /* @__PURE__ */ jsx("div", { className: "w-full border-t border-border-default" }) })
852
+ ] }),
853
+ discription && /* @__PURE__ */ jsx("div", { className: "text-text-secondary text-xs font-medium ml-1.5", children: discription })
854
+ ] }) }),
855
+ expanded && tools && /* @__PURE__ */ jsx("div", { className: "ml-3 flex items-center gap-2", children: tools })
856
+ ] }),
857
+ /* @__PURE__ */ jsx(AccordionContent, { children })
858
+ ] })
91
859
  }
92
860
  );
93
861
  }
94
862
  export {
95
863
  Accordion,
96
- AccordionDetails,
97
- AccordionSummary,
864
+ AccordionContent,
865
+ AccordionItem2 as AccordionItem,
866
+ AccordionTrigger2 as AccordionTrigger,
98
867
  CustomizedAccordions as default
99
868
  };
100
869
  //# sourceMappingURL=Accordion.es.js.map