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