@dashforge/tw 1.1.0 → 1.1.1

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 (390) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/index.esm.js +1 -1
  3. package/dist/src/index.d.ts +1 -1
  4. package/package.json +8 -3
  5. package/.swcrc +0 -29
  6. package/A11Y.md +0 -130
  7. package/CONSUMER-VALIDATION.md +0 -130
  8. package/COVERAGE.md +0 -63
  9. package/PARITY.md +0 -481
  10. package/PERFORMANCE.md +0 -227
  11. package/REFINEMENT-NOTES.md +0 -50
  12. package/THEME-AUDIT.md +0 -174
  13. package/dashforge-tw-1.0.0.tgz +0 -0
  14. package/eslint.config.mjs +0 -62
  15. package/project.json +0 -15
  16. package/rollup.config.cjs +0 -16
  17. package/src/components/Accordion/Accordion.test.tsx +0 -95
  18. package/src/components/Accordion/Accordion.tsx +0 -97
  19. package/src/components/Accordion/accordion.types.ts +0 -66
  20. package/src/components/Accordion/accordion.variants.ts +0 -32
  21. package/src/components/Alert/Alert.test.tsx +0 -302
  22. package/src/components/Alert/Alert.tsx +0 -186
  23. package/src/components/Alert/alert.types.ts +0 -144
  24. package/src/components/Alert/alert.variants.ts +0 -71
  25. package/src/components/AppShell/AppShell.test.tsx +0 -223
  26. package/src/components/AppShell/AppShell.tsx +0 -239
  27. package/src/components/AppShell/appShell.types.ts +0 -49
  28. package/src/components/AppShell/appShell.variants.ts +0 -54
  29. package/src/components/AspectRatio/AspectRatio.test.tsx +0 -173
  30. package/src/components/AspectRatio/AspectRatio.tsx +0 -73
  31. package/src/components/AspectRatio/aspectRatio.types.ts +0 -54
  32. package/src/components/Autocomplete/Autocomplete.perf.test.tsx +0 -225
  33. package/src/components/Autocomplete/Autocomplete.test.tsx +0 -556
  34. package/src/components/Autocomplete/Autocomplete.tsx +0 -1069
  35. package/src/components/Autocomplete/autocomplete.types.ts +0 -198
  36. package/src/components/Autocomplete/autocomplete.variants.ts +0 -141
  37. package/src/components/Avatar/Avatar.test.tsx +0 -287
  38. package/src/components/Avatar/Avatar.tsx +0 -304
  39. package/src/components/Avatar/avatar.types.ts +0 -205
  40. package/src/components/Avatar/avatar.variants.ts +0 -194
  41. package/src/components/Badge/Badge.test.tsx +0 -385
  42. package/src/components/Badge/Badge.tsx +0 -174
  43. package/src/components/Badge/badge.types.ts +0 -154
  44. package/src/components/Badge/badge.variants.ts +0 -161
  45. package/src/components/Box/Box.test.tsx +0 -391
  46. package/src/components/Box/Box.tsx +0 -112
  47. package/src/components/Box/box.types.ts +0 -116
  48. package/src/components/Box/box.variants.ts +0 -230
  49. package/src/components/Breadcrumbs/Breadcrumbs.perf.test.tsx +0 -128
  50. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +0 -231
  51. package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -203
  52. package/src/components/Breadcrumbs/breadcrumbs.types.ts +0 -87
  53. package/src/components/Breadcrumbs/breadcrumbs.variants.ts +0 -54
  54. package/src/components/Button/Button.test.tsx +0 -204
  55. package/src/components/Button/Button.tsx +0 -151
  56. package/src/components/Button/button.types.ts +0 -110
  57. package/src/components/Button/button.variants.ts +0 -159
  58. package/src/components/Calendar/Calendar.test.tsx +0 -75
  59. package/src/components/Calendar/Calendar.tsx +0 -264
  60. package/src/components/Calendar/calendar.types.ts +0 -65
  61. package/src/components/Calendar/calendar.variants.ts +0 -64
  62. package/src/components/Card/Card.test.tsx +0 -291
  63. package/src/components/Card/Card.tsx +0 -241
  64. package/src/components/Card/card.types.ts +0 -132
  65. package/src/components/Checkbox/Checkbox.test.tsx +0 -146
  66. package/src/components/Checkbox/Checkbox.tsx +0 -286
  67. package/src/components/Checkbox/checkbox.types.ts +0 -88
  68. package/src/components/Checkbox/checkbox.variants.ts +0 -68
  69. package/src/components/Chip/Chip.test.tsx +0 -316
  70. package/src/components/Chip/Chip.tsx +0 -224
  71. package/src/components/Chip/chip.types.ts +0 -128
  72. package/src/components/Chip/chip.variants.ts +0 -173
  73. package/src/components/ConfirmDialog/ConfirmDialog.perf.test.tsx +0 -172
  74. package/src/components/ConfirmDialog/ConfirmDialog.test.tsx +0 -311
  75. package/src/components/ConfirmDialog/ConfirmDialog.tsx +0 -252
  76. package/src/components/ConfirmDialog/confirmDialog.types.ts +0 -70
  77. package/src/components/ConfirmDialog/confirmDialog.variants.ts +0 -76
  78. package/src/components/Container/Container.test.tsx +0 -209
  79. package/src/components/Container/Container.tsx +0 -74
  80. package/src/components/Container/container.types.ts +0 -45
  81. package/src/components/Container/container.variants.ts +0 -81
  82. package/src/components/DataGrid/DataGrid.perf.test.tsx +0 -114
  83. package/src/components/DataGrid/DataGrid.test.tsx +0 -1153
  84. package/src/components/DataGrid/DataGrid.tsx +0 -1282
  85. package/src/components/DataGrid/dataGrid.types.ts +0 -238
  86. package/src/components/DataGrid/dataGrid.variants.ts +0 -152
  87. package/src/components/DataGrid/filters/ColumnFilters.test.tsx +0 -330
  88. package/src/components/DataGrid/filters/ColumnFilters.tsx +0 -456
  89. package/src/components/DataGrid/reorder/useColumnReorder.test.ts +0 -130
  90. package/src/components/DataGrid/reorder/useColumnReorder.ts +0 -144
  91. package/src/components/DataGrid/resize/useColumnResize.test.ts +0 -144
  92. package/src/components/DataGrid/resize/useColumnResize.ts +0 -135
  93. package/src/components/DataGrid/visibility/ColumnVisibilityMenu.tsx +0 -186
  94. package/src/components/DatePicker/DatePicker.test.tsx +0 -76
  95. package/src/components/DatePicker/DatePicker.tsx +0 -305
  96. package/src/components/DatePicker/datePicker.types.ts +0 -77
  97. package/src/components/DatePicker/datePicker.variants.ts +0 -50
  98. package/src/components/DateRangePicker/DateRangePicker.test.tsx +0 -92
  99. package/src/components/DateRangePicker/DateRangePicker.tsx +0 -510
  100. package/src/components/DateRangePicker/dateRangePicker.types.ts +0 -74
  101. package/src/components/DateRangePicker/dateRangePicker.variants.ts +0 -101
  102. package/src/components/DateTimePicker/DateTimePicker.test.tsx +0 -78
  103. package/src/components/DateTimePicker/DateTimePicker.tsx +0 -347
  104. package/src/components/DateTimePicker/dateTimePicker.types.ts +0 -79
  105. package/src/components/DateTimePicker/dateTimePicker.variants.ts +0 -55
  106. package/src/components/Dialog/Dialog.test.tsx +0 -96
  107. package/src/components/Dialog/Dialog.tsx +0 -102
  108. package/src/components/Dialog/dialog.types.ts +0 -62
  109. package/src/components/Dialog/dialog.variants.ts +0 -66
  110. package/src/components/Divider/Divider.test.tsx +0 -243
  111. package/src/components/Divider/Divider.tsx +0 -140
  112. package/src/components/Divider/divider.types.ts +0 -52
  113. package/src/components/Divider/divider.variants.ts +0 -116
  114. package/src/components/Grid/Grid.test.tsx +0 -321
  115. package/src/components/Grid/Grid.tsx +0 -148
  116. package/src/components/Grid/grid.types.ts +0 -112
  117. package/src/components/Grid/grid.variants.ts +0 -133
  118. package/src/components/IconButton/IconButton.test.tsx +0 -367
  119. package/src/components/IconButton/IconButton.tsx +0 -159
  120. package/src/components/IconButton/iconButton.types.ts +0 -106
  121. package/src/components/IconButton/iconButton.variants.ts +0 -31
  122. package/src/components/LeftNav/LeftNav.perf.test.tsx +0 -172
  123. package/src/components/LeftNav/LeftNav.test.tsx +0 -302
  124. package/src/components/LeftNav/LeftNav.tsx +0 -330
  125. package/src/components/LeftNav/leftNav.types.ts +0 -120
  126. package/src/components/LeftNav/leftNav.variants.ts +0 -107
  127. package/src/components/Menu/Menu.test.tsx +0 -408
  128. package/src/components/Menu/Menu.tsx +0 -335
  129. package/src/components/Menu/menu.types.ts +0 -221
  130. package/src/components/Menu/menu.variants.ts +0 -132
  131. package/src/components/NumberField/NumberField.test.tsx +0 -83
  132. package/src/components/NumberField/NumberField.tsx +0 -321
  133. package/src/components/NumberField/numberField.types.ts +0 -72
  134. package/src/components/NumberField/numberField.variants.ts +0 -94
  135. package/src/components/OTPField/OTPField.test.tsx +0 -121
  136. package/src/components/OTPField/OTPField.tsx +0 -250
  137. package/src/components/OTPField/otpField.types.ts +0 -58
  138. package/src/components/OTPField/otpField.variants.ts +0 -72
  139. package/src/components/Pagination/Pagination.test.tsx +0 -314
  140. package/src/components/Pagination/Pagination.tsx +0 -277
  141. package/src/components/Pagination/pagination.helpers.ts +0 -102
  142. package/src/components/Pagination/pagination.types.ts +0 -117
  143. package/src/components/Pagination/pagination.variants.ts +0 -117
  144. package/src/components/Popover/Popover.test.tsx +0 -72
  145. package/src/components/Popover/Popover.tsx +0 -55
  146. package/src/components/Popover/popover.types.ts +0 -42
  147. package/src/components/Popover/popover.variants.ts +0 -24
  148. package/src/components/RadioGroup/RadioGroup.test.tsx +0 -140
  149. package/src/components/RadioGroup/RadioGroup.tsx +0 -283
  150. package/src/components/RadioGroup/radioGroup.types.ts +0 -85
  151. package/src/components/RadioGroup/radioGroup.variants.ts +0 -87
  152. package/src/components/Skeleton/Skeleton.test.tsx +0 -127
  153. package/src/components/Skeleton/Skeleton.tsx +0 -49
  154. package/src/components/Skeleton/skeleton.types.ts +0 -59
  155. package/src/components/Skeleton/skeleton.variants.ts +0 -87
  156. package/src/components/Snackbar/Snackbar.perf.test.tsx +0 -144
  157. package/src/components/Snackbar/Snackbar.test.tsx +0 -327
  158. package/src/components/Snackbar/Snackbar.tsx +0 -316
  159. package/src/components/Snackbar/snackbar.types.ts +0 -127
  160. package/src/components/Snackbar/snackbar.variants.ts +0 -81
  161. package/src/components/Spinner/Spinner.test.tsx +0 -199
  162. package/src/components/Spinner/Spinner.tsx +0 -158
  163. package/src/components/Spinner/spinner.types.ts +0 -113
  164. package/src/components/Spinner/spinner.variants.ts +0 -83
  165. package/src/components/Stack/Stack.test.tsx +0 -309
  166. package/src/components/Stack/Stack.tsx +0 -115
  167. package/src/components/Stack/stack.types.ts +0 -68
  168. package/src/components/Stack/stack.variants.ts +0 -80
  169. package/src/components/Switch/Switch.test.tsx +0 -131
  170. package/src/components/Switch/Switch.tsx +0 -158
  171. package/src/components/Switch/switch.types.ts +0 -36
  172. package/src/components/Switch/switch.variants.ts +0 -70
  173. package/src/components/Table/Table.perf.test.tsx +0 -81
  174. package/src/components/Table/Table.test.tsx +0 -674
  175. package/src/components/Table/Table.tsx +0 -863
  176. package/src/components/Table/cells/RenderButton.tsx +0 -23
  177. package/src/components/Table/cells/RenderChip.tsx +0 -37
  178. package/src/components/Table/cells/RenderText.tsx +0 -37
  179. package/src/components/Table/cells/RenderTwoLine.tsx +0 -34
  180. package/src/components/Table/cells/RowActionsMenu.tsx +0 -147
  181. package/src/components/Table/cells/cells.test.tsx +0 -247
  182. package/src/components/Table/cells/index.ts +0 -14
  183. package/src/components/Table/table.types.ts +0 -438
  184. package/src/components/Table/table.variants.ts +0 -207
  185. package/src/components/Tabs/Tabs.test.tsx +0 -145
  186. package/src/components/Tabs/Tabs.tsx +0 -77
  187. package/src/components/Tabs/tabs.types.ts +0 -55
  188. package/src/components/Tabs/tabs.variants.ts +0 -69
  189. package/src/components/Tabs/useTabs.ts +0 -167
  190. package/src/components/TextField/TextField.test.tsx +0 -198
  191. package/src/components/TextField/TextField.tsx +0 -245
  192. package/src/components/TextField/textField.types.ts +0 -90
  193. package/src/components/TextField/textField.variants.ts +0 -105
  194. package/src/components/Textarea/Textarea.test.tsx +0 -75
  195. package/src/components/Textarea/Textarea.tsx +0 -190
  196. package/src/components/Textarea/textarea.types.ts +0 -60
  197. package/src/components/Textarea/textarea.variants.ts +0 -85
  198. package/src/components/TimePicker/TimePicker.test.tsx +0 -65
  199. package/src/components/TimePicker/TimePicker.tsx +0 -274
  200. package/src/components/TimePicker/timePicker.types.ts +0 -69
  201. package/src/components/TimePicker/timePicker.variants.ts +0 -53
  202. package/src/components/Tooltip/Tooltip.test.tsx +0 -73
  203. package/src/components/Tooltip/Tooltip.tsx +0 -70
  204. package/src/components/Tooltip/tooltip.types.ts +0 -44
  205. package/src/components/Tooltip/tooltip.variants.ts +0 -28
  206. package/src/components/TopBar/TopBar.test.tsx +0 -129
  207. package/src/components/TopBar/TopBar.tsx +0 -66
  208. package/src/components/TopBar/topBar.types.ts +0 -42
  209. package/src/components/TopBar/topBar.variants.ts +0 -38
  210. package/src/components/Typography/Typography.test.tsx +0 -247
  211. package/src/components/Typography/Typography.tsx +0 -112
  212. package/src/components/Typography/typography.types.ts +0 -65
  213. package/src/components/Typography/typography.variants.ts +0 -130
  214. package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +0 -86
  215. package/src/components/VisuallyHidden/VisuallyHidden.tsx +0 -59
  216. package/src/components/VisuallyHidden/visuallyHidden.types.ts +0 -45
  217. package/src/components/_shared/data/getNestedValue.test.ts +0 -50
  218. package/src/components/_shared/data/getNestedValue.ts +0 -32
  219. package/src/components/_shared/data/useColumnAutoDetect.test.ts +0 -123
  220. package/src/components/_shared/data/useColumnAutoDetect.ts +0 -100
  221. package/src/components/_shared/data/useControllableState.ts +0 -48
  222. package/src/components/_shared/data/useDebouncedValue.ts +0 -24
  223. package/src/components/_shared/data/useTableFilter.test.ts +0 -166
  224. package/src/components/_shared/data/useTableFilter.ts +0 -118
  225. package/src/components/_shared/data/useTableSearch.test.ts +0 -115
  226. package/src/components/_shared/data/useTableSearch.ts +0 -66
  227. package/src/components/_shared/data/useTableSelection.test.ts +0 -100
  228. package/src/components/_shared/data/useTableSelection.ts +0 -100
  229. package/src/components/_shared/data/useTableSort.test.ts +0 -150
  230. package/src/components/_shared/data/useTableSort.ts +0 -141
  231. package/src/components/_shared/data/useVirtualizer.test.ts +0 -158
  232. package/src/components/_shared/data/useVirtualizer.ts +0 -199
  233. package/src/components/_shared/resolveValidationState.ts +0 -60
  234. package/src/components/_shared/severity/index.ts +0 -33
  235. package/src/components/_shared/severity/severity.types.ts +0 -50
  236. package/src/components/_shared/severity/severityIcons.tsx +0 -104
  237. package/src/components/_shared/severity/severityVariants.test.ts +0 -136
  238. package/src/components/_shared/severity/severityVariants.ts +0 -115
  239. package/src/components/_shared/themeIdentity.test.ts +0 -113
  240. package/src/hooks/useAccessState.spec.tsx +0 -161
  241. package/src/hooks/useAccessState.ts +0 -81
  242. package/src/index.ts +0 -550
  243. package/src/utils/cn.spec.ts +0 -16
  244. package/src/utils/cn.ts +0 -29
  245. package/test-output/vitest/coverage/base.css +0 -224
  246. package/test-output/vitest/coverage/block-navigation.js +0 -87
  247. package/test-output/vitest/coverage/clover.xml +0 -2418
  248. package/test-output/vitest/coverage/coverage-final.json +0 -89
  249. package/test-output/vitest/coverage/favicon.png +0 -0
  250. package/test-output/vitest/coverage/index.html +0 -746
  251. package/test-output/vitest/coverage/prettify.css +0 -1
  252. package/test-output/vitest/coverage/prettify.js +0 -2
  253. package/test-output/vitest/coverage/sort-arrow-sprite.png +0 -0
  254. package/test-output/vitest/coverage/sorter.js +0 -210
  255. package/test-output/vitest/coverage/src/components/Accordion/Accordion.tsx.html +0 -376
  256. package/test-output/vitest/coverage/src/components/Accordion/accordion.variants.ts.html +0 -181
  257. package/test-output/vitest/coverage/src/components/Accordion/index.html +0 -131
  258. package/test-output/vitest/coverage/src/components/AppShell/AppShell.tsx.html +0 -802
  259. package/test-output/vitest/coverage/src/components/AppShell/appShell.variants.ts.html +0 -247
  260. package/test-output/vitest/coverage/src/components/AppShell/index.html +0 -131
  261. package/test-output/vitest/coverage/src/components/AspectRatio/AspectRatio.tsx.html +0 -304
  262. package/test-output/vitest/coverage/src/components/AspectRatio/index.html +0 -116
  263. package/test-output/vitest/coverage/src/components/Autocomplete/Autocomplete.tsx.html +0 -3292
  264. package/test-output/vitest/coverage/src/components/Autocomplete/autocomplete.variants.ts.html +0 -508
  265. package/test-output/vitest/coverage/src/components/Autocomplete/index.html +0 -131
  266. package/test-output/vitest/coverage/src/components/Box/Box.tsx.html +0 -334
  267. package/test-output/vitest/coverage/src/components/Box/box.variants.ts.html +0 -775
  268. package/test-output/vitest/coverage/src/components/Box/index.html +0 -131
  269. package/test-output/vitest/coverage/src/components/Breadcrumbs/Breadcrumbs.tsx.html +0 -694
  270. package/test-output/vitest/coverage/src/components/Breadcrumbs/breadcrumbs.variants.ts.html +0 -247
  271. package/test-output/vitest/coverage/src/components/Breadcrumbs/index.html +0 -131
  272. package/test-output/vitest/coverage/src/components/Button/Button.tsx.html +0 -535
  273. package/test-output/vitest/coverage/src/components/Button/button.variants.ts.html +0 -562
  274. package/test-output/vitest/coverage/src/components/Button/index.html +0 -131
  275. package/test-output/vitest/coverage/src/components/Checkbox/Checkbox.tsx.html +0 -943
  276. package/test-output/vitest/coverage/src/components/Checkbox/checkbox.variants.ts.html +0 -289
  277. package/test-output/vitest/coverage/src/components/Checkbox/index.html +0 -131
  278. package/test-output/vitest/coverage/src/components/ConfirmDialog/ConfirmDialog.tsx.html +0 -841
  279. package/test-output/vitest/coverage/src/components/ConfirmDialog/confirmDialog.variants.ts.html +0 -313
  280. package/test-output/vitest/coverage/src/components/ConfirmDialog/index.html +0 -131
  281. package/test-output/vitest/coverage/src/components/Container/Container.tsx.html +0 -307
  282. package/test-output/vitest/coverage/src/components/Container/container.variants.ts.html +0 -328
  283. package/test-output/vitest/coverage/src/components/Container/index.html +0 -131
  284. package/test-output/vitest/coverage/src/components/DataGrid/DataGrid.tsx.html +0 -3937
  285. package/test-output/vitest/coverage/src/components/DataGrid/dataGrid.variants.ts.html +0 -541
  286. package/test-output/vitest/coverage/src/components/DataGrid/filters/ColumnFilters.tsx.html +0 -1453
  287. package/test-output/vitest/coverage/src/components/DataGrid/filters/index.html +0 -116
  288. package/test-output/vitest/coverage/src/components/DataGrid/index.html +0 -131
  289. package/test-output/vitest/coverage/src/components/DataGrid/reorder/index.html +0 -116
  290. package/test-output/vitest/coverage/src/components/DataGrid/reorder/useColumnReorder.ts.html +0 -517
  291. package/test-output/vitest/coverage/src/components/DataGrid/resize/index.html +0 -116
  292. package/test-output/vitest/coverage/src/components/DataGrid/resize/useColumnResize.ts.html +0 -490
  293. package/test-output/vitest/coverage/src/components/DataGrid/visibility/ColumnVisibilityMenu.tsx.html +0 -592
  294. package/test-output/vitest/coverage/src/components/DataGrid/visibility/index.html +0 -116
  295. package/test-output/vitest/coverage/src/components/DateTimePicker/DateTimePicker.tsx.html +0 -1042
  296. package/test-output/vitest/coverage/src/components/DateTimePicker/dateTimePicker.variants.ts.html +0 -337
  297. package/test-output/vitest/coverage/src/components/DateTimePicker/index.html +0 -131
  298. package/test-output/vitest/coverage/src/components/Dialog/Dialog.tsx.html +0 -391
  299. package/test-output/vitest/coverage/src/components/Dialog/dialog.variants.ts.html +0 -283
  300. package/test-output/vitest/coverage/src/components/Dialog/index.html +0 -131
  301. package/test-output/vitest/coverage/src/components/Divider/Divider.tsx.html +0 -505
  302. package/test-output/vitest/coverage/src/components/Divider/divider.variants.ts.html +0 -433
  303. package/test-output/vitest/coverage/src/components/Divider/index.html +0 -131
  304. package/test-output/vitest/coverage/src/components/Grid/Grid.tsx.html +0 -529
  305. package/test-output/vitest/coverage/src/components/Grid/grid.variants.ts.html +0 -484
  306. package/test-output/vitest/coverage/src/components/Grid/index.html +0 -131
  307. package/test-output/vitest/coverage/src/components/LeftNav/LeftNav.tsx.html +0 -1075
  308. package/test-output/vitest/coverage/src/components/LeftNav/index.html +0 -131
  309. package/test-output/vitest/coverage/src/components/LeftNav/leftNav.variants.ts.html +0 -406
  310. package/test-output/vitest/coverage/src/components/NumberField/NumberField.tsx.html +0 -1048
  311. package/test-output/vitest/coverage/src/components/NumberField/index.html +0 -131
  312. package/test-output/vitest/coverage/src/components/NumberField/numberField.variants.ts.html +0 -367
  313. package/test-output/vitest/coverage/src/components/OTPField/OTPField.tsx.html +0 -835
  314. package/test-output/vitest/coverage/src/components/OTPField/index.html +0 -131
  315. package/test-output/vitest/coverage/src/components/OTPField/otpField.variants.ts.html +0 -301
  316. package/test-output/vitest/coverage/src/components/Pagination/Pagination.tsx.html +0 -916
  317. package/test-output/vitest/coverage/src/components/Pagination/index.html +0 -146
  318. package/test-output/vitest/coverage/src/components/Pagination/pagination.helpers.ts.html +0 -391
  319. package/test-output/vitest/coverage/src/components/Pagination/pagination.variants.ts.html +0 -436
  320. package/test-output/vitest/coverage/src/components/Popover/Popover.tsx.html +0 -250
  321. package/test-output/vitest/coverage/src/components/Popover/index.html +0 -131
  322. package/test-output/vitest/coverage/src/components/Popover/popover.variants.ts.html +0 -157
  323. package/test-output/vitest/coverage/src/components/RadioGroup/RadioGroup.tsx.html +0 -934
  324. package/test-output/vitest/coverage/src/components/RadioGroup/index.html +0 -131
  325. package/test-output/vitest/coverage/src/components/RadioGroup/radioGroup.variants.ts.html +0 -346
  326. package/test-output/vitest/coverage/src/components/Skeleton/Skeleton.tsx.html +0 -232
  327. package/test-output/vitest/coverage/src/components/Skeleton/index.html +0 -131
  328. package/test-output/vitest/coverage/src/components/Skeleton/skeleton.variants.ts.html +0 -346
  329. package/test-output/vitest/coverage/src/components/Snackbar/Snackbar.tsx.html +0 -979
  330. package/test-output/vitest/coverage/src/components/Snackbar/index.html +0 -131
  331. package/test-output/vitest/coverage/src/components/Snackbar/snackbar.variants.ts.html +0 -307
  332. package/test-output/vitest/coverage/src/components/Stack/Stack.tsx.html +0 -430
  333. package/test-output/vitest/coverage/src/components/Stack/index.html +0 -131
  334. package/test-output/vitest/coverage/src/components/Stack/stack.variants.ts.html +0 -325
  335. package/test-output/vitest/coverage/src/components/Switch/Switch.tsx.html +0 -559
  336. package/test-output/vitest/coverage/src/components/Switch/index.html +0 -131
  337. package/test-output/vitest/coverage/src/components/Switch/switch.variants.ts.html +0 -295
  338. package/test-output/vitest/coverage/src/components/Table/Table.tsx.html +0 -2677
  339. package/test-output/vitest/coverage/src/components/Table/cells/RenderButton.tsx.html +0 -154
  340. package/test-output/vitest/coverage/src/components/Table/cells/RenderChip.tsx.html +0 -385
  341. package/test-output/vitest/coverage/src/components/Table/cells/RenderText.tsx.html +0 -196
  342. package/test-output/vitest/coverage/src/components/Table/cells/RenderTwoLine.tsx.html +0 -187
  343. package/test-output/vitest/coverage/src/components/Table/cells/RowActionsMenu.tsx.html +0 -526
  344. package/test-output/vitest/coverage/src/components/Table/cells/index.html +0 -191
  345. package/test-output/vitest/coverage/src/components/Table/cells/index.ts.html +0 -127
  346. package/test-output/vitest/coverage/src/components/Table/index.html +0 -131
  347. package/test-output/vitest/coverage/src/components/Table/table.variants.ts.html +0 -706
  348. package/test-output/vitest/coverage/src/components/Tabs/Tabs.tsx.html +0 -283
  349. package/test-output/vitest/coverage/src/components/Tabs/index.html +0 -131
  350. package/test-output/vitest/coverage/src/components/Tabs/tabs.variants.ts.html +0 -292
  351. package/test-output/vitest/coverage/src/components/TextField/TextField.tsx.html +0 -820
  352. package/test-output/vitest/coverage/src/components/TextField/index.html +0 -131
  353. package/test-output/vitest/coverage/src/components/TextField/textField.variants.ts.html +0 -400
  354. package/test-output/vitest/coverage/src/components/Textarea/Textarea.tsx.html +0 -655
  355. package/test-output/vitest/coverage/src/components/Textarea/index.html +0 -131
  356. package/test-output/vitest/coverage/src/components/Textarea/textarea.variants.ts.html +0 -340
  357. package/test-output/vitest/coverage/src/components/Tooltip/Tooltip.tsx.html +0 -295
  358. package/test-output/vitest/coverage/src/components/Tooltip/index.html +0 -131
  359. package/test-output/vitest/coverage/src/components/Tooltip/tooltip.variants.ts.html +0 -169
  360. package/test-output/vitest/coverage/src/components/TopBar/TopBar.tsx.html +0 -283
  361. package/test-output/vitest/coverage/src/components/TopBar/index.html +0 -131
  362. package/test-output/vitest/coverage/src/components/TopBar/topBar.variants.ts.html +0 -199
  363. package/test-output/vitest/coverage/src/components/Typography/Typography.tsx.html +0 -421
  364. package/test-output/vitest/coverage/src/components/Typography/index.html +0 -131
  365. package/test-output/vitest/coverage/src/components/Typography/typography.variants.ts.html +0 -436
  366. package/test-output/vitest/coverage/src/components/VisuallyHidden/VisuallyHidden.tsx.html +0 -262
  367. package/test-output/vitest/coverage/src/components/VisuallyHidden/index.html +0 -116
  368. package/test-output/vitest/coverage/src/components/_shared/data/getNestedValue.ts.html +0 -181
  369. package/test-output/vitest/coverage/src/components/_shared/data/index.html +0 -236
  370. package/test-output/vitest/coverage/src/components/_shared/data/useColumnAutoDetect.ts.html +0 -385
  371. package/test-output/vitest/coverage/src/components/_shared/data/useControllableState.ts.html +0 -229
  372. package/test-output/vitest/coverage/src/components/_shared/data/useDebouncedValue.ts.html +0 -157
  373. package/test-output/vitest/coverage/src/components/_shared/data/useTableFilter.ts.html +0 -439
  374. package/test-output/vitest/coverage/src/components/_shared/data/useTableSearch.ts.html +0 -283
  375. package/test-output/vitest/coverage/src/components/_shared/data/useTableSelection.ts.html +0 -385
  376. package/test-output/vitest/coverage/src/components/_shared/data/useTableSort.ts.html +0 -508
  377. package/test-output/vitest/coverage/src/components/_shared/data/useVirtualizer.ts.html +0 -682
  378. package/test-output/vitest/coverage/src/components/_shared/index.html +0 -116
  379. package/test-output/vitest/coverage/src/components/_shared/resolveValidationState.ts.html +0 -265
  380. package/test-output/vitest/coverage/src/hooks/index.html +0 -116
  381. package/test-output/vitest/coverage/src/hooks/useAccessState.ts.html +0 -328
  382. package/test-output/vitest/coverage/src/index.html +0 -116
  383. package/test-output/vitest/coverage/src/index.ts.html +0 -1153
  384. package/test-output/vitest/coverage/src/utils/cn.ts.html +0 -172
  385. package/test-output/vitest/coverage/src/utils/index.html +0 -116
  386. package/tsconfig.json +0 -13
  387. package/tsconfig.lib.json +0 -58
  388. package/tsconfig.spec.json +0 -34
  389. package/vite.config.ts +0 -33
  390. package/vitest.config.mts +0 -29
