@yamada-ui/modal 1.3.9 → 1.3.10-dev-20240917033401
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-2EF6C34T.mjs +35 -0
- package/dist/chunk-2EF6C34T.mjs.map +1 -0
- package/dist/chunk-2GGZOTUT.mjs +32 -0
- package/dist/chunk-2GGZOTUT.mjs.map +1 -0
- package/dist/chunk-2UHL64SV.mjs +150 -0
- package/dist/chunk-2UHL64SV.mjs.map +1 -0
- package/dist/chunk-2XQPQIQG.mjs +32 -0
- package/dist/chunk-2XQPQIQG.mjs.map +1 -0
- package/dist/chunk-3CPIBNSS.mjs +32 -0
- package/dist/chunk-3CPIBNSS.mjs.map +1 -0
- package/dist/chunk-3S4JQQU3.mjs +32 -0
- package/dist/chunk-3S4JQQU3.mjs.map +1 -0
- package/dist/chunk-4G6PCQ4G.mjs +51 -0
- package/dist/chunk-4G6PCQ4G.mjs.map +1 -0
- package/dist/chunk-4J4ISPN7.mjs +26 -0
- package/dist/chunk-4J4ISPN7.mjs.map +1 -0
- package/dist/chunk-5OKOSAXO.mjs +37 -0
- package/dist/chunk-5OKOSAXO.mjs.map +1 -0
- package/dist/chunk-B2LUOR6L.mjs +32 -0
- package/dist/chunk-B2LUOR6L.mjs.map +1 -0
- package/dist/chunk-B436JYPR.mjs +34 -0
- package/dist/chunk-B436JYPR.mjs.map +1 -0
- package/dist/chunk-CW5ZZAAV.mjs +34 -0
- package/dist/chunk-CW5ZZAAV.mjs.map +1 -0
- package/dist/chunk-DV6BTDBZ.mjs +32 -0
- package/dist/chunk-DV6BTDBZ.mjs.map +1 -0
- package/dist/chunk-G646NVHY.mjs +176 -0
- package/dist/chunk-G646NVHY.mjs.map +1 -0
- package/dist/chunk-HM447TIY.mjs +32 -0
- package/dist/chunk-HM447TIY.mjs.map +1 -0
- package/dist/chunk-I6LPF3F6.mjs +95 -0
- package/dist/chunk-I6LPF3F6.mjs.map +1 -0
- package/dist/chunk-OFDDT2JT.mjs +32 -0
- package/dist/chunk-OFDDT2JT.mjs.map +1 -0
- package/dist/chunk-RSAJUBWR.mjs +32 -0
- package/dist/chunk-RSAJUBWR.mjs.map +1 -0
- package/dist/chunk-WEDZHILB.mjs +29 -0
- package/dist/chunk-WEDZHILB.mjs.map +1 -0
- package/dist/chunk-Y2QXIJZA.mjs +138 -0
- package/dist/chunk-Y2QXIJZA.mjs.map +1 -0
- package/dist/chunk-Y5NCRCDU.mjs +32 -0
- package/dist/chunk-Y5NCRCDU.mjs.map +1 -0
- package/dist/chunk-ZR2AEIGZ.mjs +116 -0
- package/dist/chunk-ZR2AEIGZ.mjs.map +1 -0
- package/dist/dialog-body.d.mts +8 -0
- package/dist/dialog-body.d.ts +8 -0
- package/dist/dialog-body.js +94 -0
- package/dist/dialog-body.js.map +1 -0
- package/dist/dialog-body.mjs +10 -0
- package/dist/dialog-body.mjs.map +1 -0
- package/dist/dialog-close-button.d.mts +8 -0
- package/dist/dialog-close-button.d.ts +8 -0
- package/dist/dialog-close-button.js +96 -0
- package/dist/dialog-close-button.js.map +1 -0
- package/dist/dialog-close-button.mjs +10 -0
- package/dist/dialog-close-button.mjs.map +1 -0
- package/dist/dialog-footer.d.mts +8 -0
- package/dist/dialog-footer.d.ts +8 -0
- package/dist/dialog-footer.js +91 -0
- package/dist/dialog-footer.js.map +1 -0
- package/dist/dialog-footer.mjs +10 -0
- package/dist/dialog-footer.mjs.map +1 -0
- package/dist/dialog-header.d.mts +8 -0
- package/dist/dialog-header.d.ts +8 -0
- package/dist/dialog-header.js +91 -0
- package/dist/dialog-header.js.map +1 -0
- package/dist/dialog-header.mjs +10 -0
- package/dist/dialog-header.mjs.map +1 -0
- package/dist/dialog-overlay.d.mts +8 -0
- package/dist/dialog-overlay.d.ts +8 -0
- package/dist/dialog-overlay.js +108 -0
- package/dist/dialog-overlay.js.map +1 -0
- package/dist/dialog-overlay.mjs +10 -0
- package/dist/dialog-overlay.mjs.map +1 -0
- package/dist/dialog.d.mts +7 -21
- package/dist/dialog.d.ts +7 -21
- package/dist/dialog.js +593 -678
- package/dist/dialog.js.map +1 -1
- package/dist/dialog.mjs +20 -13
- package/dist/drawer-body.d.mts +8 -0
- package/dist/drawer-body.d.ts +8 -0
- package/dist/drawer-body.js +94 -0
- package/dist/drawer-body.js.map +1 -0
- package/dist/drawer-body.mjs +10 -0
- package/dist/drawer-body.mjs.map +1 -0
- package/dist/drawer-close-button.d.mts +9 -0
- package/dist/drawer-close-button.d.ts +9 -0
- package/dist/drawer-close-button.js +96 -0
- package/dist/drawer-close-button.js.map +1 -0
- package/dist/drawer-close-button.mjs +10 -0
- package/dist/drawer-close-button.mjs.map +1 -0
- package/dist/drawer-content.d.mts +16 -0
- package/dist/drawer-content.d.ts +16 -0
- package/dist/drawer-content.js +278 -0
- package/dist/drawer-content.js.map +1 -0
- package/dist/drawer-content.mjs +12 -0
- package/dist/drawer-content.mjs.map +1 -0
- package/dist/drawer-drag-bar.d.mts +8 -0
- package/dist/drawer-drag-bar.d.ts +8 -0
- package/dist/drawer-drag-bar.js +66 -0
- package/dist/drawer-drag-bar.js.map +1 -0
- package/dist/drawer-drag-bar.mjs +9 -0
- package/dist/drawer-drag-bar.mjs.map +1 -0
- package/dist/drawer-footer.d.mts +8 -0
- package/dist/drawer-footer.d.ts +8 -0
- package/dist/drawer-footer.js +91 -0
- package/dist/drawer-footer.js.map +1 -0
- package/dist/drawer-footer.mjs +10 -0
- package/dist/drawer-footer.mjs.map +1 -0
- package/dist/drawer-header.d.mts +8 -0
- package/dist/drawer-header.d.ts +8 -0
- package/dist/drawer-header.js +91 -0
- package/dist/drawer-header.js.map +1 -0
- package/dist/drawer-header.mjs +10 -0
- package/dist/drawer-header.mjs.map +1 -0
- package/dist/drawer-overlay.d.mts +8 -0
- package/dist/drawer-overlay.d.ts +8 -0
- package/dist/drawer-overlay.js +108 -0
- package/dist/drawer-overlay.js.map +1 -0
- package/dist/drawer-overlay.mjs +10 -0
- package/dist/drawer-overlay.mjs.map +1 -0
- package/dist/drawer.d.mts +8 -27
- package/dist/drawer.d.ts +8 -27
- package/dist/drawer.js +405 -640
- package/dist/drawer.js.map +1 -1
- package/dist/drawer.mjs +14 -17
- package/dist/index.d.mts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +492 -413
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -18
- package/dist/modal-body.d.mts +3 -2
- package/dist/modal-body.d.ts +3 -2
- package/dist/modal-body.js +13 -856
- package/dist/modal-body.js.map +1 -1
- package/dist/modal-body.mjs +2 -1
- package/dist/modal-close-button.d.mts +3 -2
- package/dist/modal-close-button.d.ts +3 -2
- package/dist/modal-close-button.js +13 -854
- package/dist/modal-close-button.js.map +1 -1
- package/dist/modal-close-button.mjs +2 -1
- package/dist/modal-content.d.mts +9 -0
- package/dist/modal-content.d.ts +9 -0
- package/dist/modal-content.js +178 -0
- package/dist/modal-content.js.map +1 -0
- package/dist/modal-content.mjs +11 -0
- package/dist/modal-content.mjs.map +1 -0
- package/dist/modal-context.d.mts +27 -0
- package/dist/modal-context.d.ts +27 -0
- package/dist/modal-context.js +54 -0
- package/dist/modal-context.js.map +1 -0
- package/dist/modal-context.mjs +18 -0
- package/dist/modal-context.mjs.map +1 -0
- package/dist/modal-footer.d.mts +2 -1
- package/dist/modal-footer.d.ts +2 -1
- package/dist/modal-footer.js +13 -857
- package/dist/modal-footer.js.map +1 -1
- package/dist/modal-footer.mjs +2 -1
- package/dist/modal-header.d.mts +2 -1
- package/dist/modal-header.d.ts +2 -1
- package/dist/modal-header.js +13 -857
- package/dist/modal-header.js.map +1 -1
- package/dist/modal-header.mjs +2 -1
- package/dist/modal-overlay.d.mts +2 -1
- package/dist/modal-overlay.d.ts +2 -1
- package/dist/modal-overlay.js +16 -843
- package/dist/modal-overlay.js.map +1 -1
- package/dist/modal-overlay.mjs +2 -1
- package/dist/modal.d.mts +10 -14
- package/dist/modal.d.ts +10 -14
- package/dist/modal.js +183 -508
- package/dist/modal.js.map +1 -1
- package/dist/modal.mjs +13 -5
- package/package.json +10 -10
- package/dist/chunk-7PS3HWMF.mjs +0 -938
- package/dist/chunk-7PS3HWMF.mjs.map +0 -1
package/dist/dialog.js
CHANGED
|
@@ -21,578 +21,233 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/dialog.tsx
|
|
22
22
|
var dialog_exports = {};
|
|
23
23
|
__export(dialog_exports, {
|
|
24
|
-
Dialog: () => Dialog
|
|
25
|
-
DialogBody: () => DialogBody,
|
|
26
|
-
DialogCloseButton: () => DialogCloseButton,
|
|
27
|
-
DialogFooter: () => DialogFooter,
|
|
28
|
-
DialogHeader: () => DialogHeader,
|
|
29
|
-
DialogOverlay: () => DialogOverlay
|
|
24
|
+
Dialog: () => Dialog
|
|
30
25
|
});
|
|
31
26
|
module.exports = __toCommonJS(dialog_exports);
|
|
32
27
|
var import_button = require("@yamada-ui/button");
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
28
|
+
var import_core13 = require("@yamada-ui/core");
|
|
29
|
+
var import_motion7 = require("@yamada-ui/motion");
|
|
30
|
+
var import_utils18 = require("@yamada-ui/utils");
|
|
36
31
|
|
|
37
|
-
// src/
|
|
32
|
+
// src/dialog-body.tsx
|
|
38
33
|
var import_core2 = require("@yamada-ui/core");
|
|
39
|
-
var
|
|
40
|
-
var import_motion2 = require("@yamada-ui/motion");
|
|
41
|
-
var import_portal = require("@yamada-ui/portal");
|
|
42
|
-
var import_transitions2 = require("@yamada-ui/transitions");
|
|
43
|
-
var import_use_value2 = require("@yamada-ui/use-value");
|
|
44
|
-
var import_utils2 = require("@yamada-ui/utils");
|
|
45
|
-
var import_react2 = require("react");
|
|
46
|
-
var import_react_remove_scroll = require("react-remove-scroll");
|
|
34
|
+
var import_utils3 = require("@yamada-ui/utils");
|
|
47
35
|
|
|
48
|
-
// src/
|
|
36
|
+
// src/modal-body.tsx
|
|
49
37
|
var import_core = require("@yamada-ui/core");
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
39
|
+
|
|
40
|
+
// src/modal-context.ts
|
|
53
41
|
var import_utils = require("@yamada-ui/utils");
|
|
54
|
-
var
|
|
55
|
-
|
|
42
|
+
var [ModalProvider, useModal] = (0, import_utils.createContext)({
|
|
43
|
+
name: `ModalContext`,
|
|
44
|
+
errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
|
|
45
|
+
});
|
|
46
|
+
var [DialogProvider, useDialog] = (0, import_utils.createContext)({
|
|
47
|
+
name: `DialogContext`,
|
|
48
|
+
errorMessage: `useDialog returned is 'undefined'. Seems you forgot to wrap the components in "<Dialog />" `
|
|
49
|
+
});
|
|
56
50
|
var [DrawerProvider, useDrawer] = (0, import_utils.createContext)({
|
|
57
51
|
name: `DrawerContext`,
|
|
58
52
|
errorMessage: `useDrawer returned is 'undefined'. Seems you forgot to wrap the components in "<Drawer />" `
|
|
59
53
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
withCloseButton = !closeOnDrag,
|
|
76
|
-
withOverlay = true,
|
|
77
|
-
withDragBar = true,
|
|
78
|
-
allowPinchZoom,
|
|
79
|
-
autoFocus,
|
|
80
|
-
restoreFocus,
|
|
81
|
-
initialFocusRef,
|
|
82
|
-
finalFocusRef,
|
|
83
|
-
blockScrollOnMount,
|
|
84
|
-
closeOnOverlay,
|
|
85
|
-
closeOnEsc,
|
|
86
|
-
lockFocusAcrossFrames,
|
|
87
|
-
duration = { enter: 0.4, exit: 0.3 },
|
|
88
|
-
dragConstraints = 0,
|
|
89
|
-
dragElastic = 0.1,
|
|
90
|
-
dragOffset = 80,
|
|
91
|
-
dragVelocity = 100,
|
|
92
|
-
blankForDragProps,
|
|
93
|
-
portalProps,
|
|
94
|
-
containerProps,
|
|
95
|
-
...rest
|
|
96
|
-
} = (0, import_core.omitThemeProps)(mergedProps, ["isFullHeight"]);
|
|
97
|
-
const validChildren = (0, import_utils.getValidChildren)(children);
|
|
98
|
-
const [customDrawerOverlay, ...cloneChildren] = (0, import_utils.findChildren)(
|
|
99
|
-
validChildren,
|
|
100
|
-
DrawerOverlay
|
|
101
|
-
);
|
|
102
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
103
|
-
Modal,
|
|
104
|
-
{
|
|
105
|
-
ref,
|
|
106
|
-
...{
|
|
107
|
-
isOpen,
|
|
108
|
-
onClose,
|
|
109
|
-
onOverlayClick,
|
|
110
|
-
onEsc,
|
|
111
|
-
onCloseComplete,
|
|
112
|
-
withCloseButton: false,
|
|
113
|
-
withOverlay: false,
|
|
114
|
-
allowPinchZoom,
|
|
115
|
-
autoFocus,
|
|
116
|
-
restoreFocus,
|
|
117
|
-
initialFocusRef,
|
|
118
|
-
finalFocusRef,
|
|
119
|
-
blockScrollOnMount,
|
|
120
|
-
closeOnOverlay,
|
|
121
|
-
closeOnEsc,
|
|
122
|
-
lockFocusAcrossFrames,
|
|
123
|
-
duration,
|
|
124
|
-
portalProps,
|
|
125
|
-
containerProps
|
|
126
|
-
},
|
|
127
|
-
children: [
|
|
128
|
-
customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerOverlay, {}) : null,
|
|
129
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
130
|
-
DrawerContent,
|
|
131
|
-
{
|
|
132
|
-
...{
|
|
133
|
-
dragConstraints,
|
|
134
|
-
dragElastic,
|
|
135
|
-
dragOffset,
|
|
136
|
-
dragVelocity,
|
|
137
|
-
withCloseButton,
|
|
138
|
-
withDragBar,
|
|
139
|
-
blankForDragProps,
|
|
140
|
-
...rest,
|
|
141
|
-
placement,
|
|
142
|
-
closeOnDrag
|
|
143
|
-
},
|
|
144
|
-
children: cloneChildren
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
) });
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
var DrawerContent = (0, import_motion.motionForwardRef)(
|
|
153
|
-
({
|
|
154
|
-
className,
|
|
155
|
-
children,
|
|
156
|
-
placement: _placement,
|
|
157
|
-
withCloseButton,
|
|
158
|
-
withDragBar,
|
|
159
|
-
closeOnDrag,
|
|
160
|
-
dragConstraints,
|
|
161
|
-
dragElastic,
|
|
162
|
-
dragOffset,
|
|
163
|
-
dragVelocity,
|
|
164
|
-
blankForDragProps,
|
|
165
|
-
...rest
|
|
166
|
-
}, ref) => {
|
|
167
|
-
const { isOpen, onClose, duration } = useModal();
|
|
168
|
-
const styles = useDrawer();
|
|
169
|
-
const placement = (0, import_use_value.useValue)(_placement);
|
|
170
|
-
const validChildren = (0, import_utils.getValidChildren)(children);
|
|
171
|
-
const [customDrawerCloseButton, ...cloneChildren] = (0, import_utils.findChildren)(
|
|
172
|
-
validChildren,
|
|
173
|
-
DrawerCloseButton
|
|
174
|
-
);
|
|
175
|
-
const blankForDragBg = (0, import_react.useMemo)(() => {
|
|
176
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
177
|
-
const propBg = (_c = (_b = (_a = rest.backgroundColor) != null ? _a : rest.bgColor) != null ? _b : rest.background) != null ? _c : rest.bg;
|
|
178
|
-
const styleBg = (_j = (_h = (_f = (_d = styles.container) == null ? void 0 : _d.backgroundColor) != null ? _f : (_e = styles.container) == null ? void 0 : _e.bgColor) != null ? _h : (_g = styles.container) == null ? void 0 : _g.background) != null ? _j : (_i = styles.container) == null ? void 0 : _i.bg;
|
|
179
|
-
const computedBg = propBg != null ? propBg : styleBg;
|
|
180
|
-
return (0, import_utils.isArray)(computedBg) ? computedBg : [computedBg];
|
|
181
|
-
}, [rest, styles]);
|
|
182
|
-
const blankForDrag = (0, import_react.useMemo)(() => {
|
|
183
|
-
let position = {};
|
|
184
|
-
switch (placement) {
|
|
185
|
-
case "top":
|
|
186
|
-
position = { top: "calc(-100dvh + 1px)", left: 0, right: 0 };
|
|
187
|
-
break;
|
|
188
|
-
case "bottom":
|
|
189
|
-
position = { bottom: "calc(-100dvh + 1px)", left: 0, right: 0 };
|
|
190
|
-
break;
|
|
191
|
-
case "left":
|
|
192
|
-
position = { left: "calc(-100% + 1px)", top: 0, bottom: 0 };
|
|
193
|
-
break;
|
|
194
|
-
case "right":
|
|
195
|
-
position = { right: "calc(-100% + 1px)", top: 0, bottom: 0 };
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
const [lightBg, darkBg] = blankForDragBg;
|
|
199
|
-
return {
|
|
200
|
-
_after: {
|
|
201
|
-
content: '""',
|
|
202
|
-
display: "block",
|
|
203
|
-
w: "100%",
|
|
204
|
-
h: "100dvh",
|
|
205
|
-
bg: lightBg,
|
|
206
|
-
position: "absolute",
|
|
207
|
-
...position,
|
|
208
|
-
...blankForDragProps
|
|
209
|
-
},
|
|
210
|
-
_dark: {
|
|
211
|
-
_after: {
|
|
212
|
-
bg: darkBg
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
}, [placement, blankForDragBg, blankForDragProps]);
|
|
217
|
-
const css = (0, import_react.useMemo)(
|
|
218
|
-
() => ({
|
|
219
|
-
display: "flex",
|
|
220
|
-
flexDirection: placement === "top" || placement === "bottom" ? "column" : "row",
|
|
221
|
-
outline: 0,
|
|
222
|
-
...closeOnDrag ? blankForDrag : {},
|
|
223
|
-
...styles.container
|
|
224
|
-
}),
|
|
225
|
-
[blankForDrag, closeOnDrag, placement, styles]
|
|
226
|
-
);
|
|
227
|
-
const getDragDirectionRestriction = (0, import_react.useCallback)(
|
|
228
|
-
(value) => {
|
|
229
|
-
switch (placement) {
|
|
230
|
-
case "top":
|
|
231
|
-
return { bottom: value };
|
|
232
|
-
case "bottom":
|
|
233
|
-
return { top: value };
|
|
234
|
-
case "left":
|
|
235
|
-
return { right: value };
|
|
236
|
-
case "right":
|
|
237
|
-
return { left: value };
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
[placement]
|
|
241
|
-
);
|
|
242
|
-
const getDragDirection = (0, import_react.useCallback)(() => {
|
|
243
|
-
switch (placement) {
|
|
244
|
-
case "top":
|
|
245
|
-
case "bottom":
|
|
246
|
-
return "y";
|
|
247
|
-
case "left":
|
|
248
|
-
case "right":
|
|
249
|
-
return "x";
|
|
250
|
-
}
|
|
251
|
-
}, [placement]);
|
|
252
|
-
const isCloseByDragInfo = (0, import_react.useCallback)(
|
|
253
|
-
(info) => {
|
|
254
|
-
switch (placement) {
|
|
255
|
-
case "top":
|
|
256
|
-
return info.velocity.y <= dragVelocity * -1 || info.offset.y <= dragOffset * -1;
|
|
257
|
-
case "bottom":
|
|
258
|
-
return info.velocity.y >= dragVelocity || info.offset.y >= dragOffset;
|
|
259
|
-
case "left":
|
|
260
|
-
return info.velocity.x <= dragVelocity * -1 || info.offset.x <= dragOffset * -1;
|
|
261
|
-
case "right":
|
|
262
|
-
return info.velocity.x >= dragVelocity || info.offset.x >= dragOffset;
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
[placement, dragVelocity, dragOffset]
|
|
266
|
-
);
|
|
267
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
268
|
-
import_transitions.Slide,
|
|
54
|
+
|
|
55
|
+
// src/modal-body.tsx
|
|
56
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
57
|
+
var ModalBody = (0, import_core.forwardRef)(
|
|
58
|
+
({ className, __css, ...rest }, ref) => {
|
|
59
|
+
const { styles, scrollBehavior } = useModal();
|
|
60
|
+
const css = {
|
|
61
|
+
display: "flex",
|
|
62
|
+
flexDirection: "column",
|
|
63
|
+
alignItems: "flex-start",
|
|
64
|
+
overflow: scrollBehavior === "inside" ? "auto" : void 0,
|
|
65
|
+
...__css ? __css : styles.body
|
|
66
|
+
};
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
+
import_core.ui.div,
|
|
269
69
|
{
|
|
270
70
|
ref,
|
|
271
|
-
className: (0,
|
|
272
|
-
isOpen,
|
|
273
|
-
placement,
|
|
274
|
-
duration,
|
|
275
|
-
drag: closeOnDrag ? getDragDirection() : false,
|
|
276
|
-
dragConstraints: getDragDirectionRestriction(dragConstraints),
|
|
277
|
-
dragElastic: getDragDirectionRestriction(dragElastic),
|
|
278
|
-
dragSnapToOrigin: true,
|
|
279
|
-
dragMomentum: false,
|
|
280
|
-
onDragEnd: (_, info) => {
|
|
281
|
-
if (isCloseByDragInfo(info)) onClose == null ? void 0 : onClose();
|
|
282
|
-
},
|
|
283
|
-
tabIndex: -1,
|
|
71
|
+
className: (0, import_utils2.cx)("ui-modal__body", className),
|
|
284
72
|
__css: css,
|
|
285
|
-
...rest
|
|
286
|
-
children: [
|
|
287
|
-
customDrawerCloseButton != null ? customDrawerCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerCloseButton, {}) : null,
|
|
288
|
-
withDragBar && closeOnDrag && (placement === "bottom" || placement === "right") ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerDragBar, {}) : null,
|
|
289
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
290
|
-
import_core.ui.div,
|
|
291
|
-
{
|
|
292
|
-
className: "ui-drawer__inner",
|
|
293
|
-
__css: { display: "flex", flexDirection: "column", ...styles.inner },
|
|
294
|
-
children: cloneChildren
|
|
295
|
-
}
|
|
296
|
-
),
|
|
297
|
-
withDragBar && closeOnDrag && (placement === "top" || placement === "left") ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerDragBar, {}) : null
|
|
298
|
-
]
|
|
73
|
+
...rest
|
|
299
74
|
}
|
|
300
75
|
);
|
|
301
76
|
}
|
|
302
77
|
);
|
|
303
|
-
|
|
78
|
+
|
|
79
|
+
// src/dialog-body.tsx
|
|
80
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
81
|
+
var DialogBody = (0, import_core2.forwardRef)(
|
|
304
82
|
({ className, ...rest }, ref) => {
|
|
305
|
-
const styles =
|
|
306
|
-
const css = { ...styles.
|
|
307
|
-
return /* @__PURE__ */ (0,
|
|
308
|
-
|
|
83
|
+
const styles = useDialog();
|
|
84
|
+
const css = { ...styles.body };
|
|
85
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
86
|
+
ModalBody,
|
|
309
87
|
{
|
|
310
88
|
ref,
|
|
311
|
-
className: (0,
|
|
89
|
+
className: (0, import_utils3.cx)("ui-dialog__body", className),
|
|
312
90
|
__css: css,
|
|
313
91
|
...rest
|
|
314
92
|
}
|
|
315
93
|
);
|
|
316
94
|
}
|
|
317
95
|
);
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
338
|
-
ModalCloseButton,
|
|
96
|
+
|
|
97
|
+
// src/dialog-close-button.tsx
|
|
98
|
+
var import_core4 = require("@yamada-ui/core");
|
|
99
|
+
var import_utils5 = require("@yamada-ui/utils");
|
|
100
|
+
|
|
101
|
+
// src/modal-close-button.tsx
|
|
102
|
+
var import_close_button = require("@yamada-ui/close-button");
|
|
103
|
+
var import_core3 = require("@yamada-ui/core");
|
|
104
|
+
var import_utils4 = require("@yamada-ui/utils");
|
|
105
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
106
|
+
var ModalCloseButton = (0, import_core3.forwardRef)(
|
|
107
|
+
({ onClick, __css, ...rest }, ref) => {
|
|
108
|
+
const { styles, onClose } = useModal();
|
|
109
|
+
const css = {
|
|
110
|
+
position: "absolute",
|
|
111
|
+
...__css ? __css : styles.closeButton
|
|
112
|
+
};
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
114
|
+
import_close_button.CloseButton,
|
|
339
115
|
{
|
|
340
116
|
ref,
|
|
341
|
-
className: (0,
|
|
117
|
+
className: (0, import_utils4.cx)("ui-modal__close-button"),
|
|
342
118
|
__css: css,
|
|
119
|
+
onClick: (0, import_utils4.handlerAll)(onClick, (ev) => {
|
|
120
|
+
ev.stopPropagation();
|
|
121
|
+
onClose == null ? void 0 : onClose();
|
|
122
|
+
}),
|
|
343
123
|
...rest
|
|
344
124
|
}
|
|
345
125
|
);
|
|
346
126
|
}
|
|
347
127
|
);
|
|
348
|
-
|
|
128
|
+
|
|
129
|
+
// src/dialog-close-button.tsx
|
|
130
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
131
|
+
var DialogCloseButton = (0, import_core4.forwardRef)(
|
|
349
132
|
({ className, ...rest }, ref) => {
|
|
350
|
-
const styles =
|
|
351
|
-
const css = { ...styles.
|
|
352
|
-
return /* @__PURE__ */ (0,
|
|
353
|
-
|
|
133
|
+
const styles = useDialog();
|
|
134
|
+
const css = { ...styles.closeButton };
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
136
|
+
ModalCloseButton,
|
|
354
137
|
{
|
|
355
138
|
ref,
|
|
356
|
-
className: (0,
|
|
139
|
+
className: (0, import_utils5.cx)("ui-dialog__close-button", className),
|
|
357
140
|
__css: css,
|
|
358
141
|
...rest
|
|
359
142
|
}
|
|
360
143
|
);
|
|
361
144
|
}
|
|
362
145
|
);
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
146
|
+
|
|
147
|
+
// src/dialog-footer.tsx
|
|
148
|
+
var import_core6 = require("@yamada-ui/core");
|
|
149
|
+
var import_utils7 = require("@yamada-ui/utils");
|
|
150
|
+
|
|
151
|
+
// src/modal-footer.tsx
|
|
152
|
+
var import_core5 = require("@yamada-ui/core");
|
|
153
|
+
var import_utils6 = require("@yamada-ui/utils");
|
|
154
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
155
|
+
var ModalFooter = (0, import_core5.forwardRef)(
|
|
156
|
+
({ className, __css, ...rest }, ref) => {
|
|
157
|
+
const { styles } = useModal();
|
|
158
|
+
const css = {
|
|
159
|
+
display: "flex",
|
|
160
|
+
alignItems: "center",
|
|
161
|
+
justifyContent: "flex-end",
|
|
162
|
+
...__css ? __css : styles.footer
|
|
163
|
+
};
|
|
164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
165
|
+
import_core5.ui.footer,
|
|
369
166
|
{
|
|
370
167
|
ref,
|
|
371
|
-
className: (0,
|
|
168
|
+
className: (0, import_utils6.cx)("ui-modal__footer", className),
|
|
372
169
|
__css: css,
|
|
373
170
|
...rest
|
|
374
171
|
}
|
|
375
172
|
);
|
|
376
173
|
}
|
|
377
174
|
);
|
|
378
|
-
|
|
175
|
+
|
|
176
|
+
// src/dialog-footer.tsx
|
|
177
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
178
|
+
var DialogFooter = (0, import_core6.forwardRef)(
|
|
379
179
|
({ className, ...rest }, ref) => {
|
|
380
|
-
const styles =
|
|
180
|
+
const styles = useDialog();
|
|
381
181
|
const css = { ...styles.footer };
|
|
382
|
-
return /* @__PURE__ */ (0,
|
|
182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
383
183
|
ModalFooter,
|
|
384
184
|
{
|
|
385
185
|
ref,
|
|
386
|
-
className: (0,
|
|
186
|
+
className: (0, import_utils7.cx)("ui-dialog__footer", className),
|
|
387
187
|
__css: css,
|
|
388
|
-
...rest
|
|
389
|
-
}
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
// src/modal.tsx
|
|
395
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
396
|
-
var [ModalProvider, useModal] = (0, import_utils2.createContext)({
|
|
397
|
-
name: `ModalContext`,
|
|
398
|
-
errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
|
|
399
|
-
});
|
|
400
|
-
var Modal = (0, import_motion2.motionForwardRef)(
|
|
401
|
-
({ size, ...props }, ref) => {
|
|
402
|
-
const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("Modal", {
|
|
403
|
-
size,
|
|
404
|
-
...props
|
|
405
|
-
});
|
|
406
|
-
const {
|
|
407
|
-
className,
|
|
408
|
-
children,
|
|
409
|
-
isOpen,
|
|
410
|
-
onClose,
|
|
411
|
-
onOverlayClick,
|
|
412
|
-
onEsc,
|
|
413
|
-
onCloseComplete,
|
|
414
|
-
placement: _placement = "center",
|
|
415
|
-
outside = "fallback(4, 1rem)",
|
|
416
|
-
withCloseButton = true,
|
|
417
|
-
withOverlay = true,
|
|
418
|
-
allowPinchZoom = false,
|
|
419
|
-
scrollBehavior = "inside",
|
|
420
|
-
autoFocus,
|
|
421
|
-
restoreFocus,
|
|
422
|
-
initialFocusRef,
|
|
423
|
-
finalFocusRef,
|
|
424
|
-
blockScrollOnMount = true,
|
|
425
|
-
closeOnOverlay = true,
|
|
426
|
-
closeOnEsc = true,
|
|
427
|
-
lockFocusAcrossFrames = true,
|
|
428
|
-
animation = "scale",
|
|
429
|
-
duration,
|
|
430
|
-
portalProps,
|
|
431
|
-
containerProps,
|
|
432
|
-
...rest
|
|
433
|
-
} = (0, import_core2.omitThemeProps)(mergedProps);
|
|
434
|
-
const onKeyDown = (0, import_react2.useCallback)(
|
|
435
|
-
(ev) => {
|
|
436
|
-
if (ev.key !== "Escape") return;
|
|
437
|
-
ev.stopPropagation();
|
|
438
|
-
if (closeOnEsc) onClose == null ? void 0 : onClose();
|
|
439
|
-
onEsc == null ? void 0 : onEsc();
|
|
440
|
-
},
|
|
441
|
-
[closeOnEsc, onClose, onEsc]
|
|
442
|
-
);
|
|
443
|
-
const validChildren = (0, import_utils2.getValidChildren)(children);
|
|
444
|
-
const [customModalOverlay, ...cloneChildren] = (0, import_utils2.findChildren)(
|
|
445
|
-
validChildren,
|
|
446
|
-
ModalOverlay,
|
|
447
|
-
DialogOverlay,
|
|
448
|
-
DrawerOverlay
|
|
449
|
-
);
|
|
450
|
-
let [drawerContent] = (0, import_utils2.findChildren)(validChildren, DrawerContent);
|
|
451
|
-
if (drawerContent)
|
|
452
|
-
drawerContent = (0, import_react2.cloneElement)(drawerContent, { onKeyDown });
|
|
453
|
-
const placement = (0, import_use_value2.useValue)(_placement);
|
|
454
|
-
const css = {
|
|
455
|
-
position: "fixed",
|
|
456
|
-
top: 0,
|
|
457
|
-
left: 0,
|
|
458
|
-
zIndex: "fallback(jeice, 110)",
|
|
459
|
-
w: "100vw",
|
|
460
|
-
h: "100dvh",
|
|
461
|
-
p: size !== "full" ? outside : void 0,
|
|
462
|
-
display: "flex",
|
|
463
|
-
justifyContent: placement.includes("left") ? "flex-start" : placement.includes("right") ? "flex-end" : "center",
|
|
464
|
-
alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
|
|
465
|
-
};
|
|
466
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
467
|
-
ModalProvider,
|
|
468
|
-
{
|
|
469
|
-
value: {
|
|
470
|
-
isOpen,
|
|
471
|
-
onClose,
|
|
472
|
-
onOverlayClick,
|
|
473
|
-
withCloseButton,
|
|
474
|
-
scrollBehavior,
|
|
475
|
-
closeOnOverlay,
|
|
476
|
-
animation,
|
|
477
|
-
duration,
|
|
478
|
-
styles
|
|
479
|
-
},
|
|
480
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_motion2.AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
481
|
-
import_focus_lock.FocusLock,
|
|
482
|
-
{
|
|
483
|
-
autoFocus,
|
|
484
|
-
initialFocusRef,
|
|
485
|
-
finalFocusRef,
|
|
486
|
-
restoreFocus,
|
|
487
|
-
lockFocusAcrossFrames,
|
|
488
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
489
|
-
import_react_remove_scroll.RemoveScroll,
|
|
490
|
-
{
|
|
491
|
-
allowPinchZoom,
|
|
492
|
-
enabled: blockScrollOnMount,
|
|
493
|
-
forwardProps: true,
|
|
494
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.ui.div, { __css: css, ...containerProps, children: [
|
|
495
|
-
customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModalOverlay, {}) : null,
|
|
496
|
-
drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
497
|
-
ModalContent,
|
|
498
|
-
{
|
|
499
|
-
ref,
|
|
500
|
-
className,
|
|
501
|
-
onKeyDown,
|
|
502
|
-
...rest,
|
|
503
|
-
children: cloneChildren
|
|
504
|
-
}
|
|
505
|
-
)
|
|
506
|
-
] })
|
|
507
|
-
}
|
|
508
|
-
)
|
|
509
|
-
}
|
|
510
|
-
) }) : null })
|
|
511
|
-
}
|
|
512
|
-
);
|
|
513
|
-
}
|
|
514
|
-
);
|
|
515
|
-
var getModalContentProps = (animation = "scale", duration) => {
|
|
516
|
-
switch (animation) {
|
|
517
|
-
case "scale":
|
|
518
|
-
return {
|
|
519
|
-
...import_transitions2.scaleFadeProps,
|
|
520
|
-
custom: { scale: 0.95, reverse: true, duration }
|
|
521
|
-
};
|
|
522
|
-
case "top":
|
|
523
|
-
return {
|
|
524
|
-
...import_transitions2.slideFadeProps,
|
|
525
|
-
custom: { offsetY: -16, reverse: true, duration }
|
|
526
|
-
};
|
|
527
|
-
case "right":
|
|
528
|
-
return {
|
|
529
|
-
...import_transitions2.slideFadeProps,
|
|
530
|
-
custom: { offsetX: 16, reverse: true, duration }
|
|
531
|
-
};
|
|
532
|
-
case "left":
|
|
533
|
-
return {
|
|
534
|
-
...import_transitions2.slideFadeProps,
|
|
535
|
-
custom: { offsetX: -16, reverse: true, duration }
|
|
536
|
-
};
|
|
537
|
-
case "bottom":
|
|
538
|
-
return {
|
|
539
|
-
...import_transitions2.slideFadeProps,
|
|
540
|
-
custom: { offsetY: 16, reverse: true, duration }
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
var ModalContent = (0, import_motion2.motionForwardRef)(
|
|
545
|
-
({ className, children, __css, ...rest }, ref) => {
|
|
546
|
-
const {
|
|
547
|
-
styles,
|
|
548
|
-
scrollBehavior,
|
|
549
|
-
withCloseButton,
|
|
550
|
-
onClose,
|
|
551
|
-
animation,
|
|
552
|
-
duration
|
|
553
|
-
} = useModal();
|
|
554
|
-
const validChildren = (0, import_utils2.getValidChildren)(children);
|
|
555
|
-
const [customModalCloseButton, ...cloneChildren] = (0, import_utils2.findChildren)(
|
|
556
|
-
validChildren,
|
|
557
|
-
ModalCloseButton,
|
|
558
|
-
DialogCloseButton
|
|
188
|
+
...rest
|
|
189
|
+
}
|
|
559
190
|
);
|
|
560
|
-
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
// src/dialog-header.tsx
|
|
195
|
+
var import_core8 = require("@yamada-ui/core");
|
|
196
|
+
var import_utils9 = require("@yamada-ui/utils");
|
|
197
|
+
|
|
198
|
+
// src/modal-header.tsx
|
|
199
|
+
var import_core7 = require("@yamada-ui/core");
|
|
200
|
+
var import_utils8 = require("@yamada-ui/utils");
|
|
201
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
202
|
+
var ModalHeader = (0, import_core7.forwardRef)(
|
|
203
|
+
({ className, __css, ...rest }, ref) => {
|
|
204
|
+
const { styles } = useModal();
|
|
561
205
|
const css = {
|
|
562
|
-
position: "relative",
|
|
563
|
-
maxH: "100%",
|
|
564
206
|
display: "flex",
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
...__css ? __css : styles.container
|
|
207
|
+
alignItems: "center",
|
|
208
|
+
justifyContent: "flex-start",
|
|
209
|
+
...__css ? __css : styles.header
|
|
569
210
|
};
|
|
570
|
-
return /* @__PURE__ */ (0,
|
|
571
|
-
|
|
211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
212
|
+
import_core7.ui.header,
|
|
572
213
|
{
|
|
573
|
-
role: "dialog",
|
|
574
|
-
"aria-modal": "true",
|
|
575
214
|
ref,
|
|
576
|
-
className: (0,
|
|
577
|
-
tabIndex: -1,
|
|
215
|
+
className: (0, import_utils8.cx)("ui-modal__header", className),
|
|
578
216
|
__css: css,
|
|
579
|
-
...
|
|
580
|
-
...rest,
|
|
581
|
-
children: [
|
|
582
|
-
customModalCloseButton != null ? customModalCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModalCloseButton, {}) : null,
|
|
583
|
-
cloneChildren
|
|
584
|
-
]
|
|
217
|
+
...rest
|
|
585
218
|
}
|
|
586
219
|
);
|
|
587
220
|
}
|
|
588
221
|
);
|
|
589
222
|
|
|
223
|
+
// src/dialog-header.tsx
|
|
224
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
225
|
+
var DialogHeader = (0, import_core8.forwardRef)(
|
|
226
|
+
({ className, ...rest }, ref) => {
|
|
227
|
+
const styles = useDialog();
|
|
228
|
+
const css = { ...styles.header };
|
|
229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
230
|
+
ModalHeader,
|
|
231
|
+
{
|
|
232
|
+
ref,
|
|
233
|
+
className: (0, import_utils9.cx)("ui-dialog__header", className),
|
|
234
|
+
__css: css,
|
|
235
|
+
...rest
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
// src/dialog-overlay.tsx
|
|
242
|
+
var import_motion2 = require("@yamada-ui/motion");
|
|
243
|
+
var import_utils11 = require("@yamada-ui/utils");
|
|
244
|
+
|
|
590
245
|
// src/modal-overlay.tsx
|
|
591
|
-
var
|
|
592
|
-
var
|
|
593
|
-
var
|
|
594
|
-
var
|
|
595
|
-
var ModalOverlay = (0,
|
|
246
|
+
var import_motion = require("@yamada-ui/motion");
|
|
247
|
+
var import_transitions = require("@yamada-ui/transitions");
|
|
248
|
+
var import_utils10 = require("@yamada-ui/utils");
|
|
249
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
250
|
+
var ModalOverlay = (0, import_motion.motionForwardRef)(
|
|
596
251
|
({ className, __css, onClick, ...rest }, ref) => {
|
|
597
252
|
const {
|
|
598
253
|
styles,
|
|
@@ -610,15 +265,15 @@ var ModalOverlay = (0, import_motion3.motionForwardRef)(
|
|
|
610
265
|
h: "100vh",
|
|
611
266
|
...__css ? __css : styles.overlay
|
|
612
267
|
};
|
|
613
|
-
const props = animation !== "none" ?
|
|
614
|
-
return /* @__PURE__ */ (0,
|
|
615
|
-
|
|
268
|
+
const props = animation !== "none" ? import_transitions.fadeProps : {};
|
|
269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
270
|
+
import_motion.motion.div,
|
|
616
271
|
{
|
|
617
272
|
ref,
|
|
618
|
-
className: (0,
|
|
273
|
+
className: (0, import_utils10.cx)("ui-modal__overlay", className),
|
|
619
274
|
custom: { duration },
|
|
620
275
|
__css: css,
|
|
621
|
-
onClick: (0,
|
|
276
|
+
onClick: (0, import_utils10.handlerAll)(onClick, onOverlayClick, (ev) => {
|
|
622
277
|
ev.stopPropagation();
|
|
623
278
|
if (closeOnOverlay) onClose == null ? void 0 : onClose();
|
|
624
279
|
}),
|
|
@@ -629,52 +284,249 @@ var ModalOverlay = (0, import_motion3.motionForwardRef)(
|
|
|
629
284
|
}
|
|
630
285
|
);
|
|
631
286
|
|
|
632
|
-
// src/
|
|
633
|
-
var
|
|
634
|
-
var
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
const css = {
|
|
641
|
-
position: "absolute",
|
|
642
|
-
...__css ? __css : styles.closeButton
|
|
643
|
-
};
|
|
644
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
645
|
-
import_close_button.CloseButton,
|
|
287
|
+
// src/dialog-overlay.tsx
|
|
288
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
289
|
+
var DialogOverlay = (0, import_motion2.motionForwardRef)(
|
|
290
|
+
({ className, ...rest }, ref) => {
|
|
291
|
+
const styles = useDialog();
|
|
292
|
+
const css = { ...styles.overlay };
|
|
293
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
294
|
+
ModalOverlay,
|
|
646
295
|
{
|
|
647
296
|
ref,
|
|
648
|
-
className: (0,
|
|
297
|
+
className: (0, import_utils11.cx)("ui-dialog__overlay", className),
|
|
649
298
|
__css: css,
|
|
650
|
-
onClick: (0, import_utils4.handlerAll)(onClick, (ev) => {
|
|
651
|
-
ev.stopPropagation();
|
|
652
|
-
onClose == null ? void 0 : onClose();
|
|
653
|
-
}),
|
|
654
299
|
...rest
|
|
655
300
|
}
|
|
656
301
|
);
|
|
657
302
|
}
|
|
658
303
|
);
|
|
659
304
|
|
|
660
|
-
// src/modal
|
|
661
|
-
var
|
|
662
|
-
var
|
|
663
|
-
var
|
|
664
|
-
var
|
|
305
|
+
// src/modal.tsx
|
|
306
|
+
var import_core12 = require("@yamada-ui/core");
|
|
307
|
+
var import_focus_lock = require("@yamada-ui/focus-lock");
|
|
308
|
+
var import_motion6 = require("@yamada-ui/motion");
|
|
309
|
+
var import_portal = require("@yamada-ui/portal");
|
|
310
|
+
var import_use_value2 = require("@yamada-ui/use-value");
|
|
311
|
+
var import_utils17 = require("@yamada-ui/utils");
|
|
312
|
+
var import_react2 = require("react");
|
|
313
|
+
var import_react_remove_scroll = require("react-remove-scroll");
|
|
314
|
+
|
|
315
|
+
// src/drawer-content.tsx
|
|
316
|
+
var import_core11 = require("@yamada-ui/core");
|
|
317
|
+
var import_motion3 = require("@yamada-ui/motion");
|
|
318
|
+
var import_transitions2 = require("@yamada-ui/transitions");
|
|
319
|
+
var import_use_value = require("@yamada-ui/use-value");
|
|
320
|
+
var import_utils14 = require("@yamada-ui/utils");
|
|
321
|
+
var import_react = require("react");
|
|
322
|
+
|
|
323
|
+
// src/drawer-close-button.tsx
|
|
324
|
+
var import_core9 = require("@yamada-ui/core");
|
|
325
|
+
var import_utils12 = require("@yamada-ui/utils");
|
|
326
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
327
|
+
var DrawerCloseButton = (0, import_core9.forwardRef)(
|
|
328
|
+
({ className, ...rest }, ref) => {
|
|
329
|
+
const styles = useDrawer();
|
|
330
|
+
const css = { ...styles.closeButton };
|
|
331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
332
|
+
ModalCloseButton,
|
|
333
|
+
{
|
|
334
|
+
ref,
|
|
335
|
+
className: (0, import_utils12.cx)("ui-drawer__close-button", className),
|
|
336
|
+
__css: css,
|
|
337
|
+
...rest
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
// src/drawer-drag-bar.tsx
|
|
344
|
+
var import_core10 = require("@yamada-ui/core");
|
|
345
|
+
var import_utils13 = require("@yamada-ui/utils");
|
|
346
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
347
|
+
var DrawerDragBar = (0, import_core10.forwardRef)(
|
|
665
348
|
({ className, __css, ...rest }, ref) => {
|
|
666
|
-
const
|
|
667
|
-
const css = {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
349
|
+
const styles = useDrawer();
|
|
350
|
+
const css = { ...styles.dragBar };
|
|
351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
352
|
+
import_core10.ui.div,
|
|
353
|
+
{
|
|
354
|
+
ref,
|
|
355
|
+
className: (0, import_utils13.cx)("ui-drawer__drag-bar", className),
|
|
356
|
+
__css: css,
|
|
357
|
+
...rest
|
|
358
|
+
}
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
// src/drawer-content.tsx
|
|
364
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
365
|
+
var DrawerContent = (0, import_motion3.motionForwardRef)(
|
|
366
|
+
({
|
|
367
|
+
className,
|
|
368
|
+
children,
|
|
369
|
+
placement: _placement,
|
|
370
|
+
withCloseButton,
|
|
371
|
+
withDragBar,
|
|
372
|
+
closeOnDrag,
|
|
373
|
+
dragConstraints,
|
|
374
|
+
dragElastic,
|
|
375
|
+
dragOffset,
|
|
376
|
+
dragVelocity,
|
|
377
|
+
blankForDragProps,
|
|
378
|
+
...rest
|
|
379
|
+
}, ref) => {
|
|
380
|
+
const { isOpen, onClose, duration } = useModal();
|
|
381
|
+
const styles = useDrawer();
|
|
382
|
+
const placement = (0, import_use_value.useValue)(_placement);
|
|
383
|
+
const validChildren = (0, import_utils14.getValidChildren)(children);
|
|
384
|
+
const [customDrawerCloseButton, ...cloneChildren] = (0, import_utils14.findChildren)(
|
|
385
|
+
validChildren,
|
|
386
|
+
DrawerCloseButton
|
|
387
|
+
);
|
|
388
|
+
const blankForDragBg = (0, import_react.useMemo)(() => {
|
|
389
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
390
|
+
const propBg = (_c = (_b = (_a = rest.backgroundColor) != null ? _a : rest.bgColor) != null ? _b : rest.background) != null ? _c : rest.bg;
|
|
391
|
+
const styleBg = (_j = (_h = (_f = (_d = styles.container) == null ? void 0 : _d.backgroundColor) != null ? _f : (_e = styles.container) == null ? void 0 : _e.bgColor) != null ? _h : (_g = styles.container) == null ? void 0 : _g.background) != null ? _j : (_i = styles.container) == null ? void 0 : _i.bg;
|
|
392
|
+
const computedBg = propBg != null ? propBg : styleBg;
|
|
393
|
+
return (0, import_utils14.isArray)(computedBg) ? computedBg : [computedBg];
|
|
394
|
+
}, [rest, styles]);
|
|
395
|
+
const blankForDrag = (0, import_react.useMemo)(() => {
|
|
396
|
+
let position = {};
|
|
397
|
+
switch (placement) {
|
|
398
|
+
case "top":
|
|
399
|
+
position = { top: "calc(-100dvh + 1px)", left: 0, right: 0 };
|
|
400
|
+
break;
|
|
401
|
+
case "bottom":
|
|
402
|
+
position = { bottom: "calc(-100dvh + 1px)", left: 0, right: 0 };
|
|
403
|
+
break;
|
|
404
|
+
case "left":
|
|
405
|
+
position = { left: "calc(-100% + 1px)", top: 0, bottom: 0 };
|
|
406
|
+
break;
|
|
407
|
+
case "right":
|
|
408
|
+
position = { right: "calc(-100% + 1px)", top: 0, bottom: 0 };
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
const [lightBg, darkBg] = blankForDragBg;
|
|
412
|
+
return {
|
|
413
|
+
_after: {
|
|
414
|
+
content: '""',
|
|
415
|
+
display: "block",
|
|
416
|
+
w: "100%",
|
|
417
|
+
h: "100dvh",
|
|
418
|
+
bg: lightBg,
|
|
419
|
+
position: "absolute",
|
|
420
|
+
...position,
|
|
421
|
+
...blankForDragProps
|
|
422
|
+
},
|
|
423
|
+
_dark: {
|
|
424
|
+
_after: {
|
|
425
|
+
bg: darkBg
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}, [placement, blankForDragBg, blankForDragProps]);
|
|
430
|
+
const css = (0, import_react.useMemo)(
|
|
431
|
+
() => ({
|
|
432
|
+
display: "flex",
|
|
433
|
+
flexDirection: placement === "top" || placement === "bottom" ? "column" : "row",
|
|
434
|
+
outline: 0,
|
|
435
|
+
...closeOnDrag ? blankForDrag : {},
|
|
436
|
+
...styles.container
|
|
437
|
+
}),
|
|
438
|
+
[blankForDrag, closeOnDrag, placement, styles]
|
|
439
|
+
);
|
|
440
|
+
const getDragDirectionRestriction = (0, import_react.useCallback)(
|
|
441
|
+
(value) => {
|
|
442
|
+
switch (placement) {
|
|
443
|
+
case "top":
|
|
444
|
+
return { bottom: value };
|
|
445
|
+
case "bottom":
|
|
446
|
+
return { top: value };
|
|
447
|
+
case "left":
|
|
448
|
+
return { right: value };
|
|
449
|
+
case "right":
|
|
450
|
+
return { left: value };
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
[placement]
|
|
454
|
+
);
|
|
455
|
+
const getDragDirection = (0, import_react.useCallback)(() => {
|
|
456
|
+
switch (placement) {
|
|
457
|
+
case "top":
|
|
458
|
+
case "bottom":
|
|
459
|
+
return "y";
|
|
460
|
+
case "left":
|
|
461
|
+
case "right":
|
|
462
|
+
return "x";
|
|
463
|
+
}
|
|
464
|
+
}, [placement]);
|
|
465
|
+
const isCloseByDragInfo = (0, import_react.useCallback)(
|
|
466
|
+
(info) => {
|
|
467
|
+
switch (placement) {
|
|
468
|
+
case "top":
|
|
469
|
+
return info.velocity.y <= dragVelocity * -1 || info.offset.y <= dragOffset * -1;
|
|
470
|
+
case "bottom":
|
|
471
|
+
return info.velocity.y >= dragVelocity || info.offset.y >= dragOffset;
|
|
472
|
+
case "left":
|
|
473
|
+
return info.velocity.x <= dragVelocity * -1 || info.offset.x <= dragOffset * -1;
|
|
474
|
+
case "right":
|
|
475
|
+
return info.velocity.x >= dragVelocity || info.offset.x >= dragOffset;
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
[placement, dragVelocity, dragOffset]
|
|
479
|
+
);
|
|
480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
481
|
+
import_transitions2.Slide,
|
|
482
|
+
{
|
|
483
|
+
ref,
|
|
484
|
+
className: (0, import_utils14.cx)("ui-drawer", className),
|
|
485
|
+
isOpen,
|
|
486
|
+
placement,
|
|
487
|
+
duration,
|
|
488
|
+
drag: closeOnDrag ? getDragDirection() : false,
|
|
489
|
+
dragConstraints: getDragDirectionRestriction(dragConstraints),
|
|
490
|
+
dragElastic: getDragDirectionRestriction(dragElastic),
|
|
491
|
+
dragSnapToOrigin: true,
|
|
492
|
+
dragMomentum: false,
|
|
493
|
+
onDragEnd: (_, info) => {
|
|
494
|
+
if (isCloseByDragInfo(info)) onClose == null ? void 0 : onClose();
|
|
495
|
+
},
|
|
496
|
+
tabIndex: -1,
|
|
497
|
+
__css: css,
|
|
498
|
+
...rest,
|
|
499
|
+
children: [
|
|
500
|
+
customDrawerCloseButton != null ? customDrawerCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DrawerCloseButton, {}) : null,
|
|
501
|
+
withDragBar && closeOnDrag && (placement === "bottom" || placement === "right") ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DrawerDragBar, {}) : null,
|
|
502
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
503
|
+
import_core11.ui.div,
|
|
504
|
+
{
|
|
505
|
+
className: "ui-drawer__inner",
|
|
506
|
+
__css: { display: "flex", flexDirection: "column", ...styles.inner },
|
|
507
|
+
children: cloneChildren
|
|
508
|
+
}
|
|
509
|
+
),
|
|
510
|
+
withDragBar && closeOnDrag && (placement === "top" || placement === "left") ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DrawerDragBar, {}) : null
|
|
511
|
+
]
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
|
|
517
|
+
// src/drawer-overlay.tsx
|
|
518
|
+
var import_motion4 = require("@yamada-ui/motion");
|
|
519
|
+
var import_utils15 = require("@yamada-ui/utils");
|
|
520
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
521
|
+
var DrawerOverlay = (0, import_motion4.motionForwardRef)(
|
|
522
|
+
({ className, ...rest }, ref) => {
|
|
523
|
+
const styles = useDrawer();
|
|
524
|
+
const css = { ...styles.overlay };
|
|
525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
526
|
+
ModalOverlay,
|
|
675
527
|
{
|
|
676
528
|
ref,
|
|
677
|
-
className: (0,
|
|
529
|
+
className: (0, import_utils15.cx)("ui-drawer__overlay", className),
|
|
678
530
|
__css: css,
|
|
679
531
|
...rest
|
|
680
532
|
}
|
|
@@ -682,66 +534,209 @@ var ModalHeader = (0, import_core4.forwardRef)(
|
|
|
682
534
|
}
|
|
683
535
|
);
|
|
684
536
|
|
|
685
|
-
// src/modal-
|
|
686
|
-
var
|
|
687
|
-
var
|
|
688
|
-
var
|
|
689
|
-
var
|
|
690
|
-
|
|
691
|
-
|
|
537
|
+
// src/modal-content.tsx
|
|
538
|
+
var import_motion5 = require("@yamada-ui/motion");
|
|
539
|
+
var import_transitions3 = require("@yamada-ui/transitions");
|
|
540
|
+
var import_utils16 = require("@yamada-ui/utils");
|
|
541
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
542
|
+
var getModalContentProps = (animation = "scale", duration) => {
|
|
543
|
+
switch (animation) {
|
|
544
|
+
case "scale":
|
|
545
|
+
return {
|
|
546
|
+
...import_transitions3.scaleFadeProps,
|
|
547
|
+
custom: { scale: 0.95, reverse: true, duration }
|
|
548
|
+
};
|
|
549
|
+
case "top":
|
|
550
|
+
return {
|
|
551
|
+
...import_transitions3.slideFadeProps,
|
|
552
|
+
custom: { offsetY: -16, reverse: true, duration }
|
|
553
|
+
};
|
|
554
|
+
case "right":
|
|
555
|
+
return {
|
|
556
|
+
...import_transitions3.slideFadeProps,
|
|
557
|
+
custom: { offsetX: 16, reverse: true, duration }
|
|
558
|
+
};
|
|
559
|
+
case "left":
|
|
560
|
+
return {
|
|
561
|
+
...import_transitions3.slideFadeProps,
|
|
562
|
+
custom: { offsetX: -16, reverse: true, duration }
|
|
563
|
+
};
|
|
564
|
+
case "bottom":
|
|
565
|
+
return {
|
|
566
|
+
...import_transitions3.slideFadeProps,
|
|
567
|
+
custom: { offsetY: 16, reverse: true, duration }
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
var ModalContent = (0, import_motion5.motionForwardRef)(
|
|
572
|
+
({ className, children, __css, ...rest }, ref) => {
|
|
573
|
+
const {
|
|
574
|
+
styles,
|
|
575
|
+
scrollBehavior,
|
|
576
|
+
withCloseButton,
|
|
577
|
+
onClose,
|
|
578
|
+
animation,
|
|
579
|
+
duration
|
|
580
|
+
} = useModal();
|
|
581
|
+
const validChildren = (0, import_utils16.getValidChildren)(children);
|
|
582
|
+
const [customModalCloseButton, ...cloneChildren] = (0, import_utils16.findChildren)(
|
|
583
|
+
validChildren,
|
|
584
|
+
ModalCloseButton,
|
|
585
|
+
DialogCloseButton
|
|
586
|
+
);
|
|
587
|
+
const props = animation !== "none" ? getModalContentProps(animation, duration) : {};
|
|
692
588
|
const css = {
|
|
589
|
+
position: "relative",
|
|
590
|
+
maxH: "100%",
|
|
693
591
|
display: "flex",
|
|
694
592
|
flexDirection: "column",
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
...__css ? __css : styles.
|
|
593
|
+
overflow: scrollBehavior === "inside" ? "hidden" : "auto",
|
|
594
|
+
outline: 0,
|
|
595
|
+
...__css ? __css : styles.container
|
|
698
596
|
};
|
|
699
|
-
return /* @__PURE__ */ (0,
|
|
700
|
-
|
|
597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
598
|
+
import_motion5.motion.section,
|
|
701
599
|
{
|
|
600
|
+
role: "dialog",
|
|
601
|
+
"aria-modal": "true",
|
|
702
602
|
ref,
|
|
703
|
-
className: (0,
|
|
603
|
+
className: (0, import_utils16.cx)("ui-modal", className),
|
|
604
|
+
tabIndex: -1,
|
|
704
605
|
__css: css,
|
|
705
|
-
...
|
|
606
|
+
...props,
|
|
607
|
+
...rest,
|
|
608
|
+
children: [
|
|
609
|
+
customModalCloseButton != null ? customModalCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ModalCloseButton, {}) : null,
|
|
610
|
+
cloneChildren
|
|
611
|
+
]
|
|
706
612
|
}
|
|
707
613
|
);
|
|
708
614
|
}
|
|
709
615
|
);
|
|
710
616
|
|
|
711
|
-
// src/modal
|
|
712
|
-
var
|
|
713
|
-
var
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
617
|
+
// src/modal.tsx
|
|
618
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
619
|
+
var Modal = (0, import_motion6.motionForwardRef)(
|
|
620
|
+
({ size, ...props }, ref) => {
|
|
621
|
+
const [styles, mergedProps] = (0, import_core12.useComponentMultiStyle)("Modal", {
|
|
622
|
+
size,
|
|
623
|
+
...props
|
|
624
|
+
});
|
|
625
|
+
const {
|
|
626
|
+
className,
|
|
627
|
+
children,
|
|
628
|
+
isOpen,
|
|
629
|
+
onClose,
|
|
630
|
+
onOverlayClick,
|
|
631
|
+
onEsc,
|
|
632
|
+
onCloseComplete,
|
|
633
|
+
placement: _placement = "center",
|
|
634
|
+
outside = "fallback(4, 1rem)",
|
|
635
|
+
withCloseButton = true,
|
|
636
|
+
withOverlay = true,
|
|
637
|
+
allowPinchZoom = false,
|
|
638
|
+
scrollBehavior = "inside",
|
|
639
|
+
autoFocus,
|
|
640
|
+
restoreFocus,
|
|
641
|
+
initialFocusRef,
|
|
642
|
+
finalFocusRef,
|
|
643
|
+
blockScrollOnMount = true,
|
|
644
|
+
closeOnOverlay = true,
|
|
645
|
+
closeOnEsc = true,
|
|
646
|
+
lockFocusAcrossFrames = true,
|
|
647
|
+
animation = "scale",
|
|
648
|
+
duration,
|
|
649
|
+
portalProps,
|
|
650
|
+
containerProps,
|
|
651
|
+
...rest
|
|
652
|
+
} = (0, import_core12.omitThemeProps)(mergedProps);
|
|
653
|
+
const onKeyDown = (0, import_react2.useCallback)(
|
|
654
|
+
(ev) => {
|
|
655
|
+
if (ev.key !== "Escape") return;
|
|
656
|
+
ev.stopPropagation();
|
|
657
|
+
if (closeOnEsc) onClose == null ? void 0 : onClose();
|
|
658
|
+
onEsc == null ? void 0 : onEsc();
|
|
659
|
+
},
|
|
660
|
+
[closeOnEsc, onClose, onEsc]
|
|
661
|
+
);
|
|
662
|
+
const validChildren = (0, import_utils17.getValidChildren)(children);
|
|
663
|
+
const [customModalOverlay, ...cloneChildren] = (0, import_utils17.findChildren)(
|
|
664
|
+
validChildren,
|
|
665
|
+
ModalOverlay,
|
|
666
|
+
DialogOverlay,
|
|
667
|
+
DrawerOverlay
|
|
668
|
+
);
|
|
669
|
+
let [drawerContent] = (0, import_utils17.findChildren)(validChildren, DrawerContent);
|
|
670
|
+
if (drawerContent)
|
|
671
|
+
drawerContent = (0, import_react2.cloneElement)(drawerContent, { onKeyDown });
|
|
672
|
+
const placement = (0, import_use_value2.useValue)(_placement);
|
|
718
673
|
const css = {
|
|
674
|
+
position: "fixed",
|
|
675
|
+
top: 0,
|
|
676
|
+
left: 0,
|
|
677
|
+
zIndex: "fallback(jeice, 110)",
|
|
678
|
+
w: "100vw",
|
|
679
|
+
h: "100dvh",
|
|
680
|
+
p: size !== "full" ? outside : void 0,
|
|
719
681
|
display: "flex",
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
...__css ? __css : styles.footer
|
|
682
|
+
justifyContent: placement.includes("left") ? "flex-start" : placement.includes("right") ? "flex-end" : "center",
|
|
683
|
+
alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
|
|
723
684
|
};
|
|
724
|
-
return /* @__PURE__ */ (0,
|
|
725
|
-
|
|
685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
686
|
+
ModalProvider,
|
|
726
687
|
{
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
688
|
+
value: {
|
|
689
|
+
isOpen,
|
|
690
|
+
onClose,
|
|
691
|
+
onOverlayClick,
|
|
692
|
+
withCloseButton,
|
|
693
|
+
scrollBehavior,
|
|
694
|
+
closeOnOverlay,
|
|
695
|
+
animation,
|
|
696
|
+
duration,
|
|
697
|
+
styles
|
|
698
|
+
},
|
|
699
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_motion6.AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
700
|
+
import_focus_lock.FocusLock,
|
|
701
|
+
{
|
|
702
|
+
autoFocus,
|
|
703
|
+
initialFocusRef,
|
|
704
|
+
finalFocusRef,
|
|
705
|
+
restoreFocus,
|
|
706
|
+
lockFocusAcrossFrames,
|
|
707
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
708
|
+
import_react_remove_scroll.RemoveScroll,
|
|
709
|
+
{
|
|
710
|
+
allowPinchZoom,
|
|
711
|
+
enabled: blockScrollOnMount,
|
|
712
|
+
forwardProps: true,
|
|
713
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_core12.ui.div, { __css: css, ...containerProps, children: [
|
|
714
|
+
customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ModalOverlay, {}) : null,
|
|
715
|
+
drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
716
|
+
ModalContent,
|
|
717
|
+
{
|
|
718
|
+
ref,
|
|
719
|
+
className,
|
|
720
|
+
onKeyDown,
|
|
721
|
+
...rest,
|
|
722
|
+
children: cloneChildren
|
|
723
|
+
}
|
|
724
|
+
)
|
|
725
|
+
] })
|
|
726
|
+
}
|
|
727
|
+
)
|
|
728
|
+
}
|
|
729
|
+
) }) : null })
|
|
731
730
|
}
|
|
732
731
|
);
|
|
733
732
|
}
|
|
734
733
|
);
|
|
735
734
|
|
|
736
735
|
// src/dialog.tsx
|
|
737
|
-
var
|
|
738
|
-
var
|
|
739
|
-
name: `DialogContext`,
|
|
740
|
-
errorMessage: `useDialog returned is 'undefined'. Seems you forgot to wrap the components in "<Dialog />" `
|
|
741
|
-
});
|
|
742
|
-
var Dialog = (0, import_motion4.motionForwardRef)(
|
|
736
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
737
|
+
var Dialog = (0, import_motion7.motionForwardRef)(
|
|
743
738
|
({ size, ...props }, ref) => {
|
|
744
|
-
const [styles, mergedProps] = (0,
|
|
739
|
+
const [styles, mergedProps] = (0, import_core13.useComponentMultiStyle)("Dialog", {
|
|
745
740
|
size,
|
|
746
741
|
...props
|
|
747
742
|
});
|
|
@@ -761,17 +756,17 @@ var Dialog = (0, import_motion4.motionForwardRef)(
|
|
|
761
756
|
onSuccess,
|
|
762
757
|
containerProps,
|
|
763
758
|
...rest
|
|
764
|
-
} = (0,
|
|
765
|
-
const validChildren = (0,
|
|
766
|
-
const [customDialogOverlay] = (0,
|
|
767
|
-
const [customDialogCloseButton] = (0,
|
|
759
|
+
} = (0, import_core13.omitThemeProps)(mergedProps);
|
|
760
|
+
const validChildren = (0, import_utils18.getValidChildren)(children);
|
|
761
|
+
const [customDialogOverlay] = (0, import_utils18.findChildren)(validChildren, DialogOverlay);
|
|
762
|
+
const [customDialogCloseButton] = (0, import_utils18.findChildren)(
|
|
768
763
|
validChildren,
|
|
769
764
|
DialogCloseButton
|
|
770
765
|
);
|
|
771
|
-
const [customDialogHeader] = (0,
|
|
772
|
-
const [customDialogBody] = (0,
|
|
773
|
-
const [customDialogFooter] = (0,
|
|
774
|
-
const cloneChildren = !(0,
|
|
766
|
+
const [customDialogHeader] = (0, import_utils18.findChildren)(validChildren, DialogHeader);
|
|
767
|
+
const [customDialogBody] = (0, import_utils18.findChildren)(validChildren, DialogBody);
|
|
768
|
+
const [customDialogFooter] = (0, import_utils18.findChildren)(validChildren, DialogFooter);
|
|
769
|
+
const cloneChildren = !(0, import_utils18.isEmpty)(validChildren) ? (0, import_utils18.omitChildren)(
|
|
775
770
|
validChildren,
|
|
776
771
|
DialogOverlay,
|
|
777
772
|
DialogCloseButton,
|
|
@@ -780,20 +775,20 @@ var Dialog = (0, import_motion4.motionForwardRef)(
|
|
|
780
775
|
DialogFooter
|
|
781
776
|
) : children;
|
|
782
777
|
const css = { ...styles.container };
|
|
783
|
-
const cancelButtonProps = (0,
|
|
784
|
-
const otherButtonProps = (0,
|
|
785
|
-
const successButtonProps = (0,
|
|
778
|
+
const cancelButtonProps = (0, import_utils18.isValidElement)(cancel) ? { children: cancel } : cancel;
|
|
779
|
+
const otherButtonProps = (0, import_utils18.isValidElement)(other) ? { children: other } : other;
|
|
780
|
+
const successButtonProps = (0, import_utils18.isValidElement)(success) ? { children: success } : success;
|
|
786
781
|
if (cancelButtonProps && !cancelButtonProps.variant)
|
|
787
782
|
cancelButtonProps.variant = "ghost";
|
|
788
783
|
if (otherButtonProps && !otherButtonProps.colorScheme)
|
|
789
784
|
otherButtonProps.colorScheme = "secondary";
|
|
790
785
|
if (successButtonProps && !successButtonProps.colorScheme)
|
|
791
786
|
successButtonProps.colorScheme = "primary";
|
|
792
|
-
return /* @__PURE__ */ (0,
|
|
787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
793
788
|
Modal,
|
|
794
789
|
{
|
|
795
790
|
ref,
|
|
796
|
-
className: (0,
|
|
791
|
+
className: (0, import_utils18.cx)("ui-dialog", className),
|
|
797
792
|
__css: css,
|
|
798
793
|
...{
|
|
799
794
|
onClose,
|
|
@@ -804,26 +799,26 @@ var Dialog = (0, import_motion4.motionForwardRef)(
|
|
|
804
799
|
size
|
|
805
800
|
},
|
|
806
801
|
children: [
|
|
807
|
-
customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0,
|
|
808
|
-
customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0,
|
|
809
|
-
customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0,
|
|
810
|
-
customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0,
|
|
811
|
-
customDialogFooter != null ? customDialogFooter : footer || cancelButtonProps || otherButtonProps || successButtonProps ? /* @__PURE__ */ (0,
|
|
812
|
-
cancelButtonProps ? /* @__PURE__ */ (0,
|
|
802
|
+
customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DialogOverlay, {}) : null,
|
|
803
|
+
customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DialogCloseButton, {}) : null,
|
|
804
|
+
customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DialogHeader, { children: header }) : null,
|
|
805
|
+
customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DialogBody, { children: cloneChildren }) : null,
|
|
806
|
+
customDialogFooter != null ? customDialogFooter : footer || cancelButtonProps || otherButtonProps || successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DialogFooter, { children: footer != null ? footer : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
807
|
+
cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
813
808
|
import_button.Button,
|
|
814
809
|
{
|
|
815
810
|
onClick: () => onCancel == null ? void 0 : onCancel(onClose),
|
|
816
811
|
...cancelButtonProps
|
|
817
812
|
}
|
|
818
813
|
) : null,
|
|
819
|
-
otherButtonProps ? /* @__PURE__ */ (0,
|
|
814
|
+
otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
820
815
|
import_button.Button,
|
|
821
816
|
{
|
|
822
817
|
onClick: () => onOther == null ? void 0 : onOther(onClose),
|
|
823
818
|
...otherButtonProps
|
|
824
819
|
}
|
|
825
820
|
) : null,
|
|
826
|
-
successButtonProps ? /* @__PURE__ */ (0,
|
|
821
|
+
successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
827
822
|
import_button.Button,
|
|
828
823
|
{
|
|
829
824
|
onClick: () => onSuccess == null ? void 0 : onSuccess(onClose),
|
|
@@ -836,88 +831,8 @@ var Dialog = (0, import_motion4.motionForwardRef)(
|
|
|
836
831
|
) });
|
|
837
832
|
}
|
|
838
833
|
);
|
|
839
|
-
var DialogOverlay = (0, import_motion4.motionForwardRef)(
|
|
840
|
-
({ className, ...rest }, ref) => {
|
|
841
|
-
const styles = useDialog();
|
|
842
|
-
const css = { ...styles.overlay };
|
|
843
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
844
|
-
ModalOverlay,
|
|
845
|
-
{
|
|
846
|
-
ref,
|
|
847
|
-
className: (0, import_utils8.cx)("ui-dialog__overlay", className),
|
|
848
|
-
__css: css,
|
|
849
|
-
...rest
|
|
850
|
-
}
|
|
851
|
-
);
|
|
852
|
-
}
|
|
853
|
-
);
|
|
854
|
-
var DialogCloseButton = (0, import_core7.forwardRef)(
|
|
855
|
-
({ className, ...rest }, ref) => {
|
|
856
|
-
const styles = useDialog();
|
|
857
|
-
const css = { ...styles.closeButton };
|
|
858
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
859
|
-
ModalCloseButton,
|
|
860
|
-
{
|
|
861
|
-
ref,
|
|
862
|
-
className: (0, import_utils8.cx)("ui-dialog__close-button", className),
|
|
863
|
-
__css: css,
|
|
864
|
-
...rest
|
|
865
|
-
}
|
|
866
|
-
);
|
|
867
|
-
}
|
|
868
|
-
);
|
|
869
|
-
var DialogHeader = (0, import_core7.forwardRef)(
|
|
870
|
-
({ className, ...rest }, ref) => {
|
|
871
|
-
const styles = useDialog();
|
|
872
|
-
const css = { ...styles.header };
|
|
873
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
874
|
-
ModalHeader,
|
|
875
|
-
{
|
|
876
|
-
ref,
|
|
877
|
-
className: (0, import_utils8.cx)("ui-dialog__header", className),
|
|
878
|
-
__css: css,
|
|
879
|
-
...rest
|
|
880
|
-
}
|
|
881
|
-
);
|
|
882
|
-
}
|
|
883
|
-
);
|
|
884
|
-
var DialogBody = (0, import_core7.forwardRef)(
|
|
885
|
-
({ className, ...rest }, ref) => {
|
|
886
|
-
const styles = useDialog();
|
|
887
|
-
const css = { ...styles.body };
|
|
888
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
889
|
-
ModalBody,
|
|
890
|
-
{
|
|
891
|
-
ref,
|
|
892
|
-
className: (0, import_utils8.cx)("ui-dialog__body", className),
|
|
893
|
-
__css: css,
|
|
894
|
-
...rest
|
|
895
|
-
}
|
|
896
|
-
);
|
|
897
|
-
}
|
|
898
|
-
);
|
|
899
|
-
var DialogFooter = (0, import_core7.forwardRef)(
|
|
900
|
-
({ className, ...rest }, ref) => {
|
|
901
|
-
const styles = useDialog();
|
|
902
|
-
const css = { ...styles.footer };
|
|
903
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
904
|
-
ModalFooter,
|
|
905
|
-
{
|
|
906
|
-
ref,
|
|
907
|
-
className: (0, import_utils8.cx)("ui-dialog__footer", className),
|
|
908
|
-
__css: css,
|
|
909
|
-
...rest
|
|
910
|
-
}
|
|
911
|
-
);
|
|
912
|
-
}
|
|
913
|
-
);
|
|
914
834
|
// Annotate the CommonJS export names for ESM import in node:
|
|
915
835
|
0 && (module.exports = {
|
|
916
|
-
Dialog
|
|
917
|
-
DialogBody,
|
|
918
|
-
DialogCloseButton,
|
|
919
|
-
DialogFooter,
|
|
920
|
-
DialogHeader,
|
|
921
|
-
DialogOverlay
|
|
836
|
+
Dialog
|
|
922
837
|
});
|
|
923
838
|
//# sourceMappingURL=dialog.js.map
|