@yamada-ui/modal 0.2.7 → 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/index.js CHANGED
@@ -61,62 +61,70 @@ var [DrawerProvider, useDrawer] = (0, import_utils.createContext)({
61
61
  name: `DrawerContext`,
62
62
  errorMessage: `useDrawer returned is 'undefined'. Seems you forgot to wrap the components in "<Drawer />" `
63
63
  });
64
- var Drawer = (0, import_core.forwardRef)(({ size, ...props }, ref) => {
65
- const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Drawer", { size, ...props });
66
- const {
67
- children,
68
- isOpen,
69
- placement = "right",
70
- onClose,
71
- onOverlayClick,
72
- onEsc,
73
- onCloseComplete,
74
- withCloseButton = true,
75
- withOverlay = true,
76
- allowPinchZoom,
77
- autoFocus,
78
- restoreFocus,
79
- initialFocusRef,
80
- finalFocusRef,
81
- blockScrollOnMount,
82
- closeOnOverlay,
83
- closeOnEsc,
84
- lockFocusAcrossFrames,
85
- duration = { enter: 0.4, exit: 0.3 },
86
- ...rest
87
- } = (0, import_core.omitThemeProps)(mergedProps);
88
- const validChildren = (0, import_utils.getValidChildren)(children);
89
- const [customDrawerOverlay, ...cloneChildren] = (0, import_utils.findChildren)(validChildren, DrawerOverlay);
90
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
91
- Modal,
92
- {
93
- ref,
94
- ...{
95
- isOpen,
96
- onClose,
97
- onOverlayClick,
98
- onEsc,
99
- onCloseComplete,
100
- withCloseButton: false,
101
- withOverlay: false,
102
- allowPinchZoom,
103
- autoFocus,
104
- restoreFocus,
105
- initialFocusRef,
106
- finalFocusRef,
107
- blockScrollOnMount,
108
- closeOnOverlay,
109
- closeOnEsc,
110
- lockFocusAcrossFrames,
111
- duration
112
- },
113
- children: [
114
- customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerOverlay, {}) : null,
115
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerContent, { ...{ placement, withCloseButton, ...rest }, children: cloneChildren })
116
- ]
117
- }
118
- ) });
119
- });
64
+ var Drawer = (0, import_core.forwardRef)(
65
+ ({ size, ...props }, ref) => {
66
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Drawer", {
67
+ size,
68
+ ...props
69
+ });
70
+ const {
71
+ children,
72
+ isOpen,
73
+ placement = "right",
74
+ onClose,
75
+ onOverlayClick,
76
+ onEsc,
77
+ onCloseComplete,
78
+ withCloseButton = true,
79
+ withOverlay = true,
80
+ allowPinchZoom,
81
+ autoFocus,
82
+ restoreFocus,
83
+ initialFocusRef,
84
+ finalFocusRef,
85
+ blockScrollOnMount,
86
+ closeOnOverlay,
87
+ closeOnEsc,
88
+ lockFocusAcrossFrames,
89
+ duration = { enter: 0.4, exit: 0.3 },
90
+ ...rest
91
+ } = (0, import_core.omitThemeProps)(mergedProps);
92
+ const validChildren = (0, import_utils.getValidChildren)(children);
93
+ const [customDrawerOverlay, ...cloneChildren] = (0, import_utils.findChildren)(
94
+ validChildren,
95
+ DrawerOverlay
96
+ );
97
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
98
+ Modal,
99
+ {
100
+ ref,
101
+ ...{
102
+ isOpen,
103
+ onClose,
104
+ onOverlayClick,
105
+ onEsc,
106
+ onCloseComplete,
107
+ withCloseButton: false,
108
+ withOverlay: false,
109
+ allowPinchZoom,
110
+ autoFocus,
111
+ restoreFocus,
112
+ initialFocusRef,
113
+ finalFocusRef,
114
+ blockScrollOnMount,
115
+ closeOnOverlay,
116
+ closeOnEsc,
117
+ lockFocusAcrossFrames,
118
+ duration
119
+ },
120
+ children: [
121
+ customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerOverlay, {}) : null,
122
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerContent, { ...{ placement, withCloseButton, ...rest }, children: cloneChildren })
123
+ ]
124
+ }
125
+ ) });
126
+ }
127
+ );
120
128
  var DrawerContent = (0, import_core.forwardRef)(
121
129
  ({ className, children, placement, withCloseButton, ...rest }, ref) => {
122
130
  const { isOpen, onClose, duration } = useModal();
@@ -186,19 +194,45 @@ var DrawerHeader = (0, import_core.forwardRef)(
186
194
  ({ className, ...rest }, ref) => {
187
195
  const styles = useDrawer();
188
196
  const css = { ...styles.header };
189
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeader, { ref, className: (0, import_utils.cx)("ui-drawer-header", className), __css: css, ...rest });
197
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
198
+ ModalHeader,
199
+ {
200
+ ref,
201
+ className: (0, import_utils.cx)("ui-drawer-header", className),
202
+ __css: css,
203
+ ...rest
204
+ }
205
+ );
206
+ }
207
+ );
208
+ var DrawerBody = (0, import_core.forwardRef)(
209
+ ({ className, ...rest }, ref) => {
210
+ const styles = useDrawer();
211
+ const css = { ...styles.body };
212
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
213
+ ModalBody,
214
+ {
215
+ ref,
216
+ className: (0, import_utils.cx)("ui-drawer-body", className),
217
+ __css: css,
218
+ ...rest
219
+ }
220
+ );
190
221
  }
