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