@plyaz/ui 0.4.2 → 0.4.3

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 (74) hide show
  1. package/dist/types/components/Button/Button.d.ts.map +1 -1
  2. package/dist/types/components/Form/LoginForm.d.ts.map +1 -1
  3. package/dist/types/components/Form/SignupForm.d.ts.map +1 -1
  4. package/dist/types/components/Select/Select.d.ts.map +1 -1
  5. package/dist/ui.cjs19.js +1 -1
  6. package/dist/ui.cjs20.js +1 -1
  7. package/dist/ui.cjs21.js +1 -1
  8. package/dist/ui.cjs30.js +1 -1
  9. package/dist/ui.cjs31.js +1 -1
  10. package/dist/ui.cjs32.js +1 -1
  11. package/dist/ui.cjs33.js +1 -1
  12. package/dist/ui.cjs34.js +1 -1
  13. package/dist/ui.cjs35.js +1 -1
  14. package/dist/ui.cjs36.js +1 -1
  15. package/dist/ui.cjs37.js +1 -1
  16. package/dist/ui.cjs38.js +1 -1
  17. package/dist/ui.cjs39.js +1 -1
  18. package/dist/ui.cjs40.js +1 -1
  19. package/dist/ui.cjs41.js +1 -1
  20. package/dist/ui.cjs42.js +1 -1
  21. package/dist/ui.cjs43.js +1 -1
  22. package/dist/ui.cjs44.js +1 -1
  23. package/dist/ui.cjs45.js +1 -1
  24. package/dist/ui.cjs46.js +1 -1
  25. package/dist/ui.cjs47.js +1 -1
  26. package/dist/ui.cjs48.js +1 -1
  27. package/dist/ui.cjs49.js +1 -1
  28. package/dist/ui.cjs50.js +1 -1
  29. package/dist/ui.cjs53.js +1 -1
  30. package/dist/ui.cjs55.js +1 -1
  31. package/dist/ui.cjs56.js +1 -1
  32. package/dist/ui.cjs66.js +1 -1
  33. package/dist/ui.cjs68.js +1 -1
  34. package/dist/ui.cjs73.js +1 -38
  35. package/dist/ui.cjs74.js +38 -1
  36. package/dist/ui.cjs75.js +1 -1
  37. package/dist/ui.cjs76.js +1 -1
  38. package/dist/ui.cjs77.js +1 -1
  39. package/dist/ui.es15.js +8 -2
  40. package/dist/ui.es19.js +1 -1
  41. package/dist/ui.es20.js +1 -1
  42. package/dist/ui.es21.js +20 -20
  43. package/dist/ui.es30.js +3 -26
  44. package/dist/ui.es31.js +5 -2727
  45. package/dist/ui.es32.js +45 -3
  46. package/dist/ui.es33.js +25 -5
  47. package/dist/ui.es34.js +50 -43
  48. package/dist/ui.es35.js +7 -52
  49. package/dist/ui.es36.js +124 -7
  50. package/dist/ui.es37.js +12 -122
  51. package/dist/ui.es38.js +134 -14
  52. package/dist/ui.es39.js +10 -134
  53. package/dist/ui.es40.js +217 -10
  54. package/dist/ui.es41.js +13 -217
  55. package/dist/ui.es42.js +34 -14
  56. package/dist/ui.es43.js +10 -33
  57. package/dist/ui.es44.js +51 -10
  58. package/dist/ui.es45.js +4 -52
  59. package/dist/ui.es46.js +6 -4
  60. package/dist/ui.es47.js +28 -6
  61. package/dist/ui.es48.js +50 -28
  62. package/dist/ui.es49.js +9 -50
  63. package/dist/ui.es50.js +2729 -9
  64. package/dist/ui.es53.js +1 -1
  65. package/dist/ui.es55.js +1 -1
  66. package/dist/ui.es56.js +1 -1
  67. package/dist/ui.es66.js +1 -1
  68. package/dist/ui.es68.js +4 -4
  69. package/dist/ui.es73.js +65 -69
  70. package/dist/ui.es74.js +68 -8
  71. package/dist/ui.es75.js +9 -14
  72. package/dist/ui.es76.js +14 -66
  73. package/dist/ui.es77.js +65 -64
  74. package/package.json +1 -1
