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.
- package/CHANGELOG.md +139 -73
- package/CONTRIBUTING.md +46 -44
- package/README.md +192 -190
- package/SECURITY.md +15 -15
- package/banhaten.config.example.json +11 -11
- package/docs/design-spacing.md +13 -0
- package/docs/design-system/README.md +22 -20
- package/docs/design-system/adoption-quality-remediation.md +87 -87
- package/docs/design-system/agent-usage.md +13 -13
- package/docs/design-system/appearance-presets.md +189 -189
- package/docs/design-system/appearances/default.md +94 -94
- package/docs/design-system/appearances/rounded.md +95 -95
- package/docs/design-system/appearances/sharp.md +95 -95
- package/docs/design-system/component-docs-pattern.md +81 -81
- package/docs/design-system/component-implementation-ownership-audit.md +245 -244
- package/docs/design-system/component-quality-audit-2026-08-20.md +225 -223
- package/docs/design-system/component-showcase-consistency-report.md +219 -219
- package/docs/design-system/component-token-consistency-audit.md +173 -173
- package/docs/design-system/components/README.md +90 -76
- package/docs/design-system/components/accordion.md +53 -53
- package/docs/design-system/components/activity-feed.md +94 -94
- package/docs/design-system/components/activity-heatmap.md +57 -57
- package/docs/design-system/components/agent-input.md +85 -0
- package/docs/design-system/components/alert-dialog.md +72 -72
- package/docs/design-system/components/alert.md +98 -98
- package/docs/design-system/components/approval-card.md +134 -0
- package/docs/design-system/components/aspect-ratio.md +45 -45
- package/docs/design-system/components/attribute.md +89 -89
- package/docs/design-system/components/autocomplete.md +75 -75
- package/docs/design-system/components/avatar.md +54 -54
- package/docs/design-system/components/badge.md +54 -54
- package/docs/design-system/components/banner.md +87 -87
- package/docs/design-system/components/breadcrumbs.md +177 -176
- package/docs/design-system/components/button-group.md +98 -98
- package/docs/design-system/components/button.md +83 -80
- package/docs/design-system/components/card.md +88 -88
- package/docs/design-system/components/carousel.md +46 -46
- package/docs/design-system/components/catalog-components.md +47 -47
- package/docs/design-system/components/chart.md +95 -24
- package/docs/design-system/components/checkbox.md +54 -54
- package/docs/design-system/components/collapsible.md +67 -53
- package/docs/design-system/components/command.md +62 -62
- package/docs/design-system/components/context-menu.md +46 -46
- package/docs/design-system/components/date-picker.md +81 -79
- package/docs/design-system/components/divider.md +102 -102
- package/docs/design-system/components/empty-state.md +56 -56
- package/docs/design-system/components/field.md +70 -70
- package/docs/design-system/components/file-upload.md +187 -187
- package/docs/design-system/components/hover-card.md +48 -48
- package/docs/design-system/components/icons.md +48 -48
- package/docs/design-system/components/inline-citations.md +93 -0
- package/docs/design-system/components/input-group.md +58 -58
- package/docs/design-system/components/input-otp.md +56 -56
- package/docs/design-system/components/input.md +117 -61
- package/docs/design-system/components/item.md +59 -57
- package/docs/design-system/components/kbd.md +54 -49
- package/docs/design-system/components/label.md +49 -49
- package/docs/design-system/components/menu.md +71 -61
- package/docs/design-system/components/menubar.md +47 -47
- package/docs/design-system/components/modal.md +105 -105
- package/docs/design-system/components/native-select.md +54 -54
- package/docs/design-system/components/navigation-menu.md +50 -50
- package/docs/design-system/components/onboarding-step-list-item.md +82 -82
- package/docs/design-system/components/page-header.md +93 -86
- package/docs/design-system/components/pagination.md +57 -57
- package/docs/design-system/components/popover.md +60 -60
- package/docs/design-system/components/progress-slider.md +50 -50
- package/docs/design-system/components/progress.md +76 -76
- package/docs/design-system/components/radio-card.md +51 -51
- package/docs/design-system/components/radio-group.md +57 -57
- package/docs/design-system/components/resizable.md +44 -44
- package/docs/design-system/components/rolling-count.md +61 -0
- package/docs/design-system/components/scroll-area.md +51 -51
- package/docs/design-system/components/segmented-control.md +54 -54
- package/docs/design-system/components/select.md +68 -62
- package/docs/design-system/components/sheet.md +67 -67
- package/docs/design-system/components/shimmer-text.md +67 -0
- package/docs/design-system/components/sidebar.md +127 -76
- package/docs/design-system/components/skeleton.md +75 -75
- package/docs/design-system/components/slideout.md +65 -65
- package/docs/design-system/components/slider.md +63 -63
- package/docs/design-system/components/social-button.md +50 -50
- package/docs/design-system/components/spinner.md +62 -62
- package/docs/design-system/components/steps.md +65 -65
- package/docs/design-system/components/streaming-text.md +82 -0
- package/docs/design-system/components/table.md +419 -414
- package/docs/design-system/components/tabs.md +59 -55
- package/docs/design-system/components/tag.md +80 -80
- package/docs/design-system/components/task-list.md +95 -0
- package/docs/design-system/components/textarea.md +50 -50
- package/docs/design-system/components/thinking-reasoning.md +72 -0
- package/docs/design-system/components/thinking-state.md +67 -0
- package/docs/design-system/components/timeline.md +83 -83
- package/docs/design-system/components/toast.md +58 -58
- package/docs/design-system/components/toggle.md +81 -81
- package/docs/design-system/components/toolbar.md +92 -87
- package/docs/design-system/components/tooltip.md +94 -92
- package/docs/design-system/components/typography.md +18 -18
- package/docs/design-system/density-and-elevation.md +65 -61
- package/docs/design-system/design-system-test-missing-items.md +368 -368
- package/docs/design-system/direction-and-localization.md +23 -23
- package/docs/design-system/form-recipes.md +73 -73
- package/docs/design-system/gap-promotion-policy.md +21 -21
- package/docs/design-system/icons.md +74 -69
- package/docs/design-system/installation.md +70 -68
- package/docs/design-system/launch-comparison-shadcn.md +98 -98
- package/docs/design-system/registry-and-cli.md +64 -64
- package/docs/design-system/release-policy.md +30 -30
- package/docs/design-system/roadmap.md +14 -14
- package/docs/design-system/support-matrix.md +23 -23
- package/docs/design-system/tabs.md +54 -53
- package/docs/design-system/template-gap-audit.md +32 -0
- package/docs/design-system/templates.md +59 -0
- package/docs/design-system/token-governance.md +72 -60
- package/package.json +98 -98
- package/registry/component-contract.json +40 -40
- package/registry/components/accordion.tsx +155 -155
- package/registry/components/agent-input-parts.tsx +552 -0
- package/registry/components/agent-input-state.ts +156 -0
- package/registry/components/agent-input.css +307 -0
- package/registry/components/agent-input.tsx +382 -0
- package/registry/components/alert-dialog.tsx +297 -297
- package/registry/components/alert.tsx +293 -293
- package/registry/components/approval-card.css +409 -0
- package/registry/components/approval-card.tsx +401 -0
- package/registry/components/approval-frame.tsx +108 -0
- package/registry/components/approval-questions.tsx +559 -0
- package/registry/components/aspect-ratio.tsx +30 -30
- package/registry/components/attribute.tsx +454 -448
- package/registry/components/autocomplete.tsx +598 -651
- package/registry/components/avatar.tsx +385 -381
- package/registry/components/badge.tsx +629 -629
- package/registry/components/button-group.tsx +565 -565
- package/registry/components/button.tsx +127 -123
- package/registry/components/card.tsx +638 -638
- package/registry/components/carousel.tsx +296 -296
- package/registry/components/chart-block-data.ts +177 -0
- package/registry/components/chart-block.css +171 -0
- package/registry/components/chart-block.tsx +260 -0
- package/registry/components/chart-interactions.ts +123 -0
- package/registry/components/chart-options.cartesian.ts +162 -0
- package/registry/components/chart-options.paint.ts +99 -0
- package/registry/components/chart-options.parts.ts +72 -0
- package/registry/components/chart-options.radial.ts +109 -0
- package/registry/components/chart-options.ts +44 -0
- package/registry/components/chart-options.types.ts +67 -0
- package/registry/components/chart.tsx +203 -203
- package/registry/components/checkbox.tsx +247 -247
- package/registry/components/collapsible.tsx +109 -69
- package/registry/components/command.tsx +208 -208
- package/registry/components/context-menu.tsx +236 -236
- package/registry/components/data-chart.tsx +40 -0
- package/registry/components/date-picker.tsx +1289 -1277
- package/registry/components/echart-theme.ts +246 -0
- package/registry/components/echart.css +49 -0
- package/registry/components/echart.tsx +178 -0
- package/registry/components/expanded/ActivityFeed.tsx +227 -227
- package/registry/components/expanded/ActivityHeatmap.tsx +64 -64
- package/registry/components/expanded/Banner.tsx +179 -179
- package/registry/components/expanded/Breadcrumbs.tsx +131 -131
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +205 -205
- package/registry/components/expanded/CatalogDivider.tsx +49 -49
- package/registry/components/expanded/EmptyState.tsx +155 -155
- package/registry/components/expanded/FileUpload.tsx +543 -543
- package/registry/components/expanded/OnboardingStepListItem.tsx +60 -59
- package/registry/components/expanded/PageHeader.tsx +179 -166
- package/registry/components/expanded/Slideout.tsx +108 -108
- package/registry/components/expanded/Steps.tsx +402 -402
- package/registry/components/expanded/Table.tsx +1092 -1071
- package/registry/components/expanded/Timeline.tsx +203 -203
- package/registry/components/expanded/activityFeed.css +248 -248
- package/registry/components/expanded/activityHeatmap.css +66 -66
- package/registry/components/expanded/banner.css +260 -255
- package/registry/components/expanded/breadcrumbs.css +140 -140
- package/registry/components/expanded/catalogComponentsShowcase.css +87 -87
- package/registry/components/expanded/divider.css +75 -75
- package/registry/components/expanded/emptyState.css +111 -111
- package/registry/components/expanded/fileUpload.css +457 -457
- package/registry/components/expanded/onboardingStepListItem.css +135 -126
- package/registry/components/expanded/pageHeader.css +248 -290
- package/registry/components/expanded/slideout.css +276 -276
- package/registry/components/expanded/steps.css +356 -356
- package/registry/components/expanded/table.css +606 -603
- package/registry/components/expanded/timeline.css +286 -286
- package/registry/components/field.tsx +283 -283
- package/registry/components/hover-card.tsx +48 -48
- package/registry/components/inline-citations.css +126 -0
- package/registry/components/inline-citations.tsx +292 -0
- package/registry/components/input-content.ts +107 -107
- package/registry/components/input-group.tsx +130 -130
- package/registry/components/input-otp.tsx +584 -584
- package/registry/components/input.tsx +990 -972
- package/registry/components/item.tsx +189 -189
- package/registry/components/kbd.tsx +246 -151
- package/registry/components/label.tsx +78 -78
- package/registry/components/menu.tsx +978 -986
- package/registry/components/menubar.tsx +226 -226
- package/registry/components/modal.tsx +872 -872
- package/registry/components/native-select.tsx +205 -205
- package/registry/components/navigation-menu.tsx +171 -171
- package/registry/components/pagination.css +36 -36
- package/registry/components/pagination.tsx +560 -555
- package/registry/components/popover.tsx +338 -338
- package/registry/components/progress-slider.tsx +216 -216
- package/registry/components/radio-card.tsx +676 -677
- package/registry/components/radio-group.tsx +570 -570
- package/registry/components/resizable.tsx +108 -108
- package/registry/components/rolling-count.css +37 -0
- package/registry/components/rolling-count.tsx +110 -0
- package/registry/components/scroll-area.tsx +91 -91
- package/registry/components/segmented-control.tsx +87 -87
- package/registry/components/select-content.tsx +218 -218
- package/registry/components/select.tsx +937 -932
- package/registry/components/sheet.tsx +305 -305
- package/registry/components/shimmer-text.css +69 -0
- package/registry/components/shimmer-text.tsx +43 -0
- package/registry/components/sidebar.tsx +1433 -358
- package/registry/components/skeleton.css +54 -54
- package/registry/components/skeleton.tsx +482 -482
- package/registry/components/slider.tsx +380 -380
- package/registry/components/social-button.tsx +387 -387
- package/registry/components/spinner.tsx +78 -78
- package/registry/components/streaming-text.css +45 -0
- package/registry/components/streaming-text.tsx +165 -0
- package/registry/components/table-elements.tsx +128 -128
- package/registry/components/tabs.css +222 -218
- package/registry/components/tabs.tsx +241 -241
- package/registry/components/tag.tsx +423 -423
- package/registry/components/task-list.css +328 -0
- package/registry/components/task-list.tsx +429 -0
- package/registry/components/textarea.tsx +610 -610
- package/registry/components/thinking-reasoning.css +178 -0
- package/registry/components/thinking-reasoning.tsx +253 -0
- package/registry/components/thinking-state.css +8 -0
- package/registry/components/thinking-state.tsx +46 -0
- package/registry/components/toast.tsx +136 -136
- package/registry/components/toggle.tsx +256 -256
- package/registry/components/toolbar.tsx +539 -539
- package/registry/components/tooltip.tsx +433 -431
- package/registry/examples/agent-input-demo.tsx +90 -0
- package/registry/examples/alert-demo.tsx +34 -34
- package/registry/examples/alert-dialog-demo.tsx +42 -42
- package/registry/examples/approval-card-demo.tsx +83 -0
- package/registry/examples/aspect-ratio-demo.tsx +11 -11
- package/registry/examples/attribute-demo.tsx +65 -65
- package/registry/examples/autocomplete-demo.tsx +109 -109
- package/registry/examples/avatar-demo.tsx +132 -132
- package/registry/examples/badge-demo.tsx +69 -69
- package/registry/examples/button-demo.tsx +86 -83
- package/registry/examples/button-group-demo.tsx +63 -63
- package/registry/examples/card-demo.tsx +86 -86
- package/registry/examples/carousel-demo.tsx +43 -43
- package/registry/examples/chart-block-demo.tsx +5 -0
- package/registry/examples/chart-demo.tsx +18 -33
- package/registry/examples/checkbox-demo.tsx +62 -62
- package/registry/examples/collapsible-demo.tsx +16 -16
- package/registry/examples/collection-filter-bar-demo.tsx +135 -135
- package/registry/examples/command-demo.tsx +42 -42
- package/registry/examples/command-palette-demo.tsx +235 -236
- package/registry/examples/context-menu-demo.tsx +29 -29
- package/registry/examples/control-density-contract-demo.tsx +65 -61
- package/registry/examples/date-picker-demo.tsx +127 -127
- package/registry/examples/divider-demo.tsx +17 -17
- package/registry/examples/expanded/activity-heatmap-demo.tsx +29 -29
- package/registry/examples/expanded/banner-demo.tsx +48 -48
- package/registry/examples/expanded/breadcrumbs-demo.tsx +59 -59
- package/registry/examples/expanded/empty-state-demo.tsx +39 -39
- package/registry/examples/expanded/file-upload-demo.tsx +60 -60
- package/registry/examples/expanded/onboarding-step-demo.tsx +11 -11
- package/registry/examples/expanded/slideout-demo.tsx +15 -15
- package/registry/examples/expanded/steps-demo.tsx +29 -29
- package/registry/examples/expanded/tabs-demo.tsx +13 -13
- package/registry/examples/expanded/timeline-demo.tsx +18 -18
- package/registry/examples/field-demo.tsx +51 -51
- package/registry/examples/hover-card-demo.tsx +23 -23
- package/registry/examples/inline-citations-demo.tsx +31 -0
- package/registry/examples/input-actions-demo.tsx +36 -0
- package/registry/examples/input-demo.tsx +87 -87
- package/registry/examples/input-group-demo.tsx +16 -16
- package/registry/examples/input-otp-demo.tsx +72 -72
- package/registry/examples/item-demo.tsx +46 -46
- package/registry/examples/kbd-demo.tsx +12 -11
- package/registry/examples/label-demo.tsx +20 -20
- package/registry/examples/menu-demo.tsx +122 -122
- package/registry/examples/menubar-demo.tsx +34 -34
- package/registry/examples/modal-demo.tsx +74 -74
- package/registry/examples/native-select-demo.tsx +16 -16
- package/registry/examples/navigation-menu-demo.tsx +29 -29
- package/registry/examples/pagination-demo.tsx +20 -20
- package/registry/examples/popover-demo.tsx +547 -546
- package/registry/examples/progress-demo.tsx +37 -37
- package/registry/examples/progress-slider-demo.tsx +29 -29
- package/registry/examples/radio-card-demo.tsx +51 -51
- package/registry/examples/radio-group-demo.tsx +62 -62
- package/registry/examples/resizable-demo.tsx +22 -22
- package/registry/examples/results-toolbar-demo.tsx +44 -44
- package/registry/examples/rolling-count-demo.tsx +39 -0
- package/registry/examples/scroll-area-demo.tsx +15 -15
- package/registry/examples/segmented-control-demo.tsx +39 -39
- package/registry/examples/select-demo.tsx +87 -87
- package/registry/examples/sheet-demo.tsx +47 -47
- package/registry/examples/shimmer-text-demo.tsx +20 -0
- package/registry/examples/sidebar-demo.tsx +101 -57
- package/registry/examples/slider-demo.tsx +31 -31
- package/registry/examples/social-button-demo.tsx +61 -61
- package/registry/examples/spinner-demo.tsx +59 -59
- package/registry/examples/streaming-text-demo.tsx +28 -0
- package/registry/examples/tabs-demo.tsx +13 -13
- package/registry/examples/tag-demo.tsx +29 -29
- package/registry/examples/task-list-demo.tsx +74 -0
- package/registry/examples/textarea-demo.tsx +79 -79
- package/registry/examples/thinking-reasoning-demo.tsx +74 -0
- package/registry/examples/thinking-state-demo.tsx +13 -0
- package/registry/examples/toast-demo.tsx +35 -35
- package/registry/examples/toggle-demo.tsx +59 -59
- package/registry/examples/tooltip-demo.tsx +115 -115
- package/registry/guidance/USAGE.md +27 -27
- package/registry/guidance/charts.LICENSE.txt +24 -0
- package/registry/hooks/use-controllable-state.ts +33 -0
- package/registry/hooks/use-direction.ts +207 -207
- package/registry/hooks/use-listbox-navigation.ts +73 -0
- package/registry/hooks/use-motion-end.ts +55 -0
- package/registry/hooks/use-reduced-motion.ts +28 -0
- package/registry/index.json +1634 -184
- package/registry/styles/globals.css +1462 -1570
- package/registry.json +364 -10
- package/schema/config.schema.json +51 -51
- package/schema/registry.schema.json +194 -190
- package/schema/tokens.schema.json +167 -163
- package/src/cli/command-line.js +194 -194
- package/src/cli/config-editors.js +9 -9
- package/src/cli/doctor.js +399 -399
- package/src/cli/file-transaction.js +302 -295
- package/src/cli/global-css.js +153 -153
- package/src/cli/index.js +1002 -1009
- package/src/cli/install-plan.js +592 -592
- package/src/cli/install-receipt.js +171 -171
- package/src/cli/jsonc.js +203 -203
- package/src/cli/package-install-state.js +254 -254
- package/src/cli/package-manager.js +238 -238
- package/src/cli/package-plan.js +185 -185
- package/src/cli/package-version.js +97 -97
- package/src/cli/registry-query.js +207 -207
- package/src/cli/reporting.js +55 -55
- package/src/cli/schema-validation.js +19 -19
- package/src/cli/source-scanner.js +686 -686
- package/src/cli/vite-config.js +478 -478
- 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
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
|
163
|
-
|
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
167
|
-
| `
|
|
168
|
-
| `
|
|
169
|
-
| `
|
|
170
|
-
| `
|
|
171
|
-
| `
|
|
172
|
-
| `
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
175
|
-
| `
|
|
176
|
-
| `
|
|
177
|
-
| `
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
| { type: "
|
|
186
|
-
| { type: "
|
|
187
|
-
| { type: "
|
|
188
|
-
| { type: "
|
|
189
|
-
| { type: "
|
|
190
|
-
| { type: "
|
|
191
|
-
| { type: "
|
|
192
|
-
| { type: "
|
|
193
|
-
| { type: "
|
|
194
|
-
| { type: "
|
|
195
|
-
| { type: "
|
|
196
|
-
| { type: "
|
|
197
|
-
| { type: "
|
|
198
|
-
| { type: "
|
|
199
|
-
|
|
200
|
-
type
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
-
|
|
305
|
-
|
|
306
|
-
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
-
|
|
349
|
-
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
-
|
|
384
|
-
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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`, `--
|
|
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 -->
|