strata-react 1.0.32 → 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.
- package/README.md +11 -1
- package/UPGRADING.md +2 -0
- package/dist/components/conversation.d.ts +67 -0
- package/dist/components/cursor.d.ts +44 -0
- package/dist/components/dialog.d.ts +1 -1
- package/dist/components/folder-picker.d.ts +42 -0
- package/dist/components/lightbox.d.ts +34 -0
- package/dist/components/line-chart.d.ts +92 -3
- package/dist/components/markable-text.d.ts +56 -0
- package/dist/components/media-group.d.ts +25 -0
- package/dist/components/media-player.d.ts +80 -2
- package/dist/components/media.d.ts +6 -1
- package/dist/components/region-editor.d.ts +55 -0
- package/dist/components/sequence-timeline.d.ts +50 -0
- package/dist/components/transcript-view.d.ts +36 -0
- package/dist/components/tree.d.ts +41 -0
- package/dist/components/waveform.d.ts +66 -0
- package/dist/cursor-DDGBPiTJ.js +290 -0
- package/dist/cursor-DDGBPiTJ.js.map +1 -0
- package/dist/field-7Z4N5r5g.js +178 -0
- package/dist/field-7Z4N5r5g.js.map +1 -0
- package/dist/{geo-C0jcFp4q.js → format-B32-PVi2.js} +2 -119
- package/dist/format-B32-PVi2.js.map +1 -0
- package/dist/hls/index.d.ts +19 -0
- package/dist/hls.js +84 -0
- package/dist/hls.js.map +1 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.js +9511 -6296
- package/dist/index.js.map +1 -1
- package/dist/lib/geo.d.ts +17 -1
- package/dist/lib/marks.d.ts +6 -0
- package/dist/lib/region.d.ts +46 -0
- package/dist/lib/rich-text.d.ts +44 -0
- package/dist/lib/sequence.d.ts +34 -0
- package/dist/lib/transcript.d.ts +28 -0
- package/dist/lib/waveform.d.ts +36 -0
- package/dist/map/fan.d.ts +15 -0
- package/dist/map/index.d.ts +3 -1
- package/dist/map/markers.d.ts +60 -0
- package/dist/map/route-map.d.ts +53 -1
- package/dist/map.js +626 -40
- package/dist/map.js.map +1 -1
- package/dist/panorama/gl.d.ts +16 -0
- package/dist/panorama/index.d.ts +2 -0
- package/dist/panorama/panorama-viewer.d.ts +56 -0
- package/dist/panorama/projection.d.ts +45 -0
- package/dist/panorama.js +657 -0
- package/dist/panorama.js.map +1 -0
- package/dist/{query-DgJMyXTT.js → query-BJcxJLhh.js} +3 -2
- package/dist/{query-DgJMyXTT.js.map → query-BJcxJLhh.js.map} +1 -1
- package/dist/{run-BqZGKhW9.js → run-DzyLrZlA.js} +23 -5
- package/dist/run-DzyLrZlA.js.map +1 -0
- package/dist/testing.js +2 -2
- package/dist/{theme-BgTOESmN.js → theme-CFNi6WUO.js} +5 -175
- package/dist/theme-CFNi6WUO.js.map +1 -0
- package/dist/value-controls-D6O9TsM6.js +356 -0
- package/dist/value-controls-D6O9TsM6.js.map +1 -0
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +19 -4
- package/dist/geo-C0jcFp4q.js.map +0 -1
- package/dist/run-BqZGKhW9.js.map +0 -1
- 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
|
|
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,6 +146,14 @@ 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` |
|
|
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 |
|
|
147
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 |
|
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
|
+
- `MediaElementState` has new members (`window`, `playWindow`, `ready`, `waitingForMore`, `reportProblem`): code that builds one by hand (a stand-in for `Transport`, say) must add them. `useMediaElement` and `MediaPlayer` now keep the pitch whenever the rate changes (`preservesPitch`).
|
|
17
|
+
- `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.
|
|
16
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.
|
|
17
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).
|
|
18
20
|
- `renderWithStrata` and `renderRoutes` render a `StrataToastRegion` and clear the toast queue before each render. A test whose route tree already renders the region (a root layout route) passes `toasts: false`, or finds every toast twice.
|
|
@@ -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;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** Who set the cursor: a pointer or key over a member, or playback (a player's clock). */
|
|
3
|
+
export type CursorOwner = "pointer" | "playback";
|
|
4
|
+
/** How a member's own x relates to the scope's unit. Both default to the identity. */
|
|
5
|
+
export type CursorMapping = {
|
|
6
|
+
/** From this member's x to the scope's unit (a chart in seconds in a scope in metres: look it up in the series). */
|
|
7
|
+
toCursor?: (x: number) => number;
|
|
8
|
+
/** From the scope's unit to this member's x. */
|
|
9
|
+
fromCursor?: (at: number) => number;
|
|
10
|
+
};
|
|
11
|
+
type Snapshot = {
|
|
12
|
+
/** The position now: the pointer's while there is one, else playback's; null when neither is set. */
|
|
13
|
+
at: number | null;
|
|
14
|
+
/** Who wrote `at`; a member ignores a position it wrote. */
|
|
15
|
+
source: string | null;
|
|
16
|
+
owner: CursorOwner | null;
|
|
17
|
+
};
|
|
18
|
+
export type CursorScopeProps = {
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
/** Words for the position in the scope's unit ("12.4 km along", "1:23"), for the polite announcement. Without it nothing is announced. */
|
|
21
|
+
format?: (at: number) => string;
|
|
22
|
+
/** Milliseconds between announcements. Default 1000. */
|
|
23
|
+
announceEvery?: number;
|
|
24
|
+
};
|
|
25
|
+
/** Holds one cursor position for the charts, map and seek bar inside it, with a throttled polite announcement of where a pointer or key has put it. */
|
|
26
|
+
export declare function CursorScope({ children, format, announceEvery }: CursorScopeProps): React.JSX.Element;
|
|
27
|
+
/** What a member reads and writes. */
|
|
28
|
+
export type SharedCursor = Snapshot & {
|
|
29
|
+
/** This member's own id: positions it writes are not drawn back at it. */
|
|
30
|
+
source: string;
|
|
31
|
+
/** The position another member (or playback) put there, in the scope's unit; null when none or when this member wrote it. */
|
|
32
|
+
other: number | null;
|
|
33
|
+
/** The pointer or keyboard is at `at` over this member (the scope's unit). `null`: it left. */
|
|
34
|
+
setPointer: (at: number | null) => void;
|
|
35
|
+
/** Playback is at `at` (the scope's unit). Call it from the player's clock; `null` when it stops. */
|
|
36
|
+
setPlayback: (at: number | null) => void;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Join the nearest `CursorScope` as one member. Returns null outside a scope, so a component can take a
|
|
40
|
+
* `cursor` prop and do nothing when the app has not set one up. `source` is this member's id; the
|
|
41
|
+
* default is a unique one.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useSharedCursor(source?: string): SharedCursor | null;
|
|
44
|
+
export {};
|
|
@@ -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;
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
+
import { CursorMapping } from './cursor';
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
export type Point = {
|
|
3
4
|
x: number;
|
|
4
5
|
y: number;
|
|
5
6
|
};
|
|
7
|
+
/** Shading tones for `spans`: the role's subtle fill. */
|
|
8
|
+
export type SpanTone = "neutral" | "info" | "success" | "warning" | "danger";
|
|
9
|
+
/** A stretch of x shaded behind the line (stops, usable footage, a chosen stretch). */
|
|
10
|
+
export type ChartSpan = {
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
label: string;
|
|
14
|
+
tone?: SpanTone;
|
|
15
|
+
};
|
|
16
|
+
/** A labelled point on the line, as a control. */
|
|
17
|
+
export type ChartMark = {
|
|
18
|
+
x: number;
|
|
19
|
+
/** Its name: "Clip 4". Said with its x, listed for screen readers and shown on hover and focus. */
|
|
20
|
+
label: string;
|
|
21
|
+
/** Any CSS colour, normally a role. Default the foreground. */
|
|
22
|
+
colour?: string;
|
|
23
|
+
selected?: boolean;
|
|
24
|
+
};
|
|
6
25
|
export type LineChartProps = {
|
|
7
26
|
/** What the chart shows, as a sentence. Used as the accessible name and the table caption. */
|
|
8
27
|
label: string;
|
|
@@ -18,8 +37,29 @@ export type LineChartProps = {
|
|
|
18
37
|
/** What x is, as the screen-reader table's first column heading: "Distance", "Day". Default "Time". */
|
|
19
38
|
xLabel?: string;
|
|
20
39
|
formatY: (y: number) => string;
|
|
21
|
-
/** Where to put x labels, in x units. The chart drops every other one (and so on) when they would overlap at its width. */
|
|
22
|
-
xTicks: number[]
|
|
40
|
+
/** Where to put x labels, in x units, or a function of the visible range (so labels can switch between clock time and distance). The chart drops every other one (and so on) when they would overlap at its width. */
|
|
41
|
+
xTicks: number[] | ((range: {
|
|
42
|
+
min: number;
|
|
43
|
+
max: number;
|
|
44
|
+
}) => number[]);
|
|
45
|
+
/** A fixed x range, for charts that share one axis (`LineChartGroup` sets it). Default: the series' own. */
|
|
46
|
+
xDomain?: readonly [number, number];
|
|
47
|
+
/** `"none"` draws no x labels: the upper charts of a stack. Default `"labels"`. */
|
|
48
|
+
xAxis?: "labels" | "none";
|
|
49
|
+
/** `"log"` for a quantity that spans decades (pace, a magnitude). Ticks are 1, 2, 5 steps chosen here; a reading at or below zero is not drawn and is counted under the chart. Default `"linear"`. */
|
|
50
|
+
yScale?: "linear" | "log";
|
|
51
|
+
/** The smaller value at the top (pace: faster is up). */
|
|
52
|
+
yInvert?: boolean;
|
|
53
|
+
/** Stretches shaded behind the line, named in the key and the text for screen readers. */
|
|
54
|
+
spans?: readonly ChartSpan[];
|
|
55
|
+
/** Labelled points on the line. One tab stop; arrows move between them. */
|
|
56
|
+
marks?: readonly ChartMark[];
|
|
57
|
+
/** A mark was pressed (a click, Enter or Space). */
|
|
58
|
+
onMarkSelect?: (mark: ChartMark) => void;
|
|
59
|
+
/** What shows beside a mark on hover and focus: words, as in `Tooltip`. Default the mark's label and x. */
|
|
60
|
+
renderMarkCard?: (mark: ChartMark) => React.ReactNode;
|
|
61
|
+
/** Join the nearest `CursorScope`: hovering or arrowing here puts a rule and this chart's reading in every member, and theirs shows here. `true` when x is the scope's unit; a mapping when it is not (time here, distance there). */
|
|
62
|
+
cursor?: boolean | CursorMapping;
|
|
23
63
|
/** Pin the bottom of the y-axis (default: 0, or lower if a reading is negative). A reading below it still shows. */
|
|
24
64
|
yMin?: number;
|
|
25
65
|
/** Pin the top of the y-axis, for a bounded quantity such as a percentage (`yMax={100}`), so a low reading looks low. Choose a range that divides into four steps. A reading above it still shows. */
|
|
@@ -65,10 +105,59 @@ export declare function yScale(values: number[], pin?: {
|
|
|
65
105
|
max: number;
|
|
66
106
|
ticks: number[];
|
|
67
107
|
};
|
|
108
|
+
/** What a y scale gives the chart: its ends, ticks and where a value falls between them (0 at `min`, 1 at `max`). */
|
|
109
|
+
export type YScale = {
|
|
110
|
+
min: number;
|
|
111
|
+
max: number;
|
|
112
|
+
ticks: number[];
|
|
113
|
+
at: (v: number) => number;
|
|
114
|
+
log: boolean;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* A logarithmic y axis over the positive values: the ends are the nearest 1, 2, 5 steps outside the
|
|
118
|
+
* data, the ticks are those steps, thinned to whole decades and then every k-th decade when there are
|
|
119
|
+
* more than seven. Values at or below zero are ignored (the chart reports them). A pinned end is used as
|
|
120
|
+
* given when it is positive and does not cut a reading off.
|
|
121
|
+
*/
|
|
122
|
+
export declare function logScale(values: number[], pin?: {
|
|
123
|
+
min?: number;
|
|
124
|
+
max?: number;
|
|
125
|
+
}): YScale;
|
|
126
|
+
/** The value of a series at x, read between the two readings either side (flat beyond the ends). Series need not be sorted. */
|
|
127
|
+
export declare function valueAt(series: readonly Point[], x: number): number;
|
|
68
128
|
/**
|
|
69
129
|
* The x ticks that fit at this width: every k-th tick, the smallest k for which neighbouring labels
|
|
70
130
|
* leave a gap, so the spacing stays even. `scale` maps an x value to a pixel.
|
|
71
131
|
*/
|
|
72
132
|
export declare function fitTicks(ticks: number[], scale: (x: number) => number, widthOf: (t: number) => number, gap?: number): number[];
|
|
73
133
|
/** One measured series, drawn in real pixels, with the peak and current readings labelled on the chart and every reading in a screen-reader table. Optional plan, threshold band and `colourScale`. */
|
|
74
|
-
export declare function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel, formatY, xTicks, yMin, yMax, colour, colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, height, className, }: LineChartProps): React.JSX.Element;
|
|
134
|
+
export declare function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel, formatY, xTicks, xDomain, xAxis, yScale: yMode, yInvert, spans, marks, onMarkSelect, renderMarkCard, cursor: cursorProp, yMin, yMax, colour, colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, height, className, }: LineChartProps): React.JSX.Element;
|
|
135
|
+
/** One chart of a `LineChartGroup`: the props that differ per chart. The group owns the x axis, the cursor, `current` and `onPick`. */
|
|
136
|
+
export type GroupedChart = Omit<LineChartProps, "formatX" | "xLabel" | "xTicks" | "xDomain" | "xAxis" | "current" | "onPick" | "cursor" | "readout" | "label"> & {
|
|
137
|
+
/** Names this chart in the group's reading and its own accessible name. Default `seriesLabel`. */
|
|
138
|
+
label?: string;
|
|
139
|
+
};
|
|
140
|
+
export type LineChartGroupProps = {
|
|
141
|
+
/** What the stack shows, as a sentence. */
|
|
142
|
+
label: string;
|
|
143
|
+
charts: readonly GroupedChart[];
|
|
144
|
+
formatX: (x: number) => string;
|
|
145
|
+
xLabel?: string;
|
|
146
|
+
xTicks: LineChartProps["xTicks"];
|
|
147
|
+
/** Drawn on every chart (a chart's own `spans` and `marks` replace them). */
|
|
148
|
+
spans?: readonly ChartSpan[];
|
|
149
|
+
marks?: readonly ChartMark[];
|
|
150
|
+
onMarkSelect?: (mark: ChartMark) => void;
|
|
151
|
+
renderMarkCard?: (mark: ChartMark) => React.ReactNode;
|
|
152
|
+
/** The current x, drawn on every chart. */
|
|
153
|
+
current?: number;
|
|
154
|
+
onPick?: (x: number) => void;
|
|
155
|
+
className?: string;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Charts stacked on one x axis: one shared range, labels on the last chart only, and one cursor, so
|
|
159
|
+
* hovering or arrowing in any chart puts a rule and that chart's own reading in all of them (read
|
|
160
|
+
* together, and announced as one sentence, politely, at most once a second). Inside a `CursorScope`
|
|
161
|
+
* already, it joins that scope (a map beside the charts moves with them); otherwise it makes its own.
|
|
162
|
+
*/
|
|
163
|
+
export declare function LineChartGroup({ label, charts, formatX, xLabel, xTicks, spans, marks, onMarkSelect, renderMarkCard, current, onPick, className }: LineChartGroupProps): 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
|
|
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;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Shortcut } from './hotkeys';
|
|
2
|
+
import { CursorMapping } from './cursor';
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
export type Precision = "seconds" | "ms" | "frames";
|
|
4
5
|
type TimeProps = {
|
|
@@ -36,10 +37,14 @@ export type SeekBarProps = TimeProps & {
|
|
|
36
37
|
bigStep?: number;
|
|
37
38
|
label?: string;
|
|
38
39
|
disabled?: boolean;
|
|
40
|
+
/** Join the nearest `CursorScope` (strata-react issue #184): a pointer over the bar puts its time in every member, another member's position shows as a faint tick, and the bar's own time is the scope's playback position (`playback: false` to leave that to the app). A mapping when the scope's unit is not seconds (a route's metres). */
|
|
41
|
+
cursor?: boolean | (CursorMapping & {
|
|
42
|
+
playback?: boolean;
|
|
43
|
+
});
|
|
39
44
|
className?: string;
|
|
40
45
|
};
|
|
41
46
|
/** A seek bar: dragged, clicked and moved by keys (arrows `step`, Page keys `bigStep`, Home and End), with its time as the accessible value. */
|
|
42
|
-
export declare function SeekBar({ time, duration: known, onSeek, marks, onMarkPress, buffered, step, bigStep, label, precision, fps, disabled: off, className }: SeekBarProps): React.JSX.Element;
|
|
47
|
+
export declare function SeekBar({ time, duration: known, onSeek, marks, onMarkPress, buffered, step, bigStep, label, precision, fps, disabled: off, cursor: cursorProp, className }: SeekBarProps): React.JSX.Element;
|
|
43
48
|
export type TransportProps = {
|
|
44
49
|
playing: boolean;
|
|
45
50
|
onPlayPause: () => void;
|