strata-react 1.0.9 → 1.0.11

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 CHANGED
@@ -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 lists virtualise from 100 rows; 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 |
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 lists virtualise from 100 rows; 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 |
@@ -134,6 +134,7 @@ function KilnRoom() {
134
134
  | Overlays | `Dialog`, `DialogProps`, `AlertDialog`, `Popover`, `Tooltip` | React Aria underneath. A dialog always has a title and, via `actions`'s close render prop, a way out; `closable={false}` while work cannot stop; `placement="end"` is a sheet. `AlertDialog` is the only confirm: required verb on the confirm button, Cancel focused first, no outside dismiss, stays open with the reason when an async confirm fails. `Popover` needs a `label`. `Tooltip` opens on hover and focus and `IconButton` uses it. All portal onto the `layer-*` stacking utilities |
135
135
  | Value controls | `NumberField`, `Slider`, `ColorField` | Set a number or colour precisely, inside `Field`. `NumberField` and `Slider` are React Aria's; the number field runs with `commitBehavior="validate"`, so a typed value outside `min`/`max` is kept on screen, explained in the `Field` ("Enter a value from 0% to 500%.") and never passed to `onChange`. A value that is not known is `null` and shows an en dash, never 0 or NaN. Digits and decimal mark follow `locale`. The unit sits inside the control, and in the slider's spoken value when `Intl` has it (%, °, ms, s, kB, MB, GB, kbps, Mbps). Arrows step, Home/End jump to the limits; `Slider editable` adds a number field. `ColorField`: platform picker, typed hex that is normalised, app suggestions, and a contrast note against `against`. No motion on value changes |
136
136
  | Notices and progress | `Alert`, `toast`, `StrataToastRegion`, `useClientWork`, `JobStatus` | Three weights. A `toast` confirms finished work and goes by itself (5 s plus 40 ms a character, 8 s minimum with an action, paused under the pointer or focus, always dismissable); it has no danger tone, because an error a person must act on is an inline `Alert` with its recovery as `action` (`announce` makes it `role="alert"` only when it answers something the person just did). `StrataToastRegion` goes once at the app root. `useClientWork` runs browser work with progress, cancel (aborts its `signal`, ends `cancelled`, never `failed`) and a double-start guard; `JobStatus` shows it exactly as it shows a server job, with `onCancel`, `cancelled` and `onDismiss` |
137
+ | Media playback | `Transport`, `SeekBar`, `TimeReadout`, `VolumeControl`, `RateChoice`, `MediaStage`, `StageGuides`, `transportShortcuts`, `format.timecode` | The controls around anything that plays, wired to a player the app owns (HTML media, Web Audio, a canvas, a data replay). Every control is a named icon button in one toolbar; the play button's name is "Play" or "Pause". `SeekBar` has the formatted time as its accessible value, arrows step 5 s and Page keys 30 s by default, and optional marks. `VolumeControl` shows its percent, and muting remembers the level. `transportShortcuts` is the one list for `useHotkeys` and `KeysLegend` (Space and K, J and L, the arrows by a frame, Home and End). `format.timecode` prints m:ss, m:ss.mmm or m:ss:ff. `MediaStage` fits a picture of any aspect ratio into the pane with a letterbox on the sunken surface role, and takes overlays such as `StageGuides` |
137
138
  | Timeline | `Timeline`, `useTimelineZoom`, `TimelineZoomControls`, `noOverlap` | Items with a start and a length in lanes on a zoomable time axis, for media edits, bookings, rotas and plans. The timeline draws and the app decides: every move, trim, lane change, selection and current-time change is reported (`onItemChange`, `onSelect`, `onPositionChange`) and the app applies it; `validate` refuses a change with a reason shown in words while it is made. One tab stop for the items; arrows move between them, Ctrl+arrows nudge and change lane, Alt+arrows trim, the current time is its own slider, `+` `-` `0` zoom, and each change is announced ("run-02.mp4 moved to 0:13"). The ruler picks steps people write on a scale so labels never collide. Only items near the view are rendered |
138
139
  | Sortable list | `SortableList` | Reorder a list and move items between lists, by pointer and by keyboard. React Aria's `GridList` with `useDragAndDrop` (no `@dnd-kit`): a grip per row is the drag handle, so clicking a row selects it and its own actions still work; Enter on the grip picks up, arrows and Tab choose a position or list, Enter drops, Escape cancels, with React Aria's screen-reader announcements. Items carry a kind (`getKind`); a list takes the kinds in `accepts` and says why it refuses another (`refuses`, shown with an icon while that kind is dragged over it). The list never changes the data: `onReorder` and `onInsert` report the move and the app applies it, undoably |
139
140
  | File intake | `FileButton`, `FileDropZone`, `FileOutcomes`, `MissingFile`, `useFileIntake` | Pick or drop local files, then one outcome per file. `FileButton` is React Aria's `FileTrigger` behind a real named button (the keyboard and phone route); `FileDropZone` is its `DropZone` and says what it takes while a drag is over it. `useFileIntake({ accept, acceptLabel, process })` judges each file after the drop, so a wrong one is named with its reason (type, `maxBytes`, your `check`), runs your own `process` per file (a throw becomes `Failed` with its message and a retry), and never blocks the rest. `FileOutcomes` draws the rows and announces one summary per batch. `MissingFile` is a status word and a "Relink" that opens the picker for that item. Nothing assumes a server |
package/UPGRADING.md CHANGED
@@ -16,6 +16,7 @@ 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
+ - **`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.
19
20
  - **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.
20
21
  - **`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.
21
22
  - **`Button` has no `asChild`.** A button that navigates is a link: use a router `Link`.
@@ -32,6 +32,19 @@ export type LineChartProps = {
32
32
  }[];
33
33
  /** Says what the colours mean, shown beside the legend swatch when `colourScale` is set. */
34
34
  colourScaleLabel?: string;
35
+ /** The current x, supplied by the app and drawn as a rule with its value ("now" in a replay, a playhead). Cheap to update often. */
36
+ current?: number;
37
+ /** The value at the rule, as a sentence part. Default: `formatX` and the value read off the line. */
38
+ formatCurrent?: (at: {
39
+ x: number;
40
+ y: number;
41
+ }) => string;
42
+ /** Read values at the pointer, and by keyboard on the plot (arrows, Home, End). `readout` words the reading; default `formatX: formatY`. */
43
+ readout?: boolean | ((p: Point) => string);
44
+ /** The viewer chose a reading (a click, or Enter on the plot): its x, so the app can seek or select. */
45
+ onPick?: (x: number) => void;
46
+ /** One flat, pale tint under the line. Only where the area carries the meaning (a profile, a running total). */
47
+ area?: boolean;
35
48
  height?: number;
36
49
  className?: string;
37
50
  };
