@slashsuite/ui-react 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/agent-docs/components/app-shell.md +136 -0
- package/agent-docs/components/avatar-stack.md +64 -0
- package/agent-docs/components/avatar.md +76 -0
- package/agent-docs/components/badge.md +61 -0
- package/agent-docs/components/body-text.md +158 -0
- package/agent-docs/components/bottom-sheet.md +95 -0
- package/agent-docs/components/breadcrumbs.md +62 -0
- package/agent-docs/components/bullet-list.md +54 -0
- package/agent-docs/components/button.md +135 -0
- package/agent-docs/components/callout.md +86 -0
- package/agent-docs/components/card-grid.md +108 -0
- package/agent-docs/components/card.md +113 -0
- package/agent-docs/components/centered-layout.md +90 -0
- package/agent-docs/components/chat-composer.md +48 -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 +75 -0
- package/agent-docs/components/cluster.md +106 -0
- package/agent-docs/components/code-example.md +48 -0
- package/agent-docs/components/code.md +70 -0
- package/agent-docs/components/colour-scheme-toggle.md +92 -0
- package/agent-docs/components/container.md +50 -0
- package/agent-docs/components/copy-button.md +61 -0
- package/agent-docs/components/copy-line.md +54 -0
- package/agent-docs/components/date-field.md +103 -0
- package/agent-docs/components/date-range-picker.md +101 -0
- package/agent-docs/components/detail-layout.md +147 -0
- package/agent-docs/components/dialog.md +178 -0
- package/agent-docs/components/disclosure.md +66 -0
- package/agent-docs/components/divider.md +62 -0
- package/agent-docs/components/docs-layout.md +160 -0
- package/agent-docs/components/drawer.md +128 -0
- package/agent-docs/components/empty-state.md +67 -0
- package/agent-docs/components/field-dialog.md +97 -0
- package/agent-docs/components/field.md +68 -0
- package/agent-docs/components/fieldset.md +82 -0
- package/agent-docs/components/file-drop.md +52 -0
- package/agent-docs/components/form-layout.md +141 -0
- package/agent-docs/components/form-row.md +93 -0
- package/agent-docs/components/full-bleed-layout.md +116 -0
- package/agent-docs/components/headings.md +101 -0
- package/agent-docs/components/hero.md +59 -0
- package/agent-docs/components/icon-button.md +92 -0
- package/agent-docs/components/icon.md +66 -0
- package/agent-docs/components/image.md +64 -0
- package/agent-docs/components/input.md +83 -0
- package/agent-docs/components/kbd.md +38 -0
- package/agent-docs/components/key-value-list.md +81 -0
- package/agent-docs/components/lightbox.md +97 -0
- package/agent-docs/components/list-layout.md +154 -0
- package/agent-docs/components/list-row.md +116 -0
- package/agent-docs/components/loading.md +69 -0
- package/agent-docs/components/markdown.md +51 -0
- package/agent-docs/components/media-tile.md +97 -0
- package/agent-docs/components/menu.md +103 -0
- package/agent-docs/components/meta-list.md +69 -0
- package/agent-docs/components/morph.md +128 -0
- package/agent-docs/components/navigation-progress.md +56 -0
- package/agent-docs/components/outline-region.md +63 -0
- package/agent-docs/components/page-fade.md +116 -0
- package/agent-docs/components/page-header.md +93 -0
- package/agent-docs/components/pagination.md +64 -0
- package/agent-docs/components/pill.md +104 -0
- package/agent-docs/components/progress-bar.md +66 -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 +74 -0
- package/agent-docs/components/scroll-strip.md +48 -0
- package/agent-docs/components/segmented-control.md +133 -0
- package/agent-docs/components/select.md +65 -0
- package/agent-docs/components/show.md +120 -0
- package/agent-docs/components/side-column.md +70 -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 +67 -0
- package/agent-docs/components/sortable-list.md +107 -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 +88 -0
- package/agent-docs/components/stat-tile.md +69 -0
- package/agent-docs/components/status-pages.md +105 -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.md +373 -0
- package/agent-docs/components/tabs.md +180 -0
- package/agent-docs/components/text-link.md +105 -0
- package/agent-docs/components/textarea.md +51 -0
- package/agent-docs/components/timeline.md +79 -0
- package/agent-docs/components/toast.md +86 -0
- package/agent-docs/components/trend-chart.md +61 -0
- package/agent-docs/components/video.md +44 -0
- package/agent-docs/llms.txt +155 -0
- package/package.json +6 -3
- package/skills/uislash/SKILL.md +20 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
## Container
|
|
2
|
+
|
|
3
|
+
Group: Layout
|
|
4
|
+
|
|
5
|
+
When to use: Content outside an `AppShell`, such as a band in a `bleed` shell, that must start at the same x as the page.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
One `Container` is the content edge: everything inside it starts at the same x.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Card, Container, Text } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<Container as="section" aria-label="Billing">
|
|
13
|
+
<Card title="Plan">
|
|
14
|
+
<Text>Team, billed monthly.</Text>
|
|
15
|
+
</Card>
|
|
16
|
+
</Container>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Do
|
|
20
|
+
- `Container` is the only place the page width (`max-w-6xl`) and side padding are defined; a header, a page and a footer inside one start at the same x.
|
|
21
|
+
- `AppShell` already wraps its header, main and footer in one. Use `Container` only for a part of a `bleed` shell that spans the page, so its content still keeps the edge.
|
|
22
|
+
- `as` picks the element: `div` (default), `main`, `header`, `footer`, `section` or `nav`. A `section` or `nav` needs an `aria-label`.
|
|
23
|
+
- Space inside it with a `Stack`; a `Container` has no vertical padding or gap of its own.
|
|
24
|
+
- `ref` reaches the rendered element, for a parent that measures or scrolls it.
|
|
25
|
+
|
|
26
|
+
### Don't
|
|
27
|
+
- Never nest a `Container` in a `Container`: the padding doubles.
|
|
28
|
+
|
|
29
|
+
A `Container` inside a `Container` pads the content twice, so it no longer lines up with the page. `AppShell` already wraps its main in one.
|
|
30
|
+
```tsx
|
|
31
|
+
import { Card, Container, Text } from "@slashsuite/ui-react";
|
|
32
|
+
|
|
33
|
+
<Container as="section" aria-label="Billing">
|
|
34
|
+
<Container>
|
|
35
|
+
<Card title="Plan">
|
|
36
|
+
<Text>Team, billed monthly.</Text>
|
|
37
|
+
</Card>
|
|
38
|
+
</Container>
|
|
39
|
+
</Container>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Accessibility
|
|
43
|
+
- A `Container` adds no role: a `div` is not a landmark. `as` picks `main`, `header`, `footer`, `section` or `nav` when the part should be one.
|
|
44
|
+
- `aria-*` and `data-*` go on the rendered element.
|
|
45
|
+
|
|
46
|
+
### Props
|
|
47
|
+
### Container
|
|
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" | "div" | "main" | "section" (default div). The element: `div`, `main`, `header`, `footer`, `section` or `nav`.
|
|
50
|
+
- ref: Ref<HTMLElement>. Reaches the rendered element, for a parent that measures or scrolls it.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
## CopyButton
|
|
2
|
+
|
|
3
|
+
Group: Actions
|
|
4
|
+
|
|
5
|
+
When to use: A value the page already shows that a reader will paste elsewhere.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- CopyLine (copy-line.md): The text to copy is one line, such as a command.
|
|
9
|
+
- Code (code.md): The text to copy is a block of code: `CodeBlock copy`, or `CodeExample copy` in docs.
|
|
10
|
+
|
|
11
|
+
### The one right way
|
|
12
|
+
`CopyButton` writes `text` to the clipboard and swaps its label to `copiedLabel`.
|
|
13
|
+
```tsx
|
|
14
|
+
import { CopyButton } from "@slashsuite/ui-react";
|
|
15
|
+
|
|
16
|
+
<CopyButton text="hc_live_9f2c41" label="Copy token" copiedLabel="Token copied" />
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Do
|
|
21
|
+
- `text` is what is copied; `copiedLabel` shows in place of the label for two seconds once it is on the clipboard.
|
|
22
|
+
- Name what is copied in `label` and `copiedLabel` (`"Copy token"`, `"Token copied"`) when the page has more than one.
|
|
23
|
+
- A command or token in its own box is a `CopyLine`, which carries this button.
|
|
24
|
+
- Place a `CopyButton` yourself only when neither a `CopyLine` nor `copy` on a `CodeBlock` or `CodeExample` fits.
|
|
25
|
+
- On a page rendered to static HTML and never hydrated, inline `copyScript` once, as `colourSchemeScript` is: every `CopyButton`, `CopyLine`, and `CodeBlock` or `CodeExample` with `copy` then works. A hydrated button copies for itself and the script stays out of its way.
|
|
26
|
+
|
|
27
|
+
### Don't
|
|
28
|
+
- Do not write the clipboard call by hand in a `Button`.
|
|
29
|
+
|
|
30
|
+
A hand-rolled copy Button gives no feedback and does not survive a refused clipboard.
|
|
31
|
+
```tsx
|
|
32
|
+
import { Button } from "@slashsuite/ui-react";
|
|
33
|
+
|
|
34
|
+
<Button
|
|
35
|
+
variant="ghost"
|
|
36
|
+
size="sm"
|
|
37
|
+
onClick={() => {
|
|
38
|
+
void navigator.clipboard.writeText("hc_live_9f2c41");
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
Copy token
|
|
42
|
+
</Button>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Accessibility
|
|
46
|
+
- 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 copy.
|
|
48
|
+
- A refused or missing clipboard leaves the label unchanged; nothing is announced.
|
|
49
|
+
|
|
50
|
+
### Props
|
|
51
|
+
### CopyButton
|
|
52
|
+
Writes `text` to the clipboard and shows `copiedLabel` for two seconds, then `label` again. Defaults to `type="button"`. Its accessible name stays `label`; a polite status region beside it announces `copiedLabel` on each copy. A refused or missing clipboard leaves it on `label`. Every other button prop, `disabled` included, goes on the `<button>`. On a page rendered to static HTML without hydration, inline `copyScript` and the button works there too.
|
|
53
|
+
- copiedLabel: string (default Copied). The text shown for two seconds once the copy has gone through, and announced.
|
|
54
|
+
- label: string (default Copy). The button's text, and its accessible name.
|
|
55
|
+
- text: string (required). What goes on the clipboard.
|
|
56
|
+
|
|
57
|
+
### Functions
|
|
58
|
+
- copyScript: `copyScript: string`. A string of JavaScript to inline once on a page rendered to static HTML: one click listener on `document` that makes every copy button work without hydration.
|
|
59
|
+
```tsx
|
|
60
|
+
<script is:inline set:html={copyScript} />
|
|
61
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
## CopyLine
|
|
2
|
+
|
|
3
|
+
Group: Actions
|
|
4
|
+
|
|
5
|
+
When to use: A command or token a reader pastes elsewhere.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- CopyButton (copy-button.md): Neither a line nor a code block fits, so the button is placed by hand.
|
|
9
|
+
- Code (code.md): The text is a block of several lines: `CodeBlock copy`.
|
|
10
|
+
|
|
11
|
+
### The one right way
|
|
12
|
+
One command or token to paste: `CopyLine` is the box and the copy button together.
|
|
13
|
+
```tsx
|
|
14
|
+
import { CopyLine } from "@slashsuite/ui-react";
|
|
15
|
+
|
|
16
|
+
<CopyLine text="bun add @slashsuite/ui-react" />
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Do
|
|
21
|
+
- Give the whole line as `text`; the box shows it and the button copies it.
|
|
22
|
+
- Several lines are a `CodeBlock`; `CopyLine` is one line.
|
|
23
|
+
- A long token wraps inside the box.
|
|
24
|
+
- `disabled` disables the button, for a line shown before the page is interactive.
|
|
25
|
+
|
|
26
|
+
### Don't
|
|
27
|
+
Inline code beside a loose `CopyButton` is two parts that drift apart; the text can differ from what is copied.
|
|
28
|
+
```tsx
|
|
29
|
+
import { Cluster, Code, CopyButton } from "@slashsuite/ui-react";
|
|
30
|
+
|
|
31
|
+
<Cluster>
|
|
32
|
+
<Code>bun add @slashsuite/ui-react</Code>
|
|
33
|
+
<CopyButton text="bun add @slashsuite/ui-react" />
|
|
34
|
+
</Cluster>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`CopyLine` is one line of text: a newline in it collapses into a space and the box runs on.
|
|
38
|
+
```tsx
|
|
39
|
+
import { CopyLine } from "@slashsuite/ui-react";
|
|
40
|
+
|
|
41
|
+
<CopyLine text={"bun install\nbun run build"} />
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Accessibility
|
|
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 `Copy`, whose status region announces `Copied` after each copy.
|
|
48
|
+
|
|
49
|
+
### Props
|
|
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`.
|
|
52
|
+
- disabled: boolean. Disables the copy button, e.g. until hydration.
|
|
53
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
54
|
+
- text: string (required). The line shown, and what the button copies.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
## DateField
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: Any date a person enters; leave `calendar` off for a date the person knows by heart.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
```tsx
|
|
9
|
+
import { DateField } from "@slashsuite/ui-react";
|
|
10
|
+
|
|
11
|
+
<DateField calendar label="Date of birth" hint="As on your ID document." />
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Do
|
|
16
|
+
- A date is a `DateField`, never an `Input`. The format is always DD/MM/YYYY and weeks start on Monday, whatever the browser's locale.
|
|
17
|
+
- `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
|
+
- It draws its own label: give it `label` and `hint`, and do not wrap it in a `Field`.
|
|
19
|
+
- 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
|
+
- The value is a `CalendarDate` (`value`, `defaultValue`, `onChange`, `minValue`, `maxValue`). `fromISODate` reads a stored `YYYY-MM-DD` and `toISODate` writes one.
|
|
21
|
+
- `name` posts the date as `YYYY-MM-DD` in a form, or an empty string.
|
|
22
|
+
- `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.
|
|
24
|
+
|
|
25
|
+
### Don't
|
|
26
|
+
A text input takes any characters, so 17/5/90, 1990-05-17 and "May" all arrive, and nothing says which is meant.
|
|
27
|
+
```tsx
|
|
28
|
+
import { Input } from "@slashsuite/ui-react";
|
|
29
|
+
|
|
30
|
+
<Input aria-label="Date of birth" placeholder="DD/MM/YYYY" />
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
A hint where the error belongs: the field is never marked invalid and the reader is not told what is wrong. A rejected date takes `error` with the reason.
|
|
35
|
+
```tsx
|
|
36
|
+
import { DateField } from "@slashsuite/ui-react";
|
|
37
|
+
|
|
38
|
+
<DateField calendar label="Paid on" hint="The day the money moved." />
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
A stored date written by hand from its parts drops the leading zeros (2026-10-6). `toISODate` writes the one `YYYY-MM-DD` form.
|
|
43
|
+
```tsx
|
|
44
|
+
import { Caption, DateField, fromISODate, Stack } from "@slashsuite/ui-react";
|
|
45
|
+
import { useState } from "react";
|
|
46
|
+
|
|
47
|
+
function Example() {
|
|
48
|
+
const [paid, setPaid] = useState(fromISODate("2026-10-06"));
|
|
49
|
+
return (
|
|
50
|
+
<Stack gap="xs">
|
|
51
|
+
<DateField calendar label="Paid on" value={paid} onChange={setPaid} />
|
|
52
|
+
<Caption>
|
|
53
|
+
Stored as {paid ? `${paid.year}-${paid.month}-${paid.day}` : "nothing yet"}.
|
|
54
|
+
</Caption>
|
|
55
|
+
</Stack>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
A calendar for a date the person knows by heart makes them page back decades. A birthday is typed: leave `calendar` out.
|
|
61
|
+
```tsx
|
|
62
|
+
import { DateField } from "@slashsuite/ui-react";
|
|
63
|
+
|
|
64
|
+
<DateField calendar label="Date of birth" hint="DD/MM/YYYY" />
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Accessibility
|
|
69
|
+
- The label names a `role="group"`; each of day, month and year is its own editable segment (`role="spinbutton"`), so a person can type digits or use the arrow keys.
|
|
70
|
+
- The `hint` is the field's `aria-describedby`; the `error` and the built-in messages replace it, and an `error` is `role="alert"`.
|
|
71
|
+
- With `calendar`, the calendar button is labelled "Calendar" and opens a popover dialog, with a month and a year select (named by `monthLabel` and `yearLabel`), arrow-key movement across days and a Clear button.
|
|
72
|
+
- Inside a `Dialog` or `Drawer` the calendar opens inside it, so it still takes focus.
|
|
73
|
+
- The focus ring comes from the component.
|
|
74
|
+
|
|
75
|
+
### Props
|
|
76
|
+
### DateField
|
|
77
|
+
A segmented DD / MM / YYYY date input. 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
|
+
- calendar: boolean. Adds a calendar button that opens a month view in a popover; the field is a date picker.
|
|
79
|
+
- defaultOpen: boolean. Open the calendar on mount. Only a `calendar` field takes `defaultOpen`.
|
|
80
|
+
- defaultValue: CalendarDate | null. The date it starts with, uncontrolled.
|
|
81
|
+
- disabled: boolean. Disables the field: no typing, no calendar.
|
|
82
|
+
- error: ReactNode. Marks the field invalid and shows this in red with `role="alert"`, in place of the hint and of
|
|
83
|
+
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 replaces it.
|
|
85
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
86
|
+
- label: ReactNode. The field's visible label, above it. Without one, name the field with `aria-label`.
|
|
87
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
88
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
89
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
90
|
+
- maxValue: DateValue | null. The latest date allowed: a later one marks the field invalid with its own message.
|
|
91
|
+
- minValue: DateValue | null. The earliest date allowed: an earlier one marks the field invalid with its own message.
|
|
92
|
+
- 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.
|
|
94
|
+
- onChange: ((value: CalendarDate | null) => void). Called with the new date, or `null` when the field is cleared or the date is incomplete.
|
|
95
|
+
- required: boolean. Marks a date required: the field is `aria-required`, and an empty one is invalid.
|
|
96
|
+
- size: "sm" | "md" | "lg" (default md). The field's height and text, on the same scale as an `Input`: `sm` is `text-sm`, `md` `text-base`,
|
|
97
|
+
`lg` `text-lg`, one step down under an `AppShell density="compact"`, and never under 16px on touch.
|
|
98
|
+
- value: CalendarDate | null. The date shown, controlled, with `onChange`; `null` is an empty field.
|
|
99
|
+
- yearLabel: string (default Year). The year dropdown's name, for an app in another language. Only a `calendar` field takes `yearLabel`.
|
|
100
|
+
|
|
101
|
+
### Functions
|
|
102
|
+
- fromISODate: `fromISODate(iso: string | null | undefined): CalendarDate | null`. Reads a stored `"YYYY-MM-DD"` into the `CalendarDate` a picker takes; `null` for an empty, malformed or impossible string.
|
|
103
|
+
- toISODate: `toISODate(date: CalendarDate | null | undefined): string`. Writes a `CalendarDate` as `"YYYY-MM-DD"`, or `""` for none, so it drops into a form field or storage.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
## DateRangePicker
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: A from and to date: a report period, a timeline filter.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A from and to date is one `DateRangePicker`, with the app's presets built from its own today.
|
|
9
|
+
```tsx
|
|
10
|
+
import {
|
|
11
|
+
Caption,
|
|
12
|
+
DateRangePicker,
|
|
13
|
+
DateRange,
|
|
14
|
+
fromISODate,
|
|
15
|
+
Stack,
|
|
16
|
+
toISODate,
|
|
17
|
+
} from "@slashsuite/ui-react";
|
|
18
|
+
import { useState } from "react";
|
|
19
|
+
|
|
20
|
+
function Example() {
|
|
21
|
+
const today = fromISODate("2026-10-31");
|
|
22
|
+
const presets = today
|
|
23
|
+
? [7, 30, 90].map((days) => ({
|
|
24
|
+
label: `Last ${days} days`,
|
|
25
|
+
value: { start: today.subtract({ days: days - 1 }), end: today },
|
|
26
|
+
}))
|
|
27
|
+
: [];
|
|
28
|
+
const [period, setPeriod] = useState<DateRange | null>(
|
|
29
|
+
today ? { start: today.set({ day: 1 }), end: today } : null,
|
|
30
|
+
);
|
|
31
|
+
return (
|
|
32
|
+
<Stack gap="xs">
|
|
33
|
+
<DateRangePicker
|
|
34
|
+
label="Report period"
|
|
35
|
+
startName="from"
|
|
36
|
+
endName="to"
|
|
37
|
+
value={period}
|
|
38
|
+
onChange={setPeriod}
|
|
39
|
+
presets={presets}
|
|
40
|
+
/>
|
|
41
|
+
<Caption>
|
|
42
|
+
{period
|
|
43
|
+
? `From ${toISODate(period.start)} to ${toISODate(period.end)}.`
|
|
44
|
+
: "No period yet."}
|
|
45
|
+
</Caption>
|
|
46
|
+
</Stack>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Do
|
|
52
|
+
- A from and to date is one `DateRangePicker`, never two `DateField`s. A single date is a `DateField`.
|
|
53
|
+
- 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
|
+
- 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`.
|
|
56
|
+
|
|
57
|
+
### Don't
|
|
58
|
+
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".
|
|
59
|
+
```tsx
|
|
60
|
+
import { Cluster, DateField, fromISODate } from "@slashsuite/ui-react";
|
|
61
|
+
|
|
62
|
+
<Cluster gap="sm">
|
|
63
|
+
<DateField calendar label="From" defaultValue={fromISODate("2026-10-02")} />
|
|
64
|
+
<DateField calendar label="To" defaultValue={fromISODate("2026-10-31")} />
|
|
65
|
+
</Cluster>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Accessibility
|
|
69
|
+
- Each side is a `role="group"` named "Start date" and "End date", of DD, MM and YYYY segments (`role="spinbutton"`) that take digits or the arrow keys.
|
|
70
|
+
- 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
|
+
- 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
|
+
- Inside a `Dialog` or `Drawer` the calendar opens inside it, so it still takes focus. The focus ring comes from the component.
|
|
73
|
+
|
|
74
|
+
### Props
|
|
75
|
+
### DateRangePicker
|
|
76
|
+
A from and to date in one field: DD/MM/YYYY "to" DD/MM/YYYY 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`.
|
|
77
|
+
- defaultOpen: boolean. Open the calendar on mount.
|
|
78
|
+
- defaultValue: { start: CalendarDate; end: CalendarDate } | null. The range shown first when the picker holds its own value.
|
|
79
|
+
- disabled: boolean. Disables the field: no typing, no calendar.
|
|
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 with `role="alert"`, in place of the hint and of
|
|
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 replaces it.
|
|
84
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
85
|
+
- label: ReactNode. The field's visible label, above it. Without one, name the field with `aria-label`.
|
|
86
|
+
- maxValue: DateValue | null. The latest date allowed: a later one marks the field invalid with its own message.
|
|
87
|
+
- minValue: DateValue | null. The earliest date allowed: an earlier one marks the field invalid with its own message.
|
|
88
|
+
- monthLabel: string (default Month). The month dropdown's name, for an app in another language.
|
|
89
|
+
- onChange: ((range: { start: CalendarDate; end: CalendarDate } | null) => void). Called with the range once both sides make one, and with `null` when they stop making one.
|
|
90
|
+
- presets: readonly DateRangePreset[]. Ready-made ranges, a row of buttons above the month. The app builds them from its own today;
|
|
91
|
+
the picker has none of its own and never reads the clock.
|
|
92
|
+
- required: boolean. Marks a date required: the field is `aria-required`, and an empty one is invalid.
|
|
93
|
+
- size: "sm" | "md" | "lg" (default md). The field's height and text, on the same scale as an `Input`: `sm` is `text-sm`, `md` `text-base`,
|
|
94
|
+
`lg` `text-lg`, one step down under an `AppShell density="compact"`, and never under 16px on touch.
|
|
95
|
+
- startName: string. Posts the start as `YYYY-MM-DD` in a form, or `""` while there is no range.
|
|
96
|
+
- value: { start: CalendarDate; end: CalendarDate } | null. The range, or `null` for none. Reported only when both days are complete, real and in order.
|
|
97
|
+
- yearLabel: string (default Year). The year dropdown's name, for an app in another language.
|
|
98
|
+
|
|
99
|
+
### Types
|
|
100
|
+
- DateRange: `{ start: CalendarDate; end: CalendarDate }`. A from and to date: `start` on or before `end`.
|
|
101
|
+
- DateRangePreset: `{ label: string; value: DateRange }`. A ready-made range the app builds from its own today, such as "Last 7 days".
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
## DetailLayout
|
|
2
|
+
|
|
3
|
+
Group: Page layouts
|
|
4
|
+
|
|
5
|
+
When to use: One quote, build or member, with its content in the main column and its facts in the aside.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
The record's content is the main column; the facts about it go in `aside`.
|
|
9
|
+
```tsx
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
Card,
|
|
13
|
+
DetailLayout,
|
|
14
|
+
KeyValue,
|
|
15
|
+
KeyValueList,
|
|
16
|
+
Text,
|
|
17
|
+
} from "@slashsuite/ui-react";
|
|
18
|
+
|
|
19
|
+
<DetailLayout
|
|
20
|
+
title="Quote Q-1042"
|
|
21
|
+
description="Naledi Mokoena"
|
|
22
|
+
actions={<Button variant="outline">Edit</Button>}
|
|
23
|
+
aside={
|
|
24
|
+
<Card title="Details">
|
|
25
|
+
<KeyValueList>
|
|
26
|
+
<KeyValue label="Status">Sent</KeyValue>
|
|
27
|
+
<KeyValue label="Premium">R 1 240 / mo</KeyValue>
|
|
28
|
+
</KeyValueList>
|
|
29
|
+
</Card>
|
|
30
|
+
}
|
|
31
|
+
>
|
|
32
|
+
<Card title="Cover">
|
|
33
|
+
<Text>Life cover of R 1 500 000, to age 65.</Text>
|
|
34
|
+
</Card>
|
|
35
|
+
</DetailLayout>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Full page
|
|
39
|
+
A whole record page: the shell with its brand and nav, then the layout with the record in `children` and its facts in `aside`.
|
|
40
|
+
```tsx
|
|
41
|
+
import {
|
|
42
|
+
AppShell,
|
|
43
|
+
Button,
|
|
44
|
+
Card,
|
|
45
|
+
DetailLayout,
|
|
46
|
+
KeyValue,
|
|
47
|
+
KeyValueList,
|
|
48
|
+
Tabs,
|
|
49
|
+
Text,
|
|
50
|
+
} from "@slashsuite/ui-react";
|
|
51
|
+
|
|
52
|
+
<AppShell
|
|
53
|
+
brand={<a href="#">Hack Cove</a>}
|
|
54
|
+
nav={
|
|
55
|
+
<Tabs
|
|
56
|
+
label="Main"
|
|
57
|
+
items={[
|
|
58
|
+
{ label: "Quotes", href: "#quotes", selected: true },
|
|
59
|
+
{ label: "Clients", href: "#clients" },
|
|
60
|
+
]}
|
|
61
|
+
/>
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
<DetailLayout
|
|
65
|
+
title="Quote Q-1042"
|
|
66
|
+
description="Naledi Mokoena"
|
|
67
|
+
actions={<Button variant="outline">Edit</Button>}
|
|
68
|
+
aside={
|
|
69
|
+
<Card title="Details">
|
|
70
|
+
<KeyValueList>
|
|
71
|
+
<KeyValue label="Status">Sent</KeyValue>
|
|
72
|
+
<KeyValue label="Premium">R 1 240 / mo</KeyValue>
|
|
73
|
+
</KeyValueList>
|
|
74
|
+
</Card>
|
|
75
|
+
}
|
|
76
|
+
>
|
|
77
|
+
<Card title="Cover">
|
|
78
|
+
<Text>Life cover of R 1 500 000, to age 65.</Text>
|
|
79
|
+
</Card>
|
|
80
|
+
<Card title="Notes">
|
|
81
|
+
<Text>The client asked to be debited on the 25th.</Text>
|
|
82
|
+
</Card>
|
|
83
|
+
</DetailLayout>
|
|
84
|
+
</AppShell>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Do
|
|
88
|
+
- The record's content is the `children`, in the main two thirds; they are spaced as a `Stack`, so give each block its own `Card`.
|
|
89
|
+
- The facts about the record go in `aside`, in the third beside it: a `Card` with a `KeyValueList`, a status, the people on it.
|
|
90
|
+
- Both columns are required: with nothing for the aside, use `ListLayout`.
|
|
91
|
+
- From `lg` the aside sits beside the content; below it, it stacks under the content.
|
|
92
|
+
- `sticky` keeps the aside in view from `lg` as a long page scrolls: it sticks under the shell's header, and an aside taller than the room left scrolls inside itself, so its end stays reachable. Leave it off when the aside is ordinary cards that may be taller than the screen; below `lg` it stacks either way.
|
|
93
|
+
- `asideLabel` names the aside's landmark. Set it when the page has another complementary landmark (a `SidebarLayout` rail, a `FullBleedLayout` panel), so a screen reader can tell them apart. It only names the aside; `DetailLayout` never folds it.
|
|
94
|
+
- The header props are the same as `ListLayout`: `breadcrumbs`, `title`, `description`, `actions`, `tabs`.
|
|
95
|
+
|
|
96
|
+
### Don't
|
|
97
|
+
`ListLayout` has no aside, so the facts become one more block under the content. Use `DetailLayout` for a record.
|
|
98
|
+
```tsx
|
|
99
|
+
import {
|
|
100
|
+
Button,
|
|
101
|
+
Card,
|
|
102
|
+
KeyValue,
|
|
103
|
+
KeyValueList,
|
|
104
|
+
ListLayout,
|
|
105
|
+
Text,
|
|
106
|
+
} from "@slashsuite/ui-react";
|
|
107
|
+
|
|
108
|
+
<ListLayout
|
|
109
|
+
title="Quote Q-1042"
|
|
110
|
+
description="Naledi Mokoena"
|
|
111
|
+
actions={<Button variant="outline">Edit</Button>}
|
|
112
|
+
>
|
|
113
|
+
<Card title="Cover">
|
|
114
|
+
<Text>Life cover of R 1 500 000, to age 65.</Text>
|
|
115
|
+
</Card>
|
|
116
|
+
<Card title="Details">
|
|
117
|
+
<KeyValueList>
|
|
118
|
+
<KeyValue label="Status">Sent</KeyValue>
|
|
119
|
+
<KeyValue label="Premium">R 1 240 / mo</KeyValue>
|
|
120
|
+
</KeyValueList>
|
|
121
|
+
</Card>
|
|
122
|
+
</ListLayout>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Accessibility
|
|
126
|
+
- The title is the page's `h1`.
|
|
127
|
+
- The aside is an `<aside>`, a complementary landmark; the main column is a plain `div`.
|
|
128
|
+
- In the DOM the content comes first and the aside second, so that is the reading and tab order on every screen.
|
|
129
|
+
- With `sticky` a scrolling aside is still in the tab order, and a focus ring on a control in it is not cut off at its edge. An aside that scrolls and holds no link, field or button (plain text) takes one tab stop, named by `asideLabel`, so the keyboard can scroll it; an aside with a control in it takes none.
|
|
130
|
+
|
|
131
|
+
### Props
|
|
132
|
+
### DetailLayout
|
|
133
|
+
A detail page: header, then `children` (two thirds from `lg`) beside `aside` (one third), which stacks below on a smaller screen: a `SideColumn asideWidth="third"` under a `PageHeader`. `sticky` keeps the aside in view from `lg` as a long page scrolls: it sticks under AppShell's header and, if it is taller than the room left, scrolls itself so its end stays reachable. While `loading` it owns the wait and passes it to everything inside, the header too.
|
|
134
|
+
- actions: ReactNode. Right of the title on `sm` and up, below it on a phone.
|
|
135
|
+
- aside: ReactNode (required). The side column: one third from `lg`, below `children` on a smaller screen.
|
|
136
|
+
- asideLabel: string. Names the aside's landmark (`aria-label`), so a page with another complementary landmark can tell them apart. It does not fold the aside. Left out, the aside is unnamed.
|
|
137
|
+
- breadcrumbs: ReactNode. A `Breadcrumbs` above the title.
|
|
138
|
+
- description: ReactNode. The lede under the title: a `Lead`, so it outranks the body text after it.
|
|
139
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
140
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
141
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
142
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
143
|
+
- sticky: boolean (default false). From `lg`, keeps the aside in view under the header as the page scrolls; an aside taller than
|
|
144
|
+
the screen scrolls inside itself. Off by default, since an aside of ordinary cards may be
|
|
145
|
+
taller than the screen. Below `lg` the aside stacks as ever.
|
|
146
|
+
- tabs: ReactNode. A `Tabs` (or similar) under the title.
|
|
147
|
+
- title: ReactNode (required). The page's `h1`.
|