banhaten 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/CHANGELOG.md +139 -73
  2. package/CONTRIBUTING.md +46 -44
  3. package/README.md +192 -190
  4. package/SECURITY.md +15 -15
  5. package/banhaten.config.example.json +11 -11
  6. package/docs/design-spacing.md +13 -0
  7. package/docs/design-system/README.md +22 -20
  8. package/docs/design-system/adoption-quality-remediation.md +87 -87
  9. package/docs/design-system/agent-usage.md +13 -13
  10. package/docs/design-system/appearance-presets.md +189 -189
  11. package/docs/design-system/appearances/default.md +94 -94
  12. package/docs/design-system/appearances/rounded.md +95 -95
  13. package/docs/design-system/appearances/sharp.md +95 -95
  14. package/docs/design-system/component-docs-pattern.md +81 -81
  15. package/docs/design-system/component-implementation-ownership-audit.md +245 -244
  16. package/docs/design-system/component-quality-audit-2026-08-20.md +225 -223
  17. package/docs/design-system/component-showcase-consistency-report.md +219 -219
  18. package/docs/design-system/component-token-consistency-audit.md +173 -173
  19. package/docs/design-system/components/README.md +90 -76
  20. package/docs/design-system/components/accordion.md +53 -53
  21. package/docs/design-system/components/activity-feed.md +94 -94
  22. package/docs/design-system/components/activity-heatmap.md +57 -57
  23. package/docs/design-system/components/agent-input.md +85 -0
  24. package/docs/design-system/components/alert-dialog.md +72 -72
  25. package/docs/design-system/components/alert.md +98 -98
  26. package/docs/design-system/components/approval-card.md +134 -0
  27. package/docs/design-system/components/aspect-ratio.md +45 -45
  28. package/docs/design-system/components/attribute.md +89 -89
  29. package/docs/design-system/components/autocomplete.md +75 -75
  30. package/docs/design-system/components/avatar.md +54 -54
  31. package/docs/design-system/components/badge.md +54 -54
  32. package/docs/design-system/components/banner.md +87 -87
  33. package/docs/design-system/components/breadcrumbs.md +177 -176
  34. package/docs/design-system/components/button-group.md +98 -98
  35. package/docs/design-system/components/button.md +83 -80
  36. package/docs/design-system/components/card.md +88 -88
  37. package/docs/design-system/components/carousel.md +46 -46
  38. package/docs/design-system/components/catalog-components.md +47 -47
  39. package/docs/design-system/components/chart.md +95 -24
  40. package/docs/design-system/components/checkbox.md +54 -54
  41. package/docs/design-system/components/collapsible.md +67 -53
  42. package/docs/design-system/components/command.md +62 -62
  43. package/docs/design-system/components/context-menu.md +46 -46
  44. package/docs/design-system/components/date-picker.md +81 -79
  45. package/docs/design-system/components/divider.md +102 -102
  46. package/docs/design-system/components/empty-state.md +56 -56
  47. package/docs/design-system/components/field.md +70 -70
  48. package/docs/design-system/components/file-upload.md +187 -187
  49. package/docs/design-system/components/hover-card.md +48 -48
  50. package/docs/design-system/components/icons.md +48 -48
  51. package/docs/design-system/components/inline-citations.md +93 -0
  52. package/docs/design-system/components/input-group.md +58 -58
  53. package/docs/design-system/components/input-otp.md +56 -56
  54. package/docs/design-system/components/input.md +117 -61
  55. package/docs/design-system/components/item.md +59 -57
  56. package/docs/design-system/components/kbd.md +54 -49
  57. package/docs/design-system/components/label.md +49 -49
  58. package/docs/design-system/components/menu.md +71 -61
  59. package/docs/design-system/components/menubar.md +47 -47
  60. package/docs/design-system/components/modal.md +105 -105
  61. package/docs/design-system/components/native-select.md +54 -54
  62. package/docs/design-system/components/navigation-menu.md +50 -50
  63. package/docs/design-system/components/onboarding-step-list-item.md +82 -82
  64. package/docs/design-system/components/page-header.md +93 -86
  65. package/docs/design-system/components/pagination.md +57 -57
  66. package/docs/design-system/components/popover.md +60 -60
  67. package/docs/design-system/components/progress-slider.md +50 -50
  68. package/docs/design-system/components/progress.md +76 -76
  69. package/docs/design-system/components/radio-card.md +51 -51
  70. package/docs/design-system/components/radio-group.md +57 -57
  71. package/docs/design-system/components/resizable.md +44 -44
  72. package/docs/design-system/components/rolling-count.md +61 -0
  73. package/docs/design-system/components/scroll-area.md +51 -51
  74. package/docs/design-system/components/segmented-control.md +54 -54
  75. package/docs/design-system/components/select.md +68 -62
  76. package/docs/design-system/components/sheet.md +67 -67
  77. package/docs/design-system/components/shimmer-text.md +67 -0
  78. package/docs/design-system/components/sidebar.md +127 -76
  79. package/docs/design-system/components/skeleton.md +75 -75
  80. package/docs/design-system/components/slideout.md +65 -65
  81. package/docs/design-system/components/slider.md +63 -63
  82. package/docs/design-system/components/social-button.md +50 -50
  83. package/docs/design-system/components/spinner.md +62 -62
  84. package/docs/design-system/components/steps.md +65 -65
  85. package/docs/design-system/components/streaming-text.md +82 -0
  86. package/docs/design-system/components/table.md +419 -414
  87. package/docs/design-system/components/tabs.md +59 -55
  88. package/docs/design-system/components/tag.md +80 -80
  89. package/docs/design-system/components/task-list.md +95 -0
  90. package/docs/design-system/components/textarea.md +50 -50
  91. package/docs/design-system/components/thinking-reasoning.md +72 -0
  92. package/docs/design-system/components/thinking-state.md +67 -0
  93. package/docs/design-system/components/timeline.md +83 -83
  94. package/docs/design-system/components/toast.md +58 -58
  95. package/docs/design-system/components/toggle.md +81 -81
  96. package/docs/design-system/components/toolbar.md +92 -87
  97. package/docs/design-system/components/tooltip.md +94 -92
  98. package/docs/design-system/components/typography.md +18 -18
  99. package/docs/design-system/density-and-elevation.md +65 -61
  100. package/docs/design-system/design-system-test-missing-items.md +368 -368
  101. package/docs/design-system/direction-and-localization.md +23 -23
  102. package/docs/design-system/form-recipes.md +73 -73
  103. package/docs/design-system/gap-promotion-policy.md +21 -21
  104. package/docs/design-system/icons.md +74 -69
  105. package/docs/design-system/installation.md +70 -68
  106. package/docs/design-system/launch-comparison-shadcn.md +98 -98
  107. package/docs/design-system/registry-and-cli.md +64 -64
  108. package/docs/design-system/release-policy.md +30 -30
  109. package/docs/design-system/roadmap.md +14 -14
  110. package/docs/design-system/support-matrix.md +23 -23
  111. package/docs/design-system/tabs.md +54 -53
  112. package/docs/design-system/template-gap-audit.md +32 -0
  113. package/docs/design-system/templates.md +59 -0
  114. package/docs/design-system/token-governance.md +72 -60
  115. package/package.json +98 -98
  116. package/registry/component-contract.json +40 -40
  117. package/registry/components/accordion.tsx +155 -155
  118. package/registry/components/agent-input-parts.tsx +552 -0
  119. package/registry/components/agent-input-state.ts +156 -0
  120. package/registry/components/agent-input.css +307 -0
  121. package/registry/components/agent-input.tsx +382 -0
  122. package/registry/components/alert-dialog.tsx +297 -297
  123. package/registry/components/alert.tsx +293 -293
  124. package/registry/components/approval-card.css +409 -0
  125. package/registry/components/approval-card.tsx +401 -0
  126. package/registry/components/approval-frame.tsx +108 -0
  127. package/registry/components/approval-questions.tsx +559 -0
  128. package/registry/components/aspect-ratio.tsx +30 -30
  129. package/registry/components/attribute.tsx +454 -448
  130. package/registry/components/autocomplete.tsx +598 -651
  131. package/registry/components/avatar.tsx +385 -381
  132. package/registry/components/badge.tsx +629 -629
  133. package/registry/components/button-group.tsx +565 -565
  134. package/registry/components/button.tsx +127 -123
  135. package/registry/components/card.tsx +638 -638
  136. package/registry/components/carousel.tsx +296 -296
  137. package/registry/components/chart-block-data.ts +177 -0
  138. package/registry/components/chart-block.css +171 -0
  139. package/registry/components/chart-block.tsx +260 -0
  140. package/registry/components/chart-interactions.ts +123 -0
  141. package/registry/components/chart-options.cartesian.ts +162 -0
  142. package/registry/components/chart-options.paint.ts +99 -0
  143. package/registry/components/chart-options.parts.ts +72 -0
  144. package/registry/components/chart-options.radial.ts +109 -0
  145. package/registry/components/chart-options.ts +44 -0
  146. package/registry/components/chart-options.types.ts +67 -0
  147. package/registry/components/chart.tsx +203 -203
  148. package/registry/components/checkbox.tsx +247 -247
  149. package/registry/components/collapsible.tsx +109 -69
  150. package/registry/components/command.tsx +208 -208
  151. package/registry/components/context-menu.tsx +236 -236
  152. package/registry/components/data-chart.tsx +40 -0
  153. package/registry/components/date-picker.tsx +1289 -1277
  154. package/registry/components/echart-theme.ts +246 -0
  155. package/registry/components/echart.css +49 -0
  156. package/registry/components/echart.tsx +178 -0
  157. package/registry/components/expanded/ActivityFeed.tsx +227 -227
  158. package/registry/components/expanded/ActivityHeatmap.tsx +64 -64
  159. package/registry/components/expanded/Banner.tsx +179 -179
  160. package/registry/components/expanded/Breadcrumbs.tsx +131 -131
  161. package/registry/components/expanded/CatalogComponentsShowcase.tsx +205 -205
  162. package/registry/components/expanded/CatalogDivider.tsx +49 -49
  163. package/registry/components/expanded/EmptyState.tsx +155 -155
  164. package/registry/components/expanded/FileUpload.tsx +543 -543
  165. package/registry/components/expanded/OnboardingStepListItem.tsx +60 -59
  166. package/registry/components/expanded/PageHeader.tsx +179 -166
  167. package/registry/components/expanded/Slideout.tsx +108 -108
  168. package/registry/components/expanded/Steps.tsx +402 -402
  169. package/registry/components/expanded/Table.tsx +1092 -1071
  170. package/registry/components/expanded/Timeline.tsx +203 -203
  171. package/registry/components/expanded/activityFeed.css +248 -248
  172. package/registry/components/expanded/activityHeatmap.css +66 -66
  173. package/registry/components/expanded/banner.css +260 -255
  174. package/registry/components/expanded/breadcrumbs.css +140 -140
  175. package/registry/components/expanded/catalogComponentsShowcase.css +87 -87
  176. package/registry/components/expanded/divider.css +75 -75
  177. package/registry/components/expanded/emptyState.css +111 -111
  178. package/registry/components/expanded/fileUpload.css +457 -457
  179. package/registry/components/expanded/onboardingStepListItem.css +135 -126
  180. package/registry/components/expanded/pageHeader.css +248 -290
  181. package/registry/components/expanded/slideout.css +276 -276
  182. package/registry/components/expanded/steps.css +356 -356
  183. package/registry/components/expanded/table.css +606 -603
  184. package/registry/components/expanded/timeline.css +286 -286
  185. package/registry/components/field.tsx +283 -283
  186. package/registry/components/hover-card.tsx +48 -48
  187. package/registry/components/inline-citations.css +126 -0
  188. package/registry/components/inline-citations.tsx +292 -0
  189. package/registry/components/input-content.ts +107 -107
  190. package/registry/components/input-group.tsx +130 -130
  191. package/registry/components/input-otp.tsx +584 -584
  192. package/registry/components/input.tsx +990 -972
  193. package/registry/components/item.tsx +189 -189
  194. package/registry/components/kbd.tsx +246 -151
  195. package/registry/components/label.tsx +78 -78
  196. package/registry/components/menu.tsx +978 -986
  197. package/registry/components/menubar.tsx +226 -226
  198. package/registry/components/modal.tsx +872 -872
  199. package/registry/components/native-select.tsx +205 -205
  200. package/registry/components/navigation-menu.tsx +171 -171
  201. package/registry/components/pagination.css +36 -36
  202. package/registry/components/pagination.tsx +560 -555
  203. package/registry/components/popover.tsx +338 -338
  204. package/registry/components/progress-slider.tsx +216 -216
  205. package/registry/components/radio-card.tsx +676 -677
  206. package/registry/components/radio-group.tsx +570 -570
  207. package/registry/components/resizable.tsx +108 -108
  208. package/registry/components/rolling-count.css +37 -0
  209. package/registry/components/rolling-count.tsx +110 -0
  210. package/registry/components/scroll-area.tsx +91 -91
  211. package/registry/components/segmented-control.tsx +87 -87
  212. package/registry/components/select-content.tsx +218 -218
  213. package/registry/components/select.tsx +937 -932
  214. package/registry/components/sheet.tsx +305 -305
  215. package/registry/components/shimmer-text.css +69 -0
  216. package/registry/components/shimmer-text.tsx +43 -0
  217. package/registry/components/sidebar.tsx +1433 -358
  218. package/registry/components/skeleton.css +54 -54
  219. package/registry/components/skeleton.tsx +482 -482
  220. package/registry/components/slider.tsx +380 -380
  221. package/registry/components/social-button.tsx +387 -387
  222. package/registry/components/spinner.tsx +78 -78
  223. package/registry/components/streaming-text.css +45 -0
  224. package/registry/components/streaming-text.tsx +165 -0
  225. package/registry/components/table-elements.tsx +128 -128
  226. package/registry/components/tabs.css +222 -218
  227. package/registry/components/tabs.tsx +241 -241
  228. package/registry/components/tag.tsx +423 -423
  229. package/registry/components/task-list.css +328 -0
  230. package/registry/components/task-list.tsx +429 -0
  231. package/registry/components/textarea.tsx +610 -610
  232. package/registry/components/thinking-reasoning.css +178 -0
  233. package/registry/components/thinking-reasoning.tsx +253 -0
  234. package/registry/components/thinking-state.css +8 -0
  235. package/registry/components/thinking-state.tsx +46 -0
  236. package/registry/components/toast.tsx +136 -136
  237. package/registry/components/toggle.tsx +256 -256
  238. package/registry/components/toolbar.tsx +539 -539
  239. package/registry/components/tooltip.tsx +433 -431
  240. package/registry/examples/agent-input-demo.tsx +90 -0
  241. package/registry/examples/alert-demo.tsx +34 -34
  242. package/registry/examples/alert-dialog-demo.tsx +42 -42
  243. package/registry/examples/approval-card-demo.tsx +83 -0
  244. package/registry/examples/aspect-ratio-demo.tsx +11 -11
  245. package/registry/examples/attribute-demo.tsx +65 -65
  246. package/registry/examples/autocomplete-demo.tsx +109 -109
  247. package/registry/examples/avatar-demo.tsx +132 -132
  248. package/registry/examples/badge-demo.tsx +69 -69
  249. package/registry/examples/button-demo.tsx +86 -83
  250. package/registry/examples/button-group-demo.tsx +63 -63
  251. package/registry/examples/card-demo.tsx +86 -86
  252. package/registry/examples/carousel-demo.tsx +43 -43
  253. package/registry/examples/chart-block-demo.tsx +5 -0
  254. package/registry/examples/chart-demo.tsx +18 -33
  255. package/registry/examples/checkbox-demo.tsx +62 -62
  256. package/registry/examples/collapsible-demo.tsx +16 -16
  257. package/registry/examples/collection-filter-bar-demo.tsx +135 -135
  258. package/registry/examples/command-demo.tsx +42 -42
  259. package/registry/examples/command-palette-demo.tsx +235 -236
  260. package/registry/examples/context-menu-demo.tsx +29 -29
  261. package/registry/examples/control-density-contract-demo.tsx +65 -61
  262. package/registry/examples/date-picker-demo.tsx +127 -127
  263. package/registry/examples/divider-demo.tsx +17 -17
  264. package/registry/examples/expanded/activity-heatmap-demo.tsx +29 -29
  265. package/registry/examples/expanded/banner-demo.tsx +48 -48
  266. package/registry/examples/expanded/breadcrumbs-demo.tsx +59 -59
  267. package/registry/examples/expanded/empty-state-demo.tsx +39 -39
  268. package/registry/examples/expanded/file-upload-demo.tsx +60 -60
  269. package/registry/examples/expanded/onboarding-step-demo.tsx +11 -11
  270. package/registry/examples/expanded/slideout-demo.tsx +15 -15
  271. package/registry/examples/expanded/steps-demo.tsx +29 -29
  272. package/registry/examples/expanded/tabs-demo.tsx +13 -13
  273. package/registry/examples/expanded/timeline-demo.tsx +18 -18
  274. package/registry/examples/field-demo.tsx +51 -51
  275. package/registry/examples/hover-card-demo.tsx +23 -23
  276. package/registry/examples/inline-citations-demo.tsx +31 -0
  277. package/registry/examples/input-actions-demo.tsx +36 -0
  278. package/registry/examples/input-demo.tsx +87 -87
  279. package/registry/examples/input-group-demo.tsx +16 -16
  280. package/registry/examples/input-otp-demo.tsx +72 -72
  281. package/registry/examples/item-demo.tsx +46 -46
  282. package/registry/examples/kbd-demo.tsx +12 -11
  283. package/registry/examples/label-demo.tsx +20 -20
  284. package/registry/examples/menu-demo.tsx +122 -122
  285. package/registry/examples/menubar-demo.tsx +34 -34
  286. package/registry/examples/modal-demo.tsx +74 -74
  287. package/registry/examples/native-select-demo.tsx +16 -16
  288. package/registry/examples/navigation-menu-demo.tsx +29 -29
  289. package/registry/examples/pagination-demo.tsx +20 -20
  290. package/registry/examples/popover-demo.tsx +547 -546
  291. package/registry/examples/progress-demo.tsx +37 -37
  292. package/registry/examples/progress-slider-demo.tsx +29 -29
  293. package/registry/examples/radio-card-demo.tsx +51 -51
  294. package/registry/examples/radio-group-demo.tsx +62 -62
  295. package/registry/examples/resizable-demo.tsx +22 -22
  296. package/registry/examples/results-toolbar-demo.tsx +44 -44
  297. package/registry/examples/rolling-count-demo.tsx +39 -0
  298. package/registry/examples/scroll-area-demo.tsx +15 -15
  299. package/registry/examples/segmented-control-demo.tsx +39 -39
  300. package/registry/examples/select-demo.tsx +87 -87
  301. package/registry/examples/sheet-demo.tsx +47 -47
  302. package/registry/examples/shimmer-text-demo.tsx +20 -0
  303. package/registry/examples/sidebar-demo.tsx +101 -57
  304. package/registry/examples/slider-demo.tsx +31 -31
  305. package/registry/examples/social-button-demo.tsx +61 -61
  306. package/registry/examples/spinner-demo.tsx +59 -59
  307. package/registry/examples/streaming-text-demo.tsx +28 -0
  308. package/registry/examples/tabs-demo.tsx +13 -13
  309. package/registry/examples/tag-demo.tsx +29 -29
  310. package/registry/examples/task-list-demo.tsx +74 -0
  311. package/registry/examples/textarea-demo.tsx +79 -79
  312. package/registry/examples/thinking-reasoning-demo.tsx +74 -0
  313. package/registry/examples/thinking-state-demo.tsx +13 -0
  314. package/registry/examples/toast-demo.tsx +35 -35
  315. package/registry/examples/toggle-demo.tsx +59 -59
  316. package/registry/examples/tooltip-demo.tsx +115 -115
  317. package/registry/guidance/USAGE.md +27 -27
  318. package/registry/guidance/charts.LICENSE.txt +24 -0
  319. package/registry/hooks/use-controllable-state.ts +33 -0
  320. package/registry/hooks/use-direction.ts +207 -207
  321. package/registry/hooks/use-listbox-navigation.ts +73 -0
  322. package/registry/hooks/use-motion-end.ts +55 -0
  323. package/registry/hooks/use-reduced-motion.ts +28 -0
  324. package/registry/index.json +1634 -184
  325. package/registry/styles/globals.css +1462 -1570
  326. package/registry.json +364 -10
  327. package/schema/config.schema.json +51 -51
  328. package/schema/registry.schema.json +194 -190
  329. package/schema/tokens.schema.json +167 -163
  330. package/src/cli/command-line.js +194 -194
  331. package/src/cli/config-editors.js +9 -9
  332. package/src/cli/doctor.js +399 -399
  333. package/src/cli/file-transaction.js +302 -295
  334. package/src/cli/global-css.js +153 -153
  335. package/src/cli/index.js +1002 -1009
  336. package/src/cli/install-plan.js +592 -592
  337. package/src/cli/install-receipt.js +171 -171
  338. package/src/cli/jsonc.js +203 -203
  339. package/src/cli/package-install-state.js +254 -254
  340. package/src/cli/package-manager.js +238 -238
  341. package/src/cli/package-plan.js +185 -185
  342. package/src/cli/package-version.js +97 -97
  343. package/src/cli/registry-query.js +207 -207
  344. package/src/cli/reporting.js +55 -55
  345. package/src/cli/schema-validation.js +19 -19
  346. package/src/cli/source-scanner.js +686 -686
  347. package/src/cli/vite-config.js +478 -478
  348. package/tokens/banhaten.tokens.json +458 -224
