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