@midas-ds/components 1.0.2 → 1.0.3

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