@drjoshcsimmons/scl 0.1.1 → 0.1.2

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 +218 -8
  2. package/dist/index101.js +648 -48
  3. package/dist/index102.js +167 -205
  4. package/dist/index104.js +1 -1
  5. package/dist/index106.js +12 -21
  6. package/dist/index107.js +15 -3
  7. package/dist/index108.js +3 -32
  8. package/dist/index109.js +32 -12
  9. package/dist/index11.js +2 -2
  10. package/dist/index110.js +18 -12
  11. package/dist/index112.js +1 -1
  12. package/dist/index115.js +1 -1
  13. package/dist/index116.js +1 -1
  14. package/dist/index117.js +25 -2
  15. package/dist/index118.js +29 -2
  16. package/dist/index119.js +5 -25
  17. package/dist/index12.js +1 -1
  18. package/dist/index120.js +2 -29
  19. package/dist/index121.js +2 -5
  20. package/dist/index125.js +1 -1
  21. package/dist/index126.js +1 -1
  22. package/dist/index13.js +2 -2
  23. package/dist/index130.js +1 -1
  24. package/dist/index14.js +2 -2
  25. package/dist/index15.js +2 -2
  26. package/dist/index17.js +4 -4
  27. package/dist/index18.js +2 -2
  28. package/dist/index20.js +2 -2
  29. package/dist/index21.js +1 -1
  30. package/dist/index23.js +2 -2
  31. package/dist/index24.js +1 -1
  32. package/dist/index25.js +4 -4
  33. package/dist/index26.js +1 -1
  34. package/dist/index27.js +3 -3
  35. package/dist/index29.js +1 -1
  36. package/dist/index31.js +1 -1
  37. package/dist/index33.js +1 -1
  38. package/dist/index36.js +2 -2
  39. package/dist/index37.js +1 -1
  40. package/dist/index4.js +2 -2
  41. package/dist/index45.js +237 -33
  42. package/dist/index46.js +11 -125
  43. package/dist/index47.js +33 -237
  44. package/dist/index48.js +118 -11
  45. package/dist/index49.js +70 -57
  46. package/dist/index5.js +1 -1
  47. package/dist/index50.js +298 -237
  48. package/dist/index51.js +6 -3
  49. package/dist/index52.js +249 -62
  50. package/dist/index53.js +12 -236
  51. package/dist/index54.js +60 -11
  52. package/dist/index55.js +242 -298
  53. package/dist/index56.js +249 -12
  54. package/dist/index57.js +9 -225
  55. package/dist/index58.js +125 -11
  56. package/dist/index59.js +12 -31
  57. package/dist/index6.js +1 -1
  58. package/dist/index60.js +16 -258
  59. package/dist/index61.js +225 -12
  60. package/dist/index62.js +11 -118
  61. package/dist/index63.js +4 -5
  62. package/dist/index64.js +238 -19
  63. package/dist/index65.js +234 -16
  64. package/dist/index66.js +509 -220
  65. package/dist/index67.js +143 -112
  66. package/dist/index68.js +112 -143
  67. package/dist/index69.js +323 -241
  68. package/dist/index7.js +1 -1
  69. package/dist/index70.js +2 -2
  70. package/dist/index71.js +392 -487
  71. package/dist/index72.js +20 -433
  72. package/dist/index73.js +823 -299
  73. package/dist/index74.js +9 -860
  74. package/dist/index75.js +31 -9
  75. package/dist/index76.js +5 -66
  76. package/dist/index77.js +64 -23
  77. package/dist/index78.js +51 -6
  78. package/dist/index79.js +4 -54
  79. package/dist/index8.js +1 -1
  80. package/dist/index80.js +25 -44
  81. package/dist/index81.js +33 -51
  82. package/dist/index82.js +67 -32
  83. package/dist/index83.js +1 -1
  84. package/dist/index84.js +54 -7
  85. package/dist/index85.js +10 -5
  86. package/dist/index86.js +30 -25
  87. package/dist/index87.js +11 -67
  88. package/dist/index88.js +43 -52
  89. package/dist/index89.js +7 -10
  90. package/dist/index9.js +2 -2
  91. package/dist/index90.js +15 -4
  92. package/dist/index91.js +124 -29
  93. package/dist/index92.js +131 -9
  94. package/dist/index93.js +14 -181
  95. package/dist/index94.js +13 -13
  96. package/dist/index95.js +8 -649
  97. package/dist/index96.js +47 -122
  98. package/dist/index97.js +47 -128
  99. package/dist/index98.js +6 -14
  100. package/dist/index99.js +24 -14
  101. package/package.json +3 -2
