strata-react 1.0.33 → 1.0.36

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.
Files changed (62) hide show
  1. package/README.md +13 -3
  2. package/UPGRADING.md +2 -0
  3. package/dist/components/compare-parts.d.ts +16 -0
  4. package/dist/components/compare-video-grid.d.ts +5 -1
  5. package/dist/components/compare-video.d.ts +12 -1
  6. package/dist/components/compare.d.ts +8 -1
  7. package/dist/components/conversation.d.ts +67 -0
  8. package/dist/components/dialog.d.ts +1 -1
  9. package/dist/components/folder-picker.d.ts +42 -0
  10. package/dist/components/lightbox.d.ts +34 -0
  11. package/dist/components/markable-text.d.ts +56 -0
  12. package/dist/components/media-group.d.ts +25 -0
  13. package/dist/components/media-player.d.ts +80 -2
  14. package/dist/components/pair-vote.d.ts +3 -2
  15. package/dist/components/region-editor.d.ts +55 -0
  16. package/dist/components/sequence-timeline.d.ts +50 -0
  17. package/dist/components/transcript-view.d.ts +36 -0
  18. package/dist/components/tree.d.ts +41 -0
  19. package/dist/components/video-clock.d.ts +9 -1
  20. package/dist/components/viewport.d.ts +22 -0
  21. package/dist/components/waveform.d.ts +66 -0
  22. package/dist/{cursor-DplHNzj3.js → cursor-DDGBPiTJ.js} +2 -200
  23. package/dist/cursor-DDGBPiTJ.js.map +1 -0
  24. package/dist/field-7Z4N5r5g.js +178 -0
  25. package/dist/field-7Z4N5r5g.js.map +1 -0
  26. package/dist/format-B32-PVi2.js +201 -0
  27. package/dist/format-B32-PVi2.js.map +1 -0
  28. package/dist/hls/index.d.ts +19 -0
  29. package/dist/hls.js +84 -0
  30. package/dist/hls.js.map +1 -0
  31. package/dist/index.d.ts +17 -1
  32. package/dist/index.js +3646 -584
  33. package/dist/index.js.map +1 -1
  34. package/dist/lib/marks.d.ts +6 -0
  35. package/dist/lib/region.d.ts +46 -0
  36. package/dist/lib/rich-text.d.ts +44 -0
  37. package/dist/lib/sequence.d.ts +34 -0
  38. package/dist/lib/transcript.d.ts +28 -0
  39. package/dist/lib/waveform.d.ts +36 -0
  40. package/dist/map.js +4 -2
  41. package/dist/map.js.map +1 -1
  42. package/dist/panorama/gl.d.ts +16 -0
  43. package/dist/panorama/index.d.ts +2 -0
  44. package/dist/panorama/panorama-viewer.d.ts +56 -0
  45. package/dist/panorama/projection.d.ts +45 -0
  46. package/dist/panorama.js +657 -0
  47. package/dist/panorama.js.map +1 -0
  48. package/dist/{query-DgJMyXTT.js → query-BJcxJLhh.js} +3 -2
  49. package/dist/{query-DgJMyXTT.js.map → query-BJcxJLhh.js.map} +1 -1
  50. package/dist/{run-BqZGKhW9.js → run-DzyLrZlA.js} +23 -5
  51. package/dist/run-DzyLrZlA.js.map +1 -0
  52. package/dist/testing.js +2 -2
  53. package/dist/{theme-BgTOESmN.js → theme-CFNi6WUO.js} +5 -175
  54. package/dist/theme-CFNi6WUO.js.map +1 -0
  55. package/dist/value-controls-D6O9TsM6.js +356 -0
  56. package/dist/value-controls-D6O9TsM6.js.map +1 -0
  57. package/dist/visual-cli.js +1 -1
  58. package/dist/visual.js +1 -1
  59. package/package.json +19 -4
  60. package/dist/cursor-DplHNzj3.js.map +0 -1
  61. package/dist/run-BqZGKhW9.js.map +0 -1
  62. package/dist/theme-BgTOESmN.js.map +0 -1
