@navikt/ds-react 8.10.4 → 8.10.6

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 (244) hide show
  1. package/cjs/data/data-grid/index.d.ts +2 -0
  2. package/cjs/data/data-grid/index.js +7 -0
  3. package/cjs/data/data-grid/index.js.map +1 -0
  4. package/cjs/data/data-grid/root/DataGridRoot.context.d.ts +11 -0
  5. package/cjs/data/data-grid/root/DataGridRoot.context.js +11 -0
  6. package/cjs/data/data-grid/root/DataGridRoot.context.js.map +1 -0
  7. package/cjs/data/data-grid/root/DataGridRoot.d.ts +38 -0
  8. package/cjs/data/data-grid/root/DataGridRoot.js +68 -0
  9. package/cjs/data/data-grid/root/DataGridRoot.js.map +1 -0
  10. package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +11 -13
  11. package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
  12. package/cjs/data/drag-and-drop/root/DragAndDrop.context.d.ts +4 -2
  13. package/cjs/data/drag-and-drop/root/DragAndDrop.context.js.map +1 -1
  14. package/cjs/data/drag-and-drop/root/DragAndDropRoot.js +44 -46
  15. package/cjs/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
  16. package/cjs/data/drag-and-drop/types.d.ts +0 -4
  17. package/cjs/data/stories/Data.test-data.d.ts +2 -5
  18. package/cjs/data/stories/Data.test-data.js +30 -39
  19. package/cjs/data/stories/Data.test-data.js.map +1 -1
  20. package/cjs/data/table/base-cell/DataTableBaseCell.d.ts +15 -15
  21. package/cjs/data/table/base-cell/DataTableBaseCell.js +4 -8
  22. package/cjs/data/table/base-cell/DataTableBaseCell.js.map +1 -1
  23. package/cjs/data/table/column-header/DataTableColumnHeader.d.ts +24 -6
  24. package/cjs/data/table/column-header/DataTableColumnHeader.js +22 -27
  25. package/cjs/data/table/column-header/DataTableColumnHeader.js.map +1 -1
  26. package/cjs/data/table/column-header/useTableColumnResize.d.ts +19 -29
  27. package/cjs/data/table/column-header/useTableColumnResize.js +24 -22
  28. package/cjs/data/table/column-header/useTableColumnResize.js.map +1 -1
  29. package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +1 -1
  30. package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js +2 -2
  31. package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -1
  32. package/cjs/data/table/helpers/collectTableRowEntries.d.ts +9 -7
  33. package/cjs/data/table/helpers/collectTableRowEntries.js +18 -10
  34. package/cjs/data/table/helpers/collectTableRowEntries.js.map +1 -1
  35. package/cjs/data/table/helpers/selection/getMultipleSelectProps.d.ts +13 -11
  36. package/cjs/data/table/helpers/selection/getMultipleSelectProps.js +43 -53
  37. package/cjs/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
  38. package/cjs/data/table/helpers/selection/getSingleSelectProps.d.ts +9 -8
  39. package/cjs/data/table/helpers/selection/getSingleSelectProps.js +23 -10
  40. package/cjs/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
  41. package/cjs/data/table/helpers/selection/selection.types.d.ts +19 -19
  42. package/cjs/data/table/helpers/selection/selection.utils.d.ts +21 -0
  43. package/cjs/data/table/helpers/selection/selection.utils.js +46 -0
  44. package/cjs/data/table/helpers/selection/selection.utils.js.map +1 -0
  45. package/cjs/data/table/helpers/table-focus.d.ts +0 -3
  46. package/cjs/data/table/helpers/table-focus.js +38 -8
  47. package/cjs/data/table/helpers/table-focus.js.map +1 -1
  48. package/cjs/data/table/hooks/useColumnOptions.d.ts +16 -5
  49. package/cjs/data/table/hooks/useColumnOptions.js +26 -8
  50. package/cjs/data/table/hooks/useColumnOptions.js.map +1 -1
  51. package/cjs/data/table/hooks/useGridCache.js +2 -2
  52. package/cjs/data/table/hooks/useGridCache.js.map +1 -1
  53. package/cjs/data/table/hooks/useTableDetailsPanel.d.ts +10 -13
  54. package/cjs/data/table/hooks/useTableDetailsPanel.js +7 -6
  55. package/cjs/data/table/hooks/useTableDetailsPanel.js.map +1 -1
  56. package/cjs/data/table/hooks/useTableItems.d.ts +31 -17
  57. package/cjs/data/table/hooks/useTableItems.js +10 -20
  58. package/cjs/data/table/hooks/useTableItems.js.map +1 -1
  59. package/cjs/data/table/hooks/useTableKeyboardNav.d.ts +1 -6
  60. package/cjs/data/table/hooks/useTableKeyboardNav.js +6 -5
  61. package/cjs/data/table/hooks/useTableKeyboardNav.js.map +1 -1
  62. package/cjs/data/table/hooks/useTableSelection.d.ts +6 -6
  63. package/cjs/data/table/hooks/useTableSelection.js +13 -13
  64. package/cjs/data/table/hooks/useTableSelection.js.map +1 -1
  65. package/cjs/data/table/hooks/useTableSort.d.ts +2 -2
  66. package/cjs/data/table/hooks/useTableSort.js +4 -5
  67. package/cjs/data/table/hooks/useTableSort.js.map +1 -1
  68. package/cjs/data/table/root/DataTable.types.d.ts +22 -13
  69. package/cjs/data/table/root/DataTableRoot.context.d.ts +13 -7
  70. package/cjs/data/table/root/DataTableRoot.context.js.map +1 -1
  71. package/cjs/data/table/root/DataTableRoot.d.ts +49 -72
  72. package/cjs/data/table/root/DataTableRoot.js +56 -72
  73. package/cjs/data/table/root/DataTableRoot.js.map +1 -1
  74. package/cjs/data/table/root/DataTableRoot.legacy.d.ts +2 -7
  75. package/cjs/data/table/root/DataTableRoot.legacy.js +17 -3
  76. package/cjs/data/table/root/DataTableRoot.legacy.js.map +1 -1
  77. package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js +4 -4
  78. package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -1
  79. package/cjs/data/table/tbody/DataTableTbody.js +4 -2
  80. package/cjs/data/table/tbody/DataTableTbody.js.map +1 -1
  81. package/cjs/data/table/tr/DataTableTr.d.ts +5 -3
  82. package/cjs/data/table/tr/DataTableTr.js +36 -23
  83. package/cjs/data/table/tr/DataTableTr.js.map +1 -1
  84. package/cjs/table/ColumnHeader.js +2 -1
  85. package/cjs/table/ColumnHeader.js.map +1 -1
  86. package/esm/data/data-grid/index.d.ts +2 -0
  87. package/esm/data/data-grid/index.js +3 -0
  88. package/esm/data/data-grid/index.js.map +1 -0
  89. package/esm/data/data-grid/root/DataGridRoot.context.d.ts +11 -0
  90. package/esm/data/data-grid/root/DataGridRoot.context.js +7 -0
  91. package/esm/data/data-grid/root/DataGridRoot.context.js.map +1 -0
  92. package/esm/data/data-grid/root/DataGridRoot.d.ts +38 -0
  93. package/esm/data/data-grid/root/DataGridRoot.js +32 -0
  94. package/esm/data/data-grid/root/DataGridRoot.js.map +1 -0
  95. package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +11 -13
  96. package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
  97. package/esm/data/drag-and-drop/root/DragAndDrop.context.d.ts +4 -2
  98. package/esm/data/drag-and-drop/root/DragAndDrop.context.js.map +1 -1
  99. package/esm/data/drag-and-drop/root/DragAndDropRoot.js +44 -46
  100. package/esm/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
  101. package/esm/data/drag-and-drop/types.d.ts +0 -4
  102. package/esm/data/stories/Data.test-data.d.ts +2 -5
  103. package/esm/data/stories/Data.test-data.js +30 -39
  104. package/esm/data/stories/Data.test-data.js.map +1 -1
  105. package/esm/data/table/base-cell/DataTableBaseCell.d.ts +15 -15
  106. package/esm/data/table/base-cell/DataTableBaseCell.js +4 -8
  107. package/esm/data/table/base-cell/DataTableBaseCell.js.map +1 -1
  108. package/esm/data/table/column-header/DataTableColumnHeader.d.ts +24 -6
  109. package/esm/data/table/column-header/DataTableColumnHeader.js +23 -28
  110. package/esm/data/table/column-header/DataTableColumnHeader.js.map +1 -1
  111. package/esm/data/table/column-header/useTableColumnResize.d.ts +19 -29
  112. package/esm/data/table/column-header/useTableColumnResize.js +24 -22
  113. package/esm/data/table/column-header/useTableColumnResize.js.map +1 -1
  114. package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +1 -1
  115. package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js +2 -2
  116. package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -1
  117. package/esm/data/table/helpers/collectTableRowEntries.d.ts +9 -7
  118. package/esm/data/table/helpers/collectTableRowEntries.js +18 -10
  119. package/esm/data/table/helpers/collectTableRowEntries.js.map +1 -1
  120. package/esm/data/table/helpers/selection/getMultipleSelectProps.d.ts +13 -11
  121. package/esm/data/table/helpers/selection/getMultipleSelectProps.js +43 -53
  122. package/esm/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
  123. package/esm/data/table/helpers/selection/getSingleSelectProps.d.ts +9 -8
  124. package/esm/data/table/helpers/selection/getSingleSelectProps.js +23 -10
  125. package/esm/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
  126. package/esm/data/table/helpers/selection/selection.types.d.ts +19 -19
  127. package/esm/data/table/helpers/selection/selection.utils.d.ts +21 -0
  128. package/esm/data/table/helpers/selection/selection.utils.js +43 -0
  129. package/esm/data/table/helpers/selection/selection.utils.js.map +1 -0
  130. package/esm/data/table/helpers/table-focus.d.ts +0 -3
  131. package/esm/data/table/helpers/table-focus.js +38 -8
  132. package/esm/data/table/helpers/table-focus.js.map +1 -1
  133. package/esm/data/table/hooks/useColumnOptions.d.ts +16 -5
  134. package/esm/data/table/hooks/useColumnOptions.js +26 -8
  135. package/esm/data/table/hooks/useColumnOptions.js.map +1 -1
  136. package/esm/data/table/hooks/useGridCache.js +2 -2
  137. package/esm/data/table/hooks/useGridCache.js.map +1 -1
  138. package/esm/data/table/hooks/useTableDetailsPanel.d.ts +10 -13
  139. package/esm/data/table/hooks/useTableDetailsPanel.js +7 -6
  140. package/esm/data/table/hooks/useTableDetailsPanel.js.map +1 -1
  141. package/esm/data/table/hooks/useTableItems.d.ts +31 -17
  142. package/esm/data/table/hooks/useTableItems.js +11 -18
  143. package/esm/data/table/hooks/useTableItems.js.map +1 -1
  144. package/esm/data/table/hooks/useTableKeyboardNav.d.ts +1 -6
  145. package/esm/data/table/hooks/useTableKeyboardNav.js +7 -6
  146. package/esm/data/table/hooks/useTableKeyboardNav.js.map +1 -1
  147. package/esm/data/table/hooks/useTableSelection.d.ts +6 -6
  148. package/esm/data/table/hooks/useTableSelection.js +13 -13
  149. package/esm/data/table/hooks/useTableSelection.js.map +1 -1
  150. package/esm/data/table/hooks/useTableSort.d.ts +2 -2
  151. package/esm/data/table/hooks/useTableSort.js +4 -5
  152. package/esm/data/table/hooks/useTableSort.js.map +1 -1
  153. package/esm/data/table/root/DataTable.types.d.ts +22 -13
  154. package/esm/data/table/root/DataTableRoot.context.d.ts +13 -7
  155. package/esm/data/table/root/DataTableRoot.context.js.map +1 -1
  156. package/esm/data/table/root/DataTableRoot.d.ts +49 -72
  157. package/esm/data/table/root/DataTableRoot.js +58 -74
  158. package/esm/data/table/root/DataTableRoot.js.map +1 -1
  159. package/esm/data/table/root/DataTableRoot.legacy.d.ts +2 -7
  160. package/esm/data/table/root/DataTableRoot.legacy.js +17 -3
  161. package/esm/data/table/root/DataTableRoot.legacy.js.map +1 -1
  162. package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js +4 -4
  163. package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -1
  164. package/esm/data/table/tbody/DataTableTbody.js +4 -2
  165. package/esm/data/table/tbody/DataTableTbody.js.map +1 -1
  166. package/esm/data/table/tr/DataTableTr.d.ts +5 -3
  167. package/esm/data/table/tr/DataTableTr.js +35 -23
  168. package/esm/data/table/tr/DataTableTr.js.map +1 -1
  169. package/esm/table/ColumnHeader.js +2 -1
  170. package/esm/table/ColumnHeader.js.map +1 -1
  171. package/package.json +8 -7
  172. package/src/data/data-grid/index.ts +3 -0
  173. package/src/data/data-grid/root/DataGridRoot.context.ts +16 -0
  174. package/src/data/data-grid/root/DataGridRoot.tsx +71 -0
  175. package/src/data/drag-and-drop/drag-handler/DragAndDropDragHandler.tsx +11 -17
  176. package/src/data/drag-and-drop/root/DragAndDrop.context.tsx +4 -2
  177. package/src/data/drag-and-drop/root/DragAndDropRoot.tsx +63 -52
  178. package/src/data/drag-and-drop/types.ts +0 -5
  179. package/src/data/stories/Data.test-data.tsx +52 -44
  180. package/src/data/table/agent-component-review.md +175 -0
  181. package/src/data/table/base-cell/DataTableBaseCell.tsx +31 -21
  182. package/src/data/table/column-header/DataTableColumnHeader.tsx +63 -58
  183. package/src/data/table/column-header/useTableColumnResize.ts +55 -71
  184. package/src/data/table/details-panel-row/DataTableDetailsPanelRow.tsx +7 -3
  185. package/src/data/table/helpers/collectTableRowEntries.ts +32 -19
  186. package/src/data/table/helpers/selection/getMultipleSelectProps.ts +65 -85
  187. package/src/data/table/helpers/selection/getSingleSelectProps.ts +35 -17
  188. package/src/data/table/helpers/selection/selection.types.ts +19 -19
  189. package/src/data/table/helpers/selection/selection.utils.test.ts +161 -0
  190. package/src/data/table/helpers/selection/selection.utils.ts +73 -0
  191. package/src/data/table/helpers/table-focus.ts +63 -9
  192. package/src/data/table/hooks/__tests__/useTableItems.test.ts +48 -8
  193. package/src/data/table/hooks/useColumnOptions.ts +48 -14
  194. package/src/data/table/hooks/useGridCache.ts +3 -2
  195. package/src/data/table/hooks/useTableDetailsPanel.tsx +25 -25
  196. package/src/data/table/hooks/useTableItems.ts +51 -42
  197. package/src/data/table/hooks/useTableKeyboardNav.ts +7 -15
  198. package/src/data/table/hooks/useTableSelection.ts +26 -31
  199. package/src/data/table/hooks/useTableSort.ts +10 -9
  200. package/src/data/table/root/DataTable.types.ts +30 -25
  201. package/src/data/table/root/DataTableRoot.context.ts +19 -7
  202. package/src/data/table/root/DataTableRoot.legacy.tsx +22 -14
  203. package/src/data/table/root/DataTableRoot.tsx +271 -320
  204. package/src/data/table/sub-row-toggle/DataTableSubRowToggle.tsx +5 -4
  205. package/src/data/table/tbody/DataTableTbody.tsx +6 -2
  206. package/src/data/table/tr/DataTableTr.tsx +98 -35
  207. package/src/table/ColumnHeader.tsx +2 -1
  208. package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.d.ts +0 -22
  209. package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js +0 -35
  210. package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js.map +0 -1
  211. package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.d.ts +0 -27
  212. package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.js +0 -86
  213. package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +0 -1
  214. package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.d.ts +0 -5
  215. package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.js +0 -6
  216. package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +0 -1
  217. package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.d.ts +0 -24
  218. package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.js +0 -108
  219. package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.js.map +0 -1
  220. package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.d.ts +0 -46
  221. package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.js +0 -112
  222. package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.js.map +0 -1
  223. package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.d.ts +0 -22
  224. package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js +0 -29
  225. package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js.map +0 -1
  226. package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.d.ts +0 -27
  227. package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.js +0 -50
  228. package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +0 -1
  229. package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.d.ts +0 -5
  230. package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.js +0 -3
  231. package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +0 -1
  232. package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.d.ts +0 -24
  233. package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.js +0 -68
  234. package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.js.map +0 -1
  235. package/esm/data/table/helpers/selection/SelectionSubtreeHelper.d.ts +0 -46
  236. package/esm/data/table/helpers/selection/SelectionSubtreeHelper.js +0 -109
  237. package/esm/data/table/helpers/selection/SelectionSubtreeHelper.js.map +0 -1
  238. package/src/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.tsx +0 -104
  239. package/src/data/drag-and-drop-old/item/DataDragAndDropItem.tsx +0 -74
  240. package/src/data/drag-and-drop-old/root/DataDragAndDrop.context.tsx +0 -11
  241. package/src/data/drag-and-drop-old/root/DataDragAndDropRoot.tsx +0 -96
  242. package/src/data/table/helpers/selection/SelectionSubtreeHelper.test.ts +0 -66
  243. package/src/data/table/helpers/selection/SelectionSubtreeHelper.ts +0 -162
  244. package/src/data/table/hooks/__tests__/useTableSelection.test.ts +0 -488
