@yamada-ui/modal 0.2.7 → 0.2.8

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.
@@ -50,7 +50,14 @@ var import_utils = require("@yamada-ui/utils");
50
50
  var import_jsx_runtime = require("react/jsx-runtime");
51
51
  var ModalOverlay = (0, import_core.forwardRef)(
52
52
  ({ className, __css, onClick, ...rest }, ref) => {
53
- const { styles, closeOnOverlay, onOverlayClick, onClose, animation, duration } = useModal();
53
+ const {
54
+ styles,
55
+ closeOnOverlay,
56
+ onOverlayClick,
57
+ onClose,
58
+ animation,
59
+ duration
60
+ } = useModal();
54
61
  const css = {
55
62
  position: "fixed",
56
63
  top: 0,
@@ -121,7 +128,15 @@ var ModalHeader = (0, import_core3.forwardRef)(
121
128
  justifyContent: "flex-start",
122
129
  ...__css ? __css : styles.header
123
130
  };
124
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.header, { ref, className: (0, import_utils3.cx)("ui-modal-header", className), __css: css, ...rest });
131
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
132
+ import_core3.ui.header,
133
+ {
134
+ ref,
135
+ className: (0, import_utils3.cx)("ui-modal-header", className),
136
+ __css: css,
137
+ ...rest
138
+ }
139
+ );
125
140
  }
126
141
  );
127
142
 
@@ -138,7 +153,15 @@ var ModalFooter = (0, import_core4.forwardRef)(
138
153
  justifyContent: "flex-end",
139
154
  ...__css ? __css : styles.footer
140
155
  };
141
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.footer, { ref, className: (0, import_utils4.cx)("ui-modal-footer", className), __css: css, ...rest });
156
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
157
+ import_core4.ui.footer,
158
+ {
159
+ ref,
160
+ className: (0, import_utils4.cx)("ui-modal-footer", className),
161
+ __css: css,
162
+ ...rest
163
+ }
164
+ );
142
165
  }
143
166
  );
144
167
 
@@ -151,69 +174,101 @@ var [DialogProvider, useDialog] = (0, import_utils5.createContext)({
151
174
  name: `DialogContext`,
152
175
  errorMessage: `useDialog returned is 'undefined'. Seems you forgot to wrap the components in "<Dialog />" `
153
176
  });
