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