@telegraph/modal 0.0.47 → 0.0.49
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/CHANGELOG.md +12 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +342 -271
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/Modal/Modal.d.ts +3 -2
- package/dist/types/Modal/Modal.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -1,104 +1,139 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as u, Fragment as I, jsxs as S } from "react/jsx-runtime";
|
|
2
2
|
import * as v from "@radix-ui/react-dialog";
|
|
3
|
-
import { FocusScope as
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
import * as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return o.useEffect(() => {
|
|
15
|
-
e.current = t;
|
|
16
|
-
}), o.useMemo(() => (...n) => {
|
|
17
|
-
var r;
|
|
18
|
-
return (r = e.current) == null ? void 0 : r.call(e, ...n);
|
|
19
|
-
}, []);
|
|
20
|
-
}
|
|
21
|
-
function ne({
|
|
22
|
-
prop: t,
|
|
23
|
-
defaultProp: e,
|
|
24
|
-
onChange: n = () => {
|
|
25
|
-
}
|
|
26
|
-
}) {
|
|
27
|
-
const [r, s] = re({ defaultProp: e, onChange: n }), i = t !== void 0, l = i ? t : r, a = M(n), u = o.useCallback(
|
|
28
|
-
(c) => {
|
|
29
|
-
if (i) {
|
|
30
|
-
const m = typeof c == "function" ? c(t) : c;
|
|
31
|
-
m !== t && a(m);
|
|
32
|
-
} else
|
|
33
|
-
s(c);
|
|
34
|
-
},
|
|
35
|
-
[i, t, s, a]
|
|
36
|
-
);
|
|
37
|
-
return [l, u];
|
|
38
|
-
}
|
|
39
|
-
function re({
|
|
40
|
-
defaultProp: t,
|
|
41
|
-
onChange: e
|
|
42
|
-
}) {
|
|
43
|
-
const n = o.useState(t), [r] = n, s = o.useRef(r), i = M(e);
|
|
44
|
-
return o.useEffect(() => {
|
|
45
|
-
s.current !== r && (i(r), s.current = r);
|
|
46
|
-
}, [r, s, i]), n;
|
|
47
|
-
}
|
|
48
|
-
function R(t, e, { checkForDefaultPrevented: n = !0 } = {}) {
|
|
49
|
-
return function(s) {
|
|
50
|
-
if (t == null || t(s), n === !1 || !s.defaultPrevented)
|
|
51
|
-
return e == null ? void 0 : e(s);
|
|
52
|
-
};
|
|
53
|
-
}
|
|
3
|
+
import { FocusScope as q } from "@radix-ui/react-focus-scope";
|
|
4
|
+
import * as s from "react";
|
|
5
|
+
import b from "react";
|
|
6
|
+
import * as G from "react-dom";
|
|
7
|
+
import J from "react-dom";
|
|
8
|
+
import * as Q from "@radix-ui/react-visually-hidden";
|
|
9
|
+
import { Button as ee } from "@telegraph/button";
|
|
10
|
+
import { RefToTgphRef as te } from "@telegraph/helpers";
|
|
11
|
+
import { Lucide as ne } from "@telegraph/icon";
|
|
12
|
+
import { Stack as g, Box as re } from "@telegraph/layout";
|
|
13
|
+
import { AnimatePresence as oe, motion as T } from "framer-motion";
|
|
54
14
|
function se(t, e) {
|
|
55
15
|
typeof t == "function" ? t(e) : t != null && (t.current = e);
|
|
56
16
|
}
|
|
57
|
-
function
|
|
17
|
+
function ie(...t) {
|
|
58
18
|
return (e) => t.forEach((n) => se(n, e));
|
|
59
19
|
}
|
|
60
|
-
var
|
|
61
|
-
const { children: n, ...r } = t,
|
|
20
|
+
var W = s.forwardRef((t, e) => {
|
|
21
|
+
const { children: n, ...r } = t, o = s.Children.toArray(n), i = o.find(ce);
|
|
62
22
|
if (i) {
|
|
63
|
-
const
|
|
64
|
-
return /* @__PURE__ */
|
|
23
|
+
const a = i.props.children, c = o.map((y) => y === i ? s.Children.count(a) > 1 ? s.Children.only(null) : s.isValidElement(a) ? a.props.children : null : y);
|
|
24
|
+
return /* @__PURE__ */ u(N, { ...r, ref: e, children: s.isValidElement(a) ? s.cloneElement(a, void 0, c) : null });
|
|
65
25
|
}
|
|
66
|
-
return /* @__PURE__ */
|
|
26
|
+
return /* @__PURE__ */ u(N, { ...r, ref: e, children: n });
|
|
67
27
|
});
|
|
68
|
-
|
|
69
|
-
var
|
|
28
|
+
W.displayName = "Slot";
|
|
29
|
+
var N = s.forwardRef((t, e) => {
|
|
70
30
|
const { children: n, ...r } = t;
|
|
71
|
-
if (
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
...
|
|
31
|
+
if (s.isValidElement(n)) {
|
|
32
|
+
const o = ue(n);
|
|
33
|
+
return s.cloneElement(n, {
|
|
34
|
+
...le(r, n.props),
|
|
75
35
|
// @ts-ignore
|
|
76
|
-
ref: e ?
|
|
36
|
+
ref: e ? ie(e, o) : o
|
|
77
37
|
});
|
|
78
38
|
}
|
|
79
|
-
return
|
|
39
|
+
return s.Children.count(n) > 1 ? s.Children.only(null) : null;
|
|
80
40
|
});
|
|
81
|
-
|
|
82
|
-
var
|
|
83
|
-
function
|
|
84
|
-
return
|
|
41
|
+
N.displayName = "SlotClone";
|
|
42
|
+
var ae = ({ children: t }) => /* @__PURE__ */ u(I, { children: t });
|
|
43
|
+
function ce(t) {
|
|
44
|
+
return s.isValidElement(t) && t.type === ae;
|
|
85
45
|
}
|
|
86
|
-
function
|
|
46
|
+
function le(t, e) {
|
|
87
47
|
const n = { ...e };
|
|
88
48
|
for (const r in e) {
|
|
89
|
-
const
|
|
90
|
-
/^on[A-Z]/.test(r) ?
|
|
91
|
-
i(...
|
|
92
|
-
} :
|
|
49
|
+
const o = t[r], i = e[r];
|
|
50
|
+
/^on[A-Z]/.test(r) ? o && i ? n[r] = (...c) => {
|
|
51
|
+
i(...c), o(...c);
|
|
52
|
+
} : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...i } : r === "className" && (n[r] = [o, i].filter(Boolean).join(" "));
|
|
93
53
|
}
|
|
94
54
|
return { ...t, ...n };
|
|
95
55
|
}
|
|
96
|
-
function
|
|
97
|
-
var r,
|
|
56
|
+
function ue(t) {
|
|
57
|
+
var r, o;
|
|
98
58
|
let e = (r = Object.getOwnPropertyDescriptor(t.props, "ref")) == null ? void 0 : r.get, n = e && "isReactWarning" in e && e.isReactWarning;
|
|
99
|
-
return n ? t.ref : (e = (
|
|
59
|
+
return n ? t.ref : (e = (o = Object.getOwnPropertyDescriptor(t, "ref")) == null ? void 0 : o.get, n = e && "isReactWarning" in e && e.isReactWarning, n ? t.props.ref : t.props.ref || t.ref);
|
|
60
|
+
}
|
|
61
|
+
var de = [
|
|
62
|
+
"a",
|
|
63
|
+
"button",
|
|
64
|
+
"div",
|
|
65
|
+
"form",
|
|
66
|
+
"h2",
|
|
67
|
+
"h3",
|
|
68
|
+
"img",
|
|
69
|
+
"input",
|
|
70
|
+
"label",
|
|
71
|
+
"li",
|
|
72
|
+
"nav",
|
|
73
|
+
"ol",
|
|
74
|
+
"p",
|
|
75
|
+
"span",
|
|
76
|
+
"svg",
|
|
77
|
+
"ul"
|
|
78
|
+
], fe = de.reduce((t, e) => {
|
|
79
|
+
const n = s.forwardRef((r, o) => {
|
|
80
|
+
const { asChild: i, ...a } = r, c = i ? W : e;
|
|
81
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ u(c, { ...a, ref: o });
|
|
82
|
+
});
|
|
83
|
+
return n.displayName = `Primitive.${e}`, { ...t, [e]: n };
|
|
84
|
+
}, {}), pe = globalThis != null && globalThis.document ? s.useLayoutEffect : () => {
|
|
85
|
+
}, ye = "Portal", j = s.forwardRef((t, e) => {
|
|
86
|
+
var c;
|
|
87
|
+
const { container: n, ...r } = t, [o, i] = s.useState(!1);
|
|
88
|
+
pe(() => i(!0), []);
|
|
89
|
+
const a = n || o && ((c = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : c.body);
|
|
90
|
+
return a ? J.createPortal(/* @__PURE__ */ u(fe.div, { ...r, ref: e }), a) : null;
|
|
91
|
+
});
|
|
92
|
+
j.displayName = ye;
|
|
93
|
+
var he = j;
|
|
94
|
+
function U(t) {
|
|
95
|
+
const e = s.useRef(t);
|
|
96
|
+
return s.useEffect(() => {
|
|
97
|
+
e.current = t;
|
|
98
|
+
}), s.useMemo(() => (...n) => {
|
|
99
|
+
var r;
|
|
100
|
+
return (r = e.current) == null ? void 0 : r.call(e, ...n);
|
|
101
|
+
}, []);
|
|
100
102
|
}
|
|
101
|
-
|
|
103
|
+
function me({
|
|
104
|
+
prop: t,
|
|
105
|
+
defaultProp: e,
|
|
106
|
+
onChange: n = () => {
|
|
107
|
+
}
|
|
108
|
+
}) {
|
|
109
|
+
const [r, o] = ve({ defaultProp: e, onChange: n }), i = t !== void 0, a = i ? t : r, c = U(n), y = s.useCallback(
|
|
110
|
+
(l) => {
|
|
111
|
+
if (i) {
|
|
112
|
+
const f = typeof l == "function" ? l(t) : l;
|
|
113
|
+
f !== t && c(f);
|
|
114
|
+
} else
|
|
115
|
+
o(l);
|
|
116
|
+
},
|
|
117
|
+
[i, t, o, c]
|
|
118
|
+
);
|
|
119
|
+
return [a, y];
|
|
120
|
+
}
|
|
121
|
+
function ve({
|
|
122
|
+
defaultProp: t,
|
|
123
|
+
onChange: e
|
|
124
|
+
}) {
|
|
125
|
+
const n = s.useState(t), [r] = n, o = s.useRef(r), i = U(e);
|
|
126
|
+
return s.useEffect(() => {
|
|
127
|
+
o.current !== r && (i(r), o.current = r);
|
|
128
|
+
}, [r, o, i]), n;
|
|
129
|
+
}
|
|
130
|
+
function x(t, e, { checkForDefaultPrevented: n = !0 } = {}) {
|
|
131
|
+
return function(o) {
|
|
132
|
+
if (t == null || t(o), n === !1 || !o.defaultPrevented)
|
|
133
|
+
return e == null ? void 0 : e(o);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
var ge = [
|
|
102
137
|
"a",
|
|
103
138
|
"button",
|
|
104
139
|
"div",
|
|
@@ -115,165 +150,165 @@ var ue = [
|
|
|
115
150
|
"span",
|
|
116
151
|
"svg",
|
|
117
152
|
"ul"
|
|
118
|
-
],
|
|
119
|
-
const n =
|
|
120
|
-
const { asChild: i, ...
|
|
121
|
-
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */
|
|
153
|
+
], z = ge.reduce((t, e) => {
|
|
154
|
+
const n = s.forwardRef((r, o) => {
|
|
155
|
+
const { asChild: i, ...a } = r, c = i ? W : e;
|
|
156
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ u(c, { ...a, ref: o });
|
|
122
157
|
});
|
|
123
158
|
return n.displayName = `Primitive.${e}`, { ...t, [e]: n };
|
|
124
159
|
}, {});
|
|
125
|
-
function
|
|
126
|
-
t &&
|
|
160
|
+
function Ee(t, e) {
|
|
161
|
+
t && G.flushSync(() => t.dispatchEvent(e));
|
|
127
162
|
}
|
|
128
|
-
function
|
|
163
|
+
function be(t, e) {
|
|
129
164
|
typeof t == "function" ? t(e) : t != null && (t.current = e);
|
|
130
165
|
}
|
|
131
|
-
function
|
|
132
|
-
return (e) => t.forEach((n) =>
|
|
166
|
+
function Ce(...t) {
|
|
167
|
+
return (e) => t.forEach((n) => be(n, e));
|
|
133
168
|
}
|
|
134
|
-
function
|
|
135
|
-
return
|
|
169
|
+
function V(...t) {
|
|
170
|
+
return s.useCallback(Ce(...t), t);
|
|
136
171
|
}
|
|
137
|
-
function
|
|
138
|
-
const e =
|
|
139
|
-
return
|
|
172
|
+
function A(t) {
|
|
173
|
+
const e = s.useRef(t);
|
|
174
|
+
return s.useEffect(() => {
|
|
140
175
|
e.current = t;
|
|
141
|
-
}),
|
|
176
|
+
}), s.useMemo(() => (...n) => {
|
|
142
177
|
var r;
|
|
143
178
|
return (r = e.current) == null ? void 0 : r.call(e, ...n);
|
|
144
179
|
}, []);
|
|
145
180
|
}
|
|
146
|
-
function
|
|
147
|
-
const n =
|
|
148
|
-
|
|
149
|
-
const r = (
|
|
150
|
-
|
|
181
|
+
function Pe(t, e = globalThis == null ? void 0 : globalThis.document) {
|
|
182
|
+
const n = A(t);
|
|
183
|
+
s.useEffect(() => {
|
|
184
|
+
const r = (o) => {
|
|
185
|
+
o.key === "Escape" && n(o);
|
|
151
186
|
};
|
|
152
187
|
return e.addEventListener("keydown", r, { capture: !0 }), () => e.removeEventListener("keydown", r, { capture: !0 });
|
|
153
188
|
}, [n, e]);
|
|
154
189
|
}
|
|
155
|
-
var
|
|
190
|
+
var Le = "DismissableLayer", B = "dismissableLayer.update", we = "dismissableLayer.pointerDownOutside", Re = "dismissableLayer.focusOutside", $, K = s.createContext({
|
|
156
191
|
layers: /* @__PURE__ */ new Set(),
|
|
157
192
|
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
158
193
|
branches: /* @__PURE__ */ new Set()
|
|
159
|
-
}),
|
|
194
|
+
}), X = s.forwardRef(
|
|
160
195
|
(t, e) => {
|
|
161
196
|
const {
|
|
162
197
|
disableOutsidePointerEvents: n = !1,
|
|
163
198
|
onEscapeKeyDown: r,
|
|
164
|
-
onPointerDownOutside:
|
|
199
|
+
onPointerDownOutside: o,
|
|
165
200
|
onFocusOutside: i,
|
|
166
|
-
onInteractOutside:
|
|
167
|
-
onDismiss:
|
|
168
|
-
...
|
|
169
|
-
} = t,
|
|
170
|
-
const
|
|
171
|
-
!
|
|
172
|
-
},
|
|
173
|
-
const
|
|
174
|
-
[...
|
|
175
|
-
},
|
|
176
|
-
return
|
|
177
|
-
|
|
178
|
-
},
|
|
179
|
-
if (
|
|
180
|
-
return n && (
|
|
181
|
-
n &&
|
|
201
|
+
onInteractOutside: a,
|
|
202
|
+
onDismiss: c,
|
|
203
|
+
...y
|
|
204
|
+
} = t, l = s.useContext(K), [d, f] = s.useState(null), h = (d == null ? void 0 : d.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, C] = s.useState({}), D = V(e, (p) => f(p)), P = Array.from(l.layers), [L] = [...l.layersWithOutsidePointerEventsDisabled].slice(-1), w = P.indexOf(L), m = d ? P.indexOf(d) : -1, M = l.layersWithOutsidePointerEventsDisabled.size > 0, E = m >= w, Z = xe((p) => {
|
|
205
|
+
const R = p.target, F = [...l.branches].some((O) => O.contains(R));
|
|
206
|
+
!E || F || (o == null || o(p), a == null || a(p), p.defaultPrevented || c == null || c());
|
|
207
|
+
}, h), k = Se((p) => {
|
|
208
|
+
const R = p.target;
|
|
209
|
+
[...l.branches].some((O) => O.contains(R)) || (i == null || i(p), a == null || a(p), p.defaultPrevented || c == null || c());
|
|
210
|
+
}, h);
|
|
211
|
+
return Pe((p) => {
|
|
212
|
+
m === l.layers.size - 1 && (r == null || r(p), !p.defaultPrevented && c && (p.preventDefault(), c()));
|
|
213
|
+
}, h), s.useEffect(() => {
|
|
214
|
+
if (d)
|
|
215
|
+
return n && (l.layersWithOutsidePointerEventsDisabled.size === 0 && ($ = h.body.style.pointerEvents, h.body.style.pointerEvents = "none"), l.layersWithOutsidePointerEventsDisabled.add(d)), l.layers.add(d), _(), () => {
|
|
216
|
+
n && l.layersWithOutsidePointerEventsDisabled.size === 1 && (h.body.style.pointerEvents = $);
|
|
182
217
|
};
|
|
183
|
-
}, [
|
|
184
|
-
|
|
185
|
-
}, [
|
|
186
|
-
const
|
|
187
|
-
return document.addEventListener(
|
|
188
|
-
}, []), /* @__PURE__ */
|
|
189
|
-
|
|
218
|
+
}, [d, h, n, l]), s.useEffect(() => () => {
|
|
219
|
+
d && (l.layers.delete(d), l.layersWithOutsidePointerEventsDisabled.delete(d), _());
|
|
220
|
+
}, [d, l]), s.useEffect(() => {
|
|
221
|
+
const p = () => C({});
|
|
222
|
+
return document.addEventListener(B, p), () => document.removeEventListener(B, p);
|
|
223
|
+
}, []), /* @__PURE__ */ u(
|
|
224
|
+
z.div,
|
|
190
225
|
{
|
|
191
|
-
...
|
|
192
|
-
ref:
|
|
226
|
+
...y,
|
|
227
|
+
ref: D,
|
|
193
228
|
style: {
|
|
194
|
-
pointerEvents:
|
|
229
|
+
pointerEvents: M ? E ? "auto" : "none" : void 0,
|
|
195
230
|
...t.style
|
|
196
231
|
},
|
|
197
|
-
onFocusCapture:
|
|
198
|
-
onBlurCapture:
|
|
199
|
-
onPointerDownCapture:
|
|
232
|
+
onFocusCapture: x(t.onFocusCapture, k.onFocusCapture),
|
|
233
|
+
onBlurCapture: x(t.onBlurCapture, k.onBlurCapture),
|
|
234
|
+
onPointerDownCapture: x(
|
|
200
235
|
t.onPointerDownCapture,
|
|
201
|
-
|
|
236
|
+
Z.onPointerDownCapture
|
|
202
237
|
)
|
|
203
238
|
}
|
|
204
239
|
);
|
|
205
240
|
}
|
|
206
241
|
);
|
|
207
|
-
|
|
208
|
-
var
|
|
209
|
-
const n =
|
|
210
|
-
return
|
|
242
|
+
X.displayName = Le;
|
|
243
|
+
var De = "DismissableLayerBranch", Oe = s.forwardRef((t, e) => {
|
|
244
|
+
const n = s.useContext(K), r = s.useRef(null), o = V(e, r);
|
|
245
|
+
return s.useEffect(() => {
|
|
211
246
|
const i = r.current;
|
|
212
247
|
if (i)
|
|
213
248
|
return n.branches.add(i), () => {
|
|
214
249
|
n.branches.delete(i);
|
|
215
250
|
};
|
|
216
|
-
}, [n.branches]), /* @__PURE__ */
|
|
251
|
+
}, [n.branches]), /* @__PURE__ */ u(z.div, { ...t, ref: o });
|
|
217
252
|
});
|
|
218
|
-
|
|
219
|
-
function
|
|
220
|
-
const n =
|
|
253
|
+
Oe.displayName = De;
|
|
254
|
+
function xe(t, e = globalThis == null ? void 0 : globalThis.document) {
|
|
255
|
+
const n = A(t), r = s.useRef(!1), o = s.useRef(() => {
|
|
221
256
|
});
|
|
222
|
-
return
|
|
223
|
-
const i = (
|
|
224
|
-
if (
|
|
225
|
-
let
|
|
226
|
-
|
|
227
|
-
|
|
257
|
+
return s.useEffect(() => {
|
|
258
|
+
const i = (c) => {
|
|
259
|
+
if (c.target && !r.current) {
|
|
260
|
+
let y = function() {
|
|
261
|
+
Y(
|
|
262
|
+
we,
|
|
228
263
|
n,
|
|
229
|
-
|
|
264
|
+
l,
|
|
230
265
|
{ discrete: !0 }
|
|
231
266
|
);
|
|
232
267
|
};
|
|
233
|
-
const
|
|
234
|
-
|
|
268
|
+
const l = { originalEvent: c };
|
|
269
|
+
c.pointerType === "touch" ? (e.removeEventListener("click", o.current), o.current = y, e.addEventListener("click", o.current, { once: !0 })) : y();
|
|
235
270
|
} else
|
|
236
|
-
e.removeEventListener("click",
|
|
271
|
+
e.removeEventListener("click", o.current);
|
|
237
272
|
r.current = !1;
|
|
238
|
-
},
|
|
273
|
+
}, a = window.setTimeout(() => {
|
|
239
274
|
e.addEventListener("pointerdown", i);
|
|
240
275
|
}, 0);
|
|
241
276
|
return () => {
|
|
242
|
-
window.clearTimeout(
|
|
277
|
+
window.clearTimeout(a), e.removeEventListener("pointerdown", i), e.removeEventListener("click", o.current);
|
|
243
278
|
};
|
|
244
279
|
}, [e, n]), {
|
|
245
280
|
// ensures we check React component tree (not just DOM tree)
|
|
246
281
|
onPointerDownCapture: () => r.current = !0
|
|
247
282
|
};
|
|
248
283
|
}
|
|
249
|
-
function
|
|
250
|
-
const n =
|
|
251
|
-
return
|
|
252
|
-
const
|
|
253
|
-
i.target && !r.current &&
|
|
284
|
+
function Se(t, e = globalThis == null ? void 0 : globalThis.document) {
|
|
285
|
+
const n = A(t), r = s.useRef(!1);
|
|
286
|
+
return s.useEffect(() => {
|
|
287
|
+
const o = (i) => {
|
|
288
|
+
i.target && !r.current && Y(Re, n, { originalEvent: i }, {
|
|
254
289
|
discrete: !1
|
|
255
290
|
});
|
|
256
291
|
};
|
|
257
|
-
return e.addEventListener("focusin",
|
|
292
|
+
return e.addEventListener("focusin", o), () => e.removeEventListener("focusin", o);
|
|
258
293
|
}, [e, n]), {
|
|
259
294
|
onFocusCapture: () => r.current = !0,
|
|
260
295
|
onBlurCapture: () => r.current = !1
|
|
261
296
|
};
|
|
262
297
|
}
|
|
263
|
-
function
|
|
264
|
-
const t = new CustomEvent(
|
|
298
|
+
function _() {
|
|
299
|
+
const t = new CustomEvent(B);
|
|
265
300
|
document.dispatchEvent(t);
|
|
266
301
|
}
|
|
267
|
-
function
|
|
268
|
-
const
|
|
269
|
-
e &&
|
|
302
|
+
function Y(t, e, n, { discrete: r }) {
|
|
303
|
+
const o = n.originalEvent.target, i = new CustomEvent(t, { bubbles: !1, cancelable: !0, detail: n });
|
|
304
|
+
e && o.addEventListener(t, e, { once: !0 }), r ? Ee(o, i) : o.dispatchEvent(i);
|
|
270
305
|
}
|
|
271
|
-
const
|
|
306
|
+
const Te = ({
|
|
272
307
|
id: t,
|
|
273
308
|
layers: e,
|
|
274
309
|
children: n,
|
|
275
310
|
...r
|
|
276
|
-
}) => t === e[e.length - 1] ? /* @__PURE__ */
|
|
311
|
+
}) => t === e[e.length - 1] ? /* @__PURE__ */ u(X, { ...r, children: n }) : /* @__PURE__ */ u(I, { children: n }), H = b.createContext({
|
|
277
312
|
layers: [],
|
|
278
313
|
setLayers: () => {
|
|
279
314
|
},
|
|
@@ -283,135 +318,154 @@ const Le = ({
|
|
|
283
318
|
},
|
|
284
319
|
removeTopLayer: () => {
|
|
285
320
|
}
|
|
286
|
-
}),
|
|
287
|
-
const [e, n] =
|
|
288
|
-
const { layer:
|
|
289
|
-
if (typeof
|
|
290
|
-
return n((
|
|
291
|
-
n((
|
|
292
|
-
},
|
|
293
|
-
n(e.filter((
|
|
321
|
+
}), qe = ({ children: t }) => {
|
|
322
|
+
const [e, n] = b.useState([]), r = (a, c = {}) => {
|
|
323
|
+
const { layer: y } = c;
|
|
324
|
+
if (typeof y == "number")
|
|
325
|
+
return n((l) => l.length - 1 < y ? [...l, a] : [...l.slice(0, y), a, ...l.slice(y)]);
|
|
326
|
+
n((l) => [...l, a]);
|
|
327
|
+
}, o = (a) => {
|
|
328
|
+
n(e.filter((c) => c !== a));
|
|
294
329
|
}, i = () => {
|
|
295
|
-
const
|
|
296
|
-
|
|
330
|
+
const a = e[e.length - 1];
|
|
331
|
+
a && o(a);
|
|
297
332
|
};
|
|
298
|
-
return /* @__PURE__ */
|
|
299
|
-
|
|
333
|
+
return /* @__PURE__ */ u(
|
|
334
|
+
H.Provider,
|
|
300
335
|
{
|
|
301
|
-
value: { layers: e, setLayers: n, addLayer: r, removeLayer:
|
|
336
|
+
value: { layers: e, setLayers: n, addLayer: r, removeLayer: o, removeTopLayer: i },
|
|
302
337
|
children: t
|
|
303
338
|
}
|
|
304
339
|
);
|
|
305
|
-
},
|
|
340
|
+
}, Ne = () => b.useContext(H), Be = ({
|
|
306
341
|
defaultOpen: t,
|
|
307
342
|
open: e,
|
|
308
343
|
onOpenChange: n,
|
|
309
344
|
...r
|
|
310
345
|
}) => {
|
|
311
|
-
const [
|
|
346
|
+
const [o, i] = me({
|
|
312
347
|
prop: e,
|
|
313
348
|
onChange: n,
|
|
314
349
|
defaultProp: t
|
|
315
350
|
});
|
|
316
|
-
if (
|
|
317
|
-
return /* @__PURE__ */
|
|
318
|
-
},
|
|
351
|
+
if (o)
|
|
352
|
+
return /* @__PURE__ */ u(We, { open: o, onOpenChange: i, ...r });
|
|
353
|
+
}, We = ({
|
|
319
354
|
open: t,
|
|
320
355
|
onOpenChange: e,
|
|
321
356
|
a11yTitle: n,
|
|
322
357
|
a11yDescription: r,
|
|
323
|
-
children:
|
|
358
|
+
children: o,
|
|
324
359
|
layer: i,
|
|
360
|
+
// Focus scope props
|
|
361
|
+
trapped: a,
|
|
362
|
+
onMountAutoFocus: c,
|
|
363
|
+
onUnmountAutoFocus: y,
|
|
325
364
|
...l
|
|
326
365
|
}) => {
|
|
327
|
-
var
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
!
|
|
331
|
-
}, [
|
|
332
|
-
const
|
|
333
|
-
return /* @__PURE__ */
|
|
334
|
-
|
|
366
|
+
var L, w;
|
|
367
|
+
const d = n, f = Ne();
|
|
368
|
+
b.useEffect(() => {
|
|
369
|
+
!f || !t || f.layers.includes(d) || f.addLayer(d, { layer: i });
|
|
370
|
+
}, [d, i, f, t]);
|
|
371
|
+
const h = ((L = f.layers) == null ? void 0 : L.indexOf(d)) || 0, C = ((w = f.layers) == null ? void 0 : w.length) || 0, D = h !== 0, P = d === f.layers[f.layers.length - 1];
|
|
372
|
+
return /* @__PURE__ */ u(
|
|
373
|
+
Te,
|
|
335
374
|
{
|
|
336
|
-
id:
|
|
337
|
-
layers:
|
|
338
|
-
onEscapeKeyDown: (
|
|
339
|
-
|
|
375
|
+
id: d,
|
|
376
|
+
layers: f.layers,
|
|
377
|
+
onEscapeKeyDown: (m) => {
|
|
378
|
+
m.preventDefault(), f.removeTopLayer(), e(!1);
|
|
340
379
|
},
|
|
341
|
-
onPointerDownOutside: (
|
|
342
|
-
|
|
380
|
+
onPointerDownOutside: (m) => {
|
|
381
|
+
m.preventDefault(), f.removeTopLayer(), e(!1);
|
|
343
382
|
},
|
|
344
|
-
children: /* @__PURE__ */
|
|
383
|
+
children: /* @__PURE__ */ S(
|
|
345
384
|
v.Root,
|
|
346
385
|
{
|
|
347
386
|
open: t,
|
|
348
|
-
onOpenChange: (
|
|
349
|
-
var
|
|
350
|
-
if (((
|
|
351
|
-
return
|
|
352
|
-
e(
|
|
387
|
+
onOpenChange: (m) => {
|
|
388
|
+
var E;
|
|
389
|
+
if (((E = f == null ? void 0 : f.layers) == null ? void 0 : E.length) > 0)
|
|
390
|
+
return m === !1 && d === f.layers[f.layers.length - 1] ? (f.removeLayer(d), e(!1)) : void 0;
|
|
391
|
+
e(m);
|
|
353
392
|
},
|
|
354
393
|
children: [
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
/* @__PURE__ */
|
|
357
|
-
r && /* @__PURE__ */
|
|
394
|
+
/* @__PURE__ */ S(Q.Root, { children: [
|
|
395
|
+
/* @__PURE__ */ u(v.Title, { children: n }),
|
|
396
|
+
r && /* @__PURE__ */ u(v.Description, { children: r })
|
|
358
397
|
] }),
|
|
359
|
-
/* @__PURE__ */
|
|
360
|
-
|
|
398
|
+
/* @__PURE__ */ u(oe, { children: t && // We add the className "tgph" here so that styles within
|
|
399
|
+
// the portal get scoped properly to telegraph
|
|
400
|
+
/* @__PURE__ */ u(he, { className: "tgph", children: /* @__PURE__ */ u(Ae, { layer: h, children: /* @__PURE__ */ u(
|
|
401
|
+
q,
|
|
361
402
|
{
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
top: m ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${c} )` : "var(--tgph-spacing-16)"
|
|
368
|
-
},
|
|
369
|
-
exit: { top: 0 },
|
|
370
|
-
transition: { type: "spring", duration: 0.3, bounce: 0 },
|
|
371
|
-
w: "full",
|
|
372
|
-
justify: "center",
|
|
373
|
-
style: {
|
|
374
|
-
position: "fixed",
|
|
375
|
-
left: 0,
|
|
376
|
-
maxHeight: "calc(100vh - var(--tgph-spacing-32))",
|
|
377
|
-
maxWidth: "calc(100vw - var(--tgph-spacing-8))",
|
|
378
|
-
zIndex: `calc(var(--tgph-zIndex-modal) + ${c})`
|
|
379
|
-
},
|
|
380
|
-
children: /* @__PURE__ */ d(
|
|
403
|
+
trapped: typeof a == "boolean" ? a : P,
|
|
404
|
+
onMountAutoFocus: c,
|
|
405
|
+
onUnmountAutoFocus: y,
|
|
406
|
+
asChild: !0,
|
|
407
|
+
children: /* @__PURE__ */ u(te, { children: /* @__PURE__ */ u(
|
|
381
408
|
g,
|
|
382
409
|
{
|
|
383
|
-
|
|
384
|
-
|
|
410
|
+
as: T.div,
|
|
411
|
+
initial: {
|
|
412
|
+
top: `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${C - 1})`
|
|
413
|
+
},
|
|
385
414
|
animate: {
|
|
386
|
-
|
|
387
|
-
transformOrigin: "center center"
|
|
415
|
+
top: D ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${h} )` : "var(--tgph-spacing-16)"
|
|
388
416
|
},
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
w:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
417
|
+
exit: { top: 0 },
|
|
418
|
+
transition: { type: "spring", duration: 0.3, bounce: 0 },
|
|
419
|
+
w: "full",
|
|
420
|
+
justify: "center",
|
|
421
|
+
style: {
|
|
422
|
+
position: "fixed",
|
|
423
|
+
left: 0,
|
|
424
|
+
maxHeight: "calc(100vh - var(--tgph-spacing-32))",
|
|
425
|
+
maxWidth: "calc(100vw - var(--tgph-spacing-8))",
|
|
426
|
+
zIndex: `calc(var(--tgph-zIndex-modal) + ${h})`
|
|
427
|
+
},
|
|
428
|
+
children: /* @__PURE__ */ u(
|
|
429
|
+
g,
|
|
430
|
+
{
|
|
431
|
+
direction: "column",
|
|
432
|
+
as: T.div,
|
|
433
|
+
animate: {
|
|
434
|
+
scale: 1.02 - Math.abs(C - h) * 0.02,
|
|
435
|
+
transformOrigin: "center center"
|
|
436
|
+
},
|
|
437
|
+
transition: {
|
|
438
|
+
duration: 0.2,
|
|
439
|
+
bounce: 0,
|
|
440
|
+
type: "spring"
|
|
441
|
+
},
|
|
442
|
+
maxW: l.maxW ?? "160",
|
|
443
|
+
w: l.w ?? "full",
|
|
444
|
+
bg: "surface-1",
|
|
445
|
+
border: "px",
|
|
446
|
+
rounded: "4",
|
|
447
|
+
shadow: "3",
|
|
448
|
+
...l,
|
|
449
|
+
children: o
|
|
450
|
+
},
|
|
451
|
+
`content-${d}`
|
|
452
|
+
)
|
|
398
453
|
},
|
|
399
|
-
`
|
|
400
|
-
)
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
) }) })
|
|
454
|
+
`container-${d}`
|
|
455
|
+
) })
|
|
456
|
+
}
|
|
457
|
+
) }) }) })
|
|
404
458
|
]
|
|
405
459
|
},
|
|
406
|
-
|
|
460
|
+
d
|
|
407
461
|
)
|
|
408
462
|
}
|
|
409
463
|
);
|
|
410
|
-
},
|
|
411
|
-
/* @__PURE__ */
|
|
412
|
-
|
|
464
|
+
}, Ae = ({ layer: t, children: e }) => t > 0 ? e : /* @__PURE__ */ S(v.Overlay, { children: [
|
|
465
|
+
/* @__PURE__ */ u(
|
|
466
|
+
re,
|
|
413
467
|
{
|
|
414
|
-
as:
|
|
468
|
+
as: T.div,
|
|
415
469
|
initial: { opacity: 0 },
|
|
416
470
|
animate: { opacity: 1 },
|
|
417
471
|
exit: { opacity: 0 },
|
|
@@ -428,24 +482,41 @@ const Le = ({
|
|
|
428
482
|
}
|
|
429
483
|
),
|
|
430
484
|
e
|
|
431
|
-
] }),
|
|
432
|
-
({ children: t, ...e }, n) => /* @__PURE__ */
|
|
433
|
-
),
|
|
485
|
+
] }), Me = b.forwardRef(
|
|
486
|
+
({ children: t, ...e }, n) => /* @__PURE__ */ u(v.Content, { ref: n, asChild: !0, ...e, children: /* @__PURE__ */ u(g, { direction: "column", h: "full", ...e, children: t }) })
|
|
487
|
+
), ke = ({
|
|
434
488
|
size: t = "1",
|
|
435
489
|
variant: e = "ghost",
|
|
436
490
|
...n
|
|
437
|
-
}) => /* @__PURE__ */
|
|
438
|
-
|
|
491
|
+
}) => /* @__PURE__ */ u(v.Close, { asChild: !0, children: /* @__PURE__ */ u(
|
|
492
|
+
ee,
|
|
439
493
|
{
|
|
440
|
-
icon: { icon:
|
|
494
|
+
icon: { icon: ne.X, alt: "Close Modal" },
|
|
441
495
|
variant: e,
|
|
442
496
|
size: t,
|
|
443
497
|
...n
|
|
444
498
|
}
|
|
445
|
-
) }),
|
|
499
|
+
) }), Fe = ({
|
|
500
|
+
style: t,
|
|
501
|
+
children: e,
|
|
502
|
+
...n
|
|
503
|
+
}) => /* @__PURE__ */ u(
|
|
504
|
+
g,
|
|
505
|
+
{
|
|
506
|
+
direction: "column",
|
|
507
|
+
px: "6",
|
|
508
|
+
py: "4",
|
|
509
|
+
style: {
|
|
510
|
+
overflowY: "auto",
|
|
511
|
+
...t
|
|
512
|
+
},
|
|
513
|
+
...n,
|
|
514
|
+
children: e
|
|
515
|
+
}
|
|
516
|
+
), $e = ({
|
|
446
517
|
children: t,
|
|
447
518
|
...e
|
|
448
|
-
}) => /* @__PURE__ */
|
|
519
|
+
}) => /* @__PURE__ */ u(
|
|
449
520
|
g,
|
|
450
521
|
{
|
|
451
522
|
direction: "row",
|
|
@@ -457,10 +528,10 @@ const Le = ({
|
|
|
457
528
|
...e,
|
|
458
529
|
children: t
|
|
459
530
|
}
|
|
460
|
-
),
|
|
531
|
+
), _e = ({
|
|
461
532
|
children: t,
|
|
462
533
|
...e
|
|
463
|
-
}) => /* @__PURE__ */
|
|
534
|
+
}) => /* @__PURE__ */ u(
|
|
464
535
|
g,
|
|
465
536
|
{
|
|
466
537
|
direction: "row",
|
|
@@ -473,17 +544,17 @@ const Le = ({
|
|
|
473
544
|
...e,
|
|
474
545
|
children: t
|
|
475
546
|
}
|
|
476
|
-
),
|
|
477
|
-
Object.assign(
|
|
478
|
-
Root:
|
|
479
|
-
Content:
|
|
480
|
-
Close:
|
|
481
|
-
Body:
|
|
482
|
-
Header:
|
|
483
|
-
Footer:
|
|
547
|
+
), Ie = {};
|
|
548
|
+
Object.assign(Ie, {
|
|
549
|
+
Root: Be,
|
|
550
|
+
Content: Me,
|
|
551
|
+
Close: ke,
|
|
552
|
+
Body: Fe,
|
|
553
|
+
Header: $e,
|
|
554
|
+
Footer: _e
|
|
484
555
|
});
|
|
485
556
|
export {
|
|
486
|
-
|
|
487
|
-
|
|
557
|
+
Ie as Modal,
|
|
558
|
+
qe as ModalStackingProvider
|
|
488
559
|
};
|
|
489
560
|
//# sourceMappingURL=index.mjs.map
|