@slashsuite/ui-react 0.12.1 → 0.13.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/MIGRATING.md +386 -8
- package/README.md +89 -44
- package/agent-docs/components/app-shell.md +9 -6
- package/agent-docs/components/article-layout.md +140 -0
- package/agent-docs/components/audio.md +42 -0
- package/agent-docs/components/badge.md +2 -1
- package/agent-docs/components/body-text.md +26 -15
- package/agent-docs/components/bottom-sheet.md +27 -17
- package/agent-docs/components/breadcrumbs.md +10 -6
- package/agent-docs/components/button.md +2 -2
- package/agent-docs/components/call-to-action.md +59 -0
- package/agent-docs/components/callout.md +4 -3
- package/agent-docs/components/card-grid.md +15 -7
- package/agent-docs/components/card.md +33 -18
- package/agent-docs/components/cart-button.md +63 -0
- package/agent-docs/components/chat-composer.md +4 -3
- package/agent-docs/components/checkbox.md +11 -5
- package/agent-docs/components/cluster.md +10 -8
- package/agent-docs/components/code-example.md +2 -2
- package/agent-docs/components/code.md +7 -5
- package/agent-docs/components/colour-scheme-toggle.md +12 -6
- 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 +2 -1
- package/agent-docs/components/copy-button.md +7 -5
- package/agent-docs/components/copy-line.md +6 -5
- package/agent-docs/components/date-field.md +14 -11
- package/agent-docs/components/date-range-picker.md +16 -9
- package/agent-docs/components/date-time-field.md +73 -0
- package/agent-docs/components/dialog.md +22 -68
- package/agent-docs/components/disclosure.md +4 -0
- package/agent-docs/components/docs-layout.md +10 -6
- package/agent-docs/components/drawer.md +13 -4
- package/agent-docs/components/embed-frame.md +48 -0
- package/agent-docs/components/empty-state.md +4 -1
- package/agent-docs/components/field-dialog.md +6 -5
- package/agent-docs/components/field.md +10 -7
- package/agent-docs/components/fieldset.md +4 -4
- package/agent-docs/components/flow-diagram.md +87 -0
- package/agent-docs/components/form-layout.md +4 -1
- package/agent-docs/components/form-row.md +7 -7
- package/agent-docs/components/full-bleed-layout.md +0 -2
- package/agent-docs/components/headings.md +13 -7
- package/agent-docs/components/hero.md +11 -2
- package/agent-docs/components/icon-button.md +1 -3
- package/agent-docs/components/icon.md +6 -13
- package/agent-docs/components/image.md +24 -14
- package/agent-docs/components/input.md +8 -7
- package/agent-docs/components/key-value-list.md +4 -1
- package/agent-docs/components/lightbox.md +1 -1
- package/agent-docs/components/list-layout.md +5 -7
- package/agent-docs/components/list-row.md +37 -34
- package/agent-docs/components/loading.md +2 -2
- package/agent-docs/components/markdown.md +13 -13
- package/agent-docs/components/media-tile.md +8 -4
- package/agent-docs/components/menu.md +19 -12
- package/agent-docs/components/meta-list.md +2 -2
- package/agent-docs/components/morph.md +11 -5
- package/agent-docs/components/navigation-progress.md +2 -2
- package/agent-docs/components/number-field.md +75 -0
- package/agent-docs/components/outline-region.md +19 -8
- package/agent-docs/components/page-fade.md +2 -1
- package/agent-docs/components/pill.md +7 -6
- 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/promo-banner.md +46 -0
- package/agent-docs/components/prose-layout.md +1 -1
- package/agent-docs/components/radio-group.md +9 -6
- package/agent-docs/components/scroll-strip.md +3 -3
- package/agent-docs/components/segmented-control.md +4 -2
- package/agent-docs/components/select.md +8 -3
- package/agent-docs/components/show.md +2 -2
- package/agent-docs/components/side-column.md +13 -9
- package/agent-docs/components/sidebar-layout.md +1 -1
- package/agent-docs/components/site-footer.md +4 -4
- package/agent-docs/components/site-search.md +21 -9
- package/agent-docs/components/slider.md +59 -0
- package/agent-docs/components/sortable-list.md +15 -10
- package/agent-docs/components/stack.md +3 -3
- package/agent-docs/components/stacked-bar.md +7 -4
- package/agent-docs/components/state-machine.md +95 -0
- package/agent-docs/components/status-pages.md +13 -6
- package/agent-docs/components/stepper.md +54 -0
- package/agent-docs/components/switch.md +4 -4
- package/agent-docs/components/table-of-contents.md +78 -0
- package/agent-docs/components/table.md +35 -24
- package/agent-docs/components/tabs.md +24 -26
- package/agent-docs/components/text-link.md +12 -7
- package/agent-docs/components/textarea.md +4 -2
- package/agent-docs/components/toast.md +19 -14
- package/agent-docs/components/video.md +7 -2
- package/agent-docs/llms.txt +22 -3
- 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 +4 -2
- package/dist/Button.js +9 -87
- 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 +116 -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/core/button.d.ts +33 -0
- package/dist/core/button.js +89 -0
- package/dist/core/control.d.ts +15 -0
- package/dist/core/control.js +14 -0
- package/dist/core/fixtures/button.d.ts +26 -0
- package/dist/core/fixtures/button.js +52 -0
- package/dist/core/fixtures/types.d.ts +13 -0
- package/dist/core/fixtures/types.js +10 -0
- package/dist/core/focus.d.ts +7 -0
- package/dist/core/focus.js +7 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +12 -0
- package/dist/core/parity.d.ts +22 -0
- package/dist/core/parity.js +53 -0
- package/dist/core/themeNative.d.ts +62 -0
- package/dist/core/themeNative.js +290 -0
- package/dist/cx.d.ts +17 -5
- package/dist/cx.js +18 -5
- package/dist/dateLocale.d.ts +17 -0
- package/dist/dateLocale.js +30 -0
- package/dist/density.d.ts +17 -3
- package/dist/density.js +30 -19
- 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/focus.d.ts +2 -0
- package/dist/focus.js +9 -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 +77 -0
- package/dist/stateMachineDots.js +188 -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 +38 -0
- package/dist/useFlowLayout.js +122 -0
- package/package.json +5 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
## Combobox
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: One choice from more items than a `Select` reads well: a country, a time zone, a teammate.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A choice from a long list is a `Combobox`: typing a few letters finds it.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Combobox } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<Combobox
|
|
13
|
+
label="Time zone"
|
|
14
|
+
defaultValue="Europe/Amsterdam"
|
|
15
|
+
width="md"
|
|
16
|
+
items={[
|
|
17
|
+
"Africa/Johannesburg",
|
|
18
|
+
"America/New_York",
|
|
19
|
+
"Asia/Singapore",
|
|
20
|
+
"Asia/Tokyo",
|
|
21
|
+
"Australia/Sydney",
|
|
22
|
+
"Europe/Amsterdam",
|
|
23
|
+
"Europe/London",
|
|
24
|
+
"Pacific/Auckland",
|
|
25
|
+
].map((zone) => ({ value: zone, label: zone.replace("_", " ") }))}
|
|
26
|
+
/>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Do
|
|
30
|
+
- Give it a `label`; it draws its own label, `hint` and `error`, so it is never put in a `Field`.
|
|
31
|
+
- `items` are a `Select`'s: `{ value, label, disabled? }`. Typing filters them by label; the chevron opens the whole list.
|
|
32
|
+
- Keep it with `defaultValue`, or control it with `value` and `onChange(value)`; `name` posts the chosen `value`.
|
|
33
|
+
- Say what an empty filter means in another language with `emptyLabel`.
|
|
34
|
+
- `size` and `width` are the same choices as on `Input`. Up to a dozen choices is a `Select`, and up to five a `RadioGroup`.
|
|
35
|
+
|
|
36
|
+
### Don't
|
|
37
|
+
- Do not make the person scroll a long `Select` for their entry.
|
|
38
|
+
|
|
39
|
+
A `Select` of a long list makes the person scroll through every entry for theirs.
|
|
40
|
+
```tsx
|
|
41
|
+
import { Select } from "@slashsuite/ui-react";
|
|
42
|
+
|
|
43
|
+
<Select
|
|
44
|
+
aria-label="Time zone"
|
|
45
|
+
defaultValue="Europe/Amsterdam"
|
|
46
|
+
items={[
|
|
47
|
+
"Africa/Johannesburg",
|
|
48
|
+
"America/New_York",
|
|
49
|
+
"Asia/Singapore",
|
|
50
|
+
"Asia/Tokyo",
|
|
51
|
+
"Australia/Sydney",
|
|
52
|
+
"Europe/Amsterdam",
|
|
53
|
+
"Europe/London",
|
|
54
|
+
"Pacific/Auckland",
|
|
55
|
+
].map((zone) => ({ value: zone, label: zone.replace("_", " ") }))}
|
|
56
|
+
/>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Accessibility
|
|
60
|
+
- React Aria's combobox: the input is a `combobox` with the label as its name, and the list a `listbox` it controls.
|
|
61
|
+
- Arrow keys move through the list, Enter picks, Escape closes it; the chevron button is out of the tab order.
|
|
62
|
+
- A `hint` and an `error` are the field's description; an `error` marks it `aria-invalid` and is announced politely.
|
|
63
|
+
- Inside a modal `Dialog` the list draws in the dialog, so it stays reachable.
|
|
64
|
+
|
|
65
|
+
### Props
|
|
66
|
+
### Combobox
|
|
67
|
+
A text field that filters a list of choices as the person types, for a choice from more items than a `Select` reads well (a country, a time zone, a teammate): React Aria's `ComboBox`. Typing narrows the list by label; arrow keys move through it, Enter picks, Escape closes it. The chevron opens the whole list. Its value is the chosen item's `value`, posted under `name`. `label`, `hint`, `error`, `required` and `disabled` are a `DateField`'s; `size` and `width` an `Input`'s. Inside a modal `Dialog` the list draws in the dialog. While `loading` the label is drawn and the field is a bone of its height.
|
|
68
|
+
- defaultValue: string | null. The item's `value` it starts with, uncontrolled.
|
|
69
|
+
- disabled: boolean. Disables the field and its button.
|
|
70
|
+
- emptyLabel: string (default No matches). The line the list shows when nothing matches what was typed, for an app in another language.
|
|
71
|
+
- error: ReactNode. Marks the field invalid and shows this in red under the hint, announced politely.
|
|
72
|
+
- hint: ReactNode. A muted line under the field that says more; it stays while an error shows under it.
|
|
73
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
74
|
+
- items: readonly SelectItem[] (required). The choices, in order; typing filters them by label.
|
|
75
|
+
- label: ReactNode. The field's visible label, above it. Without one, name the field with `aria-label`.
|
|
76
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
77
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
78
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
79
|
+
- name: string. Posts the chosen item's `value` in a form under this key.
|
|
80
|
+
- onChange: ((value: string | null) => void). Called with the chosen item's `value`, or `null` when the choice is cleared.
|
|
81
|
+
- required: boolean. Marks a choice required: the field is `aria-required`, and an empty one is invalid.
|
|
82
|
+
- size: Size | ResponsiveSize (default md). `sm` is compact, `text-sm` with less padding, for dense forms and table rows; `md` is `text-base`;
|
|
83
|
+
`lg` is `text-lg` with more padding, for a hero form. Under an `AppShell density="compact"` each
|
|
84
|
+
is one type step down, and on a touch screen a field is never under 16px.
|
|
85
|
+
`{ base: "md", md: "lg" }` changes size at the `md` breakpoint (48rem), in CSS, as a `Button`'s
|
|
86
|
+
does: give the field and the buttons in its row the same value, so the row stays aligned.
|
|
87
|
+
- value: string | null. The chosen item's `value`, controlled, with `onChange`. `null` is nothing chosen.
|
|
88
|
+
- width: "sm" | "md" | "lg" | "auto" | "xs" | "fill" | "full". `full` (default) fills the parent; `fill` grows to fill the room left in a row beside other items (it can shrink to nothing, so buttons stay on the line); `xs`, `sm`, `md`, `lg` are fixed; `auto` adds no width class, so the control is as wide as the browser makes it.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
## ConfirmDialog
|
|
2
|
+
|
|
3
|
+
Group: Feedback
|
|
4
|
+
|
|
5
|
+
When to use: An action that destroys something or cannot be undone: delete, discard, revoke, sign out everywhere.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Dialog (dialog.md): A form, or a question with more than two answers.
|
|
9
|
+
- Toast (toast.md): The action can be undone: do it, and offer Undo in a toast.
|
|
10
|
+
|
|
11
|
+
### The one right way
|
|
12
|
+
A question that names the action, one line of consequence, and Cancel beside the action: it opens on Cancel, so a stray Enter cancels.
|
|
13
|
+
```tsx
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { Button, ConfirmDialog } from "@slashsuite/ui-react";
|
|
16
|
+
|
|
17
|
+
function Example() {
|
|
18
|
+
const [open, setOpen] = useState(false);
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<Button variant="outline" onClick={() => setOpen(true)}>
|
|
22
|
+
Delete build
|
|
23
|
+
</Button>
|
|
24
|
+
{open && (
|
|
25
|
+
<ConfirmDialog
|
|
26
|
+
title="Delete build?"
|
|
27
|
+
description="This removes the build and every snapshot in it."
|
|
28
|
+
confirm="Delete"
|
|
29
|
+
busyLabel="Deleting…"
|
|
30
|
+
onConfirm={() => Promise.resolve()}
|
|
31
|
+
onClose={() => setOpen(false)}
|
|
32
|
+
/>
|
|
33
|
+
)}
|
|
34
|
+
</>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Do
|
|
40
|
+
- Render it only while it is open: `{open && <ConfirmDialog … onClose={() => setOpen(false)} />}`.
|
|
41
|
+
- `title` is the question and names the action ("Delete build?"), `description` is the consequence in one sentence, and `confirm` is the action as a verb ("Delete"), never "OK" or "Yes".
|
|
42
|
+
- `tone` is `danger` (the default) for an action that destroys or cannot be undone, and `neutral` for one that can be reversed, such as Archive.
|
|
43
|
+
- `onConfirm` runs the action. Return its promise: the button is busy (`busyLabel`) until it settles, resolving closes the dialog, and a rejection shows its message above the buttons and keeps the dialog open for a retry.
|
|
44
|
+
- Set `cancel` and `closeLabel` to the reader's language when the page is not in English.
|
|
45
|
+
|
|
46
|
+
### Don't
|
|
47
|
+
- Do not ask before an action that can be undone: do it, and offer Undo in a `Toast`.
|
|
48
|
+
- Do not build one from a `Dialog` with only the action in its footer: a confirmation always has Cancel.
|
|
49
|
+
|
|
50
|
+
A hand-built `Dialog` with no Cancel and no consequence: the only way on is the one button that destroys the build, and nothing says what it destroys.
|
|
51
|
+
```tsx
|
|
52
|
+
import { useState } from "react";
|
|
53
|
+
import { Button, Dialog } from "@slashsuite/ui-react";
|
|
54
|
+
|
|
55
|
+
function Example() {
|
|
56
|
+
const [open, setOpen] = useState(false);
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<Button variant="outline" onClick={() => setOpen(true)}>
|
|
60
|
+
Delete build
|
|
61
|
+
</Button>
|
|
62
|
+
{open && (
|
|
63
|
+
<Dialog
|
|
64
|
+
title="Are you sure?"
|
|
65
|
+
onClose={() => setOpen(false)}
|
|
66
|
+
footer={
|
|
67
|
+
<Button tone="danger" onClick={() => setOpen(false)}>
|
|
68
|
+
Delete
|
|
69
|
+
</Button>
|
|
70
|
+
}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Accessibility
|
|
79
|
+
- It is an `alertdialog` on the browser's own `<dialog>`: the page behind goes inert, focus stays inside and Esc closes it.
|
|
80
|
+
- It is named by its `title` and described by its `description`, so a screen reader reads the question and the consequence as it opens.
|
|
81
|
+
- It opens on Cancel, so Enter or Space pressed by habit cancels rather than destroys.
|
|
82
|
+
- Esc, the backdrop and the close button all cancel, as Cancel does; only the confirm button runs the action.
|
|
83
|
+
- While the action runs, the confirm button is busy (`aria-busy`); a rejection is announced as an alert inside the dialog.
|
|
84
|
+
|
|
85
|
+
### Props
|
|
86
|
+
### ConfirmDialog
|
|
87
|
+
A `Dialog` that asks before an action: the question as its title, the consequence under it, and Cancel beside the one action. It is an `alertdialog` and opens on Cancel, so a stray Enter cancels. Render it only while it is open.
|
|
88
|
+
- busyLabel: string. What the confirm button says while `onConfirm` runs, such as "Deleting…".
|
|
89
|
+
- cancel: string (default Cancel). The cancel button's text, for an app in another language.
|
|
90
|
+
- closeLabel: string (default Close). The name of the close button in the top corner, for an app in another language.
|
|
91
|
+
- confirm: string (required). The confirm button's text, the action as a verb: "Delete".
|
|
92
|
+
- description: ReactNode (required). The consequence, in one sentence: "This removes the build and every snapshot in it." It describes the dialog.
|
|
93
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
94
|
+
- onClose: () => void (required). Called when the dialog closes: Cancel, Esc, the backdrop, the close button, or a confirm that went through.
|
|
95
|
+
- onConfirm: () => void | Promise<unknown> (required). Runs the action. A returned promise keeps the confirm button busy until it settles: resolving
|
|
96
|
+
closes the dialog, and a rejection shows its message in the dialog and keeps it open.
|
|
97
|
+
- title: string (required). The question, naming the action: "Delete build?". It is the dialog's accessible name.
|
|
98
|
+
- tone: "neutral" | "danger" (default danger). `danger` for an action that destroys or cannot be undone, which draws the confirm button red.
|
|
@@ -46,5 +46,6 @@ import { Card, Container, Text } from "@slashsuite/ui-react";
|
|
|
46
46
|
### Props
|
|
47
47
|
### Container
|
|
48
48
|
The one content edge: every page's width and side padding. This file is the only place they are defined, so a header, a page and a footer inside a Container start at the same x.
|
|
49
|
-
- as: "nav" | "header" | "footer" | "
|
|
49
|
+
- as: "nav" | "header" | "footer" | "main" | "div" | "section" (default div). The element: `div`, `main`, `header`, `footer`, `section` or `nav`.
|
|
50
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
50
51
|
- ref: Ref<HTMLElement>. Reaches the rendered element, for a parent that measures or scrolls it.
|
|
@@ -14,11 +14,10 @@ When to use: A value the page already shows that a reader will paste elsewhere.
|
|
|
14
14
|
import { CopyButton } from "@slashsuite/ui-react";
|
|
15
15
|
|
|
16
16
|
<CopyButton text="hc_live_9f2c41" label="Copy token" copiedLabel="Token copied" />
|
|
17
|
-
|
|
18
17
|
```
|
|
19
18
|
|
|
20
19
|
### Do
|
|
21
|
-
- `text` is what is copied; `copiedLabel` shows in place of the label for two seconds once it is on the clipboard.
|
|
20
|
+
- `text` is what is copied; `copiedLabel` shows in place of the label for two seconds once it is on the clipboard, and `failedLabel` ("Failed") when the browser refuses the copy or has no clipboard.
|
|
22
21
|
- Name what is copied in `label` and `copiedLabel` (`"Copy token"`, `"Token copied"`) when the page has more than one.
|
|
23
22
|
- A command or token in its own box is a `CopyLine`, which carries this button.
|
|
24
23
|
- Place a `CopyButton` yourself only when neither a `CopyLine` nor `copy` on a `CodeBlock` or `CodeExample` fits.
|
|
@@ -44,13 +43,16 @@ import { Button } from "@slashsuite/ui-react";
|
|
|
44
43
|
|
|
45
44
|
### Accessibility
|
|
46
45
|
- A native `<button>` with `type="button"` and a focus ring from the component.
|
|
47
|
-
- The accessible name is always `label`. A copy shows `copiedLabel` for two seconds and a polite status region beside the button announces it, again on every
|
|
48
|
-
-
|
|
46
|
+
- The accessible name is always `label`. A copy shows `copiedLabel` (or `failedLabel`) for two seconds and a polite status region beside the button announces it, again on every press; the region empties when the label goes back.
|
|
47
|
+
- The button is at least 24px square, the WCAG minimum target.
|
|
48
|
+
- No `<style>` element: the two seconds are a Web Animation, so the label works under a strict, nonce-based CSP.
|
|
49
49
|
|
|
50
50
|
### Props
|
|
51
51
|
### CopyButton
|
|
52
|
-
Writes `text` to the clipboard and shows `copiedLabel` for two seconds, then `label` again. Defaults to `type="button"
|
|
52
|
+
Writes `text` to the clipboard and shows `copiedLabel` for two seconds, then `label` again; a refused or missing clipboard shows `failedLabel` instead. Defaults to `type="button"` and is at least 24px square. Its accessible name stays `label`; a polite status region beside it announces `copiedLabel` or `failedLabel` on each press and empties again when the label goes back. Every other button prop, `disabled` included, goes on the `<button>`. Nothing is styled by a `<style>` element, so it works under a strict CSP. On a page rendered to static HTML without hydration, inline `copyScript` and the button works there too.
|
|
53
53
|
- copiedLabel: string (default Copied). The text shown for two seconds once the copy has gone through, and announced.
|
|
54
|
+
- failedLabel: string (default Failed). The text shown for two seconds when the browser refuses the copy or has no clipboard, and
|
|
55
|
+
announced. Keep it about as long as `copiedLabel`, since the button is as wide as the longest.
|
|
54
56
|
- label: string (default Copy). The button's text, and its accessible name.
|
|
55
57
|
- text: string (required). What goes on the clipboard.
|
|
56
58
|
|
|
@@ -13,12 +13,12 @@ One command or token to paste: `CopyLine` is the box and the copy button togethe
|
|
|
13
13
|
```tsx
|
|
14
14
|
import { CopyLine } from "@slashsuite/ui-react";
|
|
15
15
|
|
|
16
|
-
<CopyLine text="bun add @slashsuite/ui-react" />
|
|
17
|
-
|
|
16
|
+
<CopyLine text="bun add @slashsuite/ui-react" label="install command" />
|
|
18
17
|
```
|
|
19
18
|
|
|
20
19
|
### Do
|
|
21
20
|
- Give the whole line as `text`; the box shows it and the button copies it.
|
|
21
|
+
- Say what the line is in `label` (`"install command"`, `"API token"`): the button is named "Copy install command", so two lines on one page are told apart. It still reads "Copy".
|
|
22
22
|
- Several lines are a `CodeBlock`; `CopyLine` is one line.
|
|
23
23
|
- A long token wraps inside the box.
|
|
24
24
|
- `disabled` disables the button, for a line shown before the page is interactive.
|
|
@@ -38,17 +38,18 @@ import { Cluster, Code, CopyButton } from "@slashsuite/ui-react";
|
|
|
38
38
|
```tsx
|
|
39
39
|
import { CopyLine } from "@slashsuite/ui-react";
|
|
40
40
|
|
|
41
|
-
<CopyLine text={"bun install\nbun run build"} />
|
|
41
|
+
<CopyLine text={"bun install\nbun run build"} label="commands" />
|
|
42
42
|
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
### Accessibility
|
|
46
46
|
- The text is a `<code>` element, so a reader can select it by hand as well.
|
|
47
|
-
- The button is a `CopyButton`: a native button named `
|
|
47
|
+
- The button is a `CopyButton`: a native button named "Copy" and `label`, whose status region announces "Copied" (or "Failed") after each press.
|
|
48
48
|
|
|
49
49
|
### Props
|
|
50
50
|
### CopyLine
|
|
51
|
-
One line of mono text in a box, with a `CopyButton`: a command or a token to paste elsewhere. `disabled` disables the button, e.g. until hydration. An `id`, `data-*` and `aria-*` go on the root `<div>`, so `data-testid` lands there; the `<code>` holds only `text`.
|
|
51
|
+
One line of mono text in a box, with a `CopyButton`: a command or a token to paste elsewhere. `label` says what the line is, and the button is named "Copy <label>" (it still reads "Copy"), so several lines on a page can be told apart. `disabled` disables the button, e.g. until hydration. An `id`, `data-*` and `aria-*` go on the root `<div>`, so `data-testid` lands there; the `<code>` holds only `text`.
|
|
52
52
|
- disabled: boolean. Disables the copy button, e.g. until hydration.
|
|
53
53
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
54
|
+
- label: string (required). What the line is, in a few lower-case words ("install command", "API token"): the copy button's accessible name is "Copy " and this.
|
|
54
55
|
- text: string (required). The line shown, and what the button copies.
|
|
@@ -9,18 +9,17 @@ When to use: Any date a person enters; leave `calendar` off for a date the perso
|
|
|
9
9
|
import { DateField } from "@slashsuite/ui-react";
|
|
10
10
|
|
|
11
11
|
<DateField calendar label="Date of birth" hint="As on your ID document." />
|
|
12
|
-
|
|
13
12
|
```
|
|
14
13
|
|
|
15
14
|
### Do
|
|
16
|
-
- A date is a `DateField`, never an `Input`.
|
|
15
|
+
- A date is a `DateField`, never an `Input`. It follows the browser's locale: 11/29/2026 in en-US, 29/11/2026 in en-GB. `locale` (a BCP 47 tag) sets another for the order, the month names and the messages; `name` posts `YYYY-MM-DD` whatever the locale. The calendar's weeks start on Monday.
|
|
17
16
|
- `calendar` adds a calendar button, and `defaultOpen` opens it on mount; without `calendar` the field is typed only, for a date the person knows by heart (a birthday).
|
|
18
17
|
- It draws its own label: give it `label` and `hint`, and do not wrap it in a `Field`.
|
|
19
18
|
- A message from outside, a server's say, is `error`: it marks the field invalid and replaces the hint. An impossible date, such as 31/02/1990, shows its own message.
|
|
20
19
|
- The value is a `CalendarDate` (`value`, `defaultValue`, `onChange`, `minValue`, `maxValue`). `fromISODate` reads a stored `YYYY-MM-DD` and `toISODate` writes one.
|
|
21
20
|
- `name` posts the date as `YYYY-MM-DD` in a form, or an empty string.
|
|
22
21
|
- `size` is `sm`, `md` (default) or `lg`, the same heights as `Input`. `disabled` and `required` work as on an `Input`; say why it is disabled in its `hint`.
|
|
23
|
-
- With `calendar`, `monthLabel` and `yearLabel` name the month and year dropdowns, for an app in another language.
|
|
22
|
+
- With `calendar`, `monthLabel` and `yearLabel` name the month and year dropdowns and `clearLabel` the Clear button, for an app in another language.
|
|
24
23
|
|
|
25
24
|
### Don't
|
|
26
25
|
A text input takes any characters, so 17/5/90, 1990-05-17 and "May" all arrive, and nothing says which is meant.
|
|
@@ -36,7 +35,6 @@ A hint where the error belongs: the field is never marked invalid and the reader
|
|
|
36
35
|
import { DateField } from "@slashsuite/ui-react";
|
|
37
36
|
|
|
38
37
|
<DateField calendar label="Paid on" hint="The day the money moved." />
|
|
39
|
-
|
|
40
38
|
```
|
|
41
39
|
|
|
42
40
|
A stored date written by hand from its parts drops the leading zeros (2026-10-6). `toISODate` writes the one `YYYY-MM-DD` form.
|
|
@@ -61,8 +59,7 @@ A calendar for a date the person knows by heart makes them page back decades. A
|
|
|
61
59
|
```tsx
|
|
62
60
|
import { DateField } from "@slashsuite/ui-react";
|
|
63
61
|
|
|
64
|
-
<DateField calendar label="Date of birth" hint="
|
|
65
|
-
|
|
62
|
+
<DateField calendar label="Date of birth" hint="As on your ID document." />
|
|
66
63
|
```
|
|
67
64
|
|
|
68
65
|
### Accessibility
|
|
@@ -74,27 +71,33 @@ import { DateField } from "@slashsuite/ui-react";
|
|
|
74
71
|
|
|
75
72
|
### Props
|
|
76
73
|
### DateField
|
|
77
|
-
A segmented DD / MM / YYYY
|
|
74
|
+
A segmented date input, in the order of its `locale` (by default the browser's): DD / MM / YYYY in en-GB. Values are `CalendarDate`s; `name` posts it as `YYYY-MM-DD`. `calendar` adds a calendar button that opens a month view in a popover, at the same height as the plain field; `defaultOpen` opens it on mount. While `loading` the label is drawn and the field is a bone of its height.
|
|
78
75
|
- calendar: boolean. Adds a calendar button that opens a month view in a popover; the field is a date picker.
|
|
76
|
+
- clearLabel: string (default Clear). The calendar's footer button that empties the field, for an app in another language. Only a `calendar` field takes `clearLabel`.
|
|
79
77
|
- defaultOpen: boolean. Open the calendar on mount. Only a `calendar` field takes `defaultOpen`.
|
|
80
78
|
- defaultValue: CalendarDate | null. The date it starts with, uncontrolled.
|
|
81
79
|
- disabled: boolean. Disables the field: no typing, no calendar.
|
|
82
|
-
- error: ReactNode. Marks the field invalid and shows this in red
|
|
80
|
+
- error: ReactNode. Marks the field invalid and shows this in red under the hint, announced politely, in place of
|
|
83
81
|
the built-in message (an impossible date, or one outside min/max). Like `Field`'s `error`.
|
|
84
|
-
- hint: ReactNode. A muted line under the field that says more; an error
|
|
82
|
+
- hint: ReactNode. A muted line under the field that says more; it stays while an error shows under it.
|
|
85
83
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
86
84
|
- label: ReactNode. The field's visible label, above it. Without one, name the field with `aria-label`.
|
|
87
85
|
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
88
86
|
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
89
87
|
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
88
|
+
- locale: string. The locale the field writes its date in, a BCP 47 tag: `en-GB` is DD/MM/YYYY, `en-US`
|
|
89
|
+
MM/DD/YYYY, `en-ZA` YYYY/MM/DD. It sets the order of the segments, the month names, the
|
|
90
|
+
calendar's first weekday and the dates in its messages. Without it the field follows the app's
|
|
91
|
+
own `I18nProvider`, or else the browser's language.
|
|
90
92
|
- maxValue: DateValue | null. The latest date allowed: a later one marks the field invalid with its own message.
|
|
91
93
|
- minValue: DateValue | null. The earliest date allowed: an earlier one marks the field invalid with its own message.
|
|
92
94
|
- monthLabel: string (default Month). The month dropdown's name, for an app in another language. Only a `calendar` field takes `monthLabel`.
|
|
93
|
-
- name: string. Posts the date in a form as `YYYY-MM-DD` under this key, or an empty string
|
|
95
|
+
- name: string. Posts the date in a form as `YYYY-MM-DD` under this key, or an empty string, whatever the `locale`.
|
|
94
96
|
- onChange: ((value: CalendarDate | null) => void). Called with the new date, or `null` when the field is cleared or the date is incomplete.
|
|
95
97
|
- required: boolean. Marks a date required: the field is `aria-required`, and an empty one is invalid.
|
|
96
|
-
- size:
|
|
98
|
+
- size: Size | ResponsiveSize (default md). The field's height and text, on the same scale as an `Input`: `sm` is `text-sm`, `md` `text-base`,
|
|
97
99
|
`lg` `text-lg`, one step down under an `AppShell density="compact"`, and never under 16px on touch.
|
|
100
|
+
`{ base: "md", md: "lg" }` changes size at the `md` breakpoint (48rem), in CSS, as an `Input`'s does.
|
|
98
101
|
- value: CalendarDate | null. The date shown, controlled, with `onChange`; `null` is an empty field.
|
|
99
102
|
- yearLabel: string (default Year). The year dropdown's name, for an app in another language. Only a `calendar` field takes `yearLabel`.
|
|
100
103
|
|
|
@@ -39,9 +39,7 @@ function Example() {
|
|
|
39
39
|
presets={presets}
|
|
40
40
|
/>
|
|
41
41
|
<Caption>
|
|
42
|
-
{period
|
|
43
|
-
? `From ${toISODate(period.start)} to ${toISODate(period.end)}.`
|
|
44
|
-
: "No period yet."}
|
|
42
|
+
{period ? `From ${toISODate(period.start)} to ${toISODate(period.end)}.` : "No period yet."}
|
|
45
43
|
</Caption>
|
|
46
44
|
</Stack>
|
|
47
45
|
);
|
|
@@ -52,7 +50,7 @@ function Example() {
|
|
|
52
50
|
- A from and to date is one `DateRangePicker`, never two `DateField`s. A single date is a `DateField`.
|
|
53
51
|
- The value is `{ start, end }` of `CalendarDate`s, or `null`. It is reported only when both sides are complete, real dates within `minValue` and `maxValue` and the start is on or before the end; anything else reports `null` and the field says why. `startName` and `endName` post each side as `YYYY-MM-DD` in a form, or an empty string while there is no range.
|
|
54
52
|
- Presets come from the app: build "Last 7 days", "Last 30 days" and "Last 90 days" from the app's own today (`today(getLocalTimeZone())` from `@internationalized/date`) and pass them as `presets`. The picker has none of its own and never reads the clock. A preset sets the range and closes the calendar.
|
|
55
|
-
- It draws its own label: give it `label` and `hint`, and do not wrap it in a `Field`. `error`, `size`, `disabled`, `required`, `monthLabel` and `yearLabel` work as on `DateField`.
|
|
53
|
+
- It draws its own label: give it `label` and `hint`, and do not wrap it in a `Field`. `error`, `size`, `disabled`, `required`, `locale`, `monthLabel` and `yearLabel` work as on `DateField`.
|
|
56
54
|
|
|
57
55
|
### Don't
|
|
58
56
|
Two `DateField`s do not know about each other: nothing stops an end before the start, and there is no one press for "Last 30 days".
|
|
@@ -66,23 +64,29 @@ import { Cluster, DateField, fromISODate } from "@slashsuite/ui-react";
|
|
|
66
64
|
```
|
|
67
65
|
|
|
68
66
|
### Accessibility
|
|
69
|
-
- Each side is a `role="group"` named "Start date" and "End date", of
|
|
67
|
+
- Each side is a `role="group"` named "Start date" and "End date" (`startLabel` and `endLabel` rename them, and `toLabel` the "to" between them; `clearLabel` the calendar's Clear), of day, month and year segments in the order of the locale (`role="spinbutton"`) that take digits or the arrow keys.
|
|
70
68
|
- The calendar button is labelled "Calendar" and opens a popover dialog: the arrow keys move across days, Enter on a day starts the range and Enter on a second ends it, and Escape closes it without a change.
|
|
71
69
|
- An impossible day, such as 31/02/2026, keeps what was typed and says which side and why: "End date: February 2026 has 28 days."
|
|
72
70
|
- Inside a `Dialog` or `Drawer` the calendar opens inside it, so it still takes focus. The focus ring comes from the component.
|
|
73
71
|
|
|
74
72
|
### Props
|
|
75
73
|
### DateRangePicker
|
|
76
|
-
A from and to date in one field
|
|
74
|
+
A from and to date in one field, each side in the locale's order, and a calendar button that opens one Monday-first month, where two presses pick the range. `presets` adds the app's ready-made ranges above the month. The range is reported only when both sides are complete, real dates within min/max and the start is on or before the end; otherwise `null`.
|
|
75
|
+
- clearLabel: string (default Clear). The calendar's footer button that empties the range.
|
|
77
76
|
- defaultOpen: boolean. Open the calendar on mount.
|
|
78
77
|
- defaultValue: { start: CalendarDate; end: CalendarDate } | null. The range shown first when the picker holds its own value.
|
|
79
78
|
- disabled: boolean. Disables the field: no typing, no calendar.
|
|
79
|
+
- endLabel: string (default End date). The name of the end date's segments, for a screen reader.
|
|
80
80
|
- endName: string. Posts the end as `YYYY-MM-DD` in a form, or `""` while there is no range.
|
|
81
|
-
- error: ReactNode. Marks the field invalid and shows this in red
|
|
81
|
+
- error: ReactNode. Marks the field invalid and shows this in red under the hint, announced politely, in place of
|
|
82
82
|
the built-in message (an impossible date, or one outside min/max). Like `Field`'s `error`.
|
|
83
|
-
- hint: ReactNode. A muted line under the field that says more; an error
|
|
83
|
+
- hint: ReactNode. A muted line under the field that says more; it stays while an error shows under it.
|
|
84
84
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
85
85
|
- label: ReactNode. The field's visible label, above it. Without one, name the field with `aria-label`.
|
|
86
|
+
- locale: string. The locale the field writes its date in, a BCP 47 tag: `en-GB` is DD/MM/YYYY, `en-US`
|
|
87
|
+
MM/DD/YYYY, `en-ZA` YYYY/MM/DD. It sets the order of the segments, the month names, the
|
|
88
|
+
calendar's first weekday and the dates in its messages. Without it the field follows the app's
|
|
89
|
+
own `I18nProvider`, or else the browser's language.
|
|
86
90
|
- maxValue: DateValue | null. The latest date allowed: a later one marks the field invalid with its own message.
|
|
87
91
|
- minValue: DateValue | null. The earliest date allowed: an earlier one marks the field invalid with its own message.
|
|
88
92
|
- monthLabel: string (default Month). The month dropdown's name, for an app in another language.
|
|
@@ -90,9 +94,12 @@ the built-in message (an impossible date, or one outside min/max). Like `Field`'
|
|
|
90
94
|
- presets: readonly DateRangePreset[]. Ready-made ranges, a row of buttons above the month. The app builds them from its own today;
|
|
91
95
|
the picker has none of its own and never reads the clock.
|
|
92
96
|
- required: boolean. Marks a date required: the field is `aria-required`, and an empty one is invalid.
|
|
93
|
-
- size:
|
|
97
|
+
- size: Size | ResponsiveSize (default md). The field's height and text, on the same scale as an `Input`: `sm` is `text-sm`, `md` `text-base`,
|
|
94
98
|
`lg` `text-lg`, one step down under an `AppShell density="compact"`, and never under 16px on touch.
|
|
99
|
+
`{ base: "md", md: "lg" }` changes size at the `md` breakpoint (48rem), in CSS, as an `Input`'s does.
|
|
100
|
+
- startLabel: string (default Start date). The name of the start date's segments, for a screen reader.
|
|
95
101
|
- startName: string. Posts the start as `YYYY-MM-DD` in a form, or `""` while there is no range.
|
|
102
|
+
- toLabel: string (default to). The word between the two dates.
|
|
96
103
|
- value: { start: CalendarDate; end: CalendarDate } | null. The range, or `null` for none. Reported only when both days are complete, real and in order.
|
|
97
104
|
- yearLabel: string (default Year). The year dropdown's name, for an app in another language.
|
|
98
105
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
## DateTimeField
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: A moment a person enters: a booking, a meeting's start, a deadline with its hour.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A date with its time is one `DateTimeField`: one label, one value, posted as `YYYY-MM-DDTHH:mm`.
|
|
9
|
+
```tsx
|
|
10
|
+
import { DateTimeField, fromISODateTime } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<DateTimeField
|
|
13
|
+
label="Starts at"
|
|
14
|
+
hint="Your local time."
|
|
15
|
+
name="startsAt"
|
|
16
|
+
defaultValue={fromISODateTime("2026-11-29T14:05")}
|
|
17
|
+
/>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Do
|
|
21
|
+
- A date with its time is one `DateTimeField`, never a `DateField` beside an `Input`. A date alone is a `DateField`.
|
|
22
|
+
- The clock follows the locale: 24-hour in en-GB, AM/PM in en-US. `locale` sets another, as on `DateField`.
|
|
23
|
+
- The value is a `CalendarDateTime`. `name` posts `YYYY-MM-DDTHH:mm` on the 24-hour clock, or an empty string; `fromISODateTime` reads that string and `toISODateTime` writes one.
|
|
24
|
+
- It has no calendar. `label`, `hint`, `error`, `minValue`, `maxValue`, `required`, `disabled`, `size` and `loading` work as on `DateField`.
|
|
25
|
+
|
|
26
|
+
### Don't
|
|
27
|
+
A date field beside a text input: the time takes any characters, and the two halves are checked and posted apart.
|
|
28
|
+
```tsx
|
|
29
|
+
import { DateField, Input, Stack } from "@slashsuite/ui-react";
|
|
30
|
+
|
|
31
|
+
<Stack gap="sm">
|
|
32
|
+
<DateField label="Starts on" />
|
|
33
|
+
<Input aria-label="Starts at" placeholder="14:05" />
|
|
34
|
+
</Stack>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Accessibility
|
|
38
|
+
- The label names a `role="group"` of day, month, year, hour and minute segments (and AM/PM where the locale has it), each a `role="spinbutton"` that takes digits or the arrow keys.
|
|
39
|
+
- A required field partly filled blocks the form and says "Enter the whole date and time."
|
|
40
|
+
- The focus ring comes from the component.
|
|
41
|
+
|
|
42
|
+
### Props
|
|
43
|
+
### DateTimeField
|
|
44
|
+
A segmented date and time input, to the minute: the date in the order of its `locale` (by default the browser's), then hours and minutes on the clock the locale uses, 24-hour in en-GB and with AM/PM in en-US. Values are `CalendarDateTime`s; `name` posts it as `YYYY-MM-DDTHH:mm`. It has no calendar. While `loading` the label is drawn and the field is a bone of its height.
|
|
45
|
+
- defaultValue: CalendarDateTime | null. The date and time shown first when the field holds its own value.
|
|
46
|
+
- disabled: boolean. Disables the field: no typing, no calendar.
|
|
47
|
+
- error: ReactNode. Marks the field invalid and shows this in red under the hint, announced politely, in place of
|
|
48
|
+
the built-in message (an impossible date, or one outside min/max). Like `Field`'s `error`.
|
|
49
|
+
- hint: ReactNode. A muted line under the field that says more; it stays while an error shows under it.
|
|
50
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
51
|
+
- label: ReactNode. The field's visible label, above it. Without one, name the field with `aria-label`.
|
|
52
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
53
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
54
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
55
|
+
- locale: string. The locale the field writes its date in, a BCP 47 tag: `en-GB` is DD/MM/YYYY, `en-US`
|
|
56
|
+
MM/DD/YYYY, `en-ZA` YYYY/MM/DD. It sets the order of the segments, the month names, the
|
|
57
|
+
calendar's first weekday and the dates in its messages. Without it the field follows the app's
|
|
58
|
+
own `I18nProvider`, or else the browser's language.
|
|
59
|
+
- maxValue: DateValue | null. The latest date and time the field takes; later ones are invalid.
|
|
60
|
+
- minValue: DateValue | null. The earliest date and time the field takes; earlier ones are invalid.
|
|
61
|
+
- name: string. Posts the date and time in a form as `YYYY-MM-DDTHH:mm` (24-hour) under this key, or an empty
|
|
62
|
+
string, whatever the `locale`.
|
|
63
|
+
- onChange: ((value: CalendarDateTime | null) => void). Called with the date and time once every segment is filled, the day exists and it is within
|
|
64
|
+
`minValue`/`maxValue`, and with `null` when it stops being one.
|
|
65
|
+
- required: boolean. Marks a date required: the field is `aria-required`, and an empty one is invalid.
|
|
66
|
+
- size: Size | ResponsiveSize (default md). The field's height and text, on the same scale as an `Input`: `sm` is `text-sm`, `md` `text-base`,
|
|
67
|
+
`lg` `text-lg`, one step down under an `AppShell density="compact"`, and never under 16px on touch.
|
|
68
|
+
`{ base: "md", md: "lg" }` changes size at the `md` breakpoint (48rem), in CSS, as an `Input`'s does.
|
|
69
|
+
- value: CalendarDateTime | null. The date and time shown, controlled, with `onChange`; `null` is an empty field.
|
|
70
|
+
|
|
71
|
+
### Functions
|
|
72
|
+
- fromISODateTime: `fromISODateTime(iso: string | null | undefined): CalendarDateTime | null`. Reads a stored `"YYYY-MM-DDTHH:mm"` into a `CalendarDateTime`; `null` for an empty, malformed or impossible string.
|
|
73
|
+
- toISODateTime: `toISODateTime(value: CalendarDateTime | null | undefined): string`. Writes a `CalendarDateTime` as `"YYYY-MM-DDTHH:mm"`, or `""` for none.
|