@plyaz/ui 0.4.5 → 0.4.6

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 (166) hide show
  1. package/dist/types/components/index.d.ts.map +1 -1
  2. package/dist/ui.cjs.js +1 -1
  3. package/dist/ui.cjs10.js +4 -1
  4. package/dist/ui.cjs11.js +1 -1
  5. package/dist/ui.cjs12.js +1 -1
  6. package/dist/ui.cjs13.js +1 -19
  7. package/dist/ui.cjs14.js +19 -7
  8. package/dist/ui.cjs15.js +7 -53
  9. package/dist/ui.cjs16.js +53 -1
  10. package/dist/ui.cjs17.js +1 -1
  11. package/dist/ui.cjs18.js +1 -31
  12. package/dist/ui.cjs19.js +31 -1
  13. package/dist/ui.cjs20.js +1 -1
  14. package/dist/ui.cjs21.js +1 -1
  15. package/dist/ui.cjs22.js +1 -6
  16. package/dist/ui.cjs23.js +2 -2
  17. package/dist/ui.cjs24.js +2 -2
  18. package/dist/ui.cjs25.js +6 -1
  19. package/dist/ui.cjs26.js +1 -1
  20. package/dist/ui.cjs27.js +1 -9
  21. package/dist/ui.cjs28.js +3 -8
  22. package/dist/ui.cjs29.js +14 -1
  23. package/dist/ui.cjs3.js +1 -5
  24. package/dist/ui.cjs30.js +1 -1
  25. package/dist/ui.cjs31.js +1 -1
  26. package/dist/ui.cjs32.js +1 -1
  27. package/dist/ui.cjs33.js +1 -1
  28. package/dist/ui.cjs34.js +1 -1
  29. package/dist/ui.cjs35.js +1 -1
  30. package/dist/ui.cjs36.js +1 -1
  31. package/dist/ui.cjs37.js +1 -1
  32. package/dist/ui.cjs38.js +1 -1
  33. package/dist/ui.cjs39.js +1 -1
  34. package/dist/ui.cjs4.js +5 -1
  35. package/dist/ui.cjs40.js +1 -1
  36. package/dist/ui.cjs41.js +1 -1
  37. package/dist/ui.cjs42.js +1 -1
  38. package/dist/ui.cjs43.js +1 -1
  39. package/dist/ui.cjs44.js +1 -1
  40. package/dist/ui.cjs45.js +1 -1
  41. package/dist/ui.cjs46.js +1 -1
  42. package/dist/ui.cjs47.js +1 -1
  43. package/dist/ui.cjs48.js +1 -1
  44. package/dist/ui.cjs49.js +1 -1
  45. package/dist/ui.cjs5.js +1 -1
  46. package/dist/ui.cjs50.js +1 -1
  47. package/dist/ui.cjs51.js +1 -1
  48. package/dist/ui.cjs53.js +1 -1
  49. package/dist/ui.cjs54.js +6 -1
  50. package/dist/ui.cjs55.js +6 -1
  51. package/dist/ui.cjs56.js +6 -1
  52. package/dist/ui.cjs57.js +6 -1
  53. package/dist/ui.cjs58.js +1 -6
  54. package/dist/ui.cjs59.js +1 -6
  55. package/dist/ui.cjs6.js +1 -1
  56. package/dist/ui.cjs60.js +1 -6
  57. package/dist/ui.cjs61.js +1 -6
  58. package/dist/ui.cjs62.js +1 -1
  59. package/dist/ui.cjs63.js +1 -1
  60. package/dist/ui.cjs64.js +1 -1
  61. package/dist/ui.cjs65.js +1 -1
  62. package/dist/ui.cjs66.js +1 -1
  63. package/dist/ui.cjs67.js +1 -1
  64. package/dist/ui.cjs68.js +1 -4
  65. package/dist/ui.cjs69.js +4 -1
  66. package/dist/ui.cjs7.js +1 -7
  67. package/dist/ui.cjs70.js +1 -1
  68. package/dist/ui.cjs71.js +1 -1
  69. package/dist/ui.cjs72.js +1 -1
  70. package/dist/ui.cjs73.js +1 -1
  71. package/dist/ui.cjs74.js +1 -1
  72. package/dist/ui.cjs75.js +1 -1
  73. package/dist/ui.cjs78.js +1 -1
  74. package/dist/ui.cjs79.js +1 -1
  75. package/dist/ui.cjs8.js +7 -1
  76. package/dist/ui.cjs80.js +1 -1
  77. package/dist/ui.cjs81.js +1 -1
  78. package/dist/ui.cjs82.js +1 -1
  79. package/dist/ui.cjs83.js +1 -1
  80. package/dist/ui.cjs84.js +1 -0
  81. package/dist/ui.cjs9.js +1 -4
  82. package/dist/ui.css +1 -0
  83. package/dist/ui.es.js +38 -37
  84. package/dist/ui.es10.js +22 -17
  85. package/dist/ui.es11.js +16 -29
  86. package/dist/ui.es12.js +26 -18
  87. package/dist/ui.es13.js +19 -34
  88. package/dist/ui.es14.js +37 -43
  89. package/dist/ui.es15.js +42 -210
  90. package/dist/ui.es16.js +212 -3
  91. package/dist/ui.es17.js +3 -15
  92. package/dist/ui.es18.js +15 -133
  93. package/dist/ui.es19.js +131 -49
  94. package/dist/ui.es20.js +50 -5
  95. package/dist/ui.es21.js +5 -860
  96. package/dist/ui.es22.js +861 -10
  97. package/dist/ui.es23.js +3 -3
  98. package/dist/ui.es24.js +3 -3
  99. package/dist/ui.es25.js +10 -8
  100. package/dist/ui.es26.js +8 -2
  101. package/dist/ui.es27.js +2 -33
  102. package/dist/ui.es28.js +23 -235
  103. package/dist/ui.es29.js +245 -33
  104. package/dist/ui.es3.js +7 -22
  105. package/dist/ui.es30.js +33 -27
  106. package/dist/ui.es31.js +22 -2724
  107. package/dist/ui.es32.js +2728 -3
  108. package/dist/ui.es33.js +3 -6
  109. package/dist/ui.es34.js +5 -44
  110. package/dist/ui.es35.js +43 -50
  111. package/dist/ui.es36.js +52 -7
  112. package/dist/ui.es37.js +7 -124
  113. package/dist/ui.es38.js +122 -12
  114. package/dist/ui.es39.js +14 -134
  115. package/dist/ui.es4.js +19 -39
  116. package/dist/ui.es40.js +134 -10
  117. package/dist/ui.es41.js +10 -217
  118. package/dist/ui.es42.js +217 -13
  119. package/dist/ui.es43.js +14 -34
  120. package/dist/ui.es44.js +33 -10
  121. package/dist/ui.es45.js +10 -51
  122. package/dist/ui.es46.js +52 -4
  123. package/dist/ui.es47.js +4 -6
  124. package/dist/ui.es48.js +6 -28
  125. package/dist/ui.es49.js +28 -50
  126. package/dist/ui.es5.js +40 -30
  127. package/dist/ui.es50.js +50 -9
  128. package/dist/ui.es51.js +9 -2
  129. package/dist/ui.es52.js +2 -2
  130. package/dist/ui.es53.js +2 -12
  131. package/dist/ui.es54.js +25 -206
  132. package/dist/ui.es55.js +22 -22
  133. package/dist/ui.es56.js +39 -25
  134. package/dist/ui.es57.js +17 -397
  135. package/dist/ui.es58.js +12 -25
  136. package/dist/ui.es59.js +205 -21
  137. package/dist/ui.es6.js +32 -23
  138. package/dist/ui.es60.js +21 -38
  139. package/dist/ui.es61.js +25 -18
  140. package/dist/ui.es62.js +395 -22
  141. package/dist/ui.es63.js +24 -28
  142. package/dist/ui.es64.js +29 -5
  143. package/dist/ui.es65.js +5 -5
  144. package/dist/ui.es66.js +5 -3
  145. package/dist/ui.es67.js +3 -24
  146. package/dist/ui.es68.js +22 -108
  147. package/dist/ui.es69.js +108 -14
  148. package/dist/ui.es7.js +24 -22
  149. package/dist/ui.es70.js +14 -523
  150. package/dist/ui.es71.js +511 -114
  151. package/dist/ui.es72.js +111 -117
  152. package/dist/ui.es73.js +130 -61
  153. package/dist/ui.es74.js +2 -2
  154. package/dist/ui.es75.js +1 -1
  155. package/dist/ui.es78.js +64 -3
  156. package/dist/ui.es79.js +3 -22
  157. package/dist/ui.es8.js +22 -19
  158. package/dist/ui.es80.js +23 -23
  159. package/dist/ui.es81.js +21 -11
  160. package/dist/ui.es82.js +11 -26
  161. package/dist/ui.es83.js +27 -4
  162. package/dist/ui.es84.js +7 -0
  163. package/dist/ui.es9.js +20 -18
  164. package/package.json +1 -1
  165. package/dist/ui.cjs2.js +0 -1
  166. package/dist/ui.es2.js +0 -9