154
- var Dialog = (0, import_core5.forwardRef)(({ size, ...props }, ref) => {
155
- const [styles, mergedProps] = (0, import_core5.useMultiComponentStyle)("Dialog", { size, ...props });
156
- const {
157
- className,
158
- children,
159
- withOverlay = true,
160
- withCloseButton = true,
161
- header,
162
- footer,
163
- cancel,
164
- other,
165
- success,
166
- onClose,
167
- onCancel,
168
- onOther,
169
- onSuccess,
170
- ...rest
171
- } = (0, import_core5.omitThemeProps)(mergedProps);
172
- const validChildren = (0, import_utils5.getValidChildren)(children);
173
- const [customDialogOverlay] = (0, import_utils5.findChildren)(validChildren, DialogOverlay);
174
- const [customDialogCloseButton] = (0, import_utils5.findChildren)(validChildren, DialogCloseButton);
175
- const [customDialogHeader] = (0, import_utils5.findChildren)(validChildren, DialogHeader);
176
- const [customDialogBody] = (0, import_utils5.findChildren)(validChildren, DialogBody);
177
- const [customDialogFooter] = (0, import_utils5.findChildren)(validChildren, DialogFooter);
178
- const cloneChildren = !(0, import_utils5.isEmpty)(validChildren) ? (0, import_utils5.omitChildren)(
179
- validChildren,
180
- DialogOverlay,
181
- DialogCloseButton,
182
- DialogHeader,
183
- DialogBody,
184
- DialogFooter
185
- ) : children;
186
- const css = { ...styles.container };
187
- const cancelButtonProps = (0, import_utils5.isValidElement)(cancel) ? { children: cancel } : cancel;
188
- const otherButtonProps = (0, import_utils5.isValidElement)(other) ? { children: other } : other;
189
- const successButtonProps = (0, import_utils5.isValidElement)(success) ? { children: success } : success;
190
- if (cancelButtonProps && !cancelButtonProps.variant)
191
- cancelButtonProps.variant = "ghost";
192
- if (otherButtonProps && !otherButtonProps.colorScheme)
193
- otherButtonProps.colorScheme = "secondary";
194
- if (successButtonProps && !successButtonProps.colorScheme)
195
- successButtonProps.colorScheme = "primary";
196
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
197
- Modal,
198
- {
199
- ref,
200
- className: (0, import_utils5.cx)("ui-dialog", className),
201
- __css: css,
202
- ...{ size, onClose, withOverlay: false, withCloseButton: false, ...rest },
203
- children: [
204
- customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogOverlay, {}) : null,
205
- customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogCloseButton, {}) : null,
206
- customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogHeader, { children: header }) : null,
207
- customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogBody, { children: cloneChildren }) : null,
208
- customDialogFooter != null ? customDialogFooter : footer || cancelButtonProps || otherButtonProps || successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogFooter, { children: footer != null ? footer : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
209
- cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_button.Button, { onClick: () => onCancel == null ? void 0 : onCancel(onClose), ...cancelButtonProps }) : null,
210
- otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_button.Button, { onClick: () => onOther == null ? void 0 : onOther(onClose), ...otherButtonProps }) : null,
211
- successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_button.Button, { onClick: () => onSuccess == null ? void 0 : onSuccess(onClose), ...successButtonProps }) : null
212
- ] }) }) : null
213
- ]
214
- }
215
- ) });
216
- });
177
+ var Dialog = (0, import_core5.forwardRef)(
178
+ ({ size, ...props }, ref) => {
179
+ const [styles, mergedProps] = (0, import_core5.useMultiComponentStyle)("Dialog", {
180
+ size,
181
+ ...props
182
+ });
183
+ const {
184
+ className,
185
+ children,
186
+ withOverlay = true,
187
+ withCloseButton = true,
188
+ header,
189
+ footer,
190
+ cancel,
191
+ other,
192
+ success,
193
+ onClose,
194
+ onCancel,
195
+ onOther,
196
+ onSuccess,
197
+ ...rest
198
+ } = (0, import_core5.omitThemeProps)(mergedProps);
199
+ const validChildren = (0, import_utils5.getValidChildren)(children);
200
+ const [customDialogOverlay] = (0, import_utils5.findChildren)(validChildren, DialogOverlay);
201
+ const [customDialogCloseButton] = (0, import_utils5.findChildren)(
202
+ validChildren,
203
+ DialogCloseButton
204
+ );
205
+ const [customDialogHeader] = (0, import_utils5.findChildren)(validChildren, DialogHeader);
206
+ const [customDialogBody] = (0, import_utils5.findChildren)(validChildren, DialogBody);
207
+ const [customDialogFooter] = (0, import_utils5.findChildren)(validChildren, DialogFooter);
208
+ const cloneChildren = !(0, import_utils5.isEmpty)(validChildren) ? (0, import_utils5.omitChildren)(
209
+ validChildren,
210
+ DialogOverlay,
211
+ DialogCloseButton,
212
+ DialogHeader,
213
+ DialogBody,
214
+ DialogFooter
215
+ ) : children;
216
+ const css = { ...styles.container };
217
+ const cancelButtonProps = (0, import_utils5.isValidElement)(cancel) ? { children: cancel } : cancel;
218
+ const otherButtonProps = (0, import_utils5.isValidElement)(other) ? { children: other } : other;
219
+ const successButtonProps = (0, import_utils5.isValidElement)(success) ? { children: success } : success;
220
+ if (cancelButtonProps && !cancelButtonProps.variant)
221
+ cancelButtonProps.variant = "ghost";
222
+ if (otherButtonProps && !otherButtonProps.colorScheme)
223
+ otherButtonProps.colorScheme = "secondary";
224
+ if (successButtonProps && !successButtonProps.colorScheme)
225
+ successButtonProps.colorScheme = "primary";
226
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
227
+ Modal,
228
+ {
229
+ ref,
230
+ className: (0, import_utils5.cx)("ui-dialog", className),
231
+ __css: css,
232
+ ...{
233
+ size,
234
+ onClose,
235
+ withOverlay: false,
236
+ withCloseButton: false,
237
+ ...rest
238
+ },
239
+ children: [
240
+ customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogOverlay, {}) : null,
241
+ customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogCloseButton, {}) : null,
242
+ customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogHeader, { children: header }) : null,
243
+ customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogBody, { children: cloneChildren }) : null,
244
+ customDialogFooter != null ? customDialogFooter : footer || cancelButtonProps || otherButtonProps || successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogFooter, { children: footer != null ? footer : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
245
+ cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
246
+ import_button.Button,
247
+ {
248
+ onClick: () => onCancel == null ? void 0 : onCancel(onClose),
249
+ ...cancelButtonProps
250
+ }
251
+ ) : null,
252
+ otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
253
+ import_button.Button,
254
+ {
255
+ onClick: () => onOther == null ? void 0 : onOther(onClose),
256
+ ...otherButtonProps
257
+ }
258
+ ) : null,
259
+ successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
260
+ import_button.Button,
261
+ {
262
+ onClick: () => onSuccess == null ? void 0 : onSuccess(onClose),
263
+ ...successButtonProps
264
+ }
265
+ ) : null
266
+ ] }) }) : null
267
+ ]
268
+ }
269
+ ) });
270
+ }
271
+ );
217
272
  var DialogOverlay = (0, import_core5.forwardRef)(
218
273
  ({ className, ...rest }, ref) => {
219
274
  const styles = useDialog();
@@ -248,19 +303,45 @@ var DialogHeader = (0, import_core5.forwardRef)(
248
303
  ({ className, ...rest }, ref) => {
249
304
  const styles = useDialog();
250
305
  const css = { ...styles.header };
251
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ModalHeader, { ref, className: (0, import_utils5.cx)("ui-dialog-header", className), __css: css, ...rest });
306
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
307
+ ModalHeader,
308
+ {
309
+ ref,
310
+ className: (0, import_utils5.cx)("ui-dialog-header", className),
311
+ __css: css,
312
+ ...rest
313
+ }
314
+ );
315
+ }
316
+ );
317
+ var DialogBody = (0, import_core5.forwardRef)(
318
+ ({ className, ...rest }, ref) => {
319
+ const styles = useDialog();
320
+ const css = { ...styles.body };
321
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
322
+ ModalBody,
323
+ {
324
+ ref,
325
+ className: (0, import_utils5.cx)("ui-dialog-body", className),
326
+ __css: css,
327
+ ...rest
328
+ }
329
+ );
252
330
  }