package/dist/index92.js CHANGED
@@ -1,15 +1,137 @@
1
- import { s as r } from "./index105.js";
2
- function s() {
3
- return r.useSyncExternalStore(
4
- e,
5
- () => !0,
6
- () => !1
1
+ import * as d from "react";
2
+ import { useComposedRefs as R } from "./index80.js";
3
+ import { Primitive as M } from "./index81.js";
4
+ import { useCallbackRef as y } from "./index85.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));
50
+ }
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);
56
+ };
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]
7
69
  );
70
+ return /* @__PURE__ */ _(M.div, { tabIndex: -1, ...g, ref: A, onKeyDown: P });
71
+ });
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;
8
77
  }
9
- function e() {
10
- return () => {
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
+ }
88
+ });
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
+ }
113
+ }
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
+ }
11
126
  };
12
127
  }
128
+ function C(e, n) {
129
+ const t = [...e], u = t.indexOf(n);
130
+ return u !== -1 && t.splice(u, 1), t;
131
+ }
132
+ function W(e) {
133
+ return e.filter((n) => n.tagName !== "A");
134
+ }
13
135
  export {
14
- s as useIsHydrated
136
+ k as FocusScope
15
137
  };
package/dist/index93.js CHANGED
@@ -1,183 +1,16 @@
1
- import * as c from "react";
2
- import { composeEventHandlers as p } from "./index78.js";
3
- import { createCollection as V } from "./index80.js";
4
- import { useComposedRefs as j } from "./index77.js";
5
- import { createContextScope as z } from "./index76.js";
6
- import { useId as q } from "./index83.js";
7
- import { Primitive as G } from "./index82.js";
8
- import { useCallbackRef as J } from "./index89.js";
9
- import { useControllableState as Q } from "./index81.js";
10
- import { useDirection as W } from "./index84.js";
11
- import { jsx as d } from "react/jsx-runtime";
12
- var y = "rovingFocusGroup.onEntryFocus", X = { bubbles: !1, cancelable: !0 }, I = "RovingFocusGroup", [D, N, Z] = V(I), [$, Fe] = z(
13
- I,
14
- [Z]
15
- ), [ee, oe] = $(I), O = c.forwardRef(
16
- (e, r) => /* @__PURE__ */ d(D.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ d(D.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ d(te, { ...e, ref: r }) }) })
17
- );
18
- O.displayName = I;
19
- var te = c.forwardRef((e, r) => {
20
- const {
21
- __scopeRovingFocusGroup: s,
22
- orientation: o,
23
- loop: T = !1,
24
- dir: w,
25
- currentTabStopId: v,
26
- defaultCurrentTabStopId: C,
27
- onCurrentTabStopIdChange: S,
28
- onEntryFocus: m,
29
- preventScrollOnEntryFocus: u = !1,
30
- ...b
31
- } = e, F = c.useRef(null), g = j(r, F), R = W(w), [E, t] = Q({
32
- prop: v,
33
- defaultProp: C ?? null,
34
- onChange: S,
35
- caller: I
36
- }), [i, h] = c.useState(!1), a = J(m), l = N(s), A = c.useRef(!1), [L, P] = c.useState(0);
37
- return c.useEffect(() => {
38
- const n = F.current;
39
- if (n)
40
- return n.addEventListener(y, a), () => n.removeEventListener(y, a);
41
- }, [a]), /* @__PURE__ */ d(
42
- ee,
43
- {
44
- scope: s,
45
- orientation: o,
46
- dir: R,
47
- loop: T,
48
- currentTabStopId: E,
49
- onItemFocus: c.useCallback(
50
- (n) => t(n),
51
- [t]
52
- ),
53
- onItemShiftTab: c.useCallback(() => h(!0), []),
54
- onFocusableItemAdd: c.useCallback(
55
- () => P((n) => n + 1),
56
- []
57
- ),
58
- onFocusableItemRemove: c.useCallback(
59
- () => P((n) => n - 1),
60
- []
61
- ),
62
- children: /* @__PURE__ */ d(
63
- G.div,
64
- {
65
- tabIndex: i || L === 0 ? -1 : 0,
66
- "data-orientation": o,
67
- ...b,
68
- ref: g,
69
- style: { outline: "none", ...e.style },
70
- onMouseDown: p(e.onMouseDown, () => {
71
- A.current = !0;
72
- }),
73
- onFocus: p(e.onFocus, (n) => {
74
- const U = !A.current;
75
- if (n.target === n.currentTarget && U && !i) {
76
- const x = new CustomEvent(y, X);
77
- if (n.currentTarget.dispatchEvent(x), !x.defaultPrevented) {
78
- const _ = l().filter((f) => f.focusable), B = _.find((f) => f.active), Y = _.find((f) => f.id === E), H = [B, Y, ..._].filter(
79
- Boolean
80
- ).map((f) => f.ref.current);
81
- k(H, u);
82
- }
83
- }
84
- A.current = !1;
85
- }),
86
- onBlur: p(e.onBlur, () => h(!1))
87
- }
88
- )
89
- }
90
- );
91
- }), K = "RovingFocusGroupItem", M = c.forwardRef(
92
- (e, r) => {
93
- const {
94
- __scopeRovingFocusGroup: s,
95
- focusable: o = !0,
96
- active: T = !1,
97
- tabStopId: w,
98
- children: v,
99
- ...C
100
- } = e, S = q(), m = w || S, u = oe(K, s), b = u.currentTabStopId === m, F = N(s), { onFocusableItemAdd: g, onFocusableItemRemove: R, currentTabStopId: E } = u;
101
- return c.useEffect(() => {
102
- if (o)
103
- return g(), () => R();
104
- }, [o, g, R]), /* @__PURE__ */ d(
105
- D.ItemSlot,
106
- {
107
- scope: s,
108
- id: m,
109
- focusable: o,
110
- active: T,
111
- children: /* @__PURE__ */ d(
112
- G.span,
113
- {
114
- tabIndex: b ? 0 : -1,
115
- "data-orientation": u.orientation,
116
- ...C,
117
- ref: r,
118
- onMouseDown: p(e.onMouseDown, (t) => {
119
- o ? u.onItemFocus(m) : t.preventDefault();
120
- }),
121
- onFocus: p(e.onFocus, () => u.onItemFocus(m)),
122
- onKeyDown: p(e.onKeyDown, (t) => {
123
- if (t.key === "Tab" && t.shiftKey) {
124
- u.onItemShiftTab();
125
- return;
126
- }
127
- if (t.target !== t.currentTarget) return;
128
- const i = ce(t, u.orientation, u.dir);
129
- if (i !== void 0) {
130
- if (t.metaKey || t.ctrlKey || t.altKey || t.shiftKey) return;
131
- t.preventDefault();
132
- let a = F().filter((l) => l.focusable).map((l) => l.ref.current);
133
- if (i === "last") a.reverse();
134
- else if (i === "prev" || i === "next") {
135
- i === "prev" && a.reverse();
136
- const l = a.indexOf(t.currentTarget);
137
- a = u.loop ? se(a, l + 1) : a.slice(l + 1);
138
- }
139
- setTimeout(() => k(a));
140
- }
141
- }),
142
- children: typeof v == "function" ? v({ isCurrentTabStop: b, hasTabStop: E != null }) : v
143
- }
144
- )
145
- }
146
- );
147
- }
148
- );
149
- M.displayName = K;
150
- var re = {
151
- ArrowLeft: "prev",
152
- ArrowUp: "prev",
153
- ArrowRight: "next",
154
- ArrowDown: "next",
155
- PageUp: "first",
156
- Home: "first",
157
- PageDown: "last",
158
- End: "last"
159
- };
160
- function ne(e, r) {
161
- return r !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
162
- }
163
- function ce(e, r, s) {
164
- const o = ne(e.key, s);
165
- if (!(r === "vertical" && ["ArrowLeft", "ArrowRight"].includes(o)) && !(r === "horizontal" && ["ArrowUp", "ArrowDown"].includes(o)))
166
- return re[o];
167
- }
168
- function k(e, r = !1) {
169
- const s = document.activeElement;
170
- for (const o of e)
171
- if (o === s || (o.focus({ preventScroll: r }), document.activeElement !== s)) return;
172
- }
173
- function se(e, r) {
174
- return e.map((s, o) => e[(r + o) % e.length]);
175
- }
176
- var ge = O, Re = M;
1
+ import * as r from "react";
2
+ import s from "react-dom";
3
+ import { Primitive as c } from "./index81.js";
4
+ import { useLayoutEffect as u } from "./index79.js";
5
+ import { jsx as l } from "react/jsx-runtime";
6
+ var p = "Portal", d = r.forwardRef((e, a) => {
7
+ var o;
8
+ const { container: f, ...i } = e, [m, n] = r.useState(!1);
9
+ u(() => n(!0), []);
10
+ const t = f || m && ((o = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : o.body);
11
+ return t ? s.createPortal(/* @__PURE__ */ l(c.div, { ...i, ref: a }), t) : null;
12
+ });
13
+ d.displayName = p;
177
14
  export {
178
- Re as Item,
179
- ge as Root,
180
- O as RovingFocusGroup,
181
- M as RovingFocusGroupItem,
182
- Fe as createRovingFocusGroupScope
15
+ d as Portal
183
16
  };
package/dist/index94.js CHANGED
@@ -1,17 +1,17 @@
1
- var m = 1, j = 0.9, k = 0.8, B = 0.17, v = 0.1, w = 0.999, D = 0.9999, G = 0.99, H = /[\\\/_+.#"@\[\(\{&]/, J = /[\\\/_+.#"@\[\(\{&]/g, K = /[\s-]/, A = /[\s-]/g;
2
- function $(t, o, e, i, n, h, u) {
3
- if (h === o.length) return n === t.length ? m : G;
4
- var s = `${n},${h}`;
5
- if (u[s] !== void 0) return u[s];
6
- for (var d = i.charAt(h), a = e.indexOf(d, n), l = 0, r, g, c, p; a >= 0; ) r = $(t, o, e, i, a + 1, h + 1, u), r > l && (a === n ? r *= m : H.test(t.charAt(a - 1)) ? (r *= k, c = t.slice(n, a - 1).match(J), c && n > 0 && (r *= Math.pow(w, c.length))) : K.test(t.charAt(a - 1)) ? (r *= j, p = t.slice(n, a - 1).match(A), p && n > 0 && (r *= Math.pow(w, p.length))) : (r *= B, n > 0 && (r *= Math.pow(w, a - n))), t.charAt(a) !== o.charAt(h) && (r *= D)), (r < v && e.charAt(a - 1) === i.charAt(h + 1) || i.charAt(h + 1) === i.charAt(h) && e.charAt(a - 1) !== i.charAt(h)) && (g = $(t, o, e, i, a + 1, h + 2, u), g * v > r && (r = g * v)), r > l && (l = r), a = e.indexOf(d, a + 1);
7
- return u[s] = l, l;
1
+ import * as r from "react";
2
+ var t = 0;
3
+ function a() {
4
+ r.useEffect(() => {
5
+ const e = document.querySelectorAll("[data-radix-focus-guard]");
6
+ return document.body.insertAdjacentElement("afterbegin", e[0] ?? n()), document.body.insertAdjacentElement("beforeend", e[1] ?? n()), t++, () => {
7
+ t === 1 && document.querySelectorAll("[data-radix-focus-guard]").forEach((o) => o.remove()), t--;
8
+ };
9
+ }, []);
8
10
  }
9
- function x(t) {
10
- return t.toLowerCase().replace(A, " ");
11
- }
12
- function M(t, o, e) {
13
- return t = e && e.length > 0 ? `${t + " " + e.join(" ")}` : t, $(t, o, x(t), x(o), 0, 0, {});
11
+ function n() {
12
+ const e = document.createElement("span");
13
+ return e.setAttribute("data-radix-focus-guard", ""), e.tabIndex = 0, e.style.outline = "none", e.style.opacity = "0", e.style.position = "fixed", e.style.pointerEvents = "none", e;
14
14
  }
15
15
  export {
16
- M as a
16
+ a as useFocusGuards
17
17
  };