@jobber/components 9.5.3 → 9.6.0

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 (178) hide show
  1. package/Combobox.d.ts +1 -0
  2. package/Combobox.js +17 -0
  3. package/dist/Autocomplete/index.cjs +0 -2
  4. package/dist/Autocomplete/index.mjs +0 -2
  5. package/dist/Autocomplete-cjs.js +4 -5
  6. package/dist/Autocomplete-es.js +1 -2
  7. package/dist/Card/index.cjs +2 -2
  8. package/dist/Card/index.mjs +2 -2
  9. package/dist/Chip/index.cjs +0 -2
  10. package/dist/Chip/index.mjs +0 -2
  11. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +0 -2
  12. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +0 -2
  13. package/dist/Chips/InternalChipDismissible/index.cjs +0 -2
  14. package/dist/Chips/InternalChipDismissible/index.mjs +0 -2
  15. package/dist/Chips/index.cjs +0 -2
  16. package/dist/Chips/index.mjs +0 -2
  17. package/dist/Combobox/Combobox.contentSlots.d.ts +5 -0
  18. package/dist/Combobox/Combobox.context.d.ts +34 -0
  19. package/dist/Combobox/Combobox.d.ts +69 -0
  20. package/dist/Combobox/Combobox.footer.d.ts +7 -0
  21. package/dist/Combobox/Combobox.items.d.ts +25 -0
  22. package/dist/Combobox/Combobox.responsive.d.ts +54 -0
  23. package/dist/Combobox/Combobox.selectAll.d.ts +4 -0
  24. package/dist/Combobox/Combobox.slotFactory.d.ts +7 -0
  25. package/dist/Combobox/Combobox.testUtils.d.ts +12 -0
  26. package/dist/Combobox/Combobox.types.d.ts +166 -0
  27. package/dist/Combobox/index.cjs +35 -0
  28. package/dist/Combobox/index.d.ts +2 -0
  29. package/dist/Combobox/index.mjs +29 -0
  30. package/dist/Combobox-cjs.js +675 -0
  31. package/dist/Combobox-es.js +673 -0
  32. package/dist/ComboboxPrimitive-cjs.js +88 -47
  33. package/dist/ComboboxPrimitive-es.js +39 -23
  34. package/dist/{ComboboxChipRemove-cjs.js → ComboboxSeparator-cjs.js} +501 -455
  35. package/dist/{ComboboxChipRemove-es.js → ComboboxSeparator-es.js} +500 -456
  36. package/dist/ConfirmationModal/index.cjs +0 -2
  37. package/dist/ConfirmationModal/index.mjs +0 -2
  38. package/dist/ContentBlock/index.cjs +1 -0
  39. package/dist/ContentBlock/index.mjs +1 -0
  40. package/dist/ContentBlock-cjs.js +2 -18
  41. package/dist/ContentBlock-es.js +1 -17
  42. package/dist/DataDump/index.cjs +2 -2
  43. package/dist/DataDump/index.mjs +2 -2
  44. package/dist/DataList/components/DataListActions/index.cjs +0 -2
  45. package/dist/DataList/components/DataListActions/index.mjs +0 -2
  46. package/dist/DataList/components/DataListBulkActions/index.cjs +0 -2
  47. package/dist/DataList/components/DataListBulkActions/index.mjs +0 -2
  48. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +0 -2
  49. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +0 -2
  50. package/dist/DataList/components/DataListFilters/index.cjs +0 -2
  51. package/dist/DataList/components/DataListFilters/index.mjs +0 -2
  52. package/dist/DataList/components/DataListHeader/index.cjs +0 -2
  53. package/dist/DataList/components/DataListHeader/index.mjs +0 -2
  54. package/dist/DataList/components/DataListItem/index.cjs +0 -2
  55. package/dist/DataList/components/DataListItem/index.mjs +0 -2
  56. package/dist/DataList/components/DataListItemActions/index.cjs +0 -2
  57. package/dist/DataList/components/DataListItemActions/index.mjs +0 -2
  58. package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +0 -2
  59. package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +0 -2
  60. package/dist/DataList/components/DataListItems/index.cjs +0 -2
  61. package/dist/DataList/components/DataListItems/index.mjs +0 -2
  62. package/dist/DataList/components/DataListLayout/index.cjs +0 -2
  63. package/dist/DataList/components/DataListLayout/index.mjs +0 -2
  64. package/dist/DataList/components/DataListLayoutActions/index.cjs +0 -2
  65. package/dist/DataList/components/DataListLayoutActions/index.mjs +0 -2
  66. package/dist/DataList/index.cjs +0 -2
  67. package/dist/DataList/index.mjs +0 -2
  68. package/dist/DatePicker/index.cjs +0 -2
  69. package/dist/DatePicker/index.mjs +0 -2
  70. package/dist/DatePicker-cjs.js +4 -5
  71. package/dist/DatePicker-es.js +1 -2
  72. package/dist/Dialog/index.cjs +2 -2
  73. package/dist/Dialog/index.mjs +2 -2
  74. package/dist/DrawerDescription-cjs.js +268 -99
  75. package/dist/DrawerDescription-es.js +270 -103
  76. package/dist/DrawerTitle-cjs.js +2 -6
  77. package/dist/DrawerTitle-es.js +3 -7
  78. package/dist/FieldDescription-cjs.js +184 -181
  79. package/dist/FieldDescription-es.js +187 -184
  80. package/dist/FilterPicker/components/FilterPickerActivator/index.cjs +0 -2
  81. package/dist/FilterPicker/components/FilterPickerActivator/index.mjs +0 -2
  82. package/dist/FilterPicker/components/FilterPickerContent/index.cjs +0 -2
  83. package/dist/FilterPicker/components/FilterPickerContent/index.mjs +0 -2
  84. package/dist/FilterPicker/components/FilterPickerTrigger/index.cjs +0 -2
  85. package/dist/FilterPicker/components/FilterPickerTrigger/index.mjs +0 -2
  86. package/dist/FilterPicker/index.cjs +0 -2
  87. package/dist/FilterPicker/index.mjs +0 -2
  88. package/dist/FilterPickerContent-cjs.js +4 -5
  89. package/dist/FilterPickerContent-es.js +1 -2
  90. package/dist/FormatFile/index.cjs +0 -2
  91. package/dist/FormatFile/index.mjs +0 -2
  92. package/dist/Gallery/index.cjs +0 -2
  93. package/dist/Gallery/index.mjs +0 -2
  94. package/dist/InputDate/index.cjs +0 -2
  95. package/dist/InputDate/index.mjs +0 -2
  96. package/dist/InputNumber/index.cjs +2 -2
  97. package/dist/InputNumber/index.mjs +2 -2
  98. package/dist/InputNumber/types.d.ts +5 -0
  99. package/dist/InputNumber-cjs.js +2 -2
  100. package/dist/InputNumber-es.js +2 -2
  101. package/dist/LightBox/index.cjs +0 -2
  102. package/dist/LightBox/index.mjs +0 -2
  103. package/dist/Menu/index.cjs +2 -2
  104. package/dist/Menu/index.mjs +2 -2
  105. package/dist/Menu-cjs.js +4 -5
  106. package/dist/Menu-es.js +1 -2
  107. package/dist/MenuSubmenuTrigger-cjs.js +206 -164
  108. package/dist/MenuSubmenuTrigger-es.js +194 -152
  109. package/dist/Modal/index.cjs +0 -2
  110. package/dist/Modal/index.mjs +1 -3
  111. package/dist/NumberFieldInput-cjs.js +187 -308
  112. package/dist/NumberFieldInput-es.js +187 -308
  113. package/dist/Page/index.cjs +2 -2
  114. package/dist/Page/index.mjs +2 -2
  115. package/dist/Popover/index.cjs +0 -2
  116. package/dist/Popover/index.mjs +0 -2
  117. package/dist/Popover-cjs.js +7 -8
  118. package/dist/Popover-es.js +1 -2
  119. package/dist/ScrollAreaViewport-cjs.js +747 -1093
  120. package/dist/ScrollAreaViewport-es.js +734 -1081
  121. package/dist/Select/index.cjs +2 -2
  122. package/dist/Select/index.mjs +2 -2
  123. package/dist/SelectGroupLabel-cjs.js +207 -306
  124. package/dist/SelectGroupLabel-es.js +203 -302
  125. package/dist/SelectPrimitive-cjs.js +11 -17
  126. package/dist/SelectPrimitive-es.js +1 -7
  127. package/dist/Tooltip/index.cjs +0 -2
  128. package/dist/Tooltip/index.mjs +0 -2
  129. package/dist/Tooltip-cjs.js +6 -7
  130. package/dist/Tooltip-es.js +1 -2
  131. package/dist/buttonRenderAdapter-cjs.js +2 -1
  132. package/dist/buttonRenderAdapter-es.js +2 -1
  133. package/dist/dialogReturnFocus-cjs.js +1 -1
  134. package/dist/dialogReturnFocus-es.js +2 -2
  135. package/dist/docs/InputNumber/InputNumber.md +2 -2
  136. package/dist/docs/SelectPrimitive/SelectPrimitive.md +1 -1
  137. package/dist/floating-ui.react-cjs.js +2557 -185
  138. package/dist/floating-ui.react-es.js +2512 -149
  139. package/dist/getMappedBreakpointWidth-cjs.js +21 -0
  140. package/dist/getMappedBreakpointWidth-es.js +18 -0
  141. package/dist/index.cjs +15 -10
  142. package/dist/index.d.mts +1 -0
  143. package/dist/index.d.ts +1 -0
  144. package/dist/index.mjs +14 -10
  145. package/dist/mergeClassName-cjs.js +12 -0
  146. package/dist/mergeClassName-es.js +10 -0
  147. package/dist/primitives/BottomSheet/index.cjs +1 -1
  148. package/dist/primitives/BottomSheet/index.mjs +1 -1
  149. package/dist/primitives/ComboboxPrimitive/ComboboxPrimitive.d.ts +2 -2
  150. package/dist/primitives/ComboboxPrimitive/index.cjs +4 -5
  151. package/dist/primitives/ComboboxPrimitive/index.mjs +4 -5
  152. package/dist/primitives/SelectPrimitive/index.cjs +1 -2
  153. package/dist/primitives/SelectPrimitive/index.mjs +1 -2
  154. package/dist/primitives/index.cjs +3 -3
  155. package/dist/primitives/index.mjs +3 -3
  156. package/dist/scrollEdges-cjs.js +1 -11
  157. package/dist/scrollEdges-es.js +1 -11
  158. package/dist/scrollable-cjs.js +58 -0
  159. package/dist/scrollable-es.js +54 -0
  160. package/dist/styles.css +759 -42
  161. package/dist/unstyledPrimitives/index.cjs +720 -478
  162. package/dist/unstyledPrimitives/index.mjs +663 -421
  163. package/dist/useCompositeListItem-cjs.js +2108 -361
  164. package/dist/useCompositeListItem-es.js +2076 -331
  165. package/dist/useLabel-cjs.js +2 -3
  166. package/dist/useLabel-es.js +2 -3
  167. package/dist/useRenderElement-cjs.js +9 -7
  168. package/dist/useRenderElement-es.js +9 -7
  169. package/dist/useScrollLock-cjs.js +819 -344
  170. package/dist/useScrollLock-es.js +732 -296
  171. package/dist/useScrollToActive-cjs.js +4 -5
  172. package/dist/useScrollToActive-es.js +1 -2
  173. package/dist/utils/meta/meta.json +43 -1
  174. package/package.json +8 -3
  175. package/dist/floating-ui.react-dom-cjs.js +0 -2103
  176. package/dist/floating-ui.react-dom-es.js +0 -2072
  177. package/dist/floating-ui.utils-cjs.js +0 -342
  178. package/dist/floating-ui.utils-es.js +0 -300