@@ -1,416 +1,420 @@
1
- # Table
2
-
3
- The table component family includes `Table` and `DataTable`.
4
-
5
- `Table` is the composable data surface. It owns layout, headers, row states, selection, sortable header affordances, and RTL mirroring. Cells are filled by table item variants, so new content can be added without creating one-off row layouts.
6
-
7
- `DataTable` is the dataset workflow wrapper. It composes the existing Banhaten `Table`, `Toolbar`, `Pagination`, and `Spinner` components to provide search, filters, sorting, selection summary, bulk actions, pagination, and empty/loading/error states.
8
-
9
- Figma references:
10
-
11
- - `Table Example`, node `449:2354`
12
- - `Table item 1.2`, node `438:41157`
13
-
14
- ## Structure
15
-
16
- ```tsx
17
- <Table
18
- dir="ltr"
19
- columns={columns}
20
- rows={rows}
21
- selectedRowIds={selectedRowIds}
22
- onSelectedRowIdsChange={setSelectedRowIds}
23
- />
24
-
25
- <DataTable
26
- title="Component Operations"
27
- description="Track component readiness across design-system work."
28
- columns={columns}
29
- rows={rows}
30
- selectedRowIds={selectedRowIds}
31
- onSelectedRowIdsChange={setSelectedRowIds}
32
- search={{ label: "Search projects", placeholder: "Search projects..." }}
33
- filters={filters}
34
- pagination={{ pageSize: 10 }}
35
- />
36
-
37
- <TableRoot aria-label="Compact audit data">
38
- <TableHeader>
39
- <TableRowElement>
40
- <TableHead>Activity</TableHead>
41
- </TableRowElement>
42
- </TableHeader>
43
- <TableBody>
44
- <TableRowElement>
45
- <TableCell>Member invited</TableCell>
46
- </TableRowElement>
47
- </TableBody>
48
- </TableRoot>
49
- ```
50
-
51
- The table is composed from these parts:
52
-
53
- - `Table`: scroll container and semantic table/grid root.
54
- - `TableHeader`: one header row with sortable header cells.
55
- - `TableRow`: one data row with `default`, `selected`, and `disabled` states plus native hover styling.
56
- - `TableCell`: the layout shell for any table item.
57
- - `TableItem`: the content variant rendered inside a cell.
58
- - `DataTable`: composed workflow shell for search, filters, actions, pagination, and table states.
59
- - `DataTableSurface`: ARIA table surface for bespoke CSS-grid rows while keeping the table root owned by Banhaten.
60
- - `TableRoot`, `TableHeader`, `TableBody`, `TableRowElement`, `TableHead`, and `TableCell`: owned semantic elements for product-specific read-only tables that do not fit the data-column API.
61
-
62
- Use semantic `<table>` markup when the table is mostly read-only data. Use an ARIA grid only when the product needs cell-level keyboard navigation. Interactive content inside cells, such as checkboxes, toggles, and actions, must remain real controls.
63
-
64
- ## Layout
65
-
66
- The Figma sample is `1024px` wide, but the implementation should be responsive. Fixed columns keep their design widths and the primary text column fills the remaining space.
67
-
68
- ```ts
69
- const exampleColumns = [
70
- { id: "select", width: 42, kind: "selection" },
71
- { id: "project", header: "Project Name", width: "fill", sortable: true },
72
- { id: "leader", header: "Project Leader", width: 203, sortable: true },
73
- { id: "status", header: "Status", width: 147, sortable: true },
74
- { id: "progress", header: "Progress", width: 160, sortable: true },
75
- { id: "deadline", header: "Deadline", width: 155, sortable: true },
76
- { id: "actions", width: 44, kind: "actions" },
77
- ];
78
- ```
79
-
80
- RTL tables reverse the visual column order and align cell content to the end. The selection cell moves to the far right, and the action cell moves to the far left. The row data order should not change.
81
-
82
- ## Sizing
83
-
84
- | Area | Size | LTR height | RTL height |
85
- | --- | --- | ---: | ---: |
86
- | Header row | `sm` | `44px` | `44px` |
87
- | Body row | `sm` | `48px` | `44px` |
88
- | Body row | `lg` | `56px` | `56px` |
89
-
90
- Cell padding is `12px` on the inline axis. The fixed `44px` action column keeps `8px` inline padding around its `28px` action button. Inline content gap is `6px`; header label and sort icon gap is `4px`. The base checkbox and action columns use fixed dimensions so hover, selected, and icon states do not shift the table.
91
-
92
- ## States
93
-
94
- | State | Treatment |
95
- | --- | --- |
96
- | `default` | Default background with a subtle bottom divider. |
97
- | Native hover | Ghost hover background across the full row. |
98
- | `selected` | Selected row background and checked selection control. |
99
- | `disabled` | Disabled content color and no row actions. |
100
-
101
- The selected checkbox uses the brand or checkbox fill and a white check icon. Header checkbox supports checked, unchecked, and indeterminate states.
102
-
103
- ## Token Mapping
104
-
105
- The Figma nodes use names such as `interactive/table/header`, `interactive/ghost/hover`, and `bg/neutral/soft`. In this documentation set, map those to the semantic token contract:
106
-
107
- | Figma intent | Design-system token |
108
- | --- | --- |
109
- | Table header background | `background.muted` |
110
- | Row hover background | `background.hover` |
111
- | Row selected background | `background.selected` |
112
- | Row divider | `border.subtle` |
113
- | Body text | `content.default` |
114
- | Header text and secondary labels | `content.subtle` |
115
- | Checkbox active fill | `background.brand` |
116
- | Progress track | `background.muted` |
117
- | Progress fill | `background.success` or component success fill |
118
- | Row height | `density.tableRowHeight` |
119
- | Control radius | `shape.control` |
120
- | Avatar, badge, and progress radius | `shape.badge` |
121
-
122
- Do not hard-code preset-specific values in the table. Appearance presets may change density, radius, borders, and hover treatment while preserving the same component API.
123
-
124
- ## Column API
125
-
126
- Use semantic names in code even if the Figma variant labels are title-cased.
127
-
128
- ```ts
129
- type TableDirection = "ltr" | "rtl";
130
- type TableSize = "sm" | "lg";
131
- type TableRowState = "default" | "selected" | "disabled";
132
-
133
- type TableColumn<Row> = {
134
- id: string;
135
- header?: string;
136
- width?: number | "fill";
137
- minWidth?: number;
138
- align?: "start" | "center" | "end";
139
- sortable?: boolean;
140
- sortValue?: (row: Row) => TableSortValue;
141
- searchValue?: (row: Row) => string;
142
- kind?: "data" | "selection" | "actions";
143
- item?: TableItemFactory<Row>;
144
- renderCell?: (row: Row) => React.ReactNode;
145
- };
146
-
147
- type TableItemFactory<Row> = (row: Row) => TableItem;
148
- type TableSortValue = string | number | boolean | Date | null | undefined;
149
- type TableSortState = { columnId: string; direction: "asc" | "desc" } | null;
150
- ```
151
-
152
- Use `item` for standard content variants and `renderCell` only for custom product-specific cells. Custom cells still render inside `TableCell`, so spacing, alignment, row height, truncation, RTL behavior, and disabled state stay consistent.
153
-
154
- Use `sortValue` when the visible cell content should sort by an underlying value, such as dates, percentages, status rank, or formatted numbers. Use `searchValue` when the cell should contribute searchable text that is different from the visible content.
155
-
156
- ## Table Items
157
-
158
- The item catalog in Figma supports these cell content variants. Code may normalize visual variants into semantic item types; for example, `baseLeading`, `baseRegular`, and `subtle` all map to the `text` item with different `weight` and `tone` values.
159
-
160
- | Figma item type | Use for | Notes |
161
- | --- | --- | --- |
162
- | `checkbox` | Row selection | Fixed selection column. |
163
- | `baseLeading` | Primary label | Medium body label. |
164
- | `baseRegular` | Standard body text | Regular body label. |
165
- | `subtle` | Secondary text | Uses subtle content color. |
166
- | `avatarText` | Person, owner, assignee | Avatar plus label; `lg` may include caption. |
167
- | `rating` | Star rating | Five 20px stars with full, half, and empty states. |
168
- | `progress` | Percent completion | 8px track, percent label, mirrored fill in RTL. |
169
- | `toggle` | Binary row setting | 32px switch in `sm`; preserve native button semantics. |
170
- | `badges` | Status and categorical chips | Supports multiple badges and overflow count. |
171
- | `onlyAvatar` | Compact person cell | Single avatar centered or aligned by column. |
172
- | `avatarStack` | Team or group membership | Overlapped 20px avatars, optional count and add button. |
173
- | `tags` | Neutral labels | Bordered tags with compact 24px height. |
174
- | `file` | Attachment indicator | Icon-only file cell. |
175
- | `brandLogoText` | Brand or account identity | Logo plus label. |
176
- | `payment` | Payment method | Payment icon plus optional label. |
177
- | `image` | Thumbnail item | Image thumbnail plus label. |
178
- | `action` | Single row menu | Icon button, usually overflow menu. |
179
- | `actionGroup` | Multiple row actions | View, edit, delete group; reverse order in RTL. |
180
-
181
- ```ts
182
- type TableItem =
183
- | { type: "checkbox"; checked: boolean; indeterminate?: boolean }
184
- | { type: "text"; tone?: "default" | "subtle"; weight?: "regular" | "medium"; value: string }
185
- | { type: "avatarText"; name: string; caption?: string; src?: string; status?: "top" | "bottom" }
186
- | { type: "rating"; value: number; max?: 5 }
187
- | { type: "progress"; value: number; label?: string; tone?: "success" | "brand" }
188
- | { type: "toggle"; checked: boolean; disabled?: boolean }
189
- | { type: "badges"; items: BadgeItem[]; maxVisible?: number }
190
- | { type: "onlyAvatar"; src?: string; alt: string }
191
- | { type: "avatarStack"; avatars: AvatarItem[]; count?: number; canAdd?: boolean }
192
- | { type: "tags"; items: string[]; maxVisible?: number }
193
- | { type: "file"; label?: string }
194
- | { type: "brandLogoText"; label: string; logoSrc?: string }
195
- | { type: "payment"; brand: "maestro" | "mastercard" | "visa" | string; label?: string }
196
- | { type: "image"; label: string; src: string }
197
- | { type: "action"; label: string; icon: "more"; onAction: () => void }
198
- | { type: "actionGroup"; actions: TableAction[] };
199
-
200
- type BadgeItem = {
201
- label: string;
202
- tone?: "blue" | "fuchsia" | "amber" | "neutral" | "success" | "warning" | "danger";
203
- dot?: boolean;
204
- };
205
-
206
- type AvatarItem = {
207
- src?: string;
208
- alt: string;
209
- };
210
-
211
- type TableAction = {
212
- label: string;
213
- icon: "view" | "edit" | "delete" | "more";
214
- onAction: () => void;
215
- };
216
- ```
217
-
218
- The item union intentionally describes content, not layout. `TableCell` decides padding, alignment, truncation, and RTL mirroring.
219
-
220
- ## Adding Items
221
-
222
- Add a new table item by defining it on a column. The row supplies content values; the column controls presentation.
223
-
224
- ```tsx
225
- const columns: TableColumn<Project>[] = [
226
- {
227
- id: "project",
228
- header: "Project Name",
229
- width: "fill",
230
- sortable: true,
231
- item: (project) => ({
232
- type: "text",
233
- value: project.name,
234
- weight: "regular",
235
- }),
236
- },
237
- {
238
- id: "leader",
239
- header: "Project Leader",
240
- width: 203,
241
- sortable: true,
242
- item: (project) => ({
243
- type: "avatarText",
244
- name: project.leader.name,
245
- src: project.leader.avatarUrl,
246
- }),
247
- },
248
- {
249
- id: "status",
250
- header: "Status",
251
- width: 147,
252
- sortable: true,
253
- item: (project) => ({
254
- type: "badges",
255
- items: [{ label: project.status, tone: "blue", dot: true }],
256
- }),
257
- },
258
- {
259
- id: "progress",
260
- header: "Progress",
261
- width: 160,
262
- sortable: true,
263
- item: (project) => ({
264
- type: "progress",
265
- value: project.progress,
266
- label: `${project.progress}%`,
267
- tone: "success",
268
- }),
269
- },
270
- {
271
- id: "deadline",
272
- header: "Deadline",
273
- width: 155,
274
- sortable: true,
275
- item: (project) => ({
276
- type: "text",
277
- value: project.deadlineLabel,
278
- }),
279
- },
280
- {
281
- id: "actions",
282
- width: 44,
283
- kind: "actions",
284
- item: (project) => ({
285
- type: "action",
286
- label: `Open actions for ${project.name}`,
287
- icon: "more",
288
- onAction: () => openProjectActions(project.id),
289
- }),
290
- },
291
- ];
292
- ```
293
-
294
- For a custom item, first check whether the content can be represented by the existing union. Add a new item type only when the content appears in more than one table or needs shared behavior such as keyboard handling, truncation, or overflow.
295
-
296
- ## Header Behavior
297
-
298
- Sortable headers render the label plus the expand-up-down icon. When sorted, the header cell sets `aria-sort` to `ascending` or `descending`; otherwise it uses `none`. Header controls must have a clear label such as `Sort by Project Name`.
299
-
300
- `Table` accepts `sort` and `onSortChange` when the host owns sorting. `DataTable` can own sorting internally with `defaultSort`, or operate as a controlled component with `sort` and `onSortChange`.
301
-
302
- The select-all checkbox announces:
303
-
304
- - unchecked when no visible rows are selected;
305
- - checked when all visible rows are selected;
306
- - indeterminate when some visible rows are selected.
307
-
308
- ## Data Table
309
-
310
- Use `DataTable` when the product needs the complete dataset browsing workflow instead of only rows and columns.
311
-
312
- ```tsx
313
- const filters = [
314
- {
315
- id: "review",
316
- label: "Status",
317
- value: "Review",
318
- active: statusFilter === "Review",
319
- onAction: () => setStatusFilter("Review"),
320
- predicate: (row) => row.status === "Review",
321
- },
322
- ];
323
-
324
- <DataTable
325
- actions={[{ label: "Export", variant: "soft" }]}
326
- bulkActions={[{ label: "Archive", variant: "outline" }]}
327
- columns={columns}
328
- defaultSort={{ columnId: "project", direction: "asc" }}
329
- emptyState={{
330
- title: "No matching projects",
331
- description: "Try another search or return to all statuses.",
332
- }}
333
- filters={filters}
334
- pagination={{ pageSize: 10 }}
335
- rows={rows}
336
- search={{ label: "Search projects", placeholder: "Search projects..." }}
337
- />
338
- ```
339
-
340
- `DataTable` applies active filter predicates, searches row text from `getRowSearchText`, column `searchValue`, or table item text, sorts by column `sortValue` or table item value, and paginates the resulting rows. Set `pagination={false}` for unpaginated datasets.
341
-
342
- ## Accessibility
343
-
344
- - Preserve native controls for checkbox, toggle, buttons, and menu triggers.
345
- - Use `aria-selected` on selected rows.
346
- - Provide labels for icon-only actions.
347
- - Keep focus outlines visible through `border.focus`.
348
- - Truncate long text visually, but keep the full value available through `title` or an accessible label when useful.
349
- - Do not put multiple unrelated buttons into one unlabeled cell; group row actions with a clear accessible name.
350
-
351
- ## Usage
352
-
353
- ```tsx
354
- <Table
355
- dir="ltr"
356
- columns={columns}
357
- rows={projects}
358
- selectedRowIds={selectedRowIds}
359
- onSelectedRowIdsChange={setSelectedRowIds}
360
- />
361
-
362
- <Table
363
- dir="rtl"
364
- columns={columns}
365
- rows={projects}
366
- selectedRowIds={selectedRowIds}
367
- onSelectedRowIdsChange={setSelectedRowIds}
368
- />
369
- ```
370
-
371
- ## Preset Impact
372
-
373
- - `default`: normal row density, quiet header background, modest control radius.
374
- - `rounded`: slightly taller rows, softer hover treatment, larger badges and control radius.
375
- - `sharp`: denser rows, stronger dividers, square or near-square controls.
376
-
377
- ## Implementation Notes
378
-
379
- - Use Remix icons for Figma icon matches: `expand-up-down-line`, `more-fill`, `check-fill`, `eye-line`, `pencil-line`, and `delete-bin-line`.
380
- - Progress bars are `8px` high and pill-shaped. In RTL, the filled segment grows from the right.
381
- - Badges are `24px` tall, pill-shaped, and use `11px / 14px` medium text.
382
- - Tags are `24px` tall with a 1px border and `13px / 20px` medium text.
383
- - Avatar-with-text cells use the shared 24px avatar in `sm` rows. Avatar-only and avatar-stack cells use 20px avatars. All three use 32px avatars in `lg` rows.
384
- - Action buttons are fixed `28px` in `sm` rows and `32px` in `lg` rows.
385
-
386
- ## Install
387
-
388
- ```bash
389
- npx banhaten add table
390
- ```
391
-
392
- ## API
393
-
394
- Supported runtime exports: `DataTable`, `Table`, `DataTableSurface`, `TableBody`, `TableCell`, `TableHead`, `TableHeader`, `TableRoot`, `TableRowElement`.
395
-
396
- Use the live registry docs for the generated API table and source-backed examples.
397
-
398
- ## Examples
399
-
400
- Primary registry example: `examples/expanded/table-demo.tsx`.
401
-
402
- Open the live component page or run `npx banhaten docs table` to inspect source files, install command, and examples.
403
-
404
- ## Token Contract
405
-
406
- Component styles must resolve through Banhaten semantic tokens, component aliases, or documented exception-ledger values.
407
- Do not add raw colors, pixel values, opacity utilities, z-index values, durations, or shadow literals directly to component source.
408
- Covered source files: `components/expanded/table.css`, `components/expanded/Table.tsx`.
409
-
410
- ## RTL Rules
411
-
412
- This component has no special RTL contract beyond inherited document direction and logical spacing.
413
-
1
+ # Table
2
+
3
+ The table component family includes `Table` and `DataTable`.
4
+
5
+ `Table` is the composable data surface. It owns layout, headers, row states, selection, sortable header affordances, and RTL mirroring. Cells are filled by table item variants, so new content can be added without creating one-off row layouts.
6
+
7
+ `DataTable` is the dataset workflow wrapper. It composes the existing Banhaten `Table`, `Toolbar`, `Pagination`, and `Spinner` components to provide search, filters, sorting, selection summary, bulk actions, pagination, and empty/loading/error states.
8
+
9
+ Figma references:
10
+
11
+ - `Table Example`, node `449:2354`
12
+ - `Table item 1.2`, node `438:41157`
13
+
14
+ ## Structure
15
+
16
+ ```tsx
17
+ <Table
18
+ dir="ltr"
19
+ columns={columns}
20
+ rows={rows}
21
+ selectedRowIds={selectedRowIds}
22
+ onSelectedRowIdsChange={setSelectedRowIds}
23
+ />
24
+
25
+ <DataTable
26
+ title="Component Operations"
27
+ description="Track component readiness across design-system work."
28
+ columns={columns}
29
+ rows={rows}
30
+ selectedRowIds={selectedRowIds}
31
+ onSelectedRowIdsChange={setSelectedRowIds}
32
+ search={{ label: "Search projects", placeholder: "Search projects..." }}
33
+ filters={filters}
34
+ pagination={{ pageSize: 10 }}
35
+ />
36
+
37
+ <TableRoot aria-label="Compact audit data">
38
+ <TableHeader>
39
+ <TableRowElement>
40
+ <TableHead>Activity</TableHead>
41
+ </TableRowElement>
42
+ </TableHeader>
43
+ <TableBody>
44
+ <TableRowElement>
45
+ <TableCell>Member invited</TableCell>
46
+ </TableRowElement>
47
+ </TableBody>
48
+ </TableRoot>
49
+ ```
50
+
51
+ The table is composed from these parts:
52
+
53
+ - `Table`: scroll container and semantic table/grid root.
54
+ - `TableHeader`: one header row with sortable header cells.
55
+ - `TableRow`: one data row with `default`, `selected`, and `disabled` states plus native hover styling.
56
+ - `TableCell`: the layout shell for any table item.
57
+ - `TableItem`: the content variant rendered inside a cell.
58
+ - `DataTable`: composed workflow shell for search, filters, actions, pagination, and table states.
59
+ - `DataTableSurface`: ARIA table surface for bespoke CSS-grid rows while keeping the table root owned by Banhaten.
60
+ - `TableRoot`, `TableHeader`, `TableBody`, `TableRowElement`, `TableHead`, and `TableCell`: owned semantic elements for product-specific read-only tables that do not fit the data-column API.
61
+
62
+ Use semantic `<table>` markup when the table is mostly read-only data. Use an ARIA grid only when the product needs cell-level keyboard navigation. Interactive content inside cells, such as checkboxes, toggles, and actions, must remain real controls.
63
+
64
+ ## Layout
65
+
66
+ The Figma sample is `1024px` wide, but the implementation should be responsive. Fixed columns keep their design widths and the primary text column fills the remaining space.
67
+
68
+ ```ts
69
+ const exampleColumns = [
70
+ { id: "select", width: 42, kind: "selection" },
71
+ { id: "project", header: "Project Name", width: "fill", sortable: true },
72
+ { id: "leader", header: "Project Leader", width: 203, sortable: true },
73
+ { id: "status", header: "Status", width: 147, sortable: true },
74
+ { id: "progress", header: "Progress", width: 160, sortable: true },
75
+ { id: "deadline", header: "Deadline", width: 155, sortable: true },
76
+ { id: "actions", width: 44, kind: "actions" },
77
+ ];
78
+ ```
79
+
80
+ RTL tables reverse the visual column order and align cell content to the end. The selection cell moves to the far right, and the action cell moves to the far left. The row data order should not change. An `avatarText` name and caption each resolve their own content direction, so an opposing script truncates at its actual end without changing the avatar layout.
81
+
82
+ ## Sizing
83
+
84
+ | Area | Size | LTR height | RTL height |
85
+ | --- | --- | ---: | ---: |
86
+ | Header row | `sm` | `44px` | `44px` |
87
+ | Body row | `sm` | `48px` | `44px` |
88
+ | Body row | `lg` | `56px` | `56px` |
89
+
90
+ Cell padding is `12px` on the inline axis. The fixed `44px` action column keeps `8px` inline padding around its `28px` action button. Inline content gap is `6px`; header label and sort icon gap is `4px`. The base checkbox and action columns use fixed dimensions so hover, selected, and icon states do not shift the table.
91
+
92
+ ## States
93
+
94
+ | State | Treatment |
95
+ | --- | --- |
96
+ | `default` | Default background with a subtle bottom divider. |
97
+ | Native hover | Ghost hover background across the full row. |
98
+ | `selected` | Selected row background and checked selection control. |
99
+ | `disabled` | Disabled content color and no row actions. |
100
+
101
+ The selected checkbox uses the brand or checkbox fill and a mode-aware contrasting check icon. Header checkbox supports checked, unchecked, and indeterminate states.
102
+
103
+ ## Token Mapping
104
+
105
+ The Figma nodes use names such as `interactive/table/header`, `interactive/ghost/hover`, and `bg/neutral/soft`. In this documentation set, map those to the semantic token contract:
106
+
107
+ | Figma intent | Design-system token |
108
+ | --- | --- |
109
+ | Table header background | `background.muted` |
110
+ | Row hover background | `background.hover` |
111
+ | Row selected background | `background.selected` |
112
+ | Row divider | `border.subtle` |
113
+ | Body text | `content.default` |
114
+ | Header text and secondary labels | `content.subtle` |
115
+ | Checkbox active fill | `background.brand` |
116
+ | Progress track | `background.muted` |
117
+ | Progress fill | `background.success` or component success fill |
118
+ | Row height | `density.tableRowHeight` |
119
+ | Control radius | `shape.control` |
120
+ | Avatar, badge, and progress radius | `shape.badge` |
121
+
122
+ Do not hard-code preset-specific values in the table. Appearance presets may change density, radius, borders, and hover treatment while preserving the same component API.
123
+
124
+ ## Column API
125
+
126
+ Use semantic names in code even if the Figma variant labels are title-cased.
127
+
128
+ ```ts
129
+ type TableDirection = "ltr" | "rtl";
130
+ type TableSize = "sm" | "lg";
131
+ type TableRowState = "default" | "selected" | "disabled";
132
+
133
+ type TableColumn<Row> = {
134
+ id: string;
135
+ header?: string;
136
+ width?: number | "fill";
137
+ minWidth?: number;
138
+ align?: "start" | "center" | "end";
139
+ sortable?: boolean;
140
+ sortValue?: (row: Row) => TableSortValue;
141
+ searchValue?: (row: Row) => string;
142
+ kind?: "data" | "selection" | "actions";
143
+ item?: TableItemFactory<Row>;
144
+ renderCell?: (row: Row) => React.ReactNode;
145
+ };
146
+
147
+ type TableItemFactory<Row> = (row: Row) => TableItem;
148
+ type TableSortValue = string | number | boolean | Date | null | undefined;
149
+ type TableSortState = { columnId: string; direction: "asc" | "desc" } | null;
150
+ ```
151
+
152
+ Use `item` for standard content variants and `renderCell` only for custom product-specific cells. Custom cells still render inside `TableCell`, so spacing, alignment, row height, truncation, RTL behavior, and disabled state stay consistent.
153
+
154
+ Cell content resolves in this order: `renderCell`, `item`, then an own row field whose key matches the column `id`. The implicit row-field fallback applies only to ordinary data columns and renders string or number values—including `0`—through the standard text item. Use `item` or `renderCell` for formatted values, booleans, dates, objects, and custom nodes. Selection and action columns never read an implicit row value; return `null` from `renderCell` when a deliberately blank data cell is required.
155
+
156
+ Use `sortValue` when the visible cell content should sort by an underlying value, such as dates, percentages, status rank, or formatted numbers. Use `searchValue` when the cell should contribute searchable text that is different from the visible content.
157
+
158
+ ## Table Items
159
+
160
+ The item catalog in Figma supports these cell content variants. Code may normalize visual variants into semantic item types; for example, `baseLeading`, `baseRegular`, and `subtle` all map to the `text` item with different `weight` and `tone` values.
161
+
162
+ | Figma item type | Use for | Notes |
163
+ | --- | --- | --- |
164
+ | `checkbox` | Row selection | Fixed selection column. |
165
+ | `baseLeading` | Primary label | Medium body label. |
166
+ | `baseRegular` | Standard body text | Regular body label. |
167
+ | `subtle` | Secondary text | Uses subtle content color. |
168
+ | `avatarText` | Person, owner, assignee | Avatar plus label; `lg` may include caption. Name and caption resolve direction independently. |
169
+ | `rating` | Star rating | Five 20px stars with full, half, and empty states. |
170
+ | `progress` | Percent completion | 8px track, percent label, mirrored fill in RTL. |
171
+ | `toggle` | Binary row setting | 32px switch in `sm`; preserve native button semantics. |
172
+ | `badges` | Status and categorical chips | Supports multiple badges and overflow count. |
173
+ | `onlyAvatar` | Compact person cell | Single avatar centered or aligned by column. |
174
+ | `avatarStack` | Team or group membership | Overlapped 20px avatars, optional count and add button. |
175
+ | `tags` | Neutral labels | Bordered tags with compact 24px height. |
176
+ | `file` | Attachment indicator | Icon-only file cell. |
177
+ | `brandLogoText` | Brand or account identity | Logo plus label. |
178
+ | `payment` | Payment method | Payment icon plus optional label. |
179
+ | `image` | Thumbnail item | Image thumbnail plus label. |
180
+ | `action` | Single row menu | Icon button, usually overflow menu. |
181
+ | `actionGroup` | Multiple row actions | View, edit, delete group; reverse order in RTL. |
182
+
183
+ ```ts
184
+ type TableItem =
185
+ | { type: "checkbox"; checked: boolean; indeterminate?: boolean }
186
+ | { type: "text"; tone?: "default" | "subtle"; weight?: "regular" | "medium"; value: string }
187
+ | { type: "avatarText"; name: string; caption?: string; src?: string; status?: "top" | "bottom" }
188
+ | { type: "rating"; value: number; max?: 5 }
189
+ | { type: "progress"; value: number; label?: string; tone?: "success" | "brand" }
190
+ | { type: "toggle"; checked: boolean; disabled?: boolean }
191
+ | { type: "badges"; items: BadgeItem[]; maxVisible?: number }
192
+ | { type: "onlyAvatar"; src?: string; alt: string }
193
+ | { type: "avatarStack"; avatars: AvatarItem[]; count?: number; canAdd?: boolean }
194
+ | { type: "tags"; items: string[]; maxVisible?: number }
195
+ | { type: "file"; label?: string }
196
+ | { type: "brandLogoText"; label: string; logoSrc?: string }
197
+ | { type: "payment"; brand: "maestro" | "mastercard" | "visa" | string; label?: string }
198
+ | { type: "image"; label: string; src: string }
199
+ | { type: "action"; label: string; icon: "more"; onAction: () => void }
200
+ | { type: "actionGroup"; actions: TableAction[] };
201
+
202
+ type BadgeItem = {
203
+ label: string;
204
+ tone?: "blue" | "fuchsia" | "amber" | "neutral" | "success" | "warning" | "danger";
205
+ dot?: boolean;
206
+ };
207
+
208
+ type AvatarItem = {
209
+ src?: string;
210
+ alt: string;
211
+ };
212
+
213
+ type TableAction = {
214
+ label: string;
215
+ icon: "view" | "edit" | "delete" | "more";
216
+ onAction: () => void;
217
+ };
218
+ ```
219
+
220
+ The item union intentionally describes content, not layout. `TableCell` decides padding, alignment, truncation, and RTL mirroring.
221
+
222
+ ## Adding Items
223
+
224
+ Add a new table item by defining it on a column. The row supplies content values; the column controls presentation.
225
+
226
+ ```tsx
227
+ const columns: TableColumn<Project>[] = [
228
+ {
229
+ id: "project",
230
+ header: "Project Name",
231
+ width: "fill",
232
+ sortable: true,
233
+ item: (project) => ({
234
+ type: "text",
235
+ value: project.name,
236
+ weight: "regular",
237
+ }),
238
+ },
239
+ {
240
+ id: "leader",
241
+ header: "Project Leader",
242
+ width: 203,
243
+ sortable: true,
244
+ item: (project) => ({
245
+ type: "avatarText",
246
+ name: project.leader.name,
247
+ src: project.leader.avatarUrl,
248
+ }),
249
+ },
250
+ {
251
+ id: "status",
252
+ header: "Status",
253
+ width: 147,
254
+ sortable: true,
255
+ item: (project) => ({
256
+ type: "badges",
257
+ items: [{ label: project.status, tone: "blue", dot: true }],
258
+ }),
259
+ },
260
+ {
261
+ id: "progress",
262
+ header: "Progress",
263
+ width: 160,
264
+ sortable: true,
265
+ item: (project) => ({
266
+ type: "progress",
267
+ value: project.progress,
268
+ label: `${project.progress}%`,
269
+ tone: "success",
270
+ }),
271
+ },
272
+ {
273
+ id: "deadline",
274
+ header: "Deadline",
275
+ width: 155,
276
+ sortable: true,
277
+ item: (project) => ({
278
+ type: "text",
279
+ value: project.deadlineLabel,
280
+ }),
281
+ },
282
+ {
283
+ id: "actions",
284
+ width: 44,
285
+ kind: "actions",
286
+ item: (project) => ({
287
+ type: "action",
288
+ label: `Open actions for ${project.name}`,
289
+ icon: "more",
290
+ onAction: () => openProjectActions(project.id),
291
+ }),
292
+ },
293
+ ];
294
+ ```
295
+
296
+ For a custom item, first check whether the content can be represented by the existing union. Add a new item type only when the content appears in more than one table or needs shared behavior such as keyboard handling, truncation, or overflow.
297
+
298
+ ## Header Behavior
299
+
300
+ Sortable headers render the label plus the expand-up-down icon. When sorted, the header cell sets `aria-sort` to `ascending` or `descending`; otherwise it uses `none`. Header controls must have a clear label such as `Sort by Project Name`.
301
+
302
+ `Table` accepts `sort` and `onSortChange` when the host owns sorting. `DataTable` can own sorting internally with `defaultSort`, or operate as a controlled component with `sort` and `onSortChange`.
303
+
304
+ The select-all checkbox announces:
305
+
306
+ - unchecked when no visible rows are selected;
307
+ - checked when all visible rows are selected;
308
+ - indeterminate when some visible rows are selected.
309
+
310
+ ## Data Table
311
+
312
+ Use `DataTable` when the product needs the complete dataset browsing workflow instead of only rows and columns.
313
+
314
+ ```tsx
315
+ const filters = [
316
+ {
317
+ id: "review",
318
+ label: "Status",
319
+ value: "Review",
320
+ active: statusFilter === "Review",
321
+ onAction: () => setStatusFilter("Review"),
322
+ predicate: (row) => row.status === "Review",
323
+ },
324
+ ];
325
+
326
+ <DataTable
327
+ actions={[{ label: "Export", variant: "soft" }]}
328
+ bulkActions={[{ label: "Archive", variant: "outline" }]}
329
+ columns={columns}
330
+ defaultSort={{ columnId: "project", direction: "asc" }}
331
+ emptyState={{
332
+ title: "No matching projects",
333
+ description: "Try another search or return to all statuses.",
334
+ }}
335
+ filters={filters}
336
+ pagination={{ pageSize: 10 }}
337
+ rows={rows}
338
+ search={{ label: "Search projects", placeholder: "Search projects..." }}
339
+ />
340
+ ```
341
+
342
+ `DataTable` applies active filter predicates, searches row text from `getRowSearchText`, column `searchValue`, or table item text, sorts by column `sortValue` or table item value, and paginates the resulting rows. Set `pagination={false}` for unpaginated datasets. When `pagination.showCaption` is enabled, the Pagination caption receives the same measured visible range and total as the DataTable footer summary; the standalone Pagination demo default is never used for table data.
343
+
344
+ Direction does not choose language. Pass `pagination.messages` to localize Pagination controls and accessible names, and pass `labels.resultsSummary` to format the measured DataTable range and total. An explicit `pagination.ariaLabel` overrides the message catalog's navigation label.
345
+
346
+ ## Accessibility
347
+
348
+ - Preserve native controls for checkbox, toggle, buttons, and menu triggers.
349
+ - Use `aria-selected` on selected rows.
350
+ - Provide labels for icon-only actions.
351
+ - Keep focus outlines visible through `border.focus`.
352
+ - Truncate long text visually, but keep the full value available through `title` or an accessible label when useful.
353
+ - Do not put multiple unrelated buttons into one unlabeled cell; group row actions with a clear accessible name.
354
+
355
+ ## Usage
356
+
357
+ ```tsx
358
+ <Table
359
+ dir="ltr"
360
+ columns={columns}
361
+ rows={projects}
362
+ selectedRowIds={selectedRowIds}
363
+ onSelectedRowIdsChange={setSelectedRowIds}
364
+ />
365
+
366
+ <Table
367
+ dir="rtl"
368
+ columns={columns}
369
+ rows={projects}
370
+ selectedRowIds={selectedRowIds}
371
+ onSelectedRowIdsChange={setSelectedRowIds}
372
+ />
373
+ ```
374
+
375
+ ## Preset Impact
376
+
377
+ - `default`: normal row density, quiet header background, modest control radius.
378
+ - `rounded`: slightly taller rows, softer hover treatment, larger badges and control radius.
379
+ - `sharp`: denser rows, stronger dividers, square or near-square controls.
380
+
381
+ ## Implementation Notes
382
+
383
+ - Use Remix icons for Figma icon matches: `expand-up-down-line`, `more-fill`, `check-fill`, `eye-line`, `pencil-line`, and `delete-bin-line`.
384
+ - Progress bars are `8px` high and pill-shaped. In RTL, the filled segment grows from the right.
385
+ - Badges are `24px` tall, pill-shaped, and use `11px / 14px` medium text.
386
+ - Tags are `24px` tall with a 1px border and `13px / 20px` medium text.
387
+ - Avatar-with-text cells use the shared 24px avatar in `sm` rows. Avatar-only and avatar-stack cells use 20px avatars. All three use 32px avatars in `lg` rows.
388
+ - Action buttons are fixed `28px` in `sm` rows and `32px` in `lg` rows.
389
+
390
+ ## Install
391
+
392
+ ```bash
393
+ npx banhaten add table
394
+ ```
395
+
396
+ ## API
397
+
398
+ Supported runtime exports: `DataTable`, `Table`, `DataTableSurface`, `TableBody`, `TableCell`, `TableHead`, `TableHeader`, `TableRoot`, `TableRowElement`.
399
+
400
+ Use the live registry docs for the generated API table and source-backed examples.
401
+
402
+ ## Examples
403
+
404
+ Primary registry example: `examples/expanded/table-demo.tsx`.
405
+
406
+ Open the live component page or run `npx banhaten docs table` to inspect source files, install command, and examples.
407
+
408
+ ## Token Contract
409
+
410
+ Component styles must resolve through Banhaten semantic tokens, component aliases, or documented exception-ledger values.
411
+ Do not add raw colors, pixel values, opacity utilities, z-index values, durations, or shadow literals directly to component source.
412
+ Covered source files: `components/expanded/table.css`, `components/expanded/Table.tsx`.
413
+
414
+ ## RTL Rules
415
+
416
+ The table layout inherits document direction and uses logical spacing. Within `avatarText`, the independently truncated name and caption use `dir="auto"`; this preserves the identifying start of Latin content in an RTL table (and Arabic content in an LTR table) while the avatar and columns continue to mirror with the table.
417
+
414
418
  <!-- registry-contract:start -->