package/dist/ui.es33.js CHANGED
@@ -1,9 +1,6 @@
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);
5
- };
1
+ function m(t, [a, n]) {
2
+ return Math.min(n, Math.max(a, t));
6
3
  }
7
4
  export {
8
- h as composeEventHandlers
5
+ m as clamp
9
6
  };
package/dist/ui.es34.js CHANGED
@@ -1,48 +1,9 @@
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 });
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);
13
5
  };
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
- ];
45
6
  }
46
7
  export {
47
- D as createCollection
8
+ h as composeEventHandlers
48
9
  };
package/dist/ui.es35.js CHANGED
@@ -1,55 +1,48 @@
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}\``);
1
+ import r from "react";
2
+ import { createContextScope as y } from "./ui.es36.js";
3
+ import { useComposedRefs as S } from "./ui.es31.js";
4
+ import { createSlot as M } from "./ui.es20.js";
5
+ import { j as d } from "./ui.es17.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 });
20
19
  }
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]
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)
30
37
  );
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;
38
+ }, [e.collectionRef, e.itemMap]);
39
+ }
40
+ return [
41
+ { Provider: p, Slot: C, ItemSlot: x },
42
+ O,
43
+ E
44
+ ];
52
45
  }
53
46
  export {
54
- $ as createContextScope
47
+ D as createCollection
55
48
  };