package/dist/ui.es32.js CHANGED
@@ -1,6 +1,48 @@
1
- function m(t, [a, n]) {
2
- return Math.min(n, Math.max(a, t));
1
+ import r from "react";
2
+ import { createContextScope as y } from "./ui.es34.js";
3
+ import { useComposedRefs as S } from "./ui.es33.js";
4
+ import { createSlot as M } from "./ui.es19.js";
5
+ import { j as d } from "./ui.es16.js";
6
+ function D(s) {
7
+ const m = s + "CollectionProvider", [A, E] = y(m), [N, f] = A(
8
+ m,
9
+ { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
10
+ ), p = (c) => {
11
+ const { scope: e, children: l } = c, o = r.useRef(null), t = r.useRef(/* @__PURE__ */ new Map()).current;
12
+ return /* @__PURE__ */ d.jsx(N, { scope: e, itemMap: t, collectionRef: o, children: l });
13
+ };
14
+ p.displayName = m;
15
+ const a = s + "CollectionSlot", _ = M(a), C = r.forwardRef(
16
+ (c, e) => {
17
+ const { scope: l, children: o } = c, t = f(a, l), n = S(e, t.collectionRef);
18
+ return /* @__PURE__ */ d.jsx(_, { ref: n, children: o });
19
+ }
20
+ );
21
+ C.displayName = a;
22
+ const u = s + "CollectionItemSlot", R = "data-radix-collection-item", T = M(u), x = r.forwardRef(
23
+ (c, e) => {
24
+ const { scope: l, children: o, ...t } = c, n = r.useRef(null), I = S(e, n), i = f(u, l);
25
+ return r.useEffect(() => (i.itemMap.set(n, { ref: n, ...t }), () => void i.itemMap.delete(n))), /* @__PURE__ */ d.jsx(T, { [R]: "", ref: I, children: o });
26
+ }
27
+ );
28
+ x.displayName = u;
29
+ function O(c) {
30
+ const e = f(s + "CollectionConsumer", c);
31
+ return r.useCallback(() => {
32
+ const o = e.collectionRef.current;
33
+ if (!o) return [];
34
+ const t = Array.from(o.querySelectorAll(`[${R}]`));
35
+ return Array.from(e.itemMap.values()).sort(
36
+ (i, v) => t.indexOf(i.ref.current) - t.indexOf(v.ref.current)
37
+ );
38
+ }, [e.collectionRef, e.itemMap]);
39
+ }
40
+ return [
41
+ { Provider: p, Slot: C, ItemSlot: x },
42
+ O,
43
+ E
44
+ ];
3
45
  }
4
46
  export {
5
- m as clamp
47
+ D as createCollection
6
48
  };
package/dist/ui.es33.js CHANGED
@@ -1,9 +1,29 @@
1
- function h(f, c, { checkForDefaultPrevented: p = !0 } = {}) {
2
- return function(s) {
3
- if (f == null || f(s), p === !1 || !s.defaultPrevented)
4
- return c == null ? void 0 : c(s);
1
+ import * as f from "react";
2
+ function l(n, o) {
3
+ if (typeof n == "function")
4
+ return n(o);
5
+ n != null && (n.current = o);
6
+ }
7
+ function i(...n) {
8
+ return (o) => {
9
+ let u = !1;
10
+ const c = n.map((t) => {
11
+ const e = l(t, o);
12
+ return !u && typeof e == "function" && (u = !0), e;
13
+ });
14
+ if (u)
15
+ return () => {
16
+ for (let t = 0; t < c.length; t++) {
17
+ const e = c[t];
18
+ typeof e == "function" ? e() : l(n[t], null);
19
+ }
20
+ };
5
21
  };
6
22
  }
23
+ function s(...n) {
24
+ return f.useCallback(i(...n), n);
25
+ }
7
26
  export {
8
- h as composeEventHandlers
27
+ i as composeRefs,
28
+ s as useComposedRefs
9
29
  };
package/dist/ui.es34.js CHANGED
@@ -1,48 +1,55 @@
1
- import r from "react";
2
- import { createContextScope as y } from "./ui.es35.js";
3
- import { useComposedRefs as S } from "./ui.es30.js";
4
- import { createSlot as M } from "./ui.es19.js";
5
- import { j as d } from "./ui.es16.js";
6
- function D(s) {
7
- const m = s + "CollectionProvider", [A, E] = y(m), [N, f] = A(
8
- m,
9
- { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
10
- ), p = (c) => {
11
- const { scope: e, children: l } = c, o = r.useRef(null), t = r.useRef(/* @__PURE__ */ new Map()).current;
12
- return /* @__PURE__ */ d.jsx(N, { scope: e, itemMap: t, collectionRef: o, children: l });
13
- };
14
- p.displayName = m;
15
- const a = s + "CollectionSlot", _ = M(a), C = r.forwardRef(
16
- (c, e) => {
17
- const { scope: l, children: o } = c, t = f(a, l), n = S(e, t.collectionRef);
18
- return /* @__PURE__ */ d.jsx(_, { ref: n, children: o });
19
- }
20
- );
21
- C.displayName = a;
22
- const u = s + "CollectionItemSlot", R = "data-radix-collection-item", T = M(u), x = r.forwardRef(
23
- (c, e) => {
24
- const { scope: l, children: o, ...t } = c, n = r.useRef(null), I = S(e, n), i = f(u, l);
25
- return r.useEffect(() => (i.itemMap.set(n, { ref: n, ...t }), () => void i.itemMap.delete(n))), /* @__PURE__ */ d.jsx(T, { [R]: "", ref: I, children: o });
1
+ import * as i from "react";
2
+ import { j as h } from "./ui.es16.js";
3
+ function $(t, x = []) {
4
+ let o = [];
5
+ function C(u, e) {
6
+ const n = i.createContext(e), r = o.length;
7
+ o = [...o, e];
8
+ const m = (a) => {
9
+ var v;
10
+ const { scope: c, children: S, ...p } = a, f = ((v = c == null ? void 0 : c[t]) == null ? void 0 : v[r]) || n, _ = i.useMemo(() => p, Object.values(p));
11
+ return /* @__PURE__ */ h.jsx(f.Provider, { value: _, children: S });
12
+ };
13
+ m.displayName = u + "Provider";
14
+ function d(a, c) {
15
+ var f;
16
+ const S = ((f = c == null ? void 0 : c[t]) == null ? void 0 : f[r]) || n, p = i.useContext(S);
17
+ if (p) return p;
18
+ if (e !== void 0) return e;
19
+ throw new Error(`\`${a}\` must be used within \`${u}\``);
26
20
  }
27
- );
28
- x.displayName = u;
29
- function O(c) {
30
- const e = f(s + "CollectionConsumer", c);
31
- return r.useCallback(() => {
32
- const o = e.collectionRef.current;
33
- if (!o) return [];
34
- const t = Array.from(o.querySelectorAll(`[${R}]`));
35
- return Array.from(e.itemMap.values()).sort(
36
- (i, v) => t.indexOf(i.ref.current) - t.indexOf(v.ref.current)
37
- );
38
- }, [e.collectionRef, e.itemMap]);
21
+ return [m, d];
39
22
  }
40
- return [
41
- { Provider: p, Slot: C, ItemSlot: x },
42
- O,
43
- E
44
- ];
23
+ const s = () => {
24
+ const u = o.map((e) => i.createContext(e));
25
+ return function(n) {
26
+ const r = (n == null ? void 0 : n[t]) || u;
27
+ return i.useMemo(
28
+ () => ({ [`__scope${t}`]: { ...n, [t]: r } }),
29
+ [n, r]
30
+ );
31
+ };
32
+ };
33
+ return s.scopeName = t, [C, l(s, ...x)];
34
+ }
35
+ function l(...t) {
36
+ const x = t[0];
37
+ if (t.length === 1) return x;
38
+ const o = () => {
39
+ const C = t.map((s) => ({
40
+ useScope: s(),
41
+ scopeName: s.scopeName
42
+ }));
43
+ return function(u) {
44
+ const e = C.reduce((n, { useScope: r, scopeName: m }) => {
45
+ const a = r(u)[`__scope${m}`];
46
+ return { ...n, ...a };
47
+ }, {});
48
+ return i.useMemo(() => ({ [`__scope${x.scopeName}`]: e }), [e]);
49
+ };
50
+ };
51
+ return o.scopeName = x.scopeName, o;
45
52
  }
46
53
  export {
47
- D as createCollection
54
+ $ as createContextScope
48
55
  };
package/dist/ui.es35.js CHANGED
@@ -1,55 +1,10 @@
1
- import * as i from "react";
2
- import { j as h } from "./ui.es16.js";
3
- function $(t, x = []) {
4
- let o = [];
5
- function C(u, e) {
6
- const n = i.createContext(e), r = o.length;
7
- o = [...o, e];
8
- const m = (a) => {
9
- var v;
10
- const { scope: c, children: S, ...p } = a, f = ((v = c == null ? void 0 : c[t]) == null ? void 0 : v[r]) || n, _ = i.useMemo(() => p, Object.values(p));
11
- return /* @__PURE__ */ h.jsx(f.Provider, { value: _, children: S });
12
- };
13
- m.displayName = u + "Provider";
14
- function d(a, c) {
15
- var f;
16
- const S = ((f = c == null ? void 0 : c[t]) == null ? void 0 : f[r]) || n, p = i.useContext(S);
17
- if (p) return p;
18
- if (e !== void 0) return e;
19
- throw new Error(`\`${a}\` must be used within \`${u}\``);
20
- }
21
- return [m, d];
22
- }
23
- const s = () => {
24
- const u = o.map((e) => i.createContext(e));
25
- return function(n) {
26
- const r = (n == null ? void 0 : n[t]) || u;
27
- return i.useMemo(
28
- () => ({ [`__scope${t}`]: { ...n, [t]: r } }),
29
- [n, r]
30
- );
31
- };
32
- };
33
- return s.scopeName = t, [C, l(s, ...x)];
34
- }
35
- function l(...t) {
36
- const x = t[0];
37
- if (t.length === 1) return x;
38
- const o = () => {
39
- const C = t.map((s) => ({
40
- useScope: s(),
41
- scopeName: s.scopeName
42
- }));
43
- return function(u) {
44
- const e = C.reduce((n, { useScope: r, scopeName: m }) => {
45
- const a = r(u)[`__scope${m}`];
46
- return { ...n, ...a };
47
- }, {});
48
- return i.useMemo(() => ({ [`__scope${x.scopeName}`]: e }), [e]);
49
- };
50
- };
51
- return o.scopeName = x.scopeName, o;
1
+ import * as t from "react";
2
+ import "./ui.es16.js";
3
+ var r = t.createContext(void 0);
4
+ function n(o) {
5
+ const e = t.useContext(r);
6
+ return o || e || "ltr";
52
7
  }
53
8
  export {
54
- $ as createContextScope
9
+ n as useDirection
55
10
  };
package/dist/ui.es36.js CHANGED
@@ -1,10 +1,127 @@
1
- import * as t from "react";
2
- import "./ui.es16.js";
3
- var r = t.createContext(void 0);
4
- function n(o) {
5
- const e = t.useContext(r);
6
- return o || e || "ltr";
1
+ import * as n from "react";
2
+ import { composeEventHandlers as m } from "./ui.es31.js";
3
+ import { Primitive as R, dispatchDiscreteCustomEvent as k } from "./ui.es42.js";
4
+ import { useComposedRefs as g } from "./ui.es33.js";
5
+ import { useCallbackRef as w } from "./ui.es43.js";
6
+ import { useEscapeKeydown as U } from "./ui.es53.js";
7
+ import { j as x } from "./ui.es16.js";
8
+ var j = "DismissableLayer", p = "dismissableLayer.update", z = "dismissableLayer.pointerDownOutside", H = "dismissableLayer.focusOutside", L, T = n.createContext({
9
+ layers: /* @__PURE__ */ new Set(),
10
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
11
+ branches: /* @__PURE__ */ new Set()
12
+ }), M = 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(T), [u, S] = n.useState(null), f = (u == null ? void 0 : u.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, F] = n.useState({}), W = g(e, (s) => S(s)), y = Array.from(c.layers), [A] = [...c.layersWithOutsidePointerEventsDisabled].slice(-1), N = y.indexOf(A), b = u ? y.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(p, s), () => document.removeEventListener(p, s);
41
+ }, []), /* @__PURE__ */ x.jsx(
42
+ R.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
+ M.displayName = j;
61
+ var X = "DismissableLayerBranch", Y = n.forwardRef((r, e) => {
62
+ const i = n.useContext(T), o = n.useRef(null), t = g(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__ */ x.jsx(R.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(() => {
74
+ });
75
+ return n.useEffect(() => {
76
+ const a = (d) => {
77
+ if (d.target && !o.current) {
78
+ let v = function() {
79
+ B(
80
+ z,
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 && B(H, 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(p);
118
+ document.dispatchEvent(r);
119
+ }
120
+ function B(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);
7
123
  }
8
124
  export {
9
- n as useDirection
125
+ M as DismissableLayer,
126
+ Y as DismissableLayerBranch
10
127
  };
package/dist/ui.es37.js CHANGED
@@ -1,127 +1,17 @@
1
- import * as n from "react";
2
- import { composeEventHandlers as m } from "./ui.es33.js";
3
- import { Primitive as R, dispatchDiscreteCustomEvent as k } from "./ui.es43.js";
4
- import { useComposedRefs as g } from "./ui.es30.js";
5
- import { useCallbackRef as w } from "./ui.es44.js";
6
- import { useEscapeKeydown as U } from "./ui.es53.js";
7
- import { j as x } from "./ui.es16.js";
8
- var j = "DismissableLayer", p = "dismissableLayer.update", z = "dismissableLayer.pointerDownOutside", H = "dismissableLayer.focusOutside", L, T = n.createContext({
9
- layers: /* @__PURE__ */ new Set(),
10
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
11
- branches: /* @__PURE__ */ new Set()
12
- }), M = 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(T), [u, S] = n.useState(null), f = (u == null ? void 0 : u.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, F] = n.useState({}), W = g(e, (s) => S(s)), y = Array.from(c.layers), [A] = [...c.layersWithOutsidePointerEventsDisabled].slice(-1), N = y.indexOf(A), b = u ? y.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(p, s), () => document.removeEventListener(p, s);
41
- }, []), /* @__PURE__ */ x.jsx(
42
- R.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
- M.displayName = j;
61
- var X = "DismissableLayerBranch", Y = n.forwardRef((r, e) => {
62
- const i = n.useContext(T), o = n.useRef(null), t = g(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__ */ x.jsx(R.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(() => {
74
- });
75
- return n.useEffect(() => {
76
- const a = (d) => {
77
- if (d.target && !o.current) {
78
- let v = function() {
79
- B(
80
- z,
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);
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--;
96
8
  };
97
- }, [e, i]), {
98
- // ensures we check React component tree (not just DOM tree)
99
- onPointerDownCapture: () => o.current = !0
100
- };
9
+ }, []);
101
10
  }
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 && B(H, 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(p);
118
- document.dispatchEvent(r);
119
- }
120
- function B(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);
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;
123
14
  }
124
15
  export {
125
- M as DismissableLayer,
126
- Y as DismissableLayerBranch
16
+ a as useFocusGuards
127
17
  };