415
419
  ## Registry Contract
416
420
 
@@ -422,8 +426,9 @@ This table is generated from `registry/index.json`; edit the component-owned sou
422
426
  | `supportedExports` | `components/expanded/Table.tsx: DataTable, Table`, `components/table-elements.tsx: DataTableSurface, TableBody, TableCell, TableHead, TableHeader, TableRoot, TableRowElement` |
423
427
  | `parts` | `Table`, `DataTable`, `DataTableSurface`, `TableRoot`, `TableHeader`, `TableBody`, `TableRowElement`, `TableHead`, `TableCell` |
424
428
  | `registryDependencies` | `avatar`, `badge`, `button`, `checkbox`, `pagination`, `progress`, `spinner`, `tag`, `toggle`, `toolbar` |
429
+ | `features` | `measured DataTable pagination captions`, `explicit DataTable pagination message catalogs`, `safe row-key cell fallback` |
425
430
  | `modes` | `table`, `data-table` |
426
431
  | `sizes` | `sm`, `lg` |
427
432
  | `states` | `default`, `selected`, `disabled`, `loading`, `empty`, `error` |
428
- | `tokens` | `--bh-avatar-fallback-font-size-md`, `--bh-avatar-fallback-font-size-xs`, `--bh-avatar-size-md`, `--bh-avatar-size-xs`, `--bh-bg-accent-amber-subtle`, `--bh-bg-accent-fuchsia-subtle`, `--bh-bg-accent-golden-default`, `--bh-bg-brand-default`, `--bh-bg-brand-soft`, `--bh-bg-danger-subtle`, `--bh-bg-default`, `--bh-bg-muted`, `--bh-bg-neutral-medium`, `--bh-bg-neutral-soft`, `--bh-bg-neutral-subtle`, `--bh-bg-raised`, `--bh-bg-success-default`, `--bh-bg-success-subtle`, `--bh-bg-warning-default`, `--bh-bg-warning-subtle`, `--bh-border-brand-strong`, `--bh-border-default`, `--bh-border-focus`, `--bh-border-subtle`, `--bh-content-accent-amber-strong`, `--bh-content-accent-fuchsia-strong`, `--bh-content-brand-default`, `--bh-content-danger-strong`, `--bh-content-default`, `--bh-content-muted`, `--bh-content-on-brand`, `--bh-content-subtle`, `--bh-content-success-default`, `--bh-content-warning-strong`, `--bh-control-default`, `--bh-duration-fast`, `--bh-easing-standard`, `--bh-focus-ring-width`, `--bh-font-family`, `--bh-font-weight-semibold`, `--bh-icon-stroke-190`, `--bh-icon-stroke-225`, `--bh-input-width`, `--bh-interactive-ghost-hover`, `--bh-opacity-0`, `--bh-opacity-100`, `--bh-opacity-muted`, `--bh-radius-full`, `--bh-radius-lg-8`, `--bh-radius-md-6`, `--bh-radius-sm-4`, `--bh-space-12xl-128`, `--bh-space-16xl-256`, `--bh-space-19xl-384`, `--bh-space-2xl-14`, `--bh-space-3xl-16`, `--bh-space-4xl-20`, `--bh-space-5xl-24`, `--bh-space-6xl-32`, `--bh-space-7xl-40`, `--bh-space-8xl-48`, `--bh-space-md-8`, `--bh-space-sm-6`, `--bh-space-xl-12`, `--bh-space-xs-4`, `--bh-space-xxs-2`, `--bh-space-xxxs-1`, `--bh-table-min-width`, `--bh-table-selection-column-min-width`, `--bh-text-base-letter-spacing`, `--bh-text-body-2xs-regular-font-size`, `--bh-text-body-2xs-regular-line-height`, `--bh-text-body-3xs-regular-font-size`, `--bh-text-body-3xs-regular-line-height`, `--bh-text-body-lg-semibold-font-size`, `--bh-text-body-lg-semibold-font-weight`, `--bh-text-body-lg-semibold-line-height`, `--bh-text-body-md-semibold-font-size`, `--bh-text-body-md-semibold-font-weight`, `--bh-text-body-md-semibold-line-height`, `--bh-text-body-sm-medium-font-weight`, `--bh-text-body-sm-regular-font-size`, `--bh-text-body-sm-regular-font-weight`, `--bh-text-body-sm-regular-line-height`, `--bh-text-body-xs-regular-font-size`, `--shadow-component-focus-ring` |
433
+ | `tokens` | `--bh-avatar-fallback-font-size-md`, `--bh-avatar-fallback-font-size-xs`, `--bh-avatar-size-md`, `--bh-avatar-size-xs`, `--bh-bg-accent-amber-subtle`, `--bh-bg-accent-fuchsia-subtle`, `--bh-bg-accent-golden-default`, `--bh-bg-brand-default`, `--bh-bg-brand-soft`, `--bh-bg-danger-subtle`, `--bh-bg-default`, `--bh-bg-muted`, `--bh-bg-neutral-medium`, `--bh-bg-neutral-soft`, `--bh-bg-neutral-subtle`, `--bh-bg-raised`, `--bh-bg-success-default`, `--bh-bg-success-subtle`, `--bh-bg-warning-default`, `--bh-bg-warning-subtle`, `--bh-border-brand-strong`, `--bh-border-default`, `--bh-border-focus`, `--bh-border-subtle`, `--bh-content-accent-amber-strong`, `--bh-content-accent-fuchsia-strong`, `--bh-content-brand-default`, `--bh-content-danger-strong`, `--bh-content-default`, `--bh-content-muted`, `--bh-content-on-brand`, `--bh-content-subtle`, `--bh-content-success-default`, `--bh-content-warning-strong`, `--bh-control-default`, `--bh-duration-fast`, `--bh-easing-standard`, `--bh-focus-ring-width`, `--bh-font-family`, `--bh-font-weight-semibold`, `--bh-icon-size-default`, `--bh-icon-slot-size-default`, `--bh-icon-stroke-190`, `--bh-icon-stroke-225`, `--bh-input-width`, `--bh-interactive-ghost-hover`, `--bh-opacity-0`, `--bh-opacity-100`, `--bh-opacity-muted`, `--bh-radius-full`, `--bh-radius-lg-8`, `--bh-radius-md-6`, `--bh-radius-sm-4`, `--bh-space-12xl-128`, `--bh-space-16xl-256`, `--bh-space-19xl-384`, `--bh-space-2xl-14`, `--bh-space-3xl-16`, `--bh-space-4xl-20`, `--bh-space-5xl-24`, `--bh-space-6xl-32`, `--bh-space-7xl-40`, `--bh-space-8xl-48`, `--bh-space-md-8`, `--bh-space-sm-6`, `--bh-space-xl-12`, `--bh-space-xs-4`, `--bh-space-xxs-2`, `--bh-space-xxxs-1`, `--bh-table-min-width`, `--bh-table-selection-column-min-width`, `--bh-text-base-letter-spacing`, `--bh-text-body-2xs-regular-font-size`, `--bh-text-body-2xs-regular-line-height`, `--bh-text-body-3xs-regular-font-size`, `--bh-text-body-3xs-regular-line-height`, `--bh-text-body-lg-semibold-font-size`, `--bh-text-body-lg-semibold-font-weight`, `--bh-text-body-lg-semibold-line-height`, `--bh-text-body-md-semibold-font-size`, `--bh-text-body-md-semibold-font-weight`, `--bh-text-body-md-semibold-line-height`, `--bh-text-body-sm-medium-font-weight`, `--bh-text-body-sm-regular-font-size`, `--bh-text-body-sm-regular-font-weight`, `--bh-text-body-sm-regular-line-height`, `--bh-text-body-xs-regular-font-size`, `--elevation-component-focus-ring` |
429
434
  <!-- registry-contract:end -->