strata-react 1.3.11 → 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, 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 |
@@ -1,7 +1,7 @@
1
1
  import { IconComponent } from '../lib/icon';
2
2
  import { ButtonProps } from './button';
3
3
  import * as React from "react";
4
- type Target = {
4
+ export type Target = {
5
5
  /** An app route (React Router): `"/learners/7"`, `"?tab=log"`. Client-side navigation, the basename applied. */
6
6
  to: string;
7
7
  href?: undefined;
@@ -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,6 +34,15 @@ export type ButtonLinkProps = BaseProps & Target & {
32
34
  export type TextLinkProps = BaseProps & Target & {
33
35
  icon?: IconComponent;
34
36
  };
37
+ export declare function useTarget(target: Target, newTab: boolean | undefined, state?: unknown): {
38
+ provide: (node: React.ReactNode) => React.JSX.Element;
39
+ props: {
40
+ href: string;
41
+ download: string | boolean | undefined;
42
+ target: string | undefined;
43
+ rel: string | undefined;
44
+ };
45
+ };
35
46
  /**
36
47
  * 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).
37
48
  */
@@ -136,6 +136,24 @@ export type MediaSession = {
136
136
  album?: string;
137
137
  artwork?: string;
138
138
  };
139
+ /**
140
+ * What is playing, drawn across the top of a video while it is paused or the pointer is on it: a
141
+ * title, who made it, and their picture. Plain data; the player draws it.
142
+ */
143
+ export type MediaHeading = {
144
+ /** What is playing ("Glazing a celadon bowl"). */
145
+ title: string;
146
+ /** An app route the title leads to. */
147
+ to?: string;
148
+ /** Under the title: who made it, or where it is from ("Kiln room"). */
149
+ subtitle?: string;
150
+ /** An app route the subtitle leads to, and the picture with it when there is a subtitle to name that link. */
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;
154
+ /** A small round picture before the words (the maker's avatar). `null` draws the subtitle's first letter instead. */
155
+ avatar?: string | null;
156
+ };
139
157
  export type MediaPlayerProps = {
140
158
  /** Names the player and its element. */
141
159
  label: string;
@@ -200,6 +218,8 @@ export type MediaPlayerProps = {
200
218
  progressEvery?: number;
201
219
  /** The player's state and requests (`seek`, `setVolume`, `time`, `duration`…), for an app that acts on playback from beside it: a chapter list, comments at a time (strata-react issue #211). An object ref holds the latest state without rendering again; a function ref is called with it on every render. */
202
220
  mediaRef?: React.Ref<MediaElementState>;
221
+ /** What is playing, across the top of a video: shown while it is paused, and for a few seconds after the pointer moves on it, a key is pressed or playing starts; hidden with the controls (strata-react issue #329). Video only. */
222
+ heading?: MediaHeading;
203
223
  /** Drawn over the picture only (never the controls) in a box that fills it; the app's classes choose the corner (`absolute bottom-3 right-3`). Anything interactive in it is clickable and focusable. A video's box keeps its shape before the metadata loads, so the overlay has a stable place. */
204
224
  overlay?: (media: MediaElementState) => React.ReactNode;
205
225
  /** Content below the controls for playback-related messages and actions. Hides with the controls during idle fullscreen playback. */
@@ -219,4 +239,4 @@ export declare const SPEECH_RATES: readonly number[];
219
239
  * a touch device), with the failure to load shown and retried. For an editor or a replay, use the
220
240
  * parts and `useMediaElement` directly.
221
241
  */
222
- 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, spans, spanKinds, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, overlay, status, warning, aspect, fullscreen, className, }: MediaPlayerProps): React.JSX.Element;
242
+ 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, spans, spanKinds, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen, className, }: MediaPlayerProps): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -41,7 +41,7 @@ export { JobsTable, type JobsTableProps, type JobRow } from './components/jobs-t
41
41
  export { Thumbnail, ThumbnailSkeleton, type ThumbnailProps, type AspectRatio } from './components/thumbnail';