@@ -54,4 +67,4 @@ export declare function yScale(values: number[], pin?: {
54
67
  */
55
68
  export declare function fitTicks(ticks: number[], scale: (x: number) => number, widthOf: (t: number) => number, gap?: number): number[];
56
69
  /** One measured series, drawn in real pixels, with the peak and current readings labelled on the chart and every reading in a screen-reader table. Optional plan, threshold band and `colourScale`. */
57
- export declare function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, formatY, xTicks, yMin, yMax, colour, colourScale, colourScaleLabel, height, className, }: LineChartProps): React.JSX.Element;
70
+ export declare function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, formatY, xTicks, yMin, yMax, colour, colourScale, colourScaleLabel, current, formatCurrent, readout, onPick, area, height, className, }: LineChartProps): React.JSX.Element;
@@ -0,0 +1,99 @@
1
+ import { Shortcut } from './hotkeys';
2
+ import * as React from "react";
3
+ export type Precision = "seconds" | "ms" | "frames";
4
+ type TimeProps = {
5
+ precision?: Precision;
6
+ fps?: number;
7
+ };
8
+ /** The current and total time, in `tabular-nums`, as `<time>` elements. */
9
+ export declare function TimeReadout({ time, duration, precision, fps, className }: {
10
+ time: number;
11
+ duration: number | null;
12
+ } & TimeProps & {
13
+ className?: string;
14
+ }): React.JSX.Element;
15
+ export type SeekBarProps = TimeProps & {
16
+ time: number;
17
+ duration: number;
18
+ /** The viewer asked for this time (drag, click or key). */
19
+ onSeek: (time: number) => void;
20
+ /** Named points on the bar (chapters, markers). Pressing one seeks to it. */
21
+ marks?: readonly {
22
+ time: number;
23
+ label: string;
24
+ }[];
25
+ /** How far has loaded or been recorded, drawn behind the played part. */
26
+ buffered?: number;
27
+ /** Arrow key step in seconds. Default 5. */
28
+ step?: number;
29
+ /** Page Up and Page Down step in seconds. Default 30. */
30
+ bigStep?: number;
31
+ label?: string;
32
+ disabled?: boolean;
33
+ className?: string;
34
+ };
35
+ /** A seek bar: dragged, clicked and moved by keys (arrows `step`, Page keys `bigStep`, Home and End), with its time as the accessible value. */
36
+ export declare function SeekBar({ time, duration, onSeek, marks, buffered, step, bigStep, label, precision, fps, disabled, className }: SeekBarProps): React.JSX.Element;
37
+ export type TransportProps = {
38
+ playing: boolean;
39
+ onPlayPause: () => void;
40
+ onStop?: () => void;
41
+ onToStart?: () => void;
42
+ onToEnd?: () => void;
43
+ onStepBack?: () => void;
44
+ onStepForward?: () => void;
45
+ /** What a step is called in the buttons' names: "frame" (default) or "second". */
46
+ stepUnit?: string;
47
+ /** Anything else on the row: the time readout, a seek bar, volume. */
48
+ children?: React.ReactNode;
49
+ className?: string;
50
+ };
51
+ /** The transport buttons for a player the app owns. Every control is a named icon button; the play button's name is "Play" or "Pause" from `playing`. Only the buttons whose handler is passed are drawn. */
52
+ export declare function Transport({ playing, onPlayPause, onStop, onToStart, onToEnd, onStepBack, onStepForward, stepUnit, children, className }: TransportProps): React.JSX.Element;
53
+ export type VolumeControlProps = {
54
+ /** 0 to 100. */
55
+ volume: number;
56
+ onVolumeChange: (volume: number) => void;
57
+ /** Allow over 100 (a boost), up to this. Default 100. */
58
+ max?: number;
59
+ disabled?: boolean;
60
+ className?: string;
61
+ };
62
+ /** A mute button and a volume slider with its value in percent. Muting sets the volume to 0 and remembers the level; unmuting puts it back. Moving the slider from 0 unmutes. */
63
+ export declare function VolumeControl({ volume, onVolumeChange, max, disabled, className }: VolumeControlProps): React.JSX.Element;
64
+ /** A choice of playback speed ("0.5×", "1×", "1.5×") on a native select, named "Playback speed". */
65
+ export declare function RateChoice({ rate, onRateChange, rates, className }: {
66
+ rate: number;
67
+ onRateChange: (rate: number) => void;
68
+ rates?: readonly number[];
69
+ className?: string;
70
+ }): React.JSX.Element;
71
+ /**
72
+ * The shortcuts a player takes, as one list for `useHotkeys` and `KeysLegend`: Space and K play
73
+ * or pause, J and L go back or forward `jump` seconds, the arrows by `frame` seconds, Home and End
74
+ * to the ends, M mutes. Pass the player's actions; the labels are the legend's words.
75
+ */
76
+ export declare function transportShortcuts({ toggle, seek, time, duration, frame, jump, toggleMute }: {
77
+ toggle: () => void;
78
+ seek: (time: number) => void;
79
+ time: number;
80
+ duration: number;
81
+ frame?: number;
82
+ jump?: number;
83
+ toggleMute?: () => void;
84
+ }): Shortcut[];
85
+ /** A frame that fits content of an aspect ratio into the pane, letterboxed on the sunken surface role (light and dark both), with room for the app's overlays. */
86
+ export declare function MediaStage({ aspect, children, label, className }: {
87
+ aspect: number | `${number}/${number}`;
88
+ children: React.ReactNode;
89
+ label: string;
90
+ className?: string;
91
+ }): React.JSX.Element;
92
+ /** Guides over a stage: action-safe and title-safe frames (90% and 80%), a centre cross and a rule-of-thirds grid. Drawn as two strokes (light over dark) so they read on any picture. */
93
+ export declare function StageGuides({ safe, thirds, centre, className }: {
94
+ safe?: boolean;
95
+ thirds?: boolean;
96
+ centre?: boolean;
97
+ className?: string;
98
+ }): React.JSX.Element;
99
+ export {};
@@ -1,16 +1,19 @@
1
1
  import * as React from "react";
