strata-react 1.0.21 → 1.0.26
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 +2 -2
- package/UPGRADING.md +4 -0
- package/dist/components/compare.d.ts +6 -1
- package/dist/components/media-player.d.ts +1 -1
- package/dist/components/pair-vote.d.ts +57 -0
- package/dist/components/switch.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +235 -167
- package/dist/index.js.map +1 -1
- package/dist/{query-CP78goXj.js → query-DgJMyXTT.js} +164 -3
- package/dist/query-DgJMyXTT.js.map +1 -0
- package/dist/testing/index.d.ts +10 -4
- package/dist/testing.js +11 -7
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/query-CP78goXj.js.map +0 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ it against the built files:
|
|
|
36
36
|
| Import | Needs | Why |
|
|
37
37
|
|---|---|---|
|
|
38
38
|
| `strata-react` | `react`, `react-dom`, `react-router`, `@tanstack/react-query`, `tailwindcss` | The stack is fixed: `DataTable` and `Tabs` keep sort and tab in the URL, `AppShell` links with `NavLink`, every remote read is `useLoad`. The barrel imports both libraries, so an app that uses only a `Button` still installs them (both are needed for anything past a static page) |
|
|
39
|
-
| `strata-react/testing` | the above, plus `@testing-library/react` | `renderWithStrata` and `renderRoutes` wrap Testing Library's `render` |
|
|
39
|
+
| `strata-react/testing` | the above, plus `@testing-library/react` | `renderWithStrata` and `renderRoutes` wrap Testing Library's `render`, with a `StrataToastRegion` (so a toast can be found; `toasts: false` if your route tree renders the region, which a root layout route is the best place for) and the toast queue cleared first |
|
|
40
40
|
| `strata-react/map` | `leaflet` (optional peer, `^1.9.4`) | `RouteMap`: themed routes and a moving position on the tiles an app supplies |
|
|
41
41
|
| `strata-react/visual`, `strata-visual` | `playwright` (exact version), `msw`, `vite` | The screenshot runner; see [Visual regression for apps](#visual-regression-for-apps) |
|
|
42
42
|
|
|
@@ -127,7 +127,7 @@ strata-react is ESM-only (`exports` has only `import`), as is its peer `react-ro
|
|
|
127
127
|
| 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 |
|
|
128
128
|
| 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 |
|
|
129
129
|
| 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`); `xLabel` names the x column of its table |
|
|
130
|
-
| 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:
|
|
130
|
+
| Compare | `Compare`, `PairVote`, `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. `PairVote` wraps `Compare` for a blind pairwise judgment: answer keys `a` `b` `t` `s` in Compare's one legend, a vote bar with no filled button, `pending`, a flag menu, a progress line, preload and Undo. Pictures only so far: text, audio and video are the next changes |
|
|
131
131
|
| 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 |
|
|
132
132
|
| 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 |
|
|
133
133
|
| Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `useInfiniteLoad`, `useJob`, `toLoad`, `staleOf`, `fetchJson`, `HttpError`, `readErrorBody`, `fieldErrorsOf` | TanStack Query in, `Load<T>` out; a refetch that fails after a good read stays `ready` with `stale` set, never an error panel; `useInfiniteLoad` works out the cursor itself (after the last item held), merges pages by key and can `dismiss` an item at once; `useJob` polls a job's status only while it runs and invalidates the queries it changes once, when it ends; `fetchJson` reads an error response's body onto the `HttpError` (`body`, `reason`, `fieldErrors`, read by `readErrorBody` or the API's own `readError`) |
|
package/UPGRADING.md
CHANGED
|
@@ -13,6 +13,9 @@ Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Chang
|
|
|
13
13
|
|
|
14
14
|
## After v0.1.17 (2026-11-11 to 2026-11-12)
|
|
15
15
|
|
|
16
|
+
- `MediaPlayer`: the `<audio>`/`<video>` element is now labelled "<label>, audio" (or "video") and the group keeps "<label>"; a test that queried the element by the bare label queries the group or the longer name. With several players on a page, Space, K, J, L and M go to the one last played, focused or pressed (a single player is unchanged); `shortcuts={false}` still opts out.
|
|
17
|
+
- `Switch` and `Checkbox` `detail` is now the control's accessible description, not part of its name: `getByRole("switch", { name: "Show 1 video" })` finds it, and a test that matched the name with a regex to include the detail should query the exact label (and `toHaveAccessibleDescription` for the detail).
|
|
18
|
+
- `renderWithStrata` and `renderRoutes` render a `StrataToastRegion` and clear the toast queue before each render. A test whose route tree already renders the region (a root layout route) passes `toasts: false`, or finds every toast twice.
|
|
16
19
|
- `LineChart` no longer marks its last point "<value> now" when `current` is set (the rule, dot and label at the end of the line are gone; `current` already says where now is). A chart that has `current` and wants the end marked passes `end="now"`; a chart without `current` that does not want it passes `end="none"`. Baselines of charts with `current` change.
|
|
17
20
|
- `SeekBar` with a `duration` of 0, `NaN` or `Infinity` (or `null`, now allowed) is drawn disabled; before it was enabled with the thumb at 0. Nothing to change unless a test seeks a bar with no duration.
|
|
18
21
|
- Arrows and macOS modifiers in `KeysLegend`, `CommandLegend`, menu shortcuts and tooltip hints are drawn as icons, each followed by a screen-reader name (`←` reads "left arrow", `⌘` "Command"), so the text no longer contains the symbol: a test that queries `"j or ↓"` queries `"j or down arrow"`, and `"⌘Z"` is `"Command Z"`. Their baselines change a little.
|
|
@@ -30,6 +33,7 @@ package). `@radix-ui/react-slot` is gone.
|
|
|
30
33
|
- **`@tanstack/react-virtual` is no longer a dependency.** Strata does not need it; if an app imported it through Strata, add it itself.
|
|
31
34
|
- **`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.
|
|
32
35
|
- **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.
|
|
36
|
+
- **`Compare`'s flip shortcut is labelled with the candidates' labels** ("Flip X and Y"), not always "Flip A and B". A test or visual baseline that reads the legend changes.
|
|
33
37
|
- **`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.
|
|
34
38
|
- **`Button` has no `asChild`.** A button that navigates is a link: use a router `Link`.
|
|
35
39
|
Do not rely on `@radix-ui/react-slot` arriving through Strata.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Shortcut } from './hotkeys';
|
|
1
2
|
import { ReadPixels } from './difference';
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
/** A picture to compare. */
|
|
@@ -43,7 +44,11 @@ export type CompareProps = {
|
|
|
43
44
|
modes?: readonly CompareMode[];
|
|
44
45
|
/** Bind the view, zoom and full-screen keys on the window. Default true; turn off when a surrounding screen binds the same keys. */
|
|
45
46
|
keys?: boolean;
|
|
47
|
+
/** Shortcuts of the surrounding screen (the answer keys of a `PairVote`), bound with Compare's own and drawn in the same legend, so there is one list and the two cannot clash unseen. Listed first. */
|
|
48
|
+
extraShortcuts?: Shortcut[];
|
|
49
|
+
/** Drawn under the picture, above the legend, and kept in full screen: where a vote bar goes so the answer is never out of reach of the pictures. */
|
|
50
|
+
footer?: React.ReactNode;
|
|
46
51
|
className?: string;
|
|
47
52
|
};
|
|
48
53
|
/** Two pictures to judge, side by side or laid over each other, zoomed and panned together, and full screen. */
|
|
49
|
-
export declare function Compare({ label, a, b, blind, missing, mode, onModeChange, modes, keys, cannotCompare, readPixels, defaultDifference, className }: CompareProps): React.JSX.Element;
|
|
54
|
+
export declare function Compare({ label, a, b, blind, missing, mode, onModeChange, modes, keys, extraShortcuts, footer, cannotCompare, readPixels, defaultDifference, className }: CompareProps): React.JSX.Element;
|
|
@@ -72,7 +72,7 @@ export type MediaPlayerProps = {
|
|
|
72
72
|
session?: MediaSession;
|
|
73
73
|
/** The playback speeds offered. Default 0.5 to 2; for speech use {@link SPEECH_RATES}. */
|
|
74
74
|
rates?: readonly number[];
|
|
75
|
-
/** Keys on the page (Space or K, J and L for 10 s, M). Default true; turn off when the screen binds its own. */
|
|
75
|
+
/** Keys on the page (Space or K, J and L for 10 s, M). Default true; turn off when the screen binds its own. With several players on a page the keys go to the one last played, focused or pressed. */
|
|
76
76
|
shortcuts?: boolean;
|
|
77
77
|
/** The last source has ended. */
|
|
78
78
|
onEnded?: () => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Candidate, CompareProps } from './compare';
|
|
2
|
+
import { Load } from './data-view';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/** One answer to a pair: a side, "about the same", "can't tell", or a flag with its reason. */
|
|
5
|
+
export type PairAnswer = {
|
|
6
|
+
answer: "a" | "b" | "tie" | "skip";
|
|
7
|
+
} | {
|
|
8
|
+
answer: "flag";
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
/** A pair to judge. */
|
|
12
|
+
export type Pair = {
|
|
13
|
+
label: string;
|
|
14
|
+
a: Candidate;
|
|
15
|
+
b: Candidate;
|
|
16
|
+
};
|
|
17
|
+
/** Words for the vote bar, all in the product's voice. */
|
|
18
|
+
export type PairVoteWords = {
|
|
19
|
+
/** Default "About the same". */
|
|
20
|
+
tie?: string;
|
|
21
|
+
/** Default "Can't tell". */
|
|
22
|
+
skip?: string;
|
|
23
|
+
/** What choosing a side says: `(label) => "Prefer " + label`. Default "Prefer …". */
|
|
24
|
+
prefer?: (label: string) => string;
|
|
25
|
+
/** Said while an answer is being saved. Default "Saving your answer…". */
|
|
26
|
+
pending?: string;
|
|
27
|
+
/** The flag menu's button. Default "Flag this pair". */
|
|
28
|
+
flag?: string;
|
|
29
|
+
};
|
|
30
|
+
/** Props for `PairVote`. */
|
|
31
|
+
export type PairVoteProps = Omit<CompareProps, "label" | "a" | "b" | "extraShortcuts" | "footer"> & {
|
|
32
|
+
/** The pair now being judged, as a read. */
|
|
33
|
+
pair: Load<Pair | null>;
|
|
34
|
+
/** Mirrors the pictures and the bar while the pair loads. Required. */
|
|
35
|
+
skeleton: React.ReactNode;
|
|
36
|
+
/** What to show when there is nothing left to judge, and what to do next. Required. */
|
|
37
|
+
empty: React.ReactNode;
|
|
38
|
+
/** Receives the answer. The caller sends it and sets `pending` meanwhile. */
|
|
39
|
+
onAnswer: (answer: PairAnswer) => void;
|
|
40
|
+
/** An answer is being saved: buttons and keys are off. */
|
|
41
|
+
pending: boolean;
|
|
42
|
+
/** A line above the pictures: "12 pairs left". */
|
|
43
|
+
progress?: React.ReactNode;
|
|
44
|
+
/** Reasons the judge can give for setting a pair aside ("Picture missing", "Not the same scene"); no flag menu without them. */
|
|
45
|
+
flagReasons?: readonly string[];
|
|
46
|
+
/** Addresses of the next pairs' pictures, fetched ahead so the next pair is on screen the moment this one is answered. */
|
|
47
|
+
preload?: readonly string[];
|
|
48
|
+
/** The answer just given: what it was, how to take it back, and what to show of the pair after (`reveal`, never during the judgment). */
|
|
49
|
+
last?: {
|
|
50
|
+
text: string;
|
|
51
|
+
onUndo: () => void;
|
|
52
|
+
reveal?: React.ReactNode;
|
|
53
|
+
};
|
|
54
|
+
words?: PairVoteWords;
|
|
55
|
+
};
|
|
56
|
+
/** A blind pairwise judgment: two pictures in `Compare`, answer keys in its legend, and a vote bar that never leans on either side. */
|
|
57
|
+
export declare function PairVote({ pair, skeleton, empty, onAnswer, pending, progress, flagReasons, preload, last, words, ...compare }: PairVoteProps): React.JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
/** Props for `Switch`. */
|
|
2
3
|
export type SwitchProps = {
|
|
3
4
|
/** What it turns on, as the visible label: "Show elevation profile". Required. */
|
|
@@ -11,4 +12,4 @@ export type SwitchProps = {
|
|
|
11
12
|
className?: string;
|
|
12
13
|
};
|
|
13
14
|
/** An on/off setting that applies at once, its label and control one target. */
|
|
14
|
-
export declare function Switch({ label, detail, on, defaultOn, onChange, disabled, className }: SwitchProps):
|
|
15
|
+
export declare function Switch({ label, detail, on, defaultOn, onChange, disabled, className }: SwitchProps): React.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export { Compare, type CompareProps, type CompareMode, type Candidate, type Imag
|
|
|
65
65
|
export { ViewportFrame, useViewport, type ViewportFrameProps, type ViewportState } from './components/viewport';
|
|
66
66
|
export { FullscreenFrame, canFullscreen, type FullscreenFrameProps } from './components/fullscreen-frame';
|
|
67
67
|
export { FIT, MIN_SCALE, MAX_SCALE, clampViewport, zoomAt, actualPixelsScale, type Viewport } from './lib/viewport';
|
|
68
|
+
export { PairVote, type PairVoteProps, type PairVoteWords, type PairAnswer, type Pair } from './components/pair-vote';
|
|
68
69
|
export { CompareGrid, type CompareGridProps } from './components/compare-grid';
|
|
69
70
|
export { useDifference, type DifferenceState, type ReadPixels } from './components/difference';
|
|
70
71
|
export { differences, readPixels, resample, MAX_SIDE, DEFAULT_TOLERANCE, type Difference, type Pixels } from './lib/image-diff';
|