package/README.md CHANGED
@@ -38,9 +38,11 @@ it against the built files:
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
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
+ | `strata-react/hls` | `hls.js` (optional peer, `^1.6.0`) | `attachHls` for `MediaPlayer attach` and `useAttachedSource`: HLS through hls.js wherever the browser has Media Source Extensions (the element's own where not), recovered quietly where it can be, and a stream still being made |
42
+ | `strata-react/panorama` | none | `PanoramaViewer`: a 360 (equirectangular) picture or video as a window you pan and zoom, WebGL2 with a flat fallback; its own entry so an app with no 360 ships no GL code |
41
43
  | `strata-react/visual`, `strata-visual` | `playwright` (exact version), `msw`, `vite` | The screenshot runner; see [Visual regression for apps](#visual-regression-for-apps) |
42
44
 
43
- The last three are optional peers: an app that never imports those entries never needs them.
45
+ The map, HLS, testing and visual entries need optional peers: an app that never imports those entries never needs them.
44
46
 
45
47
  **An unreleased commit** can be installed from GitHub with
46
48
  `npm install github:jburnhams/strata-react#<sha>`. npm then runs `prepare`, which installs every
@@ -127,7 +129,7 @@ strata-react is ESM-only (`exports` has only `import`), as is its peer `react-ro
127
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 |
128
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 |
129
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 |
130
- | 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 |
131
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 |
132
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 |
133
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`) |
@@ -144,7 +146,15 @@ strata-react is ESM-only (`exports` has only `import`), as is its peer `react-ro
144
146
  | 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` |
145
147
  | Media player | `MediaPlayer`, `useMediaElement`, `SPEECH_RATES` | Play a file or a sequence of chapters without the event glue: the element, its state, Strata's controls (or the browser's own on a touch device, `controls="auto"`), a load error with Try again, `navigator.mediaSession` metadata, the seek bar spanning the whole sequence. `useMediaElement(ref)` alone follows an element drawn with the browser's controls |
