@octanejs/base-ui 0.1.31 → 0.1.32

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 (201) hide show
  1. package/dist/cjs/accordion.cjs +497 -0
  2. package/dist/cjs/alert-dialog.cjs +65 -0
  3. package/dist/cjs/avatar.cjs +234 -0
  4. package/dist/cjs/button.cjs +54 -0
  5. package/dist/cjs/checkbox-group.cjs +165 -0
  6. package/dist/cjs/checkbox.cjs +475 -0
  7. package/dist/cjs/collapsible.cjs +700 -0
  8. package/dist/cjs/context-menu.cjs +257 -0
  9. package/dist/cjs/csp-provider.cjs +40 -0
  10. package/dist/cjs/dialog.cjs +741 -0
  11. package/dist/cjs/direction-provider.cjs +35 -0
  12. package/dist/cjs/field.cjs +559 -0
  13. package/dist/cjs/fieldset.cjs +101 -0
  14. package/dist/cjs/form.cjs +177 -0
  15. package/dist/cjs/index.cjs +133 -0
  16. package/dist/cjs/input.cjs +32 -0
  17. package/dist/cjs/internal.cjs +51 -0
  18. package/dist/cjs/menu.cjs +2420 -0
  19. package/dist/cjs/menubar.cjs +132 -0
  20. package/dist/cjs/merge-props.cjs +34 -0
  21. package/dist/cjs/meter.cjs +169 -0
  22. package/dist/cjs/number-field.cjs +812 -0
  23. package/dist/cjs/popover.cjs +966 -0
  24. package/dist/cjs/preview-card.cjs +632 -0
  25. package/dist/cjs/progress.cjs +206 -0
  26. package/dist/cjs/radio-group.cjs +264 -0
  27. package/dist/cjs/radio.cjs +327 -0
  28. package/dist/cjs/separator.cjs +44 -0
  29. package/dist/cjs/slider.cjs +1384 -0
  30. package/dist/cjs/switch.cjs +306 -0
  31. package/dist/cjs/tabs.cjs +727 -0
  32. package/dist/cjs/toast.cjs +1766 -0
  33. package/dist/cjs/toggle-group.cjs +118 -0
  34. package/dist/cjs/toggle.cjs +121 -0
  35. package/dist/cjs/tooltip.cjs +835 -0
  36. package/dist/cjs/unstable-use-media-query.cjs +79 -0
  37. package/dist/cjs/use-render.cjs +40 -0
  38. package/dist/cjs/utils/CSPContext.cjs +38 -0
  39. package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
  40. package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
  41. package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
  42. package/dist/cjs/utils/DirectionContext.cjs +34 -0
  43. package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
  44. package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
  45. package/dist/cjs/utils/MenubarContext.cjs +40 -0
  46. package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
  47. package/dist/cjs/utils/RequestQueue.cjs +111 -0
  48. package/dist/cjs/utils/TimeoutManager.cjs +50 -0
  49. package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
  50. package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
  51. package/dist/cjs/utils/addEventListener.cjs +33 -0
  52. package/dist/cjs/utils/areArraysEqual.cjs +30 -0
  53. package/dist/cjs/utils/clamp.cjs +30 -0
  54. package/dist/cjs/utils/closePart.cjs +70 -0
  55. package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
  56. package/dist/cjs/utils/composeRefs.cjs +68 -0
  57. package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
  58. package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
  59. package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
  60. package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
  61. package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
  62. package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
  63. package/dist/cjs/utils/composite/keys.cjs +174 -0
  64. package/dist/cjs/utils/composite/list-utils.cjs +90 -0
  65. package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
  66. package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
  67. package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
  68. package/dist/cjs/utils/constants.cjs +56 -0
  69. package/dist/cjs/utils/contains.cjs +46 -0
  70. package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
  71. package/dist/cjs/utils/dom.cjs +35 -0
  72. package/dist/cjs/utils/empty.cjs +34 -0
  73. package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
  74. package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
  75. package/dist/cjs/utils/field/FormContext.cjs +41 -0
  76. package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
  77. package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
  78. package/dist/cjs/utils/field/constants.cjs +68 -0
  79. package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
  80. package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
  81. package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
  82. package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
  83. package/dist/cjs/utils/field/useLabel.cjs +99 -0
  84. package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
  85. package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
  86. package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
  87. package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
  88. package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
  89. package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
  90. package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
  91. package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
  92. package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
  93. package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
  94. package/dist/cjs/utils/floating/composite.cjs +42 -0
  95. package/dist/cjs/utils/floating/constants.cjs +34 -0
  96. package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
  97. package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
  98. package/dist/cjs/utils/floating/element.cjs +103 -0
  99. package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
  100. package/dist/cjs/utils/floating/event.cjs +65 -0
  101. package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
  102. package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
  103. package/dist/cjs/utils/floating/markOthers.cjs +181 -0
  104. package/dist/cjs/utils/floating/nodes.cjs +48 -0
  105. package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
  106. package/dist/cjs/utils/floating/tabbable.cjs +242 -0
  107. package/dist/cjs/utils/floating/types.cjs +16 -0
  108. package/dist/cjs/utils/floating/useClick.cjs +153 -0
  109. package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
  110. package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
  111. package/dist/cjs/utils/floating/useFloating.cjs +186 -0
  112. package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
  113. package/dist/cjs/utils/floating/useFocus.cjs +184 -0
  114. package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
  115. package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
  116. package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
  117. package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
  118. package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
  119. package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
  120. package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
  121. package/dist/cjs/utils/formatNumber.cjs +60 -0
  122. package/dist/cjs/utils/generateId.cjs +32 -0
  123. package/dist/cjs/utils/getCssDimensions.cjs +42 -0
  124. package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
  125. package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
  126. package/dist/cjs/utils/getElementRef.cjs +35 -0
  127. package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
  128. package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
  129. package/dist/cjs/utils/hideMiddleware.cjs +42 -0
  130. package/dist/cjs/utils/inertValue.cjs +30 -0
  131. package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
  132. package/dist/cjs/utils/mergeCleanups.cjs +37 -0
  133. package/dist/cjs/utils/mergeObjects.cjs +39 -0
  134. package/dist/cjs/utils/mergeProps.cjs +182 -0
  135. package/dist/cjs/utils/noop.cjs +29 -0
  136. package/dist/cjs/utils/number/constants.cjs +34 -0
  137. package/dist/cjs/utils/number/parse.cjs +258 -0
  138. package/dist/cjs/utils/number/types.cjs +16 -0
  139. package/dist/cjs/utils/number/validate.cjs +104 -0
  140. package/dist/cjs/utils/owner.cjs +35 -0
  141. package/dist/cjs/utils/platform.cjs +83 -0
  142. package/dist/cjs/utils/popupStateMapping.cjs +74 -0
  143. package/dist/cjs/utils/popups/index.cjs +39 -0
  144. package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
  145. package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
  146. package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
  147. package/dist/cjs/utils/popups/store.cjs +118 -0
  148. package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
  149. package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
  150. package/dist/cjs/utils/resolveClassName.cjs +30 -0
  151. package/dist/cjs/utils/resolveRef.cjs +33 -0
  152. package/dist/cjs/utils/resolveStyle.cjs +30 -0
  153. package/dist/cjs/utils/serializeValue.cjs +40 -0
  154. package/dist/cjs/utils/slider/asc.cjs +30 -0
  155. package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
  156. package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
  157. package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
  158. package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
  159. package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
  160. package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
  161. package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
  162. package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
  163. package/dist/cjs/utils/store/ReactStore.cjs +135 -0
  164. package/dist/cjs/utils/store/Store.cjs +83 -0
  165. package/dist/cjs/utils/store/createSelector.cjs +74 -0
  166. package/dist/cjs/utils/store/useStore.cjs +51 -0
  167. package/dist/cjs/utils/stringifyLocale.cjs +36 -0
  168. package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
  169. package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
  170. package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
  171. package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
  172. package/dist/cjs/utils/useBaseUiId.cjs +36 -0
  173. package/dist/cjs/utils/useButton.cjs +177 -0
  174. package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
  175. package/dist/cjs/utils/useControlled.cjs +47 -0
  176. package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
  177. package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
  178. package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
  179. package/dist/cjs/utils/useIsHydrating.cjs +44 -0
  180. package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
  181. package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
  182. package/dist/cjs/utils/useOnMount.cjs +36 -0
  183. package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
  184. package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
  185. package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
  186. package/dist/cjs/utils/usePopupViewport.cjs +283 -0
  187. package/dist/cjs/utils/usePositioner.cjs +53 -0
  188. package/dist/cjs/utils/usePressAndHold.cjs +51 -0
  189. package/dist/cjs/utils/usePreviousValue.cjs +47 -0
  190. package/dist/cjs/utils/useRefWithInit.cjs +41 -0
  191. package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
  192. package/dist/cjs/utils/useRenderElement.cjs +106 -0
  193. package/dist/cjs/utils/useScrollLock.cjs +232 -0
  194. package/dist/cjs/utils/useStableCallback.cjs +41 -0
  195. package/dist/cjs/utils/useTimeout.cjs +66 -0
  196. package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
  197. package/dist/cjs/utils/useValueAsRef.cjs +43 -0
  198. package/dist/cjs/utils/useValueChanged.cjs +55 -0
  199. package/dist/cjs/utils/valueToPercent.cjs +30 -0
  200. package/dist/cjs/utils/visuallyHidden.cjs +49 -0
  201. package/package.json +20 -8
