@slashsuite/ui-react 0.11.3 → 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.
Files changed (96) hide show
  1. package/README.md +14 -1
  2. package/agent-docs/components/app-shell.md +136 -0
  3. package/agent-docs/components/avatar-stack.md +64 -0
  4. package/agent-docs/components/avatar.md +76 -0
  5. package/agent-docs/components/badge.md +61 -0
  6. package/agent-docs/components/body-text.md +158 -0
  7. package/agent-docs/components/bottom-sheet.md +95 -0
  8. package/agent-docs/components/breadcrumbs.md +62 -0
  9. package/agent-docs/components/bullet-list.md +54 -0
  10. package/agent-docs/components/button.md +135 -0
  11. package/agent-docs/components/callout.md +86 -0
  12. package/agent-docs/components/card-grid.md +108 -0
  13. package/agent-docs/components/card.md +113 -0
  14. package/agent-docs/components/centered-layout.md +90 -0
  15. package/agent-docs/components/chat-composer.md +48 -0
  16. package/agent-docs/components/chat-message.md +61 -0
  17. package/agent-docs/components/chat-thread.md +49 -0
  18. package/agent-docs/components/checkbox.md +75 -0
  19. package/agent-docs/components/cluster.md +106 -0
  20. package/agent-docs/components/code-example.md +48 -0
  21. package/agent-docs/components/code.md +70 -0
  22. package/agent-docs/components/colour-scheme-toggle.md +92 -0
  23. package/agent-docs/components/container.md +50 -0
  24. package/agent-docs/components/copy-button.md +61 -0
  25. package/agent-docs/components/copy-line.md +54 -0
  26. package/agent-docs/components/date-field.md +103 -0
  27. package/agent-docs/components/date-range-picker.md +101 -0
  28. package/agent-docs/components/detail-layout.md +147 -0
  29. package/agent-docs/components/dialog.md +178 -0
  30. package/agent-docs/components/disclosure.md +66 -0
  31. package/agent-docs/components/divider.md +62 -0
  32. package/agent-docs/components/docs-layout.md +160 -0
  33. package/agent-docs/components/drawer.md +128 -0
  34. package/agent-docs/components/empty-state.md +67 -0
  35. package/agent-docs/components/field-dialog.md +97 -0
  36. package/agent-docs/components/field.md +68 -0
  37. package/agent-docs/components/fieldset.md +82 -0
  38. package/agent-docs/components/file-drop.md +52 -0
  39. package/agent-docs/components/form-layout.md +141 -0
  40. package/agent-docs/components/form-row.md +93 -0
  41. package/agent-docs/components/full-bleed-layout.md +116 -0
  42. package/agent-docs/components/headings.md +101 -0
  43. package/agent-docs/components/hero.md +59 -0
  44. package/agent-docs/components/icon-button.md +92 -0
  45. package/agent-docs/components/icon.md +66 -0
  46. package/agent-docs/components/image.md +64 -0
  47. package/agent-docs/components/input.md +83 -0
  48. package/agent-docs/components/kbd.md +38 -0
  49. package/agent-docs/components/key-value-list.md +81 -0
  50. package/agent-docs/components/lightbox.md +97 -0
  51. package/agent-docs/components/list-layout.md +154 -0
  52. package/agent-docs/components/list-row.md +116 -0
  53. package/agent-docs/components/loading.md +69 -0
  54. package/agent-docs/components/markdown.md +51 -0
  55. package/agent-docs/components/media-tile.md +97 -0
  56. package/agent-docs/components/menu.md +103 -0
  57. package/agent-docs/components/meta-list.md +69 -0
  58. package/agent-docs/components/morph.md +128 -0
  59. package/agent-docs/components/navigation-progress.md +56 -0
  60. package/agent-docs/components/outline-region.md +63 -0
  61. package/agent-docs/components/page-fade.md +116 -0
  62. package/agent-docs/components/page-header.md +93 -0
  63. package/agent-docs/components/pagination.md +64 -0
  64. package/agent-docs/components/pill.md +104 -0
  65. package/agent-docs/components/progress-bar.md +66 -0
  66. package/agent-docs/components/prose-layout.md +87 -0
  67. package/agent-docs/components/prose.md +41 -0
  68. package/agent-docs/components/radio-group.md +74 -0
  69. package/agent-docs/components/scroll-strip.md +48 -0
  70. package/agent-docs/components/segmented-control.md +133 -0
  71. package/agent-docs/components/select.md +65 -0
  72. package/agent-docs/components/show.md +120 -0
  73. package/agent-docs/components/side-column.md +70 -0
  74. package/agent-docs/components/sidebar-layout.md +134 -0
  75. package/agent-docs/components/site-footer.md +63 -0
  76. package/agent-docs/components/site-search.md +67 -0
  77. package/agent-docs/components/sortable-list.md +107 -0
  78. package/agent-docs/components/split-bar.md +54 -0
  79. package/agent-docs/components/stack.md +197 -0
  80. package/agent-docs/components/stacked-bar.md +88 -0
  81. package/agent-docs/components/stat-tile.md +69 -0
  82. package/agent-docs/components/status-pages.md +105 -0
  83. package/agent-docs/components/steps.md +74 -0
  84. package/agent-docs/components/sticky-bar.md +51 -0
  85. package/agent-docs/components/switch.md +79 -0
  86. package/agent-docs/components/table.md +373 -0
  87. package/agent-docs/components/tabs.md +180 -0
  88. package/agent-docs/components/text-link.md +105 -0
  89. package/agent-docs/components/textarea.md +51 -0
  90. package/agent-docs/components/timeline.md +79 -0
  91. package/agent-docs/components/toast.md +86 -0
  92. package/agent-docs/components/trend-chart.md +61 -0
  93. package/agent-docs/components/video.md +44 -0
  94. package/agent-docs/llms.txt +155 -0
  95. package/package.json +6 -3
  96. package/skills/uislash/SKILL.md +20 -0
