strata-react 1.3.12 → 1.3.13

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
@@ -173,7 +173,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
173
173
  | Overlays | `Dialog`, `DialogProps`, `AlertDialog`, `Popover`, `Tooltip` | React Aria underneath. A dialog always has a title and, via `actions`'s close render prop, a way out; `closable={false}` while work cannot stop; `placement="end"` is a sheet. `AlertDialog` is the only confirm: required verb on the confirm button, Cancel focused first, no outside dismiss, stays open with the reason when an async confirm fails. `Popover` needs a `label`. `Tooltip` opens on hover and focus and `IconButton` uses it. All portal onto the `layer-*` stacking utilities |
174
174
  | Value controls | `NumberField`, `Slider`, `ColorField`, `SecretField` | Set a number or colour precisely, inside `Field`. `NumberField` and `Slider` are React Aria's; the number field runs with `commitBehavior="validate"`, so a typed value outside `min`/`max` is kept on screen, explained in the `Field` ("Enter a value from 0% to 500%.") and never passed to `onChange`. A value that is not known is `null` and shows an en dash, never 0 or NaN. Digits and decimal mark follow `locale`. The unit sits inside the control, and in the slider's spoken value when `Intl` has it (%, °, ms, s, kB, MB, GB, kbps, Mbps). Arrows step, Home/End jump to the limits; `Slider editable` adds a number field. `ColorField`: platform picker, typed hex that is normalised, app suggestions, and a contrast note against `against`. No motion on value changes. `NumberField` options for a value set a little at a time or that costs work to change: `nudge={[0.1, 1, 10]}` (a toolbar of named step buttons that repeat when held and stop at the limits), `suggestion={{ value, label, reason }}` (a row with the reason in words and Use this value, never applied by itself) and `preview` (changes wait behind Apply and Revert; `onChange` is Apply's). `SecretField` is a credential the server keeps and never shows again: not set, set (no characters, no length, no input in the DOM), a masked entry with a Show toggle named for what it reveals, `onSave` through `AsyncButton`, Replace, a confirmed Remove that says what stops working, and a Test whose result is text beside it; a set, untouched field reports nothing |
175
175
  | 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` |
176
- | Media player | `MediaPlayer`, `useMediaElement`, `SPEECH_RATES`, `useMediaSpans`, `SpanActions`, `PlayerNotice`, `SpanStrip` | 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, `heading` (title, subtitle, avatar, each a link) is drawn across the top of a video while paused or the pointer moves, and a video keeps a 16:9 (or `aspect`) box before its metadata loads. A video has a Full screen button and the `f` key by default (`fullscreen={false}` removes them); on the picture a click plays or pauses, a double click toggles full screen and the wheel sets the volume while the player has focus. A kind's `colour` names a custom property of the app's theme (`"--seg-sponsor"`) instead of a tone, each range carries `data-kind`, and under the browser's own controls a `SpanStrip` under the picture draws the ranges. `start` begins a first load at a time (an attacher's `startAt`, or a seek once the metadata is in) and says "Picked up at 2:05" with Start over (`resumeWords`); `onProgress` reports the position and the seconds actually played through, each once, a skipped span counted (`useMediaElement` takes it too, with `markWatched`). The HLS attacher starts a `growing` source at its beginning, honours `config.startPosition` and takes `words` for its failures. |
176
+ | Media player | `MediaPlayer`, `useMediaElement`, `SPEECH_RATES`, `useMediaSpans`, `SpanActions`, `PlayerNotice`, `SpanStrip` | 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, `heading` (title, subtitle, avatar, each a link, with the app's router `state`) is drawn across the top of a video while paused or the pointer moves, and a video keeps a 16:9 (or `aspect`) box before its metadata loads. A video has a Full screen button and the `f` key by default (`fullscreen={false}` removes them); on the picture a click plays or pauses, a double click toggles full screen and the wheel sets the volume while the player has focus. A kind's `colour` names a custom property of the app's theme (`"--seg-sponsor"`) instead of a tone, each range carries `data-kind`, and under the browser's own controls a `SpanStrip` under the picture draws the ranges. `start` begins a first load at a time (an attacher's `startAt`, or a seek once the metadata is in) and says "Picked up at 2:05" with Start over (`resumeWords`); `onProgress` reports the position and the seconds actually played through, each once, a skipped span counted (`useMediaElement` takes it too, with `markWatched`). The HLS attacher starts a `growing` source at its beginning, honours `config.startPosition` and takes `words` for its failures. |
177
177
  | 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` |
178
178
  | Listening and reading | `Waveform`, `TranscriptView`, `PlayWindowButton`, `MediaGroup`, `FilmStrip`; `resamplePeaks`, `peaksFromAudio`, `peakGain`, `phraseAt`, `wordAt`, `pickEvenly`, `frameAt` | 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, `normalise` to draw quiet sound to fill the height and say by how much); `FilmStrip` is a row of frames from a stretch of video that fits its width (picked evenly), each with its time, pressing one seeks (`onSeek`, one tab stop with arrow keys), and the frame at `time` inside `span` is ringed; 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 |
179
179
  | 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 |
@@ -21,6 +21,8 @@ type BaseProps = {
21
21
  "aria-label"?: string;
22
22
  id?: string;
23
23
  onPress?: ButtonProps["onPress"];
24
+ /** React Router's location state for a `to` link (where the person came from, read on the next page with `useLocation().state`). */
25
+ state?: unknown;
24
26
  };
25
27
  /** Props of `ButtonLink`. */
