strata-react 1.0.40 → 1.0.42

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
@@ -121,15 +121,39 @@ function KilnRoom() {
121
121
 
122
122
  strata-react is ESM-only (`exports` has only `import`), as is its peer `react-router`. **Vitest is the supported runner**: it needs no configuration beyond the `strata-react/testing` helpers. An app on Jest has to do the work itself (strata-vid's `jest.base.config.js` is a working example): transform `.mjs` along with `.js`; leave `strata-react`, `react-router`, `@remix-run`, `cookie-es`, `@tanstack` and `pixelmatch` out of `transformIgnorePatterns` so Babel compiles them; and replace `import.meta` for CommonJS with a small Babel plugin (react-router reads it). Strata's own suite runs on Vitest only, so a Jest setup is the app's to keep working.
123
123
 
124
+ ### An app that already has its own Tailwind colours and sizes
125
+
126
+ `strata.css` clears Tailwind's stock colours, type sizes, radii, shadows and fonts, so `bg-stone-100`, `text-sm`, `rounded-xl` and
127
+ `shadow-lg` stop compiling (even `@apply bg-stone-100` fails to build). That is right for a new app and a cliff for an app of
128
+ thousands of lines. Such an app imports the same stylesheet **without the reset** and moves screens over one at a time:
129
+
130
+ ```css
131
+ @import "tailwindcss";
132
+ @import "strata-react/strata.migrate.css"; /* everything in strata.css except the namespace reset */
133
+ @import "./theme.generated.css"; /* still needed: the roles Strata's components use (bg-primary, border-input…) */
134
+ @import "./theme.css";
135
+ ```
136
+
137
+ 1. Supply the roles. Generate the palette with `palette.mjs` as for a new app, or, to keep today's look, write the role variables
138
+ from the app's own colours (`:root { --primary: var(--color-emerald-600); --background: var(--color-stone-50); … }` and the
139
+ `@theme inline { --color-primary: var(--primary); … }` mapping `palette.mjs` writes: the stock `--color-*` variables still exist
140
+ in this mode). Turn on dark mode through `ThemeProvider`; the app's own `dark:` classes keep working beside it.
141
+ 2. Convert a screen at a time to Strata components and roles. `npx strata-stock-classes src` lists the stock classes left
142
+ (colours, `text-sm`…, `rounded-xl`…, `shadow-lg`…, `font-serif`) by file and line, with the role that replaces each;
143
+ `--fail` exits 1 while any remain, to hold the line in CI. It reads class names as text, so it is a list to work from.
144
+ 3. When it finds none, change the import to `strata-react/strata.css`. A new app starts there; use the migration import only
145
+ for an existing one. The integration suite checks that a stock class and a Strata component compile together in this mode,
146
+ and that the normal one still removes the stock ones.
147
+
124
148
  ## Components
125
149
 
126
150
  | Group | Exports | Notes |
127
151
  |---|---|---|
128
- | 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; `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` |
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` |
129
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 |
130
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: 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 |
131
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). |
132
- | 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); `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 |
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 |
133
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. 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") |
134
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 |
135
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`) |
@@ -152,7 +176,7 @@ strata-react is ESM-only (`exports` has only `import`), as is its peer `react-ro
152
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 |
153
177
  | Pictures from a set | `Lightbox`, `RegionEditor`; `moveRect`, `resizeRect`, `lerpRect` | A picture opened from a grid in a full-size `Dialog` (previous/next, arrow keys, "3 of 40", zoom and 1:1, details beside it, neighbours preloaded, a `missing` sentence, Compare ticked hand-off); named windows drawn and moved on a picture by pointer, keys and numbers, with aspect and bounds held, and a from/to move with a Watch preview |
154
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 |
155
- | Browsing | `Tree`, `FolderPicker` | A hierarchy that loads as it opens (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 |
179
+ | Browsing | `Tree`, `FolderPicker` | A hierarchy that loads as it opens (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 |
156
180
  | Marking text | `MarkableText`, `Mark`, `MarkSummary`; `rangeBetween` | Select words by drag, Shift+click and Shift+arrows (ids in document order, so it holds across virtualised rows), apply the app's marks from a bar or single-key chords, marks drawn by role, pattern and text, summarised and announced |
157
181
  | Maps | `strata-react/map`: `RouteMap`; `geo`, `LatLng` (main entry) | Routes and a position that moves along them, on Leaflet (no react-leaflet), behind its own entry. Tiles are the app's (`tiles.light`, `tiles.dark`, each with its attribution); the dark scheme uses the dark set or a filter over the light one. Route colours are roles resolved at draw time; `values` with `colourScale` colour a route by value in runs of one step, with a key that names the steps; a single route gets direction chevrons and start/finish marks (a loop is one mark). The position is one marker moved with `setLatLng`: no route is redrawn for it (keep `routes` stable). As picture content (a route inset over footage): `zoom` sets any zoom (animate it per frame), `follow="centre"` holds the view exactly on a position with no animation (a frame is deterministic), and `positions` draws several, each tied to a route, in its colour and named in the text alternative; routes are not redrawn for any of it. Leaflet's keyboard pan and zoom stay; the map is named by `label` and described by a generated text alternative (routes, lengths, position along). Overlay slots `topEnd` and `bottomStart` avoid Leaflet's own controls and attribution. Leaflet's stylesheet is injected once, so an app imports nothing. `geo` (distance, bearing, bounds, `pointAlong`, `arrows`, `ends`) and `format.distance` need no map library |
158
182
  | Timeline | `Timeline`, `useTimelineZoom`, `TimelineZoomControls`, `noOverlap` | Items with a start and a length in lanes on a zoomable time axis, for media edits, bookings, rotas and plans. The timeline draws and the app decides: every move, trim, lane change, selection and current-time change is reported (`onItemChange`, `onSelect`, `onPositionChange`) and the app applies it; `validate` refuses a change with a reason shown in words while it is made. One tab stop for the items; arrows move between them, Ctrl+arrows nudge and change lane, Alt+arrows trim, the current time is its own slider, `+` `-` `0` zoom, and each change is announced ("run-02.mp4 moved to 0:13"). The ruler picks steps people write on a scale so labels never collide. Lanes take drops from outside (`dropTypes`, `onDrop` with the lane and snapped time, `validateDrop`, and React Aria's keyboard drag landing at the current time), `laneRows` makes them taller, `kindColours` fixes each kind's stripe, and the header column fits its content. Only items near the view are rendered |
package/UPGRADING.md CHANGED
@@ -11,6 +11,15 @@ 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.40 (2026-11-13 to 2026-11-14)
15
+
16
+ - Two `StrataToastRegion`s mounted at once no longer draw every toast twice: the first mounted draws and a second draws nothing (and warns in development, naming `renderRoutes(..., { toasts: false })`). A test that worked around the doubling with `findAllByText` can use `findByText`; an app with a region in a layout and another in a page loses the page's.
17
+ - Full screen on `Compare` and `CompareVideo` now fills what the controls leave (measured), whatever `maxHeight` was, where a caller's `maxHeight` used to cap it too, and where no `maxHeight` left the frame as tall as its width made it. New `maxHeight="fit"` and `reserve` measure the page; `"viewport"` is still the fixed guess.
18
+ - A picture that loads with no size (an SVG without one) no longer sets `Compare`'s aspect to NaN; the 3:2 box stays.
19
+ - `Button`, `IconButton` and `RowAction` refuse `title` (the type is `never`; React Aria's button never forwarded it, so a tip carried over from a native button silently vanished). Wrap the button in a `Tooltip`, or give `IconButton` a `label` and `hint`. In development a `title` that gets through (an untyped caller) and a button whose only content is one symbol with no `aria-label` log a warning once.
20
+ - Development warnings (a second toast region, command clashes, the media-player key clash, and the new `Button` ones) now read `process.env.NODE_ENV`, which your bundler replaces; before, the library build had turned them off. Expect to see them in development if you were doing any of those things.
21
+ - `FolderPicker`'s `useFolders` may return `{ folders, footer }` as well as an array; a row with a `badge` has `, badge` in its name (`name: "film-2026, project"`). `FolderPicker` and `Tree` gain props only; a picker that sets none of them is unchanged, except that a chosen folder's own listing is now read for its footer (cached, so no second request when the tree has it open).
22
+
14
23
  ## After v1.0.39 (2026-11-13)
15
24
 
16
25
  - `Tree`'s props are now a union: give `selected` and `onSelect` (one chosen node) or `choices` from `useChoices` (several). Code that passed `selected` and `onSelect` compiles as before.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ // strata-stock-classes: list the stock Tailwind classes an app still uses (src/migrate/cli.ts, built into dist/).
3
+ import { main } from "../dist/migrate-cli.js";
4
+
5
+ process.exitCode = await main(process.argv.slice(2));
@@ -7,8 +7,10 @@ export declare const buttonVariants: (props?: ({
7
7
  variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
8
8
  size?: "default" | "sm" | "icon" | "icon-sm" | null | undefined;
9
9
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
10
- export type ButtonProps = Omit<React.ComponentProps<"button">, "className" | "style"> & VariantProps<typeof buttonVariants> & {
10
+ export type ButtonProps = Omit<React.ComponentProps<"button">, "className" | "style" | "title"> & VariantProps<typeof buttonVariants> & {
11
11
  className?: string;
12
+ /** Not accepted: a `title` is a poor tooltip (no keyboard focus, no touch) and React Aria's button drops it. Wrap the button in a `Tooltip`, or use `IconButton`'s `label` and `hint`. */
13
+ title?: never;
12
14
  /** React Aria's press event (mouse, touch, pen and keyboard alike). `onClick` also works. */
13
15
  onPress?: (event: PressEvent) => void;
14
16
  /** When a press begins and ends: for a control that acts while held (a nudge that repeats). */
@@ -4,6 +4,31 @@ import { Candidate } from './compare';
4
4
  import { FramePick } from './viewport';
5
5
  import * as React from "react";
6
6
  export declare const VIEWPORT_HEIGHT = "max(16rem, calc(100svh - 14rem))";
7
+ /** The least a frame is made, however little room is left: a pair this small can still be told apart. */
8
+ export declare const MIN_FIT = 120;
9
+ /** The tallest each row of frames may be so that all of `chrome` and `rows` rows fit in `space` pixels. Pure, so it is tested without a layout. */
10
+ export declare function fitFrames({ space, chrome, rows, min }: {
11
+ space: number;
12
+ chrome: number;
13
+ rows: number;
14
+ min?: number;
15
+ }): number;
16
+ /** Frame cap for what the caller asked for: a measured height for `"fit"` and in full screen (whatever the caller passed, so the frame fills what the controls leave), the guess for `"viewport"`, the caller's own length otherwise. */
17
+ export declare function frameCap(maxHeight: string | undefined, fit: number | null, full: boolean): string | undefined;
18
+ /**
19
+ * How tall each frame may be for the pair and everything around it to fit the window (issue #229), measured, not
20
+ * guessed. In the page: the window's height from the top of `root` (as the page is at its top), less what `root` draws
21
+ * besides its frames (toolbar, captions, footer, legend: the bottom of its last child, not its height, which a stretched
22
+ * full-screen section would inflate), less what follows it (later siblings of it and of its ancestors, then `reserve` for
23
+ * padding and gaps the caller knows). In full screen: the window from the top of `root`, nothing after. Divided by the
24
+ * rows of frames (side by side is one row; below `sm` it is two) and floored at `MIN_FIT`. Frames are found by
25
+ * `data-viewport-frame`, so an app never queries for them. Null until measured, or when `enabled` is false.
26
+ */
27
+ export declare function useFitHeight(root: React.RefObject<HTMLElement | null>, { enabled, full, reserve }: {
28
+ enabled: boolean;
29
+ full: boolean;
30
+ reserve?: number;
31
+ }): number | null;
7
32
  /** Words for click to choose, in the product's voice. */
8
33
  export type PickWords = {
9
34
  /** What hovering a side says, and what the frame is described as: `(label) => "Click to choose " + label`. */
@@ -45,8 +45,10 @@ export type CompareVideoProps = {
45
45
  audio?: "a" | "b" | "none";
46
46
  /** Draw nearest-neighbour when shown larger than the video's own pixels (`zoomed`, default), always, or never. */
47
47
  pixelated?: "zoomed" | "always" | "never";
48
- /** How tall a frame may be: a CSS length or `"viewport"`, as in `Compare`. */
48
+ /** How tall a frame may be: a CSS length, `"viewport"` (a fixed guess) or `"fit"` (measured), as in `Compare`; full screen fills what the controls leave. */
49
49
  maxHeight?: string;
50
+ /** With `maxHeight="fit"`: pixels of the page below this that it cannot measure, as in `Compare`. Default 0. */
51
+ reserve?: number;
50
52
  /** Bind the keys on the window. Default true. */
51
53
  keys?: boolean;
52
54
  /** Shortcuts of the surrounding screen, bound with these and listed first in the same legend. */
@@ -56,4 +58,4 @@ export type CompareVideoProps = {
56
58
  className?: string;
57
59
  };
58
60
  /** Two videos to judge by eye on one clock: side by side, swipe, fade or blink, zoomed together, with matched sound and full screen. */
59
- export declare function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates, regions, moments, loop: loopProp, onLoopChange, audio, onPick, pick, pickWords, autoPlay, loopWhole, pixelated, maxHeight, keys, extraShortcuts, footer, className }: CompareVideoProps): React.JSX.Element;
61
+ export declare function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates, regions, moments, loop: loopProp, onLoopChange, audio, onPick, pick, pickWords, autoPlay, loopWhole, pixelated, maxHeight, reserve, keys, extraShortcuts, footer, className }: CompareVideoProps): React.JSX.Element;
@@ -66,8 +66,10 @@ export type CompareProps = {
66
66
  readPixels?: ReadPixels;
67
67
  /** Which views are offered. Default all five. Must include `mode`. */
68
68
  modes?: readonly CompareMode[];
69
- /** How tall a frame may be, so the pair and the answer fit on one screen: a CSS length (`"60svh"`) or `"viewport"` (the window's height less room for the toolbar, captions, a vote bar and the key legend). The frame narrows to keep the picture's shape. Default: as tall as the width makes it. */
69
+ /** How tall a frame may be, so the pair and the answer fit on one screen: a CSS length (`"60svh"`), `"viewport"` (the window's height less a fixed 14rem for the toolbar, captions, a vote bar and the key legend: a guess), or `"fit"` (measured: the window from the top of this component, less what it draws besides its frames and what follows it in the page, shared between the rows of frames, never under 120 px; re-measured as the page changes; see `reserve`). The frame narrows to keep the picture's shape. In full screen the frame fills what the controls leave, whatever this is. Default: as tall as the width makes it. */
70
70
  maxHeight?: string;
71
+ /** With `maxHeight="fit"`: pixels of the page below this component that it cannot measure (padding and gaps of the screen around it); later siblings are measured. Default 0. */
72
+ reserve?: number;
71
73
  /** Named boxes in the source's coordinates to look at enlarged: a strip of chips, keys `q` `w` `e` `r` `y` `u`, nearest-neighbour drawing while one is shown, and Shift-drag to make another. They work in every view. The same share of each side is shown, whatever its pixel size. Label them by content ("Face"), never by candidate. */
72
74
  regions?: readonly Region[];
73
75
  /** Called with the side clicked or tapped, in the views where a click is unambiguous: side by side, swipe (by the side of the divider) and blink (the side showing). A pointer convenience: the keys and the vote bar stay the way to answer. A `PairVote` sets this for you. */
@@ -85,4 +87,4 @@ export type CompareProps = {
85
87
  className?: string;
86
88
  };
87
89
  /** Two pictures to judge, side by side or laid over each other, zoomed and panned together, and full screen. */
88
- export declare function Compare({ label, a, b, blind, missing, mode, onModeChange, modes, regions, onPick, pick, pickWords, keys, extraShortcuts, footer, maxHeight, cannotCompare, readPixels, defaultDifference, className }: CompareProps): React.JSX.Element;
90
+ export declare function Compare({ label, a, b, blind, missing, mode, onModeChange, modes, regions, onPick, pick, pickWords, keys, extraShortcuts, footer, maxHeight, reserve, cannotCompare, readPixels, defaultDifference, className }: CompareProps): React.JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { Load } from './data-view';
2
2
  import { Expanded } from './disclosure';
3
+ import { Tone } from './status';
3
4
  import * as React from "react";
4
5
  /** One folder in a listing. */
5
6
  export type Folder = {
@@ -9,12 +10,22 @@ export type Folder = {
9
10
  name: string;
10
11
  /** How many folders are inside it, when the server knows; shown beside the name. */
11
12
  count?: number;
13
+ /** A word about the folder ("project"), shown beside the name as text on a tint and included in its row's name. */
14
+ badge?: string;
15
+ /** The badge's tone. Default `neutral`. */
16
+ tone?: Tone;
17
+ };
18
+ /** What a listing hook may return instead of a bare array: the folders and a sentence about the folder they are in. */
19
+ export type FolderListing = {
20
+ folders: readonly Folder[];
21
+ /** Shown under the tree while this folder is the one being looked at: "3 camera files here". */
22
+ footer?: string;
12
23
  };
13
24
  export type FolderPickerProps = {
14
25
  /** Names the picker: "Choose a folder for the project". Required. */
15
26
  label: string;
16
- /** Reads one folder's subfolders (`null` is the top). A hook: `useLoad` inside. */
17
- useFolders: (path: string | null) => Load<readonly Folder[]>;
27
+ /** Reads one folder's subfolders (`null` is the top). A hook: `useLoad` inside. It may return `{ folders, footer }` to say something about the folder itself. */
28
+ useFolders: (path: string | null) => Load<readonly Folder[] | FolderListing>;
18
29
  /** The folder being looked at, or `null`. */
19
30
  value: string | null;
20
31
  onChange: (path: string | null) => void;
@@ -24,6 +35,12 @@ export type FolderPickerProps = {
24
35
  expanded: Expanded;
25
36
  /** Folders chosen before, newest first. */
26
37
  recent?: readonly string[];
38
+ /** Whether the looked-at folder may be chosen: `true`, or the reason it may not, shown beside the disabled button. Given the folder when the listing has it. */
39
+ canChoose?: (path: string, folder: Folder | undefined) => true | string;
40
+ /** Names the choosing button: "Create project here". Default "Choose this folder". */
41
+ chooseLabel?: string;
42
+ /** Asked when the person opens a folder in the tree: `"choose"` takes it as chosen at once and keeps it closed, `"enter"` (the default) opens it. */
43
+ onOpen?: (folder: Folder) => "choose" | "enter";
27
44
  /** Makes a folder named `name` in `parent`. Throw (an `HttpError`) to refuse; its reason is shown on the field. Without it there is no New folder. */
28
45
  onCreate?: (parent: string, name: string) => Promise<unknown>;
29
46
  /** The name of the top: "Server". Default "Top". */
@@ -39,4 +56,4 @@ export declare const parentOf: (path: string) => string | null;
39
56
  /** Every folder from the top down to `path`, which the tree must have open to show it. */
40
57
  export declare const ancestorsOf: (path: string) => string[];
41
58
  /** A server folder chooser: a lazy tree, a breadcrumb that is also editable text, Up, recents, a New folder field that shows the server's refusal, and Choose this folder as the one filled button. */
42
- export declare function FolderPicker({ label, useFolders, value, onChange, onChoose, expanded, recent, onCreate, topLabel, emptyRow, height, className }: FolderPickerProps): React.JSX.Element;
59
+ export declare function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose, expanded, recent, canChoose, chooseLabel, onOpen, onCreate, topLabel, emptyRow, height, className }: FolderPickerProps): React.JSX.Element;
@@ -1,3 +1,4 @@
1
+ import * as React from "react";
1
2
  /** What a toast says. */
2
3
  export type ToastContentProps = {
3
4
  /** What finished, past tense, in the product's words: "Export finished". */
@@ -29,5 +30,5 @@ export type StrataToastRegionProps = {
29
30
  label?: string;
30
31
  className?: string;
31
32
  };
32
- /** The one place toasts appear. Render it once at the app root. A labelled landmark (F6), polite, above panes and the undo bar. */
33
- export declare function StrataToastRegion({ label, className }: StrataToastRegionProps): import('react').JSX.Element;
33
+ /** The one place toasts appear. Render it once at the app root; a second one mounted at the same time draws nothing and warns in development. A labelled landmark (F6), polite, above panes and the undo bar. */
34
+ export declare function StrataToastRegion({ label, className }: StrataToastRegionProps): React.JSX.Element | null;
@@ -38,6 +38,8 @@ type TreeCommon<N> = {
38
38
  renderNode?: (node: N, state: TreeNodeState) => React.ReactNode;
39
39
  /** Which nodes are open; from `useExpanded`, optionally in the URL. */
40
40
  expanded: Expanded;
41
+ /** Asked when the person opens a branch (chevron or Right arrow): return `false` to keep it closed, having done something else with it (a folder that is a project is chosen, not entered). Not asked for opens the app makes itself. */
42
+ beforeOpen?: (node: N) => boolean;
41
43
  /** The skeleton row while a node's children load. Default: a muted bar. */
42
44
  loadingRow?: React.ReactNode;
43
45
  /** What an open node with nothing in it says: "No folders". Required, so an empty branch is never blank. */
@@ -47,5 +49,5 @@ type TreeCommon<N> = {
47
49
  className?: string;
48
50
  };
49
51
  /** A hierarchy whose children load as each node opens (a `useChildren` hook per open node): a skeleton row, a Try again row and an "empty" row per node, type-ahead and arrow keys, single selection, open state optionally in the URL, always virtualised. */
50
- export declare function Tree<N>({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, choices, expanded, loadingRow, emptyRow, height, className }: TreeProps<N>): React.JSX.Element;
52
+ export declare function Tree<N>({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, choices, expanded, beforeOpen, loadingRow, emptyRow, height, className }: TreeProps<N>): React.JSX.Element;
51
53
  export {};
@@ -3,6 +3,15 @@ import "react";
3
3
  import { Button } from "react-aria-components";
4
4
  import { cva } from "class-variance-authority";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/lib/dev.ts
7
+ /** Whether the app is running in development, decided by the app's bundler. */
8
+ function isDev() {
9
+ try {
10
+ return process.env.NODE_ENV !== "production";
11
+ } catch {
12
+ return false;
13
+ }
14
+ }
6
15
  // src/components/button.tsx
7
16
  var buttonVariants = cva("inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-(--control-icon) [&_svg]:shrink-0", {
8
17
  variants: {
@@ -33,6 +42,7 @@ var buttonVariants = cva("inline-flex max-w-full shrink-0 cursor-pointer items-c
33
42
  * `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.
34
43
  */
35
44
  function Button$1({ className, variant, size, type = "button", disabled, children, ...props }) {
45
+ if (isDev()) warnOnLoss(props, children);
36
46
  return /* @__PURE__ */ jsx(Button, {
37
47
  type,
38
48
  isDisabled: disabled,
@@ -48,6 +58,19 @@ function Button$1({ className, variant, size, type = "button", disabled, childre
48
58
  }) : children
49
59
  });
50
60
  }
61
+ /** Development only: what a native button had that this one loses or cannot name (issue #231). */
62
+ function warnOnLoss(props, children) {
63
+ if (props.title !== void 0 && !warned.has("title")) {
64
+ warned.add("title");
65
+ console.warn("strata-react: Button does not pass `title` through (React Aria's button drops it, and a title has no keyboard or touch). Wrap the button in a `Tooltip`, or use IconButton's `label` and `hint`.");
66
+ }
67
+ const glyph = typeof children === "string" ? children.trim() : "";
68
+ if (glyph && Array.from(glyph).length === 1 && !/[\p{L}\p{N}]/u.test(glyph) && !props["aria-label"] && !props["aria-labelledby"] && !warned.has("glyph")) {
69
+ warned.add("glyph");
70
+ console.warn(`strata-react: a Button whose only content is "${glyph}" has no accessible name. Give it an aria-label, or use an IconButton with a label.`);
71
+ }
72
+ }
73
+ var warned = /* @__PURE__ */ new Set();
51
74
  /** An icon-only button. `label` is required and becomes the accessible name and the tooltip (hover and keyboard focus); `hint` adds a muted aside to it, such as a shortcut. */
52
75
  function IconButton({ icon: Icon, label, hint, variant = "ghost", size = "default", ...props }) {
53
76
  return /* @__PURE__ */ jsx(Tooltip$1, {
@@ -151,6 +174,6 @@ var describeActionError = (error) => error instanceof HttpError ? error.status >
151
174
  function fieldErrorsOf(error) {
152
175
  return error instanceof HttpError ? error.fieldErrors : {};
153
176
  }
154
- export { readErrorBody as a, RowAction as c, fieldErrorsOf as i, buttonVariants as l, describeActionError as n, Button$1 as o, describeHttpError as r, IconButton as s, HttpError as t };
177
+ export { readErrorBody as a, RowAction as c, fieldErrorsOf as i, buttonVariants as l, describeActionError as n, Button$1 as o, describeHttpError as r, IconButton as s, HttpError as t, isDev as u };
155
178
 
156
- //# sourceMappingURL=errors-BunUBqpA.js.map
179
+ //# sourceMappingURL=errors-ByjNcEDc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-ByjNcEDc.js","names":["Button","AriaButton","Tooltip"],"sources":["../src/lib/dev.ts","../src/components/button.tsx","../src/lib/errors.ts"],"sourcesContent":["// Development-only checks (a warning for a mistake a type cannot catch). `import.meta.env.DEV` is\n// replaced by the library build itself, so in the published package it is always false and the check\n// never runs in an app's development. `process.env.NODE_ENV` is left for the app's bundler to replace\n// (Vite, webpack and the rest do, in dependencies too), so the app decides. Where nothing replaces it\n// `process` does not exist, and the check is off.\n\n/** Whether the app is running in development, decided by the app's bundler. */\nexport function isDev(): boolean {\n try {\n return process.env.NODE_ENV !== \"production\";\n } catch {\n return false;\n }\n}\n","import * as React from \"react\";\nimport { Button as AriaButton, type PressEvent } from \"react-aria-components\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\nimport type { ControlSize } from \"../lib/control\";\nimport { Tooltip } from \"./tooltip\";\nimport { isDev } from \"../lib/dev\";\n\n// Variant names are shadcn's, so copied code and agents' prior knowledge still work. Two things\n// differ on purpose:\n// 1. The default variant is `outline`, not the filled accent. A bare <Button> is the restrained\n// one; the accent (`variant=\"default\"`) has to be asked for, once per view. Generated app screens\n// put the accent on every button; 12 of 23 real product screens had no filled primary at all.\n// 2. Heights come from --control-h, shared with Input and NativeSelect, so density changes move\n// every control together.\n// 3. React Aria is the primitives layer (CLAUDE.md, \"The stack\"): behaviour and accessibility come\n// from it, the look from our tokens. `asChild`/`Slot` is gone; a button that navigates is a link.\n// 4. `press`: the button gives 2% under a click or a finger, over 100ms. Buttons are used tens of\n// times a day, so that is all the motion they get (character.md, the frequency budget).\n// 5. `title` is refused, not passed through (issue #231). React Aria's `Button` does not forward it,\n// so a tip moved over from a native button vanished with nothing said. Passing it through would\n// give a tip that has no keyboard focus, no touch and a long, unstyled delay; the answer is a\n// `Tooltip` (and `IconButton`'s `label` and `hint`). The type says so (`title?: never`) and, for\n// an untyped caller, so does a development warning. A button whose only child is one symbol\n// (`✕`, `−`, `+`) has no accessible name from its text and gets a development warning too.\nexport const buttonVariants = cva(\n \"inline-flex max-w-full shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-control type-label transition-state press disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-(--control-icon) [&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary-10\",\n outline: \"border border-input bg-background text-foreground hover:bg-muted\",\n secondary: \"bg-muted text-foreground hover:bg-neutral-4\",\n ghost: \"text-foreground hover:bg-muted\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-danger\",\n link: \"h-auto px-0 text-primary-11 underline underline-offset-4 hover:text-primary-12\",\n },\n size: {\n default: \"h-(--control-h) px-(--control-px)\",\n sm: \"h-(--control-h-sm) px-(--control-px-sm)\",\n icon: \"size-(--control-h)\",\n \"icon-sm\": \"size-(--control-h-sm)\",\n },\n },\n defaultVariants: { variant: \"outline\", size: \"default\" },\n },\n);\n\nexport type ButtonProps = Omit<React.ComponentProps<\"button\">, \"className\" | \"style\" | \"title\"> &\n VariantProps<typeof buttonVariants> & {\n className?: string;\n /** Not accepted: a `title` is a poor tooltip (no keyboard focus, no touch) and React Aria's button drops it. Wrap the button in a `Tooltip`, or use `IconButton`'s `label` and `hint`. */\n title?: never;\n /** React Aria's press event (mouse, touch, pen and keyboard alike). `onClick` also works. */\n onPress?: (event: PressEvent) => void;\n /** When a press begins and ends: for a control that acts while held (a nudge that repeats). */\n onPressStart?: (event: PressEvent) => void;\n onPressEnd?: (event: PressEvent) => void;\n };\n\n/**\n * A button with shadcn's variant names, built on React Aria's `Button` (press handling that behaves\n * the same for mouse, touch, pen and keyboard, focus-visible and hover state). The default variant is\n * `outline`; ask for the filled accent (`variant=\"default\"`) once per view. `type` defaults to `button`.\n * `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.\n */\nexport function Button({ className, variant, size, type = \"button\", disabled, children, ...props }: ButtonProps) {\n if (isDev()) warnOnLoss(props as Record<string, unknown>, children);\n // data-variant says which variant was drawn, so a test can check \"one filled button per view\"\n // without reading class names (strata-react issue #48, `filledButtons` in strata-react/testing).\n return (\n <AriaButton\n type={type}\n isDisabled={disabled}\n data-variant={variant ?? \"outline\"}\n className={cn(buttonVariants({ variant, size }), className)}\n {...(props as object)}\n >\n {/* A text label that cannot fit its column is cut with an ellipsis, not drawn past the button (issue #116). */}\n {typeof children === \"string\" ? <span className=\"min-w-0 truncate\">{children}</span> : children}\n </AriaButton>\n );\n}\n\n/** Development only: what a native button had that this one loses or cannot name (issue #231). */\nfunction warnOnLoss(props: Record<string, unknown>, children: React.ReactNode) {\n if (props.title !== undefined && !warned.has(\"title\")) {\n warned.add(\"title\");\n console.warn(\"strata-react: Button does not pass `title` through (React Aria's button drops it, and a title has no keyboard or touch). Wrap the button in a `Tooltip`, or use IconButton's `label` and `hint`.\");\n }\n const glyph = typeof children === \"string\" ? children.trim() : \"\";\n if (glyph && Array.from(glyph).length === 1 && !/[\\p{L}\\p{N}]/u.test(glyph) && !props[\"aria-label\"] && !props[\"aria-labelledby\"] && !warned.has(\"glyph\")) {\n warned.add(\"glyph\");\n console.warn(`strata-react: a Button whose only content is \"${glyph}\" has no accessible name. Give it an aria-label, or use an IconButton with a label.`);\n }\n}\nconst warned = new Set<string>();\n\n// An icon-only button cannot be written without a name: `label` is required by the type, becomes\n// the accessible name and is shown as a `Tooltip` on hover and keyboard focus, so the name and the\n// visible hint come from one string and cannot drift. This makes the most common generated\n// accessibility defect (an unlabelled icon button) a compile error instead of an audit finding.\nexport type IconButtonProps = Omit<ButtonProps, \"size\" | \"children\" | \"aria-label\"> & {\n /** `sm` is --control-h-sm, the height of a small `Toggle` or `Button`, for a toolbar or property row. Default --control-h. */\n size?: ControlSize;\n icon: IconComponent;\n label: string;\n /** Shown after the label in its tooltip, muted: \"Ctrl+Z\". */\n hint?: React.ReactNode;\n};\n\n/** An icon-only button. `label` is required and becomes the accessible name and the tooltip (hover and keyboard focus); `hint` adds a muted aside to it, such as a shortcut. */\nexport function IconButton({ icon: Icon, label, hint, variant = \"ghost\", size = \"default\", ...props }: IconButtonProps) {\n return (\n <Tooltip label={label} hint={hint}>\n <Button size={size === \"sm\" ? \"icon-sm\" : \"icon\"} variant={variant} aria-label={label} {...props}>\n <Icon aria-hidden />\n </Button>\n </Tooltip>\n );\n}\n\n// A row action says what it does in the row (\"Withdraw\") and whom it does it to in its name\n// (\"Withdraw Tom Ellery\"): a table of eight \"Withdraw\" buttons is eight identical names in a\n// screen reader's list of controls. The name is an aria-label that starts with the visible verb,\n// so it meets WCAG 2.5.3 (label in name) and voice control still finds it by \"Withdraw\". Visually\n// hidden suffix text is not used: a hidden span joined to the verb did not form a name with its\n// space in dom-testing-library (strata-react issue #11). Ghost and small, one per row, shown only\n// on the rows where it applies; an icon-only row action is an `IconButton` whose `label` names the\n// row the same way. It keeps the row's pitch: rows with and without the action are the same height.\nexport type RowActionProps = Omit<ButtonProps, \"children\" | \"aria-label\"> & {\n /** The visible verb, sentence case: \"Withdraw\", \"Remove\". */\n label: string;\n /** What the row is, as a person would say it: \"Tom Ellery\", \"Moonbeam\". Completes the accessible name. */\n subject: string;\n icon?: IconComponent;\n};\n\n/** A small ghost action for one table row: shows `label`, and is named \"`label` `subject`\" so every row's action has its own name. */\nexport function RowAction({ label, subject, icon: Icon, variant = \"ghost\", size = \"sm\", className, ...props }: RowActionProps) {\n // -my-1.5 lets the 32px button sit in the 20px line of a table row, inside the row's padding, so\n // rows with an action keep the same pitch as rows without one.\n return (\n <Button variant={variant} size={size} aria-label={`${label} ${subject}`} className={cn(\"-my-1.5\", className)} {...props}>\n {Icon && <Icon aria-hidden />}\n {label}\n </Button>\n );\n}\n","// Errors, described for a person. Anything that fails in front of someone (a load in DataView, an\n// action in AsyncButton) says what happened in a sentence, in the product's words, not the\n// developer's: `HttpError`'s own message (\"409 Conflict from /api/bookings\") is for logs. Loads\n// and actions share HttpError's status sentences, so the same failure reads the same everywhere,\n// and differ only in what is true afterwards: a failed load changed nothing, while a failed action\n// may have reached the server, so its sentence does not promise that.\n//\n// A server's own reason beats the status text (strata-react issue #42, from python-app-template).\n// FastAPI and most JSON APIs say why a 4xx happened in the body (`{\"detail\": \"the data folder must\n// be an absolute path\"}`), and a client that drops it has to repeat every server rule to show the\n// person anything better than \"Bad Request\", which drifts and cannot cover rules only the server\n// can check. So `fetchJson` reads an error response's body, `HttpError` keeps it with the reason\n// and any per-field messages found in it, and the sentences below use the reason for a 4xx.\n// Per-field messages (FastAPI's 422 `detail: [{loc, msg}]`) are keyed by field name, so\n// `useAsyncAction`'s `fieldErrors` can put each under its `Field`, never in a toast. A 5xx body is\n// not shown: it is usually a stack trace or a proxy's HTML page, and is kept on `body` for logs.\n\n/** What `readErrorBody` finds in an error response: the server's sentence, and messages per field. */\nexport type ErrorBody = {\n /** Why the server refused, in its own words. */\n reason?: string;\n /** Messages for individual fields, keyed by field name (`\"name\"`, `\"address.city\"`). */\n fields?: Record<string, string>;\n};\n\n/** Thrown by `fetchJson` on a non-2xx response; carries the status, the response body and the server's reason for `describeHttpError` and `describeActionError`. */\nexport class HttpError extends Error {\n /** The server's sentence for why it refused, from the body (`detail`, `message`, `error`), if it gave one. */\n readonly reason?: string;\n /** Messages for individual fields from the body (FastAPI's 422 `detail: [{loc, msg}]`), keyed by field name. Empty when there are none. */\n readonly fieldErrors: Readonly<Record<string, string>>;\n\n constructor(\n readonly status: number,\n readonly statusText: string,\n readonly url: string,\n /** The response body: parsed JSON when it was JSON, else its text; undefined when empty. */\n readonly body?: unknown,\n found: ErrorBody = readErrorBody(body),\n ) {\n super(`${status} ${statusText} from ${url}`);\n this.name = \"HttpError\";\n this.reason = found.reason;\n this.fieldErrors = found.fields ?? {};\n }\n}\n\nconst text = (value: unknown) => (typeof value === \"string\" && value.trim() ? value.trim() : undefined);\n\n/** A field name from a FastAPI/pydantic `loc`: the path after where it came from (`[\"body\", \"address\", \"city\"]` is `\"address.city\"`). */\nfunction fieldName(loc: unknown) {\n if (!Array.isArray(loc)) return undefined;\n const path = loc.map(String);\n if ([\"body\", \"query\", \"path\", \"header\", \"cookie\", \"form\"].includes(path[0]) && path.length > 1) path.shift();\n return path.join(\".\") || undefined;\n}\n\n/**\n * The default reading of an error body, for the shapes most JSON APIs use: `{ detail: \"…\" }`\n * (FastAPI), `{ message: \"…\" }`, `{ error: \"…\" }` or `{ error: { message: \"…\" } }` for the reason,\n * and FastAPI's validation list `{ detail: [{ loc, msg }] }` for per-field messages. A short\n * plain-text body (not HTML) is taken as the reason too. Pass your own to `fetchJson` for other APIs.\n */\nexport function readErrorBody(body: unknown): ErrorBody {\n if (typeof body === \"string\") {\n const t = text(body);\n return t && t.length <= 300 && !t.startsWith(\"<\") ? { reason: t } : {};\n }\n if (!body || typeof body !== \"object\") return {};\n const b = body as Record<string, unknown>;\n if (Array.isArray(b.detail)) {\n const fields: Record<string, string> = {};\n for (const item of b.detail as unknown[]) {\n const entry = item as { loc?: unknown; msg?: unknown } | null;\n const name = fieldName(entry?.loc);\n const msg = text(entry?.msg);\n if (name && msg && !fields[name]) fields[name] = msg;\n }\n return { fields };\n }\n const nested = b.error && typeof b.error === \"object\" ? text((b.error as Record<string, unknown>).message) : undefined;\n return { reason: text(b.detail) ?? text(b.message) ?? text(b.error) ?? nested };\n}\n\n/** Writes an error for a person: what happened, in a sentence. A product passes its own words. */\nexport type DescribeError = (error: unknown) => string;\n\n/** A sentence ends once: \"…absolute path\" and \"…absolute path.\" both end in one full stop. */\nconst sentence = (s: string) => (/[.!?…]$/.test(s) ? s : `${s}.`);\n\nfunction refused(error: HttpError) {\n if (error.reason) return `The request was refused: ${sentence(error.reason)}`;\n if (Object.keys(error.fieldErrors).length) return \"The request was refused: check the fields marked.\";\n return `The request was refused (${error.status}): ${error.statusText || \"no reason given\"}.`;\n}\n\n/** The default `DescribeError` for loads: the HTTP status in a sentence (with the server's reason for a 4xx), else the error's message, else a plain fallback. */\nexport const describeHttpError: DescribeError = (error) =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}). Nothing was changed.`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : \"The data could not be loaded. Nothing was changed.\";\n\n/** The default for `useAsyncAction`: the HTTP status in a sentence (with the server's reason for a 4xx), else the thrown Error's message, else undefined (the retry label alone). */\nexport const describeActionError = (error: unknown): string | undefined =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}).`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : undefined;\n\n/** Messages for individual fields carried by what was thrown: an `HttpError`'s `fieldErrors`, else none. */\nexport function fieldErrorsOf(error: unknown): Readonly<Record<string, string>> {\n return error instanceof HttpError ? error.fieldErrors : {};\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,QAAiB;CAC/B,IAAI;EACF,OAAA,QAAA,IAAA,aAAgC;CAClC,QAAQ;EACN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QAAQ,KAAK,IACf,iBAAiB,SAAS,MAAM,UAC9B,MAAM,UACN,KAAA;;AAGR,SAAgB,cAAc,OAAkD;CAC9E,OAAO,iBAAiB,YAAY,MAAM,cAAc,CAAC;AAC3D"}
package/dist/index.d.ts CHANGED
@@ -95,6 +95,6 @@ export { moveRect, resizeRect, fitRect, drawRect, lerpRect, ease, type Rect, typ
95
95
  export { SequenceTimeline, type SequenceTimelineProps, type SequenceItem, type CutRoom, type CutChange } from './components/sequence-timeline';
96
96
  export { snapToGrid, stepOnGrid, gridPoints, clampToRoom, settleCut, type Grid, type CutLimit } from './lib/sequence';
97
97
  export { Tree, type TreeProps, type TreeNodeState } from './components/tree';
98
- export { FolderPicker, parentOf, ancestorsOf, type FolderPickerProps, type Folder } from './components/folder-picker';
98
+ export { FolderPicker, parentOf, ancestorsOf, type FolderPickerProps, type Folder, type FolderListing } from './components/folder-picker';
99
99
  export { MarkableText, Mark, MarkSummary, type MarkableTextProps, type MarkKind, type MarkTone, type MarkPattern } from './components/markable-text';
100
100
  export { rangeBetween, countMarks, stepId } from './lib/marks';