@yamada-ui/modal 0.2.7 → 0.2.9

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