strata-react 1.0.20 → 1.0.24

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
@@ -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: voting, text, audio and video are the next changes |
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,8 @@ 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
+ - `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.
16
18
  - `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.
17
19
  - 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.
18
20
  - The dim behind a `Dialog`, `AlertDialog`, `CommandMenu` and full-screen view is black at an alpha (the `scrim` utility), not `foreground`: in a dark theme it now dims the page instead of brightening it. Dark baselines of anything with an open overlay change.
@@ -29,6 +31,7 @@ package). `@radix-ui/react-slot` is gone.
29
31
  - **`@tanstack/react-virtual` is no longer a dependency.** Strata does not need it; if an app imported it through Strata, add it itself.
30
32
  - **`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.
31
33
  - **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.
34
+ - **`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.
32
35
  - **`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.
33
36
  - **`Button` has no `asChild`.** A button that navigates is a link: use a router `Link`.
34
37
  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;
@@ -34,6 +34,8 @@ export type LineChartProps = {
34
34
  }[];
35
35
  /** Says what the colours mean, shown beside the legend swatch when `colourScale` is set. */
36
36
  colourScaleLabel?: string;
37
+ /** What the end of the line is. `"now"` marks the last reading with a rule, a dot and "<value> now": right for a live reading, where the last point is the present. `"none"` leaves it unmarked: right for a series whose x is not time running up to now (an elevation profile, where the last point is the finish). Default `"now"`, or `"none"` when `current` is set, since `current` already says where now is. The peak label stays either way. */
38
+ end?: "now" | "none";
37
39
  /** 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. */
38
40
  current?: number;
39
41
  /** The value at the rule, as a sentence part. Default: `formatX` and the value read off the line. */
@@ -69,4 +71,4 @@ export declare function yScale(values: number[], pin?: {
69
71
  */
70
72
  export declare function fitTicks(ticks: number[], scale: (x: number) => number, widthOf: (t: number) => number, gap?: number): number[];
71
73
  /** 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`. */
72
- export declare function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel, formatY, xTicks, yMin, yMax, colour, colourScale, colourScaleLabel, current, formatCurrent, readout, onPick, area, height, className, }: LineChartProps): React.JSX.Element;
74
+ export declare function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel, formatY, xTicks, yMin, yMax, colour, colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, height, className, }: LineChartProps): 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;
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';
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { a as toLoad, c as describeActionError, d as readErrorBody, i as staleOf
4
4
  import * as React from "react";
5
5
  import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, I18nProvider, Input as Input$1, Keyboard, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, NumberField as NumberField$1, Popover as Popover$1, Row, SearchField, Separator, Slider as Slider$1, SliderOutput, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Toolbar as Toolbar$1, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
6
6
  import { cva } from "class-variance-authority";
7
- import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronRight, CircleAlert, CircleCheck, FileQuestion, GripVertical, History, ImageOff, Info, Loader, LoaderCircle, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Play, Redo2, RotateCcw, Scan, Search, SkipBack, SkipForward, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
7
+ import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronRight, CircleAlert, CircleCheck, FileQuestion, Flag, GripVertical, History, ImageOff, Info, Loader, LoaderCircle, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Play, Redo2, RotateCcw, Scan, Search, SkipBack, SkipForward, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { Link, NavLink, useSearchParams } from "react-router";
10
10
  import { createSortedRowModel, flexRender, rowSortingFeature, tableFeatures, useTable } from "@tanstack/react-table";
@@ -3351,6 +3351,48 @@ function useMediaElement(ref) {
3351
3351
  read
3352
3352
  ]);
3353
3353
  }
3354
+ var keyPlayers = (() => {
3355
+ const ids = /* @__PURE__ */ new Set();
3356
+ let active = null;
3357
+ let warned = false;
3358
+ const listeners = /* @__PURE__ */ new Set();
3359
+ let snapshot = {
3360
+ count: 0,
3361
+ active: null
3362
+ };
3363
+ const emit = () => {
3364
+ snapshot = {
3365
+ count: ids.size,
3366
+ active
3367
+ };
3368
+ listeners.forEach((l) => l());
3369
+ };
3370
+ return {
3371
+ subscribe: (l) => {
3372
+ listeners.add(l);
3373
+ return () => void listeners.delete(l);
3374
+ },
3375
+ get: () => snapshot,
3376
+ add(id) {
3377
+ ids.add(id);
3378
+ if (ids.size === 2 && !warned && typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
3379
+ warned = true;
3380
+ console.warn("strata-react: several MediaPlayers are on this page, so Space, K, J, L and M go to the one last played or focused. Pass shortcuts={false} to one you bind your own keys for.");
3381
+ }
3382
+ emit();
3383
+ },
3384
+ remove(id) {
3385
+ ids.delete(id);
3386
+ if (active === id) active = null;
3387
+ emit();
3388
+ },
3389
+ use(id) {
3390
+ if (active === id || !ids.has(id)) return;
3391
+ active = id;
3392
+ emit();
3393
+ }
3394
+ };
3395
+ })();
3354
3396
  /** Playback speeds an audiobook or lecture listener expects. */
