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