@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.
Files changed (174) hide show
  1. package/README.md +362 -60
  2. package/dist/components/data-display/Avatar.cjs +1 -1
  3. package/dist/components/data-display/Avatar.cjs.map +1 -1
  4. package/dist/components/data-display/Avatar.colors.cjs +2 -0
  5. package/dist/components/data-display/Avatar.colors.cjs.map +1 -0
  6. package/dist/components/data-display/Avatar.colors.mjs +45 -0
  7. package/dist/components/data-display/Avatar.colors.mjs.map +1 -0
  8. package/dist/components/data-display/Avatar.context.cjs +1 -1
  9. package/dist/components/data-display/Avatar.context.cjs.map +1 -1
  10. package/dist/components/data-display/Avatar.context.mjs +4 -2
  11. package/dist/components/data-display/Avatar.context.mjs.map +1 -1
  12. package/dist/components/data-display/Avatar.mjs +103 -96
  13. package/dist/components/data-display/Avatar.mjs.map +1 -1
  14. package/dist/components/data-display/Avatar.sizes.cjs +2 -0
  15. package/dist/components/data-display/Avatar.sizes.cjs.map +1 -0
  16. package/dist/components/data-display/Avatar.sizes.mjs +41 -0
  17. package/dist/components/data-display/Avatar.sizes.mjs.map +1 -0
  18. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  19. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  20. package/dist/components/data-display/AvatarGroup.context.cjs +2 -0
  21. package/dist/components/data-display/AvatarGroup.context.cjs.map +1 -0
  22. package/dist/components/data-display/AvatarGroup.context.mjs +9 -0
  23. package/dist/components/data-display/AvatarGroup.context.mjs.map +1 -0
  24. package/dist/components/data-display/AvatarGroup.mjs +65 -122
  25. package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
  26. package/dist/components/data-display/AvatarGroup.partition.cjs +2 -0
  27. package/dist/components/data-display/AvatarGroup.partition.cjs.map +1 -0
  28. package/dist/components/data-display/AvatarGroup.partition.mjs +14 -0
  29. package/dist/components/data-display/AvatarGroup.partition.mjs.map +1 -0
  30. package/dist/components/data-display/AvatarGroup.parts.cjs +2 -0
  31. package/dist/components/data-display/AvatarGroup.parts.cjs.map +1 -0
  32. package/dist/components/data-display/AvatarGroup.parts.mjs +178 -0
  33. package/dist/components/data-display/AvatarGroup.parts.mjs.map +1 -0
  34. package/dist/components/data-display/InteractionTag.cjs +1 -1
  35. package/dist/components/data-display/InteractionTag.cjs.map +1 -1
  36. package/dist/components/data-display/InteractionTag.mjs +36 -33
  37. package/dist/components/data-display/InteractionTag.mjs.map +1 -1
  38. package/dist/components/data-display/List.cjs +1 -1
  39. package/dist/components/data-display/List.cjs.map +1 -1
  40. package/dist/components/data-display/List.mjs +245 -195
  41. package/dist/components/data-display/List.mjs.map +1 -1
  42. package/dist/components/data-display/List.registry.cjs.map +1 -1
  43. package/dist/components/data-display/List.registry.mjs.map +1 -1
  44. package/dist/components/data-display/Persona.cjs +1 -1
  45. package/dist/components/data-display/Persona.cjs.map +1 -1
  46. package/dist/components/data-display/Persona.mjs +96 -37
  47. package/dist/components/data-display/Persona.mjs.map +1 -1
  48. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  49. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  50. package/dist/components/data-display/PresenceBadge.mjs +42 -28
  51. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  52. package/dist/components/data-display/Tag.cjs +1 -1
  53. package/dist/components/data-display/Tag.cjs.map +1 -1
  54. package/dist/components/data-display/Tag.mjs +111 -108
  55. package/dist/components/data-display/Tag.mjs.map +1 -1
  56. package/dist/components/layout/Card.cjs +1 -1
  57. package/dist/components/layout/Card.cjs.map +1 -1
  58. package/dist/components/layout/Card.context.cjs +2 -0
  59. package/dist/components/layout/Card.context.cjs.map +1 -0
  60. package/dist/components/layout/Card.context.mjs +14 -0
  61. package/dist/components/layout/Card.context.mjs.map +1 -0
  62. package/dist/components/layout/Card.mjs +138 -92
  63. package/dist/components/layout/Card.mjs.map +1 -1
  64. package/dist/components/layout/Card.preview.cjs +2 -0
  65. package/dist/components/layout/Card.preview.cjs.map +1 -0
  66. package/dist/components/layout/Card.preview.mjs +22 -0
  67. package/dist/components/layout/Card.preview.mjs.map +1 -0
  68. package/dist/components/layout/Carousel.button.cjs +2 -0
  69. package/dist/components/layout/Carousel.button.cjs.map +1 -0
  70. package/dist/components/layout/Carousel.button.mjs +34 -0
  71. package/dist/components/layout/Carousel.button.mjs.map +1 -0
  72. package/dist/components/layout/Carousel.cjs +1 -1
  73. package/dist/components/layout/Carousel.cjs.map +1 -1
  74. package/dist/components/layout/Carousel.context.cjs +2 -0
  75. package/dist/components/layout/Carousel.context.cjs.map +1 -0
  76. package/dist/components/layout/Carousel.context.mjs +24 -0
  77. package/dist/components/layout/Carousel.context.mjs.map +1 -0
  78. package/dist/components/layout/Carousel.drag.cjs +2 -0
  79. package/dist/components/layout/Carousel.drag.cjs.map +1 -0
  80. package/dist/components/layout/Carousel.drag.mjs +79 -0
  81. package/dist/components/layout/Carousel.drag.mjs.map +1 -0
  82. package/dist/components/layout/Carousel.groups.cjs +2 -0
  83. package/dist/components/layout/Carousel.groups.cjs.map +1 -0
  84. package/dist/components/layout/Carousel.groups.mjs +23 -0
  85. package/dist/components/layout/Carousel.groups.mjs.map +1 -0
  86. package/dist/components/layout/Carousel.mjs +288 -150
  87. package/dist/components/layout/Carousel.mjs.map +1 -1
  88. package/dist/components/layout/Carousel.styles.cjs +2 -0
  89. package/dist/components/layout/Carousel.styles.cjs.map +1 -0
  90. package/dist/components/layout/Carousel.styles.mjs +30 -0
  91. package/dist/components/layout/Carousel.styles.mjs.map +1 -0
  92. package/dist/components/layout/Overflow.cjs +1 -1
  93. package/dist/components/layout/Overflow.cjs.map +1 -1
  94. package/dist/components/layout/Overflow.mjs +240 -192
  95. package/dist/components/layout/Overflow.mjs.map +1 -1
  96. package/dist/components/layout/Overflow.store.cjs +2 -0
  97. package/dist/components/layout/Overflow.store.cjs.map +1 -0
  98. package/dist/components/layout/Overflow.store.mjs +209 -0
  99. package/dist/components/layout/Overflow.store.mjs.map +1 -0
  100. package/dist/components/layout/TabList.cjs +1 -1
  101. package/dist/components/layout/TabList.cjs.map +1 -1
  102. package/dist/components/layout/TabList.mjs +163 -124
  103. package/dist/components/layout/TabList.mjs.map +1 -1
  104. package/dist/components/navigation/Breadcrumb.cjs +1 -1
  105. package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
  106. package/dist/components/navigation/Breadcrumb.mjs +239 -84
  107. package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
  108. package/dist/components/overlays/Dialog.slots.cjs +1 -1
  109. package/dist/components/overlays/Dialog.slots.cjs.map +1 -1
  110. package/dist/components/overlays/Dialog.slots.mjs +19 -15
  111. package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
  112. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  113. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  114. package/dist/components/overlays/TeachingPopover.context.cjs +2 -0
  115. package/dist/components/overlays/TeachingPopover.context.cjs.map +1 -0
  116. package/dist/components/overlays/TeachingPopover.context.mjs +51 -0
  117. package/dist/components/overlays/TeachingPopover.context.mjs.map +1 -0
  118. package/dist/components/overlays/TeachingPopover.mjs +15 -185
  119. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  120. package/dist/components/overlays/TeachingPopover.parts.cjs +2 -0
  121. package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -0
  122. package/dist/components/overlays/TeachingPopover.parts.mjs +398 -0
  123. package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -0
  124. package/dist/components/overlays/TeachingPopover.root.cjs +2 -0
  125. package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -0
  126. package/dist/components/overlays/TeachingPopover.root.mjs +150 -0
  127. package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -0
  128. package/dist/components/overlays/TeachingPopover.stack.cjs +2 -0
  129. package/dist/components/overlays/TeachingPopover.stack.cjs.map +1 -0
  130. package/dist/components/overlays/TeachingPopover.stack.mjs +86 -0
  131. package/dist/components/overlays/TeachingPopover.stack.mjs.map +1 -0
  132. package/dist/components/table/DataGrid.cjs +1 -1
  133. package/dist/components/table/DataGrid.cjs.map +1 -1
  134. package/dist/components/table/DataGrid.mjs +540 -311
  135. package/dist/components/table/DataGrid.mjs.map +1 -1
  136. package/dist/components/table/Table.cjs +1 -1
  137. package/dist/components/table/Table.cjs.map +1 -1
  138. package/dist/components/table/Table.mjs +183 -60
  139. package/dist/components/table/Table.mjs.map +1 -1
  140. package/dist/components/table/Table.shared.cjs +2 -0
  141. package/dist/components/table/Table.shared.cjs.map +1 -0
  142. package/dist/components/table/Table.shared.mjs +65 -0
  143. package/dist/components/table/Table.shared.mjs.map +1 -0
  144. package/dist/index.cjs +1 -1
  145. package/dist/index.d.cts +2299 -213
  146. package/dist/index.d.ts +2299 -213
  147. package/dist/index.mjs +135 -127
  148. package/dist/lib/breadcrumb.cjs +2 -0
  149. package/dist/lib/breadcrumb.cjs.map +1 -0
  150. package/dist/lib/breadcrumb.mjs +26 -0
  151. package/dist/lib/breadcrumb.mjs.map +1 -0
  152. package/dist/lib/classNames.cjs +1 -1
  153. package/dist/lib/classNames.cjs.map +1 -1
  154. package/dist/lib/classNames.mjs +143 -95
  155. package/dist/lib/classNames.mjs.map +1 -1
  156. package/dist/lib/events.cjs +1 -1
  157. package/dist/lib/events.cjs.map +1 -1
  158. package/dist/lib/events.mjs +35 -8
  159. package/dist/lib/events.mjs.map +1 -1
  160. package/dist/lib/icons.cjs +1 -1
  161. package/dist/lib/icons.cjs.map +1 -1
  162. package/dist/lib/icons.mjs +34 -20
  163. package/dist/lib/icons.mjs.map +1 -1
  164. package/dist/lib/initials.cjs +2 -0
  165. package/dist/lib/initials.cjs.map +1 -0
  166. package/dist/lib/initials.mjs +21 -0
  167. package/dist/lib/initials.mjs.map +1 -0
  168. package/dist/lib/table.cjs +2 -0
  169. package/dist/lib/table.cjs.map +1 -0
  170. package/dist/lib/table.mjs +16 -0
  171. package/dist/lib/table.mjs.map +1 -0
  172. package/dist/styles.css +1 -1
  173. package/package.json +1 -1
  174. 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, slotRendersContent as s } from "../../lib/slot.mjs";
