strata-react 1.3.15 → 1.3.16

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.
Files changed (52) hide show
  1. package/README.md +47 -8
  2. package/UPGRADING.md +13 -0
  3. package/dist/components/data-table.d.ts +6 -0
  4. package/dist/components/field.d.ts +2 -0
  5. package/dist/components/hotkeys.d.ts +1 -1
  6. package/dist/components/link-card.d.ts +4 -2
  7. package/dist/components/pause-button.d.ts +7 -0
  8. package/dist/components/schedule-table.d.ts +24 -0
  9. package/dist/components/system-panel.d.ts +58 -0
  10. package/dist/components/theme.d.ts +46 -1
  11. package/dist/{errors-D99YX4XL.js → errors-D0TsKLwJ.js} +2 -2
  12. package/dist/{errors-D99YX4XL.js.map → errors-D0TsKLwJ.js.map} +1 -1
  13. package/dist/{field-QCCmWTuY.js → field-jfhLD5XX.js} +22 -15
  14. package/dist/{field-QCCmWTuY.js.map → field-jfhLD5XX.js.map} +1 -1
  15. package/dist/{format-B32-PVi2.js → format-BNkXVwFx.js} +67 -6
  16. package/dist/format-BNkXVwFx.js.map +1 -0
  17. package/dist/index.d.ts +6 -3
  18. package/dist/index.js +796 -409
  19. package/dist/index.js.map +1 -1
  20. package/dist/lib/breakpoint.d.ts +4 -0
  21. package/dist/lib/format.d.ts +59 -6
  22. package/dist/map.js +3 -3
  23. package/dist/{microphone-BZXMKTCM.js → microphone-CZy0bNEx.js} +138 -91
  24. package/dist/microphone-CZy0bNEx.js.map +1 -0
  25. package/dist/panorama.js +2 -2
  26. package/dist/query/index.d.ts +5 -1
  27. package/dist/query/poll.d.ts +24 -0
  28. package/dist/reading.css +11 -0
  29. package/dist/{run-hR9neQHM.js → run-BT2WKzMz.js} +83 -17
  30. package/dist/run-BT2WKzMz.js.map +1 -0
  31. package/dist/strata.bare.css +279 -0
  32. package/dist/strata.css +840 -10
  33. package/dist/strata.migrate.css +15 -6
  34. package/dist/testing/index.d.ts +4 -2
  35. package/dist/testing.js +32 -6
  36. package/dist/testing.js.map +1 -1
  37. package/dist/{theme-By3DSUTs.js → theme-CFBAYaiu.js} +147 -6
  38. package/dist/theme-CFBAYaiu.js.map +1 -0
  39. package/dist/{value-controls-B7iNh4WO.js → value-controls-WRXbtUp6.js} +21 -6
  40. package/dist/value-controls-WRXbtUp6.js.map +1 -0
  41. package/dist/visual/capture.d.ts +2 -0
  42. package/dist/visual/fonts.d.ts +18 -0
  43. package/dist/visual/index.d.ts +1 -0
  44. package/dist/visual/types.d.ts +7 -1
  45. package/dist/visual-cli.js +1 -1
  46. package/dist/visual.js +1 -1
  47. package/package.json +12 -3
  48. package/dist/format-B32-PVi2.js.map +0 -1
  49. package/dist/microphone-BZXMKTCM.js.map +0 -1
  50. package/dist/run-hR9neQHM.js.map +0 -1
  51. package/dist/theme-By3DSUTs.js.map +0 -1
  52. package/dist/value-controls-B7iNh4WO.js.map +0 -1
package/README.md CHANGED
@@ -53,10 +53,49 @@ Use it to try a fix before it is released, then move back to the npm version.
53
53
 
54
54
  ## Set up an app
55
55
 
56
+ **The default look is in `strata.css`.** One import gives an app a finished, checked theme (light and
57
+ dark) and nothing else to write:
58
+
59
+ ```css
60
+ @import "tailwindcss";
61
+ @import "strata-react/strata.css"; /* the contract and the default look: palette, status roles, faces, radii, shadow */
62
+ ```
63
+
64
+ It is petrol and marigold on a faintly cool ground, with three radii that differ (6, 10 and 14 px), one
65
+ petrol-tinted shadow for what floats, **Instrument Sans** for text (at 85% width and heavier for titles and
66
+ big figures) and **JetBrains Mono** for code, both bundled. Marigold is the one warm accent and only marks
67
+ where attention already is (a selection, the active item of a keyboard-worked list). Every value is a token:
68
+ override any of them in a later `:root`, `.dark` or `@theme` block, or bring a whole palette
69
+ (`theme.generated.css`) after it. **Palettes are themes beside light and dark.** Five ship in `strata.css` (petrol and marigold, pine and coral,
70
+ cobalt and tangerine, steel and mint, clay and teal), each with a light and a dark set, chosen with a
71
+ `data-palette` attribute on the root that `ThemeProvider` sets (`defaultPalette`, persisted under
72
+ `strata-palette`). The picker is `<PaletteChoice />` (a list for a settings page, each option with a swatch
73
+ in its own colours) or `<PaletteChoice compact />` (swatches for a header); `usePalette()` is the hook, and
74
+ `paletteScript()` goes in `<head>` beside `colorSchemeScript()` so the page does not flash the default.
75
+ Status colours are the same in every palette. An app's own palette is a `[data-palette="name"]` block (and
76
+ `.dark [data-palette="name"]`) of the same roles, passed to `PaletteChoice options`.
77
+
78
+ Reading surfaces can add `@import "strata-react/reading.css"` for Source
79
+ Serif 4 as `font-reading`; it is opt-in so other apps bundle nothing for it.
80
+
81
+ **To opt out of the look** (an app that has its own, such as Tubes) import the contract alone, which is what
82
+ `strata.css` was before the look existed:
83
+
84
+ ```css
85
+ @import "strata-react/strata.bare.css"; /* no colours, no look; Geist is the only default (the face) */
86
+ ```
87
+
88
+ The ramps are `palette.mjs` output (`--primary "#00798f" --secondary "#f2a900" --contrast 0.5 --ground tinted`);
89
+ regenerate rather than edit. The Storybook and the example app run on the default look, so every baseline in
90
+ `tests/visual/baselines/` shows it.
91
+
92
+ The longer form, for a product with its own palette (imports `strata.bare.css`):
93
+
94
+
56
95
  ```css
57
96
  /* src/app.css */
58
97
  @import "tailwindcss";
59
- @import "strata-react/strata.css"; /* token contract, namespace reset, type steps, base layer */
98
+ @import "strata-react/strata.bare.css"; /* token contract, namespace reset, type steps, base layer; no look */
60
99
  @import "./theme.generated.css"; /* your palette: ux-research ux-design/skill/scripts/palette.mjs */
61
100
  @import "./theme.css"; /* your status roles, faces and subject colours, with reasons */
62
101
  ```
