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