191
222
  );
192
- var DrawerBody = (0, import_core.forwardRef)(({ className, ...rest }, ref) => {
193
- const styles = useDrawer();
194
- const css = { ...styles.body };
195
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalBody, { ref, className: (0, import_utils.cx)("ui-drawer-body", className), __css: css, ...rest });
196
- });
197
223
  var DrawerFooter = (0, import_core.forwardRef)(
198
224
  ({ className, ...rest }, ref) => {
199
225
  const styles = useDrawer();
200
226
  const css = { ...styles.footer };
201
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalFooter, { ref, className: (0, import_utils.cx)("ui-drawer-footer", className), __css: css, ...rest });
227
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
228
+ ModalFooter,
229
+ {
230
+ ref,
231
+ className: (0, import_utils.cx)("ui-drawer-footer", className),
232
+ __css: css,
233
+ ...rest
234
+ }
235
+ );
202
236
  }
203
237
  );
204
238
 
@@ -208,107 +242,121 @@ var [ModalProvider, useModal] = (0, import_utils2.createContext)({
208
242
  name: `ModalContext`,
209
243
  errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
210
244
  });
211
- var Modal = (0, import_core2.forwardRef)(({ size, ...props }, ref) => {
212
- const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("Modal", { size, ...props });
213
- const {
214
- className,
215
- children,
216
- isOpen,
217
- onClose,
218
- onOverlayClick,
219
- onEsc,
220
- onCloseComplete,
221
- placement: _placement = "center",
222
- outside = "md",
223
- withCloseButton = true,
224
- withOverlay = true,
225
- allowPinchZoom = false,
226
- scrollBehavior = "inside",
227
- autoFocus,
228
- restoreFocus,
229
- initialFocusRef,
230
- finalFocusRef,
231
- blockScrollOnMount = true,
232
- closeOnOverlay = true,
233
- closeOnEsc = true,
234
- lockFocusAcrossFrames = true,
235
- animation = "scale",
236
- duration,
237
- ...rest
238
- } = (0, import_core2.omitThemeProps)(mergedProps);
239
- const onKeyDown = (0, import_react.useCallback)(
240
- (event) => {
241
- if (event.key !== "Escape")
242
- return;
243
- event.stopPropagation();
244
- if (closeOnEsc)
245
- onClose == null ? void 0 : onClose();
246
- onEsc == null ? void 0 : onEsc();
247
- },
248
- [closeOnEsc, onClose, onEsc]
249
- );
250
- const validChildren = (0, import_utils2.getValidChildren)(children);
251
- const [customModalOverlay, ...cloneChildren] = (0, import_utils2.findChildren)(
252
- validChildren,
253
- ModalOverlay,
254
- DialogOverlay,
255
- DrawerOverlay
256
- );
257
- let [drawerContent] = (0, import_utils2.findChildren)(validChildren, DrawerContent);
258
- if (drawerContent)
259
- drawerContent = (0, import_react.cloneElement)(drawerContent, { onKeyDown });
260
- const placement = (0, import_use_value.useValue)(_placement);
261
- const css = {
262
- position: "fixed",
263
- top: 0,
264
- left: 0,
265
- zIndex: "beerus",
266
- w: "100vw",
267
- h: "100vh",
268
- p: size !== "full" ? outside : void 0,
269
- display: "flex",
270
- justifyContent: placement.includes("right") ? "flex-start" : placement.includes("left") ? "flex-end" : "center",
271
- alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
272
- };
273
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
274
- ModalProvider,
275
- {
276
- value: {
277
- isOpen,
278
- onClose,
279
- onOverlayClick,
280
- withCloseButton,
281
- scrollBehavior,
282
- closeOnOverlay,
283
- animation,
284
- duration,
285
- styles
245
+ var Modal = (0, import_core2.forwardRef)(
246
+ ({ size, ...props }, ref) => {
247
+ const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("Modal", {
248
+ size,
249
+ ...props
250
+ });
251
+ const {
252
+ className,
253
+ children,
254
+ isOpen,
255
+ onClose,
256
+ onOverlayClick,
257
+ onEsc,
258
+ onCloseComplete,
259
+ placement: _placement = "center",
260
+ outside = "md",
261
+ withCloseButton = true,
262
+ withOverlay = true,
263
+ allowPinchZoom = false,
264
+ scrollBehavior = "inside",
265
+ autoFocus,
266
+ restoreFocus,
267
+ initialFocusRef,
268
+ finalFocusRef,
269
+ blockScrollOnMount = true,
270
+ closeOnOverlay = true,
271
+ closeOnEsc = true,
272
+ lockFocusAcrossFrames = true,
273
+ animation = "scale",
274
+ duration,
275
+ ...rest
276
+ } = (0, import_core2.omitThemeProps)(mergedProps);
277
+ const onKeyDown = (0, import_react.useCallback)(
278
+ (event) => {
279
+ if (event.key !== "Escape")
280
+ return;
281
+ event.stopPropagation();
282
+ if (closeOnEsc)
283
+ onClose == null ? void 0 : onClose();
284
+ onEsc == null ? void 0 : onEsc();
286
285
  },
287
- 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)(
288
- import_focus_lock.FocusLock,
289
- {
290
- autoFocus,
291
- initialFocusRef,
292
- finalFocusRef,
293
- restoreFocus,
294
- lockFocusAcrossFrames,
295
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
296
- import_react_remove_scroll.RemoveScroll,
297
- {
298
- allowPinchZoom,
299
- enabled: blockScrollOnMount,
300
- forwardProps: true,
301
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.ui.div, { __css: css, children: [
302
- customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModalOverlay, {}) : null,
303
- drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModalContent, { ref, className, onKeyDown, ...rest, children: cloneChildren })
304
- ] })
305
- }
306
- )
307
- }
308
- ) }) : null })
309
- }
310
- );
311
- });
286
+ [closeOnEsc, onClose, onEsc]
287
+ );
288
+ const validChildren = (0, import_utils2.getValidChildren)(children);
289
+ const [customModalOverlay, ...cloneChildren] = (0, import_utils2.findChildren)(
290
+ validChildren,
291
+ ModalOverlay,
292
+ DialogOverlay,
293
+ DrawerOverlay
294
+ );
295
+ let [drawerContent] = (0, import_utils2.findChildren)(validChildren, DrawerContent);
296
+ if (drawerContent)
297
+ drawerContent = (0, import_react.cloneElement)(drawerContent, { onKeyDown });
298
+ const placement = (0, import_use_value.useValue)(_placement);
299
+ const css = {
300
+ position: "fixed",
301
+ top: 0,
302
+ left: 0,
303
+ zIndex: "beerus",
304
+ w: "100vw",
305
+ h: "100vh",
306
+ p: size !== "full" ? outside : void 0,
307
+ display: "flex",
308
+ justifyContent: placement.includes("right") ? "flex-start" : placement.includes("left") ? "flex-end" : "center",
309
+ alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
310
+ };
311
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
312
+ ModalProvider,
313
+ {
314
+ value: {
315
+ isOpen,
316
+ onClose,
317
+ onOverlayClick,
318
+ withCloseButton,
319
+ scrollBehavior,
320
+ closeOnOverlay,
321
+ animation,
322
+ duration,
323
+ styles
324
+ },
325
+ 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)(
326
+ import_focus_lock.FocusLock,
327
+ {
328
+ autoFocus,
329
+ initialFocusRef,
330
+ finalFocusRef,
331
+ restoreFocus,
332
+ lockFocusAcrossFrames,
333
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
334
+ import_react_remove_scroll.RemoveScroll,
335
+ {
336
+ allowPinchZoom,
337
+ enabled: blockScrollOnMount,
338
+ forwardProps: true,
339
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.ui.div, { __css: css, children: [
340
+ customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModalOverlay, {}) : null,
341
+ drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
342
+ ModalContent,
343
+ {
344
+ ref,
345
+ className,
346
+ onKeyDown,
347
+ ...rest,
348
+ children: cloneChildren
349
+ }
350
+ )
351
+ ] })
352
+ }
353
+ )
354
+ }
355
+ ) }) : null })
356
+ }
357
+ );
358
+ }
359
+ );
312
360
  var getModalContentProps = (animation = "scale", duration) => {
313
361
  switch (animation) {
314
362
  case "scale":
@@ -340,7 +388,14 @@ var getModalContentProps = (animation = "scale", duration) => {
340
388
  };
341
389
  var ModalContent = (0, import_core2.forwardRef)(
342
390
  ({ className, children, __css, ...rest }, ref) => {
343
- const { styles, scrollBehavior, withCloseButton, onClose, animation, duration } = useModal();
391
+ const {
392
+ styles,
393
+ scrollBehavior,
394
+ withCloseButton,
395
+ onClose,
396
+ animation,
397
+ duration
398
+ } = useModal();
344
399
  const validChildren = (0, import_utils2.getValidChildren)(children);
345
400
  const [customModalCloseButton, ...cloneChildren] = (0, import_utils2.findChildren)(
346
401
  validChildren,
@@ -384,7 +439,14 @@ var import_utils3 = require("@yamada-ui/utils");
384
439
  var import_jsx_runtime3 = require("react/jsx-runtime");
385
440
  var ModalOverlay = (0, import_core3.forwardRef)(
386
441
  ({ className, __css, onClick, ...rest }, ref) => {
387
- const { styles, closeOnOverlay, onOverlayClick, onClose, animation, duration } = useModal();
442
+ const {
443
+ styles,
444
+ closeOnOverlay,
445
+ onOverlayClick,
446
+ onClose,
447
+ animation,
448
+ duration
449
+ } = useModal();
388
450
  const css = {
389
451
  position: "fixed",
390
452
  top: 0,
@@ -455,7 +517,15 @@ var ModalHeader = (0, import_core5.forwardRef)(
455
517
  justifyContent: "flex-start",
456
518
  ...__css ? __css : styles.header
457
519
  };
458
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.header, { ref, className: (0, import_utils5.cx)("ui-modal-header", className), __css: css, ...rest });
520
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
521
+ import_core5.ui.header,
522
+ {
523
+ ref,
524
+ className: (0, import_utils5.cx)("ui-modal-header", className),
525
+ __css: css,
526
+ ...rest
527
+ }
528
+ );
459
529
  }
460
530
  );
461
531
 
@@ -473,7 +543,15 @@ var ModalBody = (0, import_core6.forwardRef)(
473
543
  overflow: scrollBehavior === "inside" ? "auto" : void 0,
474
544
  ...__css ? __css : styles.body
475
545
  };
476
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core6.ui.main, { ref, className: (0, import_utils6.cx)("ui-modal-body", className), __css: css, ...rest });
546
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
547
+ import_core6.ui.main,
548
+ {
549
+ ref,
550
+ className: (0, import_utils6.cx)("ui-modal-body", className),
551
+ __css: css,
552
+ ...rest
553
+ }
554
+ );
477
555
  }
478
556
  );
