@arun-dev/headless 4.6.0 → 4.8.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/dist/chunk-2S4XG4VD.js +33 -0
- package/dist/combobox/index.cjs +1057 -0
- package/dist/combobox/index.d.cts +288 -0
- package/dist/combobox/index.d.ts +288 -0
- package/dist/combobox/index.js +873 -0
- package/dist/menu/index.cjs +438 -0
- package/dist/menu/index.d.cts +115 -0
- package/dist/menu/index.d.ts +115 -0
- package/dist/menu/index.js +255 -0
- package/dist/tabs/index.cjs +62 -43
- package/dist/tabs/index.d.cts +15 -4
- package/dist/tabs/index.d.ts +15 -4
- package/dist/tabs/index.js +37 -43
- package/package.json +21 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/core/rovingFocus.ts
|
|
2
|
+
function byDocumentOrder(a, b) {
|
|
3
|
+
const x = a.ref.current;
|
|
4
|
+
const y = b.ref.current;
|
|
5
|
+
if (!x || !y) return 0;
|
|
6
|
+
return x.compareDocumentPosition(y) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
7
|
+
}
|
|
8
|
+
function rovingIndex(key, {
|
|
9
|
+
count,
|
|
10
|
+
current,
|
|
11
|
+
orientation,
|
|
12
|
+
rtl
|
|
13
|
+
}) {
|
|
14
|
+
if (count === 0) return null;
|
|
15
|
+
const [prevKey, nextKey] = orientation === "vertical" ? ["ArrowUp", "ArrowDown"] : rtl ? ["ArrowRight", "ArrowLeft"] : ["ArrowLeft", "ArrowRight"];
|
|
16
|
+
switch (key) {
|
|
17
|
+
case nextKey:
|
|
18
|
+
return current < 0 ? 0 : (current + 1) % count;
|
|
19
|
+
case prevKey:
|
|
20
|
+
return current < 0 ? count - 1 : (current - 1 + count) % count;
|
|
21
|
+
case "Home":
|
|
22
|
+
return 0;
|
|
23
|
+
case "End":
|
|
24
|
+
return count - 1;
|
|
25
|
+
default:
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
byDocumentOrder,
|
|
32
|
+
rovingIndex
|
|
33
|
+
};
|