@yselimcan/ui 0.0.3 → 0.0.5

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 (225) hide show
  1. package/dist/index100.js +5 -4
  2. package/dist/index101.js +7 -66
  3. package/dist/index102.js +87 -8
  4. package/dist/index103.js +11 -12
  5. package/dist/index104.js +62 -3
  6. package/dist/index105.js +38 -4
  7. package/dist/index106.js +14 -6
  8. package/dist/index107.js +32 -7
  9. package/dist/index108.js +19 -88
  10. package/dist/index109.js +4 -11
  11. package/dist/index110.js +4 -63
  12. package/dist/index111.js +4 -37
  13. package/dist/index112.js +12 -14
  14. package/dist/index113.js +18 -32
  15. package/dist/index114.js +13 -19
  16. package/dist/index115.js +295 -4
  17. package/dist/index116.js +5 -4
  18. package/dist/index117.js +39 -5
  19. package/dist/index118.js +124 -10
  20. package/dist/index119.js +21 -19
  21. package/dist/index120.js +77 -13
  22. package/dist/index121.js +59 -291
  23. package/dist/index122.js +45 -4
  24. package/dist/index123.js +14 -39
  25. package/dist/index124.js +4 -124
  26. package/dist/index125.js +29 -20
  27. package/dist/index126.js +5 -77
  28. package/dist/index127.js +25 -62
  29. package/dist/index128.js +16 -44
  30. package/dist/index129.js +21 -29
  31. package/dist/index130.js +58 -11
  32. package/dist/index131.js +16 -65
  33. package/dist/index132.js +24 -50
  34. package/dist/index133.js +39 -11
  35. package/dist/index134.js +42 -12
  36. package/dist/index135.js +20 -11
  37. package/dist/index136.js +44 -36
  38. package/dist/index137.js +51 -11
  39. package/dist/index138.js +17 -8
  40. package/dist/index139.js +11 -5
  41. package/dist/index140.js +21 -86
  42. package/dist/index141.js +35 -11
  43. package/dist/index142.js +223 -256
  44. package/dist/index143.js +279 -75
  45. package/dist/index144.js +53 -11
  46. package/dist/index145.js +13 -54
  47. package/dist/index146.js +79 -11
  48. package/dist/index147.js +3 -11
  49. package/dist/index148.js +2 -2
  50. package/dist/index149.js +23 -18
  51. package/dist/index150.js +14 -65
  52. package/dist/index151.js +63 -98
  53. package/dist/index152.js +4 -9
  54. package/dist/index153.js +103 -7
  55. package/dist/index154.js +78 -21
  56. package/dist/index155.js +259 -99
  57. package/dist/index156.js +11 -7
  58. package/dist/index157.js +10 -32
  59. package/dist/index158.js +38 -228
  60. package/dist/index159.js +4 -74
  61. package/dist/index160.js +63 -280
  62. package/dist/index161.js +10 -54
  63. package/dist/index162.js +8 -3
  64. package/dist/index163.js +5 -14
  65. package/dist/index164.js +132 -14
  66. package/dist/index165.js +51 -26
  67. package/dist/index166.js +11 -7
  68. package/dist/index167.js +116 -21
  69. package/dist/index168.js +12 -25
  70. package/dist/index169.js +8 -160
  71. package/dist/index17.js +4 -4
  72. package/dist/index170.js +12 -113
  73. package/dist/index171.js +22 -75
  74. package/dist/index172.js +11 -64
  75. package/dist/index173.js +65 -68
  76. package/dist/index174.js +13 -14
  77. package/dist/index175.js +13 -6
  78. package/dist/index176.js +11 -16
  79. package/dist/index177.js +11 -21
  80. package/dist/index178.js +86 -57
  81. package/dist/index179.js +11 -17
  82. package/dist/index18.js +4 -4
  83. package/dist/index180.js +11 -27
  84. package/dist/index181.js +56 -42
  85. package/dist/index182.js +10 -20
  86. package/dist/index183.js +11 -48
  87. package/dist/index184.js +15 -48
  88. package/dist/index185.js +8 -17
  89. package/dist/index186.js +8 -11
  90. package/dist/index187.js +102 -34
  91. package/dist/index188.js +7 -15
  92. package/dist/index189.js +31 -78
  93. package/dist/index19.js +10 -10
  94. package/dist/index190.js +74 -23
  95. package/dist/index191.js +15 -4
  96. package/dist/index192.js +28 -11
  97. package/dist/index193.js +7 -10
  98. package/dist/index194.js +22 -40
  99. package/dist/index195.js +25 -5
  100. package/dist/index196.js +160 -9
  101. package/dist/index197.js +113 -11
  102. package/dist/index198.js +73 -115
  103. package/dist/index199.js +64 -11
  104. package/dist/index20.js +3 -3
  105. package/dist/index201.js +2 -2
  106. package/dist/index202.js +5 -5
  107. package/dist/index203.js +1 -1
  108. package/dist/index204.js +2 -2
  109. package/dist/index205.js +3 -3
  110. package/dist/index206.js +12 -4
  111. package/dist/index207.js +4 -19
  112. package/dist/index208.js +4 -128
  113. package/dist/index209.js +10 -45
  114. package/dist/index21.js +4 -4
  115. package/dist/index210.js +16 -17
  116. package/dist/index211.js +22 -5
  117. package/dist/index212.js +122 -175
  118. package/dist/index213.js +45 -76
  119. package/dist/index214.js +15 -396
  120. package/dist/index215.js +5 -7
  121. package/dist/index216.js +181 -5
  122. package/dist/index217.js +74 -15
  123. package/dist/index218.js +396 -12
  124. package/dist/index219.js +38 -32
  125. package/dist/index22.js +5 -5
  126. package/dist/index220.js +57 -39
  127. package/dist/index221.js +28 -57
  128. package/dist/index222.js +7 -27
  129. package/dist/index223.js +12 -7
  130. package/dist/index224.js +10 -11
  131. package/dist/index225.js +5 -5
  132. package/dist/index226.js +21 -11
  133. package/dist/index227.js +11 -21
  134. package/dist/index228.js +7 -11
  135. package/dist/index229.js +42 -7
  136. package/dist/index23.js +3 -3
  137. package/dist/index230.js +4 -43
  138. package/dist/index231.js +5 -597
  139. package/dist/index232.js +596 -11
  140. package/dist/index233.js +12 -4
  141. package/dist/index234.js +11 -6
  142. package/dist/index235.js +32 -11
  143. package/dist/index236.js +208 -14
  144. package/dist/index237.js +4 -209
  145. package/dist/index238.js +13 -3
  146. package/dist/index239.js +47 -13
  147. package/dist/index24.js +9 -9
  148. package/dist/index240.js +3 -47
  149. package/dist/index241.js +12 -3
  150. package/dist/index242.js +56 -11
  151. package/dist/index243.js +29 -57
  152. package/dist/index244.js +13 -29
  153. package/dist/index245.js +9 -14
  154. package/dist/index246.js +207 -9
  155. package/dist/index247.js +13 -205
  156. package/dist/index248.js +317 -16
  157. package/dist/index249.js +3 -6
  158. package/dist/index250.js +3 -322
  159. package/dist/index251.js +21 -3
  160. package/dist/index252.js +6 -3
  161. package/dist/index253.js +1 -1
  162. package/dist/index26.js +1 -1
  163. package/dist/index27.js +1 -1
  164. package/dist/index28.js +1 -1
  165. package/dist/index32.js +1 -1
  166. package/dist/index33.js +17 -17
  167. package/dist/index34.js +5 -5
  168. package/dist/index35.js +14 -14
  169. package/dist/index36.js +11 -11
  170. package/dist/index37.js +8 -8
  171. package/dist/index38.js +9 -9
  172. package/dist/index39.js +5 -5
  173. package/dist/index40.js +3 -3
  174. package/dist/index41.js +4 -4
  175. package/dist/index42.js +2 -2
  176. package/dist/index43.js +2 -2
  177. package/dist/index44.js +1 -1
  178. package/dist/index45.js +6 -6
  179. package/dist/index46.js +10 -10
  180. package/dist/index47.js +9 -9
  181. package/dist/index48.js +17 -17
  182. package/dist/index49.js +4 -4
  183. package/dist/index50.js +11 -11
  184. package/dist/index52.js +24 -24
  185. package/dist/index53.js +3 -3
  186. package/dist/index54.js +30 -30
  187. package/dist/index55.js +14 -14
  188. package/dist/index56.js +13 -13
  189. package/dist/index57.js +2 -2
  190. package/dist/index58.js +4 -4
  191. package/dist/index59.js +6 -6
  192. package/dist/index60.js +12 -12
  193. package/dist/index61.js +5 -5
  194. package/dist/index62.js +4 -4
  195. package/dist/index63.js +12 -12
  196. package/dist/index64.js +5 -5
  197. package/dist/index65.js +3 -3
  198. package/dist/index66.js +14 -14
  199. package/dist/index69.js +32 -32
  200. package/dist/index70.js +5 -5
  201. package/dist/index71.js +18 -18
  202. package/dist/index72.js +23 -23
  203. package/dist/index73.js +8 -8
  204. package/dist/index74.js +2 -2
  205. package/dist/index75.js +12 -12
  206. package/dist/index76.js +3 -3
  207. package/dist/index77.js +5 -5
  208. package/dist/index78.js +4 -4
  209. package/dist/index79.js +1 -1
  210. package/dist/index80.js +1 -1
  211. package/dist/index81.js +16 -16
  212. package/dist/index82.js +5 -5
  213. package/dist/index83.js +5 -5
  214. package/dist/index86.js +11 -54
  215. package/dist/index87.js +54 -11
  216. package/dist/index88.js +11 -11
  217. package/dist/index89.js +6 -6
  218. package/dist/index94.js +4 -133
  219. package/dist/index95.js +63 -24
  220. package/dist/index96.js +8 -8
  221. package/dist/index97.js +14 -5
  222. package/dist/index98.js +3 -12
  223. package/dist/index99.js +3 -22
  224. package/dist/styles.css +1 -1
  225. package/package.json +1 -1
