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