42
42
  export { FilmStrip, pickEvenly, frameAt, type FilmStripProps, type FilmFrame } from './components/film-strip';
43
43
  export { DataTable, TableSkeleton, parseSort, serialiseSort, type CellValue, type Column, type Sort, type DataTableProps, type RowSelection, type RowExpansion, } from './components/data-table';
44
- 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, type MediaProgress, type ResumeWords } from './components/media-player';
44
+ 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, type MediaHeading, type MediaProgress, type ResumeWords } from './components/media-player';
45
45
  export { useMediaSpans, SpanActions, PlayerNotice, type SpanActionsNotice, type MediaSpanData, type SpanKind, type SpanBehaviour, type SpanOutcome, type SpanWords, type MediaSpansState } from './components/media-spans';
46
46
  export { TranscriptView, type TranscriptViewProps, type TranscriptSeek } from './components/transcript-view';
47
47
  export { phraseAt, wordAt, wordId, phraseOfWordId, isDoubtful, phraseDoubtful, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptWord } from './lib/transcript';
package/dist/index.js CHANGED
@@ -3754,6 +3754,64 @@ function createWatchedRanges() {
3754
3754
  clear: () => void (ranges = [])
3755
3755
  };
3756
3756
  }
3757
+ // src/components/link.tsx
3758
+ function useTarget(target, newTab, state) {
3759
+ const navigate = useNavigate();
3760
+ return {
3761
+ provide: (node) => /* @__PURE__ */ jsx(RouterProvider, {
3762
+ navigate: (to) => void navigate(to, state === void 0 ? void 0 : { state }),
3763
+ useHref,
3764
+ children: node
3765
+ }),
3766
+ props: {
3767
+ href: target.to ?? target.href,
3768
+ download: target.href === void 0 ? void 0 : target.download,
3769
+ target: newTab ? "_blank" : void 0,
3770
+ rel: newTab || target.href !== void 0 ? "noreferrer" : void 0
3771
+ }
3772
+ };
3773
+ }
3774
+ /**
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
+ */
3777
+ function ButtonLink(all) {
3778
+ const { to, href, download, newTab, state, variant, size, icon: Icon, className, children, ...rest } = all;
3779
+ const { provide, props } = useTarget({
3780
+ to,
3781
+ href,
3782
+ download
3783
+ }, newTab, state);
3784
+ return provide(/* @__PURE__ */ jsxs(Link, {
3785
+ ...rest,
3786
+ ...props,
3787
+ "data-variant": variant ?? "outline",
3788
+ className: cn(buttonVariants({
3789
+ variant,
3790
+ size
3791
+ }), "no-underline", className),
3792
+ children: [Icon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }), typeof children === "string" ? /* @__PURE__ */ jsx("span", {
3793
+ className: "min-w-0 truncate",
3794
+ children
3795
+ }) : children]
3796
+ }));
3797
+ }
3798
+ /**
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
+ */
3801
+ function TextLink(all) {
3802
+ const { to, href, download, newTab, state, icon: Icon, className, children, ...rest } = all;
3803
+ const { provide, props } = useTarget({
3804
+ to,
3805
+ href,
3806
+ download
3807
+ }, newTab, state);
3808
+ return provide(/* @__PURE__ */ jsxs(Link, {
3809
+ ...rest,
3810
+ ...props,
3811
+ className: cn("inline-flex items-center gap-1 rounded-control text-primary-11 underline underline-offset-4 transition-state hover:text-primary-12 [&_svg]:size-4 [&_svg]:shrink-0", className),
3812
+ children: [Icon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }), children]
3813
+ }));
3814
+ }
3757
3815
  // src/components/media-player.tsx
3758
3816
  /** How far one notch of the wheel over a focused video moves the volume, in percent. */
3759
3817
  var WHEEL_VOLUME_STEP = 5;