253
331
  );
254
- var DialogBody = (0, import_core5.forwardRef)(({ className, ...rest }, ref) => {
255
- const styles = useDialog();
256
- const css = { ...styles.body };
257
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ModalBody, { ref, className: (0, import_utils5.cx)("ui-dialog-body", className), __css: css, ...rest });
258
- });
259
332
  var DialogFooter = (0, import_core5.forwardRef)(
260
333
  ({ className, ...rest }, ref) => {
261
334
  const styles = useDialog();
262
335
  const css = { ...styles.footer };
263
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ModalFooter, { ref, className: (0, import_utils5.cx)("ui-dialog-footer", className), __css: css, ...rest });
336
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
337
+ ModalFooter,
338
+ {
339
+ ref,
340
+ className: (0, import_utils5.cx)("ui-dialog-footer", className),
341
+ __css: css,
342
+ ...rest
343
+ }
344
+ );
264
345
  }
265
346
  );
266
347
 
@@ -270,62 +351,70 @@ var [DrawerProvider, useDrawer] = (0, import_utils6.createContext)({
270
351
  name: `DrawerContext`,
271
352
  errorMessage: `useDrawer returned is 'undefined'. Seems you forgot to wrap the components in "<Drawer />" `
272
353
  });
273
- var Drawer = (0, import_core6.forwardRef)(({ size, ...props }, ref) => {
274
- const [styles, mergedProps] = (0, import_core6.useMultiComponentStyle)("Drawer", { size, ...props });
275
- const {
276
- children,
277
- isOpen,
278
- placement = "right",
279
- onClose,
280
- onOverlayClick,
281
- onEsc,
282
- onCloseComplete,
283
- withCloseButton = true,
284
- withOverlay = true,
285
- allowPinchZoom,
286
- autoFocus,
287
- restoreFocus,
288
- initialFocusRef,
289
- finalFocusRef,
290
- blockScrollOnMount,
291
- closeOnOverlay,
292
- closeOnEsc,
293
- lockFocusAcrossFrames,
294
- duration = { enter: 0.4, exit: 0.3 },
295
- ...rest
296
- } = (0, import_core6.omitThemeProps)(mergedProps);
297
- const validChildren = (0, import_utils6.getValidChildren)(children);
298
- const [customDrawerOverlay, ...cloneChildren] = (0, import_utils6.findChildren)(validChildren, DrawerOverlay);
299
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
300
- Modal,
301
- {
302
- ref,
303
- ...{
304
- isOpen,
305
- onClose,
306
- onOverlayClick,
307
- onEsc,
308
- onCloseComplete,
309
- withCloseButton: false,
310
- withOverlay: false,
311
- allowPinchZoom,
312
- autoFocus,
313
- restoreFocus,
314
- initialFocusRef,
315
- finalFocusRef,
316
- blockScrollOnMount,
317
- closeOnOverlay,
318
- closeOnEsc,
319
- lockFocusAcrossFrames,
320
- duration
321
- },
322
- children: [
323
- customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerOverlay, {}) : null,
324
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerContent, { ...{ placement, withCloseButton, ...rest }, children: cloneChildren })
325
- ]
326
- }
327
- ) });
328
- });
354
+ var Drawer = (0, import_core6.forwardRef)(
355
+ ({ size, ...props }, ref) => {
356
+ const [styles, mergedProps] = (0, import_core6.useMultiComponentStyle)("Drawer", {
357
+ size,
358
+ ...props
359
+ });
360
+ const {
361
+ children,
362
+ isOpen,
363
+ placement = "right",
364
+ onClose,
365
+ onOverlayClick,
366
+ onEsc,
367
+ onCloseComplete,
368
+ withCloseButton = true,
369
+ withOverlay = true,
370
+ allowPinchZoom,
371
+ autoFocus,
372
+ restoreFocus,
373
+ initialFocusRef,
374
+ finalFocusRef,
375
+ blockScrollOnMount,
376
+ closeOnOverlay,
377
+ closeOnEsc,
378
+ lockFocusAcrossFrames,
379
+ duration = { enter: 0.4, exit: 0.3 },
380
+ ...rest
381
+ } = (0, import_core6.omitThemeProps)(mergedProps);
382
+ const validChildren = (0, import_utils6.getValidChildren)(children);
383
+ const [customDrawerOverlay, ...cloneChildren] = (0, import_utils6.findChildren)(
384
+ validChildren,
385
+ DrawerOverlay
386
+ );
387
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
388
+ Modal,
389
+ {
390
+ ref,
391
+ ...{
392
+ isOpen,
393
+ onClose,
394
+ onOverlayClick,
395
+ onEsc,
396
+ onCloseComplete,
397
+ withCloseButton: false,
398
+ withOverlay: false,
399
+ allowPinchZoom,
400
+ autoFocus,
401
+ restoreFocus,
402
+ initialFocusRef,
403
+ finalFocusRef,
404
+ blockScrollOnMount,
405
+ closeOnOverlay,
406
+ closeOnEsc,
407
+ lockFocusAcrossFrames,
408
+ duration
409
+ },
410
+ children: [
411
+ customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerOverlay, {}) : null,
412
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerContent, { ...{ placement, withCloseButton, ...rest }, children: cloneChildren })
413
+ ]
414
+ }
415
+ ) });
416
+ }
417
+ );
329
418
  var DrawerContent = (0, import_core6.forwardRef)(
330
419
  ({ className, children, placement, withCloseButton, ...rest }, ref) => {
331
420
  const { isOpen, onClose, duration } = useModal();
@@ -395,19 +484,45 @@ var DrawerHeader = (0, import_core6.forwardRef)(
395
484
  ({ className, ...rest }, ref) => {
396
485
  const styles = useDrawer();
397
486
  const css = { ...styles.header };
398
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModalHeader, { ref, className: (0, import_utils6.cx)("ui-drawer-header", className), __css: css, ...rest });
487
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
488
+ ModalHeader,
489
+ {
490
+ ref,
491
+ className: (0, import_utils6.cx)("ui-drawer-header", className),
492
+ __css: css,
493
+ ...rest
494
+ }
495
+ );
496
+ }
497
+ );
498
+ var DrawerBody = (0, import_core6.forwardRef)(
499
+ ({ className, ...rest }, ref) => {
500
+ const styles = useDrawer();
501
+ const css = { ...styles.body };
502
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
503
+ ModalBody,
504
+ {
505
+ ref,
506
+ className: (0, import_utils6.cx)("ui-drawer-body", className),
507
+ __css: css,
508
+ ...rest
509
+ }
510
+ );
399
511
  }