6
- import { composeEventHandlers as c } from "../../lib/composeEventHandlers.mjs";
7
- import { listClassNames as l, listItemClassNames as u } from "../../lib/classNames.mjs";
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 f } from "../../hooks/useControllable.mjs";
10
- import { useId as p } from "../../hooks/useId.mjs";
11
- import { getArrowIntent as m, getDirection as h } from "../../lib/direction.mjs";
12
- import { FOCUSABLE_SELECTOR as g, isFocusable as _ } from "../../lib/focus.mjs";
13
- import { useRovingTabIndex as v } from "../../hooks/useRovingTabIndex.mjs";
14
- import { useMergedRefs as y } from "../../hooks/useMergedRefs.mjs";
15
- import { forcedColors as b } from "../../lib/styles.mjs";
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 w } from "react/jsx-runtime";
21
+ import { jsx as C, jsxs as oe } from "react/jsx-runtime";
19
22
  //#region src/components/data-display/List.tsx
20
- var T = S.createContext(null);
21
- T.displayName = "ListContext";
22
- var E = null;
23
- function D() {
24
- return E ??= {
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
- }, E;
36
+ }, T;
31
37
  }
32
- function O(e) {
33
- return S.useContext(T) || (r(e, "a List"), D());
38
+ function D(e) {
39
+ return S.useContext(w) || (r(e, "a List"), E());
34
40
  }
35
- var k = [];
36
- function A(e) {
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 j(e) {
40
- return t(e).some(({ node: e }) => n(e, W) && s(e.props.action));
57
+ function A(e) {
58
+ return t(e).some(({ node: e }) => n(e, G) && c(e.props.action));
41
59
  }
42
- var M = [
43
- g,
44
- "[data-list-action]",
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 P(e) {
64
+ function N(e) {
65
65
  return e.ctrlKey || e.altKey || e.metaKey ? !1 : e.key === "Enter" || e.key === " ";
66
66
  }
67
- var F = /* @__PURE__ */ new Set([
67
+ var P = /* @__PURE__ */ new Set([
68
68
  "textbox",
69
69
  "searchbox",
70
70
  "combobox",
71
71
  "spinbutton",
72
72
  "slider"
73
- ]), I = /* @__PURE__ */ new Set([
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 L(e) {
84
+ function I(e) {
85
85
  let t = e.getAttribute("role");
86
- if (t !== null && F.has(t)) return !0;
86
+ if (t !== null && P.has(t)) return !0;
87
87
  let n = e.localName;
88
- return n === "textarea" || n === "select" ? !0 : n === "input" ? !I.has(e.type) : e.matches("[contenteditable]:not([contenteditable=\"false\"])");
88
+ return n === "textarea" || n === "select" ? !0 : n === "input" ? !F.has(e.type) : e.matches("[contenteditable]:not([contenteditable=\"false\"])");
89
89
  }
90
- function R(e) {
91
- return Array.from(e.querySelectorAll(g)).filter((e) => _(e));
90
+ function L(e) {
91
+ return Array.from(e.querySelectorAll(m)).filter((e) => h(e));
92
92
  }
93
- function z(e) {
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 B(e, t) {
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 : R(o)[0] ?? null : null;
109
+ return o ? o.hasAttribute("tabindex") ? o : L(o)[0] ?? null : null;
110
110
  }
111
- function V(e) {
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 H(e) {
115
+ function V(e) {
116
116
  let t = [];
117
- for (let n of R(e)) {
118
- let r = L(n) ? e : n;
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 U = (t) => {
124
- let { selectable: n = !1, selectionMode: r, selectedItems: o, defaultSelectedItems: s, onSelectionChange: u, selectedItem: d, defaultSelectedItem: p, onSelectedItemChange: m, className: h, children: g, ref: _, onKeyDown: b, onKeyDownCapture: w, onFocus: E, ...D } = t;
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 O = r === "multiple" || r === "multi", M = S.useMemo(() => !O && d !== void 0 ? d === null ? k : [d] : o, [
127
- O,
128
- d,
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
- ]), N = S.useMemo(() => !O && p != null ? [p] : s ?? k, [
131
- O,
132
- p,
130
+ ]), T = S.useMemo(() => !b && d != null ? [d] : s ?? O, [
131
+ b,
132
+ d,
133
133
  s
134
- ]), [P, F] = f(M, N, (e) => {
134
+ ]), [E, D] = te(oe, T, (e) => {
135
135
  let t = [...e];
136
- u?.(t), O || m?.(t[0] ?? null);
137
- }), [I] = S.useState(() => new x());
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
- I.setActive(n);
140
- }, [I, n]);
141
- let L = S.useSyncExternalStore(I.subscribe, I.getSnapshot, I.getServerSnapshot), R = S.useMemo(() => L ? P.filter((e) => L.valueSet.has(e)) : P, [L, P]), z = S.useMemo(() => new Set(R), [R]), V = n && (L ? L.hasActions : j(g)), H = n ? V ? "grid" : "listbox" : "list", U = L ? L.values.find((e) => z.has(e)) ?? null : R[0] ?? null, { containerProps: W, getTabIndex: G } = v({
142
- activeValue: U,
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: (L?.count ?? 0) > 7,
145
- tabStop: "active",
144
+ typeahead: (M?.count ?? 0) > 7,
145
+ tabStop: n ? "active" : "last-focused",
146
146
  itemSelector: ":scope > [data-roving-value]"
147
- }), { ref: K, onKeyDown: q, onKeyDownCapture: J, onFocus: Y } = W, X = S.useRef(null), ee = y(_, n ? K : null, X);
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 = I.takeFocusLoss(), t = X.current;
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 || B(t, e)?.focus();
153
- }, [H, I]), S.useLayoutEffect(() => {
154
- I.syncOrder(X.current);
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 Z = S.useCallback((e) => {
157
- F((t) => {
158
- let n = I.prune(t), r = n.includes(e);
159
- return O ? r ? n.filter((t) => t !== e) : [...n, e] : r ? [] : [e];
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
- O,
163
- I,
164
- F
165
- ]), Q = L?.duplicates ?? k;
166
+ b,
167
+ j,
168
+ D
169
+ ]), X = M?.duplicates ?? O;
166
170
  S.useEffect(() => {
167
- for (let e of Q) A(e);
168
- }, [Q]);
169
- let $ = R.length;
171
+ for (let e of X) se(e);
172
+ }, [X]);
173
+ let Z = N.length;
170
174
  S.useEffect(() => {
171
- n && !O && $ > 1 && a("List:single-several-selected", `List: a single-selection list (selectionMode "single") received ${$} selected items. Pass one value with \`selectedItem\`, or use selectionMode="multiple".`);
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
- O,
175
- $
178
+ b,
179
+ Z
176
180
  ]);
177
- let te = S.useMemo(() => ({
178
- mode: H,
179
- selectedValues: z,
180
- toggleItem: Z,
181
- getTabIndex: G,
182
- registry: I
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
- H,
185
- z,
186
- Z,
187
- G,
188
- I
189
- ]), ne = H === "grid" ? "div" : "ul", re = H === "grid" ? "grid" : H === "listbox" ? "listbox" : "list";
190
- return /* @__PURE__ */ C(T.Provider, {
191
- value: te,
192
- children: /* @__PURE__ */ C(ne, {
193
- role: re,
194
- "aria-multiselectable": n && O ? !0 : void 0,
195
- className: e(l.root, "m-0 list-none p-0", h),
196
- ...D,
197
- ref: ee,
198
- "data-roving-container": n ? "" : void 0,
199
- onKeyDown: n ? c(b, q) : b,
200
- onKeyDownCapture: n ? c(w, J) : w,
201
- onFocus: n ? c(E, Y, { checkDefaultPrevented: !1 }) : E,
202
- children: g
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
- U.displayName = "List";
207
- var W = ({ value: t, action: n, className: r, children: i, onClick: a, onKeyDown: l, ref: f, ...g }) => {
208
- let { mode: _, selectedValues: v, toggleItem: x, getTabIndex: T, registry: E } = O("ListItem"), D = p("list-item"), k = t || void 0, A = k ?? D, j = s(n), [M] = S.useState(() => ({})), F = S.useRef(null), I = y(f, F);
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
- E.set(M, {
211
- value: k,
212
- hasAction: j,
213
- element: F
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
- j
220
- ]), S.useLayoutEffect(() => () => E.delete(M), [E, M]);
221
- let B = d((e) => {
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
- E.recordFocusLoss({
224
- value: k,
225
- index: t ? z(t) : -1
248
+ k.recordFocusLoss({
249
+ value: A,
250
+ index: t ? R(t) : -1
226
251
  });
227
252
  });
228
253
  S.useLayoutEffect(() => {
229
- let e = F.current;
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) && E.recordFocusLoss({
234
- value: k,
235
- index: z(e)
258
+ t && e.contains(t) && k.recordFocusLoss({
259
+ value: A,
260
+ index: R(e)
236
261
  });
237
262
  };
238
- }, [E, k]);
239
- let U = k !== void 0 && v.has(k), W = _ !== "list", G = () => {
240
- k !== void 0 && x(k);
241
- }, K = (e) => {
242
- N(e) || G();
243
- }, q = (e) => {
244
- N(e) || P(e) && (e.preventDefault(), G());
245
- }, Y = (e) => {
246
- let t = e.currentTarget, n = e.target, r = V(t);
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 (P(e)) {
250
- e.preventDefault(), G();
286
+ if (N(e)) {
287
+ Q(e);
251
288
  return;
252
289
  }
253
- let i = m(e.key, {
290
+ let i = f(e.key, {
254
291
  orientation: "horizontal",
255
- dir: h(t)
256
- }) === "next" && r ? H(r)[0] : void 0;
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 && L(n)) {
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 = R(r).find((e) => L(e));
302
+ let t = L(r).find((e) => I(e));
266
303
  t && (e.preventDefault(), t.focus());
267
304
  return;
268
305
  }
269
- let i = m(e.key, {
306
+ let i = f(e.key, {
270
307
  orientation: "horizontal",
271
- dir: h(t)
308
+ dir: p(t)
272
309
  });
273
310
  if (!i) return;
274
311
  e.preventDefault();
275
- let a = H(r), o = a.indexOf(n);
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
- }, X = _ === "grid" ? "div" : "li", ee = _ === "grid" ? "div" : "span", Z = _ === "grid" ? "row" : _ === "listbox" ? "option" : "listitem", Q = W ? {
278
- "aria-selected": U,
279
- tabIndex: T(A),
280
- "data-roving-value": A,
281
- "data-selected": U ? "" : void 0,
282
- onClick: c(a, K),
283
- onKeyDown: c(l, _ === "grid" ? Y : q)
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: a,
286
- onKeyDown: l
287
- };
288
- return /* @__PURE__ */ w(X, {
289
- role: Z,
290
- className: e(u.root, "flex items-center border-b border-border px-4 py-2 text-body-1", W && ["relative cursor-pointer", "focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"], W && (U ? ["bg-subtle-selected before:absolute before:inset-y-2 before:start-0 before:w-0.5 before:rounded-full before:bg-primary", b.selectedContainer] : "hover:bg-subtle-hover"), r),
291
- ...g,
292
- ref: I,
293
- ...Q,
294
- children: [/* @__PURE__ */ C(ee, {
295
- role: _ === "grid" ? "gridcell" : void 0,
296
- className: e(u.content, "min-w-0 flex-1"),
297
- children: i
298
- }), j && /* @__PURE__ */ C(J, {
299
- grid: _ === "grid",
300
- onRemovedWithFocus: B,
301
- children: o(n)
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
- W.displayName = "ListItem";
306
- var G = ["[data-roving-container]", ...[
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(", "), K = [
366
+ ].map((e) => `[role="${e}"]`)].join(", "), q = [
317
367
  "tabindex",
318
368
  "href",
319
369
  "contenteditable",
320
370
  "controls"
321
371
  ];
322
- function q(e) {
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(g)) {
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(G);
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: K
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 J({ grid: t, onRemovedWithFocus: n, children: r }) {
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 ? q(e) : void 0;
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
- J.displayName = "ListActionCell";
378
- var Y = /* @__PURE__ */ Object.assign(U, { Item: W });
427
+ le.displayName = "ListActionCell";
428
+ var Y = /* @__PURE__ */ Object.assign(H, { Item: G });
379
429
  //#endregion
380
- export { Y as List, W as ListItem };
430
+ export { Y as List, G as ListItem };
381
431
 
382
432
  //# sourceMappingURL=List.mjs.map