3355
3397
  var SPEECH_RATES = [
3356
3398
  .75,
@@ -3473,7 +3515,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3473
3515
  React.useEffect(() => {
3474
3516
  if (onTimeChange) onTimeChange(time);
3475
3517
  }, [time]);
3476
- useHotkeys(React.useMemo(() => [
3518
+ const keys = React.useMemo(() => [
3477
3519
  {
3478
3520
  keys: [" ", "k"],
3479
3521
  label: "Play or pause",
@@ -3501,7 +3543,27 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3501
3543
  time,
3502
3544
  offsets,
3503
3545
  index
3504
- ]), { enabled: shortcuts && !native });
3546
+ ]);
3547
+ const id = React.useId();
3548
+ React.useEffect(() => {
3549
+ if (!shortcuts || native) return;
3550
+ keyPlayers.add(id);
3551
+ return () => keyPlayers.remove(id);
3552
+ }, [
3553
+ id,
3554
+ shortcuts,
3555
+ native
3556
+ ]);
3557
+ const page = React.useSyncExternalStore(keyPlayers.subscribe, keyPlayers.get, keyPlayers.get);
3558
+ React.useEffect(() => {
3559
+ if (media.playing && shortcuts && !native) keyPlayers.use(id);
3560
+ }, [
3561
+ media.playing,
3562
+ id,
3563
+ shortcuts,
3564
+ native
3565
+ ]);
3566
+ useHotkeys(keys, { enabled: shortcuts && !native && (page.count <= 1 || page.active === id) });
3505
3567
  React.useEffect(() => {
3506
3568
  if (!session || typeof navigator === "undefined" || !("mediaSession" in navigator) || typeof MediaMetadata === "undefined") return;
3507
3569
  const s = navigator.mediaSession;
@@ -3556,7 +3618,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3556
3618
  controls: native,
3557
3619
  autoPlay,
3558
3620
  preload: "metadata",
3559
- "aria-label": label
3621
+ "aria-label": `${label}, ${kind}`
3560
3622
  };
3561
3623
  const element = kind === "video" ? /* @__PURE__ */ jsx("video", {
3562
3624
  ...common,
@@ -3571,6 +3633,8 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3571
3633
  return /* @__PURE__ */ jsxs("div", {
3572
3634
  role: "group",
3573
3635
  "aria-label": label,
3636
+ onFocusCapture: () => keyPlayers.use(id),
3637
+ onPointerDownCapture: () => keyPlayers.use(id),
3574
3638
  className: cn("grid w-full gap-2", className),
3575
3639
  children: [
3576
3640
  element,
@@ -5452,7 +5516,7 @@ function fitTicks(ticks, scale, widthOf, gap = 12) {
5452
5516
  return sorted.slice(0, 1);
5453
5517
  }
5454
5518
  /** 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`. */
5455
- function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel = "Time", formatY, xTicks, yMin, yMax, colour = "var(--chart-1)", colourScale, colourScaleLabel, current, formatCurrent, readout, onPick, area, height = 280, className }) {
5519
+ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel = "Time", formatY, xTicks, yMin, yMax, colour = "var(--chart-1)", colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, height = 280, className }) {
5456
5520
  const [ref, width] = useWidth();
5457
5521
  const gradientId = `heat-${React.useId().replace(/[^\w-]/g, "")}`;
5458
5522
  const all = [...series, ...planned ?? []];
@@ -5486,6 +5550,7 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
5486
5550
  ]);
5487
5551
  const path = (pts) => pts.map((p, i) => `${i ? "L" : "M"}${sx(p.x).toFixed(1)},${sy(p.y).toFixed(1)}`).join("");
5488
5552
  const last = series[series.length - 1];
5553
+ const showEnd = (end ?? (current === void 0 ? "now" : "none")) === "now";
5489
5554
  const peak = series.reduce((a, b) => b.y > a.y ? b : a, series[0]);
5490
5555
  const stops = colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : [];
5491
5556
  /** The colour a value lands on: the highest stop at or below it. Used for the labelled points. */
@@ -5571,27 +5636,29 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
5571
5636
  className: "fill-foreground type-caption tabular-nums",
5572
5637
  children: [formatY(peak.y), " peak"]
5573
5638
  }),
5574
- /* @__PURE__ */ jsx("line", {
5575
- x1: sx(last.x),
5576
- x2: sx(last.x),
5577
- y1: pad.top,
5578
- y2: pad.top + h,
5579
- stroke: "var(--foreground)",
5580
- strokeWidth: 1
5581
- }),
5582
- /* @__PURE__ */ jsx("circle", {
5583
- cx: sx(last.x),
5584
- cy: sy(last.y),
5585
- r: 3.5,
5586
- fill: colourAt(last.y)
5587
- }),
5588
- /* @__PURE__ */ jsxs("text", {
5589
- x: sx(last.x) - 8,
5590
- y: sy(last.y) - 10,
5591
- textAnchor: "end",
5592
- className: "fill-foreground type-label tabular-nums",
5593
- children: [formatY(last.y), " now"]
5594
- })
5639
+ showEnd && /* @__PURE__ */ jsxs(Fragment, { children: [
5640
+ /* @__PURE__ */ jsx("line", {
5641
+ x1: sx(last.x),
5642
+ x2: sx(last.x),
5643
+ y1: pad.top,
5644
+ y2: pad.top + h,
5645
+ stroke: "var(--foreground)",
5646
+ strokeWidth: 1
5647
+ }),
5648
+ /* @__PURE__ */ jsx("circle", {
5649
+ cx: sx(last.x),
5650
+ cy: sy(last.y),
5651
+ r: 3.5,
5652
+ fill: colourAt(last.y)
5653
+ }),
5654
+ /* @__PURE__ */ jsxs("text", {
5655
+ x: sx(last.x) - 8,
5656
+ y: sy(last.y) - 10,
5657
+ textAnchor: "end",
5658
+ className: "fill-foreground type-label tabular-nums",
5659
+ children: [formatY(last.y), " now"]
5660
+ })
5661
+ ] })
5595
5662
  ] }), [
5596
5663
  width,
5597
5664
  height,
@@ -5605,7 +5672,8 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
5605
5672
  colourScale,
5606
5673
  formatX,
5607
5674
  formatY,
5608
- area
5675
+ area,
5676
+ showEnd
5609
5677
  ]);
