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