@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
@@ -3,21 +3,23 @@ import { cn as e } from "../../lib/cn.mjs";
3
3
  import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
4
4
  import { isDev as r, reportMissingContext as i, resolveDeprecatedProp as a, warnDeprecated as o, warnOnce as s } from "../../lib/dev.mjs";
5
5
  import { composeEventHandlers as c } from "../../lib/composeEventHandlers.mjs";
6
- import { dataGridBodyClassNames as l, dataGridCellClassNames as u, dataGridClassNames as d, dataGridHeaderCellClassNames as f, dataGridHeaderClassNames as p, dataGridRowClassNames as m } from "../../lib/classNames.mjs";
7
- import { useControllable as h } from "../../hooks/useControllable.mjs";
8
- import { useId as ee } from "../../hooks/useId.mjs";
9
- import { useMergedRefs as g } from "../../hooks/useMergedRefs.mjs";
10
- import { useGridNavigation as te } from "./useGridNavigation.mjs";
11
- import { focusRingInset as _, forcedColors as v } from "../../lib/styles.mjs";
12
- import * as y from "react";
13
- import { Fragment as ne, jsx as b, jsxs as x } from "react/jsx-runtime";
6
+ import { dataGridBodyClassNames as l, dataGridCellClassNames as u, dataGridClassNames as d, dataGridHeaderCellClassNames as f, dataGridHeaderClassNames as p, dataGridRowClassNames as m, dataGridSelectionCellClassNames as h } from "../../lib/classNames.mjs";
7
+ import { useControllable as g } from "../../hooks/useControllable.mjs";
8
+ import { useId as _ } from "../../hooks/useId.mjs";
9
+ import { useMergedRefs as v } from "../../hooks/useMergedRefs.mjs";
10
+ import { useGridNavigation as y } from "./useGridNavigation.mjs";
11
+ import { focusRingInset as b, forcedColors as x } from "../../lib/styles.mjs";
12
+ import { endsTextSelection as S, isForeignEvent as ee } from "../../lib/events.mjs";
13
+ import { SELECTION_CELL_CLASSES as C, TableSelectionControl as te, TableSortButton as w, getTablePartKind as ne, markTablePart as re } from "./Table.shared.mjs";
14
+ import * as T from "react";
15
+ import { jsx as E, jsxs as ie } from "react/jsx-runtime";
14
16
  //#region src/components/table/DataGrid.tsx