@@ -151,15 +190,15 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
151
190
  |---|---|---|
152
191
  | 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
192
  | 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`, `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
- | 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). |
193
+ | Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar`, `WorkflowSteps`, `JobsTable`, `ScheduleTable`, `SystemPanel`, `useSystemInfo`, `PauseButton` | 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; `ScheduleTable` is a machine's scheduled jobs (systemd timers, cron), not the queue: each job's last result as a word (OK, Failed, Running, Never run), when it last ran and when it runs next, the last two dropping on a phone; `SystemPanel` is strata-python's `GET /api/system` (`useSystemInfo()` reads it): version and commit, uptime, each folder as a `Meter` on shared disk limits ("Filling up", "Nearly full") or the word Missing, each service Up or Down with the server's reason, and the app's own `facts`; `PauseButton` takes the `Poll` from `usePoll` (passed to `useLoad({ poll })`): a fixed-name "Pause updates" toggle and "Updated 12:00" |
194
+ | 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).; a `DataTable` column's `hideBelow="sm"` hides its header and cells together on a narrow screen (CSS only; a virtualised table drops the column by a media query), never a hand-written `matchMedia` filter |
156
195
  | 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
196
  | 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
197
  | 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`, `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
- | 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) |
198
+ | Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `usePoll`, `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; `useLoad({ poll })` with `usePoll({ every })` reads again on an interval until the person pauses it (`PauseButton`), and once at once on resume; `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` |
199
+ | 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 only when it is on another origin or `external`) |
161
200
  | 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