@@ -1,4 +1,6 @@
1
1
  import React from "react";
2
+ import { MenuElipsisVerticalIcon } from "@navikt/aksel-icons";
3
+ import { Button } from "../../button";
2
4
  import { Tag } from "../../tag";
3
5
  import type { ColumnDefinitions } from "../table/root/DataTable.types";
4
6
 
@@ -17,81 +19,53 @@ type SWData = {
17
19
  nestedRows: Omit<NestedSWData, "nestedRows">[];
18
20
  };
19
21
 
20
- type Details = {
21
- visible: boolean;
22
- };
23
-
24
- const columnDef_TEST_DATA: ColumnDefinitions<SWData, Details> = [
22
+ const columnDef_TEST_DATA: ColumnDefinitions<SWData> = [
25
23
  {
26
24
  id: "id",
27
25
  label: "Id",
28
26
  cell: (row) => row.id,
29
- align: "right",
30
- autoWidth: true,
31
- details: {
32
- visible: true,
33
- },
27
+ width: { autoResizeOnce: true },
34
28
  },
35
29
  {
36
30
  label: "Name",
37
31
  id: "name",
38
32
  cell: (row) =>
39
33
  `${row.name} ${row?.nestedRows?.length > 0 ? `(${row?.nestedRows?.length})` : ""}`,
40
- details: {
41
- visible: true,
42
- },
43
34
  },
44
35
  {
45
36
  label: "National id",
46
37
  id: "nationalId",
47
38
  cell: (row) => row.nationalId,
48
39
  align: "right",
49
- autoWidth: true,
50
- details: {
51
- visible: true,
52
- },
40
+ width: { autoResizeOnce: true },
53
41
  },
54
42
  {
55
43
  label: "Day job",
56
44
  id: "dayJob",
57
45
  cell: (row) => row.dayJob,
58
- details: {
59
- visible: true,
60
- },
61
46
  },
62
47
  {
63
48
  label: "Supervisor",
64
49
  id: "supervisor",
65
50
  cell: (row) => row.supervisor,
66
- details: {
67
- visible: true,
68
- },
69
51
  },
70
52
  {
71
53
  label: "Date received",
72
54
  id: "dateReceived",
73
55
  cell: (row) => row.dateReceived,
74
- details: {
75
- visible: true,
76
- },
77
56
  },
78
57
  {
79
58
  label: "Message",
80
59
  id: "message",
81
60
  cell: (row) => row.message,
82
- details: {
83
- visible: true,
84
- },
85
61
  },
86
62
  {
87
63
  label: "Age",
88
64
  id: "age",
89
65
  cell: (row) => row.age,
90
66
  align: "right",
91
- autoWidth: true,
92
- details: {
93
- visible: true,
94
- },
67
+ width: { autoResizeOnce: true },
68
+
95
69
  /* TODO: NOt yet implemented */
96
70
  /* footer: ({ table }) => {
97
71
  const ages: number[] = [];
@@ -112,27 +86,61 @@ const columnDef_TEST_DATA: ColumnDefinitions<SWData, Details> = [
112
86
  data-color={row.forceSensitive ? "accent" : "warning"}
113
87
  >{`${row.forceSensitive ? "Yes" : "No"}`}</Tag>
114
88
  ),
115
- autoWidth: true,
89
+ width: { autoResizeOnce: true },
116
90
  align: "center",
117
- details: {
118
- visible: true,
119
- },
120
91
  },
121
92
  {
122
93
  label: "Home system",
123
94
  id: "homeSystem",
124
95
  cell: (row) => row.homeSystem,
125
- details: {
126
- visible: true,
127
- },
128
96
  },
129
97
  {
130
98
  label: "Skills",
131
99
  id: "skills",
132
- cell: (row) => row.skills,
133
- details: {
134
- visible: true,
135
- },
100
+ cell: (row) =>
101
+ row.skills.map((skill) => (
102
+ <Tag key={skill} size="small" variant="moderate">
103
+ {skill}
104
+ </Tag>
105
+ )),
106
+ /* cell: (row) => (
107
+ <Bleed marginBlock="space-4" marginInline="space-4">
108
+ {row.skills.map((skill) => (
109
+ <Box
110
+ key={skill}
111
+ style={{ display: "inline-block" }}
112
+ padding="space-4"
113
+ >
114
+ <Tag size="small" variant="moderate">
115
+ {skill}
116
+ </Tag>
117
+ </Box>
118
+ ))}
119
+ </Bleed>
120
+ ), */
121
+ },
122
+ {
123
+ label: "Actions",
124
+ id: "actions",
125
+ width: { autoResizeOnce: true },
126
+ cell: (row) => (
127
+ <>
128
+ <Button
129
+ size="xsmall"
130
+ variant="secondary"
131
+ data-color="neutral"
132
+ onClick={() => alert(`Edit ${row.name}`)}
133
+ >
134
+ Edit
135
+ </Button>
136
+ <Button
137
+ size="xsmall"
138
+ variant="secondary"
139
+ data-color="neutral"
140
+ icon={<MenuElipsisVerticalIcon title="Meny" />}
141
+ />
142
+ </>
143
+ ),
136
144
  },
137
145
  ];
138
146
 
@@ -0,0 +1,175 @@
1
+ # DataTable Beta Readiness Review
2
+
3
+ ## Summary
4
+
5
+ The DataTable is a well-architected component with thoughtful separation of concerns (hooks, helpers, sub-components). The keyboard navigation, selection cascading, and sort state management are solid. However, there are several a11y gaps, API inconsistencies, and edge cases that should be addressed before a public beta.
6
+
7
+ ---
8
+
9
+ ## Findings
10
+
11
+ | # | Category | Finding | Severity | Recommendation |
12
+ | --- | --------------- | ------------------------------------------------------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
13
+ | 2 | A11y | No `aria-selected` on selected rows | 🔴 | Add `aria-selected="true"` on `<tr>` for selected rows (required by grid/table selection pattern per ARIA APG). |
14
+ | 3 | A11y | No `aria-label`/`aria-labelledby` on the table element | 🟡 | Expose a `label` or `aria-label` prop. Without it, screen readers announce the table generically. React Aria requires a label on every table. |
15
+ | 4 | A11y | Hardcoded Norwegian strings without i18n support | 🟡 | All aria-labels ("Vis under-rader", "Skjul detaljer", "Velg alle synlige rader", "Laster innhold", resize labels) are Norwegian-only. Expose a `labels`/`translations` prop or accept them via column definitions for i18n. |
16
+ | 5 | A11y | Sub-rows should use `role="treegrid"` | 🟡 | When `subRows` is provided, the table should use `role="treegrid"` with `aria-level`, `aria-setsize`, `aria-posinset` on rows. Already flagged as TODO in code. |
17
+ | 7 | API | `disableRowSelection` signature inconsistency with stories | 🔴 | Type declares `({ row, id }) => boolean` but stories pass `({ id }) => id === 2`. The prop name is confusing: "disable" + returns `true` to disable = double negative. Consider `isRowSelectable` (positive predicate) like React Aria's `disabledKeys` pattern. |
18
+ | 8 | API | `stickyColumns` type is overly restrictive | 🟡 | `first?: "1"` and `last?: "1"` prevent future extension to 2+ sticky columns. Use `number` instead. |
19
+ | 9 | API | `sort` and `onSortChange` mixed into `DataTableProps` via `TableSortOptions` | 🟡 | Spreading sort props at root level makes the API flat but could collide with native HTML attributes or future features. Consider grouping into a `sort={{ state, onChange, defaultState }}` pattern. However, this is a style preference — the flat API is also valid. |
20
+ | 10 | API | `children?: never` prevents slot-based composition | 🟢 | The data-driven API is good for beta, but consider a path to compositional usage (render props or slot API) for GA. MUI and TanStack offer both modes. |
21
+ | 11 | API | Missing `aria-rowcount`/`aria-colcount` for virtualized/paginated tables | 🟡 | When data is paginated (as in `SelectionPagination` story), ATs cannot know total row count. Expose `totalRowCount` prop that maps to `aria-rowcount`. |
22
+ | 12 | Code Quality | `selectableIdsSet` in `getMultipleSelectProps` iterates all rows including sub-rows | 🟡 | "Select all" selects ALL rows in `itemDetails` including hidden sub-rows. The `selectableIdsSet` should filter by `visibleRowIds` for the "select all" checkbox, while still cascading to children when selecting individual parent rows. Variable naming is misleading. |
23
+ | 13 | Code Quality | `useTableSelection` passes `tableItems` (full object) to `getMultipleSelectProps` | 🟡 | This couples selection logic to the full table items shape. Consider passing only what's needed (`visibleRowIds`, `childRowIdsById`, `itemDetails`). |
24
+ | 14 | Performance | `columns.map()` inside render creates new objects on each render | 🟢 | `useColumnOptions` is memoized — this is fine. The `columns.map()` inside `DataTableTBodyContent` render loop is acceptable for normal table sizes. |
25
+ | 15 | Performance | No virtualization support | 🟢 | For beta, this is acceptable. Document the performance ceiling (recommended max ~500-1000 rows without virtualization). For GA, consider integrating with `@tanstack/react-virtual`. |
26
+ | 16 | Potential Issue | `fullWidthColSpan` may be wrong when `subRows` adds the expansion column | 🔴 | `fullWidthColSpan` counts `columns.length + layout filler + selection + detailsPanel`. The `RowExpansionCell` renders a separate `<td>` for detailsPanel. If both `subRows` AND `detailsPanel` are used together, verify `fullWidthColSpan` is correct. Check with `NestedRowsWithMasterDetail` story. |
27
+ | 17 | Potential Issue | Selection row-click fires AND toggles selection simultaneously | 🟡 | When `onRowClick` and `selection` are both enabled and `disableRowSelectionOnClick` is false (default), clicking a row both selects it and fires `onRowClick`. The default should probably be `disableRowSelectionOnClick: true` when `onRowClick` is also provided. |
28
+ | 18 | Potential Issue | `getRowId` fallback uses index — breaks selection on reorder/filter | 🟡 | If users don't provide `getRowId` and data changes (filter, sort, paginate), selection state becomes stale because index-based IDs shift. Consider logging a dev warning when `selection` is used without `getRowId`. |
29
+ | 19 | API | `loading.loadingLabel` only applies to skeleton/overlay mode | 🟢 | When `loadingState` is a custom ReactNode, there's no mechanism to announce loading to ATs. The `aria-busy` on the table partially covers this but `aria-live` region would be more robust. |
30
+ | 20 | API | `detailsPanel.getHeight` returns `number \| "auto"` — inconsistent with CSS patterns | 🟢 | Consider accepting a CSS value string (`"200px"`, `"auto"`) or always `number` (pixels). The mixed type works but requires the consumer to handle units. |
31
+ | 21 | A11y | Details panel row `aria-controls` relationship from toggle to content | 🟢 | The expansion button has `aria-controls={expansionId}` and the panel `<td>` has the matching `id`. Correctly implemented. ✓ No issue. |
32
+ | 22 | Code Quality | `@ts-expect-error` for Slot ref in `TableElementWrapper` | 🟢 | Minor tech debt. Consider typing the Slot component to accept ref properly. |
33
+ | 23 | API | No `onRowDoubleClick` or `onCellClick` callbacks | 🟢 | Common in MUI DataGrid. Not needed for beta but worth considering for GA. |
34
+ | 24 | Potential Issue | Sort `onSortChange` may double-fire in controlled mode | 🟡 | In `useTableSort`, `setSort(next)` is called and then `onSortChange?.(next, detail)` separately. If `useControllableState` invokes `onChange` internally, `onSortChange` fires twice in controlled mode. Verify. |
35
+ | 25 | API | `selection` prop type accepts partial object with no `selectionMode` | 🟡 | `SelectionProps` has `selectionMode?: "none" \| "single" \| "multiple"` defaulting to `"none"`. Passing `selection={{}}` without `selectionMode` silently does nothing. Consider requiring `selectionMode` when `selection` is provided (discriminated union). |
36
+ | 26 | Potential Issue | Keyboard nav `focusInitialTableTarget` always focuses first cell (including header) | 🟢 | Initial focus can go to the first data cell. Currently goes to first `td`/`th` which may be the selection header cell. Minor UX concern. |
37
+ | 27 | A11y | Resize handle uses `role="slider"` without `aria-valuemin`/`aria-valuemax` | 🟡 | ARIA slider requires `aria-valuemin` and `aria-valuemax`. Currently only `aria-valuenow` is set. Screen readers may not announce the range correctly. |
38
+
39
+ ---
40
+
41
+ ## Details
42
+
43
+ ### Finding #2 — Missing `aria-selected`
44
+
45
+ ```tsx
46
+ // In DataTableTr, add:
47
+ <tr
48
+ {...rest}
49
+ aria-selected={selected || undefined}
50
+ // ...existing props
51
+ >
52
+ ```
53
+
54
+ ### Finding #7 — `disableRowSelection` API
55
+
56
+ Current signature:
57
+
58
+ ```ts
59
+ disableRowSelection?: (({ row, id }: { row: T; id: string | number }) => boolean) | boolean;
60
+ ```
61
+
62
+ Stories use:
63
+
64
+ ```tsx
65
+ disableRowSelection: ({ id }) => id === 2 || id === 1;
66
+ ```
67
+
68
+ Recommended rename for clarity (breaking but pre-beta):
69
+
70
+ ```ts
71
+ isRowSelectionDisabled?: (row: T, id: string | number) => boolean;
72
+ // OR (React Aria style):
73
+ disabledKeys?: (string | number)[];
74
+ ```
75
+
76
+ ### Finding #24 — Possible double-fire of `onSortChange`
77
+
78
+ In `useTableSort`:
79
+
80
+ ```ts
81
+ const handleSortClick = useCallback((id, event) => {
82
+ // ...
83
+ setSort(next); // If controlled, useControllableState calls onChange
84
+ onSortChange?.(next, detail); // Also called explicitly
85
+ }, [...]);
86
+ ```
87
+
88
+ If `useControllableState` invokes `onChange` when the `value` prop changes, `onSortChange` is called twice. Verify by checking if `useControllableState` has its own `onChange` invocation path. If it does, remove the explicit `onSortChange` call and pass it as `onChange` to `useControllableState`.
89
+
90
+ ---
91
+
92
+ ## API & Developer Experience Analysis
93
+
94
+ ### Overall API shape
95
+
96
+ The top-level API uses a **data-driven pattern** — you pass `data` + `columnDefinitions` and the component renders everything. This is the right choice for a "batteries included" table. The prop surface splits into:
97
+
98
+ - **Core:** `data`, `columnDefinitions`, `getRowId`
99
+ - **Features (objects):** `selection`, `loading`, `detailsPanel`, `subRows`, `stickyColumns`
100
+ - **Features (flat):** `sort`, `defaultSort`, `onSortChange`, `onRowClick`, `withKeyboardNav`
101
+ - **Appearance:** `rowDensity`, `zebraStripes`, `truncateContent`, `textSize`, `layout`
102
+
103
+ This is generally good — feature-objects group related props, and appearance props are flat. However there are some inconsistencies.
104
+
105
+ ### Findings: API & DX
106
+
107
+ | # | Category | Finding | Severity | Recommendation |
108
+ | --- | -------- | -------------------------------------------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
109
+ | 28 | DX | `header` vs `label` in ColumnDefinition is confusing | 🟡 | Both exist on every column. `label` is required and used for a11y/sort button labels. `header` is optional and overrides what's rendered. Developers will ask "which one is my header text?" Consider: `header` (required, replaces current `label`) + `headerContent` or just always use `header` for rendering and `aria-label` when the header is non-textual. |
110
+ | 29 | DX | `selection` vs sort props use different grouping patterns | 🟡 | Selection is grouped: `selection={{ selectionMode, onSelectionChange, ... }}`. Sort is flat: `sort`, `defaultSort`, `onSortChange`. This inconsistency will confuse devs. Either group sort (`sort={{ state, defaultState, onChange }}`) or flatten selection. Since sort also uses `detail` parameter, the flat pattern is defensible, but be consistent — pick one and apply it everywhere. |
111
+ | 30 | DX | `ColumnDefinition` mixes rendering, behavior, and sizing concerns | 🟢 | A single column def contains `cell`, `header`, `label`, `sortable`, `align`, `resizable`, `width`, `defaultWidth`, `autoWidth`, `minWidth`, `maxWidth`, `onWidthChange`, `isRowHeader`, `details`. That's 14+ properties. For beta this is fine (flat = discoverable), but for GA consider splitting into `column.sizing` or using separate configuration layers for power users. |
112
+ | 31 | DX | `detailsPanel` and `subRows` both have `expandedRowIds`/`defaultExpandedRowIds`/`onExpandedRowIdsChange` | 🟡 | Same prop names exist in both objects. When both features are used together (`NestedRowsWithMasterDetail`), developers must understand these are independent expansion states. The naming collision makes this unclear. Consider `detailsPanel.expandedRowIds` staying as-is but subRows using `expandedSubRowIds` or documenting clearly that they're independent. |
113
+ | 32 | DX | Resize props pollute column definition for non-resizable tables | 🟢 | When `layout="auto"`, resize props (`resizable`, `width`, `defaultWidth`, `autoWidth`, `minWidth`, `maxWidth`, `onWidthChange`) are all ignored. Developers may set them without realizing they have no effect. The JSDoc on `resizable` mentions this, but it's easy to miss. |
114
+ | 33 | DX | `getRowId` return type `string \| number` makes controlled selection awkward | 🟡 | `selectedKeys` is `(string \| number)[]`. If `getRowId` returns a number (like `row.id`), the consumer can pass `selectedKeys: [1, 2]` fine. But if they later compare with `===`, `string` vs `number` mismatches bite. TanStack Table uses `string` only for row IDs. Consider normalizing to `string` internally (with automatic `String()` coercion) or staying `number` only — pick one. |
115
+ | 34 | DX | No way to hide/show columns dynamically | 🟡 | Consumers must filter `columnDefinitions` array externally to toggle column visibility. This is fine API-wise (keep it data-driven), but should be documented as the expected pattern. The `Data.settings.stories.tsx` likely shows this but it's not obvious from the types alone. |
116
+ | 35 | DX | `loading` object has confusing interaction between its props | 🟡 | Three modes: (1) `isLoading + loadingState` → custom content, (2) `isLoading + loadingRows` → skeletons, (3) `isLoading` alone → overlay on existing data. These modes are implicit from which subset of props you pass. A discriminated union would make intent explicit, but adds verbosity. At minimum, JSDoc should clearly document "if you pass X, Y is ignored." |
117
+ | 36 | DX | `withKeyboardNav` defaults to `true` — unexpected for simple tables | 🟢 | Most table components default keyboard nav to off. When devs use DataTable for a simple read-only table, the `tabIndex=0` and arrow-key behavior is unexpected. Consider defaulting to `false` or auto-enabling only when interactive features (selection, sorting) are present. |
118
+ | 37 | DX | `onRowClick` doesn't convey which row data was clicked | 🟡 | Signature is `(rowId, event) => void`. Consumers must look up `rowId` in their own data array to get the row object. Consider `(rowData: T, rowId, event) => void` — this is what MUI and TanStack expose. Avoids forcing an O(n) lookup. |
119
+ | 38 | DX | `isRowHeader` on ColumnDefinition has no enforcement or guidance | 🟢 | JSDoc says "each row should have one rowheader" but nothing prevents 0 or many. This is a documentation issue, not a code issue. Consider a dev-mode warning if no column has `isRowHeader: true`. |
120
+
121
+ ### What's working well (keep as-is)
122
+
123
+ - **Controlled/uncontrolled pattern** is consistent across selection, sort, sub-rows expansion, and details panel expansion. All use `value`/`defaultValue`/`onChange` semantics.
124
+ - **`getRowId`** — good that it's optional with a sensible fallback, and the JSDoc warns about the tradeoff.
125
+ - **`columnDefinitions` as a typed array** — gives excellent autocomplete and catches typos at compile time.
126
+ - **`selection.selectionMode`** driving the UI (checkbox vs radio) automatically — reduces decision surface.
127
+ - **Sort cycling** (none → asc → desc → none) with shift-click for multi-sort is well thought out.
128
+ - **Feature-as-object pattern** (`loading`, `selection`, `detailsPanel`, `subRows`) — good discoverability, scales well for adding future options.
129
+
130
+ ---
131
+
132
+ ## Priority Summary
133
+
134
+ ### 🔴 Beta Blockers (must fix)
135
+
136
+ 1. **#2** — Add `aria-selected` on selected rows
137
+ 2. **#7** — Resolve `disableRowSelection` API inconsistency (breaking change is OK pre-beta)
138
+ 3. **#16** — Verify `fullWidthColSpan` correctness with combined subRows + detailsPanel
139
+
140
+ ### 🟡 Should Fix Before Beta
141
+
142
+ 5. **#3** — Require/encourage table label
143
+ 6. **#4** — Externalize hardcoded Norwegian strings
144
+ 7. **#5** — `role="treegrid"` for sub-rows
145
+ 8. **#8** — `stickyColumns` type to `number`
146
+ 9. **#11** — `aria-rowcount` for paginated tables
147
+ 10. **#12** — Verify "select all" behavior with pagination
148
+ 11. **#17** — Default `disableRowSelectionOnClick: true` when `onRowClick` is set
149
+ 12. **#18** — Dev warning for selection without `getRowId`
150
+ 13. **#24** — Verify sort `onSortChange` double-fire
151
+ 14. **#25** — Make `selectionMode` required when `selection` is provided
152
+ 15. **#27** — Add `aria-valuemin`/`aria-valuemax` to resize slider
153
+ 16. **#28** — Clarify `header` vs `label` in ColumnDefinition
154
+ 17. **#29** — Decide on consistent grouping pattern (flat vs object) for features
155
+ 18. **#31** — Disambiguate `expandedRowIds` between subRows and detailsPanel
156
+ 19. **#33** — Normalize row ID type (string-only or document clearly)
157
+ 20. **#35** — Document loading prop interactions or use discriminated union
158
+ 21. **#37** — Add `rowData` to `onRowClick` callback signature
159
+
160
+ ### 🟢 Post-Beta / GA
161
+
162
+ 22. **#9** — Consider grouping sort props
163
+ 23. **#10** — Compositional/slot API
164
+ 24. **#15** — Virtualization
165
+ 25. **#19** — `aria-live` for loading announcements
166
+ 26. **#20** — `getHeight` type cleanup
167
+ 27. **#22** — Fix `@ts-expect-error` tech debt
168
+ 28. **#23** — `onRowDoubleClick`/`onCellClick`
169
+ 29. **#26** — Initial focus target
170
+ 30. **#14** — Performance for large tables (acceptable for beta)
171
+ 31. **#30** — Split ColumnDefinition into layers for power users
172
+ 32. **#32** — Warn when resize props used with `layout="auto"`
173
+ 33. **#34** — Document column visibility pattern
174
+ 34. **#36** — Consider `withKeyboardNav` default
175
+ 35. **#38** — Dev warning for missing `isRowHeader`
@@ -2,21 +2,23 @@ import React, { forwardRef } from "react";
2
2
  import { cl } from "../../../utils/helpers";
3
3
  import { useDataTableContext } from "../root/DataTableRoot.context";
4
4
 
5
- interface DataTableBaseCellProps extends React.HTMLAttributes<HTMLTableCellElement> {
5
+ interface DataTableBaseCellProps extends Omit<
6
+ React.TdHTMLAttributes<HTMLTableCellElement>,
7
+ "width"
8
+ > {
6
9
  /**
7
- * Content alignment inside cell
10
+ * Content alignment inside cell.
11
+ *
12
+ * Quantitative figures like amounts and percentages should be right‑aligned (but not phone numbers, postal codes etc.)
8
13
  * @default "left"
9
14
  */
10
15
  textAlign?: "left" | "center" | "right";
11
16
  /**
12
- * TODO: Shouldnt be needed to declare these here... But getting type-errors if not
17
+ * Internal cell type that controls padding, alignment, row-click prevention, and resize behavior.
18
+ * - `"action"`: Centers content, removes cell padding, prevents row click, and disables column resize.
19
+ * Used for selection (checkbox/radio) and expansion (expand/collapse) cells.
13
20
  */
14
- colSpan?: number;
15
- rowSpan?: number;
16
- /**
17
- * Temp hack to solve overflow and alignment
18
- */
19
- UNSAFE_isSelection?: boolean;
21
+ cellType?: "action";
20
22
  /**
21
23
  * When true, clicking this cell will not trigger `onRowClick` on the row.
22
24
  * Useful for cells that contain their own interactive content or actions
@@ -28,18 +30,13 @@ interface DataTableBaseCellProps extends React.HTMLAttributes<HTMLTableCellEleme
28
30
  * This is only needed when using `layout="auto"` together with
29
31
  * `truncateContent` on `<DataTable>` and you want the cell to be truncated.
30
32
  */
31
- contentMaxWidth?: number | `${number}${string}`;
33
+ contentMaxWidth?: number | string;
32
34
  /**
33
35
  * Makes the cell sticky.
34
36
  */
35
37
  isSticky?: "start" | "end" | false;
36
38
  }
37
39
 
38
- /**
39
- * TODO:
40
- * - Need a "type" or something that centers content instead of relying on isSelection prop.
41
- * - Need a separate prop do disabled resizing instead of relying on isSelection prop.
42
- */
43
40
  const DataTableBaseCell = forwardRef<
44
41
  HTMLTableCellElement,
45
42
  DataTableBaseCellProps & {
@@ -47,6 +44,12 @@ const DataTableBaseCell = forwardRef<
47
44
  * Cell type
48
45
  */
49
46
  as: "th" | "td";
47
+ /**
48
+ * Content to render before the main cell content.
49
+ *
50
+ * **WARNING: Adding content here that takes up space will probably break auto-resizing!**
51
+ */
52
+ beforeContent?: React.ReactNode;
50
53
  }
51
54
  >(
52
55
  (
@@ -54,13 +57,14 @@ const DataTableBaseCell = forwardRef<
54
57
  className,
55
58
  children,
56
59
  as: Component,
60
+ beforeContent,
57
61
  textAlign = "left",
58
- colSpan,
59
- UNSAFE_isSelection,
62
+ cellType,
60
63
  preventRowClick,
61
64
  contentMaxWidth,
62
- rowSpan,
63
65
  isSticky,
66
+ colSpan,
67
+ rowSpan,
64
68
  ...rest
65
69
  },
66
70
  forwardedRef,
@@ -74,15 +78,21 @@ const DataTableBaseCell = forwardRef<
74
78
  className={cl("aksel-data-table__cell", className)}
75
79
  tabIndex={withKeyboardNav ? -1 : undefined}
76
80
  data-align={textAlign}
77
- data-selectable={UNSAFE_isSelection}
81
+ data-cell-type={cellType || undefined}
78
82
  data-prevent-row-click={
79
- preventRowClick || UNSAFE_isSelection || undefined
83
+ preventRowClick || cellType === "action" || undefined
80
84
  }
81
85
  data-sticky={isSticky || undefined}
82
86
  colSpan={colSpan}
83
87
  rowSpan={rowSpan}
84
88
  >
85
- <div style={{ maxWidth: contentMaxWidth }}>{children}</div>
89
+ {beforeContent}
90
+ <div
91
+ className="aksel-data-table__cell-content"
92
+ style={{ maxWidth: contentMaxWidth }}
93
+ >
94
+ {children}
95
+ </div>
86
96
  </Component>
87
97
  );
88
98
  },