146
148
  | 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` |
147
- | Maps | `strata-react/map`: `RouteMap`; `geo`, `LatLng` (main entry) | Routes and a position that moves along them, on Leaflet (no react-leaflet), behind its own entry. Tiles are the app's (`tiles.light`, `tiles.dark`, each with its attribution); the dark scheme uses the dark set or a filter over the light one. Route colours are roles resolved at draw time; `values` with `colourScale` colour a route by value in runs of one step, with a key that names the steps; a single route gets direction chevrons and start/finish marks (a loop is one mark). The position is one marker moved with `setLatLng`: no route is redrawn for it (keep `routes` stable). As picture content (a route inset over footage): `zoom` sets any zoom (animate it per frame), `follow="centre"` holds the view exactly on a position with no animation (a frame is deterministic), and `positions` draws several, each tied to a route, in its colour and named in the text alternative; routes are not redrawn for any of it. Leaflet's keyboard pan and zoom stay; the map is named by `label` and described by a generated text alternative (routes, lengths, position along). Overlay slots `topEnd` and `bottomStart` avoid Leaflet's own controls and attribution. Items on the map (`markers`): pins in states that are shapes as well as colour (circle, ringed, diamond), a stretch of a route drawn heavier, a close group fanned out deterministically around its true place with leader lines, only those near the view drawn, a card per marker, a key; `cursor` shows a shared reading from a `CursorScope`; `onViewChange` reports the settled view, `view` restores one, and a reset control returns to the fit; `picking` + `onPick` chooses a place by click or by arrow keys, with the nearest point on each route. Leaflet's stylesheet is injected once, so an app imports nothing. `geo` (distance, bearing, bounds, `pointAlong`, `arrows`, `ends`, `snap`, `slice`) and `format.distance` need no map library |
149
+ | Listening and reading | `Waveform`, `TranscriptView`, `PlayWindowButton`, `MediaGroup`; `resamplePeaks`, `peaksFromAudio`, `phraseAt`, `wordAt` | Timed media: a waveform from peaks or a decoded file (one slider, marks by line style, named spans, zoom, a keyboard-made range, a spectrogram underlay); timed text that marks the heard word and plays from any word (modes, speakers, follow and Jump to now, virtualised); `MediaPlayer window` plays one stretch of a file, `MediaGroup` lets one player play at a time, `PlayWindowButton` is a row's play control on a shared element |
150
+ | Streams | `MediaPlayer attach`/`growing`, `useAttachedSource`, `attachHls` (`strata-react/hls`) | A source the element cannot play is attached by an engine; a source still being made says so, shows what exists as ready, and waits at its end without ending |
151
+ | 360 | `PanoramaViewer` (`strata-react/panorama`), `project`, `unproject`, `describeView` | A 360 picture or video as a controlled window (yaw, pitch, field of view), drag, wheel, pinch and keys, an overlay in the picture's coordinates, said in words, a flat fallback with no WebGL2 |
152
+ | Conversation | `Conversation`, `Composer`, `RichText`; `matchEntities`, `parseRichText` | A question-and-answer thread: answers stream, finish or fail in place (Try again), one polite announcement per finished answer, following only while at the bottom (Jump to latest); a composer that sends on Enter and is disabled with its reason while answering (Stop); a safe text subset (bold, code, lists, http links, never HTML) whose known ids, longest first and whole words only, become buttons |
153
+ | Pictures from a set | `Lightbox`, `RegionEditor`; `moveRect`, `resizeRect`, `lerpRect` | A picture opened from a grid in a full-size `Dialog` (previous/next, arrow keys, "3 of 40", zoom and 1:1, details beside it, neighbours preloaded, a `missing` sentence, Compare ticked hand-off); named windows drawn and moved on a picture by pointer, keys and numbers, with aspect and bounds held, and a from/to move with a Watch preview |
154
+ | Sequences | `SequenceTimeline`; `snapToGrid`, `stepOnGrid`, `settleCut` | A gapless strip of windows whose cuts are sliders: dragged or stepped along a beat grid inside the room the app gives, the refusal said in words, both windows' new lengths announced; Shift+click chooses a run |
155
+ | Browsing | `Tree`, `FolderPicker` | A hierarchy that loads as it opens (a hook per open node; skeleton, Try again and empty rows; always virtualised) and a server folder chooser on it: breadcrumb that is also editable text, Up, recents, New folder with the server's refusal on the field, Choose this folder |
156
+ | Marking text | `MarkableText`, `Mark`, `MarkSummary`; `rangeBetween` | Select words by drag, Shift+click and Shift+arrows (ids in document order, so it holds across virtualised rows), apply the app's marks from a bar or single-key chords, marks drawn by role, pattern and text, summarised and announced |
157
+ | Maps | `strata-react/map`: `RouteMap`; `geo`, `LatLng` (main entry) | Routes and a position that moves along them, on Leaflet (no react-leaflet), behind its own entry. Tiles are the app's (`tiles.light`, `tiles.dark`, each with its attribution); the dark scheme uses the dark set or a filter over the light one. Route colours are roles resolved at draw time; `values` with `colourScale` colour a route by value in runs of one step, with a key that names the steps; a single route gets direction chevrons and start/finish marks (a loop is one mark). The position is one marker moved with `setLatLng`: no route is redrawn for it (keep `routes` stable). As picture content (a route inset over footage): `zoom` sets any zoom (animate it per frame), `follow="centre"` holds the view exactly on a position with no animation (a frame is deterministic), and `positions` draws several, each tied to a route, in its colour and named in the text alternative; routes are not redrawn for any of it. Leaflet's keyboard pan and zoom stay; the map is named by `label` and described by a generated text alternative (routes, lengths, position along). Overlay slots `topEnd` and `bottomStart` avoid Leaflet's own controls and attribution. Leaflet's stylesheet is injected once, so an app imports nothing. `geo` (distance, bearing, bounds, `pointAlong`, `arrows`, `ends`) and `format.distance` need no map library |
148
158
  | 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. Lanes take drops from outside (`dropTypes`, `onDrop` with the lane and snapped time, `validateDrop`, and React Aria's keyboard drag landing at the current time), `laneRows` makes them taller, `kindColours` fixes each kind's stripe, and the header column fits its content. Only items near the view are rendered |
149
159
  | 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 |
150
160
  | 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; the name wraps in a narrow pane and a `thumbnail` can lead it. Nothing assumes a server |
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
+ - `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.
17
+ - `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`).
16
18
  - `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.
17
19
  - `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.