5610
5678
  const tableEl = React.useMemo(() => /* @__PURE__ */ jsx("div", {
5611
5679
  className: "sr-only",
@@ -7046,7 +7114,7 @@ var ALL_MODES = [
7046
7114
  "difference"
7047
7115
  ];
7048
7116
  /** Two pictures to judge, side by side or laid over each other, zoomed and panned together, and full screen. */
7049
- function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_MODES, keys = true, cannotCompare = "Could not read these pictures to compare their pixels.", readPixels, defaultDifference = "brightness", className }) {
7117
+ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_MODES, keys = true, extraShortcuts = [], footer, cannotCompare = "Could not read these pictures to compare their pixels.", readPixels, defaultDifference = "brightness", className }) {
7050
7118
  const { viewport, setViewport } = useViewport();
7051
7119
  const [full, setFull] = React.useState(false);
7052
7120
  const pairKey = `${a.media.src}|${b.media.src}`;
@@ -7071,6 +7139,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
7071
7139
  const flip = () => setShowing((s) => s === "a" ? "b" : "a");
7072
7140
  const offered = modes.includes(mode) ? modes : [mode, ...modes];
7073
7141
  const shortcuts = [
7142
+ ...extraShortcuts,
7074
7143
  ...offered.map((m, i) => ({
7075
7144
  keys: [String(i + 1)],
7076
7145
  label: MODE_LABEL[m],
@@ -7078,7 +7147,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
7078
7147
  })),
7079
7148
  {
7080
7149
  keys: ["x"],
7081
- label: "Flip A and B",
7150
+ label: `Flip ${a.label} and ${b.label}`,
7082
7151
  run: flip,
7083
7152
  disabled: mode !== "blink"
7084
7153
  },
@@ -7360,11 +7429,162 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
7360
7429
  size: "sm"
7361
7430
  }) }),
7362
7431
  body,
7432
+ footer,
7363
7433
  keys && /* @__PURE__ */ jsx(KeysLegend, { shortcuts })
7364
7434
  ]
7365
7435
  })
7366
7436
  });
7367
7437
  }
