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