2
- /** A list that renders only its visible rows (TanStack Virtual) from `virtualizeFrom` items, keeping list semantics for screen readers. */
3
- export declare function VirtualList<T>({ label, items, itemKey, children, estimateSize, height, virtualizeFrom, bounded, footer, className, }: {
2
+ /** A list that renders only its visible rows (React Aria's GridList and Virtualizer) from `virtualizeFrom` items, with arrow-key navigation between rows. */
3
+ export declare function VirtualList<T>({ label, items, itemKey, children, estimateSize, rowHeight, height, virtualizeFrom, bounded, footer, className, }: {
4
4
  label: string;
5
5
  items: T[];
6
6
  itemKey: (item: T) => string;
7
7
  children: (item: T, index: number) => React.ReactNode;
8
+ /** First-paint height of a row, in px; rows are measured after they render. */
8
9
  estimateSize?: number;
10
+ /** Every row is exactly this tall (px): nothing is measured. */
11
+ rowHeight?: number;
9
12
  height?: number;
10
13
  virtualizeFrom?: number;
11
- /** Scroll inside a region capped at `height` even below `virtualizeFrom`, so growing past it changes nothing on screen. */
14
+ /** Scroll inside a box capped at `height` even below `virtualizeFrom`, so growing past it changes nothing on screen. */
12
15
  bounded?: boolean;
13
- /** After the last row, inside the scroll region (a next-page row, an end note). */
16
+ /** After the last row, inside the scroll box (a next-page row, an end note). */
14
17
  footer?: React.ReactNode;
15
18
  className?: string;
16
19
  }): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -34,6 +34,7 @@ export { useClientWork, type ClientWork, type WorkContext, type WorkPhase } from
34
34
  export { JobStatus, type JobStatusProps, type JobFailure, type JobWords } from './components/job-status';
35
35
  export { Thumbnail, ThumbnailSkeleton, type ThumbnailProps, type AspectRatio } from './components/thumbnail';
36
36
  export { DataTable, TableSkeleton, parseSort, serialiseSort, type CellValue, type Column, type Sort, type DataTableProps, type RowSelection, type RowExpansion, } from './components/data-table';
37
+ export { Transport, TimeReadout, SeekBar, VolumeControl, RateChoice, MediaStage, StageGuides, transportShortcuts, type TransportProps, type SeekBarProps, type VolumeControlProps, type Precision } from './components/media';
37
38
  export { Timeline, TimelineZoomControls, useTimelineZoom, noOverlap, type TimelineProps, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelineChange } from './components/timeline';
38
39
  export { tickStep, ticksBetween, tickLabel } from './lib/timeline';
39
40
  export { SortableList, type SortableListProps, type DropTarget } from './components/sortable-list';