26
28
  export type ButtonLinkProps = BaseProps & Target & {
@@ -32,7 +34,7 @@ export type ButtonLinkProps = BaseProps & Target & {
32
34
  export type TextLinkProps = BaseProps & Target & {
33
35
  icon?: IconComponent;
34
36
  };
35
- export declare function useTarget(target: Target, newTab: boolean | undefined): {
37
+ export declare function useTarget(target: Target, newTab: boolean | undefined, state?: unknown): {
36
38
  provide: (node: React.ReactNode) => React.JSX.Element;
37
39
  props: {
38
40
  href: string;
@@ -149,6 +149,8 @@ export type MediaHeading = {
149
149
  subtitle?: string;
150
150
  /** An app route the subtitle leads to, and the picture with it when there is a subtitle to name that link. */
151
151
  subtitleTo?: string;
152
+ /** React Router's location state the heading's links carry (where the person came from, for the next page to read). */
153
+ state?: unknown;
152
154
  /** A small round picture before the words (the maker's avatar). `null` draws the subtitle's first letter instead. */
153
155
  avatar?: string | null;
154
156
  };
package/dist/index.js CHANGED
@@ -3755,11 +3755,11 @@ function createWatchedRanges() {
3755
3755
  };
3756
3756
  }
3757
3757
  // src/components/link.tsx
3758
- function useTarget(target, newTab) {
3758
+ function useTarget(target, newTab, state) {
3759
3759
  const navigate = useNavigate();
3760
3760
  return {
3761
3761
  provide: (node) => /* @__PURE__ */ jsx(RouterProvider, {
3762
- navigate: (to) => void navigate(to),
3762
+ navigate: (to) => void navigate(to, state === void 0 ? void 0 : { state }),
3763
3763
  useHref,
3764
3764
  children: node
3765
3765
  }),
@@ -3775,12 +3775,12 @@ function useTarget(target, newTab) {
3775
3775
  * A link drawn as a `Button` (React Router `to`, or `href` for a download or another site): the same variants and heights, `variant="default"` is the filled one and counts for the one-filled-button rule (`data-variant` is set).
3776
3776
  */
3777
3777
  function ButtonLink(all) {
3778
- const { to, href, download, newTab, variant, size, icon: Icon, className, children, ...rest } = all;
3778
+ const { to, href, download, newTab, state, variant, size, icon: Icon, className, children, ...rest } = all;
3779
3779
  const { provide, props } = useTarget({
3780
3780
  to,
3781
3781
  href,
3782
3782
  download
3783
- }, newTab);
3783
+ }, newTab, state);
3784
3784
  return provide(/* @__PURE__ */ jsxs(Link, {
3785
3785
  ...rest,
3786
3786
  ...props,
@@ -3799,12 +3799,12 @@ function ButtonLink(all) {
3799
3799
  * The house in-app link: accent ink, underlined, for a sentence, a table cell or an empty state's next step. `to` for a route, `href` for a file or another site.
3800
3800
  */
3801
3801
  function TextLink(all) {
3802
- const { to, href, download, newTab, icon: Icon, className, children, ...rest } = all;
3802
+ const { to, href, download, newTab, state, icon: Icon, className, children, ...rest } = all;
3803
3803
  const { provide, props } = useTarget({
3804
3804
  to,
3805
3805
  href,
3806
3806
  download
3807
- }, newTab);
3807
+ }, newTab, state);
3808
3808
  return provide(/* @__PURE__ */ jsxs(Link, {
3809
3809
  ...rest,
3810
3810
  ...props,
@@ -4910,6 +4910,7 @@ function PictureHeading({ heading, shown }) {
4910
4910
  "data-shown": shown || void 0,
4911
4911
  className: cn("picture-shade pointer-events-none absolute inset-x-0 top-0 flex items-center gap-3 px-4 pt-3 pb-10 transition-state", shown ? "opacity-100" : "opacity-0 has-[:focus-visible]:opacity-100 has-[:focus-visible]:[&_a]:pointer-events-auto"),
4912
4912
  children: [avatar && (heading.subtitleTo && heading.subtitle ? /* @__PURE__ */ jsx(HeadingLink, {
4913
+ state: heading.state,
4913
4914
  to: heading.subtitleTo,
4914
4915
  className: cn("shrink-0 rounded-pill", shown && "pointer-events-auto"),
4915
4916
  label: heading.subtitle,
@@ -4917,6 +4918,7 @@ function PictureHeading({ heading, shown }) {
4917
4918
  }) : avatar), /* @__PURE__ */ jsxs("div", {
4918
4919
  className: "grid min-w-0",
4919
4920
  children: [heading.to ? /* @__PURE__ */ jsx(HeadingLink, {
4921
+ state: heading.state,
4920
4922
  to: heading.to,
4921
4923
  className: cn("type-heading", link),
4922
4924
  children: heading.title
@@ -4924,6 +4926,7 @@ function PictureHeading({ heading, shown }) {
4924
4926
  className: "type-heading truncate",
4925
4927
  children: heading.title
4926
4928
  }), heading.subtitle && (heading.subtitleTo ? /* @__PURE__ */ jsx(HeadingLink, {
4929
+ state: heading.state,
4927
4930
  to: heading.subtitleTo,
4928
4931
  className: cn("type-body-sm", link),
4929
4932
  children: heading.subtitle
@@ -4934,8 +4937,8 @@ function PictureHeading({ heading, shown }) {
4934
4937
  })]
4935
4938
  });
4936
4939
  }
4937
- function HeadingLink({ to, className, label, children }) {
4938
- const { provide, props } = useTarget({ to }, false);
4940
+ function HeadingLink({ to, state, className, label, children }) {
4941
+ const { provide, props } = useTarget({ to }, false, state);
4939
4942
  return provide(/* @__PURE__ */ jsx(Link, {
4940
4943
  ...props,
4941
4944
  "aria-label": label,