@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.
@@ -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(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
15
- return function(s) {
16
- if (e == null || e(s), n === !1 || !s.defaultPrevented)
17
- return t == null ? void 0 : t(s);
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(e, t) {
21
- typeof e == "function" ? e(t) : e != null && (e.current = t);
20
+ function oe(t, e) {
21
+ typeof t == "function" ? t(e) : t != null && (t.current = e);
22
22
  }
23
- function ie(...e) {
24
- return (t) => e.forEach((n) => oe(n, t));
23
+ function j(...t) {
24
+ return (e) => t.forEach((n) => oe(n, e));
25
25
  }
26
- var j = o.forwardRef((e, t) => {
27
- const { children: n, ...r } = e, 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: t, 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: t, children: n });
35
+ return /* @__PURE__ */ d(W, { ...s, ref: e, children: n });
33
36
  });
34
- j.displayName = "Slot";
35
- var B = o.forwardRef((e, t) => {
36
- const { children: n, ...r } = e;
37
- if (o.isValidElement(n)) {
38
- const s = ue(n);
39
- return o.cloneElement(n, {
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: t ? ie(t, 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: e }) => /* @__PURE__ */ d(Z, { children: e });
49
- function ce(e) {
50
- return o.isValidElement(e) && e.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(e, t) {
53
- const n = { ...t };
54
- for (const r in t) {
55
- const s = e[r], i = t[r];
56
- /^on[A-Z]/.test(r) ? s && i ? n[r] = (...c) => {
57
- i(...c), s(...c);
58
- } : s && (n[r] = s) : r === "style" ? n[r] = { ...s, ...i } : r === "className" && (n[r] = [s, i].filter(Boolean).join(" "));
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 { ...e, ...n };
63
+ return { ...t, ...n };
61
64
  }
62
- function ue(e) {
63
- var r, s;
64
- let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
65
- return n ? e.ref : (t = (s = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : s.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
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,196 +84,178 @@ var de = [
81
84
  "span",
82
85
  "svg",
83
86
  "ul"
84
- ], _ = de.reduce((e, t) => {
85
- const n = o.forwardRef((r, s) => {
86
- const { asChild: i, ...a } = r, c = i ? j : t;
87
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ d(c, { ...a, ref: s });
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.${t}`, { ...e, [t]: n };
92
+ return n.displayName = `Primitive.${e}`, { ...t, [e]: n };
90
93
  }, {});
91
- function fe(e, t) {
92
- e && q.flushSync(() => e.dispatchEvent(t));
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 N(e) {
104
- const t = o.useRef(e);
105
- return o.useEffect(() => {
106
- t.current = e;
107
- }), o.useMemo(() => (...n) => {
108
- var r;
109
- return (r = t.current) == null ? void 0 : r.call(t, ...n);
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 he(e, t = globalThis == null ? void 0 : globalThis.document) {
113
- const n = N(e);
114
- o.useEffect(() => {
115
- const r = (s) => {
116
- s.key === "Escape" && n(s);
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 t.addEventListener("keydown", r, { capture: !0 }), () => t.removeEventListener("keydown", r, { capture: !0 });
119
- }, [n, t]);
112
+ return e.addEventListener("keydown", s, { capture: !0 }), () => e.removeEventListener("keydown", s, { capture: !0 });
113
+ }, [n, e]);
120
114
  }
121
- var me = "DismissableLayer", W = "dismissableLayer.update", ve = "dismissableLayer.pointerDownOutside", Ee = "dismissableLayer.focusOutside", M, U = o.createContext({
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
- }), z = o.forwardRef(
126
- (e, t) => {
119
+ }), $ = i.forwardRef(
120
+ (t, e) => {
127
121
  const {
128
122
  disableOutsidePointerEvents: n = !1,
129
- onEscapeKeyDown: r,
130
- onPointerDownOutside: s,
131
- onFocusOutside: i,
123
+ onEscapeKeyDown: s,
124
+ onPointerDownOutside: r,
125
+ onFocusOutside: o,
132
126
  onInteractOutside: a,
133
127
  onDismiss: c,
134
128
  ...p
135
- } = e, l = o.useContext(U), [u, y] = o.useState(null), h = (u == null ? void 0 : u.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, w] = o.useState({}), b = $(t, (f) => y(f)), C = Array.from(l.layers), [L] = [...l.layersWithOutsidePointerEventsDisabled].slice(-1), m = C.indexOf(L), D = u ? C.indexOf(u) : -1, P = l.layersWithOutsidePointerEventsDisabled.size > 0, k = D >= m, H = Ce((f) => {
136
- const R = f.target, F = [...l.branches].some((O) => O.contains(R));
137
- !k || F || (s == null || s(f), a == null || a(f), f.defaultPrevented || c == null || c());
138
- }, h), A = Le((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) => {
139
133
  const R = f.target;
140
- [...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());
141
135
  }, h);
142
- return he((f) => {
143
- D === l.layers.size - 1 && (r == null || r(f), !f.defaultPrevented && c && (f.preventDefault(), c()));
144
- }, 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(() => {
145
139
  if (u)
146
- return n && (l.layersWithOutsidePointerEventsDisabled.size === 0 && (M = h.body.style.pointerEvents, h.body.style.pointerEvents = "none"), l.layersWithOutsidePointerEventsDisabled.add(u)), l.layers.add(u), I(), () => {
147
- n && l.layersWithOutsidePointerEventsDisabled.size === 1 && (h.body.style.pointerEvents = M);
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]), o.useEffect(() => () => {
150
- u && (l.layers.delete(u), l.layersWithOutsidePointerEventsDisabled.delete(u), I());
151
- }, [u, l]), o.useEffect(() => {
152
- const f = () => w({});
153
- return document.addEventListener(W, f), () => document.removeEventListener(W, f);
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
- _.div,
149
+ z.div,
156
150
  {
157
151
  ...p,
158
152
  ref: b,
159
153
  style: {
160
- pointerEvents: P ? k ? "auto" : "none" : void 0,
161
- ...e.style
154
+ pointerEvents: w ? k ? "auto" : "none" : void 0,
155
+ ...t.style
162
156
  },
163
- onFocusCapture: x(e.onFocusCapture, A.onFocusCapture),
164
- onBlurCapture: x(e.onBlurCapture, A.onBlurCapture),
165
- onPointerDownCapture: x(
166
- e.onPointerDownCapture,
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
- z.displayName = me;
174
- var ge = "DismissableLayerBranch", be = o.forwardRef((e, t) => {
175
- const n = o.useContext(U), r = o.useRef(null), s = $(t, r);
176
- return o.useEffect(() => {
177
- const i = r.current;
178
- if (i)
179
- return n.branches.add(i), () => {
180
- 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);
181
175
  };
182
- }, [n.branches]), /* @__PURE__ */ d(_.div, { ...e, ref: s });
176
+ }, [n.branches]), /* @__PURE__ */ d(z.div, { ...t, ref: r });
183
177
  });
184
- be.displayName = ge;
185
- function Ce(e, t = globalThis == null ? void 0 : globalThis.document) {
186
- const n = N(e), r = o.useRef(!1), s = o.useRef(() => {
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 o.useEffect(() => {
189
- const i = (c) => {
190
- if (c.target && !r.current) {
182
+ return i.useEffect(() => {
183
+ const o = (c) => {
184
+ if (c.target && !s.current) {
191
185
  let p = function() {
192
- V(
193
- ve,
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" ? (t.removeEventListener("click", s.current), s.current = p, t.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();
201
195
  } else
202
- t.removeEventListener("click", s.current);
203
- r.current = !1;
196
+ e.removeEventListener("click", r.current);
197
+ s.current = !1;
204
198
  }, a = window.setTimeout(() => {
205
- t.addEventListener("pointerdown", i);
199
+ e.addEventListener("pointerdown", o);
206
200
  }, 0);
207
201
  return () => {
208
- window.clearTimeout(a), t.removeEventListener("pointerdown", i), t.removeEventListener("click", s.current);
202
+ window.clearTimeout(a), e.removeEventListener("pointerdown", o), e.removeEventListener("click", r.current);
209
203
  };
210
- }, [t, n]), {
204
+ }, [e, n]), {
211
205
  // ensures we check React component tree (not just DOM tree)
212
- onPointerDownCapture: () => r.current = !0
206
+ onPointerDownCapture: () => s.current = !0
213
207
  };
214
208
  }
215
- function Le(e, t = globalThis == null ? void 0 : globalThis.document) {
216
- const n = N(e), r = o.useRef(!1);
217
- return o.useEffect(() => {
218
- const s = (i) => {
219
- i.target && !r.current && V(Ee, n, { originalEvent: i }, {
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 t.addEventListener("focusin", s), () => t.removeEventListener("focusin", s);
224
- }, [t, n]), {
225
- onFocusCapture: () => r.current = !0,
226
- onBlurCapture: () => r.current = !1
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 I() {
230
- const e = new CustomEvent(W);
231
- document.dispatchEvent(e);
223
+ function M() {
224
+ const t = new CustomEvent(N);
225
+ document.dispatchEvent(t);
232
226
  }
233
- function V(e, t, n, { discrete: r }) {
234
- const s = n.originalEvent.target, i = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: n });
235
- t && s.addEventListener(e, t, { once: !0 }), r ? fe(s, i) : s.dispatchEvent(i);
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 K(e) {
238
- const t = o.useRef(e);
239
- return o.useEffect(() => {
240
- t.current = e;
241
- }), o.useMemo(() => (...n) => {
242
- var r;
243
- return (r = t.current) == null ? void 0 : r.call(t, ...n);
244
- }, []);
245
- }
246
- function Pe({
247
- prop: e,
248
- defaultProp: t,
231
+ function be({
232
+ prop: t,
233
+ defaultProp: e,
249
234
  onChange: n = () => {
250
235
  }
251
236
  }) {
252
- const [r, s] = Re({ defaultProp: t, onChange: n }), i = e !== void 0, a = i ? e : 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(
253
238
  (l) => {
254
- if (i) {
255
- const y = typeof l == "function" ? l(e) : l;
256
- y !== e && c(y);
239
+ if (o) {
240
+ const y = typeof l == "function" ? l(t) : l;
241
+ y !== t && c(y);
257
242
  } else
258
- s(l);
243
+ r(l);
259
244
  },
260
- [i, e, s, c]
245
+ [o, t, r, c]
261
246
  );
262
247
  return [a, p];
263
248
  }
264
- function Re({
265
- defaultProp: e,
266
- onChange: t
249
+ function Ce({
250
+ defaultProp: t,
251
+ onChange: e
267
252
  }) {
268
- const n = o.useState(e), [r] = n, s = o.useRef(r), i = K(t);
269
- return o.useEffect(() => {
270
- s.current !== r && (i(r), s.current = r);
271
- }, [r, s, i]), n;
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 = g.createContext({
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
- }), Ue = ({ children: e }) => {
284
- const [t, n] = g.useState([]), r = (a) => {
268
+ }), je = ({ children: t }) => {
269
+ const [e, n] = E.useState([]), s = (a) => {
285
270
  n((c) => [...c, a]);
286
- }, s = (a) => {
287
- n(t.filter((c) => c !== a));
288
- }, i = () => {
289
- const a = t[t.length - 1];
290
- a && s(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: t, setLayers: n, addLayer: r, removeLayer: s, removeTopLayer: i },
296
- children: e
280
+ value: { layers: e, setLayers: n, addLayer: s, removeLayer: r, removeTopLayer: o },
281
+ children: t
297
282
  }
298
283
  );
299
- }, Y = () => g.useContext(X), we = ({
300
- defaultOpen: e,
301
- open: t,
284
+ }, Y = () => E.useContext(X), Le = ({
285
+ defaultOpen: t,
286
+ open: e,
302
287
  onOpenChange: n,
303
- ...r
288
+ ...s
304
289
  }) => {
305
- const [s, i] = Pe({
306
- prop: t,
290
+ const [r, o] = be({
291
+ prop: e,
307
292
  onChange: n,
308
- defaultProp: e
309
- }), a = Y(), c = r.a11yTitle;
310
- if (g.useEffect(() => {
311
- !s && a.layers.includes(c) && a.removeLayer(c);
312
- }, [c, a, s]), !!s)
313
- return /* @__PURE__ */ d(De, { open: s, onOpenChange: i, ...r });
314
- }, De = ({
315
- open: e,
316
- onOpenChange: t,
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: r,
319
- children: s,
303
+ a11yDescription: s,
304
+ children: r,
320
305
  // Focus scope props
321
- trapped: i,
306
+ trapped: o,
322
307
  onMountAutoFocus: a,
323
308
  onUnmountAutoFocus: c,
324
309
  ...p
325
310
  }) => {
326
- var C, L;
311
+ var C, P;
327
312
  const l = n, u = Y();
328
- g.useEffect(() => {
329
- !u || !e || u.layers.includes(l) || u.addLayer(l);
330
- }, [l, u, e]);
331
- const y = ((C = u.layers) == null ? void 0 : C.indexOf(l)) || 0, h = ((L = u.layers) == null ? void 0 : L.length) || 0, w = y !== 0, b = l === u.layers[u.layers.length - 1];
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
- z,
318
+ $,
334
319
  {
335
320
  onEscapeKeyDown: (m) => {
336
- b && (m.preventDefault(), u.removeTopLayer(), t(!1));
321
+ b && (m.preventDefault(), u.removeTopLayer(), e(!1));
337
322
  },
338
323
  onPointerDownOutside: (m) => {
339
- b && (m.preventDefault(), u.removeTopLayer(), t(!1));
324
+ b && (m.preventDefault(), u.removeTopLayer(), e(!1));
340
325
  },
341
- children: /* @__PURE__ */ S(
326
+ children: /* @__PURE__ */ T(
342
327
  v.Root,
343
328
  {
344
- open: e,
329
+ open: t,
345
330
  onOpenChange: (m) => {
346
- var P;
347
- if (((P = u == null ? void 0 : u.layers) == null ? void 0 : P.length) > 0)
348
- return m === !1 && l === u.layers[u.layers.length - 1] ? (u.removeLayer(l), t(!1)) : void 0;
349
- t(m);
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__ */ S(Q.Root, { children: [
337
+ /* @__PURE__ */ T(Q.Root, { children: [
353
338
  /* @__PURE__ */ d(v.Title, { children: n }),
354
- r && /* @__PURE__ */ d(v.Description, { children: r })
339
+ s && /* @__PURE__ */ d(v.Description, { children: s })
355
340
  ] }),
356
- /* @__PURE__ */ d(se, { children: e && // We add the className "tgph" here so that styles within
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(Oe, { layer: y, 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 i == "boolean" ? i : b,
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
- E,
351
+ g,
367
352
  {
368
- as: T.div,
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: 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)"
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
- E,
372
+ g,
388
373
  {
389
374
  direction: "column",
390
- as: T.div,
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: s
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
- }, Oe = ({ layer: e, children: t }) => e > 0 ? t : /* @__PURE__ */ S(v.Overlay, { children: [
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: T.div,
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
- t
443
- ] }), xe = g.forwardRef(
444
- ({ children: e, ...t }, n) => /* @__PURE__ */ d(v.Content, { ref: n, asChild: !0, ...t, children: /* @__PURE__ */ d(E, { direction: "column", h: "full", ...t, children: e }) })
445
- ), Se = ({
446
- size: e = "1",
447
- variant: t = "ghost",
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: t,
454
- size: e,
438
+ variant: e,
439
+ size: t,
455
440
  ...n
456
441
  }
457
- ) }), Te = ({
458
- style: e,
459
- children: t,
442
+ ) }), Oe = ({
443
+ style: t,
444
+ children: e,
460
445
  ...n
461
446
  }) => /* @__PURE__ */ d(
462
- E,
447
+ g,
463
448
  {
464
449
  direction: "column",
465
450
  px: "6",
466
451
  py: "4",
467
452
  style: {
468
453
  overflowY: "auto",
469
- ...e
454
+ ...t
470
455
  },
471
456
  ...n,
472
- children: t
457
+ children: e
473
458
  }
474
- ), Be = ({
475
- children: e,
476
- ...t
459
+ ), xe = ({
460
+ children: t,
461
+ ...e
477
462
  }) => /* @__PURE__ */ d(
478
- E,
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
- ...t,
487
- children: e
471
+ ...e,
472
+ children: t
488
473
  }
489
- ), We = ({
490
- children: e,
491
- ...t
474
+ ), Se = ({
475
+ children: t,
476
+ ...e
492
477
  }) => /* @__PURE__ */ d(
493
- E,
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
- ...t,
503
- children: e
487
+ ...e,
488
+ children: t
504
489
  }
505
- ), Ne = {};
506
- Object.assign(Ne, {
507
- Root: we,
508
- Content: xe,
509
- Close: Se,
510
- Body: Te,
511
- Header: Be,
512
- Footer: We
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
- Ne as Modal,
516
- Ue as ModalStackingProvider
500
+ Te as Modal,
501
+ je as ModalStackingProvider
517
502
  };
518
503
  //# sourceMappingURL=index.mjs.map