package/dist/ui.es36.js CHANGED
@@ -1,10 +1,55 @@
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 i from "react";
2
+ import { j as h } from "./ui.es17.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;
7
52
  }
8
53
  export {
9
- n as useDirection
54
+ $ as createContextScope
10
55
  };
package/dist/ui.es37.js CHANGED
@@ -1,127 +1,10 @@
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);
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);
1
+ import * as t from "react";
2
+ import "./ui.es17.js";
3
+ var r = t.createContext(void 0);
4
+ function n(o) {
5
+ const e = t.useContext(r);
6
+ return o || e || "ltr";
123
7
  }
124
8
  export {
125
- M as DismissableLayer,
126
- Y as DismissableLayerBranch
9
+ n as useDirection
127
10
  };
package/dist/ui.es38.js CHANGED
@@ -1,17 +1,127 @@
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--;
1
+ import * as n from "react";
2
+ import { composeEventHandlers as m } from "./ui.es34.js";
3
+ import { Primitive as R, dispatchDiscreteCustomEvent as k } from "./ui.es44.js";
4
+ import { useComposedRefs as g } from "./ui.es31.js";
5
+ import { useCallbackRef as w } from "./ui.es45.js";
6
+ import { useEscapeKeydown as U } from "./ui.es58.js";
7
+ import { j as x } from "./ui.es17.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);
8
96
  };
9
- }, []);
97
+ }, [e, i]), {
98
+ // ensures we check React component tree (not just DOM tree)
99
+ onPointerDownCapture: () => o.current = !0
100
+ };
10
101
  }
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;
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);
14
123
  }
15
124
  export {
16
- a as useFocusGuards
125
+ M as DismissableLayer,
126
+ Y as DismissableLayerBranch
17
127
  };
package/dist/ui.es39.js CHANGED
@@ -1,137 +1,17 @@
1
- import * as d from "react";
2
- import { useComposedRefs as P } from "./ui.es30.js";
3
- import { Primitive as M } from "./ui.es43.js";
4
- import { useCallbackRef as y } from "./ui.es44.js";
5
- import { j as _ } from "./ui.es16.js";
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, R] = d.useState(null), E = y(p), v = y(L), b = d.useRef(null), U = P(n, (s) => R(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(V(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 A = 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__ */ _.jsx(M.div, { tabIndex: -1, ...g, ref: U, onKeyDown: A });
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;
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
- }
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 = j();
115
- function j() {
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
- }
126
- };
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 V(e) {
133
- return e.filter((n) => n.tagName !== "A");
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
+ }, []);
10
+ }
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;
134
14
  }
135
15
  export {
136
- k as FocusScope
16
+ a as useFocusGuards
137
17
  };