@@ -4262,7 +4320,7 @@ function useCoarsePointer() {
4262
4320
  * a touch device), with the failure to load shown and retried. For an editor or a replay, use the
4263
4321
  * parts and `useMediaElement` directly.
4264
4322
  */
4265
- function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, overlay, status, warning, aspect, fullscreen = true, className }) {
4323
+ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen = true, className }) {
4266
4324
  const list = React.useMemo(() => sources ?? (src ? [{
4267
4325
  src,
4268
4326
  title: label
@@ -4472,19 +4530,24 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
4472
4530
  const [fullApi, setFullApi] = React.useState(false);
4473
4531
  React.useEffect(() => setFullApi(canFullscreen()), []);
4474
4532
  const canFull = fullscreen && fullApi && kind === "video" && !native;
4475
- const autoHideControls = full && canFull && media.playing;
4533
+ const autoHide = media.playing && kind === "video";
4476
4534
  const [controlsIdle, setControlsIdle] = React.useState(false);
4477
4535
  const idleTimer = React.useRef(void 0);
4478
4536
  const wakeControls = React.useCallback(() => {
4479
4537
  clearTimeout(idleTimer.current);
4480
4538
  setControlsIdle(false);
4481
- if (autoHideControls) idleTimer.current = setTimeout(() => setControlsIdle(true), 3e3);
4482
- }, [autoHideControls]);
4539
+ if (autoHide) idleTimer.current = setTimeout(() => setControlsIdle(true), 3e3);
4540
+ }, [autoHide]);
4541
+ const sleepControls = React.useCallback(() => {
4542
+ clearTimeout(idleTimer.current);
4543
+ setControlsIdle(true);
4544
+ }, []);
4483
4545
  React.useEffect(() => {
4484
4546
  wakeControls();
4485
4547
  return () => clearTimeout(idleTimer.current);
4486
4548
  }, [wakeControls]);
4487
- const hideControls = autoHideControls && controlsIdle;
4549
+ const idle = autoHide && controlsIdle;
4550
+ const hideControls = full && canFull && autoHide && controlsIdle;
4488
4551
  const stage = React.useRef(null);
4489
4552
  const latest = React.useRef(media);
4490
4553
  latest.current = media;
@@ -4561,7 +4624,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
4561
4624
  shortcuts,
4562
4625
  native
4563
4626
  ]);
4564
- const activeKeys = autoHideControls ? keys.map((shortcut) => ({
4627
+ const activeKeys = autoHide ? keys.map((shortcut) => ({
4565
4628
  ...shortcut,
4566
4629
  run: () => {
4567
4630
  wakeControls();
@@ -4632,21 +4695,28 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
4632
4695
  tabIndex: -1,
4633
4696
  className: cn("relative w-full overflow-hidden rounded-surface bg-surface-sunken outline-none", full && "min-h-0 flex-1"),
4634
4697
  style: full ? void 0 : { aspectRatio: aspect ?? natural ?? 16 / 9 },
4635
- children: [/* @__PURE__ */ jsx("video", {
4636
- ...common,
4637
- poster,
4638
- playsInline: true,
4639
- onClick: native ? void 0 : () => media.toggle(),
4640
- onDoubleClick: canFull ? () => setFull((f) => !f) : void 0,
4641
- className: "absolute inset-0 size-full object-contain"
4642
- }), (overlay || showActions) && /* @__PURE__ */ jsxs("div", {
4643
- className: "pointer-events-none absolute inset-0 [&>*]:pointer-events-auto",
4644
- children: [overlay?.(media), showActions && /* @__PURE__ */ jsx(SpanActions, {
4645
- state: spanState,
4646
- other: resumeNotice,
4647
- className: cn("absolute right-3 flex flex-col items-end gap-2", native ? "bottom-14" : "bottom-3")
4648
- })]
4649
- })]
4698
+ children: [
4699
+ /* @__PURE__ */ jsx("video", {
4700
+ ...common,
4701
+ poster,
4702
+ playsInline: true,
4703
+ onClick: native ? void 0 : () => media.toggle(),
4704
+ onDoubleClick: canFull ? () => setFull((f) => !f) : void 0,
4705
+ className: "absolute inset-0 size-full object-contain"
4706
+ }),
4707
+ heading && /* @__PURE__ */ jsx(PictureHeading, {
4708
+ heading,
4709
+ shown: !idle
4710
+ }),
4711
+ (overlay || showActions) && /* @__PURE__ */ jsxs("div", {
4712
+ className: "pointer-events-none absolute inset-0 [&>*]:pointer-events-auto",
4713
+ children: [overlay?.(media), showActions && /* @__PURE__ */ jsx(SpanActions, {
4714
+ state: spanState,
4715
+ other: resumeNotice,
4716
+ className: cn("absolute right-3 flex flex-col items-end gap-2", native ? "bottom-14" : "bottom-3")
4717
+ })]
4718
+ })
4719
+ ]
4650
4720
  }) : /* @__PURE__ */ jsx("audio", {
4651
4721
  ...common,
4652
4722
  className: native ? "w-full" : "hidden"
@@ -4666,9 +4736,13 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
4666
4736
  role: "group",
4667
4737
  "aria-label": label,
4668
4738
  onFocusCapture: () => keyPlayers.use(id),
4669
- onMouseMoveCapture: autoHideControls ? wakeControls : void 0,
4670
- onKeyDownCapture: autoHideControls ? wakeControls : void 0,
4671
- onPointerDownCapture: () => keyPlayers.use(id),
4739
+ onMouseMoveCapture: autoHide ? wakeControls : void 0,
4740
+ onKeyDownCapture: autoHide ? wakeControls : void 0,
4741
+ onMouseLeave: autoHide && !full ? sleepControls : void 0,
4742
+ onPointerDownCapture: () => {
4743
+ keyPlayers.use(id);
4744
+ if (autoHide) wakeControls();
4745
+ },
4672
4746
  className: cn("relative grid w-full gap-2", full && "flex h-full min-h-0 flex-col"),
4673
4747
  children: [
4674
4748
  element,
@@ -4820,6 +4894,58 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
4820
4894
  })
4821
4895
  });
4822
4896
  }
4897
+ function PictureHeading({ heading, shown }) {
4898
+ const link = cn("min-w-0 truncate rounded-control underline-offset-4 hover:underline", shown && "pointer-events-auto");
4899
+ const avatar = heading.avatar !== void 0 && /* @__PURE__ */ jsx(Thumbnail, {
4900
+ src: heading.avatar,
4901
+ alt: "",
4902
+ eager: true,
4903
+ className: "w-9 shrink-0 rounded-pill",
4904
+ fallback: /* @__PURE__ */ jsx("span", {
4905
+ className: "grid size-full place-items-center bg-surface-sunken type-label text-foreground",
4906
+ children: (heading.subtitle ?? heading.title).slice(0, 1).toUpperCase()
4907
+ })
4908
+ });
4909
+ return /* @__PURE__ */ jsxs("div", {
4910
+ "data-shown": shown || void 0,
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
+ children: [avatar && (heading.subtitleTo && heading.subtitle ? /* @__PURE__ */ jsx(HeadingLink, {
4913
+ state: heading.state,
4914
+ to: heading.subtitleTo,
4915
+ className: cn("shrink-0 rounded-pill", shown && "pointer-events-auto"),
4916
+ label: heading.subtitle,
4917
+ children: avatar
4918
+ }) : avatar), /* @__PURE__ */ jsxs("div", {
4919
+ className: "grid min-w-0",
4920
+ children: [heading.to ? /* @__PURE__ */ jsx(HeadingLink, {
4921
+ state: heading.state,
4922
+ to: heading.to,
4923
+ className: cn("type-heading", link),
4924
+ children: heading.title
4925
+ }) : /* @__PURE__ */ jsx("p", {
4926
+ className: "type-heading truncate",
4927
+ children: heading.title
4928
+ }), heading.subtitle && (heading.subtitleTo ? /* @__PURE__ */ jsx(HeadingLink, {
4929
+ state: heading.state,
4930
+ to: heading.subtitleTo,
4931
+ className: cn("type-body-sm", link),
4932
+ children: heading.subtitle
4933
+ }) : /* @__PURE__ */ jsx("p", {
4934
+ className: "type-body-sm truncate",
4935
+ children: heading.subtitle
4936
+ }))]
4937
+ })]
4938
+ });
4939
+ }
4940
+ function HeadingLink({ to, state, className, label, children }) {
4941
+ const { provide, props } = useTarget({ to }, false, state);
4942
+ return provide(/* @__PURE__ */ jsx(Link, {
4943
+ ...props,
4944
+ "aria-label": label,
4945
+ className,
4946
+ children
4947
+ }));
4948
+ }
4823
4949
  // src/lib/transcript.ts
4824
4950
  /** The id of a word for marking (`TranscriptView`'s `marking`, `Mark`): its phrase and its place in it. */
4825
4951
  var wordId = (phraseId, index) => `${phraseId}:${index}`;
@@ -12471,64 +12597,6 @@ function TakeLevel({ peak, lead, className }) {
12471
12597
  })]
12472
12598
  });