479
557
 
@@ -490,7 +568,15 @@ var ModalFooter = (0, import_core7.forwardRef)(
490
568
  justifyContent: "flex-end",
491
569
  ...__css ? __css : styles.footer
492
570
  };
493
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.ui.footer, { ref, className: (0, import_utils7.cx)("ui-modal-footer", className), __css: css, ...rest });
571
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
572
+ import_core7.ui.footer,
573
+ {
574
+ ref,
575
+ className: (0, import_utils7.cx)("ui-modal-footer", className),
576
+ __css: css,
577
+ ...rest
578
+ }
579
+ );
494
580
  }
495
581
  );
496
582
 
@@ -503,69 +589,101 @@ var [DialogProvider, useDialog] = (0, import_utils8.createContext)({
503
589
  name: `DialogContext`,
504
590
  errorMessage: `useDialog returned is 'undefined'. Seems you forgot to wrap the components in "<Dialog />" `
505
591
  });
506
- var Dialog = (0, import_core8.forwardRef)(({ size, ...props }, ref) => {
507
- const [styles, mergedProps] = (0, import_core8.useMultiComponentStyle)("Dialog", { size, ...props });
508
- const {
509
- className,
510
- children,
511
- withOverlay = true,
512
- withCloseButton = true,
513
- header,
514
- footer,
515
- cancel,
516
- other,
517
- success,
518
- onClose,
519
- onCancel,
520
- onOther,
521
- onSuccess,
522
- ...rest
523
- } = (0, import_core8.omitThemeProps)(mergedProps);
524
- const validChildren = (0, import_utils8.getValidChildren)(children);
525
- const [customDialogOverlay] = (0, import_utils8.findChildren)(validChildren, DialogOverlay);
526
- const [customDialogCloseButton] = (0, import_utils8.findChildren)(validChildren, DialogCloseButton);
527
- const [customDialogHeader] = (0, import_utils8.findChildren)(validChildren, DialogHeader);
528
- const [customDialogBody] = (0, import_utils8.findChildren)(validChildren, DialogBody);
529
- const [customDialogFooter] = (0, import_utils8.findChildren)(validChildren, DialogFooter);
530
- const cloneChildren = !(0, import_utils8.isEmpty)(validChildren) ? (0, import_utils8.omitChildren)(
531
- validChildren,
532
- DialogOverlay,
533
- DialogCloseButton,
534
- DialogHeader,
535
- DialogBody,
536
- DialogFooter
537
- ) : children;
538
- const css = { ...styles.container };
539
- const cancelButtonProps = (0, import_utils8.isValidElement)(cancel) ? { children: cancel } : cancel;
540
- const otherButtonProps = (0, import_utils8.isValidElement)(other) ? { children: other } : other;
541
- const successButtonProps = (0, import_utils8.isValidElement)(success) ? { children: success } : success;
542
- if (cancelButtonProps && !cancelButtonProps.variant)
543
- cancelButtonProps.variant = "ghost";
544
- if (otherButtonProps && !otherButtonProps.colorScheme)
545
- otherButtonProps.colorScheme = "secondary";
546
- if (successButtonProps && !successButtonProps.colorScheme)
547
- successButtonProps.colorScheme = "primary";
548
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
549
- Modal,
550
- {
551
- ref,
552
- className: (0, import_utils8.cx)("ui-dialog", className),
553
- __css: css,
554
- ...{ size, onClose, withOverlay: false, withCloseButton: false, ...rest },
555
- children: [
556
- customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogOverlay, {}) : null,
557
- customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogCloseButton, {}) : null,
558
- customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogHeader, { children: header }) : null,
559
- customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogBody, { children: cloneChildren }) : null,
560
- 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: [
561
- cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_button.Button, { onClick: () => onCancel == null ? void 0 : onCancel(onClose), ...cancelButtonProps }) : null,
562
- otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_button.Button, { onClick: () => onOther == null ? void 0 : onOther(onClose), ...otherButtonProps }) : null,
563
- successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_button.Button, { onClick: () => onSuccess == null ? void 0 : onSuccess(onClose), ...successButtonProps }) : null
564
- ] }) }) : null
565
- ]
566
- }
567
- ) });
568
- });
592
+ var Dialog = (0, import_core8.forwardRef)(
593
+ ({ size, ...props }, ref) => {
594
+ const [styles, mergedProps] = (0, import_core8.useMultiComponentStyle)("Dialog", {
595
+ size,
596
+ ...props
597
+ });
598
+ const {
599
+ className,
600
+ children,
601
+ withOverlay = true,
602
+ withCloseButton = true,
603
+ header,
604
+ footer,
605
+ cancel,
606
+ other,
607
+ success,
608
+ onClose,
609
+ onCancel,
610
+ onOther,
611
+ onSuccess,
612
+ ...rest
613
+ } = (0, import_core8.omitThemeProps)(mergedProps);
614
+ const validChildren = (0, import_utils8.getValidChildren)(children);
615
+ const [customDialogOverlay] = (0, import_utils8.findChildren)(validChildren, DialogOverlay);
616
+ const [customDialogCloseButton] = (0, import_utils8.findChildren)(
617
+ validChildren,
618
+ DialogCloseButton
619
+ );
620
+ const [customDialogHeader] = (0, import_utils8.findChildren)(validChildren, DialogHeader);
621
+ const [customDialogBody] = (0, import_utils8.findChildren)(validChildren, DialogBody);
622
+ const [customDialogFooter] = (0, import_utils8.findChildren)(validChildren, DialogFooter);
623
+ const cloneChildren = !(0, import_utils8.isEmpty)(validChildren) ? (0, import_utils8.omitChildren)(
624
+ validChildren,
625
+ DialogOverlay,
626
+ DialogCloseButton,
627
+ DialogHeader,
628
+ DialogBody,
629
+ DialogFooter
630
+ ) : children;
631
+ const css = { ...styles.container };
632
+ const cancelButtonProps = (0, import_utils8.isValidElement)(cancel) ? { children: cancel } : cancel;
633
+ const otherButtonProps = (0, import_utils8.isValidElement)(other) ? { children: other } : other;
634
+ const successButtonProps = (0, import_utils8.isValidElement)(success) ? { children: success } : success;
635
+ if (cancelButtonProps && !cancelButtonProps.variant)
636
+ cancelButtonProps.variant = "ghost";
637
+ if (otherButtonProps && !otherButtonProps.colorScheme)
638
+ otherButtonProps.colorScheme = "secondary";
639
+ if (successButtonProps && !successButtonProps.colorScheme)
640
+ successButtonProps.colorScheme = "primary";
641
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
642
+ Modal,
643
+ {
644
+ ref,
645
+ className: (0, import_utils8.cx)("ui-dialog", className),
646
+ __css: css,
647
+ ...{
648
+ size,
649
+ onClose,
650
+ withOverlay: false,
651
+ withCloseButton: false,
652
+ ...rest
653
+ },
654
+ children: [
655
+ customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogOverlay, {}) : null,
656
+ customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogCloseButton, {}) : null,
657
+ customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogHeader, { children: header }) : null,
658
+ customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogBody, { children: cloneChildren }) : null,
659
+ 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: [
660
+ cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
661
+ import_button.Button,
662
+ {
663
+ onClick: () => onCancel == null ? void 0 : onCancel(onClose),
664
+ ...cancelButtonProps
665
+ }
666
+ ) : null,
667
+ otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
668
+ import_button.Button,
669
+ {
670
+ onClick: () => onOther == null ? void 0 : onOther(onClose),
671
+ ...otherButtonProps
672
+ }
673
+ ) : null,
674
+ successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
675
+ import_button.Button,
676
+ {
677
+ onClick: () => onSuccess == null ? void 0 : onSuccess(onClose),
678
+ ...successButtonProps
679
+ }
680
+ ) : null
681
+ ] }) }) : null
682
+ ]
683
+ }
684
+ ) });
685
+ }
686
+ );
569
687
  var DialogOverlay = (0, import_core8.forwardRef)(
570
688
  ({ className, ...rest }, ref) => {
571
689
  const styles = useDialog();
@@ -600,19 +718,45 @@ var DialogHeader = (0, import_core8.forwardRef)(
600
718
  ({ className, ...rest }, ref) => {
601
719
  const styles = useDialog();
602
720
  const css = { ...styles.header };
603
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModalHeader, { ref, className: (0, import_utils8.cx)("ui-dialog-header", className), __css: css, ...rest });
721
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
722
+ ModalHeader,
723
+ {
724
+ ref,
725
+ className: (0, import_utils8.cx)("ui-dialog-header", className),
726
+ __css: css,
727
+ ...rest
728
+ }
729
+ );
730
+ }
731
+ );
732
+ var DialogBody = (0, import_core8.forwardRef)(
733
+ ({ className, ...rest }, ref) => {
734
+ const styles = useDialog();
735
+ const css = { ...styles.body };
736
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
737
+ ModalBody,
738
+ {
739
+ ref,
740
+ className: (0, import_utils8.cx)("ui-dialog-body", className),
741
+ __css: css,
742
+ ...rest
743
+ }
744
+ );
604
745
  }
605
746
  );
606
- var DialogBody = (0, import_core8.forwardRef)(({ className, ...rest }, ref) => {
607
- const styles = useDialog();
608
- const css = { ...styles.body };
609
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModalBody, { ref, className: (0, import_utils8.cx)("ui-dialog-body", className), __css: css, ...rest });
610
- });
611
747
  var DialogFooter = (0, import_core8.forwardRef)(
612
748
  ({ className, ...rest }, ref) => {
613
749
  const styles = useDialog();
614
750
  const css = { ...styles.footer };
615
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModalFooter, { ref, className: (0, import_utils8.cx)("ui-dialog-footer", className), __css: css, ...rest });
751
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
752
+ ModalFooter,
753
+ {
754
+ ref,
755
+ className: (0, import_utils8.cx)("ui-dialog-footer", className),
756
+ __css: css,
757
+ ...rest
758
+ }
759
+ );
616
760
  }
617
761
  );
618
762
  // Annotate the CommonJS export names for ESM import in node: