@handamade/psi-react 0.9.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Checkbox/Checkbox.d.ts +6 -0
- package/dist/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/Pagination/Pagination.d.ts +45 -0
- package/dist/Pagination/Pagination.d.ts.map +1 -0
- package/dist/Table/Table.d.ts +38 -0
- package/dist/Table/Table.d.ts.map +1 -0
- package/dist/Table/TableBody.d.ts +8 -0
- package/dist/Table/TableBody.d.ts.map +1 -0
- package/dist/Table/TableCell.d.ts +11 -0
- package/dist/Table/TableCell.d.ts.map +1 -0
- package/dist/Table/TableContext.d.ts +19 -0
- package/dist/Table/TableContext.d.ts.map +1 -0
- package/dist/Table/TableHead.d.ts +12 -0
- package/dist/Table/TableHead.d.ts.map +1 -0
- package/dist/Table/TableHeaderCell.d.ts +13 -0
- package/dist/Table/TableHeaderCell.d.ts.map +1 -0
- package/dist/Table/TableRow.d.ts +12 -0
- package/dist/Table/TableRow.d.ts.map +1 -0
- package/dist/Table/TableSelectionCell.d.ts +8 -0
- package/dist/Table/TableSelectionCell.d.ts.map +1 -0
- package/dist/Toast/Toast.d.ts +29 -0
- package/dist/Toast/Toast.d.ts.map +1 -0
- package/dist/Toast/ToastProvider.d.ts +34 -0
- package/dist/Toast/ToastProvider.d.ts.map +1 -0
- package/dist/Toast/ToastRegion.d.ts +42 -0
- package/dist/Toast/ToastRegion.d.ts.map +1 -0
- package/dist/Toast/useToast.d.ts +27 -0
- package/dist/Toast/useToast.d.ts.map +1 -0
- package/dist/a11y-meta.d.ts.map +1 -1
- package/dist/icons/IconAlertCircle.d.ts +7 -0
- package/dist/icons/IconAlertCircle.d.ts.map +1 -0
- package/dist/icons/IconAlertTriangle.d.ts +7 -0
- package/dist/icons/IconAlertTriangle.d.ts.map +1 -0
- package/dist/icons/IconInfo.d.ts +7 -0
- package/dist/icons/IconInfo.d.ts.map +1 -0
- package/dist/icons/index.d.ts +3 -0
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +939 -509
- package/dist/manifest.json +403 -0
- package/dist/patterns.json +84 -21
- package/dist/styles.css +1 -1
- package/docs/Checkbox.md +1 -0
- package/docs/Pagination.md +32 -0
- package/docs/Table.md +36 -0
- package/docs/TableBody.md +27 -0
- package/docs/TableCell.md +28 -0
- package/docs/TableHead.md +27 -0
- package/docs/TableHeaderCell.md +29 -0
- package/docs/TableRow.md +29 -0
- package/docs/Toast.md +51 -0
- package/docs/ToastProvider.md +39 -0
- package/docs/ToastRegion.md +39 -0
- package/llms.txt +18 -3
- package/package.json +2 -2
package/docs/Checkbox.md
CHANGED
|
@@ -8,6 +8,7 @@ Native checkbox with a built-in label; for independent binary choices.
|
|
|
8
8
|
| Prop | Type | Default | Required | Description |
|
|
9
9
|
|---|---|---|---|---|
|
|
10
10
|
| `children` | `ReactNode` | — | no | Label text. |
|
|
11
|
+
| `aria-label` | `string` | — | no | Accessible name when there is no visible label — a table's row-selection checkbox, say. Optional, unlike IconButton's required form (D60): a labelled checkbox is still the common case. |
|
|
11
12
|
| `ref` | `Ref<HTMLInputElement>` | — | no | Forwarded ref to the underlying `<input type="checkbox">` element. |
|
|
12
13
|
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
13
14
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# Pagination
|
|
3
|
+
|
|
4
|
+
Numbered pager with ellipsis truncation (D63). Standalone rather than a Table family member: `table-pagination` composes it as a Toolbar sibling of the page-size Select.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `page` | `number` | — | yes | Current page, 1-based. |
|
|
11
|
+
| `pageCount` | `number` | — | yes | Total number of pages. |
|
|
12
|
+
| `onPageChange` | `(page: number) => void` | — | yes | Called with the requested page. Required — unlike Table's `onSortChange`/ `onSelectionChange`, which are optional because `sortable`/`selectable` gate whether they're meaningful, `Pagination` has no such gating boolean: the prop is unconditionally meaningful, so a `Pagination` without it is a dead control (final review finding, D62). |
|
|
13
|
+
| `siblingCount` | `number` | 1 | no | Pages shown either side of the current one before truncating. |
|
|
14
|
+
| `aria-label` | `string` | Pagination | no | Accessible name for the nav landmark. |
|
|
15
|
+
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
16
|
+
|
|
17
|
+
## Theming
|
|
18
|
+
|
|
19
|
+
This component has no `--psi-pagination-*` tokens — its styling binds scale tokens only, so there is nothing component-scoped to override. Theme changes reach it through the semantic tokens of its children and surroundings.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Rules
|
|
24
|
+
|
|
25
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
26
|
+
- danger only for actions with real consequences.
|
|
27
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
28
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
29
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
30
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
31
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
32
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
package/docs/Table.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# Table
|
|
3
|
+
|
|
4
|
+
Data table on native table semantics. Holds no state: sorting, selection and pagination are the consumer's (D62, extending D50/D53).
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `size` | `32 \| 40 \| 48` | 40 | no | Row height in px. |
|
|
11
|
+
| `stickyHeader` | `boolean` | — | no | Pins the header while the body scrolls. |
|
|
12
|
+
| `sortable` | `boolean` | false | no | Enables the sort affordance on header cells that declare a `sortKey`. |
|
|
13
|
+
| `sort` | `TableSortState \| null` | — | no | Controlled sort state; `null` when nothing is sorted. |
|
|
14
|
+
| `onSortChange` | `((sort: TableSortState) => void)` | — | no | Called when a header's sort control is activated. Optional in the type because `sortable` may be false; a discriminated union expressing the real contract does not survive docgen's flat prop extraction, which would strip these props from the manifest entirely (D62). |
|
|
15
|
+
| `selectable` | `boolean` | false | no | Renders the row-selection checkbox column. |
|
|
16
|
+
| `selected` | `ReadonlySet<string>` | new Set<string>() | no | Controlled selection, keyed by each `TableRow`'s `rowId`. |
|
|
17
|
+
| `onSelectionChange` | `((selected: ReadonlySet<string>) => void)` | — | no | Called with the next selection. See `onSortChange` on why it is optional. |
|
|
18
|
+
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
19
|
+
| `ref` | `Ref<HTMLTableElement>` | — | no | Forwarded ref to the underlying `<table>` element. |
|
|
20
|
+
|
|
21
|
+
## Theming
|
|
22
|
+
|
|
23
|
+
Override `--psi-table-*` custom properties at any scope; interactive states derive automatically (L - 0.04 hover, L - 0.08 active).
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Rules
|
|
28
|
+
|
|
29
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
30
|
+
- danger only for actions with real consequences.
|
|
31
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
32
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
33
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
34
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
35
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
36
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# TableBody
|
|
3
|
+
|
|
4
|
+
`<tbody>` wrapper.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
11
|
+
|
|
12
|
+
## Theming
|
|
13
|
+
|
|
14
|
+
This component has no `--psi-table-body-*` tokens — its styling binds scale tokens only, so there is nothing component-scoped to override. Theme changes reach it through the semantic tokens of its children and surroundings.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
21
|
+
- danger only for actions with real consequences.
|
|
22
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
23
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
24
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
25
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
26
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
27
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# TableCell
|
|
3
|
+
|
|
4
|
+
`<td>`. `numeric` means right-aligned *and* tabular — a column that aligns but whose digits jitter between rows defeats the purpose.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `numeric` | `boolean` | — | no | Right-aligns and renders tabular figures (D62). |
|
|
11
|
+
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
12
|
+
|
|
13
|
+
## Theming
|
|
14
|
+
|
|
15
|
+
This component has no `--psi-table-cell-*` tokens — its styling binds scale tokens only, so there is nothing component-scoped to override. Theme changes reach it through the semantic tokens of its children and surroundings.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
22
|
+
- danger only for actions with real consequences.
|
|
23
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
24
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
25
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
26
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
27
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
28
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# TableHead
|
|
3
|
+
|
|
4
|
+
`<thead>`. When the table is selectable, prepends the select-all cell to the FIRST header row so the header's column count matches the body's — the checkbox column is Table's, not the consumer's schema. Clones the row rather than rebuilding it, so the consumer's own props on that `TableRow` survive.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
11
|
+
|
|
12
|
+
## Theming
|
|
13
|
+
|
|
14
|
+
This component has no `--psi-table-head-*` tokens — its styling binds scale tokens only, so there is nothing component-scoped to override. Theme changes reach it through the semantic tokens of its children and surroundings.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
21
|
+
- danger only for actions with real consequences.
|
|
22
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
23
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
24
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
25
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
26
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
27
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# TableHeaderCell
|
|
3
|
+
|
|
4
|
+
`<th scope="col">`. `aria-sort` belongs on the th, never on the inner button — assistive tech reads the sort state from the column header.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `sortKey` | `string` | — | no | Sort key this column emits. Enables the sort control when the table is `sortable`. |
|
|
11
|
+
| `numeric` | `boolean` | — | no | Right-aligns and renders tabular figures (D62). |
|
|
12
|
+
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
13
|
+
|
|
14
|
+
## Theming
|
|
15
|
+
|
|
16
|
+
This component has no `--psi-table-header-cell-*` tokens — its styling binds scale tokens only, so there is nothing component-scoped to override. Theme changes reach it through the semantic tokens of its children and surroundings.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
23
|
+
- danger only for actions with real consequences.
|
|
24
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
25
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
26
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
27
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
28
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
29
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
package/docs/TableRow.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# TableRow
|
|
3
|
+
|
|
4
|
+
`<tr>`. `rowId` is the key the `selected` set holds.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `rowId` | `string` | — | no | Stable identity for selection. Required for selectable tables (D62). |
|
|
11
|
+
| `selectLabel` | `string` | — | no | Accessible name for this row's selection checkbox. |
|
|
12
|
+
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
13
|
+
|
|
14
|
+
## Theming
|
|
15
|
+
|
|
16
|
+
This component has no `--psi-table-row-*` tokens — its styling binds scale tokens only, so there is nothing component-scoped to override. Theme changes reach it through the semantic tokens of its children and surroundings.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
23
|
+
- danger only for actions with real consequences.
|
|
24
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
25
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
26
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
27
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
28
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
29
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
package/docs/Toast.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# Toast
|
|
3
|
+
|
|
4
|
+
A single transient notification card (D64). Controlled and presentational: it holds no state, runs no timer, and never removes itself — `onDismiss` reports and the owner disposes, exactly as Dialog (D50) and Menu (D53) do. Toast does not carry its own `role`/`aria-live`. Politeness belongs to the two persistent wrappers inside ToastRegion, because a live region must pre-exist the content it announces; a role on the toast itself would reintroduce the mount-with-content problem one level down. Composed by hand with ToastRegion for full control, or driven by ToastProvider's queue.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `variant` | `"neutral" \| "success" \| "warning" \| "danger"` | neutral | no | Status variant. |
|
|
11
|
+
| `children` | `ReactNode` | — | yes | The message. |
|
|
12
|
+
| `action` | `ReactNode` | — | no | Trailing affordance — a ghost Button (Undo, Retry, View). |
|
|
13
|
+
| `onDismiss` | `(() => void)` | — | no | When provided, renders the dismiss button and calls this. Toast does not remove itself; the owner disposes. |
|
|
14
|
+
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
15
|
+
| `ref` | `Ref<HTMLDivElement>` | — | no | Forwarded ref to the underlying `<div>`. |
|
|
16
|
+
|
|
17
|
+
## Keyboard & assistive tech
|
|
18
|
+
|
|
19
|
+
| Keys | Behavior |
|
|
20
|
+
|---|---|
|
|
21
|
+
| Tab | Reaches the action and the dismiss button in DOM order. Esc is not a dismissal — a toast is not modal and traps nothing. |
|
|
22
|
+
| Enter / Space | Activates the focused action or dismiss button. |
|
|
23
|
+
|
|
24
|
+
Presentational and controlled (D64): onDismiss reports and the owner disposes; Toast never removes itself. It carries no role/aria-live of its own — politeness belongs to ToastRegion's two persistent wrappers. The variant's meaning is announced by a visually hidden status word ("Success:", "Warning:", "Error:"), never by colour and icon shape alone; the icon is aria-hidden. neutral has no status and gets no prefix. The dismiss button requires no props — it is labelled "Dismiss notification".
|
|
25
|
+
|
|
26
|
+
## Theming
|
|
27
|
+
|
|
28
|
+
Override `--psi-toast-*` custom properties at any scope.
|
|
29
|
+
|
|
30
|
+
## Variant guidance
|
|
31
|
+
|
|
32
|
+
- **accent** — Primary action, draws attention. Submit, CTA, main action in a group.
|
|
33
|
+
- **accent-subtle** — Accent tone, lower visual weight. Selected state, active filter, soft CTA.
|
|
34
|
+
- **neutral** — Default, structurally present. Secondary actions, toolbar buttons.
|
|
35
|
+
- **neutral-subtle** — Minimal chrome. Inline actions, table row actions.
|
|
36
|
+
- **ghost** — No visible container until hover. Icon-only triggers, compact toolbars.
|
|
37
|
+
- **outline** — Bordered ghost — visible structure, no fill until hover. Marketing CTA, download button; hover fills accent.
|
|
38
|
+
- **danger** — Destructive action. Delete, remove, disconnect.
|
|
39
|
+
- **danger-subtle** — Destructive context, low urgency. Warning badges, soft destructive hints.
|
|
40
|
+
- **success | warning** — Status communication (Tag only). Status badges, labels.
|
|
41
|
+
|
|
42
|
+
## Rules
|
|
43
|
+
|
|
44
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
45
|
+
- danger only for actions with real consequences.
|
|
46
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
47
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
48
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
49
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
50
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
51
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# ToastProvider
|
|
3
|
+
|
|
4
|
+
Owns the toast queue, its auto-dismiss timers, and the single ToastRegion (D65). This is the library's one stateful container, and the exception is deliberately narrow. D50 and D53 rejected internal state for Dialog and Menu because the consumer already owned the state that decided visibility — a menu is open because a user clicked a trigger the consumer rendered. A toast has no such owner: it is created by an outcome, not by a UI state, and it disappears on a timer nobody is watching. The rule that survives is the useful half — presentational components stay controlled (`Toast` still holds nothing), a stateful container may exist when the state has no natural owner, and it must be opt-in. Timers pause while the pointer or focus is inside the region (WCAG 2.2.1), and resume with the time *remaining* rather than a fresh full duration — restarting would let a user hold a toast open indefinitely by jiggling the mouse.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `limit` | `number` | 3 | no | Max simultaneous toasts; the oldest is evicted first. |
|
|
11
|
+
| `duration` | `number` | 5000 | no | Auto-dismiss for toasts with no action, in ms. |
|
|
12
|
+
| `actionDuration` | `number` | 10000 | no | Auto-dismiss for toasts carrying an action, in ms. An affordance that vanishes before it can be reached is not an affordance. |
|
|
13
|
+
| `placement` | `"top-start" \| "top-end" \| "bottom-start" \| "bottom-end"` | bottom-end | no | Corner the stack occupies. |
|
|
14
|
+
| `children` | `ReactNode` | — | yes | The subtree that may call `useToast()`. The region is rendered alongside it. |
|
|
15
|
+
|
|
16
|
+
## Keyboard & assistive tech
|
|
17
|
+
|
|
18
|
+
| Keys | Behavior |
|
|
19
|
+
|---|---|
|
|
20
|
+
| Tab | Focus entering the region pauses every auto-dismiss timer; leaving resumes them. |
|
|
21
|
+
|
|
22
|
+
Owns the queue, the auto-dismiss timers and the single ToastRegion (D65). Timers pause while the pointer or focus is inside the region and resume with the time remaining, satisfying WCAG 2.2.1 for content that disappears on a timer. Toasts carrying an action get a longer default lifetime, so the affordance cannot vanish before it is reached. useToast() throws outside a provider rather than silently no-opping.
|
|
23
|
+
|
|
24
|
+
## Theming
|
|
25
|
+
|
|
26
|
+
This component has no `--psi-toast-provider-*` tokens — its styling binds scale tokens only, so there is nothing component-scoped to override. Theme changes reach it through the semantic tokens of its children and surroundings.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
33
|
+
- danger only for actions with real consequences.
|
|
34
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
35
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
36
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
37
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
38
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
39
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!-- Generated by emit-docs.ts — do not edit. -->
|
|
2
|
+
# ToastRegion
|
|
3
|
+
|
|
4
|
+
The positioned live region that holds the toast stack (D64). Two things here are load-bearing and both look like details: 1. **The two live wrappers are always rendered**, empty queue included. A live region announces mutations to a subtree that already existed; a wrapper that mounts together with its first toast reads as a new subtree, and that first toast is never announced. 2. **`popover="manual"`, not `"auto"`.** Manual puts the region in the native top layer without light dismiss. The top layer is required because Dialog uses showModal() — also top layer — so a fixed region at --psi-z-overlay would paint *under* the modal backdrop, hiding the confirmation for the action a user just took inside a dialog. And `auto` would be dismissed by the very click that raised the toast. Routing reads `variant` off each child, the same Children.map technique Table uses for select-all injection. Consequence of the split, visible in the `InRegion` VR baseline: the stack is grouped by politeness, not strictly chronological — every assertive toast sorts below every polite one regardless of arrival order. Chronological order is preserved *within* each group. Keeping it exact across both would mean one live region with a politeness that changes per message, which is the thing the two wrappers exist to avoid. Accepted: at `limit` 3 the grouping reads as severity ordering, and the newest toast still lands nearest the screen edge within its group.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
| Prop | Type | Default | Required | Description |
|
|
9
|
+
|---|---|---|---|---|
|
|
10
|
+
| `placement` | `"top-start" \| "top-end" \| "bottom-start" \| "bottom-end"` | bottom-end | no | Corner the stack occupies. |
|
|
11
|
+
| `aria-label` | `string` | Notifications | no | Accessible name for the region. |
|
|
12
|
+
| `children` | `ReactNode` | — | yes | The toast stack — `Toast` elements, routed to a live wrapper by variant. |
|
|
13
|
+
| `className` | `string` | — | no | Additional CSS class name(s) merged onto the component's root element. |
|
|
14
|
+
| `ref` | `Ref<HTMLDivElement>` | — | no | Forwarded ref to the region element. |
|
|
15
|
+
|
|
16
|
+
## Keyboard & assistive tech
|
|
17
|
+
|
|
18
|
+
| Keys | Behavior |
|
|
19
|
+
|---|---|
|
|
20
|
+
| Tab | Moves into the stacked toasts' controls in DOM order; the region itself is not focusable. |
|
|
21
|
+
|
|
22
|
+
Renders two always-present live wrappers — role="status"/aria-live="polite" and role="alert"/aria-live="assertive" — and routes each toast into one by variant (neutral/success polite, warning/danger assertive). Both stay in the DOM when the queue is empty: a live region announces mutations to a subtree that already existed, so a wrapper mounting with its first toast would leave that toast unannounced. Sits on the native top layer via popover="manual", so a toast raised from inside a modal Dialog is still painted above the backdrop and still announced — though showModal() makes everything outside the dialog inert, so it cannot be clicked until the dialog closes; manual (not auto) means no light dismiss, so the click that raised the toast cannot close it. The region is click-through (pointer-events: none) and each toast takes its own clicks back.
|
|
23
|
+
|
|
24
|
+
## Theming
|
|
25
|
+
|
|
26
|
+
This component has no `--psi-toast-region-*` tokens — its styling binds scale tokens only, so there is nothing component-scoped to override. Theme changes reach it through the semantic tokens of its children and surroundings.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
- One accent per visual group; everything else neutral or ghost.
|
|
33
|
+
- danger only for actions with real consequences.
|
|
34
|
+
- Sizes are px numbers (24|32|40|48), never S/M/L.
|
|
35
|
+
- Typography tokens are --psi-text-{size}-{lineHeight}-{weight}.
|
|
36
|
+
- Override component tokens (--psi-{component}-*), not semantic tokens, for one-off theming.
|
|
37
|
+
- --psi-button-font overrides button typography across all sizes (documented D34 override; ember → mono).
|
|
38
|
+
- Wrap labeled form controls in Field — label association, description/error line, aria-describedby and aria-invalid come wired; don't hand-roll label+message rows.
|
|
39
|
+
- Use Dialog for blocking modal flows — title/footer slots, dismissible gate; danger stays on the footer Buttons, one accent per group.
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @handamade/psi-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
28 React 19 components consuming @handamade/psi-tokens. Zero runtime deps, CSS Modules, ref-as-prop.
|
|
4
4
|
|
|
5
5
|
## Machine-readable artifacts
|
|
6
6
|
- dist/manifest.json: full component/prop inventory with types and defaults
|
|
@@ -36,8 +36,23 @@
|
|
|
36
36
|
## AspectRatio
|
|
37
37
|
- <AspectRatio ratio={16/10}>{children}</AspectRatio>: a frame div with CSS aspect-ratio set from the numeric ratio prop — wrap images/media to reserve layout space before load. Combine with the .psi-media-tint utility for the brand media-tint treatment.
|
|
38
38
|
|
|
39
|
-
## Icons (
|
|
40
|
-
- Full icon set: IconPlus, IconMinus, IconCheck, IconClose, IconChevronDown, IconChevronRight, IconSearch, IconSettings, IconUser, IconEye, IconEyeOff, IconEdit, IconCopy, IconTrash, IconLoader, IconExternalLink, plus D36 additions — arrows IconArrowDown and IconArrowUpRight, and social glyphs IconLinkedIn, IconGitHub, IconX, IconInstagram.
|
|
39
|
+
## Icons (25)
|
|
40
|
+
- Full icon set: IconPlus, IconMinus, IconCheck, IconClose, IconChevronDown, IconChevronRight, IconSearch, IconSettings, IconUser, IconEye, IconEyeOff, IconEdit, IconCopy, IconTrash, IconLoader, IconExternalLink, plus D36 additions — arrows IconArrowDown and IconArrowUpRight, and social glyphs IconLinkedIn, IconGitHub, IconX, IconInstagram — plus the D64 status glyphs IconInfo, IconAlertTriangle and IconAlertCircle.
|
|
41
|
+
|
|
42
|
+
## Table family (6)
|
|
43
|
+
- `<Table>` renders `<table>` and is **controlled-only** — it holds no state (D62). Sorting is `sort={{key, direction}}` + `onSortChange`; selection is `selected` (a `ReadonlySet<string>` keyed by each `<TableRow rowId>`) + `onSelectionChange`. `sortable` and `selectable` only enable the affordances. `size` is `32 | 40 | 48` px (default 40) and `stickyHeader` pins the header. It does no filtering, sorting or slicing of rows — the consumer does that.
|
|
44
|
+
- `<TableHead>`, `<TableBody>`, `<TableRow>` render `<thead>`, `<tbody>`, `<tr>`. `<TableHeaderCell>` renders `<th scope="col">`, taking `sortKey` to become sortable and putting `aria-sort` on the `<th>`. `<TableCell>` renders `<td>`. Both cells take `numeric`, which right-aligns **and** renders tabular figures.
|
|
45
|
+
- Selecting rows: give each `<TableRow>` a `rowId` and a `selectLabel` — the row checkbox has no visible label, so `selectLabel` is its accessible name. `<TableHead>` grows the select-all checkbox automatically; do not add one. Consult dist/patterns.json for the `data-table` pattern.
|
|
46
|
+
|
|
47
|
+
## Pagination
|
|
48
|
+
- `<Pagination page={n} pageCount={total} onPageChange={...}>`: a numbered pager with ellipsis truncation (`‹ 1 … 4 5 6 … 13 ›`), built from Button/IconButton (D63). `siblingCount` (default 1) sets how many pages flank the current one before truncating; `aria-current="page"` marks the active page and the ellipsis is inert.
|
|
49
|
+
- It is **standalone, not a Table family member** and has no connection to `Table` — `Table` has no `page` prop. The `table-pagination` pattern composes it as a `Toolbar` sibling of a page-size `Select`; the consumer owns page state and slices the rows.
|
|
50
|
+
|
|
51
|
+
## Toast family (3) + useToast
|
|
52
|
+
- `<Toast variant="neutral|success|warning|danger" action={...} onDismiss={...}>message</Toast>` is presentational and **controlled** (D64): it holds no state, runs no timer and never removes itself — `onDismiss` reports and the owner disposes. Variants are Tag's **status** axis, not the flat action variants; there is deliberately no `accent`. The variant's meaning is announced by a visually hidden status word, so never rely on the icon colour alone.
|
|
53
|
+
- `<ToastRegion placement="bottom-end">` is the positioned container and must wrap every toast. It renders **two always-present live wrappers** (`role="status"` polite, `role="alert"` assertive) and routes each toast by variant — neutral/success polite, warning/danger assertive. It sits on the native top layer via `popover="manual"`, so a toast raised from inside a modal `Dialog` is still painted above the backdrop and still announced — though not clickable until the dialog closes, since `showModal()` makes everything outside the dialog inert. Raise toasts *after* the dialog closes if they carry an `action`.
|
|
54
|
+
- `<ToastProvider limit={3} duration={5000} actionDuration={10000}>` owns the queue, the timers and the single region — the library's **one stateful container** (D65), and opt-in. Inside it, `const toast = useToast()` gives `show({variant, message, action}) => id`, `dismiss(id)` and `clear()`. Timers pause while the pointer or focus is in the region and resume with the time remaining (WCAG 2.2.1); toasts carrying an action get the longer lifetime.
|
|
55
|
+
- **Do not hand-roll a queue or a `setTimeout`** — that is what `ToastProvider` is for. Do not render a bare `<Toast>` outside a `ToastRegion`: it would announce nothing. `useToast()` throws outside a provider rather than silently doing nothing.
|
|
41
56
|
|
|
42
57
|
## Compositions (recipes for what has no component yet)
|
|
43
58
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handamade/psi-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"tsx": "^4.22.4",
|
|
41
41
|
"vite": "^6.0.0",
|
|
42
42
|
"vitest": "^3.2.6",
|
|
43
|
-
"@handamade/psi-tokens": "0.
|
|
43
|
+
"@handamade/psi-tokens": "0.11.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "vite build && tsc -p tsconfig.build.json && tsx scripts/emit-manifest.ts && tsx scripts/emit-patterns.ts && tsx scripts/emit-docs.ts",
|