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