@yamada-ui/modal 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dialog.js CHANGED
@@ -52,62 +52,70 @@ var [DrawerProvider, useDrawer] = (0, import_utils.createContext)({
52
52
  name: `DrawerContext`,
53
53
  errorMessage: `useDrawer returned is 'undefined'. Seems you forgot to wrap the components in "<Drawer />" `
54
54
  });
55
- var Drawer = (0, import_core.forwardRef)(({ size, ...props }, ref) => {
56
- const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Drawer", { size, ...props });
57
- const {
58
- children,
59
- isOpen,
60
- placement = "right",
61
- onClose,
62
- onOverlayClick,
63
- onEsc,
64
- onCloseComplete,
65
- withCloseButton = true,
66
- withOverlay = true,
67
- allowPinchZoom,
68
- autoFocus,
69
- restoreFocus,
70
- initialFocusRef,
71
- finalFocusRef,
72
- blockScrollOnMount,
73
- closeOnOverlay,
74
- closeOnEsc,
75
- lockFocusAcrossFrames,
76
- duration = { enter: 0.4, exit: 0.3 },
77
- ...rest
78
- } = (0, import_core.omitThemeProps)(mergedProps);
79
- const validChildren = (0, import_utils.getValidChildren)(children);
80
- const [customDrawerOverlay, ...cloneChildren] = (0, import_utils.findChildren)(validChildren, DrawerOverlay);
81
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
82
- Modal,
83
- {
84
- ref,
85
- ...{
86
- isOpen,
87
- onClose,
88
- onOverlayClick,
89
- onEsc,
90
- onCloseComplete,
91
- withCloseButton: false,
92
- withOverlay: false,
93
- allowPinchZoom,
94
- autoFocus,
95
- restoreFocus,
96
- initialFocusRef,
97
- finalFocusRef,
98
- blockScrollOnMount,
99
- closeOnOverlay,
100
- closeOnEsc,
101
- lockFocusAcrossFrames,
102
- duration
103
- },
104
- children: [
105
- customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerOverlay, {}) : null,
106
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerContent, { ...{ placement, withCloseButton, ...rest }, children: cloneChildren })
107
- ]
108
- }
109
- ) });
110
- });
55
+ var Drawer = (0, import_core.forwardRef)(
56
+ ({ size, ...props }, ref) => {
57
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Drawer", {
58
+ size,
59
+ ...props
60
+ });
61
+ const {
62
+ children,
63
+ isOpen,
64
+ placement = "right",
65
+ onClose,
66
+ onOverlayClick,
67
+ onEsc,
68
+ onCloseComplete,
69
+ withCloseButton = true,
70
+ withOverlay = true,
71
+ allowPinchZoom,
72
+ autoFocus,
73
+ restoreFocus,
74
+ initialFocusRef,
75
+ finalFocusRef,
76
+ blockScrollOnMount,
77
+ closeOnOverlay,
78
+ closeOnEsc,
79
+ lockFocusAcrossFrames,
80
+ duration = { enter: 0.4, exit: 0.3 },
81
+ ...rest
82
+ } = (0, import_core.omitThemeProps)(mergedProps);
83
+ const validChildren = (0, import_utils.getValidChildren)(children);
84
+ const [customDrawerOverlay, ...cloneChildren] = (0, import_utils.findChildren)(
85
+ validChildren,
86
+ DrawerOverlay
87
+ );
88
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
89
+ Modal,
90
+ {
91
+ ref,
92
+ ...{
93
+ isOpen,
94
+ onClose,
95
+ onOverlayClick,
96
+ onEsc,
97
+ onCloseComplete,
98
+ withCloseButton: false,
99
+ withOverlay: false,
100
+ allowPinchZoom,
101
+ autoFocus,
102
+ restoreFocus,
103
+ initialFocusRef,
104
+ finalFocusRef,
105
+ blockScrollOnMount,
106
+ closeOnOverlay,
107
+ closeOnEsc,
108
+ lockFocusAcrossFrames,
109
+ duration
110
+ },
111
+ children: [
112
+ customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerOverlay, {}) : null,
113
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerContent, { ...{ placement, withCloseButton, ...rest }, children: cloneChildren })
114
+ ]
115
+ }
116
+ ) });
117
+ }
118
+ );
111
119
  var DrawerContent = (0, import_core.forwardRef)(
112
120
  ({ className, children, placement, withCloseButton, ...rest }, ref) => {
113
121
  const { isOpen, onClose, duration } = useModal();
@@ -177,19 +185,45 @@ var DrawerHeader = (0, import_core.forwardRef)(
177
185
  ({ className, ...rest }, ref) => {
178
186
  const styles = useDrawer();
179
187
  const css = { ...styles.header };
180
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeader, { ref, className: (0, import_utils.cx)("ui-drawer-header", className), __css: css, ...rest });
188
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
189
+ ModalHeader,
190
+ {
191
+ ref,
192
+ className: (0, import_utils.cx)("ui-drawer-header", className),
193
+ __css: css,
194
+ ...rest
195
+ }
196
+ );
197
+ }
198
+ );
199
+ var DrawerBody = (0, import_core.forwardRef)(
200
+ ({ className, ...rest }, ref) => {
201
+ const styles = useDrawer();
202
+ const css = { ...styles.body };
203
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
204
+ ModalBody,
205
+ {
206
+ ref,
207
+ className: (0, import_utils.cx)("ui-drawer-body", className),
208
+ __css: css,
209
+ ...rest
210
+ }
211
+ );
181
212
  }
