@mortenbrudvik/waveui 0.14.1 → 0.16.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 (265) hide show
  1. package/README.md +413 -53
  2. package/dist/components/data-display/InfoButton.cjs +1 -1
  3. package/dist/components/data-display/InfoButton.cjs.map +1 -1
  4. package/dist/components/data-display/InfoButton.mjs +90 -82
  5. package/dist/components/data-display/InfoButton.mjs.map +1 -1
  6. package/dist/components/data-display/InfoLabel.cjs +1 -1
  7. package/dist/components/data-display/InfoLabel.cjs.map +1 -1
  8. package/dist/components/data-display/InfoLabel.mjs +19 -18
  9. package/dist/components/data-display/InfoLabel.mjs.map +1 -1
  10. package/dist/components/data-display/List.cjs +1 -1
  11. package/dist/components/data-display/List.cjs.map +1 -1
  12. package/dist/components/data-display/List.mjs +405 -219
  13. package/dist/components/data-display/List.mjs.map +1 -1
  14. package/dist/components/data-display/List.registry.cjs +1 -1
  15. package/dist/components/data-display/List.registry.cjs.map +1 -1
  16. package/dist/components/data-display/List.registry.mjs +12 -6
  17. package/dist/components/data-display/List.registry.mjs.map +1 -1
  18. package/dist/components/feedback/MessageBarGroup.cjs +2 -0
  19. package/dist/components/feedback/MessageBarGroup.cjs.map +1 -0
  20. package/dist/components/feedback/MessageBarGroup.mjs +63 -0
  21. package/dist/components/feedback/MessageBarGroup.mjs.map +1 -0
  22. package/dist/components/feedback/ProgressBar.cjs +1 -1
  23. package/dist/components/feedback/ProgressBar.cjs.map +1 -1
  24. package/dist/components/feedback/ProgressBar.mjs +41 -39
  25. package/dist/components/feedback/ProgressBar.mjs.map +1 -1
  26. package/dist/components/feedback/Toaster.cjs +1 -1
  27. package/dist/components/feedback/Toaster.cjs.map +1 -1
  28. package/dist/components/feedback/Toaster.mjs +222 -216
  29. package/dist/components/feedback/Toaster.mjs.map +1 -1
  30. package/dist/components/input/Combobox.cjs +1 -1
  31. package/dist/components/input/Combobox.cjs.map +1 -1
  32. package/dist/components/input/Combobox.mjs +163 -148
  33. package/dist/components/input/Combobox.mjs.map +1 -1
  34. package/dist/components/input/Dropdown.cjs +1 -1
  35. package/dist/components/input/Dropdown.cjs.map +1 -1
  36. package/dist/components/input/Dropdown.mjs +132 -117
  37. package/dist/components/input/Dropdown.mjs.map +1 -1
  38. package/dist/components/input/Listbox.cjs +1 -1
  39. package/dist/components/input/Listbox.cjs.map +1 -1
  40. package/dist/components/input/Listbox.mjs +90 -78
  41. package/dist/components/input/Listbox.mjs.map +1 -1
  42. package/dist/components/input/Option.cjs +1 -1
  43. package/dist/components/input/Option.cjs.map +1 -1
  44. package/dist/components/input/Option.data.cjs +2 -0
  45. package/dist/components/input/Option.data.cjs.map +1 -0
  46. package/dist/components/input/Option.data.mjs +114 -0
  47. package/dist/components/input/Option.data.mjs.map +1 -0
  48. package/dist/components/input/Option.mjs +21 -17
  49. package/dist/components/input/Option.mjs.map +1 -1
  50. package/dist/components/layout/Accordion.cjs +1 -1
  51. package/dist/components/layout/Accordion.cjs.map +1 -1
  52. package/dist/components/layout/Accordion.mjs +124 -109
  53. package/dist/components/layout/Accordion.mjs.map +1 -1
  54. package/dist/components/layout/Carousel.cjs +1 -1
  55. package/dist/components/layout/Carousel.cjs.map +1 -1
  56. package/dist/components/layout/Carousel.mjs +207 -193
  57. package/dist/components/layout/Carousel.mjs.map +1 -1
  58. package/dist/components/layout/FlatTree.cjs +2 -0
  59. package/dist/components/layout/FlatTree.cjs.map +1 -0
  60. package/dist/components/layout/FlatTree.context.cjs +2 -0
  61. package/dist/components/layout/FlatTree.context.cjs.map +1 -0
  62. package/dist/components/layout/FlatTree.context.mjs +20 -0
  63. package/dist/components/layout/FlatTree.context.mjs.map +1 -0
  64. package/dist/components/layout/FlatTree.item.cjs +2 -0
  65. package/dist/components/layout/FlatTree.item.cjs.map +1 -0
  66. package/dist/components/layout/FlatTree.item.mjs +90 -0
  67. package/dist/components/layout/FlatTree.item.mjs.map +1 -0
  68. package/dist/components/layout/FlatTree.mjs +276 -0
  69. package/dist/components/layout/FlatTree.mjs.map +1 -0
  70. package/dist/components/layout/TabList.cjs +1 -1
  71. package/dist/components/layout/TabList.cjs.map +1 -1
  72. package/dist/components/layout/TabList.mjs +149 -108
  73. package/dist/components/layout/TabList.mjs.map +1 -1
  74. package/dist/components/layout/Tree.cjs.map +1 -1
  75. package/dist/components/layout/Tree.context.cjs +1 -1
  76. package/dist/components/layout/Tree.context.cjs.map +1 -1
  77. package/dist/components/layout/Tree.context.mjs +2 -1
  78. package/dist/components/layout/Tree.context.mjs.map +1 -1
  79. package/dist/components/layout/Tree.core.cjs +1 -1
  80. package/dist/components/layout/Tree.core.cjs.map +1 -1
  81. package/dist/components/layout/Tree.core.mjs +162 -148
  82. package/dist/components/layout/Tree.core.mjs.map +1 -1
  83. package/dist/components/layout/Tree.mjs.map +1 -1
  84. package/dist/components/layout/Tree.selection.cjs +1 -1
  85. package/dist/components/layout/Tree.selection.cjs.map +1 -1
  86. package/dist/components/layout/Tree.selection.mjs +11 -57
  87. package/dist/components/layout/Tree.selection.mjs.map +1 -1
  88. package/dist/components/layout/useFlatTree.cjs +2 -0
  89. package/dist/components/layout/useFlatTree.cjs.map +1 -0
  90. package/dist/components/layout/useFlatTree.mjs +83 -0
  91. package/dist/components/layout/useFlatTree.mjs.map +1 -0
  92. package/dist/components/navigation/Menu.popover.cjs +1 -1
  93. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  94. package/dist/components/navigation/Menu.popover.mjs +154 -168
  95. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  96. package/dist/components/navigation/Nav.cjs +1 -1
  97. package/dist/components/navigation/Nav.cjs.map +1 -1
  98. package/dist/components/navigation/Nav.mjs +156 -136
  99. package/dist/components/navigation/Nav.mjs.map +1 -1
  100. package/dist/components/navigation/NavDrawer.cjs +1 -1
  101. package/dist/components/navigation/NavDrawer.cjs.map +1 -1
  102. package/dist/components/navigation/NavDrawer.mjs +48 -45
  103. package/dist/components/navigation/NavDrawer.mjs.map +1 -1
  104. package/dist/components/overlays/Dialog.cjs +1 -1
  105. package/dist/components/overlays/Dialog.cjs.map +1 -1
  106. package/dist/components/overlays/Dialog.mjs +128 -122
  107. package/dist/components/overlays/Dialog.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 +12 -12
  111. package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
  112. package/dist/components/overlays/Drawer.cjs.map +1 -1
  113. package/dist/components/overlays/Drawer.mjs.map +1 -1
  114. package/dist/components/overlays/Drawer.panel.cjs +1 -1
  115. package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
  116. package/dist/components/overlays/Drawer.panel.mjs +97 -81
  117. package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
  118. package/dist/components/overlays/Drawer.root.cjs +1 -1
  119. package/dist/components/overlays/Drawer.root.cjs.map +1 -1
  120. package/dist/components/overlays/Drawer.root.mjs +34 -31
  121. package/dist/components/overlays/Drawer.root.mjs.map +1 -1
  122. package/dist/components/overlays/Popover.cjs +1 -1
  123. package/dist/components/overlays/Popover.cjs.map +1 -1
  124. package/dist/components/overlays/Popover.mjs +231 -216
  125. package/dist/components/overlays/Popover.mjs.map +1 -1
  126. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  127. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  128. package/dist/components/overlays/TeachingPopover.parts.cjs +1 -1
  129. package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -1
  130. package/dist/components/overlays/TeachingPopover.parts.mjs +199 -177
  131. package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -1
  132. package/dist/components/overlays/TeachingPopover.root.cjs +1 -1
  133. package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -1
  134. package/dist/components/overlays/TeachingPopover.root.mjs +93 -92
  135. package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -1
  136. package/dist/components/overlays/Tooltip.cjs +1 -1
  137. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  138. package/dist/components/overlays/Tooltip.mjs +66 -61
  139. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  140. package/dist/components/provider/WaveProvider.cjs +1 -1
  141. package/dist/components/provider/WaveProvider.cjs.map +1 -1
  142. package/dist/components/provider/WaveProvider.mjs +26 -23
  143. package/dist/components/provider/WaveProvider.mjs.map +1 -1
  144. package/dist/components/table/DataGrid.cjs +1 -1
  145. package/dist/components/table/DataGrid.cjs.map +1 -1
  146. package/dist/components/table/DataGrid.context.cjs +2 -0
  147. package/dist/components/table/DataGrid.context.cjs.map +1 -0
  148. package/dist/components/table/DataGrid.context.mjs +74 -0
  149. package/dist/components/table/DataGrid.context.mjs.map +1 -0
  150. package/dist/components/table/DataGrid.header.cjs +2 -0
  151. package/dist/components/table/DataGrid.header.cjs.map +1 -0
  152. package/dist/components/table/DataGrid.header.mjs +168 -0
  153. package/dist/components/table/DataGrid.header.mjs.map +1 -0
  154. package/dist/components/table/DataGrid.mjs +488 -591
  155. package/dist/components/table/DataGrid.mjs.map +1 -1
  156. package/dist/components/table/DataGrid.sizing.cjs +2 -0
  157. package/dist/components/table/DataGrid.sizing.cjs.map +1 -0
  158. package/dist/components/table/DataGrid.sizing.mjs +187 -0
  159. package/dist/components/table/DataGrid.sizing.mjs.map +1 -0
  160. package/dist/components/table/DataGrid.store.cjs +2 -0
  161. package/dist/components/table/DataGrid.store.cjs.map +1 -0
  162. package/dist/components/table/DataGrid.store.mjs +108 -0
  163. package/dist/components/table/DataGrid.store.mjs.map +1 -0
  164. package/dist/components/table/DataGrid.window.cjs +2 -0
  165. package/dist/components/table/DataGrid.window.cjs.map +1 -0
  166. package/dist/components/table/DataGrid.window.mjs +165 -0
  167. package/dist/components/table/DataGrid.window.mjs.map +1 -0
  168. package/dist/components/table/Table.cjs +1 -1
  169. package/dist/components/table/Table.cjs.map +1 -1
  170. package/dist/components/table/Table.mjs +74 -72
  171. package/dist/components/table/Table.mjs.map +1 -1
  172. package/dist/components/table/Table.resize.cjs +2 -0
  173. package/dist/components/table/Table.resize.cjs.map +1 -0
  174. package/dist/components/table/Table.resize.mjs +98 -0
  175. package/dist/components/table/Table.resize.mjs.map +1 -0
  176. package/dist/components/table/useGridNavigation.cjs +1 -1
  177. package/dist/components/table/useGridNavigation.cjs.map +1 -1
  178. package/dist/components/table/useGridNavigation.mjs +343 -140
  179. package/dist/components/table/useGridNavigation.mjs.map +1 -1
  180. package/dist/components/table/useTableColumnSizing.cjs +2 -0
  181. package/dist/components/table/useTableColumnSizing.cjs.map +1 -0
  182. package/dist/components/table/useTableColumnSizing.mjs +76 -0
  183. package/dist/components/table/useTableColumnSizing.mjs.map +1 -0
  184. package/dist/components/table/useTableFeatures.cjs +2 -0
  185. package/dist/components/table/useTableFeatures.cjs.map +1 -0
  186. package/dist/components/table/useTableFeatures.mjs +110 -0
  187. package/dist/components/table/useTableFeatures.mjs.map +1 -0
  188. package/dist/components/table/useTableSelection.cjs +2 -0
  189. package/dist/components/table/useTableSelection.cjs.map +1 -0
  190. package/dist/components/table/useTableSelection.mjs +39 -0
  191. package/dist/components/table/useTableSelection.mjs.map +1 -0
  192. package/dist/components/table/useTableSort.cjs +2 -0
  193. package/dist/components/table/useTableSort.cjs.map +1 -0
  194. package/dist/components/table/useTableSort.mjs +58 -0
  195. package/dist/components/table/useTableSort.mjs.map +1 -0
  196. package/dist/hooks/useActiveDescendant.cjs +1 -1
  197. package/dist/hooks/useActiveDescendant.cjs.map +1 -1
  198. package/dist/hooks/useActiveDescendant.mjs +33 -25
  199. package/dist/hooks/useActiveDescendant.mjs.map +1 -1
  200. package/dist/hooks/useCollapsePresence.cjs +2 -0
  201. package/dist/hooks/useCollapsePresence.cjs.map +1 -0
  202. package/dist/hooks/useCollapsePresence.mjs +21 -0
  203. package/dist/hooks/useCollapsePresence.mjs.map +1 -0
  204. package/dist/hooks/useFocusBeforeClose.cjs +2 -0
  205. package/dist/hooks/useFocusBeforeClose.cjs.map +1 -0
  206. package/dist/hooks/useFocusBeforeClose.mjs +33 -0
  207. package/dist/hooks/useFocusBeforeClose.mjs.map +1 -0
  208. package/dist/hooks/useListbox.cjs +1 -1
  209. package/dist/hooks/useListbox.cjs.map +1 -1
  210. package/dist/hooks/useListbox.mjs +140 -130
  211. package/dist/hooks/useListbox.mjs.map +1 -1
  212. package/dist/hooks/useMotion.cjs +2 -0
  213. package/dist/hooks/useMotion.cjs.map +1 -0
  214. package/dist/hooks/useMotion.mjs +14 -0
  215. package/dist/hooks/useMotion.mjs.map +1 -0
  216. package/dist/hooks/usePresenceGroup.cjs +2 -0
  217. package/dist/hooks/usePresenceGroup.cjs.map +1 -0
  218. package/dist/hooks/usePresenceGroup.mjs +68 -0
  219. package/dist/hooks/usePresenceGroup.mjs.map +1 -0
  220. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  221. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  222. package/dist/hooks/useRovingTabIndex.mjs +1 -1
  223. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  224. package/dist/hooks/useSelection.cjs +2 -0
  225. package/dist/hooks/useSelection.cjs.map +1 -0
  226. package/dist/hooks/useSelection.mjs +57 -0
  227. package/dist/hooks/useSelection.mjs.map +1 -0
  228. package/dist/hooks/useVirtualWindow.cjs +2 -0
  229. package/dist/hooks/useVirtualWindow.cjs.map +1 -0
  230. package/dist/hooks/useVirtualWindow.mjs +102 -0
  231. package/dist/hooks/useVirtualWindow.mjs.map +1 -0
  232. package/dist/index.cjs +1 -1
  233. package/dist/index.d.cts +2249 -179
  234. package/dist/index.d.ts +2249 -179
  235. package/dist/index.mjs +147 -135
  236. package/dist/lib/classNames.cjs +1 -1
  237. package/dist/lib/classNames.cjs.map +1 -1
  238. package/dist/lib/classNames.mjs +125 -95
  239. package/dist/lib/classNames.mjs.map +1 -1
  240. package/dist/lib/columnSizing.cjs +2 -0
  241. package/dist/lib/columnSizing.cjs.map +1 -0
  242. package/dist/lib/columnSizing.mjs +27 -0
  243. package/dist/lib/columnSizing.mjs.map +1 -0
  244. package/dist/lib/flatTree.cjs +2 -0
  245. package/dist/lib/flatTree.cjs.map +1 -0
  246. package/dist/lib/flatTree.mjs +118 -0
  247. package/dist/lib/flatTree.mjs.map +1 -0
  248. package/dist/lib/motion.cjs +2 -0
  249. package/dist/lib/motion.cjs.map +1 -0
  250. package/dist/lib/motion.mjs +43 -0
  251. package/dist/lib/motion.mjs.map +1 -0
  252. package/dist/lib/selection.cjs +2 -0
  253. package/dist/lib/selection.cjs.map +1 -0
  254. package/dist/lib/selection.mjs +28 -0
  255. package/dist/lib/selection.mjs.map +1 -0
  256. package/dist/lib/treeCascade.cjs +2 -0
  257. package/dist/lib/treeCascade.cjs.map +1 -0
  258. package/dist/lib/treeCascade.mjs +52 -0
  259. package/dist/lib/treeCascade.mjs.map +1 -0
  260. package/dist/lib/virtual.cjs +2 -0
  261. package/dist/lib/virtual.cjs.map +1 -0
  262. package/dist/lib/virtual.mjs +54 -0
  263. package/dist/lib/virtual.mjs.map +1 -0
  264. package/dist/styles.css +1 -1
  265. package/package.json +2 -1
