tfy-web-components 0.0.34 → 0.0.36

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 (230) 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 +5 -2
  49. package/dist/components/atoms/IconProvider.es.js +69 -10
  50. package/dist/components/atoms/IconProvider.es.js.map +1 -1
  51. package/dist/components/atoms/Logo.d.ts +18 -0
  52. package/dist/components/atoms/Logo.es.js +79 -0
  53. package/dist/components/atoms/Logo.es.js.map +1 -0
  54. package/dist/components/atoms/Modal.d.ts +27 -3
  55. package/dist/components/atoms/Modal.es.js +15 -16
  56. package/dist/components/atoms/Modal.es.js.map +1 -1
  57. package/dist/components/atoms/Notification.d.ts +1 -1
  58. package/dist/components/atoms/Notification.es.js +26 -3
  59. package/dist/components/atoms/Notification.es.js.map +1 -1
  60. package/dist/components/atoms/OutlinedRadio.d.ts +6 -2
  61. package/dist/components/atoms/OutlinedRadio.es.js +12 -25
  62. package/dist/components/atoms/OutlinedRadio.es.js.map +1 -1
  63. package/dist/components/atoms/Progress.d.ts +48 -0
  64. package/dist/components/atoms/Progress.es.js +279 -0
  65. package/dist/components/atoms/Progress.es.js.map +1 -0
  66. package/dist/components/atoms/Skeleton.d.ts +9 -3
  67. package/dist/components/atoms/Skeleton.es.js +33 -3
  68. package/dist/components/atoms/Skeleton.es.js.map +1 -1
  69. package/dist/components/atoms/Spinner.d.ts +15 -4
  70. package/dist/components/atoms/Spinner.es.js +86 -22
  71. package/dist/components/atoms/Spinner.es.js.map +1 -1
  72. package/dist/components/atoms/Switch.d.ts +19 -7
  73. package/dist/components/atoms/Switch.es.js +288 -50
  74. package/dist/components/atoms/Switch.es.js.map +1 -1
  75. package/dist/components/atoms/TabButton.d.ts +17 -3
  76. package/dist/components/atoms/TabButton.es.js +647 -25
  77. package/dist/components/atoms/TabButton.es.js.map +1 -1
  78. package/dist/components/atoms/TabPanel.es.js +1 -1
  79. package/dist/components/atoms/Tag.d.ts +43 -0
  80. package/dist/components/atoms/Tag.es.js +219 -0
  81. package/dist/components/atoms/Tag.es.js.map +1 -0
  82. package/dist/components/atoms/Tooltip.d.ts +36 -14
  83. package/dist/components/atoms/Tooltip.es.js +7 -114
  84. package/dist/components/atoms/Tooltip.es.js.map +1 -1
  85. package/dist/components/molecules/Alert.d.ts +1 -1
  86. package/dist/components/molecules/Alert.es.js +13 -9
  87. package/dist/components/molecules/Alert.es.js.map +1 -1
  88. package/dist/components/molecules/CopyField.d.ts +2 -2
  89. package/dist/components/molecules/CopyField.es.js +3 -4
  90. package/dist/components/molecules/CopyField.es.js.map +1 -1
  91. package/dist/components/molecules/CustomDrawer.d.ts +5 -4
  92. package/dist/components/molecules/CustomDrawer.es.js +141 -82
  93. package/dist/components/molecules/CustomDrawer.es.js.map +1 -1
  94. package/dist/components/molecules/Dialog.d.ts +16 -8
  95. package/dist/components/molecules/Dialog.es.js +33 -31
  96. package/dist/components/molecules/Dialog.es.js.map +1 -1
  97. package/dist/components/molecules/ImagesPreview.es.js +15 -11
  98. package/dist/components/molecules/ImagesPreview.es.js.map +1 -1
  99. package/dist/components/molecules/Input.d.ts +1 -1
  100. package/dist/components/molecules/Input.es.js +3 -5
  101. package/dist/components/molecules/Input.es.js.map +1 -1
  102. package/dist/components/molecules/Markdown/ExpandableMarkdown.d.ts +8 -8
  103. package/dist/components/molecules/Markdown/components.d.ts +12 -11
  104. package/dist/components/molecules/Markdown.es.js +26 -49
  105. package/dist/components/molecules/Markdown.es.js.map +1 -1
  106. package/dist/components/molecules/Notify.d.ts +30 -1
  107. package/dist/components/molecules/Notify.es.js +91 -36
  108. package/dist/components/molecules/Notify.es.js.map +1 -1
  109. package/dist/components/molecules/SimpleCodeEditor.es.js +32 -19
  110. package/dist/components/molecules/SimpleCodeEditor.es.js.map +1 -1
  111. package/dist/components/molecules/ToggleButton.d.ts +3 -2
  112. package/dist/components/molecules/ToggleButton.es.js +155 -57
  113. package/dist/components/molecules/ToggleButton.es.js.map +1 -1
  114. package/dist/components/molecules/agent-chat/UserMessage.es.js +2 -2
  115. package/dist/components/molecules/agent-chat/UserMessage.es.js.map +1 -1
  116. package/dist/components/molecules/agent-chat/UserMessageEdit.es.js +5 -5
  117. package/dist/components/molecules/agent-chat/UserMessageEdit.es.js.map +1 -1
  118. package/dist/components/molecules/agent-chat/index.d.ts +0 -6
  119. package/dist/components/molecules/agent-chat.es.js +76 -407
  120. package/dist/components/molecules/agent-chat.es.js.map +1 -1
  121. package/dist/components/molecules/monacoEditorCore/MonacoEditorCore.d.ts +0 -1
  122. package/dist/components/theme/colors.d.ts +17 -53
  123. package/dist/components/theme/colors.es.js +384 -180
  124. package/dist/components/theme/colors.es.js.map +1 -1
  125. package/dist/components/theme/theme.d.ts +14 -11
  126. package/dist/components/theme/theme.es.js +3 -64
  127. package/dist/components/theme/theme.es.js.map +1 -1
  128. package/dist/components/theme/useTheme.es.js +1 -4
  129. package/dist/components/theme/useTheme.es.js.map +1 -1
  130. package/dist/composite-CrCQWAKA.js +108 -0
  131. package/dist/composite-CrCQWAKA.js.map +1 -0
  132. package/dist/composite-DCpXNxz9.js +66 -0
  133. package/dist/composite-DCpXNxz9.js.map +1 -0
  134. package/dist/conversions-CbWPvHRE.js +14 -0
  135. package/dist/conversions-CbWPvHRE.js.map +1 -0
  136. package/dist/error-FX4R42W-.js +6 -0
  137. package/dist/error-FX4R42W-.js.map +1 -0
  138. package/dist/fonts.css +7 -0
  139. package/dist/hooks/useContainerDimensions.d.ts +1 -1
  140. package/dist/index-B806bfA-.js +257 -0
  141. package/dist/index-B806bfA-.js.map +1 -0
  142. package/dist/index-DSVg79g-.js +45 -0
  143. package/dist/index-DSVg79g-.js.map +1 -0
  144. package/dist/index.d.ts +21 -4
  145. package/dist/index.es.js +58 -9
  146. package/dist/index.es.js.map +1 -1
  147. package/dist/inertValue-IJM5NA30.js +11 -0
  148. package/dist/inertValue-IJM5NA30.js.map +1 -0
  149. package/dist/lib/utils.d.ts +1 -0
  150. package/dist/markdown.css +13 -14
  151. package/dist/new-components/atoms/Checkbox.d.ts +6 -0
  152. package/dist/new-components/atoms/Checkbox.es.js +423 -0
  153. package/dist/new-components/atoms/Checkbox.es.js.map +1 -0
  154. package/dist/new-components/atoms/Chip.d.ts +38 -0
  155. package/dist/new-components/atoms/Chip.es.js +269 -0
  156. package/dist/new-components/atoms/Chip.es.js.map +1 -0
  157. package/dist/new-components/atoms/Popover.d.ts +87 -0
  158. package/dist/new-components/atoms/Popover.es.js +21 -0
  159. package/dist/new-components/atoms/Popover.es.js.map +1 -0
  160. package/dist/new-components/atoms/Radio.d.ts +14 -0
  161. package/dist/new-components/atoms/Radio.es.js +536 -0
  162. package/dist/new-components/atoms/Radio.es.js.map +1 -0
  163. package/dist/new-components/atoms/SegmentedControl.d.ts +28 -0
  164. package/dist/new-components/atoms/SegmentedControl.es.js +326 -0
  165. package/dist/new-components/atoms/SegmentedControl.es.js.map +1 -0
  166. package/dist/new-components/atoms/Slider.d.ts +8 -0
  167. package/dist/new-components/atoms/Slider.es.js +1415 -0
  168. package/dist/new-components/atoms/Slider.es.js.map +1 -0
  169. package/dist/new-components/atoms/Toggletip.d.ts +43 -0
  170. package/dist/new-components/atoms/Toggletip.es.js +216 -0
  171. package/dist/new-components/atoms/Toggletip.es.js.map +1 -0
  172. package/dist/new-components/atoms/stories/ThemeComparison.d.ts +8 -0
  173. package/dist/shadowDom-Bq4g0Qeu.js +52 -0
  174. package/dist/shadowDom-Bq4g0Qeu.js.map +1 -0
  175. package/dist/style.css +1 -1
  176. package/dist/tfy-YZ5zY9Jw.js +6 -0
  177. package/dist/tfy-YZ5zY9Jw.js.map +1 -0
  178. package/dist/theme.css +9 -154
  179. package/dist/tokens.css +1124 -0
  180. package/dist/useAnimationFrame-DwhymJoW.js +108 -0
  181. package/dist/useAnimationFrame-DwhymJoW.js.map +1 -0
  182. package/dist/useAriaLabelledBy-B6n92QBS.js +49 -0
  183. package/dist/useAriaLabelledBy-B6n92QBS.js.map +1 -0
  184. package/dist/useBaseUiId-Ch7ujXpo.js +281 -0
  185. package/dist/useBaseUiId-Ch7ujXpo.js.map +1 -0
  186. package/dist/useButton-PUBhT4Vo.js +235 -0
  187. package/dist/useButton-PUBhT4Vo.js.map +1 -0
  188. package/dist/useControlled-BSyYkg5C.js +65 -0
  189. package/dist/useControlled-BSyYkg5C.js.map +1 -0
  190. package/dist/useIsoLayoutEffect-e9VA-ICd.js +499 -0
  191. package/dist/useIsoLayoutEffect-e9VA-ICd.js.map +1 -0
  192. package/dist/useLabelableId-DCLzrdD-.js +241 -0
  193. package/dist/useLabelableId-DCLzrdD-.js.map +1 -0
  194. package/dist/useOpenInteractionType-DGWLoAqp.js +1086 -0
  195. package/dist/useOpenInteractionType-DGWLoAqp.js.map +1 -0
  196. package/dist/usePopupHandleStore-BdS-xYID.js +2372 -0
  197. package/dist/usePopupHandleStore-BdS-xYID.js.map +1 -0
  198. package/dist/useTimeout-BXf1hDIL.js +46 -0
  199. package/dist/useTimeout-BXf1hDIL.js.map +1 -0
  200. package/dist/useTransitionStatus-C9gg_XJ-.js +202 -0
  201. package/dist/useTransitionStatus-C9gg_XJ-.js.map +1 -0
  202. package/dist/useValueAsRef-BfFRcMg6.js +28 -0
  203. package/dist/useValueAsRef-BfFRcMg6.js.map +1 -0
  204. package/dist/utils/classNames.d.ts +3 -2
  205. package/dist/visuallyHidden-B6H2X3_Y.js +26 -0
  206. package/dist/visuallyHidden-B6H2X3_Y.js.map +1 -0
  207. package/dist/vite-env.d.ts +18 -0
  208. package/package.json +30 -22
  209. package/dist/Input-BvwIpntS.js.map +0 -1
  210. package/dist/Notification-BT4CZ69U.js +0 -39
  211. package/dist/Notification-BT4CZ69U.js.map +0 -1
  212. package/dist/RootFontSizeContext-7vgn7Y_k.js +0 -22
  213. package/dist/RootFontSizeContext-7vgn7Y_k.js.map +0 -1
  214. package/dist/classNames-Dy-RXSjS.js +0 -9
  215. package/dist/classNames-Dy-RXSjS.js.map +0 -1
  216. package/dist/components/molecules/DropdownMenu.d.ts +0 -18
  217. package/dist/components/molecules/DropdownMenu.es.js +0 -104
  218. package/dist/components/molecules/DropdownMenu.es.js.map +0 -1
  219. package/dist/components/molecules/ThumbsFeedback.d.ts +0 -13
  220. package/dist/components/molecules/ThumbsFeedback.es.js +0 -98
  221. package/dist/components/molecules/ThumbsFeedback.es.js.map +0 -1
  222. package/dist/components/molecules/agent-chat/SandboxToolCall.d.ts +0 -15
  223. package/dist/components/molecules/agent-chat/ToolCallCard.d.ts +0 -26
  224. package/dist/components/molecules/agent-chat/ToolCallContentBlock.d.ts +0 -17
  225. package/dist/components/theme/lightColorPlugin.d.ts +0 -1
  226. package/dist/components/theme/lightColorPlugin.es.js +0 -92
  227. package/dist/components/theme/lightColorPlugin.es.js.map +0 -1
  228. package/dist/tailwindPreset.d.ts +0 -144
  229. package/dist/tailwindPreset.es.js +0 -100
  230. package/dist/tailwindPreset.es.js.map +0 -1
