@drjoshcsimmons/scl 0.1.10 → 0.1.11

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.
Files changed (101) hide show
  1. package/dist/index100.js +47 -49
  2. package/dist/index101.js +51 -44
  3. package/dist/index102.js +30 -9
  4. package/dist/index103.js +3 -14
  5. package/dist/index104.js +3 -3
  6. package/dist/index105.js +46 -7
  7. package/dist/index107.js +7 -46
  8. package/dist/index108.js +176 -43
  9. package/dist/index109.js +47 -29
  10. package/dist/index11.js +2 -2
  11. package/dist/index110.js +30 -55
  12. package/dist/index111.js +650 -30
  13. package/dist/index112.js +30 -13
  14. package/dist/index115.js +6 -48
  15. package/dist/index116.js +1 -1
  16. package/dist/index12.js +1 -1
  17. package/dist/index124.js +48 -6
  18. package/dist/index125.js +2 -25
  19. package/dist/index126.js +53 -29
  20. package/dist/index127.js +65 -5
  21. package/dist/index128.js +25 -2
  22. package/dist/index129.js +29 -53
  23. package/dist/index13.js +2 -2
  24. package/dist/index130.js +5 -65
  25. package/dist/index131.js +2 -5
  26. package/dist/index132.js +2 -3
  27. package/dist/index133.js +5 -24
  28. package/dist/index134.js +3 -113
  29. package/dist/index135.js +23 -15
  30. package/dist/index136.js +113 -2
  31. package/dist/index137.js +16 -2
  32. package/dist/index14.js +2 -2
  33. package/dist/index141.js +1 -1
  34. package/dist/index142.js +1 -1
  35. package/dist/index15.js +2 -2
  36. package/dist/index17.js +4 -4
  37. package/dist/index18.js +2 -2
  38. package/dist/index20.js +1 -1
  39. package/dist/index21.js +1 -1
  40. package/dist/index22.js +1 -1
  41. package/dist/index23.js +2 -2
  42. package/dist/index24.js +1 -1
  43. package/dist/index25.js +3 -3
  44. package/dist/index26.js +1 -1
  45. package/dist/index27.js +2 -2
  46. package/dist/index29.js +1 -1
  47. package/dist/index31.js +1 -1
  48. package/dist/index33.js +1 -1
  49. package/dist/index36.js +1 -1
  50. package/dist/index37.js +1 -1
  51. package/dist/index45.js +1 -1
  52. package/dist/index48.js +310 -12
  53. package/dist/index49.js +5 -2
  54. package/dist/index50.js +124 -59
  55. package/dist/index51.js +62 -107
  56. package/dist/index52.js +55 -244
  57. package/dist/index53.js +256 -18
  58. package/dist/index54.js +12 -236
  59. package/dist/index55.js +249 -11
  60. package/dist/index56.js +9 -530
  61. package/dist/index57.js +102 -209
  62. package/dist/index58.js +5 -4
  63. package/dist/index59.js +31 -82
  64. package/dist/index6.js +1 -1
  65. package/dist/index60.js +71 -249
  66. package/dist/index61.js +860 -12
  67. package/dist/index62.js +9 -435
  68. package/dist/index63.js +147 -111
  69. package/dist/index64.js +333 -28
  70. package/dist/index65.js +410 -285
  71. package/dist/index66.js +241 -12
  72. package/dist/index67.js +18 -332
  73. package/dist/index68.js +219 -248
  74. package/dist/index69.js +11 -241
  75. package/dist/index7.js +1 -1
  76. package/dist/index70.js +11 -860
  77. package/dist/index71.js +130 -9
  78. package/dist/index72.js +234 -16
  79. package/dist/index73.js +509 -109
  80. package/dist/index74.js +16 -159
  81. package/dist/index75.js +247 -66
  82. package/dist/index80.js +1 -1
  83. package/dist/index82.js +1 -1
  84. package/dist/index84.js +15 -4
  85. package/dist/index85.js +51 -65
  86. package/dist/index86.js +11 -30
  87. package/dist/index87.js +4 -6
  88. package/dist/index88.js +30 -25
  89. package/dist/index89.js +10 -178
  90. package/dist/index9.js +1 -1
  91. package/dist/index90.js +8 -10
  92. package/dist/index91.js +5 -3
  93. package/dist/index92.js +24 -649
  94. package/dist/index93.js +65 -51
  95. package/dist/index94.js +124 -29
  96. package/dist/index95.js +125 -115
  97. package/dist/index96.js +13 -134
  98. package/dist/index97.js +14 -13
  99. package/dist/index98.js +8 -14
  100. package/dist/index99.js +50 -9
  101. package/package.json +1 -1
