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