strata-react 1.0.35 → 1.0.37

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
@@ -129,7 +129,7 @@ strata-react is ESM-only (`exports` has only `import`), as is its peer `react-ro
129
129
  | 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 |
130
130
  | 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 |
131
131
  | 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 |
132
- | Compare | `Compare`, `PairVote`, `PairJudge`, `CompareAudio`, `CompareText`, `CompareGrid`, `CompareVideoGrid`, `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. `CompareAudio` is one transport for two clips with an A/B switch that keeps the playhead (same time, or the same share when the lengths differ), a loop range and loudness matching (the louder clip turned down to the quieter, by RMS); `CompareText` is two texts scrolled together with a word diff and an optional reference; `PairJudge` is the answering around any of them; `CompareVideo` is two videos on one clock (play, pause, seek and speed drive both, the follower kept within a frame, both held while either waits for data) in side by side, swipe, fade and blink, with zoom and pan locked and nearest-neighbour pixels past 1:1, candidates of different sizes drawn in one box, one soundtrack (`audio`), and the same slots as the rest. Frame by frame (`,` `.`), a loop range the app can hold (`i` `o` `c`), speeds down to 0.1 and named `moments` are in it; `CompareVideoGrid` is every candidate's video at once on that one clock (one transport, one zoom, regions, a loop, stepping), light on the browser (metadata only until the first play, cells out of sight paused and left out of the sync, sound off unless `audio` names a cell, a cell that falls behind marked "Catching up"), with an optional `reference` drawn first, never blind and nearest-neighbour. `regions` (on `Compare`, `CompareVideo` and `CompareGrid`) names boxes in the source's coordinates to look at enlarged: chips, keys `q` `w` `e` `r` `y` `u`, nearest-neighbour drawing, the box outlined while its chip is pointed at, and Shift-drag to make another |
132
+ | Compare | `Compare`, `PairVote`, `PairJudge`, `CompareAudio`, `CompareText`, `CompareGrid`, `CompareVideoGrid`, `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, and click to choose (a click on the picture you prefer, not a drag or double click; in swipe the side of the divider, in blink the side showing, none in fade or difference; `onPick` on `Compare` and `CompareVideo`, `pick={false}` turns it off). `CompareAudio` is one transport for two clips with an A/B switch that keeps the playhead (same time, or the same share when the lengths differ), a loop range and loudness matching (the louder clip turned down to the quieter, by RMS); `CompareText` is two texts scrolled together with a word diff and an optional reference; `PairJudge` is the answering around any of them; `CompareVideo` is two videos on one clock (play, pause, seek and speed drive both, the follower kept within a frame, both held while either waits for data) in side by side, swipe, fade and blink, with zoom and pan locked and nearest-neighbour pixels past 1:1, candidates of different sizes drawn in one box, one soundtrack (`audio`), and the same slots as the rest. `autoPlay` starts the pair once both can play (muted; not with reduced motion unless `"always"`) and `loopWhole` loops the whole clip when no range is set (also on `CompareVideoGrid`). Frame by frame (`,` `.`), a loop range the app can hold (`i` `o` `c`), speeds down to 0.1 and named `moments` are in it; `CompareVideoGrid` is every candidate's video at once on that one clock (one transport, one zoom, regions, a loop, stepping), light on the browser (metadata only until the first play, cells out of sight paused and left out of the sync, sound off unless `audio` names a cell, a cell that falls behind marked "Catching up"), with an optional `reference` drawn first, never blind and nearest-neighbour. `regions` (on `Compare`, `CompareVideo` and `CompareGrid`) names boxes in the source's coordinates to look at enlarged: chips, keys `q` `w` `e` `r` `y` `u`, nearest-neighbour drawing, the box outlined while its chip is pointed at, and Shift-drag to make another |
133
133
  | 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 |
134
134
  | 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 |
135
135
  | 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
+ - `RouteMap` now always has a tile under the last pixel column of the map (Leaflet could leave one bare, depending on the path the view took). A `RouteMap` baseline in a centred follow may gain one column of tile at the right edge.
17
+ - `PairVote` and `Compare`/`CompareVideo` with `onPick` now choose on a click (after a 300 ms wait for a double click), so a screen that passes `onPick` or uses `PairVote` sees clicks answer; `pick={false}` keeps a click for panning only. `PairVoteSlot` gains an optional `onPick`: a custom `view` that spreads the whole slot onto `Compare` or `CompareVideo` gets it, and one that picks fields by hand adds it. `CompareVideo` and `CompareVideoGrid` now go back to 0, paused, when the pair's sources change (before, the position carried over). New props `autoPlay` and `loopWhole` are off by default.
16
18
  - `MediaElementState` has new members (`window`, `playWindow`, `ready`, `waitingForMore`, `reportProblem`): code that builds one by hand (a stand-in for `Transport`, say) must add them. `useMediaElement` and `MediaPlayer` now keep the pitch whenever the rate changes (`preservesPitch`).
17
19
  - `RouteMap` draws a "Reset view" button under the zoom control; a test that counts the map's buttons, and any `RouteMap` visual baseline, will see it.
18
20
  - `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.
