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