@cdx-ui/components 0.2.3 → 0.2.4
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/AGENTS.md +24 -0
- package/README.md +2 -0
- package/coverage.svg +1 -1
- package/docs/components/accordion/content.md +538 -0
- package/docs/components/alert/content.md +203 -0
- package/docs/components/alert-dialog/content.md +319 -0
- package/docs/components/avatar/content.md +368 -0
- package/docs/components/avatar/design.md +202 -0
- package/docs/components/badge/content.md +235 -0
- package/docs/components/bottom-sheet/content.md +351 -0
- package/docs/components/bottom-sheet/design.md +249 -0
- package/docs/components/breadcrumbs/content.md +169 -0
- package/docs/components/button/content.md +398 -0
- package/docs/components/button/design.md +258 -0
- package/docs/components/calendar/content.md +137 -0
- package/docs/components/card/content.md +283 -0
- package/docs/components/carousel/content.md +416 -0
- package/docs/components/checkbox/content.md +236 -0
- package/docs/components/checkbox/design.md +214 -0
- package/docs/components/chip/content.md +439 -0
- package/docs/components/chip/design.md +418 -0
- package/docs/components/color-area/content.md +86 -0
- package/docs/components/color-field/content.md +134 -0
- package/docs/components/color-picker/content.md +208 -0
- package/docs/components/color-slider/content.md +120 -0
- package/docs/components/color-swatch/content.md +64 -0
- package/docs/components/color-swatch-picker/content.md +126 -0
- package/docs/components/content.md +97 -0
- package/docs/components/currency-input/content.md +205 -0
- package/docs/components/data-grid/content.md +522 -0
- package/docs/components/date-field/content.md +147 -0
- package/docs/components/date-picker/content.md +360 -0
- package/docs/components/date-range-picker/content.md +301 -0
- package/docs/components/date-time-field/content.md +157 -0
- package/docs/components/date-time-list/content.md +105 -0
- package/docs/components/date-time-picker/content.md +272 -0
- package/docs/components/dialog/content.md +436 -0
- package/docs/components/dialog/design.md +192 -0
- package/docs/components/divider/content.md +112 -0
- package/docs/components/drawer/content.md +436 -0
- package/docs/components/field/content.md +277 -0
- package/docs/components/form/content.md +62 -0
- package/docs/components/full-screen-dialog/content.md +881 -0
- package/docs/components/heading/content.md +55 -0
- package/docs/components/icon/content.md +190 -0
- package/docs/components/icon-button/content.md +200 -0
- package/docs/components/icon-button/design.md +165 -0
- package/docs/components/image/content.md +104 -0
- package/docs/components/input/content.md +281 -0
- package/docs/components/input/design.md +389 -0
- package/docs/components/insurance-disclosure/content.md +103 -0
- package/docs/components/link/content.md +180 -0
- package/docs/components/link/design.md +160 -0
- package/docs/components/list-item/content.md +695 -0
- package/docs/components/menu/content.md +1247 -0
- package/docs/components/month-calendar/content.md +84 -0
- package/docs/components/month-picker/content.md +273 -0
- package/docs/components/otp-input/content.md +327 -0
- package/docs/components/progress-bar/content.md +87 -0
- package/docs/components/progress-circle/content.md +176 -0
- package/docs/components/progress-segmented/content.md +119 -0
- package/docs/components/quick-action-button/content.md +154 -0
- package/docs/components/quick-action-button/design.md +170 -0
- package/docs/components/radio/content.md +224 -0
- package/docs/components/range-calendar/content.md +123 -0
- package/docs/components/reorderable-list/content.md +309 -0
- package/docs/components/scoped-theme/content.md +47 -0
- package/docs/components/scroll-shadow/content.md +686 -0
- package/docs/components/select/content.md +400 -0
- package/docs/components/select/design.md +301 -0
- package/docs/components/skeleton/content.md +103 -0
- package/docs/components/slider/content.md +423 -0
- package/docs/components/stack/content.md +161 -0
- package/docs/components/switch/content.md +150 -0
- package/docs/components/switch/design.md +208 -0
- package/docs/components/table/content.md +548 -0
- package/docs/components/table-pagination/content.md +177 -0
- package/docs/components/tabs/content.md +292 -0
- package/docs/components/text/content.md +142 -0
- package/docs/components/textarea/content.md +222 -0
- package/docs/components/tile/content.md +703 -0
- package/docs/components/toast/content.md +456 -0
- package/docs/components/toggle-button/content.md +505 -0
- package/docs/components/tooltip/content.md +350 -0
- package/docs/components/virtualized-list/content.md +250 -0
- package/docs/foundations/content.md +9 -0
- package/docs/foundations/expressions/icons/content.md +19 -0
- package/docs/foundations/styles/tokens/all-tokens/content.md +192 -0
- package/docs/foundations/styles/tokens/what-are-tokens/content.md +33 -0
- package/docs/foundations/styles/tokens/what-are-tokens/design.md +33 -0
- package/docs/getting-started/content.md +4 -0
- package/docs/getting-started/designers/content.md +13 -0
- package/docs/getting-started/designers/design.md +13 -0
- package/docs/getting-started/developers/accessibility/content.md +31 -0
- package/docs/getting-started/developers/content.md +612 -0
- package/docs/getting-started/developers/styling/content.md +193 -0
- package/docs/llms.txt +193 -0
- package/docs/patterns/account-management/content.md +75 -0
- package/docs/patterns/authentication/content.md +52 -0
- package/docs/patterns/content.md +10 -0
- package/docs/patterns/dashboard/content.md +39 -0
- package/docs/patterns/empty-states/content.md +31 -0
- package/docs/patterns/forms/content.md +109 -0
- package/docs/patterns/onboarding/content.md +69 -0
- package/docs/patterns/payments/content.md +35 -0
- package/docs/patterns/settings/content.md +72 -0
- package/docs/resources/content.md +9 -0
- package/docs/resources/figma-libraries/content.md +42 -0
- package/docs/resources/release-notes/0.0.1-beta.118/content.md +27 -0
- package/docs/resources/release-notes/0.0.1-beta.122/content.md +21 -0
- package/docs/resources/release-notes/0.0.1-beta.124/content.md +16 -0
- package/docs/resources/release-notes/0.0.1-beta.126/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.127/content.md +14 -0
- package/docs/resources/release-notes/0.0.1-beta.128/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.129/content.md +18 -0
- package/docs/resources/release-notes/0.0.1-beta.130/content.md +18 -0
- package/docs/resources/release-notes/0.0.1-beta.133/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.134/content.md +17 -0
- package/docs/resources/release-notes/0.0.1-beta.136/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.137/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.138/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.139/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.140/content.md +26 -0
- package/docs/resources/release-notes/0.0.1-beta.141/content.md +63 -0
- package/docs/resources/release-notes/0.0.1-beta.142/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.143/content.md +12 -0
- package/docs/resources/release-notes/0.0.1-beta.144/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.145/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.147/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.149/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.150/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.152/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.154/content.md +15 -0
- package/docs/resources/release-notes/0.0.1-beta.156/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.158/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.159/content.md +11 -0
- package/docs/resources/release-notes/0.0.1-beta.160/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.161/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.163/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.164/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.166/content.md +17 -0
- package/docs/resources/release-notes/0.0.1-beta.167/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.168/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.169/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.171/content.md +16 -0
- package/docs/resources/release-notes/0.0.1-beta.172/content.md +24 -0
- package/docs/resources/release-notes/0.0.1-beta.173/content.md +15 -0
- package/docs/resources/release-notes/0.0.1-beta.174/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.176/content.md +32 -0
- package/docs/resources/release-notes/0.0.1-beta.179/content.md +11 -0
- package/docs/resources/release-notes/0.0.1-beta.182/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.185/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.187/content.md +27 -0
- package/docs/resources/release-notes/0.1.1/content.md +23 -0
- package/docs/resources/release-notes/0.1.2/content.md +7 -0
- package/docs/resources/release-notes/0.1.4/content.md +19 -0
- package/docs/resources/release-notes/0.1.5/content.md +7 -0
- package/docs/resources/release-notes/0.1.6/content.md +7 -0
- package/docs/resources/release-notes/0.2.0/content.md +31 -0
- package/docs/resources/release-notes/0.2.1/content.md +17 -0
- package/docs/resources/release-notes/0.2.2/content.md +11 -0
- package/docs/resources/release-notes/0.2.3/content.md +15 -0
- package/docs/resources/release-notes/content.md +64 -0
- package/lib/commonjs/components/DateTimeList/index.js +11 -26
- package/lib/commonjs/components/DateTimeList/index.js.map +1 -1
- package/lib/commonjs/components/DateTimeList/styles.js +2 -12
- package/lib/commonjs/components/DateTimeList/styles.js.map +1 -1
- package/lib/commonjs/components/ListItem/index.js.map +1 -1
- package/lib/commonjs/components/ListItem/styles.js +2 -1
- package/lib/commonjs/components/ListItem/styles.js.map +1 -1
- package/lib/commonjs/components/Menu/index.js +11 -5
- package/lib/commonjs/components/Menu/index.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/gradient.js +29 -0
- package/lib/commonjs/components/ScrollShadow/gradient.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/index.js +171 -44
- package/lib/commonjs/components/ScrollShadow/index.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/styles.js +58 -14
- package/lib/commonjs/components/ScrollShadow/styles.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/useComposedScrollHandler.js +63 -0
- package/lib/commonjs/components/ScrollShadow/useComposedScrollHandler.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +48 -8
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/commonjs/components/Tabs/index.js +16 -23
- package/lib/commonjs/components/Tabs/index.js.map +1 -1
- package/lib/commonjs/components/Tabs/styles.js +1 -10
- package/lib/commonjs/components/Tabs/styles.js.map +1 -1
- package/lib/commonjs/figma/ListItem.SectionHeader.figma.js +20 -5
- package/lib/commonjs/figma/ListItem.SectionHeader.figma.js.map +1 -1
- package/lib/module/components/DateTimeList/index.js +12 -27
- package/lib/module/components/DateTimeList/index.js.map +1 -1
- package/lib/module/components/DateTimeList/styles.js +1 -11
- package/lib/module/components/DateTimeList/styles.js.map +1 -1
- package/lib/module/components/ListItem/index.js.map +1 -1
- package/lib/module/components/ListItem/styles.js +2 -1
- package/lib/module/components/ListItem/styles.js.map +1 -1
- package/lib/module/components/Menu/index.js +11 -5
- package/lib/module/components/Menu/index.js.map +1 -1
- package/lib/module/components/ScrollShadow/gradient.js +24 -0
- package/lib/module/components/ScrollShadow/gradient.js.map +1 -0
- package/lib/module/components/ScrollShadow/index.js +170 -48
- package/lib/module/components/ScrollShadow/index.js.map +1 -1
- package/lib/module/components/ScrollShadow/styles.js +57 -13
- package/lib/module/components/ScrollShadow/styles.js.map +1 -1
- package/lib/module/components/ScrollShadow/useComposedScrollHandler.js +57 -0
- package/lib/module/components/ScrollShadow/useComposedScrollHandler.js.map +1 -0
- package/lib/module/components/ScrollShadow/useScrollShadow.js +46 -8
- package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/module/components/Tabs/index.js +17 -24
- package/lib/module/components/Tabs/index.js.map +1 -1
- package/lib/module/components/Tabs/styles.js +0 -9
- package/lib/module/components/Tabs/styles.js.map +1 -1
- package/lib/module/figma/ListItem.SectionHeader.figma.js +20 -5
- package/lib/module/figma/ListItem.SectionHeader.figma.js.map +1 -1
- package/lib/typescript/components/DateTimeList/index.d.ts.map +1 -1
- package/lib/typescript/components/DateTimeList/styles.d.ts +1 -4
- package/lib/typescript/components/DateTimeList/styles.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/index.d.ts +5 -4
- package/lib/typescript/components/ListItem/index.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts.map +1 -1
- package/lib/typescript/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/gradient.d.ts +7 -0
- package/lib/typescript/components/ScrollShadow/gradient.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/index.d.ts +57 -15
- package/lib/typescript/components/ScrollShadow/index.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/styles.d.ts +8 -2
- package/lib/typescript/components/ScrollShadow/styles.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/useComposedScrollHandler.d.ts +13 -0
- package/lib/typescript/components/ScrollShadow/useComposedScrollHandler.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts +15 -2
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
- package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
- package/lib/typescript/components/Tabs/styles.d.ts +0 -7
- package/lib/typescript/components/Tabs/styles.d.ts.map +1 -1
- package/lib/typescript/figma/ListItem.SectionHeader.figma.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/components/DateTimeList/index.tsx +13 -26
- package/src/components/DateTimeList/styles.ts +1 -10
- package/src/components/ListItem/index.tsx +5 -4
- package/src/components/ListItem/styles.ts +1 -0
- package/src/components/Menu/index.tsx +11 -8
- package/src/components/ScrollShadow/gradient.ts +48 -0
- package/src/components/ScrollShadow/index.tsx +300 -69
- package/src/components/ScrollShadow/styles.ts +45 -28
- package/src/components/ScrollShadow/useComposedScrollHandler.ts +58 -0
- package/src/components/ScrollShadow/useScrollShadow.ts +72 -10
- package/src/components/Tabs/index.tsx +25 -35
- package/src/components/Tabs/styles.ts +0 -9
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
# Table (https://design.candescent.com/docs/components/table)
|
|
2
|
+
|
|
3
|
+
Resources: [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/data-visualization-table--default)
|
|
4
|
+
|
|
5
|
+
`Table` is a presentational compound component for rendering tabular data. Compose header, body, footer, and cell sub-slots declaratively. For a web data-driven grid with sort, filters, selection, and pagination, use `DataGrid` from `@cdx-ui/data-grid`. Sorting, filtering, and pagination on `Table` itself are consumer responsibilities.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Table } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic
|
|
12
|
+
|
|
13
|
+
Use `Table.Caption` for an accessible title, then compose `Table.Header`, `Table.Body`, and rows of `Table.Head` / `Table.Cell` cells.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Table } from '@cdx-ui/components';
|
|
17
|
+
|
|
18
|
+
const invoices = [
|
|
19
|
+
{ id: 'INV001', status: 'Paid', method: 'Credit Card', amount: '$250.00' },
|
|
20
|
+
{ id: 'INV002', status: 'Pending', method: 'PayPal', amount: '$150.00' },
|
|
21
|
+
{ id: 'INV003', status: 'Unpaid', method: 'Bank Transfer', amount: '$350.00' },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export default function TableBasicDemo() {
|
|
25
|
+
return (
|
|
26
|
+
<Table>
|
|
27
|
+
<Table.Caption>A list of your recent invoices.</Table.Caption>
|
|
28
|
+
<Table.Header>
|
|
29
|
+
<Table.Row>
|
|
30
|
+
<Table.Head>Invoice</Table.Head>
|
|
31
|
+
<Table.Head>Status</Table.Head>
|
|
32
|
+
<Table.Head>Method</Table.Head>
|
|
33
|
+
<Table.Head align="end">Amount</Table.Head>
|
|
34
|
+
</Table.Row>
|
|
35
|
+
</Table.Header>
|
|
36
|
+
<Table.Body>
|
|
37
|
+
{invoices.map((invoice) => (
|
|
38
|
+
<Table.Row key={invoice.id}>
|
|
39
|
+
<Table.Cell>{invoice.id}</Table.Cell>
|
|
40
|
+
<Table.Cell>{invoice.status}</Table.Cell>
|
|
41
|
+
<Table.Cell>{invoice.method}</Table.Cell>
|
|
42
|
+
<Table.Cell align="end">{invoice.amount}</Table.Cell>
|
|
43
|
+
</Table.Row>
|
|
44
|
+
))}
|
|
45
|
+
</Table.Body>
|
|
46
|
+
</Table>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Set `fullBleed` on the root when the table should align flush with a parent container — the first column drops left padding and the last column drops right padding on every row.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
<Table fullBleed>{/* ... */}</Table>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Footer
|
|
58
|
+
|
|
59
|
+
`Table.Footer` groups summary rows such as totals. On web, pass `colSpan` to merge cells.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { Table } from '@cdx-ui/components';
|
|
63
|
+
|
|
64
|
+
const invoices = [
|
|
65
|
+
{ id: 'INV001', status: 'Paid', amount: '$250.00' },
|
|
66
|
+
{ id: 'INV002', status: 'Pending', amount: '$150.00' },
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
export default function TableWithFooterDemo() {
|
|
70
|
+
return (
|
|
71
|
+
<Table>
|
|
72
|
+
<Table.Caption>Recent invoices</Table.Caption>
|
|
73
|
+
<Table.Header>
|
|
74
|
+
<Table.Row>
|
|
75
|
+
<Table.Head>Invoice</Table.Head>
|
|
76
|
+
<Table.Head>Status</Table.Head>
|
|
77
|
+
<Table.Head align="end">Amount</Table.Head>
|
|
78
|
+
</Table.Row>
|
|
79
|
+
</Table.Header>
|
|
80
|
+
<Table.Body>
|
|
81
|
+
{invoices.map((invoice) => (
|
|
82
|
+
<Table.Row key={invoice.id}>
|
|
83
|
+
<Table.Cell>{invoice.id}</Table.Cell>
|
|
84
|
+
<Table.Cell>{invoice.status}</Table.Cell>
|
|
85
|
+
<Table.Cell align="end">{invoice.amount}</Table.Cell>
|
|
86
|
+
</Table.Row>
|
|
87
|
+
))}
|
|
88
|
+
</Table.Body>
|
|
89
|
+
<Table.Footer>
|
|
90
|
+
<Table.Row>
|
|
91
|
+
<Table.Cell colSpan={2}>Total</Table.Cell>
|
|
92
|
+
<Table.Cell align="end">$400.00</Table.Cell>
|
|
93
|
+
</Table.Row>
|
|
94
|
+
</Table.Footer>
|
|
95
|
+
</Table>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Rich cells
|
|
101
|
+
|
|
102
|
+
Cells can compose text, status indicators, and other Forge UI components. Tables with more columns remain horizontally scrollable on compact screens.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { Box, Chip, Table, Text } from '@cdx-ui/components';
|
|
106
|
+
|
|
107
|
+
const transactions = [
|
|
108
|
+
{
|
|
109
|
+
merchant: 'Northstar Market',
|
|
110
|
+
detail: 'Groceries · Sep 8',
|
|
111
|
+
category: 'Groceries',
|
|
112
|
+
color: 'success',
|
|
113
|
+
status: 'Posted',
|
|
114
|
+
amount: '−$86.42',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
merchant: 'Cloud Nine Media',
|
|
118
|
+
detail: 'Subscription · Sep 7',
|
|
119
|
+
category: 'Entertainment',
|
|
120
|
+
color: 'info',
|
|
121
|
+
status: 'Posted',
|
|
122
|
+
amount: '−$18.99',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
merchant: 'City Electric',
|
|
126
|
+
detail: 'Autopay · Sep 6',
|
|
127
|
+
category: 'Utilities',
|
|
128
|
+
color: 'warning',
|
|
129
|
+
status: 'Pending',
|
|
130
|
+
amount: '−$124.30',
|
|
131
|
+
},
|
|
132
|
+
] as const;
|
|
133
|
+
|
|
134
|
+
export default function TableRichCellsDemo() {
|
|
135
|
+
return (
|
|
136
|
+
<Table accessibilityLabel="Recent account activity">
|
|
137
|
+
<Table.Header>
|
|
138
|
+
<Table.Row>
|
|
139
|
+
<Table.Head>Merchant</Table.Head>
|
|
140
|
+
<Table.Head>Category</Table.Head>
|
|
141
|
+
<Table.Head>Status</Table.Head>
|
|
142
|
+
<Table.Head align="end">Amount</Table.Head>
|
|
143
|
+
</Table.Row>
|
|
144
|
+
</Table.Header>
|
|
145
|
+
<Table.Body>
|
|
146
|
+
{transactions.map((transaction) => (
|
|
147
|
+
<Table.Row key={transaction.merchant}>
|
|
148
|
+
<Table.Cell>
|
|
149
|
+
<Box className="gap-0.5">
|
|
150
|
+
<Text weight="medium" numberOfLines={1}>
|
|
151
|
+
{transaction.merchant}
|
|
152
|
+
</Text>
|
|
153
|
+
<Text size="sm" color="secondary" numberOfLines={1}>
|
|
154
|
+
{transaction.detail}
|
|
155
|
+
</Text>
|
|
156
|
+
</Box>
|
|
157
|
+
</Table.Cell>
|
|
158
|
+
<Table.Cell>
|
|
159
|
+
<Chip size="small" color={transaction.color}>
|
|
160
|
+
<Chip.Label>{transaction.category}</Chip.Label>
|
|
161
|
+
</Chip>
|
|
162
|
+
</Table.Cell>
|
|
163
|
+
<Table.Cell>{transaction.status}</Table.Cell>
|
|
164
|
+
<Table.Cell align="end">{transaction.amount}</Table.Cell>
|
|
165
|
+
</Table.Row>
|
|
166
|
+
))}
|
|
167
|
+
</Table.Body>
|
|
168
|
+
</Table>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Row actions
|
|
174
|
+
|
|
175
|
+
Compose interactive controls such as `Menu` inside `Table.Cell` for per-row actions. Use the
|
|
176
|
+
logical `align` prop to align both text and composed content with RTL support.
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import { IconButton, Menu, Table } from '@cdx-ui/components';
|
|
180
|
+
import { MoreHoriz } from '@cdx-ui/icons';
|
|
181
|
+
|
|
182
|
+
const products = [
|
|
183
|
+
{ name: 'Wireless Mouse', price: '$29.99' },
|
|
184
|
+
{ name: 'Mechanical Keyboard', price: '$129.99' },
|
|
185
|
+
];
|
|
186
|
+
|
|
187
|
+
export default function TableRowActionsDemo() {
|
|
188
|
+
return (
|
|
189
|
+
<Table fullBleed>
|
|
190
|
+
<Table.Header>
|
|
191
|
+
<Table.Row>
|
|
192
|
+
<Table.Head>Product</Table.Head>
|
|
193
|
+
<Table.Head align="end">Price</Table.Head>
|
|
194
|
+
<Table.Head align="end">Actions</Table.Head>
|
|
195
|
+
</Table.Row>
|
|
196
|
+
</Table.Header>
|
|
197
|
+
<Table.Body>
|
|
198
|
+
{products.map((product) => (
|
|
199
|
+
<Table.Row key={product.name}>
|
|
200
|
+
<Table.Cell>{product.name}</Table.Cell>
|
|
201
|
+
<Table.Cell align="end">{product.price}</Table.Cell>
|
|
202
|
+
<Table.Cell align="end">
|
|
203
|
+
<Menu placement="bottom-end">
|
|
204
|
+
<Menu.Trigger asChild>
|
|
205
|
+
<IconButton
|
|
206
|
+
as={MoreHoriz}
|
|
207
|
+
accessibilityLabel={`Actions for ${product.name}`}
|
|
208
|
+
variant="ghost"
|
|
209
|
+
size="small"
|
|
210
|
+
/>
|
|
211
|
+
</Menu.Trigger>
|
|
212
|
+
<Menu.Popup>
|
|
213
|
+
<Menu.Content accessibilityLabel={`${product.name} actions`}>
|
|
214
|
+
<Menu.Item>
|
|
215
|
+
<Menu.ItemLabel>Edit</Menu.ItemLabel>
|
|
216
|
+
</Menu.Item>
|
|
217
|
+
<Menu.Item color="danger">
|
|
218
|
+
<Menu.ItemLabel>Delete</Menu.ItemLabel>
|
|
219
|
+
</Menu.Item>
|
|
220
|
+
</Menu.Content>
|
|
221
|
+
</Menu.Popup>
|
|
222
|
+
</Menu>
|
|
223
|
+
</Table.Cell>
|
|
224
|
+
</Table.Row>
|
|
225
|
+
))}
|
|
226
|
+
</Table.Body>
|
|
227
|
+
</Table>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## In card
|
|
233
|
+
|
|
234
|
+
On mobile, a headerless table can present key-value summaries inside a card. Pair it with a compact visual summary built from layout primitives while chart components are unavailable, and keep the values in the table as the accessible source of detail.
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { Box, Card, Heading, HStack, Table, Text } from '@cdx-ui/components';
|
|
238
|
+
|
|
239
|
+
const categories = [
|
|
240
|
+
{
|
|
241
|
+
name: 'Rent',
|
|
242
|
+
amount: '$2,240',
|
|
243
|
+
percent: 42,
|
|
244
|
+
indicatorClassName: 'bg-surface-action-strong',
|
|
245
|
+
dotClassName: 'size-3 rounded-full bg-surface-action-strong',
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: 'Entertainment',
|
|
249
|
+
amount: '$1,015',
|
|
250
|
+
percent: 19,
|
|
251
|
+
indicatorClassName: 'bg-surface-info-strong',
|
|
252
|
+
dotClassName: 'size-3 rounded-full bg-surface-info-strong',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'Dining out',
|
|
256
|
+
amount: '$685',
|
|
257
|
+
percent: 13,
|
|
258
|
+
indicatorClassName: 'bg-surface-warning-strong',
|
|
259
|
+
dotClassName: 'size-3 rounded-full bg-surface-warning-strong',
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: 'Utilities',
|
|
263
|
+
amount: '$520',
|
|
264
|
+
percent: 10,
|
|
265
|
+
indicatorClassName: 'bg-surface-success-strong',
|
|
266
|
+
dotClassName: 'size-3 rounded-full bg-surface-success-strong',
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: 'Other',
|
|
270
|
+
amount: '$865',
|
|
271
|
+
percent: 16,
|
|
272
|
+
indicatorClassName: 'bg-surface-secondary',
|
|
273
|
+
dotClassName: 'size-3 rounded-full bg-surface-secondary',
|
|
274
|
+
},
|
|
275
|
+
] as const;
|
|
276
|
+
|
|
277
|
+
export default function TableMobileSpendingBreakdownDemo() {
|
|
278
|
+
return (
|
|
279
|
+
<Card className="w-full max-w-sm overflow-hidden">
|
|
280
|
+
<Card.Stripe />
|
|
281
|
+
<Card.Header>
|
|
282
|
+
<Heading size="sm">Spending this month</Heading>
|
|
283
|
+
</Card.Header>
|
|
284
|
+
<Card.Content className="gap-5">
|
|
285
|
+
<Box className="items-center gap-1 py-2">
|
|
286
|
+
<Text size="xl" weight="semibold">
|
|
287
|
+
$5,325
|
|
288
|
+
</Text>
|
|
289
|
+
<Text size="sm" weight="semibold" color="secondary" className="uppercase">
|
|
290
|
+
Total
|
|
291
|
+
</Text>
|
|
292
|
+
</Box>
|
|
293
|
+
<Box
|
|
294
|
+
accessible
|
|
295
|
+
accessibilityLabel="Rent 42%, entertainment 19%, dining out 13%, utilities 10%, other 16%"
|
|
296
|
+
className="h-3 flex-row overflow-hidden rounded-full"
|
|
297
|
+
>
|
|
298
|
+
{categories.map((category) => (
|
|
299
|
+
<Box
|
|
300
|
+
key={category.name}
|
|
301
|
+
className={category.indicatorClassName}
|
|
302
|
+
style={{ flex: category.percent }}
|
|
303
|
+
/>
|
|
304
|
+
))}
|
|
305
|
+
</Box>
|
|
306
|
+
<Table fullBleed accessibilityLabel="Spending by category">
|
|
307
|
+
<Table.Body>
|
|
308
|
+
{categories.map((category) => (
|
|
309
|
+
<Table.Row key={category.name}>
|
|
310
|
+
<Table.Cell>
|
|
311
|
+
<HStack space="sm" className="items-center">
|
|
312
|
+
<Box className={category.dotClassName} />
|
|
313
|
+
<Text numberOfLines={1}>{category.name}</Text>
|
|
314
|
+
</HStack>
|
|
315
|
+
</Table.Cell>
|
|
316
|
+
<Table.Cell align="end">{category.amount}</Table.Cell>
|
|
317
|
+
<Table.Cell align="end">{category.percent}%</Table.Cell>
|
|
318
|
+
</Table.Row>
|
|
319
|
+
))}
|
|
320
|
+
</Table.Body>
|
|
321
|
+
</Table>
|
|
322
|
+
</Card.Content>
|
|
323
|
+
</Card>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
import { Box, Card, Chip, Heading, HStack, Table, Text } from '@cdx-ui/components';
|
|
330
|
+
|
|
331
|
+
const spendingDays = [
|
|
332
|
+
{ day: 'M', barClassName: 'h-10 w-1.5 rounded-full bg-surface-action-strong' },
|
|
333
|
+
{ day: 'T', barClassName: 'h-8 w-1.5 rounded-full bg-surface-action-strong' },
|
|
334
|
+
{ day: 'W', barClassName: 'h-10 w-1.5 rounded-full bg-surface-action-strong' },
|
|
335
|
+
{ day: 'T', barClassName: 'h-9 w-1.5 rounded-full bg-surface-action-strong' },
|
|
336
|
+
{ day: 'F', barClassName: 'h-8 w-1.5 rounded-full bg-surface-action-strong' },
|
|
337
|
+
{ day: 'S', barClassName: 'h-16 w-1.5 rounded-full bg-surface-warning-strong' },
|
|
338
|
+
{ day: 'S', barClassName: 'h-20 w-1.5 rounded-full bg-surface-warning-strong' },
|
|
339
|
+
] as const;
|
|
340
|
+
|
|
341
|
+
export default function TableMobileSpendingComparisonDemo() {
|
|
342
|
+
return (
|
|
343
|
+
<Card className="w-full max-w-sm overflow-hidden">
|
|
344
|
+
<Card.Stripe />
|
|
345
|
+
<Card.Header className="flex-row items-center justify-between">
|
|
346
|
+
<Heading size="sm">Spending patterns</Heading>
|
|
347
|
+
<Chip size="small" color="warning">
|
|
348
|
+
<Chip.Label>Review</Chip.Label>
|
|
349
|
+
</Chip>
|
|
350
|
+
</Card.Header>
|
|
351
|
+
<Card.Content className="gap-5">
|
|
352
|
+
<Box className="gap-0.5">
|
|
353
|
+
<Text size="xl" weight="semibold">
|
|
354
|
+
40%
|
|
355
|
+
</Text>
|
|
356
|
+
<Text weight="medium">more on weekends</Text>
|
|
357
|
+
</Box>
|
|
358
|
+
<HStack
|
|
359
|
+
accessible
|
|
360
|
+
accessibilityLabel="Daily spending rises from Monday through Sunday and is highest on weekends"
|
|
361
|
+
className="items-end justify-between px-2"
|
|
362
|
+
>
|
|
363
|
+
{spendingDays.map((entry, index) => (
|
|
364
|
+
<Box key={`${entry.day}-${String(index)}`} className="items-center gap-2">
|
|
365
|
+
<Box className="h-20 justify-end">
|
|
366
|
+
<Box className={entry.barClassName} />
|
|
367
|
+
</Box>
|
|
368
|
+
<Text size="sm">{entry.day}</Text>
|
|
369
|
+
</Box>
|
|
370
|
+
))}
|
|
371
|
+
</HStack>
|
|
372
|
+
<Table fullBleed accessibilityLabel="Average spending comparison">
|
|
373
|
+
<Table.Body>
|
|
374
|
+
<Table.Row>
|
|
375
|
+
<Table.Cell>Weekend average</Table.Cell>
|
|
376
|
+
<Table.Cell align="end">$89</Table.Cell>
|
|
377
|
+
</Table.Row>
|
|
378
|
+
<Table.Row>
|
|
379
|
+
<Table.Cell>Weekday average</Table.Cell>
|
|
380
|
+
<Table.Cell align="end">$52</Table.Cell>
|
|
381
|
+
</Table.Row>
|
|
382
|
+
</Table.Body>
|
|
383
|
+
</Table>
|
|
384
|
+
</Card.Content>
|
|
385
|
+
</Card>
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## API
|
|
391
|
+
|
|
392
|
+
### Table
|
|
393
|
+
|
|
394
|
+
Root table container. On web, renders semantic `<table>` markup inside a horizontally scrollable wrapper. On native, renders a horizontally scrollable flex layout.
|
|
395
|
+
|
|
396
|
+
| Prop | Type | Default | Description |
|
|
397
|
+
| --- | --- | --- | --- |
|
|
398
|
+
| `className?` | `string` | — | — |
|
|
399
|
+
| `children?` | `ReactNode` | — | — |
|
|
400
|
+
| `fullBleed?` | `boolean \| null` | — | — |
|
|
401
|
+
| `asChild?` | `boolean` | — | — |
|
|
402
|
+
| `containerStyle?` | `ViewStyle` | — | — |
|
|
403
|
+
|
|
404
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
405
|
+
|
|
406
|
+
| Attribute | Values | Description |
|
|
407
|
+
| ----------- | ------- | -------------- |
|
|
408
|
+
| `data-slot` | `table` | Root container |
|
|
409
|
+
|
|
410
|
+
## Sub-components
|
|
411
|
+
|
|
412
|
+
### Table.Caption
|
|
413
|
+
|
|
414
|
+
Accessible table title or summary.
|
|
415
|
+
|
|
416
|
+
| Prop | Type | Default | Description |
|
|
417
|
+
| --- | --- | --- | --- |
|
|
418
|
+
| `className?` | `string` | — | — |
|
|
419
|
+
| `children?` | `ReactNode` | — | — |
|
|
420
|
+
| `asChild?` | `boolean` | — | — |
|
|
421
|
+
|
|
422
|
+
Inherits all [`TextProps`](https://reactnative.dev/docs/text#props).
|
|
423
|
+
|
|
424
|
+
| Attribute | Values | Description |
|
|
425
|
+
| ----------- | --------------- | ----------- |
|
|
426
|
+
| `data-slot` | `table-caption` | Caption |
|
|
427
|
+
|
|
428
|
+
### Table.Header
|
|
429
|
+
|
|
430
|
+
Header section containing header rows. Renders `<thead>` on web.
|
|
431
|
+
|
|
432
|
+
| Prop | Type | Default | Description |
|
|
433
|
+
| --- | --- | --- | --- |
|
|
434
|
+
| `className?` | `string` | — | — |
|
|
435
|
+
| `children?` | `ReactNode` | — | — |
|
|
436
|
+
| `asChild?` | `boolean` | — | — |
|
|
437
|
+
|
|
438
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
439
|
+
|
|
440
|
+
| Attribute | Values | Description |
|
|
441
|
+
| ----------- | -------------- | -------------- |
|
|
442
|
+
| `data-slot` | `table-header` | Header section |
|
|
443
|
+
|
|
444
|
+
### Table.Body
|
|
445
|
+
|
|
446
|
+
Body section containing data rows. Renders `<tbody>` on web.
|
|
447
|
+
|
|
448
|
+
| Prop | Type | Default | Description |
|
|
449
|
+
| --- | --- | --- | --- |
|
|
450
|
+
| `className?` | `string` | — | — |
|
|
451
|
+
| `children?` | `ReactNode` | — | — |
|
|
452
|
+
| `asChild?` | `boolean` | — | — |
|
|
453
|
+
|
|
454
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
455
|
+
|
|
456
|
+
| Attribute | Values | Description |
|
|
457
|
+
| ----------- | ------------ | ------------ |
|
|
458
|
+
| `data-slot` | `table-body` | Body section |
|
|
459
|
+
|
|
460
|
+
### Table.Footer
|
|
461
|
+
|
|
462
|
+
Footer section for totals and summaries. Renders `<tfoot>` on web.
|
|
463
|
+
|
|
464
|
+
| Prop | Type | Default | Description |
|
|
465
|
+
| --- | --- | --- | --- |
|
|
466
|
+
| `className?` | `string` | — | — |
|
|
467
|
+
| `children?` | `ReactNode` | — | — |
|
|
468
|
+
| `asChild?` | `boolean` | — | — |
|
|
469
|
+
|
|
470
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
471
|
+
|
|
472
|
+
| Attribute | Values | Description |
|
|
473
|
+
| ----------- | -------------- | -------------- |
|
|
474
|
+
| `data-slot` | `table-footer` | Footer section |
|
|
475
|
+
|
|
476
|
+
### Table.Row
|
|
477
|
+
|
|
478
|
+
A single table row. Renders `<tr>` on web.
|
|
479
|
+
|
|
480
|
+
| Prop | Type | Default | Description |
|
|
481
|
+
| --- | --- | --- | --- |
|
|
482
|
+
| `className?` | `string` | — | — |
|
|
483
|
+
| `children?` | `ReactNode` | — | — |
|
|
484
|
+
| `asChild?` | `boolean` | — | — |
|
|
485
|
+
|
|
486
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
487
|
+
|
|
488
|
+
| Attribute | Values | Description |
|
|
489
|
+
| ----------- | ----------- | ----------- |
|
|
490
|
+
| `data-slot` | `table-row` | Table row |
|
|
491
|
+
|
|
492
|
+
### Table.Head
|
|
493
|
+
|
|
494
|
+
Header cell within a header row. Renders `<th scope="col">` on web by default.
|
|
495
|
+
|
|
496
|
+
| Prop | Type | Default | Description |
|
|
497
|
+
| --- | --- | --- | --- |
|
|
498
|
+
| `className?` | `string` | — | — |
|
|
499
|
+
| `children?` | `ReactNode` | — | — |
|
|
500
|
+
| `asChild?` | `boolean` | — | — |
|
|
501
|
+
| `align?` | `'start' \| 'center' \| 'end'` | `'start'` | Logical horizontal alignment for text and composed content. |
|
|
502
|
+
| `colSpan?` | `number` | — | — |
|
|
503
|
+
| `rowSpan?` | `number` | — | — |
|
|
504
|
+
| `scope?` | `'col' \| 'row' \| 'colgroup' \| 'rowgroup'` | — | — |
|
|
505
|
+
|
|
506
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props). Accepts logical `align`, `colSpan`, `rowSpan`, and `scope` (web).
|
|
507
|
+
|
|
508
|
+
| Attribute | Values | Description |
|
|
509
|
+
| ----------- | ------------ | ----------- |
|
|
510
|
+
| `data-slot` | `table-head` | Header cell |
|
|
511
|
+
|
|
512
|
+
### Table.Cell
|
|
513
|
+
|
|
514
|
+
Data cell within a body or footer row. Renders `<td>` on web.
|
|
515
|
+
|
|
516
|
+
| Prop | Type | Default | Description |
|
|
517
|
+
| --- | --- | --- | --- |
|
|
518
|
+
| `className?` | `string` | — | — |
|
|
519
|
+
| `children?` | `ReactNode` | — | — |
|
|
520
|
+
| `asChild?` | `boolean` | — | — |
|
|
521
|
+
| `align?` | `'start' \| 'center' \| 'end'` | `'start'` | Logical horizontal alignment for text and composed content. |
|
|
522
|
+
| `colSpan?` | `number` | — | — |
|
|
523
|
+
| `rowSpan?` | `number` | — | — |
|
|
524
|
+
|
|
525
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props). Accepts logical `align`, `colSpan`, and `rowSpan` (web).
|
|
526
|
+
|
|
527
|
+
| Attribute | Values | Description |
|
|
528
|
+
| ----------- | ------------ | ----------- |
|
|
529
|
+
| `data-slot` | `table-cell` | Data cell |
|
|
530
|
+
|
|
531
|
+
## Anatomy
|
|
532
|
+
|
|
533
|
+
| `data-slot` | Element |
|
|
534
|
+
| --------------- | --------------- |
|
|
535
|
+
| `table` | `Table` |
|
|
536
|
+
| `table-caption` | `Table.Caption` |
|
|
537
|
+
| `table-header` | `Table.Header` |
|
|
538
|
+
| `table-body` | `Table.Body` |
|
|
539
|
+
| `table-footer` | `Table.Footer` |
|
|
540
|
+
| `table-row` | `Table.Row` |
|
|
541
|
+
| `table-head` | `Table.Head` |
|
|
542
|
+
| `table-cell` | `Table.Cell` |
|
|
543
|
+
|
|
544
|
+
## Accessibility
|
|
545
|
+
|
|
546
|
+
On web, `Table` renders native table semantics (`table`, `thead`, `tbody`, `tfoot`, `tr`, `th`, `td`, `caption`). Use `Table.Caption` or `accessibilityLabel` on the root so screen readers can identify the table.
|
|
547
|
+
|
|
548
|
+
On native, rows and cells use flex layout with header/text roles. For complex grids requiring full screen-reader table navigation, prefer web or validate with VoiceOver and TalkBack during review.
|