- | 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 |
201
+ | Theme | `ThemeProvider` (`defaultPalette`), `PaletteChoice`, `usePalette`, `paletteScript`, `palettes`, `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
202
  | 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
203
  | 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
204
  | 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 |
@@ -192,7 +231,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
192
231
  | File intake | `FileButton`, `FileDropZone`, `FileOutcomes`, `MissingFile`, `useFileIntake` | Pick or drop local files, then one outcome per file. `FileButton` is React Aria's `FileTrigger` behind a real named button (the keyboard and phone route); `FileDropZone` is its `DropZone` and says what it takes while a drag is over it; it ignores the app's own drags (every `DragSource`'s, and any type named in `refuseTypes`), so a keyboard drag to a timeline lane does not stop on it. `useFileIntake({ accept, acceptLabel, process })` judges each file after the drop, so a wrong one is named with its reason (type, `maxBytes`, your `check`), runs your own `process` per file (a throw becomes `Failed` with its message and a retry), and never blocks the rest. `FileOutcomes` draws the rows and announces one summary per batch. `MissingFile` is a status word and a "Relink" that opens the picker for that item; the name wraps in a narrow pane and a `thumbnail` can lead it. Nothing assumes a server |
193
232
  | Inspector | `Inspector`, `InspectorSection`, `PropertyRow`, `PropertyList` | Properties of the selected thing. `Inspector` is a labelled region with the selection's name as its heading and the empty state (`empty`, required) when `title` is `null`; `selectionKey` gives a new selection fresh controls and keeps focus in the panel. `InspectorSection` is React Aria's `Disclosure` with the body mounted only while open; open and closed are remembered under `storageKey` (storage that throws just means defaults). `PropertyRow` is a `Field` with a "Reset <label>" that shows only while `modified`. `PropertyList` is a `dl`: missing values print an en dash heard as "Not known", units follow a non-breaking space, long values truncate with the whole value in a tooltip |
194
233
  | Feedback | `UndoBar`, `useUndoable`, `Done` | Undo before confirm; the hook owns which rows are out of view (`isRemoved`), a failed commit brings the row back with Try again in the same bar, and `flush()` commits before a dependent action; `Done` is the one celebration, and it must say what happens next |
195
- | Helpers | `cn`, `format`, `createFormat`, `NBSP` | `cn` knows `type-*`; all numbers and dates through `Intl`; `format.integer(n)`, `.decimal(n)`, `.percent(n)` are callable and keep Intl's methods; `format.bytes(n, unit?)` writes sizes in decimal units (`byteUnit` shares one unit across figures); `format.date(at)` ("8 Nov 2026") and `format.dateTime(at)` ("8 Nov 2026, 06:05"), like `clock`, `day` and `shortDay`, take a Date, ISO string or epoch ms; `format.ago(at, now?)` ("3 weeks ago"), `format.compact(n)` ("1.2k", and `count(n, one, many, { compact: true })`), `format.runningTime(seconds)` ("1:02:09") and `format.share(n)` ("<1%" for a part that rounds to 0); every number and date formatter prints the placeholder (`format.missing`, an en dash) for `null` or `undefined`; `createFormat(locale, { timeZone, missing })` fixes the zone and the placeholder; units and counts join with a non-breaking space |
234
+ | Helpers | `cn`, `format`, `createFormat`, `NBSP` | `cn` knows `type-*`; all numbers and dates through `Intl`; `format.integer(n)`, `.decimal(n)`, `.percent(n)` are callable and keep Intl's methods; `format.bytes(n, unit?)` writes sizes in decimal units, `{ binary: true }` (or a unit such as "GiB") in KiB, MiB, GiB (`byteUnit` shares one unit across figures); `format.duration(seconds)` ("16 min", "3.5 h", "2 days", or `{ style: "parts" }` for an uptime, "1d 1h 0m"), `format.measure(12.3, "GB")` and `format.agoTick(seconds)` ("−2 min", for a history chart's axis); `format.date(at)` ("8 Nov 2026") and `format.dateTime(at)` ("8 Nov 2026, 06:05"), like `clock`, `day` and `shortDay`, take a Date, ISO string or epoch ms; `format.ago(at, now?)` ("3 weeks ago"), `format.compact(n)` ("1.2k", and `count(n, one, many, { compact: true })`), `format.runningTime(seconds)` ("1:02:09") and `format.share(n)` ("<1%" for a part that rounds to 0); every number and date formatter prints the placeholder (`format.missing`, an en dash) for `null` or `undefined`; `createFormat(locale, { timeZone, missing })` fixes the zone and the placeholder; units and counts join with a non-breaking space |
196
235
  | Testing | `strata-react/testing`: `renderWithStrata`, `renderRoutes`, `createTestQueryClient`, `installLayoutShims`, `installFakeIntersectionObserver`, `filledButtons`, `expectOneFilledButton`, `asyncButtonPhase` | Router + query client around Testing Library's `render`; `renderRoutes(routes, { route, basename })` renders the app's own `RouteObject[]` in a memory data router, so layout routes, redirects, loaders and error elements run, and returns the `router` (where a redirect landed is `router.state.location`) and an act-wrapped `navigate`; a fixed box and ResizeObserver so measuring components render in jsdom; an IntersectionObserver the test fires with `scrollToEnd()` or `intersect(el)`; `filledButtons()` and `expectOneFilledButton()` check "one filled button per view" from `data-variant`, and `asyncButtonPhase(el)` reads an `AsyncButton`'s phase. Role names keep the non-breaking space from `format.count`, so match them with the same call or a `\s` regex |
197
236
  | API types | `strata-react/api-types` and the `strata-api-types` command | See "API types from the server" below |
198
237
  | Visual regression | `strata-react/visual` and the `strata-visual` command | Screenshots an app's Storybook and its routes in each MSW state, light and dark, against baselines in the app's repo |
@@ -308,7 +347,7 @@ so an app that names none still loads a face. Anything that falls through to
308
347
  Mac, and a glyph missing from a web font (an arrow, `⌘`) falls back the same way; no threshold
309
348
  absorbs that. The runner asks Chromium which face drew each element's text and fails the shot
310
349
  naming the face and an example (`"DejaVu Sans" in <kbd> "⌘"`). `systemFonts: "warn"` reports
311
- instead; `"allow"` skips the check. **Lazy pictures.** A whole-page (route) shot of a page taller than the window is first shown to the page in a window as tall as itself, and waits for the pictures that start loading (a `Thumbnail` below the fold), then the window goes back to its size, so the baseline shows what a person sees after scrolling, not grey loading boxes; `scrollThrough: false` takes the page as it loads. Story tags pick the viewport: `visual-wide`, `visual-phone`, `no-visual` to skip.
350
+ instead; `"allow"` skips the check; `systemFonts: { pin: "DejaVu Sans", files: ["tests/visual/fonts/DejaVuSans.ttf"] }` is for an app that chooses `system-ui` on purpose: on Linux the runner gives Chromium a fontconfig file whose only fonts are those files and which answers every system family with the pin, so the baselines match on every machine (elsewhere it warns and the machine's face is drawn; record baselines where CI does). **Lazy pictures.** A whole-page (route) shot of a page taller than the window is first shown to the page in a window as tall as itself, and waits up to 15 s for the pictures that start loading (a `Thumbnail` below the fold; a picture still missing then is reported on the shot, not passed over), then the window goes back to its size, so the baseline shows what a person sees after scrolling, not grey loading boxes; `scrollThrough: false` takes the page as it loads. Story tags pick the viewport: `visual-wide`, `visual-phone`, `no-visual` to skip.
312
351
  Pages run in UTC and `en-US`; set `timezone`, `locale` or a frozen `time` in the config.
313
352
  Strata's own suite (`strata-visual.config.ts`, with the kiln-room example app in
314
353
  `examples/kiln-app/`) is a working reference.
package/UPGRADING.md CHANGED
@@ -11,7 +11,20 @@ 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-25 (latest)
15
+ - `Poll` has a new member, `with({ every })` (#349): a read with its own pace takes `useLoad({ poll: poll.with({ every: 60_000 }) })` and keeps the page's pause, resume and "updated" time. A `Poll` you build by hand (in a test or story) must now supply `with`; one from `usePoll` already has it.
16
+ - `SystemPanel` takes `headingLevel` (2, 3 or 4; default 2, unchanged) so a page's own `h2` section can hold it (#348). `renderWithStrata` and `renderRoutes` take `base: "/_home/"` (#350): a `<base href>` for the render, removed on unmount, so `withBase`, `createApi` and `useSystemInfo` read the mount point they read in production; delete a hand-written `<base>` in your setup file.
17
+ - Visual baselines: `status-and-figures-pausebutton`, `-scheduletable`, `-systempanel` and `navigation-linkcard--same-site` were recorded before the default look and moved to it.
18
+
19
+ ## 2026-11-25 (later)
20
+ - `useHotkeys` also hears a key pressed on a control inside a grid or table row (a tile's checkbox) in the capture phase, because React Aria's row hooks stop those keys reaching `window` (#328): shortcuts that were dead after a checkbox click now run. A test that clicked the tile instead of its checkbox to avoid this can click the checkbox.
21
+ - `LinkCard` with an `href` on the page's own origin (`/notes/`) no longer draws the leaving arrow; `external` says it either way (#340). A baseline with such a card moves: the arrow is gone.
22
+ - `format.byteUnit(n)` is typed `ByteUnit | BinaryByteUnit` (its value for the default decimal call is unchanged); `format.bytes`'s second argument also takes `{ binary, unit }`.
23
+ - `strata-visual` waits up to 15 s (was 3) for pictures in a whole-page shot and reports ones still not loaded as a problem on the shot (#331), where it used to pass silently; a page that holds an `<img>` request open on purpose fails its route shot until `scrollThrough: false`. `systemFonts` also takes `{ pin, files }` (#342).
24
+
14
25
  ## 2026-11-25
26
+ - New: palettes as themes. `ThemeProvider` now also sets `data-palette` on the root (default `petrol`, persisted under `strata-palette`; `defaultPalette`, `paletteStorageKey`), which `strata.css` keys four extra palettes on; `PaletteChoice` and `usePalette` are the picker and hook. Apps on `strata.bare.css` get none of the palette CSS and see only the attribute. `Choice` (in `ChoiceGroup`) takes an optional decorative `leading`.
27
+ - **`strata.css` now includes Strata's default look** (petrol and marigold palette, status roles, radii 6/10/14 px, a tinted overlay shadow, **Instrument Sans** and **JetBrains Mono**, bundled). **An app that has its own look must change its import to `strata-react/strata.bare.css`**, which is exactly what `strata.css` was until now (no colours, Geist as the only default); then nothing else changes (Tubes: that one line). An app that stays on `strata.css` and defines every role itself is unchanged for those roles but picks up the look for anything it does not set (radii, shadow, faces, title voice, `--accent`); override those in a later `:root`, `.dark` or `@theme` block. `strata.migrate.css` is the bare contract without the stock-class reset, as before. New opt-in `strata-react/reading.css` brings Source Serif 4 as `font-reading`. New dependencies of strata-react: `@fontsource-variable/instrument-sans`, `@fontsource-variable/jetbrains-mono` (apps install nothing; the app's bundler must resolve the `.woff2` urls, as for Geist).
15
28
  - The default `--font-sans` is **Geist Variable**, bundled (Fontsource, a dependency of strata-react), where it was the system sans. An app that names its own face in `--font-sans` is unchanged; an app that never did gets a new look and moved baselines (re-record them: the face is now the same on every machine, so the screenshots no longer depend on its fonts). Mono is still a system face. `strata.css` now `@import`s `@fontsource-variable/geist`, so **the app's build must resolve a CSS `url()` to a `.woff2`**: Vite does this with nothing added (the files are emitted with hashed names under the app's base); a build that runs the Tailwind CLI and esbuild on its own must copy `node_modules/@fontsource-variable/geist/files/*.woff2` next to the compiled CSS (the rules say `./files/…`) or name its own face.
16
29
 
17
30
  ## 2026-11-24
@@ -1,3 +1,4 @@
1
+ import { Breakpoint } from '../lib/breakpoint';
1
2
  import * as React from "react";
2
3
  /** What a column's `value` may be: a number, text or a date, or `null`/`undefined` when the row has none. */