@@ -1,863 +0,0 @@
1
- import { useMemo, useEffect, type ReactNode, type MouseEvent } from 'react';
2
- import { cn } from '../../utils/cn.js';
3
- import { useAccessState } from '../../hooks/useAccessState.js';
4
- import { Skeleton } from '../Skeleton/Skeleton.js';
5
- import { tableVariants } from './table.variants.js';
6
- import { useControllableState } from '../_shared/data/useControllableState.js';
7
- import { useDebouncedValue } from '../_shared/data/useDebouncedValue.js';
8
- import { useTableSearch } from '../_shared/data/useTableSearch.js';
9
- import { useTableFilter } from '../_shared/data/useTableFilter.js';
10
- import { useTableSort, cycleSortFor } from '../_shared/data/useTableSort.js';
11
- import { useTableSelection } from '../_shared/data/useTableSelection.js';
12
- import { getNestedValue } from '../_shared/data/getNestedValue.js';
13
- import {
14
- useColumnAutoDetect,
15
- resolveAlign,
16
- resolveMonospace,
17
- resolveTabularNums,
18
- } from '../_shared/data/useColumnAutoDetect.js';
19
- import type {
20
- TableProps,
21
- TableColumn,
22
- TableSortModel,
23
- TableFilterModel,
24
- TableLabels,
25
- } from './table.types.js';
26
-
27
- const DEFAULT_LABELS: Required<TableLabels> = {
28
- searchPlaceholder: 'Search...',
29
- noData: 'No data',
30
- noResults: 'No matching results',
31
- loading: 'Loading…',
32
- ariaSortNone: 'Not sorted. Click to sort ascending.',
33
- ariaSortAscending: 'Sorted ascending. Click to sort descending.',
34
- ariaSortDescending: 'Sorted descending. Click to clear sort.',
35
- ariaSelectRow: 'Select row',
36
- ariaSelectAllRows: 'Select all rows',
37
- ariaExpandRow: 'Expand row',
38
- ariaCollapseRow: 'Collapse row',
39
- selectedCount: '{count} selected',
40
- clearSelection: 'Clear selection',
41
- filterColumn: 'Filter',
42
- filterApply: 'Apply',
43
- filterClear: 'Clear',
44
- filterMin: 'Min',
45
- filterMax: 'Max',
46
- filterFrom: 'From',
47
- filterTo: 'To',
48
- filterAll: 'All',
49
- filterTrue: 'True',
50
- filterFalse: 'False',
51
- density: 'Density',
52
- densityCompact: 'Compact',
53
- densityComfortable: 'Comfortable',
54
- densitySpacious: 'Spacious',
55
- columnsButton: 'Columns',
56
- columnsTitle: 'Toggle columns',
57
- columnsToggleAll: 'Toggle all columns',
58
- };
59
-
60
- const DEFAULT_GET_ROW_ID = <T extends object>(_row: T, index: number) => String(index);
61
-
62
- /**
63
- * Dashforge TW `<Table>` — declarative-first, market-grounded table.
64
- *
65
- * Design references:
66
- * - Visual: Stripe (clean line dividers, hover row actions, sticky header)
67
- * - Density: Pencil & Paper UX research (compact / comfortable / spacious)
68
- * - A11Y: W3C WAI Table tutorial (semantic `<table>`, scope, aria-sort)
69
- * - Column model: extended from Dashforge MUI Table existing API
70
- *
71
- * Smart defaults: column types auto-detected → numbers right-aligned
72
- * + tabular-nums, dates monospace, booleans center-aligned. Override
73
- * via explicit `align` / `monospace` per column.
74
- *
75
- * State (sort / search / filter / selection / expansion) is internal
76
- * by default; pass the controlled prop + matching change handler to
77
- * lift state up — same pattern as `<TextField>` value.
78
- *
79
- * i18n: pass `header: t('users.name')` for column headers; pass
80
- * `labels={{ searchPlaceholder: t('...'), ... }}` for internal default
81
- * strings.
82
- */
83
- export function Table<T extends object>(props: TableProps<T>) {
84
- const {
85
- rows,
86
- cols,
87
- getRowId = DEFAULT_GET_ROW_ID,
88
-
89
- // State props (controllable)
90
- sortModel: sortModelProp,
91
- onSortChange,
92
- defaultSortModel,
93
-
94
- enableSearch = false,
95
- searchQuery: searchQueryProp,
96
- onSearchQueryChange,
97
- searchPlaceholder,
98
- searchDebounceMs = 200,
99
-
100
- filterModel: filterModelProp,
101
- onFilterChange,
102
-
103
- rowSelection = 'none',
104
- selectedRowIds: selectedRowIdsProp,
105
- onSelectionChange,
106
- bulkActions,
107
-
108
- expandable,
109
-
110
- rowActions,
111
-
112
- loading = false,
113
- loadingRowCount = 5,
114
- emptyState,
115
-
116
- stickyHeader = true,
117
- caption,
118
- showCaption = false,
119
-
120
- access: tableAccess,
121
-
122
- labels: labelsProp,
123
-
124
- variant,
125
- size,
126
- density,
127
-
128
- sx,
129
- slotProps,
130
- } = props;
131
-
132
- const labels = { ...DEFAULT_LABELS, ...labelsProp };
133
- const tableAccessState = useAccessState(tableAccess);
134
-
135
- // Dev-only guard: `getRowId` is optional (positional-index fallback)
136
- // but that fallback breaks row identity once rows reorder (sort) or
137
- // change presence (search / filter) — selection + expansion state
138
- // then jump to the wrong rows. Warn when it's omitted AND a feature
139
- // that relies on stable identity is active. Stripped in production.
140
- const getRowIdProvided = props.getRowId !== undefined;
141
- useEffect(() => {
142
- if (process.env.NODE_ENV === 'production') return;
143
- if (getRowIdProvided) return;
144
- const identityMatters =
145
- rowSelection !== 'none' ||
146
- expandable != null ||
147
- enableSearch ||
148
- cols.some((c) => Boolean(c.sortable));
149
- if (identityMatters) {
150
- console.warn(
151
- '[Dashforge Table] `getRowId` is not set — falling back to the ' +
152
- 'positional row index. With sort / search / selection / ' +
153
- 'expandable rows active, the index-based key breaks row ' +
154
- 'identity when rows reorder. Pass a stable resolver, e.g. ' +
155
- '`getRowId={(row) => row.id}`.',
156
- );
157
- }
158
- }, [getRowIdProvided, rowSelection, expandable, enableSearch, cols]);
159
-
160
- // ───── Controllable state machinery ─────
161
-
162
- const [sortModel, setSortModel] = useControllableState<TableSortModel>({
163
- controlledValue: sortModelProp,
164
- defaultValue: defaultSortModel ?? [],
165
- onChange: onSortChange,
166
- });
167
- const [searchQuery, setSearchQuery] = useControllableState<string>({
168
- controlledValue: searchQueryProp,
169
- defaultValue: '',
170
- onChange: onSearchQueryChange,
171
- });
172
- // Filter UI (per-column quick filters) is scoped for v1-bis; for now
173
- // the model is read-only inside the component — the consumer wires it
174
- // up via `filterModelProp` + `onFilterChange` from their own state.
175
- // Until the in-table filter UI ships, only the controlled mode is
176
- // meaningful, so we don't need an internal setter.
177
- void onFilterChange;
178
- const filterModel: TableFilterModel = filterModelProp ?? [];
179
- const [selectedRowIds, setSelectedRowIds] = useControllableState<string[]>({
180
- controlledValue: selectedRowIdsProp,
181
- defaultValue: [],
182
- onChange: onSelectionChange,
183
- });
184
- const [expandedRowIds, setExpandedRowIds] = useControllableState<string[]>({
185
- controlledValue: expandable?.expandedRowIds,
186
- defaultValue: [],
187
- onChange: expandable?.onExpandChange,
188
- });
189
-
190
- // ───── RBAC: filter out hidden columns ─────
191
-
192
- const visibleCols = useMemo(
193
- () =>
194
- cols.filter(
195
- (col) => !col.access || col.access.onUnauthorized !== 'hide',
196
- ),
197
- [cols],
198
- );
199
-
200
- // ───── Smart-default column types ─────
201
-
202
- const columnTypes = useColumnAutoDetect(rows, visibleCols);
203
-
204
- // ───── Pipeline: search → filter → sort ─────
205
-
206
- const debouncedSearchQuery = useDebouncedValue(searchQuery, searchDebounceMs);
207
- const searchedRows = useTableSearch(rows, visibleCols, debouncedSearchQuery);
208
- const filteredRows = useTableFilter(searchedRows, filterModel);
209
- const sortedRows = useTableSort(filteredRows, visibleCols, sortModel);
210
-
211
- // ───── Selection helpers ─────
212
-
213
- const visibleRowIds = useMemo(
214
- () => sortedRows.map((row, idx) => getRowId(row, idx)),
215
- [sortedRows, getRowId],
216
- );
217
-
218
- const selection = useTableSelection(rowSelection, selectedRowIds, setSelectedRowIds);
219
-
220
- const selectedRows = useMemo(
221
- () => sortedRows.filter((row, idx) => selection.isSelected(getRowId(row, idx))),
222
- [sortedRows, selection, getRowId],
223
- );
224
-
225
- // ───── Variant recipe ─────
226
-
227
- const v = tableVariants({ variant, size, density, stickyHeader });
228
-
229
- // ───── Render ─────
230
-
231
- if (!tableAccessState.visible) return null;
232
-
233
- const isTableInteractive = !tableAccessState.disabled;
234
- const showSelectionColumn = rowSelection !== 'none';
235
- const showExpandColumn = expandable != null;
236
- const showRowActionsColumn = rowActions != null;
237
-
238
- const totalColumnCount =
239
- visibleCols.length +
240
- (showSelectionColumn ? 1 : 0) +
241
- (showExpandColumn ? 1 : 0) +
242
- (showRowActionsColumn ? 1 : 0);
243
-
244
- return (
245
- <div
246
- className={cn(v.root(), sx, slotProps?.root?.className)}
247
- data-disabled={!isTableInteractive ? 'true' : undefined}
248
- >
249
- {/* ───── Toolbar (search) ───── */}
250
- {enableSearch && (
251
- <div className={cn(v.toolbar(), slotProps?.toolbar?.className)}>
252
- <label className={cn(v.search(), slotProps?.search?.className)}>
253
- <span className="sr-only">{labels.searchPlaceholder}</span>
254
- <SearchIcon className="ml-2 shrink-0 text-neutral-500" />
255
- <input
256
- type="text"
257
- value={searchQuery}
258
- onChange={(e) => setSearchQuery(e.target.value)}
259
- placeholder={searchPlaceholder ?? labels.searchPlaceholder}
260
- disabled={!isTableInteractive}
261
- className={cn(
262
- 'flex-1 bg-transparent border-0 outline-none',
263
- 'px-2 py-1.5',
264
- // placeholder color auto-inverts via the CSS-var preset;
265
- // no `dark:` variant needed on neutral palette.
266
- 'placeholder:text-neutral-400',
267
- 'disabled:opacity-50 disabled:cursor-not-allowed',
268
- )}
269
- />
270
- </label>
271
- </div>
272
- )}
273
-
274
- {/* ───── Scroll wrapper ───── */}
275
- <div className={cn(v.scroll(), slotProps?.scroll?.className)}>
276
- <table className={cn(v.table(), slotProps?.table?.className)}>
277
- {caption != null && (
278
- <caption className={cn(!showCaption && 'sr-only', 'py-2 text-sm text-neutral-500')}>
279
- {caption}
280
- </caption>
281
- )}
282
-
283
- {/* ───── Header ───── */}
284
- <thead className={cn(v.thead(), slotProps?.thead?.className)}>
285
- <tr className={cn(v.headerRow(), slotProps?.headerRow?.className)}>
286
- {showSelectionColumn && (
287
- <th
288
- scope="col"
289
- className={cn(
290
- v.headerCell(),
291
- v.selectionCell(),
292
- slotProps?.headerCell?.className,
293
- slotProps?.selectionCell?.className,
294
- )}
295
- >
296
- {rowSelection === 'multiple' && (
297
- <input
298
- type="checkbox"
299
- aria-label={labels.ariaSelectAllRows}
300
- checked={selection.isAllSelected(visibleRowIds)}
301
- ref={(el) => {
302
- if (el) el.indeterminate = selection.isIndeterminate(visibleRowIds);
303
- }}
304
- onChange={() => selection.toggleAll(visibleRowIds)}
305
- disabled={!isTableInteractive}
306
- className="cursor-pointer"
307
- />
308
- )}
309
- </th>
310
- )}
311
-
312
- {showExpandColumn && (
313
- <th
314
- scope="col"
315
- aria-hidden="true"
316
- className={cn(
317
- v.headerCell(),
318
- v.expandToggleCell(),
319
- slotProps?.headerCell?.className,
320
- slotProps?.expandToggleCell?.className,
321
- )}
322
- />
323
- )}
324
-
325
- {visibleCols.map((col) => (
326
- <HeaderCell
327
- key={col.field as string}
328
- col={col}
329
- sortModel={sortModel}
330
- onSortClick={(e) => handleSortClick(col, e, sortModel, setSortModel)}
331
- inferredType={columnTypes.get(col.field as string)}
332
- labels={labels}
333
- className={cn(v.headerCell(), slotProps?.headerCell?.className)}
334
- buttonClassName={v.headerCellButton()}
335
- disabled={!isTableInteractive}
336
- />
337
- ))}
338
-
339
- {showRowActionsColumn && (
340
- <th
341
- scope="col"
342
- aria-hidden="true"
343
- className={cn(
344
- v.headerCell(),
345
- 'w-12',
346
- slotProps?.headerCell?.className,
347
- )}
348
- />
349
- )}
350
- </tr>
351
- </thead>
352
-
353
- {/* ───── Body ───── */}
354
- <tbody className={cn(v.tbody(), slotProps?.tbody?.className)}>
355
- {loading
356
- ? renderLoadingRows({
357
- count: loadingRowCount,
358
- visibleCols,
359
- showSelectionColumn,
360
- showExpandColumn,
361
- showRowActionsColumn,
362
- rowClass: cn(v.row(), slotProps?.row?.className),
363
- cellClass: cn(v.cell(), slotProps?.cell?.className),
364
- })
365
- : sortedRows.length === 0
366
- ? renderEmptyState({
367
- totalColumnCount,
368
- emptyState,
369
- // Distinguish a genuinely empty dataset from one
370
- // emptied by an active search / filter.
371
- fallback:
372
- rows.length > 0 &&
373
- (debouncedSearchQuery.trim().length > 0 ||
374
- filterModel.length > 0)
375
- ? labels.noResults
376
- : labels.noData,
377
- cellClass: cn(v.cell(), v.emptyState(), slotProps?.emptyState?.className),
378
- })
379
- : sortedRows.map((row, idx) => {
380
- const rowId = getRowId(row, idx);
381
- const isSelected = selection.isSelected(rowId);
382
- const isExpanded = expandedRowIds.includes(rowId);
383
- return (
384
- <Row
385
- key={rowId}
386
- row={row}
387
- rowId={rowId}
388
- rowIndex={idx}
389
- isSelected={isSelected}
390
- isExpanded={isExpanded}
391
- visibleCols={visibleCols}
392
- columnTypes={columnTypes}
393
- rowSelection={rowSelection}
394
- showSelectionColumn={showSelectionColumn}
395
- showExpandColumn={showExpandColumn}
396
- showRowActionsColumn={showRowActionsColumn}
397
- expandable={expandable}
398
- rowActions={rowActions}
399
- labels={labels}
400
- toggleRow={selection.toggleRow}
401
- toggleExpand={(id) =>
402
- setExpandedRowIds((prev) =>
403
- prev.includes(id)
404
- ? prev.filter((p) => p !== id)
405
- : [...prev, id],
406
- )
407
- }
408
- isInteractive={isTableInteractive}
409
- rowClass={cn(v.row(), slotProps?.row?.className)}
410
- cellClass={cn(v.cell(), slotProps?.cell?.className)}
411
- selectionCellClass={cn(
412
- v.cell(),
413
- v.selectionCell(),
414
- slotProps?.cell?.className,
415
- slotProps?.selectionCell?.className,
416
- )}
417
- expandToggleCellClass={cn(
418
- v.cell(),
419
- v.expandToggleCell(),
420
- slotProps?.cell?.className,
421
- slotProps?.expandToggleCell?.className,
422
- )}
423
- rowActionsCellClass={cn(
424
- v.cell(),
425
- v.rowActionsCell(),
426
- slotProps?.cell?.className,
427
- slotProps?.rowActionsCell?.className,
428
- )}
429
- expandedRowClass={cn(v.expandedRow(), slotProps?.expandedRow?.className)}
430
- totalColumnCount={totalColumnCount}
431
- />
432
- );
433
- })}
434
- </tbody>
435
- </table>
436
- </div>
437
-
438
- {/* ───── Bulk action footer (sticky) ───── */}
439
- {bulkActions && selectedRows.length > 0 && (
440
- <div
441
- className={cn(v.bulkActionFooter(), slotProps?.bulkActionFooter?.className)}
442
- role="region"
443
- aria-label={labels.selectedCount.replace('{count}', String(selectedRows.length))}
444
- >
445
- <span className="text-sm text-neutral-700">
446
- {labels.selectedCount.replace('{count}', String(selectedRows.length))}
447
- </span>
448
- <div className="flex items-center gap-2">
449
- {bulkActions(selectedRows)}
450
- <button
451
- type="button"
452
- onClick={selection.clearSelection}
453
- className={cn(
454
- // text-neutral-500 → text-neutral-900 on hover; both auto-invert.
455
- 'text-sm text-neutral-500 hover:text-neutral-900',
456
- 'underline-offset-2 hover:underline',
457
- 'focus:outline-none focus-visible:underline',
458
- )}
459
- >
460
- {labels.clearSelection}
461
- </button>
462
- </div>
463
- </div>
464
- )}
465
- </div>
466
- );
467
- }
468
-
469
- // ───── Header cell (with sort button) ─────
470
-
471
- function HeaderCell<T extends object>(props: {
472
- col: TableColumn<T>;
473
- sortModel: TableSortModel;
474
- onSortClick: (e: MouseEvent<HTMLButtonElement>) => void;
475
- inferredType: string | undefined;
476
- labels: Required<TableLabels>;
477
- className: string;
478
- buttonClassName: string;
479
- disabled: boolean;
480
- }) {
481
- const { col, sortModel, onSortClick, inferredType, labels, className, buttonClassName, disabled } = props;
482
-
483
- const align = resolveAlign(col, inferredType as never);
484
- const alignClass =
485
- align === 'right' ? 'text-right' : align === 'center' ? 'text-center' : 'text-left';
486
-
487
- const sortEntry = sortModel.find((s) => s.field === col.field);
488
- const ariaSort: 'ascending' | 'descending' | 'none' =
489
- sortEntry?.direction === 'asc'
490
- ? 'ascending'
491
- : sortEntry?.direction === 'desc'
492
- ? 'descending'
493
- : 'none';
494
-
495
- const headerContent =
496
- typeof col.header === 'function' ? col.header() : col.header;
497
-
498
- const cellStyle = {
499
- width: col.width != null ? `${col.width}px` : undefined,
500
- minWidth: col.minWidth != null ? `${col.minWidth}px` : undefined,
501
- flex: col.flex,
502
- };
503
-
504
- if (col.sortable) {
505
- return (
506
- <th
507
- scope="col"
508
- aria-sort={ariaSort}
509
- className={cn(className, alignClass)}
510
- style={cellStyle}
511
- >
512
- <button
513
- type="button"
514
- onClick={onSortClick}
515
- disabled={disabled}
516
- aria-label={
517
- ariaSort === 'ascending'
518
- ? labels.ariaSortAscending
519
- : ariaSort === 'descending'
520
- ? labels.ariaSortDescending
521
- : labels.ariaSortNone
522
- }
523
- className={cn(
524
- buttonClassName,
525
- align === 'right' && 'flex-row-reverse',
526
- 'disabled:cursor-not-allowed disabled:opacity-50',
527
- )}
528
- >
529
- <span>{headerContent}</span>
530
- <SortIcon direction={sortEntry?.direction} />
531
- </button>
532
- </th>
533
- );
534
- }
535
-
536
- return (
537
- <th
538
- scope="col"
539
- className={cn(className, alignClass)}
540
- style={cellStyle}
541
- >
542
- {headerContent}
543
- </th>
544
- );
545
- }
546
-
547
- // ───── Data row ─────
548
-
549
- function Row<T extends object>(props: {
550
- row: T;
551
- rowId: string;
552
- rowIndex: number;
553
- isSelected: boolean;
554
- isExpanded: boolean;
555
- visibleCols: TableColumn<T>[];
556
- columnTypes: Map<string, string>;
557
- rowSelection: 'none' | 'single' | 'multiple';
558
- showSelectionColumn: boolean;
559
- showExpandColumn: boolean;
560
- showRowActionsColumn: boolean;
561
- expandable: TableProps<T>['expandable'];
562
- rowActions: TableProps<T>['rowActions'];
563
- labels: Required<TableLabels>;
564
- toggleRow: (rowId: string) => void;
565
- toggleExpand: (rowId: string) => void;
566
- isInteractive: boolean;
567
- rowClass: string;
568
- cellClass: string;
569
- selectionCellClass: string;
570
- expandToggleCellClass: string;
571
- rowActionsCellClass: string;
572
- expandedRowClass: string;
573
- totalColumnCount: number;
574
- }) {
575
- const {
576
- row,
577
- rowId,
578
- rowIndex,
579
- isSelected,
580
- isExpanded,
581
- visibleCols,
582
- columnTypes,
583
- rowSelection,
584
- showSelectionColumn,
585
- showExpandColumn,
586
- showRowActionsColumn,
587
- expandable,
588
- rowActions,
589
- labels,
590
- toggleRow,
591
- toggleExpand,
592
- isInteractive,
593
- rowClass,
594
- cellClass,
595
- selectionCellClass,
596
- expandToggleCellClass,
597
- rowActionsCellClass,
598
- expandedRowClass,
599
- totalColumnCount,
600
- } = props;
601
-
602
- return (
603
- <>
604
- <tr
605
- data-selected={isSelected ? 'true' : 'false'}
606
- aria-selected={rowSelection !== 'none' ? isSelected : undefined}
607
- className={rowClass}
608
- >
609
- {showSelectionColumn && (
610
- <td className={selectionCellClass}>
611
- <input
612
- type="checkbox"
613
- aria-label={labels.ariaSelectRow}
614
- checked={isSelected}
615
- onChange={() => toggleRow(rowId)}
616
- disabled={!isInteractive}
617
- className="cursor-pointer"
618
- />
619
- </td>
620
- )}
621
-
622
- {showExpandColumn && (
623
- <td className={expandToggleCellClass}>
624
- <button
625
- type="button"
626
- onClick={() => toggleExpand(rowId)}
627
- aria-label={isExpanded ? labels.ariaCollapseRow : labels.ariaExpandRow}
628
- aria-expanded={isExpanded}
629
- disabled={!isInteractive}
630
- className={cn(
631
- 'inline-flex items-center justify-center h-6 w-6 rounded',
632
- // text-neutral-500 + hover bump; both auto-invert via CSS-var preset.
633
- 'text-neutral-500 hover:text-neutral-900',
634
- 'focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500',
635
- 'transition-transform motion-reduce:transition-none',
636
- isExpanded && 'rotate-90',
637
- )}
638
- >
639
- <ChevronRightIcon />
640
- </button>
641
- </td>
642
- )}
643
-
644
- {visibleCols.map((col) => (
645
- <DataCell
646
- key={col.field as string}
647
- col={col}
648
- row={row}
649
- rowIndex={rowIndex}
650
- isSelected={isSelected}
651
- isExpanded={isExpanded}
652
- inferredType={columnTypes.get(col.field as string)}
653
- cellClass={cellClass}
654
- />
655
- ))}
656
-
657
- {showRowActionsColumn && rowActions && (
658
- <td className={rowActionsCellClass}>
659
- {rowActions(row)}
660
- </td>
661
- )}
662
- </tr>
663
-
664
- {isExpanded && expandable && (
665
- <tr className={expandedRowClass}>
666
- <td colSpan={totalColumnCount} className="p-3">
667
- {expandable.render(row)}
668
- </td>
669
- </tr>
670
- )}
671
- </>
672
- );
673
- }
674
-
675
- // ───── Data cell ─────
676
-
677
- function DataCell<T extends object>(props: {
678
- col: TableColumn<T>;
679
- row: T;
680
- rowIndex: number;
681
- isSelected: boolean;
682
- isExpanded: boolean;
683
- inferredType: string | undefined;
684
- cellClass: string;
685
- }) {
686
- const { col, row, rowIndex, isSelected, isExpanded, inferredType, cellClass } = props;
687
- const value = getNestedValue(row, col.field as string);
688
- const align = resolveAlign(col, inferredType as never);
689
- // tabularNums = digit alignment via font-variant-numeric — does NOT
690
- // change the font family. Auto-true for number / date columns.
691
- const tabularNums = resolveTabularNums(col, inferredType as never);
692
- // monospace = font-family override (font-mono). Library never
693
- // auto-picks a font family — only explicit consumer opt-in. The
694
- // consumer's theme font-sans is preserved by default.
695
- const monospace = resolveMonospace(col);
696
- const alignClass =
697
- align === 'right' ? 'text-right' : align === 'center' ? 'text-center' : 'text-left';
698
-
699
- // Per-column RBAC state for the cellRenderer context
700
- const columnAccessState = col.access
701
- ? {
702
- hidden: col.access.onUnauthorized === 'hide',
703
- disabled: col.access.onUnauthorized === 'disable',
704
- readonly: col.access.onUnauthorized === 'readonly',
705
- }
706
- : null;
707
-
708
- const content = col.cellRenderer
709
- ? col.cellRenderer({
710
- row,
711
- value,
712
- rowIndex,
713
- isSelected,
714
- isExpanded,
715
- access: columnAccessState,
716
- })
717
- : renderDefaultCell(value);
718
-
719
- return (
720
- <td
721
- className={cn(
722
- cellClass,
723
- alignClass,
724
- tabularNums && 'tabular-nums',
725
- monospace && 'font-mono',
726
- )}
727
- style={{
728
- width: col.width != null ? `${col.width}px` : undefined,
729
- minWidth: col.minWidth != null ? `${col.minWidth}px` : undefined,
730
- }}
731
- >
732
- {content}
733
- </td>
734
- );
735
- }
736
-
737
- // ───── Helpers ─────
738
-
739
- function renderDefaultCell(value: unknown): ReactNode {
740
- if (value == null) return null;
741
- if (typeof value === 'boolean') return value ? '✓' : '✗';
742
- if (value instanceof Date) return value.toISOString().slice(0, 10);
743
- if (typeof value === 'object') return JSON.stringify(value);
744
- return value as ReactNode;
745
- }
746
-
747
- function handleSortClick<T extends object>(
748
- col: TableColumn<T>,
749
- event: MouseEvent<HTMLButtonElement>,
750
- current: TableSortModel,
751
- setSortModel: (next: TableSortModel | ((prev: TableSortModel) => TableSortModel)) => void,
752
- ) {
753
- if (!col.sortable) return;
754
- const multi = event.shiftKey;
755
- setSortModel((prev) => cycleSortFor(prev, col.field as string, multi));
756
- }
757
-
758
- function renderLoadingRows<T extends object>(args: {
759
- count: number;
760
- visibleCols: TableColumn<T>[];
761
- showSelectionColumn: boolean;
762
- showExpandColumn: boolean;
763
- showRowActionsColumn: boolean;
764
- rowClass: string;
765
- cellClass: string;
766
- }): ReactNode {
767
- const { count, visibleCols, showSelectionColumn, showExpandColumn, showRowActionsColumn, rowClass, cellClass } = args;
768
- // No explicit row height here (unlike DataGrid's loading rows, which
769
- // pin `rowHeight` for the virtualization math): Table is auto-height
770
- // by design. Skeleton rows inherit the same density padding via
771
- // `cellClass`, so they line up with real rows without a fixed height.
772
- return Array.from({ length: count }).map((_, i) => (
773
- <tr key={`loading-${i}`} className={rowClass} aria-busy="true">
774
- {showSelectionColumn && <td className={cellClass}><Skeleton variant="rectangle" width="16px" height="16px" /></td>}
775
- {showExpandColumn && <td className={cellClass}><Skeleton variant="rectangle" width="16px" height="16px" /></td>}
776
- {visibleCols.map((col) => (
777
- <td key={col.field as string} className={cellClass}>
778
- <Skeleton variant="text" width="80%" />
779
- </td>
780
- ))}
781
- {showRowActionsColumn && <td className={cellClass}><Skeleton variant="rectangle" width="24px" height="24px" /></td>}
782
- </tr>
783
- ));
784
- }
785
-
786
- function renderEmptyState(args: {
787
- totalColumnCount: number;
788
- emptyState: ReactNode;
789
- fallback: string;
790
- cellClass: string;
791
- }): ReactNode {
792
- return (
793
- <tr>
794
- <td colSpan={args.totalColumnCount} className={args.cellClass}>
795
- {args.emptyState ?? args.fallback}
796
- </td>
797
- </tr>
798
- );
799
- }
800
-
801
- // ───── Icons ─────
802
-
803
- function SortIcon(props: { direction?: 'asc' | 'desc' }) {
804
- return (
805
- <svg
806
- width="0.75em"
807
- height="0.75em"
808
- viewBox="0 0 16 16"
809
- fill="currentColor"
810
- aria-hidden="true"
811
- className="shrink-0 opacity-60 group-hover:opacity-100"
812
- >
813
- {props.direction === 'asc' ? (
814
- <path d="M8 4l4 6H4z" />
815
- ) : props.direction === 'desc' ? (
816
- <path d="M8 12L4 6h8z" />
817
- ) : (
818
- <>
819
- <path d="M8 3l3 4H5z" opacity="0.5" />
820
- <path d="M8 13l-3-4h6z" opacity="0.5" />
821
- </>
822
- )}
823
- </svg>
824
- );
825
- }
826
-
827
- function ChevronRightIcon() {
828
- return (
829
- <svg
830
- width="0.875em"
831
- height="0.875em"
832
- viewBox="0 0 16 16"
833
- fill="none"
834
- stroke="currentColor"
835
- strokeWidth="1.5"
836
- strokeLinecap="round"
837
- strokeLinejoin="round"
838
- aria-hidden="true"
839
- >
840
- <path d="M6 4l4 4-4 4" />
841
- </svg>
842
- );
843
- }
844
-
845
- function SearchIcon(props: { className?: string }) {
846
- return (
847
- <svg
848
- width="0.875em"
849
- height="0.875em"
850
- viewBox="0 0 16 16"
851
- fill="none"
852
- stroke="currentColor"
853
- strokeWidth="1.5"
854
- strokeLinecap="round"
855
- strokeLinejoin="round"
856
- aria-hidden="true"
857
- className={props.className}
858
- >
859
- <circle cx="7" cy="7" r="4.5" />
860
- <path d="M11 11l3 3" />
861
- </svg>
862
- );
863
- }