package/dist/index120.js CHANGED
@@ -1,15 +1,79 @@
1
- const t = "ArrowUp", n = "ArrowDown", o = "ArrowLeft", R = "ArrowRight", e = "Home", c = "End", E = /* @__PURE__ */ new Set([o, R]), A = /* @__PURE__ */ new Set([t, n]), O = /* @__PURE__ */ new Set([...E, ...A]);
2
- [...O];
3
- const s = /* @__PURE__ */ new Set([t, n, o, R, e, "End"]);
1
+ import * as l from "react";
2
+ import { useStableCallback as a } from "./index127.js";
3
+ import { useIsoLayoutEffect as o } from "./index126.js";
4
+ import { useTransitionStatus as s } from "./index133.js";
5
+ import { useOpenChangeComplete as f } from "./index113.js";
6
+ function m(e, n) {
7
+ const t = l.useRef(null);
8
+ return l.useCallback((i) => {
9
+ e !== void 0 && (t.current !== null && (n.context.triggerElements.delete(t.current), t.current = null), i !== null && (t.current = e, n.context.triggerElements.add(e, i)));
10
+ }, [n, e]);
11
+ }
12
+ function E(e, n, t, i) {
13
+ const r = t.useState("isMountedByTrigger", e), c = m(e, t), g = a((u) => {
14
+ c(u), u !== null && t.select("open") && t.select("activeTriggerId") == null && t.update({
15
+ activeTriggerId: e,
16
+ activeTriggerElement: u,
17
+ ...i
18
+ });
19
+ });
20
+ return o(() => {
21
+ r && t.update({
22
+ activeTriggerElement: n.current,
23
+ ...i
24
+ });
25
+ }, [r, t, n, ...Object.values(i)]), {
26
+ registerTrigger: g,
27
+ isMountedByThisTrigger: r
28
+ };
29
+ }
30
+ function C(e) {
31
+ const n = e.useState("open");
32
+ o(() => {
33
+ if (n && !e.select("activeTriggerId") && e.context.triggerElements.size === 1) {
34
+ const t = e.context.triggerElements.entries().next();
35
+ if (!t.done) {
36
+ const [i, r] = t.value;
37
+ e.update({
38
+ activeTriggerId: i,
39
+ activeTriggerElement: r
40
+ });
41
+ }
42
+ }
43
+ }, [n, e]);
44
+ }
45
+ function x(e, n, t) {
46
+ const {
47
+ mounted: i,
48
+ setMounted: r,
49
+ transitionStatus: c
50
+ } = s(e);
51
+ n.useSyncedValues({
52
+ mounted: i,
53
+ transitionStatus: c
54
+ });
55
+ const g = a(() => {
56
+ r(!1), n.update({
57
+ activeTriggerId: null,
58
+ activeTriggerElement: null,
59
+ mounted: !1
60
+ }), t?.(), n.context.onOpenChangeComplete?.(!1);
61
+ }), u = n.useState("preventUnmountingOnClose");
62
+ return f({
63
+ enabled: !u,
64
+ open: e,
65
+ ref: n.context.popupRef,
66
+ onComplete() {
67
+ e || g();
68
+ }
69
+ }), {
70
+ forceUnmount: g,
71
+ transitionStatus: c
72
+ };
73
+ }
4
74
  export {
5
- n as ARROW_DOWN,
6
- O as ARROW_KEYS,
7
- o as ARROW_LEFT,
8
- R as ARROW_RIGHT,
9
- t as ARROW_UP,
10
- s as COMPOSITE_KEYS,
11
- c as END,
12
- e as HOME,
13
- E as HORIZONTAL_KEYS,
14
- A as VERTICAL_KEYS
75
+ C as useImplicitActiveTrigger,
76
+ x as useOpenStateTransitions,
77
+ E as useTriggerDataForwarding,
78
+ m as useTriggerRegistration
15
79
  };
