@telegraph/modal 0.0.59 → 0.0.61
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 +17 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +243 -258
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +5 -5
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 (
|
|
17
|
-
return
|
|
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
|
-
function oe(
|
|
21
|
-
typeof
|
|
20
|
+
function oe(t, e) {
|
|
21
|
+
typeof t == "function" ? t(e) : t != null && (t.current = e);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
return (
|
|
23
|
+
function j(...t) {
|
|
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:
|
|
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
|
|
53
|
-
const n = { ...
|
|
54
|
-
for (const
|
|
55
|
-
const
|
|
56
|
-
/^on[A-Z]/.test(
|
|
57
|
-
|
|
58
|
-
} :
|
|
55
|
+
function ce(t, e) {
|
|
56
|
+
const n = { ...e };
|
|
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
|
-
return { ...
|
|
63
|
+
return { ...t, ...n };
|
|
61
64
|
}
|
|
62
|
-
function
|
|
63
|
-
var
|
|
64
|
-
let
|
|
65
|
-
return n ?
|
|
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,196 +84,178 @@ 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
|
-
return n.displayName = `Primitive.${
|
|
92
|
+
return n.displayName = `Primitive.${e}`, { ...t, [e]: n };
|
|
90
93
|
}, {});
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
function pe(e, t) {
|
|
95
|
-
typeof e == "function" ? e(t) : e != null && (e.current = t);
|
|
96
|
-
}
|
|
97
|
-
function ye(...e) {
|
|
98
|
-
return (t) => e.forEach((n) => pe(n, t));
|
|
99
|
-
}
|
|
100
|
-
function $(...e) {
|
|
101
|
-
return o.useCallback(ye(...e), e);
|
|
94
|
+
function de(t, e) {
|
|
95
|
+
t && q.flushSync(() => t.dispatchEvent(e));
|
|
102
96
|
}
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
}),
|
|
108
|
-
var
|
|
109
|
-
return (
|
|
97
|
+
function L(t) {
|
|
98
|
+
const e = i.useRef(t);
|
|
99
|
+
return i.useEffect(() => {
|
|
100
|
+
e.current = t;
|
|
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 n =
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
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);
|
|
117
111
|
};
|
|
118
|
-
return
|
|
119
|
-
}, [n,
|
|
112
|
+
return e.addEventListener("keydown", s, { capture: !0 }), () => e.removeEventListener("keydown", s, { capture: !0 });
|
|
113
|
+
}, [n, e]);
|
|
120
114
|
}
|
|
121
|
-
var
|
|
115
|
+
var pe = "DismissableLayer", N = "dismissableLayer.update", ye = "dismissableLayer.pointerDownOutside", he = "dismissableLayer.focusOutside", I, V = i.createContext({
|
|
122
116
|
layers: /* @__PURE__ */ new Set(),
|
|
123
117
|
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
124
118
|
branches: /* @__PURE__ */ new Set()
|
|
125
|
-
}),
|
|
126
|
-
(
|
|
119
|
+
}), $ = i.forwardRef(
|
|
120
|
+
(t, e) => {
|
|
127
121
|
const {
|
|
128
122
|
disableOutsidePointerEvents: n = !1,
|
|
129
|
-
onEscapeKeyDown:
|
|
130
|
-
onPointerDownOutside:
|
|
131
|
-
onFocusOutside:
|
|
123
|
+
onEscapeKeyDown: s,
|
|
124
|
+
onPointerDownOutside: r,
|
|
125
|
+
onFocusOutside: o,
|
|
132
126
|
onInteractOutside: a,
|
|
133
127
|
onDismiss: c,
|
|
134
128
|
...p
|
|
135
|
-
} =
|
|
136
|
-
const R = f.target, F = [...l.branches].some((
|
|
137
|
-
!k || F || (
|
|
138
|
-
}, h), A =
|
|
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) => {
|
|
139
133
|
const R = f.target;
|
|
140
|
-
[...l.branches].some((
|
|
134
|
+
[...l.branches].some((x) => x.contains(R)) || (o == null || o(f), a == null || a(f), f.defaultPrevented || c == null || c());
|
|
141
135
|
}, h);
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
}, 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(() => {
|
|
145
139
|
if (u)
|
|
146
|
-
return n && (l.layersWithOutsidePointerEventsDisabled.size === 0 && (
|
|
147
|
-
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);
|
|
148
142
|
};
|
|
149
|
-
}, [u, h, n, l]),
|
|
150
|
-
u && (l.layers.delete(u), l.layersWithOutsidePointerEventsDisabled.delete(u),
|
|
151
|
-
}, [u, l]),
|
|
152
|
-
const f = () =>
|
|
153
|
-
return document.addEventListener(
|
|
143
|
+
}, [u, h, n, l]), i.useEffect(() => () => {
|
|
144
|
+
u && (l.layers.delete(u), l.layersWithOutsidePointerEventsDisabled.delete(u), M());
|
|
145
|
+
}, [u, l]), i.useEffect(() => {
|
|
146
|
+
const f = () => D({});
|
|
147
|
+
return document.addEventListener(N, f), () => document.removeEventListener(N, f);
|
|
154
148
|
}, []), /* @__PURE__ */ d(
|
|
155
|
-
|
|
149
|
+
z.div,
|
|
156
150
|
{
|
|
157
151
|
...p,
|
|
158
152
|
ref: b,
|
|
159
153
|
style: {
|
|
160
|
-
pointerEvents:
|
|
161
|
-
...
|
|
154
|
+
pointerEvents: w ? k ? "auto" : "none" : void 0,
|
|
155
|
+
...t.style
|
|
162
156
|
},
|
|
163
|
-
onFocusCapture:
|
|
164
|
-
onBlurCapture:
|
|
165
|
-
onPointerDownCapture:
|
|
166
|
-
|
|
157
|
+
onFocusCapture: S(t.onFocusCapture, A.onFocusCapture),
|
|
158
|
+
onBlurCapture: S(t.onBlurCapture, A.onBlurCapture),
|
|
159
|
+
onPointerDownCapture: S(
|
|
160
|
+
t.onPointerDownCapture,
|
|
167
161
|
H.onPointerDownCapture
|
|
168
162
|
)
|
|
169
163
|
}
|
|
170
164
|
);
|
|
171
165
|
}
|
|
172
166
|
);
|
|
173
|
-
|
|
174
|
-
var
|
|
175
|
-
const n =
|
|
176
|
-
return
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
return n.branches.add(
|
|
180
|
-
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);
|
|
181
175
|
};
|
|
182
|
-
}, [n.branches]), /* @__PURE__ */ d(
|
|
176
|
+
}, [n.branches]), /* @__PURE__ */ d(z.div, { ...t, ref: r });
|
|
183
177
|
});
|
|
184
|
-
|
|
185
|
-
function
|
|
186
|
-
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(() => {
|
|
187
181
|
});
|
|
188
|
-
return
|
|
189
|
-
const
|
|
190
|
-
if (c.target && !
|
|
182
|
+
return i.useEffect(() => {
|
|
183
|
+
const o = (c) => {
|
|
184
|
+
if (c.target && !s.current) {
|
|
191
185
|
let p = function() {
|
|
192
|
-
|
|
193
|
-
|
|
186
|
+
K(
|
|
187
|
+
ye,
|
|
194
188
|
n,
|
|
195
189
|
l,
|
|
196
190
|
{ discrete: !0 }
|
|
197
191
|
);
|
|
198
192
|
};
|
|
199
193
|
const l = { originalEvent: c };
|
|
200
|
-
c.pointerType === "touch" ? (
|
|
194
|
+
c.pointerType === "touch" ? (e.removeEventListener("click", r.current), r.current = p, e.addEventListener("click", r.current, { once: !0 })) : p();
|
|
201
195
|
} else
|
|
202
|
-
|
|
203
|
-
|
|
196
|
+
e.removeEventListener("click", r.current);
|
|
197
|
+
s.current = !1;
|
|
204
198
|
}, a = window.setTimeout(() => {
|
|
205
|
-
|
|
199
|
+
e.addEventListener("pointerdown", o);
|
|
206
200
|
}, 0);
|
|
207
201
|
return () => {
|
|
208
|
-
window.clearTimeout(a),
|
|
202
|
+
window.clearTimeout(a), e.removeEventListener("pointerdown", o), e.removeEventListener("click", r.current);
|
|
209
203
|
};
|
|
210
|
-
}, [
|
|
204
|
+
}, [e, n]), {
|
|
211
205
|
// ensures we check React component tree (not just DOM tree)
|
|
212
|
-
onPointerDownCapture: () =>
|
|
206
|
+
onPointerDownCapture: () => s.current = !0
|
|
213
207
|
};
|
|
214
208
|
}
|
|
215
|
-
function
|
|
216
|
-
const n =
|
|
217
|
-
return
|
|
218
|
-
const
|
|
219
|
-
|
|
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 }, {
|
|
220
214
|
discrete: !1
|
|
221
215
|
});
|
|
222
216
|
};
|
|
223
|
-
return
|
|
224
|
-
}, [
|
|
225
|
-
onFocusCapture: () =>
|
|
226
|
-
onBlurCapture: () =>
|
|
217
|
+
return e.addEventListener("focusin", r), () => e.removeEventListener("focusin", r);
|
|
218
|
+
}, [e, n]), {
|
|
219
|
+
onFocusCapture: () => s.current = !0,
|
|
220
|
+
onBlurCapture: () => s.current = !1
|
|
227
221
|
};
|
|
228
222
|
}
|
|
229
|
-
function
|
|
230
|
-
const
|
|
231
|
-
document.dispatchEvent(
|
|
223
|
+
function M() {
|
|
224
|
+
const t = new CustomEvent(N);
|
|
225
|
+
document.dispatchEvent(t);
|
|
232
226
|
}
|
|
233
|
-
function
|
|
234
|
-
const
|
|
235
|
-
|
|
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);
|
|
236
230
|
}
|
|
237
|
-
function
|
|
238
|
-
|
|
239
|
-
|
|
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,
|
|
231
|
+
function be({
|
|
232
|
+
prop: t,
|
|
233
|
+
defaultProp: e,
|
|
249
234
|
onChange: n = () => {
|
|
250
235
|
}
|
|
251
236
|
}) {
|
|
252
|
-
const [
|
|
237
|
+
const [s, r] = Ce({ defaultProp: e, onChange: n }), o = t !== void 0, a = o ? t : s, c = L(n), p = i.useCallback(
|
|
253
238
|
(l) => {
|
|
254
|
-
if (
|
|
255
|
-
const y = typeof l == "function" ? l(
|
|
256
|
-
y !==
|
|
239
|
+
if (o) {
|
|
240
|
+
const y = typeof l == "function" ? l(t) : l;
|
|
241
|
+
y !== t && c(y);
|
|
257
242
|
} else
|
|
258
|
-
|
|
243
|
+
r(l);
|
|
259
244
|
},
|
|
260
|
-
[
|
|
245
|
+
[o, t, r, c]
|
|
261
246
|
);
|
|
262
247
|
return [a, p];
|
|
263
248
|
}
|
|
264
|
-
function
|
|
265
|
-
defaultProp:
|
|
266
|
-
onChange:
|
|
249
|
+
function Ce({
|
|
250
|
+
defaultProp: t,
|
|
251
|
+
onChange: e
|
|
267
252
|
}) {
|
|
268
|
-
const n =
|
|
269
|
-
return
|
|
270
|
-
|
|
271
|
-
}, [
|
|
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;
|
|
272
257
|
}
|
|
273
|
-
const X =
|
|
258
|
+
const X = E.createContext({
|
|
274
259
|
layers: [],
|
|
275
260
|
setLayers: () => {
|
|
276
261
|
},
|
|
@@ -280,97 +265,97 @@ const X = g.createContext({
|
|
|
280
265
|
},
|
|
281
266
|
removeTopLayer: () => {
|
|
282
267
|
}
|
|
283
|
-
}),
|
|
284
|
-
const [
|
|
268
|
+
}), je = ({ children: t }) => {
|
|
269
|
+
const [e, n] = E.useState([]), s = (a) => {
|
|
285
270
|
n((c) => [...c, a]);
|
|
286
|
-
},
|
|
287
|
-
n(
|
|
288
|
-
},
|
|
289
|
-
const a =
|
|
290
|
-
a &&
|
|
271
|
+
}, r = (a) => {
|
|
272
|
+
n(e.filter((c) => c !== a));
|
|
273
|
+
}, o = () => {
|
|
274
|
+
const a = e[e.length - 1];
|
|
275
|
+
a && r(a);
|
|
291
276
|
};
|
|
292
277
|
return /* @__PURE__ */ d(
|
|
293
278
|
X.Provider,
|
|
294
279
|
{
|
|
295
|
-
value: { layers:
|
|
296
|
-
children:
|
|
280
|
+
value: { layers: e, setLayers: n, addLayer: s, removeLayer: r, removeTopLayer: o },
|
|
281
|
+
children: t
|
|
297
282
|
}
|
|
298
283
|
);
|
|
299
|
-
}, Y = () =>
|
|
300
|
-
defaultOpen:
|
|
301
|
-
open:
|
|
284
|
+
}, Y = () => E.useContext(X), Le = ({
|
|
285
|
+
defaultOpen: t,
|
|
286
|
+
open: e,
|
|
302
287
|
onOpenChange: n,
|
|
303
|
-
...
|
|
288
|
+
...s
|
|
304
289
|
}) => {
|
|
305
|
-
const [
|
|
306
|
-
prop:
|
|
290
|
+
const [r, o] = be({
|
|
291
|
+
prop: e,
|
|
307
292
|
onChange: n,
|
|
308
|
-
defaultProp:
|
|
309
|
-
}), a = Y(), c =
|
|
310
|
-
if (
|
|
311
|
-
!
|
|
312
|
-
}, [c, a,
|
|
313
|
-
return /* @__PURE__ */ d(
|
|
314
|
-
},
|
|
315
|
-
open:
|
|
316
|
-
onOpenChange:
|
|
293
|
+
defaultProp: t
|
|
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 = ({
|
|
300
|
+
open: t,
|
|
301
|
+
onOpenChange: e,
|
|
317
302
|
a11yTitle: n,
|
|
318
|
-
a11yDescription:
|
|
319
|
-
children:
|
|
303
|
+
a11yDescription: s,
|
|
304
|
+
children: r,
|
|
320
305
|
// Focus scope props
|
|
321
|
-
trapped:
|
|
306
|
+
trapped: o,
|
|
322
307
|
onMountAutoFocus: a,
|
|
323
308
|
onUnmountAutoFocus: c,
|
|
324
309
|
...p
|
|
325
310
|
}) => {
|
|
326
|
-
var C,
|
|
311
|
+
var C, P;
|
|
327
312
|
const l = n, u = Y();
|
|
328
|
-
|
|
329
|
-
!u || !
|
|
330
|
-
}, [l, u,
|
|
331
|
-
const y = ((C = u.layers) == null ? void 0 : C.indexOf(l)) || 0, h = ((
|
|
313
|
+
E.useEffect(() => {
|
|
314
|
+
!u || !t || u.layers.includes(l) || u.addLayer(l);
|
|
315
|
+
}, [l, u, t]);
|
|
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];
|
|
332
317
|
return /* @__PURE__ */ d(
|
|
333
|
-
|
|
318
|
+
$,
|
|
334
319
|
{
|
|
335
320
|
onEscapeKeyDown: (m) => {
|
|
336
|
-
b && (m.preventDefault(), u.removeTopLayer(),
|
|
321
|
+
b && (m.preventDefault(), u.removeTopLayer(), e(!1));
|
|
337
322
|
},
|
|
338
323
|
onPointerDownOutside: (m) => {
|
|
339
|
-
b && (m.preventDefault(), u.removeTopLayer(),
|
|
324
|
+
b && (m.preventDefault(), u.removeTopLayer(), e(!1));
|
|
340
325
|
},
|
|
341
|
-
children: /* @__PURE__ */
|
|
326
|
+
children: /* @__PURE__ */ T(
|
|
342
327
|
v.Root,
|
|
343
328
|
{
|
|
344
|
-
open:
|
|
329
|
+
open: t,
|
|
345
330
|
onOpenChange: (m) => {
|
|
346
|
-
var
|
|
347
|
-
if (((
|
|
348
|
-
return m === !1 && l === u.layers[u.layers.length - 1] ? (u.removeLayer(l),
|
|
349
|
-
|
|
331
|
+
var w;
|
|
332
|
+
if (((w = u == null ? void 0 : u.layers) == null ? void 0 : w.length) > 0)
|
|
333
|
+
return m === !1 && l === u.layers[u.layers.length - 1] ? (u.removeLayer(l), e(!1)) : void 0;
|
|
334
|
+
e(m);
|
|
350
335
|
},
|
|
351
336
|
children: [
|
|
352
|
-
/* @__PURE__ */
|
|
337
|
+
/* @__PURE__ */ T(Q.Root, { children: [
|
|
353
338
|
/* @__PURE__ */ d(v.Title, { children: n }),
|
|
354
|
-
|
|
339
|
+
s && /* @__PURE__ */ d(v.Description, { children: s })
|
|
355
340
|
] }),
|
|
356
|
-
/* @__PURE__ */ d(se, { children:
|
|
341
|
+
/* @__PURE__ */ d(se, { children: t && // We add the className "tgph" here so that styles within
|
|
357
342
|
// the portal get scoped properly to telegraph
|
|
358
|
-
/* @__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(
|
|
359
344
|
G,
|
|
360
345
|
{
|
|
361
|
-
trapped: typeof
|
|
346
|
+
trapped: typeof o == "boolean" ? o : b,
|
|
362
347
|
onMountAutoFocus: a,
|
|
363
348
|
onUnmountAutoFocus: c,
|
|
364
349
|
asChild: !0,
|
|
365
350
|
children: /* @__PURE__ */ d(te, { children: /* @__PURE__ */ d(
|
|
366
|
-
|
|
351
|
+
g,
|
|
367
352
|
{
|
|
368
|
-
as:
|
|
353
|
+
as: B.div,
|
|
369
354
|
initial: {
|
|
370
355
|
top: `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${h - 1})`
|
|
371
356
|
},
|
|
372
357
|
animate: {
|
|
373
|
-
top:
|
|
358
|
+
top: D ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${y} )` : "var(--tgph-spacing-16)"
|
|
374
359
|
},
|
|
375
360
|
exit: { top: 0 },
|
|
376
361
|
transition: { type: "spring", duration: 0.3, bounce: 0 },
|
|
@@ -384,10 +369,10 @@ const X = g.createContext({
|
|
|
384
369
|
zIndex: `calc(var(--tgph-zIndex-modal) + ${y})`
|
|
385
370
|
},
|
|
386
371
|
children: /* @__PURE__ */ d(
|
|
387
|
-
|
|
372
|
+
g,
|
|
388
373
|
{
|
|
389
374
|
direction: "column",
|
|
390
|
-
as:
|
|
375
|
+
as: B.div,
|
|
391
376
|
animate: {
|
|
392
377
|
scale: 1.02 - Math.abs(h - y) * 0.02,
|
|
393
378
|
transformOrigin: "center center"
|
|
@@ -404,7 +389,7 @@ const X = g.createContext({
|
|
|
404
389
|
rounded: "4",
|
|
405
390
|
shadow: "3",
|
|
406
391
|
...p,
|
|
407
|
-
children:
|
|
392
|
+
children: r
|
|
408
393
|
},
|
|
409
394
|
`content-${l}`
|
|
410
395
|
)
|
|
@@ -419,11 +404,11 @@ const X = g.createContext({
|
|
|
419
404
|
)
|
|
420
405
|
}
|
|
421
406
|
);
|
|
422
|
-
},
|
|
407
|
+
}, we = ({ layer: t, children: e }) => t > 0 ? e : /* @__PURE__ */ T(v.Overlay, { children: [
|
|
423
408
|
/* @__PURE__ */ d(
|
|
424
409
|
re,
|
|
425
410
|
{
|
|
426
|
-
as:
|
|
411
|
+
as: B.div,
|
|
427
412
|
initial: { opacity: 0 },
|
|
428
413
|
animate: { opacity: 1 },
|
|
429
414
|
exit: { opacity: 0 },
|
|
@@ -439,43 +424,43 @@ const X = g.createContext({
|
|
|
439
424
|
}
|
|
440
425
|
}
|
|
441
426
|
),
|
|
442
|
-
|
|
443
|
-
] }),
|
|
444
|
-
({ children:
|
|
445
|
-
),
|
|
446
|
-
size:
|
|
447
|
-
variant:
|
|
427
|
+
e
|
|
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 = ({
|
|
431
|
+
size: t = "1",
|
|
432
|
+
variant: e = "ghost",
|
|
448
433
|
...n
|
|
449
434
|
}) => /* @__PURE__ */ d(v.Close, { asChild: !0, children: /* @__PURE__ */ d(
|
|
450
435
|
ee,
|
|
451
436
|
{
|
|
452
437
|
icon: { icon: ne.X, alt: "Close Modal" },
|
|
453
|
-
variant:
|
|
454
|
-
size:
|
|
438
|
+
variant: e,
|
|
439
|
+
size: t,
|
|
455
440
|
...n
|
|
456
441
|
}
|
|
457
|
-
) }),
|
|
458
|
-
style:
|
|
459
|
-
children:
|
|
442
|
+
) }), Oe = ({
|
|
443
|
+
style: t,
|
|
444
|
+
children: e,
|
|
460
445
|
...n
|
|
461
446
|
}) => /* @__PURE__ */ d(
|
|
462
|
-
|
|
447
|
+
g,
|
|
463
448
|
{
|
|
464
449
|
direction: "column",
|
|
465
450
|
px: "6",
|
|
466
451
|
py: "4",
|
|
467
452
|
style: {
|
|
468
453
|
overflowY: "auto",
|
|
469
|
-
...
|
|
454
|
+
...t
|
|
470
455
|
},
|
|
471
456
|
...n,
|
|
472
|
-
children:
|
|
457
|
+
children: e
|
|
473
458
|
}
|
|
474
|
-
),
|
|
475
|
-
children:
|
|
476
|
-
...
|
|
459
|
+
), xe = ({
|
|
460
|
+
children: t,
|
|
461
|
+
...e
|
|
477
462
|
}) => /* @__PURE__ */ d(
|
|
478
|
-
|
|
463
|
+
g,
|
|
479
464
|
{
|
|
480
465
|
direction: "row",
|
|
481
466
|
justify: "space-between",
|
|
@@ -483,14 +468,14 @@ const X = g.createContext({
|
|
|
483
468
|
px: "6",
|
|
484
469
|
py: "4",
|
|
485
470
|
borderBottom: "px",
|
|
486
|
-
...
|
|
487
|
-
children:
|
|
471
|
+
...e,
|
|
472
|
+
children: t
|
|
488
473
|
}
|
|
489
|
-
),
|
|
490
|
-
children:
|
|
491
|
-
...
|
|
474
|
+
), Se = ({
|
|
475
|
+
children: t,
|
|
476
|
+
...e
|
|
492
477
|
}) => /* @__PURE__ */ d(
|
|
493
|
-
|
|
478
|
+
g,
|
|
494
479
|
{
|
|
495
480
|
direction: "row",
|
|
496
481
|
align: "center",
|
|
@@ -499,20 +484,20 @@ const X = g.createContext({
|
|
|
499
484
|
px: "6",
|
|
500
485
|
py: "4",
|
|
501
486
|
borderTop: "px",
|
|
502
|
-
...
|
|
503
|
-
children:
|
|
487
|
+
...e,
|
|
488
|
+
children: t
|
|
504
489
|
}
|
|
505
|
-
),
|
|
506
|
-
Object.assign(
|
|
507
|
-
Root:
|
|
508
|
-
Content:
|
|
509
|
-
Close:
|
|
510
|
-
Body:
|
|
511
|
-
Header:
|
|
512
|
-
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
|
|
513
498
|
});
|
|
514
499
|
export {
|
|
515
|
-
|
|
516
|
-
|
|
500
|
+
Te as Modal,
|
|
501
|
+
je as ModalStackingProvider
|
|
517
502
|
};
|
|
518
503
|
//# sourceMappingURL=index.mjs.map
|