18
20
  - `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).
@@ -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;
@@ -0,0 +1,67 @@
1
+ import { EntityMatcher } from '../lib/rich-text';
2
+ import * as React from "react";
3
+ export type RichTextProps = {
4
+ /** The text, in the small subset: paragraphs, `- ` and `1. ` lists, **bold**, `code`, [links](https://…). */
5
+ children: string;
6
+ /** Ids that become buttons: a list (longest first, whole words only) or a function reporting matches. */
7
+ entities?: EntityMatcher;
8
+ /** Called with the id when an entity button is pressed. Without it, an id is drawn as code. */
9
+ onOpen?: (id: string) => void;
10
+ className?: string;
11
+ };
12
+ /** Draws a small safe subset of text (bold, code, lists, http links) and turns known ids into buttons. Never HTML: whatever the string holds is shown as text. */
13
+ export declare function RichText({ children, entities, onOpen, className }: RichTextProps): React.JSX.Element;
14
+ /** One turn of the thread. `failed` cannot be written without the sentence saying what happened. */
15
+ export type ConversationTurn = {
16
+ id: string;
17
+ role: "person" | "answer";
18
+ time: Date | string | number;
19
+ text: string;
20
+ lookedUp?: React.ReactNode;
21
+ } & ({
22
+ state?: "done";
23
+ } | {
24
+ state: "streaming";
25
+ } | {
26
+ state: "failed";
27
+ error: string;
28
+ });
29
+ export type ConversationProps = {
30
+ /** Names the thread for assistive technology: "Questions about the kiln". */
31
+ label: string;
32
+ turns: readonly ConversationTurn[];
33
+ /** Who the answers come from, shown on each: "Assistant". */
34
+ answerName: string;
35
+ /** What a person is called in their own turns: "You". */
36
+ personName?: string;
37
+ entities?: EntityMatcher;
38
+ /** An id in an answer was pressed. */
39
+ onOpen?: (id: string) => void;
40
+ /** Try again on a failed answer; the turn is replaced in place. */
41
+ onRetry: (turnId: string) => void;
42
+ /** Shown while there are no turns: the app's invitation, with the suggested questions if it likes. */
43
+ empty: React.ReactNode;
44
+ /** What the "what it looked up" disclosure is called. */
45
+ lookedUpLabel?: string;
46
+ className?: string;
47
+ };
48
+ /** A thread of turns: answers stream, finish or fail in place; the log follows only while the person is at the bottom (with Jump to latest), and a finished answer is announced once, politely. */
49
+ export declare function Conversation({ label, turns, answerName, personName, entities, onOpen, onRetry, empty, lookedUpLabel, className }: ConversationProps): React.JSX.Element;
50
+ export type ComposerProps = {
51
+ /** Names the box: "Ask about the kiln". */
52
+ label: string;
53
+ /** Called with the trimmed text on Enter or the send button; the box then clears. */
54
+ onSend: (text: string) => void;
55
+ /** An answer is on its way: the box is disabled, with `answeringReason` under it, and send becomes Stop. */
56
+ answering?: boolean;
57
+ /** Stops the answer in progress. Required, so a long answer can always be cut short. */
58
+ onStop: () => void;
59
+ /** Why the box is disabled while answering, in the app's words: "Waiting for the answer." */
60
+ answeringReason: string;
61
+ /** Questions to start from; each is a button that sends. */
62
+ suggestions?: readonly string[];
63
+ sendLabel?: string;
64
+ className?: string;
65
+ };
66
+ /** The box a question is typed in: Enter sends, Shift+Enter is a new line, disabled with its reason while answering (and Stop), suggestions as buttons. */
67
+ export declare function Composer({ label, onSend, answering, onStop, answeringReason, suggestions, sendLabel, className }: ComposerProps): React.JSX.Element;
@@ -22,7 +22,7 @@ export type DialogProps = Common & {
22
22
  closable?: boolean;
23
23
  /** `center` is a dialog; `end` is a sheet down the right edge. Default `center`. */
24
24
  placement?: "center" | "end";
25
- size?: "sm" | "md" | "lg";
25
+ size?: "sm" | "md" | "lg" | "full";
26
26
  };
27
27
  /** A modal dialog with a required title; focus goes in and returns, Escape and a close control dismiss it. `placement="end"` makes it a sheet. */
28
28
  export declare function Dialog({ title, description, trigger, open, onOpenChange, className, children, actions, hideTitle, closable, placement, size, }: DialogProps): React.JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { Load } from './data-view';
2
+ import { Expanded } from './disclosure';
3
+ import * as React from "react";
4
+ /** One folder in a listing. */
5
+ export type Folder = {
6
+ /** The full path, which is also its key. */
7
+ path: string;
8
+ /** The last part, shown. */
9
+ name: string;
10
+ /** How many folders are inside it, when the server knows; shown beside the name. */
11
+ count?: number;
12
+ };
13
+ export type FolderPickerProps = {
14
+ /** Names the picker: "Choose a folder for the project". Required. */
15
+ label: string;
16
+ /** Reads one folder's subfolders (`null` is the top). A hook: `useLoad` inside. */
17
+ useFolders: (path: string | null) => Load<readonly Folder[]>;
18
+ /** The folder being looked at, or `null`. */
19
+ value: string | null;
20
+ onChange: (path: string | null) => void;
21
+ /** The person chose this folder. */
22
+ onChoose: (path: string) => void;
23
+ /** Which folders are open in the tree; from `useExpanded`, optionally in the URL. */
24
+ expanded: Expanded;
25
+ /** Folders chosen before, newest first. */
26
+ recent?: readonly string[];
27
+ /** Makes a folder named `name` in `parent`. Throw (an `HttpError`) to refuse; its reason is shown on the field. Without it there is no New folder. */
28
+ onCreate?: (parent: string, name: string) => Promise<unknown>;
29
+ /** The name of the top: "Server". Default "Top". */
30
+ topLabel?: string;
31
+ /** What a folder with no folders in it says. Default "No folders". */
32
+ emptyRow?: string;
33
+ /** The height of the tree before it scrolls. Default 18rem. */
34
+ height?: string;
35
+ className?: string;
36
+ };
37
+ /** The parent of a path, or `null` at the top. */
38
+ export declare const parentOf: (path: string) => string | null;
39
+ /** Every folder from the top down to `path`, which the tree must have open to show it. */
40
+ export declare const ancestorsOf: (path: string) => string[];
41
+ /** A server folder chooser: a lazy tree, a breadcrumb that is also editable text, Up, recents, a New folder field that shows the server's refusal, and Choose this folder as the one filled button. */
42
+ export declare function FolderPicker({ label, useFolders, value, onChange, onChoose, expanded, recent, onCreate, topLabel, emptyRow, height, className }: FolderPickerProps): React.JSX.Element;
@@ -0,0 +1,34 @@
1
+ import * as React from "react";
2
+ /** One picture in the set. */
3
+ export type LightboxItem = {
4
+ id: string;
5
+ /** The picture's address. */
6
+ src: string;
7
+ /** What it shows, for the picture's alternative text: "Bowl 12, front". Required. */
8
+ label: string;
9
+ /** Its natural size in pixels, for 1:1. */
10
+ natural?: readonly [number, number];
11
+ };
12
+ export type LightboxProps = {
13
+ /** The dialog's title: "Photos of firing f-0412". Required. */
14
+ title: string;
15
+ items: readonly LightboxItem[];
16
+ index: number;
17
+ onIndexChange: (index: number) => void;
18
+ open: boolean;
19
+ onOpenChange: (open: boolean) => void;
20
+ /** What shows in place of a picture that did not load, in words: "This photo could not be loaded." Required. */
21
+ missing: string;
22
+ /** Beside the picture (a `PropertyList` or `Inspector` fits), under it when narrow. */
23
+ details?: (item: LightboxItem) => React.ReactNode;
24
+ /** Name of the folded details on a narrow screen. */
25
+ detailsLabel?: string;
26
+ /** Ids ticked in the grid; with `onCompare` this shows "Compare ticked". */
27
+ ticked?: readonly string[];
28
+ /** Hands the ticked ids to the app. Needs two or more. */
29
+ onCompare?: (ids: readonly string[]) => void;
30
+ /** Width over height of the frame before the picture loads. Default 3:2. */
31
+ aspect?: number;
32
+ };
33
+ /** A picture from a set in a full-size dialog: previous/next and arrow keys, "3 of 40", zoom and pan, details beside it, neighbours preloaded, a `missing` sentence for one that fails, and a Compare ticked hand-off. Focus returns to the tile that opened it. */
34
+ export declare function Lightbox({ title, items, index, onIndexChange, open, onOpenChange, missing, details, detailsLabel, ticked, onCompare, aspect }: LightboxProps): React.JSX.Element;
@@ -0,0 +1,56 @@
1
+ import { IconComponent } from '../lib/icon';
2
+ import * as React from "react";
3
+ /** A tone for a mark, as a role colour. */
4
+ export type MarkTone = "neutral" | "info" | "success" | "warning" | "danger";
5
+ /** An underline pattern, so a mark does not depend on its colour. */
6
+ export type MarkPattern = "solid" | "dashed" | "dotted" | "double" | "wavy";
7
+ /** One kind of mark the app offers. */
8
+ export type MarkKind = {
9
+ /** What is stored per word. */
10
+ key: string;
11
+ /** What the mark means, said and shown: "Must use". Never a colour name. */
12
+ label: string;
13
+ tone: MarkTone;
14
+ pattern: MarkPattern;
15
+ /** Shown in the toolbar, legend and summary beside the label. */
16
+ icon?: IconComponent;
17
+ /** The chord that applies it to the selection: `["g"]`. Single keys are fine; they never fire while typing. */
18
+ keys?: string[];
19
+ };
20
+ /** One word (or phrase, or clip) that can be marked. Draws its mark, its selection and the caret; inside a `MarkableText`. */
21
+ export declare function Mark({ id, children, className }: {
22
+ id: string;
23
+ children: React.ReactNode;
24
+ className?: string;
25
+ }): React.JSX.Element;
26
+ /** "12 words must use, 3 never": a count for each kind in use, with its icon. */
27
+ export declare function MarkSummary({ marks, kinds, unit, className }: {
28
+ marks: Readonly<Record<string, string | undefined>>;
29
+ kinds: readonly MarkKind[];
30
+ unit?: readonly [string, string];
31
+ className?: string;
32
+ }): React.JSX.Element;
33
+ export type MarkableTextProps = {
34
+ /** Names the region: "Transcript, for marking". Required. */
35
+ label: string;
36
+ /** Every markable id in document order, including those in rows not mounted now. */
37
+ ids: readonly string[];
38
+ /** The mark on each id (a kind's `key`); ids with none are unmarked. */
39
+ marks: Readonly<Record<string, string | undefined>>;
40
+ kinds: readonly MarkKind[];
41
+ /** Apply a kind (or `null` to clear) to the selected ids. The app stores it. */
42
+ onMark: (ids: readonly string[], kind: string | null) => void;
43
+ /** Chords that clear the selection's marks: `["w"]`. */
44
+ clearKeys?: string[];
45
+ /** The caret moved to this id (so a virtualised list can scroll it into view). */
46
+ onCaretChange?: (id: string) => void;
47
+ /** What one id is called in counts: `["word", "words"]`. */
48
+ unit?: readonly [string, string];
49
+ /** Show the summary line under the text. Default true. */
50
+ summary?: boolean;
51
+ /** The text, with `<Mark id>` elements. */
52
+ children: React.ReactNode;
53
+ className?: string;
54
+ };
55
+ /** Selects ids over `<Mark>` words by drag, Shift+click and Shift+arrows (a run in the app's order, so it holds across virtualised rows), offers the app's marks as chorded commands in a bar, says each change in words, and lists what is marked. */
56
+ export declare function MarkableText({ label, ids, marks, kinds, onMark, clearKeys, onCaretChange, unit, summary, children, className }: MarkableTextProps): React.JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { MediaElementState, MediaWindow } from './media-player';
2
+ import * as React from "react";
3
+ /** Adds an element to a named group until the returned function is called; whenever one plays, the others pause. */
4
+ export declare function joinMediaGroup(name: string, el: HTMLMediaElement): () => void;
5
+ /** The group a `MediaGroup` above this point names, or null. */
6
+ export declare function useMediaGroupName(): string | null;
7
+ /** Players and elements under it play one at a time: starting one pauses the others. */
8
+ export declare function MediaGroup({ name, children }: {
9
+ name?: string;
10
+ children: React.ReactNode;
11
+ }): React.JSX.Element;
12
+ /** Whether two windows are the same stretch. */
13
+ export declare const sameWindow: (a: MediaWindow | null | undefined, b: MediaWindow | null | undefined) => boolean;
14
+ export type PlayWindowButtonProps = {
15
+ /** The shared element's handle from `useMediaElement`. */
16
+ media: Pick<MediaElementState, "playing" | "window" | "playWindow" | "pause">;
17
+ /** The stretch it plays, in seconds. */
18
+ window: MediaWindow;
19
+ /** What it plays, in the row's words: "Play phrase 12" (the name stays the same while it plays; the pressed state says the rest). */
20
+ label: string;
21
+ size?: "default" | "sm";
22
+ className?: string;
23
+ };
24
+ /** A row's play button for one window of a shared element: named for what it plays, pressed while it plays, a second press pauses. */
25
+ export declare function PlayWindowButton({ media, window: w, label, size, className }: PlayWindowButtonProps): React.JSX.Element;
@@ -9,6 +9,16 @@ export type MediaProblem = {
9
9
  };
10
10
  /** What `useMediaElement` returns: the element's state as values, and the requests a player makes of it. */
11
11
  export type MediaElementState = {
12
+ /** Seconds that can be sought to: for a source still being made, the end of what exists; otherwise the duration (or 0 while it is not known). */
13
+ ready: number;
14
+ /** A source that is still being made has been played up to the end of what exists, and is waiting for more. */
15
+ waitingForMore: boolean;
16
+ /** Shows a stream's own failure (one the element cannot report, such as a stream engine's fatal error) as the load error, with Try again. */
17
+ reportProblem: (message: string | null) => void;
18
+ /** The stretch of the file being played, if any: the `window` option, or the last `playWindow`. */
19
+ window: MediaWindow | null;
20
+ /** Plays a stretch: seeks to its start, plays, and stops (or loops) at its end. */
21
+ playWindow: (window: MediaWindow) => Promise<void>;
12
22
  playing: boolean;
13
23
  /** Seconds. */
14
24
  time: number;
@@ -35,8 +45,58 @@ export type MediaElementState = {
35
45
  /** Loads again, and plays if it was playing. For the error state's "Try again". */
36
46
  retry: () => void;
37
47
  };
48
+ /** A stretch of a file, in seconds. */
49
+ export type MediaWindow = {
50
+ start: number;
51
+ end: number;
52
+ };
53
+ /** What `useMediaElement` can be asked to do besides follow the element. */
54
+ export type MediaElementOptions = {
55
+ /** Bound playback to a stretch: it starts at `start` (a play from outside it seeks there) and stops at `end`. */
56
+ window?: MediaWindow | null;
57
+ /** At the end of the window, go back to its start and carry on, instead of stopping. */
58
+ loop?: boolean;
59
+ /** Join a group: when this element plays, the others in the group pause. Defaults to the nearest `MediaGroup`. */
60
+ group?: string;
61
+ /** Called every animation frame while playing, with the element's time, for highlighting what is being heard. */
62
+ onTimeUpdate?: (time: number) => void;
63
+ /** The window's end was reached (once per play; not called when it loops). */
64
+ onWindowEnd?: () => void;
65
+ /** The source is still being made (a growing stream): its duration is the end of what exists and keeps growing, it never counts as ended, and playback that reached the end carries on when more arrives. */
66
+ growing?: boolean;
67
+ /** Loads again from `time`, for a source the element cannot reload itself (a stream engine). Replaces the element's `load()` in `retry`. */
68
+ onRetry?: (time: number) => void;
69
+ };
38
70
  /** Follows an `<audio>` or `<video>` and returns its state and the requests a player makes. Works with the browser's own controls too. */
39
- export declare function useMediaElement(ref: React.RefObject<HTMLMediaElement | null>): MediaElementState;
71
+ export declare function useMediaElement(ref: React.RefObject<HTMLMediaElement | null>, options?: MediaElementOptions): MediaElementState;
72
+ /** What a stream engine is given when it takes over an element. */
73
+ export type StreamContext = {
74
+ /** Where to start, seconds (a reload starts where playback was). */
75
+ startAt: number;
76
+ /** Tell the player the stream failed, in words for the person: it shows the load error with Try again. */
77
+ onProblem: (message: string) => void;
78
+ };
79
+ /** A stream engine's hold on an element, so the player can end it and restart it. */
80
+ export type StreamAttachment = {
81
+ /** Lets go of the element: stops loading, frees what the engine made. */
82
+ detach: () => void;
83
+ /** Starts again from `at` seconds (the player's Try again). */
84
+ reload: (at: number) => void;
85
+ };
86
+ /**
87
+ * Plays a source the element cannot play by itself (HLS outside Safari, say) by taking over the
88
+ * element: sets what it needs on it, and returns a hold the player ends when the source changes or the
89
+ * player unmounts. `strata-react/hls` has one; any engine that fits is used the same way.
90
+ */
91
+ export type SourceAttacher = (el: HTMLMediaElement, src: string, context: StreamContext) => StreamAttachment;
92
+ /**
93
+ * Hands `src` to a stream engine (`attach`) for the element in `ref`, and ends the hold when `src` changes, `attach` does, or the component unmounts.
94
+ * Use it for a plain `<video>` the app owns, with `useMediaElement`; `MediaPlayer` does it for `attach`.
95
+ * Returns `reload`, for the player's Try again (`useMediaElement`'s `onRetry`), and gives the engine's failures to `onProblem` (`reportProblem`).
96
+ */
97
+ export declare function useAttachedSource(ref: React.RefObject<HTMLMediaElement | null>, src: string | undefined, attach: SourceAttacher | undefined, onProblem?: (message: string) => void): {
98
+ reload: (at: number) => void;
99
+ };
40
100
  /** One file in a sequence. */
41
101
  export type MediaSource = {
42
102
  src: string;
@@ -74,6 +134,24 @@ export type MediaPlayerProps = {
74
134
  rates?: readonly number[];
75
135
  /** 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
136
  shortcuts?: boolean;
137
+ /** Play only a stretch of the file (seconds): it starts at `start`, stops at `end` (or loops), the seek bar and time show the stretch, and "Playing 0:12 to 0:15" is announced. One file only, not with `sources`. */
138
+ window?: MediaWindow;
139
+ /** Go back to the start of `window` at its end and carry on. */
140
+ loop?: boolean;
141
+ /** Show the whole file's timeline with the window marked, instead of the window as the whole bar. */
142
+ showFull?: boolean;
143
+ /** Join a group: starting this player pauses the others in it. Defaults to the nearest `MediaGroup`. */
144
+ group?: string;
145
+ /** Called every animation frame while playing, with the time in the file (not in the window), for highlighting. */
146
+ onTimeUpdate?: (time: number) => void;
147
+ /** The window reached its end (not called when it loops). */
148
+ onWindowEnd?: () => void;
149
+ /** Plays the sources through a stream engine instead of the element's own `src` (`attachHls` from `strata-react/hls` for HLS). The element is the same one throughout, so playback carries on across sources as ever. */
150
+ attach?: SourceAttacher;
151
+ /** The source is still being made (a stream that grows while it plays): the seek bar shows the part that exists, a "Still being made" word and `status` (what the app says about progress) appear, and playback that catches up with the end waits, says so, and resumes when more arrives, without an `onEnded`. Give the source's `duration` when the whole length is known. */
152
+ growing?: {
153
+ status?: string;
154
+ };
77
155
  /** The last source has ended. */
78
156
  onEnded?: () => void;
79
157
  /** Called as the element plays, with the time in the whole sequence. */
@@ -87,4 +165,4 @@ export declare const SPEECH_RATES: readonly number[];
87
165
  * a touch device), with the failure to load shown and retried. For an editor or a replay, use the
88
166
  * parts and `useMediaElement` directly.
89
167
  */
90
- export declare function MediaPlayer({ label, kind, src, sources, index: controlledIndex, onIndexChange, autoAdvance, controls, autoPlay, poster, session, rates, shortcuts, onEnded, onTimeChange, className, }: MediaPlayerProps): React.JSX.Element;
168
+ export declare function MediaPlayer({ label, kind, src, sources, index: controlledIndex, onIndexChange, autoAdvance, controls, autoPlay, poster, session, rates, shortcuts, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, className, }: MediaPlayerProps): 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). */