182
213
  );
183
- var DrawerBody = (0, import_core.forwardRef)(({ className, ...rest }, ref) => {
184
- const styles = useDrawer();
185
- const css = { ...styles.body };
186
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalBody, { ref, className: (0, import_utils.cx)("ui-drawer-body", className), __css: css, ...rest });
187
- });
188
214
  var DrawerFooter = (0, import_core.forwardRef)(
189
215
  ({ className, ...rest }, ref) => {
190
216
  const styles = useDrawer();
191
217
  const css = { ...styles.footer };
192
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalFooter, { ref, className: (0, import_utils.cx)("ui-drawer-footer", className), __css: css, ...rest });
218
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
219
+ ModalFooter,
220
+ {
221
+ ref,
222
+ className: (0, import_utils.cx)("ui-drawer-footer", className),
223
+ __css: css,
224
+ ...rest
225
+ }
226
+ );
193
227
  }
194
228
  );
195
229
 
@@ -199,107 +233,121 @@ var [ModalProvider, useModal] = (0, import_utils2.createContext)({
199
233
  name: `ModalContext`,
200
234
  errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
201
235
  });
202
- var Modal = (0, import_core2.forwardRef)(({ size, ...props }, ref) => {
203
- const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("Modal", { size, ...props });
204
- const {
205
- className,
206
- children,
207
- isOpen,
208
- onClose,
209
- onOverlayClick,
210
- onEsc,
211
- onCloseComplete,
212
- placement: _placement = "center",
213
- outside = "md",
214
- withCloseButton = true,
215
- withOverlay = true,
216
- allowPinchZoom = false,
217
- scrollBehavior = "inside",
218
- autoFocus,
219
- restoreFocus,
220
- initialFocusRef,
221
- finalFocusRef,
222
- blockScrollOnMount = true,
223
- closeOnOverlay = true,
224
- closeOnEsc = true,
225
- lockFocusAcrossFrames = true,
226
- animation = "scale",
227
- duration,
228
- ...rest
229
- } = (0, import_core2.omitThemeProps)(mergedProps);
230
- const onKeyDown = (0, import_react.useCallback)(
231
- (event) => {
232
- if (event.key !== "Escape")
233
- return;
234
- event.stopPropagation();
235
- if (closeOnEsc)
236
- onClose == null ? void 0 : onClose();
237
- onEsc == null ? void 0 : onEsc();
238
- },
239
- [closeOnEsc, onClose, onEsc]
240
- );
241
- const validChildren = (0, import_utils2.getValidChildren)(children);
242
- const [customModalOverlay, ...cloneChildren] = (0, import_utils2.findChildren)(
243
- validChildren,
244
- ModalOverlay,
245
- DialogOverlay,
246
- DrawerOverlay
247
- );
248
- let [drawerContent] = (0, import_utils2.findChildren)(validChildren, DrawerContent);
249
- if (drawerContent)
250
- drawerContent = (0, import_react.cloneElement)(drawerContent, { onKeyDown });
251
- const placement = (0, import_use_value.useValue)(_placement);
252
- const css = {
253
- position: "fixed",
254
- top: 0,
255
- left: 0,
256
- zIndex: "beerus",
257
- w: "100vw",
258
- h: "100vh",
259
- p: size !== "full" ? outside : void 0,
260
- display: "flex",
261
- justifyContent: placement.includes("right") ? "flex-start" : placement.includes("left") ? "flex-end" : "center",
262
- alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
263
- };
264
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
265
- ModalProvider,
266
- {
267
- value: {
268
- isOpen,
269
- onClose,
270
- onOverlayClick,
271
- withCloseButton,
272
- scrollBehavior,
273
- closeOnOverlay,
274
- animation,
275
- duration,
276
- styles
236
+ var Modal = (0, import_core2.forwardRef)(
237
+ ({ size, ...props }, ref) => {
238
+ const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("Modal", {
239
+ size,
240
+ ...props
241
+ });
242
+ const {
243
+ className,
244
+ children,
245
+ isOpen,
246
+ onClose,
247
+ onOverlayClick,
248
+ onEsc,
249
+ onCloseComplete,
250
+ placement: _placement = "center",
251
+ outside = "md",
252
+ withCloseButton = true,
253
+ withOverlay = true,
254
+ allowPinchZoom = false,
255
+ scrollBehavior = "inside",
256
+ autoFocus,
257
+ restoreFocus,
258
+ initialFocusRef,
259
+ finalFocusRef,
260
+ blockScrollOnMount = true,
261
+ closeOnOverlay = true,
262
+ closeOnEsc = true,
263
+ lockFocusAcrossFrames = true,
264
+ animation = "scale",
265
+ duration,
266
+ ...rest
267
+ } = (0, import_core2.omitThemeProps)(mergedProps);
268
+ const onKeyDown = (0, import_react.useCallback)(
269
+ (event) => {
270
+ if (event.key !== "Escape")
271
+ return;
272
+ event.stopPropagation();
273
+ if (closeOnEsc)
274
+ onClose == null ? void 0 : onClose();
275
+ onEsc == null ? void 0 : onEsc();
277
276
  },
278
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_motion.AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
279
- import_focus_lock.FocusLock,
280
- {
281
- autoFocus,
282
- initialFocusRef,
283
- finalFocusRef,
284
- restoreFocus,
285
- lockFocusAcrossFrames,
286
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
287
- import_react_remove_scroll.RemoveScroll,
288
- {
289
- allowPinchZoom,
290
- enabled: blockScrollOnMount,
291
- forwardProps: true,
292
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.ui.div, { __css: css, children: [
293
- customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModalOverlay, {}) : null,
294
- drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModalContent, { ref, className, onKeyDown, ...rest, children: cloneChildren })
295
- ] })
296
- }
297
- )
298
- }
299
- ) }) : null })
300
- }
301
- );
302
- });
277
+ [closeOnEsc, onClose, onEsc]
278
+ );
279
+ const validChildren = (0, import_utils2.getValidChildren)(children);
280
+ const [customModalOverlay, ...cloneChildren] = (0, import_utils2.findChildren)(
281
+ validChildren,
282
+ ModalOverlay,
283
+ DialogOverlay,
284
+ DrawerOverlay
285
+ );
286
+ let [drawerContent] = (0, import_utils2.findChildren)(validChildren, DrawerContent);
287
+ if (drawerContent)
288
+ drawerContent = (0, import_react.cloneElement)(drawerContent, { onKeyDown });
289
+ const placement = (0, import_use_value.useValue)(_placement);
290
+ const css = {
291
+ position: "fixed",
292
+ top: 0,
293
+ left: 0,
294
+ zIndex: "beerus",
295
+ w: "100vw",
296
+ h: "100vh",
297
+ p: size !== "full" ? outside : void 0,
298
+ display: "flex",
299
+ justifyContent: placement.includes("right") ? "flex-start" : placement.includes("left") ? "flex-end" : "center",
300
+ alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
301
+ };
302
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
303
+ ModalProvider,
304
+ {
305
+ value: {
306
+ isOpen,
307
+ onClose,
308
+ onOverlayClick,
309
+ withCloseButton,
310
+ scrollBehavior,
311
+ closeOnOverlay,
312
+ animation,
313
+ duration,
314
+ styles
315
+ },
316
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_motion.AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
317
+ import_focus_lock.FocusLock,
318
+ {
319
+ autoFocus,
320
+ initialFocusRef,
321
+ finalFocusRef,
322
+ restoreFocus,
323
+ lockFocusAcrossFrames,
324
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
325
+ import_react_remove_scroll.RemoveScroll,
326
+ {
327
+ allowPinchZoom,
328
+ enabled: blockScrollOnMount,
329
+ forwardProps: true,
330
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.ui.div, { __css: css, children: [
331
+ customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModalOverlay, {}) : null,
332
+ drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
333
+ ModalContent,
334
+ {
335
+ ref,
336
+ className,
337
+ onKeyDown,
338
+ ...rest,
339
+ children: cloneChildren
340
+ }
341
+ )
342
+ ] })
343
+ }
344
+ )
345
+ }
346
+ ) }) : null })
347
+ }
348
+ );
349
+ }
350
+ );
303
351
  var getModalContentProps = (animation = "scale", duration) => {
304
352
  switch (animation) {
305
353
  case "scale":
@@ -331,7 +379,14 @@ var getModalContentProps = (animation = "scale", duration) => {
331
379
  };
332
380
  var ModalContent = (0, import_core2.forwardRef)(
333
381
  ({ className, children, __css, ...rest }, ref) => {
334
- const { styles, scrollBehavior, withCloseButton, onClose, animation, duration } = useModal();
382
+ const {
383
+ styles,
384
+ scrollBehavior,
385
+ withCloseButton,
386
+ onClose,
387
+ animation,
388
+ duration
389
+ } = useModal();
335
390
  const validChildren = (0, import_utils2.getValidChildren)(children);
336
391
  const [customModalCloseButton, ...cloneChildren] = (0, import_utils2.findChildren)(
337
392
  validChildren,
@@ -375,7 +430,14 @@ var import_utils3 = require("@yamada-ui/utils");
375
430
  var import_jsx_runtime3 = require("react/jsx-runtime");
376
431
  var ModalOverlay = (0, import_core3.forwardRef)(
377
432
  ({ className, __css, onClick, ...rest }, ref) => {
378
- const { styles, closeOnOverlay, onOverlayClick, onClose, animation, duration } = useModal();
433
+ const {
434
+ styles,
435
+ closeOnOverlay,
436
+ onOverlayClick,
437
+ onClose,
438
+ animation,
439
+ duration
440
+ } = useModal();
379
441
  const css = {
380
442
  position: "fixed",
381
443
  top: 0,
@@ -446,7 +508,15 @@ var ModalHeader = (0, import_core5.forwardRef)(
446
508
  justifyContent: "flex-start",
447
509
  ...__css ? __css : styles.header
448
510
  };
449
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.header, { ref, className: (0, import_utils5.cx)("ui-modal-header", className), __css: css, ...rest });
511
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
512
+ import_core5.ui.header,
513
+ {
514
+ ref,
515
+ className: (0, import_utils5.cx)("ui-modal-header", className),
516
+ __css: css,
517
+ ...rest
518
+ }
519
+ );
450
520
  }
451
521
  );
452
522
 
@@ -464,7 +534,15 @@ var ModalBody = (0, import_core6.forwardRef)(
464
534
  overflow: scrollBehavior === "inside" ? "auto" : void 0,
465
535
  ...__css ? __css : styles.body
466
536
  };
467
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core6.ui.main, { ref, className: (0, import_utils6.cx)("ui-modal-body", className), __css: css, ...rest });
537
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
538
+ import_core6.ui.main,
539
+ {
540
+ ref,
541
+ className: (0, import_utils6.cx)("ui-modal-body", className),
542
+ __css: css,
543
+ ...rest
544
+ }
545
+ );
468
546
  }
469
547
  );