7438
+ // src/components/pair-vote.tsx
7439
+ /** A blind pairwise judgment: two pictures in `Compare`, answer keys in its legend, and a vote bar that never leans on either side. */
7440
+ function PairVote({ pair, skeleton, empty, onAnswer, pending, progress, flagReasons, preload, last, words = {}, ...compare }) {
7441
+ React.useEffect(() => {
7442
+ for (const src of preload ?? []) new Image().src = src;
7443
+ }, [preload]);
7444
+ const w = {
7445
+ tie: "About the same",
7446
+ skip: "Can't tell",
7447
+ pending: "Saving your answer…",
7448
+ flag: "Flag this pair",
7449
+ prefer: (l) => `Prefer ${l}`,
7450
+ ...words
7451
+ };
7452
+ return /* @__PURE__ */ jsxs("div", {
7453
+ className: "grid gap-3",
7454
+ children: [
7455
+ progress && /* @__PURE__ */ jsx("p", {
7456
+ className: "type-body-sm text-muted-foreground",
7457
+ children: progress
7458
+ }),
7459
+ /* @__PURE__ */ jsx(DataView, {
7460
+ state: pair,
7461
+ isEmpty: (p) => p === null,
7462
+ skeleton,
7463
+ empty,
7464
+ children: (p) => p && /* @__PURE__ */ jsx(Judged, {
7465
+ pair: p,
7466
+ onAnswer,
7467
+ pending,
7468
+ flagReasons,
7469
+ words: w,
7470
+ last,
7471
+ compare
7472
+ })
7473
+ }),
7474
+ last && !(pair.status === "ready" && pair.data) && /* @__PURE__ */ jsx(LastAnswer, { last })
7475
+ ]
7476
+ });
7477
+ }
7478
+ function LastAnswer({ last }) {
7479
+ return /* @__PURE__ */ jsxs("div", {
7480
+ role: "status",
7481
+ className: "flex flex-wrap items-center gap-3 type-body-sm text-muted-foreground",
7482
+ children: [
7483
+ /* @__PURE__ */ jsx("span", { children: last.text }),
7484
+ /* @__PURE__ */ jsx(Button, {
7485
+ size: "sm",
7486
+ variant: "ghost",
7487
+ onPress: last.onUndo,
7488
+ children: "Undo"
7489
+ }),
7490
+ last.reveal
7491
+ ]
7492
+ });
7493
+ }
7494
+ function Judged({ pair, onAnswer, pending, flagReasons, words, last, compare }) {
7495
+ const { a, b } = pair;
7496
+ const answer = (x) => !pending && onAnswer(x);
7497
+ const shortcuts = [
7498
+ {
7499
+ keys: ["a"],
7500
+ label: words.prefer(a.label),
7501
+ run: () => answer({ answer: "a" }),
7502
+ disabled: pending
7503
+ },
7504
+ {
7505
+ keys: ["b"],
7506
+ label: words.prefer(b.label),
7507
+ run: () => answer({ answer: "b" }),
7508
+ disabled: pending
7509
+ },
7510
+ {
7511
+ keys: ["t"],
7512
+ label: words.tie,
7513
+ run: () => answer({ answer: "tie" }),
7514
+ disabled: pending
7515
+ },
7516
+ {
7517
+ keys: ["s"],
7518
+ label: words.skip,
7519
+ run: () => answer({ answer: "skip" }),
7520
+ disabled: pending
7521
+ }
7522
+ ];
7523
+ const footer = /* @__PURE__ */ jsxs("div", {
7524
+ className: cn("grid gap-2"),
7525
+ "aria-busy": pending || void 0,
7526
+ children: [
7527
+ /* @__PURE__ */ jsxs("div", {
7528
+ role: "group",
7529
+ "aria-label": "Your answer",
7530
+ className: "flex flex-wrap items-center gap-2",
7531
+ children: [
7532
+ /* @__PURE__ */ jsx(Button, {
7533
+ disabled: pending,
7534
+ onPress: () => answer({ answer: "a" }),
7535
+ children: words.prefer(a.label)
7536
+ }),
7537
+ /* @__PURE__ */ jsx(Button, {
7538
+ disabled: pending,
7539
+ onPress: () => answer({ answer: "tie" }),
7540
+ children: words.tie
7541
+ }),
7542
+ /* @__PURE__ */ jsx(Button, {
7543
+ disabled: pending,
7544
+ onPress: () => answer({ answer: "b" }),
7545
+ children: words.prefer(b.label)
7546
+ }),
7547
+ /* @__PURE__ */ jsx(Button, {
7548
+ variant: "ghost",
7549
+ disabled: pending,
7550
+ onPress: () => answer({ answer: "skip" }),
7551
+ children: words.skip
7552
+ }),
7553
+ flagReasons && flagReasons.length > 0 && /* @__PURE__ */ jsx(Menu, {
7554
+ label: words.flag,
7555
+ trigger: /* @__PURE__ */ jsxs(Button, {
7556
+ variant: "ghost",
7557
+ disabled: pending,
7558
+ children: [/* @__PURE__ */ jsx(Flag, { "aria-hidden": true }), words.flag]
7559
+ }),
7560
+ items: flagReasons.map((reason) => ({
7561
+ id: reason,
7562
+ label: reason,
7563
+ run: () => answer({
7564
+ answer: "flag",
7565
+ reason
7566
+ })
7567
+ }))
7568
+ })
7569
+ ]
7570
+ }),
7571
+ pending && /* @__PURE__ */ jsx("p", {
7572
+ role: "status",
7573
+ className: "type-body-sm text-muted-foreground",
7574
+ children: words.pending
7575
+ }),
7576
+ last && /* @__PURE__ */ jsx(LastAnswer, { last })
7577
+ ]
7578
+ });
7579
+ return /* @__PURE__ */ jsx(Compare, {
7580
+ ...compare,
7581
+ label: pair.label,
7582
+ a,
7583
+ b,
7584
+ extraShortcuts: shortcuts,
7585
+ footer
7586
+ });
7587
+ }
7368
7588
  // src/components/compare-grid.tsx
7369
7589
  var COLUMNS = {
7370
7590
  2: "sm:grid-cols-2",
@@ -8097,6 +8317,6 @@ function SaveStatus({ state, onRetry, className }) {
8097
8317
  ]
8098
8318
  });
8099
8319
  }
8100
- export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareGrid, CompositionBar, ContextMenu, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, differences, fetchJson, fieldErrorsOf, format, formatChord, geo, isReservedChord, isTypingTarget, labelOf, matchesAccept, matchesChord, noOverlap, parseChord, parseSort, readErrorBody, readPixels, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, zoomAt };
8320
+ export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareGrid, CompositionBar, ContextMenu, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairVote, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, differences, fetchJson, fieldErrorsOf, format, formatChord, geo, isReservedChord, isTypingTarget, labelOf, matchesAccept, matchesChord, noOverlap, parseChord, parseSort, readErrorBody, readPixels, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, zoomAt };
8101
8321
 
8102
8322
  //# sourceMappingURL=index.js.map