@@ -1,304 +1,121 @@
1
1
  "use client";
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
3
  import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
4
- import { isDev as r, reportMissingContext as i, resolveDeprecatedProp as a, warnDeprecated as o, warnOnce as s } from "../../lib/dev.mjs";
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, 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";
4
+ import { isDev as r, resolveDeprecatedProp as i, warnDeprecated as a, warnOnce as o } from "../../lib/dev.mjs";
5
+ import { composeEventHandlers as s } from "../../lib/composeEventHandlers.mjs";
6
+ import { dataGridBodyClassNames as c, dataGridCellClassNames as l, dataGridClassNames as u, dataGridRowClassNames as d, dataGridSelectionCellClassNames as f } from "../../lib/classNames.mjs";
7
+ import { useControllable as p } from "../../hooks/useControllable.mjs";
8
+ import { useId as ee } from "../../hooks/useId.mjs";
9
+ import { useMergedRefs as m } from "../../hooks/useMergedRefs.mjs";
10
+ import { clearIds as h, selectAllIds as g, summarizeSelection as _, toggleId as v } from "../../lib/selection.mjs";
11
+ import { useGridNavigation as te } from "./useGridNavigation.mjs";
12
+ import { focusRingInset as y, forcedColors as b } from "../../lib/styles.mjs";
13
+ import { endsTextSelection as ne, isForeignEvent as x } from "../../lib/events.mjs";
14
+ import { SELECTION_CELL_CLASSES as re, TableSelectionControl as S, markTablePart as C } from "./Table.shared.mjs";
15
+ import { DataGridFixedLayoutContext as w, DataGridResizeContext as ie, useDataGridColumnSizing as ae } from "./DataGrid.sizing.mjs";
16
+ import { DataGridWindowContext as T, DataGridWindowRowContext as E, getWindowNavigationModel as D, renderWindowRows as oe, useDataGridWindow as se } from "./DataGrid.window.mjs";
17
+ import { createSelectionStore as O } from "./DataGrid.store.mjs";
18
+ import { DataGridContext as ce, DataGridHeaderRowHintContext as le, DataGridItemSelectionDisabledContext as ue, DataGridItemsContext as de, DataGridRowContext as fe, DataGridRowIdContext as pe, DataGridSectionContext as k, DataGridSortContext as me, useDataGridContext as A, useDataGridRowContext as j } from "./DataGrid.context.mjs";
19
+ import { DataGridHeader as M, DataGridHeaderCell as he, DataGridSelectionHeaderSlot as ge, cellBase as N, isSelectionCellElement as P } from "./DataGrid.header.mjs";
20
+ import * as F from "react";
21
+ import { jsx as I, jsxs as _e } from "react/jsx-runtime";
16
22
  //#region src/components/table/DataGrid.tsx
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) => {
20
- for (let t of Array.from(e)) t();
21
- }, p = () => {
22
- if (l !== void 0) return l;
23
- let e = null;
24
- for (let t of n) {
25
- if (r.has(t)) {
26
- e = t;
27
- break;
28
- }
29
- e ??= t;
30
- }
31
- return l = e, e;
32
- }, m = (e) => {
33
- if (n.size < 2 || !n.has(e)) return;
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), () => {
50
- e.delete(t);
51
- });
52
- return {
53
- subscribe: y(u),
54
- subscribeSelectAll: y(d),
55
- register(e) {
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;
66
- return () => {
67
- t || (t = !0, _(e, () => v(i, e, -1)), h());
68
- };
69
- },
70
- isDisabled(e) {
71
- return i.has(e);
72
- },
73
- setSelected(e) {
74
- let t = new Set(e);
75
- if (!(t.size === n.size && e.every((e) => n.has(e)))) {
76
- n = t, l = void 0, o = 0;
77
- for (let e of t) g(e) && (o += 1);
78
- f(u), h();
79
- }
80
- },
81
- setSingleMode(e) {
82
- c = e;
83
- },
84
- isSelected(e, t = !1) {
85
- return t ? p() === e : n.has(e);
86
- },
87
- countRegistrations(e) {
88
- return r.get(e) ?? 0;
89
- },
90
- getSelectAllState() {
91
- return s;
92
- },
93
- getRegistered() {
94
- return Array.from(r.keys());
95
- },
96
- prune(e) {
97
- return e.filter((e) => r.has(e));
98
- }
99
- };
100
- }
101
- function A() {
102
- let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = null, r = () => {
103
- let r = null, i = null;
104
- for (let [t, a] of e) {
105
- let o = a();
106
- if (!o) {
107
- if (n !== null && e.has(n)) return;
108
- continue;
109
- }
110
- (!i || o.compareDocumentPosition(i) & Node.DOCUMENT_POSITION_FOLLOWING) && (r = t, i = o);
111
- }
112
- if (r === null && (r = e.keys().next().value ?? null), r !== n) {
113
- n = r;
114
- for (let e of Array.from(t)) e();
115
- }
116
- };
117
- return {
118
- subscribe(e) {
119
- return t.add(e), () => {
120
- t.delete(e);
121
- };
122
- },
123
- register(t, n) {
124
- return e.set(t, n), r(), () => {
125
- e.delete(t), r();
126
- };
127
- },
128
- getFirst: () => n,
129
- refresh: r
130
- };
131
- }
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 = {
133
- selectionMode: "none",
134
- store: k([]),
135
- toggleRow: () => {},
136
- toggleAll: () => {},
137
- radioName: "",
138
- selectAllLabel: D,
139
- selectionHeaderLabel: O,
140
- selectOnRowClick: !1,
141
- selectionAppearance: "brand",
142
- subtleSelection: !1
143
- }, I = {
144
- sort: null,
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
155
- };
156
- function R(e) {
157
- return T.useContext(j) || (i(e, "DataGrid"), ce);
158
- }
159
- function le(e) {
160
- return T.useContext(se) || (i(e, "DataGrid.Row"), L);
161
- }
162
- function z(e) {
163
- return T.useContext(M) || (i(e, "DataGrid"), I);
164
- }
165
- var ue = [];
166
- function de(e) {
23
+ var ve = [], ye = [];
24
+ function L(e) {
167
25
  return e === void 0 ? void 0 : Array.from(e);
168
26
  }
169
- function fe(e, t) {
27
+ function be(e, t) {
170
28
  return e.length === t.length && e.every((e, n) => e === t[n]);
171
29
  }
172
- function pe({ key: e, node: t }) {
173
- return /* @__PURE__ */ E(T.Fragment, { children: t }, e);
30
+ function xe(e, t, n) {
31
+ if (n.length === 0) return e;
32
+ let r = new Set(e), i = _(r, n).all ? h(r, n) : g(r, n), a = new Set(t);
33
+ return [...Array.from(i).filter((e) => !a.has(e)), ...t.filter((e) => i.has(e))];
34
+ }
35
+ function Se({ key: e, node: t }) {
36
+ return /* @__PURE__ */ I(F.Fragment, { children: t }, e);
174
37
  }
175
- function B(e) {
176
- return a("DataGrid", e.columnId, e.id, "columns[].id", "columns[].columnId");
38
+ function Ce(e) {
39
+ return t(e).filter(({ node: e }) => F.isValidElement(e)).length;
177
40
  }
178
- function me(e) {
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.`);
41
+ function R(e) {
42
+ return i("DataGrid", e.columnId, e.id, "columns[].id", "columns[].columnId");
180
43
  }
181
- var V = "px-4 py-3 border-b border-border", H = {
44
+ function we(e) {
45
+ o(`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.`);
46
+ }
47
+ var Te = {
182
48
  brand: "hover:bg-subtle-hover data-[selected]:bg-selected transition-colors motion-reduce:transition-none",
183
49
  neutral: "hover:bg-subtle-hover data-[selected]:bg-subtle-selected transition-colors motion-reduce:transition-none",
184
50
  none: "hover:bg-subtle-hover transition-colors motion-reduce:transition-none"
185
51
  };
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."));
52
+ function z(r) {
53
+ let { items: c, getRowId: l, isSelectionDisabled: d, sort: f, defaultSort: h, sortColumn: g, defaultSortColumn: _, sortDirection: y, defaultSortDirection: b, onSortChange: ne, selectionMode: x = "none", selectedItems: re, defaultSelectedItems: S, onSelectedItemsChange: C, selectedKeys: oe, defaultSelectedKeys: le, onSelectionChange: k, labels: A, selectOnRowClick: j = !1, selectionAppearance: ge = "brand", subtleSelection: N = !1, columns: P, resizableColumns: _e = !1, columnSizingOptions: we, columnWidths: Te, defaultColumnWidths: z, onColumnWidthsChange: B, virtualWindow: U, containerProps: W, children: G, className: De, style: Oe, onKeyDown: ke, onFocus: Ae, onBlur: je, onPointerDownCapture: Me, ref: Ne, ...Pe } = r, K = c !== void 0, Fe = f !== void 0 || h !== void 0, q = !Fe && !K, [Ie, Le] = F.useState(!q);
54
+ !q && !Ie && Le(!0);
55
+ let Re = Ie || !q, ze = g !== void 0 || y !== void 0;
56
+ g !== void 0 && a("DataGrid", "sortColumn", "sort"), y !== void 0 && a("DataGrid", "sortDirection", "sort"), _ !== void 0 && a("DataGrid", "defaultSortColumn", "defaultSort"), b !== void 0 && a("DataGrid", "defaultSortDirection", "defaultSort");
57
+ let Be = ze || _ !== void 0 || b !== void 0, Ve = Fe && Be, He = !q && !Fe && Be;
58
+ F.useEffect(() => {
59
+ Ve ? o("DataGrid:mixed-sort", "DataGrid: do not mix `sort`/`defaultSort` with the deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection`. `sort`/`defaultSort` win.") : He && o("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`.");
60
+ }, [Ve, He]), F.useEffect(() => {
61
+ q && (g !== void 0 && y === void 0 ? o("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.") : y !== void 0 && g === void 0 && o("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."));
199
62
  }, [
200
- W,
201
- p,
202
- h
63
+ q,
64
+ g,
65
+ y
203
66
  ]);
204
- let [be, xe] = T.useState(() => ({
205
- column: m ?? "",
67
+ let [Ue, We] = F.useState(() => ({
68
+ column: _ ?? "",
206
69
  direction: b ?? "ascending"
207
- })), Se = T.useMemo(() => {
208
- if (p === void 0 && h === void 0) return;
209
- let e = p ?? be.column;
70
+ })), Ge = F.useMemo(() => {
71
+ if (g === void 0 && y === void 0) return;
72
+ let e = g ?? Ue.column;
210
73
  return e === "" ? null : {
211
74
  columnId: e,
212
- direction: h ?? be.direction
75
+ direction: y ?? Ue.direction
213
76
  };
214
77
  }, [
215
- p,
216
- h,
217
- be
218
- ]), Ce = T.useMemo(() => m ? {
219
- columnId: m,
78
+ g,
79
+ y,
80
+ Ue
81
+ ]), Ke = F.useMemo(() => _ ? {
82
+ columnId: _,
220
83
  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 : {
84
+ } : null, [_, b]), qe = q ? Ge : f, Je = Ke;
85
+ h === void 0 ? He && (Je = null) : Je = h;
86
+ let Ye = F.useRef(void 0), [Xe, Ze] = p(qe, Je, (e) => {
87
+ e && (q && We((t) => t.column === e.columnId && t.direction === e.direction ? t : {
225
88
  column: e.columnId,
226
89
  direction: e.direction
227
- }), x && (he ? x(e, Ee.current) : x(e.columnId, e.direction)));
228
- }), ke = T.useCallback((e, t) => {
229
- Ee.current = { event: t };
90
+ }), ne && (Re ? ne(e, Ye.current) : ne(e.columnId, e.direction)));
91
+ }), Qe = F.useCallback((e, t) => {
92
+ Ye.current = { event: t };
230
93
  try {
231
- Oe((t) => ({
94
+ Ze((t) => ({
232
95
  columnId: e,
233
96
  direction: t?.columnId === e && t.direction === "ascending" ? "descending" : "ascending"
234
97
  }));
235
98
  } finally {
236
- Ee.current = void 0;
99
+ Ye.current = void 0;
237
100
  }
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 };
101
+ }, [Ze]), $e = F.useMemo(() => ({
102
+ sort: Xe,
103
+ requestSort: Qe
104
+ }), [Xe, Qe]);
105
+ k !== void 0 && a("DataGrid", "onSelectionChange", "onSelectedItemsChange");
106
+ let et = F.useMemo(() => L(oe), [oe]), tt = F.useMemo(() => L(le), [le]), nt = i("DataGrid", re, et, "selectedKeys", "selectedItems"), rt = i("DataGrid", S, tt, "defaultSelectedKeys", "defaultSelectedItems") ?? ve, it = F.useRef(void 0), [at, ot] = p(nt, rt, (e) => {
107
+ C?.([...e], it.current), k?.(new Set(e));
108
+ }), st = F.useCallback((e, t) => {
109
+ it.current = { event: e };
247
110
  try {
248
- Le(t);
111
+ ot(t);
249
112
  } finally {
250
- Fe.current = void 0;
113
+ it.current = void 0;
251
114
  }
252
- }, [Le]), Q = S === "single", [$] = T.useState(() => k(Ie, Q));
253
- T.useLayoutEffect(() => {
254
- $.setSelected(Ie);
255
- }, [$, Ie]), T.useLayoutEffect(() => {
256
- $.setSingleMode(Q);
257
- }, [$, Q]);
258
- let ze = T.useCallback((e, t) => {
259
- Re(t, (t) => {
260
- let n = $.prune(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;
262
- });
263
- }, [
264
- Q,
265
- Re,
266
- $
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;
275
- });
276
- }, [Re, $]), He = _("wave-datagrid-selection"), Ue = ie?.selectAll ?? D, We = ie?.selectionHeader ?? O, Ge = T.useMemo(() => ({
277
- selectionMode: S,
278
- store: $,
279
- toggleRow: ze,
280
- toggleAll: Ve,
281
- radioName: He,
282
- selectAllLabel: Ue,
283
- selectionHeaderLabel: We,
284
- selectOnRowClick: A,
285
- selectionAppearance: N,
286
- subtleSelection: P
287
- }), [
288
- S,
289
- $,
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;
115
+ }, [ot]), J = F.useMemo(() => {
116
+ if (c === void 0) return null;
300
117
  let e = /* @__PURE__ */ new Set();
301
- return i.map((t, n) => {
118
+ return c.map((t, n) => {
302
119
  let r = l ? l(t) : String(n), i = e.has(r) ? `${r}\u0000${n}` : r;
303
120
  return e.add(i), {
304
121
  item: t,
@@ -307,79 +124,221 @@ function W(r) {
307
124
  key: i
308
125
  };
309
126
  });
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;
127
+ }, [c, l]), ct = x !== "none", lt = F.useMemo(() => J === null || !d || !ct ? null : J.map((e) => d(e.item, e.index)), [
128
+ J,
129
+ d,
130
+ ct
131
+ ]), ut = F.useMemo(() => {
132
+ if (J === null || !ct) return null;
133
+ let e = /* @__PURE__ */ new Set();
134
+ if (lt) for (let t of J) lt[t.index] && e.add(t.rowId);
135
+ return {
136
+ ids: J.map((e) => e.rowId),
137
+ disabled: e
138
+ };
139
+ }, [
140
+ J,
141
+ lt,
142
+ ct
143
+ ]), Y = x === "single", [X] = F.useState(() => O(at, Y, ut));
144
+ F.useLayoutEffect(() => {
145
+ X.setUniverse(ut);
146
+ }, [X, ut]), F.useLayoutEffect(() => {
147
+ X.setSelected(at);
148
+ }, [X, at]), F.useLayoutEffect(() => {
149
+ X.setSingleMode(Y);
150
+ }, [X, Y]);
151
+ let dt = F.useCallback((e, t) => {
152
+ st(t, (t) => {
153
+ let n;
154
+ if (K) {
155
+ let r = new Set(Y ? t.slice(0, 1) : t);
156
+ n = Array.from(v(r, e, Y ? "single" : "multiple", { allowEmpty: !0 }));
157
+ } else {
158
+ let r = X.prune(t);
159
+ n = Y ? r[0] === e ? [] : [e] : r.includes(e) ? r.filter((t) => t !== e) : [...r, e];
160
+ }
161
+ return be(n, t) ? t : n;
162
+ });
312
163
  }, [
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));
164
+ K,
165
+ Y,
166
+ st,
167
+ X
168
+ ]), ft = at.length;
169
+ F.useEffect(() => {
170
+ Y && ft > 1 && o("DataGrid:single-several-selected", `DataGrid: a single-selection grid (selectionMode "single") has ${ft} selected row ids; only ${K ? "the first one" : "the first one that is rendered"} is selected. Pass at most one id in \`selectedItems\`/\`defaultSelectedItems\`, or use selectionMode="multiple".`);
320
171
  }, [
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, {
172
+ Y,
173
+ ft,
174
+ K
175
+ ]);
176
+ let pt = F.useCallback((e) => {
177
+ st(e, (e) => {
178
+ let t;
179
+ if (K) t = xe(e, X.getUniverseIds(), X.getSelectableIds());
180
+ else {
181
+ let n = new Set(X.prune(e)), r = X.getRegistered(), i = r.filter((e) => !X.isDisabled(e));
182
+ t = i.length > 0 && i.every((e) => n.has(e)) ? r.filter((e) => X.isDisabled(e) && n.has(e)) : r.filter((e) => !X.isDisabled(e) || n.has(e));
183
+ }
184
+ return be(t, e) ? e : t;
185
+ });
186
+ }, [
187
+ K,
188
+ st,
189
+ X
190
+ ]), mt = ee("wave-datagrid-selection"), ht = A?.selectAll ?? "Select all rows", gt = A?.selectionHeader ?? "Selection", _t = F.useMemo(() => ({
191
+ selectionMode: x,
192
+ store: X,
193
+ toggleRow: dt,
194
+ toggleAll: pt,
195
+ radioName: mt,
196
+ selectAllLabel: ht,
197
+ selectionHeaderLabel: gt,
198
+ selectOnRowClick: j,
199
+ selectionAppearance: ge,
200
+ subtleSelection: N
201
+ }), [
202
+ x,
203
+ X,
204
+ dt,
205
+ pt,
206
+ mt,
207
+ ht,
208
+ gt,
209
+ j,
210
+ ge,
211
+ N
212
+ ]), vt = Xe?.columnId, yt = Xe?.direction, bt = F.useMemo(() => {
213
+ if (K && vt !== void 0 && P) return P.find((e) => R(e) === vt)?.compare;
214
+ }, [
215
+ K,
216
+ vt,
217
+ P
218
+ ]), xt = F.useMemo(() => {
219
+ if (J === null || !bt) return J;
220
+ let e = bt;
221
+ return J.slice().sort(yt === "descending" ? (t, n) => -e(t.item, n.item) : (t, n) => e(t.item, n.item));
222
+ }, [
223
+ J,
224
+ bt,
225
+ yt
226
+ ]), St = F.useMemo(() => {
227
+ if (!P || !K) return null;
228
+ let e = P.map((e, t) => R(e) ?? t);
229
+ return (t) => /* @__PURE__ */ I(H, { children: P.map((n, r) => /* @__PURE__ */ I(Ee, { children: n.renderCell?.(t) }, e[r])) });
230
+ }, [P, K]), Ct = F.useMemo(() => ({
231
+ rows: xt,
232
+ renderColumnsRow: St,
233
+ selectionDisabled: lt
234
+ }), [
235
+ xt,
236
+ St,
237
+ lt
238
+ ]), wt = P?.some((e) => e.columnId === void 0 && e.id === void 0) ?? !1;
239
+ F.useEffect(() => {
240
+ wt && o("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`.");
241
+ }, [wt]);
242
+ let Tt = P ? t(G) : [], Et = (e) => Tt.find(({ node: t }) => n(t, e))?.node, Dt = Et(M), Ot = Et(V), kt = n(Ot, V) ? Ot.props.children : void 0, At = U !== void 0 && K && P !== void 0 && (kt === void 0 || typeof kt == "function") ? U : null, Z = At !== null, jt = n(Dt, M) ? Ce(Dt.props.children) : 1, Mt = c?.length ?? 0, { gridRef: Nt, gridProps: Pt, activeRowIndex: Ft, pendingRowIndex: It } = te({ model: D(At, Mt, jt) }), Q = se({
243
+ virtualWindow: At,
244
+ ignored: U !== void 0 && !Z,
245
+ rows: xt,
246
+ headerRowCount: jt,
247
+ columnCount: (P?.length ?? 0) + +!!ct,
248
+ activeRowIndex: Ft,
249
+ pendingRowIndex: It
250
+ }), Lt = m(Ne, Nt, Q.tableRef), Rt = (e) => {
251
+ Pt.onFocus(e), Q.onFocus(e);
252
+ }, zt = (e) => {
253
+ Pt.onBlur(e), Q.onBlur(e);
254
+ }, Bt = _e || we !== void 0 || Te !== void 0 || z !== void 0, Vt = Bt && !(P && K);
255
+ F.useEffect(() => {
256
+ Vt && o("DataGrid:resizable-columns-require-columns", "DataGrid: `resizableColumns`, `columnSizingOptions`, `columnWidths` and `defaultColumnWidths` need the `columns` prop together with `items`, and are ignored without them. Render the grid from `items` and `columns`.");
257
+ }, [Vt]);
258
+ let Ht = Bt && !Vt || Z, Ut = F.useMemo(() => Ht && P ? P.map(R) : ye, [Ht, P]), $ = ae({
259
+ enabled: Ht,
260
+ resizable: _e,
261
+ columnIds: Ut,
262
+ selectionColumn: x !== "none",
263
+ columnSizingOptions: we,
264
+ columnWidths: Te,
265
+ defaultColumnWidths: z,
266
+ onColumnWidthsChange: B,
267
+ resizeColumnLabel: A?.resizeColumn,
268
+ columnWidthText: A?.columnWidth
269
+ }), Wt = G, Gt = P && Dt === void 0 ? /* @__PURE__ */ I(M, { children: /* @__PURE__ */ I("tr", { children: P.map((e, t) => {
270
+ let n = R(e);
271
+ return /* @__PURE__ */ I(he, {
338
272
  columnId: n,
339
273
  sortable: e.sortable ?? e.compare !== void 0,
340
274
  children: e.renderHeaderCell ? e.renderHeaderCell() : e.label
341
275
  }, 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)
276
+ }) }) }, "wave-generated-header") : null, Kt = P && K && Ot === void 0 ? /* @__PURE__ */ I(V, {}, "wave-generated-body") : null;
277
+ if (Gt || Kt || $.colgroup) {
278
+ let e = ({ node: e }) => n(e, "caption"), t = Tt.filter((t) => !e(t)), r = Kt ? t.findIndex(({ node: e }) => n(e, "tfoot")) : -1, i = r >= 0 ? r : t.length;
279
+ Wt = [
280
+ ...Tt.filter(e).map(Se),
281
+ $.colgroup,
282
+ Gt,
283
+ ...t.slice(0, i).map(Se),
284
+ Kt,
285
+ ...t.slice(i).map(Se)
351
286
  ];
352
287
  }
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, {
288
+ let { className: qt, "aria-label": Jt, "aria-labelledby": Yt, ref: Xt, ...Zt } = W ?? {}, Qt = m(Xt, Q.scrollerRef, At?.scrollRef), $t = Zt.role !== void 0, en = !$t && (Jt !== void 0 || Yt !== void 0);
289
+ return F.useEffect(() => {
290
+ en && o("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.");
291
+ }, [en]), /* @__PURE__ */ I(ce.Provider, {
292
+ value: _t,
293
+ children: /* @__PURE__ */ I(me.Provider, {
294
+ value: $e,
295
+ children: /* @__PURE__ */ I(de.Provider, {
296
+ value: Ct,
297
+ children: /* @__PURE__ */ I(fe.Provider, {
363
298
  value: null,
364
- children: /* @__PURE__ */ E(oe.Provider, {
299
+ children: /* @__PURE__ */ I(pe.Provider, {
365
300
  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
301
+ children: /* @__PURE__ */ I(ue.Provider, {
302
+ value: void 0,
303
+ children: /* @__PURE__ */ I(ie.Provider, {
304
+ value: $.resizeContext,
305
+ children: /* @__PURE__ */ I(w.Provider, {
306
+ value: $.colgroup !== null,
307
+ children: /* @__PURE__ */ I("div", {
308
+ tabIndex: Z ? -1 : void 0,
309
+ ...Zt,
310
+ ref: Qt,
311
+ "aria-label": $t ? Jt : void 0,
312
+ "aria-labelledby": $t ? Yt : void 0,
313
+ className: e(u.container, "overflow-x-auto rounded-md border border-border", Z && "[overflow-anchor:none]", qt),
314
+ children: /* @__PURE__ */ I("table", {
315
+ ref: Lt,
316
+ role: "grid",
317
+ "aria-multiselectable": x === "multiple" || void 0,
318
+ "aria-rowcount": Z ? Mt + jt : void 0,
319
+ "data-selection-appearance": ge,
320
+ "data-subtle-selection": N ? "" : void 0,
321
+ "data-resizing": $.resizing ? "" : void 0,
322
+ className: e(u.root, "w-full border-separate border-spacing-0", N && "group/grid", De),
323
+ style: $.tableStyle ? {
324
+ ...$.tableStyle,
325
+ ...Oe
326
+ } : Oe,
327
+ ...Pe,
328
+ onKeyDown: s(ke, Pt.onKeyDown),
329
+ onFocus: s(Ae, Rt, { checkDefaultPrevented: !1 }),
330
+ onBlur: s(je, zt, { checkDefaultPrevented: !1 }),
331
+ onPointerDownCapture: s(Me, Q.onPointerDownCapture),
332
+ children: /* @__PURE__ */ I(T.Provider, {
333
+ value: Q.context,
334
+ children: /* @__PURE__ */ I(E.Provider, {
335
+ value: null,
336
+ children: Wt
337
+ })
338
+ })
339
+ })
340
+ })
341
+ })
383
342
  })
384
343
  })
385
344
  })
@@ -388,332 +347,270 @@ function W(r) {
388
347
  })
389
348
  });
390
349
  }
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", {
395
- scope: "col",
396
- ...y,
397
- ref: i,
398
- "data-selection-cell": "",
399
- className: e(n, p.selectionCell, C, "text-start", b, d),
400
- children: t === "multiple" ? /* @__PURE__ */ E(te, {
401
- ref: h,
402
- type: "checkbox",
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", {
414
- className: "sr-only",
415
- children: c
416
- })
417
- });
418
- }
419
- var K = {
420
- subscribe: () => () => {},
421
- register: () => () => {},
422
- getFirst: () => null,
423
- refresh: () => {}
424
- };
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;
350
+ z.displayName = "DataGrid";
351
+ var B = F.memo(function({ item: e, index: t, rowId: n, selectionDisabled: r, render: i, position: a, ariaRowIndex: o, height: s }) {
352
+ let c = F.useMemo(() => a === void 0 || o === void 0 ? null : {
353
+ index: a,
354
+ ariaRowIndex: o,
355
+ height: s
429
356
  }, [
357
+ a,
430
358
  o,
431
- s,
432
- n
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,
444
- "data-selection-cell": "",
445
- className: e(r, p.selectionCell, C, b, m)
446
- });
447
- }
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
457
- });
458
- return T.cloneElement(e, void 0, i, /* @__PURE__ */ E(F.Provider, {
459
- value: o,
460
- children: n
461
- }));
462
- }
463
- return /* @__PURE__ */ E(F.Provider, {
464
- value: o,
465
- children: e
466
- });
467
- });
468
- return a(e);
469
- }
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(() => {
473
- d.refresh();
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, {
479
- value: "header",
480
- children: /* @__PURE__ */ E(P.Provider, {
481
- value: d,
482
- children: /* @__PURE__ */ E("thead", {
483
- ref: u,
484
- className: e(p.root, "bg-card", n),
485
- ...a,
486
- children: f
359
+ s
360
+ ]);
361
+ return /* @__PURE__ */ I(pe.Provider, {
362
+ value: n,
363
+ children: /* @__PURE__ */ I(ue.Provider, {
364
+ value: r,
365
+ children: /* @__PURE__ */ I(E.Provider, {
366
+ value: c,
367
+ children: i(e, t)
487
368
  })
488
369
  })
489
370
  });
490
- };
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) => {
494
- let t = e.currentTarget.firstElementChild;
495
- m !== void 0 && t?.localName === "button" && t.contains(e.target) && p(m, e.nativeEvent);
496
- };
497
- return T.useEffect(() => {
498
- n && !t && s("DataGrid.HeaderCell:sortable-without-columnId", "DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.");
499
- }, [n, t]), /* @__PURE__ */ E("th", {
500
- ref: l,
501
- scope: "col",
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", {
507
- className: "inline-flex items-center gap-1",
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
516
- })
517
- });
518
- };
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, {
371
+ }), V = ({ children: t, className: n, ref: r, ...i }) => {
372
+ let a = F.useContext(de), s = F.useContext(T), l = a?.rows ?? null, u = typeof t == "function" && l === null;
373
+ F.useEffect(() => {
374
+ u && o("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.");
375
+ }, [u]);
376
+ let d = a?.selectionDisabled ?? null, f = (e) => {
377
+ if (!e || !l) return null;
378
+ if (s) {
379
+ let { headerRowCount: t, virtualWindow: n } = s;
380
+ return oe(s, l.length, (r) => {
381
+ let i = l[r];
382
+ return /* @__PURE__ */ I(B, {
383
+ item: i.item,
384
+ index: i.index,
385
+ rowId: i.rowId,
386
+ selectionDisabled: d?.[i.index],
387
+ render: e,
388
+ position: r,
389
+ ariaRowIndex: r + t + 1,
390
+ height: n.itemSize
391
+ }, `row:${i.key}`);
392
+ });
393
+ }
394
+ return l.map((t) => /* @__PURE__ */ I(B, {
395
+ item: t.item,
396
+ index: t.index,
397
+ rowId: t.rowId,
398
+ selectionDisabled: d?.[t.index],
399
+ render: e
400
+ }, t.key));
401
+ }, p;
402
+ return p = typeof t == "function" ? f(t) : t === void 0 ? f(a?.renderColumnsRow ?? null) : t, /* @__PURE__ */ I(k.Provider, {
537
403
  value: "body",
538
- children: /* @__PURE__ */ E("tbody", {
404
+ children: /* @__PURE__ */ I("tbody", {
539
405
  ref: r,
540
- className: e(l.root, n),
406
+ className: e(c.root, n),
541
407
  ...i,
542
- children: d
408
+ children: p
543
409
  })
544
410
  });
545
411
  };
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;
412
+ V.displayName = "DataGridBody";
413
+ var H = ({ rowId: i, selectionLabel: a, selectionCellProps: c, children: l, className: u, style: f, onClick: p, onKeyDown: m, ref: h, ...g }) => {
414
+ let { selectionMode: _, store: v, toggleRow: te, selectOnRowClick: y, selectionAppearance: re } = A("DataGrid.Row"), S = F.useContext(E), C = F.useContext(pe), w = i ?? C ?? void 0, ie = F.useContext(k), ae = F.useContext(le), T = ie === "header", D = _ !== "none" && !T, oe = ee("wave-datagrid-row-label"), se = t(l), O;
415
+ for (let { node: e } of se) if (P(e)) {
416
+ O = e.props;
551
417
  break;
552
418
  }
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), [
419
+ let ce = O !== void 0, de = F.useContext(ue), me = O?.disabled ?? c?.disabled, j = me ?? de ?? !1, M = O?.invisible ?? c?.invisible ?? !1, he = O?.["aria-labelledby"], N = O?.["aria-label"] ?? c?.["aria-label"] ?? a, ve = _ === "single", ye = F.useCallback(() => w !== void 0 && v.isSelected(w, ve), [
554
420
  w,
555
421
  v,
556
- L
557
- ]), z = T.useSyncExternalStore(v.subscribe, le, le);
558
- T.useLayoutEffect(() => {
559
- if (w === void 0 || D) return;
422
+ ve
423
+ ]), L = F.useSyncExternalStore(v.subscribe, ye, ye);
424
+ F.useLayoutEffect(() => {
425
+ if (w === void 0 || T) return;
560
426
  let e = v.register(w);
561
- return r && v.countRegistrations(w) > 1 && me(w), e;
427
+ return r && v.countRegistrations(w) > 1 && we(w), e;
562
428
  }, [
563
429
  v,
564
430
  w,
565
- D
566
- ]), T.useLayoutEffect(() => {
567
- if (w !== void 0 && !D && P) return v.disable(w);
431
+ T
432
+ ]), F.useLayoutEffect(() => {
433
+ if (w !== void 0 && !T && j) return v.disable(w);
568
434
  }, [
569
435
  v,
570
436
  w,
437
+ T,
438
+ j
439
+ ]), F.useEffect(() => {
440
+ D && w === void 0 && o("DataGrid.Row:missing-rowId", "DataGrid.Row: a selectable grid needs a `rowId` on every row; this row has no selection control.");
441
+ }, [D, w]);
442
+ let be = D && w !== void 0 && de !== void 0 && me !== void 0 && me !== de;
443
+ F.useEffect(() => {
444
+ if (!be) return;
445
+ let e = (e) => e ? "disabled" : "enabled";
446
+ o("DataGrid:selection-disabled-mismatch", `DataGrid: the selection cell of row "${w}" is ${e(j)} (\`DataGrid.SelectionCell disabled\` or \`selectionCellProps.disabled\`), but \`isSelectionDisabled\` says its item is ${e(!j)}. Select-all skips a row that either one disables, and the row's control follows its cell: make them agree, or leave the cell's \`disabled\` unset to take it from \`isSelectionDisabled\`.`);
447
+ }, [
448
+ be,
449
+ w,
450
+ j
451
+ ]);
452
+ let xe = D && i !== void 0 && C !== null && i !== C;
453
+ F.useEffect(() => {
454
+ xe ? o("DataGrid.Row:row-id-mismatch", "DataGrid.Row: a row rendered from the grid's `items` sets its own `rowId`, which differs from its item's id (`getRowId`, by default the item's index). Select-all and its checkbox use the ids from `getRowId`, so the row is outside them and select-all selects ids that no row has. Pass a `getRowId` that returns the row's id, and leave out `rowId`.") : D && w !== void 0 && C === null && v.isOutsideUniverse(w) && o("DataGrid.Row:row-id-outside-items", "DataGrid.Row: a selectable row in a grid with `items` has a `rowId` that is no item's id (`getRowId`, by default the item's index). Select-all and its checkbox use the ids of `items`, so the row is outside them. Render the rows from `items` (a `DataGrid.Body` render function, or `columns`) with a `getRowId` that returns their ids.");
455
+ }, [
456
+ xe,
571
457
  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;
458
+ w,
459
+ C,
460
+ v
461
+ ]);
462
+ let Ce = D && w !== void 0 && N === void 0 && he === void 0, R = (e) => {
463
+ if (!D || w === void 0 || e.key !== " ") return;
578
464
  let t = e.target;
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;
465
+ (t === e.currentTarget || t.parentElement === e.currentTarget) && (e.preventDefault(), j || te(w, e.nativeEvent));
466
+ }, z = (e) => {
467
+ if (!y || !D || w === void 0 || j) return;
582
468
  let t = e.currentTarget;
583
- ee(e, { isOwnPart: (e) => e.parentElement === t }) || S(e) || y(w, e.nativeEvent);
469
+ x(e, { isOwnPart: (e) => e.parentElement === t }) || ne(e) || te(w, e.nativeEvent);
584
470
  }, B, V = -1;
585
- if (ue) {
586
- let e = A.findIndex(({ node: e }) => n(e, Z, "td", "th"));
471
+ if (Ce) {
472
+ let e = se.findIndex(({ node: e }) => n(e, Ee, "td", "th"));
587
473
  if (e >= 0) {
588
- let t = A[e].node;
589
- B = t.props.id ?? k, t.props.id === void 0 && (V = e);
474
+ let t = se[e].node;
475
+ B = t.props.id ?? oe, t.props.id === void 0 && (V = e);
590
476
  }
591
477
  }
592
- let W = A.map(({ key: e, node: t }, n) => pe({
478
+ let H = se.map(({ key: e, node: t }, n) => Se({
593
479
  key: e,
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
480
+ node: n === V ? F.cloneElement(t, { id: oe }) : t
481
+ })), W = Ce && B === void 0;
482
+ F.useEffect(() => {
483
+ W && o("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).");
484
+ }, [W]);
485
+ let G = he ?? B, De = N ?? (G === void 0 ? "Select row" : void 0), Oe = F.useMemo(() => ({
486
+ selectionCellProps: c,
487
+ hasSelectionCell: ce,
488
+ rowId: D ? w : void 0,
489
+ isSelected: L,
490
+ disabled: j,
491
+ invisible: M,
492
+ ariaLabel: De,
493
+ ariaLabelledBy: G
608
494
  }), [
609
- o,
610
- M,
611
- O,
495
+ c,
496
+ ce,
497
+ D,
612
498
  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]
499
+ L,
500
+ j,
501
+ M,
502
+ De,
503
+ G
504
+ ]), ke = null;
505
+ return !ce && T && _ !== "none" ? ke = /* @__PURE__ */ I(ge, {
506
+ selectionMode: _,
507
+ initialFirst: ae,
508
+ cellProps: c
509
+ }) : !ce && D && (ke = /* @__PURE__ */ I(U, { component: "DataGrid.Row" })), /* @__PURE__ */ I(fe.Provider, {
510
+ value: Oe,
511
+ children: /* @__PURE__ */ _e("tr", {
512
+ ref: h,
513
+ className: e(d.root, "group/table-row", !T && Te[re], D && L && b.selectedContainer, u),
514
+ "aria-selected": D ? L : void 0,
515
+ "data-selected": D && L ? "" : void 0,
516
+ ...g,
517
+ style: S?.height === void 0 ? f : {
518
+ ...f,
519
+ height: S.height
520
+ },
521
+ ...S && {
522
+ "aria-rowindex": S.ariaRowIndex,
523
+ "data-row-index": S.index
524
+ },
525
+ onClick: s(p, z),
526
+ onKeyDown: s(m, R),
527
+ children: [ke, H]
634
528
  })
635
529
  });
636
530
  };
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", {
531
+ H.displayName = "DataGridRow";
532
+ function U({ component: t, stableClassName: n, className: r, controlRef: i, "aria-describedby": a, ref: o, ...s }) {
533
+ let { selectionMode: c, toggleRow: l, radioName: u, subtleSelection: f } = A(t), p = j(t), ee = F.useContext(E)?.index !== void 0, { rowId: m } = p, h = c === "single";
534
+ return /* @__PURE__ */ I("td", {
641
535
  role: "gridcell",
642
536
  ...s,
643
537
  ref: o,
644
538
  "data-selection-cell": "",
645
- className: e(n, m.selectionCell, C, b, f.selectionCellProps?.className, r),
646
- children: p !== void 0 && c !== "none" && /* @__PURE__ */ E(te, {
539
+ className: e(n, d.selectionCell, re, ee && "py-0 align-middle", y, p.selectionCellProps?.className, r),
540
+ children: m !== void 0 && c !== "none" && /* @__PURE__ */ I(S, {
647
541
  ref: i,
648
542
  type: h ? "radio" : "checkbox",
649
543
  name: h ? u : void 0,
650
544
  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,
545
+ checked: p.isSelected,
546
+ disabled: p.disabled,
547
+ invisible: p.invisible,
548
+ subtle: f,
549
+ onChange: (e) => l(m, e.nativeEvent),
550
+ "aria-label": p.ariaLabel,
551
+ "aria-labelledby": p.ariaLabelledBy,
658
552
  "aria-describedby": a,
659
- className: m.selectionControl
553
+ className: d.selectionControl
660
554
  })
661
555
  });
662
556
  }
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, {
557
+ var W = ({ disabled: t, invisible: n, className: r, "aria-label": i, "aria-labelledby": a, "aria-describedby": s, controlRef: c, ref: l, ...u }) => {
558
+ let { selectionMode: d } = A("DataGrid.SelectionCell"), p = F.useContext(k), ee = F.useContext(le), m = F.useContext(fe), h = d === "none", g = !h && m !== null && !m.hasSelectionCell;
559
+ if (F.useEffect(() => {
560
+ h && o("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.");
561
+ }, [h]), F.useEffect(() => {
562
+ g && o("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).");
563
+ }, [g]), h) return null;
564
+ if (p === "header") {
565
+ let o = m?.selectionCellProps;
566
+ return /* @__PURE__ */ I(ge, {
673
567
  ref: l,
674
568
  selectionMode: d,
675
- initialFirst: p,
676
- stableClassName: h.root,
569
+ initialFirst: ee,
570
+ stableClassName: f.root,
677
571
  cellProps: {
678
572
  ...u,
679
- className: e(s?.className, r),
680
- disabled: t ?? s?.disabled,
681
- invisible: n ?? s?.invisible,
682
- "aria-label": i ?? s?.["aria-label"],
573
+ className: e(o?.className, r),
574
+ disabled: t ?? o?.disabled,
575
+ invisible: n ?? o?.invisible,
576
+ "aria-label": i ?? o?.["aria-label"],
683
577
  "aria-labelledby": a,
684
- "aria-describedby": o,
578
+ "aria-describedby": s,
685
579
  controlRef: c
686
580
  }
687
581
  });
688
582
  }
689
- return /* @__PURE__ */ E(ye, {
583
+ return /* @__PURE__ */ I(U, {
690
584
  ...u,
691
585
  ref: l,
692
586
  component: "DataGrid.SelectionCell",
693
- stableClassName: h.root,
587
+ stableClassName: f.root,
694
588
  className: r,
695
589
  controlRef: c,
696
- "aria-describedby": o
590
+ "aria-describedby": s
697
591
  });
698
592
  };
699
- X.displayName = "DataGridSelectionCell", re(X, "dataGridSelectionCell");
700
- var Z = ({ children: t, className: n, ref: r, ...i }) => /* @__PURE__ */ E("td", {
701
- ref: r,
702
- role: "gridcell",
703
- className: e(u.root, V, "relative text-body-1", b, n),
704
- ...i,
705
- children: t
706
- });
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
593
+ W.displayName = "DataGridSelectionCell", C(W, "dataGridSelectionCell");
594
+ var Ee = ({ children: t, className: n, ref: r, ...i }) => {
595
+ let a = F.useContext(w), o = F.useContext(E)?.index !== void 0;
596
+ return /* @__PURE__ */ I("td", {
597
+ ref: r,
598
+ role: "gridcell",
599
+ className: e(l.root, N, "relative text-body-1", (a || o) && "overflow-hidden text-ellipsis whitespace-nowrap", o && "py-0 align-middle", y, n),
600
+ ...i,
601
+ children: t
602
+ });
603
+ };
604
+ Ee.displayName = "DataGridCell";
605
+ var G = /* @__PURE__ */ Object.assign(z, {
606
+ Header: M,
607
+ HeaderCell: he,
608
+ Body: V,
609
+ Row: H,
610
+ Cell: Ee,
611
+ SelectionCell: W
715
612
  });
716
613
  //#endregion
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 };
614
+ export { G as DataGrid, V as DataGridBody, Ee as DataGridCell, M as DataGridHeader, he as DataGridHeaderCell, H as DataGridRow, W as DataGridSelectionCell, O as createSelectionStore };
718
615
 
719
616
  //# sourceMappingURL=DataGrid.mjs.map