@yamada-ui/modal 0.1.12 → 0.2.0

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