strata-react 1.0.11 → 1.0.12
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 +3 -3
- package/UPGRADING.md +3 -0
- package/dist/components/checkbox.d.ts +11 -0
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/selectable-grid.d.ts +1 -1
- package/dist/components/selection.d.ts +1 -0
- package/dist/index.js +392 -405
- package/dist/index.js.map +1 -1
- package/dist/testing.js.map +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Rules for working in this repo, for people and coding agents: [`CLAUDE.md`](./CL
|
|
|
15
15
|
## The stack
|
|
16
16
|
|
|
17
17
|
Node 26 · React 19 · TypeScript · Vite 8 · Tailwind v4 · class-variance-authority · lucide-react ·
|
|
18
|
-
TanStack Query
|
|
18
|
+
TanStack Query and Table · React Router · Vitest + Testing Library + MSW ·
|
|
19
19
|
Storybook 10 · Playwright Chromium + pixelmatch visual regression · GitHub Actions.
|
|
20
20
|
|
|
21
21
|
## Install
|
|
@@ -27,7 +27,7 @@ npm install -D tailwindcss @tailwindcss/vite
|
|
|
27
27
|
|
|
28
28
|
The npm package is built: nothing runs on install. It needs **Node 26 or later**, for apps as
|
|
29
29
|
well as for this repo; an older Node gets an `EBADENGINE` warning, so upgrade it. Strata's own dependencies
|
|
30
|
-
(React Aria Components, TanStack Table
|
|
30
|
+
(React Aria Components, TanStack Table, class-variance-authority, clsx, tailwind-merge,
|
|
31
31
|
lucide-react) come with it, so an app does not list them.
|
|
32
32
|
|
|
33
33
|
**Peers.** What an app installs follows from what it imports, and the integration suite checks
|
|
@@ -121,7 +121,7 @@ function KilnRoom() {
|
|
|
121
121
|
| Actions | `Button`, `IconButton`, `RowAction`, `AsyncButton`, `useAsyncAction` | Default is `outline`; one filled button per view; `IconButton` requires `label`; `RowAction` is named for its row ("Withdraw Tom Ellery"); `AsyncButton` keeps one width through idle, pending, done and error, and announces `error` with its retry label; buttons carry `data-variant` and `AsyncButton` `data-phase` for tests; `useAsyncAction` returns `{ phase, run, error, thrown, fieldErrors, clearFieldError }` with a stable `run`, describes an `HttpError` in a sentence with the server's own reason for a 4xx (`describeActionError`, or the product's own `describeError`), and `validate` plus a server's 422 put messages on `fieldErrors` for each `Field` |
|
|
122
122
|
| Form | `Field`, `Input`, `Textarea`, `NativeSelect`, `ChoiceGroup`, `Checkbox` | `Field` wires label, hint, error, `aria-describedby`, `aria-invalid`, and `action` puts a one-field form's button on the control's row with the hint and error under both; `Checkbox` requires `label` and is one target with it, and has a mixed state |
|
|
123
123
|
| Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar` | A status is always a word; figures have no icons or sparklines; `Meter` is a `meter` named for what it measures, with its reading in words ("72% used"), threshold notches, and a `Status` word once a threshold is crossed (each threshold must name its state); `CompositionBar` is a stacked bar over a table naming every part, its amount and share, and names the remainder (`total` needs `restLabel`); a part that is there reads "<1%" and keeps a sliver, never "0%"; `JobStatus` is a long-running server job: a required word per state beside the app's sentence, a progress bar when the total is known, each failure named with its reason, announced only when the item changes or the job ends |
|
|
124
|
-
| Data | `DataView`, `Load<T>`, `Stale`, `StaleNotice`, `LoadError`, `EmptyState`, `Skeleton`, `Thumbnail`, `ThumbnailSkeleton`, `DataTable`, `TableSkeleton`, `VirtualList`, `InfiniteList`, `LoadMore`, `useInView`, `LineChart` | `DataView` requires skeleton and empty, keeps data on screen under a `StaleNotice` (why, how old, Try again) when a refresh fails, and takes an `error` renderer for an app's own look of a failed read (default `LoadError`, always inside an alert); `Thumbnail` is a remote image in a box of fixed `aspect`, with a skeleton while it loads, the required `missing` words (or a `fallback` drawing, such as an avatar's initial) when it fails or `src` is null, required `alt`, `children` overlaid in its corners, and a request only once it nears the screen (`eager` for the first few); tables and
|
|
124
|
+
| Data | `DataView`, `Load<T>`, `Stale`, `StaleNotice`, `LoadError`, `EmptyState`, `Skeleton`, `Thumbnail`, `ThumbnailSkeleton`, `DataTable`, `TableSkeleton`, `VirtualList`, `InfiniteList`, `LoadMore`, `useInView`, `LineChart` | `DataView` requires skeleton and empty, keeps data on screen under a `StaleNotice` (why, how old, Try again) when a refresh fails, and takes an `error` renderer for an app's own look of a failed read (default `LoadError`, always inside an alert); `Thumbnail` is a remote image in a box of fixed `aspect`, with a skeleton while it loads, the required `missing` words (or a `fallback` drawing, such as an avatar's initial) when it fails or `src` is null, required `alt`, `children` overlaid in its corners, and a request only once it nears the screen (`eager` for the first few); tables, lists and tile grids virtualise from 100 rows, on React Aria's Virtualizer; a `DataTable` is a React Aria table (a `grid`) over TanStack Table's data model; a `DataTable` column with `value` sorts by type with missing values last both ways and draws a placeholder (`missing`, default an en dash); `InfiniteList` loads the next page on approach, with a skeleton for it, a Try again row when it fails and a Show more button for the keyboard, and `scroll="page"` draws a grid that scrolls with the page; `LoadMore` is that next-page row for any list or grid; charts label values directly; `LineChart` can also follow an app's position (`current`), read a value at the pointer or by arrow keys (`readout`, one slider whose value text is the reading), report a picked x (`onPick`) and fill one flat area (`area`) |
|
|
125
125
|
| Compare | `Compare`, `CompareGrid`, `ViewportFrame`, `useViewport`, `FullscreenFrame`, `useDifference`, `differences` | Two pictures judged together: side by side, swipe (a divider that moves from the keyboard), fade, blink (`x` flips) and difference (a live difference blend with amplify, or pixelmatch's changed pixels with a tolerance and the share that differ; pixels are read only when that view is open, at most 2048 px on the long side, and a picture the browser will not let the page read says so in words); `CompareGrid` is every candidate at once with the same zoom and full screen, and `actions` for what a tile offers; one zoom and pan for both sides (buttons, `+` `-` `0`, Ctrl-wheel or trackpad pinch, drag, arrow keys, double click, `1:1`), and full screen (the browser's Fullscreen API, a modal where there is none). `blind` is required: a blind comparison names pictures by `label` only and never writes the variant `id`, `note` or `alt`. A picture that fails shows the required `missing` words in its place; the keys come from one `Shortcut[]` shared with `KeysLegend`, and `keys={false}` leaves them to a surrounding screen. Pictures only so far: voting, text, audio and video are the next changes |
|
|
126
126
|
| Selection | `useSelection`, `BulkBar`, `SelectableGrid`, `DataTable`'s `selection` (`RowSelection<T>`) | Opt-in checkbox column with "Select all shown" that respects `isSelectable`; Shift-click or Shift+Space chooses or clears the run from the last row clicked, in the order shown; `initial` (keys or a test on the row) chooses a row the first time it appears, so it applies to data that loads later; the selection drops rows that are gone; `BulkBar` announces the count politely, and while it is up its one filled action is the view's only one (the screen's primary goes to `outline`); `SelectableGrid` is the same selection as a grid of pictures (`renderImage`), each tile one labelled target, virtualised from 100 tiles |
|
|
127
127
|
| Expansion | `Disclosure`, `useExpanded`, `DataTable`'s `expansion` (`RowExpansion<T>`) | Show more of one row in place. The toggle is a button with `aria-expanded`; the body is mounted only while open, so a request inside it runs on first open (unlike `<details>`, which mounts every closed body); `useExpanded({ param })` shares the open keys across a list or table and keeps them in the URL; a table's detail row spans the data columns and is measured when virtualised |
|
package/UPGRADING.md
CHANGED
|
@@ -16,6 +16,9 @@ Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Chang
|
|
|
16
16
|
React Aria Components is now the primitives layer (`react-aria-components`, installed with the
|
|
17
17
|
package). `@radix-ui/react-slot` is gone.
|
|
18
18
|
|
|
19
|
+
- **`DataTable` is a `grid`**, not a `table`: query `getByRole("grid", { name: caption })`, cells as `gridcell` and the first column's cells as `rowheader` (React Aria requires a row header; it is the first column). A sortable header is the `columnheader` itself, with no inner `button`: click it, and `aria-sort` is `"none"` until sorted. The `region` that wrapped a table is gone, and a toggle has no `aria-controls`. A click on a cell no longer touches the selection: only the checkbox or Space chooses a row. A part-chosen "Select all shown" still clears. Virtualised tables (100+ rows) size columns evenly rather than to their content. In a jsdom test of a virtualised table with `expansion`, or of a `SelectableGrid` of 100+ tiles, set `Element.prototype.scrollHeight` (the Virtualizer measures rows by it).
|
|
20
|
+
- **`SelectableGrid` is a `grid` of `row`s** (was a `list` of `listitem`s, a `region` once virtualised): query `getByRole("grid", { name: label })`; a press anywhere on a tile toggles it as before, and Shift-click, Shift+Space and "Select all shown" still extend and clear. Virtualised tiles keep a margin of one gap around the box.
|
|
21
|
+
- **`@tanstack/react-virtual` is no longer a dependency.** Strata does not need it; if an app imported it through Strata, add it itself.
|
|
19
22
|
- **`VirtualList` and `InfiniteList` (region mode) are a `grid` of `row`s**, not a `list` of `listitem`s in a `region`: query `getByRole("grid", { name })` and count items with `[data-index]` (the next-page row is a row too). Arrow keys move between rows. New `rowHeight` prop for fixed-height rows. `scroll="page"` is unchanged.
|
|
20
23
|
- **State classes are the `tailwindcss-react-aria-components` variants** (`selected:`, `focus-visible:`, `hover:`, `disabled:`), loaded by `strata.css` (the plugin is installed with the package). A test that matched a class such as `data-[selected]:border-foreground` now matches `selected:border-foreground`; hover colours no longer apply on touch screens.
|
|
21
24
|
- **`Compare`'s default view switch has a fifth view, `difference`** (key `5`). An app that renders `Compare` without `modes` sees one more toggle (and its visual baselines move); pass `modes={["side", "swipe", "fade", "blink"]}` to keep the previous four.
|
|
@@ -25,3 +25,14 @@ export declare function useShiftNote(): {
|
|
|
25
25
|
};
|
|
26
26
|
take: () => CheckboxGesture;
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* The checkbox of a React Aria `Table` row or header (`slot="selection"`): its checked, mixed and
|
|
30
|
+
* disabled state come from the table, so it takes only a name. A `Checkbox` is controlled and would
|
|
31
|
+
* fight the table's own selection state. Not exported from the package: `DataTable` uses it.
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export declare function TableSelectionCheckbox({ label, className, disabled }: {
|
|
35
|
+
label: string;
|
|
36
|
+
className?: string;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
}): React.JSX.Element;
|
|
@@ -74,7 +74,7 @@ export type DataTableProps<T> = {
|
|
|
74
74
|
export declare function parseSort(value: string | null): Sort | undefined;
|
|
75
75
|
/** Writes a sort in its URL form (`pieces.desc`). */
|
|
76
76
|
export declare function serialiseSort(sort: Sort): string;
|
|
77
|
-
/** A table on TanStack Table: muted headers, row rules, right-aligned tabular numbers, sortable headers with `aria-sort`, virtualised from `virtualizeFrom` rows, sort optionally kept in the URL (`sortParam`). */
|
|
77
|
+
/** A table on React Aria's Table with TanStack Table's data model: muted headers, row rules, right-aligned tabular numbers, sortable headers with `aria-sort`, virtualised from `virtualizeFrom` rows, sort optionally kept in the URL (`sortParam`). */
|
|
78
78
|
export declare function DataTable<T>(props: DataTableProps<T>): React.JSX.Element;
|
|
79
79
|
/** The loading placeholder for a `DataTable`, shaped like its rows. */
|
|
80
80
|
export declare function TableSkeleton({ rows, columns }: {
|
|
@@ -5,7 +5,7 @@ export type TileAspect = "square" | "portrait" | "landscape";
|
|
|
5
5
|
/** Smallest tile width: `sm` 96px (dense crops), `md` 144px, `lg` 192px. Tiles grow to fill the row. */
|
|
6
6
|
export type TileSize = "sm" | "md" | "lg";
|
|
7
7
|
export type SelectableGridProps<T> = {
|
|
8
|
-
/** Names the
|
|
8
|
+
/** Names the grid of tiles. */
|
|
9
9
|
label: string;
|
|
10
10
|
rows: T[];
|
|
11
11
|
rowKey: (row: T) => string;
|
|
@@ -38,6 +38,7 @@ export declare function useSelectRows<T>(rows: readonly T[], rowKey: (row: T) =>
|
|
|
38
38
|
toggle: (key: string, on: boolean, { shiftKey }: {
|
|
39
39
|
shiftKey: boolean;
|
|
40
40
|
}) => void;
|
|
41
|
+
setAnchor: (key: string | null) => void;
|
|
41
42
|
all: {
|
|
42
43
|
checked: boolean | "mixed";
|
|
43
44
|
toggle: () => void;
|