@@ -1,8 +1,24 @@
1
1
  import { Viewport } from '../lib/viewport';
2
2
  import { Shortcut } from './hotkeys';
3
3
  import { Candidate } from './compare';
4
+ import { FramePick } from './viewport';
4
5
  import * as React from "react";
5
6
  export declare const VIEWPORT_HEIGHT = "max(16rem, calc(100svh - 14rem))";
7
+ /** Words for click to choose, in the product's voice. */
8
+ export type PickWords = {
9
+ /** What hovering a side says, and what the frame is described as: `(label) => "Click to choose " + label`. */
10
+ choose?: (label: string) => string;
11
+ /** Said under the view's controls in a view where a click cannot choose (fade, difference): `(view) => ...`. */
12
+ unavailable?: (view: string) => string;
13
+ };
14
+ /** What a pair's frames do with a click (issue #201): the same answer as the keys, only where a click is unambiguous. Blind: only a candidate's `label` is ever said. */
15
+ export declare function makePicker(a: Candidate<unknown>, b: Candidate<unknown>, onPick: (side: "a" | "b") => void, words?: PickWords): {
16
+ /** A frame that is one whole side. */
17
+ one(side: "a" | "b"): FramePick;
18
+ /** A frame cut by a swipe divider at `divider` percent: the left is A, the right is B. */
19
+ split(divider: number): FramePick;
20
+ unavailable: (view: string) => string;
21
+ };
6
22
  /** A word for a picture's name on the page: its label, with its note unless blind. */
