@rpcbase/ui 0.238.0 → 0.239.0

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 (299) hide show
  1. package/dist/components/AddressAutocompleteInput/index.d.ts.map +1 -1
  2. package/dist/helpers/useMapsLibrary.d.ts.map +1 -1
  3. package/dist/index121.js +10 -10
  4. package/dist/index123.js +2 -2
  5. package/dist/index124.js +3 -3
  6. package/dist/index151.js +4 -4
  7. package/dist/index156.js +1 -1
  8. package/dist/index157.js +1 -1
  9. package/dist/index164.js +1 -1
  10. package/dist/index165.js +6 -6
  11. package/dist/index167.js +1 -1
  12. package/dist/index169.js +1 -1
  13. package/dist/index172.js +3 -3
  14. package/dist/index175.js +1 -1
  15. package/dist/index176.js +4 -4
  16. package/dist/index182.js +1 -1
  17. package/dist/index184.js +12 -12
  18. package/dist/index185.js +1 -1
  19. package/dist/index187.js +5 -5
  20. package/dist/index189.js +6 -6
  21. package/dist/index190.js +5 -5
  22. package/dist/index193.js +3 -3
  23. package/dist/index194.js +5 -5
  24. package/dist/index22.js.map +1 -1
  25. package/dist/index237.js +14 -27
  26. package/dist/index237.js.map +1 -1
  27. package/dist/index238.js +7 -12
  28. package/dist/index238.js.map +1 -1
  29. package/dist/index239.js +9 -24
  30. package/dist/index239.js.map +1 -1
  31. package/dist/index240.js +10 -5
  32. package/dist/index240.js.map +1 -1
  33. package/dist/index241.js +20 -15
  34. package/dist/index241.js.map +1 -1
  35. package/dist/index242.js +10 -7
  36. package/dist/index242.js.map +1 -1
  37. package/dist/index243.js +9 -10
  38. package/dist/index243.js.map +1 -1
  39. package/dist/index244.js +9 -10
  40. package/dist/index244.js.map +1 -1
  41. package/dist/index245.js +4 -21
  42. package/dist/index245.js.map +1 -1
  43. package/dist/index246.js +5 -10
  44. package/dist/index246.js.map +1 -1
  45. package/dist/index247.js +16 -9
  46. package/dist/index247.js.map +1 -1
  47. package/dist/index248.js +8 -8
  48. package/dist/index248.js.map +1 -1
  49. package/dist/index249.js +18 -4
  50. package/dist/index249.js.map +1 -1
  51. package/dist/index250.js +15 -5
  52. package/dist/index250.js.map +1 -1
  53. package/dist/index251.js +12 -16
  54. package/dist/index251.js.map +1 -1
  55. package/dist/index252.js +29 -9
  56. package/dist/index252.js.map +1 -1
  57. package/dist/index253.js +12 -18
  58. package/dist/index253.js.map +1 -1
  59. package/dist/index254.js +25 -15
  60. package/dist/index254.js.map +1 -1
  61. package/dist/index255.js +5 -12
  62. package/dist/index255.js.map +1 -1
  63. package/dist/index256.js +14 -20
  64. package/dist/index256.js.map +1 -1
  65. package/dist/index257.js +146 -58
  66. package/dist/index257.js.map +1 -1
  67. package/dist/index258.js +30 -6
  68. package/dist/index258.js.map +1 -1
  69. package/dist/index259.js +9 -11
  70. package/dist/index259.js.map +1 -1
  71. package/dist/index260.js +44 -46
  72. package/dist/index260.js.map +1 -1
  73. package/dist/index261.js +12 -4
  74. package/dist/index261.js.map +1 -1
  75. package/dist/index262.js +43 -28
  76. package/dist/index262.js.map +1 -1
  77. package/dist/index263.js +93 -14
  78. package/dist/index263.js.map +1 -1
  79. package/dist/index264.js +86 -5
  80. package/dist/index264.js.map +1 -1
  81. package/dist/index265.js +105 -21
  82. package/dist/index265.js.map +1 -1
  83. package/dist/index266.js +51 -50
  84. package/dist/index266.js.map +1 -1
  85. package/dist/index267.js +11 -25
  86. package/dist/index267.js.map +1 -1
  87. package/dist/index268.js +37 -41
  88. package/dist/index268.js.map +1 -1
  89. package/dist/index269.js +8 -39
  90. package/dist/index269.js.map +1 -1
  91. package/dist/index270.js +117 -45
  92. package/dist/index270.js.map +1 -1
  93. package/dist/index271.js +17 -20
  94. package/dist/index271.js.map +1 -1
  95. package/dist/index272.js +14 -69
  96. package/dist/index272.js.map +1 -1
  97. package/dist/index273.js +3 -17
  98. package/dist/index273.js.map +1 -1
  99. package/dist/index274.js +36 -11
  100. package/dist/index274.js.map +1 -1
  101. package/dist/index275.js +20 -27
  102. package/dist/index275.js.map +1 -1
  103. package/dist/index276.js +9 -13
  104. package/dist/index276.js.map +1 -1
  105. package/dist/index277.js +8 -18
  106. package/dist/index277.js.map +1 -1
  107. package/dist/index278.js +20 -37
  108. package/dist/index278.js.map +1 -1
  109. package/dist/index279.js +59 -255
  110. package/dist/index279.js.map +1 -1
  111. package/dist/index280.js +6 -278
  112. package/dist/index280.js.map +1 -1
  113. package/dist/index281.js +10 -67
  114. package/dist/index281.js.map +1 -1
  115. package/dist/index282.js +47 -96
  116. package/dist/index282.js.map +1 -1
  117. package/dist/index283.js +4 -84
  118. package/dist/index283.js.map +1 -1
  119. package/dist/index284.js +29 -3
  120. package/dist/index284.js.map +1 -1
  121. package/dist/index285.js +15 -28
  122. package/dist/index285.js.map +1 -1
  123. package/dist/index286.js +5 -16
  124. package/dist/index286.js.map +1 -1
  125. package/dist/index287.js +22 -35
  126. package/dist/index287.js.map +1 -1
  127. package/dist/index288.js +51 -16
  128. package/dist/index288.js.map +1 -1
  129. package/dist/index289.js +25 -3
  130. package/dist/index289.js.map +1 -1
  131. package/dist/index290.js +41 -26
  132. package/dist/index290.js.map +1 -1
  133. package/dist/index291.js +38 -27
  134. package/dist/index291.js.map +1 -1
  135. package/dist/index292.js +45 -4
  136. package/dist/index292.js.map +1 -1
  137. package/dist/index293.js +20 -78
  138. package/dist/index293.js.map +1 -1
  139. package/dist/index294.js +65 -264
  140. package/dist/index294.js.map +1 -1
  141. package/dist/index295.js +17 -11
  142. package/dist/index295.js.map +1 -1
  143. package/dist/index296.js +11 -10
  144. package/dist/index296.js.map +1 -1
  145. package/dist/index297.js +26 -24
  146. package/dist/index297.js.map +1 -1
  147. package/dist/index298.js +13 -16
  148. package/dist/index298.js.map +1 -1
  149. package/dist/index299.js +15 -122
  150. package/dist/index299.js.map +1 -1
  151. package/dist/index3.js.map +1 -1
  152. package/dist/index300.js +36 -5
  153. package/dist/index300.js.map +1 -1
  154. package/dist/index301.js +260 -38
  155. package/dist/index301.js.map +1 -1
  156. package/dist/index302.js +275 -62
  157. package/dist/index302.js.map +1 -1
  158. package/dist/index303.js +68 -13
  159. package/dist/index303.js.map +1 -1
  160. package/dist/index304.js +99 -7
  161. package/dist/index304.js.map +1 -1
  162. package/dist/index305.js +83 -5
  163. package/dist/index305.js.map +1 -1
  164. package/dist/index306.js +3 -3
  165. package/dist/index306.js.map +1 -1
  166. package/dist/index307.js +29 -10
  167. package/dist/index307.js.map +1 -1
  168. package/dist/index308.js +15 -6
  169. package/dist/index308.js.map +1 -1
  170. package/dist/index309.js +34 -133
  171. package/dist/index309.js.map +1 -1
  172. package/dist/index310.js +15 -398
  173. package/dist/index310.js.map +1 -1
  174. package/dist/index311.js +3 -52
  175. package/dist/index311.js.map +1 -1
  176. package/dist/index312.js +26 -11
  177. package/dist/index312.js.map +1 -1
  178. package/dist/index313.js +27 -10
  179. package/dist/index313.js.map +1 -1
  180. package/dist/index314.js +4 -14
  181. package/dist/index314.js.map +1 -1
  182. package/dist/index315.js +75 -151
  183. package/dist/index315.js.map +1 -1
  184. package/dist/index316.js +267 -28
  185. package/dist/index316.js.map +1 -1
  186. package/dist/index317.js +11 -9
  187. package/dist/index317.js.map +1 -1
  188. package/dist/index318.js +11 -49
  189. package/dist/index318.js.map +1 -1
  190. package/dist/index319.js +25 -11
  191. package/dist/index319.js.map +1 -1
  192. package/dist/index320.js +15 -43
  193. package/dist/index320.js.map +1 -1
  194. package/dist/index321.js +119 -89
  195. package/dist/index321.js.map +1 -1
  196. package/dist/index322.js +5 -86
  197. package/dist/index322.js.map +1 -1
  198. package/dist/index323.js +39 -104
  199. package/dist/index323.js.map +1 -1
  200. package/dist/index324.js +60 -47
  201. package/dist/index324.js.map +1 -1
  202. package/dist/index325.js +13 -11
  203. package/dist/index325.js.map +1 -1
  204. package/dist/index326.js +7 -37
  205. package/dist/index326.js.map +1 -1
  206. package/dist/index327.js +5 -8
  207. package/dist/index327.js.map +1 -1
  208. package/dist/index328.js +3 -116
  209. package/dist/index328.js.map +1 -1
  210. package/dist/index329.js +10 -17
  211. package/dist/index329.js.map +1 -1
  212. package/dist/index330.js +7 -15
  213. package/dist/index330.js.map +1 -1
  214. package/dist/index331.js +133 -3
  215. package/dist/index331.js.map +1 -1
  216. package/dist/index332.js +398 -35
  217. package/dist/index332.js.map +1 -1
  218. package/dist/index333.js +52 -20
  219. package/dist/index333.js.map +1 -1
  220. package/dist/index334.js +11 -9
  221. package/dist/index334.js.map +1 -1
  222. package/dist/index335.js +11 -8
  223. package/dist/index335.js.map +1 -1
  224. package/dist/index336.js +3 -3
  225. package/dist/index339.js +1 -1
  226. package/dist/index346.js +2 -2
  227. package/dist/index347.js +5 -122
  228. package/dist/index347.js.map +1 -1
  229. package/dist/index348.js +121 -31
  230. package/dist/index348.js.map +1 -1
  231. package/dist/index349.js +31 -72
  232. package/dist/index349.js.map +1 -1
  233. package/dist/index350.js +70 -139
  234. package/dist/index350.js.map +1 -1
  235. package/dist/index351.js +116 -35
  236. package/dist/index351.js.map +1 -1
  237. package/dist/index352.js +56 -44
  238. package/dist/index352.js.map +1 -1
  239. package/dist/index353.js +49 -14
  240. package/dist/index353.js.map +1 -1
  241. package/dist/index354.js +15 -6
  242. package/dist/index354.js.map +1 -1
  243. package/dist/index362.js +19 -10
  244. package/dist/index362.js.map +1 -1
  245. package/dist/index363.js +4 -17
  246. package/dist/index363.js.map +1 -1
  247. package/dist/index365.js +12 -4
  248. package/dist/index365.js.map +1 -1
  249. package/dist/index366.js +15 -19
  250. package/dist/index366.js.map +1 -1
  251. package/dist/index367.js +19 -43
  252. package/dist/index367.js.map +1 -1
  253. package/dist/index368.js +40 -13
  254. package/dist/index368.js.map +1 -1
  255. package/dist/index369.js +17 -4
  256. package/dist/index369.js.map +1 -1
  257. package/dist/index370.js +4 -200
  258. package/dist/index370.js.map +1 -1
  259. package/dist/index371.js +197 -74
  260. package/dist/index371.js.map +1 -1
  261. package/dist/index372.js +77 -20
  262. package/dist/index372.js.map +1 -1
  263. package/dist/index374.js +3 -3
  264. package/dist/index375.js +1 -1
  265. package/dist/index376.js +3 -3
  266. package/dist/index378.js +2 -2
  267. package/dist/index380.js +1 -1
  268. package/dist/index381.js +2 -2
  269. package/dist/index384.js +2 -2
  270. package/dist/index386.js +1 -1
  271. package/dist/index407.js +1 -1
  272. package/dist/index44.js +1 -1
  273. package/dist/index45.js +2 -2
  274. package/dist/index49.js +28 -28
  275. package/dist/index50.js +21 -21
  276. package/dist/index51.js +1 -1
  277. package/dist/index52.js +8 -8
  278. package/dist/index53.js +2 -2
  279. package/dist/index55.js +17 -17
  280. package/dist/index56.js +4 -4
  281. package/dist/index57.js +3 -3
  282. package/dist/index58.js +7 -7
  283. package/dist/index59.js +4 -4
  284. package/dist/index60.js +12 -12
  285. package/dist/index61.js +2 -2
  286. package/dist/index62.js +2 -2
  287. package/dist/index70.js +1 -1
  288. package/dist/index71.js +1 -1
  289. package/dist/index74.js +6 -2
  290. package/dist/index74.js.map +1 -1
  291. package/dist/index75.js +8 -2
  292. package/dist/index75.js.map +1 -1
  293. package/dist/index76.js +5 -5
  294. package/dist/index76.js.map +1 -1
  295. package/dist/index77.js +2 -8
  296. package/dist/index77.js.map +1 -1
  297. package/dist/index78.js +2 -6
  298. package/dist/index78.js.map +1 -1
  299. package/package.json +1 -1
package/dist/index348.js CHANGED
@@ -1,36 +1,126 @@
1
- import { useId as f } from "./index345.js";
2
- import { useRefWithInit as u } from "./index258.js";
3
- import { useIsoLayoutEffect as g } from "./index261.js";
4
- import { isElement as E } from "./index309.js";
5
- import { useFloatingParentNodeId as d } from "./index382.js";
6
- import { FloatingRootStore as S } from "./index384.js";
7
- function C(p) {
8
- const {
9
- popupStore: n,
10
- treatPopupAsFloatingElement: a = !1,
11
- onOpenChange: c
12
- } = p, o = f(), m = d() != null, r = n.useState("open"), t = n.useState("activeTriggerElement"), s = n.useState(a ? "popupElement" : "positionerElement"), l = n.context.triggerElements, e = u(() => new S({
13
- open: r,
14
- transitionStatus: void 0,
15
- referenceElement: t,
16
- floatingElement: s,
17
- triggerElements: l,
18
- onOpenChange: c,
19
- floatingId: o,
20
- syncOnly: !0,
21
- nested: m
22
- })).current;
23
- return g(() => {
24
- const i = {
25
- open: r,
26
- floatingId: o,
27
- referenceElement: t,
28
- floatingElement: s
1
+ import { getWindow as d, isOverflowElement as m } from "./index331.js";
2
+ import { addEventListener as T } from "./index322.js";
3
+ import { isIOS as E, isWebKit as H } from "./index323.js";
4
+ import { ownerDocument as a } from "./index306.js";
5
+ import { useIsoLayoutEffect as z } from "./index283.js";
6
+ import { Timeout as k } from "./index307.js";
7
+ import { AnimationFrame as j } from "./index324.js";
8
+ import { NOOP as F } from "./index286.js";
9
+ let Y = {}, C = {}, O = "";
10
+ function R(s) {
11
+ if (typeof document > "u")
12
+ return !1;
13
+ const e = a(s);
14
+ return d(e).innerWidth - e.documentElement.clientWidth > 0;
15
+ }
16
+ function I(s) {
17
+ if (!(typeof CSS < "u" && CSS.supports && CSS.supports("scrollbar-gutter", "stable")) || typeof document > "u")
18
+ return !1;
19
+ const t = a(s), o = t.documentElement, l = t.body, r = m(o) ? o : l, i = r.style.overflowY, c = o.style.scrollbarGutter;
20
+ o.style.scrollbarGutter = "stable", r.style.overflowY = "scroll";
21
+ const u = r.offsetWidth;
22
+ r.style.overflowY = "hidden";
23
+ const f = r.offsetWidth;
24
+ return r.style.overflowY = i, o.style.scrollbarGutter = c, u === f;
25
+ }
26
+ function V(s) {
27
+ const e = a(s), t = e.documentElement, o = e.body, l = m(t) ? t : o, r = {
28
+ overflowY: l.style.overflowY,
29
+ overflowX: l.style.overflowX
30
+ };
31
+ return Object.assign(l.style, {
32
+ overflowY: "hidden",
33
+ overflowX: "hidden"
34
+ }), () => {
35
+ Object.assign(l.style, r);
36
+ };
37
+ }
38
+ function q(s) {
39
+ const e = a(s), t = e.documentElement, o = e.body, l = d(t);
40
+ let r = 0, i = 0, c = !1;
41
+ const u = j.create();
42
+ if (H && (l.visualViewport?.scale ?? 1) !== 1)
43
+ return () => {
29
44
  };
30
- E(t) && (i.domReferenceElement = t), e.state.positionReference === e.state.referenceElement && (i.positionReference = t), e.update(i);
31
- }, [r, o, t, s, e]), e.context.onOpenChange = c, e.context.nested = m, e;
45
+ function f() {
46
+ const h = l.getComputedStyle(t), n = l.getComputedStyle(o), v = (h.scrollbarGutter || "").includes("both-edges") ? "stable both-edges" : "stable";
47
+ r = t.scrollTop, i = t.scrollLeft, Y = {
48
+ scrollbarGutter: t.style.scrollbarGutter,
49
+ overflowY: t.style.overflowY,
50
+ overflowX: t.style.overflowX
51
+ }, O = t.style.scrollBehavior, C = {
52
+ position: o.style.position,
53
+ height: o.style.height,
54
+ width: o.style.width,
55
+ boxSizing: o.style.boxSizing,
56
+ overflowY: o.style.overflowY,
57
+ overflowX: o.style.overflowX,
58
+ scrollBehavior: o.style.scrollBehavior
59
+ };
60
+ const G = t.scrollHeight > t.clientHeight, B = t.scrollWidth > t.clientWidth, W = h.overflowY === "scroll" || n.overflowY === "scroll", x = h.overflowX === "scroll" || n.overflowX === "scroll", b = Math.max(0, l.innerWidth - o.clientWidth), w = Math.max(0, l.innerHeight - o.clientHeight), p = parseFloat(n.marginTop) + parseFloat(n.marginBottom), g = parseFloat(n.marginLeft) + parseFloat(n.marginRight), S = m(t) ? t : o;
61
+ if (c = I(s), c) {
62
+ t.style.scrollbarGutter = v, S.style.overflowY = "hidden", S.style.overflowX = "hidden";
63
+ return;
64
+ }
65
+ Object.assign(t.style, {
66
+ scrollbarGutter: v,
67
+ overflowY: "hidden",
68
+ overflowX: "hidden"
69
+ }), (G || W) && (t.style.overflowY = "scroll"), (B || x) && (t.style.overflowX = "scroll"), Object.assign(o.style, {
70
+ position: "relative",
71
+ height: p || w ? `calc(100dvh - ${p + w}px)` : "100dvh",
72
+ width: g || b ? `calc(100vw - ${g + b}px)` : "100vw",
73
+ boxSizing: "border-box",
74
+ overflow: "hidden",
75
+ scrollBehavior: "unset"
76
+ }), o.scrollTop = r, o.scrollLeft = i, t.setAttribute("data-base-ui-scroll-locked", ""), t.style.scrollBehavior = "unset";
77
+ }
78
+ function y() {
79
+ Object.assign(t.style, Y), Object.assign(o.style, C), c || (t.scrollTop = r, t.scrollLeft = i, t.removeAttribute("data-base-ui-scroll-locked"), t.style.scrollBehavior = O);
80
+ }
81
+ function L() {
82
+ y(), u.request(f);
83
+ }
84
+ f();
85
+ const X = T(l, "resize", L);
86
+ return () => {
87
+ u.cancel(), y(), typeof l.removeEventListener == "function" && X();
88
+ };
89
+ }
90
+ class A {
91
+ lockCount = 0;
92
+ restore = null;
93
+ timeoutLock = k.create();
94
+ timeoutUnlock = k.create();
95
+ acquire(e) {
96
+ return this.lockCount += 1, this.lockCount === 1 && this.restore === null && this.timeoutLock.start(0, () => this.lock(e)), this.release;
97
+ }
98
+ release = () => {
99
+ this.lockCount -= 1, this.lockCount === 0 && this.restore && this.timeoutUnlock.start(0, this.unlock);
100
+ };
101
+ unlock = () => {
102
+ this.lockCount === 0 && this.restore && (this.restore?.(), this.restore = null);
103
+ };
104
+ lock(e) {
105
+ if (this.lockCount === 0 || this.restore !== null)
106
+ return;
107
+ const o = a(e).documentElement, l = d(o).getComputedStyle(o).overflowY;
108
+ if (l === "hidden" || l === "clip") {
109
+ this.restore = F;
110
+ return;
111
+ }
112
+ const r = E || !R(e);
113
+ this.restore = r ? V(e) : q(e);
114
+ }
115
+ }
116
+ const K = new A();
117
+ function tt(s = !0, e = null) {
118
+ z(() => {
119
+ if (s)
120
+ return K.acquire(e);
121
+ }, [s, e]);
32
122
  }
33
123
  export {
34
- C as useSyncedFloatingRootContext
124
+ tt as useScrollLock
35
125
  };
36
126
  //# sourceMappingURL=index348.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index348.js","sources":["../../../node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js"],"sourcesContent":["'use client';\n\nimport { useId } from '@base-ui/utils/useId';\nimport { useRefWithInit } from '@base-ui/utils/useRefWithInit';\nimport { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';\nimport { isElement } from '@floating-ui/utils/dom';\nimport { useFloatingParentNodeId } from \"../components/FloatingTree.js\";\nimport { FloatingRootStore } from \"../components/FloatingRootStore.js\";\n/**\n * Initializes a FloatingRootStore that is kept in sync with the provided PopupStore.\n * The new instance is created only once and updated on every render.\n */\nexport function useSyncedFloatingRootContext(options) {\n const {\n popupStore,\n treatPopupAsFloatingElement = false,\n onOpenChange\n } = options;\n const floatingId = useId();\n const nested = useFloatingParentNodeId() != null;\n const open = popupStore.useState('open');\n const referenceElement = popupStore.useState('activeTriggerElement');\n const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? 'popupElement' : 'positionerElement');\n const triggerElements = popupStore.context.triggerElements;\n const store = useRefWithInit(() => new FloatingRootStore({\n open,\n transitionStatus: undefined,\n referenceElement,\n floatingElement,\n triggerElements,\n onOpenChange,\n floatingId,\n syncOnly: true,\n nested\n })).current;\n useIsoLayoutEffect(() => {\n const valuesToSync = {\n open,\n floatingId,\n referenceElement,\n floatingElement\n };\n if (isElement(referenceElement)) {\n valuesToSync.domReferenceElement = referenceElement;\n }\n if (store.state.positionReference === store.state.referenceElement) {\n valuesToSync.positionReference = referenceElement;\n }\n store.update(valuesToSync);\n }, [open, floatingId, referenceElement, floatingElement, store]);\n\n // TODO: When `setOpen` is a part of the PopupStore API, we don't need to sync it.\n store.context.onOpenChange = onOpenChange;\n store.context.nested = nested;\n return store;\n}"],"names":["useSyncedFloatingRootContext","options","popupStore","treatPopupAsFloatingElement","onOpenChange","floatingId","useId","nested","useFloatingParentNodeId","open","referenceElement","floatingElement","triggerElements","store","useRefWithInit","FloatingRootStore","useIsoLayoutEffect","valuesToSync","isElement"],"mappings":";;;;;;AAYO,SAASA,EAA6BC,GAAS;AACpD,QAAM;AAAA,IACJ,YAAAC;AAAA,IACA,6BAAAC,IAA8B;AAAA,IAC9B,cAAAC;AAAA,EACJ,IAAMH,GACEI,IAAaC,EAAK,GAClBC,IAASC,EAAuB,KAAM,MACtCC,IAAOP,EAAW,SAAS,MAAM,GACjCQ,IAAmBR,EAAW,SAAS,sBAAsB,GAC7DS,IAAkBT,EAAW,SAASC,IAA8B,iBAAiB,mBAAmB,GACxGS,IAAkBV,EAAW,QAAQ,iBACrCW,IAAQC,EAAe,MAAM,IAAIC,EAAkB;AAAA,IACvD,MAAAN;AAAA,IACA,kBAAkB;AAAA,IAClB,kBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,cAAAR;AAAA,IACA,YAAAC;AAAA,IACA,UAAU;AAAA,IACV,QAAAE;AAAA,EACJ,CAAG,CAAC,EAAE;AACJ,SAAAS,EAAmB,MAAM;AACvB,UAAMC,IAAe;AAAA,MACnB,MAAAR;AAAA,MACA,YAAAJ;AAAA,MACA,kBAAAK;AAAA,MACA,iBAAAC;AAAA,IACN;AACI,IAAIO,EAAUR,CAAgB,MAC5BO,EAAa,sBAAsBP,IAEjCG,EAAM,MAAM,sBAAsBA,EAAM,MAAM,qBAChDI,EAAa,oBAAoBP,IAEnCG,EAAM,OAAOI,CAAY;AAAA,EAC3B,GAAG,CAACR,GAAMJ,GAAYK,GAAkBC,GAAiBE,CAAK,CAAC,GAG/DA,EAAM,QAAQ,eAAeT,GAC7BS,EAAM,QAAQ,SAASN,GAChBM;AACT;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index348.js","sources":["../../../node_modules/@base-ui/utils/esm/useScrollLock.js"],"sourcesContent":["'use client';\n\nimport { isOverflowElement } from '@floating-ui/utils/dom';\nimport { addEventListener } from \"./addEventListener.js\";\nimport { isIOS, isWebKit } from \"./detectBrowser.js\";\nimport { ownerDocument, ownerWindow } from \"./owner.js\";\nimport { useIsoLayoutEffect } from \"./useIsoLayoutEffect.js\";\nimport { Timeout } from \"./useTimeout.js\";\nimport { AnimationFrame } from \"./useAnimationFrame.js\";\nimport { NOOP } from \"./empty.js\";\nlet originalHtmlStyles = {};\nlet originalBodyStyles = {};\nlet originalHtmlScrollBehavior = '';\nfunction hasInsetScrollbars(referenceElement) {\n if (typeof document === 'undefined') {\n return false;\n }\n const doc = ownerDocument(referenceElement);\n const win = ownerWindow(doc);\n return win.innerWidth - doc.documentElement.clientWidth > 0;\n}\nfunction supportsStableScrollbarGutter(referenceElement) {\n const supported = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('scrollbar-gutter', 'stable');\n if (!supported || typeof document === 'undefined') {\n return false;\n }\n const doc = ownerDocument(referenceElement);\n const html = doc.documentElement;\n const body = doc.body;\n const scrollContainer = isOverflowElement(html) ? html : body;\n const originalScrollContainerOverflowY = scrollContainer.style.overflowY;\n const originalHtmlStyleGutter = html.style.scrollbarGutter;\n html.style.scrollbarGutter = 'stable';\n scrollContainer.style.overflowY = 'scroll';\n const before = scrollContainer.offsetWidth;\n scrollContainer.style.overflowY = 'hidden';\n const after = scrollContainer.offsetWidth;\n scrollContainer.style.overflowY = originalScrollContainerOverflowY;\n html.style.scrollbarGutter = originalHtmlStyleGutter;\n return before === after;\n}\nfunction preventScrollOverlayScrollbars(referenceElement) {\n const doc = ownerDocument(referenceElement);\n const html = doc.documentElement;\n const body = doc.body;\n\n // If an `overflow` style is present on <html>, we need to lock it, because a lock on <body>\n // won't have any effect.\n // But if <body> has an `overflow` style (like `overflow-x: hidden`), we need to lock it\n // instead, as sticky elements shift otherwise.\n const elementToLock = isOverflowElement(html) ? html : body;\n const originalElementToLockStyles = {\n overflowY: elementToLock.style.overflowY,\n overflowX: elementToLock.style.overflowX\n };\n Object.assign(elementToLock.style, {\n overflowY: 'hidden',\n overflowX: 'hidden'\n });\n return () => {\n Object.assign(elementToLock.style, originalElementToLockStyles);\n };\n}\nfunction preventScrollInsetScrollbars(referenceElement) {\n const doc = ownerDocument(referenceElement);\n const html = doc.documentElement;\n const body = doc.body;\n const win = ownerWindow(html);\n let scrollTop = 0;\n let scrollLeft = 0;\n let updateGutterOnly = false;\n const resizeFrame = AnimationFrame.create();\n\n // Pinch-zoom in Safari causes a shift. Just don't lock scroll if there's any pinch-zoom.\n if (isWebKit && (win.visualViewport?.scale ?? 1) !== 1) {\n return () => {};\n }\n function lockScroll() {\n /* DOM reads: */\n\n const htmlStyles = win.getComputedStyle(html);\n const bodyStyles = win.getComputedStyle(body);\n const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || '';\n const hasBothEdges = htmlScrollbarGutterValue.includes('both-edges');\n const scrollbarGutterValue = hasBothEdges ? 'stable both-edges' : 'stable';\n scrollTop = html.scrollTop;\n scrollLeft = html.scrollLeft;\n originalHtmlStyles = {\n scrollbarGutter: html.style.scrollbarGutter,\n overflowY: html.style.overflowY,\n overflowX: html.style.overflowX\n };\n originalHtmlScrollBehavior = html.style.scrollBehavior;\n originalBodyStyles = {\n position: body.style.position,\n height: body.style.height,\n width: body.style.width,\n boxSizing: body.style.boxSizing,\n overflowY: body.style.overflowY,\n overflowX: body.style.overflowX,\n scrollBehavior: body.style.scrollBehavior\n };\n const isScrollableY = html.scrollHeight > html.clientHeight;\n const isScrollableX = html.scrollWidth > html.clientWidth;\n const hasConstantOverflowY = htmlStyles.overflowY === 'scroll' || bodyStyles.overflowY === 'scroll';\n const hasConstantOverflowX = htmlStyles.overflowX === 'scroll' || bodyStyles.overflowX === 'scroll';\n\n // Values can be negative in Firefox\n const scrollbarWidth = Math.max(0, win.innerWidth - body.clientWidth);\n const scrollbarHeight = Math.max(0, win.innerHeight - body.clientHeight);\n\n // Avoid shift due to the default <body> margin. This does cause elements to be clipped\n // with whitespace. Warn if <body> has margins?\n const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom);\n const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight);\n const elementToLock = isOverflowElement(html) ? html : body;\n updateGutterOnly = supportsStableScrollbarGutter(referenceElement);\n\n /*\n * DOM writes:\n * Do not read the DOM past this point!\n */\n\n if (updateGutterOnly) {\n html.style.scrollbarGutter = scrollbarGutterValue;\n elementToLock.style.overflowY = 'hidden';\n elementToLock.style.overflowX = 'hidden';\n return;\n }\n Object.assign(html.style, {\n scrollbarGutter: scrollbarGutterValue,\n overflowY: 'hidden',\n overflowX: 'hidden'\n });\n if (isScrollableY || hasConstantOverflowY) {\n html.style.overflowY = 'scroll';\n }\n if (isScrollableX || hasConstantOverflowX) {\n html.style.overflowX = 'scroll';\n }\n Object.assign(body.style, {\n position: 'relative',\n height: marginY || scrollbarHeight ? `calc(100dvh - ${marginY + scrollbarHeight}px)` : '100dvh',\n width: marginX || scrollbarWidth ? `calc(100vw - ${marginX + scrollbarWidth}px)` : '100vw',\n boxSizing: 'border-box',\n overflow: 'hidden',\n scrollBehavior: 'unset'\n });\n body.scrollTop = scrollTop;\n body.scrollLeft = scrollLeft;\n html.setAttribute('data-base-ui-scroll-locked', '');\n html.style.scrollBehavior = 'unset';\n }\n function cleanup() {\n Object.assign(html.style, originalHtmlStyles);\n Object.assign(body.style, originalBodyStyles);\n if (!updateGutterOnly) {\n html.scrollTop = scrollTop;\n html.scrollLeft = scrollLeft;\n html.removeAttribute('data-base-ui-scroll-locked');\n html.style.scrollBehavior = originalHtmlScrollBehavior;\n }\n }\n function handleResize() {\n cleanup();\n resizeFrame.request(lockScroll);\n }\n lockScroll();\n const unsubscribeResize = addEventListener(win, 'resize', handleResize);\n return () => {\n resizeFrame.cancel();\n cleanup();\n // Sometimes this cleanup can run after test teardown because it is called\n // in a `setTimeout(fn, 0)`. Guard the returned cleanup to avoid calling\n // `removeEventListener` when it is no longer available in tests.\n if (typeof win.removeEventListener === 'function') {\n unsubscribeResize();\n }\n };\n}\nclass ScrollLocker {\n lockCount = 0;\n restore = null;\n timeoutLock = Timeout.create();\n timeoutUnlock = Timeout.create();\n acquire(referenceElement) {\n this.lockCount += 1;\n if (this.lockCount === 1 && this.restore === null) {\n this.timeoutLock.start(0, () => this.lock(referenceElement));\n }\n return this.release;\n }\n release = () => {\n this.lockCount -= 1;\n if (this.lockCount === 0 && this.restore) {\n this.timeoutUnlock.start(0, this.unlock);\n }\n };\n unlock = () => {\n if (this.lockCount === 0 && this.restore) {\n this.restore?.();\n this.restore = null;\n }\n };\n lock(referenceElement) {\n if (this.lockCount === 0 || this.restore !== null) {\n return;\n }\n const doc = ownerDocument(referenceElement);\n const html = doc.documentElement;\n const htmlOverflowY = ownerWindow(html).getComputedStyle(html).overflowY;\n\n // If the site author already hid overflow on <html>, respect it and bail out.\n if (htmlOverflowY === 'hidden' || htmlOverflowY === 'clip') {\n this.restore = NOOP;\n return;\n }\n const hasOverlayScrollbars = isIOS || !hasInsetScrollbars(referenceElement);\n\n // On iOS, scroll locking does not work if the navbar is collapsed. Due to numerous\n // side effects and bugs that arise on iOS, it must be researched extensively before\n // being enabled to ensure it doesn't cause the following issues:\n // - Textboxes must scroll into view when focused, nor cause a glitchy scroll animation.\n // - The navbar must not force itself into view and cause layout shift.\n // - Scroll containers must not flicker upon closing a popup when it has an exit animation.\n this.restore = hasOverlayScrollbars ? preventScrollOverlayScrollbars(referenceElement) : preventScrollInsetScrollbars(referenceElement);\n }\n}\nconst SCROLL_LOCKER = new ScrollLocker();\n\n/**\n * Locks the scroll of the document when enabled.\n *\n * @param enabled - Whether to enable the scroll lock.\n * @param referenceElement - Element to use as a reference for lock calculations.\n */\nexport function useScrollLock(enabled = true, referenceElement = null) {\n useIsoLayoutEffect(() => {\n if (!enabled) {\n return undefined;\n }\n return SCROLL_LOCKER.acquire(referenceElement);\n }, [enabled, referenceElement]);\n}"],"names":["originalHtmlStyles","originalBodyStyles","originalHtmlScrollBehavior","hasInsetScrollbars","referenceElement","doc","ownerDocument","ownerWindow","supportsStableScrollbarGutter","html","body","scrollContainer","isOverflowElement","originalScrollContainerOverflowY","originalHtmlStyleGutter","before","after","preventScrollOverlayScrollbars","elementToLock","originalElementToLockStyles","preventScrollInsetScrollbars","win","scrollTop","scrollLeft","updateGutterOnly","resizeFrame","AnimationFrame","isWebKit","lockScroll","htmlStyles","bodyStyles","scrollbarGutterValue","isScrollableY","isScrollableX","hasConstantOverflowY","hasConstantOverflowX","scrollbarWidth","scrollbarHeight","marginY","marginX","cleanup","handleResize","unsubscribeResize","addEventListener","ScrollLocker","Timeout","htmlOverflowY","NOOP","hasOverlayScrollbars","isIOS","SCROLL_LOCKER","useScrollLock","enabled","useIsoLayoutEffect"],"mappings":";;;;;;;;AAUA,IAAIA,IAAqB,CAAA,GACrBC,IAAqB,CAAA,GACrBC,IAA6B;AACjC,SAASC,EAAmBC,GAAkB;AAC5C,MAAI,OAAO,WAAa;AACtB,WAAO;AAET,QAAMC,IAAMC,EAAcF,CAAgB;AAE1C,SADYG,EAAYF,CAAG,EAChB,aAAaA,EAAI,gBAAgB,cAAc;AAC5D;AACA,SAASG,EAA8BJ,GAAkB;AAEvD,MAAI,EADc,OAAO,MAAQ,OAAe,IAAI,YAAY,IAAI,SAAS,oBAAoB,QAAQ,MACvF,OAAO,WAAa;AACpC,WAAO;AAET,QAAMC,IAAMC,EAAcF,CAAgB,GACpCK,IAAOJ,EAAI,iBACXK,IAAOL,EAAI,MACXM,IAAkBC,EAAkBH,CAAI,IAAIA,IAAOC,GACnDG,IAAmCF,EAAgB,MAAM,WACzDG,IAA0BL,EAAK,MAAM;AAC3C,EAAAA,EAAK,MAAM,kBAAkB,UAC7BE,EAAgB,MAAM,YAAY;AAClC,QAAMI,IAASJ,EAAgB;AAC/B,EAAAA,EAAgB,MAAM,YAAY;AAClC,QAAMK,IAAQL,EAAgB;AAC9B,SAAAA,EAAgB,MAAM,YAAYE,GAClCJ,EAAK,MAAM,kBAAkBK,GACtBC,MAAWC;AACpB;AACA,SAASC,EAA+Bb,GAAkB;AACxD,QAAMC,IAAMC,EAAcF,CAAgB,GACpCK,IAAOJ,EAAI,iBACXK,IAAOL,EAAI,MAMXa,IAAgBN,EAAkBH,CAAI,IAAIA,IAAOC,GACjDS,IAA8B;AAAA,IAClC,WAAWD,EAAc,MAAM;AAAA,IAC/B,WAAWA,EAAc,MAAM;AAAA,EACnC;AACE,gBAAO,OAAOA,EAAc,OAAO;AAAA,IACjC,WAAW;AAAA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vB,QAAKD;AAGL,aAAOF,EAAc,QAAQ9C,CAAgB;AAAA,EAC/C,GAAG,CAACgD,GAAShD,CAAgB,CAAC;AAChC;","x_google_ignoreList":[0]}
package/dist/index349.js CHANGED
@@ -1,77 +1,36 @@
1
- import * as r from "react";
2
- import { useId as E } from "./index345.js";
3
- import { EMPTY_OBJECT as P } from "./index264.js";
4
- import { getFloatingFocusElement as S } from "./index290.js";
5
- import { useFloatingParentNodeId as F } from "./index382.js";
6
- const y = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
7
- function $(c, g = {}) {
8
- const a = "rootStore" in c ? c.rootStore : c, l = a.useState("open"), u = a.useState("floatingId"), I = a.useState("domReferenceElement"), d = a.useState("floatingElement"), {
9
- role: o = "dialog"
10
- } = g, x = E(), s = I?.id || x, t = r.useMemo(() => S(d)?.id || u, [d, u]), e = y.get(o) ?? o, m = F() != null, i = r.useMemo(() => e === "tooltip" || o === "label" ? P : {
11
- "aria-haspopup": e === "alertdialog" ? "dialog" : e,
12
- "aria-expanded": "false",
13
- ...e === "listbox" && {
14
- role: "combobox"
15
- },
16
- ...e === "menu" && m && {
17
- role: "menuitem"
18
- },
19
- ...o === "select" && {
20
- "aria-autocomplete": "none"
21
- },
22
- ...o === "combobox" && {
23
- "aria-autocomplete": "list"
24
- }
25
- }, [e, m, o]), p = r.useMemo(() => e === "tooltip" || o === "label" ? {
26
- [`aria-${o === "label" ? "labelledby" : "describedby"}`]: l ? t : void 0
27
- } : {
28
- ...i,
29
- "aria-expanded": l ? "true" : "false",
30
- "aria-controls": l ? t : void 0,
31
- ...e === "menu" && {
32
- id: s
33
- }
34
- }, [e, t, l, s, o, i]), f = r.useMemo(() => {
35
- const n = {
36
- id: t,
37
- ...e && {
38
- role: e
39
- }
1
+ import { useId as f } from "./index345.js";
2
+ import { useRefWithInit as u } from "./index280.js";
3
+ import { useIsoLayoutEffect as g } from "./index283.js";
4
+ import { isElement as E } from "./index331.js";
5
+ import { useFloatingParentNodeId as d } from "./index382.js";
6
+ import { FloatingRootStore as S } from "./index384.js";
7
+ function C(p) {
8
+ const {
9
+ popupStore: n,
10
+ treatPopupAsFloatingElement: a = !1,
11
+ onOpenChange: c
12
+ } = p, o = f(), m = d() != null, r = n.useState("open"), t = n.useState("activeTriggerElement"), s = n.useState(a ? "popupElement" : "positionerElement"), l = n.context.triggerElements, e = u(() => new S({
13
+ open: r,
14
+ transitionStatus: void 0,
15
+ referenceElement: t,
16
+ floatingElement: s,
17
+ triggerElements: l,
18
+ onOpenChange: c,
19
+ floatingId: o,
20
+ syncOnly: !0,
21
+ nested: m
22
+ })).current;
23
+ return g(() => {
24
+ const i = {
25
+ open: r,
26
+ floatingId: o,
27
+ referenceElement: t,
28
+ floatingElement: s
40
29
  };
41
- return e === "tooltip" || o === "label" ? n : {
42
- ...n,
43
- ...e === "menu" && {
44
- "aria-labelledby": s
45
- }
46
- };
47
- }, [e, t, s, o]), b = r.useCallback(({
48
- active: n,
49
- selected: M
50
- }) => {
51
- const R = {
52
- role: "option",
53
- ...n && {
54
- id: `${t}-fui-option`
55
- }
56
- };
57
- switch (o) {
58
- case "select":
59
- case "combobox":
60
- return {
61
- ...R,
62
- "aria-selected": M
63
- };
64
- }
65
- return {};
66
- }, [t, o]);
67
- return r.useMemo(() => ({
68
- reference: p,
69
- floating: f,
70
- item: b,
71
- trigger: i
72
- }), [p, f, i, b]);
30
+ E(t) && (i.domReferenceElement = t), e.state.positionReference === e.state.referenceElement && (i.positionReference = t), e.update(i);
31
+ }, [r, o, t, s, e]), e.context.onOpenChange = c, e.context.nested = m, e;
73
32
  }
74
33
  export {
75
- $ as useRole
34
+ C as useSyncedFloatingRootContext
76
35
  };
77
36
  //# sourceMappingURL=index349.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index349.js","sources":["../../../node_modules/@base-ui/react/esm/floating-ui-react/hooks/useRole.js"],"sourcesContent":["import * as React from 'react';\nimport { useId } from '@base-ui/utils/useId';\nimport { EMPTY_OBJECT } from '@base-ui/utils/empty';\nimport { getFloatingFocusElement } from \"../utils/element.js\";\nimport { useFloatingParentNodeId } from \"../components/FloatingTree.js\";\nconst componentRoleToAriaRoleMap = new Map([['select', 'listbox'], ['combobox', 'listbox'], ['label', false]]);\n\n/**\n * Adds base screen reader props to the reference and floating elements for a\n * given floating element `role`.\n * @see https://floating-ui.com/docs/useRole\n */\nexport function useRole(context, props = {}) {\n const store = 'rootStore' in context ? context.rootStore : context;\n const open = store.useState('open');\n const defaultFloatingId = store.useState('floatingId');\n const domReference = store.useState('domReferenceElement');\n const floatingElement = store.useState('floatingElement');\n const {\n role = 'dialog'\n } = props;\n const defaultReferenceId = useId();\n const referenceId = domReference?.id || defaultReferenceId;\n const floatingId = React.useMemo(() => getFloatingFocusElement(floatingElement)?.id || defaultFloatingId, [floatingElement, defaultFloatingId]);\n const ariaRole = componentRoleToAriaRoleMap.get(role) ?? role;\n const parentId = useFloatingParentNodeId();\n const isNested = parentId != null;\n const trigger = React.useMemo(() => {\n if (ariaRole === 'tooltip' || role === 'label') {\n return EMPTY_OBJECT;\n }\n return {\n 'aria-haspopup': ariaRole === 'alertdialog' ? 'dialog' : ariaRole,\n 'aria-expanded': 'false',\n ...(ariaRole === 'listbox' && {\n role: 'combobox'\n }),\n ...(ariaRole === 'menu' && isNested && {\n role: 'menuitem'\n }),\n ...(role === 'select' && {\n 'aria-autocomplete': 'none'\n }),\n ...(role === 'combobox' && {\n 'aria-autocomplete': 'list'\n })\n };\n }, [ariaRole, isNested, role]);\n const reference = React.useMemo(() => {\n if (ariaRole === 'tooltip' || role === 'label') {\n return {\n [`aria-${role === 'label' ? 'labelledby' : 'describedby'}`]: open ? floatingId : undefined\n };\n }\n const triggerProps = trigger;\n return {\n ...triggerProps,\n 'aria-expanded': open ? 'true' : 'false',\n 'aria-controls': open ? floatingId : undefined,\n ...(ariaRole === 'menu' && {\n id: referenceId\n })\n };\n }, [ariaRole, floatingId, open, referenceId, role, trigger]);\n const floating = React.useMemo(() => {\n const floatingProps = {\n id: floatingId,\n ...(ariaRole && {\n role: ariaRole\n })\n };\n if (ariaRole === 'tooltip' || role === 'label') {\n return floatingProps;\n }\n return {\n ...floatingProps,\n ...(ariaRole === 'menu' && {\n 'aria-labelledby': referenceId\n })\n };\n }, [ariaRole, floatingId, referenceId, role]);\n const item = React.useCallback(({\n active,\n selected\n }) => {\n const commonProps = {\n role: 'option',\n ...(active && {\n id: `${floatingId}-fui-option`\n })\n };\n\n // For `menu`, we are unable to tell if the item is a `menuitemradio`\n // or `menuitemcheckbox`. For backwards-compatibility reasons, also\n // avoid defaulting to `menuitem` as it may overwrite custom role props.\n switch (role) {\n case 'select':\n case 'combobox':\n return {\n ...commonProps,\n 'aria-selected': selected\n };\n default:\n }\n return {};\n }, [floatingId, role]);\n return React.useMemo(() => ({\n reference,\n floating,\n item,\n trigger\n }), [reference, floating, trigger, item]);\n}"],"names":["componentRoleToAriaRoleMap","useRole","context","props","store","open","defaultFloatingId","domReference","floatingElement","role","defaultReferenceId","useId","referenceId","floatingId","React","getFloatingFocusElement","ariaRole","isNested","useFloatingParentNodeId","trigger","EMPTY_OBJECT","reference","floating","floatingProps","item","active","selected","commonProps"],"mappings":";;;;;AAKA,MAAMA,IAA6B,oBAAI,IAAI,CAAC,CAAC,UAAU,SAAS,GAAG,CAAC,YAAY,SAAS,GAAG,CAAC,SAAS,EAAK,CAAC,CAAC;AAOtG,SAASC,EAAQC,GAASC,IAAQ,IAAI;AAC3C,QAAMC,IAAQ,eAAeF,IAAUA,EAAQ,YAAYA,GACrDG,IAAOD,EAAM,SAAS,MAAM,GAC5BE,IAAoBF,EAAM,SAAS,YAAY,GAC/CG,IAAeH,EAAM,SAAS,qBAAqB,GACnDI,IAAkBJ,EAAM,SAAS,iBAAiB,GAClD;AAAA,IACJ,MAAAK,IAAO;AAAA,EACX,IAAMN,GACEO,IAAqBC,EAAK,GAC1BC,IAAcL,GAAc,MAAMG,GAClCG,IAAaC,EAAM,QAAQ,MAAMC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AAAA,EACE,GAAG,CAACI,GAAUH,GAAYD,GAAaH,CAAI,CAAC,GACtCe,IAAOV,EAAM,YAAY,CAAC;AAAA,IAC9B,QAAAW;AAAA,IACA,UAAAC;AAAA,EACJ,MAAQ;AACJ,UAAMC,IAAc;AAAA,MAClB,MAAM;AAAA,MACN,GAAIF,KAAU;AAAA,QACZ,IAAI,GAAGZ,CAAU;AAAA,MACzB;AAAA,IACA;AAKI,YAAQJ,GAAI;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AACH,eAAO;AAAA,UACL,GAAGkB;AAAA,UACH,iBAAiBD;AAAA,QAC3B;AAAA,IAEA;AACI,WAAO,CAAA;AAAA,EACT,GAAG,CAACb,GAAYJ,CAAI,CAAC;AACrB,SAAOK,EAAM,QAAQ,OAAO;AAAA,IAC1B,WAAAO;AAAA,IACA,UAAAC;AAAA,IACA,MAAAE;AAAA,IACA,SAAAL;AAAA,EACJ,IAAM,CAACE,GAAWC,GAAUH,GAASK,CAAI,CAAC;AAC1C;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index349.js","sources":["../../../node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js"],"sourcesContent":["'use client';\n\nimport { useId } from '@base-ui/utils/useId';\nimport { useRefWithInit } from '@base-ui/utils/useRefWithInit';\nimport { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';\nimport { isElement } from '@floating-ui/utils/dom';\nimport { useFloatingParentNodeId } from \"../components/FloatingTree.js\";\nimport { FloatingRootStore } from \"../components/FloatingRootStore.js\";\n/**\n * Initializes a FloatingRootStore that is kept in sync with the provided PopupStore.\n * The new instance is created only once and updated on every render.\n */\nexport function useSyncedFloatingRootContext(options) {\n const {\n popupStore,\n treatPopupAsFloatingElement = false,\n onOpenChange\n } = options;\n const floatingId = useId();\n const nested = useFloatingParentNodeId() != null;\n const open = popupStore.useState('open');\n const referenceElement = popupStore.useState('activeTriggerElement');\n const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? 'popupElement' : 'positionerElement');\n const triggerElements = popupStore.context.triggerElements;\n const store = useRefWithInit(() => new FloatingRootStore({\n open,\n transitionStatus: undefined,\n referenceElement,\n floatingElement,\n triggerElements,\n onOpenChange,\n floatingId,\n syncOnly: true,\n nested\n })).current;\n useIsoLayoutEffect(() => {\n const valuesToSync = {\n open,\n floatingId,\n referenceElement,\n floatingElement\n };\n if (isElement(referenceElement)) {\n valuesToSync.domReferenceElement = referenceElement;\n }\n if (store.state.positionReference === store.state.referenceElement) {\n valuesToSync.positionReference = referenceElement;\n }\n store.update(valuesToSync);\n }, [open, floatingId, referenceElement, floatingElement, store]);\n\n // TODO: When `setOpen` is a part of the PopupStore API, we don't need to sync it.\n store.context.onOpenChange = onOpenChange;\n store.context.nested = nested;\n return store;\n}"],"names":["useSyncedFloatingRootContext","options","popupStore","treatPopupAsFloatingElement","onOpenChange","floatingId","useId","nested","useFloatingParentNodeId","open","referenceElement","floatingElement","triggerElements","store","useRefWithInit","FloatingRootStore","useIsoLayoutEffect","valuesToSync","isElement"],"mappings":";;;;;;AAYO,SAASA,EAA6BC,GAAS;AACpD,QAAM;AAAA,IACJ,YAAAC;AAAA,IACA,6BAAAC,IAA8B;AAAA,IAC9B,cAAAC;AAAA,EACJ,IAAMH,GACEI,IAAaC,EAAK,GAClBC,IAASC,EAAuB,KAAM,MACtCC,IAAOP,EAAW,SAAS,MAAM,GACjCQ,IAAmBR,EAAW,SAAS,sBAAsB,GAC7DS,IAAkBT,EAAW,SAASC,IAA8B,iBAAiB,mBAAmB,GACxGS,IAAkBV,EAAW,QAAQ,iBACrCW,IAAQC,EAAe,MAAM,IAAIC,EAAkB;AAAA,IACvD,MAAAN;AAAA,IACA,kBAAkB;AAAA,IAClB,kBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,cAAAR;AAAA,IACA,YAAAC;AAAA,IACA,UAAU;AAAA,IACV,QAAAE;AAAA,EACJ,CAAG,CAAC,EAAE;AACJ,SAAAS,EAAmB,MAAM;AACvB,UAAMC,IAAe;AAAA,MACnB,MAAAR;AAAA,MACA,YAAAJ;AAAA,MACA,kBAAAK;AAAA,MACA,iBAAAC;AAAA,IACN;AACI,IAAIO,EAAUR,CAAgB,MAC5BO,EAAa,sBAAsBP,IAEjCG,EAAM,MAAM,sBAAsBA,EAAM,MAAM,qBAChDI,EAAa,oBAAoBP,IAEnCG,EAAM,OAAOI,CAAY;AAAA,EAC3B,GAAG,CAACR,GAAMJ,GAAYK,GAAkBC,GAAiBE,CAAK,CAAC,GAG/DA,EAAM,QAAQ,eAAeT,GAC7BS,EAAM,QAAQ,SAASN,GAChBM;AACT;","x_google_ignoreList":[0]}
package/dist/index350.js CHANGED
@@ -1,146 +1,77 @@
1
- import * as u from "react";
2
- import { Store as l } from "./index283.js";
3
- import { useStore as a } from "./index277.js";
4
- import { useStableCallback as f } from "./index262.js";
5
- import { useIsoLayoutEffect as c } from "./index261.js";
6
- import { NOOP as h } from "./index264.js";
7
- class g extends l {
8
- /**
9
- * Creates a new ReactStore instance.
10
- *
11
- * @param state Initial state of the store.
12
- * @param context Non-reactive context values.
13
- * @param selectors Optional selectors for use with `useState`.
14
- */
15
- constructor(e, t = {}, s) {
16
- super(e), this.context = t, this.selectors = s;
17
- }
18
- /**
19
- * Non-reactive values such as refs, callbacks, etc.
20
- */
21
- /**
22
- * Synchronizes a single external value into the store.
23
- *
24
- * Note that the while the value in `state` is updated immediately, the value returned
25
- * by `useState` is updated before the next render (similarly to React's `useState`).
26
- */
27
- useSyncedValue(e, t) {
28
- u.useDebugValue(e), c(() => {
29
- this.state[e] !== t && this.set(e, t);
30
- }, [e, t]);
31
- }
32
- /**
33
- * Synchronizes a single external value into the store and
34
- * cleans it up (sets to `undefined`) on unmount.
35
- *
36
- * Note that the while the value in `state` is updated immediately, the value returned
37
- * by `useState` is updated before the next render (similarly to React's `useState`).
38
- */
39
- useSyncedValueWithCleanup(e, t) {
40
- const s = this;
41
- c(() => (s.state[e] !== t && s.set(e, t), () => {
42
- s.set(e, void 0);
43
- }), [s, e, t]);
44
- }
45
- /**
46
- * Synchronizes multiple external values into the store.
47
- *
48
- * Note that the while the values in `state` are updated immediately, the values returned
49
- * by `useState` are updated before the next render (similarly to React's `useState`).
50
- */
51
- useSyncedValues(e) {
52
- const t = this;
53
- if (process.env.NODE_ENV !== "production") {
54
- u.useDebugValue(e, (r) => Object.keys(r));
55
- const o = u.useRef(Object.keys(e)).current, n = Object.keys(e);
56
- (o.length !== n.length || o.some((r, i) => r !== n[i])) && console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
1
+ import * as r from "react";
2
+ import { useId as E } from "./index345.js";
3
+ import { EMPTY_OBJECT as P } from "./index286.js";
4
+ import { getFloatingFocusElement as S } from "./index312.js";
5
+ import { useFloatingParentNodeId as F } from "./index382.js";
6
+ const y = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", !1]]);
7
+ function $(c, g = {}) {
8
+ const a = "rootStore" in c ? c.rootStore : c, l = a.useState("open"), u = a.useState("floatingId"), I = a.useState("domReferenceElement"), d = a.useState("floatingElement"), {
9
+ role: o = "dialog"
10
+ } = g, x = E(), s = I?.id || x, t = r.useMemo(() => S(d)?.id || u, [d, u]), e = y.get(o) ?? o, m = F() != null, i = r.useMemo(() => e === "tooltip" || o === "label" ? P : {
11
+ "aria-haspopup": e === "alertdialog" ? "dialog" : e,
12
+ "aria-expanded": "false",
13
+ ...e === "listbox" && {
14
+ role: "combobox"
15
+ },
16
+ ...e === "menu" && m && {
17
+ role: "menuitem"
18
+ },
19
+ ...o === "select" && {
20
+ "aria-autocomplete": "none"
21
+ },
22
+ ...o === "combobox" && {
23
+ "aria-autocomplete": "list"
57
24
  }
58
- const s = Object.values(e);
59
- c(() => {
60
- t.update(e);
61
- }, [t, ...s]);
62
- }
63
- /**
64
- * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
65
- * is non-undefined, the store's state at `key` is updated to match `controlled`.
66
- */
67
- useControlledProp(e, t) {
68
- u.useDebugValue(e);
69
- const s = t !== void 0;
70
- if (c(() => {
71
- s && !Object.is(this.state[e], t) && super.setState({
72
- ...this.state,
73
- [e]: t
74
- });
75
- }, [e, t, s]), process.env.NODE_ENV !== "production") {
76
- const o = this.controlledValues ??= /* @__PURE__ */ new Map();
77
- o.has(e) || o.set(e, s);
78
- const n = o.get(e);
79
- n !== void 0 && n !== s && console.error(`A component is changing the ${s ? "" : "un"}controlled state of ${e.toString()} to be ${s ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
25
+ }, [e, m, o]), p = r.useMemo(() => e === "tooltip" || o === "label" ? {
26
+ [`aria-${o === "label" ? "labelledby" : "describedby"}`]: l ? t : void 0
27
+ } : {
28
+ ...i,
29
+ "aria-expanded": l ? "true" : "false",
30
+ "aria-controls": l ? t : void 0,
31
+ ...e === "menu" && {
32
+ id: s
80
33
  }
81
- }
82
- /** Gets the current value from the store using a selector with the provided key.
83
- *
84
- * @param key Key of the selector to use.
85
- */
86
- select(e, t, s, o) {
87
- const n = this.selectors[e];
88
- return n(this.state, t, s, o);
89
- }
90
- /**
91
- * Returns a value from the store's state using a selector function.
92
- * Used to subscribe to specific parts of the state.
93
- * This methods causes a rerender whenever the selected state changes.
94
- *
95
- * @param key Key of the selector to use.
96
- */
97
- useState(e, t, s, o) {
98
- return u.useDebugValue(e), a(this, this.selectors[e], t, s, o);
99
- }
100
- /**
101
- * Wraps a function with `useStableCallback` to ensure it has a stable reference
102
- * and assigns it to the context.
103
- *
104
- * @param key Key of the event callback. Must be a function in the context.
105
- * @param fn Function to assign.
106
- */
107
- useContextCallback(e, t) {
108
- u.useDebugValue(e);
109
- const s = f(t ?? h);
110
- this.context[e] = s;
111
- }
112
- /**
113
- * Returns a stable setter function for a specific key in the store's state.
114
- * It's commonly used to pass as a ref callback to React elements.
115
- *
116
- * @param key Key of the state to set.
117
- */
118
- useStateSetter(e) {
119
- const t = u.useRef(void 0);
120
- return t.current === void 0 && (t.current = (s) => {
121
- this.set(e, s);
122
- }), t.current;
123
- }
124
- /**
125
- * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
126
- *
127
- * @param key Key of the selector to observe.
128
- * @param listener Listener function called when the selector result changes.
129
- */
130
- observe(e, t) {
131
- let s;
132
- typeof e == "function" ? s = e : s = this.selectors[e];
133
- let o = s(this.state);
134
- return t(o, o, this), this.subscribe((n) => {
135
- const r = s(n);
136
- if (!Object.is(o, r)) {
137
- const i = o;
138
- o = r, t(r, i, this);
34
+ }, [e, t, l, s, o, i]), f = r.useMemo(() => {
35
+ const n = {
36
+ id: t,
37
+ ...e && {
38
+ role: e
139
39
  }
140
- });
141
- }
40
+ };
41
+ return e === "tooltip" || o === "label" ? n : {
42
+ ...n,
43
+ ...e === "menu" && {
44
+ "aria-labelledby": s
45
+ }
46
+ };
47
+ }, [e, t, s, o]), b = r.useCallback(({
48
+ active: n,
49
+ selected: M
50
+ }) => {
51
+ const R = {
52
+ role: "option",
53
+ ...n && {
54
+ id: `${t}-fui-option`
55
+ }
56
+ };
57
+ switch (o) {
58
+ case "select":
59
+ case "combobox":
60
+ return {
61
+ ...R,
62
+ "aria-selected": M
63
+ };
64
+ }
65
+ return {};
66
+ }, [t, o]);
67
+ return r.useMemo(() => ({
68
+ reference: p,
69
+ floating: f,
70
+ item: b,
71
+ trigger: i
72
+ }), [p, f, i, b]);
142
73
  }
143
74
  export {
144
- g as ReactStore
75
+ $ as useRole
145
76
  };
146
77
  //# sourceMappingURL=index350.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index350.js","sources":["../../../node_modules/@base-ui/utils/esm/store/ReactStore.js"],"sourcesContent":["/* False positives - ESLint thinks we're calling a hook from a class component. */\n/* eslint-disable react-hooks/rules-of-hooks */\n'use client';\n\nimport * as React from 'react';\nimport { Store } from \"./Store.js\";\nimport { useStore } from \"./useStore.js\";\nimport { useStableCallback } from \"../useStableCallback.js\";\nimport { useIsoLayoutEffect } from \"../useIsoLayoutEffect.js\";\nimport { NOOP } from \"../empty.js\";\n\n/**\n * A Store that supports controlled state keys, non-reactive values and provides utility methods for React.\n */\nexport class ReactStore extends Store {\n /**\n * Creates a new ReactStore instance.\n *\n * @param state Initial state of the store.\n * @param context Non-reactive context values.\n * @param selectors Optional selectors for use with `useState`.\n */\n constructor(state, context = {}, selectors) {\n super(state);\n this.context = context;\n this.selectors = selectors;\n }\n\n /**\n * Non-reactive values such as refs, callbacks, etc.\n */\n\n /**\n * Synchronizes a single external value into the store.\n *\n * Note that the while the value in `state` is updated immediately, the value returned\n * by `useState` is updated before the next render (similarly to React's `useState`).\n */\n useSyncedValue(key, value) {\n React.useDebugValue(key);\n useIsoLayoutEffect(() => {\n if (this.state[key] !== value) {\n this.set(key, value);\n }\n }, [key, value]);\n }\n\n /**\n * Synchronizes a single external value into the store and\n * cleans it up (sets to `undefined`) on unmount.\n *\n * Note that the while the value in `state` is updated immediately, the value returned\n * by `useState` is updated before the next render (similarly to React's `useState`).\n */\n useSyncedValueWithCleanup(key, value) {\n // eslint-disable-next-line consistent-this\n const store = this;\n useIsoLayoutEffect(() => {\n if (store.state[key] !== value) {\n store.set(key, value);\n }\n return () => {\n store.set(key, undefined);\n };\n }, [store, key, value]);\n }\n\n /**\n * Synchronizes multiple external values into the store.\n *\n * Note that the while the values in `state` are updated immediately, the values returned\n * by `useState` are updated before the next render (similarly to React's `useState`).\n */\n useSyncedValues(statePart) {\n // eslint-disable-next-line consistent-this\n const store = this;\n if (process.env.NODE_ENV !== 'production') {\n // Check that an object with the same shape is passed on every render\n React.useDebugValue(statePart, p => Object.keys(p));\n const keys = React.useRef(Object.keys(statePart)).current;\n const nextKeys = Object.keys(statePart);\n if (keys.length !== nextKeys.length || keys.some((key, index) => key !== nextKeys[index])) {\n console.error('ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.');\n }\n }\n const dependencies = Object.values(statePart);\n useIsoLayoutEffect(() => {\n store.update(statePart);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [store, ...dependencies]);\n }\n\n /**\n * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`\n * is non-undefined, the store's state at `key` is updated to match `controlled`.\n */\n useControlledProp(key, controlled) {\n React.useDebugValue(key);\n const isControlled = controlled !== undefined;\n useIsoLayoutEffect(() => {\n if (isControlled && !Object.is(this.state[key], controlled)) {\n // Set the internal state to match the controlled value.\n super.setState({\n ...this.state,\n [key]: controlled\n });\n }\n }, [key, controlled, isControlled]);\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line\n const cache = this.controlledValues ??= new Map();\n if (!cache.has(key)) {\n cache.set(key, isControlled);\n }\n const previouslyControlled = cache.get(key);\n if (previouslyControlled !== undefined && previouslyControlled !== isControlled) {\n console.error(`A component is changing the ${isControlled ? '' : 'un'}controlled state of ${key.toString()} to be ${isControlled ? 'un' : ''}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);\n }\n }\n }\n\n /** Gets the current value from the store using a selector with the provided key.\n *\n * @param key Key of the selector to use.\n */\n\n select(key, a1, a2, a3) {\n const selector = this.selectors[key];\n return selector(this.state, a1, a2, a3);\n }\n\n /**\n * Returns a value from the store's state using a selector function.\n * Used to subscribe to specific parts of the state.\n * This methods causes a rerender whenever the selected state changes.\n *\n * @param key Key of the selector to use.\n */\n\n useState(key, a1, a2, a3) {\n React.useDebugValue(key);\n return useStore(this, this.selectors[key], a1, a2, a3);\n }\n\n /**\n * Wraps a function with `useStableCallback` to ensure it has a stable reference\n * and assigns it to the context.\n *\n * @param key Key of the event callback. Must be a function in the context.\n * @param fn Function to assign.\n */\n useContextCallback(key, fn) {\n React.useDebugValue(key);\n const stableFunction = useStableCallback(fn ?? NOOP);\n this.context[key] = stableFunction;\n }\n\n /**\n * Returns a stable setter function for a specific key in the store's state.\n * It's commonly used to pass as a ref callback to React elements.\n *\n * @param key Key of the state to set.\n */\n useStateSetter(key) {\n const ref = React.useRef(undefined);\n if (ref.current === undefined) {\n ref.current = value => {\n this.set(key, value);\n };\n }\n return ref.current;\n }\n\n /**\n * Observes changes derived from the store's selectors and calls the listener when the selected value changes.\n *\n * @param key Key of the selector to observe.\n * @param listener Listener function called when the selector result changes.\n */\n\n observe(selector, listener) {\n let selectFn;\n if (typeof selector === 'function') {\n selectFn = selector;\n } else {\n selectFn = this.selectors[selector];\n }\n let prevValue = selectFn(this.state);\n listener(prevValue, prevValue, this);\n return this.subscribe(nextState => {\n const nextValue = selectFn(nextState);\n if (!Object.is(prevValue, nextValue)) {\n const oldValue = prevValue;\n prevValue = nextValue;\n listener(nextValue, oldValue, this);\n }\n });\n }\n}"],"names":["ReactStore","Store","state","context","selectors","key","value","React","useIsoLayoutEffect","store","statePart","p","keys","nextKeys","index","dependencies","controlled","isControlled","cache","previouslyControlled","a1","a2","a3","selector","useStore","fn","stableFunction","useStableCallback","NOOP","ref","listener","selectFn","prevValue","nextState","nextValue","oldValue"],"mappings":";;;;;;AAcO,MAAMA,UAAmBC,EAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpC,YAAYC,GAAOC,IAAU,CAAA,GAAIC,GAAW;AAC1C,UAAMF,CAAK,GACX,KAAK,UAAUC,GACf,KAAK,YAAYC;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,eAAeC,GAAKC,GAAO;AACzB,IAAAC,EAAM,cAAcF,CAAG,GACvBG,EAAmB,MAAM;AACvB,MAAI,KAAK,MAAMH,CAAG,MAAMC,KACtB,KAAK,IAAID,GAAKC,CAAK;AAAA,IAEvB,GAAG,CAACD,GAAKC,CAAK,CAAC;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,0BAA0BD,GAAKC,GAAO;AAEpC,UAAMG,IAAQ;AACd,IAAAD,EAAmB,OACbC,EAAM,MAAMJ,CAAG,MAAMC,KACvBG,EAAM,IAAIJ,GAAKC,C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WA,GAAW,IAAI,GAC5B,KAAK,UAAU,CAAAC,MAAa;AACjC,YAAMC,IAAYH,EAASE,CAAS;AACpC,UAAI,CAAC,OAAO,GAAGD,GAAWE,CAAS,GAAG;AACpC,cAAMC,IAAWH;AACjB,QAAAA,IAAYE,GACZJ,EAASI,GAAWC,GAAU,IAAI;AAAA,MACpC;AAAA,IACF,CAAC;AAAA,EACH;AACF;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index350.js","sources":["../../../node_modules/@base-ui/react/esm/floating-ui-react/hooks/useRole.js"],"sourcesContent":["import * as React from 'react';\nimport { useId } from '@base-ui/utils/useId';\nimport { EMPTY_OBJECT } from '@base-ui/utils/empty';\nimport { getFloatingFocusElement } from \"../utils/element.js\";\nimport { useFloatingParentNodeId } from \"../components/FloatingTree.js\";\nconst componentRoleToAriaRoleMap = new Map([['select', 'listbox'], ['combobox', 'listbox'], ['label', false]]);\n\n/**\n * Adds base screen reader props to the reference and floating elements for a\n * given floating element `role`.\n * @see https://floating-ui.com/docs/useRole\n */\nexport function useRole(context, props = {}) {\n const store = 'rootStore' in context ? context.rootStore : context;\n const open = store.useState('open');\n const defaultFloatingId = store.useState('floatingId');\n const domReference = store.useState('domReferenceElement');\n const floatingElement = store.useState('floatingElement');\n const {\n role = 'dialog'\n } = props;\n const defaultReferenceId = useId();\n const referenceId = domReference?.id || defaultReferenceId;\n const floatingId = React.useMemo(() => getFloatingFocusElement(floatingElement)?.id || defaultFloatingId, [floatingElement, defaultFloatingId]);\n const ariaRole = componentRoleToAriaRoleMap.get(role) ?? role;\n const parentId = useFloatingParentNodeId();\n const isNested = parentId != null;\n const trigger = React.useMemo(() => {\n if (ariaRole === 'tooltip' || role === 'label') {\n return EMPTY_OBJECT;\n }\n return {\n 'aria-haspopup': ariaRole === 'alertdialog' ? 'dialog' : ariaRole,\n 'aria-expanded': 'false',\n ...(ariaRole === 'listbox' && {\n role: 'combobox'\n }),\n ...(ariaRole === 'menu' && isNested && {\n role: 'menuitem'\n }),\n ...(role === 'select' && {\n 'aria-autocomplete': 'none'\n }),\n ...(role === 'combobox' && {\n 'aria-autocomplete': 'list'\n })\n };\n }, [ariaRole, isNested, role]);\n const reference = React.useMemo(() => {\n if (ariaRole === 'tooltip' || role === 'label') {\n return {\n [`aria-${role === 'label' ? 'labelledby' : 'describedby'}`]: open ? floatingId : undefined\n };\n }\n const triggerProps = trigger;\n return {\n ...triggerProps,\n 'aria-expanded': open ? 'true' : 'false',\n 'aria-controls': open ? floatingId : undefined,\n ...(ariaRole === 'menu' && {\n id: referenceId\n })\n };\n }, [ariaRole, floatingId, open, referenceId, role, trigger]);\n const floating = React.useMemo(() => {\n const floatingProps = {\n id: floatingId,\n ...(ariaRole && {\n role: ariaRole\n })\n };\n if (ariaRole === 'tooltip' || role === 'label') {\n return floatingProps;\n }\n return {\n ...floatingProps,\n ...(ariaRole === 'menu' && {\n 'aria-labelledby': referenceId\n })\n };\n }, [ariaRole, floatingId, referenceId, role]);\n const item = React.useCallback(({\n active,\n selected\n }) => {\n const commonProps = {\n role: 'option',\n ...(active && {\n id: `${floatingId}-fui-option`\n })\n };\n\n // For `menu`, we are unable to tell if the item is a `menuitemradio`\n // or `menuitemcheckbox`. For backwards-compatibility reasons, also\n // avoid defaulting to `menuitem` as it may overwrite custom role props.\n switch (role) {\n case 'select':\n case 'combobox':\n return {\n ...commonProps,\n 'aria-selected': selected\n };\n default:\n }\n return {};\n }, [floatingId, role]);\n return React.useMemo(() => ({\n reference,\n floating,\n item,\n trigger\n }), [reference, floating, trigger, item]);\n}"],"names":["componentRoleToAriaRoleMap","useRole","context","props","store","open","defaultFloatingId","domReference","floatingElement","role","defaultReferenceId","useId","referenceId","floatingId","React","getFloatingFocusElement","ariaRole","isNested","useFloatingParentNodeId","trigger","EMPTY_OBJECT","reference","floating","floatingProps","item","active","selected","commonProps"],"mappings":";;;;;AAKA,MAAMA,IAA6B,oBAAI,IAAI,CAAC,CAAC,UAAU,SAAS,GAAG,CAAC,YAAY,SA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