@okam/stack-ui 1.43.0 → 1.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/index180.js +1 -1
- package/index180.mjs +3 -3
- package/index181.js +1 -1
- package/index181.mjs +1 -1
- package/index182.js +1 -1
- package/index182.mjs +1 -1
- package/index183.js +1 -1
- package/index183.mjs +2 -2
- package/index282.js +1 -1
- package/index282.mjs +9 -31
- package/index283.js +1 -1
- package/index283.mjs +133 -9
- package/index284.js +1 -1
- package/index284.mjs +43 -133
- package/index285.js +1 -1
- package/index285.mjs +231 -43
- package/index286.js +1 -1
- package/index286.mjs +27 -227
- package/index341.js +1 -1
- package/index341.mjs +20 -65
- package/index342.js +1 -1
- package/index342.mjs +29 -54
- package/index343.js +1 -1
- package/index343.mjs +63 -51
- package/index344.js +1 -1
- package/index344.mjs +44 -271
- package/index345.js +1 -1
- package/index345.mjs +52 -18
- package/index346.js +1 -1
- package/index346.mjs +281 -21
- package/index347.js +1 -1
- package/index347.mjs +20 -29
- package/index8.js +1 -1
- package/index8.mjs +1 -1
- package/package.json +1 -1
package/index285.mjs
CHANGED
|
@@ -1,46 +1,234 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
import { getItemElement as B, useCollectionId as ue, isNonContiguousSelectionModifier as H } from "./index341.mjs";
|
|
2
|
+
import { useTypeSelect as fe } from "./index342.mjs";
|
|
3
|
+
import { getActiveElement as se } from "./index244.mjs";
|
|
4
|
+
import { mergeProps as q } from "./index158.mjs";
|
|
5
|
+
import { focusWithoutScrolling as G } from "./index248.mjs";
|
|
6
|
+
import { useRouter as ae } from "./index249.mjs";
|
|
7
|
+
import { useUpdateLayoutEffect as j } from "./index254.mjs";
|
|
8
|
+
import { useEvent as S } from "./index262.mjs";
|
|
9
|
+
import { scrollIntoView as de, scrollIntoViewport as J } from "./index263.mjs";
|
|
10
|
+
import { FOCUS_EVENT as ve, CLEAR_FOCUS_EVENT as pe } from "./index266.mjs";
|
|
11
|
+
import { isCtrlKeyPressed as F } from "./index267.mjs";
|
|
12
|
+
import { isTabbable as be } from "./index268.mjs";
|
|
13
|
+
import { moveVirtualFocus as me, dispatchVirtualFocus as ye, getFocusableTreeWalker as $e } from "@react-aria/focus";
|
|
14
|
+
import { flushSync as Ke } from "react-dom";
|
|
15
|
+
import { useRef as m, useEffect as C } from "react";
|
|
16
|
+
import { getInteractionModality as Q } from "./index329.mjs";
|
|
17
|
+
import { focusSafely as X } from "./index340.mjs";
|
|
18
|
+
import { useLocale as Fe } from "@react-aria/i18n";
|
|
19
|
+
function Ue(Y) {
|
|
20
|
+
let { selectionManager: e, keyboardDelegate: o, ref: i, autoFocus: w = !1, shouldFocusWrap: x = !1, disallowEmptySelection: Z = !1, disallowSelectAll: g = !1, escapeKeyBehavior: _ = "clearSelection", selectOnFocus: y = e.selectionBehavior === "replace", disallowTypeAhead: ee = !1, shouldUseVirtualFocus: b, allowsTabNavigation: le = !1, isVirtualized: N, scrollRef: s = i, linkBehavior: U = "action" } = Y, { direction: T } = Fe(), oe = ae(), te = (l) => {
|
|
21
|
+
var r;
|
|
22
|
+
if (l.altKey && l.key === "Tab" && l.preventDefault(), !(!((r = i.current) === null || r === void 0) && r.contains(l.target))) return;
|
|
23
|
+
const c = (t, v) => {
|
|
24
|
+
if (t != null) {
|
|
25
|
+
if (e.isLink(t) && U === "selection" && y && !H(l)) {
|
|
26
|
+
Ke(() => {
|
|
27
|
+
e.setFocusedKey(t, v);
|
|
28
|
+
});
|
|
29
|
+
let p = B(i, t), W = e.getItemProps(t);
|
|
30
|
+
p && oe.open(p, l, W.href, W.routerOptions);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (e.setFocusedKey(t, v), e.isLink(t) && U === "override") return;
|
|
34
|
+
l.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(t) : y && !H(l) && e.replaceSelection(t);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
switch (l.key) {
|
|
38
|
+
case "ArrowDown":
|
|
39
|
+
if (o.getKeyBelow) {
|
|
40
|
+
var n, f, u;
|
|
41
|
+
let t = e.focusedKey != null ? (n = o.getKeyBelow) === null || n === void 0 ? void 0 : n.call(o, e.focusedKey) : (f = o.getFirstKey) === null || f === void 0 ? void 0 : f.call(o);
|
|
42
|
+
t == null && x && (t = (u = o.getFirstKey) === null || u === void 0 ? void 0 : u.call(o, e.focusedKey)), t != null && (l.preventDefault(), c(t));
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case "ArrowUp":
|
|
46
|
+
if (o.getKeyAbove) {
|
|
47
|
+
var a, d, A;
|
|
48
|
+
let t = e.focusedKey != null ? (a = o.getKeyAbove) === null || a === void 0 ? void 0 : a.call(o, e.focusedKey) : (d = o.getLastKey) === null || d === void 0 ? void 0 : d.call(o);
|
|
49
|
+
t == null && x && (t = (A = o.getLastKey) === null || A === void 0 ? void 0 : A.call(o, e.focusedKey)), t != null && (l.preventDefault(), c(t));
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case "ArrowLeft":
|
|
53
|
+
if (o.getKeyLeftOf) {
|
|
54
|
+
var k, I, M;
|
|
55
|
+
let t = e.focusedKey != null ? (k = o.getKeyLeftOf) === null || k === void 0 ? void 0 : k.call(o, e.focusedKey) : null;
|
|
56
|
+
t == null && x && (t = T === "rtl" ? (I = o.getFirstKey) === null || I === void 0 ? void 0 : I.call(o, e.focusedKey) : (M = o.getLastKey) === null || M === void 0 ? void 0 : M.call(o, e.focusedKey)), t != null && (l.preventDefault(), c(t, T === "rtl" ? "first" : "last"));
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case "ArrowRight":
|
|
60
|
+
if (o.getKeyRightOf) {
|
|
61
|
+
var R, V, O;
|
|
62
|
+
let t = e.focusedKey != null ? (R = o.getKeyRightOf) === null || R === void 0 ? void 0 : R.call(o, e.focusedKey) : null;
|
|
63
|
+
t == null && x && (t = T === "rtl" ? (V = o.getLastKey) === null || V === void 0 ? void 0 : V.call(o, e.focusedKey) : (O = o.getFirstKey) === null || O === void 0 ? void 0 : O.call(o, e.focusedKey)), t != null && (l.preventDefault(), c(t, T === "rtl" ? "last" : "first"));
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case "Home":
|
|
67
|
+
if (o.getFirstKey) {
|
|
68
|
+
if (e.focusedKey === null && l.shiftKey) return;
|
|
69
|
+
l.preventDefault();
|
|
70
|
+
let t = o.getFirstKey(e.focusedKey, F(l));
|
|
71
|
+
e.setFocusedKey(t), t != null && (F(l) && l.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(t) : y && e.replaceSelection(t));
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case "End":
|
|
75
|
+
if (o.getLastKey) {
|
|
76
|
+
if (e.focusedKey === null && l.shiftKey) return;
|
|
77
|
+
l.preventDefault();
|
|
78
|
+
let t = o.getLastKey(e.focusedKey, F(l));
|
|
79
|
+
e.setFocusedKey(t), t != null && (F(l) && l.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(t) : y && e.replaceSelection(t));
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
case "PageDown":
|
|
83
|
+
if (o.getKeyPageBelow && e.focusedKey != null) {
|
|
84
|
+
let t = o.getKeyPageBelow(e.focusedKey);
|
|
85
|
+
t != null && (l.preventDefault(), c(t));
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
case "PageUp":
|
|
89
|
+
if (o.getKeyPageAbove && e.focusedKey != null) {
|
|
90
|
+
let t = o.getKeyPageAbove(e.focusedKey);
|
|
91
|
+
t != null && (l.preventDefault(), c(t));
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case "a":
|
|
95
|
+
F(l) && e.selectionMode === "multiple" && g !== !0 && (l.preventDefault(), e.selectAll());
|
|
96
|
+
break;
|
|
97
|
+
case "Escape":
|
|
98
|
+
_ === "clearSelection" && !Z && e.selectedKeys.size !== 0 && (l.stopPropagation(), l.preventDefault(), e.clearSelection());
|
|
99
|
+
break;
|
|
100
|
+
case "Tab":
|
|
101
|
+
if (!le) {
|
|
102
|
+
if (l.shiftKey) i.current.focus();
|
|
103
|
+
else {
|
|
104
|
+
let t = $e(i.current, {
|
|
105
|
+
tabbable: !0
|
|
106
|
+
}), v, p;
|
|
107
|
+
do
|
|
108
|
+
p = t.lastChild(), p && (v = p);
|
|
109
|
+
while (p);
|
|
110
|
+
v && (!v.contains(document.activeElement) || document.activeElement && !be(document.activeElement)) && G(v);
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, E = m({
|
|
116
|
+
top: 0,
|
|
117
|
+
left: 0
|
|
118
|
+
});
|
|
119
|
+
S(s, "scroll", N ? void 0 : () => {
|
|
120
|
+
var l, r, c, n;
|
|
121
|
+
E.current = {
|
|
122
|
+
top: (c = (l = s.current) === null || l === void 0 ? void 0 : l.scrollTop) !== null && c !== void 0 ? c : 0,
|
|
123
|
+
left: (n = (r = s.current) === null || r === void 0 ? void 0 : r.scrollLeft) !== null && n !== void 0 ? n : 0
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
let re = (l) => {
|
|
127
|
+
if (e.isFocused) {
|
|
128
|
+
l.currentTarget.contains(l.target) || e.setFocused(!1);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (l.currentTarget.contains(l.target)) {
|
|
132
|
+
if (e.setFocused(!0), e.focusedKey == null) {
|
|
133
|
+
var r, c;
|
|
134
|
+
let u = (d) => {
|
|
135
|
+
d != null && (e.setFocusedKey(d), y && !e.isSelected(d) && e.replaceSelection(d));
|
|
136
|
+
}, a = l.relatedTarget;
|
|
137
|
+
var n, f;
|
|
138
|
+
a && l.currentTarget.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_FOLLOWING ? u((n = e.lastSelectedKey) !== null && n !== void 0 ? n : (r = o.getLastKey) === null || r === void 0 ? void 0 : r.call(o)) : u((f = e.firstSelectedKey) !== null && f !== void 0 ? f : (c = o.getFirstKey) === null || c === void 0 ? void 0 : c.call(o));
|
|
139
|
+
} else !N && s.current && (s.current.scrollTop = E.current.top, s.current.scrollLeft = E.current.left);
|
|
140
|
+
if (e.focusedKey != null && s.current) {
|
|
141
|
+
let u = B(i, e.focusedKey);
|
|
142
|
+
u instanceof HTMLElement && (!u.contains(document.activeElement) && !b && G(u), Q() === "keyboard" && J(u, {
|
|
143
|
+
containingElement: i.current
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, ce = (l) => {
|
|
148
|
+
l.currentTarget.contains(l.relatedTarget) || e.setFocused(!1);
|
|
149
|
+
}, $ = m(!1);
|
|
150
|
+
S(i, ve, b ? (l) => {
|
|
151
|
+
let { detail: r } = l;
|
|
152
|
+
l.stopPropagation(), e.setFocused(!0), (r == null ? void 0 : r.focusStrategy) === "first" && ($.current = !0);
|
|
153
|
+
} : void 0), j(() => {
|
|
154
|
+
if ($.current) {
|
|
155
|
+
var l, r;
|
|
156
|
+
let c = (r = (l = o.getFirstKey) === null || l === void 0 ? void 0 : l.call(o)) !== null && r !== void 0 ? r : null;
|
|
157
|
+
if (c == null) {
|
|
158
|
+
let n = se();
|
|
159
|
+
me(i.current), ye(n, null), e.collection.size > 0 && ($.current = !1);
|
|
160
|
+
} else
|
|
161
|
+
e.setFocusedKey(c), $.current = !1;
|
|
162
|
+
}
|
|
163
|
+
}, [
|
|
164
|
+
e.collection
|
|
165
|
+
]), j(() => {
|
|
166
|
+
e.collection.size > 0 && ($.current = !1);
|
|
167
|
+
}, [
|
|
168
|
+
e.focusedKey
|
|
169
|
+
]), S(i, pe, b ? (l) => {
|
|
170
|
+
var r;
|
|
171
|
+
l.stopPropagation(), e.setFocused(!1), !((r = l.detail) === null || r === void 0) && r.clearFocusKey && e.setFocusedKey(null);
|
|
172
|
+
} : void 0);
|
|
173
|
+
const z = m(w), h = m(!1);
|
|
174
|
+
C(() => {
|
|
175
|
+
if (z.current) {
|
|
176
|
+
var l, r;
|
|
177
|
+
let f = null;
|
|
178
|
+
var c;
|
|
179
|
+
w === "first" && (f = (c = (l = o.getFirstKey) === null || l === void 0 ? void 0 : l.call(o)) !== null && c !== void 0 ? c : null);
|
|
180
|
+
var n;
|
|
181
|
+
w === "last" && (f = (n = (r = o.getLastKey) === null || r === void 0 ? void 0 : r.call(o)) !== null && n !== void 0 ? n : null);
|
|
182
|
+
let u = e.selectedKeys;
|
|
183
|
+
if (u.size) {
|
|
184
|
+
for (let a of u) if (e.canSelectItem(a)) {
|
|
185
|
+
f = a;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
e.setFocused(!0), e.setFocusedKey(f), f == null && !b && i.current && X(i.current), e.collection.size > 0 && (z.current = !1, h.current = !0);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
let D = m(e.focusedKey), K = m(null);
|
|
193
|
+
C(() => {
|
|
194
|
+
if (e.isFocused && e.focusedKey != null && (e.focusedKey !== D.current || h.current) && s.current && i.current) {
|
|
195
|
+
let l = Q(), r = B(i, e.focusedKey);
|
|
196
|
+
if (!(r instanceof HTMLElement))
|
|
197
|
+
return;
|
|
198
|
+
(l === "keyboard" || h.current) && (K.current && cancelAnimationFrame(K.current), K.current = requestAnimationFrame(() => {
|
|
199
|
+
s.current && (de(s.current, r), l !== "virtual" && J(r, {
|
|
200
|
+
containingElement: i.current
|
|
201
|
+
}));
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
!b && e.isFocused && e.focusedKey == null && D.current != null && i.current && X(i.current), D.current = e.focusedKey, h.current = !1;
|
|
205
|
+
}), C(() => () => {
|
|
206
|
+
K.current && cancelAnimationFrame(K.current);
|
|
207
|
+
}, []), S(i, "react-aria-focus-scope-restore", (l) => {
|
|
208
|
+
l.preventDefault(), e.setFocused(!0);
|
|
209
|
+
});
|
|
210
|
+
let P = {
|
|
211
|
+
onKeyDown: te,
|
|
212
|
+
onFocus: re,
|
|
213
|
+
onBlur: ce,
|
|
214
|
+
onMouseDown(l) {
|
|
215
|
+
s.current === l.target && l.preventDefault();
|
|
216
|
+
}
|
|
217
|
+
}, { typeSelectProps: ie } = fe({
|
|
218
|
+
keyboardDelegate: o,
|
|
219
|
+
selectionManager: e
|
|
220
|
+
});
|
|
221
|
+
ee || (P = q(ie, P));
|
|
222
|
+
let L;
|
|
223
|
+
b || (L = e.focusedKey == null ? 0 : -1);
|
|
224
|
+
let ne = ue(e.collection);
|
|
225
|
+
return {
|
|
226
|
+
collectionProps: q(P, {
|
|
227
|
+
tabIndex: L,
|
|
228
|
+
"data-collection": ne
|
|
229
|
+
})
|
|
230
|
+
};
|
|
43
231
|
}
|
|
44
232
|
export {
|
|
45
|
-
|
|
233
|
+
Ue as useSelectableCollection
|
|
46
234
|
};
|
package/index286.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("./index343.js"),y=require("./index271.js"),g=require("react");function K(t){var l;let[e,s]=y.useControlledState(t.selectedKey,(l=t.defaultSelectedKey)!==null&&l!==void 0?l:null,t.onSelectionChange),i=g.useMemo(()=>e!=null?[e]:[],[e]),{collection:a,disabledKeys:u,selectionManager:d}=S.useListState({...t,selectionMode:"single",disallowEmptySelection:!0,allowDuplicateSelectionEvents:!0,selectedKeys:i,onSelectionChange:o=>{if(o==="all")return;var n;let c=(n=o.values().next().value)!==null&&n!==void 0?n:null;c===e&&t.onSelectionChange&&t.onSelectionChange(c),s(c)}}),r=e!=null?a.getItem(e):null;return{collection:a,disabledKeys:u,selectionManager:d,selectedKey:e,setSelectedKey:s,selectedItem:r}}exports.useSingleSelectListState=K;
|
package/index286.mjs
CHANGED
|
@@ -1,234 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import { useLocale as Fe } from "@react-aria/i18n";
|
|
19
|
-
function Ue(Y) {
|
|
20
|
-
let { selectionManager: e, keyboardDelegate: o, ref: i, autoFocus: w = !1, shouldFocusWrap: x = !1, disallowEmptySelection: Z = !1, disallowSelectAll: g = !1, escapeKeyBehavior: _ = "clearSelection", selectOnFocus: y = e.selectionBehavior === "replace", disallowTypeAhead: ee = !1, shouldUseVirtualFocus: b, allowsTabNavigation: le = !1, isVirtualized: N, scrollRef: s = i, linkBehavior: U = "action" } = Y, { direction: T } = Fe(), oe = ae(), te = (l) => {
|
|
21
|
-
var r;
|
|
22
|
-
if (l.altKey && l.key === "Tab" && l.preventDefault(), !(!((r = i.current) === null || r === void 0) && r.contains(l.target))) return;
|
|
23
|
-
const c = (t, v) => {
|
|
24
|
-
if (t != null) {
|
|
25
|
-
if (e.isLink(t) && U === "selection" && y && !H(l)) {
|
|
26
|
-
Ke(() => {
|
|
27
|
-
e.setFocusedKey(t, v);
|
|
28
|
-
});
|
|
29
|
-
let p = B(i, t), W = e.getItemProps(t);
|
|
30
|
-
p && oe.open(p, l, W.href, W.routerOptions);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (e.setFocusedKey(t, v), e.isLink(t) && U === "override") return;
|
|
34
|
-
l.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(t) : y && !H(l) && e.replaceSelection(t);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
switch (l.key) {
|
|
38
|
-
case "ArrowDown":
|
|
39
|
-
if (o.getKeyBelow) {
|
|
40
|
-
var n, f, u;
|
|
41
|
-
let t = e.focusedKey != null ? (n = o.getKeyBelow) === null || n === void 0 ? void 0 : n.call(o, e.focusedKey) : (f = o.getFirstKey) === null || f === void 0 ? void 0 : f.call(o);
|
|
42
|
-
t == null && x && (t = (u = o.getFirstKey) === null || u === void 0 ? void 0 : u.call(o, e.focusedKey)), t != null && (l.preventDefault(), c(t));
|
|
43
|
-
}
|
|
44
|
-
break;
|
|
45
|
-
case "ArrowUp":
|
|
46
|
-
if (o.getKeyAbove) {
|
|
47
|
-
var a, d, A;
|
|
48
|
-
let t = e.focusedKey != null ? (a = o.getKeyAbove) === null || a === void 0 ? void 0 : a.call(o, e.focusedKey) : (d = o.getLastKey) === null || d === void 0 ? void 0 : d.call(o);
|
|
49
|
-
t == null && x && (t = (A = o.getLastKey) === null || A === void 0 ? void 0 : A.call(o, e.focusedKey)), t != null && (l.preventDefault(), c(t));
|
|
50
|
-
}
|
|
51
|
-
break;
|
|
52
|
-
case "ArrowLeft":
|
|
53
|
-
if (o.getKeyLeftOf) {
|
|
54
|
-
var k, I, M;
|
|
55
|
-
let t = e.focusedKey != null ? (k = o.getKeyLeftOf) === null || k === void 0 ? void 0 : k.call(o, e.focusedKey) : null;
|
|
56
|
-
t == null && x && (t = T === "rtl" ? (I = o.getFirstKey) === null || I === void 0 ? void 0 : I.call(o, e.focusedKey) : (M = o.getLastKey) === null || M === void 0 ? void 0 : M.call(o, e.focusedKey)), t != null && (l.preventDefault(), c(t, T === "rtl" ? "first" : "last"));
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case "ArrowRight":
|
|
60
|
-
if (o.getKeyRightOf) {
|
|
61
|
-
var R, V, O;
|
|
62
|
-
let t = e.focusedKey != null ? (R = o.getKeyRightOf) === null || R === void 0 ? void 0 : R.call(o, e.focusedKey) : null;
|
|
63
|
-
t == null && x && (t = T === "rtl" ? (V = o.getLastKey) === null || V === void 0 ? void 0 : V.call(o, e.focusedKey) : (O = o.getFirstKey) === null || O === void 0 ? void 0 : O.call(o, e.focusedKey)), t != null && (l.preventDefault(), c(t, T === "rtl" ? "last" : "first"));
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
case "Home":
|
|
67
|
-
if (o.getFirstKey) {
|
|
68
|
-
if (e.focusedKey === null && l.shiftKey) return;
|
|
69
|
-
l.preventDefault();
|
|
70
|
-
let t = o.getFirstKey(e.focusedKey, F(l));
|
|
71
|
-
e.setFocusedKey(t), t != null && (F(l) && l.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(t) : y && e.replaceSelection(t));
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
case "End":
|
|
75
|
-
if (o.getLastKey) {
|
|
76
|
-
if (e.focusedKey === null && l.shiftKey) return;
|
|
77
|
-
l.preventDefault();
|
|
78
|
-
let t = o.getLastKey(e.focusedKey, F(l));
|
|
79
|
-
e.setFocusedKey(t), t != null && (F(l) && l.shiftKey && e.selectionMode === "multiple" ? e.extendSelection(t) : y && e.replaceSelection(t));
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
case "PageDown":
|
|
83
|
-
if (o.getKeyPageBelow && e.focusedKey != null) {
|
|
84
|
-
let t = o.getKeyPageBelow(e.focusedKey);
|
|
85
|
-
t != null && (l.preventDefault(), c(t));
|
|
86
|
-
}
|
|
87
|
-
break;
|
|
88
|
-
case "PageUp":
|
|
89
|
-
if (o.getKeyPageAbove && e.focusedKey != null) {
|
|
90
|
-
let t = o.getKeyPageAbove(e.focusedKey);
|
|
91
|
-
t != null && (l.preventDefault(), c(t));
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
case "a":
|
|
95
|
-
F(l) && e.selectionMode === "multiple" && g !== !0 && (l.preventDefault(), e.selectAll());
|
|
96
|
-
break;
|
|
97
|
-
case "Escape":
|
|
98
|
-
_ === "clearSelection" && !Z && e.selectedKeys.size !== 0 && (l.stopPropagation(), l.preventDefault(), e.clearSelection());
|
|
99
|
-
break;
|
|
100
|
-
case "Tab":
|
|
101
|
-
if (!le) {
|
|
102
|
-
if (l.shiftKey) i.current.focus();
|
|
103
|
-
else {
|
|
104
|
-
let t = $e(i.current, {
|
|
105
|
-
tabbable: !0
|
|
106
|
-
}), v, p;
|
|
107
|
-
do
|
|
108
|
-
p = t.lastChild(), p && (v = p);
|
|
109
|
-
while (p);
|
|
110
|
-
v && (!v.contains(document.activeElement) || document.activeElement && !be(document.activeElement)) && G(v);
|
|
111
|
-
}
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}, E = m({
|
|
116
|
-
top: 0,
|
|
117
|
-
left: 0
|
|
118
|
-
});
|
|
119
|
-
S(s, "scroll", N ? void 0 : () => {
|
|
120
|
-
var l, r, c, n;
|
|
121
|
-
E.current = {
|
|
122
|
-
top: (c = (l = s.current) === null || l === void 0 ? void 0 : l.scrollTop) !== null && c !== void 0 ? c : 0,
|
|
123
|
-
left: (n = (r = s.current) === null || r === void 0 ? void 0 : r.scrollLeft) !== null && n !== void 0 ? n : 0
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
let re = (l) => {
|
|
127
|
-
if (e.isFocused) {
|
|
128
|
-
l.currentTarget.contains(l.target) || e.setFocused(!1);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (l.currentTarget.contains(l.target)) {
|
|
132
|
-
if (e.setFocused(!0), e.focusedKey == null) {
|
|
133
|
-
var r, c;
|
|
134
|
-
let u = (d) => {
|
|
135
|
-
d != null && (e.setFocusedKey(d), y && !e.isSelected(d) && e.replaceSelection(d));
|
|
136
|
-
}, a = l.relatedTarget;
|
|
137
|
-
var n, f;
|
|
138
|
-
a && l.currentTarget.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_FOLLOWING ? u((n = e.lastSelectedKey) !== null && n !== void 0 ? n : (r = o.getLastKey) === null || r === void 0 ? void 0 : r.call(o)) : u((f = e.firstSelectedKey) !== null && f !== void 0 ? f : (c = o.getFirstKey) === null || c === void 0 ? void 0 : c.call(o));
|
|
139
|
-
} else !N && s.current && (s.current.scrollTop = E.current.top, s.current.scrollLeft = E.current.left);
|
|
140
|
-
if (e.focusedKey != null && s.current) {
|
|
141
|
-
let u = B(i, e.focusedKey);
|
|
142
|
-
u instanceof HTMLElement && (!u.contains(document.activeElement) && !b && G(u), Q() === "keyboard" && J(u, {
|
|
143
|
-
containingElement: i.current
|
|
144
|
-
}));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, ce = (l) => {
|
|
148
|
-
l.currentTarget.contains(l.relatedTarget) || e.setFocused(!1);
|
|
149
|
-
}, $ = m(!1);
|
|
150
|
-
S(i, ve, b ? (l) => {
|
|
151
|
-
let { detail: r } = l;
|
|
152
|
-
l.stopPropagation(), e.setFocused(!0), (r == null ? void 0 : r.focusStrategy) === "first" && ($.current = !0);
|
|
153
|
-
} : void 0), j(() => {
|
|
154
|
-
if ($.current) {
|
|
155
|
-
var l, r;
|
|
156
|
-
let c = (r = (l = o.getFirstKey) === null || l === void 0 ? void 0 : l.call(o)) !== null && r !== void 0 ? r : null;
|
|
157
|
-
if (c == null) {
|
|
158
|
-
let n = se();
|
|
159
|
-
me(i.current), ye(n, null), e.collection.size > 0 && ($.current = !1);
|
|
160
|
-
} else
|
|
161
|
-
e.setFocusedKey(c), $.current = !1;
|
|
162
|
-
}
|
|
163
|
-
}, [
|
|
164
|
-
e.collection
|
|
165
|
-
]), j(() => {
|
|
166
|
-
e.collection.size > 0 && ($.current = !1);
|
|
167
|
-
}, [
|
|
168
|
-
e.focusedKey
|
|
169
|
-
]), S(i, pe, b ? (l) => {
|
|
170
|
-
var r;
|
|
171
|
-
l.stopPropagation(), e.setFocused(!1), !((r = l.detail) === null || r === void 0) && r.clearFocusKey && e.setFocusedKey(null);
|
|
172
|
-
} : void 0);
|
|
173
|
-
const z = m(w), h = m(!1);
|
|
174
|
-
C(() => {
|
|
175
|
-
if (z.current) {
|
|
176
|
-
var l, r;
|
|
177
|
-
let f = null;
|
|
178
|
-
var c;
|
|
179
|
-
w === "first" && (f = (c = (l = o.getFirstKey) === null || l === void 0 ? void 0 : l.call(o)) !== null && c !== void 0 ? c : null);
|
|
1
|
+
import { useListState as f } from "./index343.mjs";
|
|
2
|
+
import { useControlledState as S } from "./index271.mjs";
|
|
3
|
+
import { useMemo as y } from "react";
|
|
4
|
+
function g(l) {
|
|
5
|
+
var t;
|
|
6
|
+
let [e, c] = S(l.selectedKey, (t = l.defaultSelectedKey) !== null && t !== void 0 ? t : null, l.onSelectionChange), i = y(() => e != null ? [
|
|
7
|
+
e
|
|
8
|
+
] : [], [
|
|
9
|
+
e
|
|
10
|
+
]), { collection: o, disabledKeys: d, selectionManager: u } = f({
|
|
11
|
+
...l,
|
|
12
|
+
selectionMode: "single",
|
|
13
|
+
disallowEmptySelection: !0,
|
|
14
|
+
allowDuplicateSelectionEvents: !0,
|
|
15
|
+
selectedKeys: i,
|
|
16
|
+
onSelectionChange: (s) => {
|
|
17
|
+
if (s === "all") return;
|
|
180
18
|
var n;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (u.size) {
|
|
184
|
-
for (let a of u) if (e.canSelectItem(a)) {
|
|
185
|
-
f = a;
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
e.setFocused(!0), e.setFocusedKey(f), f == null && !b && i.current && X(i.current), e.collection.size > 0 && (z.current = !1, h.current = !0);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
let D = m(e.focusedKey), K = m(null);
|
|
193
|
-
C(() => {
|
|
194
|
-
if (e.isFocused && e.focusedKey != null && (e.focusedKey !== D.current || h.current) && s.current && i.current) {
|
|
195
|
-
let l = Q(), r = B(i, e.focusedKey);
|
|
196
|
-
if (!(r instanceof HTMLElement))
|
|
197
|
-
return;
|
|
198
|
-
(l === "keyboard" || h.current) && (K.current && cancelAnimationFrame(K.current), K.current = requestAnimationFrame(() => {
|
|
199
|
-
s.current && (de(s.current, r), l !== "virtual" && J(r, {
|
|
200
|
-
containingElement: i.current
|
|
201
|
-
}));
|
|
202
|
-
}));
|
|
203
|
-
}
|
|
204
|
-
!b && e.isFocused && e.focusedKey == null && D.current != null && i.current && X(i.current), D.current = e.focusedKey, h.current = !1;
|
|
205
|
-
}), C(() => () => {
|
|
206
|
-
K.current && cancelAnimationFrame(K.current);
|
|
207
|
-
}, []), S(i, "react-aria-focus-scope-restore", (l) => {
|
|
208
|
-
l.preventDefault(), e.setFocused(!0);
|
|
209
|
-
});
|
|
210
|
-
let P = {
|
|
211
|
-
onKeyDown: te,
|
|
212
|
-
onFocus: re,
|
|
213
|
-
onBlur: ce,
|
|
214
|
-
onMouseDown(l) {
|
|
215
|
-
s.current === l.target && l.preventDefault();
|
|
19
|
+
let a = (n = s.values().next().value) !== null && n !== void 0 ? n : null;
|
|
20
|
+
a === e && l.onSelectionChange && l.onSelectionChange(a), c(a);
|
|
216
21
|
}
|
|
217
|
-
},
|
|
218
|
-
keyboardDelegate: o,
|
|
219
|
-
selectionManager: e
|
|
220
|
-
});
|
|
221
|
-
ee || (P = q(ie, P));
|
|
222
|
-
let L;
|
|
223
|
-
b || (L = e.focusedKey == null ? 0 : -1);
|
|
224
|
-
let ne = ue(e.collection);
|
|
22
|
+
}), r = e != null ? o.getItem(e) : null;
|
|
225
23
|
return {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
24
|
+
collection: o,
|
|
25
|
+
disabledKeys: d,
|
|
26
|
+
selectionManager: u,
|
|
27
|
+
selectedKey: e,
|
|
28
|
+
setSelectedKey: c,
|
|
29
|
+
selectedItem: r
|
|
230
30
|
};
|
|
231
31
|
}
|
|
232
32
|
export {
|
|
233
|
-
|
|
33
|
+
g as useSingleSelectListState
|
|
234
34
|
};
|
package/index341.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index185.js"),i=require("./index250.js");function u(e){return i.isAppleDevice()?e.altKey:e.ctrlKey}function a(e,t){var o,f;let r=`[data-key="${CSS.escape(String(t))}"]`,n=(o=e.current)===null||o===void 0?void 0:o.dataset.collection;return n&&(r=`[data-collection="${CSS.escape(n)}"]${r}`),(f=e.current)===null||f===void 0?void 0:f.querySelector(r)}const c=new WeakMap;function d(e){let t=l.useId();return c.set(e,t),t}function $(e){return c.get(e)}exports.getCollectionId=$;exports.getItemElement=a;exports.isNonContiguousSelectionModifier=u;exports.useCollectionId=d;
|