@yamada-ui/modal 0.0.0-dev-20230603042803

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Hirotomo Yamada
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @yamada-ui/modal
2
+
3
+ ## Installation
4
+
5
+ ```sh
6
+ $ pnpm add @yamada-ui/modal
7
+ ```
8
+
9
+ or
10
+
11
+ ```sh
12
+ $ yarn add @yamada-ui/modal
13
+ ```
14
+
15
+ or
16
+
17
+ ```sh
18
+ $ npm install @yamada-ui/modal
19
+ ```
20
+
21
+ ## Contribution
22
+
23
+ Wouldn't you like to contribute? That's amazing! We have prepared a [contribution guide](https://github.com/hirotomoyamada/yamada-ui/blob/main/CONTRIBUTING.md) to assist you.
24
+
25
+ ## Licence
26
+
27
+ This package is licensed under the terms of the
28
+ [MIT license](https://github.com/hirotomoyamada/yamada-ui/blob/main/LICENSE).
@@ -0,0 +1,620 @@
1
+ // src/modal.tsx
2
+ import {
3
+ ui as ui5,
4
+ forwardRef as forwardRef8,
5
+ omitThemeProps as omitThemeProps3,
6
+ useMultiComponentStyle as useMultiComponentStyle3
7
+ } from "@yamada-ui/core";
8
+ import { FocusLock } from "@yamada-ui/focus-lock";
9
+ import {
10
+ motion as motion2,
11
+ AnimatePresence
12
+ } from "@yamada-ui/motion";
13
+ import { Portal } from "@yamada-ui/portal";
14
+ import { scaleFadeProps, slideFadeProps } from "@yamada-ui/transitions";
15
+ import { useValue } from "@yamada-ui/use-value";
16
+ import { cx as cx8, createContext as createContext3, getValidChildren as getValidChildren3, findChildren as findChildren3 } from "@yamada-ui/utils";
17
+ import { cloneElement, useCallback } from "react";
18
+ import { RemoveScroll } from "react-remove-scroll";
19
+
20
+ // src/modal-overlay.tsx
21
+ import { ui, forwardRef } from "@yamada-ui/core";
22
+ import { motion } from "@yamada-ui/motion";
23
+ import { fadeProps } from "@yamada-ui/transitions";
24
+ import { cx, handlerAll } from "@yamada-ui/utils";
25
+ import { jsx } from "react/jsx-runtime";
26
+ var ModalOverlay = forwardRef(
27
+ ({ className, __css, onClick, ...rest }, ref) => {
28
+ const { styles, closeOnOverlay, onOverlayClick, onClose, animation, duration } = useModal();
29
+ const css = {
30
+ position: "fixed",
31
+ top: 0,
32
+ left: 0,
33
+ w: "100vw",
34
+ h: "100vh",
35
+ ...__css ? __css : styles.overlay
36
+ };
37
+ const props = animation !== "none" ? fadeProps : {};
38
+ return /* @__PURE__ */ jsx(
39
+ ui.div,
40
+ {
41
+ as: motion.div,
42
+ ref,
43
+ className: cx("ui-modal-overlay", className),
44
+ custom: { duration },
45
+ __css: css,
46
+ onClick: handlerAll(onClick, onOverlayClick, (event) => {
47
+ event.stopPropagation();
48
+ if (closeOnOverlay)
49
+ onClose == null ? void 0 : onClose();
50
+ }),
51
+ ...props,
52
+ ...rest
53
+ }
54
+ );
55
+ }
56
+ );
57
+
58
+ // src/modal-close-button.tsx
59
+ import { CloseButton } from "@yamada-ui/close-button";
60
+ import { forwardRef as forwardRef2 } from "@yamada-ui/core";
61
+ import { cx as cx2, handlerAll as handlerAll2 } from "@yamada-ui/utils";
62
+ import { jsx as jsx2 } from "react/jsx-runtime";
63
+ var ModalCloseButton = forwardRef2(
64
+ ({ onClick, __css, ...rest }, ref) => {
65
+ const { styles, onClose } = useModal();
66
+ const css = {
67
+ position: "absolute",
68
+ ...__css ? __css : styles.closeButton
69
+ };
70
+ return /* @__PURE__ */ jsx2(
71
+ CloseButton,
72
+ {
73
+ ref,
74
+ className: cx2("ui-modal-close-button"),
75
+ __css: css,
76
+ onClick: handlerAll2(onClick, (event) => {
77
+ event.stopPropagation();
78
+ onClose == null ? void 0 : onClose();
79
+ }),
80
+ ...rest
81
+ }
82
+ );
83
+ }
84
+ );
85
+
86
+ // src/modal-header.tsx
87
+ import { ui as ui2, forwardRef as forwardRef3 } from "@yamada-ui/core";
88
+ import { cx as cx3 } from "@yamada-ui/utils";
89
+ import { jsx as jsx3 } from "react/jsx-runtime";
90
+ var ModalHeader = forwardRef3(
91
+ ({ className, __css, ...rest }, ref) => {
92
+ const { styles } = useModal();
93
+ const css = {
94
+ display: "flex",
95
+ alignItems: "center",
96
+ justifyContent: "flex-start",
97
+ ...__css ? __css : styles.header
98
+ };
99
+ return /* @__PURE__ */ jsx3(ui2.header, { ref, className: cx3("ui-modal-header", className), __css: css, ...rest });
100
+ }
101
+ );
102
+
103
+ // src/modal-body.tsx
104
+ import { ui as ui3, forwardRef as forwardRef4 } from "@yamada-ui/core";
105
+ import { cx as cx4 } from "@yamada-ui/utils";
106
+ import { jsx as jsx4 } from "react/jsx-runtime";
107
+ var ModalBody = forwardRef4(
108
+ ({ className, __css, ...rest }, ref) => {
109
+ const { styles, scrollBehavior } = useModal();
110
+ const css = {
111
+ display: "flex",
112
+ flexDirection: "column",
113
+ alignItems: "flex-start",
114
+ overflow: scrollBehavior === "inside" ? "auto" : void 0,
115
+ ...__css ? __css : styles.body
116
+ };
117
+ return /* @__PURE__ */ jsx4(ui3.main, { ref, className: cx4("ui-modal-body", className), __css: css, ...rest });
118
+ }
119
+ );
120
+
121
+ // src/modal-footer.tsx
122
+ import { ui as ui4, forwardRef as forwardRef5 } from "@yamada-ui/core";
123
+ import { cx as cx5 } from "@yamada-ui/utils";
124
+ import { jsx as jsx5 } from "react/jsx-runtime";
125
+ var ModalFooter = forwardRef5(
126
+ ({ className, __css, ...rest }, ref) => {
127
+ const { styles } = useModal();
128
+ const css = {
129
+ display: "flex",
130
+ alignItems: "center",
131
+ justifyContent: "flex-end",
132
+ ...__css ? __css : styles.footer
133
+ };
134
+ return /* @__PURE__ */ jsx5(ui4.footer, { ref, className: cx5("ui-modal-footer", className), __css: css, ...rest });
135
+ }
136
+ );
137
+
138
+ // src/dialog.tsx
139
+ import { Button } from "@yamada-ui/button";
140
+ import {
141
+ forwardRef as forwardRef6,
142
+ useMultiComponentStyle,
143
+ omitThemeProps
144
+ } from "@yamada-ui/core";
145
+ import {
146
+ createContext,
147
+ getValidChildren,
148
+ findChildren,
149
+ omitChildren,
150
+ isValidElement,
151
+ isEmpty,
152
+ cx as cx6
153
+ } from "@yamada-ui/utils";
154
+ import { Fragment, jsx as jsx6, jsxs } from "react/jsx-runtime";
155
+ var [DialogProvider, useDialog] = createContext({
156
+ name: `DialogContext`,
157
+ errorMessage: `useDialog returned is 'undefined'. Seems you forgot to wrap the components in "<Dialog />" `
158
+ });
159
+ var Dialog = forwardRef6(({ size, ...props }, ref) => {
160
+ const [styles, mergedProps] = useMultiComponentStyle("Dialog", { size, ...props });
161
+ const {
162
+ className,
163
+ children,
164
+ withOverlay = true,
165
+ withCloseButton = true,
166
+ header,
167
+ footer,
168
+ cancel,
169
+ other,
170
+ success,
171
+ onClose,
172
+ onCancel,
173
+ onOther,
174
+ onSuccess,
175
+ ...rest
176
+ } = omitThemeProps(mergedProps);
177
+ const validChildren = getValidChildren(children);
178
+ const [customDialogOverlay] = findChildren(validChildren, DialogOverlay);
179
+ const [customDialogCloseButton] = findChildren(validChildren, DialogCloseButton);
180
+ const [customDialogHeader] = findChildren(validChildren, DialogHeader);
181
+ const [customDialogBody] = findChildren(validChildren, DialogBody);
182
+ const [customDialogFooter] = findChildren(validChildren, DialogFooter);
183
+ const cloneChildren = !isEmpty(validChildren) ? omitChildren(
184
+ validChildren,
185
+ DialogOverlay,
186
+ DialogCloseButton,
187
+ DialogHeader,
188
+ DialogBody,
189
+ DialogFooter
190
+ ) : children;
191
+ const css = { ...styles.container };
192
+ const cancelButtonProps = isValidElement(cancel) ? { children: cancel } : cancel;
193
+ const otherButtonProps = isValidElement(other) ? { children: other } : other;
194
+ const successButtonProps = isValidElement(success) ? { children: success } : success;
195
+ if (cancelButtonProps && !cancelButtonProps.variant)
196
+ cancelButtonProps.variant = "ghost";
197
+ if (otherButtonProps && !otherButtonProps.colorScheme)
198
+ otherButtonProps.colorScheme = "secondary";
199
+ if (successButtonProps && !successButtonProps.colorScheme)
200
+ successButtonProps.colorScheme = "primary";
201
+ return /* @__PURE__ */ jsx6(DialogProvider, { value: styles, children: /* @__PURE__ */ jsxs(
202
+ Modal,
203
+ {
204
+ ref,
205
+ __css: css,
206
+ ...{ size, onClose, withOverlay: false, withCloseButton: false, ...rest },
207
+ children: [
208
+ customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ jsx6(DialogOverlay, {}) : null,
209
+ customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ jsx6(DialogCloseButton, {}) : null,
210
+ customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ jsx6(DialogHeader, { children: header }) : null,
211
+ customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ jsx6(DialogBody, { children: cloneChildren }) : null,
212
+ customDialogFooter != null ? customDialogFooter : footer || cancelButtonProps || otherButtonProps || successButtonProps ? /* @__PURE__ */ jsx6(DialogFooter, { children: footer != null ? footer : /* @__PURE__ */ jsxs(Fragment, { children: [
213
+ cancelButtonProps ? /* @__PURE__ */ jsx6(Button, { onClick: () => onCancel == null ? void 0 : onCancel(onClose), ...cancelButtonProps }) : null,
214
+ otherButtonProps ? /* @__PURE__ */ jsx6(Button, { onClick: () => onOther == null ? void 0 : onOther(onClose), ...otherButtonProps }) : null,
215
+ successButtonProps ? /* @__PURE__ */ jsx6(Button, { onClick: () => onSuccess == null ? void 0 : onSuccess(onClose), ...successButtonProps }) : null
216
+ ] }) }) : null
217
+ ]
218
+ }
219
+ ) });
220
+ });
221
+ var DialogOverlay = forwardRef6(
222
+ ({ className, ...rest }, ref) => {
223
+ const styles = useDialog();
224
+ const css = { ...styles.overlay };
225
+ return /* @__PURE__ */ jsx6(
226
+ ModalOverlay,
227
+ {
228
+ ref,
229
+ className: cx6("ui-dialog-overlay", className),
230
+ __css: css,
231
+ ...rest
232
+ }
233
+ );
234
+ }
235
+ );
236
+ var DialogCloseButton = forwardRef6(
237
+ ({ className, ...rest }, ref) => {
238
+ const styles = useDialog();
239
+ const css = { ...styles.closeButton };
240
+ return /* @__PURE__ */ jsx6(
241
+ ModalCloseButton,
242
+ {
243
+ ref,
244
+ className: cx6("ui-dialog-close-button", className),
245
+ __css: css,
246
+ ...rest
247
+ }
248
+ );
249
+ }
250
+ );
251
+ var DialogHeader = forwardRef6(
252
+ ({ className, ...rest }, ref) => {
253
+ const styles = useDialog();
254
+ const css = { ...styles.header };
255
+ return /* @__PURE__ */ jsx6(ModalHeader, { ref, className: cx6("ui-dialog-header", className), __css: css, ...rest });
256
+ }
257
+ );
258
+ var DialogBody = forwardRef6(({ className, ...rest }, ref) => {
259
+ const styles = useDialog();
260
+ const css = { ...styles.body };
261
+ return /* @__PURE__ */ jsx6(ModalBody, { ref, className: cx6("ui-dialog-body", className), __css: css, ...rest });
262
+ });
263
+ var DialogFooter = forwardRef6(
264
+ ({ className, ...rest }, ref) => {
265
+ const styles = useDialog();
266
+ const css = { ...styles.footer };
267
+ return /* @__PURE__ */ jsx6(ModalFooter, { ref, className: cx6("ui-dialog-footer", className), __css: css, ...rest });
268
+ }
269
+ );
270
+
271
+ // src/drawer.tsx
272
+ import {
273
+ forwardRef as forwardRef7,
274
+ useMultiComponentStyle as useMultiComponentStyle2,
275
+ omitThemeProps as omitThemeProps2
276
+ } from "@yamada-ui/core";
277
+ import { Slide } from "@yamada-ui/transitions";
278
+ import { createContext as createContext2, getValidChildren as getValidChildren2, findChildren as findChildren2, cx as cx7 } from "@yamada-ui/utils";
279
+ import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
280
+ var [DrawerProvider, useDrawer] = createContext2({
281
+ name: `DrawerContext`,
282
+ errorMessage: `useDrawer returned is 'undefined'. Seems you forgot to wrap the components in "<Drawer />" `
283
+ });
284
+ var Drawer = forwardRef7(({ size, ...props }, ref) => {
285
+ const [styles, mergedProps] = useMultiComponentStyle2("Drawer", { size, ...props });
286
+ const {
287
+ className,
288
+ children,
289
+ isOpen,
290
+ placement = "right",
291
+ onClose,
292
+ onOverlayClick,
293
+ onEsc,
294
+ onCloseComplete,
295
+ withCloseButton = true,
296
+ withOverlay = true,
297
+ allowPinchZoom,
298
+ autoFocus,
299
+ restoreFocus,
300
+ initialFocusRef,
301
+ finalFocusRef,
302
+ blockScrollOnMount,
303
+ closeOnOverlay,
304
+ closeOnEsc,
305
+ lockFocusAcrossFrames,
306
+ duration = { enter: 0.4, exit: 0.3 },
307
+ ...rest
308
+ } = omitThemeProps2(mergedProps);
309
+ const validChildren = getValidChildren2(children);
310
+ const [customDrawerOverlay, ...cloneChildren] = findChildren2(validChildren, DrawerOverlay);
311
+ return /* @__PURE__ */ jsx7(DrawerProvider, { value: styles, children: /* @__PURE__ */ jsxs2(
312
+ Modal,
313
+ {
314
+ ref,
315
+ ...{
316
+ isOpen,
317
+ onClose,
318
+ onOverlayClick,
319
+ onEsc,
320
+ onCloseComplete,
321
+ withCloseButton: false,
322
+ withOverlay: false,
323
+ allowPinchZoom,
324
+ autoFocus,
325
+ restoreFocus,
326
+ initialFocusRef,
327
+ finalFocusRef,
328
+ blockScrollOnMount,
329
+ closeOnOverlay,
330
+ closeOnEsc,
331
+ lockFocusAcrossFrames,
332
+ duration
333
+ },
334
+ children: [
335
+ customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ jsx7(DrawerOverlay, {}) : null,
336
+ /* @__PURE__ */ jsx7(DrawerContent, { ...{ placement, withCloseButton, ...rest }, children: cloneChildren })
337
+ ]
338
+ }
339
+ ) });
340
+ });
341
+ var DrawerContent = forwardRef7(
342
+ ({ className, children, placement, withCloseButton, ...rest }, ref) => {
343
+ const { isOpen, onClose, duration } = useModal();
344
+ const styles = useDrawer();
345
+ const validChildren = getValidChildren2(children);
346
+ const [customDrawerCloseButton, ...cloneChildren] = findChildren2(
347
+ validChildren,
348
+ DrawerCloseButton
349
+ );
350
+ const css = {
351
+ display: "flex",
352
+ flexDirection: "column",
353
+ width: "100%",
354
+ outline: 0,
355
+ ...styles.container
356
+ };
357
+ return /* @__PURE__ */ jsxs2(
358
+ Slide,
359
+ {
360
+ ref,
361
+ className: cx7("ui-drawer", className),
362
+ tabIndex: -1,
363
+ isOpen,
364
+ placement,
365
+ duration,
366
+ __css: css,
367
+ ...rest,
368
+ children: [
369
+ customDrawerCloseButton != null ? customDrawerCloseButton : withCloseButton && onClose ? /* @__PURE__ */ jsx7(DrawerCloseButton, {}) : null,
370
+ cloneChildren
371
+ ]
372
+ }
373
+ );
374
+ }
375
+ );
376
+ var DrawerOverlay = forwardRef7(
377
+ ({ className, ...rest }, ref) => {
378
+ const styles = useDrawer();
379
+ const css = { ...styles.overlay };
380
+ return /* @__PURE__ */ jsx7(
381
+ ModalOverlay,
382
+ {
383
+ ref,
384
+ className: cx7("ui-drawer-overlay", className),
385
+ __css: css,
386
+ ...rest
387
+ }
388
+ );
389
+ }
390
+ );
391
+ var DrawerCloseButton = forwardRef7(
392
+ ({ className, ...rest }, ref) => {
393
+ const styles = useDrawer();
394
+ const css = { ...styles.closeButton };
395
+ return /* @__PURE__ */ jsx7(
396
+ ModalCloseButton,
397
+ {
398
+ ref,
399
+ className: cx7("ui-drawer-close-button", className),
400
+ __css: css,
401
+ ...rest
402
+ }
403
+ );
404
+ }
405
+ );
406
+ var DrawerHeader = forwardRef7(
407
+ ({ className, ...rest }, ref) => {
408
+ const styles = useDrawer();
409
+ const css = { ...styles.header };
410
+ return /* @__PURE__ */ jsx7(ModalHeader, { ref, className: cx7("ui-drawer-header", className), __css: css, ...rest });
411
+ }
412
+ );
413
+ var DrawerBody = forwardRef7(({ className, ...rest }, ref) => {
414
+ const styles = useDrawer();
415
+ const css = { ...styles.body };
416
+ return /* @__PURE__ */ jsx7(ModalBody, { ref, className: cx7("ui-drawer-body", className), __css: css, ...rest });
417
+ });
418
+ var DrawerFooter = forwardRef7(
419
+ ({ className, ...rest }, ref) => {
420
+ const styles = useDrawer();
421
+ const css = { ...styles.footer };
422
+ return /* @__PURE__ */ jsx7(ModalFooter, { ref, className: cx7("ui-drawer-footer", className), __css: css, ...rest });
423
+ }
424
+ );
425
+
426
+ // src/modal.tsx
427
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
428
+ var [ModalProvider, useModal] = createContext3({
429
+ name: `ModalContext`,
430
+ errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
431
+ });
432
+ var Modal = forwardRef8(({ size, ...props }, ref) => {
433
+ const [styles, mergedProps] = useMultiComponentStyle3("Modal", { size, ...props });
434
+ const {
435
+ className,
436
+ children,
437
+ isOpen,
438
+ onClose,
439
+ onOverlayClick,
440
+ onEsc,
441
+ onCloseComplete,
442
+ placement: _placement = "center",
443
+ outside = "md",
444
+ withCloseButton = true,
445
+ withOverlay = true,
446
+ allowPinchZoom = false,
447
+ scrollBehavior = "inside",
448
+ autoFocus,
449
+ restoreFocus,
450
+ initialFocusRef,
451
+ finalFocusRef,
452
+ blockScrollOnMount = true,
453
+ closeOnOverlay = true,
454
+ closeOnEsc = true,
455
+ lockFocusAcrossFrames = true,
456
+ animation = "scale",
457
+ duration,
458
+ ...rest
459
+ } = omitThemeProps3(mergedProps);
460
+ const onKeyDown = useCallback(
461
+ (event) => {
462
+ if (event.key !== "Escape")
463
+ return;
464
+ event.stopPropagation();
465
+ if (closeOnEsc)
466
+ onClose == null ? void 0 : onClose();
467
+ onEsc == null ? void 0 : onEsc();
468
+ },
469
+ [closeOnEsc, onClose, onEsc]
470
+ );
471
+ const validChildren = getValidChildren3(children);
472
+ const [customModalOverlay, ...cloneChildren] = findChildren3(
473
+ validChildren,
474
+ ModalOverlay,
475
+ DialogOverlay,
476
+ DrawerOverlay
477
+ );
478
+ let [drawerContent] = findChildren3(validChildren, DrawerContent);
479
+ if (drawerContent)
480
+ drawerContent = cloneElement(drawerContent, { onKeyDown });
481
+ const placement = useValue(_placement);
482
+ const css = {
483
+ position: "fixed",
484
+ top: 0,
485
+ left: 0,
486
+ w: "100vw",
487
+ h: "100vh",
488
+ p: size !== "full" ? outside : void 0,
489
+ display: "flex",
490
+ justifyContent: placement.includes("right") ? "flex-start" : placement.includes("left") ? "flex-end" : "center",
491
+ alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
492
+ };
493
+ return /* @__PURE__ */ jsx8(
494
+ ModalProvider,
495
+ {
496
+ value: {
497
+ isOpen,
498
+ onClose,
499
+ onOverlayClick,
500
+ withCloseButton,
501
+ scrollBehavior,
502
+ closeOnOverlay,
503
+ animation,
504
+ duration,
505
+ styles
506
+ },
507
+ children: /* @__PURE__ */ jsx8(AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ jsx8(Portal, { children: /* @__PURE__ */ jsx8(
508
+ FocusLock,
509
+ {
510
+ autoFocus,
511
+ initialFocusRef,
512
+ finalFocusRef,
513
+ restoreFocus,
514
+ lockFocusAcrossFrames,
515
+ children: /* @__PURE__ */ jsx8(
516
+ RemoveScroll,
517
+ {
518
+ allowPinchZoom,
519
+ enabled: blockScrollOnMount,
520
+ forwardProps: true,
521
+ children: /* @__PURE__ */ jsxs3(ui5.div, { __css: css, children: [
522
+ customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ jsx8(ModalOverlay, {}) : null,
523
+ drawerContent != null ? drawerContent : /* @__PURE__ */ jsx8(ModalContent, { ref, className, onKeyDown, ...rest, children: cloneChildren })
524
+ ] })
525
+ }
526
+ )
527
+ }
528
+ ) }) : null })
529
+ }
530
+ );
531
+ });
532
+ var getModalContentProps = (animation = "scale", duration) => {
533
+ switch (animation) {
534
+ case "scale":
535
+ return {
536
+ ...scaleFadeProps,
537
+ custom: { scale: 0.95, reverse: true, duration }
538
+ };
539
+ case "top":
540
+ return {
541
+ ...slideFadeProps,
542
+ custom: { offsetY: -16, reverse: true, duration }
543
+ };
544
+ case "right":
545
+ return {
546
+ ...slideFadeProps,
547
+ custom: { offsetX: 16, reverse: true, duration }
548
+ };
549
+ case "left":
550
+ return {
551
+ ...slideFadeProps,
552
+ custom: { offsetX: -16, reverse: true, duration }
553
+ };
554
+ case "bottom":
555
+ return {
556
+ ...slideFadeProps,
557
+ custom: { offsetY: 16, reverse: true, duration }
558
+ };
559
+ }
560
+ };
561
+ var ModalContent = forwardRef8(
562
+ ({ className, children, __css, ...rest }, ref) => {
563
+ const { styles, scrollBehavior, withCloseButton, onClose, animation, duration } = useModal();
564
+ const validChildren = getValidChildren3(children);
565
+ const [customModalCloseButton, ...cloneChildren] = findChildren3(
566
+ validChildren,
567
+ ModalCloseButton,
568
+ DialogCloseButton
569
+ );
570
+ const props = animation !== "none" ? getModalContentProps(animation, duration) : {};
571
+ const css = {
572
+ position: "relative",
573
+ maxH: "100%",
574
+ display: "flex",
575
+ flexDirection: "column",
576
+ overflow: scrollBehavior === "inside" ? "hidden" : "auto",
577
+ outline: 0,
578
+ ...__css ? __css : styles.container
579
+ };
580
+ return /* @__PURE__ */ jsxs3(
581
+ ui5.section,
582
+ {
583
+ as: motion2.section,
584
+ ref,
585
+ className: cx8("ui-modal", className),
586
+ tabIndex: -1,
587
+ __css: css,
588
+ ...props,
589
+ ...rest,
590
+ children: [
591
+ customModalCloseButton != null ? customModalCloseButton : withCloseButton && onClose ? /* @__PURE__ */ jsx8(ModalCloseButton, {}) : null,
592
+ cloneChildren
593
+ ]
594
+ }
595
+ );
596
+ }
597
+ );
598
+
599
+ export {
600
+ useModal,
601
+ Modal,
602
+ ModalOverlay,
603
+ ModalCloseButton,
604
+ ModalHeader,
605
+ ModalBody,
606
+ ModalFooter,
607
+ Drawer,
608
+ DrawerContent,
609
+ DrawerOverlay,
610
+ DrawerCloseButton,
611
+ DrawerHeader,
612
+ DrawerBody,
613
+ DrawerFooter,
614
+ Dialog,
615
+ DialogOverlay,
616
+ DialogCloseButton,
617
+ DialogHeader,
618
+ DialogBody,
619
+ DialogFooter
620
+ };
@@ -0,0 +1,37 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { ThemeProps } from '@yamada-ui/core';
3
+ import { ButtonProps } from '@yamada-ui/button';
4
+ import { CloseButtonProps } from '@yamada-ui/close-button';
5
+ import { ReactNode } from 'react';
6
+ import { ModalProps } from './modal.js';
7
+ import { ModalOverlayProps } from './modal-overlay.js';
8
+ import { ModalHeaderProps } from './modal-header.js';
9
+ import { ModalBodyProps } from './modal-body.js';
10
+ import { ModalFooterProps } from './modal-footer.js';
11
+ import '@yamada-ui/focus-lock';
12
+ import '@yamada-ui/motion';
13
+
14
+ type DialogOptions = {
15
+ header?: ReactNode;
16
+ footer?: ReactNode;
17
+ cancel?: ReactNode | ButtonProps;
18
+ other?: ReactNode | ButtonProps;
19
+ success?: ReactNode | ButtonProps;
20
+ onCancel?: (onClose: (() => void) | undefined) => void;
21
+ onOther?: (onClose: (() => void) | undefined) => void;
22
+ onSuccess?: (onClose: (() => void) | undefined) => void;
23
+ };
24
+ type DialogProps = Omit<ModalProps, keyof ThemeProps> & ThemeProps<'Dialog'> & DialogOptions;
25
+ declare const Dialog: _yamada_ui_core.Component<"section", DialogProps>;
26
+ type DialogOverlayProps = ModalOverlayProps;
27
+ declare const DialogOverlay: _yamada_ui_core.Component<"div", ModalOverlayProps>;
28
+ type DialogCloseButtonProps = CloseButtonProps;
29
+ declare const DialogCloseButton: _yamada_ui_core.Component<"button", CloseButtonProps>;
30
+ type DialogHeaderProps = ModalHeaderProps;
31
+ declare const DialogHeader: _yamada_ui_core.Component<"header", ModalHeaderProps>;
32
+ type DialogBodyProps = ModalBodyProps;
33
+ declare const DialogBody: _yamada_ui_core.Component<"main", ModalBodyProps>;
34
+ type DialogFooterProps = ModalFooterProps;
35
+ declare const DialogFooter: _yamada_ui_core.Component<"footer", ModalFooterProps>;
36
+
37
+ export { Dialog, DialogBody, DialogBodyProps, DialogCloseButton, DialogCloseButtonProps, DialogFooter, DialogFooterProps, DialogHeader, DialogHeaderProps, DialogOverlay, DialogOverlayProps, DialogProps };