@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.
@@ -1,7 +1,7 @@
1
- import { jsx as d, Fragment as Z, jsxs as S } from "react/jsx-runtime";
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 o from "react";
4
- import g from "react";
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 E, Box as re } from "@telegraph/layout";
13
- import { AnimatePresence as se, motion as T } from "framer-motion";
14
- function x(t, e, { checkForDefaultPrevented: n = !0 } = {}) {
15
- return function(s) {
16
- if (t == null || t(s), n === !1 || !s.defaultPrevented)
17
- return e == null ? void 0 : e(s);
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 ie(...t) {
23
+ function j(...t) {
24
24
  return (e) => t.forEach((n) => oe(n, e));
25
25
  }
26
- var I = o.forwardRef((t, e) => {
27
- const { children: n, ...r } = t, s = o.Children.toArray(n), i = s.find(ce);
28
- if (i) {
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: e, children: o.isValidElement(a) ? o.cloneElement(a, void 0, c) : null });
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(B, { ...r, ref: e, children: n });
35
+ return /* @__PURE__ */ d(W, { ...s, ref: e, children: n });
33
36
  });
34
- I.displayName = "Slot";
35
- var B = o.forwardRef((t, e) => {
36
- const { children: n, ...r } = t;
37
- if (o.isValidElement(n)) {
38
- const s = ue(n);
39
- return o.cloneElement(n, {
40
- ...le(r, n.props),
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 ? ie(e, s) : s
45
+ ref: e ? j(e, r) : r
43
46
  });
44
47
  }
45
- return o.Children.count(n) > 1 ? o.Children.only(null) : null;
48
+ return i.Children.count(n) > 1 ? i.Children.only(null) : null;
46
49
  });
47
- B.displayName = "SlotClone";
48
- var ae = ({ children: t }) => /* @__PURE__ */ d(Z, { children: t });
49
- function ce(t) {
50
- return o.isValidElement(t) && t.type === ae;
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 le(t, e) {
55
+ function ce(t, e) {
53
56
  const n = { ...e };
54
- for (const r in e) {
55
- const s = t[r], i = e[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(" "));
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 ue(t) {
63
- var r, s;
64
- let e = (r = Object.getOwnPropertyDescriptor(t.props, "ref")) == null ? void 0 : r.get, n = e && "isReactWarning" in e && e.isReactWarning;
65
- return n ? t.ref : (e = (s = Object.getOwnPropertyDescriptor(t, "ref")) == null ? void 0 : s.get, n = e && "isReactWarning" in e && e.isReactWarning, n ? t.props.ref : t.props.ref || t.ref);
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 de = [
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
- ], $ = de.reduce((t, e) => {
85
- const n = o.forwardRef((r, s) => {
86
- const { asChild: i, ...a } = r, c = i ? I : e;
87
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ d(c, { ...a, ref: s });
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 fe(t, e) {
94
+ function de(t, e) {
92
95
  t && q.flushSync(() => t.dispatchEvent(e));
93
96
  }
94
- function pe(t, e) {
95
- typeof t == "function" ? t(e) : t != null && (t.current = e);
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
- }), o.useMemo(() => (...n) => {
108
- var r;
109
- return (r = e.current) == null ? void 0 : r.call(e, ...n);
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 he(t) {
113
- const e = o.useRef(t);
114
- return o.useEffect(() => {
115
- e.current = t;
116
- }), o.useMemo(() => (...n) => {
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", r, { capture: !0 }), () => e.removeEventListener("keydown", r, { capture: !0 });
112
+ return e.addEventListener("keydown", s, { capture: !0 }), () => e.removeEventListener("keydown", s, { capture: !0 });
128
113
  }, [n, e]);
129
114
  }
130
- var ve = "DismissableLayer", W = "dismissableLayer.update", Ee = "dismissableLayer.pointerDownOutside", ge = "dismissableLayer.focusOutside", F, U = o.createContext({
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
- }), z = o.forwardRef(
119
+ }), $ = i.forwardRef(
135
120
  (t, e) => {
136
121
  const {
137
122
  disableOutsidePointerEvents: n = !1,
138
- onEscapeKeyDown: r,
139
- onPointerDownOutside: s,
140
- onFocusOutside: i,
123
+ onEscapeKeyDown: s,
124
+ onPointerDownOutside: r,
125
+ onFocusOutside: o,
141
126
  onInteractOutside: a,
142
127
  onDismiss: c,
143
128
  ...p
144
- } = t, 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 = j(e, (f) => y(f)), C = Array.from(l.layers), [L] = [...l.layersWithOutsidePointerEventsDisabled].slice(-1), m = C.indexOf(L), D = u ? C.indexOf(u) : -1, P = l.layersWithOutsidePointerEventsDisabled.size > 0, N = D >= m, H = Le((f) => {
145
- const R = f.target, A = [...l.branches].some((O) => O.contains(R));
146
- !N || A || (s == null || s(f), a == null || a(f), f.defaultPrevented || c == null || c());
147
- }, h), k = Pe((f) => {
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((O) => O.contains(R)) || (i == null || i(f), a == null || a(f), f.defaultPrevented || c == null || c());
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 me((f) => {
152
- D === l.layers.size - 1 && (r == null || r(f), !f.defaultPrevented && c && (f.preventDefault(), c()));
153
- }, h), o.useEffect(() => {
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 && (F = h.body.style.pointerEvents, h.body.style.pointerEvents = "none"), l.layersWithOutsidePointerEventsDisabled.add(u)), l.layers.add(u), M(), () => {
156
- n && l.layersWithOutsidePointerEventsDisabled.size === 1 && (h.body.style.pointerEvents = F);
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]), o.useEffect(() => () => {
143
+ }, [u, h, n, l]), i.useEffect(() => () => {
159
144
  u && (l.layers.delete(u), l.layersWithOutsidePointerEventsDisabled.delete(u), M());
160
- }, [u, l]), o.useEffect(() => {
161
- const f = () => w({});
162
- return document.addEventListener(W, f), () => document.removeEventListener(W, f);
145
+ }, [u, l]), i.useEffect(() => {
146
+ const f = () => D({});
147
+ return document.addEventListener(N, f), () => document.removeEventListener(N, f);
163
148
  }, []), /* @__PURE__ */ d(
164
- $.div,
149
+ z.div,
165
150
  {
166
151
  ...p,
167
152
  ref: b,
168
153
  style: {
169
- pointerEvents: P ? N ? "auto" : "none" : void 0,
154
+ pointerEvents: w ? k ? "auto" : "none" : void 0,
170
155
  ...t.style
171
156
  },
172
- onFocusCapture: x(t.onFocusCapture, k.onFocusCapture),
173
- onBlurCapture: x(t.onBlurCapture, k.onBlurCapture),
174
- onPointerDownCapture: x(
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
- z.displayName = ve;
183
- var be = "DismissableLayerBranch", Ce = o.forwardRef((t, e) => {
184
- const n = o.useContext(U), r = o.useRef(null), s = j(e, r);
185
- return o.useEffect(() => {
186
- const i = r.current;
187
- if (i)
188
- return n.branches.add(i), () => {
189
- n.branches.delete(i);
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($.div, { ...t, ref: s });
176
+ }, [n.branches]), /* @__PURE__ */ d(z.div, { ...t, ref: r });
192
177
  });
193
- Ce.displayName = be;
194
- function Le(t, e = globalThis == null ? void 0 : globalThis.document) {
195
- const n = _(t), r = o.useRef(!1), s = o.useRef(() => {
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 o.useEffect(() => {
198
- const i = (c) => {
199
- if (c.target && !r.current) {
182
+ return i.useEffect(() => {
183
+ const o = (c) => {
184
+ if (c.target && !s.current) {
200
185
  let p = function() {
201
- V(
202
- Ee,
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", s.current), s.current = p, e.addEventListener("click", s.current, { once: !0 })) : p();
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", s.current);
212
- r.current = !1;
196
+ e.removeEventListener("click", r.current);
197
+ s.current = !1;
213
198
  }, a = window.setTimeout(() => {
214
- e.addEventListener("pointerdown", i);
199
+ e.addEventListener("pointerdown", o);
215
200
  }, 0);
216
201
  return () => {
217
- window.clearTimeout(a), e.removeEventListener("pointerdown", i), e.removeEventListener("click", s.current);
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: () => r.current = !0
206
+ onPointerDownCapture: () => s.current = !0
222
207
  };
223
208
  }
224
- function Pe(t, e = globalThis == null ? void 0 : globalThis.document) {
225
- const n = _(t), r = o.useRef(!1);
226
- return o.useEffect(() => {
227
- const s = (i) => {
228
- i.target && !r.current && V(ge, n, { originalEvent: i }, {
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", s), () => e.removeEventListener("focusin", s);
217
+ return e.addEventListener("focusin", r), () => e.removeEventListener("focusin", r);
233
218
  }, [e, n]), {
234
- onFocusCapture: () => r.current = !0,
235
- onBlurCapture: () => r.current = !1
219
+ onFocusCapture: () => s.current = !0,
220
+ onBlurCapture: () => s.current = !1
236
221
  };
237
222
  }
238
223
  function M() {
239
- const t = new CustomEvent(W);
224
+ const t = new CustomEvent(N);
240
225
  document.dispatchEvent(t);
241
226
  }
242
- function V(t, e, n, { discrete: r }) {
243
- const s = n.originalEvent.target, i = new CustomEvent(t, { bubbles: !1, cancelable: !0, detail: n });
244
- e && s.addEventListener(t, e, { once: !0 }), r ? fe(s, i) : s.dispatchEvent(i);
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 Re({
231
+ function be({
256
232
  prop: t,
257
233
  defaultProp: e,
258
234
  onChange: n = () => {
259
235
  }
260
236
  }) {
261
- const [r, s] = we({ defaultProp: e, onChange: n }), i = t !== void 0, a = i ? t : r, c = K(n), p = o.useCallback(
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 (i) {
239
+ if (o) {
264
240
  const y = typeof l == "function" ? l(t) : l;
265
241
  y !== t && c(y);
266
242
  } else
267
- s(l);
243
+ r(l);
268
244
  },
269
- [i, t, s, c]
245
+ [o, t, r, c]
270
246
  );
271
247
  return [a, p];
272
248
  }
273
- function we({
249
+ function Ce({
274
250
  defaultProp: t,
275
251
  onChange: e
276
252
  }) {
277
- const n = o.useState(t), [r] = n, s = o.useRef(r), i = K(e);
278
- return o.useEffect(() => {
279
- s.current !== r && (i(r), s.current = r);
280
- }, [r, s, i]), n;
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 = g.createContext({
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
- }), ze = ({ children: t }) => {
293
- const [e, n] = g.useState([]), r = (a) => {
268
+ }), je = ({ children: t }) => {
269
+ const [e, n] = E.useState([]), s = (a) => {
294
270
  n((c) => [...c, a]);
295
- }, s = (a) => {
271
+ }, r = (a) => {
296
272
  n(e.filter((c) => c !== a));
297
- }, i = () => {
273
+ }, o = () => {
298
274
  const a = e[e.length - 1];
299
- a && s(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: r, removeLayer: s, removeTopLayer: i },
280
+ value: { layers: e, setLayers: n, addLayer: s, removeLayer: r, removeTopLayer: o },
305
281
  children: t
306
282
  }
307
283
  );
308
- }, Y = () => g.useContext(X), De = ({
284
+ }, Y = () => E.useContext(X), Le = ({
309
285
  defaultOpen: t,
310
286
  open: e,
311
287
  onOpenChange: n,
312
- ...r
288
+ ...s
313
289
  }) => {
314
- const [s, i] = Re({
290
+ const [r, o] = be({
315
291
  prop: e,
316
292
  onChange: n,
317
293
  defaultProp: t
318
- }), a = Y(), c = r.a11yTitle;
319
- if (g.useEffect(() => {
320
- !s && a.layers.includes(c) && a.removeLayer(c);
321
- }, [c, a, s]), !!s)
322
- return /* @__PURE__ */ d(Oe, { open: s, onOpenChange: i, ...r });
323
- }, Oe = ({
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: r,
328
- children: s,
303
+ a11yDescription: s,
304
+ children: r,
329
305
  // Focus scope props
330
- trapped: i,
306
+ trapped: o,
331
307
  onMountAutoFocus: a,
332
308
  onUnmountAutoFocus: c,
333
309
  ...p
334
310
  }) => {
335
- var C, L;
311
+ var C, P;
336
312
  const l = n, u = Y();
337
- g.useEffect(() => {
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 = ((L = u.layers) == null ? void 0 : L.length) || 0, w = y !== 0, b = l === u.layers[u.layers.length - 1];
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
- z,
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__ */ S(
326
+ children: /* @__PURE__ */ T(
351
327
  v.Root,
352
328
  {
353
329
  open: t,
354
330
  onOpenChange: (m) => {
355
- var P;
356
- if (((P = u == null ? void 0 : u.layers) == null ? void 0 : P.length) > 0)
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__ */ S(Q.Root, { children: [
337
+ /* @__PURE__ */ T(Q.Root, { children: [
362
338
  /* @__PURE__ */ d(v.Title, { children: n }),
363
- r && /* @__PURE__ */ d(v.Description, { children: r })
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(xe, { layer: y, 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 i == "boolean" ? i : b,
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
- E,
351
+ g,
376
352
  {
377
- as: T.div,
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: w ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${y} )` : "var(--tgph-spacing-16)"
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
- E,
372
+ g,
397
373
  {
398
374
  direction: "column",
399
- as: T.div,
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: s
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
- }, xe = ({ layer: t, children: e }) => t > 0 ? e : /* @__PURE__ */ S(v.Overlay, { children: [
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: T.div,
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
- ] }), Se = g.forwardRef(
453
- ({ children: t, ...e }, n) => /* @__PURE__ */ d(v.Content, { ref: n, asChild: !0, ...e, children: /* @__PURE__ */ d(E, { direction: "column", h: "full", ...e, children: t }) })
454
- ), Te = ({
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
- ) }), Be = ({
442
+ ) }), Oe = ({
467
443
  style: t,
468
444
  children: e,
469
445
  ...n
470
446
  }) => /* @__PURE__ */ d(
471
- E,
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
- ), We = ({
459
+ ), xe = ({
484
460
  children: t,
485
461
  ...e
486
462
  }) => /* @__PURE__ */ d(
487
- E,
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
- ), Ne = ({
474
+ ), Se = ({
499
475
  children: t,
500
476
  ...e
501
477
  }) => /* @__PURE__ */ d(
502
- E,
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
- ), ke = {};
515
- Object.assign(ke, {
516
- Root: De,
517
- Content: Se,
518
- Close: Te,
519
- Body: Be,
520
- Header: We,
521
- Footer: Ne
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
- ke as Modal,
525
- ze as ModalStackingProvider
500
+ Te as Modal,
501
+ je as ModalStackingProvider
526
502
  };
527
503
  //# sourceMappingURL=index.mjs.map