@jobber/components 8.21.1 → 8.23.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.
- package/Dialog.d.ts +1 -0
- package/Dialog.js +17 -0
- package/dist/BottomSheet-cjs.js +34 -7
- package/dist/BottomSheet-es.js +34 -8
- package/dist/CSPContext-cjs.js +69 -0
- package/dist/CSPContext-es.js +46 -0
- package/dist/Card/index.cjs +3 -0
- package/dist/Card/index.mjs +3 -0
- package/dist/ComboboxChipRemove-cjs.js +54 -211
- package/dist/ComboboxChipRemove-es.js +8 -164
- package/dist/DataDump/index.cjs +3 -0
- package/dist/DataDump/index.mjs +3 -0
- package/dist/Dialog/Dialog.d.ts +3 -0
- package/dist/Dialog/Dialog.types.d.ts +205 -0
- package/dist/Dialog/DialogBottomSheet.d.ts +28 -0
- package/dist/Dialog/DialogModal.d.ts +20 -0
- package/dist/Dialog/constants.d.ts +1 -0
- package/dist/Dialog/dialogComposableShared.d.ts +53 -0
- package/dist/Dialog/dialogReturnFocus.d.ts +43 -0
- package/dist/Dialog/index.cjs +33 -0
- package/dist/Dialog/index.d.ts +4 -0
- package/dist/Dialog/index.mjs +25 -0
- package/dist/DrawerDescription-cjs.js +410 -0
- package/dist/DrawerDescription-es.js +383 -0
- package/dist/DrawerTitle-cjs.js +116 -0
- package/dist/DrawerTitle-es.js +92 -0
- package/dist/InputNumberExperimental-cjs.js +24 -23
- package/dist/InputNumberExperimental-es.js +3 -2
- package/dist/InternalBackdrop-es.js +3 -3
- package/dist/Menu/index.cjs +3 -0
- package/dist/Menu/index.mjs +3 -0
- package/dist/Menu-cjs.js +6 -4
- package/dist/Menu-es.js +6 -4
- package/dist/MenuSubmenuTrigger-cjs.js +53 -103
- package/dist/MenuSubmenuTrigger-es.js +55 -103
- package/dist/NumberFieldInput-cjs.js +9 -9
- package/dist/NumberFieldInput-es.js +3 -3
- package/dist/Page/index.cjs +3 -0
- package/dist/Page/index.mjs +3 -0
- package/dist/ScrollAreaViewport-cjs.js +921 -960
- package/dist/ScrollAreaViewport-es.js +917 -958
- package/dist/SelectGroupLabel-cjs.js +1924 -0
- package/dist/SelectGroupLabel-es.js +1888 -0
- package/dist/SelectPrimitive-cjs.js +112 -0
- package/dist/SelectPrimitive-es.js +110 -0
- package/dist/ToolbarRootContext-cjs.js +35 -0
- package/dist/ToolbarRootContext-es.js +14 -0
- package/dist/dialogReturnFocus-cjs.js +427 -0
- package/dist/dialogReturnFocus-es.js +423 -0
- package/dist/docs/SelectPrimitive/SelectPrimitive.md +326 -0
- package/dist/docs/index.md +1 -0
- package/dist/floating-ui.react-dom-cjs.js +1 -0
- package/dist/floating-ui.react-dom-es.js +2 -2
- package/dist/floating-ui.utils.dom-es.js +1 -1
- package/dist/index.cjs +15 -7
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +12 -7
- package/dist/primitives/BottomSheet/BottomSheet.d.ts +19 -1
- package/dist/primitives/BottomSheet/BottomSheet.types.d.ts +8 -0
- package/dist/primitives/BottomSheet/index.cjs +2 -0
- package/dist/primitives/BottomSheet/index.d.ts +1 -1
- package/dist/primitives/BottomSheet/index.mjs +2 -1
- package/dist/primitives/ComboboxPrimitive/index.cjs +3 -1
- package/dist/primitives/ComboboxPrimitive/index.mjs +3 -1
- package/dist/primitives/InputNumberExperimental/index.cjs +2 -1
- package/dist/primitives/InputNumberExperimental/index.mjs +2 -1
- package/dist/primitives/SelectPrimitive/SelectPrimitive.d.ts +63 -0
- package/dist/primitives/SelectPrimitive/index.cjs +29 -0
- package/dist/primitives/SelectPrimitive/index.d.ts +2 -0
- package/dist/primitives/SelectPrimitive/index.mjs +23 -0
- package/dist/primitives/SelectPrimitive/types.d.ts +16 -0
- package/dist/primitives/index.cjs +9 -1
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.mjs +8 -2
- package/dist/primitives/mergeClassName.d.ts +12 -0
- package/dist/resolveAriaLabelledBy-cjs.js +195 -0
- package/dist/resolveAriaLabelledBy-es.js +162 -0
- package/dist/styles.css +685 -0
- package/dist/unstyledPrimitives/index.cjs +434 -259
- package/dist/unstyledPrimitives/index.d.ts +2 -0
- package/dist/unstyledPrimitives/index.mjs +425 -252
- package/dist/useButton-cjs.js +2 -0
- package/dist/useButton-es.js +3 -2
- package/dist/useCompositeListItem-es.js +4 -4
- package/dist/useLabel-cjs.js +3 -329
- package/dist/useLabel-es.js +4 -299
- package/dist/useLabelableId-cjs.js +332 -0
- package/dist/useLabelableId-es.js +300 -0
- package/dist/useRenderElement-cjs.js +3 -0
- package/dist/useRenderElement-es.js +4 -1
- package/dist/utils/meta/meta.json +11 -1
- package/package.json +2 -2
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var ScrollAreaViewport = require('./ScrollAreaViewport-cjs.js');
|
|
5
|
+
var useRenderElement = require('./useRenderElement-cjs.js');
|
|
6
|
+
var InternalBackdrop = require('./InternalBackdrop-cjs.js');
|
|
7
|
+
var useButton = require('./useButton-cjs.js');
|
|
8
|
+
var CSPContext = require('./CSPContext-cjs.js');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
|
|
11
|
+
function _interopNamespaceDefault(e) {
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
29
|
+
|
|
30
|
+
const stateAttributesMapping$2 = {
|
|
31
|
+
...InternalBackdrop.popupStateMapping,
|
|
32
|
+
...useButton.transitionStatusMapping
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* An overlay displayed beneath the popup.
|
|
37
|
+
* Renders a `<div>` element.
|
|
38
|
+
*
|
|
39
|
+
* Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
|
|
40
|
+
*/
|
|
41
|
+
const DialogBackdrop = /*#__PURE__*/React__namespace.forwardRef(function DialogBackdrop(componentProps, forwardedRef) {
|
|
42
|
+
const {
|
|
43
|
+
render,
|
|
44
|
+
className,
|
|
45
|
+
forceRender = false,
|
|
46
|
+
...elementProps
|
|
47
|
+
} = componentProps;
|
|
48
|
+
const {
|
|
49
|
+
store
|
|
50
|
+
} = ScrollAreaViewport.useDialogRootContext();
|
|
51
|
+
const open = store.useState('open');
|
|
52
|
+
const nested = store.useState('nested');
|
|
53
|
+
const mounted = store.useState('mounted');
|
|
54
|
+
const transitionStatus = store.useState('transitionStatus');
|
|
55
|
+
const state = {
|
|
56
|
+
open,
|
|
57
|
+
transitionStatus
|
|
58
|
+
};
|
|
59
|
+
return useRenderElement.useRenderElement('div', componentProps, {
|
|
60
|
+
state,
|
|
61
|
+
ref: [store.context.backdropRef, forwardedRef],
|
|
62
|
+
stateAttributesMapping: stateAttributesMapping$2,
|
|
63
|
+
props: [{
|
|
64
|
+
role: 'presentation',
|
|
65
|
+
hidden: !mounted,
|
|
66
|
+
style: {
|
|
67
|
+
userSelect: 'none',
|
|
68
|
+
WebkitUserSelect: 'none'
|
|
69
|
+
}
|
|
70
|
+
}, elementProps],
|
|
71
|
+
enabled: forceRender || !nested
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
if (process.env.NODE_ENV !== "production") DialogBackdrop.displayName = "DialogBackdrop";
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A paragraph with additional information about the dialog.
|
|
78
|
+
* Renders a `<p>` element.
|
|
79
|
+
*
|
|
80
|
+
* Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
|
|
81
|
+
*/
|
|
82
|
+
const DialogDescription = /*#__PURE__*/React__namespace.forwardRef(function DialogDescription(componentProps, forwardedRef) {
|
|
83
|
+
const {
|
|
84
|
+
render,
|
|
85
|
+
className,
|
|
86
|
+
id: idProp,
|
|
87
|
+
...elementProps
|
|
88
|
+
} = componentProps;
|
|
89
|
+
const {
|
|
90
|
+
store
|
|
91
|
+
} = ScrollAreaViewport.useDialogRootContext();
|
|
92
|
+
const id = useButton.useBaseUiId(idProp);
|
|
93
|
+
store.useSyncedValueWithCleanup('descriptionElementId', id);
|
|
94
|
+
return useRenderElement.useRenderElement('p', componentProps, {
|
|
95
|
+
ref: forwardedRef,
|
|
96
|
+
props: [{
|
|
97
|
+
id
|
|
98
|
+
}, elementProps]
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
if (process.env.NODE_ENV !== "production") DialogDescription.displayName = "DialogDescription";
|
|
102
|
+
|
|
103
|
+
let DialogPopupCssVars = /*#__PURE__*/function (DialogPopupCssVars) {
|
|
104
|
+
/**
|
|
105
|
+
* Indicates how many dialogs are nested within.
|
|
106
|
+
* @type {number}
|
|
107
|
+
*/
|
|
108
|
+
DialogPopupCssVars["nestedDialogs"] = "--nested-dialogs";
|
|
109
|
+
return DialogPopupCssVars;
|
|
110
|
+
}({});
|
|
111
|
+
|
|
112
|
+
let DialogPopupDataAttributes = function (DialogPopupDataAttributes) {
|
|
113
|
+
/**
|
|
114
|
+
* Present when the dialog is open.
|
|
115
|
+
*/
|
|
116
|
+
DialogPopupDataAttributes[DialogPopupDataAttributes["open"] = InternalBackdrop.CommonPopupDataAttributes.open] = "open";
|
|
117
|
+
/**
|
|
118
|
+
* Present when the dialog is closed.
|
|
119
|
+
*/
|
|
120
|
+
DialogPopupDataAttributes[DialogPopupDataAttributes["closed"] = InternalBackdrop.CommonPopupDataAttributes.closed] = "closed";
|
|
121
|
+
/**
|
|
122
|
+
* Present when the dialog is animating in.
|
|
123
|
+
*/
|
|
124
|
+
DialogPopupDataAttributes[DialogPopupDataAttributes["startingStyle"] = InternalBackdrop.CommonPopupDataAttributes.startingStyle] = "startingStyle";
|
|
125
|
+
/**
|
|
126
|
+
* Present when the dialog is animating out.
|
|
127
|
+
*/
|
|
128
|
+
DialogPopupDataAttributes[DialogPopupDataAttributes["endingStyle"] = InternalBackdrop.CommonPopupDataAttributes.endingStyle] = "endingStyle";
|
|
129
|
+
/**
|
|
130
|
+
* Present when the dialog is nested within another dialog.
|
|
131
|
+
*/
|
|
132
|
+
DialogPopupDataAttributes["nested"] = "data-nested";
|
|
133
|
+
/**
|
|
134
|
+
* Present when the dialog has other open dialogs nested within it.
|
|
135
|
+
*/
|
|
136
|
+
DialogPopupDataAttributes["nestedDialogOpen"] = "data-nested-dialog-open";
|
|
137
|
+
return DialogPopupDataAttributes;
|
|
138
|
+
}({});
|
|
139
|
+
|
|
140
|
+
const stateAttributesMapping$1 = {
|
|
141
|
+
...InternalBackdrop.popupStateMapping,
|
|
142
|
+
...useButton.transitionStatusMapping,
|
|
143
|
+
nestedDialogOpen(value) {
|
|
144
|
+
return value ? {
|
|
145
|
+
[DialogPopupDataAttributes.nestedDialogOpen]: ''
|
|
146
|
+
} : null;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* A container for the dialog contents.
|
|
152
|
+
* Renders a `<div>` element.
|
|
153
|
+
*
|
|
154
|
+
* Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
|
|
155
|
+
*/
|
|
156
|
+
const DialogPopup = /*#__PURE__*/React__namespace.forwardRef(function DialogPopup(componentProps, forwardedRef) {
|
|
157
|
+
const {
|
|
158
|
+
className,
|
|
159
|
+
finalFocus,
|
|
160
|
+
initialFocus,
|
|
161
|
+
render,
|
|
162
|
+
...elementProps
|
|
163
|
+
} = componentProps;
|
|
164
|
+
const {
|
|
165
|
+
store
|
|
166
|
+
} = ScrollAreaViewport.useDialogRootContext();
|
|
167
|
+
const descriptionElementId = store.useState('descriptionElementId');
|
|
168
|
+
const disablePointerDismissal = store.useState('disablePointerDismissal');
|
|
169
|
+
const floatingRootContext = store.useState('floatingRootContext');
|
|
170
|
+
const rootPopupProps = store.useState('popupProps');
|
|
171
|
+
const modal = store.useState('modal');
|
|
172
|
+
const mounted = store.useState('mounted');
|
|
173
|
+
const nested = store.useState('nested');
|
|
174
|
+
const nestedOpenDialogCount = store.useState('nestedOpenDialogCount');
|
|
175
|
+
const open = store.useState('open');
|
|
176
|
+
const openMethod = store.useState('openMethod');
|
|
177
|
+
const titleElementId = store.useState('titleElementId');
|
|
178
|
+
const transitionStatus = store.useState('transitionStatus');
|
|
179
|
+
const role = store.useState('role');
|
|
180
|
+
ScrollAreaViewport.useDialogPortalContext();
|
|
181
|
+
useButton.useOpenChangeComplete({
|
|
182
|
+
open,
|
|
183
|
+
ref: store.context.popupRef,
|
|
184
|
+
onComplete() {
|
|
185
|
+
if (open) {
|
|
186
|
+
store.context.onOpenChangeComplete?.(true);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// Default initial focus logic:
|
|
192
|
+
// If opened by touch, focus the popup element to prevent the virtual keyboard from opening
|
|
193
|
+
// (this is required for Android specifically as iOS handles this automatically).
|
|
194
|
+
function defaultInitialFocus(interactionType) {
|
|
195
|
+
if (interactionType === 'touch') {
|
|
196
|
+
return store.context.popupRef.current;
|
|
197
|
+
}
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
const resolvedInitialFocus = initialFocus === undefined ? defaultInitialFocus : initialFocus;
|
|
201
|
+
const nestedDialogOpen = nestedOpenDialogCount > 0;
|
|
202
|
+
const state = {
|
|
203
|
+
open,
|
|
204
|
+
nested,
|
|
205
|
+
transitionStatus,
|
|
206
|
+
nestedDialogOpen
|
|
207
|
+
};
|
|
208
|
+
const element = useRenderElement.useRenderElement('div', componentProps, {
|
|
209
|
+
state,
|
|
210
|
+
props: [rootPopupProps, {
|
|
211
|
+
'aria-labelledby': titleElementId ?? undefined,
|
|
212
|
+
'aria-describedby': descriptionElementId ?? undefined,
|
|
213
|
+
role,
|
|
214
|
+
tabIndex: -1,
|
|
215
|
+
hidden: !mounted,
|
|
216
|
+
onKeyDown(event) {
|
|
217
|
+
if (CSPContext.COMPOSITE_KEYS.has(event.key)) {
|
|
218
|
+
event.stopPropagation();
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
style: {
|
|
222
|
+
[DialogPopupCssVars.nestedDialogs]: nestedOpenDialogCount
|
|
223
|
+
}
|
|
224
|
+
}, elementProps],
|
|
225
|
+
ref: [forwardedRef, store.context.popupRef, store.useStateSetter('popupElement')],
|
|
226
|
+
stateAttributesMapping: stateAttributesMapping$1
|
|
227
|
+
});
|
|
228
|
+
return /*#__PURE__*/jsxRuntime.jsx(InternalBackdrop.FloatingFocusManager, {
|
|
229
|
+
context: floatingRootContext,
|
|
230
|
+
openInteractionType: openMethod,
|
|
231
|
+
disabled: !mounted,
|
|
232
|
+
closeOnFocusOut: !disablePointerDismissal,
|
|
233
|
+
initialFocus: resolvedInitialFocus,
|
|
234
|
+
returnFocus: finalFocus,
|
|
235
|
+
modal: modal !== false,
|
|
236
|
+
restoreFocus: "popup",
|
|
237
|
+
children: element
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
if (process.env.NODE_ENV !== "production") DialogPopup.displayName = "DialogPopup";
|
|
241
|
+
|
|
242
|
+
let DialogViewportDataAttributes = function (DialogViewportDataAttributes) {
|
|
243
|
+
/**
|
|
244
|
+
* Present when the dialog is open.
|
|
245
|
+
*/
|
|
246
|
+
DialogViewportDataAttributes[DialogViewportDataAttributes["open"] = InternalBackdrop.CommonPopupDataAttributes.open] = "open";
|
|
247
|
+
/**
|
|
248
|
+
* Present when the dialog is closed.
|
|
249
|
+
*/
|
|
250
|
+
DialogViewportDataAttributes[DialogViewportDataAttributes["closed"] = InternalBackdrop.CommonPopupDataAttributes.closed] = "closed";
|
|
251
|
+
/**
|
|
252
|
+
* Present when the dialog is animating in.
|
|
253
|
+
*/
|
|
254
|
+
DialogViewportDataAttributes[DialogViewportDataAttributes["startingStyle"] = InternalBackdrop.CommonPopupDataAttributes.startingStyle] = "startingStyle";
|
|
255
|
+
/**
|
|
256
|
+
* Present when the dialog is animating out.
|
|
257
|
+
*/
|
|
258
|
+
DialogViewportDataAttributes[DialogViewportDataAttributes["endingStyle"] = InternalBackdrop.CommonPopupDataAttributes.endingStyle] = "endingStyle";
|
|
259
|
+
/**
|
|
260
|
+
* Present when the dialog is nested within another dialog.
|
|
261
|
+
*/
|
|
262
|
+
DialogViewportDataAttributes["nested"] = "data-nested";
|
|
263
|
+
/**
|
|
264
|
+
* Present when the dialog has other open dialogs nested within it.
|
|
265
|
+
*/
|
|
266
|
+
DialogViewportDataAttributes["nestedDialogOpen"] = "data-nested-dialog-open";
|
|
267
|
+
return DialogViewportDataAttributes;
|
|
268
|
+
}({});
|
|
269
|
+
|
|
270
|
+
const stateAttributesMapping = {
|
|
271
|
+
...InternalBackdrop.popupStateMapping,
|
|
272
|
+
...useButton.transitionStatusMapping,
|
|
273
|
+
nested(value) {
|
|
274
|
+
return value ? {
|
|
275
|
+
[DialogViewportDataAttributes.nested]: ''
|
|
276
|
+
} : null;
|
|
277
|
+
},
|
|
278
|
+
nestedDialogOpen(value) {
|
|
279
|
+
return value ? {
|
|
280
|
+
[DialogViewportDataAttributes.nestedDialogOpen]: ''
|
|
281
|
+
} : null;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* A positioning container for the dialog popup that can be made scrollable.
|
|
287
|
+
* Renders a `<div>` element.
|
|
288
|
+
*
|
|
289
|
+
* Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog)
|
|
290
|
+
*/
|
|
291
|
+
const DialogViewport = /*#__PURE__*/React__namespace.forwardRef(function DialogViewport(componentProps, forwardedRef) {
|
|
292
|
+
const {
|
|
293
|
+
className,
|
|
294
|
+
render,
|
|
295
|
+
children,
|
|
296
|
+
...elementProps
|
|
297
|
+
} = componentProps;
|
|
298
|
+
const keepMounted = ScrollAreaViewport.useDialogPortalContext();
|
|
299
|
+
const {
|
|
300
|
+
store
|
|
301
|
+
} = ScrollAreaViewport.useDialogRootContext();
|
|
302
|
+
const open = store.useState('open');
|
|
303
|
+
const nested = store.useState('nested');
|
|
304
|
+
const transitionStatus = store.useState('transitionStatus');
|
|
305
|
+
const nestedOpenDialogCount = store.useState('nestedOpenDialogCount');
|
|
306
|
+
const mounted = store.useState('mounted');
|
|
307
|
+
const nestedDialogOpen = nestedOpenDialogCount > 0;
|
|
308
|
+
const state = {
|
|
309
|
+
open,
|
|
310
|
+
nested,
|
|
311
|
+
transitionStatus,
|
|
312
|
+
nestedDialogOpen
|
|
313
|
+
};
|
|
314
|
+
const shouldRender = keepMounted || mounted;
|
|
315
|
+
return useRenderElement.useRenderElement('div', componentProps, {
|
|
316
|
+
enabled: shouldRender,
|
|
317
|
+
state,
|
|
318
|
+
ref: [forwardedRef, store.useStateSetter('viewportElement')],
|
|
319
|
+
stateAttributesMapping,
|
|
320
|
+
props: [{
|
|
321
|
+
role: 'presentation',
|
|
322
|
+
hidden: !mounted,
|
|
323
|
+
style: {
|
|
324
|
+
pointerEvents: !open ? 'none' : undefined
|
|
325
|
+
},
|
|
326
|
+
children
|
|
327
|
+
}, elementProps]
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
if (process.env.NODE_ENV !== "production") DialogViewport.displayName = "DialogViewport";
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* A handle to control a Dialog imperatively and to associate detached triggers with it.
|
|
334
|
+
*/
|
|
335
|
+
class DialogHandle {
|
|
336
|
+
/**
|
|
337
|
+
* Internal store holding the dialog state.
|
|
338
|
+
* @internal
|
|
339
|
+
*/
|
|
340
|
+
|
|
341
|
+
constructor(store) {
|
|
342
|
+
this.store = store ?? new ScrollAreaViewport.DialogStore();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Opens the dialog and associates it with the trigger with the given id.
|
|
347
|
+
* The trigger, if provided, must be a Dialog.Trigger component with this handle passed as a prop.
|
|
348
|
+
*
|
|
349
|
+
* This method should only be called in an event handler or an effect (not during rendering).
|
|
350
|
+
*
|
|
351
|
+
* @param triggerId ID of the trigger to associate with the dialog. If null, the dialog will open without a trigger association.
|
|
352
|
+
*/
|
|
353
|
+
open(triggerId) {
|
|
354
|
+
const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : undefined;
|
|
355
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
356
|
+
if (triggerId && !triggerElement) {
|
|
357
|
+
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.`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
this.store.setOpen(true, useButton.createChangeEventDetails(useButton.imperativeAction, undefined, triggerElement));
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Opens the dialog and sets the payload.
|
|
365
|
+
* Does not associate the dialog with any trigger.
|
|
366
|
+
*
|
|
367
|
+
* @param payload Payload to set when opening the dialog.
|
|
368
|
+
*/
|
|
369
|
+
openWithPayload(payload) {
|
|
370
|
+
this.store.set('payload', payload);
|
|
371
|
+
this.store.setOpen(true, useButton.createChangeEventDetails(useButton.imperativeAction, undefined, undefined));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Closes the dialog.
|
|
376
|
+
*/
|
|
377
|
+
close() {
|
|
378
|
+
this.store.setOpen(false, useButton.createChangeEventDetails(useButton.imperativeAction, undefined, undefined));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Indicates whether the dialog is currently open.
|
|
383
|
+
*/
|
|
384
|
+
get isOpen() {
|
|
385
|
+
return this.store.state.open;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Creates a new handle to connect a Dialog.Root with detached Dialog.Trigger components.
|
|
391
|
+
*/
|
|
392
|
+
function createDialogHandle() {
|
|
393
|
+
return new DialogHandle();
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* A paragraph with additional information about the drawer.
|
|
398
|
+
* Renders a `<p>` element.
|
|
399
|
+
*
|
|
400
|
+
* Documentation: [Base UI Drawer](https://base-ui.com/react/components/drawer)
|
|
401
|
+
*/
|
|
402
|
+
const DrawerDescription = DialogDescription;
|
|
403
|
+
|
|
404
|
+
exports.DialogBackdrop = DialogBackdrop;
|
|
405
|
+
exports.DialogDescription = DialogDescription;
|
|
406
|
+
exports.DialogHandle = DialogHandle;
|
|
407
|
+
exports.DialogPopup = DialogPopup;
|
|
408
|
+
exports.DialogViewport = DialogViewport;
|
|
409
|
+
exports.DrawerDescription = DrawerDescription;
|
|
410
|
+
exports.createDialogHandle = createDialogHandle;
|