@@ -0,0 +1,966 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var popover_exports = {};
20
+ __export(popover_exports, {
21
+ Popover: () => Popover,
22
+ PopoverHandle: () => PopoverHandle,
23
+ PopoverStore: () => PopoverStore,
24
+ PopoverViewportCssVars: () => PopoverViewportCssVars,
25
+ createPopoverHandle: () => createPopoverHandle,
26
+ usePopoverPortalContext: () => usePopoverPortalContext,
27
+ usePopoverPositionerContext: () => usePopoverPositionerContext,
28
+ usePopoverRootContext: () => usePopoverRootContext
29
+ });
30
+ module.exports = __toCommonJS(popover_exports);
31
+ var import_octane = require("octane");
32
+ var import_internal = require("./internal.cjs");
33
+ var import_useRenderElement = require("./utils/useRenderElement.cjs");
34
+ var import_mergeProps = require("./utils/mergeProps.cjs");
35
+ var import_useButton = require("./utils/useButton.cjs");
36
+ var import_useBaseUiId = require("./utils/useBaseUiId.cjs");
37
+ var import_createChangeEventDetails = require("./utils/createChangeEventDetails.cjs");
38
+ var import_empty = require("./utils/empty.cjs");
39
+ var import_ReactStore = require("./utils/store/ReactStore.cjs");
40
+ var import_createSelector = require("./utils/store/createSelector.cjs");
41
+ var import_useTimeout = require("./utils/useTimeout.cjs");
42
+ var import_useClick = require("./utils/floating/useClick.cjs");
43
+ var import_useDismiss = require("./utils/floating/useDismiss.cjs");
44
+ var import_FocusGuard = require("./utils/floating/FocusGuard.cjs");
45
+ var import_FloatingTree = require("./utils/floating/FloatingTree.cjs");
46
+ var import_FloatingFocusManager = require("./utils/floating/FloatingFocusManager.cjs");
47
+ var import_FloatingPortal = require("./utils/floating/FloatingPortal.cjs");
48
+ var import_useHoverFloatingInteraction = require("./utils/floating/useHoverFloatingInteraction.cjs");
49
+ var import_useAnchorPositioning = require("./utils/useAnchorPositioning.cjs");
50
+ var import_usePositioner = require("./utils/usePositioner.cjs");
51
+ var import_usePopupViewport = require("./utils/usePopupViewport.cjs");
52
+ var import_useAnchoredPopupScrollLock = require("./utils/useAnchoredPopupScrollLock.cjs");
53
+ var import_adaptiveOriginMiddleware = require("./utils/adaptiveOriginMiddleware.cjs");
54
+ var import_InternalBackdrop = require("./utils/InternalBackdrop.cjs");
55
+ var import_useAnimationsFinished = require("./utils/useAnimationsFinished.cjs");
56
+ var import_useOpenChangeComplete = require("./utils/useOpenChangeComplete.cjs");
57
+ var import_getDisabledMountTransitionStyles = require("./utils/getDisabledMountTransitionStyles.cjs");
58
+ var import_constants = require("./utils/constants.cjs");
59
+ var import_closePart = require("./utils/closePart.cjs");
60
+ var import_popupStateMapping = require("./utils/popupStateMapping.cjs");
61
+ var import_useTransitionStatus = require("./utils/useTransitionStatus.cjs");
62
+ var import_keys = require("./utils/composite/keys.cjs");
63
+ var import_inertValue = require("./utils/inertValue.cjs");
64
+ var import_dom = require("./utils/dom.cjs");
65
+ var import_useHoverReferenceInteraction = require("./utils/floating/useHoverReferenceInteraction.cjs");
66
+ var import_useOpenInteractionType = require("./utils/useOpenInteractionType.cjs");
67
+ var import_popupStateMapping2 = require("./utils/popupStateMapping.cjs");
68
+ var import_popups = require("./utils/popups/index.cjs");
69
+ var import_useTriggerFocusGuards = require("./utils/popups/useTriggerFocusGuards.cjs");
70
+ var import_popupTriggerMap = require("./utils/popups/popupTriggerMap.cjs");
71
+ const OPEN_DELAY = 300;
72
+ const CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger";
73
+ function createInitialPopoverState() {
74
+ return {
75
+ ...(0, import_popups.createInitialPopupStoreState)(),
76
+ disabled: false,
77
+ modal: false,
78
+ focusManagerModal: false,
79
+ instantType: void 0,
80
+ openMethod: null,
81
+ openChangeReason: null,
82
+ titleElementId: void 0,
83
+ descriptionElementId: void 0,
84
+ stickIfOpen: true,
85
+ nested: false,
86
+ openOnHover: false,
87
+ closeDelay: 0,
88
+ hasViewport: false
89
+ };
90
+ }
91
+ const popoverSelectors = {
92
+ ...import_popups.popupStoreSelectors,
93
+ disabled: (0, import_createSelector.createSelector)((state) => state.disabled),
94
+ instantType: (0, import_createSelector.createSelector)((state) => state.instantType),
95
+ openMethod: (0, import_createSelector.createSelector)((state) => state.openMethod),
96
+ openChangeReason: (0, import_createSelector.createSelector)((state) => state.openChangeReason),
97
+ modal: (0, import_createSelector.createSelector)((state) => state.modal),
98
+ focusManagerModal: (0, import_createSelector.createSelector)((state) => state.focusManagerModal),
99
+ stickIfOpen: (0, import_createSelector.createSelector)((state) => state.stickIfOpen),
100
+ titleElementId: (0, import_createSelector.createSelector)((state) => state.titleElementId),
101
+ descriptionElementId: (0, import_createSelector.createSelector)(
102
+ (state) => state.descriptionElementId
103
+ ),
104
+ openOnHover: (0, import_createSelector.createSelector)((state) => state.openOnHover),
105
+ closeDelay: (0, import_createSelector.createSelector)((state) => state.closeDelay),
106
+ hasViewport: (0, import_createSelector.createSelector)((state) => state.hasViewport)
107
+ };
108
+ class PopoverStore extends import_ReactStore.ReactStore {
109
+ constructor(initialState, floatingId, nested = false) {
110
+ const initial = { ...createInitialPopoverState(), ...initialState };
111
+ const triggerElements = new import_popupTriggerMap.PopupTriggerMap();
112
+ if (initial.open && initialState?.mounted === void 0) {
113
+ initial.mounted = true;
114
+ }
115
+ initial.floatingRootContext = (0, import_popups.createPopupFloatingRootContext)(
116
+ triggerElements,
117
+ floatingId,
118
+ nested
119
+ );
120
+ super(
121
+ initial,
122
+ {
123
+ popupRef: { current: null },
124
+ backdropRef: { current: null },
125
+ internalBackdropRef: { current: null },
126
+ onOpenChange: void 0,
127
+ onOpenChangeComplete: void 0,
128
+ triggerFocusTargetRef: { current: null },
129
+ beforeContentFocusGuardRef: { current: null },
130
+ stickIfOpenTimeout: new import_useTimeout.Timeout(),
131
+ triggerElements
132
+ },
133
+ popoverSelectors
134
+ );
135
+ }
136
+ setOpen = (nextOpen, eventDetails) => {
137
+ const isHover = eventDetails.reason === import_createChangeEventDetails.REASONS.triggerHover;
138
+ const isKeyboardClick = eventDetails.reason === import_createChangeEventDetails.REASONS.triggerPress && eventDetails.event.detail === 0;
139
+ const isDismissClose = !nextOpen && (eventDetails.reason === import_createChangeEventDetails.REASONS.escapeKey || eventDetails.reason == null);
140
+ const shouldPreventUnmountOnClose = (0, import_popups.attachPreventUnmountOnClose)(eventDetails);
141
+ const activeTriggerId = this.select("activeTriggerId");
142
+ if (!nextOpen && eventDetails.reason === import_createChangeEventDetails.REASONS.closePress && eventDetails.trigger == null && activeTriggerId != null) {
143
+ eventDetails.trigger = this.context.triggerElements.getById(activeTriggerId) ?? this.select("activeTriggerElement") ?? void 0;
144
+ }
145
+ this.context.onOpenChange?.(nextOpen, eventDetails);
146
+ if (eventDetails.isCanceled) {
147
+ return;
148
+ }
149
+ this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
150
+ const changeState = () => {
151
+ const updatedState = {
152
+ open: nextOpen,
153
+ openChangeReason: eventDetails.reason
154
+ };
155
+ (0, import_popups.setPopupOpenState)(
156
+ updatedState,
157
+ nextOpen,
158
+ eventDetails.trigger,
159
+ shouldPreventUnmountOnClose()
160
+ );
161
+ this.update(updatedState);
162
+ };
163
+ if (isHover) {
164
+ this.set("stickIfOpen", true);
165
+ this.context.stickIfOpenTimeout.start(import_constants.PATIENT_CLICK_THRESHOLD, () => {
166
+ this.set("stickIfOpen", false);
167
+ });
168
+ (0, import_octane.flushSync)(changeState);
169
+ } else {
170
+ changeState();
171
+ }
172
+ if (isKeyboardClick || isDismissClose) {
173
+ this.set("instantType", isKeyboardClick ? "click" : "dismiss");
174
+ } else if (eventDetails.reason === import_createChangeEventDetails.REASONS.focusOut) {
175
+ this.set("instantType", "focus");
176
+ } else {
177
+ this.set("instantType", void 0);
178
+ }
179
+ };
180
+ disposeEffect = () => {
181
+ return this.context.stickIfOpenTimeout.disposeEffect();
182
+ };
183
+ static useStore(externalStore, initialState, slot) {
184
+ const { store, internalStore } = (0, import_popups.usePopupStore)(
185
+ externalStore,
186
+ (floatingId, nested) => new PopoverStore(initialState, floatingId, nested),
187
+ false,
188
+ (0, import_internal.subSlot)(slot, "pop")
189
+ );
190
+ (0, import_octane.useEffect)(
191
+ () => internalStore?.disposeEffect(),
192
+ [internalStore],
193
+ (0, import_internal.subSlot)(slot, "dispose")
194
+ );
195
+ return store;
196
+ }
197
+ }
198
+ class PopoverHandle {
199
+ store;
200
+ constructor() {
201
+ this.store = new PopoverStore();
202
+ }
203
+ open(triggerId) {
204
+ const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) ?? void 0 : void 0;
205
+ if (triggerId && !triggerElement) {
206
+ throw new Error(`Base UI: PopoverHandle.open: No trigger found with id "${triggerId}".`);
207
+ }
208
+ this.store.setOpen(
209
+ true,
210
+ (0, import_createChangeEventDetails.createChangeEventDetails)(
211
+ import_createChangeEventDetails.REASONS.imperativeAction,
212
+ void 0,
213
+ triggerElement
214
+ )
215
+ );
216
+ }
217
+ close() {
218
+ this.store.setOpen(
219
+ false,
220
+ (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.imperativeAction, void 0, void 0)
221
+ );
222
+ }
223
+ get isOpen() {
224
+ return this.store.select("open");
225
+ }
226
+ }
227
+ function createPopoverHandle() {
228
+ return new PopoverHandle();
229
+ }
230
+ const PopoverRootContext = (0, import_octane.createContext)(void 0);
231
+ function usePopoverRootContext(optional) {
232
+ const context = (0, import_octane.useContext)(PopoverRootContext);
233
+ if (context === void 0 && !optional) {
234
+ throw new Error(
235
+ "Base UI: PopoverRootContext is missing. Popover parts must be placed within <Popover.Root>."
236
+ );
237
+ }
238
+ return context;
239
+ }
240
+ const PopoverPortalContext = (0, import_octane.createContext)(void 0);
241
+ function usePopoverPortalContext() {
242
+ const value = (0, import_octane.useContext)(PopoverPortalContext);
243
+ if (value === void 0) {
244
+ throw new Error("Base UI: <Popover.Portal> is missing.");
245
+ }
246
+ return value;
247
+ }
248
+ const PopoverPositionerContext = (0, import_octane.createContext)(
249
+ void 0
250
+ );
251
+ function usePopoverPositionerContext() {
252
+ const context = (0, import_octane.useContext)(PopoverPositionerContext);
253
+ if (!context) {
254
+ throw new Error(
255
+ "Base UI: PopoverPositionerContext is missing. PopoverPositioner parts must be placed within <Popover.Positioner>."
256
+ );
257
+ }
258
+ return context;
259
+ }
260
+ function PopoverInteractions(props) {
261
+ const slot = (0, import_internal.S)("PopoverInteractions");
262
+ const { store, modal } = props;
263
+ const floatingRootContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "frc"));
264
+ const dismiss = (0, import_useDismiss.useDismiss)(
265
+ floatingRootContext,
266
+ {
267
+ outsidePressEvent: {
268
+ mouse: modal === "trap-focus" ? "sloppy" : "intentional",
269
+ touch: "sloppy"
270
+ }
271
+ },
272
+ (0, import_internal.subSlot)(slot, "dismiss")
273
+ );
274
+ const activeTriggerProps = dismiss.reference ?? import_empty.EMPTY_OBJECT;
275
+ const inactiveTriggerProps = dismiss.trigger ?? import_empty.EMPTY_OBJECT;
276
+ const popupProps = (0, import_octane.useMemo)(
277
+ () => (0, import_mergeProps.mergeProps)(import_popups.FOCUSABLE_POPUP_PROPS, dismiss.floating),
278
+ [dismiss.floating],
279
+ (0, import_internal.subSlot)(slot, "pp")
280
+ );
281
+ (0, import_popups.usePopupInteractionProps)(
282
+ store,
283
+ { activeTriggerProps, inactiveTriggerProps, popupProps },
284
+ (0, import_internal.subSlot)(slot, "pip")
285
+ );
286
+ return null;
287
+ }
288
+ function PopoverRootComponent(props) {
289
+ const slot = (0, import_internal.S)("PopoverRoot");
290
+ const {
291
+ children,
292
+ open: openProp,
293
+ defaultOpen = false,
294
+ onOpenChange,
295
+ onOpenChangeComplete,
296
+ modal = false,
297
+ handle,
298
+ actionsRef,
299
+ triggerId: triggerIdProp,
300
+ defaultTriggerId: defaultTriggerIdProp = null
301
+ } = props;
302
+ const store = PopoverStore.useStore(
303
+ handle?.store,
304
+ {
305
+ modal,
306
+ open: defaultOpen,
307
+ openProp,
308
+ activeTriggerId: defaultTriggerIdProp,
309
+ triggerIdProp
310
+ },
311
+ (0, import_internal.subSlot)(slot, "store")
312
+ );
313
+ (0, import_popups.useInitialOpenSync)(
314
+ store,
315
+ openProp,
316
+ defaultOpen,
317
+ defaultTriggerIdProp,
318
+ (0, import_internal.subSlot)(slot, "ios")
319
+ );
320
+ store.useControlledProp("openProp", openProp, (0, import_internal.subSlot)(slot, "cp-open"));
321
+ store.useControlledProp("triggerIdProp", triggerIdProp, (0, import_internal.subSlot)(slot, "cp-tid"));
322
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
323
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
324
+ const payload = store.useState("payload", (0, import_internal.subSlot)(slot, "payload"));
325
+ const nested = (0, import_FloatingTree.useFloatingParentNodeId)() != null;
326
+ store.useContextCallback("onOpenChange", onOpenChange, (0, import_internal.subSlot)(slot, "cc-change"));
327
+ store.useContextCallback(
328
+ "onOpenChangeComplete",
329
+ onOpenChangeComplete,
330
+ (0, import_internal.subSlot)(slot, "cc-complete")
331
+ );
332
+ (0, import_popups.usePopupRootSync)(store, open, (0, import_internal.subSlot)(slot, "rootSync"));
333
+ (0, import_popups.useImplicitActiveTrigger)(store, {}, (0, import_internal.subSlot)(slot, "iat"));
334
+ const { forceUnmount } = (0, import_popups.useOpenStateTransitions)(
335
+ open,
336
+ store,
337
+ () => {
338
+ store.update({ stickIfOpen: true, openChangeReason: null });
339
+ },
340
+ (0, import_internal.subSlot)(slot, "ost")
341
+ );
342
+ store.useSyncedValues({ modal, nested }, (0, import_internal.subSlot)(slot, "sv"));
343
+ (0, import_octane.useEffect)(
344
+ () => {
345
+ if (!open) {
346
+ store.context.stickIfOpenTimeout.clear();
347
+ }
348
+ },
349
+ [store, open],
350
+ (0, import_internal.subSlot)(slot, "e:stick")
351
+ );
352
+ const handleImperativeClose = (0, import_octane.useCallback)(
353
+ () => {
354
+ store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.imperativeAction));
355
+ },
356
+ [store],
357
+ (0, import_internal.subSlot)(slot, "close")
358
+ );
359
+ (0, import_octane.useImperativeHandle)(
360
+ actionsRef,
361
+ () => ({ unmount: forceUnmount, close: handleImperativeClose }),
362
+ [forceUnmount, handleImperativeClose],
363
+ (0, import_internal.subSlot)(slot, "imp")
364
+ );
365
+ const shouldRenderInteractions = open || mounted;
366
+ const contextValue = (0, import_octane.useMemo)(() => ({ store }), [store], (0, import_internal.subSlot)(slot, "ctx"));
367
+ const resolvedChildren = typeof children === "function" && !(0, import_octane.isChildrenBlock)(children) ? children({ payload }) : children;
368
+ const content = [
369
+ shouldRenderInteractions ? (0, import_octane.createElement)(PopoverInteractions, { key: "interactions", store, modal }) : null,
370
+ (0, import_octane.createElement)(import_octane.Fragment, { key: "children", children: resolvedChildren })
371
+ ];
372
+ return (0, import_octane.createElement)(PopoverRootContext.Provider, {
373
+ value: contextValue,
374
+ children: content
375
+ });
376
+ }
377
+ function PopoverRoot(props) {
378
+ const slot = (0, import_internal.S)("PopoverRootWrapper");
379
+ if (usePopoverRootContext(true)) {
380
+ return (0, import_octane.createElement)(PopoverRootComponent, props);
381
+ }
382
+ return (0, import_octane.createElement)(import_FloatingTree.FloatingTree, {
383
+ children: (0, import_octane.createElement)(PopoverRootComponent, props)
384
+ });
385
+ }
386
+ function PopoverTrigger(componentProps) {
387
+ const slot = (0, import_internal.S)("PopoverTrigger");
388
+ const {
389
+ render,
390
+ className,
391
+ style,
392
+ disabled = false,
393
+ nativeButton = true,
394
+ handle,
395
+ payload,
396
+ openOnHover = false,
397
+ delay = OPEN_DELAY,
398
+ closeDelay = 0,
399
+ id: idProp,
400
+ ref,
401
+ ...elementProps
402
+ } = componentProps;
403
+ const rootContext = usePopoverRootContext(true);
404
+ const store = handle?.store ?? rootContext?.store;
405
+ if (!store) {
406
+ throw new Error(
407
+ "Base UI: <Popover.Trigger> must be either used within a <Popover.Root> component or provided with a handle."
408
+ );
409
+ }
410
+ const thisTriggerId = (0, import_useBaseUiId.useBaseUiId)(idProp, (0, import_internal.subSlot)(slot, "id"));
411
+ const isTriggerActive = store.useState("isTriggerActive", (0, import_internal.subSlot)(slot, "ita"), thisTriggerId);
412
+ const floatingContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "fc"));
413
+ const isOpenedByThisTrigger = store.useState(
414
+ "isOpenedByTrigger",
415
+ (0, import_internal.subSlot)(slot, "obt"),
416
+ thisTriggerId
417
+ );
418
+ const popupId = store.useState("triggerPopupId", (0, import_internal.subSlot)(slot, "tpid"), thisTriggerId);
419
+ const triggerElementRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "ter"));
420
+ const { registerTrigger, isMountedByThisTrigger } = (0, import_popups.useTriggerDataForwarding)(
421
+ thisTriggerId,
422
+ triggerElementRef,
423
+ store,
424
+ { payload, disabled, openOnHover, closeDelay },
425
+ (0, import_internal.subSlot)(slot, "tdf")
426
+ );
427
+ const openReason = store.useState("openChangeReason", (0, import_internal.subSlot)(slot, "ocr"));
428
+ const stickIfOpen = store.useState("stickIfOpen", (0, import_internal.subSlot)(slot, "sio"));
429
+ const openMethod = store.useState("openMethod", (0, import_internal.subSlot)(slot, "om"));
430
+ const focusManagerModal = store.useState("focusManagerModal", (0, import_internal.subSlot)(slot, "fmm"));
431
+ const hoverProps = (0, import_useHoverReferenceInteraction.useHoverReferenceInteraction)(
432
+ floatingContext,
433
+ {
434
+ enabled: !disabled && floatingContext != null && openOnHover && (openMethod !== "touch" || openReason !== import_createChangeEventDetails.REASONS.triggerPress),
435
+ mouseOnly: true,
436
+ move: false,
437
+ handleClose: (0, import_useHoverReferenceInteraction.safePolygon)(),
438
+ restMs: delay,
439
+ delay: { close: closeDelay },
440
+ triggerElementRef,
441
+ isActiveTrigger: isTriggerActive,
442
+ isClosing: () => store.select("transitionStatus") === "ending"
443
+ },
444
+ (0, import_internal.subSlot)(slot, "hover")
445
+ );
446
+ const click = (0, import_useClick.useClick)(
447
+ floatingContext,
448
+ { enabled: floatingContext != null, stickIfOpen },
449
+ (0, import_internal.subSlot)(slot, "click")
450
+ );
451
+ const interactionTypeProps = (0, import_useOpenInteractionType.useOpenMethodTriggerProps)(
452
+ () => store.select("open"),
453
+ (interactionType) => {
454
+ store.set("openMethod", interactionType);
455
+ },
456
+ (0, import_internal.subSlot)(slot, "omt")
457
+ );
458
+ const rootTriggerProps = store.useState(
459
+ "triggerProps",
460
+ (0, import_internal.subSlot)(slot, "tp"),
461
+ isMountedByThisTrigger
462
+ );
463
+ const { getButtonProps, buttonRef } = (0, import_useButton.useButton)(
464
+ { disabled, native: nativeButton },
465
+ (0, import_internal.subSlot)(slot, "btn")
466
+ );
467
+ const stateAttributesMapping = {
468
+ open(value) {
469
+ if (value && openReason === import_createChangeEventDetails.REASONS.triggerPress) {
470
+ return import_popupStateMapping2.pressableTriggerOpenStateMapping.open(value);
471
+ }
472
+ return import_popupStateMapping2.triggerOpenStateMapping.open(value);
473
+ }
474
+ };
475
+ const { preFocusGuardRef, handlePreFocusGuardFocus, handleFocusTargetFocus } = (0, import_useTriggerFocusGuards.useTriggerFocusGuards)(store, triggerElementRef, (0, import_internal.subSlot)(slot, "tfg"));
476
+ const state = { disabled, open: isOpenedByThisTrigger };
477
+ const element = (0, import_useRenderElement.useRenderElement)(
478
+ "button",
479
+ { render, className, style },
480
+ {
481
+ state,
482
+ ref: [buttonRef, ref, registerTrigger, triggerElementRef],
483
+ props: [
484
+ click.reference,
485
+ hoverProps,
486
+ rootTriggerProps,
487
+ interactionTypeProps,
488
+ {
489
+ [CLICK_TRIGGER_IDENTIFIER]: "",
490
+ id: thisTriggerId,
491
+ "aria-haspopup": "dialog",
492
+ "aria-expanded": isOpenedByThisTrigger,
493
+ "aria-controls": popupId
494
+ },
495
+ elementProps,
496
+ getButtonProps
497
+ ],
498
+ stateAttributesMapping
499
+ },
500
+ (0, import_internal.subSlot)(slot, "re")
501
+ );
502
+ const keyedElement = (0, import_octane.createElement)(import_octane.Fragment, { key: thisTriggerId, children: element });
503
+ if (isMountedByThisTrigger && !focusManagerModal) {
504
+ return [
505
+ (0, import_octane.createElement)(import_FocusGuard.FocusGuard, {
506
+ key: `${thisTriggerId}-pre-guard`,
507
+ ref: preFocusGuardRef,
508
+ onFocus: handlePreFocusGuardFocus
509
+ }),
510
+ keyedElement,
511
+ (0, import_octane.createElement)(import_FocusGuard.FocusGuard, {
512
+ key: `${thisTriggerId}-post-guard`,
513
+ ref: store.context.triggerFocusTargetRef,
514
+ onFocus: handleFocusTargetFocus
515
+ })
516
+ ];
517
+ }
518
+ return keyedElement;
519
+ }
520
+ function PopoverPortal(props) {
521
+ const slot = (0, import_internal.S)("PopoverPortal");
522
+ const { keepMounted = false, ref, ...portalProps } = props;
523
+ const { store } = usePopoverRootContext();
524
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
525
+ const shouldRender = mounted || keepMounted;
526
+ if (!shouldRender) {
527
+ return null;
528
+ }
529
+ return (0, import_octane.createElement)(PopoverPortalContext.Provider, {
530
+ value: keepMounted,
531
+ children: (0, import_octane.createElement)(import_FloatingPortal.FloatingPortal, { ref, ...portalProps })
532
+ });
533
+ }
534
+ function PopoverPositioner(componentProps) {
535
+ const slot = (0, import_internal.S)("PopoverPositioner");
536
+ const {
537
+ render,
538
+ className,
539
+ style,
540
+ anchor,
541
+ positionMethod = "absolute",
542
+ side = "bottom",
543
+ align = "center",
544
+ sideOffset = 0,
545
+ alignOffset = 0,
546
+ collisionBoundary = "clipping-ancestors",
547
+ collisionPadding = 5,
548
+ arrowPadding = 5,
549
+ sticky = false,
550
+ disableAnchorTracking = false,
551
+ collisionAvoidance = import_constants.POPUP_COLLISION_AVOIDANCE,
552
+ ref,
553
+ ...elementProps
554
+ } = componentProps;
555
+ const { store } = usePopoverRootContext();
556
+ const keepMounted = usePopoverPortalContext();
557
+ const nodeId = (0, import_FloatingTree.useFloatingNodeId)(void 0, (0, import_internal.subSlot)(slot, "nodeId"));
558
+ const floatingRootContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "frc"));
559
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
560
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
561
+ const openReason = store.useState("openChangeReason", (0, import_internal.subSlot)(slot, "reason"));
562
+ const triggerElement = store.useState("activeTriggerElement", (0, import_internal.subSlot)(slot, "trigger"));
563
+ const modal = store.useState("modal", (0, import_internal.subSlot)(slot, "modal"));
564
+ const openMethod = store.useState("openMethod", (0, import_internal.subSlot)(slot, "method"));
565
+ const positionerElement = store.useState("positionerElement", (0, import_internal.subSlot)(slot, "posEl"));
566
+ const instantType = store.useState("instantType", (0, import_internal.subSlot)(slot, "instant"));
567
+ const transitionStatus = store.useState("transitionStatus", (0, import_internal.subSlot)(slot, "trans"));
568
+ const hasViewport = store.useState("hasViewport", (0, import_internal.subSlot)(slot, "viewport"));
569
+ const prevTriggerElementRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "prevTrigger"));
570
+ const runOnceAnimationsFinish = (0, import_useAnimationsFinished.useAnimationsFinished)(
571
+ positionerElement,
572
+ false,
573
+ false,
574
+ (0, import_internal.subSlot)(slot, "anim")
575
+ );
576
+ const positioning = (0, import_useAnchorPositioning.useAnchorPositioning)(
577
+ {
578
+ anchor,
579
+ floatingRootContext,
580
+ positionMethod,
581
+ mounted,
582
+ side,
583
+ sideOffset,
584
+ align,
585
+ alignOffset,
586
+ arrowPadding,
587
+ collisionBoundary,
588
+ collisionPadding,
589
+ sticky,
590
+ disableAnchorTracking,
591
+ keepMounted,
592
+ nodeId,
593
+ collisionAvoidance,
594
+ adaptiveOrigin: hasViewport ? import_adaptiveOriginMiddleware.adaptiveOrigin : void 0
595
+ },
596
+ (0, import_internal.subSlot)(slot, "positioning")
597
+ );
598
+ const domReference = floatingRootContext.useState("domReferenceElement", (0, import_internal.subSlot)(slot, "domref"));
599
+ (0, import_octane.useLayoutEffect)(
600
+ () => {
601
+ const currentTriggerElement = domReference;
602
+ const prevTriggerElement = prevTriggerElementRef.current;
603
+ if (currentTriggerElement) {
604
+ prevTriggerElementRef.current = currentTriggerElement;
605
+ }
606
+ if (prevTriggerElement && currentTriggerElement && currentTriggerElement !== prevTriggerElement) {
607
+ store.set("instantType", void 0);
608
+ const ac = new AbortController();
609
+ runOnceAnimationsFinish(() => {
610
+ store.set("instantType", "trigger-change");
611
+ }, ac.signal);
612
+ return () => {
613
+ ac.abort();
614
+ };
615
+ }
616
+ return void 0;
617
+ },
618
+ [domReference, runOnceAnimationsFinish, store],
619
+ (0, import_internal.subSlot)(slot, "e:trigger")
620
+ );
621
+ (0, import_useAnchoredPopupScrollLock.useAnchoredPopupScrollLock)(
622
+ open && modal === true && openReason !== import_createChangeEventDetails.REASONS.triggerHover,
623
+ openMethod === "touch",
624
+ positionerElement,
625
+ triggerElement
626
+ );
627
+ const setPositionerElement = (0, import_octane.useCallback)(
628
+ (element2) => {
629
+ store.set("positionerElement", element2);
630
+ },
631
+ [store],
632
+ (0, import_internal.subSlot)(slot, "setPosEl")
633
+ );
634
+ const state = {
635
+ open,
636
+ side: positioning.side,
637
+ align: positioning.align,
638
+ anchorHidden: positioning.anchorHidden,
639
+ instant: instantType
640
+ };
641
+ const element = (0, import_usePositioner.usePositioner)(
642
+ componentProps,
643
+ state,
644
+ {
645
+ styles: positioning.positionerStyles,
646
+ transitionStatus,
647
+ props: elementProps,
648
+ refs: [ref, setPositionerElement],
649
+ hidden: !mounted,
650
+ inert: !open
651
+ },
652
+ (0, import_internal.subSlot)(slot, "positioner")
653
+ );
654
+ return (0, import_octane.createElement)(PopoverPositionerContext.Provider, {
655
+ value: positioning,
656
+ // Octane reconciles an ARRAY child as a keyed list, so both slots carry a key. Only the
657
+ // modal path renders the backdrop, which is why a non-modal popover never warned.
658
+ children: [
659
+ mounted && modal === true && openReason !== import_createChangeEventDetails.REASONS.triggerHover ? (0, import_octane.createElement)(import_InternalBackdrop.InternalBackdrop, {
660
+ key: "internal-backdrop",
661
+ ref: store.context.internalBackdropRef,
662
+ inert: (0, import_inertValue.inertValue)(!open),
663
+ cutout: triggerElement
664
+ }) : null,
665
+ (0, import_octane.createElement)(import_FloatingTree.FloatingNode, { key: "floating-node", id: nodeId, children: element })
666
+ ]
667
+ });
668
+ }
669
+ const popoverPopupStateAttributesMapping = {
670
+ ...import_popupStateMapping.popupStateMapping,
671
+ ...import_useTransitionStatus.transitionStatusMapping
672
+ };
673
+ function PopoverPopup(componentProps) {
674
+ const slot = (0, import_internal.S)("PopoverPopup");
675
+ const { render, className, style, initialFocus, finalFocus, ref, ...elementProps } = componentProps;
676
+ const { store } = usePopoverRootContext();
677
+ const positioner = usePopoverPositionerContext();
678
+ const insideToolbar = false;
679
+ const { context: closePartContext, hasClosePart } = (0, import_closePart.useClosePartCount)();
680
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
681
+ const openMethod = store.useState("openMethod", (0, import_internal.subSlot)(slot, "method"));
682
+ const instantType = store.useState("instantType", (0, import_internal.subSlot)(slot, "instant"));
683
+ const transitionStatus = store.useState("transitionStatus", (0, import_internal.subSlot)(slot, "trans"));
684
+ const popupProps = store.useState("popupProps", (0, import_internal.subSlot)(slot, "popupProps"));
685
+ const titleId = store.useState("titleElementId", (0, import_internal.subSlot)(slot, "titleId"));
686
+ const descriptionId = store.useState("descriptionElementId", (0, import_internal.subSlot)(slot, "descId"));
687
+ const modal = store.useState("modal", (0, import_internal.subSlot)(slot, "modal"));
688
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
689
+ const openReason = store.useState("openChangeReason", (0, import_internal.subSlot)(slot, "reason"));
690
+ const activeTriggerElement = store.useState("activeTriggerElement", (0, import_internal.subSlot)(slot, "trigger"));
691
+ const floatingContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "frc"));
692
+ const floatingId = floatingContext.useState("floatingId", (0, import_internal.subSlot)(slot, "fid"));
693
+ const disabled = store.useState("disabled", (0, import_internal.subSlot)(slot, "disabled"));
694
+ const openOnHover = store.useState("openOnHover", (0, import_internal.subSlot)(slot, "hover"));
695
+ const closeDelay = store.useState("closeDelay", (0, import_internal.subSlot)(slot, "closeDelay"));
696
+ const popupId = elementProps.id ?? floatingId;
697
+ (0, import_useOpenChangeComplete.useOpenChangeComplete)(
698
+ {
699
+ open,
700
+ ref: store.context.popupRef,
701
+ onComplete() {
702
+ if (open) {
703
+ store.context.onOpenChangeComplete?.(true);
704
+ }
705
+ }
706
+ },
707
+ (0, import_internal.subSlot)(slot, "occ")
708
+ );
709
+ (0, import_useHoverFloatingInteraction.useHoverFloatingInteraction)(
710
+ floatingContext,
711
+ { enabled: openOnHover && !disabled, closeDelay },
712
+ (0, import_internal.subSlot)(slot, "hoverInteraction")
713
+ );
714
+ const resolvedInitialFocus = initialFocus === void 0 ? (0, import_popups.createDefaultInitialFocus)(store.context.popupRef) : initialFocus;
715
+ const focusManagerModal = modal !== false && hasClosePart;
716
+ store.useSyncedValue("focusManagerModal", focusManagerModal, (0, import_internal.subSlot)(slot, "fmm"));
717
+ const setPopupElement = (0, import_octane.useCallback)(
718
+ (element2) => {
719
+ store.set("popupElement", element2);
720
+ },
721
+ [store],
722
+ (0, import_internal.subSlot)(slot, "setPopupEl")
723
+ );
724
+ const state = {
725
+ open,
726
+ side: positioner.side,
727
+ align: positioner.align,
728
+ instant: instantType,
729
+ transitionStatus
730
+ };
731
+ const element = (0, import_useRenderElement.useRenderElement)(
732
+ "div",
733
+ componentProps,
734
+ {
735
+ state,
736
+ ref: [ref, store.context.popupRef, setPopupElement],
737
+ props: [
738
+ popupProps,
739
+ {
740
+ id: popupId,
741
+ role: "dialog",
742
+ ...import_popups.FOCUSABLE_POPUP_PROPS,
743
+ "aria-labelledby": titleId,
744
+ "aria-describedby": descriptionId,
745
+ onKeyDown(event) {
746
+ if (insideToolbar && import_keys.COMPOSITE_KEYS.has(event.key)) {
747
+ event.stopPropagation();
748
+ }
749
+ }
750
+ },
751
+ (0, import_getDisabledMountTransitionStyles.getDisabledMountTransitionStyles)(transitionStatus),
752
+ elementProps
753
+ ],
754
+ stateAttributesMapping: popoverPopupStateAttributesMapping
755
+ },
756
+ (0, import_internal.subSlot)(slot, "re")
757
+ );
758
+ return (0, import_octane.createElement)(import_FloatingFocusManager.FloatingFocusManager, {
759
+ context: floatingContext,
760
+ openInteractionType: openMethod,
761
+ modal: focusManagerModal,
762
+ disabled: !mounted || openReason === import_createChangeEventDetails.REASONS.triggerHover,
763
+ initialFocus: resolvedInitialFocus,
764
+ returnFocus: finalFocus,
765
+ restoreFocus: "popup",
766
+ previousFocusableElement: (0, import_dom.isHTMLElement)(activeTriggerElement) ? activeTriggerElement : void 0,
767
+ nextFocusableElement: store.context.triggerFocusTargetRef,
768
+ beforeContentFocusGuardRef: store.context.beforeContentFocusGuardRef,
769
+ children: (0, import_octane.createElement)(import_closePart.ClosePartProvider, { value: closePartContext, children: element })
770
+ });
771
+ }
772
+ function PopoverArrow(componentProps) {
773
+ const slot = (0, import_internal.S)("PopoverArrow");
774
+ const { render, className, style, ref, ...elementProps } = componentProps;
775
+ const { store } = usePopoverRootContext();
776
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
777
+ const { arrowRef, side, align, arrowUncentered, arrowStyles } = usePopoverPositionerContext();
778
+ const state = {
779
+ open,
780
+ side,
781
+ align,
782
+ uncentered: arrowUncentered
783
+ };
784
+ return (0, import_useRenderElement.useRenderElement)(
785
+ "div",
786
+ componentProps,
787
+ {
788
+ state,
789
+ ref: [ref, arrowRef],
790
+ props: [{ style: arrowStyles, "aria-hidden": true }, elementProps],
791
+ stateAttributesMapping: import_popupStateMapping.popupStateMapping
792
+ },
793
+ (0, import_internal.subSlot)(slot, "re")
794
+ );
795
+ }
796
+ const popoverBackdropStateAttributesMapping = {
797
+ ...import_popupStateMapping.popupStateMapping,
798
+ ...import_useTransitionStatus.transitionStatusMapping
799
+ };
800
+ function PopoverBackdrop(props) {
801
+ const slot = (0, import_internal.S)("PopoverBackdrop");
802
+ const { render, className, style, ref, ...elementProps } = props;
803
+ const { store } = usePopoverRootContext();
804
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
805
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
806
+ const transitionStatus = store.useState("transitionStatus", (0, import_internal.subSlot)(slot, "trans"));
807
+ const openReason = store.useState("openChangeReason", (0, import_internal.subSlot)(slot, "reason"));
808
+ const state = {
809
+ open,
810
+ transitionStatus
811
+ };
812
+ return (0, import_useRenderElement.useRenderElement)(
813
+ "div",
814
+ props,
815
+ {
816
+ state,
817
+ ref: [store.context.backdropRef, ref],
818
+ props: [
819
+ {
820
+ role: "presentation",
821
+ hidden: !mounted,
822
+ style: {
823
+ pointerEvents: openReason === import_createChangeEventDetails.REASONS.triggerHover ? "none" : void 0,
824
+ userSelect: "none",
825
+ WebkitUserSelect: "none"
826
+ }
827
+ },
828
+ elementProps
829
+ ],
830
+ stateAttributesMapping: popoverBackdropStateAttributesMapping
831
+ },
832
+ (0, import_internal.subSlot)(slot, "re")
833
+ );
834
+ }
835
+ function PopoverTitle(componentProps) {
836
+ const slot = (0, import_internal.S)("PopoverTitle");
837
+ const { render, className, style, ref, ...elementProps } = componentProps;
838
+ const { store } = usePopoverRootContext();
839
+ const id = (0, import_useBaseUiId.useBaseUiId)(elementProps.id, (0, import_internal.subSlot)(slot, "id"));
840
+ store.useSyncedValueWithCleanup("titleElementId", id, (0, import_internal.subSlot)(slot, "sync"));
841
+ return (0, import_useRenderElement.useRenderElement)(
842
+ "h2",
843
+ componentProps,
844
+ {
845
+ ref,
846
+ props: [{ id }, elementProps]
847
+ },
848
+ (0, import_internal.subSlot)(slot, "re")
849
+ );
850
+ }
851
+ function PopoverDescription(componentProps) {
852
+ const slot = (0, import_internal.S)("PopoverDescription");
853
+ const { render, className, style, ref, ...elementProps } = componentProps;
854
+ const { store } = usePopoverRootContext();
855
+ const id = (0, import_useBaseUiId.useBaseUiId)(elementProps.id, (0, import_internal.subSlot)(slot, "id"));
856
+ store.useSyncedValueWithCleanup("descriptionElementId", id, (0, import_internal.subSlot)(slot, "sync"));
857
+ return (0, import_useRenderElement.useRenderElement)(
858
+ "p",
859
+ componentProps,
860
+ {
861
+ ref,
862
+ props: [{ id }, elementProps]
863
+ },
864
+ (0, import_internal.subSlot)(slot, "re")
865
+ );
866
+ }
867
+ function PopoverClose(componentProps) {
868
+ const slot = (0, import_internal.S)("PopoverClose");
869
+ const {
870
+ render,
871
+ className,
872
+ style,
873
+ disabled = false,
874
+ nativeButton = true,
875
+ ref,
876
+ ...elementProps
877
+ } = componentProps;
878
+ const { buttonRef, getButtonProps } = (0, import_useButton.useButton)(
879
+ { disabled, focusableWhenDisabled: false, native: nativeButton },
880
+ (0, import_internal.subSlot)(slot, "btn")
881
+ );
882
+ const { store } = usePopoverRootContext();
883
+ (0, import_closePart.useClosePartRegistration)();
884
+ return (0, import_useRenderElement.useRenderElement)(
885
+ "button",
886
+ componentProps,
887
+ {
888
+ ref: [ref, buttonRef],
889
+ props: [
890
+ {
891
+ onClick(event) {
892
+ store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.closePress, event));
893
+ }
894
+ },
895
+ elementProps,
896
+ getButtonProps
897
+ ]
898
+ },
899
+ (0, import_internal.subSlot)(slot, "re")
900
+ );
901
+ }
902
+ const PopoverViewportCssVars = {
903
+ /**
904
+ * The width of the parent popup when the previous content was rendered. Placed on the
905
+ * 'previous' container so the popup's dimensions can be frozen while content animates.
906
+ */
907
+ popupWidth: "--popup-width",
908
+ /** The height of the parent popup when the previous content was rendered. */
909
+ popupHeight: "--popup-height"
910
+ };
911
+ const viewportStateAttributesMapping = {
912
+ activationDirection: (value) => value ? { "data-activation-direction": value } : null
913
+ };
914
+ function PopoverViewport(componentProps) {
915
+ const slot = (0, import_internal.S)("PopoverViewport");
916
+ const { render, className, style, children, ref, ...elementProps } = componentProps;
917
+ const { store } = usePopoverRootContext();
918
+ const { side } = usePopoverPositionerContext();
919
+ const instantType = store.useState("instantType", (0, import_internal.subSlot)(slot, "instant"));
920
+ const { children: childrenToRender, state: viewportState } = (0, import_usePopupViewport.usePopupViewport)(
921
+ { store, side, cssVars: PopoverViewportCssVars, children },
922
+ (0, import_internal.subSlot)(slot, "vp")
923
+ );
924
+ const state = {
925
+ activationDirection: viewportState.activationDirection,
926
+ transitioning: viewportState.transitioning,
927
+ instant: instantType
928
+ };
929
+ return (0, import_useRenderElement.useRenderElement)(
930
+ "div",
931
+ { render, className, style },
932
+ {
933
+ state,
934
+ ref,
935
+ props: [elementProps, { children: childrenToRender }],
936
+ stateAttributesMapping: viewportStateAttributesMapping
937
+ },
938
+ (0, import_internal.subSlot)(slot, "re")
939
+ );
940
+ }
941
+ const Popover = {
942
+ Root: PopoverRoot,
943
+ Trigger: PopoverTrigger,
944
+ Portal: PopoverPortal,
945
+ Positioner: PopoverPositioner,
946
+ Popup: PopoverPopup,
947
+ Viewport: PopoverViewport,
948
+ Arrow: PopoverArrow,
949
+ Backdrop: PopoverBackdrop,
950
+ Title: PopoverTitle,
951
+ Description: PopoverDescription,
952
+ Close: PopoverClose,
953
+ createHandle: createPopoverHandle,
954
+ Handle: PopoverHandle
955
+ };
956
+ // Annotate the CommonJS export names for ESM import in node:
957
+ 0 && (module.exports = {
958
+ Popover,
959
+ PopoverHandle,
960
+ PopoverStore,
961
+ PopoverViewportCssVars,
962
+ createPopoverHandle,
963
+ usePopoverPortalContext,
964
+ usePopoverPositionerContext,
965
+ usePopoverRootContext
966
+ });