15
- var S = "Select all rows", C = "Selection";
16
- function w(e, t = !1) {
17
- let n = new Set(e), r = /* @__PURE__ */ new Map(), i = 0, a = "none", o = t, s, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = (e) => {
17
+ var D = "Select all rows", O = "Selection";
18
+ function k(e, t = !1) {
19
+ let n = new Set(e), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0, o = 0, s = "none", c = t, l, u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = (e) => {
18
20
  for (let t of Array.from(e)) t();
19
- }, d = () => {
20
- if (s !== void 0) return s;
21
+ }, p = () => {
22
+ if (l !== void 0) return l;
21
23
  let e = null;
22
24
  for (let t of n) {
23
25
  if (r.has(t)) {
@@ -26,54 +28,67 @@ function w(e, t = !1) {
26
28
  }
27
29
  e ??= t;
28
30
  }
29
- return s = e, e;
30
- }, f = (e) => {
31
+ return l = e, e;
32
+ }, m = (e) => {
31
33
  if (n.size < 2 || !n.has(e)) return;
32
- let t = s;
33
- s = void 0, o && d() !== t && u(c);
34
- }, p = () => {
35
- let e = i === 0 ? "none" : i === r.size ? "all" : "some";
36
- e !== a && (a = e, u(l));
37
- }, m = (e) => (t) => (e.add(t), () => {
34
+ let t = l;
35
+ l = void 0, c && p() !== t && f(u);
36
+ }, h = () => {
37
+ let e = o === 0 ? "none" : o === a ? "all" : "some";
38
+ e !== s && (s = e, f(d));
39
+ }, g = (e) => r.has(e) && !i.has(e), _ = (e, t) => {
40
+ let r = g(e);
41
+ t();
42
+ let i = g(e);
43
+ if (r === i) return;
44
+ let s = i ? 1 : -1;
45
+ a += s, n.has(e) && (o += s);
46
+ }, v = (e, t, n) => {
47
+ let r = (e.get(t) ?? 0) + n;
48
+ r > 0 ? e.set(t, r) : e.delete(t);
49
+ }, y = (e) => (t) => (e.add(t), () => {
38
50
  e.delete(t);
39
51
  });
40
52
  return {
41
- subscribe: m(c),
42
- subscribeSelectAll: m(l),
53
+ subscribe: y(u),
54
+ subscribeSelectAll: y(d),
43
55
  register(e) {
44
- let t = r.get(e) ?? 0;
45
- r.set(e, t + 1), t === 0 && n.has(e) && (i += 1), p(), t === 0 && f(e);
46
- let a = !1;
56
+ let t = !r.has(e);
57
+ _(e, () => v(r, e, 1)), h(), t && m(e);
58
+ let n = !1;
59
+ return () => {
60
+ n || (n = !0, _(e, () => v(r, e, -1)), !r.has(e) && (h(), m(e)));
61
+ };
62
+ },
63
+ disable(e) {
64
+ _(e, () => v(i, e, 1)), h();
65
+ let t = !1;
47
66
  return () => {
48
- if (a) return;
49
- a = !0;
50
- let t = (r.get(e) ?? 0) - 1;
51
- if (t > 0) {
52
- r.set(e, t);
53
- return;
54
- }
55
- r.delete(e), n.has(e) && --i, p(), f(e);
67
+ t || (t = !0, _(e, () => v(i, e, -1)), h());
56
68
  };
57
69
  },
70
+ isDisabled(e) {
71
+ return i.has(e);
72
+ },
58
73
  setSelected(e) {
59
74
  let t = new Set(e);
60
75
  if (!(t.size === n.size && e.every((e) => n.has(e)))) {
61
- n = t, s = void 0, i = 0;
62
- for (let e of t) r.has(e) && (i += 1);
63
- u(c), p();
76
+ n = t, l = void 0, o = 0;
77
+ for (let e of t) g(e) && (o += 1);
78
+ f(u), h();
64
79
  }
65
80
  },
66
81
  setSingleMode(e) {
67
- o = e;
82
+ c = e;
68
83
  },
69
84
  isSelected(e, t = !1) {
70
- return t ? d() === e : n.has(e);
85
+ return t ? p() === e : n.has(e);
71
86
  },
72
87
  countRegistrations(e) {
73
88
  return r.get(e) ?? 0;
74
89
  },
75
90
  getSelectAllState() {
76
- return a;
91
+ return s;
77
92
  },
78
93
  getRegistered() {
79
94
  return Array.from(r.keys());
@@ -83,7 +98,7 @@ function w(e, t = !1) {
83
98
  }
84
99
  };
85
100
  }
86
- function T() {
101
+ function A() {
87
102
  let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = null, r = () => {
88
103
  let r = null, i = null;
89
104
  for (let [t, a] of e) {
@@ -114,245 +129,357 @@ function T() {
114
129
  refresh: r
115
130
  };
116
131
  }
117
- var E = y.createContext(null), D = y.createContext(null), O = y.createContext("body"), k = y.createContext(null), A = y.createContext(!0), j = {
132
+ var j = T.createContext(null), M = T.createContext(null), N = T.createContext("body"), P = T.createContext(null), F = T.createContext(!0), ae = T.createContext(null), oe = T.createContext(null), se = T.createContext(null), ce = {
118
133
  selectionMode: "none",
119
- store: w([]),
134
+ store: k([]),
120
135
  toggleRow: () => {},
121
136
  toggleAll: () => {},
122
137
  radioName: "",
123
- selectAllLabel: S,
124
- selectionHeaderLabel: C
125
- }, M = {
138
+ selectAllLabel: D,
139
+ selectionHeaderLabel: O,
140
+ selectOnRowClick: !1,
141
+ selectionAppearance: "brand",
142
+ subtleSelection: !1
143
+ }, I = {
126
144
  sort: null,
127
145
  requestSort: () => {}
146
+ }, L = {
147
+ selectionCellProps: void 0,
148
+ hasSelectionCell: !0,
149
+ rowId: void 0,
150
+ isSelected: !1,
151
+ disabled: !1,
152
+ invisible: !1,
153
+ ariaLabel: void 0,
154
+ ariaLabelledBy: void 0
128
155
  };
129
- function N(e) {
130
- return y.useContext(E) || (i(e, "DataGrid"), j);
156
+ function R(e) {
157
+ return T.useContext(j) || (i(e, "DataGrid"), ce);
131
158
  }
132
- function P(e) {
133
- return y.useContext(D) || (i(e, "DataGrid"), M);
159
+ function le(e) {
160
+ return T.useContext(se) || (i(e, "DataGrid.Row"), L);
134
161
  }
135
- var F = [];
136
- function I(e) {
162
+ function z(e) {
163
+ return T.useContext(M) || (i(e, "DataGrid"), I);
164
+ }
165
+ var ue = [];
166
+ function de(e) {
137
167
  return e === void 0 ? void 0 : Array.from(e);
138
168
  }
139
- function L(e, t) {
169
+ function fe(e, t) {
140
170
  return e.length === t.length && e.every((e, n) => e === t[n]);
141
171
  }
142
- function R({ key: e, node: t }) {
143
- return /* @__PURE__ */ b(y.Fragment, { children: t }, e);
172
+ function pe({ key: e, node: t }) {
173
+ return /* @__PURE__ */ E(T.Fragment, { children: t }, e);
174
+ }
175
+ function B(e) {
176
+ return a("DataGrid", e.columnId, e.id, "columns[].id", "columns[].columnId");
144
177
  }
145
- function re(e) {
178
+ function me(e) {
146
179
  s(`DataGrid:duplicate-rowId:${e}`, `DataGrid: several rows share the rowId "${e}". Row ids must be unique within a DataGrid; rows with the same rowId are selected and deselected together.`);
147
180
  }
148
- var z = "px-4 py-3 border-b border-border", B = "w-10 px-3 py-3 border-b border-border", V = "accent-primary cursor-pointer", H = (r) => {
149
- let { sort: i, defaultSort: l, sortColumn: u, defaultSortColumn: f, sortDirection: p, defaultSortDirection: m, onSortChange: _, selectionMode: v = "none", selectedItems: T, defaultSelectedItems: O, onSelectedItemsChange: k, selectedKeys: A, defaultSelectedKeys: j, onSelectionChange: M, labels: N, columns: P, containerProps: re, children: z, className: B, onKeyDown: V, onFocus: H, onBlur: ie, ref: ae, ...U } = r, W = i !== void 0 || l !== void 0, [oe, q] = y.useState(W);
150
- W && !oe && q(!0);
151
- let J = oe || W, Y = u !== void 0 || p !== void 0;
152
- u !== void 0 && o("DataGrid", "sortColumn", "sort"), p !== void 0 && o("DataGrid", "sortDirection", "sort"), f !== void 0 && o("DataGrid", "defaultSortColumn", "defaultSort"), m !== void 0 && o("DataGrid", "defaultSortDirection", "defaultSort");
153
- let se = W && (Y || f !== void 0 || m !== void 0);
154
- y.useEffect(() => {
155
- se && s("DataGrid:mixed-sort", "DataGrid: do not mix `sort`/`defaultSort` with the deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection`. `sort`/`defaultSort` win.");
156
- }, [se]), y.useEffect(() => {
157
- W || (u !== void 0 && p === void 0 ? s("DataGrid:sortColumn-without-sortDirection", "DataGrid: `sortColumn` is controlled but `sortDirection` is not (mixed control). The direction is kept internally and toggles on repeated clicks, as in 0.4. Pass `sort` (`{ columnId, direction }`) to control both.") : p !== void 0 && u === void 0 && s("DataGrid:sortDirection-without-sortColumn", "DataGrid: `sortDirection` is controlled but `sortColumn` is not (mixed control). The column is kept internally and follows the clicked header, as in 0.4. Pass `sort` (`{ columnId, direction }`) to control both."));
181
+ var V = "px-4 py-3 border-b border-border", H = {
182
+ brand: "hover:bg-subtle-hover data-[selected]:bg-selected transition-colors motion-reduce:transition-none",
183
+ neutral: "hover:bg-subtle-hover data-[selected]:bg-subtle-selected transition-colors motion-reduce:transition-none",
184
+ none: "hover:bg-subtle-hover transition-colors motion-reduce:transition-none"
185
+ };
186
+ function U(e) {
187
+ return ne(e) === "dataGridSelectionCell";
188
+ }
189
+ function W(r) {
190
+ let { items: i, getRowId: l, sort: u, defaultSort: f, sortColumn: p, defaultSortColumn: m, sortDirection: h, defaultSortDirection: b, onSortChange: x, selectionMode: S = "none", selectedItems: ee, defaultSelectedItems: C, onSelectedItemsChange: te, selectedKeys: w, defaultSelectedKeys: ne, onSelectionChange: re, labels: ie, selectOnRowClick: A = !1, selectionAppearance: N = "brand", subtleSelection: P = !1, columns: F, containerProps: ce, children: I, className: L, onKeyDown: R, onFocus: le, onBlur: z, ref: me, ...V } = r, H = i !== void 0, U = u !== void 0 || f !== void 0, W = !U && !H, [G, K] = T.useState(!W);
191
+ !W && !G && K(!0);
192
+ let he = G || !W, ge = p !== void 0 || h !== void 0;
193
+ p !== void 0 && o("DataGrid", "sortColumn", "sort"), h !== void 0 && o("DataGrid", "sortDirection", "sort"), m !== void 0 && o("DataGrid", "defaultSortColumn", "defaultSort"), b !== void 0 && o("DataGrid", "defaultSortDirection", "defaultSort");
194
+ let _e = ge || m !== void 0 || b !== void 0, ye = U && _e, X = !W && !U && _e;
195
+ T.useEffect(() => {
196
+ ye ? s("DataGrid:mixed-sort", "DataGrid: do not mix `sort`/`defaultSort` with the deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection`. `sort`/`defaultSort` win.") : X && s("DataGrid:items-deprecated-sort", "DataGrid: the deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection` do not apply to a grid with `items` and are ignored. Pass `sort` or `defaultSort`.");
197
+ }, [ye, X]), T.useEffect(() => {
198
+ W && (p !== void 0 && h === void 0 ? s("DataGrid:sortColumn-without-sortDirection", "DataGrid: `sortColumn` is controlled but `sortDirection` is not (mixed control). The direction is kept internally and toggles on repeated clicks, as in 0.4. Pass `sort` (`{ columnId, direction }`) to control both.") : h !== void 0 && p === void 0 && s("DataGrid:sortDirection-without-sortColumn", "DataGrid: `sortDirection` is controlled but `sortColumn` is not (mixed control). The column is kept internally and follows the clicked header, as in 0.4. Pass `sort` (`{ columnId, direction }`) to control both."));
158
199
  }, [
159
200
  W,
160
- u,
161
- p
201
+ p,
202
+ h
162
203
  ]);
163
- let [ce, le] = y.useState(() => ({
164
- column: f ?? "",
165
- direction: m ?? "ascending"
166
- })), ue = y.useMemo(() => {
167
- if (u === void 0 && p === void 0) return;
168
- let e = u ?? ce.column;
204
+ let [be, xe] = T.useState(() => ({
205
+ column: m ?? "",
206
+ direction: b ?? "ascending"
207
+ })), Se = T.useMemo(() => {
208
+ if (p === void 0 && h === void 0) return;
209
+ let e = p ?? be.column;
169
210
  return e === "" ? null : {
170
211
  columnId: e,
171
- direction: p ?? ce.direction
212
+ direction: h ?? be.direction
172
213
  };
173
214
  }, [
174
- u,
175
215
  p,
176
- ce
177
- ]), de = y.useMemo(() => f ? {
178
- columnId: f,
179
- direction: m ?? "ascending"
180
- } : null, [f, m]), [fe, pe] = h(W ? i : ue, l === void 0 ? de : l, (e) => {
181
- e && (W || le((t) => t.column === e.columnId && t.direction === e.direction ? t : {
216
+ h,
217
+ be
218
+ ]), Ce = T.useMemo(() => m ? {
219
+ columnId: m,
220
+ direction: b ?? "ascending"
221
+ } : null, [m, b]), we = W ? Se : u, Te = Ce;
222
+ f === void 0 ? X && (Te = null) : Te = f;
223
+ let Ee = T.useRef(void 0), [De, Oe] = g(we, Te, (e) => {
224
+ e && (W && xe((t) => t.column === e.columnId && t.direction === e.direction ? t : {
182
225
  column: e.columnId,
183
226
  direction: e.direction
184
- }), _ && (J ? _(e) : _(e.columnId, e.direction)));
185
- }), me = y.useCallback((e) => {
186
- pe((t) => ({
187
- columnId: e,
188
- direction: t?.columnId === e && t.direction === "ascending" ? "descending" : "ascending"
189
- }));
190
- }, [pe]), he = y.useMemo(() => ({
191
- sort: fe,
192
- requestSort: me
193
- }), [fe, me]);
194
- M !== void 0 && o("DataGrid", "onSelectionChange", "onSelectedItemsChange");
195
- let ge = y.useMemo(() => I(A), [A]), _e = y.useMemo(() => I(j), [j]), ve = a("DataGrid", T, ge, "selectedKeys", "selectedItems"), ye = a("DataGrid", O, _e, "defaultSelectedKeys", "defaultSelectedItems") ?? F, [X, Z] = h(ve, ye, (e) => {
196
- k?.([...e]), M?.(new Set(e));
197
- }), Q = v === "single", [$] = y.useState(() => w(X, Q));
198
- y.useLayoutEffect(() => {
199
- $.setSelected(X);
200
- }, [$, X]), y.useLayoutEffect(() => {
227
+ }), x && (he ? x(e, Ee.current) : x(e.columnId, e.direction)));
228
+ }), ke = T.useCallback((e, t) => {
229
+ Ee.current = { event: t };
230
+ try {
231
+ Oe((t) => ({
232
+ columnId: e,
233
+ direction: t?.columnId === e && t.direction === "ascending" ? "descending" : "ascending"
234
+ }));
235
+ } finally {
236
+ Ee.current = void 0;
237
+ }
238
+ }, [Oe]), Ae = T.useMemo(() => ({
239
+ sort: De,
240
+ requestSort: ke
241
+ }), [De, ke]);
242
+ re !== void 0 && o("DataGrid", "onSelectionChange", "onSelectedItemsChange");
243
+ let je = T.useMemo(() => de(w), [w]), Me = T.useMemo(() => de(ne), [ne]), Ne = a("DataGrid", ee, je, "selectedKeys", "selectedItems"), Pe = a("DataGrid", C, Me, "defaultSelectedKeys", "defaultSelectedItems") ?? ue, Fe = T.useRef(void 0), [Ie, Le] = g(Ne, Pe, (e) => {
244
+ te?.([...e], Fe.current), re?.(new Set(e));
245
+ }), Re = T.useCallback((e, t) => {
246
+ Fe.current = { event: e };
247
+ try {
248
+ Le(t);
249
+ } finally {
250
+ Fe.current = void 0;
251
+ }
252
+ }, [Le]), Q = S === "single", [$] = T.useState(() => k(Ie, Q));
253
+ T.useLayoutEffect(() => {
254
+ $.setSelected(Ie);
255
+ }, [$, Ie]), T.useLayoutEffect(() => {
201
256
  $.setSingleMode(Q);
202
257
  }, [$, Q]);
203
- let be = y.useCallback((e) => {
204
- Z((t) => {
258
+ let ze = T.useCallback((e, t) => {
259
+ Re(t, (t) => {
205
260
  let n = $.prune(t), r;
206
- return r = Q ? n[0] === e ? [] : [e] : n.includes(e) ? n.filter((t) => t !== e) : [...n, e], L(r, t) ? t : r;
261
+ return r = Q ? n[0] === e ? [] : [e] : n.includes(e) ? n.filter((t) => t !== e) : [...n, e], fe(r, t) ? t : r;
207
262
  });
208
263
  }, [
209
264
  Q,
210
- Z,
265
+ Re,
211
266
  $
212
- ]), xe = X.length;
213
- y.useEffect(() => {
214
- Q && xe > 1 && s("DataGrid:single-several-selected", `DataGrid: a single-selection grid (selectionMode "single") has ${xe} selected row ids; only the first one that is rendered is selected. Pass at most one id in \`selectedItems\`/\`defaultSelectedItems\`, or use selectionMode="multiple".`);
215
- }, [Q, xe]);
216
- let Se = y.useCallback(() => {
217
- Z((e) => {
218
- let t = $.prune(e), n = $.getRegistered(), r = n.length > 0 && n.every((e) => t.includes(e)) ? [] : n;
219
- return L(r, e) ? e : r;
267
+ ]), Be = Ie.length;
268
+ T.useEffect(() => {
269
+ Q && Be > 1 && s("DataGrid:single-several-selected", `DataGrid: a single-selection grid (selectionMode "single") has ${Be} selected row ids; only the first one that is rendered is selected. Pass at most one id in \`selectedItems\`/\`defaultSelectedItems\`, or use selectionMode="multiple".`);
270
+ }, [Q, Be]);
271
+ let Ve = T.useCallback((e) => {
272
+ Re(e, (e) => {
273
+ let t = new Set($.prune(e)), n = $.getRegistered(), r = n.filter((e) => !$.isDisabled(e)), i = r.length > 0 && r.every((e) => t.has(e)) ? n.filter((e) => $.isDisabled(e) && t.has(e)) : n.filter((e) => !$.isDisabled(e) || t.has(e));
274
+ return fe(i, e) ? e : i;
220
275
  });
221
- }, [Z, $]), Ce = ee("wave-datagrid-selection"), we = N?.selectAll ?? S, Te = N?.selectionHeader ?? C, Ee = y.useMemo(() => ({
222
- selectionMode: v,
276
+ }, [Re, $]), He = _("wave-datagrid-selection"), Ue = ie?.selectAll ?? D, We = ie?.selectionHeader ?? O, Ge = T.useMemo(() => ({
277
+ selectionMode: S,
223
278
  store: $,
224
- toggleRow: be,
225
- toggleAll: Se,
226
- radioName: Ce,
227
- selectAllLabel: we,
228
- selectionHeaderLabel: Te
279
+ toggleRow: ze,
280
+ toggleAll: Ve,
281
+ radioName: He,
282
+ selectAllLabel: Ue,
283
+ selectionHeaderLabel: We,
284
+ selectOnRowClick: A,
285
+ selectionAppearance: N,
286
+ subtleSelection: P
229
287
  }), [
230
- v,
288
+ S,
231
289
  $,
232
- be,
233
- Se,
234
- Ce,
235
- we,
236
- Te
237
- ]), { gridRef: De, gridProps: Oe } = te(), ke = g(ae, De), Ae = z, je = P ? t(z) : [];
238
- if (P && !je.some(({ node: e }) => n(e, G))) {
239
- let e = ({ node: e }) => n(e, "caption");
240
- Ae = /* @__PURE__ */ x(ne, { children: [
241
- je.filter(e).map(R),
242
- /* @__PURE__ */ b(G, { children: /* @__PURE__ */ b("tr", { children: P.map((e) => /* @__PURE__ */ b(K, {
243
- columnId: e.id,
244
- sortable: e.sortable,
245
- children: e.label
246
- }, e.id)) }) }),
247
- je.filter((t) => !e(t)).map(R)
248
- ] });
290
+ ze,
291
+ Ve,
292
+ He,
293
+ Ue,
294
+ We,
295
+ A,
296
+ N,
297
+ P
298
+ ]), { gridRef: Ke, gridProps: qe } = y(), Je = v(me, Ke), Ye = T.useMemo(() => {
299
+ if (i === void 0) return null;
300
+ let e = /* @__PURE__ */ new Set();
301
+ return i.map((t, n) => {
302
+ let r = l ? l(t) : String(n), i = e.has(r) ? `${r}\u0000${n}` : r;
303
+ return e.add(i), {
304
+ item: t,
305
+ index: n,
306
+ rowId: r,
307
+ key: i
308
+ };
309
+ });
310
+ }, [i, l]), Xe = De?.columnId, Ze = De?.direction, Qe = T.useMemo(() => {
311
+ if (H && Xe !== void 0 && F) return F.find((e) => B(e) === Xe)?.compare;
312
+ }, [
313
+ H,
314
+ Xe,
315
+ F
316
+ ]), $e = T.useMemo(() => {
317
+ if (Ye === null || !Qe) return Ye;
318
+ let e = Qe;
319
+ return Ye.slice().sort(Ze === "descending" ? (t, n) => -e(t.item, n.item) : (t, n) => e(t.item, n.item));
320
+ }, [
321
+ Ye,
322
+ Qe,
323
+ Ze
324
+ ]), et = T.useMemo(() => {
325
+ if (!F || !H) return null;
326
+ let e = F.map((e, t) => B(e) ?? t);
327
+ return (t) => /* @__PURE__ */ E(ve, { children: F.map((n, r) => /* @__PURE__ */ E(Z, { children: n.renderCell?.(t) }, e[r])) });
328
+ }, [F, H]), tt = T.useMemo(() => ({
329
+ rows: $e,
330
+ renderColumnsRow: et
331
+ }), [$e, et]), nt = F?.some((e) => e.columnId === void 0 && e.id === void 0) ?? !1;
332
+ T.useEffect(() => {
333
+ nt && s("DataGrid:column-without-columnId", "DataGrid: a column in `columns` has no `columnId` (nor the deprecated `id`), so its header cannot sort. Give every column a unique `columnId`.");
334
+ }, [nt]);
335
+ let rt = I, it = F ? t(I) : [], at = (e) => it.some(({ node: t }) => n(t, e)), ot = F && !at(q) ? /* @__PURE__ */ E(q, { children: /* @__PURE__ */ E("tr", { children: F.map((e, t) => {
336
+ let n = B(e);
337
+ return /* @__PURE__ */ E(J, {
338
+ columnId: n,
339
+ sortable: e.sortable ?? e.compare !== void 0,
340
+ children: e.renderHeaderCell ? e.renderHeaderCell() : e.label
341
+ }, n ?? t);
342
+ }) }) }, "wave-generated-header") : null, st = F && H && !at(Y) ? /* @__PURE__ */ E(Y, {}, "wave-generated-body") : null;
343
+ if (ot || st) {
344
+ let e = ({ node: e }) => n(e, "caption"), t = it.filter((t) => !e(t)), r = st ? t.findIndex(({ node: e }) => n(e, "tfoot")) : -1, i = r >= 0 ? r : t.length;
345
+ rt = [
346
+ ...it.filter(e).map(pe),
347
+ ot,
348
+ ...t.slice(0, i).map(pe),
349
+ st,
350
+ ...t.slice(i).map(pe)
351
+ ];
249
352
  }
250
- let { className: Me, "aria-label": Ne, "aria-labelledby": Pe, ...Fe } = re ?? {}, Ie = Fe.role !== void 0, Le = !Ie && (Ne !== void 0 || Pe !== void 0);
251
- return y.useEffect(() => {
252
- Le && s("DataGrid:container-name-without-role", "DataGrid: `containerProps[\"aria-label\"]`/`[\"aria-labelledby\"]` is ignored because the wrapper has no role. Name the grid itself (`aria-label` on DataGrid), or pass a `role` (e.g. \"region\") in `containerProps` too.");
253
- }, [Le]), /* @__PURE__ */ b(E.Provider, {
254
- value: Ee,
255
- children: /* @__PURE__ */ b(D.Provider, {
256
- value: he,
257
- children: /* @__PURE__ */ b("div", {
258
- ...Fe,
259
- "aria-label": Ie ? Ne : void 0,
260
- "aria-labelledby": Ie ? Pe : void 0,
261
- className: e(d.container, "overflow-x-auto rounded-md border border-border", Me),
262
- children: /* @__PURE__ */ b("table", {
263
- ref: ke,
264
- role: "grid",
265
- "aria-multiselectable": v === "multiple" || void 0,
266
- className: e(d.root, "w-full border-separate border-spacing-0", B),
267
- ...U,
268
- onKeyDown: c(V, Oe.onKeyDown),
269
- onFocus: c(H, Oe.onFocus, { checkDefaultPrevented: !1 }),
270
- onBlur: c(ie, Oe.onBlur, { checkDefaultPrevented: !1 }),
271
- children: Ae
353
+ let { className: ct, "aria-label": lt, "aria-labelledby": ut, ...dt } = ce ?? {}, ft = dt.role !== void 0, pt = !ft && (lt !== void 0 || ut !== void 0);
354
+ return T.useEffect(() => {
355
+ pt && s("DataGrid:container-name-without-role", "DataGrid: `containerProps[\"aria-label\"]`/`[\"aria-labelledby\"]` is ignored because the wrapper has no role. Name the grid itself (`aria-label` on DataGrid), or pass a `role` (e.g. \"region\") in `containerProps` too.");
356
+ }, [pt]), /* @__PURE__ */ E(j.Provider, {
357
+ value: Ge,
358
+ children: /* @__PURE__ */ E(M.Provider, {
359
+ value: Ae,
360
+ children: /* @__PURE__ */ E(ae.Provider, {
361
+ value: tt,
362
+ children: /* @__PURE__ */ E(se.Provider, {
363
+ value: null,
364
+ children: /* @__PURE__ */ E(oe.Provider, {
365
+ value: null,
366
+ children: /* @__PURE__ */ E("div", {
367
+ ...dt,
368
+ "aria-label": ft ? lt : void 0,
369
+ "aria-labelledby": ft ? ut : void 0,
370
+ className: e(d.container, "overflow-x-auto rounded-md border border-border", ct),
371
+ children: /* @__PURE__ */ E("table", {
372
+ ref: Je,
373
+ role: "grid",
374
+ "aria-multiselectable": S === "multiple" || void 0,
375
+ "data-selection-appearance": N,
376
+ "data-subtle-selection": P ? "" : void 0,
377
+ className: e(d.root, "w-full border-separate border-spacing-0", P && "group/grid", L),
378
+ ...V,
379
+ onKeyDown: c(R, qe.onKeyDown),
380
+ onFocus: c(le, qe.onFocus, { checkDefaultPrevented: !1 }),
381
+ onBlur: c(z, qe.onBlur, { checkDefaultPrevented: !1 }),
382
+ children: rt
383
+ })
384
+ })
385
+ })
272
386
  })
273
387
  })
274
388
  })
275
389
  });
276
- };
277
- H.displayName = "DataGrid";
278
- function ie({ selectionMode: t, ref: n }) {
279
- let { store: r, toggleAll: i, selectAllLabel: a, selectionHeaderLabel: o } = N("DataGrid.Header"), s = y.useSyncExternalStore(r.subscribeSelectAll, r.getSelectAllState, r.getSelectAllState), c = y.useRef(null), [l, u] = y.useState(0);
280
- return y.useLayoutEffect(() => {
281
- c.current && (c.current.indeterminate = s === "some");
282
- }, [s, l]), /* @__PURE__ */ b("th", {
283
- ref: n,
390
+ }
391
+ W.displayName = "DataGrid";
392
+ function G({ selectionMode: t, stableClassName: n, cellProps: r, ref: i }) {
393
+ let { store: a, toggleAll: o, selectAllLabel: s, selectionHeaderLabel: c, subtleSelection: l } = R("DataGrid.Header"), u = T.useSyncExternalStore(a.subscribeSelectAll, a.getSelectAllState, a.getSelectAllState), { className: d, disabled: f, invisible: m, controlRef: h, "aria-label": g, "aria-labelledby": _, "aria-describedby": v, ...y } = r ?? {}, x = !1;
394
+ return u === "all" ? x = !0 : u === "some" && (x = "mixed"), /* @__PURE__ */ E("th", {
284
395
  scope: "col",
396
+ ...y,
397
+ ref: i,
285
398
  "data-selection-cell": "",
286
- className: e(p.selectionCell, B, "text-start", _),
287
- children: t === "multiple" ? /* @__PURE__ */ b("input", {
288
- ref: c,
399
+ className: e(n, p.selectionCell, C, "text-start", b, d),
400
+ children: t === "multiple" ? /* @__PURE__ */ E(te, {
401
+ ref: h,
289
402
  type: "checkbox",
290
- "aria-label": a,
291
- checked: s === "all",
292
- onChange: () => {
293
- u((e) => e + 1), i();
294
- },
295
- className: e(p.selectAllCheckbox, V, _)
296
- }) : /* @__PURE__ */ b("span", {
403
+ "aria-label": g ?? (_ === void 0 ? s : void 0),
404
+ "aria-labelledby": _,
405
+ "aria-describedby": v,
406
+ checked: x,
407
+ disabled: f,
408
+ invisible: m,
409
+ subtle: l,
410
+ reveal: "grid",
411
+ onChange: (e) => o(e.nativeEvent),
412
+ className: p.selectAllCheckbox
413
+ }) : /* @__PURE__ */ E("span", {
297
414
  className: "sr-only",
298
- children: o
415
+ children: c
299
416
  })
300
417
  });
301
418
  }
302
- var ae = {
419
+ var K = {
303
420
  subscribe: () => () => {},
304
421
  register: () => () => {},
305
422
  getFirst: () => null,
306
423
  refresh: () => {}
307
424
  };
308
- function U({ selectionMode: t, initialFirst: n }) {
309
- let r = y.useContext(k) ?? ae, [i] = y.useState(() => ({})), a = y.useRef(null), o = y.useCallback(() => {
310
- let e = r.getFirst();
311
- return e === null ? n : e === i;
425
+ function he({ selectionMode: t, initialFirst: n, stableClassName: r, cellProps: i, ref: a }) {
426
+ let o = T.useContext(P) ?? K, [s] = T.useState(() => ({})), c = T.useRef(null), l = v(c, a), u = T.useCallback(() => {
427
+ let e = o.getFirst();
428
+ return e === null ? n : e === s;
312
429
  }, [
313
- r,
314
- i,
430
+ o,
431
+ s,
315
432
  n
316
- ]), s = y.useCallback(() => n, [n]), c = y.useSyncExternalStore(r.subscribe, o, s);
317
- return y.useLayoutEffect(() => r.register(i, () => a.current), [r, i]), c ? /* @__PURE__ */ b(ie, {
318
- ref: a,
319
- selectionMode: t
320
- }) : /* @__PURE__ */ b("td", {
321
- ref: a,
433
+ ]), d = T.useCallback(() => n, [n]), f = T.useSyncExternalStore(o.subscribe, u, d);
434
+ if (T.useLayoutEffect(() => o.register(s, () => c.current), [o, s]), f) return /* @__PURE__ */ E(G, {
435
+ ref: l,
436
+ selectionMode: t,
437
+ stableClassName: r,
438
+ cellProps: i
439
+ });
440
+ let { className: m, disabled: h, invisible: g, controlRef: _, "aria-label": y, "aria-labelledby": x, "aria-describedby": S, ...ee } = i ?? {};
441
+ return /* @__PURE__ */ E("td", {
442
+ ...ee,
443
+ ref: l,
322
444
  "data-selection-cell": "",
323
- className: e(p.selectionCell, B, _)
445
+ className: e(r, p.selectionCell, C, b, m)
324
446
  });
325
447
  }
326
- function W(e, t) {
327
- let r = !0, i = (e) => y.Children.map(e, (e) => {
328
- if (n(e, y.Fragment)) return y.cloneElement(e, void 0, i(e.props.children));
329
- if (!y.isValidElement(e)) return e;
330
- let a = r;
331
- if (r = !1, n(e, "tr")) {
332
- let n = t === "none" ? null : /* @__PURE__ */ b(U, {
333
- selectionMode: t,
334
- initialFirst: a
448
+ function ge(e, r) {
449
+ let i = !0, a = (e) => T.Children.map(e, (e) => {
450
+ if (n(e, T.Fragment)) return T.cloneElement(e, void 0, a(e.props.children));
451
+ if (!T.isValidElement(e)) return e;
452
+ let o = i;
453
+ if (i = !1, n(e, "tr")) {
454
+ let n = e.props.children, i = r === "none" || t(n).some(({ node: e }) => U(e)) ? null : /* @__PURE__ */ E(he, {
455
+ selectionMode: r,
456
+ initialFirst: o
335
457
  });
336
- return y.cloneElement(e, void 0, n, e.props.children);
458
+ return T.cloneElement(e, void 0, i, /* @__PURE__ */ E(F.Provider, {
459
+ value: o,
460
+ children: n
461
+ }));
337
462
  }
338
- return /* @__PURE__ */ b(A.Provider, {
339
- value: a,
463
+ return /* @__PURE__ */ E(F.Provider, {
464
+ value: o,
340
465
  children: e
341
466
  });
342
467
  });
343
- return i(e);
468
+ return a(e);
344
469
  }
345
- var G = ({ children: t, className: n, ref: i, ...a }) => {
346
- let { selectionMode: o } = N("DataGrid.Header"), [c, l] = y.useState(null), u = g(i, l), [d] = y.useState(T), f = W(t, o);
347
- return y.useLayoutEffect(() => {
470
+ var q = ({ children: t, className: n, ref: i, ...a }) => {
471
+ let { selectionMode: o } = R("DataGrid.Header"), [c, l] = T.useState(null), u = v(i, l), [d] = T.useState(A), f = ge(t, o);
472
+ return T.useLayoutEffect(() => {
348
473
  d.refresh();
349
- }), y.useEffect(() => {
350
- r && c && o !== "none" && Array.from(c.rows).some((e) => e.cells.length > 0 && !e.cells[0].hasAttribute("data-selection-cell")) && s("DataGrid.Header:missing-selection-cell", "DataGrid.Header: a header row has no selection column header cell, so the header has one column fewer than the selectable rows. Render header rows as `<tr>` children of DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that another component renders.");
351
- }), /* @__PURE__ */ b(O.Provider, {
474
+ }), T.useEffect(() => {
475
+ if (!r || !c || o === "none") return;
476
+ let e = Array.from(c.rows, (e) => Array.from(e.cells).filter((e) => e.hasAttribute("data-selection-cell")));
477
+ e.some((e, t) => e.length === 0 && c.rows[t].cells.length > 0) && s("DataGrid.Header:missing-selection-cell", "DataGrid.Header: a header row has no selection column header cell, so the header has one column fewer than the selectable rows. Render header rows as `<tr>` children of DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that another component renders."), e.some((e) => e.length > 1) && s("DataGrid.Header:several-selection-cells", "DataGrid.Header: a header row has more than one selection cell. A DataGrid.SelectionCell rendered by another component is not seen, so the row also gets the automatic cell: render DataGrid.SelectionCell as a child of the row (a Fragment is fine).");
478
+ }), /* @__PURE__ */ E(N.Provider, {
352
479
  value: "header",
353
- children: /* @__PURE__ */ b(k.Provider, {
480
+ children: /* @__PURE__ */ E(P.Provider, {
354
481
  value: d,
355
- children: /* @__PURE__ */ b("thead", {
482
+ children: /* @__PURE__ */ E("thead", {
356
483
  ref: u,
357
484
  className: e(p.root, "bg-card", n),
358
485
  ...a,
@@ -361,130 +488,232 @@ var G = ({ children: t, className: n, ref: i, ...a }) => {
361
488
  })
362
489
  });
363
490
  };
364
- G.displayName = "DataGridHeader";
365
- var oe = (t) => /* @__PURE__ */ b("svg", {
366
- className: e(f.sortIcon, "h-3 w-3 shrink-0"),
367
- viewBox: "0 0 12 12",
368
- fill: "currentColor",
369
- "aria-hidden": "true",
370
- focusable: "false",
371
- children: t === "ascending" ? /* @__PURE__ */ b("path", { d: "M6 2L10 8H2L6 2Z" }) : /* @__PURE__ */ b("path", { d: "M6 10L2 4H10L6 10Z" })
372
- }), K = ({ columnId: t, sortable: n = !1, children: r, className: i, onClick: a, ref: o, ...l }) => {
373
- let { sort: u, requestSort: d } = P("DataGrid.HeaderCell"), p = n && t ? t : void 0, m = p !== void 0 && u?.columnId === p ? u.direction : null, h = (e) => {
491
+ q.displayName = "DataGridHeader";
492
+ var J = ({ columnId: t, sortable: n = !1, sortIcon: r, children: i, className: a, onClick: o, ref: l, ...u }) => {
493
+ let { sort: d, requestSort: p } = z("DataGrid.HeaderCell"), m = n && t ? t : void 0, h = m !== void 0 && d?.columnId === m ? d.direction : null, g = (e) => {
374
494
  let t = e.currentTarget.firstElementChild;
375
- p !== void 0 && t?.localName === "button" && t.contains(e.target) && d(p);
495
+ m !== void 0 && t?.localName === "button" && t.contains(e.target) && p(m, e.nativeEvent);
376
496
  };
377
- return y.useEffect(() => {
497
+ return T.useEffect(() => {
378
498
  n && !t && s("DataGrid.HeaderCell:sortable-without-columnId", "DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.");
379
- }, [n, t]), /* @__PURE__ */ b("th", {
380
- ref: o,
499
+ }, [n, t]), /* @__PURE__ */ E("th", {
500
+ ref: l,
381
501
  scope: "col",
382
- "aria-sort": p === void 0 ? void 0 : m ?? "none",
383
- className: e(f.root, z, "text-start align-middle font-semibold text-caption-1 uppercase tracking-wider", _, p !== void 0 && "p-0 hover:bg-subtle-hover", i),
384
- ...l,
385
- onClick: p === void 0 ? a : c(a, h),
386
- children: p === void 0 ? /* @__PURE__ */ b("span", {
502
+ "aria-sort": m === void 0 ? void 0 : h ?? "none",
503
+ className: e(f.root, V, "text-start align-middle font-semibold text-caption-1 uppercase tracking-wider", b, m !== void 0 && "p-0 hover:bg-subtle-hover", a),
504
+ ...u,
505
+ onClick: m === void 0 ? o : c(o, g),
506
+ children: m === void 0 ? /* @__PURE__ */ E("span", {
387
507
  className: "inline-flex items-center gap-1",
388
- children: r
389
- }) : /* @__PURE__ */ x("button", {
390
- type: "button",
391
- className: e(f.button, "inline-flex w-full cursor-pointer select-none items-center gap-1 border-0 bg-transparent px-4 py-3 text-start text-inherit [font:inherit] uppercase tracking-wider", _),
392
- children: [r, m && oe(m)]
508
+ children: i
509
+ }) : /* @__PURE__ */ E(w, {
510
+ component: "DataGrid.HeaderCell",
511
+ direction: h,
512
+ sortIcon: r,
513
+ className: f.button,
514
+ iconClassName: f.sortIcon,
515
+ children: i
393
516
  })
394
517
  });
395
518
  };
396
- K.displayName = "DataGridHeaderCell";
397
- var q = ({ children: t, className: n, ref: r, ...i }) => /* @__PURE__ */ b(O.Provider, {
398
- value: "body",
399
- children: /* @__PURE__ */ b("tbody", {
400
- ref: r,
401
- className: e(l.root, n),
402
- ...i,
403
- children: t
404
- })
405
- });
406
- q.displayName = "DataGridBody";
407
- var J = ({ rowId: i, selectionLabel: a, children: o, className: l, onKeyDown: u, ref: d, ...f }) => {
408
- let { selectionMode: p, store: h, toggleRow: g, radioName: te } = N("DataGrid.Row"), ne = y.useContext(O), S = y.useContext(A), C = ne === "header", w = p !== "none" && !C, T = ee("wave-datagrid-row-label"), E = p === "single", D = y.useCallback(() => i !== void 0 && h.isSelected(i, E), [
409
- i,
410
- h,
411
- E
412
- ]), k = y.useSyncExternalStore(h.subscribe, D, D);
413
- y.useLayoutEffect(() => {
414
- if (i === void 0 || C) return;
415
- let e = h.register(i);
416
- return r && h.countRegistrations(i) > 1 && re(i), e;
519
+ J.displayName = "DataGridHeaderCell";
520
+ var _e = T.memo(function({ item: e, index: t, rowId: n, render: r }) {
521
+ return /* @__PURE__ */ E(oe.Provider, {
522
+ value: n,
523
+ children: r(e, t)
524
+ });
525
+ }), Y = ({ children: t, className: n, ref: r, ...i }) => {
526
+ let a = T.useContext(ae), o = a?.rows ?? null, c = typeof t == "function" && o === null;
527
+ T.useEffect(() => {
528
+ c && s("DataGrid.Body:render-without-items", "DataGrid.Body: a render function child renders one row per item of the DataGrid's `items`, which is not set, so the body has no rows.");
529
+ }, [c]);
530
+ let u = (e) => e && o?.map((t) => /* @__PURE__ */ E(_e, {
531
+ item: t.item,
532
+ index: t.index,
533
+ rowId: t.rowId,
534
+ render: e
535
+ }, t.key)), d;
536
+ return d = typeof t == "function" ? u(t) : t === void 0 ? u(a?.renderColumnsRow ?? null) : t, /* @__PURE__ */ E(N.Provider, {
537
+ value: "body",
538
+ children: /* @__PURE__ */ E("tbody", {
539
+ ref: r,
540
+ className: e(l.root, n),
541
+ ...i,
542
+ children: d
543
+ })
544
+ });
545
+ };
546
+ Y.displayName = "DataGridBody";
547
+ var ve = ({ rowId: i, selectionLabel: a, selectionCellProps: o, children: l, className: u, onClick: d, onKeyDown: f, ref: p, ...h }) => {
548
+ let { selectionMode: g, store: v, toggleRow: y, selectOnRowClick: b, selectionAppearance: C } = R("DataGrid.Row"), te = T.useContext(oe), w = i ?? te ?? void 0, ne = T.useContext(N), re = T.useContext(F), D = ne === "header", O = g !== "none" && !D, k = _("wave-datagrid-row-label"), A = t(l), j;
549
+ for (let { node: e } of A) if (U(e)) {
550
+ j = e.props;
551
+ break;
552
+ }
553
+ let M = j !== void 0, P = j?.disabled ?? o?.disabled ?? !1, ae = j?.invisible ?? o?.invisible ?? !1, ce = j?.["aria-labelledby"], I = j?.["aria-label"] ?? o?.["aria-label"] ?? a, L = g === "single", le = T.useCallback(() => w !== void 0 && v.isSelected(w, L), [
554
+ w,
555
+ v,
556
+ L
557
+ ]), z = T.useSyncExternalStore(v.subscribe, le, le);
558
+ T.useLayoutEffect(() => {
559
+ if (w === void 0 || D) return;
560
+ let e = v.register(w);
561
+ return r && v.countRegistrations(w) > 1 && me(w), e;
417
562
  }, [
418
- h,
419
- i,
420
- C
421
- ]), y.useEffect(() => {
422
- w && i === void 0 && s("DataGrid.Row:missing-rowId", "DataGrid.Row: a selectable grid needs a `rowId` on every row; this row has no selection control.");
423
- }, [w, i]);
424
- let j = w && i !== void 0 && a === void 0, M = (e) => {
425
- if (!w || i === void 0 || e.key !== " ") return;
563
+ v,
564
+ w,
565
+ D
566
+ ]), T.useLayoutEffect(() => {
567
+ if (w !== void 0 && !D && P) return v.disable(w);
568
+ }, [
569
+ v,
570
+ w,
571
+ D,
572
+ P
573
+ ]), T.useEffect(() => {
574
+ O && w === void 0 && s("DataGrid.Row:missing-rowId", "DataGrid.Row: a selectable grid needs a `rowId` on every row; this row has no selection control.");
575
+ }, [O, w]);
576
+ let ue = O && w !== void 0 && I === void 0 && ce === void 0, de = (e) => {
577
+ if (!O || w === void 0 || e.key !== " ") return;
426
578
  let t = e.target;
427
- (t === e.currentTarget || t.parentElement === e.currentTarget) && (e.preventDefault(), g(i));
428
- }, P = t(o), F, I = -1;
429
- if (j) {
430
- let e = P.findIndex(({ node: e }) => n(e, Y, "td", "th"));
579
+ (t === e.currentTarget || t.parentElement === e.currentTarget) && (e.preventDefault(), P || y(w, e.nativeEvent));
580
+ }, fe = (e) => {
581
+ if (!b || !O || w === void 0 || P) return;
582
+ let t = e.currentTarget;
583
+ ee(e, { isOwnPart: (e) => e.parentElement === t }) || S(e) || y(w, e.nativeEvent);
584
+ }, B, V = -1;
585
+ if (ue) {
586
+ let e = A.findIndex(({ node: e }) => n(e, Z, "td", "th"));
431
587
  if (e >= 0) {
432
- let t = P[e].node;
433
- F = t.props.id ?? T, t.props.id === void 0 && (I = e);
588
+ let t = A[e].node;
589
+ B = t.props.id ?? k, t.props.id === void 0 && (V = e);
434
590
  }
435
591
  }
436
- let L = P.map(({ key: e, node: t }, n) => R({
592
+ let W = A.map(({ key: e, node: t }, n) => pe({
437
593
  key: e,
438
- node: n === I ? y.cloneElement(t, { id: T }) : t
439
- })), z = j && F === void 0;
440
- y.useEffect(() => {
441
- z && s("DataGrid.Row:selection-label", "DataGrid.Row: no child is a `DataGrid.Cell`, `<td>` or `<th>` element, so the row selection control is named \"Select row\". Pass `selectionLabel` (a cell rendered by another component is not seen).");
442
- }, [z]);
443
- let H = null;
444
- return C && p !== "none" ? H = /* @__PURE__ */ b(U, {
445
- selectionMode: p,
446
- initialFirst: S
447
- }) : w && (H = /* @__PURE__ */ b("td", {
594
+ node: n === V ? T.cloneElement(t, { id: k }) : t
595
+ })), G = ue && B === void 0;
596
+ T.useEffect(() => {
597
+ G && s("DataGrid.Row:selection-label", "DataGrid.Row: no child is a `DataGrid.Cell`, `<td>` or `<th>` element, so the row selection control is named \"Select row\". Pass `selectionLabel` (a cell rendered by another component is not seen).");
598
+ }, [G]);
599
+ let K = ce ?? B, ge = I ?? (K === void 0 ? "Select row" : void 0), q = T.useMemo(() => ({
600
+ selectionCellProps: o,
601
+ hasSelectionCell: M,
602
+ rowId: O ? w : void 0,
603
+ isSelected: z,
604
+ disabled: P,
605
+ invisible: ae,
606
+ ariaLabel: ge,
607
+ ariaLabelledBy: K
608
+ }), [
609
+ o,
610
+ M,
611
+ O,
612
+ w,
613
+ z,
614
+ P,
615
+ ae,
616
+ ge,
617
+ K
618
+ ]), J = null;
619
+ return !M && D && g !== "none" ? J = /* @__PURE__ */ E(he, {
620
+ selectionMode: g,
621
+ initialFirst: re,
622
+ cellProps: o
623
+ }) : !M && O && (J = /* @__PURE__ */ E(ye, { component: "DataGrid.Row" })), /* @__PURE__ */ E(se.Provider, {
624
+ value: q,
625
+ children: /* @__PURE__ */ ie("tr", {
626
+ ref: p,
627
+ className: e(m.root, "group/table-row", !D && H[C], O && z && x.selectedContainer, u),
628
+ "aria-selected": O ? z : void 0,
629
+ "data-selected": O && z ? "" : void 0,
630
+ ...h,
631
+ onClick: c(d, fe),
632
+ onKeyDown: c(f, de),
633
+ children: [J, W]
634
+ })
635
+ });
636
+ };
637
+ ve.displayName = "DataGridRow";
638
+ function ye({ component: t, stableClassName: n, className: r, controlRef: i, "aria-describedby": a, ref: o, ...s }) {
639
+ let { selectionMode: c, toggleRow: l, radioName: u, subtleSelection: d } = R(t), f = le(t), { rowId: p } = f, h = c === "single";
640
+ return /* @__PURE__ */ E("td", {
448
641
  role: "gridcell",
642
+ ...s,
643
+ ref: o,
449
644
  "data-selection-cell": "",
450
- className: e(m.selectionCell, B, _),
451
- children: i !== void 0 && /* @__PURE__ */ b("input", {
452
- type: p === "multiple" ? "checkbox" : "radio",
453
- name: p === "single" ? te : void 0,
454
- form: p === "single" ? "" : void 0,
455
- checked: k,
456
- onChange: () => g(i),
457
- "aria-label": a ?? (F ? void 0 : "Select row"),
458
- "aria-labelledby": a === void 0 ? F : void 0,
459
- className: e(m.selectionControl, V, "focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring")
645
+ className: e(n, m.selectionCell, C, b, f.selectionCellProps?.className, r),
646
+ children: p !== void 0 && c !== "none" && /* @__PURE__ */ E(te, {
647
+ ref: i,
648
+ type: h ? "radio" : "checkbox",
649
+ name: h ? u : void 0,
650
+ form: h ? "" : void 0,
651
+ checked: f.isSelected,
652
+ disabled: f.disabled,
653
+ invisible: f.invisible,
654
+ subtle: d,
655
+ onChange: (e) => l(p, e.nativeEvent),
656
+ "aria-label": f.ariaLabel,
657
+ "aria-labelledby": f.ariaLabelledBy,
658
+ "aria-describedby": a,
659
+ className: m.selectionControl
460
660
  })
461
- })), /* @__PURE__ */ x("tr", {
462
- ref: d,
463
- className: e(m.root, !C && "hover:bg-subtle-hover data-[selected]:bg-selected transition-colors motion-reduce:transition-none", w && k && v.selectedContainer, l),
464
- "aria-selected": w ? k : void 0,
465
- "data-selected": w && k ? "" : void 0,
466
- ...f,
467
- onKeyDown: c(u, M),
468
- children: [H, L]
661
+ });
662
+ }
663
+ var X = ({ disabled: t, invisible: n, className: r, "aria-label": i, "aria-labelledby": a, "aria-describedby": o, controlRef: c, ref: l, ...u }) => {
664
+ let { selectionMode: d } = R("DataGrid.SelectionCell"), f = T.useContext(N), p = T.useContext(F), m = T.useContext(se), g = d === "none", _ = !g && m !== null && !m.hasSelectionCell;
665
+ if (T.useEffect(() => {
666
+ g && s("DataGrid.SelectionCell:not-selectable", "DataGrid.SelectionCell: the grid has no row selection (`selectionMode` is \"none\"), so the cell renders nothing. Set `selectionMode` on the DataGrid, or remove the cell.");
667
+ }, [g]), T.useEffect(() => {
668
+ _ && s("DataGrid.SelectionCell:unseen", "DataGrid.SelectionCell: rendered by another component, so its DataGrid.Row did not see it and added its own selection cell. Render DataGrid.SelectionCell as a child of DataGrid.Row (a Fragment is fine).");
669
+ }, [_]), g) return null;
670
+ if (f === "header") {
671
+ let s = m?.selectionCellProps;
672
+ return /* @__PURE__ */ E(he, {
673
+ ref: l,
674
+ selectionMode: d,
675
+ initialFirst: p,
676
+ stableClassName: h.root,
677
+ cellProps: {
678
+ ...u,
679
+ className: e(s?.className, r),
680
+ disabled: t ?? s?.disabled,
681
+ invisible: n ?? s?.invisible,
682
+ "aria-label": i ?? s?.["aria-label"],
683
+ "aria-labelledby": a,
684
+ "aria-describedby": o,
685
+ controlRef: c
686
+ }
687
+ });
688
+ }
689
+ return /* @__PURE__ */ E(ye, {
690
+ ...u,
691
+ ref: l,
692
+ component: "DataGrid.SelectionCell",
693
+ stableClassName: h.root,
694
+ className: r,
695
+ controlRef: c,
696
+ "aria-describedby": o
469
697
  });
470
698
  };
471
- J.displayName = "DataGridRow";
472
- var Y = ({ children: t, className: n, ref: r, ...i }) => /* @__PURE__ */ b("td", {
699
+ X.displayName = "DataGridSelectionCell", re(X, "dataGridSelectionCell");
700
+ var Z = ({ children: t, className: n, ref: r, ...i }) => /* @__PURE__ */ E("td", {
473
701
  ref: r,
474
702
  role: "gridcell",
475
- className: e(u.root, z, "text-body-1", _, n),
703
+ className: e(u.root, V, "relative text-body-1", b, n),
476
704
  ...i,
477
705
  children: t
478
706
  });
479
- Y.displayName = "DataGridCell";
480
- var se = /* @__PURE__ */ Object.assign(H, {
481
- Header: G,
482
- HeaderCell: K,
483
- Body: q,
484
- Row: J,
485
- Cell: Y
707
+ Z.displayName = "DataGridCell";
708
+ var be = /* @__PURE__ */ Object.assign(W, {
709
+ Header: q,
710
+ HeaderCell: J,
711
+ Body: Y,
712
+ Row: ve,
713
+ Cell: Z,
714
+ SelectionCell: X
486
715
  });
487
716
  //#endregion
488
- export { se as DataGrid, q as DataGridBody, Y as DataGridCell, G as DataGridHeader, K as DataGridHeaderCell, J as DataGridRow, w as createSelectionStore };
717
+ export { be as DataGrid, Y as DataGridBody, Z as DataGridCell, q as DataGridHeader, J as DataGridHeaderCell, ve as DataGridRow, X as DataGridSelectionCell, k as createSelectionStore };
489
718
 
490
719
  //# sourceMappingURL=DataGrid.mjs.map