strata-react 1.0.33 → 1.0.35

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 (55) hide show
  1. package/README.md +12 -2
  2. package/UPGRADING.md +1 -0
  3. package/dist/components/conversation.d.ts +67 -0
  4. package/dist/components/dialog.d.ts +1 -1
  5. package/dist/components/folder-picker.d.ts +42 -0
  6. package/dist/components/lightbox.d.ts +34 -0
  7. package/dist/components/markable-text.d.ts +56 -0
  8. package/dist/components/media-group.d.ts +25 -0
  9. package/dist/components/media-player.d.ts +80 -2
  10. package/dist/components/region-editor.d.ts +55 -0
  11. package/dist/components/sequence-timeline.d.ts +50 -0
  12. package/dist/components/transcript-view.d.ts +36 -0
  13. package/dist/components/tree.d.ts +41 -0
  14. package/dist/components/waveform.d.ts +66 -0
  15. package/dist/{cursor-DplHNzj3.js → cursor-DDGBPiTJ.js} +2 -200
  16. package/dist/cursor-DDGBPiTJ.js.map +1 -0
  17. package/dist/field-7Z4N5r5g.js +178 -0
  18. package/dist/field-7Z4N5r5g.js.map +1 -0
  19. package/dist/format-B32-PVi2.js +201 -0
  20. package/dist/format-B32-PVi2.js.map +1 -0
  21. package/dist/hls/index.d.ts +19 -0
  22. package/dist/hls.js +84 -0
  23. package/dist/hls.js.map +1 -0
  24. package/dist/index.d.ts +17 -1
  25. package/dist/index.js +3454 -568
  26. package/dist/index.js.map +1 -1
  27. package/dist/lib/marks.d.ts +6 -0
  28. package/dist/lib/region.d.ts +46 -0
  29. package/dist/lib/rich-text.d.ts +44 -0
  30. package/dist/lib/sequence.d.ts +34 -0
  31. package/dist/lib/transcript.d.ts +28 -0
  32. package/dist/lib/waveform.d.ts +36 -0
  33. package/dist/map.js +4 -2
  34. package/dist/map.js.map +1 -1
  35. package/dist/panorama/gl.d.ts +16 -0
  36. package/dist/panorama/index.d.ts +2 -0
  37. package/dist/panorama/panorama-viewer.d.ts +56 -0
  38. package/dist/panorama/projection.d.ts +45 -0
  39. package/dist/panorama.js +657 -0
  40. package/dist/panorama.js.map +1 -0
  41. package/dist/{query-DgJMyXTT.js → query-BJcxJLhh.js} +3 -2
  42. package/dist/{query-DgJMyXTT.js.map → query-BJcxJLhh.js.map} +1 -1
  43. package/dist/{run-BqZGKhW9.js → run-DzyLrZlA.js} +23 -5
  44. package/dist/run-DzyLrZlA.js.map +1 -0
  45. package/dist/testing.js +2 -2
  46. package/dist/{theme-BgTOESmN.js → theme-CFNi6WUO.js} +5 -175
  47. package/dist/theme-CFNi6WUO.js.map +1 -0
  48. package/dist/value-controls-D6O9TsM6.js +356 -0
  49. package/dist/value-controls-D6O9TsM6.js.map +1 -0
  50. package/dist/visual-cli.js +1 -1
  51. package/dist/visual.js +1 -1
  52. package/package.json +19 -4
  53. package/dist/cursor-DplHNzj3.js.map +0 -1
  54. package/dist/run-BqZGKhW9.js.map +0 -1
  55. 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
@@ -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,7 @@ 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
+ - `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
17
  - `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
18
  - `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
19
  - `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).
