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