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