@@ -0,0 +1,97 @@
1
+ ## FieldDialog
2
+
3
+ Group: Feedback
4
+
5
+ When to use: Asking for a single name or value: new project, rename, a label.
6
+
7
+ ### Use instead
8
+ - FormLayout (form-layout.md): The form has several fields and a page of its own.
9
+ - Dialog (dialog.md): More than one field, or a question with no field.
10
+ - Drawer (drawer.md): A record or a long form with several fields.
11
+
12
+ ### The one right way
13
+ One value to ask for is a `FieldDialog`: it blocks an empty submit, shows the busy state and puts a rejection under the field.
14
+ ```tsx
15
+ import { useState } from "react";
16
+ import { Button, FieldDialog } from "@slashsuite/ui-react";
17
+
18
+ function Example() {
19
+ const [open, setOpen] = useState(false);
20
+ return (
21
+ <>
22
+ <Button variant="outline" onClick={() => setOpen(true)}>
23
+ New project
24
+ </Button>
25
+ {open && (
26
+ <FieldDialog
27
+ title="New project"
28
+ description="Projects hold your builds and their reviews."
29
+ label="Name"
30
+ placeholder="my-project"
31
+ hint="Letters, numbers and dashes."
32
+ emptyReason="Type a name first."
33
+ submit="Create"
34
+ busyLabel="Creating…"
35
+ onSubmit={() => Promise.resolve()}
36
+ onClose={() => setOpen(false)}
37
+ />
38
+ )}
39
+ </>
40
+ );
41
+ }
42
+ ```
43
+
44
+ ### Do
45
+ - Render it only while it is open, and give every string it shows: `title`, `label`, `placeholder`, `hint`, `emptyReason`, `submit` and `busyLabel`, and a `description` under the title when the question needs a sentence.
46
+ - `onSubmit` gets the trimmed value and returns a promise. Resolving closes the dialog; rejecting shows the error message under the field and keeps the dialog open.
47
+ - More than one field is a `Dialog` with `onSubmit` holding its `Field`s, or a `Drawer`.
48
+
49
+ ### Don't
50
+ A `Dialog` with a hand-built field has no empty check, no busy state and no error line, and each copy drifts from the next.
51
+ ```tsx
52
+ import { useState } from "react";
53
+ import { Button, Dialog, Field, Input } 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
+ New project
61
+ </Button>
62
+ {open && (
63
+ <Dialog
64
+ title="New project"
65
+ onClose={() => setOpen(false)}
66
+ footer={<Button onClick={() => setOpen(false)}>Create</Button>}
67
+ >
68
+ <Field label="Name" htmlFor="project-name">
69
+ <Input id="project-name" placeholder="my-project" />
70
+ </Field>
71
+ </Dialog>
72
+ )}
73
+ </>
74
+ );
75
+ }
76
+ ```
77
+
78
+ ### Accessibility
79
+ - It is a `Dialog`: native `<dialog>`, page behind inert, focus kept inside, Esc closes, named by its `title`.
80
+ - The input has focus when it opens and is named by `label`.
81
+ - While the field is empty the submit button is disabled and its `emptyReason` is the button's title and the field's hint.
82
+ - While `onSubmit` is pending the button is busy (`aria-busy`); a rejection shows in the field's error line, which is `role="alert"`.
83
+
84
+ ### Props
85
+ ### FieldDialog
86
+ A `Dialog` with one text field and Cancel / submit buttons. Render it only while open.
87
+ - busyLabel: string (required). What the submit button says while `onSubmit` runs.
88
+ - description: string. A muted line under the title.
89
+ - emptyReason: string (required). Said when the field is empty and the submit button is blocked.
90
+ - hint: string (required). A muted line under the field; `emptyReason` takes its place while the field is empty.
91
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
92
+ - label: string (required). The visible label above the field, which names it.
93
+ - onClose: () => void (required). Called when the dialog closes: Cancel, Esc, the backdrop, or a resolved `onSubmit`.
94
+ - onSubmit: (value: string) => Promise<unknown> (required). Gets the trimmed value. Resolving closes the dialog; a rejection shows its message in it.
95
+ - placeholder: string (required). The field's placeholder.
96
+ - submit: string (required). The submit button's text.
97
+ - title: string (required). The dialog's heading and accessible name.
@@ -0,0 +1,68 @@
1
+ ## Field
2
+
3
+ Group: Forms
4
+
5
+ When to use: Every text, select or file control: it gets a label, visible unless its purpose is plain from what surrounds it.
6
+
7
+ ### The one right way
8
+ Every control sits in a `Field`, with no `htmlFor` and no `id`: the Field ties its label and hint to the control itself.
9
+ ```tsx
10
+ import { Field, Input } from "@slashsuite/ui-react";
11
+
12
+ <Field label="Display name" hint="Shown on your reviews.">
13
+ <Input />
14
+ </Field>
15
+ ```
16
+
17
+ ### Do
18
+ - Wrap every `Input`, `Textarea` and `Select` in a `Field`, with no `htmlFor` and no `id` on the control: the `Field` links its label, hint and error to the control itself, and the `label` is always in the accessibility tree. Pass `htmlFor` only when something else must name the control by a fixed id.
19
+ - `labelHidden` draws no label text but keeps it for assistive tech: use it only when the control's purpose is plain from what surrounds it (a search box in a toolbar). Otherwise leave the label visible; a placeholder is not a label. With `layout="row"` it draws as a column.
20
+ - A `hint` is the one line of help under the control.
21
+ - A validation message is `error`, not `hint`: it replaces the hint, in red.
22
+ - Inside a `FormGrid` a `Field` takes one column; `span="full"` runs it across both.
23
+ - A `Checkbox`, a `Switch`, a `RadioGroup` and a `DateField` draw their own `label` and note (a `hint`, or an `error` in its place); do not wrap them in a `Field`. A group of them is a `Fieldset`.
24
+ - `layout="row"` puts the label beside the control, for a compact setting or a drawer row: the hint or error sits under the control, and stacked rows line their controls up.
25
+
26
+ ### Don't
27
+ A placeholder is not a label: it vanishes as soon as the person types, and it names nothing for a screen reader.
28
+ ```tsx
29
+ import { Input } from "@slashsuite/ui-react";
30
+
31
+ <Input placeholder="Display name" />
32
+
33
+ ```
34
+
35
+ An error passed as the `hint` looks like help text: it is grey and is not announced.
36
+ ```tsx
37
+ import { Field, Input } from "@slashsuite/ui-react";
38
+
39
+ <Field label="Display name" hint="Pick a shorter name.">
40
+ <Input defaultValue="A very long display name indeed" />
41
+ </Field>
42
+ ```
43
+
44
+ ### Accessibility
45
+ - The label is a real `<label>` tied to the control, so clicking the text focuses the control and a screen reader reads it as the control's name.
46
+ - An `error` is a `<p role="alert">`, so it is announced when it appears. The hint is plain text.
47
+ - The control is described by the hint, or by the error when there is one, through `aria-describedby`, so a screen reader on the control hears it after the alert has gone by.
48
+ - An `error` marks the control `aria-invalid` and turns its edge red.
49
+
50
+ ### Props
51
+ ### Field
52
+ A label above a control, with a hint or an error line under it. An error replaces the hint. Inside a `FormGrid`, `span="full"` runs the field across both columns. The `Input`, `Select`, `Textarea` or `FileDrop` inside takes the label, the note (`aria-describedby`) and, with an error, `aria-invalid` and a red edge by itself: give it no `id` and the Field no `htmlFor`. While `loading` the label is drawn and the control is a bone of its height, read from the density around it (`sm` in a `sm` card or table).
53
+ - error: ReactNode. Replaces the hint when set.
54
+ - hint: ReactNode. A muted line under the control that says more.
55
+ - htmlFor: string. A fixed id for the control inside, only when something else must name it. Unset, the Field makes one.
56
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
57
+ - label: ReactNode (required). The text above the control.
58
+ - labelHidden: boolean (default false). Keeps the `label` in the page for assistive tech and draws no text, for a control whose purpose
59
+ is plain from what surrounds it (a search box in a toolbar). `label` stays required, so the
60
+ control always has a name. With `layout="row"` the field draws as a column: an empty label
61
+ column helps nobody.
62
+ - layout: "row" | "column" (default column). `row` puts the label beside the control, for a compact setting or a drawer row; the hint or
63
+ error sits under the control. Every row label takes the same fixed column, so stacked rows line
64
+ their controls up; a long label wraps inside it. `column` puts the label above it.
65
+ - loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
66
+ Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
67
+ - loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
68
+ - span: "full". `full` spans every column of a `FormGrid`; unset takes one. It does nothing outside a `FormGrid`.
@@ -0,0 +1,82 @@
1
+ ## Fieldset
2
+
3
+ Group: Forms
4
+
5
+ When to use: Several controls that answer one question or belong together, under one name.
6
+
7
+ ### Use instead
8
+ - Tabs (tabs.md): One choice switches the panel right under the row.
9
+ - SegmentedControl (segmented-control.md): Exactly one of two to five options is on: a mode or a range.
10
+ - Button (button.md): One toggle on its own, not a named group: a `Button` with `pressed`.
11
+
12
+ ### The one right way
13
+ Checkboxes for one question go in a `Fieldset`, so a screen reader hears the question on entering the group.
14
+ ```tsx
15
+ import { Checkbox, Fieldset } from "@slashsuite/ui-react";
16
+
17
+ <Fieldset label="What is wrong?">
18
+ <Checkbox label="Wrong opening hours" />
19
+ <Checkbox label="Closed for good" />
20
+ </Fieldset>
21
+ ```
22
+
23
+ ### Do
24
+ - Several checkboxes answering one question: a `Fieldset` with the `Checkbox`es straight inside.
25
+ - A set of fields that belong together (opening hours, a low and high pair): a `Fieldset` round `Field`s, in a `FormGrid` for a row.
26
+ - The filter chips of one facet: a `Fieldset` round a `ButtonGroup` of `variant="outline"` `size="sm"` `Button`s with `pressed`. One `Fieldset` per facet; stack several in a `Stack`.
27
+ - The `label` names the group in the `Field` label's look. A `hint` is one muted line under the group, and an `error` replaces it in red.
28
+ - One choice of several is a `RadioGroup`, which is its own group: never put it in a `Fieldset`. One control is a `Field`, or a `Checkbox` or `Switch` on its own.
29
+
30
+ ### Don't
31
+ Bold text over loose checkboxes looks like a group, but the question is not their name.
32
+ ```tsx
33
+ import { Checkbox, Stack, Text } from "@slashsuite/ui-react";
34
+
35
+ <Stack gap="xs">
36
+ <Text strong>What is wrong?</Text>
37
+ <Checkbox label="Wrong opening hours" />
38
+ <Checkbox label="Closed for good" />
39
+ </Stack>
40
+ ```
41
+
42
+ Chips with no group have no name: a screen reader hears a row of buttons and not what they filter.
43
+ ```tsx
44
+ import { Button, Cluster } from "@slashsuite/ui-react";
45
+
46
+ <Cluster gap="xs" wrap>
47
+ <Button variant="outline" size="sm" pressed>
48
+ Vintage
49
+ </Button>
50
+ <Button variant="outline" size="sm" pressed={false}>
51
+ Books
52
+ </Button>
53
+ <Button variant="outline" size="sm" pressed={false}>
54
+ Now
55
+ </Button>
56
+ </Cluster>
57
+ ```
58
+
59
+ A `RadioGroup` inside a `Fieldset` is two names for one question.
60
+ ```tsx
61
+ import { Fieldset, Radio, RadioGroup } from "@slashsuite/ui-react";
62
+
63
+ <Fieldset label="Detection">
64
+ <RadioGroup label="Kind" defaultValue="layout">
65
+ <Radio value="layout" label="Layout" />
66
+ <Radio value="colour" label="Colour" />
67
+ </RadioGroup>
68
+ </Fieldset>
69
+ ```
70
+
71
+ ### Accessibility
72
+ - A `<fieldset>` named by its `<legend>`, so a screen reader announces the group's name on entering it.
73
+ - The hint, or the error in its place, is the group's `aria-describedby`; the error is a `role="alert"` line, announced when it appears.
74
+ - `disabled` on the group disables every control in it.
75
+
76
+ ### Props
77
+ ### Fieldset
78
+ A labelled group of controls: several `Checkbox`es answering one question, a set of `Field`s that belong together, or the filter chips of one facet (a `ButtonGroup` of `outline` `sm` pressed `Button`s). It is a `<fieldset>` named by its `label`, drawn as its `<legend>` in the `Field` label's look, over the children in one column; a `ButtonGroup` or a `FormGrid` inside lays out a row. `hint` is a muted line under the group and its `aria-describedby`; `error` replaces it in red with `role="alert"`. `disabled` disables every control inside. One choice of several is a `RadioGroup`, never inside a `Fieldset`. Other props go on the `<fieldset>`.
79
+ - children: ReactNode. `Checkbox`es, `Field`s (in a `FormGrid` for a row), or a `ButtonGroup` of chips.
80
+ - error: ReactNode. A red line under the group, in place of the hint, announced as an alert.
81
+ - hint: ReactNode. A muted line under the group.
82
+ - label: ReactNode (required). The group's name, drawn as its `<legend>`.
@@ -0,0 +1,52 @@
1
+ ## FileDrop
2
+
3
+ Group: Forms
4
+
5
+ When to use: Uploading a file: a statement, a photo, an import.
6
+
7
+ ### The one right way
8
+ Name the file the zone wants in its prompt, restrict it with `accept`, and show the chosen file's name from `onChange`.
9
+ ```tsx
10
+ import { useState } from "react";
11
+ import { FileDrop } from "@slashsuite/ui-react";
12
+
13
+ function Example() {
14
+ const [name, setName] = useState("");
15
+ return (
16
+ <FileDrop accept=".csv" onChange={(event) => setName(event.target.files?.[0]?.name ?? "")}>
17
+ {name === "" ? "Drop a bank statement here or click to choose" : name}
18
+ </FileDrop>
19
+ );
20
+ }
21
+ ```
22
+
23
+ ### Do
24
+ - Say what the zone wants in its children, and restrict the type with `accept`.
25
+ - Show the chosen file's name in the children from `onChange`; the zone does not do it for you.
26
+ - `size="sm"` is a compact chip or tile, `size="lg"` a roomy drop zone; `md` is the default.
27
+ - `multiple`, `name` and `disabled` go on the zone like any file input; say why it is disabled in its `Field` hint.
28
+ - Put a `FileDrop` in a `Field` when it needs a label of its own above it.
29
+
30
+ ### Don't
31
+ A prompt that never changes leaves the person unsure the file was taken, and with no `accept` any file is.
32
+ ```tsx
33
+ import { FileDrop } from "@slashsuite/ui-react";
34
+
35
+ <FileDrop>Drop here</FileDrop>
36
+
37
+ ```
38
+
39
+ ### Accessibility
40
+ - A real `<input type="file">` covers the whole zone, invisible, so a click opens the file dialog, a dragged file is taken as by any file input, and the browser's keyboard handling applies.
41
+ - The zone is a `<label>`, so its children are the input's accessible name.
42
+ - The zone shows the keyboard focus ring while the input has focus.
43
+ - In a `Field`, the `Field` around it adds its label to the input's name and its hint or error as `aria-describedby`, and an error marks the input `aria-invalid` and turns the dashed edge red.
44
+
45
+ ### Props
46
+ ### FileDrop
47
+ A dashed drop zone around a file input. The input covers the whole zone, invisible, so a click opens the file dialog and a file dragged onto it is taken by the browser as it is by any file input. `children` is the prompt; show the chosen file's name there from `onChange`. The label also shows the keyboard focus ring, the input being invisible. Every prop (`accept`, `multiple`, `name`, `disabled`, `onChange`) goes on the input.
48
+ - accept: string (native). The file types it takes, as on `<input type="file">`: `"image/*"`, `".pdf"`.
49
+ - disabled: boolean (native). Disables the drop zone; say why in its `Field` hint.
50
+ - multiple: boolean (native). Takes several files at once.
51
+ - name: string (native). The key the files post under in a form.
52
+ - size: "sm" | "md" | "lg" (default md). `sm` is a compact chip or tile: dense padding; `lg` is one step roomier than `md`.
@@ -0,0 +1,141 @@
1
+ ## FormLayout
2
+
3
+ Group: Page layouts
4
+
5
+ When to use: Creating or editing a record on a page of its own.
6
+
7
+ ### Use instead
8
+ - FormRow (form-row.md): Fields sit side by side inside the form: a `FormGrid`, or a `FormRow` to edit one record on a line.
9
+ - Stack (stack.md): The form sits in a `Card` on a page that is not the form: `Stack as="form"`.
10
+ - FieldDialog (field-dialog.md): One text value is asked for over the page, such as a new name.
11
+
12
+ ### The one right way
13
+ The fields go in `children`; Save and Cancel go in `actions`, at the end of the form.
14
+ ```tsx
15
+ import { Button, Card, Field, FormLayout, Input, Stack } from "@slashsuite/ui-react";
16
+
17
+ <FormLayout
18
+ title="New client"
19
+ description="Who is the quote for?"
20
+ onSubmit={(event) => event.preventDefault()}
21
+ actions={
22
+ <>
23
+ <Button type="submit">Save client</Button>
24
+ <Button variant="ghost">Cancel</Button>
25
+ </>
26
+ }
27
+ >
28
+ <Card title="Client">
29
+ <Stack>
30
+ <Field label="Full name">
31
+ <Input placeholder="Naledi Mokoena" />
32
+ </Field>
33
+ <Field label="Email">
34
+ <Input type="email" placeholder="naledi@example.com" />
35
+ </Field>
36
+ </Stack>
37
+ </Card>
38
+ </FormLayout>
39
+ ```
40
+
41
+ ### Full page
42
+ A whole form page: the shell with its brand and nav, then the layout with the fields in `children` and Save and Cancel in `actions`.
43
+ ```tsx
44
+ import {
45
+ AppShell,
46
+ Button,
47
+ Card,
48
+ Field,
49
+ FormLayout,
50
+ Input,
51
+ Tabs,
52
+ Stack,
53
+ } from "@slashsuite/ui-react";
54
+
55
+ <AppShell
56
+ brand={<a href="#">Hack Cove</a>}
57
+ nav={
58
+ <Tabs
59
+ label="Main"
60
+ items={[
61
+ { label: "Quotes", href: "#quotes", selected: true },
62
+ { label: "Clients", href: "#clients" },
63
+ ]}
64
+ />
65
+ }
66
+ >
67
+ <FormLayout
68
+ title="New client"
69
+ description="Who is the quote for?"
70
+ onSubmit={(event) => event.preventDefault()}
71
+ actions={
72
+ <>
73
+ <Button type="submit">Save client</Button>
74
+ <Button variant="ghost">Cancel</Button>
75
+ </>
76
+ }
77
+ >
78
+ <Card title="Client">
79
+ <Stack>
80
+ <Field label="Full name">
81
+ <Input placeholder="Naledi Mokoena" />
82
+ </Field>
83
+ <Field label="Email">
84
+ <Input type="email" />
85
+ </Field>
86
+ </Stack>
87
+ </Card>
88
+ </FormLayout>
89
+ </AppShell>
90
+ ```
91
+
92
+ ### Do
93
+ - The fields are the `children`, grouped in `Card`s; the layout spaces them in a reading-width column.
94
+ - Save and Cancel go in `actions`, at the end of the form: a `type="submit"` Button first, then a ghost Cancel. The header has no `actions` here.
95
+ - Handle the submit with `onSubmit`: other props go on the `<form>` itself.
96
+ - A failed submit (the server refused it, no connection) is `error`: an alert directly above the `actions`. An error about one field is that `Field`'s `error`.
97
+ - A form in a small panel is a `Dialog` or `FieldDialog`; a sign-in is `CenteredLayout`.
98
+
99
+ ### Don't
100
+ - Do not put Save in the header of a `ListLayout`: that is not a form.
101
+
102
+ `ListLayout` is not a form: Save sits in the header, away from the fields, and nothing submits on Enter. Use `FormLayout`.
103
+ ```tsx
104
+ import { Button, Card, Field, Input, ListLayout, Stack } from "@slashsuite/ui-react";
105
+
106
+ <ListLayout
107
+ title="New client"
108
+ description="Who is the quote for?"
109
+ actions={<Button>Save client</Button>}
110
+ >
111
+ <Card title="Client">
112
+ <Stack>
113
+ <Field label="Full name">
114
+ <Input placeholder="Naledi Mokoena" />
115
+ </Field>
116
+ <Field label="Email">
117
+ <Input type="email" placeholder="naledi@example.com" />
118
+ </Field>
119
+ </Stack>
120
+ </Card>
121
+ </ListLayout>
122
+ ```
123
+
124
+ ### Accessibility
125
+ - The root is a real `<form>`: Enter in a field submits it, and a `type="submit"` Button submits it.
126
+ - The title is the page's `h1`.
127
+ - Give each control a `Field`, so every input has a label.
128
+
129
+ ### Props
130
+ ### FormLayout
131
+ A form page: header (no header `actions`), then a `max-w-3xl` column that starts at the Container's start edge (it is not re-centred), with an `actions` row at the end. `error` is the submit's failure, a danger `Callout` (an alert) directly above that row. Other props go on the `<form>`. While `loading` it owns the wait and passes it to everything inside, the header too.
132
+ - actions: ReactNode. The row at the end of the form: its submit and cancel buttons.
133
+ - breadcrumbs: ReactNode. A `Breadcrumbs` above the title.
134
+ - description: ReactNode. The lede under the title: a `Lead`, so it outranks the body text after it.
135
+ - error: ReactNode. What went wrong with the whole submit (the server refused it, no connection), announced as an
136
+ alert directly above the `actions`. An error about one field is that `Field`'s `error`.
137
+ - loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
138
+ Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
139
+ - loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
140
+ - tabs: ReactNode. A `Tabs` (or similar) under the title.
141
+ - title: ReactNode (required). The page's `h1`.
@@ -0,0 +1,93 @@
1
+ ## FormRow
2
+
3
+ Group: Forms
4
+
5
+ When to use: `FormGrid` lays Fields out in two columns; `FormRow` puts several controls and a save button on one line.
6
+
7
+ ### Use instead
8
+ - FormLayout (form-layout.md): The whole page is one form, with Save and Cancel at its end.
9
+ - Stack (stack.md): The fields run one under another in a `Card`: a `Stack as="form"` of `Field`s.
10
+
11
+ ### The one right way
12
+ A row of controls with proportional widths, `actions` after them, and one `hint` under the whole row.
13
+ ```tsx
14
+ import { Button, FormRow, FormRowField, Input } from "@slashsuite/ui-react";
15
+
16
+ <FormRow hint="Press Save to apply the change." actions={<Button>Save</Button>}>
17
+ <FormRowField label="Description" htmlFor="do-row-desc" span={3}>
18
+ <Input id="do-row-desc" defaultValue="Kitchen renovation" />
19
+ </FormRowField>
20
+ <FormRowField label="Amount" htmlFor="do-row-amount">
21
+ <Input id="do-row-amount" defaultValue="12,400.00" numeric />
22
+ </FormRowField>
23
+ </FormRow>
24
+ ```
25
+
26
+ ### Do
27
+ - A form of several fields is a `FormGrid` of `Field`s: two columns from `md`, one below. A long control, such as a `Textarea`, takes `span="full"`.
28
+ - A line of controls to edit one record in place is a `FormRow` of `FormRowField`s, with the save `Button` as `actions`.
29
+ - `FormRowField` `span` 1 to 4 is its share of the row's width.
30
+ - The `hint` or `error` goes on the `FormRow`, once, under the whole line. A `FormRowField` has no hint or error, and a `Field` does not belong inside a `FormRow`.
31
+ - A `FormRow` inside a `FormGrid` runs across both columns.
32
+
33
+ ### Don't
34
+ A `Field` with its own hint inside a `FormRow` makes its column taller, so the controls drift out of line and the save button with them.
35
+ ```tsx
36
+ import { Button, Field, FormRow, Input } from "@slashsuite/ui-react";
37
+
38
+ <FormRow actions={<Button>Save</Button>}>
39
+ <Field label="Description" htmlFor="dont-row-desc" hint="Shown on the invoice.">
40
+ <Input id="dont-row-desc" defaultValue="Kitchen renovation" />
41
+ </Field>
42
+ <Field label="Amount" htmlFor="dont-row-amount">
43
+ <Input id="dont-row-amount" defaultValue="12,400.00" numeric />
44
+ </Field>
45
+ </FormRow>
46
+ ```
47
+
48
+ Without `span="full"` a `Textarea` takes half the width and leaves a hole beside it.
49
+ ```tsx
50
+ import { Field, FormGrid, Input, Textarea } from "@slashsuite/ui-react";
51
+
52
+ <FormGrid>
53
+ <Field label="First name" htmlFor="dont-grid-first">
54
+ <Input id="dont-grid-first" />
55
+ </Field>
56
+ <Field label="Last name" htmlFor="dont-grid-last">
57
+ <Input id="dont-grid-last" />
58
+ </Field>
59
+ <Field label="Notes" htmlFor="dont-grid-notes">
60
+ <Textarea id="dont-grid-notes" />
61
+ </Field>
62
+ </FormGrid>
63
+ ```
64
+
65
+ ### Accessibility
66
+ - `FormRowField` renders a `<label>` tied to its control by `htmlFor`, as `Field` does.
67
+ - The row's `error` is a `<p role="alert">`.
68
+ - Under `md` the fields and the action stack in reading order.
69
+
70
+ ### Props
71
+ ### FormRow
72
+ An inline-edit row: several controls side by side with proportional widths (`FormRowField` `span` 1 to 4), optional `actions` after them (a save button), and one `hint` or `error` line under the whole row. Every control sits on the bottom edge, so the actions line up with them whatever the labels do. Under `md` the fields and the actions stack. The row owns the note, so the fields beside each other keep their height: a `FormRowField` has no `hint` or `error` of its own.
73
+ - actions: ReactNode. A button or two after the last field. It keeps its own width.
74
+ - error: ReactNode. Replaces the hint when set, as `Field`'s does.
75
+ - hint: ReactNode. One muted line under the whole row.
76
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
77
+
78
+ ### FormRowField
79
+ A compact label over one control, for a `FormRow`. `span` is its share of the row (1 default). While `loading` the label is drawn and the control is a bone of its height, as in a `Field`.
80
+ - htmlFor: string (required). The id of the control inside; the label's htmlFor.
81
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
82
+ - label: ReactNode (required). The small label above the control.
83
+ - loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
84
+ Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
85
+ - loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
86
+ - span: 2 | 3 | 4 | 1 (default 1). The field's share of the row, 1 to 4: a `span` of 2 is twice as wide as a 1.
87
+
88
+ ### FormGrid
89
+ Two columns of `Field`s from `md`, one below it. A `Field` takes one column; `span="full"` runs it across both, and a `FormRow` is always full width.
90
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
91
+
92
+ ### Types
93
+ - FormRowSpan: `1 | 2 | 3 | 4`. Relative widths in a `FormRow`: a field of `span` 2 is twice as wide as one of `span` 1.
@@ -0,0 +1,116 @@
1
+ ## FullBleedLayout
2
+
3
+ Group: Page layouts
4
+
5
+ When to use: A viewer that needs the whole width, such as a snapshot, a canvas or a player; an ordinary page is not.
6
+
7
+ ### The one right way
8
+ A viewer that needs the whole width (a snapshot, a canvas, a player) fills it, with the facts in the `aside`.
9
+ ```tsx
10
+ import {
11
+ Button,
12
+ FullBleedLayout,
13
+ KeyValue,
14
+ KeyValueList,
15
+ Overline,
16
+ Text,
17
+ } from "@slashsuite/ui-react";
18
+
19
+ <FullBleedLayout
20
+ aside={
21
+ <>
22
+ <Overline as="h2">Snapshot</Overline>
23
+ <KeyValueList>
24
+ <KeyValue label="Story">Button / Primary</KeyValue>
25
+ <KeyValue label="Changed">0.4%</KeyValue>
26
+ </KeyValueList>
27
+ </>
28
+ }
29
+ >
30
+ <Text>The snapshot fills the width.</Text>
31
+ </FullBleedLayout>
32
+ ```
33
+
34
+ ### Full page
35
+ A whole viewer page: the shell with `bleed`, then the layout with the viewer in `children` and the facts in `aside`. The `EmptyState` stands in for the app's own viewer.
36
+ ```tsx
37
+ import {
38
+ AppShell,
39
+ Button,
40
+ EmptyState,
41
+ FullBleedLayout,
42
+ KeyValue,
43
+ KeyValueList,
44
+ Tabs,
45
+ Overline,
46
+ Text,
47
+ } from "@slashsuite/ui-react";
48
+
49
+ <AppShell
50
+ brand={<a href="#">Hack Cove</a>}
51
+ nav={
52
+ <Tabs
53
+ label="Main"
54
+ items={[
55
+ { label: "Quotes", href: "#quotes", selected: true },
56
+ { label: "Clients", href: "#clients" },
57
+ ]}
58
+ />
59
+ }
60
+ bleed
61
+ >
62
+ <FullBleedLayout
63
+ aside={
64
+ <>
65
+ <Overline as="h2">Snapshot</Overline>
66
+ <KeyValueList>
67
+ <KeyValue label="Story">Button / Primary</KeyValue>
68
+ <KeyValue label="Changed">0.4%</KeyValue>
69
+ </KeyValueList>
70
+ </>
71
+ }
72
+ >
73
+ <EmptyState title="Snapshot viewer">
74
+ <Text>Your viewer goes here and fills the width.</Text>
75
+ </EmptyState>
76
+ </FullBleedLayout>
77
+ </AppShell>
78
+ ```
79
+
80
+ ### Do
81
+ - Render it in an `AppShell` with `bleed`; the canvas starts at the viewport's start edge.
82
+ - It adds no padding and has no page title; the canvas is the `children`. Set `padded` when the body is not a viewer and should have the other layouts' page padding.
83
+ - Put the facts about what is shown in `aside`, a `KeyValueList` under an `Overline`. From `lg` the aside is a fixed-width column at the end; below it, it stacks under the canvas.
84
+ - Omit `aside` when the canvas stands alone.
85
+ - `asideLabel` names the aside's landmark. Set it when the page has another complementary landmark.
86
+ - `bar` is a full-width row above the canvas and the panel, such as a viewer's title and its actions in a `Cluster justify="between"`. It is a `StickyBar`: it sticks under the shell's header as the page scrolls; `padded` does not pad it.
87
+ - A page with a title and content is `ListLayout` or `DetailLayout`.
88
+
89
+ ### Don't
90
+ `FullBleedLayout` adds no padding unless `padded`, so an ordinary page lands on the screen edge. A page with a title is a `ListLayout` or `DetailLayout`.
91
+ ```tsx
92
+ import { Card, FullBleedLayout, Text } from "@slashsuite/ui-react";
93
+
94
+ <FullBleedLayout>
95
+ <Card title="Quotes">
96
+ <Text>Every quote you have sent.</Text>
97
+ </Card>
98
+ </FullBleedLayout>
99
+ ```
100
+
101
+ ### Accessibility
102
+ - The `aside` is an `<aside>`, a complementary landmark; give it a heading with `Overline as="h2"`, or name it with `asideLabel`.
103
+ - The canvas comes first in the DOM, then the panel.
104
+
105
+ ### Props
106
+ ### FullBleedLayout
107
+ Edge-to-edge `children` with an optional `aside` at the end (`lg:w-72`) that stacks below on a smaller screen. Render it in `<AppShell bleed>`. It deliberately breaks the shared start edge: a viewer that needs the whole width has no Container of its own, so `children` start at the viewport's start edge. `padded` gives them the Container's padding instead (`px-4`, `sm:px-6`, `py-8`), for a page of ordinary content beside a full-height `aside`. A `bar` is a `StickyBar` above both: the full width, on the surface with a bottom line, sticking under AppShell's header as the page scrolls. While `loading` it owns the wait and passes it to everything inside, the header too.
108
+ - aside: ReactNode. A side column on the right (`lg:w-72`) on a tinted surface; below `lg` it stacks under `children`.
109
+ - asideLabel: string. Names the `<aside>` landmark (`aria-label`). Left out, it is unnamed.
110
+ - bar: ReactNode. A full-width row above `children` and `aside` that sticks under the header, e.g. a viewer's title and actions. `padded` does not pad it.
111
+ - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
112
+ - loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
113
+ Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
114
+ - loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
115
+ - padded: boolean (default false). Pads `children` as the Container pads every other page. Off, they run to the viewport's edges.
116
+ A notice in the column is a plain `Callout` in a `Stack`, never a `Callout banner`.