strata-react 1.3.7 → 1.3.9

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
@@ -151,21 +151,22 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
151
151
  |---|---|---|
152
152
  | Actions | `Button`, `IconButton`, `RowAction`, `AsyncButton`, `useAsyncAction` | Default is `outline`; one filled button per view; `IconButton` requires `label`; `RowAction` is named for its row ("Withdraw Tom Ellery"); `AsyncButton` keeps one width through idle, pending, done and error, and announces `error` with its retry label; buttons carry `data-variant` and `AsyncButton` `data-phase` for tests; a `title` is refused (type `never`, and a development warning): a tip is a `Tooltip`, or `IconButton`'s `label` and `hint`; `useAsyncAction` returns `{ phase, run, error, thrown, fieldErrors, clearFieldError }` with a stable `run`, describes an `HttpError` in a sentence with the server's own reason for a 4xx (`describeActionError`, or the product's own `describeError`), and `validate` plus a server's 422 put messages on `fieldErrors` for each `Field` |
153
153
  | Form | `Field`, `Input`, `Textarea`, `NativeSelect`, `ChoiceGroup`, `Checkbox` | `Field` wires label, hint, error, `aria-describedby`, `aria-invalid`, and `action` puts a one-field form's button on the control's row with the hint and error under both; `Checkbox` requires `label` and is one target with it, and has a mixed state |
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 |
154
+ | Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar`, `WorkflowSteps`, `JobsTable` | 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; `WorkflowSteps` draws strata-python's shared `WorkflowRun` (`/api/workflows/<pipeline>/subjects/<id>`): each stage's state as a word, when it ran and how long it took, a failed stage's error with Try again, and Approve on a waiting gate (the first is the view's filled button), saying who approved or that its policy did; `JobsTable` is the shared jobs page (`GET /api/jobs`): each job's state as a word with its progress or error, and Cancel or Run again only where they apply. Both take the app's generated `Schema<"WorkflowRun">` and `Schema<"Task">` as they come |
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
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
- | Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `useInfiniteLoad`, `useJob`, `toLoad`, `staleOf`, `fetchJson`, `createApi`, `appBase`, `withBase`, `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(url, { json })` sends a JSON body (content type and `POST` set for you); `createTypedApi<paths>()` is the same typed by `strata-api-types`' `paths` (path, `{params}`, `query`, `json` and the answer are checked); `createApi({ base })` is `get`/`post`/`put`/`patch`/`delete` over it with the app's base put before root-relative paths (`appBase()` reads the page's `<base href>`, so the app works behind a reverse proxy; use `withBase` for an `<img src>` or a download link); `fetchJson` reads an error response's body onto the `HttpError` (`body`, `reason`, `fieldErrors`, read by `readErrorBody` or the API's own `readError`); the strata apps' shared server shapes (`strata_python.contracts`): `apiPage<T>()` gives `useInfiniteLoad` the `Page<T>` items and its own `next` cursor (nothing held or dismissed changes it), `isTaskRunning(task, FINISHED)` is `useJob`'s `isRunning` for a `Task`, and an error body's `payload` (what is already running, on a 409) is on `HttpError.payload`, read typed with `errorPayload<T>(error)` |
159
+ | Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `useInfiniteLoad`, `useJob`, `useWorkflowRun`, `isWorkflowRunning`, `toLoad`, `staleOf`, `fetchJson`, `createApi`, `appBase`, `withBase`, `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(url, { json })` sends a JSON body (content type and `POST` set for you); `createTypedApi<paths>()` is the same typed by `strata-api-types`' `paths` (path, `{params}`, `query`, `json` and the answer are checked); `createApi({ base })` is `get`/`post`/`put`/`patch`/`delete` over it with the app's base put before root-relative paths (`appBase()` reads the page's `<base href>`, so the app works behind a reverse proxy; use `withBase` for an `<img src>` or a download link); `fetchJson` reads an error response's body onto the `HttpError` (`body`, `reason`, `fieldErrors`, read by `readErrorBody` or the API's own `readError`); the strata apps' shared server shapes (`strata_python.contracts`): `apiPage<T>()` gives `useInfiniteLoad` the `Page<T>` items and its own `next` cursor (nothing held or dismissed changes it), `isTaskRunning(task, FINISHED)` is `useJob`'s `isRunning` for a `Task`, and an error body's `payload` (what is already running, on a 409) is on `HttpError.payload`, read typed with `errorPayload<T>(error)`; `useWorkflowRun({ finished })` is `useJob` for a `WorkflowRun`, polling while the run's job (`WorkflowRun.job`) is in a state not in `finished` |
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) |
161
161
  | Keyboard | `useHotkeys`, `KeysLegend`, `Shortcut`, `useActiveItem`, `ActiveList`, `isTypingTarget` | For queues worked from the keyboard; one shortcut list drives the handler and the legend; keys never fire while typing; answering moves focus to the next item |
162
162
  | Theme | `ThemeProvider`, `useColorScheme`, `useSystemColorScheme`, `ColorSchemeChoice`, `colorSchemeScript` | System, light or dark; sets `.dark`, persists in localStorage when it can; `ColorSchemeChoice` is a radio list for a settings page, or `compact` icon segments named "Appearance" for an app with no settings page |
163
163
  | Density | `Density`, `DensityName`, `ThemeProvider`'s `density`, `ControlSize` (`size="sm"` on `Input`, `NativeSelect`, `NumberField`, `IconButton`) | Control height is two variables, `--control-h` and `--control-h-sm`. `<ThemeProvider density="compact">` or `<Density page value="compact">` sets them app-wide, including dialogs and menus, which portal out of the app's root; `<Density value="compact">` is one region (a toolbar, a dense panel) and does not reach its overlays. A coarse pointer (touch) always gets 44px targets, whatever the density A second look for a region is roles alone: set `--control-h`, `--control-h-sm`, `--control-px`, `--control-px-sm`, `--control-icon` and each type step's `--type-<step>-size`, `-leading` and `-weight` (`caption`, `label`, `body-sm`, `body`, `heading`, `title`, `figure`) on a class; the defaults are today's values. |
164
164
  | Workspace | `Workspace`, `Split`, `Pane`, `useWorkspaceState`, `WorkspaceState` | One screen of panes for a tool: splits of panes with a growing stage, a header on every pane (name, actions, fold button), separators that resize by pointer and by keyboard (arrows, Shift, Home, End, Enter to restore) within each pane's `min` and `max`, panes that fold to a rail or header bar with a visible way back (and `state.toggle(id)` from a menu), sizes and folds remembered with `useWorkspaceState("name")`, and stacking below 720px. Each pane is a labelled region |
165
165
  | Writes kept while offline | `createOutbox`, `useOutbox`, `useOutboxStarted`, `OutboxStatus`, `isRefusal` | Writes that must not be lost when the connection is (answers in a game played on a tablet whose wifi drops): kept in localStorage (`strata:outbox:<name>`), sent one at a time oldest first, a dependent write (`after`) refused with what it follows; a 4xx is refused and listed with the server's reason until dismissed, anything else (no answer, 5xx, 401/403 from a login, 408, 429) waits and is tried again after 2 s doubling to a minute, at once on `online` or when the page is shown. `add` answers how the first try went (`sent`, `waiting`, `refused`) so a screen goes on without the server. Every write must be idempotent on the server (a client-made id). `OutboxStatus noun="answer"` is the sign: nothing while all is sent, "3 answers kept on this device. The server could not be reached. Trying again at 10:42." with Send now, and the refused list |
166
+ | Items kept for offline | `createReserve`, `useReserve` | The read side of the outbox: items the server made ahead (rounds of play), kept per key in localStorage (`strata:reserve:<name>:<key>`), `size` each. `take(key)` removes and returns the oldest (an item is used once); `refresh(key, fresh)` after a fresh item arrives drops kept items `sameMake(kept, fresh)` calls out of date and tops up in one request when fewer than half remain (one in flight per key; a failure is tried again at the next refresh); `useReserve(reserve, key)` is the count for "6 rounds kept for offline"; `seed` and `clear` for tests and stories. Without storage nothing is kept and `persisted` says so |
166
167
  | History and save state | `useHistory`, `useHistoryState`, `History`, `useAutoSave`, `SaveStatus`, `SaveState`, `useLeaveGuard` | Undo and redo for a document edited over a session: a step is a name and an `undo`/`redo` pair, `begin(label)` groups a drag into one step, a `key` merges a slider's pushes, a `limit` drops the oldest. `history.commands` are Undo and Redo as `Command`s ("Undo move clip", Mod+Z, Mod+Shift+Z or Mod+Y) for `useCommands` and `Menu`. `useAutoSave` debounces and never overlaps saves; `SaveStatus` is the fixed-width sign ("Saved 10:42", "Saving…", "Unsaved changes", "Not saved" with the reason and "Try again"), quiet except for a failure and its recovery. For one removal that commits after a few seconds, use `useUndoable` |
167
168
  | Links and URL choices | `ButtonLink`, `TextLink`, `useSearchParam`, `NativeSelect param=`, `ChoiceGroup param=`, `ToggleGroup param=` | `ButtonLink` is a link (`to` for a route, `href` for a download) drawn as a `Button` with its variants; it sets `data-variant`, so `variant="default"` is the view's one filled button for `expectOneFilledButton()`. `TextLink` is the house in-app link. Both are React Aria links with React Router navigation. A filter or choice a person would link to is `useSearchParam("mode", { default, parse })` (the default is never written, an invalid value reads as the default, other params are kept, history is replaced), or `param=` on the three controls, as `Tabs` does |
168
- | Speech | `speak`, `useSpeech`, `SayAgain`, `canSay`, `textOf`, `installFakeSpeech` (`strata-react/testing`) | The browser's `speechSynthesis` with the voice picked by language once voices have loaded, what is being said cancelled by the next prompt, a slightly slow default rate, and nothing where there is no speech or the person muted it. Recorded prompts (`speak(parts)`, `SayAgain parts=`): each part's clip plays in order, and the browser's voice says the words when a part has no clip or one fails (one voice per prompt). `SayAgain`'s name is the sentence it says. `installFakeSpeech()` records what was said and which clips played in a test (`clips()`, `finish()`, `failClip()`) |
169
+ | Speech | `speak`, `useSpeech`, `SayAgain`, `ClipsProvider`, `useClips`, `useSayOnShow`, `canSay`, `textOf`, `installFakeSpeech` (`strata-react/testing`) | The browser's `speechSynthesis` with the voice picked by language once voices have loaded, what is being said cancelled by the next prompt, a slightly slow default rate, and nothing where there is no speech or the person muted it. Recorded prompts (`speak(parts)`, `SayAgain parts=`): each part's clip plays in order, and the browser's voice says the words when a part has no clip or one fails (one voice per prompt). `SayAgain`'s name is the sentence it says. `installFakeSpeech()` records what was said and which clips played in a test (`clips()`, `finish()`, `failClip()`) . `ClipsProvider load=` reads the app's clip list once (a record of line text to URL, read again only when `clipsQueryKey` is invalidated); `useClips()` gives `ready`, `parts(text)`, `say(text)` and `words(text)` (`split` cuts a prompt into lines, `describe` words a line that has no clip), `useSayOnShow(text)` says a prompt once the list has arrived or failed, and `SayAgain` inside the provider needs no `parts` or `lang`; outside it, the browser's voice alone |
169
170
  | Recording | `useRecorder`, `InputLevel`, `TakeLevel`, `MicrophoneContext`, `encodeWav`, `fakeMicrophone` (`strata-react/testing`) | One take of speech from the microphone as a lossless 16-bit PCM WAV (an AudioWorklet, not MediaRecorder, which only writes compressed audio), with the browser's echo cancellation, noise suppression and gain off. `start()` resolves with the take when it stops, by `stop()` or at `maxSeconds`. `InputLevel` is the live peak in dBFS with a "Too loud" notch at -3; `TakeLevel` judges the finished take for speech in words. The device comes from `MicrophoneContext`, so tests pass `renderWithStrata(ui, { microphone: fakeMicrophone() })`. The microphone needs a secure page (https or localhost); the refusals read as sentences |
170
171
  | Toolbar and toggles | `Toolbar`, `ToolbarSeparator`, `Toggle`, `ToggleGroup`, `Switch` | A toolbar is one tab stop with arrows, Home and End inside; needs a `label`. `Toggle` (`aria-pressed`) and `ToggleGroup` (one of 2 to 7, always one chosen) show chosen as an ink border on a tint, never the filled primary, so they do not break the one-filled-button rule; an icon-only toggle still needs its `label` (shown as a tooltip). `Switch` is only for a setting that applies at once, label and control one target |
171
172
  | Commands | `Command`, `useCommands`, `Menu`, `ContextMenu`, `CommandMenu`, `CommandLegend`, `formatChord`, `matchesChord` | A command is declared once (label or label function, chords, `disabled` with a reason, `destructive`, `checked`) and drives the key handler, dropdown and menu-bar menus, the context menu, the searchable command menu (Mod+K) and the legend, so they cannot disagree. Chords are written once ("Mod+Shift+Z") and shown per platform (⇧⌘Z, Ctrl+Shift+Z); they never fire while typing or during IME composition, and a chord the browser keeps (Ctrl+S) needs `claim: true`. `useHotkeys` is unchanged for single keys |
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
+ ## 2026-11-24
15
+ - `createApi`'s `post`/`put`/`patch` send a `Blob`, bytes, `FormData`, `URLSearchParams` or a stream as it is (a Blob with its own type as Content-Type); before, any body was `JSON.stringify`ed, so such a body arrived as `{}`. `createTypedApi` takes `body` (not `json`) on an operation whose request body has only a non-JSON media type, so a workaround that went round the typed client through `fetchJson` can be deleted.
16
+ - `SayAgain` inside a `ClipsProvider` takes the recordings of `text` and the provider's `lang` itself; one given `parts` or `lang` is unchanged, and outside a provider nothing changes.
17
+
14
18
  ## 2026-11-23
15
19
  - Speech (#310): `installFakeSpeech()` now also replaces `window.Audio` until `uninstall()`, and each `Spoken` entry has `clip` (null for the browser's voice), so a test that compares a whole entry with `toEqual` adds `clip: null`. `useSpeech().say` takes a sentence or recorded parts; `stopSpeaking()` and unmounting `useSpeech` stop a playing clip too.
16
20
  - `ChoiceGrid`'s `marks` type is `ChoiceMarks` (a quiz's three words, or `{ picked }` alone); `createTypedApi`'s POST/PUT/PATCH on an operation with `requestBody?: never` no longer ask for `json`, so a `json: undefined` workaround can be deleted. The request argument is now required when the operation has a required path or query value (a call that left it out compiled and threw at run time); pass `{ path: … }`.
@@ -0,0 +1,35 @@
1
+ /** The fields of a job `JobsTable` draws: the shape of `Schema<"Task">`, which satisfies it. */
2
+ export type JobRow = {
3
+ id: number | string;
4
+ kind: string;
5
+ state: string;
6
+ created_at: string;
7
+ started_at?: string | null;
8
+ finished_at?: string | null;
9
+ error?: string | null;
10
+ attempts?: number;
11
+ domain?: string | null;
12
+ progress?: {
13
+ text?: string;
14
+ done?: number;
15
+ total?: number | null;
16
+ } | null;
17
+ };
18
+ /** The jobs table's props. */
19
+ export type JobsTableProps<T extends JobRow> = {
20
+ /** Names the table: "Jobs". */
21
+ caption: string;
22
+ /** The jobs, newest first: the items of `GET /api/jobs` pages. */
23
+ jobs: T[];
24
+ /** What a job is, in the person's words. Default its kind. */
25
+ describe?: (job: T) => string;
26
+ /** Cancels a queued or running job (`POST /api/jobs/<id>/cancel`). Without it, no Cancel. */
27
+ onCancel?: (job: T) => Promise<unknown>;
28
+ /** Runs a failed or cancelled job again (`POST /api/jobs/<id>/retry`). Without it, no Run again. */
29
+ onRetry?: (job: T) => Promise<unknown>;
30
+ /** "Now", for `format.ago` (tests and screenshots). */
31
+ now?: Date;
32
+ className?: string;
33
+ };
34
+ /** A table of the queue's jobs (`GET /api/jobs`): what each is, its state as a word with its progress or error, when it started, and Cancel or Run again where they apply. */
35
+ export declare function JobsTable<T extends JobRow>({ caption, jobs, describe, onCancel, onRetry, now, className }: JobsTableProps<T>): import('react').JSX.Element;
@@ -0,0 +1,36 @@
1
+ /** A stage's state on the server: `strata_python.contracts.StageState`. */
2
+ export type StageState = "done" | "ready" | "stale" | "failed" | "waiting" | "blocked";
3
+ /** The fields of a stage `WorkflowSteps` draws: the shape of `Schema<"StageRun">`, which satisfies it. */
4
+ export type WorkflowStage = {
5
+ name: string;
6
+ title: string;
7
+ gate: boolean;
8
+ state: string;
9
+ last?: {
10
+ status: string;
11
+ at: string;
12
+ elapsed_s?: number;
13
+ error?: string | null;
14
+ by?: string | null;
15
+ } | null;
16
+ };
17
+ /** Each state's word, in the product's terms. Any left out keeps its default. */
18
+ export type StageWords = Partial<Record<StageState | "approved", string>>;
19
+ /** The workflow steps' props. */
20
+ export type WorkflowStepsProps<S extends WorkflowStage> = {
21
+ /** What the subject's pipeline is ("Ingest of Wolf Hall"): names the list. */
22
+ label: string;
23
+ /** The stages in order: `WorkflowRun.stages`. */
24
+ stages: S[];
25
+ /** Approves a gate (the POST to `.../stages/<name>/approve`). Without it, a waiting gate has no button. */
26
+ onApprove?: (stage: S) => Promise<unknown>;
27
+ /** Runs the subject again (the POST to `.../run`). Without it, a failed stage has no button. */
28
+ onRetry?: (stage: S) => Promise<unknown>;
29
+ /** Renames the states. */
30
+ words?: StageWords;
31
+ /** "Now", for `format.ago` (tests and screenshots). */
32
+ now?: Date;
33
+ className?: string;
34
+ };
35
+ /** A subject's stages through a strata-python pipeline, each with its state as a word, when it last ran, its error, and Approve on a waiting gate or Try again on a failed stage. */
36
+ export declare function WorkflowSteps<S extends WorkflowStage>({ label, stages, onApprove, onRetry, words, now, className }: WorkflowStepsProps<S>): import('react').JSX.Element;
package/dist/index.d.ts CHANGED
@@ -36,6 +36,8 @@ export { toast, toastTimeout, StrataToastRegion, type ToastContentProps, type St
36
36
  export { useClientWork, type ClientWork, type WorkContext, type WorkPhase } from './lib/client-work';
37
37
  export { JobStatus, jobProgressText, type JobStatusProps, type JobFailure, type JobProgress, type JobWords } from './components/job-status';
38
38
  export { useJobAction, type JobAction, type JobActionOptions } from './components/job-action';
39
+ export { WorkflowSteps, type WorkflowStepsProps, type WorkflowStage, type StageState, type StageWords } from './components/workflow-steps';
40
+ export { JobsTable, type JobsTableProps, type JobRow } from './components/jobs-table';
39
41
  export { Thumbnail, ThumbnailSkeleton, type ThumbnailProps, type AspectRatio } from './components/thumbnail';
40
42
  export { DataTable, TableSkeleton, parseSort, serialiseSort, type CellValue, type Column, type Sort, type DataTableProps, type RowSelection, type RowExpansion, } from './components/data-table';
41
43
  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';
@@ -75,9 +77,11 @@ export type { ControlSize } from './lib/control';
75
77
  export { useHotkeys, KeysLegend, isTypingTarget, type Shortcut } from './components/hotkeys';
76
78
  export { useActiveItem, ActiveList, type ActiveItem } from './components/active-list';
77
79
  export { ThemeProvider, useColorScheme, useSystemColorScheme, ColorSchemeChoice, colorSchemeScript, COLOR_SCHEME_STORAGE_KEY, type ColorScheme, type ColorSchemePreference, type ColorSchemeLabels, type ColorSchemeState, } from './components/theme';
78
- export { StrataQueryProvider, createQueryClient, toLoad, staleOf, useLoad, useInfiniteLoad, useJob, isTaskRunning, apiPage, fetchJson, HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody, type FetchJsonOptions, type FetchJsonInit, createApi, createTypedApi, type TypedApi, type Api, type ApiOptions, type ApiPage, type InfiniteLoad, type InfiniteLoadOptions, type Job, type JobOptions, type More, } from './query';
80
+ export { StrataQueryProvider, createQueryClient, toLoad, staleOf, useLoad, useInfiniteLoad, useJob, isTaskRunning, useWorkflowRun, isWorkflowRunning, type WorkflowRunLike, type WorkflowRunOptions, apiPage, fetchJson, HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody, type FetchJsonOptions, type FetchJsonInit, createApi, createTypedApi, type TypedApi, type Api, type ApiOptions, type ApiPage, type InfiniteLoad, type InfiniteLoadOptions, type Job, type JobOptions, type More, } from './query';
79
81
  export { createOutbox, useOutbox, useOutboxStarted, isRefusal, type Outbox, type OutboxOptions, type OutboxRequest, type OutboxItem, type OutboxRefusal, type OutboxSnapshot, type Delivery, } from './query/outbox';
80
82
  export { OutboxStatus, type OutboxStatusProps } from './components/outbox-status';
83
+ export { createReserve, useReserve, type Reserve, type ReserveOptions } from './query/reserve';
84
+ export { ClipsProvider, useClips, useSayOnShow, clipsQueryKey, type Clips, type ClipsContext, type ClipsProviderProps, type SayOnShowOptions } from './query/clips';
81
85
  export { describeActionError, fieldErrorsOf } from './lib/errors';
82
86
  export { appBase, withBase } from './lib/base';
83
87
  export { useSearchParam, type SearchParam, type SearchParamOptions } from './lib/search-param';