package/dist/index93.js CHANGED
@@ -1,57 +1,71 @@
1
- import * as i from "react";
2
- import { jsx as _ } from "react/jsx-runtime";
3
- function $(e, x = []) {
4
- let o = [];
5
- function f(r, n) {
6
- const t = i.createContext(n);
7
- t.displayName = r + "Context";
8
- const c = o.length;
9
- o = [...o, n];
10
- const m = (a) => {
11
- var l;
12
- const { scope: s, children: C, ...p } = a, d = ((l = s == null ? void 0 : s[e]) == null ? void 0 : l[c]) || t, v = i.useMemo(() => p, Object.values(p));
13
- return /* @__PURE__ */ _(d.Provider, { value: v, children: C });
14
- };
15
- m.displayName = r + "Provider";
16
- function S(a, s) {
17
- var d;
18
- const C = ((d = s == null ? void 0 : s[e]) == null ? void 0 : d[c]) || t, p = i.useContext(C);
19
- if (p) return p;
20
- if (n !== void 0) return n;
21
- throw new Error(`\`${a}\` must be used within \`${r}\``);
1
+ import * as a from "react";
2
+ import { useComposedRefs as E } from "./index78.js";
3
+ import { useLayoutEffect as A } from "./index87.js";
4
+ function T(n, e) {
5
+ return a.useReducer((r, t) => e[r][t] ?? r, n);
6
+ }
7
+ var R = (n) => {
8
+ const { present: e, children: r } = n, t = v(e), i = typeof r == "function" ? r({ present: t.isPresent }) : a.Children.only(r), c = E(t.ref, P(i));
9
+ return typeof r == "function" || t.isPresent ? a.cloneElement(i, { ref: c }) : null;
10
+ };
11
+ R.displayName = "Presence";
12
+ function v(n) {
13
+ const [e, r] = a.useState(), t = a.useRef(null), i = a.useRef(n), c = a.useRef("none"), p = n ? "mounted" : "unmounted", [N, s] = T(p, {
14
+ mounted: {
15
+ UNMOUNT: "unmounted",
16
+ ANIMATION_OUT: "unmountSuspended"
17
+ },
18
+ unmountSuspended: {
19
+ MOUNT: "mounted",
20
+ ANIMATION_END: "unmounted"
21
+ },
22
+ unmounted: {
23
+ MOUNT: "mounted"
24
+ }
25
+ });
26
+ return a.useEffect(() => {
27
+ const o = l(t.current);
28
+ c.current = N === "mounted" ? o : "none";
29
+ }, [N]), A(() => {
30
+ const o = t.current, m = i.current;
31
+ if (m !== n) {
32
+ const f = c.current, u = l(o);
33
+ n ? s("MOUNT") : u === "none" || (o == null ? void 0 : o.display) === "none" ? s("UNMOUNT") : s(m && f !== u ? "ANIMATION_OUT" : "UNMOUNT"), i.current = n;
22
34
  }
23
- return [m, S];
24
- }
25
- const u = () => {
26
- const r = o.map((n) => i.createContext(n));
27
- return function(t) {
28
- const c = (t == null ? void 0 : t[e]) || r;
29
- return i.useMemo(
30
- () => ({ [`__scope${e}`]: { ...t, [e]: c } }),
31
- [t, c]
32
- );
33
- };
35
+ }, [n, s]), A(() => {
36
+ if (e) {
37
+ let o;
38
+ const m = e.ownerDocument.defaultView ?? window, d = (u) => {
39
+ const g = l(t.current).includes(CSS.escape(u.animationName));
40
+ if (u.target === e && g && (s("ANIMATION_END"), !i.current)) {
41
+ const O = e.style.animationFillMode;
42
+ e.style.animationFillMode = "forwards", o = m.setTimeout(() => {
43
+ e.style.animationFillMode === "forwards" && (e.style.animationFillMode = O);
44
+ });
45
+ }
46
+ }, f = (u) => {
47
+ u.target === e && (c.current = l(t.current));
48
+ };
49
+ return e.addEventListener("animationstart", f), e.addEventListener("animationcancel", d), e.addEventListener("animationend", d), () => {
50
+ m.clearTimeout(o), e.removeEventListener("animationstart", f), e.removeEventListener("animationcancel", d), e.removeEventListener("animationend", d);
51
+ };
52
+ } else
53
+ s("ANIMATION_END");
54
+ }, [e, s]), {
55
+ isPresent: ["mounted", "unmountSuspended"].includes(N),
56
+ ref: a.useCallback((o) => {
57
+ t.current = o ? getComputedStyle(o) : null, r(o);
58
+ }, [])
34
59
  };
35
- return u.scopeName = e, [f, h(u, ...x)];
36
60
  }
37
- function h(...e) {
38
- const x = e[0];
39
- if (e.length === 1) return x;
40
- const o = () => {
41
- const f = e.map((u) => ({
42
- useScope: u(),
43
- scopeName: u.scopeName
44
- }));
45
- return function(r) {
46
- const n = f.reduce((t, { useScope: c, scopeName: m }) => {
47
- const a = c(r)[`__scope${m}`];
48
- return { ...t, ...a };
49
- }, {});
50
- return i.useMemo(() => ({ [`__scope${x.scopeName}`]: n }), [n]);
51
- };
52
- };
53
- return o.scopeName = x.scopeName, o;
61
+ function l(n) {
62
+ return (n == null ? void 0 : n.animationName) || "none";
63
+ }
64
+ function P(n) {
65
+ var t, i;
66
+ let e = (t = Object.getOwnPropertyDescriptor(n.props, "ref")) == null ? void 0 : t.get, r = e && "isReactWarning" in e && e.isReactWarning;
67
+ return r ? n.ref : (e = (i = Object.getOwnPropertyDescriptor(n, "ref")) == null ? void 0 : i.get, r = e && "isReactWarning" in e && e.isReactWarning, r ? n.props.ref : n.props.ref || n.ref);
54
68
  }
55
69
  export {
56
- $ as createContextScope
70
+ R as Presence
57
71
  };
package/dist/index94.js CHANGED
@@ -1,32 +1,127 @@
1
- import * as f from "react";
2
- import "react-dom";
3
- import { createSlot as l } from "./index50.js";
4
- import { jsx as n } from "react/jsx-runtime";
5
- var u = [
6
- "a",
7
- "button",
8
- "div",
9
- "form",
10
- "h2",
11
- "h3",
12
- "img",
13
- "input",
14
- "label",
15
- "li",
16
- "nav",
17
- "ol",
18
- "p",
19
- "select",
20
- "span",
21
- "svg",
22
- "ul"
23
- ], w = u.reduce((t, i) => {
24
- const o = l(`Primitive.${i}`), r = f.forwardRef((e, m) => {
25
- const { asChild: a, ...p } = e, s = a ? o : i;
26
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ n(s, { ...p, ref: m });
1
+ import * as n from "react";
2
+ import { composeEventHandlers as m } from "./index79.js";
3
+ import { Primitive as g, dispatchDiscreteCustomEvent as k } from "./index81.js";
4
+ import { useComposedRefs as R } from "./index78.js";
5
+ import { useCallbackRef as w } from "./index86.js";
6
+ import { useEscapeKeydown as U } from "./index116.js";
7
+ import { jsx as T } from "react/jsx-runtime";
8
+ var z = "DismissableLayer", y = "dismissableLayer.update", H = "dismissableLayer.pointerDownOutside", M = "dismissableLayer.focusOutside", L, B = n.createContext({
9
+ layers: /* @__PURE__ */ new Set(),
10
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
11
+ branches: /* @__PURE__ */ new Set()
12
+ }), j = n.forwardRef(
13
+ (r, e) => {
14
+ const {
15
+ disableOutsidePointerEvents: i = !1,
16
+ onEscapeKeyDown: o,
17
+ onPointerDownOutside: t,
18
+ onFocusOutside: a,
19
+ onInteractOutside: l,
20
+ onDismiss: d,
21
+ ...v
22
+ } = r, c = n.useContext(B), [u, S] = n.useState(null), f = (u == null ? void 0 : u.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, F] = n.useState({}), W = R(e, (s) => S(s)), p = Array.from(c.layers), [A] = [...c.layersWithOutsidePointerEventsDisabled].slice(-1), N = p.indexOf(A), b = u ? p.indexOf(u) : -1, I = c.layersWithOutsidePointerEventsDisabled.size > 0, P = b >= N, _ = q((s) => {
23
+ const E = s.target, C = [...c.branches].some((h) => h.contains(E));
24
+ !P || C || (t == null || t(s), l == null || l(s), s.defaultPrevented || d == null || d());
25
+ }, f), D = G((s) => {
26
+ const E = s.target;
27
+ [...c.branches].some((h) => h.contains(E)) || (a == null || a(s), l == null || l(s), s.defaultPrevented || d == null || d());
28
+ }, f);
29
+ return U((s) => {
30
+ b === c.layers.size - 1 && (o == null || o(s), !s.defaultPrevented && d && (s.preventDefault(), d()));
31
+ }, f), n.useEffect(() => {
32
+ if (u)
33
+ return i && (c.layersWithOutsidePointerEventsDisabled.size === 0 && (L = f.body.style.pointerEvents, f.body.style.pointerEvents = "none"), c.layersWithOutsidePointerEventsDisabled.add(u)), c.layers.add(u), O(), () => {
34
+ i && c.layersWithOutsidePointerEventsDisabled.size === 1 && (f.body.style.pointerEvents = L);
35
+ };
36
+ }, [u, f, i, c]), n.useEffect(() => () => {
37
+ u && (c.layers.delete(u), c.layersWithOutsidePointerEventsDisabled.delete(u), O());
38
+ }, [u, c]), n.useEffect(() => {
39
+ const s = () => F({});
40
+ return document.addEventListener(y, s), () => document.removeEventListener(y, s);
41
+ }, []), /* @__PURE__ */ T(
42
+ g.div,
43
+ {
44
+ ...v,
45
+ ref: W,
46
+ style: {
47
+ pointerEvents: I ? P ? "auto" : "none" : void 0,
48
+ ...r.style
49
+ },
50
+ onFocusCapture: m(r.onFocusCapture, D.onFocusCapture),
51
+ onBlurCapture: m(r.onBlurCapture, D.onBlurCapture),
52
+ onPointerDownCapture: m(
53
+ r.onPointerDownCapture,
54
+ _.onPointerDownCapture
55
+ )
56
+ }
57
+ );
58
+ }
59
+ );
60
+ j.displayName = z;
61
+ var X = "DismissableLayerBranch", Y = n.forwardRef((r, e) => {
62
+ const i = n.useContext(B), o = n.useRef(null), t = R(e, o);
63
+ return n.useEffect(() => {
64
+ const a = o.current;
65
+ if (a)
66
+ return i.branches.add(a), () => {
67
+ i.branches.delete(a);
68
+ };
69
+ }, [i.branches]), /* @__PURE__ */ T(g.div, { ...r, ref: t });
70
+ });
71
+ Y.displayName = X;
72
+ function q(r, e = globalThis == null ? void 0 : globalThis.document) {
73
+ const i = w(r), o = n.useRef(!1), t = n.useRef(() => {
27
74
  });
28
- return r.displayName = `Primitive.${i}`, { ...t, [i]: r };
29
- }, {});
75
+ return n.useEffect(() => {
76
+ const a = (d) => {
77
+ if (d.target && !o.current) {
78
+ let v = function() {
79
+ x(
80
+ H,
81
+ i,
82
+ c,
83
+ { discrete: !0 }
84
+ );
85
+ };
86
+ const c = { originalEvent: d };
87
+ d.pointerType === "touch" ? (e.removeEventListener("click", t.current), t.current = v, e.addEventListener("click", t.current, { once: !0 })) : v();
88
+ } else
89
+ e.removeEventListener("click", t.current);
90
+ o.current = !1;
91
+ }, l = window.setTimeout(() => {
92
+ e.addEventListener("pointerdown", a);
93
+ }, 0);
94
+ return () => {
95
+ window.clearTimeout(l), e.removeEventListener("pointerdown", a), e.removeEventListener("click", t.current);
96
+ };
97
+ }, [e, i]), {
98
+ // ensures we check React component tree (not just DOM tree)
99
+ onPointerDownCapture: () => o.current = !0
100
+ };
101
+ }
102
+ function G(r, e = globalThis == null ? void 0 : globalThis.document) {
103
+ const i = w(r), o = n.useRef(!1);
104
+ return n.useEffect(() => {
105
+ const t = (a) => {
106
+ a.target && !o.current && x(M, i, { originalEvent: a }, {
107
+ discrete: !1
108
+ });
109
+ };
110
+ return e.addEventListener("focusin", t), () => e.removeEventListener("focusin", t);
111
+ }, [e, i]), {
112
+ onFocusCapture: () => o.current = !0,
113
+ onBlurCapture: () => o.current = !1
114
+ };
115
+ }
116
+ function O() {
117
+ const r = new CustomEvent(y);
118
+ document.dispatchEvent(r);
119
+ }
120
+ function x(r, e, i, { discrete: o }) {
121
+ const t = i.originalEvent.target, a = new CustomEvent(r, { bubbles: !1, cancelable: !0, detail: i });
122
+ e && t.addEventListener(r, e, { once: !0 }), o ? k(t, a) : t.dispatchEvent(a);
123
+ }
30
124
  export {
31
- w as Primitive
125
+ j as DismissableLayer,
126
+ Y as DismissableLayerBranch
32
127
  };
package/dist/index95.js CHANGED
@@ -1,127 +1,137 @@
1
- import * as n from "react";
2
- import { composeEventHandlers as m } from "./index79.js";
3
- import { Primitive as g, dispatchDiscreteCustomEvent as k } from "./index81.js";
1
+ import * as d from "react";
4
2
  import { useComposedRefs as R } from "./index78.js";
5
- import { useCallbackRef as w } from "./index90.js";
6
- import { useEscapeKeydown as U } from "./index116.js";
7
- import { jsx as T } from "react/jsx-runtime";
8
- var z = "DismissableLayer", y = "dismissableLayer.update", H = "dismissableLayer.pointerDownOutside", M = "dismissableLayer.focusOutside", L, B = n.createContext({
9
- layers: /* @__PURE__ */ new Set(),
10
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
11
- branches: /* @__PURE__ */ new Set()
12
- }), j = n.forwardRef(
13
- (r, e) => {
14
- const {
15
- disableOutsidePointerEvents: i = !1,
16
- onEscapeKeyDown: o,
17
- onPointerDownOutside: t,
18
- onFocusOutside: a,
19
- onInteractOutside: l,
20
- onDismiss: d,
21
- ...v
22
- } = r, c = n.useContext(B), [u, S] = n.useState(null), f = (u == null ? void 0 : u.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, F] = n.useState({}), W = R(e, (s) => S(s)), p = Array.from(c.layers), [A] = [...c.layersWithOutsidePointerEventsDisabled].slice(-1), N = p.indexOf(A), b = u ? p.indexOf(u) : -1, I = c.layersWithOutsidePointerEventsDisabled.size > 0, P = b >= N, _ = q((s) => {
23
- const E = s.target, C = [...c.branches].some((h) => h.contains(E));
24
- !P || C || (t == null || t(s), l == null || l(s), s.defaultPrevented || d == null || d());
25
- }, f), D = G((s) => {
26
- const E = s.target;
27
- [...c.branches].some((h) => h.contains(E)) || (a == null || a(s), l == null || l(s), s.defaultPrevented || d == null || d());
28
- }, f);
29
- return U((s) => {
30
- b === c.layers.size - 1 && (o == null || o(s), !s.defaultPrevented && d && (s.preventDefault(), d()));
31
- }, f), n.useEffect(() => {
32
- if (u)
33
- return i && (c.layersWithOutsidePointerEventsDisabled.size === 0 && (L = f.body.style.pointerEvents, f.body.style.pointerEvents = "none"), c.layersWithOutsidePointerEventsDisabled.add(u)), c.layers.add(u), O(), () => {
34
- i && c.layersWithOutsidePointerEventsDisabled.size === 1 && (f.body.style.pointerEvents = L);
35
- };
36
- }, [u, f, i, c]), n.useEffect(() => () => {
37
- u && (c.layers.delete(u), c.layersWithOutsidePointerEventsDisabled.delete(u), O());
38
- }, [u, c]), n.useEffect(() => {
39
- const s = () => F({});
40
- return document.addEventListener(y, s), () => document.removeEventListener(y, s);
41
- }, []), /* @__PURE__ */ T(
42
- g.div,
43
- {
44
- ...v,
45
- ref: W,
46
- style: {
47
- pointerEvents: I ? P ? "auto" : "none" : void 0,
48
- ...r.style
49
- },
50
- onFocusCapture: m(r.onFocusCapture, D.onFocusCapture),
51
- onBlurCapture: m(r.onBlurCapture, D.onBlurCapture),
52
- onPointerDownCapture: m(
53
- r.onPointerDownCapture,
54
- _.onPointerDownCapture
55
- )
3
+ import { Primitive as M } from "./index81.js";
4
+ import { useCallbackRef as y } from "./index86.js";
5
+ import { jsx as _ } from "react/jsx-runtime";
6
+ var F = "focusScope.autoFocusOnMount", T = "focusScope.autoFocusOnUnmount", N = { bubbles: !1, cancelable: !0 }, K = "FocusScope", k = d.forwardRef((e, n) => {
7
+ const {
8
+ loop: t = !1,
9
+ trapped: u = !1,
10
+ onMountAutoFocus: p,
11
+ onUnmountAutoFocus: L,
12
+ ...g
13
+ } = e, [o, U] = d.useState(null), E = y(p), v = y(L), b = d.useRef(null), A = R(n, (s) => U(s)), a = d.useRef({
14
+ paused: !1,
15
+ pause() {
16
+ this.paused = !0;
17
+ },
18
+ resume() {
19
+ this.paused = !1;
20
+ }
21
+ }).current;
22
+ d.useEffect(() => {
23
+ if (u) {
24
+ let s = function(i) {
25
+ if (a.paused || !o) return;
26
+ const c = i.target;
27
+ o.contains(c) ? b.current = c : f(b.current, { select: !0 });
28
+ }, l = function(i) {
29
+ if (a.paused || !o) return;
30
+ const c = i.relatedTarget;
31
+ c !== null && (o.contains(c) || f(b.current, { select: !0 }));
32
+ }, r = function(i) {
33
+ if (document.activeElement === document.body)
34
+ for (const h of i)
35
+ h.removedNodes.length > 0 && f(o);
36
+ };
37
+ document.addEventListener("focusin", s), document.addEventListener("focusout", l);
38
+ const m = new MutationObserver(r);
39
+ return o && m.observe(o, { childList: !0, subtree: !0 }), () => {
40
+ document.removeEventListener("focusin", s), document.removeEventListener("focusout", l), m.disconnect();
41
+ };
42
+ }
43
+ }, [u, o, a.paused]), d.useEffect(() => {
44
+ if (o) {
45
+ S.add(a);
46
+ const s = document.activeElement;
47
+ if (!o.contains(s)) {
48
+ const r = new CustomEvent(F, N);
49
+ o.addEventListener(F, E), o.dispatchEvent(r), r.defaultPrevented || (w(W(I(o)), { select: !0 }), document.activeElement === s && f(o));
56
50
  }
57
- );
58
- }
59
- );
60
- j.displayName = z;
61
- var X = "DismissableLayerBranch", Y = n.forwardRef((r, e) => {
62
- const i = n.useContext(B), o = n.useRef(null), t = R(e, o);
63
- return n.useEffect(() => {
64
- const a = o.current;
65
- if (a)
66
- return i.branches.add(a), () => {
67
- i.branches.delete(a);
51
+ return () => {
52
+ o.removeEventListener(F, E), setTimeout(() => {
53
+ const r = new CustomEvent(T, N);
54
+ o.addEventListener(T, v), o.dispatchEvent(r), r.defaultPrevented || f(s ?? document.body, { select: !0 }), o.removeEventListener(T, v), S.remove(a);
55
+ }, 0);
68
56
  };
69
- }, [i.branches]), /* @__PURE__ */ T(g.div, { ...r, ref: t });
57
+ }
58
+ }, [o, E, v, a]);
59
+ const P = d.useCallback(
60
+ (s) => {
61
+ if (!t && !u || a.paused) return;
62
+ const l = s.key === "Tab" && !s.altKey && !s.ctrlKey && !s.metaKey, r = document.activeElement;
63
+ if (l && r) {
64
+ const m = s.currentTarget, [i, c] = x(m);
65
+ i && c ? !s.shiftKey && r === c ? (s.preventDefault(), t && f(i, { select: !0 })) : s.shiftKey && r === i && (s.preventDefault(), t && f(c, { select: !0 })) : r === m && s.preventDefault();
66
+ }
67
+ },
68
+ [t, u, a.paused]
69
+ );
70
+ return /* @__PURE__ */ _(M.div, { tabIndex: -1, ...g, ref: A, onKeyDown: P });
70
71
  });
71
- Y.displayName = X;
72
- function q(r, e = globalThis == null ? void 0 : globalThis.document) {
73
- const i = w(r), o = n.useRef(!1), t = n.useRef(() => {
72
+ k.displayName = K;
73
+ function w(e, { select: n = !1 } = {}) {
74
+ const t = document.activeElement;
75
+ for (const u of e)
76
+ if (f(u, { select: n }), document.activeElement !== t) return;
77
+ }
78
+ function x(e) {
79
+ const n = I(e), t = O(n, e), u = O(n.reverse(), e);
80
+ return [t, u];
81
+ }
82
+ function I(e) {
83
+ const n = [], t = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
84
+ acceptNode: (u) => {
85
+ const p = u.tagName === "INPUT" && u.type === "hidden";
86
+ return u.disabled || u.hidden || p ? NodeFilter.FILTER_SKIP : u.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
87
+ }
74
88
  });
75
- return n.useEffect(() => {
76
- const a = (d) => {
77
- if (d.target && !o.current) {
78
- let v = function() {
79
- x(
80
- H,
81
- i,
82
- c,
83
- { discrete: !0 }
84
- );
85
- };
86
- const c = { originalEvent: d };
87
- d.pointerType === "touch" ? (e.removeEventListener("click", t.current), t.current = v, e.addEventListener("click", t.current, { once: !0 })) : v();
88
- } else
89
- e.removeEventListener("click", t.current);
90
- o.current = !1;
91
- }, l = window.setTimeout(() => {
92
- e.addEventListener("pointerdown", a);
93
- }, 0);
94
- return () => {
95
- window.clearTimeout(l), e.removeEventListener("pointerdown", a), e.removeEventListener("click", t.current);
96
- };
97
- }, [e, i]), {
98
- // ensures we check React component tree (not just DOM tree)
99
- onPointerDownCapture: () => o.current = !0
100
- };
89
+ for (; t.nextNode(); ) n.push(t.currentNode);
90
+ return n;
91
+ }
92
+ function O(e, n) {
93
+ for (const t of e)
94
+ if (!D(t, { upTo: n })) return t;
95
+ }
96
+ function D(e, { upTo: n }) {
97
+ if (getComputedStyle(e).visibility === "hidden") return !0;
98
+ for (; e; ) {
99
+ if (n !== void 0 && e === n) return !1;
100
+ if (getComputedStyle(e).display === "none") return !0;
101
+ e = e.parentElement;
102
+ }
103
+ return !1;
104
+ }
105
+ function H(e) {
106
+ return e instanceof HTMLInputElement && "select" in e;
107
+ }
108
+ function f(e, { select: n = !1 } = {}) {
109
+ if (e && e.focus) {
110
+ const t = document.activeElement;
111
+ e.focus({ preventScroll: !0 }), e !== t && H(e) && n && e.select();
112
+ }
101
113
  }
102
- function G(r, e = globalThis == null ? void 0 : globalThis.document) {
103
- const i = w(r), o = n.useRef(!1);
104
- return n.useEffect(() => {
105
- const t = (a) => {
106
- a.target && !o.current && x(M, i, { originalEvent: a }, {
107
- discrete: !1
108
- });
109
- };
110
- return e.addEventListener("focusin", t), () => e.removeEventListener("focusin", t);
111
- }, [e, i]), {
112
- onFocusCapture: () => o.current = !0,
113
- onBlurCapture: () => o.current = !1
114
+ var S = V();
115
+ function V() {
116
+ let e = [];
117
+ return {
118
+ add(n) {
119
+ const t = e[0];
120
+ n !== t && (t == null || t.pause()), e = C(e, n), e.unshift(n);
121
+ },
122
+ remove(n) {
123
+ var t;
124
+ e = C(e, n), (t = e[0]) == null || t.resume();
125
+ }
114
126
  };
115
127
  }
116
- function O() {
117
- const r = new CustomEvent(y);
118
- document.dispatchEvent(r);
128
+ function C(e, n) {
129
+ const t = [...e], u = t.indexOf(n);
130
+ return u !== -1 && t.splice(u, 1), t;
119
131
  }
120
- function x(r, e, i, { discrete: o }) {
121
- const t = i.originalEvent.target, a = new CustomEvent(r, { bubbles: !1, cancelable: !0, detail: i });
122
- e && t.addEventListener(r, e, { once: !0 }), o ? k(t, a) : t.dispatchEvent(a);
132
+ function W(e) {
133
+ return e.filter((n) => n.tagName !== "A");
123
134
  }
124
135
  export {
125
- j as DismissableLayer,
126
- Y as DismissableLayerBranch
136
+ k as FocusScope
127
137
  };