3
4
  export type CellValue = number | string | Date | null | undefined;
@@ -14,6 +15,11 @@ export type Column<T> = {
14
15
  truncate?: boolean;
15
16
  /** Keep the header for screen readers only, as for a column of row actions. `header` still names it. */
16
17
  hideHeader?: boolean;
18
+ /**
19
+ * Hide the column, header and cells together, on screens narrower than this Tailwind breakpoint
20
+ * (`"sm"` hides it on a phone). For the columns that are not the row's meaning (its name and state word stay). Not on the first column, which is the row's header. CSS only, except in a virtualised table, where the columns are laid out in script and are dropped by a media query instead.
21
+ */
22
+ hideBelow?: Breakpoint;
17
23
  className?: string;
18
24
  } & ({
19
25
  cell: (row: T) => React.ReactNode;
@@ -50,10 +50,12 @@ export type NativeSelectProps = (PlainSelectProps & {
50
50
  /** Called after the URL changes. */
51
51
  onChange?: (value: string) => void;
52
52
  });
53
+ /** One option of a `ChoiceGroup`: its value, its words, and optionally a decorative `leading` mark (a swatch) before the words, which a screen reader skips, so the label must say it all. */
53
54
  export type Choice = {
54
55
  value: string;
55
56
  label: string;
56
57
  detail?: string;
58
+ leading?: React.ReactNode;
57
59
  };
58
60
  /** Radio choices in a fieldset with a legend; each whole row is the hit target. For 2 to 5 options that each need a sentence. */
59
61
  export declare function ChoiceGroup(props: ChoiceGroupProps): React.JSX.Element;
@@ -14,7 +14,7 @@ export type Shortcut = {
14
14
  /** True when a key pressed on this element is the person typing, so single-key shortcuts must leave it alone. */
15
15
  export declare function isTypingTarget(target: EventTarget | null): boolean;
16
16
  /**
17
- * Binds single-key shortcuts on the window, ignoring keys typed into fields, chords with Ctrl, Meta
17
+ * Binds single-key shortcuts on the window (also for a key pressed on a control inside a grid row, whose React Aria hooks stop propagation), ignoring keys typed into fields, chords with Ctrl, Meta
18
18
  * or Alt, IME composition and (unless `repeat`) held keys. Pass the same list to `KeysLegend`.
19
19
  */
20
20
  export declare function useHotkeys(shortcuts: Shortcut[] | Record<string, () => void>, { enabled }?: {
@@ -6,7 +6,7 @@ export type LinkCardProps = ({
6
6
  to: To;
7
7
  href?: undefined;
8
8
  } | {
9
- /** Somewhere outside this app; the card shows an arrow. */
9
+ /** Somewhere that is not a route of this app. The card shows an arrow when it is on another origin. */
10
10
  href: string;
11
11
  to?: undefined;
12
12
  }) & {
@@ -16,12 +16,14 @@ export type LinkCardProps = ({
16
16
  description?: string;
17
17
  /** `Status` words about the destination ("Running", "Updated today"). Nothing interactive. */
18
18
  marks?: React.ReactNode;
19
+ /** For an `href`: whether it leaves the site (the arrow). Default: true when its origin is not this page's. */
20
+ external?: boolean;
19
21
  /** The title's element. h3 under a section heading; h2 when the cards are the page's sections. */
20
22
  as?: "h2" | "h3" | "h4";
21
23
  className?: string;
22
24
  };
23
25
  /** A destination as a card that is one link: its title is the link's name, the description and status marks are its description, and the whole card is the target. */
24
- export declare function LinkCard({ title, description, marks, as: Heading, className, ...destination }: LinkCardProps): React.JSX.Element;
26
+ export declare function LinkCard({ title, description, marks, as: Heading, className, external, ...destination }: LinkCardProps): React.JSX.Element;
25
27
  /** A labelled list of `LinkCard`s in a grid: one column on a phone, up to three on a wide screen. */
26
28
  export declare function LinkCardList({ label, children, className }: {
27
29
  label: string;
@@ -0,0 +1,7 @@
1
+ import { Poll } from '../query/poll';
2
+ /** The pause control of a polled screen: a "Pause updates" toggle and when the readings were last taken ("Updated 12:00"). Takes the `Poll` from `usePoll`. */
3
+ export declare function PauseButton({ poll, hideUpdated, className }: {
4
+ poll: Poll;
5
+ hideUpdated?: boolean;
6
+ className?: string;
7
+ }): import('react').JSX.Element;
@@ -0,0 +1,24 @@
1
+ /** A scheduled job as `ScheduleTable` draws it. */
2
+ export type ScheduleRow = {
3
+ /** What the job does, in the product's words: "Nightly backup". Also the row's key, so it is unique. */
4
+ label: string;
5
+ /** The last result: "ok" or "success", "failed" or "failure", or `null` for a job that has not run. Another word is shown as it is, neutrally. */
6
+ result: string | null;
7
+ /** The job is running now: the result then reads "Running". */
8
+ running?: boolean;
9
+ /** When it last ran (ISO string or Date), or `null`. */
10
+ last?: string | Date | null;
11
+ /** When it runs next, or `null` when nothing is scheduled. */
12
+ next?: string | Date | null;
13
+ };
14
+ /** The schedule table's props. */
15
+ export type ScheduleTableProps = {
16
+ /** Names the table: "Scheduled jobs". */
17
+ caption: string;
18
+ rows: ScheduleRow[];
19
+ /** "Now", for `format.ago` (tests and screenshots). */
20
+ now?: Date;
21
+ className?: string;
22
+ };
23
+ /** A table of a machine's scheduled jobs: each one's last result as a word, when it last ran and when it runs next. The last and next columns drop on a phone. */
24
+ export declare function ScheduleTable({ caption, rows, now, className }: ScheduleTableProps): import('react').JSX.Element;
@@ -0,0 +1,58 @@
1
+ import { Poll } from '../query/poll';
2
+ import { Load } from './data-view';
3
+ import { MeterThreshold } from './meter';
4
+ import * as React from "react";
5
+ /** A folder the server watches, as `GET /api/system` reports it. */
6
+ export type SystemFolder = {
7
+ name: string;
8
+ path: string;
9
+ exists: boolean;
10
+ free_bytes: number | null;
11
+ total_bytes: number | null;
12
+ };
13
+ /** A service the app calls, with its health as the service's own health endpoint answered just now. */
14
+ export type SystemService = {
15
+ name: string;
16
+ ok: boolean;
17
+ version?: string | null;
18
+ detail?: string | null;
19
+ url?: string;
20
+ };
21
+ /** What `SystemPanel` draws: the shape of strata-python's `SystemInfo` (the generated schema satisfies it, extra fields and all). */
22
+ export type SystemInfoLike = {
23
+ version: string;
24
+ commit?: string | null;
25
+ python: string;
26
+ platform: string;
27
+ started_at: string;
28
+ folders: SystemFolder[];
29
+ services: SystemService[];
30
+ };
31
+ /** The shared limits for a folder's disk, as shares of its size: filling up at 80%, nearly full at 95%. */
32
+ export declare const diskThresholds: MeterThreshold[];
33
+ /** Reads `GET /api/system` (or another path) as a `Load` for `SystemPanel`, polled when given a `Poll`. Behind a reverse proxy the path is put under the app's base. */
34
+ export declare function useSystemInfo<T extends SystemInfoLike = SystemInfoLike>({ path, poll }?: {
35
+ path?: string;
36
+ poll?: Poll;
37
+ }): Load<T>;
38
+ /** A fact of the server the panel does not know, drawn with the others: a term and its value. */
39
+ export type SystemFact = {
40
+ term: string;
41
+ value: React.ReactNode;
42
+ };
43
+ /** The system panel's props. */
44
+ export type SystemPanelProps = {
45
+ /** The read: `useSystemInfo()`, or `useLoad` on the route with the app's own types. */
46
+ load: Load<SystemInfoLike>;
47
+ /** Limits for a folder's disk, as shares of its size. Default `diskThresholds`. */
48
+ thresholds?: MeterThreshold[];
49
+ /** The app's own facts (greetings kept, queue length), drawn under the server's. */
50
+ facts?: SystemFact[];
51
+ /** "Now", for the uptime (tests and screenshots). */
52
+ now?: Date;
53
+ /** The level of the panel's three headings (Server, Folders, Services). Default 2; a page that wraps the panel in its own `h2` section passes 3 so the outline nests (#348). */
54
+ headingLevel?: 2 | 3 | 4;
55
+ className?: string;
56
+ };
57
+ /** About this server, from `GET /api/system`: version and commit, when it started, each folder's disk as a meter with its state in words, and each service as Up or Down. Loaded through `DataView`, with a skeleton and the stale notice. */
58
+ export declare function SystemPanel({ load, thresholds, facts, now, headingLevel, className }: SystemPanelProps): React.JSX.Element;
@@ -6,6 +6,18 @@ export type ColorSchemePreference = "system" | "light" | "dark";
6
6
  export type ColorScheme = "light" | "dark";
7
7
  /** The localStorage key `ThemeProvider` uses unless given another. */
8
8
  export declare const COLOR_SCHEME_STORAGE_KEY = "strata-color-scheme";
9
+ /** A palette Strata ships: its name (the `data-palette` value) and the words `PaletteChoice` shows. */
10
+ export type PaletteOption = {
11
+ name: string;
12
+ label: string;
13
+ detail?: string;
14
+ };
15
+ /** The palettes in `strata.css`: the default first, then four others. An app that adds its own in CSS passes its own list to `PaletteChoice`. */
16
+ export declare const palettes: readonly PaletteOption[];
17
+ /** The default palette: the plain `:root` look, with no override. */
18
+ export declare const DEFAULT_PALETTE = "petrol";
19
+ /** The localStorage key `ThemeProvider` keeps the palette under unless given another. */
20
+ export declare const PALETTE_STORAGE_KEY = "strata-palette";
9
21
  /** The operating system's colour scheme, kept current as it changes. Light where it cannot be read (the server, jsdom). */
10
22
  export declare function useSystemColorScheme(): ColorScheme;
11
23
  /** What `useColorScheme` returns: the chosen preference, the scheme in effect, and a setter that persists the choice. */
@@ -14,13 +26,22 @@ export type ColorSchemeState = {
14
26
  scheme: ColorScheme;
15
27
  setPreference: (preference: ColorSchemePreference) => void;
16
28
  };
29
+ /** What `usePalette` returns: the palette name in effect and a setter that persists it. */
30
+ export type PaletteState = {
31
+ palette: string;
32
+ setPalette: (palette: string) => void;
33
+ };
17
34
  /** Sets the `.dark` class strata.css keys on, from a system, light or dark preference that persists in localStorage when it can. */
18
- export declare function ThemeProvider({ children, defaultPreference, storageKey, target, density, }: {
35
+ export declare function ThemeProvider({ children, defaultPreference, storageKey, defaultPalette, paletteStorageKey, target, density, }: {
19
36
  children: React.ReactNode;
20
37
  /** The preference before a person has chosen one. */
21
38
  defaultPreference?: ColorSchemePreference;
22
39
  /** Where the choice is kept in localStorage; `null` keeps it for this visit only. */
23
40
  storageKey?: string | null;
41
+ /** The palette before a person has chosen one: a `data-palette` name from `palettes` (or the app's own). Left out, the default palette. */
42
+ defaultPalette?: string;
43
+ /** Where the palette is kept in localStorage; `null` keeps it for this visit only. */
44
+ paletteStorageKey?: string | null;
24
45
  /**
25
46
  * The element that gets the `.dark` class; the document's root element when left out. A nested
26
47
  * target can turn a light page's panel dark, not the reverse: strata.css keys dark on any
@@ -59,3 +80,27 @@ export declare function ColorSchemeChoice({ legend, labels, compact, className,
59
80
  /** Layout at the call site (compact only). */
60
81
  className?: string;
61
82
  }): React.JSX.Element;
83
+ /** The palette in effect and a setter that persists it. Must be inside `ThemeProvider`. */
84
+ export declare function usePalette(): PaletteState;
85
+ /**
86
+ * The body of an inline `<script>` for the page's `<head>` that sets `data-palette` before the first paint
87
+ * from the stored choice, so a page does not flash the default palette while the bundle loads. Pass the
88
+ * same key and default as the `ThemeProvider`; put it beside `colorSchemeScript()`.
89
+ */
90
+ export declare function paletteScript(storageKey?: string, defaultPalette?: string): string;
91
+ /**
92
+ * The palettes as radio buttons, bound to the nearest `ThemeProvider`, each with a swatch drawn in its own
93
+ * palette (primary and the one warm accent) so the colours are seen before they are chosen. A list for a
94
+ * settings page, or `compact` swatches named "Palette" for a header. The words are always present (the
95
+ * list shows them, the compact form names each swatch and shows the same words as a tooltip).
96
+ */
97
+ export declare function PaletteChoice({ legend, options, compact, className, }: {
98
+ /** The group's name, as the page words it. Defaults to "Palette". */
99
+ legend?: string;
100
+ /** The palettes offered: names that `strata.css` (or the app's own CSS) defines under `data-palette`, with their words. Defaults to `palettes`. */
101
+ options?: readonly PaletteOption[];
102
+ /** Swatches only, for a header or footer, for an app with no settings page. */
103
+ compact?: boolean;
104
+ /** Layout at the call site (compact only). */
105
+ className?: string;
106
+ }): React.JSX.Element;
@@ -1,4 +1,4 @@
1
- import { d as cn, l as Tooltip$1 } from "./field-QCCmWTuY.js";
1
+ import { d as cn, l as Tooltip$1 } from "./field-jfhLD5XX.js";
2
2
  import * as React from "react";
3
3
  import { Button } from "react-aria-components";
4
4
  import { cva } from "class-variance-authority";
@@ -198,4 +198,4 @@ function errorPayload(error) {
198
198
  }
199
199
  export { fieldErrorsOf as a, IconButton as c, isDev as d, errorPayload as i, RowAction as l, describeActionError as n, readErrorBody as o, describeHttpError as r, Button$1 as s, HttpError as t, buttonVariants as u };
200
200
 
201
- //# sourceMappingURL=errors-D99YX4XL.js.map
201
+ //# sourceMappingURL=errors-D0TsKLwJ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-D99YX4XL.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, \"aria-busy\": ariaBusy, ...props }: ButtonProps) {\n // React Aria's button drops `aria-busy` (it forwards only the aria props it knows), so it is set\n // on the element here; a pending row action says it is busy to a screen reader (issue #248).\n const ref = React.useRef<HTMLButtonElement>(null);\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n if (ariaBusy) el.setAttribute(\"aria-busy\", String(ariaBusy));\n else el.removeAttribute(\"aria-busy\");\n }, [ariaBusy]);\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 ref={ref}\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 /** The structured part of the body (`ErrorBody.payload` of the shared contract): what the app can act on, such as what is already running on a 409. Typed by the caller with `errorPayload`. */\n payload?: unknown;\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 /** The body's `payload`, when it has one (`{ detail, payload }`): data for the app, not words for the person. Read it typed with `errorPayload`. */\n readonly payload?: unknown;\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 this.payload = found.payload;\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 const payload = b.payload !== undefined && b.payload !== null ? { payload: b.payload } : {};\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, ...payload };\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, ...payload };\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\n/** The payload of an error from the server as the type the app expects (`errorPayload<{ running: string }>(error)`), or `undefined` when it is not an `HttpError` or carries none. The type is the caller's claim: check it against the API's schema. */\nexport function errorPayload<T>(error: unknown): T | undefined {\n return error instanceof HttpError ? (error.payload as T | undefined) : undefined;\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,QAAiB;CAC/B,IAAI;EACF,OAAA,QAAA,IAAA,aAAgC;CAClC,QAAQ;EACN,OAAO;CACT;AACF;;ACaA,IAAa,iBAAiB,IAC5B,oRACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,SAAS;GACT,WAAW;GACX,OAAO;GACP,aAAa;GACb,MAAM;EACR;EACA,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,MAAM;GACN,WAAW;EACb;CACF;CACA,iBAAiB;EAAE,SAAS;EAAW,MAAM;CAAU;AACzD,CACF;;;;;;;AAoBA,SAAgBA,SAAO,EAAE,WAAW,SAAS,MAAM,OAAO,UAAU,UAAU,UAAU,aAAa,UAAU,GAAG,SAAsB;CAGtI,MAAM,MAAM,MAAM,OAA0B,IAAI;CAChD,MAAM,gBAAgB;EACpB,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,IAAI,UAAU,GAAG,aAAa,aAAa,OAAO,QAAQ,CAAC;OACtD,GAAG,gBAAgB,WAAW;CACrC,GAAG,CAAC,QAAQ,CAAC;CACb,IAAI,MAAM,GAAG,WAAW,OAAkC,QAAQ;CAGlE,OACE,oBAACC,QAAD;EACO;EACC;EACN,YAAY;EACZ,gBAAc,WAAW;EACzB,WAAW,GAAG,eAAe;GAAE;GAAS;EAAK,CAAC,GAAG,SAAS;EAC1D,GAAK;EAGJ,UAAA,OAAO,aAAa,WAAW,oBAAC,QAAD;GAAM,WAAU;GAAoB;EAAe,CAAA,IAAI;CAC7E,CAAA;AAEhB;;AAGA,SAAS,WAAW,OAAgC,UAA2B;CAC7E,IAAI,MAAM,UAAU,KAAA,KAAa,CAAC,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AAW,KAAM,EAAE,MAAkC,OAAO,IAAI,KAAA;CAC7G,OAAO;EAAE,QAAQ,KAAK,EAAE,MAAM,KAAK,KAAK,EAAE,OAAO,KAAK,KAAK,EAAE,KAAK,KAAK;EAAQ,GAAG;CAAQ;AAC5F;;AAMA,IAAM,YAAY,MAAe,UAAU,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE;AAE9D,SAAS,QAAQ,OAAkB;CACjC,IAAI,MAAM,QAAQ,OAAO,4BAA4B,SAAS,MAAM,MAAM;CAC1E,IAAI,OAAO,KAAK,MAAM,WAAW,CAAC,CAAC,QAAQ,OAAO;CAClD,OAAO,4BAA4B,MAAM,OAAO,KAAK,MAAM,cAAc,kBAAkB;AAC7F;;AAGA,IAAa,qBAAoC,UAC/C,iBAAiB,YACb,MAAM,UAAU,MACd,gCAAgC,MAAM,OAAO,2BAC7C,QAAQ,KAAK,IACf,iBAAiB,SAAS,MAAM,UAC9B,MAAM,UACN;;AAGR,IAAa,uBAAuB,UAClC,iBAAiB,YACb,MAAM,UAAU,MACd,gCAAgC,MAAM,OAAO,MAC7C,QAAQ,KAAK,IACf,iBAAiB,SAAS,MAAM,UAC9B,MAAM,UACN,KAAA;;AAGR,SAAgB,cAAc,OAAkD;CAC9E,OAAO,iBAAiB,YAAY,MAAM,cAAc,CAAC;AAC3D;;AAGA,SAAgB,aAAgB,OAA+B;CAC7D,OAAO,iBAAiB,YAAa,MAAM,UAA4B,KAAA;AACzE"}
1
+ {"version":3,"file":"errors-D0TsKLwJ.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, \"aria-busy\": ariaBusy, ...props }: ButtonProps) {\n // React Aria's button drops `aria-busy` (it forwards only the aria props it knows), so it is set\n // on the element here; a pending row action says it is busy to a screen reader (issue #248).\n const ref = React.useRef<HTMLButtonElement>(null);\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n if (ariaBusy) el.setAttribute(\"aria-busy\", String(ariaBusy));\n else el.removeAttribute(\"aria-busy\");\n }, [ariaBusy]);\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 ref={ref}\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 /** The structured part of the body (`ErrorBody.payload` of the shared contract): what the app can act on, such as what is already running on a 409. Typed by the caller with `errorPayload`. */\n payload?: unknown;\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 /** The body's `payload`, when it has one (`{ detail, payload }`): data for the app, not words for the person. Read it typed with `errorPayload`. */\n readonly payload?: unknown;\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 this.payload = found.payload;\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 const payload = b.payload !== undefined && b.payload !== null ? { payload: b.payload } : {};\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, ...payload };\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, ...payload };\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\n/** The payload of an error from the server as the type the app expects (`errorPayload<{ running: string }>(error)`), or `undefined` when it is not an `HttpError` or carries none. The type is the caller's claim: check it against the API's schema. */\nexport function errorPayload<T>(error: unknown): T | undefined {\n return error instanceof HttpError ? (error.payload as T | undefined) : undefined;\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,QAAiB;CAC/B,IAAI;EACF,OAAA,QAAA,IAAA,aAAgC;CAClC,QAAQ;EACN,OAAO;CACT;AACF;;ACaA,IAAa,iBAAiB,IAC5B,oRACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,SAAS;GACT,WAAW;GACX,OAAO;GACP,aAAa;GACb,MAAM;EACR;EACA,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,MAAM;GACN,WAAW;EACb;CACF;CACA,iBAAiB;EAAE,SAAS;EAAW,MAAM;CAAU;AACzD,CACF;;;;;;;AAoBA,SAAgBA,SAAO,EAAE,WAAW,SAAS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AGR,IAAa,uBAAuB,UAClC,iBAAiB,YACb,MAAM,UAAU,MACd,gCAAgC,MAAM,OAAO,MAC7C,QAAQ,KAAK,IACf,iBAAiB,SAAS,MAAM,UAC9B,MAAM,UACN,KAAA;;AAGR,SAAgB,cAAc,OAAkD;CAC9E,OAAO,iBAAiB,YAAY,MAAM,cAAc,CAAC;AAC3D;;AAGA,SAAgB,aAAgB,OAA+B;CAC7D,OAAO,iBAAiB,YAAa,MAAM,UAA4B,KAAA;AACzE"}
@@ -290,20 +290,27 @@ function ChoiceGroupView({ legend, name, choices, value, onChange, error }) {
290
290
  choices.map((c) => /* @__PURE__ */ jsxs(Radio, {
291
291
  value: c.value,
292
292
  className: "group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1",
293
- children: [/* @__PURE__ */ jsx("span", {
294
- "aria-hidden": true,
295
- className: "mt-1 grid size-4 shrink-0 place-items-center rounded-pill border border-input bg-background transition-state group-selected:border-primary group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-ring",
296
- children: /* @__PURE__ */ jsx("span", { className: "size-2 rounded-pill bg-primary opacity-0 group-selected:opacity-100" })
297
- }), /* @__PURE__ */ jsxs("span", {
298
- className: "grid",
299
- children: [/* @__PURE__ */ jsx("span", {
300
- className: "type-body",
301
- children: c.label
302
- }), c.detail && /* @__PURE__ */ jsx("span", {
303
- className: "type-body-sm text-muted-foreground",
304
- children: c.detail
305
- })]
306
- })]
293
+ children: [
294
+ /* @__PURE__ */ jsx("span", {
295
+ "aria-hidden": true,
296
+ className: "mt-1 grid size-4 shrink-0 place-items-center rounded-pill border border-input bg-background transition-state group-selected:border-primary group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-ring",
297
+ children: /* @__PURE__ */ jsx("span", { className: "size-2 rounded-pill bg-primary opacity-0 group-selected:opacity-100" })
298
+ }),
299
+ c.leading && /* @__PURE__ */ jsx("span", {
300
+ className: "mt-0.5 shrink-0",
301
+ children: c.leading
302
+ }),
303
+ /* @__PURE__ */ jsxs("span", {
304
+ className: "grid",
305
+ children: [/* @__PURE__ */ jsx("span", {
306
+ className: "type-body",
307
+ children: c.label
308
+ }), c.detail && /* @__PURE__ */ jsx("span", {
309
+ className: "type-body-sm text-muted-foreground",
310
+ children: c.detail
311
+ })]
312
+ })
313
+ ]
307
314
  }, c.value)),
308
315
  error && /* @__PURE__ */ jsxs("p", {
309
316
  id: errorId,
@@ -318,4 +325,4 @@ function ChoiceGroupView({ legend, name, choices, value, onChange, error }) {
318
325
  }
319
326
  export { Textarea as a, useSearchParam as c, cn as d, typeSteps as f, NativeSelect as i, Tooltip$1 as l, Field as n, useFieldControl as o, Input$1 as r, controlHeight as s, ChoiceGroup as t, KeyText as u };
320
327
 
321
- //# sourceMappingURL=field-QCCmWTuY.js.map
328
+ //# sourceMappingURL=field-jfhLD5XX.js.map