470
548
 
@@ -481,7 +559,15 @@ var ModalFooter = (0, import_core7.forwardRef)(
481
559
  justifyContent: "flex-end",
482
560
  ...__css ? __css : styles.footer
483
561
  };
484
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.ui.footer, { ref, className: (0, import_utils7.cx)("ui-modal-footer", className), __css: css, ...rest });
562
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
563
+ import_core7.ui.footer,
564
+ {
565
+ ref,
566
+ className: (0, import_utils7.cx)("ui-modal-footer", className),
567
+ __css: css,
568
+ ...rest
569
+ }
570
+ );
485
571
  }
486
572
  );
487
573
 
@@ -491,69 +577,101 @@ var [DialogProvider, useDialog] = (0, import_utils8.createContext)({
491
577
  name: `DialogContext`,
492
578
  errorMessage: `useDialog returned is 'undefined'. Seems you forgot to wrap the components in "<Dialog />" `
493
579
  });
494
- var Dialog = (0, import_core8.forwardRef)(({ size, ...props }, ref) => {
495
- const [styles, mergedProps] = (0, import_core8.useMultiComponentStyle)("Dialog", { size, ...props });
496
- const {
497
- className,
498
- children,
499
- withOverlay = true,
500
- withCloseButton = true,
501
- header,
502
- footer,
503
- cancel,
504
- other,
505
- success,
506
- onClose,
507
- onCancel,
508
- onOther,
509
- onSuccess,
510
- ...rest
511
- } = (0, import_core8.omitThemeProps)(mergedProps);
512
- const validChildren = (0, import_utils8.getValidChildren)(children);
513
- const [customDialogOverlay] = (0, import_utils8.findChildren)(validChildren, DialogOverlay);
514
- const [customDialogCloseButton] = (0, import_utils8.findChildren)(validChildren, DialogCloseButton);
515
- const [customDialogHeader] = (0, import_utils8.findChildren)(validChildren, DialogHeader);
516
- const [customDialogBody] = (0, import_utils8.findChildren)(validChildren, DialogBody);
517
- const [customDialogFooter] = (0, import_utils8.findChildren)(validChildren, DialogFooter);
518
- const cloneChildren = !(0, import_utils8.isEmpty)(validChildren) ? (0, import_utils8.omitChildren)(
519
- validChildren,
520
- DialogOverlay,
521
- DialogCloseButton,
522
- DialogHeader,
523
- DialogBody,
524
- DialogFooter
525
- ) : children;
526
- const css = { ...styles.container };
527
- const cancelButtonProps = (0, import_utils8.isValidElement)(cancel) ? { children: cancel } : cancel;
528
- const otherButtonProps = (0, import_utils8.isValidElement)(other) ? { children: other } : other;
529
- const successButtonProps = (0, import_utils8.isValidElement)(success) ? { children: success } : success;
530
- if (cancelButtonProps && !cancelButtonProps.variant)
531
- cancelButtonProps.variant = "ghost";
532
- if (otherButtonProps && !otherButtonProps.colorScheme)
533
- otherButtonProps.colorScheme = "secondary";
534
- if (successButtonProps && !successButtonProps.colorScheme)
535
- successButtonProps.colorScheme = "primary";
536
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
537
- Modal,
538
- {
539
- ref,
540
- className: (0, import_utils8.cx)("ui-dialog", className),
541
- __css: css,
542
- ...{ size, onClose, withOverlay: false, withCloseButton: false, ...rest },
543
- children: [
544
- customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogOverlay, {}) : null,
545
- customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogCloseButton, {}) : null,
546
- customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogHeader, { children: header }) : null,
547
- customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogBody, { children: cloneChildren }) : null,
548
- customDialogFooter != null ? customDialogFooter : footer || cancelButtonProps || otherButtonProps || successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogFooter, { children: footer != null ? footer : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
549
- cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_button.Button, { onClick: () => onCancel == null ? void 0 : onCancel(onClose), ...cancelButtonProps }) : null,
550
- otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_button.Button, { onClick: () => onOther == null ? void 0 : onOther(onClose), ...otherButtonProps }) : null,
551
- successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_button.Button, { onClick: () => onSuccess == null ? void 0 : onSuccess(onClose), ...successButtonProps }) : null
552
- ] }) }) : null
553
- ]
554
- }
555
- ) });
556
- });
580
+ var Dialog = (0, import_core8.forwardRef)(
581
+ ({ size, ...props }, ref) => {
582
+ const [styles, mergedProps] = (0, import_core8.useMultiComponentStyle)("Dialog", {
583
+ size,
584
+ ...props
585
+ });
586
+ const {
587
+ className,
588
+ children,
589
+ withOverlay = true,
590
+ withCloseButton = true,
591
+ header,
592
+ footer,
593
+ cancel,
594
+ other,
595
+ success,
596
+ onClose,
597
+ onCancel,
598
+ onOther,
599
+ onSuccess,
600
+ ...rest
601
+ } = (0, import_core8.omitThemeProps)(mergedProps);
602
+ const validChildren = (0, import_utils8.getValidChildren)(children);
603
+ const [customDialogOverlay] = (0, import_utils8.findChildren)(validChildren, DialogOverlay);
604
+ const [customDialogCloseButton] = (0, import_utils8.findChildren)(
605
+ validChildren,
606
+ DialogCloseButton
607
+ );
608
+ const [customDialogHeader] = (0, import_utils8.findChildren)(validChildren, DialogHeader);
609
+ const [customDialogBody] = (0, import_utils8.findChildren)(validChildren, DialogBody);
610
+ const [customDialogFooter] = (0, import_utils8.findChildren)(validChildren, DialogFooter);
611
+ const cloneChildren = !(0, import_utils8.isEmpty)(validChildren) ? (0, import_utils8.omitChildren)(
612
+ validChildren,
613
+ DialogOverlay,
614
+ DialogCloseButton,
615
+ DialogHeader,
616
+ DialogBody,
617
+ DialogFooter
618
+ ) : children;
619
+ const css = { ...styles.container };
620
+ const cancelButtonProps = (0, import_utils8.isValidElement)(cancel) ? { children: cancel } : cancel;
621
+ const otherButtonProps = (0, import_utils8.isValidElement)(other) ? { children: other } : other;
622
+ const successButtonProps = (0, import_utils8.isValidElement)(success) ? { children: success } : success;
623
+ if (cancelButtonProps && !cancelButtonProps.variant)
624
+ cancelButtonProps.variant = "ghost";
625
+ if (otherButtonProps && !otherButtonProps.colorScheme)
626
+ otherButtonProps.colorScheme = "secondary";
627
+ if (successButtonProps && !successButtonProps.colorScheme)
628
+ successButtonProps.colorScheme = "primary";
629
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
630
+ Modal,
631
+ {
632
+ ref,
633
+ className: (0, import_utils8.cx)("ui-dialog", className),
634
+ __css: css,
635
+ ...{
636
+ size,
637
+ onClose,
638
+ withOverlay: false,
639
+ withCloseButton: false,
640
+ ...rest
641
+ },
642
+ children: [
643
+ customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogOverlay, {}) : null,
644
+ customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogCloseButton, {}) : null,
645
+ customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogHeader, { children: header }) : null,
646
+ customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogBody, { children: cloneChildren }) : null,
647
+ customDialogFooter != null ? customDialogFooter : footer || cancelButtonProps || otherButtonProps || successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogFooter, { children: footer != null ? footer : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
648
+ cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
649
+ import_button.Button,
650
+ {
651
+ onClick: () => onCancel == null ? void 0 : onCancel(onClose),
652
+ ...cancelButtonProps
653
+ }
654
+ ) : null,
655
+ otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
656
+ import_button.Button,
657
+ {
658
+ onClick: () => onOther == null ? void 0 : onOther(onClose),
659
+ ...otherButtonProps
660
+ }
661
+ ) : null,
662
+ successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
663
+ import_button.Button,
664
+ {
665
+ onClick: () => onSuccess == null ? void 0 : onSuccess(onClose),
666
+ ...successButtonProps
667
+ }
668
+ ) : null
669
+ ] }) }) : null
670
+ ]
671
+ }
672
+ ) });
673
+ }
674
+ );
557
675
  var DialogOverlay = (0, import_core8.forwardRef)(
558
676
  ({ className, ...rest }, ref) => {
559
677
  const styles = useDialog();
@@ -588,19 +706,45 @@ var DialogHeader = (0, import_core8.forwardRef)(
588
706
  ({ className, ...rest }, ref) => {
589
707
  const styles = useDialog();
590
708
  const css = { ...styles.header };
591
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModalHeader, { ref, className: (0, import_utils8.cx)("ui-dialog-header", className), __css: css, ...rest });
709
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
710
+ ModalHeader,
711
+ {
712
+ ref,
713
+ className: (0, import_utils8.cx)("ui-dialog-header", className),
714
+ __css: css,
715
+ ...rest
716
+ }
717
+ );
718
+ }
719
+ );
720
+ var DialogBody = (0, import_core8.forwardRef)(
721
+ ({ className, ...rest }, ref) => {
722
+ const styles = useDialog();
723
+ const css = { ...styles.body };
724
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
725
+ ModalBody,
726
+ {
727
+ ref,
728
+ className: (0, import_utils8.cx)("ui-dialog-body", className),
729
+ __css: css,
730
+ ...rest
731
+ }
732
+ );
592
733
  }
593
734
  );
594
- var DialogBody = (0, import_core8.forwardRef)(({ className, ...rest }, ref) => {
595
- const styles = useDialog();
596
- const css = { ...styles.body };
597
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModalBody, { ref, className: (0, import_utils8.cx)("ui-dialog-body", className), __css: css, ...rest });
598
- });
599
735
  var DialogFooter = (0, import_core8.forwardRef)(
600
736
  ({ className, ...rest }, ref) => {
601
737
  const styles = useDialog();
602
738
  const css = { ...styles.footer };
603
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModalFooter, { ref, className: (0, import_utils8.cx)("ui-dialog-footer", className), __css: css, ...rest });
739
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
740
+ ModalFooter,
741
+ {
742
+ ref,
743
+ className: (0, import_utils8.cx)("ui-dialog-footer", className),
744
+ __css: css,
745
+ ...rest
746
+ }
747
+ );
604
748
  }
605
749
  );
606
750
  // Annotate the CommonJS export names for ESM import in node: