@midas-ds/components 1.0.2 → 1.1.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 (175) hide show
  1. package/Button-DL6nqUco.js +182 -0
  2. package/CHANGELOG.md +15 -0
  3. package/Checkbox-q0dugR2t.js +402 -0
  4. package/{Collection-B3xUVWPF.js → Collection-KMFfVuzU.js} +179 -152
  5. package/Dialog-D6Bqrpn-.js +1952 -0
  6. package/Disclosure-dAZYXyTH.js +225 -0
  7. package/Disclosure.css +1 -0
  8. package/DragAndDrop-B0T3WgjL.js +40 -0
  9. package/FocusScope-B7CkxXNC.js +513 -0
  10. package/{Form-DXLoQL91.js → Form-BWBjJC6v.js} +79 -81
  11. package/Group-D7_8007y.js +42 -0
  12. package/Heading-RCRHv6hd.js +15 -0
  13. package/{Hidden-BQWDvze4.js → Hidden-CVlUgUJM.js} +1 -1
  14. package/Link-BnQvB-hH.js +75 -0
  15. package/ListBox-DBBiqvcR.js +474 -0
  16. package/ListKeyboardDelegate-gCXy-Xnn.js +172 -0
  17. package/PressResponder-B4g56kDz.js +31 -0
  18. package/README.md +21 -3
  19. package/{RSPContexts-EOiWkKOf.js → RSPContexts-BW2SEIqe.js} +2 -2
  20. package/SelectionManager-BfXUE1qg.js +1031 -0
  21. package/Separator-BBX9m2O2.js +49 -0
  22. package/Tag-DWt0koFj.js +728 -0
  23. package/Text-BCF0xvqL.js +15 -0
  24. package/TextField-CX4eOQf6.js +225 -0
  25. package/TextField.module-DdICj682.js +143 -0
  26. package/{VisuallyHidden-B_XzVvlX.js → VisuallyHidden-Dhr5caPC.js} +1 -1
  27. package/accordion/Accordion.d.ts +8 -8
  28. package/accordion/AccordionItem.d.ts +11 -3
  29. package/accordion/index.d.ts +0 -3
  30. package/{context-ScOIq_Gu.js → context-BpJLnOuu.js} +11 -11
  31. package/global.css +1 -0
  32. package/index-B-jHjTDC.js +120 -0
  33. package/{index-CorR1LBD.js → index-BPdc9gJ8.js} +3 -3
  34. package/{index-Dl1Q-tbj.js → index-KSgQWWiy.js} +5315 -5315
  35. package/index.d.ts +1 -0
  36. package/index.js +105 -112
  37. package/index10.js +1 -1
  38. package/index11.js +1 -1
  39. package/index12.js +1 -1
  40. package/index13.js +1 -1
  41. package/index14.js +1 -1
  42. package/index15.js +2 -2
  43. package/index16.js +2 -2
  44. package/index17.js +1 -1
  45. package/index18.js +1 -1
  46. package/index19.js +2 -2
  47. package/index2.js +1 -1
  48. package/index20.js +2 -2
  49. package/index21.js +1 -1
  50. package/index22.js +1 -1
  51. package/index23.js +1 -1
  52. package/index24.js +1 -1
  53. package/index25.js +2 -2
  54. package/index26.js +2 -2
  55. package/index27.js +2 -2
  56. package/index28.js +1 -1
  57. package/index29.js +2 -8
  58. package/index3.js +2 -4
  59. package/index30.js +17 -16
  60. package/index31.js +3 -3
  61. package/index32.js +3 -3
  62. package/index33.js +2 -2
  63. package/index34.js +3 -3
  64. package/index35.js +1 -1
  65. package/index36.js +2 -2
  66. package/index37.js +2 -2
  67. package/index38.js +2 -2
  68. package/index39.js +2 -2
  69. package/index4.js +1 -1
  70. package/index40.js +19 -12
  71. package/index41.js +61 -14
  72. package/index42.js +44 -22
  73. package/index43.js +13 -11
  74. package/index44.js +25 -4
  75. package/index45.js +16 -51
  76. package/index46.js +19 -16
  77. package/index47.js +49 -27
  78. package/index48.js +5 -18
  79. package/index49.js +25 -21
  80. package/index5.js +1 -1
  81. package/index50.js +16 -47
  82. package/index51.js +7 -3
  83. package/index52.js +18 -18
  84. package/index53.js +16 -16
  85. package/index54.js +6 -4
  86. package/index55.js +8 -21
  87. package/index56.js +13 -16
  88. package/index57.js +6 -8
  89. package/index58.js +6 -9
  90. package/index59.js +17 -13
  91. package/index6.js +1 -1
  92. package/index60.js +20 -7
  93. package/index61.js +59 -7
  94. package/index62.js +13 -17
  95. package/index63.js +9 -20
  96. package/index64.js +40 -48
  97. package/index65.js +85 -15
  98. package/index66.js +74 -11
  99. package/index67.js +23 -62
  100. package/index68.js +64 -80
  101. package/index69.js +68 -62
  102. package/index7.js +1 -1
  103. package/index70.js +138 -22
  104. package/index71.js +66 -65
  105. package/index72.js +40 -78
  106. package/index73.js +75 -133
  107. package/index74.js +69 -68
  108. package/index75.js +96 -34
  109. package/index76.js +258 -65
  110. package/index77.js +715 -63
  111. package/index78.js +478 -93
  112. package/index79.js +303 -263
  113. package/index8.js +1 -1
  114. package/index80.js +343 -678
  115. package/index81.js +242 -481
  116. package/index82.js +1329 -282
  117. package/index83.js +968 -350
  118. package/index84.js +343 -211
  119. package/index85.js +2025 -1288
  120. package/index86.js +2313 -954
  121. package/index87.js +6782 -339
  122. package/index88.js +15 -2103
  123. package/index89.js +12 -2369
  124. package/index9.js +1 -1
  125. package/index90.js +4 -6832
  126. package/index91.js +7 -15
  127. package/link/Link.d.ts +2 -2
  128. package/link-button/LinkButton.d.ts +1 -1
  129. package/package.json +7 -1
  130. package/{react.esm-D8HpDGKP.js → react.esm-sMU8Z7rL.js} +1872 -1872
  131. package/textfield/index.d.ts +0 -2
  132. package/useControlledState-Kv9K2AYu.js +30 -0
  133. package/{useDescription-D4_zk_sA.js → useDescription-B7stiK3j.js} +1 -1
  134. package/useEvent-Xk5kn5Ns.js +21 -0
  135. package/useField-DMzJIIN4.js +67 -0
  136. package/{useFilter-BnJDBCkt.js → useFilter-Bt9dbV1U.js} +1 -1
  137. package/useFocusRing-9PXyKy2A.js +1297 -0
  138. package/{useFocusable-C-N9wcwm.js → useFocusable-CcEBZe40.js} +11 -8
  139. package/{useGridSelectionCheckbox-i1rsjlC-.js → useGridSelectionCheckbox-DYgEnElE.js} +3 -3
  140. package/useHasTabbableChild-D6DwR81L.js +34 -0
  141. package/{useHighlightSelectionDescription-JVx2MW_e.js → useHighlightSelectionDescription-WYAbP4No.js} +19 -19
  142. package/useLabels-9zaZ9oa0.js +17 -0
  143. package/useListState-BfTeKTk5.js +119 -0
  144. package/{useLocalizedStringFormatter-DVCAZqcL.js → useLocalizedStringFormatter-BlCbn-hX.js} +29 -29
  145. package/{useSingleSelectListState-CmX9_L5H.js → useSingleSelectListState-DPkaL0la.js} +5 -5
  146. package/Button-CCevm2s3.js +0 -183
  147. package/Checkbox-CllWDBxF.js +0 -405
  148. package/Dialog-CLTyYwkS.js +0 -1889
  149. package/DragAndDrop-OTN7La7U.js +0 -42
  150. package/FocusScope-BR0SJ-cZ.js +0 -512
  151. package/Group-DPMuN3h8.js +0 -44
  152. package/Label-C18A_4Z5.js +0 -69
  153. package/Link-BU1h3K2a.js +0 -77
  154. package/ListBox-D21tdwTs.js +0 -463
  155. package/ListKeyboardDelegate-DxMjfMsI.js +0 -172
  156. package/PressResponder-DP8ZDNGy.js +0 -31
  157. package/SelectionManager-D4WtKtey.js +0 -988
  158. package/Separator-DLUHK9vv.js +0 -48
  159. package/Tag-CEd6WWSc.js +0 -725
  160. package/Text-DGLaY3HR.js +0 -17
  161. package/TextField-C_hq9WeT.js +0 -226
  162. package/TextField.module-Cwq1FAm7.js +0 -141
  163. package/accordion/AccordionContent.d.ts +0 -3
  164. package/accordion/AccordionTagContext.d.ts +0 -3
  165. package/accordion/AccordionTrigger.d.ts +0 -3
  166. package/index-CEg5vZQH.js +0 -132
  167. package/index-CgfokhRq.js +0 -674
  168. package/index.css +0 -1
  169. package/index92.js +0 -14
  170. package/index93.js +0 -6
  171. package/index94.js +0 -9
  172. package/useControlledState-S_TYcV_c.js +0 -45
  173. package/useFocusRing-D97-G3fT.js +0 -1324
  174. package/useHasTabbableChild-DeuCnGGv.js +0 -34
  175. package/useListState-DSOTbsL3.js +0 -119
@@ -0,0 +1,1031 @@
1
+ import U, { useRef as A, useEffect as Y, useMemo as j, useState as ee } from "react";
2
+ import { l as ue, G as we, L as xe, n as me, e as se, M as Fe, p as Se, m as ce, u as ne, x as de, N as fe, k as Te, O as ke } from "./useFocusRing-9PXyKy2A.js";
3
+ import { $ as q } from "./useEvent-Xk5kn5Ns.js";
4
+ import { flushSync as De } from "react-dom";
5
+ import { $ as Ie } from "./FocusScope-B7CkxXNC.js";
6
+ import { $ as Ae } from "./context-BpJLnOuu.js";
7
+ import { $ as Ce } from "./useDescription-B7stiK3j.js";
8
+ import { $ as Me } from "./useControlledState-Kv9K2AYu.js";
9
+ function ae(n, e) {
10
+ const t = A(!0), l = A(null);
11
+ ue(() => (t.current = !0, () => {
12
+ t.current = !1;
13
+ }), []), ue(() => {
14
+ t.current ? t.current = !1 : (!l.current || e.some((i, u) => !Object.is(i, l[u]))) && n(), l.current = e;
15
+ }, e);
16
+ }
17
+ function Ee(n, e) {
18
+ if (!n) return !1;
19
+ let t = window.getComputedStyle(n), l = /(auto|scroll)/.test(t.overflow + t.overflowX + t.overflowY);
20
+ return l && e && (l = n.scrollHeight !== n.clientHeight || n.scrollWidth !== n.clientWidth), l;
21
+ }
22
+ function Be(n, e) {
23
+ const t = [];
24
+ for (; n && n !== document.documentElement; )
25
+ Ee(n, e) && t.push(n), n = n.parentElement;
26
+ return t;
27
+ }
28
+ function ve(n, e) {
29
+ let t = he(n, e, "left"), l = he(n, e, "top"), i = e.offsetWidth, u = e.offsetHeight, s = n.scrollLeft, f = n.scrollTop, { borderTopWidth: d, borderLeftWidth: m, scrollPaddingTop: w, scrollPaddingRight: v, scrollPaddingBottom: $, scrollPaddingLeft: a } = getComputedStyle(n), T = s + parseInt(m, 10), k = f + parseInt(d, 10), b = T + n.clientWidth, h = k + n.clientHeight, g = parseInt(w, 10) || 0, p = parseInt($, 10) || 0, x = parseInt(v, 10) || 0, F = parseInt(a, 10) || 0;
30
+ t <= s + F ? s = t - parseInt(m, 10) - F : t + i > b - x && (s += t + i - b + x), l <= k + g ? f = l - parseInt(d, 10) - g : l + u > h - p && (f += l + u - h + p), n.scrollLeft = s, n.scrollTop = f;
31
+ }
32
+ function he(n, e, t) {
33
+ const l = t === "left" ? "offsetLeft" : "offsetTop";
34
+ let i = 0;
35
+ for (; e.offsetParent && (i += e[l], e.offsetParent !== n); ) {
36
+ if (e.offsetParent.contains(n)) {
37
+ i -= n[l];
38
+ break;
39
+ }
40
+ e = e.offsetParent;
41
+ }
42
+ return i;
43
+ }
44
+ function ye(n, e) {
45
+ if (n && document.contains(n)) {
46
+ let s = document.scrollingElement || document.documentElement;
47
+ if (window.getComputedStyle(s).overflow === "hidden") {
48
+ let d = Be(n);
49
+ for (let m of d) ve(m, n);
50
+ } else {
51
+ var t;
52
+ let { left: d, top: m } = n.getBoundingClientRect();
53
+ n == null || (t = n.scrollIntoView) === null || t === void 0 || t.call(n, {
54
+ block: "nearest"
55
+ });
56
+ let { left: w, top: v } = n.getBoundingClientRect();
57
+ if (Math.abs(d - w) > 1 || Math.abs(m - v) > 1) {
58
+ var l, i, u;
59
+ e == null || (i = e.containingElement) === null || i === void 0 || (l = i.scrollIntoView) === null || l === void 0 || l.call(i, {
60
+ block: "center",
61
+ inline: "center"
62
+ }), (u = n.scrollIntoView) === null || u === void 0 || u.call(n, {
63
+ block: "nearest"
64
+ });
65
+ }
66
+ }
67
+ }
68
+ }
69
+ const Le = "react-aria-clear-focus", Re = "react-aria-focus", Pe = "react-aria-update-activedescendant";
70
+ function H(n) {
71
+ return we() ? n.metaKey : n.ctrlKey;
72
+ }
73
+ const Oe = 500;
74
+ function ze(n) {
75
+ let { isDisabled: e, onLongPressStart: t, onLongPressEnd: l, onLongPress: i, threshold: u = Oe, accessibilityDescription: s } = n;
76
+ const f = A(void 0);
77
+ let { addGlobalListener: d, removeGlobalListener: m } = xe(), { pressProps: w } = me({
78
+ isDisabled: e,
79
+ onPressStart($) {
80
+ if ($.continuePropagation(), ($.pointerType === "mouse" || $.pointerType === "touch") && (t && t({
81
+ ...$,
82
+ type: "longpressstart"
83
+ }), f.current = setTimeout(() => {
84
+ $.target.dispatchEvent(new PointerEvent("pointercancel", {
85
+ bubbles: !0
86
+ })), i && i({
87
+ ...$,
88
+ type: "longpress"
89
+ }), f.current = void 0;
90
+ }, u), $.pointerType === "touch")) {
91
+ let a = (T) => {
92
+ T.preventDefault();
93
+ };
94
+ d($.target, "contextmenu", a, {
95
+ once: !0
96
+ }), d(window, "pointerup", () => {
97
+ setTimeout(() => {
98
+ m($.target, "contextmenu", a);
99
+ }, 30);
100
+ }, {
101
+ once: !0
102
+ });
103
+ }
104
+ },
105
+ onPressEnd($) {
106
+ f.current && clearTimeout(f.current), l && ($.pointerType === "mouse" || $.pointerType === "touch") && l({
107
+ ...$,
108
+ type: "longpressend"
109
+ });
110
+ }
111
+ }), v = Ce(i && !e ? s : void 0);
112
+ return {
113
+ longPressProps: se(w, v)
114
+ };
115
+ }
116
+ function ie(n) {
117
+ return Fe() ? n.altKey : n.ctrlKey;
118
+ }
119
+ const Ue = 1e3;
120
+ function We(n) {
121
+ let { keyboardDelegate: e, selectionManager: t, onTypeSelect: l } = n, i = A({
122
+ search: "",
123
+ timeout: void 0
124
+ }).current, u = (s) => {
125
+ let f = He(s.key);
126
+ if (!(!f || s.ctrlKey || s.metaKey || !s.currentTarget.contains(s.target))) {
127
+ if (f === " " && i.search.trim().length > 0 && (s.preventDefault(), "continuePropagation" in s || s.stopPropagation()), i.search += f, e.getKeyForSearch != null) {
128
+ let d = e.getKeyForSearch(i.search, t.focusedKey);
129
+ d == null && (d = e.getKeyForSearch(i.search)), d != null && (t.setFocusedKey(d), l && l(d));
130
+ }
131
+ clearTimeout(i.timeout), i.timeout = setTimeout(() => {
132
+ i.search = "";
133
+ }, Ue);
134
+ }
135
+ };
136
+ return {
137
+ typeSelectProps: {
138
+ // Using a capturing listener to catch the keydown event before
139
+ // other hooks in order to handle the Spacebar event.
140
+ onKeyDownCapture: e.getKeyForSearch ? u : void 0
141
+ }
142
+ };
143
+ }
144
+ function He(n) {
145
+ return n.length === 1 || !/^[A-Z]/i.test(n) ? n : "";
146
+ }
147
+ function nt(n) {
148
+ let { selectionManager: e, keyboardDelegate: t, ref: l, autoFocus: i = !1, shouldFocusWrap: u = !1, disallowEmptySelection: s = !1, disallowSelectAll: f = !1, selectOnFocus: d = e.selectionBehavior === "replace", disallowTypeAhead: m = !1, shouldUseVirtualFocus: w, allowsTabNavigation: v = !1, isVirtualized: $, scrollRef: a = l, linkBehavior: T = "action" } = n, { direction: k } = Ae(), b = Se(), h = (o) => {
149
+ var y;
150
+ if (o.altKey && o.key === "Tab" && o.preventDefault(), !(!((y = l.current) === null || y === void 0) && y.contains(o.target))) return;
151
+ const K = (c, z) => {
152
+ if (c != null) {
153
+ if (e.isLink(c) && T === "selection" && d && !ie(o)) {
154
+ var O;
155
+ De(() => {
156
+ e.setFocusedKey(c, z);
157
+ });
158
+ let re = (O = a.current) === null || O === void 0 ? void 0 : O.querySelector(`[data-key="${CSS.escape(c.toString())}"]`), oe = e.getItemProps(c);
159
+ re && b.open(re, o, oe.href, oe.routerOptions);
160
+ return;
161
+ }
162
+ if (e.setFocusedKey(c, z), e.isLink(c) && T === "override") return;
163
+ o.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(c) : d && !ie(o) && e.replaceSelection(c);
164
+ }
165
+ };
166
+ switch (o.key) {
167
+ case "ArrowDown":
168
+ if (t.getKeyBelow) {
169
+ var S, I, r;
170
+ let c = e.focusedKey != null ? (S = t.getKeyBelow) === null || S === void 0 ? void 0 : S.call(t, e.focusedKey) : (I = t.getFirstKey) === null || I === void 0 ? void 0 : I.call(t);
171
+ c == null && u && (c = (r = t.getFirstKey) === null || r === void 0 ? void 0 : r.call(t, e.focusedKey)), c != null && (o.preventDefault(), K(c));
172
+ }
173
+ break;
174
+ case "ArrowUp":
175
+ if (t.getKeyAbove) {
176
+ var P, B, X;
177
+ let c = e.focusedKey != null ? (P = t.getKeyAbove) === null || P === void 0 ? void 0 : P.call(t, e.focusedKey) : (B = t.getLastKey) === null || B === void 0 ? void 0 : B.call(t);
178
+ c == null && u && (c = (X = t.getLastKey) === null || X === void 0 ? void 0 : X.call(t, e.focusedKey)), c != null && (o.preventDefault(), K(c));
179
+ }
180
+ break;
181
+ case "ArrowLeft":
182
+ if (t.getKeyLeftOf) {
183
+ var V, Z, J;
184
+ let c = e.focusedKey != null ? (V = t.getKeyLeftOf) === null || V === void 0 ? void 0 : V.call(t, e.focusedKey) : null;
185
+ c == null && u && (c = k === "rtl" ? (Z = t.getFirstKey) === null || Z === void 0 ? void 0 : Z.call(t, e.focusedKey) : (J = t.getLastKey) === null || J === void 0 ? void 0 : J.call(t, e.focusedKey)), c != null && (o.preventDefault(), K(c, k === "rtl" ? "first" : "last"));
186
+ }
187
+ break;
188
+ case "ArrowRight":
189
+ if (t.getKeyRightOf) {
190
+ var Q, N, _;
191
+ let c = e.focusedKey != null ? (Q = t.getKeyRightOf) === null || Q === void 0 ? void 0 : Q.call(t, e.focusedKey) : null;
192
+ c == null && u && (c = k === "rtl" ? (N = t.getLastKey) === null || N === void 0 ? void 0 : N.call(t, e.focusedKey) : (_ = t.getFirstKey) === null || _ === void 0 ? void 0 : _.call(t, e.focusedKey)), c != null && (o.preventDefault(), K(c, k === "rtl" ? "last" : "first"));
193
+ }
194
+ break;
195
+ case "Home":
196
+ if (t.getFirstKey) {
197
+ if (e.focusedKey === null && o.shiftKey) return;
198
+ o.preventDefault();
199
+ let c = t.getFirstKey(e.focusedKey, H(o));
200
+ e.setFocusedKey(c), c != null && (H(o) && o.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(c) : d && e.replaceSelection(c));
201
+ }
202
+ break;
203
+ case "End":
204
+ if (t.getLastKey) {
205
+ if (e.focusedKey === null && o.shiftKey) return;
206
+ o.preventDefault();
207
+ let c = t.getLastKey(e.focusedKey, H(o));
208
+ e.setFocusedKey(c), c != null && (H(o) && o.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(c) : d && e.replaceSelection(c));
209
+ }
210
+ break;
211
+ case "PageDown":
212
+ if (t.getKeyPageBelow && e.focusedKey != null) {
213
+ let c = t.getKeyPageBelow(e.focusedKey);
214
+ c != null && (o.preventDefault(), K(c));
215
+ }
216
+ break;
217
+ case "PageUp":
218
+ if (t.getKeyPageAbove && e.focusedKey != null) {
219
+ let c = t.getKeyPageAbove(e.focusedKey);
220
+ c != null && (o.preventDefault(), K(c));
221
+ }
222
+ break;
223
+ case "a":
224
+ H(o) && e.selectionMode === "multiple" && f !== !0 && (o.preventDefault(), e.selectAll());
225
+ break;
226
+ case "Escape":
227
+ !s && e.selectedKeys.size !== 0 && (o.stopPropagation(), o.preventDefault(), e.clearSelection());
228
+ break;
229
+ case "Tab":
230
+ if (!v) {
231
+ if (o.shiftKey) l.current.focus();
232
+ else {
233
+ let c = Ie(l.current, {
234
+ tabbable: !0
235
+ }), z, O;
236
+ do
237
+ O = c.lastChild(), O && (z = O);
238
+ while (O);
239
+ z && !z.contains(document.activeElement) && fe(z);
240
+ }
241
+ break;
242
+ }
243
+ }
244
+ }, g = A({
245
+ top: 0,
246
+ left: 0
247
+ });
248
+ q(a, "scroll", $ ? void 0 : () => {
249
+ var o, y, K, S;
250
+ g.current = {
251
+ top: (K = (o = a.current) === null || o === void 0 ? void 0 : o.scrollTop) !== null && K !== void 0 ? K : 0,
252
+ left: (S = (y = a.current) === null || y === void 0 ? void 0 : y.scrollLeft) !== null && S !== void 0 ? S : 0
253
+ };
254
+ });
255
+ let p = (o) => {
256
+ if (e.isFocused) {
257
+ o.currentTarget.contains(o.target) || e.setFocused(!1);
258
+ return;
259
+ }
260
+ if (o.currentTarget.contains(o.target)) {
261
+ if (e.setFocused(!0), e.focusedKey == null) {
262
+ var y, K;
263
+ let r = (B) => {
264
+ B != null && (e.setFocusedKey(B), d && e.replaceSelection(B));
265
+ }, P = o.relatedTarget;
266
+ var S, I;
267
+ P && o.currentTarget.compareDocumentPosition(P) & Node.DOCUMENT_POSITION_FOLLOWING ? r((S = e.lastSelectedKey) !== null && S !== void 0 ? S : (y = t.getLastKey) === null || y === void 0 ? void 0 : y.call(t)) : r((I = e.firstSelectedKey) !== null && I !== void 0 ? I : (K = t.getFirstKey) === null || K === void 0 ? void 0 : K.call(t));
268
+ } else !$ && a.current && (a.current.scrollTop = g.current.top, a.current.scrollLeft = g.current.left);
269
+ if (e.focusedKey != null && a.current) {
270
+ let r = a.current.querySelector(`[data-key="${CSS.escape(e.focusedKey.toString())}"]`);
271
+ r && (r.contains(document.activeElement) || fe(r), de() === "keyboard" && ye(r, {
272
+ containingElement: l.current
273
+ }));
274
+ }
275
+ }
276
+ }, x = (o) => {
277
+ o.currentTarget.contains(o.relatedTarget) || e.setFocused(!1);
278
+ }, F = A(!1);
279
+ q(l, Re, w ? (o) => {
280
+ let { detail: y } = o;
281
+ o.stopPropagation(), e.setFocused(!0), (y == null ? void 0 : y.focusStrategy) === "first" && (F.current = !0);
282
+ } : void 0);
283
+ let L = ce(() => {
284
+ var o, y;
285
+ let K = (y = (o = t.getFirstKey) === null || o === void 0 ? void 0 : o.call(t)) !== null && y !== void 0 ? y : null;
286
+ if (K == null) {
287
+ var S;
288
+ (S = l.current) === null || S === void 0 || S.dispatchEvent(new CustomEvent(Pe, {
289
+ cancelable: !0,
290
+ bubbles: !0
291
+ })), e.collection.size > 0 && (F.current = !1);
292
+ } else
293
+ e.setFocusedKey(K), F.current = !1;
294
+ });
295
+ ae(() => {
296
+ F.current && L();
297
+ }, [
298
+ e.collection,
299
+ L
300
+ ]);
301
+ let M = ce(() => {
302
+ e.collection.size > 0 && (F.current = !1);
303
+ });
304
+ ae(() => {
305
+ M();
306
+ }, [
307
+ e.focusedKey,
308
+ M
309
+ ]), q(l, Le, w ? (o) => {
310
+ o.stopPropagation(), e.setFocused(!1), e.setFocusedKey(null);
311
+ } : void 0);
312
+ const D = A(i);
313
+ Y(() => {
314
+ if (D.current) {
315
+ var o, y;
316
+ let I = null;
317
+ var K;
318
+ i === "first" && (I = (K = (o = t.getFirstKey) === null || o === void 0 ? void 0 : o.call(t)) !== null && K !== void 0 ? K : null);
319
+ var S;
320
+ i === "last" && (I = (S = (y = t.getLastKey) === null || y === void 0 ? void 0 : y.call(t)) !== null && S !== void 0 ? S : null);
321
+ let r = e.selectedKeys;
322
+ if (r.size) {
323
+ for (let P of r) if (e.canSelectItem(P)) {
324
+ I = P;
325
+ break;
326
+ }
327
+ }
328
+ e.setFocused(!0), e.setFocusedKey(I), I == null && !w && l.current && ne(l.current);
329
+ }
330
+ }, []);
331
+ let W = A(e.focusedKey);
332
+ Y(() => {
333
+ if (e.isFocused && e.focusedKey != null && (e.focusedKey !== W.current || D.current) && a.current && l.current) {
334
+ let o = de(), y = l.current.querySelector(`[data-key="${CSS.escape(e.focusedKey.toString())}"]`);
335
+ if (!y)
336
+ return;
337
+ (o === "keyboard" || D.current) && (ve(a.current, y), o !== "virtual" && ye(y, {
338
+ containingElement: l.current
339
+ }));
340
+ }
341
+ !w && e.isFocused && e.focusedKey == null && W.current != null && l.current && ne(l.current), W.current = e.focusedKey, D.current = !1;
342
+ }), q(l, "react-aria-focus-scope-restore", (o) => {
343
+ o.preventDefault(), e.setFocused(!0);
344
+ });
345
+ let R = {
346
+ onKeyDown: h,
347
+ onFocus: p,
348
+ onBlur: x,
349
+ onMouseDown(o) {
350
+ a.current === o.target && o.preventDefault();
351
+ }
352
+ }, { typeSelectProps: E } = We({
353
+ keyboardDelegate: t,
354
+ selectionManager: e
355
+ });
356
+ m || (R = se(E, R));
357
+ let G;
358
+ return w ? G = -1 : G = e.focusedKey == null ? 0 : -1, {
359
+ collectionProps: {
360
+ ...R,
361
+ tabIndex: G
362
+ }
363
+ };
364
+ }
365
+ function it(n) {
366
+ let { id: e, selectionManager: t, key: l, ref: i, shouldSelectOnPressUp: u, shouldUseVirtualFocus: s, focus: f, isDisabled: d, onAction: m, allowsDifferentPressOrigin: w, linkBehavior: v = "action" } = n, $ = Se();
367
+ e = Te(e);
368
+ let a = (r) => {
369
+ if (r.pointerType === "keyboard" && ie(r)) t.toggleSelection(l);
370
+ else {
371
+ if (t.selectionMode === "none") return;
372
+ if (t.isLink(l)) {
373
+ if (v === "selection" && i.current) {
374
+ let P = t.getItemProps(l);
375
+ $.open(i.current, r, P.href, P.routerOptions), t.setSelectedKeys(t.selectedKeys);
376
+ return;
377
+ } else if (v === "override" || v === "none") return;
378
+ }
379
+ t.selectionMode === "single" ? t.isSelected(l) && !t.disallowEmptySelection ? t.toggleSelection(l) : t.replaceSelection(l) : r && r.shiftKey ? t.extendSelection(l) : t.selectionBehavior === "toggle" || r && (H(r) || r.pointerType === "touch" || r.pointerType === "virtual") ? t.toggleSelection(l) : t.replaceSelection(l);
380
+ }
381
+ };
382
+ Y(() => {
383
+ if (l === t.focusedKey && t.isFocused)
384
+ if (!s)
385
+ f ? f() : document.activeElement !== i.current && i.current && ne(i.current);
386
+ else {
387
+ var P;
388
+ let B = new CustomEvent(Pe, {
389
+ cancelable: !0,
390
+ bubbles: !0
391
+ });
392
+ (P = i.current) === null || P === void 0 || P.dispatchEvent(B);
393
+ }
394
+ }, [
395
+ i,
396
+ l,
397
+ t.focusedKey,
398
+ t.childFocusStrategy,
399
+ t.isFocused,
400
+ s
401
+ ]), d = d || t.isDisabled(l);
402
+ let T = {};
403
+ !s && !d ? T = {
404
+ tabIndex: l === t.focusedKey ? 0 : -1,
405
+ onFocus(r) {
406
+ r.target === i.current && t.setFocusedKey(l);
407
+ }
408
+ } : d && (T.onMouseDown = (r) => {
409
+ r.preventDefault();
410
+ });
411
+ let k = t.isLink(l) && v === "override", b = t.isLink(l) && v !== "selection" && v !== "none", h = !d && t.canSelectItem(l) && !k, g = (m || b) && !d, p = g && (t.selectionBehavior === "replace" ? !h : !h || t.isEmpty), x = g && h && t.selectionBehavior === "replace", F = p || x, L = A(null), M = F && h, D = A(!1), W = A(!1), R = (r) => {
412
+ if (m && m(), b && i.current) {
413
+ let P = t.getItemProps(l);
414
+ $.open(i.current, r, P.href, P.routerOptions);
415
+ }
416
+ }, E = {};
417
+ u ? (E.onPressStart = (r) => {
418
+ L.current = r.pointerType, D.current = M, r.pointerType === "keyboard" && (!F || be()) && a(r);
419
+ }, w ? (E.onPressUp = p ? void 0 : (r) => {
420
+ r.pointerType === "mouse" && h && a(r);
421
+ }, E.onPress = p ? R : (r) => {
422
+ r.pointerType !== "keyboard" && r.pointerType !== "mouse" && h && a(r);
423
+ }) : E.onPress = (r) => {
424
+ if (p || x && r.pointerType !== "mouse") {
425
+ if (r.pointerType === "keyboard" && !pe()) return;
426
+ R(r);
427
+ } else r.pointerType !== "keyboard" && h && a(r);
428
+ }) : (E.onPressStart = (r) => {
429
+ L.current = r.pointerType, D.current = M, W.current = p, h && (r.pointerType === "mouse" && !p || r.pointerType === "keyboard" && (!g || be())) && a(r);
430
+ }, E.onPress = (r) => {
431
+ (r.pointerType === "touch" || r.pointerType === "pen" || r.pointerType === "virtual" || r.pointerType === "keyboard" && F && pe() || r.pointerType === "mouse" && W.current) && (F ? R(r) : h && a(r));
432
+ }), T["data-key"] = l, E.preventFocusOnPress = s;
433
+ let { pressProps: G, isPressed: o } = me(E), y = x ? (r) => {
434
+ L.current === "mouse" && (r.stopPropagation(), r.preventDefault(), R(r));
435
+ } : void 0, { longPressProps: K } = ze({
436
+ isDisabled: !M,
437
+ onLongPress(r) {
438
+ r.pointerType === "touch" && (a(r), t.setSelectionBehavior("toggle"));
439
+ }
440
+ }), S = (r) => {
441
+ L.current === "touch" && D.current && r.preventDefault();
442
+ }, I = t.isLink(l) ? (r) => {
443
+ ke.isOpening || r.preventDefault();
444
+ } : void 0;
445
+ return {
446
+ itemProps: se(T, h || p ? G : {}, M ? K : {}, {
447
+ onDoubleClick: y,
448
+ onDragStartCapture: S,
449
+ onClick: I,
450
+ id: e
451
+ }),
452
+ isPressed: o,
453
+ isSelected: t.isSelected(l),
454
+ isFocused: t.isFocused && t.focusedKey === l,
455
+ isDisabled: d,
456
+ allowsSelection: h,
457
+ hasAction: F
458
+ };
459
+ }
460
+ function pe() {
461
+ let n = window.event;
462
+ return (n == null ? void 0 : n.key) === "Enter";
463
+ }
464
+ function be() {
465
+ let n = window.event;
466
+ return (n == null ? void 0 : n.key) === " " || (n == null ? void 0 : n.code) === "Space";
467
+ }
468
+ class Ge {
469
+ build(e, t) {
470
+ return this.context = t, $e(() => this.iterateCollection(e));
471
+ }
472
+ *iterateCollection(e) {
473
+ let { children: t, items: l } = e;
474
+ if (U.isValidElement(t) && t.type === U.Fragment) yield* this.iterateCollection({
475
+ children: t.props.children,
476
+ items: l
477
+ });
478
+ else if (typeof t == "function") {
479
+ if (!l) throw new Error("props.children was a function but props.items is missing");
480
+ let i = 0;
481
+ for (let u of l)
482
+ yield* this.getFullNode({
483
+ value: u,
484
+ index: i
485
+ }, {
486
+ renderer: t
487
+ }), i++;
488
+ } else {
489
+ let i = [];
490
+ U.Children.forEach(t, (s) => {
491
+ s && i.push(s);
492
+ });
493
+ let u = 0;
494
+ for (let s of i) {
495
+ let f = this.getFullNode({
496
+ element: s,
497
+ index: u
498
+ }, {});
499
+ for (let d of f)
500
+ u++, yield d;
501
+ }
502
+ }
503
+ }
504
+ getKey(e, t, l, i) {
505
+ if (e.key != null) return e.key;
506
+ if (t.type === "cell" && t.key != null) return `${i}${t.key}`;
507
+ let u = t.value;
508
+ if (u != null) {
509
+ var s;
510
+ let f = (s = u.key) !== null && s !== void 0 ? s : u.id;
511
+ if (f == null) throw new Error("No key found for item");
512
+ return f;
513
+ }
514
+ return i ? `${i}.${t.index}` : `$.${t.index}`;
515
+ }
516
+ getChildState(e, t) {
517
+ return {
518
+ renderer: t.renderer || e.renderer
519
+ };
520
+ }
521
+ *getFullNode(e, t, l, i) {
522
+ if (U.isValidElement(e.element) && e.element.type === U.Fragment) {
523
+ let b = [];
524
+ U.Children.forEach(e.element.props.children, (g) => {
525
+ b.push(g);
526
+ });
527
+ var u;
528
+ let h = (u = e.index) !== null && u !== void 0 ? u : 0;
529
+ for (const g of b) yield* this.getFullNode({
530
+ element: g,
531
+ index: h++
532
+ }, t, l, i);
533
+ return;
534
+ }
535
+ let s = e.element;
536
+ if (!s && e.value && t && t.renderer) {
537
+ let b = this.cache.get(e.value);
538
+ if (b && (!b.shouldInvalidate || !b.shouldInvalidate(this.context))) {
539
+ b.index = e.index, b.parentKey = i ? i.key : null, yield b;
540
+ return;
541
+ }
542
+ s = t.renderer(e.value);
543
+ }
544
+ if (U.isValidElement(s)) {
545
+ let b = s.type;
546
+ if (typeof b != "function" && typeof b.getCollectionNode != "function") {
547
+ let x = s.type;
548
+ throw new Error(`Unknown element <${x}> in collection.`);
549
+ }
550
+ let h = b.getCollectionNode(s.props, this.context);
551
+ var f;
552
+ let g = (f = e.index) !== null && f !== void 0 ? f : 0, p = h.next();
553
+ for (; !p.done && p.value; ) {
554
+ let x = p.value;
555
+ e.index = g;
556
+ var d;
557
+ let F = (d = x.key) !== null && d !== void 0 ? d : null;
558
+ F == null && (F = x.element ? null : this.getKey(s, e, t, l));
559
+ let M = [
560
+ ...this.getFullNode({
561
+ ...x,
562
+ key: F,
563
+ index: g,
564
+ wrapper: je(e.wrapper, x.wrapper)
565
+ }, this.getChildState(t, x), l ? `${l}${s.key}` : s.key, i)
566
+ ];
567
+ for (let D of M) {
568
+ var m, w;
569
+ D.value = (w = (m = x.value) !== null && m !== void 0 ? m : e.value) !== null && w !== void 0 ? w : null, D.value && this.cache.set(D.value, D);
570
+ var v;
571
+ if (e.type && D.type !== e.type) throw new Error(`Unsupported type <${te(D.type)}> in <${te((v = i == null ? void 0 : i.type) !== null && v !== void 0 ? v : "unknown parent type")}>. Only <${te(e.type)}> is supported.`);
572
+ g++, yield D;
573
+ }
574
+ p = h.next(M);
575
+ }
576
+ return;
577
+ }
578
+ if (e.key == null || e.type == null) return;
579
+ let $ = this;
580
+ var a, T;
581
+ let k = {
582
+ type: e.type,
583
+ props: e.props,
584
+ key: e.key,
585
+ parentKey: i ? i.key : null,
586
+ value: (a = e.value) !== null && a !== void 0 ? a : null,
587
+ level: i ? i.level + 1 : 0,
588
+ index: e.index,
589
+ rendered: e.rendered,
590
+ textValue: (T = e.textValue) !== null && T !== void 0 ? T : "",
591
+ "aria-label": e["aria-label"],
592
+ wrapper: e.wrapper,
593
+ shouldInvalidate: e.shouldInvalidate,
594
+ hasChildNodes: e.hasChildNodes || !1,
595
+ childNodes: $e(function* () {
596
+ if (!e.hasChildNodes || !e.childNodes) return;
597
+ let b = 0;
598
+ for (let h of e.childNodes()) {
599
+ h.key != null && (h.key = `${k.key}${h.key}`);
600
+ let g = $.getFullNode({
601
+ ...h,
602
+ index: b
603
+ }, $.getChildState(t, h), k.key, k);
604
+ for (let p of g)
605
+ b++, yield p;
606
+ }
607
+ })
608
+ };
609
+ yield k;
610
+ }
611
+ constructor() {
612
+ this.cache = /* @__PURE__ */ new WeakMap();
613
+ }
614
+ }
615
+ function $e(n) {
616
+ let e = [], t = null;
617
+ return {
618
+ *[Symbol.iterator]() {
619
+ for (let l of e) yield l;
620
+ t || (t = n());
621
+ for (let l of t)
622
+ e.push(l), yield l;
623
+ }
624
+ };
625
+ }
626
+ function je(n, e) {
627
+ if (n && e) return (t) => n(e(t));
628
+ if (n) return n;
629
+ if (e) return e;
630
+ }
631
+ function te(n) {
632
+ return n[0].toUpperCase() + n.slice(1);
633
+ }
634
+ function st(n, e, t) {
635
+ let l = j(() => new Ge(), []), { children: i, items: u, collection: s } = n;
636
+ return j(() => {
637
+ if (s) return s;
638
+ let d = l.build({
639
+ children: i,
640
+ items: u
641
+ }, t);
642
+ return e(d);
643
+ }, [
644
+ l,
645
+ i,
646
+ u,
647
+ s,
648
+ t,
649
+ e
650
+ ]);
651
+ }
652
+ function qe(n, e) {
653
+ return typeof e.getChildren == "function" ? e.getChildren(n.key) : n.childNodes;
654
+ }
655
+ function Ye(n) {
656
+ return Xe(n, 0);
657
+ }
658
+ function Xe(n, e) {
659
+ if (e < 0) return;
660
+ let t = 0;
661
+ for (let l of n) {
662
+ if (t === e) return l;
663
+ t++;
664
+ }
665
+ }
666
+ function rt(n) {
667
+ let e;
668
+ for (let t of n) e = t;
669
+ return e;
670
+ }
671
+ function le(n, e, t) {
672
+ if (e.parentKey === t.parentKey) return e.index - t.index;
673
+ let l = [
674
+ ...ge(n, e),
675
+ e
676
+ ], i = [
677
+ ...ge(n, t),
678
+ t
679
+ ], u = l.slice(0, i.length).findIndex((s, f) => s !== i[f]);
680
+ return u !== -1 ? (e = l[u], t = i[u], e.index - t.index) : l.findIndex((s) => s === t) >= 0 ? 1 : (i.findIndex((s) => s === e) >= 0, -1);
681
+ }
682
+ function ge(n, e) {
683
+ let t = [], l = e;
684
+ for (; (l == null ? void 0 : l.parentKey) != null; )
685
+ l = n.getItem(l.parentKey), l && t.unshift(l);
686
+ return t;
687
+ }
688
+ class C extends Set {
689
+ constructor(e, t, l) {
690
+ super(e), e instanceof C ? (this.anchorKey = t ?? e.anchorKey, this.currentKey = l ?? e.currentKey) : (this.anchorKey = t ?? null, this.currentKey = l ?? null);
691
+ }
692
+ }
693
+ function Ve(n, e) {
694
+ if (n.size !== e.size) return !1;
695
+ for (let t of n)
696
+ if (!e.has(t)) return !1;
697
+ return !0;
698
+ }
699
+ function ot(n) {
700
+ let { selectionMode: e = "none", disallowEmptySelection: t = !1, allowDuplicateSelectionEvents: l, selectionBehavior: i = "toggle", disabledBehavior: u = "all" } = n, s = A(!1), [, f] = ee(!1), d = A(null), m = A(null), [, w] = ee(null), v = j(() => Ke(n.selectedKeys), [
701
+ n.selectedKeys
702
+ ]), $ = j(() => Ke(n.defaultSelectedKeys, new C()), [
703
+ n.defaultSelectedKeys
704
+ ]), [a, T] = Me(v, $, n.onSelectionChange), k = j(() => n.disabledKeys ? new Set(n.disabledKeys) : /* @__PURE__ */ new Set(), [
705
+ n.disabledKeys
706
+ ]), [b, h] = ee(i);
707
+ i === "replace" && b === "toggle" && typeof a == "object" && a.size === 0 && h("replace");
708
+ let g = A(i);
709
+ return Y(() => {
710
+ i !== g.current && (h(i), g.current = i);
711
+ }, [
712
+ i
713
+ ]), {
714
+ selectionMode: e,
715
+ disallowEmptySelection: t,
716
+ selectionBehavior: b,
717
+ setSelectionBehavior: h,
718
+ get isFocused() {
719
+ return s.current;
720
+ },
721
+ setFocused(p) {
722
+ s.current = p, f(p);
723
+ },
724
+ get focusedKey() {
725
+ return d.current;
726
+ },
727
+ get childFocusStrategy() {
728
+ return m.current;
729
+ },
730
+ setFocusedKey(p, x = "first") {
731
+ d.current = p, m.current = x, w(p);
732
+ },
733
+ selectedKeys: a,
734
+ setSelectedKeys(p) {
735
+ (l || !Ve(p, a)) && T(p);
736
+ },
737
+ disabledKeys: k,
738
+ disabledBehavior: u
739
+ };
740
+ }
741
+ function Ke(n, e) {
742
+ return n ? n === "all" ? "all" : new C(n) : e;
743
+ }
744
+ class ut {
745
+ /**
746
+ * The type of selection that is allowed in the collection.
747
+ */
748
+ get selectionMode() {
749
+ return this.state.selectionMode;
750
+ }
751
+ /**
752
+ * Whether the collection allows empty selection.
753
+ */
754
+ get disallowEmptySelection() {
755
+ return this.state.disallowEmptySelection;
756
+ }
757
+ /**
758
+ * The selection behavior for the collection.
759
+ */
760
+ get selectionBehavior() {
761
+ return this.state.selectionBehavior;
762
+ }
763
+ /**
764
+ * Sets the selection behavior for the collection.
765
+ */
766
+ setSelectionBehavior(e) {
767
+ this.state.setSelectionBehavior(e);
768
+ }
769
+ /**
770
+ * Whether the collection is currently focused.
771
+ */
772
+ get isFocused() {
773
+ return this.state.isFocused;
774
+ }
775
+ /**
776
+ * Sets whether the collection is focused.
777
+ */
778
+ setFocused(e) {
779
+ this.state.setFocused(e);
780
+ }
781
+ /**
782
+ * The current focused key in the collection.
783
+ */
784
+ get focusedKey() {
785
+ return this.state.focusedKey;
786
+ }
787
+ /** Whether the first or last child of the focused key should receive focus. */
788
+ get childFocusStrategy() {
789
+ return this.state.childFocusStrategy;
790
+ }
791
+ /**
792
+ * Sets the focused key.
793
+ */
794
+ setFocusedKey(e, t) {
795
+ (e == null || this.collection.getItem(e)) && this.state.setFocusedKey(e, t);
796
+ }
797
+ /**
798
+ * The currently selected keys in the collection.
799
+ */
800
+ get selectedKeys() {
801
+ return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
802
+ }
803
+ /**
804
+ * The raw selection value for the collection.
805
+ * Either 'all' for select all, or a set of keys.
806
+ */
807
+ get rawSelection() {
808
+ return this.state.selectedKeys;
809
+ }
810
+ /**
811
+ * Returns whether a key is selected.
812
+ */
813
+ isSelected(e) {
814
+ if (this.state.selectionMode === "none") return !1;
815
+ let t = this.getKey(e);
816
+ return t == null ? !1 : this.state.selectedKeys === "all" ? this.canSelectItem(t) : this.state.selectedKeys.has(t);
817
+ }
818
+ /**
819
+ * Whether the selection is empty.
820
+ */
821
+ get isEmpty() {
822
+ return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
823
+ }
824
+ /**
825
+ * Whether all items in the collection are selected.
826
+ */
827
+ get isSelectAll() {
828
+ if (this.isEmpty) return !1;
829
+ if (this.state.selectedKeys === "all") return !0;
830
+ if (this._isSelectAll != null) return this._isSelectAll;
831
+ let e = this.getSelectAllKeys(), t = this.state.selectedKeys;
832
+ return this._isSelectAll = e.every((l) => t.has(l)), this._isSelectAll;
833
+ }
834
+ get firstSelectedKey() {
835
+ let e = null;
836
+ for (let l of this.state.selectedKeys) {
837
+ let i = this.collection.getItem(l);
838
+ (!e || i && le(this.collection, i, e) < 0) && (e = i);
839
+ }
840
+ var t;
841
+ return (t = e == null ? void 0 : e.key) !== null && t !== void 0 ? t : null;
842
+ }
843
+ get lastSelectedKey() {
844
+ let e = null;
845
+ for (let l of this.state.selectedKeys) {
846
+ let i = this.collection.getItem(l);
847
+ (!e || i && le(this.collection, i, e) > 0) && (e = i);
848
+ }
849
+ var t;
850
+ return (t = e == null ? void 0 : e.key) !== null && t !== void 0 ? t : null;
851
+ }
852
+ get disabledKeys() {
853
+ return this.state.disabledKeys;
854
+ }
855
+ get disabledBehavior() {
856
+ return this.state.disabledBehavior;
857
+ }
858
+ /**
859
+ * Extends the selection to the given key.
860
+ */
861
+ extendSelection(e) {
862
+ if (this.selectionMode === "none") return;
863
+ if (this.selectionMode === "single") {
864
+ this.replaceSelection(e);
865
+ return;
866
+ }
867
+ let t = this.getKey(e);
868
+ if (t == null) return;
869
+ let l;
870
+ if (this.state.selectedKeys === "all") l = new C([
871
+ t
872
+ ], t, t);
873
+ else {
874
+ let s = this.state.selectedKeys;
875
+ var i;
876
+ let f = (i = s.anchorKey) !== null && i !== void 0 ? i : t;
877
+ l = new C(s, f, t);
878
+ var u;
879
+ for (let d of this.getKeyRange(f, (u = s.currentKey) !== null && u !== void 0 ? u : t)) l.delete(d);
880
+ for (let d of this.getKeyRange(t, f)) this.canSelectItem(d) && l.add(d);
881
+ }
882
+ this.state.setSelectedKeys(l);
883
+ }
884
+ getKeyRange(e, t) {
885
+ let l = this.collection.getItem(e), i = this.collection.getItem(t);
886
+ return l && i ? le(this.collection, l, i) <= 0 ? this.getKeyRangeInternal(e, t) : this.getKeyRangeInternal(t, e) : [];
887
+ }
888
+ getKeyRangeInternal(e, t) {
889
+ var l;
890
+ if (!((l = this.layoutDelegate) === null || l === void 0) && l.getKeyRange) return this.layoutDelegate.getKeyRange(e, t);
891
+ let i = [], u = e;
892
+ for (; u != null; ) {
893
+ let s = this.collection.getItem(u);
894
+ if (s && (s.type === "item" || s.type === "cell" && this.allowsCellSelection) && i.push(u), u === t) return i;
895
+ u = this.collection.getKeyAfter(u);
896
+ }
897
+ return [];
898
+ }
899
+ getKey(e) {
900
+ let t = this.collection.getItem(e);
901
+ if (!t || t.type === "cell" && this.allowsCellSelection) return e;
902
+ for (; t && t.type !== "item" && t.parentKey != null; ) t = this.collection.getItem(t.parentKey);
903
+ return !t || t.type !== "item" ? null : t.key;
904
+ }
905
+ /**
906
+ * Toggles whether the given key is selected.
907
+ */
908
+ toggleSelection(e) {
909
+ if (this.selectionMode === "none") return;
910
+ if (this.selectionMode === "single" && !this.isSelected(e)) {
911
+ this.replaceSelection(e);
912
+ return;
913
+ }
914
+ let t = this.getKey(e);
915
+ if (t == null) return;
916
+ let l = new C(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
917
+ l.has(t) ? l.delete(t) : this.canSelectItem(t) && (l.add(t), l.anchorKey = t, l.currentKey = t), !(this.disallowEmptySelection && l.size === 0) && this.state.setSelectedKeys(l);
918
+ }
919
+ /**
920
+ * Replaces the selection with only the given key.
921
+ */
922
+ replaceSelection(e) {
923
+ if (this.selectionMode === "none") return;
924
+ let t = this.getKey(e);
925
+ if (t == null) return;
926
+ let l = this.canSelectItem(t) ? new C([
927
+ t
928
+ ], t, t) : new C();
929
+ this.state.setSelectedKeys(l);
930
+ }
931
+ /**
932
+ * Replaces the selection with the given keys.
933
+ */
934
+ setSelectedKeys(e) {
935
+ if (this.selectionMode === "none") return;
936
+ let t = new C();
937
+ for (let l of e) {
938
+ let i = this.getKey(l);
939
+ if (i != null && (t.add(i), this.selectionMode === "single"))
940
+ break;
941
+ }
942
+ this.state.setSelectedKeys(t);
943
+ }
944
+ getSelectAllKeys() {
945
+ let e = [], t = (l) => {
946
+ for (; l != null; ) {
947
+ if (this.canSelectItem(l)) {
948
+ var i;
949
+ let s = this.collection.getItem(l);
950
+ (s == null ? void 0 : s.type) === "item" && e.push(l);
951
+ var u;
952
+ s != null && s.hasChildNodes && (this.allowsCellSelection || s.type !== "item") && t((u = (i = Ye(qe(s, this.collection))) === null || i === void 0 ? void 0 : i.key) !== null && u !== void 0 ? u : null);
953
+ }
954
+ l = this.collection.getKeyAfter(l);
955
+ }
956
+ };
957
+ return t(this.collection.getFirstKey()), e;
958
+ }
959
+ /**
960
+ * Selects all items in the collection.
961
+ */
962
+ selectAll() {
963
+ !this.isSelectAll && this.selectionMode === "multiple" && this.state.setSelectedKeys("all");
964
+ }
965
+ /**
966
+ * Removes all keys from the selection.
967
+ */
968
+ clearSelection() {
969
+ !this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0) && this.state.setSelectedKeys(new C());
970
+ }
971
+ /**
972
+ * Toggles between select all and an empty selection.
973
+ */
974
+ toggleSelectAll() {
975
+ this.isSelectAll ? this.clearSelection() : this.selectAll();
976
+ }
977
+ select(e, t) {
978
+ this.selectionMode !== "none" && (this.selectionMode === "single" ? this.isSelected(e) && !this.disallowEmptySelection ? this.toggleSelection(e) : this.replaceSelection(e) : this.selectionBehavior === "toggle" || t && (t.pointerType === "touch" || t.pointerType === "virtual") ? this.toggleSelection(e) : this.replaceSelection(e));
979
+ }
980
+ /**
981
+ * Returns whether the current selection is equal to the given selection.
982
+ */
983
+ isSelectionEqual(e) {
984
+ if (e === this.state.selectedKeys) return !0;
985
+ let t = this.selectedKeys;
986
+ if (e.size !== t.size) return !1;
987
+ for (let l of e)
988
+ if (!t.has(l)) return !1;
989
+ for (let l of t)
990
+ if (!e.has(l)) return !1;
991
+ return !0;
992
+ }
993
+ canSelectItem(e) {
994
+ var t;
995
+ if (this.state.selectionMode === "none" || this.state.disabledKeys.has(e)) return !1;
996
+ let l = this.collection.getItem(e);
997
+ return !(!l || !(l == null || (t = l.props) === null || t === void 0) && t.isDisabled || l.type === "cell" && !this.allowsCellSelection);
998
+ }
999
+ isDisabled(e) {
1000
+ var t, l;
1001
+ return this.state.disabledBehavior === "all" && (this.state.disabledKeys.has(e) || !!(!((l = this.collection.getItem(e)) === null || l === void 0 || (t = l.props) === null || t === void 0) && t.isDisabled));
1002
+ }
1003
+ isLink(e) {
1004
+ var t, l;
1005
+ return !!(!((l = this.collection.getItem(e)) === null || l === void 0 || (t = l.props) === null || t === void 0) && t.href);
1006
+ }
1007
+ getItemProps(e) {
1008
+ var t;
1009
+ return (t = this.collection.getItem(e)) === null || t === void 0 ? void 0 : t.props;
1010
+ }
1011
+ constructor(e, t, l) {
1012
+ this.collection = e, this.state = t;
1013
+ var i;
1014
+ this.allowsCellSelection = (i = l == null ? void 0 : l.allowsCellSelection) !== null && i !== void 0 ? i : !1, this._isSelectAll = null, this.layoutDelegate = (l == null ? void 0 : l.layoutDelegate) || null;
1015
+ }
1016
+ }
1017
+ export {
1018
+ ot as $,
1019
+ st as a,
1020
+ ut as b,
1021
+ Ee as c,
1022
+ it as d,
1023
+ nt as e,
1024
+ qe as f,
1025
+ We as g,
1026
+ rt as h,
1027
+ ye as i,
1028
+ Xe as j,
1029
+ Ye as k,
1030
+ ze as l
1031
+ };