7
23
  export declare function Caption({ c, blind }: {
8
24
  c: Candidate<unknown>;
@@ -32,6 +32,10 @@ export type CompareVideoGridProps = {
32
32
  /** The looped range in seconds; give it with `onLoopChange` to keep it when the item changes. */
33
33
  loop?: VideoLoop;
34
34
  onLoopChange?: (loop: VideoLoop) => void;
35
+ /** Start playing once every cell has its metadata, muted (unless the person has chosen a sound level), and again when the cells change. Off with reduced motion unless `"always"`. Default false. */
36
+ autoPlay?: boolean | "always";
37
+ /** Loop the whole clip until stopped; a range set with `i` and `o` wins while both ends are set. Default false. */
38
+ loopWhole?: boolean;
35
39
  /** The `id` of the cell whose sound is heard. Default none: eight soundtracks at once are noise. */
36
40
  audio?: string | null;
37
41
  /** Draw nearest-neighbour when a video is shown larger than its own pixels (`zoomed`, default), always, or never. */
@@ -45,4 +49,4 @@ export type CompareVideoGridProps = {
45
49
  className?: string;
46
50
  };
47
51
  /** Many videos in a grid on one clock, zoomed and panned together, with regions, a loop, stepping and full screen. */
48
- export declare function CompareVideoGrid({ label, items, reference, blind, missing, catchingUp, actions, columns, regions, rates, moments, loop, onLoopChange, audio, pixelated, keys, extraShortcuts, footer, className }: CompareVideoGridProps): React.JSX.Element;
52
+ export declare function CompareVideoGrid({ label, items, reference, blind, missing, catchingUp, actions, columns, regions, rates, moments, loop, onLoopChange, audio, autoPlay, loopWhole, pixelated, keys, extraShortcuts, footer, className }: CompareVideoGridProps): React.JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { Shortcut } from './hotkeys';
2
+ import { PickWords } from './compare-parts';
2
3
  import { Candidate, CompareMode, VideoMedia } from './compare';
3
4
  import { VideoLoop } from './video-clock';
4
5
  import { Region } from '../lib/viewport';
@@ -30,6 +31,16 @@ export type CompareVideoProps = {
30
31
  onLoopChange?: (loop: VideoLoop) => void;
31
32
  /** Named boxes to look at enlarged, as in `Compare`, on the same clock; a box drawn by hand (Shift-drag) is for a paused clip. Nearest-neighbour while one is shown. */
32
33
  regions?: readonly Region[];
34
+ /** Called with the side clicked or tapped (side by side, swipe by the side of the divider, blink the side showing; not fade), whether the clip plays or not. A click never toggles play. A `PairVote` or `PairJudge` slot sets this. */
35
+ onPick?: (side: "a" | "b") => void;
36
+ /** Whether a click chooses at all when `onPick` is given. Default true; `false` for a screen where a click must only pan. */
37
+ pick?: boolean;
38
+ /** Words for click to choose. Defaults say "Click to choose A". */
39
+ pickWords?: PickWords;
40
+ /** Start playing when the pair has loaded, muted (unless the person has chosen a sound level), and again for each new pair. Off with reduced motion unless `"always"`. If the browser refuses, the pair stays paused with Play showing. Default false. */
41
+ autoPlay?: boolean | "always";
42
+ /** Loop the whole clip, from its end back to 0, until the judge answers. A range set with `i` and `o` wins while both ends are set; `c` goes back to the whole clip. Default false. */
43
+ loopWhole?: boolean;
33
44
  /** Which video's sound is heard; the other is muted. Default "a". */
34
45
  audio?: "a" | "b" | "none";
35
46
  /** Draw nearest-neighbour when shown larger than the video's own pixels (`zoomed`, default), always, or never. */
@@ -45,4 +56,4 @@ export type CompareVideoProps = {
45
56
  className?: string;
46
57
  };
47
58
  /** Two videos to judge by eye on one clock: side by side, swipe, fade or blink, zoomed together, with matched sound and full screen. */
48
- export declare function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates, regions, moments, loop: loopProp, onLoopChange, audio, pixelated, maxHeight, keys, extraShortcuts, footer, className }: CompareVideoProps): React.JSX.Element;
59
+ export declare function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates, regions, moments, loop: loopProp, onLoopChange, audio, onPick, pick, pickWords, autoPlay, loopWhole, pixelated, maxHeight, keys, extraShortcuts, footer, className }: CompareVideoProps): React.JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { Shortcut } from './hotkeys';
2
+ import { PickWords } from './compare-parts';
2
3
  import { ReadPixels } from './difference';
3
4
  import { Region } from '../lib/viewport';
4
5
  import * as React from "react";