@@ -1,14 +1,227 @@
1
1
  import * as React from 'react';
2
- import { u as useDialogRootContext, l as useDialogPortalContext, m as DialogStore } from './ScrollAreaViewport-es.js';
3
- import { u as useRenderElement } from './useRenderElement-es.js';
4
- import { p as popupStateMapping, t as transitionStatusMapping, u as useBaseUiId, C as CommonPopupDataAttributes, f as useOpenChangeComplete, h as createDefaultInitialFocus, F as FOCUSABLE_POPUP_PROPS, i as FloatingFocusManager, d as createChangeEventDetails, j as imperativeAction } from './useScrollLock-es.js';
2
+ import { u as useDialogRootContext, k as useDialogPortalContext, l as dialogStateAttributesMapping, m as useRenderDialogRoot, n as createNullDialogStore } from './ScrollAreaViewport-es.js';
3
+ import { f as formatErrorMessage, u as useRenderElement } from './useRenderElement-es.js';
4
+ import { A as AnimationFrame, h as createChangeEventDetails, k as imperativeAction, p as popupTransitionStateMapping, u as useBaseUiId, l as useOpenChangeComplete, m as createDefaultInitialFocus, F as FOCUSABLE_POPUP_PROPS, n as FloatingFocusManager } from './useScrollLock-es.js';
5
5
  import { C as COMPOSITE_KEYS } from './scrollEdges-es.js';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