@@ -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;
@@ -0,0 +1,55 @@
1
+ import { Easing, Rect } from '../lib/region';
2
+ import * as React from "react";
3
+ /** The tone a window is drawn in: a role colour, never a hue of its own. */
4
+ export type RegionTone = "neutral" | "info" | "success" | "warning" | "danger";
5
+ /** One window on the picture, in the picture's coordinates. */
6
+ export type EditableRegion = Rect & {
7
+ id: string;
8
+ label: string;
9
+ tone?: RegionTone;
10
+ };
11
+ export type RegionEditorProps = {
12
+ /** Names the editor: "Crop for the cover photo". Required. */
13
+ label: string;
14
+ /** The picture, drawn to fill the frame (an `<img className="size-full object-cover">`). */
15
+ children: React.ReactNode;
16
+ /** The picture's width and height, which are the units of every window. */
17
+ size: readonly [number, number];
18
+ regions: readonly EditableRegion[];
19
+ /** A window was changed and kept. Receives the whole list, edited. */
20
+ onChange: (regions: readonly EditableRegion[]) => void;
21
+ /** Which window is chosen (controlled); leave out to let the editor keep it. */
22
+ selectedId?: string | null;
23
+ onSelectedChange?: (id: string | null) => void;
24
+ /** Width over height every window keeps. */
25
+ aspect?: number;
26
+ /** The smallest a window may be. Default a twentieth of the picture. */
27
+ min?: {
28
+ w: number;
29
+ h: number;
30
+ };
31
+ /** Where windows may be. Default the whole picture. */
32
+ bounds?: Rect;
33
+ /** An arrow key's step, in the picture's units. Default a hundredth of its longer side. */
34
+ step?: number;
35
+ /** A drag on the empty picture draws a new window and calls this with it; the app adds it. Without it nothing can be drawn. */
36
+ onDraw?: (rect: Rect) => void;
37
+ /** "move": the first window is the start and the second the end; draws a line between them and a Watch button. */
38
+ mode?: "single" | "move";
39
+ /** Called as Watch plays, with the rectangle at `t` (0 to 1) and `t`. Also drawn by the editor. */
40
+ onPreview?: (rect: Rect, t: number) => void;
41
+ /** How long Watch takes, in milliseconds. Default 1500. */
42
+ duration?: number;
43
+ easing?: Easing;
44
+ /** Show a number field for each side of the chosen window under the picture. Default true. */
45
+ fields?: boolean;
46
+ /** The unit of the numbers: "px". */
47
+ unit?: string;
48
+ /** The windows as they began; with it a Reset appears while they differ. */
49
+ defaults?: readonly EditableRegion[];
50
+ className?: string;
51
+ };
52
+ /** A window said in words. */
53
+ export declare const describeRegion: (r: EditableRegion) => string;
54
+ /** Draw and move one or two named windows on a picture, with pointer, keyboard and numbers kept in step; aspect and bounds hold through all three; two windows make a from/to move with a Watch preview. */
55
+ export declare function RegionEditor({ label, children, size, regions, onChange, selectedId, onSelectedChange, aspect, min, bounds, step, onDraw, mode, onPreview, duration, easing, fields, unit, defaults, className, }: RegionEditorProps): React.JSX.Element;
@@ -0,0 +1,50 @@
1
+ import { Grid } from '../lib/sequence';
2
+ import * as React from "react";
3
+ /** One window of the sequence. Windows tile the axis: each starts where the one before ends. */
4
+ export type SequenceItem = {
5
+ id: string;
6
+ label: string;
7
+ start: number;
8
+ end: number;
9
+ };
10
+ /** The room a cut has: the earliest and latest time it may take, with the reason for each end. */
11
+ export type CutRoom = {
12
+ min: number;
13
+ max: number;
14
+ minReason?: string;
15
+ maxReason?: string;
16
+ };
17
+ /** A cut's change: the two windows with their new edges. */
18
+ export type CutChange = {
19
+ before: SequenceItem;
20
+ after: SequenceItem;
21
+ };
22
+ export type SequenceTimelineProps = {
23
+ /** Names the sequence: "Film, windows in order". Required. */
24
+ label: string;
25
+ /** The windows in time order, each starting where the last ends. */
26
+ items: readonly SequenceItem[];
27
+ /** Pixels per second; leave out to fit the width. */
28
+ zoom?: number;
29
+ /** A cut was moved (dragged and let go, or stepped by key). The app applies it. */
30
+ onCutChange: (boundaryIndex: number, time: number, change: CutChange) => void;
31
+ /** The room for the cut between `items[i]` and `items[i + 1]`. Default: each window keeps `minLength`. */
32
+ room?: (boundaryIndex: number) => CutRoom;
33
+ /** The shortest a window may be when `room` is not given. Default 0.1 s. */
34
+ minLength?: number;
35
+ /** A beat grid: a step in seconds, or the beats' times. Cuts snap to it and arrows step along it. */
36
+ grid?: Grid;
37
+ /** The arrow-key step when there is no grid. Default 0.1 s. */
38
+ step?: number;
39
+ /** The windows chosen, as ids. */
40
+ selected?: readonly string[];
41
+ /** A window or a run (Shift+click) was chosen: ids in order. */
42
+ onSelectRange?: (ids: readonly string[]) => void;
43
+ /** The inside of a window, such as a thumbnail; it gets the window and whether it is chosen. */
44
+ renderItem?: (item: SequenceItem, selected: boolean) => React.ReactNode;
45
+ /** The height of the strip. Default 5rem. */
46
+ height?: string;
47
+ className?: string;
48
+ };
49
+ /** A gapless strip of windows whose cuts are dragged or stepped, snapping to a beat grid inside the room the app gives; each cut is a slider that announces both windows' new lengths; Shift+click chooses a run. */
50
+ export declare function SequenceTimeline({ label, items, zoom, onCutChange, room, minLength, grid, step, selected, onSelectRange, renderItem, height, className, }: SequenceTimelineProps): React.JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { TranscriptGroup, TranscriptPhrase } from '../lib/transcript';
2
+ import * as React from "react";
3
+ /** What a seek from the transcript says about where it came from. */
4
+ export type TranscriptSeek = {
5
+ phraseId: string; /** The word pressed, when a word was. */
6
+ wordIndex?: number;
7
+ };
8
+ export type TranscriptViewProps = {
9
+ /** Names the transcript. */
10
+ label: string;
11
+ /** Phrases by clip, in time order. */
12
+ groups: readonly TranscriptGroup[];
13
+ /** The player's time, seconds. */
14
+ time: number;
15
+ /** A word or phrase was pressed: seconds to play from, and which. */
16
+ onSeek: (time: number, from: TranscriptSeek) => void;
17
+ /** The mode shown: "original" (the words) or a key of the phrases' `alt`. Leave out to let the component hold it. */
18
+ mode?: string;
19
+ onModeChange?: (mode: string) => void;
20
+ /** Names for the modes: `{ translated: "English" }`. Default: the key, capitalised. */
21
+ modeLabels?: Readonly<Record<string, string>>;
22
+ /** Show one speaker's phrases: "all" or a speaker. Leave out to let the component hold it. */
23
+ speaker?: string;
24
+ onSpeakerChange?: (speaker: string) => void;
25
+ /** Scroll the heard phrase into view while the person has not scrolled away. Default true. */
26
+ follow?: boolean;
27
+ /** Say each phrase politely as it starts. Default false. */
28
+ announce?: boolean;
29
+ /** A control at the start of each phrase (a `PlayWindowButton`). */
30
+ renderPlay?: (phrase: TranscriptPhrase) => React.ReactNode;
31
+ /** Height of the scroll box once it is long enough to virtualise. Default 480. */
32
+ height?: number;
33
+ className?: string;
34
+ };
35
+ /** Timed text that follows playback: the heard word marked, any word or phrase pressed to play from, modes, speakers, follow and Jump to now. */
36
+ export declare function TranscriptView({ label, groups, time, onSeek, mode: controlledMode, onModeChange, modeLabels, speaker: controlledSpeaker, onSpeakerChange, follow, announce, renderPlay, height, className }: TranscriptViewProps): React.JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { Load } from './data-view';
2
+ import { Expanded } from './disclosure';
3
+ import * as React from "react";
4
+ /** A node's place in the tree, passed to `renderNode`. */
5
+ export type TreeNodeState = {
6
+ expanded: boolean;
7
+ selected: boolean;
8
+ level: number;
9
+ branch: boolean;
10
+ };
11
+ export type TreeProps<N> = {
12
+ /** Names the tree for assistive technology: "Folders". Required. */
13
+ label: string;
14
+ /** The top level, as one read: the skeleton, the failure and Try again come from `DataView`'s `Load`. */
15
+ roots: Load<readonly N[]>;
16
+ /** The children of an open node, as a hook (`useLoad` inside). Called only while the node is open. */
17
+ useChildren: (node: N) => Load<readonly N[]>;
18
+ /** A node's key, unique in the whole tree: a path, an id. */
19
+ nodeKey: (node: N) => string;
20
+ /** A node's name: shown, and what type-ahead matches. */
21
+ nodeLabel: (node: N) => string;
22
+ /** Whether a node can open. Default: every node can. */
23
+ isBranch?: (node: N) => boolean;
24
+ /** What a row shows after the icon. Default: the name, cut with an ellipsis. */
25
+ renderNode?: (node: N, state: TreeNodeState) => React.ReactNode;
26
+ /** The chosen node's key, or `null`. */
27
+ selected: string | null;
28
+ /** A node was chosen. */
29
+ onSelect: (key: string, node: N) => void;
30
+ /** Which nodes are open; from `useExpanded`, optionally in the URL. */
31
+ expanded: Expanded;
32
+ /** The skeleton row while a node's children load. Default: a muted bar. */
33
+ loadingRow?: React.ReactNode;
34
+ /** What an open node with nothing in it says: "No folders". Required, so an empty branch is never blank. */
35
+ emptyRow: string;
36
+ /** The tallest the tree may be before it scrolls, as a CSS length. Default 24rem. */
37
+ height?: string;
38
+ className?: string;
39
+ };
40
+ /** A hierarchy whose children load as each node opens (a `useChildren` hook per open node): a skeleton row, a Try again row and an "empty" row per node, type-ahead and arrow keys, single selection, open state optionally in the URL, always virtualised. */
41
+ export declare function Tree<N>({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, expanded, loadingRow, emptyRow, height, className }: TreeProps<N>): React.JSX.Element;