@mortenbrudvik/waveui 0.11.0 → 0.13.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/README.md +157 -13
- package/dist/components/button/Link.cjs +1 -1
- package/dist/components/button/Link.cjs.map +1 -1
- package/dist/components/button/Link.mjs +4 -4
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.colors.cjs +2 -0
- package/dist/components/data-display/Avatar.colors.cjs.map +1 -0
- package/dist/components/data-display/Avatar.colors.mjs +45 -0
- package/dist/components/data-display/Avatar.colors.mjs.map +1 -0
- package/dist/components/data-display/Avatar.context.cjs +1 -1
- package/dist/components/data-display/Avatar.context.cjs.map +1 -1
- package/dist/components/data-display/Avatar.context.mjs +4 -2
- package/dist/components/data-display/Avatar.context.mjs.map +1 -1
- package/dist/components/data-display/Avatar.mjs +103 -96
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/Avatar.sizes.cjs +2 -0
- package/dist/components/data-display/Avatar.sizes.cjs.map +1 -0
- package/dist/components/data-display/Avatar.sizes.mjs +41 -0
- package/dist/components/data-display/Avatar.sizes.mjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.context.cjs +2 -0
- package/dist/components/data-display/AvatarGroup.context.cjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.context.mjs +9 -0
- package/dist/components/data-display/AvatarGroup.context.mjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.mjs +65 -122
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.partition.cjs +2 -0
- package/dist/components/data-display/AvatarGroup.partition.cjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.partition.mjs +14 -0
- package/dist/components/data-display/AvatarGroup.partition.mjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.parts.cjs +2 -0
- package/dist/components/data-display/AvatarGroup.parts.cjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.parts.mjs +178 -0
- package/dist/components/data-display/AvatarGroup.parts.mjs.map +1 -0
- package/dist/components/data-display/InfoButton.cjs +1 -1
- package/dist/components/data-display/InfoButton.cjs.map +1 -1
- package/dist/components/data-display/InfoButton.mjs +12 -12
- package/dist/components/data-display/InteractionTag.cjs +1 -1
- package/dist/components/data-display/InteractionTag.cjs.map +1 -1
- package/dist/components/data-display/InteractionTag.mjs +36 -33
- package/dist/components/data-display/InteractionTag.mjs.map +1 -1
- package/dist/components/data-display/Persona.cjs +1 -1
- package/dist/components/data-display/Persona.cjs.map +1 -1
- package/dist/components/data-display/Persona.mjs +96 -37
- package/dist/components/data-display/Persona.mjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.cjs +1 -1
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.mjs +42 -28
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +111 -108
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/feedback/Toaster.cjs +1 -1
- package/dist/components/feedback/Toaster.cjs.map +1 -1
- package/dist/components/feedback/Toaster.mjs +235 -235
- package/dist/components/feedback/Toaster.mjs.map +1 -1
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.mjs +176 -175
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +188 -187
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +41 -40
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +89 -87
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/TagPicker.root.cjs +1 -1
- package/dist/components/input/TagPicker.root.cjs.map +1 -1
- package/dist/components/input/TagPicker.root.mjs +136 -135
- package/dist/components/input/TagPicker.root.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +156 -154
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/layout/Card.cjs +1 -1
- package/dist/components/layout/Card.cjs.map +1 -1
- package/dist/components/layout/Card.context.cjs +2 -0
- package/dist/components/layout/Card.context.cjs.map +1 -0
- package/dist/components/layout/Card.context.mjs +14 -0
- package/dist/components/layout/Card.context.mjs.map +1 -0
- package/dist/components/layout/Card.mjs +138 -92
- package/dist/components/layout/Card.mjs.map +1 -1
- package/dist/components/layout/Card.preview.cjs +2 -0
- package/dist/components/layout/Card.preview.cjs.map +1 -0
- package/dist/components/layout/Card.preview.mjs +22 -0
- package/dist/components/layout/Card.preview.mjs.map +1 -0
- package/dist/components/layout/Carousel.button.cjs +2 -0
- package/dist/components/layout/Carousel.button.cjs.map +1 -0
- package/dist/components/layout/Carousel.button.mjs +34 -0
- package/dist/components/layout/Carousel.button.mjs.map +1 -0
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.context.cjs +2 -0
- package/dist/components/layout/Carousel.context.cjs.map +1 -0
- package/dist/components/layout/Carousel.context.mjs +24 -0
- package/dist/components/layout/Carousel.context.mjs.map +1 -0
- package/dist/components/layout/Carousel.drag.cjs +2 -0
- package/dist/components/layout/Carousel.drag.cjs.map +1 -0
- package/dist/components/layout/Carousel.drag.mjs +79 -0
- package/dist/components/layout/Carousel.drag.mjs.map +1 -0
- package/dist/components/layout/Carousel.groups.cjs +2 -0
- package/dist/components/layout/Carousel.groups.cjs.map +1 -0
- package/dist/components/layout/Carousel.groups.mjs +23 -0
- package/dist/components/layout/Carousel.groups.mjs.map +1 -0
- package/dist/components/layout/Carousel.mjs +288 -150
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/Carousel.styles.cjs +2 -0
- package/dist/components/layout/Carousel.styles.cjs.map +1 -0
- package/dist/components/layout/Carousel.styles.mjs +30 -0
- package/dist/components/layout/Carousel.styles.mjs.map +1 -0
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +163 -124
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +137 -127
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +4 -4
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +123 -123
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.cjs +1 -1
- package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.mjs +12 -12
- package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +173 -162
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs +96 -91
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +47 -47
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/portal/Portal.cjs +1 -1
- package/dist/components/portal/Portal.cjs.map +1 -1
- package/dist/components/portal/Portal.mjs +5 -5
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +1 -1
- package/dist/hooks/useDismiss.cjs.map +1 -1
- package/dist/hooks/useDismiss.mjs.map +1 -1
- package/dist/hooks/useFocusTrap.cjs.map +1 -1
- package/dist/hooks/useFocusTrap.mjs.map +1 -1
- package/dist/hooks/useFocusVisible.cjs +2 -0
- package/dist/hooks/useFocusVisible.cjs.map +1 -0
- package/dist/hooks/useFocusVisible.mjs +49 -0
- package/dist/hooks/useFocusVisible.mjs.map +1 -0
- package/dist/hooks/useFocusableGroup.cjs +2 -0
- package/dist/hooks/useFocusableGroup.cjs.map +1 -0
- package/dist/hooks/useFocusableGroup.mjs +70 -0
- package/dist/hooks/useFocusableGroup.mjs.map +1 -0
- package/dist/hooks/useModalLayer.cjs +1 -1
- package/dist/hooks/useModalLayer.cjs.map +1 -1
- package/dist/hooks/useModalLayer.mjs +4 -4
- package/dist/hooks/useModalOpen.cjs +2 -0
- package/dist/hooks/useModalOpen.cjs.map +1 -0
- package/dist/hooks/useModalOpen.mjs +14 -0
- package/dist/hooks/useModalOpen.mjs.map +1 -0
- package/dist/hooks/usePopupPosition.cjs +1 -1
- package/dist/hooks/usePopupPosition.cjs.map +1 -1
- package/dist/hooks/usePopupPosition.mjs +82 -53
- package/dist/hooks/usePopupPosition.mjs.map +1 -1
- package/dist/hooks/useResolvedTarget.cjs +2 -0
- package/dist/hooks/useResolvedTarget.cjs.map +1 -0
- package/dist/hooks/useResolvedTarget.mjs +37 -0
- package/dist/hooks/useResolvedTarget.mjs.map +1 -0
- package/dist/hooks/useRovingGrid.cjs +1 -1
- package/dist/hooks/useRovingGrid.cjs.map +1 -1
- package/dist/hooks/useRovingGrid.mjs +8 -57
- package/dist/hooks/useRovingGrid.mjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +142 -107
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1364 -66
- package/dist/index.d.ts +1364 -66
- package/dist/index.mjs +132 -115
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +112 -92
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/initials.cjs +2 -0
- package/dist/lib/initials.cjs.map +1 -0
- package/dist/lib/initials.mjs +21 -0
- package/dist/lib/initials.mjs.map +1 -0
- package/dist/lib/layers.cjs +1 -1
- package/dist/lib/layers.cjs.map +1 -1
- package/dist/lib/layers.mjs +112 -109
- package/dist/lib/layers.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +102 -0
|
@@ -7,7 +7,37 @@ import { getFirstTabbable as o, isHiddenInput as s } from "../lib/focus.mjs";
|
|
|
7
7
|
import { isAltGraphCharacter as c, useTypeahead as l } from "./useTypeahead.mjs";
|
|
8
8
|
import * as u from "react";
|
|
9
9
|
//#region src/hooks/useRovingTabIndex.ts
|
|
10
|
-
|
|
10
|
+
function d(e, t, n) {
|
|
11
|
+
let r = t.querySelectorAll("[role=\"row\"]");
|
|
12
|
+
if (r.length > 0) return Array.from(r).map((t) => e.filter((e) => t.contains(e.element)));
|
|
13
|
+
if (n !== void 0 && n > 0) {
|
|
14
|
+
let t = [];
|
|
15
|
+
for (let r = 0; r < e.length; r += n) t.push(e.slice(r, r + n));
|
|
16
|
+
return t;
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
function f(e, t, n) {
|
|
21
|
+
let r = e.key === "ArrowUp" || e.key === "ArrowDown", i = e.key === "Home" || e.key === "End";
|
|
22
|
+
if (!n || !r && !i) return;
|
|
23
|
+
let a = t.findIndex((e) => e.includes(n));
|
|
24
|
+
if (a < 0) return;
|
|
25
|
+
if (i) {
|
|
26
|
+
let r = (e.ctrlKey ? t.flat() : t[a]).filter((e) => !e.disabled), i = e.key === "Home" ? r[0] : r[r.length - 1];
|
|
27
|
+
return i && i !== n ? [i] : "stay";
|
|
28
|
+
}
|
|
29
|
+
let o = t[a].indexOf(n), s = e.key === "ArrowDown" ? 1 : -1;
|
|
30
|
+
for (let e = a + s; e >= 0 && e < t.length; e += s) {
|
|
31
|
+
let n, r = Infinity;
|
|
32
|
+
if (t[e].forEach((e, t) => {
|
|
33
|
+
if (e.disabled) return;
|
|
34
|
+
let i = Math.abs(t - o);
|
|
35
|
+
i < r && (n = e, r = i);
|
|
36
|
+
}), n) return [n];
|
|
37
|
+
}
|
|
38
|
+
return "stay";
|
|
39
|
+
}
|
|
40
|
+
var p = "[data-roving-value]", m = /* @__PURE__ */ new Set([
|
|
11
41
|
"radiogroup",
|
|
12
42
|
"listbox",
|
|
13
43
|
"grid",
|
|
@@ -17,12 +47,12 @@ var d = "[data-roving-value]", f = /* @__PURE__ */ new Set([
|
|
|
17
47
|
"menubar",
|
|
18
48
|
"tree",
|
|
19
49
|
"spinbutton"
|
|
20
|
-
]),
|
|
50
|
+
]), h = /* @__PURE__ */ new Set([
|
|
21
51
|
"slider",
|
|
22
52
|
"spinbutton",
|
|
23
53
|
"textbox",
|
|
24
54
|
"searchbox"
|
|
25
|
-
]),
|
|
55
|
+
]), g = /* @__PURE__ */ new Set([
|
|
26
56
|
"button",
|
|
27
57
|
"checkbox",
|
|
28
58
|
"color",
|
|
@@ -32,7 +62,7 @@ var d = "[data-roving-value]", f = /* @__PURE__ */ new Set([
|
|
|
32
62
|
"radio",
|
|
33
63
|
"reset",
|
|
34
64
|
"submit"
|
|
35
|
-
]),
|
|
65
|
+
]), _ = [
|
|
36
66
|
"disabled",
|
|
37
67
|
"aria-disabled",
|
|
38
68
|
"data-disabled-focusable",
|
|
@@ -47,47 +77,47 @@ var d = "[data-roving-value]", f = /* @__PURE__ */ new Set([
|
|
|
47
77
|
"type",
|
|
48
78
|
"contenteditable"
|
|
49
79
|
];
|
|
50
|
-
function
|
|
80
|
+
function v(e, t) {
|
|
51
81
|
if (e.hasAttribute("data-roving-container")) return !0;
|
|
52
82
|
if (!t || e.hasAttribute("data-roving-transparent")) return !1;
|
|
53
83
|
let n = e.getAttribute("role");
|
|
54
|
-
return n !== null &&
|
|
84
|
+
return n !== null && m.has(n);
|
|
55
85
|
}
|
|
56
|
-
function
|
|
57
|
-
for (let r = e; r && r !== t; r = r.parentElement) if (
|
|
86
|
+
function y(e, t, n) {
|
|
87
|
+
for (let r = e; r && r !== t; r = r.parentElement) if (v(r, n)) return !0;
|
|
58
88
|
return !1;
|
|
59
89
|
}
|
|
60
|
-
var
|
|
61
|
-
function
|
|
90
|
+
var b = "[tabindex], [data-roving-value]";
|
|
91
|
+
function x(e, t) {
|
|
62
92
|
try {
|
|
63
93
|
return e.matches(t);
|
|
64
94
|
} catch {
|
|
65
95
|
return !1;
|
|
66
96
|
}
|
|
67
97
|
}
|
|
68
|
-
function
|
|
98
|
+
function S(e) {
|
|
69
99
|
let t = /* @__PURE__ */ new Map();
|
|
70
100
|
for (let n of e) n.type === "attributes" && n.attributeName === "tabindex" && t.set(n.target, n);
|
|
71
101
|
let n = /* @__PURE__ */ new Set();
|
|
72
102
|
for (let [e, r] of t) r.oldValue === e.getAttribute("tabindex") && n.add(e);
|
|
73
103
|
return n;
|
|
74
104
|
}
|
|
75
|
-
function
|
|
105
|
+
function C(e) {
|
|
76
106
|
return e.tabIndex >= 0 && !e.hasAttribute("disabled");
|
|
77
107
|
}
|
|
78
|
-
function
|
|
108
|
+
function w(e) {
|
|
79
109
|
let { element: t } = e;
|
|
80
|
-
if (!e.nested ||
|
|
110
|
+
if (!e.nested || C(t)) return t;
|
|
81
111
|
let n = t.querySelector("[tabindex=\"0\"]");
|
|
82
112
|
if (n) return n;
|
|
83
113
|
let r = o(t);
|
|
84
114
|
return r instanceof HTMLElement ? r : null;
|
|
85
115
|
}
|
|
86
|
-
function
|
|
116
|
+
function T(e) {
|
|
87
117
|
let t = e.getAttribute("data-roving-disabled");
|
|
88
|
-
return t !== null && t !== "false" ||
|
|
118
|
+
return t !== null && t !== "false" || E(e) ? !0 : !e.hasAttribute("data-disabled-focusable") && e.getAttribute("aria-disabled") === "true";
|
|
89
119
|
}
|
|
90
|
-
function
|
|
120
|
+
function E(e) {
|
|
91
121
|
if (e.disabled === !0) return !0;
|
|
92
122
|
try {
|
|
93
123
|
return e.matches(":disabled");
|
|
@@ -95,20 +125,20 @@ function w(e) {
|
|
|
95
125
|
return !1;
|
|
96
126
|
}
|
|
97
127
|
}
|
|
98
|
-
function
|
|
128
|
+
function D(e) {
|
|
99
129
|
if (!e || e.nodeType !== 1) return !1;
|
|
100
130
|
let t = e, n = t.getAttribute("role");
|
|
101
|
-
if (n !== null &&
|
|
131
|
+
if (n !== null && h.has(n)) return !0;
|
|
102
132
|
let r = t.localName;
|
|
103
133
|
if (r === "textarea" || r === "select") return !0;
|
|
104
|
-
if (r === "input") return !
|
|
134
|
+
if (r === "input") return !g.has(t.type);
|
|
105
135
|
let i = t.closest("[contenteditable]");
|
|
106
136
|
return i !== null && i.getAttribute("contenteditable") !== "false";
|
|
107
137
|
}
|
|
108
|
-
function
|
|
109
|
-
return !e.nested && !
|
|
138
|
+
function O(e) {
|
|
139
|
+
return !e.nested && !D(e.element);
|
|
110
140
|
}
|
|
111
|
-
function
|
|
141
|
+
function k(e, t, n) {
|
|
112
142
|
let r = e.ownerDocument.defaultView;
|
|
113
143
|
if (!r) return !1;
|
|
114
144
|
for (let i = e; i && i !== t; i = i.parentElement) {
|
|
@@ -133,14 +163,14 @@ function te(e) {
|
|
|
133
163
|
return !1;
|
|
134
164
|
}
|
|
135
165
|
}
|
|
136
|
-
function
|
|
137
|
-
return [e.value, e.disabled ? 0 :
|
|
166
|
+
function A(e) {
|
|
167
|
+
return [e.value, e.disabled ? 0 : O(e) ? 1 : 2];
|
|
138
168
|
}
|
|
139
|
-
function
|
|
169
|
+
function j(e, t, n, r) {
|
|
140
170
|
let i = e.some(([, e]) => e === 1) ? 1 : 2, a = e.filter(([, e]) => e === i).map(([e]) => e);
|
|
141
171
|
return n === "last-focused" && r !== null && a.includes(r) ? r : t !== null && t !== "" && a.includes(t) ? t : a[0] ?? null;
|
|
142
172
|
}
|
|
143
|
-
function
|
|
173
|
+
function M(e, t) {
|
|
144
174
|
if (!t) return e;
|
|
145
175
|
let n = new Map(e.map((e) => [e.value, e])), r = [];
|
|
146
176
|
for (let e of t) {
|
|
@@ -149,11 +179,11 @@ function A(e, t) {
|
|
|
149
179
|
}
|
|
150
180
|
return r;
|
|
151
181
|
}
|
|
152
|
-
var
|
|
182
|
+
var N = class {
|
|
153
183
|
container = null;
|
|
154
184
|
lastFocused = null;
|
|
155
185
|
options = {
|
|
156
|
-
itemSelector:
|
|
186
|
+
itemSelector: p,
|
|
157
187
|
manageTabIndex: !1,
|
|
158
188
|
items: void 0,
|
|
159
189
|
activeValue: null,
|
|
@@ -170,7 +200,7 @@ var j = class {
|
|
|
170
200
|
subscribe = (e) => (this.notify = e, this.observe(), () => {
|
|
171
201
|
this.notify = null, this.disconnect();
|
|
172
202
|
});
|
|
173
|
-
getSnapshot = () => this.container ? (this.dirty && (this.dirty = !1, this.snapshot = JSON.stringify(this.resolveOwn().map(
|
|
203
|
+
getSnapshot = () => this.container ? (this.dirty && (this.dirty = !1, this.snapshot = JSON.stringify(this.resolveOwn().map(A))), this.snapshot) : "";
|
|
174
204
|
getServerSnapshot = () => "";
|
|
175
205
|
setContainer(e) {
|
|
176
206
|
if (e === this.container) return;
|
|
@@ -178,14 +208,14 @@ var j = class {
|
|
|
178
208
|
this.disconnect(), this.container && this.options.manageTabIndex && this.release(this.container, "all", t), this.container = e, this.dirty = !0, this.notify && (this.observe(), this.notify());
|
|
179
209
|
}
|
|
180
210
|
recordFocus(e) {
|
|
181
|
-
|
|
211
|
+
O(e) && (this.lastFocused = e.value);
|
|
182
212
|
}
|
|
183
213
|
setOptions(e) {
|
|
184
214
|
let t = this.options;
|
|
185
215
|
this.options = e, t.manageTabIndex && !e.manageTabIndex && this.container && this.release(this.container, "all", this.takeRecords()), (t.itemSelector !== e.itemSelector || t.manageTabIndex !== e.manageTabIndex || t.roleComposites !== e.roleComposites) && (this.dirty = !0, this.notify?.());
|
|
186
216
|
}
|
|
187
217
|
resolve(e = this.container) {
|
|
188
|
-
return
|
|
218
|
+
return M(this.resolveOwn(e), this.options.items);
|
|
189
219
|
}
|
|
190
220
|
resolveOwn(e = this.container) {
|
|
191
221
|
if (!e) return [];
|
|
@@ -198,7 +228,7 @@ var j = class {
|
|
|
198
228
|
let a = [], o = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
|
|
199
229
|
for (let t of i) {
|
|
200
230
|
let i = null, l = !1;
|
|
201
|
-
for (let n = t; n && n !== e; n = n.parentElement)
|
|
231
|
+
for (let n = t; n && n !== e; n = n.parentElement) v(n, r) && (i = n), (n.hidden || n.hasAttribute("inert")) && (l = !0);
|
|
202
232
|
if (l) continue;
|
|
203
233
|
let u = i ?? t;
|
|
204
234
|
if (o.has(u)) continue;
|
|
@@ -209,16 +239,16 @@ var j = class {
|
|
|
209
239
|
value: this.valueOf(u, d),
|
|
210
240
|
element: u,
|
|
211
241
|
nested: d,
|
|
212
|
-
disabled:
|
|
242
|
+
disabled: T(u)
|
|
213
243
|
};
|
|
214
|
-
d && !f.disabled && !
|
|
244
|
+
d && !f.disabled && !w(f) && (f.disabled = !0), n && !f.disabled && k(u, e, c) && (f.disabled = !0), a.push(f);
|
|
215
245
|
}
|
|
216
246
|
return a;
|
|
217
247
|
}
|
|
218
248
|
stamp() {
|
|
219
249
|
if (!this.options.manageTabIndex || !this.container) return;
|
|
220
250
|
this.release(this.container, "stale");
|
|
221
|
-
let e = this.resolve(), t = this.options.tabStop === "none" ? null :
|
|
251
|
+
let e = this.resolve(), t = this.options.tabStop === "none" ? null : j(e.map(A), this.options.activeValue, this.options.tabStop, this.lastFocused);
|
|
222
252
|
for (let n of e) {
|
|
223
253
|
if (n.nested) continue;
|
|
224
254
|
let { element: e } = n, r = n.value === t ? "0" : "-1", i = e.getAttribute("tabindex"), a = this.stamped.get(e);
|
|
@@ -230,17 +260,17 @@ var j = class {
|
|
|
230
260
|
}
|
|
231
261
|
}
|
|
232
262
|
release(e, t, n = []) {
|
|
233
|
-
let r =
|
|
234
|
-
for (let n of Array.from(e.querySelectorAll(
|
|
263
|
+
let r = S(n), { itemSelector: i, roleComposites: a } = this.options;
|
|
264
|
+
for (let n of Array.from(e.querySelectorAll(b))) {
|
|
235
265
|
let o = this.stamped.get(n);
|
|
236
|
-
if (!o || t === "stale" &&
|
|
266
|
+
if (!o || t === "stale" && x(n, i) && !y(n, e, a)) continue;
|
|
237
267
|
this.stamped.delete(n);
|
|
238
268
|
let s = n.getAttribute("tabindex");
|
|
239
269
|
!(s !== o.stamped || r.has(n)) && s !== o.tabIndex && (o.tabIndex === null ? n.removeAttribute("tabindex") : n.setAttribute("tabindex", o.tabIndex)), o.addedValue !== null && n.getAttribute("data-roving-value") === o.addedValue && n.removeAttribute("data-roving-value");
|
|
240
270
|
}
|
|
241
271
|
}
|
|
242
272
|
adopt(e) {
|
|
243
|
-
for (let t of
|
|
273
|
+
for (let t of S(e)) {
|
|
244
274
|
let e = this.stamped.get(t);
|
|
245
275
|
e && (e.tabIndex = t.getAttribute("tabindex"));
|
|
246
276
|
}
|
|
@@ -262,14 +292,14 @@ var j = class {
|
|
|
262
292
|
childList: !0,
|
|
263
293
|
attributes: !0,
|
|
264
294
|
attributeOldValue: !0,
|
|
265
|
-
attributeFilter:
|
|
295
|
+
attributeFilter: _
|
|
266
296
|
}), this.dirty = !0);
|
|
267
297
|
}
|
|
268
298
|
disconnect() {
|
|
269
299
|
this.observer?.disconnect(), this.observer = null;
|
|
270
300
|
}
|
|
271
301
|
};
|
|
272
|
-
function
|
|
302
|
+
function P(e) {
|
|
273
303
|
if (e === "") return null;
|
|
274
304
|
try {
|
|
275
305
|
return JSON.parse(e);
|
|
@@ -277,13 +307,13 @@ function M(e) {
|
|
|
277
307
|
return null;
|
|
278
308
|
}
|
|
279
309
|
}
|
|
280
|
-
function
|
|
310
|
+
function F(e) {
|
|
281
311
|
return e.getAttribute("data-roving-text") ?? e.textContent ?? "";
|
|
282
312
|
}
|
|
283
|
-
function
|
|
313
|
+
function I(e, t) {
|
|
284
314
|
return !t || typeof t.nodeType != "number" ? !1 : t === e || e.contains(t);
|
|
285
315
|
}
|
|
286
|
-
function
|
|
316
|
+
function L(e, t, n) {
|
|
287
317
|
if (e.length === 0 || !t || typeof t.nodeType != "number") return null;
|
|
288
318
|
let r = new Map(e.map((e) => [e.element, e]));
|
|
289
319
|
for (let e = t; e && e !== n; e = e.parentNode) {
|
|
@@ -292,97 +322,102 @@ function F(e, t, n) {
|
|
|
292
322
|
}
|
|
293
323
|
return null;
|
|
294
324
|
}
|
|
295
|
-
function
|
|
296
|
-
return e ? t ===
|
|
325
|
+
function R(e, t, n) {
|
|
326
|
+
return e ? t === w(e) : t === n;
|
|
297
327
|
}
|
|
298
|
-
function
|
|
299
|
-
let
|
|
328
|
+
function z(o, s) {
|
|
329
|
+
let m = s === void 0 ? void 0 : o, { activeValue: h = null, items: g, orientation: _ = "horizontal", columns: v, loop: y = !0, dir: b, itemSelector: x = p, typeahead: S = !1, homeEndKeys: C = !0, tabStop: T = "active", manageTabIndex: E = !1, onFocusMove: k } = s ?? o, [A] = u.useState(() => new N()), M = u.useSyncExternalStore(A.subscribe, A.getSnapshot, A.getServerSnapshot), [z, B] = u.useState(null), [V, ne] = u.useState(null), re = m === void 0 && g === void 0;
|
|
300
330
|
u.useLayoutEffect(() => {
|
|
301
|
-
|
|
302
|
-
itemSelector:
|
|
303
|
-
manageTabIndex:
|
|
304
|
-
items:
|
|
305
|
-
activeValue:
|
|
306
|
-
tabStop:
|
|
307
|
-
roleComposites:
|
|
308
|
-
}),
|
|
331
|
+
A.setOptions({
|
|
332
|
+
itemSelector: x,
|
|
333
|
+
manageTabIndex: E,
|
|
334
|
+
items: g,
|
|
335
|
+
activeValue: h,
|
|
336
|
+
tabStop: T,
|
|
337
|
+
roleComposites: re
|
|
338
|
+
}), m && A.setContainer(m.current), A.stamp();
|
|
309
339
|
}), u.useEffect(() => {
|
|
310
|
-
e && !te(
|
|
311
|
-
}, [
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
340
|
+
e && !te(x) && t(`useRovingTabIndex:itemSelector:${x}`, `useRovingTabIndex: itemSelector "${x}" is not a valid CSS selector in this browser; no item is navigable or tabbable.`);
|
|
341
|
+
}, [x]), u.useEffect(() => {
|
|
342
|
+
if (!e || _ !== "grid" || v) return;
|
|
343
|
+
let n = A.container;
|
|
344
|
+
n && n.querySelector("[role=\"row\"]") === null && t("useRovingTabIndex:grid-rows", "useRovingTabIndex: orientation \"grid\" needs role=\"row\" elements around the items or a `columns` count; without either it acts as \"both\".");
|
|
345
|
+
});
|
|
346
|
+
let H = u.useMemo(() => P(M), [M]), U = u.useMemo(() => {
|
|
347
|
+
if (!g) return H;
|
|
348
|
+
if (H) {
|
|
349
|
+
let e = new Map(H), t = g.flatMap((t) => {
|
|
316
350
|
let n = e.get(t);
|
|
317
351
|
return n === void 0 ? [] : [[t, n]];
|
|
318
352
|
});
|
|
319
353
|
if (t.length > 0) return t;
|
|
320
354
|
}
|
|
321
|
-
return
|
|
322
|
-
}, [
|
|
323
|
-
|
|
324
|
-
}, [
|
|
355
|
+
return g.map((e) => [e, 1]);
|
|
356
|
+
}, [g, H]), W = T === "none" ? null : U ? j(U, h, T, V) : h || null, ie = u.useCallback((e) => e === W ? 0 : -1, [W]), G = u.useCallback((e) => {
|
|
357
|
+
A.setContainer(e), m && n(m, e);
|
|
358
|
+
}, [A, m]), K = u.useRef([]), q = u.useRef([]), { onTypeahead: ae, isSearching: oe } = l({
|
|
325
359
|
getItems: () => K.current,
|
|
326
360
|
onMatch: (e, t) => {
|
|
327
361
|
q.current = t;
|
|
328
362
|
}
|
|
329
363
|
}), J = (e) => {
|
|
330
364
|
if (!e || e.disabled) return !1;
|
|
331
|
-
let t =
|
|
332
|
-
return !t || (t.focus(), !ee(t)) ? !1 : (
|
|
365
|
+
let t = w(e);
|
|
366
|
+
return !t || (t.focus(), !ee(t)) ? !1 : (A.recordFocus(e), !0);
|
|
333
367
|
}, Y = (e) => {
|
|
334
368
|
for (let t of e) if (J(t)) return;
|
|
335
369
|
}, X = r((e, t) => {
|
|
336
|
-
let n = e.metaKey || (e.altKey || e.ctrlKey) && !c(e);
|
|
337
|
-
if (e.defaultPrevented ||
|
|
338
|
-
let
|
|
339
|
-
if (!
|
|
340
|
-
let
|
|
341
|
-
if (
|
|
342
|
-
let
|
|
343
|
-
orientation: h,
|
|
344
|
-
dir:
|
|
370
|
+
let n = _ === "grid" && e.ctrlKey && !e.altKey && (e.key === "Home" || e.key === "End"), r = e.metaKey || (e.altKey || e.ctrlKey) && !c(e) && !n;
|
|
371
|
+
if (e.defaultPrevented || r || D(e.target)) return;
|
|
372
|
+
let o = A.container ?? e.currentTarget;
|
|
373
|
+
if (!I(o, e.target)) return;
|
|
374
|
+
let s = A.resolve(o), l = s.filter((e) => !e.disabled);
|
|
375
|
+
if (l.length === 0) return;
|
|
376
|
+
let u = L(s, e.target, o), p = !1, m = [], h = _ === "grid" && !t ? d(s, o, v) : null, g = h ? f(e, h, u) : void 0, x = t || g ? null : i(e.key, {
|
|
377
|
+
orientation: _ === "grid" ? h ? "horizontal" : "both" : _,
|
|
378
|
+
dir: b ?? a(e.currentTarget)
|
|
345
379
|
});
|
|
346
|
-
if (
|
|
347
|
-
|
|
380
|
+
if (g) p = !0, m = g === "stay" ? [] : g;
|
|
381
|
+
else if (x) {
|
|
382
|
+
if (p = !0, !u) m = x === "next" ? l : [...l].reverse();
|
|
348
383
|
else {
|
|
349
|
-
let e =
|
|
384
|
+
let e = x === "next" ? 1 : -1, t = s.length, n = s.indexOf(u);
|
|
350
385
|
for (let r = 1; r < t; r++) {
|
|
351
386
|
if (n += e, n < 0 || n >= t) {
|
|
352
|
-
if (!
|
|
387
|
+
if (!y) break;
|
|
353
388
|
n = (n + t) % t;
|
|
354
389
|
}
|
|
355
|
-
|
|
390
|
+
s[n].disabled || m.push(s[n]);
|
|
356
391
|
}
|
|
357
392
|
}
|
|
358
|
-
} else !t &&
|
|
393
|
+
} else !t && C && (e.key === "Home" || e.key === "End") ? (p = !0, m = e.key === "Home" ? l : [...l].reverse()) : S && R(u, e.target, o) && (K.current = s.map((e) => ({
|
|
359
394
|
value: e.value,
|
|
360
|
-
text:
|
|
395
|
+
text: F(e.element),
|
|
361
396
|
disabled: e.disabled
|
|
362
|
-
})), q.current = [],
|
|
363
|
-
if (
|
|
397
|
+
})), q.current = [], ae(e, u?.value ?? null) && (p = !0, m = q.current.flatMap((e) => l.filter((t) => t.value === e))));
|
|
398
|
+
if (p) {
|
|
364
399
|
e.preventDefault();
|
|
365
|
-
for (let t of
|
|
366
|
-
if (t ===
|
|
400
|
+
for (let t of m) {
|
|
401
|
+
if (t === u) return;
|
|
367
402
|
if (J(t)) {
|
|
368
|
-
|
|
403
|
+
k?.(t.value, e);
|
|
369
404
|
return;
|
|
370
405
|
}
|
|
371
406
|
}
|
|
372
407
|
}
|
|
373
408
|
}), Z = r((e) => X(e, !1)), Q = r((e) => {
|
|
374
|
-
|
|
409
|
+
S && e.key === " " && oe() && X(e, !0);
|
|
375
410
|
}), $ = r((e) => {
|
|
376
|
-
let t =
|
|
377
|
-
if (!
|
|
378
|
-
let n =
|
|
379
|
-
n && (
|
|
380
|
-
}),
|
|
381
|
-
J(
|
|
382
|
-
}),
|
|
383
|
-
Y(
|
|
384
|
-
}),
|
|
385
|
-
Y(
|
|
411
|
+
let t = A.container ?? e.currentTarget;
|
|
412
|
+
if (!I(t, e.target)) return;
|
|
413
|
+
let n = L(A.resolve(t), e.target, t);
|
|
414
|
+
n && (A.recordFocus(n), B(n.value), O(n) && ne(n.value), A.stamp());
|
|
415
|
+
}), se = r((e) => {
|
|
416
|
+
J(A.resolve().find((t) => t.value === e));
|
|
417
|
+
}), ce = r(() => {
|
|
418
|
+
Y(A.resolve().filter((e) => !e.disabled));
|
|
419
|
+
}), le = r(() => {
|
|
420
|
+
Y(A.resolve().filter((e) => !e.disabled).reverse());
|
|
386
421
|
});
|
|
387
422
|
return {
|
|
388
423
|
containerProps: u.useMemo(() => ({
|
|
@@ -400,14 +435,14 @@ function L(o, s) {
|
|
|
400
435
|
handleKeyDown: Z,
|
|
401
436
|
handleKeyDownCapture: Q,
|
|
402
437
|
handleFocus: $,
|
|
403
|
-
getTabIndex:
|
|
404
|
-
focusedValue:
|
|
405
|
-
focusValue:
|
|
406
|
-
focusFirst:
|
|
407
|
-
focusLast:
|
|
438
|
+
getTabIndex: ie,
|
|
439
|
+
focusedValue: z,
|
|
440
|
+
focusValue: se,
|
|
441
|
+
focusFirst: ce,
|
|
442
|
+
focusLast: le
|
|
408
443
|
};
|
|
409
444
|
}
|
|
410
445
|
//#endregion
|
|
411
|
-
export {
|
|
446
|
+
export { k as isHiddenByCss, z as useRovingTabIndex };
|
|
412
447
|
|
|
413
448
|
//# sourceMappingURL=useRovingTabIndex.mjs.map
|