@mortenbrudvik/waveui 0.12.0 → 0.14.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 +362 -60
- 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/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/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +245 -195
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/List.registry.cjs.map +1 -1
- package/dist/components/data-display/List.registry.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/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/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +240 -192
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Overflow.store.cjs +2 -0
- package/dist/components/layout/Overflow.store.cjs.map +1 -0
- package/dist/components/layout/Overflow.store.mjs +209 -0
- package/dist/components/layout/Overflow.store.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/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +239 -84
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.cjs +1 -1
- package/dist/components/overlays/Dialog.slots.cjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.mjs +19 -15
- package/dist/components/overlays/Dialog.slots.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.context.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.context.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.context.mjs +51 -0
- package/dist/components/overlays/TeachingPopover.context.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.mjs +15 -185
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.parts.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.parts.mjs +398 -0
- package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.root.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.root.mjs +150 -0
- package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.stack.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.stack.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.stack.mjs +86 -0
- package/dist/components/overlays/TeachingPopover.stack.mjs.map +1 -0
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +540 -311
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +183 -60
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/table/Table.shared.cjs +2 -0
- package/dist/components/table/Table.shared.cjs.map +1 -0
- package/dist/components/table/Table.shared.mjs +65 -0
- package/dist/components/table/Table.shared.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2299 -213
- package/dist/index.d.ts +2299 -213
- package/dist/index.mjs +135 -127
- package/dist/lib/breadcrumb.cjs +2 -0
- package/dist/lib/breadcrumb.cjs.map +1 -0
- package/dist/lib/breadcrumb.mjs +26 -0
- package/dist/lib/breadcrumb.mjs.map +1 -0
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +143 -95
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/events.cjs +1 -1
- package/dist/lib/events.cjs.map +1 -1
- package/dist/lib/events.mjs +35 -8
- package/dist/lib/events.mjs.map +1 -1
- package/dist/lib/icons.cjs +1 -1
- package/dist/lib/icons.cjs.map +1 -1
- package/dist/lib/icons.mjs +34 -20
- package/dist/lib/icons.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/table.cjs +2 -0
- package/dist/lib/table.cjs.map +1 -0
- package/dist/lib/table.mjs +16 -0
- package/dist/lib/table.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +102 -0
|
@@ -2,75 +2,75 @@
|
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
3
|
import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
|
|
4
4
|
import { reportMissingContext as r, warnDeprecated as i, warnOnce as a } from "../../lib/dev.mjs";
|
|
5
|
-
import { materialiseSlotContent as o,
|
|
6
|
-
import { composeEventHandlers as
|
|
7
|
-
import { listClassNames as
|
|
5
|
+
import { materialiseSlotContent as o, renderSlot as s, slotRendersContent as c } from "../../lib/slot.mjs";
|
|
6
|
+
import { composeEventHandlers as l } from "../../lib/composeEventHandlers.mjs";
|
|
7
|
+
import { listClassNames as ee, listItemClassNames as u } from "../../lib/classNames.mjs";
|
|
8
8
|
import { useEventCallback as d } from "../../hooks/useEventCallback.mjs";
|
|
9
|
-
import { useControllable as
|
|
10
|
-
import { useId as
|
|
11
|
-
import { getArrowIntent as
|
|
12
|
-
import { FOCUSABLE_SELECTOR as
|
|
13
|
-
import { useRovingTabIndex as
|
|
14
|
-
import { useMergedRefs as
|
|
15
|
-
import {
|
|
9
|
+
import { useControllable as te } from "../../hooks/useControllable.mjs";
|
|
10
|
+
import { useId as ne } from "../../hooks/useId.mjs";
|
|
11
|
+
import { getArrowIntent as f, getDirection as p } from "../../lib/direction.mjs";
|
|
12
|
+
import { FOCUSABLE_SELECTOR as m, isFocusable as h } from "../../lib/focus.mjs";
|
|
13
|
+
import { useRovingTabIndex as re } from "../../hooks/useRovingTabIndex.mjs";
|
|
14
|
+
import { useMergedRefs as ie } from "../../hooks/useMergedRefs.mjs";
|
|
15
|
+
import { focusableDisabledProps as ae } from "../../lib/aria.mjs";
|
|
16
|
+
import { focusRingInset as g, forcedColors as _ } from "../../lib/styles.mjs";
|
|
17
|
+
import { CheckIcon as v } from "../../lib/icons.mjs";
|
|
18
|
+
import { INTERACTIVE_SELECTOR as y, isForeignEvent as b } from "../../lib/events.mjs";
|
|
16
19
|
import { ListRegistry as x } from "./List.registry.mjs";
|
|
17
20
|
import * as S from "react";
|
|
18
|
-
import { jsx as C, jsxs as
|
|
21
|
+
import { jsx as C, jsxs as oe } from "react/jsx-runtime";
|
|
19
22
|
//#region src/components/data-display/List.tsx
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
function
|
|
24
|
-
return
|
|
23
|
+
var w = S.createContext(null);
|
|
24
|
+
w.displayName = "ListContext";
|
|
25
|
+
var T = null;
|
|
26
|
+
function E() {
|
|
27
|
+
return T ??= {
|
|
25
28
|
mode: "list",
|
|
29
|
+
navigable: !1,
|
|
30
|
+
selection: !1,
|
|
31
|
+
checkmark: !1,
|
|
26
32
|
selectedValues: /* @__PURE__ */ new Set(),
|
|
27
33
|
toggleItem: () => {},
|
|
28
34
|
getTabIndex: () => -1,
|
|
29
35
|
registry: new x()
|
|
30
|
-
},
|
|
36
|
+
}, T;
|
|
31
37
|
}
|
|
32
|
-
function
|
|
33
|
-
return S.useContext(
|
|
38
|
+
function D(e) {
|
|
39
|
+
return S.useContext(w) || (r(e, "a List"), E());
|
|
34
40
|
}
|
|
35
|
-
var
|
|
36
|
-
function
|
|
41
|
+
var O = [];
|
|
42
|
+
function k(e, t, n) {
|
|
43
|
+
return n === "composite" || e && t ? {
|
|
44
|
+
mode: "grid",
|
|
45
|
+
navigation: "composite"
|
|
46
|
+
} : e ? {
|
|
47
|
+
mode: "listbox",
|
|
48
|
+
navigation: "items"
|
|
49
|
+
} : {
|
|
50
|
+
mode: "list",
|
|
51
|
+
navigation: n === "items" ? "items" : "none"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function se(e) {
|
|
37
55
|
a(`List:duplicate:${e}`, `List: several items share the value "${e}". Item values must be unique within a List; items with the same value are selected (and tab stops) together.`);
|
|
38
56
|
}
|
|
39
|
-
function
|
|
40
|
-
return t(e).some(({ node: e }) => n(e,
|
|
57
|
+
function A(e) {
|
|
58
|
+
return t(e).some(({ node: e }) => n(e, G) && c(e.props.action));
|
|
41
59
|
}
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"label",
|
|
46
|
-
"[role=\"button\"]",
|
|
47
|
-
"[role=\"link\"]",
|
|
48
|
-
"[role=\"checkbox\"]",
|
|
49
|
-
"[role=\"switch\"]",
|
|
50
|
-
"[role=\"radio\"]",
|
|
51
|
-
"[role=\"menuitem\"]",
|
|
52
|
-
"[role=\"textbox\"]",
|
|
53
|
-
"[role=\"combobox\"]",
|
|
54
|
-
"[role=\"slider\"]",
|
|
55
|
-
"[role=\"spinbutton\"]"
|
|
56
|
-
].join(", ");
|
|
57
|
-
function N(e) {
|
|
58
|
-
let t = e.currentTarget, n = e.target;
|
|
59
|
-
if (!n || typeof n.nodeType != "number" || !t.contains(n)) return !0;
|
|
60
|
-
let r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement ?? null;
|
|
61
|
-
for (; r && r !== t; r = r.parentElement) if (r.matches(M)) return !0;
|
|
62
|
-
return !1;
|
|
60
|
+
var j = { interactive: `${y}, [data-list-action]` };
|
|
61
|
+
function M(e) {
|
|
62
|
+
return b(e, j);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function N(e) {
|
|
65
65
|
return e.ctrlKey || e.altKey || e.metaKey ? !1 : e.key === "Enter" || e.key === " ";
|
|
66
66
|
}
|
|
67
|
-
var
|
|
67
|
+
var P = /* @__PURE__ */ new Set([
|
|
68
68
|
"textbox",
|
|
69
69
|
"searchbox",
|
|
70
70
|
"combobox",
|
|
71
71
|
"spinbutton",
|
|
72
72
|
"slider"
|
|
73
|
-
]),
|
|
73
|
+
]), F = /* @__PURE__ */ new Set([
|
|
74
74
|
"button",
|
|
75
75
|
"checkbox",
|
|
76
76
|
"color",
|
|
@@ -81,22 +81,22 @@ var F = /* @__PURE__ */ new Set([
|
|
|
81
81
|
"reset",
|
|
82
82
|
"submit"
|
|
83
83
|
]);
|
|
84
|
-
function
|
|
84
|
+
function I(e) {
|
|
85
85
|
let t = e.getAttribute("role");
|
|
86
|
-
if (t !== null &&
|
|
86
|
+
if (t !== null && P.has(t)) return !0;
|
|
87
87
|
let n = e.localName;
|
|
88
|
-
return n === "textarea" || n === "select" ? !0 : n === "input" ? !
|
|
88
|
+
return n === "textarea" || n === "select" ? !0 : n === "input" ? !F.has(e.type) : e.matches("[contenteditable]:not([contenteditable=\"false\"])");
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
return Array.from(e.querySelectorAll(
|
|
90
|
+
function L(e) {
|
|
91
|
+
return Array.from(e.querySelectorAll(m)).filter((e) => h(e));
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function R(e) {
|
|
94
94
|
if (!e.parentElement) return -1;
|
|
95
95
|
let t = 0;
|
|
96
96
|
for (let n = e.previousElementSibling; n; n = n.previousElementSibling) t++;
|
|
97
97
|
return t;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function z(e, t) {
|
|
100
100
|
let n = null, r = null, i = null, a = 0;
|
|
101
101
|
for (let o = e.firstElementChild; o; o = o.nextElementSibling, a++) {
|
|
102
102
|
if (t.value !== void 0 && o.getAttribute("data-roving-value") === t.value) {
|
|
@@ -106,204 +106,254 @@ function B(e, t) {
|
|
|
106
106
|
a === t.index && (r = o), i = o;
|
|
107
107
|
}
|
|
108
108
|
let o = n ?? r ?? (t.index >= 0 ? i : null);
|
|
109
|
-
return o ? o.hasAttribute("tabindex") ? o :
|
|
109
|
+
return o ? o.hasAttribute("tabindex") ? o : L(o)[0] ?? null : null;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function B(e) {
|
|
112
112
|
for (let t = e.firstElementChild; t; t = t.nextElementSibling) if (t.hasAttribute("data-list-action")) return t;
|
|
113
113
|
return null;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function V(e) {
|
|
116
116
|
let t = [];
|
|
117
|
-
for (let n of
|
|
118
|
-
let r =
|
|
117
|
+
for (let n of L(e)) {
|
|
118
|
+
let r = I(n) ? e : n;
|
|
119
119
|
t.includes(r) || t.push(r);
|
|
120
120
|
}
|
|
121
121
|
return t;
|
|
122
122
|
}
|
|
123
|
-
var
|
|
124
|
-
let { selectable: n = !1, selectionMode: r, selectedItems: o, defaultSelectedItems: s, onSelectionChange:
|
|
123
|
+
var H = (t) => {
|
|
124
|
+
let { selectable: n = !1, selectionMode: r, selectedItems: o, defaultSelectedItems: s, onSelectionChange: c, selectedItem: u, defaultSelectedItem: d, onSelectedItemChange: ne, navigationMode: f, checkmark: p = !1, className: m, children: h, ref: ae, onKeyDown: g, onKeyDownCapture: _, onFocus: v, ...y } = t;
|
|
125
125
|
r === "multi" && i("List", "selectionMode=\"multi\"", "selectionMode=\"multiple\"");
|
|
126
|
-
let
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
let b = r === "multiple" || r === "multi", oe = S.useMemo(() => !b && u !== void 0 ? u === null ? O : [u] : o, [
|
|
127
|
+
b,
|
|
128
|
+
u,
|
|
129
129
|
o
|
|
130
|
-
]),
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
]), T = S.useMemo(() => !b && d != null ? [d] : s ?? O, [
|
|
131
|
+
b,
|
|
132
|
+
d,
|
|
133
133
|
s
|
|
134
|
-
]), [
|
|
134
|
+
]), [E, D] = te(oe, T, (e) => {
|
|
135
135
|
let t = [...e];
|
|
136
|
-
|
|
137
|
-
}), [
|
|
136
|
+
c?.(t), b || ne?.(t[0] ?? null);
|
|
137
|
+
}), [j] = S.useState(() => new x()), M = S.useSyncExternalStore(j.subscribe, j.getSnapshot, j.getServerSnapshot), N = S.useMemo(() => M ? E.filter((e) => M.valueSet.has(e)) : E, [M, E]), P = S.useMemo(() => new Set(N), [N]), F = n && f !== "composite" && (M ? M.hasActions : A(h)), { mode: I, navigation: R } = k(n, F, f), B = R !== "none", V = n && p;
|
|
138
138
|
S.useLayoutEffect(() => {
|
|
139
|
-
|
|
140
|
-
}, [
|
|
141
|
-
let
|
|
142
|
-
activeValue:
|
|
139
|
+
j.setActive(B);
|
|
140
|
+
}, [j, B]);
|
|
141
|
+
let H = M ? M.values.find((e) => P.has(e)) ?? null : N[0] ?? null, { containerProps: U, getTabIndex: W } = re({
|
|
142
|
+
activeValue: n ? H : null,
|
|
143
143
|
orientation: "vertical",
|
|
144
|
-
typeahead: (
|
|
145
|
-
tabStop: "active",
|
|
144
|
+
typeahead: (M?.count ?? 0) > 7,
|
|
145
|
+
tabStop: n ? "active" : "last-focused",
|
|
146
146
|
itemSelector: ":scope > [data-roving-value]"
|
|
147
|
-
}), { ref:
|
|
147
|
+
}), { ref: ce, onKeyDown: G, onKeyDownCapture: K, onFocus: q } = U, J = S.useRef(null), le = ie(ae, B ? ce : null, J);
|
|
148
148
|
S.useLayoutEffect(() => {
|
|
149
|
-
let e =
|
|
149
|
+
let e = j.takeFocusLoss(), t = J.current;
|
|
150
150
|
if (!e || !t) return;
|
|
151
151
|
let n = t.ownerDocument, r = n.activeElement;
|
|
152
|
-
r && r !== n.body && r.isConnected ||
|
|
153
|
-
}, [
|
|
154
|
-
|
|
152
|
+
r && r !== n.body && r.isConnected || z(t, e)?.focus();
|
|
153
|
+
}, [I, j]), S.useLayoutEffect(() => {
|
|
154
|
+
if (B) return;
|
|
155
|
+
let e = J.current, t = e?.ownerDocument.activeElement;
|
|
156
|
+
t && t.parentElement === e && !t.hasAttribute("tabindex") && L(t)[0]?.focus();
|
|
157
|
+
}, [B]), S.useLayoutEffect(() => {
|
|
158
|
+
j.syncOrder(J.current);
|
|
155
159
|
});
|
|
156
|
-
let
|
|
157
|
-
|
|
158
|
-
let n =
|
|
159
|
-
return
|
|
160
|
+
let Y = S.useCallback((e) => {
|
|
161
|
+
D((t) => {
|
|
162
|
+
let n = j.prune(t), r = n.includes(e);
|
|
163
|
+
return b ? r ? n.filter((t) => t !== e) : [...n, e] : r ? [] : [e];
|
|
160
164
|
});
|
|
161
165
|
}, [
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
]),
|
|
166
|
+
b,
|
|
167
|
+
j,
|
|
168
|
+
D
|
|
169
|
+
]), X = M?.duplicates ?? O;
|
|
166
170
|
S.useEffect(() => {
|
|
167
|
-
for (let e of
|
|
168
|
-
}, [
|
|
169
|
-
let
|
|
171
|
+
for (let e of X) se(e);
|
|
172
|
+
}, [X]);
|
|
173
|
+
let Z = N.length;
|
|
170
174
|
S.useEffect(() => {
|
|
171
|
-
n && !
|
|
175
|
+
n && !b && Z > 1 && a("List:single-several-selected", `List: a single-selection list (selectionMode "single") received ${Z} selected items. Pass one value with \`selectedItem\`, or use selectionMode="multiple".`);
|
|
172
176
|
}, [
|
|
173
177
|
n,
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
b,
|
|
179
|
+
Z
|
|
176
180
|
]);
|
|
177
|
-
let
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
let Q = n && f === "items" && F, $ = n && f === "none";
|
|
182
|
+
S.useEffect(() => {
|
|
183
|
+
Q && a("List:items-with-actions", "List: a selectable list whose items have actions is a grid (an option cannot hold interactive content), so navigationMode=\"items\" acts as \"composite\". Set navigationMode=\"composite\"."), $ && a("List:none-selectable", "List: navigationMode=\"none\" has no effect on a selectable list, whose items are always reached with the arrow keys. Remove it, or use \"items\" or \"composite\".");
|
|
184
|
+
}, [Q, $]);
|
|
185
|
+
let ue = S.useMemo(() => ({
|
|
186
|
+
mode: I,
|
|
187
|
+
navigable: B,
|
|
188
|
+
selection: n,
|
|
189
|
+
checkmark: V,
|
|
190
|
+
selectedValues: P,
|
|
191
|
+
toggleItem: Y,
|
|
192
|
+
getTabIndex: W,
|
|
193
|
+
registry: j
|
|
183
194
|
}), [
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
"data-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
195
|
+
I,
|
|
196
|
+
B,
|
|
197
|
+
n,
|
|
198
|
+
V,
|
|
199
|
+
P,
|
|
200
|
+
Y,
|
|
201
|
+
W,
|
|
202
|
+
j
|
|
203
|
+
]), de = I === "grid" ? "div" : "ul", fe = I === "grid" ? "grid" : I === "listbox" ? "listbox" : "list";
|
|
204
|
+
return /* @__PURE__ */ C(w.Provider, {
|
|
205
|
+
value: ue,
|
|
206
|
+
children: /* @__PURE__ */ C(de, {
|
|
207
|
+
role: fe,
|
|
208
|
+
"aria-multiselectable": n && b ? !0 : void 0,
|
|
209
|
+
"data-navigation-mode": R,
|
|
210
|
+
"data-checkmark": V ? "" : void 0,
|
|
211
|
+
className: e(ee.root, "m-0 list-none p-0", m),
|
|
212
|
+
...y,
|
|
213
|
+
ref: le,
|
|
214
|
+
"data-roving-container": B ? "" : void 0,
|
|
215
|
+
onKeyDown: B ? l(g, G) : g,
|
|
216
|
+
onKeyDownCapture: B ? l(_, K) : _,
|
|
217
|
+
onFocus: B ? l(v, q, { checkDefaultPrevented: !1 }) : v,
|
|
218
|
+
children: h
|
|
203
219
|
})
|
|
204
220
|
});
|
|
205
221
|
};
|
|
206
|
-
|
|
207
|
-
var
|
|
208
|
-
|
|
222
|
+
H.displayName = "List";
|
|
223
|
+
var U = "forced-colors:text-[Highlight] forced-colors:forced-color-adjust-none", W = "forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none";
|
|
224
|
+
function ce(t, { selected: n, disabled: r }) {
|
|
225
|
+
let i = e(u.checkmark, "order-first me-2 inline-flex shrink-0 items-center justify-center", r ? ["text-muted-foreground", W] : ["text-primary", U], !n && "invisible");
|
|
226
|
+
return t === void 0 ? /* @__PURE__ */ C("span", {
|
|
227
|
+
"aria-hidden": "true",
|
|
228
|
+
className: i,
|
|
229
|
+
children: /* @__PURE__ */ C(v, {})
|
|
230
|
+
}) : s(t, "span", i, { "aria-hidden": !0 });
|
|
231
|
+
}
|
|
232
|
+
var G = ({ value: t, action: n, onAction: r, disabledSelection: i = !1, checkmark: s, className: ee, children: te, onClick: m, onKeyDown: h, ref: re, ...v }) => {
|
|
233
|
+
let { mode: y, navigable: b, selection: x, checkmark: w, selectedValues: T, toggleItem: E, getTabIndex: O, registry: k } = D("ListItem"), se = ne("list-item"), A = t || void 0, j = A ?? se, P = c(n), [F] = S.useState(() => ({})), z = S.useRef(null), H = ie(re, z);
|
|
209
234
|
S.useLayoutEffect(() => {
|
|
210
|
-
|
|
211
|
-
value:
|
|
212
|
-
hasAction:
|
|
213
|
-
element:
|
|
235
|
+
k.set(F, {
|
|
236
|
+
value: A,
|
|
237
|
+
hasAction: P,
|
|
238
|
+
element: z
|
|
214
239
|
});
|
|
215
240
|
}, [
|
|
216
|
-
E,
|
|
217
|
-
M,
|
|
218
241
|
k,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
242
|
+
F,
|
|
243
|
+
A,
|
|
244
|
+
P
|
|
245
|
+
]), S.useLayoutEffect(() => () => k.delete(F), [k, F]);
|
|
246
|
+
let U = d((e) => {
|
|
222
247
|
let t = e.parentElement;
|
|
223
|
-
|
|
224
|
-
value:
|
|
225
|
-
index: t ?
|
|
248
|
+
k.recordFocusLoss({
|
|
249
|
+
value: A,
|
|
250
|
+
index: t ? R(t) : -1
|
|
226
251
|
});
|
|
227
252
|
});
|
|
228
253
|
S.useLayoutEffect(() => {
|
|
229
|
-
let e =
|
|
254
|
+
let e = z.current;
|
|
230
255
|
return () => {
|
|
231
256
|
if (!e) return;
|
|
232
257
|
let t = e.ownerDocument.activeElement;
|
|
233
|
-
t && e.contains(t) &&
|
|
234
|
-
value:
|
|
235
|
-
index:
|
|
258
|
+
t && e.contains(t) && k.recordFocusLoss({
|
|
259
|
+
value: A,
|
|
260
|
+
index: R(e)
|
|
236
261
|
});
|
|
237
262
|
};
|
|
238
|
-
}, [
|
|
239
|
-
let
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
},
|
|
246
|
-
|
|
263
|
+
}, [k, A]);
|
|
264
|
+
let W = r !== void 0 && !b;
|
|
265
|
+
S.useEffect(() => {
|
|
266
|
+
W && a("List.Item:action-not-navigable", "List.Item: `onAction` runs only on clicks here: the List does not navigate its items, so keyboard users cannot reach them. Set navigationMode=\"items\" (or \"composite\") on the List, or make it selectable.");
|
|
267
|
+
}, [W]);
|
|
268
|
+
let G = x && A !== void 0 && T.has(A), K = x && A !== void 0, q = x && i, J = q && r === void 0, Y = () => {
|
|
269
|
+
x && !i && A !== void 0 && E(A);
|
|
270
|
+
}, X = (e) => {
|
|
271
|
+
r?.(e), e.isDefaultPrevented() || Y();
|
|
272
|
+
}, Z = (e) => {
|
|
273
|
+
M(e) || X(e);
|
|
274
|
+
}, Q = (e) => {
|
|
275
|
+
if (e.key === " " && K) {
|
|
276
|
+
e.preventDefault(), Y();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
(x || r !== void 0) && (X(e), e.preventDefault());
|
|
280
|
+
}, $ = (e) => {
|
|
281
|
+
M(e) || N(e) && Q(e);
|
|
282
|
+
}, ue = (e) => {
|
|
283
|
+
let t = e.currentTarget, n = e.target, r = B(t);
|
|
247
284
|
if (!r || !r.contains(n)) {
|
|
248
285
|
if (n !== t) return;
|
|
249
|
-
if (
|
|
250
|
-
e
|
|
286
|
+
if (N(e)) {
|
|
287
|
+
Q(e);
|
|
251
288
|
return;
|
|
252
289
|
}
|
|
253
|
-
let i =
|
|
290
|
+
let i = f(e.key, {
|
|
254
291
|
orientation: "horizontal",
|
|
255
|
-
dir:
|
|
256
|
-
}) === "next" && r ?
|
|
292
|
+
dir: p(t)
|
|
293
|
+
}) === "next" && r ? V(r)[0] : void 0;
|
|
257
294
|
i && (e.preventDefault(), i.focus());
|
|
258
295
|
return;
|
|
259
296
|
}
|
|
260
|
-
if (n !== r &&
|
|
297
|
+
if (n !== r && I(n)) {
|
|
261
298
|
e.key === "Escape" && (e.preventDefault(), r.focus());
|
|
262
299
|
return;
|
|
263
300
|
}
|
|
264
301
|
if (n === r && (e.key === "Enter" || e.key === "F2")) {
|
|
265
|
-
let t =
|
|
302
|
+
let t = L(r).find((e) => I(e));
|
|
266
303
|
t && (e.preventDefault(), t.focus());
|
|
267
304
|
return;
|
|
268
305
|
}
|
|
269
|
-
let i =
|
|
306
|
+
let i = f(e.key, {
|
|
270
307
|
orientation: "horizontal",
|
|
271
|
-
dir:
|
|
308
|
+
dir: p(t)
|
|
272
309
|
});
|
|
273
310
|
if (!i) return;
|
|
274
311
|
e.preventDefault();
|
|
275
|
-
let a =
|
|
312
|
+
let a = V(r), o = a.indexOf(n);
|
|
276
313
|
i === "next" ? a[o + 1]?.focus() : o > 0 ? a[o - 1].focus() : t.focus();
|
|
277
|
-
},
|
|
278
|
-
"aria-selected":
|
|
279
|
-
tabIndex:
|
|
280
|
-
"data-roving-value":
|
|
281
|
-
"data-selected":
|
|
282
|
-
|
|
283
|
-
|
|
314
|
+
}, de = y === "grid" ? "div" : "li", fe = y === "grid" ? "div" : "span", pe = y === "grid" ? "row" : y === "listbox" ? "option" : "listitem", me = b ? {
|
|
315
|
+
"aria-selected": x ? G : void 0,
|
|
316
|
+
tabIndex: O(j),
|
|
317
|
+
"data-roving-value": j,
|
|
318
|
+
"data-selected": G ? "" : void 0,
|
|
319
|
+
...ae(J, { reachable: !0 }),
|
|
320
|
+
onClick: l(m, Z),
|
|
321
|
+
onKeyDown: l(h, y === "grid" ? ue : $)
|
|
284
322
|
} : {
|
|
285
|
-
onClick:
|
|
286
|
-
onKeyDown:
|
|
287
|
-
};
|
|
288
|
-
return /* @__PURE__ */
|
|
289
|
-
role:
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
323
|
+
onClick: r ? l(m, Z) : m,
|
|
324
|
+
onKeyDown: h
|
|
325
|
+
}, he = x ? J ? "cursor-default" : "cursor-pointer" : r && "cursor-pointer", ge = x ? !J : r !== void 0, _e = s != null && c(s), ve = x && (s == null ? w : _e);
|
|
326
|
+
return /* @__PURE__ */ oe(de, {
|
|
327
|
+
role: pe,
|
|
328
|
+
"data-disabled-selection": q ? "" : void 0,
|
|
329
|
+
className: e(u.root, "flex items-center border-b border-border px-4 py-2 text-body-1", b ? [
|
|
330
|
+
"relative",
|
|
331
|
+
he,
|
|
332
|
+
g
|
|
333
|
+
] : he, G ? ["bg-subtle-selected before:absolute before:inset-y-2 before:start-0 before:w-0.5 before:rounded-full before:bg-primary", _.selectedContainer] : ge && "hover:bg-subtle-hover", ee),
|
|
334
|
+
...v,
|
|
335
|
+
ref: H,
|
|
336
|
+
...me,
|
|
337
|
+
children: [
|
|
338
|
+
/* @__PURE__ */ C(fe, {
|
|
339
|
+
role: y === "grid" ? "gridcell" : void 0,
|
|
340
|
+
className: e(u.content, "min-w-0 flex-1"),
|
|
341
|
+
children: te
|
|
342
|
+
}),
|
|
343
|
+
P && /* @__PURE__ */ C(le, {
|
|
344
|
+
grid: y === "grid",
|
|
345
|
+
onRemovedWithFocus: U,
|
|
346
|
+
children: o(n)
|
|
347
|
+
}),
|
|
348
|
+
ve && ce(_e ? s : void 0, {
|
|
349
|
+
selected: G,
|
|
350
|
+
disabled: q
|
|
351
|
+
})
|
|
352
|
+
]
|
|
303
353
|
});
|
|
304
354
|
};
|
|
305
|
-
|
|
306
|
-
var
|
|
355
|
+
G.displayName = "ListItem";
|
|
356
|
+
var K = ["[data-roving-container]", ...[
|
|
307
357
|
"toolbar",
|
|
308
358
|
"radiogroup",
|
|
309
359
|
"listbox",
|
|
@@ -313,19 +363,19 @@ var G = ["[data-roving-container]", ...[
|
|
|
313
363
|
"menu",
|
|
314
364
|
"menubar",
|
|
315
365
|
"tree"
|
|
316
|
-
].map((e) => `[role="${e}"]`)].join(", "),
|
|
366
|
+
].map((e) => `[role="${e}"]`)].join(", "), q = [
|
|
317
367
|
"tabindex",
|
|
318
368
|
"href",
|
|
319
369
|
"contenteditable",
|
|
320
370
|
"controls"
|
|
321
371
|
];
|
|
322
|
-
function
|
|
372
|
+
function J(e) {
|
|
323
373
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new WeakSet(), r = () => {
|
|
324
374
|
for (let n of t.keys()) e.contains(n) || t.delete(n);
|
|
325
|
-
for (let r of e.querySelectorAll(
|
|
375
|
+
for (let r of e.querySelectorAll(m)) {
|
|
326
376
|
let i = r.getAttribute("tabindex");
|
|
327
377
|
if (i === "-1" || n.has(r)) continue;
|
|
328
|
-
let a = r.closest(
|
|
378
|
+
let a = r.closest(K);
|
|
329
379
|
a && e.contains(a) || (t.set(r, i), r.setAttribute("tabindex", "-1"));
|
|
330
380
|
}
|
|
331
381
|
};
|
|
@@ -346,14 +396,14 @@ function q(e) {
|
|
|
346
396
|
subtree: !0,
|
|
347
397
|
childList: !0,
|
|
348
398
|
attributes: !0,
|
|
349
|
-
attributeFilter:
|
|
399
|
+
attributeFilter: q
|
|
350
400
|
}), () => {
|
|
351
401
|
i.disconnect();
|
|
352
402
|
for (let [e, n] of t) n === null ? e.removeAttribute("tabindex") : e.setAttribute("tabindex", n);
|
|
353
403
|
t.clear();
|
|
354
404
|
};
|
|
355
405
|
}
|
|
356
|
-
function
|
|
406
|
+
function le({ grid: t, onRemovedWithFocus: n, children: r }) {
|
|
357
407
|
let i = S.useRef(null);
|
|
358
408
|
return S.useLayoutEffect(() => {
|
|
359
409
|
let e = i.current;
|
|
@@ -364,7 +414,7 @@ function J({ grid: t, onRemovedWithFocus: n, children: r }) {
|
|
|
364
414
|
};
|
|
365
415
|
}, [n, t]), S.useLayoutEffect(() => {
|
|
366
416
|
let e = i.current;
|
|
367
|
-
return t && e ?
|
|
417
|
+
return t && e ? J(e) : void 0;
|
|
368
418
|
}, [t]), /* @__PURE__ */ C(t ? "div" : "span", {
|
|
369
419
|
ref: i,
|
|
370
420
|
role: t ? "gridcell" : void 0,
|
|
@@ -374,9 +424,9 @@ function J({ grid: t, onRemovedWithFocus: n, children: r }) {
|
|
|
374
424
|
children: r
|
|
375
425
|
});
|
|
376
426
|
}
|
|
377
|
-
|
|
378
|
-
var Y = /* @__PURE__ */ Object.assign(
|
|
427
|
+
le.displayName = "ListActionCell";
|
|
428
|
+
var Y = /* @__PURE__ */ Object.assign(H, { Item: G });
|
|
379
429
|
//#endregion
|
|
380
|
-
export { Y as List,
|
|
430
|
+
export { Y as List, G as ListItem };
|
|
381
431
|
|
|
382
432
|
//# sourceMappingURL=List.mjs.map
|