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