400
512
  );
401
- var DrawerBody = (0, import_core6.forwardRef)(({ className, ...rest }, ref) => {
402
- const styles = useDrawer();
403
- const css = { ...styles.body };
404
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModalBody, { ref, className: (0, import_utils6.cx)("ui-drawer-body", className), __css: css, ...rest });
405
- });
406
513
  var DrawerFooter = (0, import_core6.forwardRef)(
407
514
  ({ className, ...rest }, ref) => {
408
515
  const styles = useDrawer();
409
516
  const css = { ...styles.footer };
410
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModalFooter, { ref, className: (0, import_utils6.cx)("ui-drawer-footer", className), __css: css, ...rest });
517
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
518
+ ModalFooter,
519
+ {
520
+ ref,
521
+ className: (0, import_utils6.cx)("ui-drawer-footer", className),
522
+ __css: css,
523
+ ...rest
524
+ }
525
+ );
411
526
  }
412
527
  );
413
528
 
@@ -417,107 +532,121 @@ var [ModalProvider, useModal] = (0, import_utils7.createContext)({
417
532
  name: `ModalContext`,
418
533
  errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
419
534
  });
420
- var Modal = (0, import_core7.forwardRef)(({ size, ...props }, ref) => {
421
- const [styles, mergedProps] = (0, import_core7.useMultiComponentStyle)("Modal", { size, ...props });
422
- const {
423
- className,
424
- children,
425
- isOpen,
426
- onClose,
427
- onOverlayClick,
428
- onEsc,
429
- onCloseComplete,
430
- placement: _placement = "center",
431
- outside = "md",
432
- withCloseButton = true,
433
- withOverlay = true,
434
- allowPinchZoom = false,
435
- scrollBehavior = "inside",
436
- autoFocus,
437
- restoreFocus,
438
- initialFocusRef,
439
- finalFocusRef,
440
- blockScrollOnMount = true,
441
- closeOnOverlay = true,
442
- closeOnEsc = true,
443
- lockFocusAcrossFrames = true,
444
- animation = "scale",
445
- duration,
446
- ...rest
447
- } = (0, import_core7.omitThemeProps)(mergedProps);
448
- const onKeyDown = (0, import_react.useCallback)(
449
- (event) => {
450
- if (event.key !== "Escape")
451
- return;
452
- event.stopPropagation();
453
- if (closeOnEsc)
454
- onClose == null ? void 0 : onClose();
455
- onEsc == null ? void 0 : onEsc();
456
- },
457
- [closeOnEsc, onClose, onEsc]
458
- );
459
- const validChildren = (0, import_utils7.getValidChildren)(children);
460
- const [customModalOverlay, ...cloneChildren] = (0, import_utils7.findChildren)(
461
- validChildren,
462
- ModalOverlay,
463
- DialogOverlay,
464
- DrawerOverlay
465
- );
466
- let [drawerContent] = (0, import_utils7.findChildren)(validChildren, DrawerContent);
467
- if (drawerContent)
468
- drawerContent = (0, import_react.cloneElement)(drawerContent, { onKeyDown });
469
- const placement = (0, import_use_value.useValue)(_placement);
470
- const css = {
471
- position: "fixed",
472
- top: 0,
473
- left: 0,
474
- zIndex: "beerus",
475
- w: "100vw",
476
- h: "100vh",
477
- p: size !== "full" ? outside : void 0,
478
- display: "flex",
479
- justifyContent: placement.includes("right") ? "flex-start" : placement.includes("left") ? "flex-end" : "center",
480
- alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
481
- };
482
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
483
- ModalProvider,
484
- {
485
- value: {
486
- isOpen,
487
- onClose,
488
- onOverlayClick,
489
- withCloseButton,
490
- scrollBehavior,
491
- closeOnOverlay,
492
- animation,
493
- duration,
494
- styles
535
+ var Modal = (0, import_core7.forwardRef)(
536
+ ({ size, ...props }, ref) => {
537
+ const [styles, mergedProps] = (0, import_core7.useMultiComponentStyle)("Modal", {
538
+ size,
539
+ ...props
540
+ });
541
+ const {
542
+ className,
543
+ children,
544
+ isOpen,
545
+ onClose,
546
+ onOverlayClick,
547
+ onEsc,
548
+ onCloseComplete,
549
+ placement: _placement = "center",
550
+ outside = "md",
551
+ withCloseButton = true,
552
+ withOverlay = true,
553
+ allowPinchZoom = false,
554
+ scrollBehavior = "inside",
555
+ autoFocus,
556
+ restoreFocus,
557
+ initialFocusRef,
558
+ finalFocusRef,
559
+ blockScrollOnMount = true,
560
+ closeOnOverlay = true,
561
+ closeOnEsc = true,
562
+ lockFocusAcrossFrames = true,
563
+ animation = "scale",
564
+ duration,
565
+ ...rest
566
+ } = (0, import_core7.omitThemeProps)(mergedProps);
567
+ const onKeyDown = (0, import_react.useCallback)(
568
+ (event) => {
569
+ if (event.key !== "Escape")
570
+ return;
571
+ event.stopPropagation();
572
+ if (closeOnEsc)
573
+ onClose == null ? void 0 : onClose();
574
+ onEsc == null ? void 0 : onEsc();
495
575
  },
496
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_motion2.AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
497
- import_focus_lock.FocusLock,
498
- {
499
- autoFocus,
500
- initialFocusRef,
501
- finalFocusRef,
502
- restoreFocus,
503
- lockFocusAcrossFrames,
504
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
505
- import_react_remove_scroll.RemoveScroll,
506
- {
507
- allowPinchZoom,
508
- enabled: blockScrollOnMount,
509
- forwardProps: true,
510
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_core7.ui.div, { __css: css, children: [
511
- customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalOverlay, {}) : null,
512
- drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalContent, { ref, className, onKeyDown, ...rest, children: cloneChildren })
513
- ] })
514
- }
515
- )
516
- }
517
- ) }) : null })
518
- }
519
- );
520
- });
576
+ [closeOnEsc, onClose, onEsc]
577
+ );
578
+ const validChildren = (0, import_utils7.getValidChildren)(children);
579
+ const [customModalOverlay, ...cloneChildren] = (0, import_utils7.findChildren)(
580
+ validChildren,
581
+ ModalOverlay,
582
+ DialogOverlay,
583
+ DrawerOverlay
584
+ );
585
+ let [drawerContent] = (0, import_utils7.findChildren)(validChildren, DrawerContent);
586
+ if (drawerContent)
587
+ drawerContent = (0, import_react.cloneElement)(drawerContent, { onKeyDown });
588
+ const placement = (0, import_use_value.useValue)(_placement);
589
+ const css = {
590
+ position: "fixed",
591
+ top: 0,
592
+ left: 0,
593
+ zIndex: "beerus",
594
+ w: "100vw",
595
+ h: "100vh",
596
+ p: size !== "full" ? outside : void 0,
597
+ display: "flex",
598
+ justifyContent: placement.includes("right") ? "flex-start" : placement.includes("left") ? "flex-end" : "center",
599
+ alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
600
+ };
601
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
602
+ ModalProvider,
603
+ {
604
+ value: {
605
+ isOpen,
606
+ onClose,
607
+ onOverlayClick,
608
+ withCloseButton,
609
+ scrollBehavior,
610
+ closeOnOverlay,
611
+ animation,
612
+ duration,
613
+ styles
614
+ },
615
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_motion2.AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
616
+ import_focus_lock.FocusLock,
617
+ {
618
+ autoFocus,
619
+ initialFocusRef,
620
+ finalFocusRef,
621
+ restoreFocus,
622
+ lockFocusAcrossFrames,
623
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
624
+ import_react_remove_scroll.RemoveScroll,
625
+ {
626
+ allowPinchZoom,
627
+ enabled: blockScrollOnMount,
628
+ forwardProps: true,
629
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_core7.ui.div, { __css: css, children: [
630
+ customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalOverlay, {}) : null,
631
+ drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
632
+ ModalContent,
633
+ {
634
+ ref,
635
+ className,
636
+ onKeyDown,
637
+ ...rest,
638
+ children: cloneChildren
639
+ }
640
+ )
641
+ ] })
642
+ }
643
+ )
644
+ }
645
+ ) }) : null })
646
+ }
647
+ );
648
+ }
649
+ );
521
650
  var getModalContentProps = (animation = "scale", duration) => {
522
651
  switch (animation) {
523
652
  case "scale":
@@ -549,7 +678,14 @@ var getModalContentProps = (animation = "scale", duration) => {
549
678
  };
550
679
  var ModalContent = (0, import_core7.forwardRef)(
551
680
  ({ className, children, __css, ...rest }, ref) => {
552
- const { styles, scrollBehavior, withCloseButton, onClose, animation, duration } = useModal();
681
+ const {
682
+ styles,
683
+ scrollBehavior,
684
+ withCloseButton,
685
+ onClose,
686
+ animation,
687
+ duration
688
+ } = useModal();
553
689
  const validChildren = (0, import_utils7.getValidChildren)(children);
554
690
  const [customModalCloseButton, ...cloneChildren] = (0, import_utils7.findChildren)(
555
691
  validChildren,
@@ -597,7 +733,15 @@ var ModalBody = (0, import_core8.forwardRef)(
597
733
  overflow: scrollBehavior === "inside" ? "auto" : void 0,
598
734
  ...__css ? __css : styles.body
599
735
  };
600
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.ui.main, { ref, className: (0, import_utils8.cx)("ui-modal-body", className), __css: css, ...rest });
736
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
737
+ import_core8.ui.main,
738
+ {
739
+ ref,
740
+ className: (0, import_utils8.cx)("ui-modal-body", className),
741
+ __css: css,
742
+ ...rest
743
+ }
744
+ );
601
745
  }
602
746
  );
603
747
  // Annotate the CommonJS export names for ESM import in node: