@slashsuite/ui-react 0.12.0 → 0.13.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/MIGRATING.md +386 -8
- package/README.md +101 -44
- package/agent-docs/components/app-shell.md +139 -0
- package/agent-docs/components/article-layout.md +140 -0
- package/agent-docs/components/audio.md +42 -0
- package/agent-docs/components/avatar-stack.md +64 -0
- package/agent-docs/components/avatar.md +76 -0
- package/agent-docs/components/badge.md +62 -0
- package/agent-docs/components/body-text.md +169 -0
- package/agent-docs/components/bottom-sheet.md +105 -0
- package/agent-docs/components/breadcrumbs.md +66 -0
- package/agent-docs/components/bullet-list.md +54 -0
- package/agent-docs/components/button.md +135 -0
- package/agent-docs/components/call-to-action.md +59 -0
- package/agent-docs/components/callout.md +87 -0
- package/agent-docs/components/card-grid.md +116 -0
- package/agent-docs/components/card.md +128 -0
- package/agent-docs/components/cart-button.md +63 -0
- package/agent-docs/components/centered-layout.md +90 -0
- package/agent-docs/components/chat-composer.md +49 -0
- package/agent-docs/components/chat-message.md +61 -0
- package/agent-docs/components/chat-thread.md +49 -0
- package/agent-docs/components/checkbox.md +81 -0
- package/agent-docs/components/cluster.md +108 -0
- package/agent-docs/components/code-example.md +48 -0
- package/agent-docs/components/code.md +72 -0
- package/agent-docs/components/colour-scheme-toggle.md +98 -0
- package/agent-docs/components/colour-swatch.md +41 -0
- package/agent-docs/components/combobox.md +88 -0
- package/agent-docs/components/confirm-dialog.md +98 -0
- package/agent-docs/components/container.md +51 -0
- package/agent-docs/components/copy-button.md +63 -0
- package/agent-docs/components/copy-line.md +55 -0
- package/agent-docs/components/date-field.md +106 -0
- package/agent-docs/components/date-range-picker.md +108 -0
- package/agent-docs/components/date-time-field.md +73 -0
- package/agent-docs/components/detail-layout.md +147 -0
- package/agent-docs/components/dialog.md +132 -0
- package/agent-docs/components/disclosure.md +70 -0
- package/agent-docs/components/divider.md +62 -0
- package/agent-docs/components/docs-layout.md +164 -0
- package/agent-docs/components/drawer.md +137 -0
- package/agent-docs/components/embed-frame.md +48 -0
- package/agent-docs/components/empty-state.md +70 -0
- package/agent-docs/components/field-dialog.md +98 -0
- package/agent-docs/components/field.md +71 -0
- package/agent-docs/components/fieldset.md +82 -0
- package/agent-docs/components/file-drop.md +52 -0
- package/agent-docs/components/flow-diagram.md +87 -0
- package/agent-docs/components/form-layout.md +144 -0
- package/agent-docs/components/form-row.md +93 -0
- package/agent-docs/components/full-bleed-layout.md +114 -0
- package/agent-docs/components/headings.md +107 -0
- package/agent-docs/components/hero.md +68 -0
- package/agent-docs/components/icon-button.md +90 -0
- package/agent-docs/components/icon.md +59 -0
- package/agent-docs/components/image.md +74 -0
- package/agent-docs/components/input.md +84 -0
- package/agent-docs/components/kbd.md +38 -0
- package/agent-docs/components/key-value-list.md +84 -0
- package/agent-docs/components/lightbox.md +97 -0
- package/agent-docs/components/list-layout.md +152 -0
- package/agent-docs/components/list-row.md +119 -0
- package/agent-docs/components/loading.md +69 -0
- package/agent-docs/components/markdown.md +51 -0
- package/agent-docs/components/media-tile.md +101 -0
- package/agent-docs/components/menu.md +110 -0
- package/agent-docs/components/meta-list.md +69 -0
- package/agent-docs/components/morph.md +134 -0
- package/agent-docs/components/navigation-progress.md +56 -0
- package/agent-docs/components/number-field.md +75 -0
- package/agent-docs/components/outline-region.md +74 -0
- package/agent-docs/components/page-fade.md +117 -0
- package/agent-docs/components/page-header.md +93 -0
- package/agent-docs/components/pagination.md +64 -0
- package/agent-docs/components/pill.md +105 -0
- package/agent-docs/components/popover.md +63 -0
- package/agent-docs/components/price.md +49 -0
- package/agent-docs/components/product-tile.md +78 -0
- package/agent-docs/components/progress-bar.md +66 -0
- package/agent-docs/components/promo-banner.md +46 -0
- package/agent-docs/components/prose-layout.md +87 -0
- package/agent-docs/components/prose.md +41 -0
- package/agent-docs/components/radio-group.md +77 -0
- package/agent-docs/components/scroll-strip.md +48 -0
- package/agent-docs/components/segmented-control.md +135 -0
- package/agent-docs/components/select.md +70 -0
- package/agent-docs/components/show.md +120 -0
- package/agent-docs/components/side-column.md +74 -0
- package/agent-docs/components/sidebar-layout.md +134 -0
- package/agent-docs/components/site-footer.md +63 -0
- package/agent-docs/components/site-search.md +79 -0
- package/agent-docs/components/slider.md +59 -0
- package/agent-docs/components/sortable-list.md +112 -0
- package/agent-docs/components/split-bar.md +54 -0
- package/agent-docs/components/stack.md +197 -0
- package/agent-docs/components/stacked-bar.md +91 -0
- package/agent-docs/components/stat-tile.md +69 -0
- package/agent-docs/components/state-machine.md +95 -0
- package/agent-docs/components/status-pages.md +112 -0
- package/agent-docs/components/stepper.md +54 -0
- package/agent-docs/components/steps.md +74 -0
- package/agent-docs/components/sticky-bar.md +51 -0
- package/agent-docs/components/switch.md +79 -0
- package/agent-docs/components/table-of-contents.md +78 -0
- package/agent-docs/components/table.md +384 -0
- package/agent-docs/components/tabs.md +178 -0
- package/agent-docs/components/text-link.md +110 -0
- package/agent-docs/components/textarea.md +53 -0
- package/agent-docs/components/timeline.md +79 -0
- package/agent-docs/components/toast.md +91 -0
- package/agent-docs/components/trend-chart.md +61 -0
- package/agent-docs/components/video.md +49 -0
- package/agent-docs/llms.txt +174 -0
- package/dist/AppShell.d.ts +25 -9
- package/dist/AppShell.js +67 -33
- package/dist/AppShellMenu.d.ts +31 -18
- package/dist/AppShellMenu.js +72 -45
- package/dist/ArticleLayout.d.ts +36 -0
- package/dist/ArticleLayout.js +27 -0
- package/dist/Audio.d.ts +16 -0
- package/dist/Audio.js +11 -0
- package/dist/Badge.d.ts +2 -1
- package/dist/Badge.js +3 -2
- package/dist/BottomSheet.d.ts +17 -6
- package/dist/BottomSheet.js +62 -11
- package/dist/Breadcrumbs.d.ts +8 -6
- package/dist/Breadcrumbs.js +17 -7
- package/dist/Button.d.ts +1 -0
- package/dist/Button.js +4 -3
- package/dist/CallToAction.d.ts +25 -0
- package/dist/CallToAction.js +17 -0
- package/dist/Callout.d.ts +2 -2
- package/dist/Callout.js +2 -2
- package/dist/Card.d.ts +88 -31
- package/dist/Card.js +55 -92
- package/dist/CardBody.d.ts +2 -0
- package/dist/CardBody.js +33 -3
- package/dist/CardGrid.d.ts +32 -4
- package/dist/CardGrid.js +42 -8
- package/dist/CardParts.d.ts +7 -1
- package/dist/CardParts.js +7 -2
- package/dist/CartButton.d.ts +33 -0
- package/dist/CartButton.js +18 -0
- package/dist/ChatComposer.d.ts +10 -4
- package/dist/ChatComposer.js +35 -13
- package/dist/Checkbox.d.ts +21 -3
- package/dist/Checkbox.js +66 -20
- package/dist/Chevron.js +1 -1
- package/dist/Cluster.d.ts +28 -15
- package/dist/Cluster.js +21 -4
- package/dist/Code.d.ts +15 -3
- package/dist/Code.js +23 -3
- package/dist/CodeBlock.d.ts +4 -4
- package/dist/CodeBlock.js +2 -2
- package/dist/CodeBody.d.ts +1 -1
- package/dist/CodeBody.js +4 -10
- package/dist/CodeExample.d.ts +1 -1
- package/dist/CodeExample.js +3 -2
- package/dist/ColourSchemeToggle.d.ts +21 -5
- package/dist/ColourSchemeToggle.js +15 -9
- package/dist/ColourSwatch.d.ts +15 -0
- package/dist/ColourSwatch.js +14 -0
- package/dist/Combobox.d.ts +42 -0
- package/dist/Combobox.js +43 -0
- package/dist/ConfirmDialog.d.ts +40 -0
- package/dist/ConfirmDialog.js +36 -0
- package/dist/Container.d.ts +3 -3
- package/dist/Container.js +1 -1
- package/dist/CopyButton.d.ts +8 -2
- package/dist/CopyButton.js +38 -28
- package/dist/CopyLine.d.ts +4 -2
- package/dist/CopyLine.js +4 -4
- package/dist/DateCalendar.d.ts +2 -0
- package/dist/DateCalendar.js +11 -9
- package/dist/DateField.d.ts +52 -21
- package/dist/DateField.js +73 -37
- package/dist/DateFieldCalendar.d.ts +12 -8
- package/dist/DateFieldCalendar.js +37 -18
- package/dist/DateRangePicker.d.ts +23 -3
- package/dist/DateRangePicker.js +10 -8
- package/dist/DateTimeField.d.ts +31 -0
- package/dist/DateTimeField.js +19 -0
- package/dist/Dialog.d.ts +42 -6
- package/dist/Dialog.js +50 -12
- package/dist/Disclosure.js +9 -1
- package/dist/DocsLayout.d.ts +13 -5
- package/dist/DocsLayout.js +11 -9
- package/dist/Drawer.d.ts +22 -7
- package/dist/Drawer.js +89 -8
- package/dist/EmbedFrame.d.ts +36 -0
- package/dist/EmbedFrame.js +18 -0
- package/dist/Field.d.ts +41 -4
- package/dist/Field.js +61 -25
- package/dist/FieldDialog.d.ts +8 -3
- package/dist/FieldDialog.js +19 -9
- package/dist/Fieldset.d.ts +3 -3
- package/dist/Fieldset.js +7 -9
- package/dist/FileDrop.js +2 -1
- package/dist/FlowDiagram.d.ts +92 -0
- package/dist/FlowDiagram.js +100 -0
- package/dist/FormRow.d.ts +6 -4
- package/dist/FormRow.js +11 -9
- package/dist/Hero.d.ts +30 -7
- package/dist/Hero.js +23 -9
- package/dist/Icon.d.ts +1 -1
- package/dist/Icon.js +1 -1
- package/dist/IconButton.js +1 -1
- package/dist/Image.d.ts +33 -9
- package/dist/Image.js +61 -16
- package/dist/Input.d.ts +1 -1
- package/dist/Input.js +4 -4
- package/dist/InputShell.d.ts +7 -0
- package/dist/InputShell.js +18 -3
- package/dist/KeyValueList.d.ts +2 -2
- package/dist/Lightbox.js +5 -3
- package/dist/ListRow.d.ts +4 -5
- package/dist/ListRow.js +36 -26
- package/dist/Mark.d.ts +10 -0
- package/dist/Mark.js +9 -0
- package/dist/Markdown.d.ts +18 -4
- package/dist/Markdown.js +176 -37
- package/dist/MediaTile.d.ts +9 -3
- package/dist/MediaTile.js +8 -4
- package/dist/Menu.d.ts +19 -8
- package/dist/Menu.js +13 -11
- package/dist/MetaList.d.ts +4 -3
- package/dist/MetaList.js +12 -4
- package/dist/Morph.d.ts +15 -1
- package/dist/Morph.js +70 -22
- package/dist/NavigationProgress.d.ts +2 -2
- package/dist/NavigationProgress.js +7 -5
- package/dist/NumberField.d.ts +66 -0
- package/dist/NumberField.js +68 -0
- package/dist/OutlineRegion.d.ts +41 -10
- package/dist/OutlineRegion.js +31 -6
- package/dist/PageFade.d.ts +9 -5
- package/dist/PageFade.js +39 -8
- package/dist/PageLayouts.d.ts +15 -5
- package/dist/PageLayouts.js +3 -3
- package/dist/Pill.d.ts +9 -4
- package/dist/Pill.js +15 -6
- package/dist/Popover.d.ts +31 -0
- package/dist/Popover.js +43 -0
- package/dist/Price.d.ts +21 -0
- package/dist/Price.js +34 -0
- package/dist/ProductTile.d.ts +36 -0
- package/dist/ProductTile.js +31 -0
- package/dist/ProgressBar.js +4 -2
- package/dist/PromoBanner.d.ts +25 -0
- package/dist/PromoBanner.js +16 -0
- package/dist/RadioGroup.d.ts +18 -8
- package/dist/RadioGroup.js +42 -18
- package/dist/ScrollStrip.d.ts +1 -1
- package/dist/ScrollStrip.js +1 -1
- package/dist/SearchInput.d.ts +17 -2
- package/dist/SearchInput.js +72 -13
- package/dist/SegmentedField.d.ts +15 -0
- package/dist/SegmentedField.js +15 -0
- package/dist/Select.js +5 -4
- package/dist/Show.d.ts +1 -1
- package/dist/Show.js +1 -1
- package/dist/SideColumn.d.ts +42 -15
- package/dist/SideColumn.js +45 -19
- package/dist/SiteFooter.d.ts +3 -3
- package/dist/SiteFooter.js +4 -3
- package/dist/SiteSearch.d.ts +57 -27
- package/dist/SiteSearch.js +13 -93
- package/dist/Slider.d.ts +27 -0
- package/dist/Slider.js +58 -0
- package/dist/SortableList.d.ts +19 -35
- package/dist/SortableList.js +36 -88
- package/dist/Stack.d.ts +4 -4
- package/dist/StackedBar.d.ts +13 -4
- package/dist/StackedBar.js +12 -7
- package/dist/StateMachine.d.ts +65 -0
- package/dist/StateMachine.js +113 -0
- package/dist/StatusPages.d.ts +28 -10
- package/dist/StatusPages.js +10 -10
- package/dist/Stepper.d.ts +21 -0
- package/dist/Stepper.js +33 -0
- package/dist/Steps.js +4 -3
- package/dist/Switch.d.ts +3 -3
- package/dist/Switch.js +18 -14
- package/dist/Table.d.ts +32 -9
- package/dist/Table.js +50 -20
- package/dist/TableCells.d.ts +24 -21
- package/dist/TableCells.js +68 -27
- package/dist/TableEditCell.d.ts +1 -1
- package/dist/TableOfContents.d.ts +34 -0
- package/dist/TableOfContents.js +23 -0
- package/dist/Tabs.d.ts +31 -16
- package/dist/Tabs.js +97 -22
- package/dist/TextLink.d.ts +18 -5
- package/dist/TextLink.js +19 -6
- package/dist/Textarea.d.ts +12 -1
- package/dist/Textarea.js +15 -2
- package/dist/ToastRegion.d.ts +17 -9
- package/dist/ToastRegion.js +70 -13
- package/dist/Tooltip.d.ts +10 -2
- package/dist/Tooltip.js +32 -11
- package/dist/Video.d.ts +19 -4
- package/dist/Video.js +15 -5
- package/dist/cardContext.d.ts +7 -0
- package/dist/cardContext.js +14 -0
- package/dist/cardControl.d.ts +15 -0
- package/dist/cardControl.js +32 -0
- package/dist/cardForm.d.ts +39 -0
- package/dist/cardForm.js +81 -0
- package/dist/cardWait.js +2 -1
- package/dist/colourScheme.d.ts +12 -2
- package/dist/colourScheme.js +32 -6
- package/dist/control.d.ts +30 -8
- package/dist/control.js +74 -7
- package/dist/copyScript.d.ts +7 -8
- package/dist/copyScript.js +8 -9
- package/dist/cx.d.ts +22 -3
- package/dist/cx.js +22 -3
- package/dist/dateLocale.d.ts +17 -0
- package/dist/dateLocale.js +30 -0
- package/dist/density.d.ts +15 -1
- package/dist/density.js +27 -8
- package/dist/emptySlot.d.ts +1 -0
- package/dist/fieldAnnounce.d.ts +11 -0
- package/dist/fieldAnnounce.js +36 -0
- package/dist/fieldControl.d.ts +7 -2
- package/dist/fieldControl.js +6 -2
- package/dist/fieldWait.d.ts +3 -3
- package/dist/fieldWait.js +3 -4
- package/dist/flowLayout.d.ts +68 -0
- package/dist/flowLayout.js +105 -0
- package/dist/fromXState.d.ts +73 -0
- package/dist/fromXState.js +110 -0
- package/dist/icons.d.ts +1 -1
- package/dist/icons.js +15 -0
- package/dist/index.d.ts +37 -11
- package/dist/index.js +24 -2
- package/dist/isoDate.d.ts +8 -1
- package/dist/isoDate.js +20 -1
- package/dist/labelWords.d.ts +16 -7
- package/dist/labelWords.js +14 -12
- package/dist/listRowProps.d.ts +17 -15
- package/dist/modal.d.ts +5 -0
- package/dist/modal.js +21 -1
- package/dist/navFold.js +6 -3
- package/dist/optionCard.d.ts +18 -0
- package/dist/optionCard.js +16 -0
- package/dist/scrollBody.d.ts +16 -0
- package/dist/scrollBody.js +15 -0
- package/dist/scrollEdges.d.ts +7 -0
- package/dist/scrollEdges.js +39 -5
- package/dist/scrollStop.d.ts +6 -2
- package/dist/scrollStop.js +24 -8
- package/dist/shownDate.d.ts +28 -10
- package/dist/shownDate.js +41 -22
- package/dist/siteSearchBody.d.ts +34 -0
- package/dist/siteSearchBody.js +117 -0
- package/dist/size.d.ts +7 -1
- package/dist/sortableDrop.d.ts +44 -0
- package/dist/sortableDrop.js +78 -0
- package/dist/sortableSlide.d.ts +9 -0
- package/dist/sortableSlide.js +70 -0
- package/dist/sortableTitle.d.ts +10 -0
- package/dist/sortableTitle.js +48 -0
- package/dist/stateMachineDots.d.ts +45 -0
- package/dist/stateMachineDots.js +162 -0
- package/dist/stickyColumn.d.ts +2 -2
- package/dist/stickyColumn.js +2 -2
- package/dist/switcher.d.ts +10 -5
- package/dist/switcher.js +7 -5
- package/dist/tableColumns.d.ts +17 -0
- package/dist/tableColumns.js +30 -2
- package/dist/tableEmpty.js +5 -5
- package/dist/tableRow.d.ts +26 -2
- package/dist/tableRow.js +23 -1
- package/dist/tableSort.d.ts +10 -5
- package/dist/tableSort.js +15 -4
- package/dist/target.d.ts +12 -0
- package/dist/target.js +12 -0
- package/dist/textBox.js +1 -1
- package/dist/truncated.d.ts +31 -0
- package/dist/truncated.js +51 -0
- package/dist/typography.d.ts +19 -11
- package/dist/typography.js +11 -13
- package/dist/useFlowLayout.d.ts +27 -0
- package/dist/useFlowLayout.js +119 -0
- package/package.json +7 -3
- package/skills/uislash/SKILL.md +20 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
## Table
|
|
2
|
+
|
|
3
|
+
Group: Data
|
|
4
|
+
|
|
5
|
+
When to use: Records that share columns, where a person compares values down a column.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- KeyValueList (key-value-list.md): One record's fields, each label beside its value.
|
|
9
|
+
- ListRow (list-row.md): Each record is a thing to open, with a line or two of detail.
|
|
10
|
+
- MetaList (meta-list.md): A few short facts inline, on one line under a title.
|
|
11
|
+
|
|
12
|
+
### The one right way
|
|
13
|
+
A table is a head and a body: names in strong cells, amounts in `numeric` cells so the figures line up.
|
|
14
|
+
```tsx
|
|
15
|
+
import {
|
|
16
|
+
Table,
|
|
17
|
+
TableBody,
|
|
18
|
+
TableCell,
|
|
19
|
+
TableHead,
|
|
20
|
+
TableHeaderCell,
|
|
21
|
+
TableRow,
|
|
22
|
+
} from "@slashsuite/ui-react";
|
|
23
|
+
|
|
24
|
+
<Table label="Quotes">
|
|
25
|
+
<TableHead>
|
|
26
|
+
<TableRow>
|
|
27
|
+
<TableHeaderCell>Client</TableHeaderCell>
|
|
28
|
+
<TableHeaderCell numeric>Premium</TableHeaderCell>
|
|
29
|
+
</TableRow>
|
|
30
|
+
</TableHead>
|
|
31
|
+
<TableBody>
|
|
32
|
+
<TableRow>
|
|
33
|
+
<TableCell tone="strong">Naledi Dlamini</TableCell>
|
|
34
|
+
<TableCell numeric>R 1 249.00</TableCell>
|
|
35
|
+
</TableRow>
|
|
36
|
+
<TableRow>
|
|
37
|
+
<TableCell tone="strong">Pieter van Wyk</TableCell>
|
|
38
|
+
<TableCell numeric>R 880.50</TableCell>
|
|
39
|
+
</TableRow>
|
|
40
|
+
</TableBody>
|
|
41
|
+
</Table>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Do
|
|
45
|
+
- Compose a `Table` from `TableHead`, `TableBody` and, for totals, `TableFoot`. A `TableHead` holds one `TableRow` of `TableHeaderCell`s; give the `Table` a `label` that names it.
|
|
46
|
+
- A column of amounts says so once, with `numeric` on its `TableHeaderCell`: the title and every cell under it are end aligned and the figures line up. A code or a type is `mono`. A cell's `tone` is `neutral` (the default), `strong` for the name of the row, `muted` for the secondary column, or a Callout tone for an amount that carries a meaning; pair the tone with a sign or a word. `secondary` is a muted second line under a cell.
|
|
47
|
+
- The total of the whole table is a `TableFoot` row. A subtotal among the body's rows is a `TableRow` with `emphasis`, the same look; a bold subtotal is not a `tone`. Neither row takes a `tone`.
|
|
48
|
+
- Mark a row's status with `tone` (a stripe and a soft fill, or `muted` to fade the row) or with `stripe` (the stripe alone, in the `muted`, `info`, `positive`, `warn` or `danger` tone, which keeps the row's hover). Give one of them, never both, and name the status in a cell as well (a `Pill`), or draw a `Legend` for the colours.
|
|
49
|
+
- A table with no rows takes `TableBody empty={<EmptyState title="No quotes yet." />}`: one muted line in a cell that spans every column the head declares, with the head still drawn. Write `TableHead` and its cells inline, so the table can count them.
|
|
50
|
+
- Group rows with a `TableGroupRow`: it spans every column the head declares, and `trailing` is a count or a subtotal at the far end. A full-width note or panel is a `TableCell span="full"`; `align="center"` centres it. `indent` (1 to 3) sets a start-aligned cell in, for the lines under a parent row. A column with nothing to say in its head (its actions) takes a `TableHeaderCell` with `label="Actions"`. Inside a `Card` a table is plain: no card of its own, only the row dividers.
|
|
51
|
+
- The cell that names its row (the customer, the build) is a `TableHeaderCell` in the body row: a row header, drawn as a strong cell. Prose wraps; everything else stays on one line: a link, a code, a figure and a date never break, and a long table scrolls sideways instead of squeezing them.
|
|
52
|
+
- A table read on a phone row by row, with few columns, takes `narrow="stack"`: on a screen narrower than `sm` (a phone) each row is a card, the first column its title and every other cell a line with its column's title. A table compared down its columns keeps the default, `narrow="scroll"`.
|
|
53
|
+
|
|
54
|
+
### Don't
|
|
55
|
+
- Do not wrap a `Table` in your own scrolling box: a table that fits lets its head stick under the page's header, and one that does not scrolls in its own card.
|
|
56
|
+
|
|
57
|
+
Amounts in plain start-aligned cells do not line up, so the eye cannot compare them.
|
|
58
|
+
```tsx
|
|
59
|
+
import {
|
|
60
|
+
Table,
|
|
61
|
+
TableBody,
|
|
62
|
+
TableCell,
|
|
63
|
+
TableHead,
|
|
64
|
+
TableHeaderCell,
|
|
65
|
+
TableRow,
|
|
66
|
+
} from "@slashsuite/ui-react";
|
|
67
|
+
|
|
68
|
+
<Table label="Quotes">
|
|
69
|
+
<TableHead>
|
|
70
|
+
<TableRow>
|
|
71
|
+
<TableHeaderCell>Client</TableHeaderCell>
|
|
72
|
+
<TableHeaderCell>Premium</TableHeaderCell>
|
|
73
|
+
</TableRow>
|
|
74
|
+
</TableHead>
|
|
75
|
+
<TableBody>
|
|
76
|
+
<TableRow>
|
|
77
|
+
<TableCell>Naledi Dlamini</TableCell>
|
|
78
|
+
<TableCell>R 1 249.00</TableCell>
|
|
79
|
+
</TableRow>
|
|
80
|
+
<TableRow>
|
|
81
|
+
<TableCell>Pieter van Wyk</TableCell>
|
|
82
|
+
<TableCell>R 880.50</TableCell>
|
|
83
|
+
</TableRow>
|
|
84
|
+
</TableBody>
|
|
85
|
+
</Table>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
A total faked as one more body row, in a strong cell, reads like a line item and is not a `<tfoot>`.
|
|
89
|
+
```tsx
|
|
90
|
+
import {
|
|
91
|
+
Table,
|
|
92
|
+
TableBody,
|
|
93
|
+
TableCell,
|
|
94
|
+
TableHead,
|
|
95
|
+
TableHeaderCell,
|
|
96
|
+
TableRow,
|
|
97
|
+
} from "@slashsuite/ui-react";
|
|
98
|
+
|
|
99
|
+
<Table label="Budget">
|
|
100
|
+
<TableHead>
|
|
101
|
+
<TableRow>
|
|
102
|
+
<TableHeaderCell>Line</TableHeaderCell>
|
|
103
|
+
<TableHeaderCell numeric>Spent</TableHeaderCell>
|
|
104
|
+
</TableRow>
|
|
105
|
+
</TableHead>
|
|
106
|
+
<TableBody>
|
|
107
|
+
<TableRow>
|
|
108
|
+
<TableCell>Groceries</TableCell>
|
|
109
|
+
<TableCell numeric>R 4 120.00</TableCell>
|
|
110
|
+
</TableRow>
|
|
111
|
+
<TableRow>
|
|
112
|
+
<TableCell>Eating out</TableCell>
|
|
113
|
+
<TableCell numeric>R 2 980.00</TableCell>
|
|
114
|
+
</TableRow>
|
|
115
|
+
<TableRow>
|
|
116
|
+
<TableCell tone="strong">Total</TableCell>
|
|
117
|
+
<TableCell numeric tone="strong">
|
|
118
|
+
R 7 100.00
|
|
119
|
+
</TableCell>
|
|
120
|
+
</TableRow>
|
|
121
|
+
</TableBody>
|
|
122
|
+
</Table>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
A toned row whose cells never say what the tone means: colour alone tells nobody who cannot see it.
|
|
126
|
+
```tsx
|
|
127
|
+
import {
|
|
128
|
+
Table,
|
|
129
|
+
TableBody,
|
|
130
|
+
TableCell,
|
|
131
|
+
TableHead,
|
|
132
|
+
TableHeaderCell,
|
|
133
|
+
TableRow,
|
|
134
|
+
} from "@slashsuite/ui-react";
|
|
135
|
+
|
|
136
|
+
<Table label="Debit orders">
|
|
137
|
+
<TableHead>
|
|
138
|
+
<TableRow>
|
|
139
|
+
<TableHeaderCell>Debit order</TableHeaderCell>
|
|
140
|
+
<TableHeaderCell numeric>Amount</TableHeaderCell>
|
|
141
|
+
</TableRow>
|
|
142
|
+
</TableHead>
|
|
143
|
+
<TableBody>
|
|
144
|
+
<TableRow>
|
|
145
|
+
<TableCell tone="strong">Insurance</TableCell>
|
|
146
|
+
<TableCell numeric>R 1 850.00</TableCell>
|
|
147
|
+
</TableRow>
|
|
148
|
+
<TableRow tone="danger">
|
|
149
|
+
<TableCell tone="strong">Gym</TableCell>
|
|
150
|
+
<TableCell numeric>R 349.00</TableCell>
|
|
151
|
+
</TableRow>
|
|
152
|
+
</TableBody>
|
|
153
|
+
</Table>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
An empty header cell leaves the column with no name, so a screen reader hears a column of unlabelled buttons.
|
|
157
|
+
```tsx
|
|
158
|
+
import {
|
|
159
|
+
Button,
|
|
160
|
+
Table,
|
|
161
|
+
TableBody,
|
|
162
|
+
TableCell,
|
|
163
|
+
TableHead,
|
|
164
|
+
TableHeaderCell,
|
|
165
|
+
TableRow,
|
|
166
|
+
} from "@slashsuite/ui-react";
|
|
167
|
+
|
|
168
|
+
<Table label="Clients">
|
|
169
|
+
<TableHead>
|
|
170
|
+
<TableRow>
|
|
171
|
+
<TableHeaderCell>Client</TableHeaderCell>
|
|
172
|
+
<TableHeaderCell align="end" />
|
|
173
|
+
</TableRow>
|
|
174
|
+
</TableHead>
|
|
175
|
+
<TableBody>
|
|
176
|
+
<TableRow>
|
|
177
|
+
<TableCell tone="strong">Naledi Dlamini</TableCell>
|
|
178
|
+
<TableCell align="end">
|
|
179
|
+
<Button variant="outline" size="sm">
|
|
180
|
+
Open
|
|
181
|
+
</Button>
|
|
182
|
+
</TableCell>
|
|
183
|
+
</TableRow>
|
|
184
|
+
</TableBody>
|
|
185
|
+
</Table>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
A button put in a header cell by hand says nothing about the order to a screen reader, and looks unlike every other sortable column.
|
|
189
|
+
```tsx
|
|
190
|
+
import {
|
|
191
|
+
Button,
|
|
192
|
+
Table,
|
|
193
|
+
TableBody,
|
|
194
|
+
TableCell,
|
|
195
|
+
TableHead,
|
|
196
|
+
TableHeaderCell,
|
|
197
|
+
TableRow,
|
|
198
|
+
} from "@slashsuite/ui-react";
|
|
199
|
+
|
|
200
|
+
<Table label="Quotes">
|
|
201
|
+
<TableHead>
|
|
202
|
+
<TableRow>
|
|
203
|
+
<TableHeaderCell>Quote</TableHeaderCell>
|
|
204
|
+
<TableHeaderCell numeric>
|
|
205
|
+
<Button variant="ghost" size="sm">
|
|
206
|
+
Total
|
|
207
|
+
</Button>
|
|
208
|
+
</TableHeaderCell>
|
|
209
|
+
</TableRow>
|
|
210
|
+
</TableHead>
|
|
211
|
+
<TableBody>
|
|
212
|
+
<TableRow>
|
|
213
|
+
<TableCell>Q-1043</TableCell>
|
|
214
|
+
<TableCell>R 18400</TableCell>
|
|
215
|
+
</TableRow>
|
|
216
|
+
</TableBody>
|
|
217
|
+
</Table>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
A cell with a column count written by hand breaks the day a column is added, and is a second empty look.
|
|
221
|
+
```tsx
|
|
222
|
+
import {
|
|
223
|
+
Table,
|
|
224
|
+
TableBody,
|
|
225
|
+
TableCell,
|
|
226
|
+
TableHead,
|
|
227
|
+
TableHeaderCell,
|
|
228
|
+
TableRow,
|
|
229
|
+
} from "@slashsuite/ui-react";
|
|
230
|
+
|
|
231
|
+
<Table label="Quotes">
|
|
232
|
+
<TableHead>
|
|
233
|
+
<TableRow>
|
|
234
|
+
<TableHeaderCell>Quote</TableHeaderCell>
|
|
235
|
+
<TableHeaderCell>Customer</TableHeaderCell>
|
|
236
|
+
<TableHeaderCell numeric>Total</TableHeaderCell>
|
|
237
|
+
</TableRow>
|
|
238
|
+
</TableHead>
|
|
239
|
+
<TableBody>
|
|
240
|
+
<TableRow>
|
|
241
|
+
<TableCell colSpan={5} align="center" tone="muted">
|
|
242
|
+
No quotes yet.
|
|
243
|
+
</TableCell>
|
|
244
|
+
</TableRow>
|
|
245
|
+
</TableBody>
|
|
246
|
+
</Table>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Accessibility
|
|
250
|
+
- A Table renders a native `<table>`; its `label` is the accessible name, a visually hidden caption.
|
|
251
|
+
- A `TableHeaderCell` in the head is a `<th scope="col">`, and in a body row a `<th scope="row">`; a `TableGroupRow` is a `<th scope="rowgroup">`.
|
|
252
|
+
- A `TableHeaderCell` `label` is hidden text inside the header cell, so an actions column still has a name for a screen reader.
|
|
253
|
+
- Colour alone never carries a row's or a cell's status; name it in text.
|
|
254
|
+
- A `lines={1}` cell that is cut shows its full text in a tooltip on hover, a tap and keyboard focus (a plain cut cell becomes a tab stop for it). The tooltip is hidden from assistive tech, which reads the whole text from the cell already.
|
|
255
|
+
- A stretched `TextLink` is a real link and the only tab stop in its row; the row's whole area is its click target.
|
|
256
|
+
- A `TableEditCell` or `InlineEdit` is a native `<button>` named by its value and its `label`. Opening moves the focus to the editor, a group named by `label`; Esc and `close` move it back to the value.
|
|
257
|
+
- A table wider than its card scrolls sideways; when nothing in it can take focus, the card takes one tab stop, a group named by the table's `label`, so the keyboard can scroll it.
|
|
258
|
+
- A table that fits its card keeps its head on screen under the page's header as the page scrolls.
|
|
259
|
+
- With `narrow="stack"` the parts keep their table roles in the stacked look, and each cell's column title is drawn for the eye and hidden from assistive tech, which reads the head.
|
|
260
|
+
- A sorted column's header has `aria-sort` (`ascending` or `descending`); a sortable column it is not sorted by has none, and its title is a native button named by the title, at least 24px tall. A sort is announced in a status region (`Sorted by Total, ascending`); `sortedLabel` words it in another language.
|
|
261
|
+
- A `selected` row has `aria-current`, not `aria-selected`, which a plain table row does not support.
|
|
262
|
+
- A `TableExpandCell` is a native button named by its `label` and `count` ("Details, 3"), with `aria-expanded` and the `aria-controls` you give it.
|
|
263
|
+
|
|
264
|
+
### Props
|
|
265
|
+
### Table
|
|
266
|
+
A list of records in a rounded, bordered card. Compose it from `TableHead`, `TableBody`, `TableFoot`, `TableRow`, `TableHeaderCell` and `TableCell`. `label` names the table for assistive tech and is not drawn. Inside a `Card` it is plain: no card of its own (border, fill and shadow), no tinted head strip and no row hover, only the row dividers. A column of figures says so once, with `numeric` on its `TableHeaderCell`: its cells then take end alignment and tabular figures. `size` is the row padding, and the buttons and pills in the rows follow it (`sm` by default); a field keeps its own `size`. Other props (`id`, `data-*`, `aria-*`) go on the `<table>`. While `loading`, a body with no rows draws five rows of bones, one per column, and an empty cell draws a bone; the table keeps its role and its name. A table that fits its box keeps its head row in view (under the `AppShell` header) while the page scrolls past its rows; one wider than its box scrolls sideways instead, and takes a tab stop when nothing in it can take focus. `narrow="stack"` draws each row as a card on a screen narrower than `sm` (a phone), the cells as lines labelled by their column's title. A click on a sortable title has the table say the new sort aloud, in `sortedLabel`'s words.
|
|
267
|
+
- label: string (required). Names the table for assistive tech; it is not drawn.
|
|
268
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
269
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
270
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
271
|
+
- narrow: "scroll" | "stack" (default scroll). What the table does on a screen narrower than `sm` (a phone): `scroll` sideways, or `stack` each row into
|
|
272
|
+
a card, the first cell its title and every other cell a line labelled by its column's title.
|
|
273
|
+
Stack a table whose rows a person reads one at a time; keep `scroll` for one they compare
|
|
274
|
+
down a column.
|
|
275
|
+
- size: "sm" | "md" | "lg" (default sm). The row padding; the buttons and fields in the rows take the same size.
|
|
276
|
+
- sortedLabel: ((column: string, sort: "ascending" | "descending") => string) (default `Sorted by Name, ascending`). What a screen reader hears after a click on a sortable title, from the column's title and the
|
|
277
|
+
new direction.
|
|
278
|
+
|
|
279
|
+
### TableHead
|
|
280
|
+
The `<thead>`: small uppercase column titles, on a tinted strip unless the table is in a card. Holds one `TableRow` of `TableHeaderCell`s. Unless the table is in a card, it stays in view under the `AppShell` header while the page scrolls past the rows, as long as the table fits its box.
|
|
281
|
+
|
|
282
|
+
### TableBody
|
|
283
|
+
The `<tbody>`: the rows, each with a line above it and, unless the table is in a card, a fill on hover. With no rows it draws `empty` (an `EmptyState`, one muted line here) in one cell that spans every column the head declares; the head stays drawn, so the reader sees what the table holds. In a loading `Table` a body with no rows draws five rows of bones instead, never `empty`.
|
|
284
|
+
- empty: ReactNode. Shown in one full-width cell when there are no rows: an `EmptyState`.
|
|
285
|
+
|
|
286
|
+
### TableFoot
|
|
287
|
+
The `<tfoot>`: totals and subtotals. Its cells are strong by default and each row has a firmer line above it, alone and in a card alike. Put it after `TableBody`; a row of it takes no `tone`.
|
|
288
|
+
|
|
289
|
+
### TableRow
|
|
290
|
+
A `<tr>`, `relative`: the anchor a `TextLink stretch` (with `href`) stretches to. Any other link, button or control in the row (a `TextLink`, a `Button`, a `Checkbox`) sits above that link and is clickable on its own, with no class from the caller. Use it in the head and the body. In the body it also draws the line above the row and, unless the table is in a card, the hover fill. `selected` marks the current row (the one open beside the table, the one being edited): the `ListRow` selected fill and `aria-current`, the row whose detail is open, not a multi-select; it wins over `tone` and `stripe`. `tone` marks the row's status (see `RowTone`): a stripe on the leading edge and a soft fill, or `muted` to fade it. A toned row keeps its fill on hover (the status stays readable), so a linked row's link, not a hover fill, says it is clickable. `stripe` is the stripe alone, in the `TextTone` colours (the first five names of a `StackedBar` segment's `VizTone`), with no fill: the row keeps its hover and its own look. Give `tone` or `stripe`, not both. Body rows only; colour alone does not say it, so name the status in a cell too (a `Pill`). A bold subtotal is not a tone: a total of the whole table is a `TableFoot` row, and a subtotal among the body's rows is `emphasis`, the same look.
|
|
291
|
+
- emphasis: boolean (default false). A subtotal in the body: the look of a `TableFoot` row, with strong cells, a firmer line
|
|
292
|
+
above and no hover. Give only one of `tone`, `stripe` and `emphasis`.
|
|
293
|
+
|
|
294
|
+
A sign row or a subtotal needs no other part.
|
|
295
|
+
- selected: boolean (default false). The row in view (its detail open beside the table): the selected fill and `aria-current`. Body
|
|
296
|
+
rows only.
|
|
297
|
+
|
|
298
|
+
As on a `ListRow`, it is not a multi-select, and a selected row takes no `tone`.
|
|
299
|
+
- stripe: "muted" | "info" | "positive" | "warn" | "danger" | "accent". A stripe on the leading edge in this tone, with no fill. Give only one of `tone`, `stripe` and `emphasis`.
|
|
300
|
+
- tone: "muted" | "neutral" | "info" | "positive" | "warn" | "danger". The row's status: a stripe on the leading edge plus the tone's soft fill, or `muted` to fade the row. Give only one of `tone`, `stripe` and `emphasis`.
|
|
301
|
+
|
|
302
|
+
### TableHeaderCell
|
|
303
|
+
A header cell. In the `TableHead` it is a column title, `<th scope="col">`. `numeric` declares a column of figures, once: the title and every cell under it take end alignment and tabular figures. A column with nothing to show in its head (a row's actions) takes `label` instead of `children`: the name a screen reader hears ("Actions"), visually hidden so the head keeps its column. `sort` and `onSort` make the column sortable: the title becomes a button that fills the cell and asks for the next direction, the column says where it stands with `aria-sort`, and the table says the new sort aloud. The app sorts its rows; the table never does. In a body or foot row it is the row's header, `<th scope="row">`: the cell that names the row (a name, a date), drawn like a `strong` cell, so a screen reader reads it before each of the row's values.
|
|
304
|
+
- align: "center" | "end" | "start" (default numeric ? "end" : "start"). The title's horizontal alignment; `end` over a column of buttons, `center` over a centred column.
|
|
305
|
+
- label: string. The column's name for a screen reader, visually hidden, for a column with no visible title (a row's actions).
|
|
306
|
+
- numeric: boolean (default false). A column of figures: this title and the cells under it are end aligned, the cells in tabular figures.
|
|
307
|
+
- onSort: ((next: "ascending" | "descending") => void). Called with the next direction on a click: `none` goes to `ascending`, then each click flips it.
|
|
308
|
+
- sort: "none" | "ascending" | "descending". Where this column stands: `ascending`, `descending`, or `none` when the table is sorted by
|
|
309
|
+
another column. The app sorts its rows and passes it back; one sorted column at a time.
|
|
310
|
+
|
|
311
|
+
With `onSort` the title becomes a button that asks for the next direction. The table never
|
|
312
|
+
sorts, filters or pages.
|
|
313
|
+
|
|
314
|
+
### TableCell
|
|
315
|
+
A `<td>`. `tone` is the text weight and colour (see `CellTone`; in a `TableFoot` it defaults to `strong`); `numeric` sets end alignment and tabular figures (a cell under a `numeric` head cell is numeric already), `mono` a small mono face. `secondary` is a second, muted line under the content. One rule for wrapping: prose (a cell of plain text) wraps onto more lines (never narrower than `min-w-48`, so it scrolls the table before it becomes a sliver); any other cell stays on one line at its content's width: one that holds a control or a link, and a `numeric` or `mono` cell (a figure, a code, a type). `lines={1}` caps a long value's width, cuts it with an ellipsis on one line and, while it is cut, shows the full text in a tooltip on hover, focus and a tap; the content is then plain text (strings and numbers), since that is what the tooltip shows. `colSpan` passes through: a cell that spans the row is a full-width panel (a note under a group), and `align="center"` centres it. A table with no rows takes `TableBody empty`, not a cell built by hand. `span="full"` spans every column the head declares, so a panel under a row needs no count. `indent` sets a start-aligned cell in by 1 to 3 levels, for a line under a parent row. While `loading` an empty cell draws one bone, the width of a short value.
|
|
316
|
+
- align: "center" | "end" | "start" (default end for a numeric cell, else start). The cell's horizontal alignment; `center` for a full-width note.
|
|
317
|
+
- colSpan: number. How many columns the cell spans; `span="full"` spans them all without a count.
|
|
318
|
+
- indent: 2 | 3 | 1. Sets the cell in by this many levels (1 to 3), for a line under a parent row. Start-aligned cells only.
|
|
319
|
+
- lines: 1. `1` caps the width and cuts a long value with an ellipsis on one line; while it is cut, the full
|
|
320
|
+
text shows in a tooltip on hover, keyboard focus and a tap. Plain text content only.
|
|
321
|
+
|
|
322
|
+
Without it, a prose cell wraps down to a floor so it never becomes a sliver, and any other cell
|
|
323
|
+
(a `Pill`, a `Switch`, a `Button`, a `TextLink`, a `numeric` or `mono` value) stays on one line
|
|
324
|
+
at its content's width.
|
|
325
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
326
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
327
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
328
|
+
- mono: boolean (default false). A small monospace face for a code or a type, and the cell never wraps.
|
|
329
|
+
- numeric: boolean (default the column's, from a `numeric` head cell). A figure: end aligned, tabular figures, and the cell never wraps.
|
|
330
|
+
- secondary: ReactNode. A second, muted line under the content.
|
|
331
|
+
- span: "full". `full` spans every column the head declares: a panel under a row, an open row's detail.
|
|
332
|
+
- tone: "muted" | "strong" | "neutral" | "info" | "positive" | "warn" | "danger". The text weight and colour (see `CellTone`). In a `TableFoot` it defaults to `strong`.
|
|
333
|
+
|
|
334
|
+
### TableEditCell
|
|
335
|
+
A `TableCell` whose value opens an editor in place: a cell that holds one `InlineEdit` and nothing else. It shows `children` as a button with a dotted underline; a click, Enter or Space swaps it for `renderEditor(close)` and moves the focus into the editor. The editor calls `close` when it has saved, and Esc closes it: both put the focus back on the value. A press outside it or Tab out of it closes it too and leaves the focus where it went, so the editor saves its value on its own change or submit, never on a close. Put the control in the cell itself, not in a popover of its own, which counts as outside. Takes `TableCell`'s `align`, `tone`, `numeric`, `mono`, `indent`, `secondary` and `span`. For an edit trigger in a cell that holds other content too, put an `InlineEdit` in a `TableCell`.
|
|
336
|
+
- align: "center" | "end" | "start" (default end for a numeric cell, else start). The cell's horizontal alignment; `center` for a full-width note.
|
|
337
|
+
- children: ReactNode (required). The value, shown while closed.
|
|
338
|
+
- colSpan: number. How many columns the cell spans; `span="full"` spans them all without a count.
|
|
339
|
+
- indent: 2 | 3 | 1. Sets the cell in by this many levels (1 to 3), for a line under a parent row. Start-aligned cells only.
|
|
340
|
+
- label: string (required). What the button does, for a screen reader, heard after the value: "Edit category". It also names the editor.
|
|
341
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
342
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
343
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
344
|
+
- mono: boolean. A small monospace face for a code or a type, and the cell never wraps.
|
|
345
|
+
- numeric: boolean (default the column's, from a `numeric` head cell). A figure: end aligned, tabular figures, and the cell never wraps.
|
|
346
|
+
- renderEditor: (close: () => void) => ReactNode (required). The control that edits the value, drawn while open. `close` shuts it and returns the focus to
|
|
347
|
+
the value.
|
|
348
|
+
|
|
349
|
+
Call `close` once the control has saved: a press outside the cell, Tab out of it and Esc all
|
|
350
|
+
close it without a save, so save on the control's own change or submit. The control sits in the
|
|
351
|
+
cell, not in a popover of its own.
|
|
352
|
+
- secondary: ReactNode. A second, muted line under the content.
|
|
353
|
+
- span: "full". `full` spans every column the head declares: a panel under a row, an open row's detail.
|
|
354
|
+
- tone: "muted" | "strong" | "neutral" | "info" | "positive" | "warn" | "danger". The text weight and colour (see `CellTone`). In a `TableFoot` it defaults to `strong`.
|
|
355
|
+
|
|
356
|
+
### InlineEdit
|
|
357
|
+
A value that opens an editor in place, as a part inside a `TableCell` that holds more than the value (an edit trigger in a column cell with other content, say). It shows `children` as a button with a dotted underline; a click, Enter or Space swaps it for `renderEditor(close)` and moves the focus into the editor. The part keeps its own open state. The editor calls `close` when it has saved, and Esc closes it: both put the focus back on the value. A press outside it or Tab out of it closes it too and leaves the focus where it went, so the editor saves its value on its own change or submit, never on a close. Put the control in the part itself, not in a popover of its own, which counts as outside. It takes the alignment of the cell around it. It is a block that bleeds half a rem into the padding of the cell it sits in, so it belongs inside a `TableCell`; a cell that holds only the value is a `TableEditCell`. `data-*` and `aria-*` go on the button, and on the editor's group while open.
|
|
358
|
+
- children: ReactNode (required). The value, shown while closed.
|
|
359
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
360
|
+
- label: string (required). What the button does, for a screen reader, heard after the value: "Edit category". It also names the editor.
|
|
361
|
+
- renderEditor: (close: () => void) => ReactNode (required). The control that edits the value, drawn while open. `close` shuts it and returns the focus to the value.
|
|
362
|
+
|
|
363
|
+
### TableGroupRow
|
|
364
|
+
A full-width group header in the body: a tinted row with a `label` that spans every column the head declares (or `colSpan` columns), and optional `trailing` text at the far end: the group's count or subtotal, muted. The group's rows follow it. The row is a `<th>`, a heading for the group, so an action on the group goes in its rows or above the table, not here. For a panel of other content across the whole row, use a `TableCell span="full"` instead.
|
|
365
|
+
- colSpan: number (default every column the `TableHead` declares). How many columns the header spans.
|
|
366
|
+
- label: ReactNode (required). The group's name, at the start of the row.
|
|
367
|
+
- trailing: ReactNode. The group's count or subtotal, muted at the far end of the row.
|
|
368
|
+
|
|
369
|
+
### TableExpandCell
|
|
370
|
+
The cell that opens and closes the row it sits in: a small ghost button with a chevron that turns down when `expanded`, named by `label` (visually hidden) and, with a `count`, the count chip after it, so it reads "Details, 3". The app holds `expanded` and renders what opens under the row: a `TableRow` with one `TableCell span="full"`, or indented child rows. Give its column a head of `<TableHeaderCell label="Details" />`. `aria-controls` names what it opens; other props go on the `<td>`.
|
|
371
|
+
- count: number. A count chip after the chevron: how many lines open under the row.
|
|
372
|
+
- expanded: boolean (required). Whether the row is open.
|
|
373
|
+
|
|
374
|
+
Hold it yourself and render what opens under the row: a `TableRow` with one `TableCell
|
|
375
|
+
span="full"`, or indented child rows. Head the column `<TableHeaderCell label="Details" />`.
|
|
376
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
377
|
+
- label: string (required). The button's name, visually hidden: "Details".
|
|
378
|
+
- onClick: MouseEventHandler<HTMLButtonElement> (required). Opens or closes the row: the app flips `expanded`.
|
|
379
|
+
|
|
380
|
+
### Types
|
|
381
|
+
- CellAlign: `"end" | "start" | "center"`. Where a table cell's content sits across it: `start`, `center` or `end` (numbers).
|
|
382
|
+
- CellTone: `Tone | "muted" | "strong"`. The text of a cell: its weight and colour. `neutral` (the default), `strong` and `muted` are the plain ones; the rest are the shared tones, for an amount that carries a meaning (a gain, an overspend). Colour alone does not say it, so a signed figure or a word says it too.
|
|
383
|
+
- RowTone: `"neutral" | "info" | "positive" | "warn" | "danger" | "muted"`. The status of a row: the Callout's tones, plus `muted`. A toned row gets a stripe on its leading edge and the tone's soft fill; `muted` fades the row instead, for one that matters less. The stripe takes the tone's text colour, which every theme already remaps, so no new palette entry.
|
|
384
|
+
- TableSort: `"ascending" | "descending" | "none"`. Where a sortable column stands: ARIA's own words. `none` is a column the table is not sorted by.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
## Tabs
|
|
2
|
+
|
|
3
|
+
Group: Navigation
|
|
4
|
+
|
|
5
|
+
When to use: Tabs switch a panel on the same page. A row of links to other pages is `Tabs` with link items.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- SegmentedControl (segmented-control.md): One value is picked from two to five, and no panel switches under the row.
|
|
9
|
+
- Fieldset (fieldset.md): Toggles that can be on together narrow a list: pressed `Button`s in a `Fieldset`, one per facet.
|
|
10
|
+
|
|
11
|
+
### The one right way
|
|
12
|
+
`Tabs` switches a view in place: each tab carries its `panel`, drawn right under the row.
|
|
13
|
+
```tsx
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { Tabs, Text } from "@slashsuite/ui-react";
|
|
16
|
+
|
|
17
|
+
function Example() {
|
|
18
|
+
const [value, setValue] = useState("overview");
|
|
19
|
+
return (
|
|
20
|
+
<Tabs
|
|
21
|
+
label="Project views"
|
|
22
|
+
value={value}
|
|
23
|
+
onChange={setValue}
|
|
24
|
+
items={[
|
|
25
|
+
{ value: "overview", label: "Overview", panel: <Text>The project at a glance.</Text> },
|
|
26
|
+
{ value: "activity", label: "Activity", panel: <Text>What changed this week.</Text> },
|
|
27
|
+
{ value: "settings", label: "Settings", panel: <Text>Who can see the project.</Text> },
|
|
28
|
+
]}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Do
|
|
35
|
+
- `Tabs` switches a view in place: each tab carries its `panel`, which Tabs draws under the row (beside the rail); the caller owns `value` and `onChange`.
|
|
36
|
+
- Every panel is mounted, the hidden ones too, so find in page reaches them. A view too heavy to mount before it is chosen is `null` until its tab is current (`panel: value === "a" ? <ViewA /> : null`), and find in page then skips it.
|
|
37
|
+
- Going to another page is link items (`href`, and `selected` on the current one): links, so the URL, the back button and a new tab all work.
|
|
38
|
+
- A `count` sits muted after the label and is read as part of the tab's name.
|
|
39
|
+
- Across, tabs are always underline, under a `PageHeader` too: one line that scrolls sideways, with a fade, when it is too wide. `orientation="vertical"` is the pill rail, the current tab filled, for a `SidebarLayout` aside, and only the rail takes `size`.
|
|
40
|
+
- `size` (`sm`, `md` the default, `lg`) sets the vertical rail on the control scale, so it lines up with a `Button` of the same size; the underline row has one size.
|
|
41
|
+
- A tab that cannot be chosen yet takes a `disabledReason` that says why.
|
|
42
|
+
- Pill links with `orientation="vertical"` are the rail of a `SidebarLayout`: one link per line.
|
|
43
|
+
|
|
44
|
+
### Don't
|
|
45
|
+
A `SegmentedControl` that swaps the panel under it picks a value, not a view: no tab list, no panel tied to it. Switching the panel is `Tabs`.
|
|
46
|
+
```tsx
|
|
47
|
+
import { useState } from "react";
|
|
48
|
+
import { SegmentedControl, Stack, Text } from "@slashsuite/ui-react";
|
|
49
|
+
|
|
50
|
+
function Example() {
|
|
51
|
+
const [value, setValue] = useState("overview");
|
|
52
|
+
return (
|
|
53
|
+
<Stack>
|
|
54
|
+
<SegmentedControl
|
|
55
|
+
label="Project views"
|
|
56
|
+
value={value}
|
|
57
|
+
onChange={setValue}
|
|
58
|
+
items={[
|
|
59
|
+
{ value: "overview", label: "Overview" },
|
|
60
|
+
{ value: "activity", label: "Activity" },
|
|
61
|
+
{ value: "settings", label: "Settings" },
|
|
62
|
+
]}
|
|
63
|
+
/>
|
|
64
|
+
<Text>Showing {value}.</Text>
|
|
65
|
+
</Stack>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
A `Tabs` row that only navigates leaves the URL, the back button and a new tab behind.
|
|
71
|
+
```tsx
|
|
72
|
+
import { useState } from "react";
|
|
73
|
+
import { Tabs } from "@slashsuite/ui-react";
|
|
74
|
+
|
|
75
|
+
function Example() {
|
|
76
|
+
const [value, setValue] = useState("quotes");
|
|
77
|
+
return (
|
|
78
|
+
<Tabs
|
|
79
|
+
label="Sections"
|
|
80
|
+
value={value}
|
|
81
|
+
onChange={(next) => {
|
|
82
|
+
setValue(next);
|
|
83
|
+
location.assign(`#${next}`);
|
|
84
|
+
}}
|
|
85
|
+
items={[
|
|
86
|
+
{ value: "quotes", label: "Quotes" },
|
|
87
|
+
{ value: "invoices", label: "Invoices" },
|
|
88
|
+
]}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
A count typed into the label is plain text: it does not mute, and it cannot be styled the same.
|
|
95
|
+
```tsx
|
|
96
|
+
import { useState } from "react";
|
|
97
|
+
import { Tabs } from "@slashsuite/ui-react";
|
|
98
|
+
|
|
99
|
+
function Example() {
|
|
100
|
+
const [value, setValue] = useState("shots");
|
|
101
|
+
return (
|
|
102
|
+
<Tabs
|
|
103
|
+
label="Assets"
|
|
104
|
+
value={value}
|
|
105
|
+
onChange={setValue}
|
|
106
|
+
items={[
|
|
107
|
+
{ value: "shots", label: "Shots (12)" },
|
|
108
|
+
{ value: "clips", label: "Clips (3)" },
|
|
109
|
+
]}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
A bare `disabled` tab is skipped by the arrows and never says why.
|
|
116
|
+
```tsx
|
|
117
|
+
import { useState } from "react";
|
|
118
|
+
import { Tabs } from "@slashsuite/ui-react";
|
|
119
|
+
|
|
120
|
+
function Example() {
|
|
121
|
+
const [value, setValue] = useState("overview");
|
|
122
|
+
return (
|
|
123
|
+
<Tabs
|
|
124
|
+
label="Project views"
|
|
125
|
+
items={[
|
|
126
|
+
{ value: "overview", label: "Overview" },
|
|
127
|
+
{ value: "builds", label: "Builds" },
|
|
128
|
+
{ value: "billing", label: "Billing", disabled: true },
|
|
129
|
+
]}
|
|
130
|
+
value={value}
|
|
131
|
+
onChange={setValue}
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
A stack of ghost link `Button`s is not a nav landmark, and nothing marks the current page.
|
|
138
|
+
```tsx
|
|
139
|
+
import { Button, Stack } from "@slashsuite/ui-react";
|
|
140
|
+
|
|
141
|
+
<Stack gap="xs">
|
|
142
|
+
<Button href="#overview" variant="ghost">
|
|
143
|
+
Overview
|
|
144
|
+
</Button>
|
|
145
|
+
<Button href="#button" variant="ghost">
|
|
146
|
+
Button
|
|
147
|
+
</Button>
|
|
148
|
+
<Button href="#card" variant="ghost">
|
|
149
|
+
Card
|
|
150
|
+
</Button>
|
|
151
|
+
</Stack>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Accessibility
|
|
155
|
+
- The row is a tab list named by `label`; the arrow keys, Home and End move between the tabs, and a `disabled` tab is skipped.
|
|
156
|
+
- A tab with `disabledReason` is `aria-disabled`: the arrow keys reach it and choose nothing, and the reason shows as a tooltip on hover, keyboard focus and a tap, read out as its description (the native `title` without CSS anchor positioning).
|
|
157
|
+
- A tab's `panel` is a `tabpanel` labelled by the tab and named in its `aria-controls`; a hidden one is `hidden="until-found"` where the browser has it, so find in page reaches its text and switches to the tab.
|
|
158
|
+
- The current tab is told apart by more than colour: the underline, and on the rail an outline round the fill. Every tab has the same weight, so choosing one does not shift the row.
|
|
159
|
+
- A tab is a `button` with `role="tab"` and `aria-selected`; only the current tab is in the tab order, and the arrow keys move and choose.
|
|
160
|
+
- Link items form a `<nav>` named by `label`; the current link gets `aria-current="page"`.
|
|
161
|
+
|
|
162
|
+
### Props
|
|
163
|
+
### Tabs
|
|
164
|
+
Tabs for switching a view in place or between pages. Across (the default) they are underline tabs: one line over a bottom rule, the current tab underlined in the accent, scrolling sideways with a fade when the row is too wide. `orientation="vertical"` is the pill rail instead, the current tab filled and outlined, for a `SidebarLayout` aside, and takes a `size`. `items` are `{ value, label, panel }` buttons (`value` and `onChange` are the caller's state; the arrow keys, Home and End move between tabs) or links (`href`, an in-app one through `LinkProvider`; `selected` on an item, or `value`, marks the current one, which gets `aria-current`). A button's `panel` is rendered as its `tabpanel`, wired to the tab and hidden while another is current. An item may carry a `count`, and a button one `disabledReason` (it stays reachable by the arrows and its reason is a tooltip) or a bare `disabled`; `disabled` on the row disables every tab. `label` names the tab list.
|
|
165
|
+
- disabled: boolean. Every option is disabled, e.g. until the page has hydrated.
|
|
166
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
167
|
+
- items: Tab[] | TabButton[] (required). The options in order: `{ value, label }` buttons, or links (`href`), the current link marked by its `selected` or by a `value` equal to the group's. Either may carry a `count`; a button may be `disabled`.
|
|
168
|
+
- label: string (required). The accessible name of the group.
|
|
169
|
+
- onChange: ((value: string) => void). Called with the option's `value` when one is chosen, by click or arrow key.
|
|
170
|
+
- orientation: "horizontal" | "vertical" (default horizontal). `horizontal` is a row of underline tabs over a bottom rule, one line that scrolls
|
|
171
|
+
sideways when it is too wide; `vertical` is the pill rail, a column at the rail's width
|
|
172
|
+
for a `SidebarLayout` aside, where the up and down arrows move between button tabs.
|
|
173
|
+
- size: "sm" | "md" | "lg" (default md). The pills' height and text, on the scale of a `Button`. Only the vertical rail takes a `size`.
|
|
174
|
+
- value: string. The `value` of the current option; for links, an alternative to `selected` on the item.
|
|
175
|
+
|
|
176
|
+
### Types
|
|
177
|
+
- Tab: `TabButton | SwitchLink`. One tab of a Tabs row: a button with a `value`, or a link with an `href`; never both kinds in one row.
|
|
178
|
+
- TabButton: `{ label: ReactNode; count?: number; title?: string; value: string; disabled?: boolean; disabledReason?: string; panel?: ReactNode }`. A button tab; its `panel` is the view it shows, rendered by Tabs under (or beside) the row.
|