8
- const stateAttributesMapping$1 = {
9
- ...popupStateMapping,
10
- ...transitionStatusMapping
11
- };
8
+ /**
9
+ * Minimal store contract exposed by popup handles to detached triggers.
10
+ *
11
+ * Detached triggers read `store` during render and subscribe to be notified when the handle switches
12
+ * between its fallback store and a root's live store.
13
+ *
14
+ * @template HandleStore Store shape exposed to detached triggers.
15
+ */
16
+
17
+ /**
18
+ * Store shape holding a trigger registry, required by `BasePopupHandle.openByTrigger` to resolve a
19
+ * trigger element by id on both the attached root's store and the fallback store.
20
+ */
21
+
22
+ /**
23
+ * Store shape required by `BasePopupHandle.openByTrigger`/`closePopup` to drive open/close state.
24
+ * Only the root-owned `Store` needs this — the `HandleStore` view exposed to detached triggers may
25
+ * omit `setOpen` entirely (as Dialog and PreviewCard's do) since it is never called while detached.
26
+ */
27
+
28
+ /**
29
+ * Shared implementation for popup handles that coordinate detached triggers with a mounted root.
30
+ *
31
+ * Subclasses provide the component-specific imperative methods, while this base class owns the
32
+ * fallback store, root store attachment stack, subscriber notifications, and development warning for
33
+ * overlapping roots.
34
+ *
35
+ * @template HandleStore Store shape exposed to detached triggers.
36
+ * @template Store Root-owned store attached by the component root.
37
+ */
38
+ class BasePopupHandle {
39
+ /**
40
+ * Stores of every root currently using this handle, in attach order. A handle is meant to be used
41
+ * by a single mounted root, but roots can transiently overlap (e.g. during an animated route
42
+ * transition), so this stack lets `attachStore`'s cleanup restore the previous root instead of
43
+ * leaving a still-mounted root uncontrollable when a newer overlapping root detaches first.
44
+ */
45
+ attachedStores = [];
46
+
47
+ /**
48
+ * Store of the root that currently controls the handle: the most recently attached one still
49
+ * mounted, or `null` when no root is attached. Imperative methods are no-ops while this is `null`.
50
+ */
51
+ attachedStoreValue = null;
52
+
53
+ /**
54
+ * Listeners notified when `attachedStore` changes, so detached triggers can follow the store pointer.
55
+ */
56
+ storeListeners = new Set();
57
+
58
+ /**
59
+ * Creates a handle backed by the store used while no root is attached.
60
+ *
61
+ * @param fallbackStore Inert, closed store handed to detached triggers while no root is attached,
62
+ * so they can render and register without a mounted root. Triggers register into whichever store
63
+ * `store` currently resolves to, so while detached they live in this store's trigger map and
64
+ * migrate themselves to the root's store (and back) as it attaches/detaches.
65
+ * @param componentName Component name used to prefix dev warnings, e.g. `'Menu'` produces
66
+ * `MenuHandle.open()` in warning text.
67
+ * @param throwOnMissingTrigger Whether `open(triggerId)` throws when no trigger with that id is
68
+ * registered. Anchored popups (Menu, Popover, Tooltip, PreviewCard) need a trigger to anchor to,
69
+ * so they throw; Dialog is not anchored and instead opens unassociated with a dev warning.
70
+ */
71
+ constructor(fallbackStore, componentName, throwOnMissingTrigger = true) {
72
+ this.fallbackStore = fallbackStore;
73
+ this.componentName = componentName;
74
+ this.throwOnMissingTrigger = throwOnMissingTrigger;
75
+ }
76
+ get attachedStore() {
77
+ return this.attachedStoreValue;
78
+ }
79
+
80
+ /**
81
+ * Store that detached triggers read from: the attached root's store, or an inert fallback store
82
+ * used while no root is attached.
83
+ * @internal
84
+ */
85
+ get store() {
86
+ return this.attachedStoreValue ?? this.fallbackStore;
87
+ }
88
+
89
+ /**
90
+ * Stable fallback store used for server rendering and hydration. Root stores cannot be recorded on
91
+ * the handle during render because a handle can be shared by concurrent server-rendered requests.
92
+ * @internal
93
+ */
94
+ get serverStore() {
95
+ return this.fallbackStore;
96
+ }
97
+
98
+ /**
99
+ * Subscribes to changes of the attached store pointer so detached triggers re-render and re-bind
100
+ * when a root attaches or detaches. Returns a function that removes the listener.
101
+ * @internal
102
+ */
103
+ subscribeStore(listener) {
104
+ this.storeListeners.add(listener);
105
+ return () => {
106
+ this.storeListeners.delete(listener);
107
+ };
108
+ }
109
+
110
+ /**
111
+ * Points the handle at a root's store and notifies subscribers so detached triggers re-render and
112
+ * re-register into it (their registration ref re-fires on the store-pointer change). Returns a
113
+ * cleanup function that detaches the store again.
114
+ * @internal
115
+ */
116
+ attachStore(newStore) {
117
+ this.attachedStores.push(newStore);
118
+ this.setActiveStore(newStore);
119
+ if (process.env.NODE_ENV !== 'production') {
120
+ if (this.attachedStores.length > 1) {
121
+ // More than one root is attached at once. This is usually a transient overlap during an
122
+ // animated route transition, where the outgoing root unmounts shortly after the incoming
123
+ // one mounts. Defer the check by a frame and only warn if the overlap is still present once
124
+ // the transition has settled (more than one root stayed mounted), so a clean handoff doesn't
125
+ // warn regardless of the exact unmount timing.
126
+ // The warning frame only exists in development; it is created lazily so it never appears on
127
+ // instances in production (like `controlledValues` in `ReactStore`).
128
+ const dev = this;
129
+ (dev.overlapWarningFrame ??= AnimationFrame.create()).request(() => {
130
+ if (this.attachedStores.length > 1) {
131
+ console.warn('Base UI: A handle is attached to more than one mounted root at the same time. ' + 'The most recently mounted root takes over and the previous one stops being controlled by the handle. ' + 'A handle should be used by a single root that stays mounted for the lifetime of the handle.');
132
+ }
133
+ });
134
+ }
135
+ }
136
+ return () => {
137
+ const index = this.attachedStores.lastIndexOf(newStore);
138
+ if (index !== -1) {
139
+ this.attachedStores.splice(index, 1);
140
+ }
141
+ // Restore control to the most recently attached root that is still mounted (or detach fully if
142
+ // none remain). Clearing unconditionally would leave a still-mounted older root uncontrollable
143
+ // when a newer overlapping root detaches first (e.g. a canceled route transition).
144
+ this.setActiveStore(this.attachedStores[this.attachedStores.length - 1] ?? null);
145
+ };
146
+ }
147
+
148
+ /**
149
+ * Sets the store that currently controls the handle and notifies subscribers when it changes, so
150
+ * detached triggers re-render and migrate their registration to the new store.
151
+ */
152
+ setActiveStore(store) {
153
+ if (this.attachedStoreValue !== store) {
154
+ this.attachedStoreValue = store;
155
+ this.storeListeners.forEach(listener => {
156
+ listener();
157
+ });
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Opens the attached root's store and associates it with the trigger with the given id, or a
163
+ * no-op (with a dev warning) while no root is attached. Shared by every concrete handle's public
164
+ * `open()` method, which only narrows the parameter type.
165
+ *
166
+ * When a trigger id is given but no matching trigger is registered, anchored popups throw (see
167
+ * `throwOnMissingTrigger`); Dialog opens unassociated with a dev warning instead.
168
+ *
169
+ * This method should only be called in an event handler or an effect (not during rendering).
170
+ *
171
+ * @param triggerId ID of the trigger to associate with the popup, or `null`/`undefined` to open
172
+ * without associating any trigger.
173
+ */
174
+ openByTrigger(triggerId) {
175
+ const attachedStore = this.attachedStore;
176
+ if (attachedStore === null) {
177
+ if (process.env.NODE_ENV !== 'production') {
178
+ console.warn(`Base UI: ${this.componentName}Handle.open() was called while no root using this handle is mounted. ` + 'The call was ignored; mount a root with this handle before opening it imperatively.');
179
+ }
180
+ return;
181
+ }
182
+
183
+ // Registered triggers normally live in the active root's store. During the commit in which a
184
+ // root attaches, a still-mounted detached trigger has not re-registered into that store yet (it
185
+ // migrates on its next render): it is still registered wherever it lived before — the fallback
186
+ // store when this is the first root to attach, or a previously attached root's store during a
187
+ // transient overlap (e.g. an animated route transition). Search the whole attachment stack
188
+ // (newest first) and the fallback map so an imperative open-by-id called in that commit (e.g.
189
+ // from a layout effect) still resolves the trigger instead of treating it as missing.
190
+ let triggerElement;
191
+ if (triggerId) {
192
+ for (let i = this.attachedStores.length - 1; i >= 0 && !triggerElement; i -= 1) {
193
+ triggerElement = this.attachedStores[i].context.triggerElements.getById(triggerId);
194
+ }
195
+ triggerElement ??= this.fallbackStore.context.triggerElements.getById(triggerId);
196
+ }
197
+ if (triggerId && !triggerElement) {
198
+ if (this.throwOnMissingTrigger) {
199
+ throw new Error(process.env.NODE_ENV !== "production" ? `Base UI: ${this.componentName}Handle.open() was called with the trigger id "${triggerId}", ` + 'but no matching trigger is registered with this handle. ' + 'An anchored popup cannot open without a trigger to anchor to. ' + `Pass the id of a mounted ${this.componentName}.Trigger that has this handle set on its "handle" prop.` : formatErrorMessage(99, this.componentName, triggerId, this.componentName));
200
+ }
201
+ if (process.env.NODE_ENV !== 'production') {
202
+ console.warn(`Base UI: ${this.componentName}Handle.open: No trigger found with id "${triggerId}". ` + 'The popup will open, but the trigger will not be associated with it.');
203
+ }
204
+ }
205
+ attachedStore.setOpen(true, createChangeEventDetails(imperativeAction, undefined, triggerElement));
206
+ }
207
+
208
+ /**
209
+ * Closes the popup by setting the attached root's store to closed, or a no-op (with a dev warning)
210
+ * while no root is attached. Shared by every concrete handle's public `close()` method.
211
+ *
212
+ * This method should only be called in an event handler or an effect (not during rendering).
213
+ */
214
+ closePopup() {
215
+ const attachedStore = this.attachedStore;
216
+ if (attachedStore === null) {
217
+ if (process.env.NODE_ENV !== 'production') {
218
+ console.warn(`Base UI: ${this.componentName}Handle.close() was called while no root using this handle is mounted. ` + 'The call was ignored.');
219
+ }
220
+ return;
221
+ }
222
+ attachedStore.setOpen(false, createChangeEventDetails(imperativeAction));
223
+ }
224
+ }
12
225
 
13
226
  /**
14
227
  * An overlay displayed beneath the popup.
@@ -24,9 +237,7 @@ const DialogBackdrop = /*#__PURE__*/React.forwardRef(function DialogBackdrop(com
24
237
  forceRender = false,
25
238
  ...elementProps
26
239
  } = componentProps;
27
- const {
28
- store
29
- } = useDialogRootContext();
240
+ const store = useDialogRootContext();
30
241
  const open = store.useState('open');
31
242
  const nested = store.useState('nested');
32
243
  const mounted = store.useState('mounted');
@@ -38,7 +249,7 @@ const DialogBackdrop = /*#__PURE__*/React.forwardRef(function DialogBackdrop(com
38
249
  return useRenderElement('div', componentProps, {
39
250
  state,
40
251
  ref: [store.context.backdropRef, forwardedRef],
41
- stateAttributesMapping: stateAttributesMapping$1,
252
+ stateAttributesMapping: popupTransitionStateMapping,
42
253
  props: [{
43
254
  role: 'presentation',
44
255
  hidden: !mounted,
@@ -66,9 +277,7 @@ const DialogDescription = /*#__PURE__*/React.forwardRef(function DialogDescripti
66
277
  id: idProp,
67
278
  ...elementProps
68
279
  } = componentProps;
69
- const {
70
- store
71
- } = useDialogRootContext();
280
+ const store = useDialogRootContext();
72
281
  const id = useBaseUiId(idProp);
73
282
  store.useSyncedValueWithCleanup('descriptionElementId', id);
74
283
  return useRenderElement('p', componentProps, {
@@ -80,59 +289,6 @@ const DialogDescription = /*#__PURE__*/React.forwardRef(function DialogDescripti
80
289
  });
81
290
  if (process.env.NODE_ENV !== "production") DialogDescription.displayName = "DialogDescription";
82
291
 
83
- let DialogPopupCssVars = /*#__PURE__*/function (DialogPopupCssVars) {
84
- /**
85
- * Indicates how many dialogs are nested within.
86
- * @type {number}
87
- */
88
- DialogPopupCssVars["nestedDialogs"] = "--nested-dialogs";
89
- return DialogPopupCssVars;
90
- }({});
91
-
92
- let DialogPopupDataAttributes = function (DialogPopupDataAttributes) {
93
- /**
94
- * Present when the dialog is open.
95
- */
96
- DialogPopupDataAttributes[DialogPopupDataAttributes["open"] = CommonPopupDataAttributes.open] = "open";
97
- /**
98
- * Present when the dialog is closed.
99
- */
100
- DialogPopupDataAttributes[DialogPopupDataAttributes["closed"] = CommonPopupDataAttributes.closed] = "closed";
101
- /**
102
- * Present when the dialog is animating in.
103
- */
104
- DialogPopupDataAttributes[DialogPopupDataAttributes["startingStyle"] = CommonPopupDataAttributes.startingStyle] = "startingStyle";
105
- /**
106
- * Present when the dialog is animating out.
107
- */
108
- DialogPopupDataAttributes[DialogPopupDataAttributes["endingStyle"] = CommonPopupDataAttributes.endingStyle] = "endingStyle";
109
- /**
110
- * Present when the dialog is nested within another dialog.
111
- */
112
- DialogPopupDataAttributes["nested"] = "data-nested";
113
- /**
114
- * Present when the dialog has other open dialogs nested within it.
115
- */
116
- DialogPopupDataAttributes["nestedDialogOpen"] = "data-nested-dialog-open";
117
- return DialogPopupDataAttributes;
118
- }({});
119
-
120
- const stateAttributesMapping = {
121
- ...popupStateMapping,
122
- ...transitionStatusMapping,
123
- nestedDialogOpen(value) {
124
- return value ? {
125
- [DialogPopupDataAttributes.nestedDialogOpen]: ''
126
- } : null;
127
- }
128
- };
129
-
130
- /**
131
- * A container for the dialog contents.
132
- * Renders a `<div>` element.
133
- *
134
- * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
135
- */
136
292
  const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(componentProps, forwardedRef) {
137
293
  const {
138
294
  render,
@@ -142,9 +298,7 @@ const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(component
142
298
  initialFocus,
143
299
  ...elementProps
144
300
  } = componentProps;
145
- const {
146
- store
147
- } = useDialogRootContext();
301
+ const store = useDialogRootContext();
148
302
  const descriptionElementId = store.useState('descriptionElementId');
149
303
  const disablePointerDismissal = store.useState('disablePointerDismissal');
150
304
  const floatingRootContext = store.useState('floatingRootContext');
@@ -159,7 +313,6 @@ const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(component
159
313
  const transitionStatus = store.useState('transitionStatus');
160
314
  const role = store.useState('role');
161
315
  const floatingId = floatingRootContext.useState('floatingId');
162
- const popupId = elementProps.id ?? floatingId;
163
316
  useDialogPortalContext();
164
317
  useOpenChangeComplete({
165
318
  open,
@@ -182,9 +335,9 @@ const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(component
182
335
  const element = useRenderElement('div', componentProps, {
183
336
  state,
184
337
  props: [rootPopupProps, {
185
- id: popupId,
186
- 'aria-labelledby': titleElementId ?? undefined,
187
- 'aria-describedby': descriptionElementId ?? undefined,
338
+ id: floatingId,
339
+ 'aria-labelledby': titleElementId,
340
+ 'aria-describedby': descriptionElementId,
188
341
  role,
189
342
  ...FOCUSABLE_POPUP_PROPS,
190
343
  hidden: !mounted,
@@ -194,11 +347,11 @@ const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(component
194
347
  }
195
348
  },
196
349
  style: {
197
- [DialogPopupCssVars.nestedDialogs]: nestedOpenDialogCount
350
+ '--nested-dialogs': nestedOpenDialogCount
198
351
  }
199
352
  }, elementProps],
200
353
  ref: [forwardedRef, store.context.popupRef, setPopupElement],
201
- stateAttributesMapping
354
+ stateAttributesMapping: dialogStateAttributesMapping
202
355
  });
203
356
  return /*#__PURE__*/jsx(FloatingFocusManager, {
204
357
  context: floatingRootContext,
@@ -215,59 +368,73 @@ const DialogPopup = /*#__PURE__*/React.forwardRef(function DialogPopup(component
215
368
  if (process.env.NODE_ENV !== "production") DialogPopup.displayName = "DialogPopup";
216
369
 
217
370
  /**
218
- * A handle to control a Dialog imperatively and to associate detached triggers with it.
371
+ * Groups all parts of the dialog.
372
+ * Doesn't render its own HTML element.
373
+ *
374
+ * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
219
375
  */
220
- class DialogHandle {
221
- /**
222
- * Internal store holding the dialog state.
223
- * @internal
224
- */
376
+ function DialogRoot(props) {
377
+ return useRenderDialogRoot('dialog', props);
378
+ }
225
379
 
226
- constructor(store) {
227
- this.store = store ?? new DialogStore();
380
+ /**
381
+ * Controls a Dialog imperatively and associates detached `Dialog.Trigger` components with a
382
+ * `Dialog.Root`. Create one with `Dialog.createHandle()` and pass it to the `handle` prop of the
383
+ * root and of any triggers rendered outside of it.
384
+ *
385
+ * The imperative methods take effect only while a root using this handle is mounted; calls made
386
+ * before a root attaches (or after it unmounts) are ignored.
387
+ */
388
+ class DialogHandle extends BasePopupHandle {
389
+ constructor() {
390
+ super(createNullDialogStore(), 'Dialog', false);
228
391
  }
229
392
 
230
393
  /**
231
- * Opens the dialog and associates it with the trigger with the given id.
232
- * The trigger, if provided, must be a matching Trigger component with this handle passed as a prop.
394
+ * Opens the dialog, optionally associating it with a trigger.
233
395
  *
234
396
  * This method should only be called in an event handler or an effect (not during rendering).
235
397
  *
236
- * @param triggerId ID of the trigger to associate with the dialog. If null, the dialog will open without a trigger association.
398
+ * @param triggerId ID of the trigger to associate with the dialog. The trigger must be a matching
399
+ * `Dialog.Trigger` with this handle passed as a prop. Pass `null` to open without associating any trigger.
237
400
  */
238
401
  open(triggerId) {
239
- const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : undefined;
240
- if (process.env.NODE_ENV !== 'production') {
241
- if (triggerId && !triggerElement) {
242
- console.warn(`Base UI: DialogHandle.open: No trigger found with id "${triggerId}". The dialog will open, but the trigger will not be associated with the dialog.`);
243
- }
244
- }
245
- this.store.setOpen(true, createChangeEventDetails(imperativeAction, undefined, triggerElement));
402
+ this.openByTrigger(triggerId);
246
403
  }
247
404
 
248
405
  /**
249
- * Opens the dialog and sets the payload.
250
- * Does not associate the dialog with any trigger.
406
+ * Opens the dialog with the given payload, without associating it with any trigger.
407
+ *
408
+ * This method should only be called in an event handler or an effect (not during rendering).
251
409
  *
252
- * @param payload Payload to set when opening the dialog.
410
+ * @param payload Payload to set when opening the dialog. It is exposed to the root's render-prop children.
253
411
  */
254
412
  openWithPayload(payload) {
255
- this.store.set('payload', payload);
256
- this.store.setOpen(true, createChangeEventDetails(imperativeAction, undefined, undefined));
413
+ const attachedStore = this.attachedStore;
414
+ if (attachedStore === null) {
415
+ if (process.env.NODE_ENV !== 'production') {
416
+ console.warn('Base UI: DialogHandle.openWithPayload() was called while no root using this handle is mounted. ' + 'The call and its payload were ignored; mount a root with this handle before opening it imperatively.');
417
+ }
418
+ return;
419
+ }
420
+ attachedStore.set('payload', payload);
421
+ attachedStore.setOpen(true, createChangeEventDetails(imperativeAction));
257
422
  }
258
423
 
259
424
  /**
260
425
  * Closes the dialog.
426
+ *
427
+ * This method should only be called in an event handler or an effect (not during rendering).
261
428
  */
262
429
  close() {
263
- this.store.setOpen(false, createChangeEventDetails(imperativeAction, undefined, undefined));
430
+ this.closePopup();
264
431
  }
265
432
 
266
433
  /**
267
- * Indicates whether the dialog is currently open.
434
+ * Whether the dialog is currently open. Returns `false` while no root is attached to the handle.
268
435
  */
269
436
  get isOpen() {
270
- return this.store.select('open');
437
+ return this.attachedStore?.select('open') ?? false;
271
438
  }
272
439
  }
273
440
 
@@ -286,4 +453,4 @@ function createDialogHandle() {
286
453
  */
287
454
  const DrawerDescription = DialogDescription;
288
455
 
289
- export { DrawerDescription as D, DialogBackdrop as a, DialogPopup as b, DialogDescription as c, createDialogHandle as d, DialogHandle as e };
456
+ export { BasePopupHandle as B, DrawerDescription as D, DialogRoot as a, DialogBackdrop as b, DialogPopup as c, DialogDescription as d, createDialogHandle as e, DialogHandle as f };
@@ -39,9 +39,7 @@ const DialogClose = /*#__PURE__*/React__namespace.forwardRef(function DialogClos
39
39
  nativeButton = true,
40
40
  ...elementProps
41
41
  } = componentProps;
42
- const {
43
- store
44
- } = ScrollAreaViewport.useDialogRootContext();
42
+ const store = ScrollAreaViewport.useDialogRootContext();
45
43
  const open = store.useState('open');
46
44
  const {
47
45
  getButtonProps,
@@ -82,9 +80,7 @@ const DialogTitle = /*#__PURE__*/React__namespace.forwardRef(function DialogTitl
82
80
  id: idProp,
83
81
  ...elementProps
84
82
  } = componentProps;
85
- const {
86
- store
87
- } = ScrollAreaViewport.useDialogRootContext();
83
+ const store = ScrollAreaViewport.useDialogRootContext();
88
84
  const id = useScrollLock.useBaseUiId(idProp);
89
85
  store.useSyncedValueWithCleanup('titleElementId', id);
90
86
  return useRenderElement.useRenderElement('h2', componentProps, {
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { u as useDialogRootContext } from './ScrollAreaViewport-es.js';
3
3
  import { u as useRenderElement } from './useRenderElement-es.js';
4
- import { c as useButton, d as createChangeEventDetails, e as closePress, u as useBaseUiId } from './useScrollLock-es.js';
4
+ import { f as useButton, h as createChangeEventDetails, j as closePress, u as useBaseUiId } from './useScrollLock-es.js';
5
5
 
6
6
  /**
7
7
  * A button that closes the dialog.
@@ -18,9 +18,7 @@ const DialogClose = /*#__PURE__*/React.forwardRef(function DialogClose(component
18
18
  nativeButton = true,
19
19
  ...elementProps
20
20
  } = componentProps;
21
- const {
22
- store
23
- } = useDialogRootContext();
21
+ const store = useDialogRootContext();
24
22
  const open = store.useState('open');
25
23
  const {
26
24
  getButtonProps,
@@ -61,9 +59,7 @@ const DialogTitle = /*#__PURE__*/React.forwardRef(function DialogTitle(component
61
59
  id: idProp,
62
60
  ...elementProps
63
61
  } = componentProps;
64
- const {
65
- store
66
- } = useDialogRootContext();
62
+ const store = useDialogRootContext();
67
63
  const id = useBaseUiId(idProp);
68
64
  store.useSyncedValueWithCleanup('titleElementId', id);
69
65
  return useRenderElement('h2', componentProps, {