@@ -69,6 +70,12 @@ export type CompareProps = {
69
70
  maxHeight?: string;
70
71
  /** Named boxes in the source's coordinates to look at enlarged: a strip of chips, keys `q` `w` `e` `r` `y` `u`, nearest-neighbour drawing while one is shown, and Shift-drag to make another. They work in every view. The same share of each side is shown, whatever its pixel size. Label them by content ("Face"), never by candidate. */
71
72
  regions?: readonly Region[];
73
+ /** Called with the side clicked or tapped, in the views where a click is unambiguous: side by side, swipe (by the side of the divider) and blink (the side showing). A pointer convenience: the keys and the vote bar stay the way to answer. A `PairVote` sets this for you. */
74
+ onPick?: (side: "a" | "b") => void;
75
+ /** Whether a click chooses at all when `onPick` is given. Default true; `false` for a screen where a click must only pan. */
76
+ pick?: boolean;
77
+ /** Words for click to choose. Defaults say "Click to choose A". */
78
+ pickWords?: PickWords;
72
79
  /** Bind the view, zoom and full-screen keys on the window. Default true; turn off when a surrounding screen binds the same keys. */
73
80
  keys?: boolean;
74
81
  /** 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. */
@@ -78,4 +85,4 @@ export type CompareProps = {
78
85
  className?: string;
79
86
  };
80
87
  /** Two pictures to judge, side by side or laid over each other, zoomed and panned together, and full screen. */
81
- export declare function Compare({ label, a, b, blind, missing, mode, onModeChange, modes, regions, keys, extraShortcuts, footer, maxHeight, cannotCompare, readPixels, defaultDifference, className }: CompareProps): React.JSX.Element;
88
+ export declare function Compare({ label, a, b, blind, missing, mode, onModeChange, modes, regions, onPick, pick, pickWords, keys, extraShortcuts, footer, maxHeight, cannotCompare, readPixels, defaultDifference, className }: CompareProps): React.JSX.Element;
@@ -15,10 +15,11 @@ export type Pair<M = ImageMedia> = {
15
15
  a: Candidate<M>;
16
16
  b: Candidate<M>;
17
17
  };
18
- /** What `PairVote` hands a `view`: the answer keys for the view's legend and the vote bar for its footer. Pass both to `CompareAudio`, `CompareText` or your own. */
18
+ /** What `PairVote` hands a `view`: the answer keys for the view's legend, the vote bar for its footer, and `onPick` for a view whose sides can be clicked (`Compare`, `CompareVideo`; absent while an answer is pending). Pass the whole slot to the view. */
19
19
  export type PairVoteSlot = {
20
20
  extraShortcuts: Shortcut[];
21
21
  footer: React.ReactNode;
22
+ onPick?: (side: "a" | "b") => void;
22
23
  };
23
24
  /** Words for the vote bar, all in the product's voice. */
24
25
  export type PairVoteWords = {
@@ -62,7 +63,7 @@ export type PairJudgeProps<M> = {
62
63
  view: (slot: PairVoteSlot, pair: Pair<M>) => React.ReactNode;
63
64
  };
64
65
  /** Props for `PairVote`: the pair judgment, drawn with `Compare`. */
65
- export type PairVoteProps = Omit<PairJudgeProps<ImageMedia>, "view"> & Omit<CompareProps, "label" | "a" | "b" | "extraShortcuts" | "footer">;
66
+ export type PairVoteProps = Omit<PairJudgeProps<ImageMedia>, "view"> & Omit<CompareProps, "label" | "a" | "b" | "extraShortcuts" | "footer" | "onPick">;
66
67
  /** A blind pairwise judgment of two pictures: `Compare`, answer keys in its legend, and a vote bar that never leans on either side. */
67
68
  export declare function PairVote({ pair, skeleton, empty, onAnswer, pending, progress, flagReasons, preload, last, words, ...compare }: PairVoteProps): React.JSX.Element;
68
69
  /** A blind pairwise judgment of anything: the answer keys, vote bar, pending, flag menu, progress, preload and Undo around a `view` that draws the pair (`CompareAudio`, `CompareText`, your own). */
@@ -15,11 +15,17 @@ export type VideoClockOptions = {
15
15
  onLoopChange?: (loop: VideoLoop) => void;
16
16
  /** The index of the video whose sound is heard; none when `null`. */
17
17
  audio: number | null;
18
+ /** Start playing once every video has its metadata (and muted, unless the person chose a sound level), and again for each new `pairKey`. `"always"` also with reduced motion. Default off. */
19
+ autoPlay?: boolean | "always";
20
+ /** Loop from 0 to the natural end when no range is set. A range with both ends set wins. Default off. */
21
+ loopWhole?: boolean;
22
+ /** Names the pair on the clock: when it changes the clock starts again at 0, paused (or playing, with `autoPlay`). */
23
+ pairKey?: string;
18
24
  };
19
25
  /** The clock and everything a transport needs. */
20
26
  export type VideoClock = ReturnType<typeof useVideoClock>;
21
27
  /** Plays, pauses, seeks, steps and loops any number of videos together. */
22
- export declare function useVideoClock({ fps, loop: loopProp, onLoopChange, audio }: VideoClockOptions): {
28
+ export declare function useVideoClock({ fps, loop: loopProp, onLoopChange, audio, autoPlay, loopWhole, pairKey }: VideoClockOptions): {
23
29
  attach: (index: number) => (el: HTMLVideoElement | null) => void;
24
30
  restore: (e: React.SyntheticEvent<HTMLVideoElement>) => void;
25
31
  wanted: boolean;
@@ -38,6 +44,8 @@ export declare function useVideoClock({ fps, loop: loopProp, onLoopChange, audio
38
44
  failed: boolean;
39
45
  loop: VideoLoop;
40
46
  looping: boolean;
47
+ /** The whole clip loops: asked for, and no range set to override it. */
48
+ loopsWhole: boolean;
41
49
  setPoint: (point: "start" | "end") => void;
42
50
  clearLoop: () => void;
43
51
  volume: number;
@@ -7,6 +7,24 @@ export type ViewportState = {
7
7
  };
8
8
  /** Zoom and pan held in React state, to give to every `ViewportFrame` that should move together. */
9
9
  export declare function useViewport(initial?: Viewport): ViewportState;
10
+ /** Where a click on a frame would choose: a stretch of the frame's width as shares (0 to 1), what it chooses and what to say about it. */
11
+ export type PickZone = {
12
+ value: string;
13
+ from: number;
14
+ to: number;
15
+ hint: string;
16
+ };
17
+ /** How a frame takes a click as a choice. */
18
+ export type FramePick = {
19
+ /** The zone under a pointer at `x` (0 to 1 across the frame), or null where a click chooses nothing. */
20
+ zoneAt: (x: number) => PickZone | null;
21
+ /** A click happened in `zone`. */
22
+ onPick: (zone: PickZone) => void;
23
+ /** What the frame is described as for assistive technology: "Click to choose A". */
24
+ describe: string;
25
+ /** Names what is being judged. A choice still waiting out the double-click window is dropped if this changes or the pick goes away (the next pair came up, or an answer is pending). */
26
+ token?: string;
27
+ };
10
28
  /** Props for `ViewportFrame`. */
11
29
  export type ViewportFrameProps = ViewportState & {
12
30
  /** Names the frame for screen readers: "Picture A". Required. */
@@ -32,6 +50,8 @@ export type ViewportFrameProps = ViewportState & {
32
50
  }) => void;
33
51
  /** A box to outline on the whole picture (a region being pointed at), as shares of it. Drawn only while the picture is fitted. */
34
52
  outline?: ShareBox | null;
53
+ /** Take a click (not a drag, not a double click) as a choice: see the note at the top of the file. Without it a click does nothing, as before. */
54
+ pick?: FramePick;
35
55
  className?: string;
36
56
  };
37
57
  /** A clipped frame whose children zoom and pan together; the viewport is the caller's, so frames can share one. */
@@ -59,5 +79,7 @@ export declare const ViewportFrame: React.ForwardRefExoticComponent<ViewportStat
59
79
  }) => void;
60
80
  /** A box to outline on the whole picture (a region being pointed at), as shares of it. Drawn only while the picture is fitted. */
61
81
  outline?: ShareBox | null;
82
+ /** Take a click (not a drag, not a double click) as a choice: see the note at the top of the file. Without it a click does nothing, as before. */
83
+ pick?: FramePick;
62
84
  className?: string;
63
85
  } & React.RefAttributes<HTMLDivElement>>;