react-motion-modal 1.4.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -160
- package/dist/index.css +1 -1
- package/dist/index.d.ts +97 -426
- package/dist/index.js +307 -235
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { jsxs as F, jsx as _ } from "react/jsx-runtime";
|
|
2
|
+
import { useReducedMotion as D, useIsPresent as G, motion as E, AnimatePresence as H } from "motion/react";
|
|
3
|
+
import { useState as j, useRef as h, useEffect as v } from "react";
|
|
4
|
+
import { createPortal as $ } from "react-dom";
|
|
5
|
+
import { useStore as K } from "zustand/react";
|
|
6
|
+
import { createStore as U } from "zustand/vanilla";
|
|
7
|
+
const a = {
|
|
7
8
|
TOP: "top",
|
|
8
9
|
TOP_LEFT: "top-left",
|
|
9
10
|
TOP_RIGHT: "top-right",
|
|
@@ -16,218 +17,214 @@ const t = {
|
|
|
16
17
|
BOTTOM_LEFT: "bottom-left",
|
|
17
18
|
BOTTOM_RIGHT: "bottom-right",
|
|
18
19
|
BOTTOM_CENTER: "bottom-center"
|
|
19
|
-
},
|
|
20
|
+
}, O = 1e3, M = {
|
|
20
21
|
duration: 0.24,
|
|
21
22
|
ease: "easeOut"
|
|
22
|
-
},
|
|
23
|
+
}, g = {
|
|
23
24
|
duration: 0.18,
|
|
24
25
|
ease: "easeIn"
|
|
25
|
-
},
|
|
26
|
-
opacity:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
closeModal: () => {
|
|
48
|
-
const r = a().modals.findIndex((i) => i.id === c);
|
|
49
|
-
s(r);
|
|
50
|
-
}
|
|
51
|
-
}, u = {
|
|
52
|
-
id: c,
|
|
53
|
-
name: o,
|
|
54
|
-
params: m
|
|
55
|
-
}, d = [...a().modals, u];
|
|
56
|
-
e({
|
|
57
|
-
modals: d,
|
|
58
|
-
active: u
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
closeAllModal() {
|
|
62
|
-
const o = a().modals;
|
|
63
|
-
e({
|
|
64
|
-
modals: [],
|
|
65
|
-
active: void 0
|
|
66
|
-
});
|
|
67
|
-
for (const n of [...o].reverse())
|
|
68
|
-
n.params?.onClose?.();
|
|
26
|
+
}, C = {
|
|
27
|
+
initial: { opacity: 0 },
|
|
28
|
+
animate: {
|
|
29
|
+
opacity: 1,
|
|
30
|
+
transition: M
|
|
31
|
+
},
|
|
32
|
+
exit: {
|
|
33
|
+
opacity: 0,
|
|
34
|
+
transition: g
|
|
35
|
+
}
|
|
36
|
+
}, R = ({
|
|
37
|
+
x: o = 0,
|
|
38
|
+
y: t = 0
|
|
39
|
+
}) => ({
|
|
40
|
+
backdrop: C,
|
|
41
|
+
content: {
|
|
42
|
+
initial: { opacity: 0, x: o, y: t },
|
|
43
|
+
animate: {
|
|
44
|
+
opacity: 1,
|
|
45
|
+
x: 0,
|
|
46
|
+
y: 0,
|
|
47
|
+
transition: M
|
|
69
48
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
exit: {
|
|
50
|
+
opacity: 0,
|
|
51
|
+
x: o,
|
|
52
|
+
y: t,
|
|
53
|
+
transition: g
|
|
73
54
|
}
|
|
74
|
-
}
|
|
75
|
-
}),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
}, C = (e) => {
|
|
88
|
-
switch (e) {
|
|
89
|
-
case t.LEFT:
|
|
90
|
-
return T("-100%", 0);
|
|
91
|
-
case t.RIGHT:
|
|
92
|
-
return T("100%", 0);
|
|
93
|
-
case t.TOP:
|
|
94
|
-
case t.TOP_CENTER:
|
|
95
|
-
return T(0, "-100%");
|
|
96
|
-
case t.BOTTOM:
|
|
97
|
-
case t.BOTTOM_CENTER:
|
|
98
|
-
return T(0, "100%");
|
|
99
|
-
case t.TOP_LEFT:
|
|
100
|
-
return T("-100%", "-100%");
|
|
101
|
-
case t.TOP_RIGHT:
|
|
102
|
-
return T("100%", "-100%");
|
|
103
|
-
case t.BOTTOM_LEFT:
|
|
104
|
-
return T("-100%", "100%");
|
|
105
|
-
case t.BOTTOM_RIGHT:
|
|
106
|
-
return T("100%", "100%");
|
|
107
|
-
case t.CENTER:
|
|
108
|
-
return {
|
|
109
|
-
initial: {
|
|
110
|
-
opacity: 0,
|
|
111
|
-
scale: 0.96
|
|
55
|
+
}
|
|
56
|
+
}), et = {
|
|
57
|
+
dialog: () => ({
|
|
58
|
+
position: a.CENTER,
|
|
59
|
+
motion: {
|
|
60
|
+
backdrop: C,
|
|
61
|
+
content: {
|
|
62
|
+
initial: { opacity: 0, scale: 0.96 },
|
|
63
|
+
animate: {
|
|
64
|
+
opacity: 1,
|
|
65
|
+
scale: 1,
|
|
66
|
+
transition: M
|
|
112
67
|
},
|
|
113
|
-
animate: R,
|
|
114
68
|
exit: {
|
|
115
69
|
opacity: 0,
|
|
116
70
|
scale: 0.96,
|
|
117
|
-
transition:
|
|
71
|
+
transition: g
|
|
118
72
|
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
drawer: (o = {}) => {
|
|
77
|
+
const t = o.side ?? "right";
|
|
78
|
+
return {
|
|
79
|
+
position: t === "left" ? a.LEFT : a.RIGHT,
|
|
80
|
+
motion: R({
|
|
81
|
+
x: t === "left" ? "-100%" : "100%"
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
sheet: (o = {}) => {
|
|
86
|
+
const t = o.edge ?? "bottom";
|
|
87
|
+
return {
|
|
88
|
+
position: t === "top" ? a.TOP : a.BOTTOM,
|
|
89
|
+
motion: R({
|
|
90
|
+
y: t === "top" ? "-100%" : "100%"
|
|
91
|
+
})
|
|
92
|
+
};
|
|
133
93
|
}
|
|
134
|
-
},
|
|
135
|
-
switch (
|
|
136
|
-
case
|
|
94
|
+
}, N = (...o) => o.filter(Boolean).join(" "), I = (o) => {
|
|
95
|
+
switch (o) {
|
|
96
|
+
case a.TOP:
|
|
137
97
|
return "react-motion-modal__body--top";
|
|
138
|
-
case
|
|
98
|
+
case a.TOP_LEFT:
|
|
139
99
|
return "react-motion-modal__body--top-left";
|
|
140
|
-
case
|
|
100
|
+
case a.TOP_RIGHT:
|
|
141
101
|
return "react-motion-modal__body--top-right";
|
|
142
|
-
case
|
|
102
|
+
case a.TOP_CENTER:
|
|
143
103
|
return "react-motion-modal__body--top-center";
|
|
144
|
-
case
|
|
104
|
+
case a.BOTTOM:
|
|
145
105
|
return "react-motion-modal__body--bottom";
|
|
146
|
-
case
|
|
106
|
+
case a.BOTTOM_LEFT:
|
|
147
107
|
return "react-motion-modal__body--bottom-left";
|
|
148
|
-
case
|
|
108
|
+
case a.BOTTOM_RIGHT:
|
|
149
109
|
return "react-motion-modal__body--bottom-right";
|
|
150
|
-
case
|
|
110
|
+
case a.BOTTOM_CENTER:
|
|
151
111
|
return "react-motion-modal__body--bottom-center";
|
|
152
|
-
case
|
|
112
|
+
case a.LEFT:
|
|
153
113
|
return "react-motion-modal__body--left";
|
|
154
|
-
case
|
|
114
|
+
case a.RIGHT:
|
|
155
115
|
return "react-motion-modal__body--right";
|
|
156
|
-
case
|
|
116
|
+
case a.CENTER:
|
|
157
117
|
return "react-motion-modal__body--center";
|
|
158
|
-
case
|
|
118
|
+
case a.CENTER_FULL:
|
|
159
119
|
return "react-motion-modal__body--center-full";
|
|
160
120
|
default:
|
|
161
|
-
return
|
|
121
|
+
return I(a.CENTER);
|
|
122
|
+
}
|
|
123
|
+
}, k = (o, t) => {
|
|
124
|
+
if (!(!o && !t))
|
|
125
|
+
return {
|
|
126
|
+
...o,
|
|
127
|
+
...t,
|
|
128
|
+
style: {
|
|
129
|
+
...o?.style,
|
|
130
|
+
...t?.style
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}, L = (...o) => {
|
|
134
|
+
const t = {};
|
|
135
|
+
for (const r of o) {
|
|
136
|
+
const u = k(t.backdrop, r?.backdrop), s = k(t.body, r?.body);
|
|
137
|
+
Object.assign(t, r), t.backdrop = u, t.body = s;
|
|
162
138
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
139
|
+
return t;
|
|
140
|
+
}, w = {
|
|
141
|
+
initial: { opacity: 1 },
|
|
142
|
+
animate: { opacity: 1, transition: { duration: 0 } },
|
|
143
|
+
exit: { opacity: 1, transition: { duration: 0 } }
|
|
144
|
+
}, z = ({ data: o, index: t, isActive: r, defaultOptions: u }) => {
|
|
145
|
+
const s = D(), i = G(), m = r && i, {
|
|
146
|
+
component: c,
|
|
147
|
+
defaultOptions: l,
|
|
148
|
+
preset: d
|
|
149
|
+
} = o.definition, e = L(
|
|
150
|
+
u,
|
|
151
|
+
d ? {
|
|
152
|
+
position: d.position,
|
|
153
|
+
motion: d.motion
|
|
154
|
+
} : void 0,
|
|
155
|
+
l,
|
|
156
|
+
o.options
|
|
157
|
+
), n = e.position ?? a.CENTER, f = e.closeOnClickOutside ?? !0, y = s ? w : e.motion?.content, b = s ? w : e.motion?.backdrop;
|
|
158
|
+
return /* @__PURE__ */ F(
|
|
159
|
+
E.div,
|
|
170
160
|
{
|
|
171
161
|
className: "react-motion-modal__root",
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
animate: m?.animate ?? { opacity: 1 },
|
|
175
|
-
layout: !0,
|
|
162
|
+
initial: !1,
|
|
163
|
+
exit: {},
|
|
176
164
|
style: {
|
|
177
|
-
zIndex:
|
|
178
|
-
pointerEvents:
|
|
179
|
-
backdropFilter:
|
|
180
|
-
WebkitBackdropFilter:
|
|
165
|
+
zIndex: O + t,
|
|
166
|
+
pointerEvents: m ? void 0 : "none",
|
|
167
|
+
backdropFilter: e.blur ? "blur(8px)" : void 0,
|
|
168
|
+
WebkitBackdropFilter: e.blur ? "blur(8px)" : void 0
|
|
181
169
|
},
|
|
182
170
|
children: [
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
|
|
171
|
+
/* @__PURE__ */ _(
|
|
172
|
+
E.div,
|
|
185
173
|
{
|
|
186
|
-
className:
|
|
174
|
+
className: N(
|
|
187
175
|
"react-motion-modal__backdrop",
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
d?.className
|
|
176
|
+
m && "react-motion-modal__active",
|
|
177
|
+
e.backdrop?.className
|
|
191
178
|
),
|
|
179
|
+
initial: b?.initial ?? { opacity: 0 },
|
|
180
|
+
animate: b?.animate ?? { opacity: 1 },
|
|
181
|
+
exit: b?.exit ?? { opacity: 0 },
|
|
192
182
|
style: {
|
|
193
|
-
zIndex:
|
|
194
|
-
...
|
|
183
|
+
zIndex: O + t,
|
|
184
|
+
...e.backdrop?.style
|
|
195
185
|
},
|
|
196
186
|
onClick: () => {
|
|
197
|
-
|
|
187
|
+
f && o.cancel("backdrop");
|
|
198
188
|
}
|
|
199
189
|
}
|
|
200
190
|
),
|
|
201
|
-
/* @__PURE__ */
|
|
191
|
+
/* @__PURE__ */ _(
|
|
202
192
|
"div",
|
|
203
193
|
{
|
|
204
194
|
role: "dialog",
|
|
205
|
-
"aria-modal":
|
|
206
|
-
"aria-hidden":
|
|
207
|
-
"aria-label":
|
|
208
|
-
"aria-labelledby":
|
|
209
|
-
"aria-describedby":
|
|
195
|
+
"aria-modal": m ? "true" : void 0,
|
|
196
|
+
"aria-hidden": m ? void 0 : !0,
|
|
197
|
+
"aria-label": e.ariaLabelledBy ? void 0 : e.ariaLabel ?? "Modal",
|
|
198
|
+
"aria-labelledby": e.ariaLabelledBy,
|
|
199
|
+
"aria-describedby": e.ariaDescribedBy,
|
|
210
200
|
tabIndex: -1,
|
|
211
|
-
"data-modal-id":
|
|
212
|
-
className:
|
|
201
|
+
"data-modal-id": o.id,
|
|
202
|
+
className: N(
|
|
213
203
|
"react-motion-modal__body",
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
204
|
+
I(n),
|
|
205
|
+
m && "react-motion-modal__body--active",
|
|
206
|
+
e.body?.className
|
|
217
207
|
),
|
|
218
208
|
style: {
|
|
219
|
-
...
|
|
220
|
-
zIndex:
|
|
209
|
+
...e.body?.style,
|
|
210
|
+
zIndex: O + t + 1
|
|
221
211
|
},
|
|
222
|
-
onClick: (
|
|
223
|
-
children: /* @__PURE__ */
|
|
224
|
-
|
|
212
|
+
onClick: (T) => T.stopPropagation(),
|
|
213
|
+
children: /* @__PURE__ */ _(
|
|
214
|
+
E.div,
|
|
225
215
|
{
|
|
226
216
|
className: "react-motion-modal__content",
|
|
227
|
-
initial:
|
|
228
|
-
animate:
|
|
229
|
-
exit:
|
|
230
|
-
children: /* @__PURE__ */
|
|
217
|
+
initial: y?.initial,
|
|
218
|
+
animate: y?.animate,
|
|
219
|
+
exit: y?.exit,
|
|
220
|
+
children: /* @__PURE__ */ _(
|
|
221
|
+
c,
|
|
222
|
+
{
|
|
223
|
+
input: o.input,
|
|
224
|
+
resolve: o.resolve,
|
|
225
|
+
cancel: (T) => o.cancel(T)
|
|
226
|
+
}
|
|
227
|
+
)
|
|
231
228
|
}
|
|
232
229
|
)
|
|
233
230
|
}
|
|
@@ -235,98 +232,173 @@ const t = {
|
|
|
235
232
|
]
|
|
236
233
|
}
|
|
237
234
|
);
|
|
238
|
-
},
|
|
235
|
+
}, q = [
|
|
239
236
|
"a[href]",
|
|
240
237
|
"button:not([disabled])",
|
|
241
238
|
"textarea:not([disabled])",
|
|
242
239
|
"input:not([disabled])",
|
|
243
240
|
"select:not([disabled])",
|
|
244
241
|
'[tabindex]:not([tabindex="-1"])'
|
|
245
|
-
].join(","),
|
|
246
|
-
|
|
247
|
-
).filter((
|
|
248
|
-
if (!
|
|
242
|
+
].join(","), S = (o) => o ? Array.from(
|
|
243
|
+
o.querySelectorAll(q)
|
|
244
|
+
).filter((t) => t.getClientRects().length > 0) : [], W = (o, t) => {
|
|
245
|
+
if (!o || t.key !== "Tab")
|
|
249
246
|
return;
|
|
250
|
-
const
|
|
251
|
-
if (!
|
|
252
|
-
|
|
247
|
+
const r = S(o), u = r[0], s = r[r.length - 1], i = document.activeElement;
|
|
248
|
+
if (!u || !s) {
|
|
249
|
+
t.preventDefault(), o.focus();
|
|
253
250
|
return;
|
|
254
251
|
}
|
|
255
|
-
if (!
|
|
256
|
-
|
|
252
|
+
if (!i || !o.contains(i)) {
|
|
253
|
+
t.preventDefault(), (t.shiftKey ? s : u).focus();
|
|
257
254
|
return;
|
|
258
255
|
}
|
|
259
|
-
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
|
|
256
|
+
t.shiftKey && i === u ? (t.preventDefault(), s.focus()) : !t.shiftKey && i === s && (t.preventDefault(), u.focus());
|
|
257
|
+
}, P = /* @__PURE__ */ new WeakMap(), x = (o) => {
|
|
258
|
+
const t = P.get(o);
|
|
259
|
+
if (!t)
|
|
260
|
+
throw new Error("Invalid modal system instance.");
|
|
261
|
+
return t;
|
|
262
|
+
}, X = (o) => x(o).store, Z = (o) => {
|
|
263
|
+
const t = x(o);
|
|
264
|
+
t.providerCount += 1;
|
|
265
|
+
let r = !0;
|
|
266
|
+
return () => {
|
|
267
|
+
r && (r = !1, t.providerCount -= 1, queueMicrotask(() => {
|
|
268
|
+
t.providerCount === 0 && o.cancelAll("provider-unmounted");
|
|
269
|
+
}));
|
|
270
|
+
};
|
|
271
|
+
}, nt = (o) => {
|
|
272
|
+
const t = U(() => ({
|
|
273
|
+
activeModals: []
|
|
274
|
+
}));
|
|
275
|
+
let r = 0;
|
|
276
|
+
const u = (c) => {
|
|
277
|
+
t.setState((l) => ({
|
|
278
|
+
activeModals: l.activeModals.filter((d) => d.id !== c)
|
|
279
|
+
}));
|
|
280
|
+
}, s = (c = "programmatic") => {
|
|
281
|
+
const l = t.getState().activeModals;
|
|
282
|
+
l[l.length - 1]?.cancel(c);
|
|
283
|
+
}, m = {
|
|
284
|
+
open(c, l, d) {
|
|
285
|
+
const e = o[c];
|
|
286
|
+
if (!e)
|
|
287
|
+
throw new Error(`Unknown modal "${c}".`);
|
|
288
|
+
if (e.policy === "singleton") {
|
|
289
|
+
const p = t.getState().activeModals.find((A) => A.name === c);
|
|
290
|
+
if (p)
|
|
291
|
+
return p.promise;
|
|
292
|
+
}
|
|
293
|
+
e.policy === "replace" && s("replaced");
|
|
294
|
+
const n = `${c}-${++r}`;
|
|
295
|
+
let f = !1, y;
|
|
296
|
+
const b = new Promise((p) => {
|
|
297
|
+
y = p;
|
|
298
|
+
}), T = (p) => {
|
|
299
|
+
f || (f = !0, u(n), y?.(p));
|
|
300
|
+
}, B = {
|
|
301
|
+
id: n,
|
|
302
|
+
name: c,
|
|
303
|
+
input: l,
|
|
304
|
+
definition: e,
|
|
305
|
+
options: d,
|
|
306
|
+
promise: b,
|
|
307
|
+
resolve(p) {
|
|
308
|
+
T({ status: "resolved", value: p });
|
|
309
|
+
},
|
|
310
|
+
cancel(p = "programmatic") {
|
|
311
|
+
T({ status: "cancelled", reason: p });
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
return t.setState((p) => ({
|
|
315
|
+
activeModals: [...p.activeModals, B]
|
|
316
|
+
})), b;
|
|
317
|
+
},
|
|
318
|
+
cancel: s,
|
|
319
|
+
cancelAll: (c = "programmatic") => {
|
|
320
|
+
const l = [...t.getState().activeModals].reverse();
|
|
321
|
+
for (const d of l)
|
|
322
|
+
d.cancel(c);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
return P.set(m, {
|
|
326
|
+
store: t,
|
|
327
|
+
providerCount: 0
|
|
328
|
+
}), m;
|
|
329
|
+
}, it = ({
|
|
330
|
+
system: o,
|
|
331
|
+
defaultOptions: t,
|
|
332
|
+
portalRoot: r
|
|
263
333
|
}) => {
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
|
|
334
|
+
const u = X(o), s = K(u, (n) => n.activeModals), i = s[s.length - 1], [m, c] = j(
|
|
335
|
+
r ?? null
|
|
336
|
+
), l = h(null), d = h(null), e = s.length > 0;
|
|
337
|
+
return v(() => {
|
|
338
|
+
c(r ?? document.body);
|
|
339
|
+
}, [r]), v(() => Z(o), [o]), v(() => {
|
|
340
|
+
const n = () => o.cancelAll("programmatic");
|
|
341
|
+
return window.addEventListener("popstate", n), () => window.removeEventListener("popstate", n);
|
|
342
|
+
}, [o]), v(() => {
|
|
343
|
+
if (!e)
|
|
272
344
|
return;
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
345
|
+
const f = L(
|
|
346
|
+
t,
|
|
347
|
+
i?.definition.preset ? {
|
|
348
|
+
position: i.definition.preset.position,
|
|
349
|
+
motion: i.definition.preset.motion
|
|
350
|
+
} : void 0,
|
|
351
|
+
i?.definition.defaultOptions,
|
|
352
|
+
i?.options
|
|
353
|
+
).closeOnPressEsc ?? !0, y = (b) => {
|
|
354
|
+
if (b.key === "Escape" && f) {
|
|
355
|
+
i?.cancel("escape");
|
|
276
356
|
return;
|
|
277
357
|
}
|
|
278
|
-
const
|
|
279
|
-
`[data-modal-id="${
|
|
358
|
+
const T = i ? l.current?.querySelector(
|
|
359
|
+
`[data-modal-id="${i.id}"]`
|
|
280
360
|
) : void 0;
|
|
281
|
-
|
|
361
|
+
W(T, b);
|
|
282
362
|
};
|
|
283
|
-
return window.addEventListener("keydown",
|
|
284
|
-
}, [
|
|
285
|
-
|
|
286
|
-
o?.id,
|
|
287
|
-
n,
|
|
288
|
-
a?.closeOnPressEsc,
|
|
289
|
-
d
|
|
290
|
-
]), y(() => {
|
|
291
|
-
if (!d)
|
|
363
|
+
return window.addEventListener("keydown", y), () => window.removeEventListener("keydown", y);
|
|
364
|
+
}, [i, t, e]), v(() => {
|
|
365
|
+
if (!e)
|
|
292
366
|
return;
|
|
293
|
-
const { body:
|
|
294
|
-
return
|
|
295
|
-
|
|
367
|
+
const { body: n } = document, f = n.style.overflow;
|
|
368
|
+
return n.style.overflow = "hidden", () => {
|
|
369
|
+
n.style.overflow = f;
|
|
296
370
|
};
|
|
297
|
-
}, [
|
|
298
|
-
if (!
|
|
371
|
+
}, [e]), v(() => {
|
|
372
|
+
if (!m)
|
|
299
373
|
return;
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
u.current?.focus?.(), u.current = null;
|
|
374
|
+
if (!e) {
|
|
375
|
+
d.current?.focus?.(), d.current = null;
|
|
303
376
|
return;
|
|
304
377
|
}
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
`[data-modal-id="${
|
|
378
|
+
d.current === null && (d.current = document.activeElement ?? null);
|
|
379
|
+
const n = i ? l.current?.querySelector(
|
|
380
|
+
`[data-modal-id="${i.id}"]`
|
|
308
381
|
) : void 0;
|
|
309
|
-
|
|
310
|
-
}, [
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
|
|
382
|
+
n && (S(n)[0] ?? n).focus();
|
|
383
|
+
}, [i, e, m]), m ? $(
|
|
384
|
+
/* @__PURE__ */ _("div", { className: "react-motion-modal", ref: l, children: /* @__PURE__ */ _(H, { initial: !0, mode: "sync", children: s.map((n, f) => /* @__PURE__ */ _(
|
|
385
|
+
z,
|
|
313
386
|
{
|
|
314
|
-
data:
|
|
315
|
-
index:
|
|
316
|
-
|
|
317
|
-
|
|
387
|
+
data: n,
|
|
388
|
+
index: f,
|
|
389
|
+
isActive: i?.id === n.id,
|
|
390
|
+
defaultOptions: t
|
|
318
391
|
},
|
|
319
|
-
|
|
392
|
+
n.id
|
|
320
393
|
)) }) }),
|
|
321
|
-
|
|
322
|
-
);
|
|
323
|
-
};
|
|
394
|
+
m
|
|
395
|
+
) : null;
|
|
396
|
+
}, at = (o) => o;
|
|
324
397
|
export {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
E as modalStore
|
|
398
|
+
a as MODAL_POSITIONS,
|
|
399
|
+
O as MODAL_Z_INDEX,
|
|
400
|
+
it as ModalProvider,
|
|
401
|
+
nt as createModalSystem,
|
|
402
|
+
at as defineModal,
|
|
403
|
+
et as motionPresets
|
|
332
404
|
};
|