@@ -0,0 +1,1074 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import * as React from "react";
6
+ import { c as cva } from "./index-DSVg79g-.js";
7
+ import { C as ControlButton } from "./Button-C77b7jpW.js";
8
+ import IconProvider from "./components/atoms/IconProvider.es.js";
9
+ import { c as classNames } from "./classNames-B1XpQHle.js";
10
+ import { f as formatErrorMessage, a as useStableCallback, b as useRenderElement, u as useIsoLayoutEffect } from "./useIsoLayoutEffect-e9VA-ICd.js";
11
+ import { a as closePress, t as triggerHover, f as focusOut, e as triggerPress, h as escapeKey, c as createChangeEventDetails, b as imperativeAction, u as useBaseUiId, j as isHTMLElement } from "./useBaseUiId-Ch7ujXpo.js";
12
+ import { a as useButton } from "./useButton-PUBhT4Vo.js";
13
+ import { R as ReactStore, e as popupStoreSelectors, r as attachPreventUnmountOnClose, s as PATIENT_CLICK_THRESHOLD, f as createPopupOpenState, g as createInitialPopupStoreState, P as PopupTriggerMap, m as fastComponent, v as FloatingTree, i as usePopupRootSync, j as useImplicitActiveTrigger, k as useOpenStateTransitions, l as PopupHandleAttachment, h as usePopupRootStore, u as useDismiss, d as usePopupInteractionProps, w as isOutsideEvent, x as getTabbableNearElement, n as fastComponentRef, o as usePopupHandleStore, q as useTriggerDataForwarding, y as FocusGuard, C as CLICK_TRIGGER_IDENTIFIER, z as pressableTriggerOpenStateMapping, t as triggerOpenStateMapping, b as FloatingPortal, A as useFloatingNodeId, B as FloatingNode, D as POPUP_COLLISION_AVOIDANCE, c as createDefaultInitialFocus, F as FOCUSABLE_POPUP_PROPS, p as popupTransitionStateMapping, a as popupStateMapping } from "./usePopupHandleStore-BdS-xYID.js";
14
+ import { i as inertValue } from "./inertValue-IJM5NA30.js";
15
+ import { u as useHoverReferenceInteraction, s as safePolygon, a as useAnchorPositioning, b as usePositioner, c as useHoverFloatingInteraction, g as getDisabledMountTransitionStyles } from "./Tooltip-BuGLP-PU.js";
16
+ import { a as useClick, b as useOpenMethodTriggerProps, u as useScrollLock, I as InternalBackdrop, F as FloatingFocusManager } from "./useOpenInteractionType-DGWLoAqp.js";
17
+ import { b as useAnimationsFinished, a as useOpenChangeComplete } from "./useTransitionStatus-C9gg_XJ-.js";
18
+ import { o as ownerDocument } from "./index-B806bfA-.js";
19
+ import { C as COMPOSITE_KEYS } from "./composite-CrCQWAKA.js";
20
+ import { u as useToolbarRootContext } from "./ToolbarRootContext-B_HxjkNI.js";
21
+ import * as ReactDOM from "react-dom";
22
+ import { T as Timeout } from "./useTimeout-BXf1hDIL.js";
23
+ const PopoverRootContext = /* @__PURE__ */ React.createContext(void 0);
24
+ if (process.env.NODE_ENV !== "production") PopoverRootContext.displayName = "PopoverRootContext";
25
+ function usePopoverRootContext(optional) {
26
+ const context = React.useContext(PopoverRootContext);
27
+ if (context === void 0 && !optional) {
28
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: PopoverRootContext is missing. Popover parts must be placed within <Popover.Root>." : formatErrorMessage(47));
29
+ }
30
+ return context;
31
+ }
32
+ const selectors = {
33
+ ...popupStoreSelectors,
34
+ disabled: (state) => state.disabled,
35
+ // `trigger-change` describes a popup moving between triggers, which only has
36
+ // meaning while it is open. Dropping it once closed keeps a late or stale
37
+ // restoration from marking a closing popup instant and skipping its exit
38
+ // transition, including on close paths that never reach `setOpen` — a
39
+ // controlled consumer committing `open={false}` goes straight through the prop.
40
+ instantType: (state) => state.instantType === "trigger-change" && !popupStoreSelectors.open(state) ? void 0 : state.instantType,
41
+ openMethod: (state) => state.openMethod,
42
+ openChangeReason: (state) => state.openChangeReason,
43
+ isPressOpenedByTrigger: (state, triggerId) => state.openChangeReason === triggerPress && popupStoreSelectors.isOpenedByTrigger(state, triggerId),
44
+ // The trigger selectors below resolve to a constant for triggers that don't use them, so state
45
+ // changes don't re-render every inactive trigger.
46
+ isTouchPressOpen: (state, openOnHover) => openOnHover && state.openMethod === "touch" && state.openChangeReason === triggerPress,
47
+ hasTriggerFocusGuards: (state, triggerId) => popupStoreSelectors.isOpenedByTrigger(state, triggerId) && !state.focusManagerModal,
48
+ modal: (state) => state.modal,
49
+ titleElementId: (state) => state.titleElementId,
50
+ descriptionElementId: (state) => state.descriptionElementId,
51
+ openOnHover: (state) => state.openOnHover,
52
+ closeDelay: (state) => state.closeDelay,
53
+ adaptiveOrigin: (state) => state.adaptiveOrigin
54
+ };
55
+ class PopoverStore extends ReactStore {
56
+ constructor(initialState, floatingId, nested) {
57
+ const triggerElements = new PopupTriggerMap();
58
+ super(createInitialState(initialState, triggerElements, floatingId, nested), createInitialContext(triggerElements), selectors);
59
+ __publicField(this, "setOpen", (nextOpen, eventDetails) => {
60
+ var _a, _b;
61
+ const isHover = eventDetails.reason === triggerHover;
62
+ const isKeyboardClick = eventDetails.reason === triggerPress && eventDetails.event.detail === 0;
63
+ const isDismissClose = !nextOpen && (eventDetails.reason === escapeKey || eventDetails.reason == null);
64
+ const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
65
+ const activeTriggerId = this.select("activeTriggerId");
66
+ if (!nextOpen && eventDetails.reason === closePress && eventDetails.trigger == null && activeTriggerId != null) {
67
+ eventDetails.trigger = this.context.triggerElements.getById(activeTriggerId) ?? this.select("activeTriggerElement") ?? void 0;
68
+ }
69
+ (_b = (_a = this.context).onOpenChange) == null ? void 0 : _b.call(_a, nextOpen, eventDetails);
70
+ if (eventDetails.isCanceled) {
71
+ return;
72
+ }
73
+ this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
74
+ const changeState = () => {
75
+ const popupOpenState = createPopupOpenState(this.state, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
76
+ popupOpenState.openChangeReason = eventDetails.reason;
77
+ this.update(popupOpenState);
78
+ };
79
+ if (isHover) {
80
+ this.context.stickIfOpen = true;
81
+ this.context.stickIfOpenTimeout.start(PATIENT_CLICK_THRESHOLD, () => {
82
+ this.context.stickIfOpen = false;
83
+ });
84
+ ReactDOM.flushSync(changeState);
85
+ } else {
86
+ changeState();
87
+ }
88
+ let instantType;
89
+ if (isKeyboardClick) {
90
+ instantType = "click";
91
+ } else if (isDismissClose) {
92
+ instantType = "dismiss";
93
+ } else if (eventDetails.reason === focusOut) {
94
+ instantType = "focus";
95
+ }
96
+ this.set("instantType", instantType);
97
+ });
98
+ }
99
+ }
100
+ function createInitialState(initialState, triggerElements, floatingId, nested = false) {
101
+ const state = {
102
+ ...createInitialPopupStoreState(triggerElements, floatingId, nested),
103
+ disabled: false,
104
+ modal: false,
105
+ focusManagerModal: false,
106
+ instantType: void 0,
107
+ openMethod: null,
108
+ openChangeReason: null,
109
+ titleElementId: void 0,
110
+ descriptionElementId: void 0,
111
+ openOnHover: false,
112
+ closeDelay: 0,
113
+ adaptiveOrigin: void 0,
114
+ ...initialState
115
+ };
116
+ if (state.open && (initialState == null ? void 0 : initialState.mounted) === void 0) {
117
+ state.mounted = true;
118
+ }
119
+ return state;
120
+ }
121
+ function createInitialContext(triggerElements) {
122
+ return {
123
+ popupRef: /* @__PURE__ */ React.createRef(),
124
+ onOpenChange: void 0,
125
+ onOpenChangeComplete: void 0,
126
+ triggerFocusTargetRef: /* @__PURE__ */ React.createRef(),
127
+ beforeTriggerFocusGuardRef: /* @__PURE__ */ React.createRef(),
128
+ beforeContentFocusGuardRef: /* @__PURE__ */ React.createRef(),
129
+ stickIfOpenTimeout: new Timeout(),
130
+ stickIfOpen: true,
131
+ triggerElements
132
+ };
133
+ }
134
+ const PopoverRootComponent = fastComponent(function PopoverRootComponent2({
135
+ props
136
+ }) {
137
+ const {
138
+ children,
139
+ open: openProp,
140
+ defaultOpen = false,
141
+ onOpenChange,
142
+ onOpenChangeComplete,
143
+ modal = false,
144
+ handle,
145
+ triggerId: triggerIdProp,
146
+ defaultTriggerId: defaultTriggerIdProp = null
147
+ } = props;
148
+ const store = usePopoverRootStore(handle, {
149
+ modal,
150
+ open: defaultOpen,
151
+ openProp,
152
+ activeTriggerId: defaultTriggerIdProp,
153
+ triggerIdProp
154
+ });
155
+ store.useControlledProp("openProp", openProp);
156
+ store.useControlledProp("triggerIdProp", triggerIdProp);
157
+ const open = store.useState("open");
158
+ const mounted = store.useState("mounted");
159
+ const payload = store.useState("payload");
160
+ store.useContextCallback("onOpenChange", onOpenChange);
161
+ store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
162
+ usePopupRootSync(store, open);
163
+ useImplicitActiveTrigger(store);
164
+ const {
165
+ forceUnmount
166
+ } = useOpenStateTransitions(open, store, () => {
167
+ store.context.stickIfOpen = true;
168
+ store.set("openChangeReason", null);
169
+ });
170
+ store.useSyncedValues({
171
+ modal
172
+ });
173
+ React.useEffect(() => {
174
+ if (!open) {
175
+ store.context.stickIfOpenTimeout.clear();
176
+ }
177
+ }, [store, open]);
178
+ React.useImperativeHandle(props.actionsRef, () => ({
179
+ unmount: forceUnmount,
180
+ close: () => store.setOpen(false, createChangeEventDetails(imperativeAction))
181
+ }), [forceUnmount, store]);
182
+ const shouldRenderInteractions = open || mounted || handle != null;
183
+ return /* @__PURE__ */ jsxs(PopoverRootContext.Provider, {
184
+ value: store,
185
+ children: [handle && /* @__PURE__ */ jsx(PopupHandleAttachment, {
186
+ handle,
187
+ store
188
+ }), shouldRenderInteractions && /* @__PURE__ */ jsx(PopoverInteractions, {
189
+ store,
190
+ modal
191
+ }), typeof children === "function" ? children({
192
+ payload
193
+ }) : children]
194
+ });
195
+ });
196
+ if (process.env.NODE_ENV !== "production") PopoverRootComponent.displayName = "PopoverRootComponent";
197
+ function PopoverRoot$1(props) {
198
+ if (usePopoverRootContext(true)) {
199
+ return /* @__PURE__ */ jsx(PopoverRootComponent, {
200
+ props
201
+ });
202
+ }
203
+ return /* @__PURE__ */ jsx(FloatingTree, {
204
+ children: /* @__PURE__ */ jsx(PopoverRootComponent, {
205
+ props
206
+ })
207
+ });
208
+ }
209
+ function usePopoverRootStore(handle, initialState) {
210
+ const store = usePopupRootStore((floatingId, nested) => new PopoverStore(initialState, floatingId, nested));
211
+ React.useEffect(() => store.context.stickIfOpenTimeout.disposeEffect(), [store]);
212
+ return store;
213
+ }
214
+ function PopoverInteractions({
215
+ store,
216
+ modal
217
+ }) {
218
+ const floatingRootContext = store.useState("floatingRootContext");
219
+ const dismiss = useDismiss(floatingRootContext, {
220
+ outsidePressEvent: {
221
+ // Ensure `aria-hidden` on outside elements is removed immediately
222
+ // on outside press when trapping focus.
223
+ mouse: modal === "trap-focus" ? "sloppy" : "intentional",
224
+ touch: "sloppy"
225
+ }
226
+ });
227
+ const triggerProps = dismiss.reference;
228
+ const popupProps = dismiss.floating;
229
+ usePopupInteractionProps(store, {
230
+ activeTriggerProps: triggerProps,
231
+ inactiveTriggerProps: triggerProps,
232
+ popupProps
233
+ });
234
+ return null;
235
+ }
236
+ const OPEN_DELAY = 300;
237
+ function useTriggerFocusGuards(store, triggerElementRef) {
238
+ function closeAndFocus(event, direction, positionerElement) {
239
+ var _a;
240
+ const guard = event.currentTarget;
241
+ ReactDOM.flushSync(() => {
242
+ store.setOpen(false, createChangeEventDetails(focusOut, event.nativeEvent, guard));
243
+ });
244
+ (_a = getTabbableNearElement(guard.isConnected ? guard : triggerElementRef.current, direction, positionerElement)) == null ? void 0 : _a.focus();
245
+ }
246
+ function handlePreFocusGuardFocus(event) {
247
+ closeAndFocus(event, -1, store.select("positionerElement"));
248
+ }
249
+ function handleFocusTargetFocus(event) {
250
+ var _a;
251
+ const positionerElement = store.select("positionerElement");
252
+ if (positionerElement && isOutsideEvent(event, positionerElement)) {
253
+ (_a = store.context.beforeContentFocusGuardRef.current) == null ? void 0 : _a.focus();
254
+ } else {
255
+ closeAndFocus(event, 1, positionerElement);
256
+ }
257
+ }
258
+ return {
259
+ handlePreFocusGuardFocus,
260
+ handleFocusTargetFocus
261
+ };
262
+ }
263
+ const PopoverTrigger$1 = fastComponentRef(function PopoverTrigger(componentProps, forwardedRef) {
264
+ const {
265
+ render,
266
+ className,
267
+ style,
268
+ disabled = false,
269
+ nativeButton = true,
270
+ handle,
271
+ payload,
272
+ openOnHover = false,
273
+ delay = OPEN_DELAY,
274
+ closeDelay = 0,
275
+ id: idProp,
276
+ ...elementProps
277
+ } = componentProps;
278
+ const rootStore = usePopoverRootContext(true);
279
+ const handleStore = usePopupHandleStore(handle);
280
+ const store = handleStore ?? rootStore;
281
+ if (!store) {
282
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: <Popover.Trigger> must be either used within a <Popover.Root> component or provided with a handle." : formatErrorMessage(74));
283
+ }
284
+ const thisTriggerId = useBaseUiId(idProp);
285
+ const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
286
+ const floatingContext = store.useState("floatingRootContext");
287
+ const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
288
+ const popupId = store.useState("triggerPopupId", thisTriggerId);
289
+ const triggerElementRef = React.useRef(null);
290
+ const {
291
+ registerTrigger,
292
+ isMountedByThisTrigger
293
+ } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
294
+ payload,
295
+ disabled,
296
+ openOnHover,
297
+ closeDelay
298
+ });
299
+ const isPressOpenedByThisTrigger = store.useState("isPressOpenedByTrigger", thisTriggerId);
300
+ const isTouchPressOpen = store.useState("isTouchPressOpen", openOnHover);
301
+ const hasFocusGuards = store.useState("hasTriggerFocusGuards", thisTriggerId);
302
+ const hoverProps = useHoverReferenceInteraction(floatingContext, {
303
+ enabled: !disabled && openOnHover && !isTouchPressOpen,
304
+ mouseOnly: true,
305
+ move: false,
306
+ handleClose: safePolygon(),
307
+ restMs: delay,
308
+ delay: {
309
+ close: closeDelay
310
+ },
311
+ triggerElementRef,
312
+ isActiveTrigger: isTriggerActive,
313
+ isClosing: () => store.select("transitionStatus") === "ending"
314
+ });
315
+ const getStickIfOpen = useStableCallback(() => store.context.stickIfOpen);
316
+ const click = useClick(floatingContext, {
317
+ stickIfOpen: getStickIfOpen
318
+ });
319
+ const interactionTypeProps = useOpenMethodTriggerProps(() => store.select("open"), (interactionType) => {
320
+ store.set("openMethod", interactionType);
321
+ });
322
+ const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
323
+ const {
324
+ getButtonProps,
325
+ buttonRef
326
+ } = useButton({
327
+ disabled,
328
+ native: nativeButton
329
+ });
330
+ const stateAttributesMapping = {
331
+ open(value) {
332
+ if (isPressOpenedByThisTrigger) {
333
+ return pressableTriggerOpenStateMapping.open(value);
334
+ }
335
+ return triggerOpenStateMapping.open(value);
336
+ }
337
+ };
338
+ const {
339
+ handlePreFocusGuardFocus,
340
+ handleFocusTargetFocus
341
+ } = useTriggerFocusGuards(store, triggerElementRef);
342
+ const state = {
343
+ disabled,
344
+ open: isOpenedByThisTrigger
345
+ };
346
+ const element = useRenderElement("button", componentProps, {
347
+ state,
348
+ ref: [buttonRef, forwardedRef, registerTrigger, triggerElementRef],
349
+ props: [click.reference, hoverProps, rootTriggerProps, interactionTypeProps, {
350
+ [CLICK_TRIGGER_IDENTIFIER]: "",
351
+ id: thisTriggerId,
352
+ "aria-haspopup": "dialog",
353
+ "aria-expanded": isOpenedByThisTrigger,
354
+ "aria-controls": popupId
355
+ }, elementProps, getButtonProps],
356
+ stateAttributesMapping
357
+ });
358
+ const keyedElement = /* @__PURE__ */ jsx(React.Fragment, {
359
+ children: element
360
+ }, thisTriggerId);
361
+ if (hasFocusGuards) {
362
+ return /* @__PURE__ */ jsxs(React.Fragment, {
363
+ children: [/* @__PURE__ */ jsx(FocusGuard, {
364
+ ref: store.context.beforeTriggerFocusGuardRef,
365
+ onFocus: handlePreFocusGuardFocus
366
+ }), keyedElement, /* @__PURE__ */ jsx(FocusGuard, {
367
+ ref: store.context.triggerFocusTargetRef,
368
+ onFocus: handleFocusTargetFocus
369
+ })]
370
+ });
371
+ }
372
+ return keyedElement;
373
+ });
374
+ if (process.env.NODE_ENV !== "production") PopoverTrigger$1.displayName = "PopoverTrigger";
375
+ const PopoverPortalContext = /* @__PURE__ */ React.createContext(void 0);
376
+ if (process.env.NODE_ENV !== "production") PopoverPortalContext.displayName = "PopoverPortalContext";
377
+ function usePopoverPortalContext() {
378
+ const value = React.useContext(PopoverPortalContext);
379
+ if (value === void 0) {
380
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: <Popover.Portal> is missing." : formatErrorMessage(45));
381
+ }
382
+ return value;
383
+ }
384
+ const PopoverPortal = /* @__PURE__ */ React.forwardRef(function PopoverPortal2(props, forwardedRef) {
385
+ const {
386
+ keepMounted = false,
387
+ ...portalProps
388
+ } = props;
389
+ const store = usePopoverRootContext();
390
+ const mounted = store.useState("mounted");
391
+ const shouldRender = mounted || keepMounted;
392
+ if (!shouldRender) {
393
+ return null;
394
+ }
395
+ return /* @__PURE__ */ jsx(PopoverPortalContext.Provider, {
396
+ value: keepMounted,
397
+ children: /* @__PURE__ */ jsx(FloatingPortal, {
398
+ ref: forwardedRef,
399
+ ...portalProps
400
+ })
401
+ });
402
+ });
403
+ if (process.env.NODE_ENV !== "production") PopoverPortal.displayName = "PopoverPortal";
404
+ const PopoverPositionerContext = /* @__PURE__ */ React.createContext(void 0);
405
+ if (process.env.NODE_ENV !== "production") PopoverPositionerContext.displayName = "PopoverPositionerContext";
406
+ function usePopoverPositionerContext() {
407
+ const context = React.useContext(PopoverPositionerContext);
408
+ if (!context) {
409
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: PopoverPositionerContext is missing. PopoverPositioner parts must be placed within <Popover.Positioner>." : formatErrorMessage(46));
410
+ }
411
+ return context;
412
+ }
413
+ function useTriggerSwitchTransition(parameters) {
414
+ const {
415
+ store,
416
+ domReference,
417
+ positionerElement,
418
+ open
419
+ } = parameters;
420
+ const previousTriggerRef = React.useRef(null);
421
+ const pendingSwitchRef = React.useRef(null);
422
+ const runOnceAnimationsFinish = useAnimationsFinished(positionerElement);
423
+ useIsoLayoutEffect(() => {
424
+ var _a;
425
+ if (open) {
426
+ return;
427
+ }
428
+ (_a = pendingSwitchRef.current) == null ? void 0 : _a.abort();
429
+ pendingSwitchRef.current = null;
430
+ if (store.state.instantType === "trigger-change") {
431
+ store.set("instantType", void 0);
432
+ }
433
+ }, [open, store]);
434
+ useIsoLayoutEffect(() => {
435
+ const currentTrigger = domReference;
436
+ const previousTrigger = previousTriggerRef.current;
437
+ if (currentTrigger) {
438
+ previousTriggerRef.current = currentTrigger;
439
+ }
440
+ if (!previousTrigger || !currentTrigger || currentTrigger === previousTrigger) {
441
+ return void 0;
442
+ }
443
+ if (!store.select("open")) {
444
+ return void 0;
445
+ }
446
+ store.set("instantType", void 0);
447
+ const abortController = new AbortController();
448
+ pendingSwitchRef.current = abortController;
449
+ runOnceAnimationsFinish(() => {
450
+ if (store.select("open")) {
451
+ store.set("instantType", "trigger-change");
452
+ }
453
+ }, abortController.signal);
454
+ return () => {
455
+ abortController.abort();
456
+ };
457
+ }, [domReference, runOnceAnimationsFinish, store]);
458
+ }
459
+ const VIEWPORT_WIDTH_TOLERANCE_PX = 20;
460
+ function useAnchoredPopupScrollLock(enabled, touchOpen, positionerElement, referenceElement) {
461
+ const [touchOpenShouldLockScroll, setTouchOpenShouldLockScroll] = React.useState(false);
462
+ useIsoLayoutEffect(() => {
463
+ if (!enabled || !touchOpen || positionerElement == null) {
464
+ setTouchOpenShouldLockScroll(false);
465
+ return;
466
+ }
467
+ const viewportWidth = ownerDocument(positionerElement).documentElement.clientWidth;
468
+ const popupWidth = positionerElement.offsetWidth;
469
+ setTouchOpenShouldLockScroll(viewportWidth > 0 && popupWidth > 0 && popupWidth >= viewportWidth - VIEWPORT_WIDTH_TOLERANCE_PX);
470
+ }, [enabled, touchOpen, positionerElement]);
471
+ useScrollLock(enabled && (!touchOpen || touchOpenShouldLockScroll), referenceElement);
472
+ }
473
+ const PopoverPositioner = /* @__PURE__ */ React.forwardRef(function PopoverPositioner2(componentProps, forwardedRef) {
474
+ const {
475
+ render,
476
+ className,
477
+ style,
478
+ anchor,
479
+ // `useAnchorPositioning` applies the same defaults to the undefined values; the names
480
+ // remain destructured to exclude the props from `elementProps`.
481
+ positionMethod,
482
+ side,
483
+ align,
484
+ sideOffset,
485
+ alignOffset,
486
+ collisionBoundary = "clipping-ancestors",
487
+ collisionPadding,
488
+ arrowPadding,
489
+ sticky,
490
+ disableAnchorTracking = false,
491
+ collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
492
+ ...elementProps
493
+ } = componentProps;
494
+ const store = usePopoverRootContext();
495
+ const keepMounted = usePopoverPortalContext();
496
+ const nodeId = useFloatingNodeId();
497
+ const floatingRootContext = store.useState("floatingRootContext");
498
+ const mounted = store.useState("mounted");
499
+ const open = store.useState("open");
500
+ const openReason = store.useState("openChangeReason");
501
+ const triggerElement = store.useState("activeTriggerElement");
502
+ const modal = store.useState("modal");
503
+ const openMethod = store.useState("openMethod");
504
+ const positionerElement = store.useState("positionerElement");
505
+ const instantType = store.useState("instantType");
506
+ const transitionStatus = store.useState("transitionStatus");
507
+ const adaptiveOrigin = store.useState("adaptiveOrigin");
508
+ const positioning = useAnchorPositioning({
509
+ anchor,
510
+ floatingRootContext,
511
+ positionMethod,
512
+ mounted,
513
+ side,
514
+ sideOffset,
515
+ align,
516
+ alignOffset,
517
+ arrowPadding,
518
+ collisionBoundary,
519
+ collisionPadding,
520
+ sticky,
521
+ disableAnchorTracking,
522
+ keepMounted,
523
+ nodeId,
524
+ collisionAvoidance,
525
+ adaptiveOrigin
526
+ });
527
+ const domReference = floatingRootContext.useState("domReferenceElement");
528
+ useTriggerSwitchTransition({
529
+ store,
530
+ domReference,
531
+ positionerElement,
532
+ open
533
+ });
534
+ const trueModalNonHover = modal === true && openReason !== triggerHover;
535
+ useAnchoredPopupScrollLock(open && trueModalNonHover, openMethod === "touch", positionerElement, triggerElement);
536
+ const setPositionerElement = store.useStateSetter("positionerElement");
537
+ const state = {
538
+ open,
539
+ side: positioning.side,
540
+ align: positioning.align,
541
+ anchorHidden: positioning.anchorHidden,
542
+ instant: instantType
543
+ };
544
+ const element = usePositioner(componentProps, state, {
545
+ styles: positioning.positionerStyles,
546
+ transitionStatus,
547
+ props: elementProps,
548
+ refs: [forwardedRef, setPositionerElement],
549
+ hidden: !mounted,
550
+ inert: !open
551
+ });
552
+ return /* @__PURE__ */ jsxs(PopoverPositionerContext.Provider, {
553
+ value: positioning,
554
+ children: [mounted && trueModalNonHover && /* @__PURE__ */ jsx(InternalBackdrop, {
555
+ inert: inertValue(!open),
556
+ cutout: triggerElement
557
+ }), /* @__PURE__ */ jsx(FloatingNode, {
558
+ id: nodeId,
559
+ children: element
560
+ })]
561
+ });
562
+ });
563
+ if (process.env.NODE_ENV !== "production") PopoverPositioner.displayName = "PopoverPositioner";
564
+ const ClosePartContext = /* @__PURE__ */ React.createContext(void 0);
565
+ if (process.env.NODE_ENV !== "production") ClosePartContext.displayName = "ClosePartContext";
566
+ function useClosePartCount() {
567
+ const [closePartCount, setClosePartCount] = React.useState(0);
568
+ const register = useStableCallback(() => {
569
+ setClosePartCount((count) => count + 1);
570
+ return () => {
571
+ setClosePartCount((count) => Math.max(0, count - 1));
572
+ };
573
+ });
574
+ const context = React.useMemo(() => ({
575
+ register
576
+ }), [register]);
577
+ return {
578
+ context,
579
+ hasClosePart: closePartCount > 0
580
+ };
581
+ }
582
+ function useClosePartRegistration() {
583
+ const context = React.useContext(ClosePartContext);
584
+ useIsoLayoutEffect(() => {
585
+ return context == null ? void 0 : context.register();
586
+ }, [context]);
587
+ }
588
+ const PopoverPopup = /* @__PURE__ */ React.forwardRef(function PopoverPopup2(componentProps, forwardedRef) {
589
+ const {
590
+ render,
591
+ className,
592
+ style,
593
+ initialFocus,
594
+ finalFocus,
595
+ ...elementProps
596
+ } = componentProps;
597
+ const store = usePopoverRootContext();
598
+ const positioner = usePopoverPositionerContext();
599
+ const insideToolbar = useToolbarRootContext() != null;
600
+ const {
601
+ context: closePartContext,
602
+ hasClosePart
603
+ } = useClosePartCount();
604
+ const open = store.useState("open");
605
+ const openMethod = store.useState("openMethod");
606
+ const instantType = store.useState("instantType");
607
+ const transitionStatus = store.useState("transitionStatus");
608
+ const popupProps = store.useState("popupProps");
609
+ const titleId = store.useState("titleElementId");
610
+ const descriptionId = store.useState("descriptionElementId");
611
+ const modal = store.useState("modal");
612
+ const mounted = store.useState("mounted");
613
+ const openReason = store.useState("openChangeReason");
614
+ const activeTriggerElement = store.useState("activeTriggerElement");
615
+ const floatingContext = store.useState("floatingRootContext");
616
+ const floatingId = floatingContext.useState("floatingId");
617
+ const disabled = store.useState("disabled");
618
+ const openOnHover = store.useState("openOnHover");
619
+ const closeDelay = store.useState("closeDelay");
620
+ useOpenChangeComplete({
621
+ open,
622
+ ref: store.context.popupRef,
623
+ onComplete() {
624
+ var _a, _b;
625
+ if (open) {
626
+ (_b = (_a = store.context).onOpenChangeComplete) == null ? void 0 : _b.call(_a, true);
627
+ }
628
+ }
629
+ });
630
+ useHoverFloatingInteraction(floatingContext, {
631
+ enabled: openOnHover && !disabled,
632
+ closeDelay
633
+ });
634
+ const resolvedInitialFocus = initialFocus === void 0 ? createDefaultInitialFocus(store.context.popupRef) : initialFocus;
635
+ const focusManagerModal = modal !== false && hasClosePart;
636
+ store.useSyncedValue("focusManagerModal", focusManagerModal);
637
+ const setPopupElement = store.useStateSetter("popupElement");
638
+ const state = {
639
+ open,
640
+ side: positioner.side,
641
+ align: positioner.align,
642
+ instant: instantType,
643
+ transitionStatus
644
+ };
645
+ const element = useRenderElement("div", componentProps, {
646
+ state,
647
+ ref: [forwardedRef, store.context.popupRef, setPopupElement],
648
+ props: [popupProps, {
649
+ id: floatingId,
650
+ role: "dialog",
651
+ ...FOCUSABLE_POPUP_PROPS,
652
+ "aria-labelledby": titleId,
653
+ "aria-describedby": descriptionId,
654
+ onKeyDown(event) {
655
+ if (insideToolbar && COMPOSITE_KEYS.has(event.key)) {
656
+ event.stopPropagation();
657
+ }
658
+ }
659
+ }, getDisabledMountTransitionStyles(transitionStatus), elementProps],
660
+ stateAttributesMapping: popupTransitionStateMapping
661
+ });
662
+ return /* @__PURE__ */ jsx(FloatingFocusManager, {
663
+ context: floatingContext,
664
+ openInteractionType: openMethod,
665
+ modal: focusManagerModal,
666
+ disabled: !mounted || openReason === triggerHover,
667
+ initialFocus: resolvedInitialFocus,
668
+ returnFocus: finalFocus,
669
+ restoreFocus: "popup",
670
+ getInsideElements: () => [store.context.beforeTriggerFocusGuardRef.current],
671
+ previousFocusableElement: isHTMLElement(activeTriggerElement) ? activeTriggerElement : void 0,
672
+ nextFocusableElement: store.context.triggerFocusTargetRef,
673
+ beforeContentFocusGuardRef: store.context.beforeContentFocusGuardRef,
674
+ children: /* @__PURE__ */ jsx(ClosePartContext.Provider, {
675
+ value: closePartContext,
676
+ children: element
677
+ })
678
+ });
679
+ });
680
+ if (process.env.NODE_ENV !== "production") PopoverPopup.displayName = "PopoverPopup";
681
+ const PopoverArrow$1 = /* @__PURE__ */ React.forwardRef(function PopoverArrow(componentProps, forwardedRef) {
682
+ const {
683
+ render,
684
+ className,
685
+ style,
686
+ ...elementProps
687
+ } = componentProps;
688
+ const store = usePopoverRootContext();
689
+ const open = store.useState("open");
690
+ const {
691
+ arrowRef,
692
+ side,
693
+ align,
694
+ arrowUncentered,
695
+ arrowStyles
696
+ } = usePopoverPositionerContext();
697
+ const state = {
698
+ open,
699
+ side,
700
+ align,
701
+ uncentered: arrowUncentered
702
+ };
703
+ const element = useRenderElement("div", componentProps, {
704
+ state,
705
+ ref: [forwardedRef, arrowRef],
706
+ props: [{
707
+ style: arrowStyles,
708
+ "aria-hidden": true
709
+ }, elementProps],
710
+ stateAttributesMapping: popupStateMapping
711
+ });
712
+ return element;
713
+ });
714
+ if (process.env.NODE_ENV !== "production") PopoverArrow$1.displayName = "PopoverArrow";
715
+ const PopoverTitle$1 = /* @__PURE__ */ React.forwardRef(function PopoverTitle(componentProps, forwardedRef) {
716
+ const {
717
+ render,
718
+ className,
719
+ style,
720
+ ...elementProps
721
+ } = componentProps;
722
+ const store = usePopoverRootContext();
723
+ const id = useBaseUiId(elementProps.id);
724
+ store.useSyncedValueWithCleanup("titleElementId", id);
725
+ const element = useRenderElement("h2", componentProps, {
726
+ ref: forwardedRef,
727
+ props: [{
728
+ id
729
+ }, elementProps]
730
+ });
731
+ return element;
732
+ });
733
+ if (process.env.NODE_ENV !== "production") PopoverTitle$1.displayName = "PopoverTitle";
734
+ const PopoverDescription$1 = /* @__PURE__ */ React.forwardRef(function PopoverDescription(componentProps, forwardedRef) {
735
+ const {
736
+ render,
737
+ className,
738
+ style,
739
+ ...elementProps
740
+ } = componentProps;
741
+ const store = usePopoverRootContext();
742
+ const id = useBaseUiId(elementProps.id);
743
+ store.useSyncedValueWithCleanup("descriptionElementId", id);
744
+ const element = useRenderElement("p", componentProps, {
745
+ ref: forwardedRef,
746
+ props: [{
747
+ id
748
+ }, elementProps]
749
+ });
750
+ return element;
751
+ });
752
+ if (process.env.NODE_ENV !== "production") PopoverDescription$1.displayName = "PopoverDescription";
753
+ const PopoverClose$1 = /* @__PURE__ */ React.forwardRef(function PopoverClose(componentProps, forwardedRef) {
754
+ const {
755
+ render,
756
+ className,
757
+ style,
758
+ disabled = false,
759
+ nativeButton = true,
760
+ ...elementProps
761
+ } = componentProps;
762
+ const {
763
+ buttonRef,
764
+ getButtonProps
765
+ } = useButton({
766
+ disabled,
767
+ focusableWhenDisabled: false,
768
+ native: nativeButton
769
+ });
770
+ const store = usePopoverRootContext();
771
+ useClosePartRegistration();
772
+ const element = useRenderElement("button", componentProps, {
773
+ ref: [forwardedRef, buttonRef],
774
+ props: [{
775
+ onClick(event) {
776
+ store.setOpen(false, createChangeEventDetails(closePress, event.nativeEvent));
777
+ }
778
+ }, elementProps, getButtonProps]
779
+ });
780
+ return element;
781
+ });
782
+ if (process.env.NODE_ENV !== "production") PopoverClose$1.displayName = "PopoverClose";
783
+ const popoverContentVariants = cva(
784
+ "focus-ring flex max-h-[min(25rem,var(--available-height))] flex-col overflow-hidden rounded-container border border-border-subtle bg-background-surface-overlay text-text-primary shadow-elevation-2 outline-none",
785
+ {
786
+ variants: {
787
+ size: {
788
+ auto: "w-auto",
789
+ sm: "w-60",
790
+ md: "w-80",
791
+ lg: "w-120"
792
+ }
793
+ },
794
+ defaultVariants: {
795
+ size: "md"
796
+ }
797
+ }
798
+ );
799
+ function PopoverRoot({ modal = false, ...props }) {
800
+ return /* @__PURE__ */ jsx(PopoverRoot$1, { "data-slot": "popover", modal, ...props });
801
+ }
802
+ function PopoverTrigger2(props) {
803
+ return /* @__PURE__ */ jsx(PopoverTrigger$1, { "data-slot": "popover-trigger", ...props });
804
+ }
805
+ function PopoverArrow2({ className, ...props }) {
806
+ return /* @__PURE__ */ jsx(
807
+ PopoverArrow$1,
808
+ {
809
+ "data-slot": "popover-arrow",
810
+ className: classNames(
811
+ "size-fit text-background-surface-overlay",
812
+ // Base UI only sets the cross-axis offset; the main-axis offset below pins the arrow
813
+ // to the surface's facing edge (with a 1px overlap into the border) instead of leaving
814
+ // it in normal flow, where it renders outside the visible card.
815
+ "data-[side=bottom]:top-[-0.1875rem] data-[side=top]:bottom-[-0.1875rem] data-[side=top]:rotate-180",
816
+ "data-[side=left]:right-[-0.3125rem] data-[side=left]:rotate-90 data-[side=right]:left-[-0.3125rem] data-[side=right]:-rotate-90",
817
+ className
818
+ ),
819
+ ...props,
820
+ children: /* @__PURE__ */ jsxs("svg", { "aria-hidden": "true", width: "8", height: "4", viewBox: "0 0 8 4", fill: "none", children: [
821
+ /* @__PURE__ */ jsx("path", { d: "M0 4h8l-4-4L0 4Z", fill: "currentColor" }),
822
+ /* @__PURE__ */ jsx("path", { d: "M0 4 4 0 8 4", className: "stroke-border-subtle" })
823
+ ] })
824
+ }
825
+ );
826
+ }
827
+ function PopoverContent({
828
+ alignment = "start",
829
+ alignOffset = 0,
830
+ anchor,
831
+ arrow = false,
832
+ arrowPadding = 12,
833
+ children,
834
+ className,
835
+ collisionAvoidance,
836
+ container,
837
+ placement = "bottom",
838
+ positionerId,
839
+ positionerClassName,
840
+ sideOffset = 4,
841
+ size = "md",
842
+ ...props
843
+ }) {
844
+ return /* @__PURE__ */ jsx(PopoverPortal, { container, children: /* @__PURE__ */ jsxs(
845
+ PopoverPositioner,
846
+ {
847
+ id: positionerId,
848
+ "data-slot": "popover-positioner",
849
+ align: alignment,
850
+ alignOffset,
851
+ anchor,
852
+ arrowPadding,
853
+ collisionAvoidance,
854
+ side: placement,
855
+ sideOffset,
856
+ className: classNames("isolate z-50", positionerClassName),
857
+ children: [
858
+ /* @__PURE__ */ jsx(
859
+ PopoverPopup,
860
+ {
861
+ "data-slot": "popover-content",
862
+ className: classNames(popoverContentVariants({ size }), className),
863
+ ...props,
864
+ children
865
+ }
866
+ ),
867
+ arrow ? /* @__PURE__ */ jsx(PopoverArrow2, {}) : null
868
+ ]
869
+ }
870
+ ) });
871
+ }
872
+ function PopoverHeader({ className, ...props }) {
873
+ return /* @__PURE__ */ jsx(
874
+ "div",
875
+ {
876
+ "data-slot": "popover-header",
877
+ className: classNames(
878
+ "flex shrink-0 items-center gap-space-8 border-b border-border-subtle py-space-8 pr-space-8 pl-space-12",
879
+ className
880
+ ),
881
+ ...props
882
+ }
883
+ );
884
+ }
885
+ function PopoverTitle2({ className, ...props }) {
886
+ return /* @__PURE__ */ jsx(
887
+ PopoverTitle$1,
888
+ {
889
+ "data-slot": "popover-title",
890
+ className: classNames("min-w-0 flex-1 truncate text-label-md text-text-primary", className),
891
+ ...props
892
+ }
893
+ );
894
+ }
895
+ function PopoverClose2({
896
+ children,
897
+ className,
898
+ "aria-label": ariaLabel = "Close",
899
+ ...props
900
+ }) {
901
+ return /* @__PURE__ */ jsx(
902
+ PopoverClose$1,
903
+ {
904
+ "data-slot": "popover-close",
905
+ render: /* @__PURE__ */ jsx(
906
+ ControlButton,
907
+ {
908
+ type: "icon",
909
+ variant: "ghost",
910
+ size: "icon-md",
911
+ className: classNames("shrink-0 text-button-ghost-icon-rest", className)
912
+ }
913
+ ),
914
+ "aria-label": ariaLabel,
915
+ ...props,
916
+ children: children ?? /* @__PURE__ */ jsx(IconProvider, { icon: "xmark", className: "size-4" })
917
+ }
918
+ );
919
+ }
920
+ function PopoverBody({ className, ...props }) {
921
+ return /* @__PURE__ */ jsx("div", { "data-slot": "popover-body", className: classNames("min-h-0 overflow-auto p-space-12", className), ...props });
922
+ }
923
+ function PopoverDescription2({ className, ...props }) {
924
+ return /* @__PURE__ */ jsx(
925
+ PopoverDescription$1,
926
+ {
927
+ "data-slot": "popover-description",
928
+ className: classNames("text-body-sm text-text-secondary", className),
929
+ ...props
930
+ }
931
+ );
932
+ }
933
+ function PopoverFooter({ className, ...props }) {
934
+ return /* @__PURE__ */ jsx(
935
+ "div",
936
+ {
937
+ "data-slot": "popover-footer",
938
+ className: classNames(
939
+ "flex shrink-0 items-center justify-end gap-space-8 border-t border-border-subtle px-space-12 py-space-8",
940
+ className
941
+ ),
942
+ ...props
943
+ }
944
+ );
945
+ }
946
+ const defaultAnchorOrigin = { horizontal: "left", vertical: "top" };
947
+ const defaultTransformOrigin = { horizontal: "left", vertical: "top" };
948
+ function resolveOriginPlacement(anchorOrigin, transformOrigin) {
949
+ const anchorVertical = anchorOrigin.vertical;
950
+ const anchorHorizontal = anchorOrigin.horizontal;
951
+ const transformVertical = transformOrigin.vertical;
952
+ const transformHorizontal = transformOrigin.horizontal;
953
+ let side = "bottom";
954
+ if (anchorVertical === "bottom" && transformVertical === "top") {
955
+ side = "bottom";
956
+ } else if (anchorVertical === "top" && transformVertical === "bottom") {
957
+ side = "top";
958
+ } else if (anchorHorizontal === "right" && transformHorizontal === "left") {
959
+ side = "right";
960
+ } else if (anchorHorizontal === "left" && transformHorizontal === "right") {
961
+ side = "left";
962
+ }
963
+ const alignmentOrigin = side === "top" || side === "bottom" ? anchorHorizontal : anchorVertical;
964
+ const align = alignmentOrigin === "left" || alignmentOrigin === "top" ? "start" : alignmentOrigin === "right" || alignmentOrigin === "bottom" ? "end" : "center";
965
+ return { align, side };
966
+ }
967
+ function resolveAnchorElement(anchorEl) {
968
+ return typeof anchorEl === "function" ? anchorEl() : anchorEl ?? null;
969
+ }
970
+ function Popover({
971
+ action,
972
+ align,
973
+ anchorEl,
974
+ anchorOrigin = defaultAnchorOrigin,
975
+ className,
976
+ classes,
977
+ closeAfterTransition: _closeAfterTransition,
978
+ children,
979
+ contentClassName,
980
+ defaultOpen,
981
+ disableEnforceFocus = false,
982
+ id,
983
+ modal,
984
+ onClose,
985
+ onOpenChange,
986
+ onOpenChangeComplete,
987
+ open,
988
+ side,
989
+ sideOffset,
990
+ slotProps,
991
+ sx: _sx,
992
+ transformOrigin = defaultTransformOrigin,
993
+ trigger,
994
+ triggerProps,
995
+ ...contentProps
996
+ }) {
997
+ var _a, _b;
998
+ const isExternallyAnchored = !trigger;
999
+ const { align: originAlign, side: originSide } = resolveOriginPlacement(anchorOrigin, transformOrigin);
1000
+ const resolvedModal = modal ?? (isExternallyAnchored && !disableEnforceFocus ? "trap-focus" : false);
1001
+ React.useImperativeHandle(
1002
+ action,
1003
+ () => ({
1004
+ // Base UI automatically tracks changes to the anchor and popup dimensions.
1005
+ updatePosition: () => void 0
1006
+ }),
1007
+ []
1008
+ );
1009
+ return /* @__PURE__ */ jsxs(
1010
+ PopoverRoot,
1011
+ {
1012
+ defaultOpen,
1013
+ modal: resolvedModal,
1014
+ onOpenChange: (nextOpen, details) => {
1015
+ onOpenChange == null ? void 0 : onOpenChange(nextOpen, details);
1016
+ if (!nextOpen) {
1017
+ onClose == null ? void 0 : onClose(details.event, details.reason === "escape-key" ? "escapeKeyDown" : "backdropClick");
1018
+ }
1019
+ },
1020
+ onOpenChangeComplete: (nextOpen) => {
1021
+ var _a2, _b2;
1022
+ onOpenChangeComplete == null ? void 0 : onOpenChangeComplete(nextOpen);
1023
+ if (nextOpen) {
1024
+ (_b2 = (_a2 = slotProps == null ? void 0 : slotProps.transition) == null ? void 0 : _a2.onEntered) == null ? void 0 : _b2.call(_a2);
1025
+ }
1026
+ },
1027
+ open,
1028
+ children: [
1029
+ trigger ? /* @__PURE__ */ jsx(PopoverTrigger2, { ...triggerProps, render: trigger }) : null,
1030
+ /* @__PURE__ */ jsxs(
1031
+ PopoverContent,
1032
+ {
1033
+ ...contentProps,
1034
+ ref: (_a = slotProps == null ? void 0 : slotProps.paper) == null ? void 0 : _a.ref,
1035
+ alignment: align ?? originAlign,
1036
+ anchor: anchorEl,
1037
+ className: classNames(contentClassName, classes == null ? void 0 : classes.paper, (_b = slotProps == null ? void 0 : slotProps.paper) == null ? void 0 : _b.className),
1038
+ finalFocus: isExternallyAnchored ? () => resolveAnchorElement(anchorEl) : contentProps.finalFocus,
1039
+ placement: side ?? originSide,
1040
+ positionerClassName: classNames(className, classes == null ? void 0 : classes.root),
1041
+ positionerId: id,
1042
+ sideOffset: sideOffset ?? (isExternallyAnchored ? 0 : void 0),
1043
+ size: contentProps.size ?? (isExternallyAnchored ? "auto" : void 0),
1044
+ children: [
1045
+ children,
1046
+ resolvedModal === "trap-focus" ? /* @__PURE__ */ jsx(PopoverClose$1, { className: "sr-only", children: "Close popover" }) : null
1047
+ ]
1048
+ }
1049
+ )
1050
+ ]
1051
+ }
1052
+ );
1053
+ }
1054
+ export {
1055
+ Popover as P,
1056
+ PopoverArrow2 as a,
1057
+ PopoverBody as b,
1058
+ PopoverClose2 as c,
1059
+ PopoverContent as d,
1060
+ PopoverDescription2 as e,
1061
+ PopoverFooter as f,
1062
+ PopoverHeader as g,
1063
+ PopoverRoot as h,
1064
+ PopoverTitle2 as i,
1065
+ PopoverTrigger2 as j,
1066
+ PopoverPortal as k,
1067
+ PopoverPositioner as l,
1068
+ PopoverPopup as m,
1069
+ PopoverDescription$1 as n,
1070
+ PopoverRoot$1 as o,
1071
+ PopoverTitle$1 as p,
1072
+ PopoverTrigger$1 as q
1073
+ };
1074
+ //# sourceMappingURL=Popover-eC_vX5By.js.map