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