strata-react 1.0.45 → 1.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -154,7 +154,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
154
154
  | Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar` | A status is always a word; figures have no icons or sparklines; `Meter` is a `meter` named for what it measures, with its reading in words ("72% used"), threshold notches, and a `Status` word once a threshold is crossed (each threshold must name its state); `CompositionBar` is a stacked bar over a table naming every part, its amount and share, and names the remainder (`total` needs `restLabel`); a part that is there reads "<1%" and keeps a sliver, never "0%"; `JobStatus` is a long-running server job (its `progress` `{ done, total, current }` reads "12 of 40 done, 28 remaining · IMG_0412"; `useJobAction` starts one: busy until the server answers, a "queued" toast with a link to the jobs page, a "finished" toast when it ends): a required word per state beside the app's sentence, a progress bar when the total is known, each failure named with its reason, announced only when the item changes or the job ends |
155
155
  | Data | `DataView`, `Load<T>`, `Stale`, `StaleNotice`, `LoadError`, `EmptyState`, `Skeleton`, `Thumbnail`, `ThumbnailSkeleton`, `DataTable`, `TableSkeleton`, `VirtualList`, `InfiniteList`, `LoadMore`, `useInView`, `LineChart` | `DataView` requires skeleton and empty, keeps data on screen under a `StaleNotice` (why, how old, Try again) when a refresh fails, and takes an `error` renderer for an app's own look of a failed read (default `LoadError`, always inside an alert); `Thumbnail` is a remote image in a box of fixed `aspect`, with a skeleton while it loads, the required `missing` words (or a `fallback` drawing, such as an avatar's initial) when it fails or `src` is null, required `alt`, `children` overlaid in its corners, and a request only once it nears the screen (`eager` for the first few); tables, lists and tile grids virtualise from 100 rows, on React Aria's Virtualizer; a `DataTable` is a React Aria table (a `grid`) over TanStack Table's data model; a `DataTable` column with `value` sorts by type with missing values last both ways and draws a placeholder (`missing`, default an en dash); `InfiniteList` loads the next page on approach, with a skeleton for it, a Try again row when it fails and a Show more button for the keyboard, and `scroll="page"` draws a grid that scrolls with the page; `LoadMore` is that next-page row for any list or grid; charts label values directly; `LineChart` can also follow an app's position (`current`), read a value at the pointer or by arrow keys (`readout`, one slider whose value text is the reading), report a picked x (`onPick`) and fill one flat area (`area`); `xLabel` names the x column of its table `Thumbnail`'s `src` may be a list tried in order, `onLoad` can reject a picture that loaded (a host's grey placeholder) and `onMissing` is told once when none worked; with `alt=""` and a `fallback` its missing state is presentational. `LoadMore` and `InfiniteList` can draw the Show more and loading rows the app's way (`more`, `loading`, and `ruled={false}` for no hairlines). |
156
156
  | Compare | `Compare`, `PairVote`, `PairJudge`, `CompareAudio`, `CompareText`, `CompareGrid`, `CompareVideoGrid`, `ViewportFrame`, `useViewport`, `FullscreenFrame`, `useDifference`, `differences` | Two pictures judged together: side by side, swipe (a divider that moves from the keyboard), fade, blink (`x` flips) and difference (a live difference blend with amplify, or pixelmatch's changed pixels with a tolerance and the share that differ; pixels are read only when that view is open, at most 2048 px on the long side, and a picture the browser will not let the page read says so in words); `maxHeight="fit"` measures the window for the pair and its surroundings instead of the `"viewport"` guess; `CompareGrid` is every candidate at once with the same zoom and full screen, and `actions` for what a tile offers; one zoom and pan for both sides (buttons, `+` `-` `0`, Ctrl-wheel or trackpad pinch, drag, arrow keys, double click, `1:1`), and full screen (the browser's Fullscreen API, a modal where there is none). `blind` is required: a blind comparison names pictures by `label` only and never writes the variant `id`, `note` or `alt`. A picture that fails shows the required `missing` words in its place; the keys come from one `Shortcut[]` shared with `KeysLegend`, and `keys={false}` leaves them to a surrounding screen. `PairVote` wraps `Compare` for a blind pairwise judgment: answer keys `a` `b` `t` `s` in Compare's one legend, a vote bar with no filled button, `pending`, a flag menu, a progress line, preload and Undo, and click to choose (a click on the picture you prefer, not a drag or double click; in swipe the side of the divider, in blink the side showing, none in fade or difference; `onPick` on `Compare` and `CompareVideo`, `pick={false}` turns it off). `CompareAudio` is one transport for two clips with an A/B switch that keeps the playhead (same time, or the same share when the lengths differ), a loop range and loudness matching (the louder clip turned down to the quieter, by RMS); `CompareText` is two texts scrolled together with a word diff and an optional reference; `PairJudge` is the answering around any of them; `CompareVideo` is two videos on one clock (play, pause, seek and speed drive both, the follower kept within a frame, both held while either waits for data) in side by side, swipe, fade and blink, with zoom and pan locked and nearest-neighbour pixels past 1:1, candidates of different sizes drawn in one box, one soundtrack (`audio`), and the same slots as the rest. `autoPlay` starts the pair once both can play (muted; not with reduced motion unless `"always"`) and `loopWhole` loops the whole clip when no range is set (also on `CompareVideoGrid`). Frame by frame (`,` `.`), a loop range the app can hold (`i` `o` `c`), speeds down to 0.1 and named `moments` are in it; `CompareVideoGrid` is every candidate's video at once on that one clock (one transport, one zoom, regions, a loop, stepping), light on the browser (metadata only until the first play, cells out of sight paused and left out of the sync, sound off unless `audio` names a cell, a cell that falls behind marked "Catching up"), with an optional `reference` drawn first, never blind and nearest-neighbour. `regions` (on `Compare`, `CompareVideo` and `CompareGrid`) names boxes in the source's coordinates to look at enlarged: chips, keys `q` `w` `e` `r` `y` `u`, nearest-neighbour drawing, the box outlined while its chip is pointed at, and Shift-drag to make another |
157
- | Selection | `useSelection`, `useChoices`, `BulkBar`, `SelectableGrid`, `DataTable`'s `selection` (`RowSelection<T>`) | Opt-in checkbox column with "Select all shown" that respects `isSelectable`; Shift-click or Shift+Space chooses or clears the run from the last row clicked, in the order shown; `initial` (keys or a test on the row) chooses a row the first time it appears, so it applies to data that loads later; the selection drops rows that are gone; `BulkBar` announces the count politely, and while it is up its one filled action is the view's only one (the screen's primary goes to `outline`); `SelectableGrid` is the same selection as a grid of pictures (`renderImage`), each tile one labelled target, virtualised from 100 tiles; as a photo grid it takes a pixel `tileSize` zoomed by Ctrl/Cmd+wheel, `+` and `-` (`onTileSizeChange`), `selectionMode` and `selectionBehavior` (`replace` is the Finder's rules; `onAction` opens), `groupBy` (sticky headings with a group box and a fold), a corner `badge`, `unselectableReason`, and counts what a filter hides ("3 chosen are hidden by the filter"); `ViewOptions` with `useViewOptions` is the one toolbar for how it is looked at: sort (natural order, direction named for the key), group, size slider, aspect, grid or list and a filter with its count, kept in `localStorage` and optionally `?sort=…&group=…&size=…`, a "View" popover on a phone. A choice can imply others: `implies(key)` (on `useSelection`, and `useChoices` for a lazy tree) keeps what the person chose apart from what that brings in, follows it through, locks the implied keys (they only clear with what implied them), and gives `implied`, `because(key)`, `counts`, a `note` for the live region and `summary(noun, then)`, the line a destructive confirm can carry ("12 results will be forgotten: 8 chosen, 4 that depend on them") |
157
+ | Selection | `useSelection`, `useChoices`, `BulkBar`, `SelectableGrid`, `DataTable`'s `selection` (`RowSelection<T>`) | Opt-in checkbox column with "Select all shown" that respects `isSelectable`; Shift-click or Shift+Space chooses or clears the run from the last row clicked, in the order shown; `initial` (keys or a test on the row) chooses a row the first time it appears, so it applies to data that loads later; the selection drops rows that are gone; `BulkBar` announces the count politely, and while it is up its one filled action is the view's only one (the screen's primary goes to `outline`); `SelectableGrid` is the same selection as a grid of pictures (`renderImage`), each tile one labelled target, virtualised from 100 tiles; as a photo grid it takes a pixel `tileSize` zoomed by Ctrl/Cmd+wheel, `+` and `-` and two-finger pinch (`onTileSizeChange`), `aspect="natural"` (rows of equal height, each picture at its `naturalAspect`), a marquee from between tiles, `selectionMode` and `selectionBehavior` (`replace` is the Finder's rules; `onAction` opens), `groupBy` (sticky headings with a group box and a fold), a corner `badge`, `unselectableReason`, and counts what a filter hides ("3 chosen are hidden by the filter"); `ViewOptions` with `useViewOptions` is the one toolbar for how it is looked at: sort (natural order, direction named for the key), group, size slider, aspect, grid or list and a filter with its count, kept in `localStorage` and optionally `?sort=…&group=…&size=…`, a "View" popover on a phone. A choice can imply others: `implies(key)` (on `useSelection`, and `useChoices` for a lazy tree) keeps what the person chose apart from what that brings in, follows it through, locks the implied keys (they only clear with what implied them), and gives `implied`, `because(key)`, `counts`, a `note` for the live region and `summary(noun, then)`, the line a destructive confirm can carry ("12 results will be forgotten: 8 chosen, 4 that depend on them") |
158
158
  | Expansion | `Disclosure`, `useExpanded`, `DataTable`'s `expansion` (`RowExpansion<T>`) | Show more of one row in place. The toggle is a button with `aria-expanded`; the body is mounted only while open, so a request inside it runs on first open (unlike `<details>`, which mounts every closed body); `useExpanded({ param })` shares the open keys across a list or table and keeps them in the URL; a table's detail row spans the data columns and is measured when virtualised |
159
159
  | Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `useInfiniteLoad`, `useJob`, `toLoad`, `staleOf`, `fetchJson`, `HttpError`, `readErrorBody`, `fieldErrorsOf` | TanStack Query in, `Load<T>` out; a refetch that fails after a good read stays `ready` with `stale` set, never an error panel; `useInfiniteLoad` works out the cursor itself (after the last item held), merges pages by key and can `dismiss` an item at once; `useJob` polls a job's status only while it runs and invalidates the queries it changes once, when it ends; `fetchJson` reads an error response's body onto the `HttpError` (`body`, `reason`, `fieldErrors`, read by `readErrorBody` or the API's own `readError`) |
160
160
  | Page and navigation | `AppShell`, `SideNav`, `Breadcrumb`, `Tabs`, `PageHeader`, `LinkCard`, `LinkCardList` | React Router; tab and sort state in the URL; a `LinkCard` is one link named by its title, described by its text and `Status` marks, with the whole card as the target (`to` a route, `href` elsewhere, marked with an arrow) |
@@ -170,10 +170,10 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
170
170
  | 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` |