package/dist/index121.js CHANGED
@@ -1,299 +1,67 @@
1
1
  "use client";
2
- import * as b from "react";
3
- import { tabbable as we, isTabbable as De, focusable as Ke } from "./index237.js";
4
- import { isHTMLElement as q, getNodeName as He, getWindow as _e, getComputedStyle as Ue } from "./index94.js";
5
- import { useMergedRefs as Re } from "./index101.js";
6
- import { useValueAsRef as H } from "./index176.js";
7
- import { useStableCallback as _ } from "./index95.js";
8
- import { useIsoLayoutEffect as U } from "./index97.js";
9
- import { visuallyHidden as We } from "./index174.js";
10
- import { useTimeout as ye } from "./index148.js";
11
- import { useAnimationFrame as $e } from "./index150.js";
12
- import { FocusGuard as Te } from "./index168.js";
13
- import { createChangeEventDetails as ze } from "./index113.js";
14
- import { createAttribute as Fe } from "./index238.js";
15
- import { enqueueFocus as te } from "./index239.js";
16
- import { markOthers as Je } from "./index240.js";
17
- import { usePortalContext as Qe } from "./index124.js";
18
- import { useFloatingTree as Xe } from "./index145.js";
19
- import { CLICK_TRIGGER_IDENTIFIER as Ye } from "./index125.js";
20
- import { resolveRef as D } from "./index241.js";
21
- import { jsxs as Ze, jsx as xe } from "react/jsx-runtime";
22
- import { isTypeableCombobox as he, getFloatingFocusElement as Ie, getDocument as I, activeElement as V, contains as m, getTarget as W } from "./index173.js";
23
- import { getTabbableOptions as re, isOutsideEvent as Le, getNextTabbable as et, getPreviousTabbable as tt } from "./index172.js";
24
- import { getNodeAncestors as ke, getNodeChildren as Ce } from "./index242.js";
25
- import { isVirtualClick as nt, isVirtualPointerEvent as rt, stopEvent as ot } from "./index222.js";
26
- import { triggerHover as st, outsidePress as ut, focusOut as it } from "./index114.js";
27
- function ct(n, p) {
28
- const h = _e(n.target);
29
- return n instanceof h.KeyboardEvent ? "keyboard" : n instanceof h.FocusEvent ? p || "keyboard" : "pointerType" in n ? n.pointerType || "keyboard" : "touches" in n ? "touch" : n instanceof h.MouseEvent ? p || (n.detail === 0 ? "keyboard" : "mouse") : "";
30
- }
31
- const Ae = 20;
32
- let L = [];
33
- function oe() {
34
- L = L.filter((n) => n.isConnected);
35
- }
36
- function at(n) {
37
- oe(), n && He(n) !== "body" && (L.push(n), L.length > Ae && (L = L.slice(-Ae)));
38
- }
39
- function ne() {
40
- return oe(), L[L.length - 1];
41
- }
42
- function ft(n) {
43
- if (!n)
44
- return null;
45
- const p = re();
46
- return De(n, p) ? n : we(n, p)[0] || n;
47
- }
48
- function lt(n) {
49
- return !n || !n.isConnected ? !1 : typeof n.checkVisibility == "function" ? n.checkVisibility() : Ue(n).display !== "none";
50
- }
51
- function Oe(n, p) {
52
- if (!p.current.includes("floating") && !n.getAttribute("role")?.includes("dialog"))
53
- return;
54
- const h = re(), $ = Ke(n, h).filter((S) => {
55
- const P = S.getAttribute("data-tabindex") || "";
56
- return De(S, h) || S.hasAttribute("data-tabindex") && !P.startsWith("-");
57
- }), N = n.getAttribute("tabindex");
58
- p.current.includes("floating") || $.length === 0 ? N !== "0" && n.setAttribute("tabindex", "0") : (N !== "-1" || n.hasAttribute("data-tabindex") && n.getAttribute("data-tabindex") !== "-1") && (n.setAttribute("tabindex", "-1"), n.setAttribute("data-tabindex", "-1"));
59
- }
60
- function Mt(n) {
61
- const {
62
- context: p,
63
- children: h,
64
- disabled: i = !1,
65
- order: $ = ["content"],
66
- initialFocus: N = !0,
67
- returnFocus: S = !0,
68
- restoreFocus: P = !1,
69
- modal: E = !0,
70
- closeOnFocusOut: M = !0,
71
- openInteractionType: Ne = "",
72
- getInsideElements: Se = () => [],
73
- nextFocusableElement: z,
74
- previousFocusableElement: J,
75
- beforeContentFocusGuardRef: Pe,
76
- externalTree: Me
77
- } = n, F = "rootStore" in p ? p.rootStore : p, v = F.useState("open"), a = F.useState("domReferenceElement"), f = F.useState("floatingElement"), {
78
- events: Q,
79
- dataRef: k
80
- } = F.context, O = _(() => k.current.floatingContext?.nodeId), se = _(Se), ue = N === !1, x = he(a) && ue, C = H($), ie = H(N), j = H(S), ce = H(Ne), R = Xe(Me), c = Qe(), Ge = b.useRef(null), qe = b.useRef(null), y = b.useRef(!1), B = b.useRef(!1), X = b.useRef(!1), ae = b.useRef(-1), fe = b.useRef(""), Y = b.useRef(""), le = ye(), de = ye(), be = $e(), Z = c != null, r = Ie(f), A = _((t = r) => t ? we(t, re()) : []), G = _((t) => {
81
- const o = A(t);
82
- return C.current.map(() => o).filter(Boolean).flat();
83
- });
84
- b.useEffect(() => {
85
- if (i || !E)
86
- return;
87
- function t(l) {
88
- l.key === "Tab" && m(r, V(I(r))) && A().length === 0 && !x && ot(l);
89
- }
90
- const o = I(r);
91
- return o.addEventListener("keydown", t), () => {
92
- o.removeEventListener("keydown", t);
93
- };
94
- }, [i, a, r, E, C, x, A, G]), b.useEffect(() => {
95
- if (i || !f)
96
- return;
97
- function t(o) {
98
- const l = W(o), d = A().indexOf(l);
99
- d !== -1 && (ae.current = d);
100
- }
101
- return f.addEventListener("focusin", t), () => {
102
- f.removeEventListener("focusin", t);
103
- };
104
- }, [i, f, A]), b.useEffect(() => {
105
- if (i || !v)
106
- return;
107
- const t = I(r);
108
- function o() {
109
- X.current = !1;
110
- }
111
- function l(d) {
112
- const e = W(d), s = m(f, e) || m(a, e) || m(c?.portalNode, e);
113
- X.current = !s, Y.current = d.pointerType || "keyboard";
114
- }
115
- function u() {
116
- Y.current = "keyboard";
117
- }
118
- return t.addEventListener("pointerdown", l, !0), t.addEventListener("pointerup", o, !0), t.addEventListener("pointercancel", o, !0), t.addEventListener("keydown", u, !0), () => {
119
- t.removeEventListener("pointerdown", l, !0), t.removeEventListener("pointerup", o, !0), t.removeEventListener("pointercancel", o, !0), t.removeEventListener("keydown", u, !0);
120
- };
121
- }, [i, f, a, r, v, c]), b.useEffect(() => {
122
- if (i || !M)
123
- return;
124
- function t() {
125
- B.current = !0, de.start(0, () => {
126
- B.current = !1;
127
- });
128
- }
129
- function o(e) {
130
- const s = e.relatedTarget, w = e.currentTarget, g = W(e);
131
- queueMicrotask(() => {
132
- const K = O(), ge = F.context.triggerElements, Be = !(m(a, s) || m(f, s) || m(s, f) || m(c?.portalNode, s) || s != null && ge.hasElement(s) || ge.hasMatchingElement((T) => m(T, s)) || s?.hasAttribute(Fe("focus-guard")) || R && (Ce(R.nodesRef.current, K).find((T) => m(T.context?.elements.floating, s) || m(T.context?.elements.domReference, s)) || ke(R.nodesRef.current, K).find((T) => [T.context?.elements.floating, Ie(T.context?.elements.floating)].includes(s) || T.context?.elements.domReference === s)));
133
- if (w === a && r && Oe(r, C), P && w !== a && !lt(g) && V(I(r)) === I(r).body) {
134
- if (q(r) && (r.focus(), P === "popup")) {
135
- be.request(() => {
136
- r.focus();
137
- });
138
- return;
139
- }
140
- const T = ae.current, ee = A(), ve = ee[T] || ee[ee.length - 1] || r;
141
- q(ve) && ve.focus();
142
- }
143
- if (k.current.insideReactTree) {
144
- k.current.insideReactTree = !1;
145
- return;
146
- }
147
- (x || !E) && s && Be && !B.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
148
- // For an "untrapped" typeable combobox (input role=combobox with
149
- // initialFocus=false), re-opening the popup and tabbing out should still close it even
150
- // when the previously focused element (e.g. the next tabbable outside the popup) is
151
- // focused again. Otherwise, the popup remains open on the second Tab sequence:
152
- // click input -> Tab (closes) -> click input -> Tab.
153
- // Allow closing when `isUntrappedTypeableCombobox` regardless of the previously focused element.
154
- (x || s !== ne()) && (y.current = !0, F.setOpen(!1, ze(it, e)));
155
- });
156
- }
157
- function l() {
158
- X.current || (k.current.insideReactTree = !0, le.start(0, () => {
159
- k.current.insideReactTree = !1;
160
- }));
161
- }
162
- const u = q(a) ? a : null, d = [];
163
- if (!(!f && !u))
164
- return u && (u.addEventListener("focusout", o), u.addEventListener("pointerdown", t), d.push(() => {
165
- u.removeEventListener("focusout", o), u.removeEventListener("pointerdown", t);
166
- })), f && (f.addEventListener("focusout", o), c && (f.addEventListener("focusout", l, !0), d.push(() => {
167
- f.removeEventListener("focusout", l, !0);
168
- })), d.push(() => {
169
- f.removeEventListener("focusout", o);
170
- })), () => {
171
- d.forEach((e) => {
172
- e();
173
- });
174
- };
175
- }, [i, a, f, r, E, R, c, F, M, P, A, x, O, C, k, le, de, be]);
176
- const me = b.useRef(null), pe = b.useRef(null), Ve = Re(me, Pe, c?.beforeInsideRef), je = Re(pe, c?.afterInsideRef);
177
- b.useEffect(() => {
178
- if (i || !f || !v)
179
- return;
180
- const t = Array.from(c?.portalNode?.querySelectorAll(`[${Fe("portal")}]`) || []), l = (R ? ke(R.nodesRef.current, O()) : []).find((e) => he(e.context?.elements.domReference || null))?.context?.elements.domReference, u = [f, l, ...t, ...se(), Ge.current, qe.current, me.current, pe.current, c?.beforeOutsideRef.current, c?.afterOutsideRef.current, D(J), D(z), x ? a : null].filter((e) => e != null), d = Je(u, E || x);
181
- return () => {
182
- d();
183
- };
184
- }, [v, i, a, f, E, C, c, x, R, O, se, z, J]), U(() => {
185
- if (!v || i || !q(r))
186
- return;
187
- const t = I(r), o = V(t);
188
- queueMicrotask(() => {
189
- const l = G(r), u = ie.current, d = typeof u == "function" ? u(ce.current || "") : u;
190
- if (d === void 0 || d === !1)
2
+ import * as v from "react";
3
+ import { useAnimationFrame as P } from "./index160.js";
4
+ import { useTimeout as b } from "./index148.js";
5
+ import { createChangeEventDetails as k } from "./index107.js";
6
+ import { isMouseLikePointerType as w, isClickLikeEvent as I } from "./index221.js";
7
+ import { isTypeableElement as x } from "./index151.js";
8
+ import { EMPTY_OBJECT as L } from "./index100.js";
9
+ import { triggerPress as y } from "./index108.js";
10
+ function Y(d, M = {}) {
11
+ const e = "rootStore" in d ? d.rootStore : d, T = e.context.dataRef, {
12
+ enabled: h = !0,
13
+ event: p = "click",
14
+ toggle: g = !0,
15
+ ignoreMouse: E = !1,
16
+ stickIfOpen: O = !0,
17
+ touchOpenDelay: n = 0
18
+ } = M, s = v.useRef(void 0), C = P(), a = b(), R = v.useMemo(() => ({
19
+ onPointerDown(t) {
20
+ s.current = t.pointerType;
21
+ },
22
+ onMouseDown(t) {
23
+ const r = s.current, o = t.nativeEvent, c = e.select("open");
24
+ if (t.button !== 0 || p === "click" || w(r, !0) && E)
25
+ return;
26
+ const m = T.current.openEvent, i = m?.type, f = e.select("domReferenceElement") !== t.currentTarget, l = c && f || !(c && g && (!(m && O) || i === "click" || i === "mousedown"));
27
+ if (x(o.target)) {
28
+ const u = k(y, o, o.target);
29
+ l && r === "touch" && n > 0 ? a.start(n, () => {
30
+ e.setOpen(!0, u);
31
+ }) : e.setOpen(l, u);
191
32
  return;
192
- let e;
193
- d === !0 || d === null ? e = l[0] || r : e = D(d), e = e || l[0] || r, !m(r, o) && te(e, {
194
- preventScroll: e === r
195
- });
196
- });
197
- }, [i, v, r, ue, G, ie, ce]), U(() => {
198
- if (i || !r)
199
- return;
200
- const t = I(r), o = V(t);
201
- at(o);
202
- function l(e) {
203
- if (e.open || (fe.current = ct(e.nativeEvent, Y.current)), e.reason === st && e.nativeEvent.type === "mouseleave" && (y.current = !0), e.reason === ut)
204
- if (e.nested)
205
- y.current = !1;
206
- else if (nt(e.nativeEvent) || rt(e.nativeEvent))
207
- y.current = !1;
208
- else {
209
- let s = !1;
210
- document.createElement("div").focus({
211
- get preventScroll() {
212
- return s = !0, !1;
213
- }
214
- }), s ? y.current = !1 : y.current = !0;
215
- }
216
- }
217
- Q.on("openchange", l);
218
- const u = t.createElement("span");
219
- u.setAttribute("tabindex", "-1"), u.setAttribute("aria-hidden", "true"), Object.assign(u.style, We), Z && a && a.insertAdjacentElement("afterend", u);
220
- function d() {
221
- const e = j.current;
222
- let s = typeof e == "function" ? e(fe.current) : e;
223
- if (s === void 0 || s === !1)
224
- return null;
225
- if (s === null && (s = !0), typeof s == "boolean") {
226
- const g = a || ne();
227
- return g && g.isConnected ? g : u;
228
33
  }
229
- const w = a || ne() || u;
230
- return D(s) || w;
231
- }
232
- return () => {
233
- Q.off("openchange", l);
234
- const e = V(t), s = m(f, e) || R && Ce(R.nodesRef.current, O(), !1).some((g) => m(g.context?.elements.floating, e)), w = d();
235
- queueMicrotask(() => {
236
- const g = ft(w), K = typeof j.current != "boolean";
237
- // eslint-disable-next-line react-hooks/exhaustive-deps
238
- j.current && !y.current && q(g) && // If the focus moved somewhere else after mount, avoid returning focus
239
- // since it likely entered a different element which should be
240
- // respected: https://github.com/floating-ui/floating-ui/issues/2607
241
- (!(!K && g !== e && e !== t.body) || s) && g.focus({
242
- preventScroll: !0
243
- }), u.remove();
34
+ const D = t.currentTarget;
35
+ C.request(() => {
36
+ const u = k(y, o, D);
37
+ l && r === "touch" && n > 0 ? a.start(n, () => {
38
+ e.setOpen(!0, u);
39
+ }) : e.setOpen(l, u);
244
40
  });
245
- };
246
- }, [i, f, r, j, k, Q, R, Z, a, O]), b.useEffect(() => {
247
- queueMicrotask(() => {
248
- y.current = !1;
249
- });
250
- }, [i]), b.useEffect(() => {
251
- if (i || !v)
252
- return;
253
- function t(l) {
254
- W(l)?.closest(`[${Ye}]`) && (B.current = !0);
255
- }
256
- const o = I(r);
257
- return o.addEventListener("pointerdown", t, !0), () => {
258
- o.removeEventListener("pointerdown", t, !0);
259
- };
260
- }, [i, v, r]), U(() => {
261
- if (!i && c)
262
- return c.setFocusManagerState({
263
- modal: E,
264
- closeOnFocusOut: M,
265
- open: v,
266
- onOpenChange: F.setOpen,
267
- domReference: a
268
- }), () => {
269
- c.setFocusManagerState(null);
270
- };
271
- }, [i, c, E, v, F, M, a]), U(() => {
272
- if (!(i || !r))
273
- return Oe(r, C), () => {
274
- queueMicrotask(oe);
275
- };
276
- }, [i, r, C]);
277
- const Ee = !i && (E ? !x : !0) && (Z || E);
278
- return /* @__PURE__ */ Ze(b.Fragment, {
279
- children: [Ee && /* @__PURE__ */ xe(Te, {
280
- "data-type": "inside",
281
- ref: Ve,
282
- onFocus: (t) => {
283
- if (E) {
284
- const o = G();
285
- te(o[o.length - 1]);
286
- } else c?.portalNode && (y.current = !1, Le(t, c.portalNode) ? et(a)?.focus() : D(J ?? c.beforeOutsideRef)?.focus());
287
- }
288
- }), h, Ee && /* @__PURE__ */ xe(Te, {
289
- "data-type": "inside",
290
- ref: je,
291
- onFocus: (t) => {
292
- E ? te(G()[0]) : c?.portalNode && (M && (y.current = !0), Le(t, c.portalNode) ? tt(a)?.focus() : D(z ?? c.afterOutsideRef)?.focus());
41
+ },
42
+ onClick(t) {
43
+ if (p === "mousedown-only")
44
+ return;
45
+ const r = s.current;
46
+ if (p === "mousedown" && r) {
47
+ s.current = void 0;
48
+ return;
293
49
  }
294
- })]
295
- });
50
+ if (w(r, !0) && E)
51
+ return;
52
+ const o = e.select("open"), c = T.current.openEvent, m = e.select("domReferenceElement") !== t.currentTarget, i = o && m || !(o && g && (!(c && O) || I(c))), f = k(y, t.nativeEvent, t.currentTarget);
53
+ i && r === "touch" && n > 0 ? a.start(n, () => {
54
+ e.setOpen(!0, f);
55
+ }) : e.setOpen(i, f);
56
+ },
57
+ onKeyDown() {
58
+ s.current = void 0;
59
+ }
60
+ }), [T, p, E, e, O, g, C, a, n]);
61
+ return v.useMemo(() => h ? {
62
+ reference: R
63
+ } : L, [h, R]);
296
64
  }
297
65
  export {
298
- Mt as FloatingFocusManager
66
+ Y as useClick
299
67
  };
package/dist/index122.js CHANGED
@@ -1,7 +1,48 @@
1
- import { isReactVersionAtLeast as r } from "./index200.js";
2
- function n(e) {
3
- return r(19) ? e : e ? "true" : void 0;
1
+ import * as l from "react";
2
+ import { FOCUSABLE_ATTRIBUTE as C, ACTIVE_KEY as s, SELECTED_KEY as E } from "./index245.js";
3
+ function k(e = []) {
4
+ const a = e.map((n) => n?.reference), g = e.map((n) => n?.floating), f = e.map((n) => n?.item), t = e.map((n) => n?.trigger), o = l.useCallback(
5
+ (n) => u(n, e, "reference"),
6
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7
+ a
8
+ ), c = l.useCallback(
9
+ (n) => u(n, e, "floating"),
10
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11
+ g
12
+ ), i = l.useCallback(
13
+ (n) => u(n, e, "item"),
14
+ // eslint-disable-next-line react-hooks/exhaustive-deps
15
+ f
16
+ ), r = l.useCallback(
17
+ (n) => u(n, e, "trigger"),
18
+ // eslint-disable-next-line react-hooks/exhaustive-deps
19
+ t
20
+ );
21
+ return l.useMemo(() => ({
22
+ getReferenceProps: o,
23
+ getFloatingProps: c,
24
+ getItemProps: i,
25
+ getTriggerProps: r
26
+ }), [o, c, i, r]);
27
+ }
28
+ function u(e, a, g) {
29
+ const f = /* @__PURE__ */ new Map(), t = g === "item", o = {};
30
+ g === "floating" && (o.tabIndex = -1, o[C] = "");
31
+ for (const c in e)
32
+ t && e && (c === s || c === E) || (o[c] = e[c]);
33
+ for (let c = 0; c < a.length; c += 1) {
34
+ let i;
35
+ const r = a[c]?.[g];
36
+ typeof r == "function" ? i = e ? r(e) : null : i = r, i && m(o, i, t, f);
37
+ }
38
+ return m(o, e, t, f), o;
39
+ }
40
+ function m(e, a, g, f) {
41
+ for (const t in a) {
42
+ const o = a[t];
43
+ g && (t === s || t === E) || (t.startsWith("on") ? (f.has(t) || f.set(t, []), typeof o == "function" && (f.get(t)?.push(o), e[t] = (...c) => f.get(t)?.map((i) => i(...c)).find((i) => i !== void 0))) : e[t] = o);
44
+ }
4
45
  }
5
46
  export {
6
- n as inertValue
47
+ k as useInteractions
7
48
  };
package/dist/index123.js CHANGED
@@ -1,41 +1,16 @@
1
- import * as i from "react";
2
- import { jsx as a } from "react/jsx-runtime";
3
- const c = /* @__PURE__ */ i.forwardRef(function(r, n) {
4
- const {
5
- cutout: e,
6
- ...p
7
- } = r;
8
- let o;
9
- if (e) {
10
- const t = e?.getBoundingClientRect();
11
- o = `polygon(
12
- 0% 0%,
13
- 100% 0%,
14
- 100% 100%,
15
- 0% 100%,
16
- 0% 0%,
17
- ${t.left}px ${t.top}px,
18
- ${t.left}px ${t.bottom}px,
19
- ${t.right}px ${t.bottom}px,
20
- ${t.right}px ${t.top}px,
21
- ${t.left}px ${t.top}px
22
- )`;
23
- }
24
- return /* @__PURE__ */ a("div", {
25
- ref: n,
26
- role: "presentation",
27
- "data-base-ui-inert": "",
28
- ...p,
29
- style: {
30
- position: "fixed",
31
- inset: 0,
32
- userSelect: "none",
33
- WebkitUserSelect: "none",
34
- clipPath: o
35
- }
36
- });
37
- });
38
- process.env.NODE_ENV !== "production" && (c.displayName = "InternalBackdrop");
1
+ const i = {
2
+ clip: "rect(0 0 0 0)",
3
+ overflow: "hidden",
4
+ whiteSpace: "nowrap",
5
+ position: "fixed",
6
+ top: 0,
7
+ left: 0,
8
+ border: 0,
9
+ padding: 0,
10
+ width: 1,
11
+ height: 1,
12
+ margin: -1
13
+ };
39
14
  export {
40
- c as InternalBackdrop
15
+ i as visuallyHidden
41
16
  };