@wallarm-org/design-system 4.7.0 → 4.8.0-rc-fix-claude-code.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/components/BulkBar/index.d.ts +5 -0
- package/dist/components/Drawer/classes.js +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +20 -0
- package/dist/components/NotificationCenter/NotificationCenter.js +65 -0
- package/dist/components/NotificationCenter/NotificationCenterBody.d.ts +18 -0
- package/dist/components/NotificationCenter/NotificationCenterBody.js +202 -0
- package/dist/components/NotificationCenter/NotificationCenterContent.d.ts +5 -0
- package/dist/components/NotificationCenter/NotificationCenterContent.js +42 -0
- package/dist/components/NotificationCenter/NotificationCenterHeader.d.ts +20 -0
- package/dist/components/NotificationCenter/NotificationCenterHeader.js +202 -0
- package/dist/components/NotificationCenter/NotificationCenterItem.d.ts +26 -0
- package/dist/components/NotificationCenter/NotificationCenterItem.js +211 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTime.d.ts +9 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTime.js +148 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTitle.d.ts +14 -0
- package/dist/components/NotificationCenter/NotificationCenterItemTitle.js +115 -0
- package/dist/components/NotificationCenter/NotificationCenterTabs.d.ts +10 -0
- package/dist/components/NotificationCenter/NotificationCenterTabs.js +77 -0
- package/dist/components/NotificationCenter/NotificationCenterTrigger.d.ts +13 -0
- package/dist/components/NotificationCenter/NotificationCenterTrigger.js +138 -0
- package/dist/components/NotificationCenter/index.d.ts +9 -0
- package/dist/components/NotificationCenter/index.js +9 -0
- package/dist/components/Overlay/Overlay.js +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +7 -5
- package/dist/components/SearchInput/SearchInput.js +119 -101
- package/dist/components/Select/SelectSearchInput.d.ts +1 -1
- package/dist/components/Table/types.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +1 -0
- package/dist/components/Tabs/Tabs.js +30 -28
- package/dist/components/Tabs/TabsList/index.d.ts +1 -1
- package/dist/components/Tabs/index.d.ts +2 -2
- package/dist/components/Tour/TourPositioner.d.ts +3 -0
- package/dist/components/Tour/TourPositioner.js +4 -4
- package/dist/guidelines/foundations/color.md +157 -0
- package/dist/guidelines/foundations/focus.md +122 -0
- package/dist/guidelines/foundations/layering.md +131 -0
- package/dist/guidelines/foundations/radius-elevation.md +111 -0
- package/dist/guidelines/foundations/spacing.md +117 -0
- package/dist/guidelines/foundations/typography.md +114 -0
- package/dist/guidelines/patterns/app-layout.md +1567 -0
- package/dist/guidelines/patterns/auth-page.md +668 -0
- package/dist/guidelines/patterns/confirmation-dialogs.md +605 -0
- package/dist/guidelines/patterns/create-edit-forms.md +768 -0
- package/dist/guidelines/patterns/detail-drawer.md +868 -0
- package/dist/guidelines/patterns/empty-states.md +461 -0
- package/dist/guidelines/patterns/entity-table.md +533 -0
- package/dist/guidelines/patterns/feedback-toasts.md +493 -0
- package/dist/guidelines/patterns/filtering.md +630 -0
- package/dist/guidelines/patterns/resource-list-page.md +558 -0
- package/dist/guidelines/patterns/settings-page.md +752 -0
- package/dist/guidelines/rules.md +25 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/metadata/components.json +12641 -9320
- package/dist/metadata/guidelines.json +1705 -0
- package/dist/theme/typography.css +5 -0
- package/dist/utils/formatDateTime.d.ts +6 -0
- package/dist/utils/formatDateTime.js +13 -1
- package/package.json +6 -1
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Entity table
|
|
3
|
+
description: Use when you render a list of users, roles, providers, channels or policies as a Table, with status badges, tags, a row menu and bulk actions.
|
|
4
|
+
components: [Table, TableActionBar, TableActionBarSelection, TableEmptyState, Badge, Tag, OverflowList, Avatar, AvatarContent, AvatarName, AvatarDescription, Code, FormatDateTime, DropdownMenu, DropdownMenuItem, Button, Tooltip, Switch, EmptyState]
|
|
5
|
+
keywords: [table, data table, grid, list, rows, columns, entity list, users table, cell, status badge, tags, +N, overflow, row menu, row actions, kebab, ellipsis, three dots, bulk actions, bulk bar, selection, checkbox, sort, empty value, em dash, column description, reorder]
|
|
6
|
+
order: 20
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Entity table
|
|
10
|
+
|
|
11
|
+
One `Table` with a fixed cell vocabulary, a trailing row menu and a bulk bar.
|
|
12
|
+
|
|
13
|
+
## When to use
|
|
14
|
+
|
|
15
|
+
| Need | Use | Not |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| A list of entities on a page | `Table` inside `PageContent` | A `div` grid, a `Card` per row |
|
|
18
|
+
| A list in a drawer or dialog | The same `Table` inside `DrawerBody` or `DialogBody` (from `@wallarm-org/design-system/Dialog`) | A custom bordered list |
|
|
19
|
+
| Actions on one row | A trailing `actions` column with a `DropdownMenu` | Buttons repeated in every row |
|
|
20
|
+
| Actions on many rows | `onRowSelectionChange` plus `TableActionBar` | Your own floating bar |
|
|
21
|
+
| Details of one entity | `Attribute` in a drawer | A two-column `Table` |
|
|
22
|
+
| Kanban, preference matrix | Product code | This pattern |
|
|
23
|
+
|
|
24
|
+
Use only these cells.
|
|
25
|
+
|
|
26
|
+
| Data | Cell | Not |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| Person | `Avatar size='md'` with `AvatarName` | `img` plus `span` |
|
|
29
|
+
| Second line | `AvatarDescription` | Two `Text` lines |
|
|
30
|
+
| Status | `Badge variant='dotted' type='secondary' color=…` | Colored text, a raw dot |
|
|
31
|
+
| Locked row | `Badge` with `Lock` in a `Tooltip` | A bare lock icon |
|
|
32
|
+
| Groups, roles | `OverflowList` of `Tag` | Joined text, custom "+N" |
|
|
33
|
+
| ID, key, hash | `Code size='m'` | A monospace `span` |
|
|
34
|
+
| Recent time | `FormatDateTime format='relative'` | `toLocaleString()` |
|
|
35
|
+
| Exact time | `FormatDateTime format='datetime'` | Two cells |
|
|
36
|
+
| Count, metric | The raw number | `meta.align` |
|
|
37
|
+
| On/off setting | `Switch` with `SwitchControl` | `Checkbox` |
|
|
38
|
+
| Missing value | `'—'` (em dash) | `0`, `N/A`, an empty cell |
|
|
39
|
+
|
|
40
|
+
## Rules
|
|
41
|
+
|
|
42
|
+
**Layout and spacing**
|
|
43
|
+
|
|
44
|
+
- The first column is pinned and never hideable: put the entity name there.
|
|
45
|
+
- `Table` owns its frame, borders, padding and header. **Never** wrap it in a bordered `div` or restyle cells via `meta.cellClassName`.
|
|
46
|
+
- `PageContent`, `DrawerBody` and `DialogBody` own the gutter. **Never** add `p-24` or any padding around `Table`.
|
|
47
|
+
- Set widths with `size`: name `320`, email `240`, status `140`, timestamp `200`, actions `60` plus `minSize: 60` (the default minimum is 96px).
|
|
48
|
+
- If columns must keep their `size`, pass `stretch={false}`.
|
|
49
|
+
- Two-line cell: add a `Text size='xs' color='secondary'` line; there is no `rowHeight`.
|
|
50
|
+
|
|
51
|
+
**Row menu**
|
|
52
|
+
|
|
53
|
+
- If rows have actions, add the trailing display column shown below (an `id`, no `accessorKey`, `enableHiding: false`).
|
|
54
|
+
- **Never** use `meta.renderMenuAction` for entity actions: its menu shows only on hover. There is no `actions` column type, `alwaysShowMenu` or `TableRow`.
|
|
55
|
+
- Trigger: `Button variant='ghost' color='neutral' size='small'`, `Ellipsis` icon, `aria-label` naming the row.
|
|
56
|
+
- Order items: open, edit, reorder, state changes, `DropdownMenuSeparator`, destructive.
|
|
57
|
+
- Use `variant='destructive'` and name the entity: "Delete user", not "Delete". Confirm before deleting.
|
|
58
|
+
- Inherited or read-only row: only view and "Open at {scope}".
|
|
59
|
+
|
|
60
|
+
**Data and selection**
|
|
61
|
+
|
|
62
|
+
- Always pass `getRowId={row => row.id}`; selection, `activeRowId` and reordering key on it.
|
|
63
|
+
- For selection, pass `rowSelection` and `onRowSelectionChange`; without the handler there are no checkboxes.
|
|
64
|
+
- Sorting: `sorting` and `onSortingChange`, plus `manualSorting` if the server sorts.
|
|
65
|
+
- Bulk actions: `Button variant='ghost' color='neutral-alt'` in `TableActionBar`; destructive last with `color='destructive'`; options go in a `DropdownMenu`.
|
|
66
|
+
- Custom selection text: `TableActionBarSelection` (from `@wallarm-org/design-system/Table`) with `BulkBarSummaryCount`, `BulkBarSummarySelectAll`, `BulkBarSummaryClear` as direct children.
|
|
67
|
+
- Drag to reorder: `onRowReorder`; pin rows with `getRowCanDrag`.
|
|
68
|
+
|
|
69
|
+
**Values**
|
|
70
|
+
|
|
71
|
+
- Status `color`: Active, Enabled, Connected `green`; Invited, Pending, Needs attention `yellow`; Expired, Failed, Error `red`; Deactivated, Disabled, Draft `gray`. `Badge` has no `status` prop.
|
|
72
|
+
- **Never** show `0` for missing data; show `'—'`. `FormatDateTime` renders `—` for `null` itself.
|
|
73
|
+
- **Never** set `meta.align` on numbers; they align right on their own. If the first row can be `null` or `'—'`, set `meta: { sortType: 'number' }`.
|
|
74
|
+
- Header explanation: `meta.description: { type: 'tooltip', content }`; `type: 'text'` keeps it visible.
|
|
75
|
+
- Import `OverflowList` from `@wallarm-org/design-system/OverflowList`; pass it a stable `items` array (`row.original.groups`). There is no `maxItems`.
|
|
76
|
+
- Tests: pass `data-testid` to `Table`; **never** select by `data-slot`.
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
The whole table: the cell vocabulary, an always-visible row menu, sorting and a bulk bar for selected rows.
|
|
81
|
+
|
|
82
|
+
Adds an ID in `Code` and an exact time to the `Cells` vocabulary. Sort by any header; select
|
|
83
|
+
rows to bring up the bulk bar.
|
|
84
|
+
|
|
85
|
+
```tsx story=Default
|
|
86
|
+
import { useState } from 'react';
|
|
87
|
+
import { Avatar, AvatarContent, AvatarDescription, AvatarFallback, AvatarName } from '@wallarm-org/design-system/Avatar';
|
|
88
|
+
import { Badge } from '@wallarm-org/design-system/Badge';
|
|
89
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
90
|
+
import { Code } from '@wallarm-org/design-system/Code';
|
|
91
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemText, DropdownMenuSeparator, DropdownMenuTrigger } from '@wallarm-org/design-system/DropdownMenu';
|
|
92
|
+
import { FormatDateTime } from '@wallarm-org/design-system/FormatDateTime';
|
|
93
|
+
import { Ellipsis, Trash2 } from '@wallarm-org/design-system/icons';
|
|
94
|
+
import { OverflowList } from '@wallarm-org/design-system/OverflowList';
|
|
95
|
+
import { Page, PageContent } from '@wallarm-org/design-system/Page';
|
|
96
|
+
import { type TableCellContext, type TableColumnDef, type TableRowSelectionState, type TableSortingState, Table, TableActionBar } from '@wallarm-org/design-system/Table';
|
|
97
|
+
import { Tag } from '@wallarm-org/design-system/Tag';
|
|
98
|
+
|
|
99
|
+
export const Default = () => {
|
|
100
|
+
const [sorting, setSorting] = useState<TableSortingState>([]);
|
|
101
|
+
const [selection, setSelection] = useState<TableRowSelectionState>({});
|
|
102
|
+
|
|
103
|
+
const STATUS = {
|
|
104
|
+
active: { label: 'Active', color: 'green' },
|
|
105
|
+
invited: { label: 'Invited', color: 'yellow' },
|
|
106
|
+
expired: { label: 'Expired', color: 'red' },
|
|
107
|
+
deactivated: { label: 'Deactivated', color: 'gray' },
|
|
108
|
+
} as const;
|
|
109
|
+
|
|
110
|
+
const renderGroup = (group: string) => <Tag key={group}>{group}</Tag>;
|
|
111
|
+
|
|
112
|
+
const renderUser = ({ row }: TableCellContext<User, unknown>) => (
|
|
113
|
+
<Avatar size='md'>
|
|
114
|
+
<AvatarFallback name={row.original.name} />
|
|
115
|
+
<AvatarContent>
|
|
116
|
+
<AvatarName>{row.original.name}</AvatarName>
|
|
117
|
+
<AvatarDescription>{row.original.email}</AvatarDescription>
|
|
118
|
+
</AvatarContent>
|
|
119
|
+
</Avatar>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const renderId = ({ row }: TableCellContext<User, unknown>) => (
|
|
123
|
+
<Code size='m'>{row.original.id}</Code>
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const renderGroups = ({ row }: TableCellContext<User, unknown>) =>
|
|
127
|
+
row.original.groups.length > 0 ? (
|
|
128
|
+
<OverflowList className='gap-4' items={row.original.groups} itemRenderer={renderGroup} />
|
|
129
|
+
) : (
|
|
130
|
+
'—'
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const renderStatus = ({ row }: TableCellContext<User, unknown>) => (
|
|
134
|
+
<Badge variant='dotted' type='secondary' color={STATUS[row.original.status].color}>
|
|
135
|
+
{STATUS[row.original.status].label}
|
|
136
|
+
</Badge>
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const renderLastSignIn = ({ row }: TableCellContext<User, unknown>) => (
|
|
140
|
+
<FormatDateTime value={row.original.lastSignIn} format='datetime' />
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const renderRequests = ({ row }: TableCellContext<User, unknown>) => row.original.requests ?? '—';
|
|
144
|
+
|
|
145
|
+
const renderActions = ({ row }: TableCellContext<User, unknown>) => {
|
|
146
|
+
const user = row.original;
|
|
147
|
+
const handleEdit = () => onEditUser(user);
|
|
148
|
+
const handleResend = () => onResendInvite(user);
|
|
149
|
+
const handleDeactivate = () => onDeactivateUser(user);
|
|
150
|
+
const handleDelete = () => onDeleteUser(user);
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<DropdownMenu data-testid='users-row-menu'>
|
|
154
|
+
<DropdownMenuTrigger asChild>
|
|
155
|
+
<Button
|
|
156
|
+
variant='ghost'
|
|
157
|
+
color='neutral'
|
|
158
|
+
size='small'
|
|
159
|
+
aria-label={`Actions for ${user.name}`}
|
|
160
|
+
>
|
|
161
|
+
<Ellipsis />
|
|
162
|
+
</Button>
|
|
163
|
+
</DropdownMenuTrigger>
|
|
164
|
+
<DropdownMenuContent>
|
|
165
|
+
<DropdownMenuItem onSelect={handleEdit}>
|
|
166
|
+
<DropdownMenuItemText>Edit</DropdownMenuItemText>
|
|
167
|
+
</DropdownMenuItem>
|
|
168
|
+
{user.status === 'invited' && (
|
|
169
|
+
<DropdownMenuItem onSelect={handleResend}>
|
|
170
|
+
<DropdownMenuItemText>Resend invite</DropdownMenuItemText>
|
|
171
|
+
</DropdownMenuItem>
|
|
172
|
+
)}
|
|
173
|
+
<DropdownMenuItem onSelect={handleDeactivate}>
|
|
174
|
+
<DropdownMenuItemText>Deactivate</DropdownMenuItemText>
|
|
175
|
+
</DropdownMenuItem>
|
|
176
|
+
<DropdownMenuSeparator />
|
|
177
|
+
<DropdownMenuItem variant='destructive' onSelect={handleDelete}>
|
|
178
|
+
<DropdownMenuItemText>Delete user</DropdownMenuItemText>
|
|
179
|
+
</DropdownMenuItem>
|
|
180
|
+
</DropdownMenuContent>
|
|
181
|
+
</DropdownMenu>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const columns: TableColumnDef<User>[] = [
|
|
186
|
+
{ accessorKey: 'name', header: 'Name', size: 320, cell: renderUser },
|
|
187
|
+
{ accessorKey: 'id', header: 'User ID', size: 160, cell: renderId },
|
|
188
|
+
{
|
|
189
|
+
accessorKey: 'groups',
|
|
190
|
+
header: 'Groups',
|
|
191
|
+
size: 240,
|
|
192
|
+
enableSorting: false,
|
|
193
|
+
cell: renderGroups,
|
|
194
|
+
},
|
|
195
|
+
{ accessorKey: 'status', header: 'Status', size: 140, cell: renderStatus },
|
|
196
|
+
{ accessorKey: 'lastSignIn', header: 'Last sign-in', size: 200, cell: renderLastSignIn },
|
|
197
|
+
{
|
|
198
|
+
accessorKey: 'requests',
|
|
199
|
+
header: 'API requests',
|
|
200
|
+
size: 140,
|
|
201
|
+
meta: { sortType: 'number', description: { type: 'tooltip', content: 'Last 24 hours' } },
|
|
202
|
+
cell: renderRequests,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
id: 'actions',
|
|
206
|
+
header: '',
|
|
207
|
+
size: 60,
|
|
208
|
+
minSize: 60,
|
|
209
|
+
enableHiding: false,
|
|
210
|
+
cell: renderActions,
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
const handleAssignGroup = () => onAssignGroup(Object.keys(selection));
|
|
215
|
+
const handleBulkDelete = () => onBulkDelete(Object.keys(selection));
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<Page name='settings-users' fullSize fixedHeight data-testid='users-page'>
|
|
219
|
+
<PageContent>
|
|
220
|
+
<Table
|
|
221
|
+
aria-label='Users'
|
|
222
|
+
data={USERS}
|
|
223
|
+
columns={columns}
|
|
224
|
+
getRowId={getUserId}
|
|
225
|
+
sorting={sorting}
|
|
226
|
+
onSortingChange={setSorting}
|
|
227
|
+
rowSelection={selection}
|
|
228
|
+
onRowSelectionChange={setSelection}
|
|
229
|
+
data-testid='users-table'
|
|
230
|
+
>
|
|
231
|
+
<TableActionBar>
|
|
232
|
+
<Button variant='ghost' color='neutral-alt' onClick={handleAssignGroup}>
|
|
233
|
+
Assign group
|
|
234
|
+
</Button>
|
|
235
|
+
<Button color='destructive' onClick={handleBulkDelete} data-testid='users-bulk-delete'>
|
|
236
|
+
<Trash2 /> Delete
|
|
237
|
+
</Button>
|
|
238
|
+
</TableActionBar>
|
|
239
|
+
</Table>
|
|
240
|
+
</PageContent>
|
|
241
|
+
</Page>
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
A person with a second line, a status badge, groups as tags, and a number whose header explains it.
|
|
247
|
+
|
|
248
|
+
Tags collapse into "+N" when the column runs out of room; a user with no groups or no requests
|
|
249
|
+
shows `—`.
|
|
250
|
+
|
|
251
|
+
```tsx story=Cells
|
|
252
|
+
import { Avatar, AvatarContent, AvatarDescription, AvatarFallback, AvatarName } from '@wallarm-org/design-system/Avatar';
|
|
253
|
+
import { Badge } from '@wallarm-org/design-system/Badge';
|
|
254
|
+
import { OverflowList } from '@wallarm-org/design-system/OverflowList';
|
|
255
|
+
import { Page, PageContent } from '@wallarm-org/design-system/Page';
|
|
256
|
+
import { type TableCellContext, type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
|
|
257
|
+
import { Tag } from '@wallarm-org/design-system/Tag';
|
|
258
|
+
|
|
259
|
+
export const Cells = () => {
|
|
260
|
+
const STATUS = {
|
|
261
|
+
active: { label: 'Active', color: 'green' },
|
|
262
|
+
invited: { label: 'Invited', color: 'yellow' },
|
|
263
|
+
expired: { label: 'Expired', color: 'red' },
|
|
264
|
+
deactivated: { label: 'Deactivated', color: 'gray' },
|
|
265
|
+
} as const;
|
|
266
|
+
|
|
267
|
+
const renderGroup = (group: string) => <Tag key={group}>{group}</Tag>;
|
|
268
|
+
|
|
269
|
+
const renderUser = ({ row }: TableCellContext<User, unknown>) => (
|
|
270
|
+
<Avatar size='md'>
|
|
271
|
+
<AvatarFallback name={row.original.name} />
|
|
272
|
+
<AvatarContent>
|
|
273
|
+
<AvatarName>{row.original.name}</AvatarName>
|
|
274
|
+
<AvatarDescription>{row.original.email}</AvatarDescription>
|
|
275
|
+
</AvatarContent>
|
|
276
|
+
</Avatar>
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
const renderStatus = ({ row }: TableCellContext<User, unknown>) => (
|
|
280
|
+
<Badge variant='dotted' type='secondary' color={STATUS[row.original.status].color}>
|
|
281
|
+
{STATUS[row.original.status].label}
|
|
282
|
+
</Badge>
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
const renderGroups = ({ row }: TableCellContext<User, unknown>) =>
|
|
286
|
+
row.original.groups.length > 0 ? (
|
|
287
|
+
<OverflowList className='gap-4' items={row.original.groups} itemRenderer={renderGroup} />
|
|
288
|
+
) : (
|
|
289
|
+
'—'
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
const renderRequests = ({ row }: TableCellContext<User, unknown>) => row.original.requests ?? '—';
|
|
293
|
+
|
|
294
|
+
const columns: TableColumnDef<User>[] = [
|
|
295
|
+
{ accessorKey: 'name', header: 'Name', size: 320, cell: renderUser },
|
|
296
|
+
{ accessorKey: 'status', header: 'Status', size: 140, cell: renderStatus },
|
|
297
|
+
{
|
|
298
|
+
accessorKey: 'groups',
|
|
299
|
+
header: 'Groups',
|
|
300
|
+
size: 240,
|
|
301
|
+
enableSorting: false,
|
|
302
|
+
cell: renderGroups,
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
accessorKey: 'requests',
|
|
306
|
+
header: 'API requests',
|
|
307
|
+
size: 140,
|
|
308
|
+
meta: { sortType: 'number', description: { type: 'tooltip', content: 'Last 24 hours' } },
|
|
309
|
+
cell: renderRequests,
|
|
310
|
+
},
|
|
311
|
+
];
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<Page name='settings-users' data-testid='users-page'>
|
|
315
|
+
<PageContent>
|
|
316
|
+
<Table
|
|
317
|
+
aria-label='Users'
|
|
318
|
+
data={USERS}
|
|
319
|
+
columns={columns}
|
|
320
|
+
getRowId={getUserId}
|
|
321
|
+
data-testid='users-table'
|
|
322
|
+
/>
|
|
323
|
+
</PageContent>
|
|
324
|
+
</Page>
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
The row menu: the trigger names the row, and the destructive item comes last and names the entity.
|
|
330
|
+
|
|
331
|
+
The column has an `id` and no `accessorKey`, and can't be hidden, so the menu never disappears
|
|
332
|
+
behind the column settings.
|
|
333
|
+
|
|
334
|
+
```tsx story=RowMenu
|
|
335
|
+
import { Avatar, AvatarContent, AvatarDescription, AvatarFallback, AvatarName } from '@wallarm-org/design-system/Avatar';
|
|
336
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
337
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemText, DropdownMenuSeparator, DropdownMenuTrigger } from '@wallarm-org/design-system/DropdownMenu';
|
|
338
|
+
import { Ellipsis } from '@wallarm-org/design-system/icons';
|
|
339
|
+
import { Page, PageContent } from '@wallarm-org/design-system/Page';
|
|
340
|
+
import { type TableCellContext, type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
|
|
341
|
+
|
|
342
|
+
export const RowMenu = () => {
|
|
343
|
+
const renderUser = ({ row }: TableCellContext<User, unknown>) => (
|
|
344
|
+
<Avatar size='md'>
|
|
345
|
+
<AvatarFallback name={row.original.name} />
|
|
346
|
+
<AvatarContent>
|
|
347
|
+
<AvatarName>{row.original.name}</AvatarName>
|
|
348
|
+
<AvatarDescription>{row.original.email}</AvatarDescription>
|
|
349
|
+
</AvatarContent>
|
|
350
|
+
</Avatar>
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
const renderActions = ({ row }: TableCellContext<User, unknown>) => {
|
|
354
|
+
const user = row.original;
|
|
355
|
+
const handleEdit = () => onEditUser(user);
|
|
356
|
+
const handleDeactivate = () => onDeactivateUser(user);
|
|
357
|
+
const handleDelete = () => onDeleteUser(user);
|
|
358
|
+
|
|
359
|
+
return (
|
|
360
|
+
<DropdownMenu data-testid='users-row-menu'>
|
|
361
|
+
<DropdownMenuTrigger asChild>
|
|
362
|
+
<Button
|
|
363
|
+
variant='ghost'
|
|
364
|
+
color='neutral'
|
|
365
|
+
size='small'
|
|
366
|
+
aria-label={`Actions for ${user.name}`}
|
|
367
|
+
>
|
|
368
|
+
<Ellipsis />
|
|
369
|
+
</Button>
|
|
370
|
+
</DropdownMenuTrigger>
|
|
371
|
+
<DropdownMenuContent>
|
|
372
|
+
<DropdownMenuItem onSelect={handleEdit}>
|
|
373
|
+
<DropdownMenuItemText>Edit</DropdownMenuItemText>
|
|
374
|
+
</DropdownMenuItem>
|
|
375
|
+
<DropdownMenuItem onSelect={handleDeactivate}>
|
|
376
|
+
<DropdownMenuItemText>Deactivate</DropdownMenuItemText>
|
|
377
|
+
</DropdownMenuItem>
|
|
378
|
+
<DropdownMenuSeparator />
|
|
379
|
+
<DropdownMenuItem variant='destructive' onSelect={handleDelete}>
|
|
380
|
+
<DropdownMenuItemText>Delete user</DropdownMenuItemText>
|
|
381
|
+
</DropdownMenuItem>
|
|
382
|
+
</DropdownMenuContent>
|
|
383
|
+
</DropdownMenu>
|
|
384
|
+
);
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
const columns: TableColumnDef<User>[] = [
|
|
388
|
+
{ accessorKey: 'name', header: 'Name', size: 320, cell: renderUser },
|
|
389
|
+
{
|
|
390
|
+
id: 'actions',
|
|
391
|
+
header: '',
|
|
392
|
+
size: 60,
|
|
393
|
+
minSize: 60,
|
|
394
|
+
enableHiding: false,
|
|
395
|
+
cell: renderActions,
|
|
396
|
+
},
|
|
397
|
+
];
|
|
398
|
+
|
|
399
|
+
return (
|
|
400
|
+
<Page name='settings-users' data-testid='users-page'>
|
|
401
|
+
<PageContent>
|
|
402
|
+
<Table
|
|
403
|
+
aria-label='Users'
|
|
404
|
+
data={USERS}
|
|
405
|
+
columns={columns}
|
|
406
|
+
getRowId={getUserId}
|
|
407
|
+
data-testid='users-table'
|
|
408
|
+
/>
|
|
409
|
+
</PageContent>
|
|
410
|
+
</Page>
|
|
411
|
+
);
|
|
412
|
+
};
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
First load keeps the header and fills the body with placeholder rows.
|
|
416
|
+
|
|
417
|
+
`isLoading` draws the skeleton rows, not a `Loader`; `skeletonCount` sets how many (12 by
|
|
418
|
+
default).
|
|
419
|
+
|
|
420
|
+
```tsx story=Loading
|
|
421
|
+
import { Page, PageContent } from '@wallarm-org/design-system/Page';
|
|
422
|
+
import { type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
|
|
423
|
+
|
|
424
|
+
export const Loading = () => {
|
|
425
|
+
const columns: TableColumnDef<User>[] = [
|
|
426
|
+
{ accessorKey: 'name', header: 'Name', size: 320 },
|
|
427
|
+
{ accessorKey: 'id', header: 'User ID', size: 160 },
|
|
428
|
+
{ accessorKey: 'groups', header: 'Groups', size: 240 },
|
|
429
|
+
{ accessorKey: 'status', header: 'Status', size: 140 },
|
|
430
|
+
{ accessorKey: 'lastSignIn', header: 'Last sign-in', size: 200 },
|
|
431
|
+
];
|
|
432
|
+
|
|
433
|
+
return (
|
|
434
|
+
<Page name='settings-users' fullSize fixedHeight data-testid='users-page'>
|
|
435
|
+
<PageContent>
|
|
436
|
+
<Table
|
|
437
|
+
aria-label='Users'
|
|
438
|
+
data={[]}
|
|
439
|
+
columns={columns}
|
|
440
|
+
getRowId={getUserId}
|
|
441
|
+
isLoading
|
|
442
|
+
skeletonCount={6}
|
|
443
|
+
data-testid='users-table'
|
|
444
|
+
/>
|
|
445
|
+
</PageContent>
|
|
446
|
+
</Page>
|
|
447
|
+
);
|
|
448
|
+
};
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
Nothing created yet: an empty state under the header.
|
|
452
|
+
|
|
453
|
+
`EmptyState type='collection-empty'` inside `TableEmptyState`. It has no button when the page
|
|
454
|
+
header already has Create.
|
|
455
|
+
|
|
456
|
+
```tsx story=Empty
|
|
457
|
+
import { EmptyState, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';
|
|
458
|
+
import { UserPlus } from '@wallarm-org/design-system/icons';
|
|
459
|
+
import { Page, PageContent } from '@wallarm-org/design-system/Page';
|
|
460
|
+
import { type TableColumnDef, Table, TableEmptyState } from '@wallarm-org/design-system/Table';
|
|
461
|
+
|
|
462
|
+
export const Empty = () => {
|
|
463
|
+
const columns: TableColumnDef<User>[] = [
|
|
464
|
+
{ accessorKey: 'name', header: 'Name', size: 320 },
|
|
465
|
+
{ accessorKey: 'id', header: 'User ID', size: 160 },
|
|
466
|
+
{ accessorKey: 'groups', header: 'Groups', size: 240 },
|
|
467
|
+
{ accessorKey: 'status', header: 'Status', size: 140 },
|
|
468
|
+
{ accessorKey: 'lastSignIn', header: 'Last sign-in', size: 200 },
|
|
469
|
+
];
|
|
470
|
+
|
|
471
|
+
return (
|
|
472
|
+
<Page name='settings-users' fullSize fixedHeight data-testid='users-page'>
|
|
473
|
+
<PageContent>
|
|
474
|
+
<Table
|
|
475
|
+
aria-label='Users'
|
|
476
|
+
data={[]}
|
|
477
|
+
columns={columns}
|
|
478
|
+
getRowId={getUserId}
|
|
479
|
+
data-testid='users-table'
|
|
480
|
+
>
|
|
481
|
+
<TableEmptyState>
|
|
482
|
+
<EmptyState type='collection-empty' data-testid='users-empty-state'>
|
|
483
|
+
<EmptyStateIllustration>
|
|
484
|
+
<UserPlus />
|
|
485
|
+
</EmptyStateIllustration>
|
|
486
|
+
<EmptyStateMessage>
|
|
487
|
+
<EmptyStateTitle>No users yet</EmptyStateTitle>
|
|
488
|
+
<EmptyStateDescription>
|
|
489
|
+
Invite people to sign in to your organization.
|
|
490
|
+
</EmptyStateDescription>
|
|
491
|
+
</EmptyStateMessage>
|
|
492
|
+
</EmptyState>
|
|
493
|
+
</TableEmptyState>
|
|
494
|
+
</Table>
|
|
495
|
+
</PageContent>
|
|
496
|
+
</Page>
|
|
497
|
+
);
|
|
498
|
+
};
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
## States
|
|
502
|
+
|
|
503
|
+
| State | Show | Example component |
|
|
504
|
+
| --- | --- | --- |
|
|
505
|
+
| First load | `isLoading` (12 skeleton rows; `skeletonCount`), not a `Loader` | `Table` |
|
|
506
|
+
| Nothing created | `EmptyState type='collection-empty'`; no button if `PageActions` has Create; keep header and toolbar | `TableEmptyState` |
|
|
507
|
+
| No matches | `type='collection-empty'`, "No results found", `Button variant='outline' color='neutral'` "Reset filters"; not `type='no-results'` | `TableEmptyState` |
|
|
508
|
+
| Rows selected | The bar appears on its own | `TableActionBar` |
|
|
509
|
+
| Row open in a drawer | `activeRowId={openId}`; not a row `className` | `Table` |
|
|
510
|
+
| Switch saving | Keep the `Switch`, `Loader` in a reserved slot beside it | `Switch`, `Loader` |
|
|
511
|
+
| Locked by scope | Disabled control, `Lock` with a `Tooltip` naming the scope; never hide the row | `Tooltip` |
|
|
512
|
+
|
|
513
|
+
## What your app owns
|
|
514
|
+
|
|
515
|
+
| You own | The DS owns |
|
|
516
|
+
| --- | --- |
|
|
517
|
+
| `columns`, order, widths | Cell padding, borders, header, hover and selected backgrounds |
|
|
518
|
+
| Status-to-`color` mapping and labels | `Badge` dot, size and colors |
|
|
519
|
+
| Row menu items and handlers | Menu focus and keyboard |
|
|
520
|
+
| Fetching, filtering, server sorting, pagination | Client sorting |
|
|
521
|
+
| Which bulk actions exist | Bar placement, "Select all", "Clear" |
|
|
522
|
+
| Delete confirmation | Nothing; compose `Dialog` |
|
|
523
|
+
| Scope marker | Nothing; compose `Badge variant='dotted'` with `Lock` |
|
|
524
|
+
| Metric cell (% over "x of y") | Nothing; compose `FormatNumber` and `Text size='xs'` |
|
|
525
|
+
| Grouped or orderable tables | `getSubRows`, `renderGroupRow`, `onRowReorder` |
|
|
526
|
+
|
|
527
|
+
## Related
|
|
528
|
+
|
|
529
|
+
- [Resource list page](./resource-list-page.md): the page shell.
|
|
530
|
+
- [Detail drawer](./detail-drawer.md): opens from a row.
|
|
531
|
+
- [Confirmation dialogs](./confirmation-dialogs.md): confirm deletes.
|
|
532
|
+
- [Feedback toasts](./feedback-toasts.md): report results.
|
|
533
|
+
- [Empty states](./empty-states.md), [Filtering](./filtering.md), [Spacing](../foundations/spacing.md).
|