@octanejs/base-ui 0.1.30 → 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,741 @@
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 dialog_exports = {};
20
+ __export(dialog_exports, {
21
+ Dialog: () => Dialog,
22
+ DialogHandle: () => DialogHandle,
23
+ DialogStore: () => DialogStore,
24
+ DialogViewportDataAttributes: () => DialogViewportDataAttributes,
25
+ createDialogHandle: () => createDialogHandle,
26
+ useDialogRootContext: () => useDialogRootContext,
27
+ useRenderDialogRoot: () => useRenderDialogRoot
28
+ });
29
+ module.exports = __toCommonJS(dialog_exports);
30
+ var import_octane = require("octane");
31
+ var import_FloatingFocusManager = require("./utils/floating/FloatingFocusManager.cjs");
32
+ var import_FloatingPortal = require("./utils/floating/FloatingPortal.cjs");
33
+ var import_internal = require("./internal.cjs");
34
+ var import_useRenderElement = require("./utils/useRenderElement.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_ReactStore = require("./utils/store/ReactStore.cjs");
39
+ var import_createSelector = require("./utils/store/createSelector.cjs");
40
+ var import_useClick = require("./utils/floating/useClick.cjs");
41
+ var import_useDismiss = require("./utils/floating/useDismiss.cjs");
42
+ var import_useScrollLock = require("./utils/useScrollLock.cjs");
43
+ var import_useOpenChangeComplete = require("./utils/useOpenChangeComplete.cjs");
44
+ var import_useOpenInteractionType = require("./utils/useOpenInteractionType.cjs");
45
+ var import_popupStateMapping = require("./utils/popupStateMapping.cjs");
46
+ var import_useTransitionStatus = require("./utils/useTransitionStatus.cjs");
47
+ var import_empty = require("./utils/empty.cjs");
48
+ var import_inertValue = require("./utils/inertValue.cjs");
49
+ var import_InternalBackdrop = require("./utils/InternalBackdrop.cjs");
50
+ var import_element = require("./utils/floating/element.cjs");
51
+ var import_keys = require("./utils/composite/keys.cjs");
52
+ var import_popups = require("./utils/popups/index.cjs");
53
+ var import_popupTriggerMap = require("./utils/popups/popupTriggerMap.cjs");
54
+ const CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger";
55
+ const popupStateAttributesMapping = {
56
+ ...import_popupStateMapping.popupStateMapping,
57
+ ...import_useTransitionStatus.transitionStatusMapping
58
+ };
59
+ const dialogSelectors = {
60
+ ...import_popups.popupStoreSelectors,
61
+ modal: (0, import_createSelector.createSelector)((state) => state.modal),
62
+ nested: (0, import_createSelector.createSelector)((state) => state.nested),
63
+ nestedOpenDialogCount: (0, import_createSelector.createSelector)(
64
+ (state) => state.nestedOpenDialogCount
65
+ ),
66
+ nestedOpenDrawerCount: (0, import_createSelector.createSelector)(
67
+ (state) => state.nestedOpenDrawerCount
68
+ ),
69
+ disablePointerDismissal: (0, import_createSelector.createSelector)(
70
+ (state) => state.disablePointerDismissal
71
+ ),
72
+ openMethod: (0, import_createSelector.createSelector)((state) => state.openMethod),
73
+ descriptionElementId: (0, import_createSelector.createSelector)((state) => state.descriptionElementId),
74
+ titleElementId: (0, import_createSelector.createSelector)((state) => state.titleElementId),
75
+ viewportElement: (0, import_createSelector.createSelector)((state) => state.viewportElement),
76
+ role: (0, import_createSelector.createSelector)((state) => state.role)
77
+ };
78
+ function createInitialDialogState(initialState = {}) {
79
+ return {
80
+ ...(0, import_popups.createInitialPopupStoreState)(),
81
+ modal: true,
82
+ disablePointerDismissal: false,
83
+ popupElement: null,
84
+ viewportElement: null,
85
+ descriptionElementId: void 0,
86
+ titleElementId: void 0,
87
+ openMethod: null,
88
+ nested: false,
89
+ nestedOpenDialogCount: 0,
90
+ nestedOpenDrawerCount: 0,
91
+ role: "dialog",
92
+ ...initialState
93
+ };
94
+ }
95
+ class DialogStore extends import_ReactStore.ReactStore {
96
+ constructor(initialState, floatingId, nested = false) {
97
+ const triggerElements = new import_popupTriggerMap.PopupTriggerMap();
98
+ const state = createInitialDialogState(initialState);
99
+ state.floatingRootContext = (0, import_popups.createPopupFloatingRootContext)(triggerElements, floatingId, nested);
100
+ super(
101
+ state,
102
+ {
103
+ popupRef: { current: null },
104
+ backdropRef: { current: null },
105
+ internalBackdropRef: { current: null },
106
+ outsidePressEnabledRef: { current: true },
107
+ triggerElements,
108
+ onOpenChange: void 0,
109
+ onOpenChangeComplete: void 0
110
+ },
111
+ dialogSelectors
112
+ );
113
+ }
114
+ setOpen = (nextOpen, eventDetails) => {
115
+ eventDetails.preventUnmountOnClose = () => {
116
+ this.set("preventUnmountingOnClose", true);
117
+ };
118
+ if (!nextOpen && eventDetails.trigger == null && this.state.activeTriggerId != null) {
119
+ eventDetails.trigger = this.state.activeTriggerElement ?? void 0;
120
+ }
121
+ this.context.onOpenChange?.(nextOpen, eventDetails);
122
+ if (eventDetails.isCanceled) {
123
+ return;
124
+ }
125
+ this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
126
+ const updatedState = { open: nextOpen };
127
+ (0, import_popups.setPopupOpenState)(updatedState, nextOpen, eventDetails.trigger);
128
+ this.update(updatedState);
129
+ };
130
+ static useStore(externalStore, initialState, slot) {
131
+ return (0, import_popups.usePopupStore)(
132
+ externalStore,
133
+ (floatingId, nested) => new DialogStore(initialState, floatingId, nested),
134
+ true,
135
+ slot
136
+ ).store;
137
+ }
138
+ }
139
+ class DialogHandle {
140
+ store;
141
+ constructor(store) {
142
+ this.store = store ?? new DialogStore();
143
+ }
144
+ open(triggerId) {
145
+ const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
146
+ this.store.setOpen(
147
+ true,
148
+ (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.imperativeAction, void 0, triggerElement)
149
+ );
150
+ }
151
+ openWithPayload(payload) {
152
+ this.store.set("payload", payload);
153
+ this.store.setOpen(
154
+ true,
155
+ (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.imperativeAction, void 0, void 0)
156
+ );
157
+ }
158
+ close() {
159
+ this.store.setOpen(
160
+ false,
161
+ (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.imperativeAction, void 0, void 0)
162
+ );
163
+ }
164
+ get isOpen() {
165
+ return this.store.select("open");
166
+ }
167
+ }
168
+ function createDialogHandle() {
169
+ return new DialogHandle();
170
+ }
171
+ const IsDrawerContext = (0, import_octane.createContext)(false);
172
+ const DialogRootContext = (0, import_octane.createContext)(void 0);
173
+ function useDialogRootContext(optional) {
174
+ const dialogRootContext = (0, import_octane.useContext)(DialogRootContext);
175
+ if (optional === false && dialogRootContext === void 0) {
176
+ throw new Error(
177
+ "Base UI: DialogRootContext is missing. Dialog parts must be placed within <Dialog.Root>."
178
+ );
179
+ }
180
+ return dialogRootContext;
181
+ }
182
+ function useDialogRoot(params, slot) {
183
+ const { store, actionsRef } = params;
184
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
185
+ (0, import_popups.usePopupRootSync)(store, open, (0, import_internal.subSlot)(slot, "rootSync"));
186
+ (0, import_popups.useImplicitActiveTrigger)(store, {}, (0, import_internal.subSlot)(slot, "iat"));
187
+ const { forceUnmount } = (0, import_popups.useOpenStateTransitions)(
188
+ open,
189
+ store,
190
+ void 0,
191
+ (0, import_internal.subSlot)(slot, "ost")
192
+ );
193
+ const handleImperativeClose = (0, import_octane.useCallback)(
194
+ () => {
195
+ store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.imperativeAction));
196
+ },
197
+ [store],
198
+ (0, import_internal.subSlot)(slot, "close")
199
+ );
200
+ (0, import_octane.useImperativeHandle)(
201
+ actionsRef,
202
+ () => ({ unmount: forceUnmount, close: handleImperativeClose }),
203
+ [forceUnmount, handleImperativeClose],
204
+ (0, import_internal.subSlot)(slot, "imp")
205
+ );
206
+ }
207
+ function DialogInteractions(props) {
208
+ const slot = (0, import_internal.S)("DialogInteractions");
209
+ const { store, parentContext, isDrawer } = props;
210
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
211
+ const disablePointerDismissal = store.useState("disablePointerDismissal", (0, import_internal.subSlot)(slot, "dpd"));
212
+ const modal = store.useState("modal", (0, import_internal.subSlot)(slot, "modal"));
213
+ const popupElement = store.useState("popupElement", (0, import_internal.subSlot)(slot, "pel"));
214
+ const floatingRootContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "frc"));
215
+ const [ownNestedOpenDialogs, setOwnNestedOpenDialogs] = (0, import_octane.useState)(0, (0, import_internal.subSlot)(slot, "nod"));
216
+ const [ownNestedOpenDrawers, setOwnNestedOpenDrawers] = (0, import_octane.useState)(0, (0, import_internal.subSlot)(slot, "ndr"));
217
+ const isTopmost = ownNestedOpenDialogs === 0;
218
+ const dismiss = (0, import_useDismiss.useDismiss)(
219
+ floatingRootContext,
220
+ {
221
+ outsidePressEvent() {
222
+ if (store.context.internalBackdropRef.current || store.context.backdropRef.current) {
223
+ return "intentional";
224
+ }
225
+ return {
226
+ mouse: modal === "trap-focus" ? "sloppy" : "intentional",
227
+ touch: "sloppy"
228
+ };
229
+ },
230
+ outsidePress(event) {
231
+ if (!store.context.outsidePressEnabledRef.current) {
232
+ return false;
233
+ }
234
+ if ("button" in event && event.button !== 0) {
235
+ return false;
236
+ }
237
+ if ("touches" in event && event.touches.length !== 1) {
238
+ return false;
239
+ }
240
+ const target = (0, import_element.getTarget)(event);
241
+ if (isTopmost && !disablePointerDismissal) {
242
+ if (modal) {
243
+ return store.context.internalBackdropRef.current || store.context.backdropRef.current ? store.context.internalBackdropRef.current === target || store.context.backdropRef.current === target || (0, import_element.contains)(target, popupElement) && !target?.hasAttribute("data-base-ui-portal") : true;
244
+ }
245
+ return true;
246
+ }
247
+ return false;
248
+ },
249
+ escapeKey: isTopmost
250
+ },
251
+ (0, import_internal.subSlot)(slot, "dismiss")
252
+ );
253
+ (0, import_useScrollLock.useScrollLock)(open && modal === true, popupElement, (0, import_internal.subSlot)(slot, "scroll"));
254
+ store.useContextCallback(
255
+ "onNestedDialogOpen",
256
+ (dialogCount, drawerCount) => {
257
+ setOwnNestedOpenDialogs(dialogCount);
258
+ setOwnNestedOpenDrawers(drawerCount);
259
+ },
260
+ (0, import_internal.subSlot)(slot, "cc-open")
261
+ );
262
+ store.useContextCallback(
263
+ "onNestedDialogClose",
264
+ () => {
265
+ setOwnNestedOpenDialogs(0);
266
+ setOwnNestedOpenDrawers(0);
267
+ },
268
+ (0, import_internal.subSlot)(slot, "cc-close")
269
+ );
270
+ (0, import_octane.useEffect)(
271
+ () => {
272
+ if (parentContext?.onNestedDialogOpen && open) {
273
+ parentContext.onNestedDialogOpen(
274
+ ownNestedOpenDialogs + 1,
275
+ ownNestedOpenDrawers + (isDrawer ? 1 : 0)
276
+ );
277
+ }
278
+ if (parentContext?.onNestedDialogClose && !open) {
279
+ parentContext.onNestedDialogClose();
280
+ }
281
+ return () => {
282
+ if (parentContext?.onNestedDialogClose && open) {
283
+ parentContext.onNestedDialogClose();
284
+ }
285
+ };
286
+ },
287
+ [isDrawer, open, ownNestedOpenDialogs, ownNestedOpenDrawers, parentContext],
288
+ (0, import_internal.subSlot)(slot, "e:parent")
289
+ );
290
+ const activeTriggerProps = dismiss.reference ?? import_empty.EMPTY_OBJECT;
291
+ const inactiveTriggerProps = dismiss.trigger ?? import_empty.EMPTY_OBJECT;
292
+ const popupProps = dismiss.floating ?? import_empty.EMPTY_OBJECT;
293
+ (0, import_popups.usePopupInteractionProps)(
294
+ store,
295
+ {
296
+ activeTriggerProps,
297
+ inactiveTriggerProps,
298
+ popupProps,
299
+ nestedOpenDialogCount: ownNestedOpenDialogs,
300
+ nestedOpenDrawerCount: ownNestedOpenDrawers
301
+ },
302
+ (0, import_internal.subSlot)(slot, "pip")
303
+ );
304
+ return null;
305
+ }
306
+ function useRenderDialogRoot(props, mode) {
307
+ const slot = (0, import_internal.S)("DialogRoot");
308
+ const {
309
+ children,
310
+ open: openProp,
311
+ defaultOpen = false,
312
+ onOpenChange,
313
+ onOpenChangeComplete,
314
+ disablePointerDismissal: disablePointerDismissalProp = false,
315
+ modal: modalProp = true,
316
+ actionsRef,
317
+ handle,
318
+ triggerId: triggerIdProp,
319
+ defaultTriggerId: defaultTriggerIdProp = null
320
+ } = props;
321
+ const isDrawer = mode === "drawer";
322
+ const isAlertDialog = mode === "alert-dialog";
323
+ const modal = isAlertDialog ? true : modalProp;
324
+ const disablePointerDismissal = isAlertDialog || disablePointerDismissalProp;
325
+ const role = isAlertDialog ? "alertdialog" : "dialog";
326
+ const parentDialogRootContext = useDialogRootContext(true);
327
+ const nested = Boolean(parentDialogRootContext);
328
+ const rootState = { modal, disablePointerDismissal, nested, role };
329
+ const store = DialogStore.useStore(
330
+ handle?.store,
331
+ {
332
+ open: defaultOpen,
333
+ openProp,
334
+ activeTriggerId: defaultTriggerIdProp,
335
+ triggerIdProp,
336
+ ...rootState
337
+ },
338
+ (0, import_internal.subSlot)(slot, "store")
339
+ );
340
+ store.useControlledProp("openProp", openProp, (0, import_internal.subSlot)(slot, "cp-open"));
341
+ store.useControlledProp("triggerIdProp", triggerIdProp, (0, import_internal.subSlot)(slot, "cp-tid"));
342
+ store.useSyncedValues(rootState, (0, import_internal.subSlot)(slot, "sv-root"));
343
+ store.useContextCallback("onOpenChange", onOpenChange, (0, import_internal.subSlot)(slot, "cc-change"));
344
+ store.useContextCallback(
345
+ "onOpenChangeComplete",
346
+ onOpenChangeComplete,
347
+ (0, import_internal.subSlot)(slot, "cc-complete")
348
+ );
349
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
350
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
351
+ const payload = store.useState("payload", (0, import_internal.subSlot)(slot, "payload"));
352
+ useDialogRoot({ store, actionsRef }, (0, import_internal.subSlot)(slot, "root"));
353
+ const shouldRenderInteractions = open || mounted;
354
+ const contextValue = (0, import_octane.useMemo)(() => ({ store }), [store], (0, import_internal.subSlot)(slot, "ctx"));
355
+ const resolvedChildren = typeof children === "function" && !(0, import_octane.isChildrenBlock)(children) ? children({ payload }) : children;
356
+ const content = [
357
+ shouldRenderInteractions ? (0, import_octane.createElement)(DialogInteractions, {
358
+ key: "interactions",
359
+ store,
360
+ parentContext: parentDialogRootContext?.store.context,
361
+ isDrawer
362
+ }) : null,
363
+ (0, import_octane.createElement)(import_octane.Fragment, { key: "children", children: resolvedChildren })
364
+ ];
365
+ return (0, import_octane.createElement)(IsDrawerContext.Provider, {
366
+ value: false,
367
+ children: (0, import_octane.createElement)(DialogRootContext.Provider, {
368
+ value: contextValue,
369
+ children: content
370
+ })
371
+ });
372
+ }
373
+ function DialogRoot(props) {
374
+ const mode = (0, import_octane.useContext)(IsDrawerContext) ? "drawer" : "dialog";
375
+ return useRenderDialogRoot(props, mode);
376
+ }
377
+ function DialogTrigger(componentProps) {
378
+ const slot = (0, import_internal.S)("DialogTrigger");
379
+ const {
380
+ render,
381
+ className,
382
+ style,
383
+ disabled = false,
384
+ nativeButton = true,
385
+ id: idProp,
386
+ payload,
387
+ handle,
388
+ ref,
389
+ ...elementProps
390
+ } = componentProps;
391
+ const dialogRootContext = useDialogRootContext(true);
392
+ const store = handle?.store ?? dialogRootContext?.store;
393
+ if (!store) {
394
+ throw new Error(
395
+ "Base UI: <Dialog.Trigger> must be used within <Dialog.Root> or provided with a handle."
396
+ );
397
+ }
398
+ const thisTriggerId = (0, import_useBaseUiId.useBaseUiId)(idProp, (0, import_internal.subSlot)(slot, "id"));
399
+ const floatingContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "fc"));
400
+ const isOpenedByThisTrigger = store.useState(
401
+ "isOpenedByTrigger",
402
+ (0, import_internal.subSlot)(slot, "obt"),
403
+ thisTriggerId
404
+ );
405
+ const popupId = store.useState("triggerPopupId", (0, import_internal.subSlot)(slot, "tpid"), thisTriggerId);
406
+ const triggerElementRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "ter"));
407
+ const { registerTrigger, isMountedByThisTrigger } = (0, import_popups.useTriggerDataForwarding)(
408
+ thisTriggerId,
409
+ triggerElementRef,
410
+ store,
411
+ { payload },
412
+ (0, import_internal.subSlot)(slot, "tdf")
413
+ );
414
+ const { getButtonProps, buttonRef } = (0, import_useButton.useButton)(
415
+ { disabled, native: nativeButton },
416
+ (0, import_internal.subSlot)(slot, "btn")
417
+ );
418
+ const click = (0, import_useClick.useClick)(
419
+ floatingContext,
420
+ { enabled: floatingContext != null },
421
+ (0, import_internal.subSlot)(slot, "click")
422
+ );
423
+ const interactionTypeProps = (0, import_useOpenInteractionType.useOpenMethodTriggerProps)(
424
+ () => store.select("open"),
425
+ (interactionType) => {
426
+ store.set("openMethod", interactionType);
427
+ },
428
+ (0, import_internal.subSlot)(slot, "omt")
429
+ );
430
+ const state = { disabled, open: isOpenedByThisTrigger };
431
+ const rootTriggerProps = store.useState(
432
+ "triggerProps",
433
+ (0, import_internal.subSlot)(slot, "tp"),
434
+ isMountedByThisTrigger
435
+ );
436
+ return (0, import_useRenderElement.useRenderElement)(
437
+ "button",
438
+ { render, className, style },
439
+ {
440
+ state,
441
+ ref: [buttonRef, ref, registerTrigger, triggerElementRef],
442
+ props: [
443
+ click.reference,
444
+ rootTriggerProps,
445
+ interactionTypeProps,
446
+ {
447
+ [CLICK_TRIGGER_IDENTIFIER]: "",
448
+ id: thisTriggerId,
449
+ "aria-haspopup": "dialog",
450
+ "aria-expanded": isOpenedByThisTrigger,
451
+ "aria-controls": popupId
452
+ },
453
+ elementProps,
454
+ getButtonProps
455
+ ],
456
+ stateAttributesMapping: import_popupStateMapping.triggerOpenStateMapping
457
+ },
458
+ (0, import_internal.subSlot)(slot, "re")
459
+ );
460
+ }
461
+ const DialogPortalContext = (0, import_octane.createContext)(void 0);
462
+ function useDialogPortalContext() {
463
+ const value = (0, import_octane.useContext)(DialogPortalContext);
464
+ if (value === void 0) {
465
+ throw new Error("Base UI: <Dialog.Portal> is missing.");
466
+ }
467
+ return value;
468
+ }
469
+ function DialogPortal(props) {
470
+ const slot = (0, import_internal.S)("DialogPortal");
471
+ const { keepMounted = false, container, children, ...portalProps } = props;
472
+ const { store } = useDialogRootContext();
473
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
474
+ const modal = store.useState("modal", (0, import_internal.subSlot)(slot, "modal"));
475
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
476
+ const shouldRender = mounted || keepMounted;
477
+ if (!shouldRender) {
478
+ return null;
479
+ }
480
+ return (0, import_octane.createElement)(DialogPortalContext.Provider, {
481
+ value: keepMounted,
482
+ children: (0, import_octane.createElement)(import_FloatingPortal.FloatingPortal, {
483
+ container,
484
+ // Octane reconciles an ARRAY child as a keyed list, so every entry needs a key —
485
+ // including the consumer's, which is why it goes through a keyed Fragment rather than
486
+ // being keyed in place. Same shape as the Popup path below.
487
+ children: [
488
+ mounted && modal === true ? (0, import_octane.createElement)(import_InternalBackdrop.InternalBackdrop, {
489
+ key: "internal-backdrop",
490
+ ref: store.context.internalBackdropRef,
491
+ inert: (0, import_inertValue.inertValue)(!open)
492
+ }) : null,
493
+ (0, import_octane.createElement)(import_octane.Fragment, { key: "children", children })
494
+ ]
495
+ })
496
+ });
497
+ }
498
+ function DialogBackdrop(componentProps) {
499
+ const slot = (0, import_internal.S)("DialogBackdrop");
500
+ const { render, className, style, forceRender = false, ref, ...elementProps } = componentProps;
501
+ const { store } = useDialogRootContext();
502
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
503
+ const nested = store.useState("nested", (0, import_internal.subSlot)(slot, "nested"));
504
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
505
+ const transitionStatus = store.useState("transitionStatus", (0, import_internal.subSlot)(slot, "ts"));
506
+ const state = { open, transitionStatus };
507
+ return (0, import_useRenderElement.useRenderElement)(
508
+ "div",
509
+ { render, className, style },
510
+ {
511
+ state,
512
+ ref: [store.context.backdropRef, ref],
513
+ stateAttributesMapping: popupStateAttributesMapping,
514
+ props: [
515
+ {
516
+ role: "presentation",
517
+ hidden: !mounted,
518
+ style: { userSelect: "none", WebkitUserSelect: "none" }
519
+ },
520
+ elementProps
521
+ ],
522
+ enabled: forceRender || !nested
523
+ },
524
+ (0, import_internal.subSlot)(slot, "re")
525
+ );
526
+ }
527
+ function DialogPopup(componentProps) {
528
+ const slot = (0, import_internal.S)("DialogPopup");
529
+ const { render, className, style, finalFocus, initialFocus, ref, ...elementProps } = componentProps;
530
+ const { store } = useDialogRootContext();
531
+ const descriptionElementId = store.useState("descriptionElementId", (0, import_internal.subSlot)(slot, "did"));
532
+ const disablePointerDismissal = store.useState("disablePointerDismissal", (0, import_internal.subSlot)(slot, "dpd"));
533
+ const floatingRootContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "frc"));
534
+ const rootPopupProps = store.useState("popupProps", (0, import_internal.subSlot)(slot, "pp"));
535
+ const modal = store.useState("modal", (0, import_internal.subSlot)(slot, "modal"));
536
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
537
+ const nested = store.useState("nested", (0, import_internal.subSlot)(slot, "nested"));
538
+ const nestedOpenDialogCount = store.useState("nestedOpenDialogCount", (0, import_internal.subSlot)(slot, "nodc"));
539
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
540
+ const openMethod = store.useState("openMethod", (0, import_internal.subSlot)(slot, "om"));
541
+ const titleElementId = store.useState("titleElementId", (0, import_internal.subSlot)(slot, "tid"));
542
+ const transitionStatus = store.useState("transitionStatus", (0, import_internal.subSlot)(slot, "ts"));
543
+ const role = store.useState("role", (0, import_internal.subSlot)(slot, "role"));
544
+ const floatingId = floatingRootContext.useState("floatingId", (0, import_internal.subSlot)(slot, "fid"));
545
+ const popupId = elementProps.id ?? floatingId;
546
+ useDialogPortalContext();
547
+ (0, import_useOpenChangeComplete.useOpenChangeComplete)(
548
+ {
549
+ open,
550
+ ref: store.context.popupRef,
551
+ onComplete() {
552
+ if (open) {
553
+ store.context.onOpenChangeComplete?.(true);
554
+ }
555
+ }
556
+ },
557
+ (0, import_internal.subSlot)(slot, "occ")
558
+ );
559
+ const resolvedInitialFocus = initialFocus === void 0 ? (0, import_popups.createDefaultInitialFocus)(store.context.popupRef) : initialFocus;
560
+ const nestedDialogOpen = nestedOpenDialogCount > 0;
561
+ const setPopupElement = store.useStateSetter("popupElement", (0, import_internal.subSlot)(slot, "spe"));
562
+ const state = { open, nested, transitionStatus, nestedDialogOpen };
563
+ const element = (0, import_useRenderElement.useRenderElement)(
564
+ "div",
565
+ { render, className, style },
566
+ {
567
+ state,
568
+ props: [
569
+ rootPopupProps,
570
+ {
571
+ id: popupId,
572
+ "aria-labelledby": titleElementId ?? void 0,
573
+ "aria-describedby": descriptionElementId ?? void 0,
574
+ role,
575
+ ...import_popups.FOCUSABLE_POPUP_PROPS,
576
+ hidden: !mounted,
577
+ onKeyDown(event) {
578
+ if (import_keys.COMPOSITE_KEYS.has(event.key)) {
579
+ event.stopPropagation();
580
+ }
581
+ },
582
+ style: { ["--nested-dialogs"]: nestedOpenDialogCount }
583
+ },
584
+ elementProps
585
+ ],
586
+ ref: [ref, store.context.popupRef, setPopupElement],
587
+ stateAttributesMapping: popupStateAttributesMapping
588
+ },
589
+ (0, import_internal.subSlot)(slot, "re")
590
+ );
591
+ return (0, import_octane.createElement)(import_FloatingFocusManager.FloatingFocusManager, {
592
+ context: floatingRootContext,
593
+ openInteractionType: openMethod,
594
+ disabled: !mounted,
595
+ closeOnFocusOut: !disablePointerDismissal,
596
+ initialFocus: resolvedInitialFocus,
597
+ returnFocus: finalFocus,
598
+ modal: modal !== false,
599
+ restoreFocus: "popup",
600
+ children: element
601
+ });
602
+ }
603
+ function DialogTitle(componentProps) {
604
+ const slot = (0, import_internal.S)("DialogTitle");
605
+ const { render, className, style, id: idProp, ref, ...elementProps } = componentProps;
606
+ const { store } = useDialogRootContext();
607
+ const id = (0, import_useBaseUiId.useBaseUiId)(idProp, (0, import_internal.subSlot)(slot, "id"));
608
+ store.useSyncedValueWithCleanup("titleElementId", id, (0, import_internal.subSlot)(slot, "sync"));
609
+ return (0, import_useRenderElement.useRenderElement)(
610
+ "h2",
611
+ { render, className, style },
612
+ { ref, props: [{ id }, elementProps] },
613
+ (0, import_internal.subSlot)(slot, "re")
614
+ );
615
+ }
616
+ function DialogDescription(componentProps) {
617
+ const slot = (0, import_internal.S)("DialogDescription");
618
+ const { render, className, style, id: idProp, ref, ...elementProps } = componentProps;
619
+ const { store } = useDialogRootContext();
620
+ const id = (0, import_useBaseUiId.useBaseUiId)(idProp, (0, import_internal.subSlot)(slot, "id"));
621
+ store.useSyncedValueWithCleanup("descriptionElementId", id, (0, import_internal.subSlot)(slot, "sync"));
622
+ return (0, import_useRenderElement.useRenderElement)(
623
+ "p",
624
+ { render, className, style },
625
+ { ref, props: [{ id }, elementProps] },
626
+ (0, import_internal.subSlot)(slot, "re")
627
+ );
628
+ }
629
+ function DialogClose(componentProps) {
630
+ const slot = (0, import_internal.S)("DialogClose");
631
+ const {
632
+ render,
633
+ className,
634
+ style,
635
+ disabled = false,
636
+ nativeButton = true,
637
+ ref,
638
+ ...elementProps
639
+ } = componentProps;
640
+ const { store } = useDialogRootContext();
641
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
642
+ const { getButtonProps, buttonRef } = (0, import_useButton.useButton)(
643
+ { disabled, native: nativeButton },
644
+ (0, import_internal.subSlot)(slot, "btn")
645
+ );
646
+ const state = { disabled };
647
+ function handleClick(event) {
648
+ if (open) {
649
+ store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.closePress, event));
650
+ }
651
+ }
652
+ return (0, import_useRenderElement.useRenderElement)(
653
+ "button",
654
+ { render, className, style },
655
+ {
656
+ state,
657
+ ref: [ref, buttonRef],
658
+ props: [{ onClick: handleClick }, elementProps, getButtonProps]
659
+ },
660
+ (0, import_internal.subSlot)(slot, "re")
661
+ );
662
+ }
663
+ const DialogViewportDataAttributes = {
664
+ open: import_popupStateMapping.CommonPopupDataAttributes.open,
665
+ closed: import_popupStateMapping.CommonPopupDataAttributes.closed,
666
+ startingStyle: import_popupStateMapping.CommonPopupDataAttributes.startingStyle,
667
+ endingStyle: import_popupStateMapping.CommonPopupDataAttributes.endingStyle,
668
+ nested: "data-nested",
669
+ nestedDialogOpen: "data-nested-dialog-open"
670
+ };
671
+ const viewportStateAttributesMapping = {
672
+ ...import_popupStateMapping.popupStateMapping,
673
+ ...import_useTransitionStatus.transitionStatusMapping,
674
+ nested(value) {
675
+ return value ? { [DialogViewportDataAttributes.nested]: "" } : null;
676
+ },
677
+ nestedDialogOpen(value) {
678
+ return value ? { [DialogViewportDataAttributes.nestedDialogOpen]: "" } : null;
679
+ }
680
+ };
681
+ function DialogViewport(componentProps) {
682
+ const slot = (0, import_internal.S)("DialogViewport");
683
+ const { render, className, style, children, ref, ...elementProps } = componentProps;
684
+ const keepMounted = useDialogPortalContext();
685
+ const { store } = useDialogRootContext();
686
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
687
+ const nested = store.useState("nested", (0, import_internal.subSlot)(slot, "nested"));
688
+ const transitionStatus = store.useState("transitionStatus", (0, import_internal.subSlot)(slot, "ts"));
689
+ const nestedOpenDialogCount = store.useState("nestedOpenDialogCount", (0, import_internal.subSlot)(slot, "nodc"));
690
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
691
+ const setViewportElement = store.useStateSetter("viewportElement", (0, import_internal.subSlot)(slot, "sve"));
692
+ const state = {
693
+ open,
694
+ nested,
695
+ transitionStatus,
696
+ nestedDialogOpen: nestedOpenDialogCount > 0
697
+ };
698
+ return (0, import_useRenderElement.useRenderElement)(
699
+ "div",
700
+ { render, className, style },
701
+ {
702
+ enabled: keepMounted || mounted,
703
+ state,
704
+ ref: [ref, setViewportElement],
705
+ stateAttributesMapping: viewportStateAttributesMapping,
706
+ props: [
707
+ {
708
+ role: "presentation",
709
+ hidden: !mounted,
710
+ style: { pointerEvents: !open ? "none" : void 0 },
711
+ children
712
+ },
713
+ elementProps
714
+ ]
715
+ },
716
+ (0, import_internal.subSlot)(slot, "re")
717
+ );
718
+ }
719
+ const Dialog = {
720
+ Root: DialogRoot,
721
+ Trigger: DialogTrigger,
722
+ Portal: DialogPortal,
723
+ Backdrop: DialogBackdrop,
724
+ Popup: DialogPopup,
725
+ Viewport: DialogViewport,
726
+ Title: DialogTitle,
727
+ Description: DialogDescription,
728
+ Close: DialogClose,
729
+ createHandle: createDialogHandle,
730
+ Handle: DialogHandle
731
+ };
732
+ // Annotate the CommonJS export names for ESM import in node:
733
+ 0 && (module.exports = {
734
+ Dialog,
735
+ DialogHandle,
736
+ DialogStore,
737
+ DialogViewportDataAttributes,
738
+ createDialogHandle,
739
+ useDialogRootContext,
740
+ useRenderDialogRoot
741
+ });