171
171
  | Media player | `MediaPlayer`, `useMediaElement`, `SPEECH_RATES`, `useMediaSpans`, `SpanActions` | 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 `spans` and `spanKinds` mark stretches (an intro, a recap, a sponsor read) on the seek bar as named ranges in a status role's tone and act on them as playback reaches them: `auto` skips (or mutes, for `action: "mute"`) with "Skipped intro" and Undo, `ask` offers a Skip button over the picture and on the `s` key, `off` only draws; each is acted on once, `onSpan` reports `skipped`, `muted`, `undone` or `played`, and `SeekBar` takes `spans` too. `mediaRef` hands out the player's state and requests (an object ref holds the latest, no render of its own), `overlay` draws the app's own thing over the picture only, and a video keeps a 16:9 (or `aspect`) box before its metadata loads. The HLS attacher starts a `growing` source at its beginning, honours `config.startPosition` and takes `words` for its failures. |
172
172
  | 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` |
173
- | 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), with doubtful words (dotted, named, counted, "Only doubtful"), a mark per phrase set from a row menu (`states`, `onPhraseState`), correction in place (Enter or F2, `onEdit`) and a hover and focus card (`renderCard`); `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 |
173
+ | 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), with doubtful words (dotted, named, counted, "Only doubtful"), a mark per phrase set from a row menu (`states`, `onPhraseState`), correction in place (Enter or F2, `onEdit`) and a hover and focus card (`renderCard`); `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; a review transcript needs no player (`time` and `onSeek` are optional), takes `marking` (words become `MarkableText` marks with ids `wordId(phraseId, index)`, selected across rows that are not mounted) and shows a corrected word (`word.correction`) dotted with the original on hover and `onCorrectionPress` to open it |
174
174
  | 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 |
175
175
  | 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 |
176
- | 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 |
176
+ | 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); answers can carry pictures (`images`, labelled, lazy, linked to full size) that stay visible beside the collapsed "looked up"; 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 |
177
177
  | Pictures from a set | `Lightbox` (`useLightboxUrl`), `BookViewer` (`useBookUrl`), `TileGrid`, `BoxOverlay`/`BoxList`/`useBoxes`, `RegionEditor`; `moveRect`, `resizeRect`, `lerpRect`, `turnedSize`, `turnRect`, `readingOrder`, `zoomToBox`, `findPage` | A picture opened from a grid in a full-size `Dialog` (previous/next, arrow keys, "3 of 40" or a position like "Page 22 (12) of 44", zoom and 1:1, details beside it, an overlay and actions for the item, a thumbnail strip, `?view=` in the URL, neighbours preloaded, a `missing` sentence, Compare ticked hand-off); a scanned book read inline as spreads or single pages with printed and scan names, go-to, `?page=` and a strip with badges; a grid of picture tiles that link (`TileGrid`, with `TileGridSkeleton`); read-only boxes on a picture linked to a list beside it; `RegionEditor` also turns the picture by an angle (the windows turn with it) and edits a spread's gutter; 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 |
178
178
  | 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 |
179
179
  | Browsing | `Tree`, `FolderPicker` | A hierarchy that loads as it opens (`current` + `onCurrentChange` is the row in view beside the ticked ones, `count` and `badge` per row, `sortChildren`, `reveal` of a deep link, `resolveBranch` so ticking a year says "2019 and its 91 folders" without opening them; a hook per open node; skeleton, Try again and empty rows; always virtualised); `choices` (from `useChoices`) chooses several: a checkbox per row, Shift ranges, a parent drawn mixed from what has loaded under it (ticking a branch never opened reads and opens it and chooses everything under it), "Select all shown", and rows the choice implies marked "Included because of …" in words 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; a `Folder` may carry a `badge` and `tone` ("project", as words), `canChoose` gives the reason the button is disabled beside it, `chooseLabel` names it, `onOpen` can answer `"choose"` to take a folder at once instead of entering it, and the listing may return a `footer` under the tree |
package/UPGRADING.md CHANGED
@@ -11,6 +11,10 @@ time. While the version is 0.x, any release may break.
11
11
 
12
12
  Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Changelog").
13
13
 
14
+ ## After v1.0.46 (2026-11-14)
15
+
16
+ - `MarkableText` now acts on arrow, Home, End and Escape keys only while its own region has focus; keys from something focusable inside it (a list of rows) are that thing's. Words drawn as `Mark`s with nothing focusable around them behave as before.
17
+
14
18
  ## After v1.0.44 (2026-11-14)
15
19
 
16
20
  - `SelectableGrid` with `groupBy` is now one virtualised list: a group's heading is a row of the grid (not a `region` with its own list per group), so a test that looked for `getByRole("region", { name })` finds the heading row instead, and only the visible rows are in the DOM. Tiles `isSelectable` refuses are now focusable (not selectable) so the arrow keys land on them and their `unselectableReason` can be read; they were skipped before. The grouped baselines move.
@@ -1,4 +1,5 @@
1
1
  import { EntityMatcher } from '../lib/rich-text';
2
+ import { AspectRatio } from './thumbnail';
2
3
  import * as React from "react";
3
4
  export type RichTextProps = {
4
5
  /** The text, in the small subset: paragraphs, `- ` and `1. ` lists, **bold**, `code`, [links](https://…). */
@@ -11,13 +12,26 @@ export type RichTextProps = {
11
12
  };
12
13
  /** 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
14
  export declare function RichText({ children, entities, onOpen, className }: RichTextProps): React.JSX.Element;
15
+ /** A picture shown with an answer (issue #257). */
16
+ export type ConversationImage = {
17
+ src: string;
18
+ /** What it shows, in words: the picture's accessible name and its visible caption. */
19
+ label: string;
20
+ /** The full-size picture, when it is not `src`: the thumbnail becomes a link that opens it in a new tab. */
21
+ href?: string;
22
+ /** Width over height, so the box is its shape before the picture loads. Default 16/9. */
23
+ aspect?: AspectRatio;
24
+ };
14
25
  /** One turn of the thread. `failed` cannot be written without the sentence saying what happened. */
15
26
  export type ConversationTurn = {
16
27
  id: string;
17
28
  role: "person" | "answer";
18
29
  time: Date | string | number;
19
30
  text: string;
31
+ /** What the answer consulted, in a collapsed disclosure. Not for a picture that is the answer: use `images`. */
20
32
  lookedUp?: React.ReactNode;
33
+ /** Pictures that are part of the answer, drawn under its text, always visible: lazy, each with its label as its name and caption, and a link to the full size when `href` is given. */
34
+ images?: readonly ConversationImage[];
21
35
  } & ({
22
36
  state?: "done";
23
37
  } | {
@@ -18,10 +18,12 @@ export type MarkKind = {
18
18
  keys?: string[];
19
19
  };
20
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 }: {
21
+ export declare function Mark({ id, children, className, onClick, onHover }: {
22
22
  id: string;
23
23
  children: React.ReactNode;
24
- className?: string;
24
+ className?: string; /** A click on the word (a press and release on it), beside selecting it: a correction opens. */
25
+ onClick?: () => void; /** The pointer is over the word (its element) or has left (`null`). */
26
+ onHover?: (el: HTMLElement | null) => void;
25
27
  }): React.JSX.Element;
26
28
  /** "12 words must use, 3 never": a count for each kind in use, with its icon. */
27
29
  export declare function MarkSummary({ marks, kinds, unit, className }: {
@@ -42,6 +44,8 @@ export type MarkableTextProps = {
42
44
  onMark: (ids: readonly string[], kind: string | null) => void;
43
45
  /** Chords that clear the selection's marks: `["w"]`. */
44
46
  clearKeys?: string[];
47
+ /** Enter on the caret's id (a word that has something to open, such as a correction). Leave out and Enter does nothing. */
48
+ onActivate?: (id: string) => void;
45
49
  /** The caret moved to this id (so a virtualised list can scroll it into view). */
46
50
  onCaretChange?: (id: string) => void;
47
51
  /** What one id is called in counts: `["word", "words"]`. */
@@ -53,4 +57,4 @@ export type MarkableTextProps = {
53
57
  className?: string;
54
58
  };
55
59
  /** 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;
60
+ export declare function MarkableText({ label, ids, marks, kinds, onMark, clearKeys, onActivate, onCaretChange, unit, summary, children, className }: MarkableTextProps): React.JSX.Element;
@@ -2,7 +2,17 @@ import { RowSelection } from './data-table';
2
2
  import { TileAspect, TileSize } from './tile-grid';
3
3
  import * as React from "react";
4
4
  export type { TileAspect, TileSize };
5
- export type SelectableGridProps<T> = {
5
+ export type SelectableGridProps<T> = SelectableGridBase<T> & ({
6
+ /** Default `square`. `portrait` is 3:4, `landscape` 4:3, or a width over height (`16 / 9`). */
7
+ aspect?: TileAspect | number;
8
+ naturalAspect?: never;
9
+ } | {
10
+ /** Each picture at its own shape, in rows of equal height that fill the width (Google Photos, Lightroom). `tileSize` is then the row height to aim for, and every row's pictures and heights are worked out from `naturalAspect` before anything loads, so nothing moves as pictures arrive. Virtualised always. */
11
+ aspect: "natural";
12
+ /** A picture's width over height, from the record (its pixel size), never from the loaded image. */
13
+ naturalAspect: (row: T) => number;
14
+ });
15
+ type SelectableGridBase<T> = {
6
16
  /** Names the grid of tiles. */
7
17
  label: string;
8
18
  rows: T[];
@@ -13,8 +23,6 @@ export type SelectableGridProps<T> = {
13
23
  detail?: (row: T) => React.ReactNode;
14
24
  /** The chosen keys and how to change them, as `DataTable` takes them; `rowLabel` names each tile's box. */
15
25
  selection: RowSelection<T>;
16
- /** Default `square`. `portrait` is 3:4, `landscape` 4:3. */
17
- aspect?: TileAspect;
18
26
  /** Default `md`. Pixels for a continuous size: the minimum tile width, growing to fill the row. */
19
27
  tileSize?: TileSize | number;
20
28
  /** Asked to change the size by Ctrl/Cmd+wheel, `+` and `-`. Give a `useViewOptions` size back to `tileSize`; omit to leave the size fixed. */
@@ -27,8 +35,12 @@ export type SelectableGridProps<T> = {
27
35
  selectionBehavior?: "toggle" | "replace";
28
36
  /** Opens a tile: Enter, or a double click with `selectionBehavior="replace"`. */
29
37
  onAction?: (row: T) => void;
30
- /** A corner badge on the picture (top right): a `Status`. */
38
+ /** A corner badge on the picture (top right): a `Status`, "RAW+JPG". */
31
39
  badge?: (row: T) => React.ReactNode;
40
+ /** A second corner (bottom right of the picture) for a count or a mark ("12", a flag), on a chip so it reads on any picture. */
41
+ mark?: (row: T) => React.ReactNode;
42
+ /** `cover` (default) crops the picture to fill its frame; `contain` fits the whole picture in it, letterboxed. */
43
+ fit?: "cover" | "contain";
32
44
  /** Puts tiles under full-width headings, in the order the rows first show them. Virtualised like the ungrouped grid. */
33
45
  groupBy?: (row: T) => string;
34
46
  /** The words for a group's heading; default the group text. */
@@ -42,4 +54,4 @@ export type SelectableGridProps<T> = {
42
54
  className?: string;
43
55
  };
44
56
  /** A grid of pictures to choose from: each tile one labelled target, "Select all shown", Shift-click ranges, virtualised from `virtualizeFrom` tiles. Pair with `useSelection` and a `BulkBar`. */
45
- export declare function SelectableGrid<T>({ label, rows, rowKey, renderImage, detail, selection, aspect, tileSize, onTileSizeChange, zoomRange, selectionMode, selectionBehavior, onAction, badge, groupBy, groupHeading, unselectableReason, virtualizeFrom, maxHeight, className, }: SelectableGridProps<T>): React.JSX.Element;
57
+ export declare function SelectableGrid<T>({ label, rows, rowKey, renderImage, detail, selection, aspect, naturalAspect, tileSize, onTileSizeChange, zoomRange, selectionMode, selectionBehavior, onAction, badge, mark, fit, groupBy, groupHeading, unselectableReason, virtualizeFrom, maxHeight, className, }: SelectableGridProps<T>): React.JSX.Element;
@@ -9,7 +9,7 @@ export declare const aspectClass: Record<TileAspect, string>;
9
9
  /** A tile size as pixels: a named size's minimum width, or the number itself (a continuous size, issue #246). */
10
10
  export declare const tileWidth: (size: TileSize | number) => number;
11
11
  /** `GridLayout` options for tiles of this size and aspect: they grow from the minimum width to fill the row, and each row is as tall as its tallest tile as measured. */
12
- export declare function tileLayoutOptions(tileSize: TileSize | number, aspect: TileAspect): {
12
+ export declare function tileLayoutOptions(tileSize: TileSize | number, aspect: TileAspect | number): {
13
13
  minItemSize: Size;
14
14
  minSpace: Size;
15
15
  };
@@ -56,4 +56,12 @@ export declare function TileGridSkeleton({ count, aspect, tileSize, className }:
56
56
  tileSize?: TileSize;
57
57
  className?: string;
58
58
  }): React.JSX.Element;
59
+ /** The loading shape of a `SelectableGrid`: `count` picture boxes at the grid's tile size and shape, for a `DataView` skeleton. With `shapes` (widths over heights, cycled) the boxes are in rows at their own shapes, as `aspect="natural"` draws them. */
60
+ export declare function SelectableGridSkeleton({ count, aspect, tileSize, shapes, className }: {
61
+ count?: number;
62
+ aspect?: TileAspect | number;
63
+ tileSize?: TileSize | number;
64
+ shapes?: readonly number[];
65
+ className?: string;
66
+ }): React.JSX.Element;
59
67
  export {};
@@ -1,4 +1,5 @@
1
1
  import { TranscriptGroup, TranscriptPhrase, TranscriptPhraseState } from '../lib/transcript';
2
+ import { MarkKind } from './markable-text';
2
3
  import * as React from "react";
3
4
  /** What a seek from the transcript says about where it came from. */
4
5
  export type TranscriptSeek = {
@@ -10,10 +11,20 @@ export type TranscriptViewProps = {
10
11
  label: string;
11
12
  /** Phrases by clip, in time order. */
12
13
  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;
14
+ /** The player's time, seconds. Leave out for a transcript with no player: nothing is heard or followed. */
15
+ time?: number;
16
+ /** A word or phrase was pressed: seconds to play from, and which. Leave out and the words and times are text. */
17
+ onSeek?: (time: number, from: TranscriptSeek) => void;
18
+ /** Mark words (`MarkableText`): the kinds, the mark on each word id (`wordId(phraseId, index)`), and `onMark(ids, kind | null)`. Words become marks to select, not seek buttons. */
19
+ marking?: {
20
+ kinds: readonly MarkKind[];
21
+ marks: Readonly<Record<string, string | undefined>>;
22
+ onMark: (ids: readonly string[], kind: string | null) => void;
23
+ clearKeys?: string[];
24
+ summary?: boolean;
25
+ };
26
+ /** A corrected word was pressed (a click, with no drag): open it for editing. Takes the click on that word from seeking. */
27
+ onCorrectionPress?: (phraseId: string, wordIndex: number) => void;
17
28
  /** The mode shown: "original" (the words) or a key of the phrases' `alt`. Leave out to let the component hold it. */
18
29
  mode?: string;
19
30
  onModeChange?: (mode: string) => void;
@@ -49,4 +60,4 @@ export type TranscriptViewProps = {
49
60
  className?: string;
50
61
  };
51
62
  /** Timed text that follows playback: the heard word marked, any word or phrase pressed to play from, modes, speakers, follow and Jump to now. */
52
- export declare function TranscriptView({ label, groups, time, onSeek, mode: controlledMode, onModeChange, modeLabels, speaker: controlledSpeaker, onSpeakerChange, follow, announce, renderPlay, doubtfulBelow, states, onPhraseState, renderActions, onEdit, renderCard, cardDelay, height, className }: TranscriptViewProps): React.JSX.Element;
63
+ export declare function TranscriptView({ label, groups, time, onSeek, marking, onCorrectionPress, mode: controlledMode, onModeChange, modeLabels, speaker: controlledSpeaker, onSpeakerChange, follow, announce, renderPlay, doubtfulBelow, states, onPhraseState, renderActions, onEdit, renderCard, cardDelay, height, className }: TranscriptViewProps): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -40,7 +40,7 @@ export { DataTable, TableSkeleton, parseSort, serialiseSort, type CellValue, typ
40
40
  export { MediaPlayer, useMediaElement, useAttachedSource, SPEECH_RATES, type MediaPlayerProps, type MediaElementState, type MediaElementOptions, type MediaWindow, type StreamContext, type StreamAttachment, type SourceAttacher, type MediaProblem, type MediaSource, type MediaSession } from './components/media-player';
41
41
  export { useMediaSpans, SpanActions, type MediaSpanData, type SpanKind, type SpanBehaviour, type SpanOutcome, type SpanWords, type MediaSpansState } from './components/media-spans';
42
42
  export { TranscriptView, type TranscriptViewProps, type TranscriptSeek } from './components/transcript-view';
43
- export { phraseAt, wordAt, isDoubtful, phraseDoubtful, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptWord } from './lib/transcript';
43
+ export { phraseAt, wordAt, wordId, phraseOfWordId, isDoubtful, phraseDoubtful, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptWord } from './lib/transcript';
44
44
  export { Waveform, type WaveformProps, type WaveformMark, type WaveformMarkKind, type WaveformSpan, type WaveformTone } from './components/waveform';
45
45
  export { resamplePeaks, toPeakPair, peaksFromAudio, type WaveformPeaks, type PeakPair, type DecodedAudio } from './lib/waveform';
46
46
  export { MediaGroup, PlayWindowButton, joinMediaGroup, type PlayWindowButtonProps } from './components/media-group';
@@ -56,7 +56,7 @@ export { BulkBar, useSelection, useChoices, type InitialSelection, type Choices,
56
56
  export type { Implies } from './lib/choice';
57
57
  export { SelectableGrid, type SelectableGridProps, type TileAspect, type TileSize, } from './components/selectable-grid';
58
58
  export { ViewOptions, useViewOptions, sortRows, type ViewOptionsProps, type ViewOptionsConfig, type ViewOptionsState, type ViewSort, type ViewGroup, type ViewGroupRows } from './components/view-options';
59
- export { TileGrid, TileGridSkeleton, type TileGridProps } from './components/tile-grid';
59
+ export { TileGrid, TileGridSkeleton, SelectableGridSkeleton, type TileGridProps } from './components/tile-grid';
60
60
  export { VirtualList } from './components/virtual-list';
61
61
  export { InfiniteList, LoadMore, type InfiniteListProps, type LoadMoreProps } from './components/infinite-list';
62
62
  export { LineChart, LineChartGroup, logScale, valueAt, type ChartMark, type ChartSpan, type GroupedChart, type LineChartGroupProps, type LineChartProps, type Point, type SpanTone, type YScale } from './components/line-chart';
@@ -90,7 +90,7 @@ export { differences, readPixels, resample, MAX_SIDE, DEFAULT_TOLERANCE, type Di
90
90
  export { Workspace, Split, Pane, useWorkspaceState, type WorkspaceState, type PaneProps } from './components/workspace';
91
91
  export { useHistory, useHistoryState, type History, type HistoryOptions, type HistoryStep, type HistoryStateOptions, type SetOptions, } from './components/history';
92
92
  export { useAutoSave, useLeaveGuard, SaveStatus, type AutoSave, type AutoSaveOptions, type SaveState } from './components/save';
93
- export { RichText, Conversation, Composer, type RichTextProps, type ConversationProps, type ConversationTurn, type ComposerProps } from './components/conversation';
93
+ export { RichText, Conversation, Composer, type RichTextProps, type ConversationProps, type ConversationTurn, type ConversationImage, type ComposerProps } from './components/conversation';
94
94
  export { parseRichText, parseInline, matchEntities, safeHref, plainText, type EntityMatch, type EntityMatcher, type Block as RichBlock, type Inline as RichInline } from './lib/rich-text';
95
95
  export { Lightbox, useLightboxUrl, type LightboxProps, type LightboxItem, type LightboxUrl } from './components/lightbox';
96
96
  export { RegionEditor, describeRegion, type RegionEditorProps, type EditableRegion, type RegionTone } from './components/region-editor';