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