12473
12599
  }
12474
- // src/components/link.tsx
12475
- function useTarget(target, newTab) {
12476
- const navigate = useNavigate();
12477
- return {
12478
- provide: (node) => /* @__PURE__ */ jsx(RouterProvider, {
12479
- navigate: (to) => void navigate(to),
12480
- useHref,
12481
- children: node
12482
- }),
12483
- props: {
12484
- href: target.to ?? target.href,
12485
- download: target.href === void 0 ? void 0 : target.download,
12486
- target: newTab ? "_blank" : void 0,
12487
- rel: newTab || target.href !== void 0 ? "noreferrer" : void 0
12488
- }
12489
- };
12490
- }
12491
- /**
12492
- * 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).
12493
- */
12494
- function ButtonLink(all) {
12495
- const { to, href, download, newTab, variant, size, icon: Icon, className, children, ...rest } = all;
12496
- const { provide, props } = useTarget({
12497
- to,
12498
- href,
12499
- download
12500
- }, newTab);
12501
- return provide(/* @__PURE__ */ jsxs(Link, {
12502
- ...rest,
12503
- ...props,
12504
- "data-variant": variant ?? "outline",
12505
- className: cn(buttonVariants({
12506
- variant,
12507
- size
12508
- }), "no-underline", className),
12509
- children: [Icon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }), typeof children === "string" ? /* @__PURE__ */ jsx("span", {
12510
- className: "min-w-0 truncate",
12511
- children
12512
- }) : children]
12513
- }));
12514
- }
12515
- /**
12516
- * 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.
12517
- */
12518
- function TextLink(all) {
12519
- const { to, href, download, newTab, icon: Icon, className, children, ...rest } = all;
12520
- const { provide, props } = useTarget({
12521
- to,
12522
- href,
12523
- download
12524
- }, newTab);
12525
- return provide(/* @__PURE__ */ jsxs(Link, {
12526
- ...rest,
12527
- ...props,
12528
- className: cn("inline-flex items-center gap-1 rounded-control text-primary-11 underline underline-offset-4 transition-state hover:text-primary-12 [&_svg]:size-4 [&_svg]:shrink-0", className),
12529
- children: [Icon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }), children]
12530
- }));
12531
- }
12532
12600
  // src/lib/image-diff.ts
12533
12601
  /** The longest side, in pixels, a picture is compared at. */
12534
12602
  var MAX_SIDE = 2048;