strata-react 1.0.43 → 1.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/UPGRADING.md +7 -0
- package/dist/components/button.d.ts +1 -1
- package/dist/components/job-action.d.ts +30 -0
- package/dist/components/job-status.d.ts +11 -1
- package/dist/components/selectable-grid.d.ts +21 -3
- package/dist/components/tile-grid.d.ts +3 -1
- package/dist/components/toast.d.ts +2 -0
- package/dist/components/tree.d.ts +20 -1
- package/dist/components/view-options.d.ts +105 -0
- package/dist/{errors-ByjNcEDc.js → errors-BXSbhx2s.js} +11 -3
- package/dist/errors-BXSbhx2s.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3259 -2648
- package/dist/index.js.map +1 -1
- package/dist/panorama.js +1 -1
- package/dist/{query-ib0ScvU2.js → query-V0TFPCcC.js} +7 -2
- package/dist/query-V0TFPCcC.js.map +1 -0
- package/dist/testing.js +1 -1
- package/dist/{value-controls-DxbyeTQd.js → value-controls-VNFdKanU.js} +5 -3
- package/dist/value-controls-VNFdKanU.js.map +1 -0
- package/package.json +1 -1
- package/dist/errors-ByjNcEDc.js.map +0 -1
- package/dist/query-ib0ScvU2.js.map +0 -1
- package/dist/value-controls-DxbyeTQd.js.map +0 -1
package/README.md
CHANGED
|
@@ -151,10 +151,10 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
|
|
|
151
151
|
|---|---|---|
|
|
152
152
|
| Actions | `Button`, `IconButton`, `RowAction`, `AsyncButton`, `useAsyncAction` | Default is `outline`; one filled button per view; `IconButton` requires `label`; `RowAction` is named for its row ("Withdraw Tom Ellery"); `AsyncButton` keeps one width through idle, pending, done and error, and announces `error` with its retry label; buttons carry `data-variant` and `AsyncButton` `data-phase` for tests; a `title` is refused (type `never`, and a development warning): a tip is a `Tooltip`, or `IconButton`'s `label` and `hint`; `useAsyncAction` returns `{ phase, run, error, thrown, fieldErrors, clearFieldError }` with a stable `run`, describes an `HttpError` in a sentence with the server's own reason for a 4xx (`describeActionError`, or the product's own `describeError`), and `validate` plus a server's 422 put messages on `fieldErrors` for each `Field` |
|
|
153
153
|
| Form | `Field`, `Input`, `Textarea`, `NativeSelect`, `ChoiceGroup`, `Checkbox` | `Field` wires label, hint, error, `aria-describedby`, `aria-invalid`, and `action` puts a one-field form's button on the control's row with the hint and error under both; `Checkbox` requires `label` and is one target with it, and has a mixed state |
|
|
154
|
-
| Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar` | A status is always a word; figures have no icons or sparklines; `Meter` is a `meter` named for what it measures, with its reading in words ("72% used"), threshold notches, and a `Status` word once a threshold is crossed (each threshold must name its state); `CompositionBar` is a stacked bar over a table naming every part, its amount and share, and names the remainder (`total` needs `restLabel`); a part that is there reads "<1%" and keeps a sliver, never "0%"; `JobStatus` is a long-running server job: a required word per state beside the app's sentence, a progress bar when the total is known, each failure named with its reason, announced only when the item changes or the job ends |
|
|
154
|
+
| Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar` | 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 |
|
|
155
155
|
| Data | `DataView`, `Load<T>`, `Stale`, `StaleNotice`, `LoadError`, `EmptyState`, `Skeleton`, `Thumbnail`, `ThumbnailSkeleton`, `DataTable`, `TableSkeleton`, `VirtualList`, `InfiniteList`, `LoadMore`, `useInView`, `LineChart` | `DataView` requires skeleton and empty, keeps data on screen under a `StaleNotice` (why, how old, Try again) when a refresh fails, and takes an `error` renderer for an app's own look of a failed read (default `LoadError`, always inside an alert); `Thumbnail` is a remote image in a box of fixed `aspect`, with a skeleton while it loads, the required `missing` words (or a `fallback` drawing, such as an avatar's initial) when it fails or `src` is null, required `alt`, `children` overlaid in its corners, and a request only once it nears the screen (`eager` for the first few); tables, lists and tile grids virtualise from 100 rows, on React Aria's Virtualizer; a `DataTable` is a React Aria table (a `grid`) over TanStack Table's data model; a `DataTable` column with `value` sorts by type with missing values last both ways and draws a placeholder (`missing`, default an en dash); `InfiniteList` loads the next page on approach, with a skeleton for it, a Try again row when it fails and a Show more button for the keyboard, and `scroll="page"` draws a grid that scrolls with the page; `LoadMore` is that next-page row for any list or grid; charts label values directly; `LineChart` can also follow an app's position (`current`), read a value at the pointer or by arrow keys (`readout`, one slider whose value text is the reading), report a picked x (`onPick`) and fill one flat area (`area`); `xLabel` names the x column of its table `Thumbnail`'s `src` may be a list tried in order, `onLoad` can reject a picture that loaded (a host's grey placeholder) and `onMissing` is told once when none worked; with `alt=""` and a `fallback` its missing state is presentational. `LoadMore` and `InfiniteList` can draw the Show more and loading rows the app's way (`more`, `loading`, and `ruled={false}` for no hairlines). |
|
|
156
156
|
| Compare | `Compare`, `PairVote`, `PairJudge`, `CompareAudio`, `CompareText`, `CompareGrid`, `CompareVideoGrid`, `ViewportFrame`, `useViewport`, `FullscreenFrame`, `useDifference`, `differences` | Two pictures judged together: side by side, swipe (a divider that moves from the keyboard), fade, blink (`x` flips) and difference (a live difference blend with amplify, or pixelmatch's changed pixels with a tolerance and the share that differ; pixels are read only when that view is open, at most 2048 px on the long side, and a picture the browser will not let the page read says so in words); `maxHeight="fit"` measures the window for the pair and its surroundings instead of the `"viewport"` guess; `CompareGrid` is every candidate at once with the same zoom and full screen, and `actions` for what a tile offers; one zoom and pan for both sides (buttons, `+` `-` `0`, Ctrl-wheel or trackpad pinch, drag, arrow keys, double click, `1:1`), and full screen (the browser's Fullscreen API, a modal where there is none). `blind` is required: a blind comparison names pictures by `label` only and never writes the variant `id`, `note` or `alt`. A picture that fails shows the required `missing` words in its place; the keys come from one `Shortcut[]` shared with `KeysLegend`, and `keys={false}` leaves them to a surrounding screen. `PairVote` wraps `Compare` for a blind pairwise judgment: answer keys `a` `b` `t` `s` in Compare's one legend, a vote bar with no filled button, `pending`, a flag menu, a progress line, preload and Undo, and click to choose (a click on the picture you prefer, not a drag or double click; in swipe the side of the divider, in blink the side showing, none in fade or difference; `onPick` on `Compare` and `CompareVideo`, `pick={false}` turns it off). `CompareAudio` is one transport for two clips with an A/B switch that keeps the playhead (same time, or the same share when the lengths differ), a loop range and loudness matching (the louder clip turned down to the quieter, by RMS); `CompareText` is two texts scrolled together with a word diff and an optional reference; `PairJudge` is the answering around any of them; `CompareVideo` is two videos on one clock (play, pause, seek and speed drive both, the follower kept within a frame, both held while either waits for data) in side by side, swipe, fade and blink, with zoom and pan locked and nearest-neighbour pixels past 1:1, candidates of different sizes drawn in one box, one soundtrack (`audio`), and the same slots as the rest. `autoPlay` starts the pair once both can play (muted; not with reduced motion unless `"always"`) and `loopWhole` loops the whole clip when no range is set (also on `CompareVideoGrid`). Frame by frame (`,` `.`), a loop range the app can hold (`i` `o` `c`), speeds down to 0.1 and named `moments` are in it; `CompareVideoGrid` is every candidate's video at once on that one clock (one transport, one zoom, regions, a loop, stepping), light on the browser (metadata only until the first play, cells out of sight paused and left out of the sync, sound off unless `audio` names a cell, a cell that falls behind marked "Catching up"), with an optional `reference` drawn first, never blind and nearest-neighbour. `regions` (on `Compare`, `CompareVideo` and `CompareGrid`) names boxes in the source's coordinates to look at enlarged: chips, keys `q` `w` `e` `r` `y` `u`, nearest-neighbour drawing, the box outlined while its chip is pointed at, and Shift-drag to make another |
|
|
157
|
-
| Selection | `useSelection`, `useChoices`, `BulkBar`, `SelectableGrid`, `DataTable`'s `selection` (`RowSelection<T>`) | Opt-in checkbox column with "Select all shown" that respects `isSelectable`; Shift-click or Shift+Space chooses or clears the run from the last row clicked, in the order shown; `initial` (keys or a test on the row) chooses a row the first time it appears, so it applies to data that loads later; the selection drops rows that are gone; `BulkBar` announces the count politely, and while it is up its one filled action is the view's only one (the screen's primary goes to `outline`); `SelectableGrid` is the same selection as a grid of pictures (`renderImage`), each tile one labelled target, virtualised from 100 tiles. A choice can imply others: `implies(key)` (on `useSelection`, and `useChoices` for a lazy tree) keeps what the person chose apart from what that brings in, follows it through, locks the implied keys (they only clear with what implied them), and gives `implied`, `because(key)`, `counts`, a `note` for the live region and `summary(noun, then)`, the line a destructive confirm can carry ("12 results will be forgotten: 8 chosen, 4 that depend on them") |
|
|
157
|
+
| Selection | `useSelection`, `useChoices`, `BulkBar`, `SelectableGrid`, `DataTable`'s `selection` (`RowSelection<T>`) | Opt-in checkbox column with "Select all shown" that respects `isSelectable`; Shift-click or Shift+Space chooses or clears the run from the last row clicked, in the order shown; `initial` (keys or a test on the row) chooses a row the first time it appears, so it applies to data that loads later; the selection drops rows that are gone; `BulkBar` announces the count politely, and while it is up its one filled action is the view's only one (the screen's primary goes to `outline`); `SelectableGrid` is the same selection as a grid of pictures (`renderImage`), each tile one labelled target, virtualised from 100 tiles; as a photo grid it takes a pixel `tileSize` zoomed by Ctrl/Cmd+wheel, `+` and `-` (`onTileSizeChange`), `selectionMode` and `selectionBehavior` (`replace` is the Finder's rules; `onAction` opens), `groupBy` (sticky headings with a group box and a fold), a corner `badge`, `unselectableReason`, and counts what a filter hides ("3 chosen are hidden by the filter"); `ViewOptions` with `useViewOptions` is the one toolbar for how it is looked at: sort (natural order, direction named for the key), group, size slider, aspect, grid or list and a filter with its count, kept in `localStorage` and optionally `?sort=…&group=…&size=…`, a "View" popover on a phone. A choice can imply others: `implies(key)` (on `useSelection`, and `useChoices` for a lazy tree) keeps what the person chose apart from what that brings in, follows it through, locks the implied keys (they only clear with what implied them), and gives `implied`, `because(key)`, `counts`, a `note` for the live region and `summary(noun, then)`, the line a destructive confirm can carry ("12 results will be forgotten: 8 chosen, 4 that depend on them") |
|
|
158
158
|
| Expansion | `Disclosure`, `useExpanded`, `DataTable`'s `expansion` (`RowExpansion<T>`) | Show more of one row in place. The toggle is a button with `aria-expanded`; the body is mounted only while open, so a request inside it runs on first open (unlike `<details>`, which mounts every closed body); `useExpanded({ param })` shares the open keys across a list or table and keeps them in the URL; a table's detail row spans the data columns and is measured when virtualised |
|
|
159
159
|
| Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `useInfiniteLoad`, `useJob`, `toLoad`, `staleOf`, `fetchJson`, `HttpError`, `readErrorBody`, `fieldErrorsOf` | TanStack Query in, `Load<T>` out; a refetch that fails after a good read stays `ready` with `stale` set, never an error panel; `useInfiniteLoad` works out the cursor itself (after the last item held), merges pages by key and can `dismiss` an item at once; `useJob` polls a job's status only while it runs and invalidates the queries it changes once, when it ends; `fetchJson` reads an error response's body onto the `HttpError` (`body`, `reason`, `fieldErrors`, read by `readErrorBody` or the API's own `readError`) |
|
|
160
160
|
| Page and navigation | `AppShell`, `SideNav`, `Breadcrumb`, `Tabs`, `PageHeader`, `LinkCard`, `LinkCardList` | React Router; tab and sort state in the URL; a `LinkCard` is one link named by its title, described by its text and `Status` marks, with the whole card as the target (`to` a route, `href` elsewhere, marked with an arrow) |
|
|
@@ -176,7 +176,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
|
|
|
176
176
|
| Conversation | `Conversation`, `Composer`, `RichText`; `matchEntities`, `parseRichText` | A question-and-answer thread: answers stream, finish or fail in place (Try again), one polite announcement per finished answer, following only while at the bottom (Jump to latest); a composer that sends on Enter and is disabled with its reason while answering (Stop); a safe text subset (bold, code, lists, http links, never HTML) whose known ids, longest first and whole words only, become buttons |
|
|
177
177
|
| Pictures from a set | `Lightbox` (`useLightboxUrl`), `BookViewer` (`useBookUrl`), `TileGrid`, `BoxOverlay`/`BoxList`/`useBoxes`, `RegionEditor`; `moveRect`, `resizeRect`, `lerpRect`, `turnedSize`, `turnRect`, `readingOrder`, `zoomToBox`, `findPage` | A picture opened from a grid in a full-size `Dialog` (previous/next, arrow keys, "3 of 40" or a position like "Page 22 (12) of 44", zoom and 1:1, details beside it, an overlay and actions for the item, a thumbnail strip, `?view=` in the URL, neighbours preloaded, a `missing` sentence, Compare ticked hand-off); a scanned book read inline as spreads or single pages with printed and scan names, go-to, `?page=` and a strip with badges; a grid of picture tiles that link (`TileGrid`, with `TileGridSkeleton`); read-only boxes on a picture linked to a list beside it; `RegionEditor` also turns the picture by an angle (the windows turn with it) and edits a spread's gutter; named windows drawn and moved on a picture by pointer, keys and numbers, with aspect and bounds held, and a from/to move with a Watch preview |
|
|
178
178
|
| Sequences | `SequenceTimeline`; `snapToGrid`, `stepOnGrid`, `settleCut` | A gapless strip of windows whose cuts are sliders: dragged or stepped along a beat grid inside the room the app gives, the refusal said in words, both windows' new lengths announced; Shift+click chooses a run |
|
|
179
|
-
| Browsing | `Tree`, `FolderPicker` | A hierarchy that loads as it opens (a hook per open node; skeleton, Try again and empty rows; always virtualised); `choices` (from `useChoices`) chooses several: a checkbox per row, Shift ranges, a parent drawn mixed from what has loaded under it (ticking a branch never opened reads and opens it and chooses everything under it), "Select all shown", and rows the choice implies marked "Included because of …" in words and a server folder chooser on it: breadcrumb that is also editable text, Up, recents, New folder with the server's refusal on the field, Choose this folder; a `Folder` may carry a `badge` and `tone` ("project", as words), `canChoose` gives the reason the button is disabled beside it, `chooseLabel` names it, `onOpen` can answer `"choose"` to take a folder at once instead of entering it, and the listing may return a `footer` under the tree |
|
|
179
|
+
| Browsing | `Tree`, `FolderPicker` | A hierarchy that loads as it opens (`current` + `onCurrentChange` is the row in view beside the ticked ones, `count` and `badge` per row, `sortChildren`, `reveal` of a deep link, `resolveBranch` so ticking a year says "2019 and its 91 folders" without opening them; a hook per open node; skeleton, Try again and empty rows; always virtualised); `choices` (from `useChoices`) chooses several: a checkbox per row, Shift ranges, a parent drawn mixed from what has loaded under it (ticking a branch never opened reads and opens it and chooses everything under it), "Select all shown", and rows the choice implies marked "Included because of …" in words and a server folder chooser on it: breadcrumb that is also editable text, Up, recents, New folder with the server's refusal on the field, Choose this folder; a `Folder` may carry a `badge` and `tone` ("project", as words), `canChoose` gives the reason the button is disabled beside it, `chooseLabel` names it, `onOpen` can answer `"choose"` to take a folder at once instead of entering it, and the listing may return a `footer` under the tree |
|
|
180
180
|
| Marking text | `MarkableText`, `Mark`, `MarkSummary`; `rangeBetween` | Select words by drag, Shift+click and Shift+arrows (ids in document order, so it holds across virtualised rows), apply the app's marks from a bar or single-key chords, marks drawn by role, pattern and text, summarised and announced |
|
|
181
181
|
| Maps | `strata-react/map`: `RouteMap`; `geo`, `LatLng` (main entry) | Routes and a position that moves along them, on Leaflet (no react-leaflet), behind its own entry. Tiles are the app's (`tiles.light`, `tiles.dark`, each with its attribution); the dark scheme uses the dark set or a filter over the light one. Route colours are roles resolved at draw time; `values` with `colourScale` colour a route by value in runs of one step, with a key that names the steps; a single route gets direction chevrons and start/finish marks (a loop is one mark). The position is one marker moved with `setLatLng`: no route is redrawn for it (keep `routes` stable). As picture content (a route inset over footage): `zoom` sets any zoom (animate it per frame), `follow="centre"` holds the view exactly on a position with no animation (a frame is deterministic), and `positions` draws several, each tied to a route, in its colour and named in the text alternative; routes are not redrawn for any of it. Leaflet's keyboard pan and zoom stay; the map is named by `label` and described by a generated text alternative (routes, lengths, position along). Overlay slots `topEnd` and `bottomStart` avoid Leaflet's own controls and attribution. Leaflet's stylesheet is injected once, so an app imports nothing. `geo` (distance, bearing, bounds, `pointAlong`, `arrows`, `ends`) and `format.distance` need no map library |
|
|
182
182
|
| Timeline | `Timeline`, `useTimelineZoom`, `TimelineZoomControls`, `noOverlap` | Items with a start and a length in lanes on a zoomable time axis, for media edits, bookings, rotas and plans. The timeline draws and the app decides: every move, trim, lane change, selection and current-time change is reported (`onItemChange`, `onSelect`, `onPositionChange`) and the app applies it; `validate` refuses a change with a reason shown in words while it is made. One tab stop for the items; arrows move between them, Ctrl+arrows nudge and change lane, Alt+arrows trim, the current time is its own slider, `+` `-` `0` zoom, and each change is announced ("run-02.mp4 moved to 0:13"). The ruler picks steps people write on a scale so labels never collide. Lanes take drops from outside (`dropTypes`, `onDrop` with the lane and snapped time, `validateDrop`, and React Aria's keyboard drag landing at the current time), `laneRows` makes them taller, `kindColours` fixes each kind's stripe, and the header column fits its content. Only items near the view are rendered |
|
package/UPGRADING.md
CHANGED
|
@@ -11,6 +11,13 @@ time. While the version is 0.x, any release may break.
|
|
|
11
11
|
|
|
12
12
|
Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Changelog").
|
|
13
13
|
|
|
14
|
+
## After v1.0.43 (2026-11-14)
|
|
15
|
+
|
|
16
|
+
- `toast.show(...)` with no `StrataToastRegion` mounted warns once in development ("nothing will be drawn") and still queues the toast; an app that called it before its region mounted will see the warning, and `renderWithStrata` keeps its region on by default so a test is unchanged.
|
|
17
|
+
- A pending `AsyncButton` (and any `Button` given `aria-busy`) now carries `aria-busy="true"` on the element; React Aria's button had been dropping it. A test that matched the button's attributes exactly may need the new one.
|
|
18
|
+
- `Toolbar` leaves Home and End to a slider inside it (they went to the first and last control before).
|
|
19
|
+
- `SelectableGrid`: a `tileSize` may be a number of pixels; with `groupBy` the grid is not virtualised and each group is its own list (an arrow key stops at a group's edge). A grid that sets none of the new props is unchanged.
|
|
20
|
+
|
|
14
21
|
## After v1.0.42 (2026-11-14)
|
|
15
22
|
|
|
16
23
|
- `strata-visual` serves an app build's `index.html` with `<base href="/">` (the target's `base`) added when the page has no base tag, as python-app-template's server does, so a build with `base: './'` finds its assets on a nested route; drop a `visual` Vite mode that injected the tag yourself (it is left alone if the page already has one).
|
|
@@ -23,7 +23,7 @@ export type ButtonProps = Omit<React.ComponentProps<"button">, "className" | "st
|
|
|
23
23
|
* `outline`; ask for the filled accent (`variant="default"`) once per view. `type` defaults to `button`.
|
|
24
24
|
* `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.
|
|
25
25
|
*/
|
|
26
|
-
export declare function Button({ className, variant, size, type, disabled, children, ...props }: ButtonProps): React.JSX.Element;
|
|
26
|
+
export declare function Button({ className, variant, size, type, disabled, children, "aria-busy": ariaBusy, ...props }: ButtonProps): React.JSX.Element;
|
|
27
27
|
export type IconButtonProps = Omit<ButtonProps, "size" | "children" | "aria-label"> & {
|
|
28
28
|
/** `sm` is --control-h-sm, the height of a small `Toggle` or `Button`, for a toolbar or property row. Default --control-h. */
|
|
29
29
|
size?: ControlSize;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Job } from '../query/job';
|
|
2
|
+
import { AsyncActionOptions, Phase } from './async-button';
|
|
3
|
+
import { ToastContentProps } from './toast';
|
|
4
|
+
/** Options for `useJobAction`. */
|
|
5
|
+
export type JobActionOptions<A extends unknown[], R, S> = Pick<AsyncActionOptions<A>, "onError" | "describeError" | "validate" | "onInvalid"> & {
|
|
6
|
+
/** Starts the job (the POST). What it returns is given to `queued`. */
|
|
7
|
+
start: (...args: A) => Promise<R>;
|
|
8
|
+
/** The job's status, from `useJob`. Its `running` drives the busy phase and the finished toast. */
|
|
9
|
+
job: Job<S>;
|
|
10
|
+
/** The toast when the job is queued: "Scan queued", from what `start` returned. */
|
|
11
|
+
queued: (result: R) => Pick<ToastContentProps, "title" | "description">;
|
|
12
|
+
/** The toast when the job ends, from its last status: "Scan finished", "12 of 14 scanned". Return `null` for none. */
|
|
13
|
+
done: (status: S) => Pick<ToastContentProps, "title" | "description" | "tone"> | null;
|
|
14
|
+
/** The page that shows jobs: the queued toast gets an action that goes there. */
|
|
15
|
+
jobsHref?: string;
|
|
16
|
+
/** The queued toast's action. Default "Show jobs". */
|
|
17
|
+
jobsLabel?: string;
|
|
18
|
+
};
|
|
19
|
+
/** What `useJobAction` returns: the phase and `run` for `AsyncButton`, and why starting failed. */
|
|
20
|
+
export type JobAction<A extends unknown[]> = {
|
|
21
|
+
/** `pending` while starting and while the job runs, `error` if it could not start, else `idle`. */
|
|
22
|
+
phase: Phase;
|
|
23
|
+
run: (...args: A) => Promise<void>;
|
|
24
|
+
/** Why the job could not be started, in the product's words, while `phase` is `error`. */
|
|
25
|
+
error: string | undefined;
|
|
26
|
+
/** The job this button started is still running. */
|
|
27
|
+
running: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** One call for a button that starts a server job: busy until the job ends, a queued toast linking to the jobs page, a finished toast with the result, and a failure to start shown on the button. */
|
|
30
|
+
export declare function useJobAction<A extends unknown[], R, S>({ start, job, queued, done, jobsHref, jobsLabel, ...asyncOptions }: JobActionOptions<A, R, S>): JobAction<A>;
|
|
@@ -5,6 +5,14 @@ export type JobFailure = {
|
|
|
5
5
|
label: string;
|
|
6
6
|
reason: string;
|
|
7
7
|
};
|
|
8
|
+
/** How far a job has got, in the one shape every job uses (issue #250): items done, items in all, and what it is on now. `JobStatus` renders it as "3 of 9 done, 6 remaining · Night Sky". */
|
|
9
|
+
export type JobProgress = {
|
|
10
|
+
done: number;
|
|
11
|
+
total: number;
|
|
12
|
+
current?: string;
|
|
13
|
+
};
|
|
14
|
+
/** The sentence for a job's progress: "3 of 9 done, 6 remaining · Night Sky". */
|
|
15
|
+
export declare function jobProgressText({ done, total, current }: JobProgress): string;
|
|
8
16
|
/** A job's three states as words, all required: "Syncing", "Finished", "Finished with failures". */
|
|
9
17
|
export type JobWords = {
|
|
10
18
|
running: string;
|
|
@@ -21,6 +29,8 @@ export type JobStatusProps = {
|
|
|
21
29
|
words: JobWords;
|
|
22
30
|
/** The app's sentence for where the job is or how it went: "Syncing 2 of 3: Night Sky." */
|
|
23
31
|
summary: string;
|
|
32
|
+
/** How far it has got, in the shared shape (`{ done, total, current }`): the bar and the sentence "3 of 9 done, 6 remaining · Night Sky" under the summary. Wins over `current` and `total`. */
|
|
33
|
+
progress?: JobProgress;
|
|
24
34
|
/** Items done or being done, with `total`, for the bar. */
|
|
25
35
|
current?: number;
|
|
26
36
|
/** Items in all, when known. No bar without it. */
|
|
@@ -42,4 +52,4 @@ export type JobStatusProps = {
|
|
|
42
52
|
className?: string;
|
|
43
53
|
};
|
|
44
54
|
/** A long-running server job: its state as a required word beside the app's sentence, a progress bar when the total is known, each failure named with its reason, and a polite announcement only when the item changes or the job ends. */
|
|
45
|
-
export declare function JobStatus({ label, running, words, summary, current, total, failures, failed, failuresLabel, cancelled, onCancel, cancelLabel, onDismiss, className, }: JobStatusProps): React.JSX.Element;
|
|
55
|
+
export declare function JobStatus({ label, running, words, summary, progress, current: currentProp, total: totalProp, failures, failed, failuresLabel, cancelled, onCancel, cancelLabel, onDismiss, className, }: JobStatusProps): React.JSX.Element;
|
|
@@ -15,8 +15,26 @@ export type SelectableGridProps<T> = {
|
|
|
15
15
|
selection: RowSelection<T>;
|
|
16
16
|
/** Default `square`. `portrait` is 3:4, `landscape` 4:3. */
|
|
17
17
|
aspect?: TileAspect;
|
|
18
|
-
/** Default `md`. */
|
|
19
|
-
tileSize?: TileSize;
|
|
18
|
+
/** Default `md`. Pixels for a continuous size: the minimum tile width, growing to fill the row. */
|
|
19
|
+
tileSize?: TileSize | number;
|
|
20
|
+
/** Asked to change the size by Ctrl/Cmd+wheel, `+` and `-`. Give a `useViewOptions` size back to `tileSize`; omit to leave the size fixed. */
|
|
21
|
+
onTileSizeChange?: (px: number) => void;
|
|
22
|
+
/** Tiles' smallest and largest width for those zooms, in px. Default 64 and 320. */
|
|
23
|
+
zoomRange?: readonly [min: number, max: number];
|
|
24
|
+
/** How many tiles can be chosen: `none` makes a grid to look at and open, `single` one tile. Default `multiple`. */
|
|
25
|
+
selectionMode?: "none" | "single" | "multiple";
|
|
26
|
+
/** `toggle` (default): a press toggles. `replace`: a press chooses that tile only, Ctrl/Cmd toggles, Shift extends. */
|
|
27
|
+
selectionBehavior?: "toggle" | "replace";
|
|
28
|
+
/** Opens a tile: Enter, or a double click with `selectionBehavior="replace"`. */
|
|
29
|
+
onAction?: (row: T) => void;
|
|
30
|
+
/** A corner badge on the picture (top right): a `Status`. */
|
|
31
|
+
badge?: (row: T) => React.ReactNode;
|
|
32
|
+
/** Puts tiles under sticky headings, in the order the rows first show them. The grid is not virtualised while grouped. */
|
|
33
|
+
groupBy?: (row: T) => string;
|
|
34
|
+
/** The words for a group's heading; default the group text. */
|
|
35
|
+
groupHeading?: (group: string, rows: T[]) => string;
|
|
36
|
+
/** Why a tile `selection.isSelectable` refuses cannot be chosen, in words ("Already in a project"). */
|
|
37
|
+
unselectableReason?: (row: T) => string | undefined;
|
|
20
38
|
/** Tile count from which only the visible rows of tiles render. Default 100. */
|
|
21
39
|
virtualizeFrom?: number;
|
|
22
40
|
/** Height of the scroll region once virtualised, in px. Default 480. */
|
|
@@ -24,4 +42,4 @@ export type SelectableGridProps<T> = {
|
|
|
24
42
|
className?: string;
|
|
25
43
|
};
|
|
26
44
|
/** A grid of pictures to choose from: each tile one labelled target, "Select all shown", Shift-click ranges, virtualised from `virtualizeFrom` tiles. Pair with `useSelection` and a `BulkBar`. */
|
|
27
|
-
export declare function SelectableGrid<T>({ label, rows, rowKey, renderImage, detail, selection, aspect, tileSize, virtualizeFrom, maxHeight, className, }: SelectableGridProps<T>): React.JSX.Element;
|
|
45
|
+
export declare function SelectableGrid<T>({ label, rows, rowKey, renderImage, detail, selection, aspect, tileSize, onTileSizeChange, zoomRange, selectionMode, selectionBehavior, onAction, badge, groupBy, groupHeading, unselectableReason, virtualizeFrom, maxHeight, className, }: SelectableGridProps<T>): React.JSX.Element;
|
|
@@ -6,8 +6,10 @@ export type TileAspect = "square" | "portrait" | "landscape";
|
|
|
6
6
|
export type TileSize = "sm" | "md" | "lg";
|
|
7
7
|
export declare const minWidth: Record<TileSize, number>;
|
|
8
8
|
export declare const aspectClass: Record<TileAspect, string>;
|
|
9
|
+
/** A tile size as pixels: a named size's minimum width, or the number itself (a continuous size, issue #246). */
|
|
10
|
+
export declare const tileWidth: (size: TileSize | number) => number;
|
|
9
11
|
/** `GridLayout` options for tiles of this size and aspect: they grow from the minimum width to fill the row, and each row is as tall as its tallest tile as measured. */
|
|
10
|
-
export declare function tileLayoutOptions(tileSize: TileSize, aspect: TileAspect): {
|
|
12
|
+
export declare function tileLayoutOptions(tileSize: TileSize | number, aspect: TileAspect): {
|
|
11
13
|
minItemSize: Size;
|
|
12
14
|
minSpace: Size;
|
|
13
15
|
};
|
|
@@ -30,5 +30,7 @@ export type StrataToastRegionProps = {
|
|
|
30
30
|
label?: string;
|
|
31
31
|
className?: string;
|
|
32
32
|
};
|
|
33
|
+
/** For tests: forget that the missing-region warning was given. */
|
|
34
|
+
export declare function resetToastWarnings(): void;
|
|
33
35
|
/** The one place toasts appear. Render it once at the app root; a second one mounted at the same time draws nothing and warns in development. A labelled landmark (F6), polite, above panes and the undo bar. */
|
|
34
36
|
export declare function StrataToastRegion({ label, className }: StrataToastRegionProps): React.JSX.Element | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Tone } from './status';
|
|
1
2
|
import { Choices } from './selection';
|
|
2
3
|
import { Load } from './data-view';
|
|
3
4
|
import { Expanded } from './disclosure';
|
|
@@ -44,10 +45,28 @@ type TreeCommon<N> = {
|
|
|
44
45
|
loadingRow?: React.ReactNode;
|
|
45
46
|
/** What an open node with nothing in it says: "No folders". Required, so an empty branch is never blank. */
|
|
46
47
|
emptyRow: string;
|
|
48
|
+
/** The row in view (not the same as ticked): highlighted, `aria-current`, moved by a press on a row's name or Enter. Works with `selected` or `choices`. */
|
|
49
|
+
current?: string | null;
|
|
50
|
+
onCurrentChange?: (key: string, node: N) => void;
|
|
51
|
+
/** How many items a node holds ("81 pictures"), drawn right aligned in tabular figures and part of the row's name. `null` draws nothing. */
|
|
52
|
+
count?: (node: N) => string | number | null | undefined;
|
|
53
|
+
/** A word on a tint after the name ("in project"), part of the row's name. */
|
|
54
|
+
badge?: (node: N) => {
|
|
55
|
+
label: string;
|
|
56
|
+
tone?: Tone;
|
|
57
|
+
} | null | undefined;
|
|
58
|
+
/** Orders the children of every node, and the top level. */
|
|
59
|
+
sortChildren?: (a: N, b: N) => number;
|
|
60
|
+
/** The keys from the top down to a node to bring into view: its ancestors open and the tree scrolls to it. Give the same array to reveal again. */
|
|
61
|
+
reveal?: readonly string[];
|
|
62
|
+
/** What is under a branch, as keys (not the branch itself), for a branch ticked before it was read. When given, ticking it does not open it: the keys are chosen and the live region says "2019 and its 91 folders". */
|
|
63
|
+
resolveBranch?: (node: N) => Promise<readonly string[]>;
|
|
64
|
+
/** What `resolveBranch`'s keys are, for the live region: `["folder", "folders"]`. Default item, items. */
|
|
65
|
+
coverNoun?: readonly [string, string];
|
|
47
66
|
/** The tallest the tree may be before it scrolls, as a CSS length. Default 24rem. */
|
|
48
67
|
height?: string;
|
|
49
68
|
className?: string;
|
|
50
69
|
};
|
|
51
70
|
/** A hierarchy whose children load as each node opens (a `useChildren` hook per open node): a skeleton row, a Try again row and an "empty" row per node, type-ahead and arrow keys, single selection, open state optionally in the URL, always virtualised. */
|
|
52
|
-
export declare function Tree<N>({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, choices, expanded, beforeOpen, loadingRow, emptyRow, height, className }: TreeProps<N>): React.JSX.Element;
|
|
71
|
+
export declare function Tree<N>({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, choices, current, onCurrentChange, count, badge, sortChildren, reveal, resolveBranch, coverNoun, expanded, beforeOpen, loadingRow, emptyRow, height, className }: TreeProps<N>): React.JSX.Element;
|
|
53
72
|
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { TileAspect } from './tile-grid';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/** A way to order rows. */
|
|
4
|
+
export type ViewSort<T> = {
|
|
5
|
+
key: string;
|
|
6
|
+
/** What the menu calls it: "Date taken". */
|
|
7
|
+
label: string;
|
|
8
|
+
/** The value to order by. `null` or `undefined` sorts last either way. */
|
|
9
|
+
value: (row: T) => string | number | Date | null | undefined;
|
|
10
|
+
/** Words for the direction buttons, from the key's own sense: `["Oldest first", "Newest first"]`. Default "Ascending", "Descending". */
|
|
11
|
+
directions?: readonly [ascending: string, descending: string];
|
|
12
|
+
/** The direction a person gets on first choosing this key. Default ascending. */
|
|
13
|
+
defaultDescending?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** A way to put rows into groups. */
|
|
16
|
+
export type ViewGroup<T> = {
|
|
17
|
+
key: string;
|
|
18
|
+
/** What the menu calls it: "Hour". */
|
|
19
|
+
label: string;
|
|
20
|
+
/** The group a row belongs to; the groups come out in the order the sorted rows first show them. */
|
|
21
|
+
of: (row: T) => string;
|
|
22
|
+
/** The heading drawn for a group; default the group's own text. */
|
|
23
|
+
heading?: (group: string) => string;
|
|
24
|
+
};
|
|
25
|
+
/** What `useViewOptions` takes. */
|
|
26
|
+
export type ViewOptionsConfig<T> = {
|
|
27
|
+
/** Names this view in `localStorage` (`strata-view:{id}`): "browser-grid". Required, so two screens do not share a size. */
|
|
28
|
+
id: string;
|
|
29
|
+
sorts?: readonly ViewSort<T>[];
|
|
30
|
+
/** Key of the sort a first visit starts with, and whether it starts descending. Default the first. */
|
|
31
|
+
defaultSort?: {
|
|
32
|
+
key: string;
|
|
33
|
+
descending?: boolean;
|
|
34
|
+
};
|
|
35
|
+
groups?: readonly ViewGroup<T>[];
|
|
36
|
+
/** Key of the group a first visit starts with; default none. */
|
|
37
|
+
defaultGroup?: string | null;
|
|
38
|
+
/** The tile width range in px; give it to get the size slider. */
|
|
39
|
+
size?: {
|
|
40
|
+
min: number;
|
|
41
|
+
max: number;
|
|
42
|
+
step?: number;
|
|
43
|
+
default: number;
|
|
44
|
+
};
|
|
45
|
+
aspects?: readonly TileAspect[];
|
|
46
|
+
defaultAspect?: TileAspect;
|
|
47
|
+
/** Offer grid or list. */
|
|
48
|
+
layouts?: boolean;
|
|
49
|
+
/** The text the filter matches in a row (everything a person would search for); give it to get the filter box. */
|
|
50
|
+
filterText?: (row: T) => string;
|
|
51
|
+
/** Keep sort, group and size in the address too (`?sort=taken-desc&group=hour&size=180`). Needs a router. Fixed for the life of the component. */
|
|
52
|
+
url?: boolean | {
|
|
53
|
+
sort?: string;
|
|
54
|
+
group?: string;
|
|
55
|
+
size?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/** One group of rows. */
|
|
59
|
+
export type ViewGroupRows<T> = {
|
|
60
|
+
key: string;
|
|
61
|
+
heading: string;
|
|
62
|
+
rows: T[];
|
|
63
|
+
};
|
|
64
|
+
/** The state `useViewOptions` returns, with the rows it applies to. */
|
|
65
|
+
export type ViewOptionsState<T> = {
|
|
66
|
+
config: ViewOptionsConfig<T>;
|
|
67
|
+
sort: string | null;
|
|
68
|
+
descending: boolean;
|
|
69
|
+
group: string | null;
|
|
70
|
+
size: number;
|
|
71
|
+
aspect: TileAspect;
|
|
72
|
+
layout: "grid" | "list";
|
|
73
|
+
query: string;
|
|
74
|
+
setSort: (key: string) => void;
|
|
75
|
+
setDescending: (descending: boolean) => void;
|
|
76
|
+
setGroup: (key: string | null) => void;
|
|
77
|
+
setSize: (size: number) => void;
|
|
78
|
+
setAspect: (aspect: TileAspect) => void;
|
|
79
|
+
setLayout: (layout: "grid" | "list") => void;
|
|
80
|
+
setQuery: (query: string) => void;
|
|
81
|
+
/** Filter by the text, then sort: the rows to draw. */
|
|
82
|
+
apply: (rows: readonly T[]) => T[];
|
|
83
|
+
/** The same rows in groups when a group key is chosen; one group, no heading, when none. */
|
|
84
|
+
grouped: (rows: readonly T[]) => ViewGroupRows<T>[];
|
|
85
|
+
/** The line beside the filter: "82 of 140" while filtering, "140" otherwise (pass the full and filtered counts). */
|
|
86
|
+
countText: (shown: number, total: number) => string;
|
|
87
|
+
/** Back to the defaults (not the filter). */
|
|
88
|
+
reset: () => void;
|
|
89
|
+
};
|
|
90
|
+
/** Rows ordered by a key: natural string order, `null` last whichever way, ties kept in their order. Exported for a screen that orders without the toolbar. */
|
|
91
|
+
export declare function sortRows<T>(rows: readonly T[], value: (row: T) => string | number | Date | null | undefined, descending?: boolean): T[];
|
|
92
|
+
/** The view's state: sort and direction, group, tile size, aspect, layout and a text filter, kept in `localStorage` and (with `url`) the address, and applied to rows with `apply` and `grouped`. Draw it with `ViewOptions`; feed the result to `SelectableGrid`. */
|
|
93
|
+
export declare function useViewOptions<T>(config: ViewOptionsConfig<T>): ViewOptionsState<T>;
|
|
94
|
+
/** Props for `ViewOptions`. */
|
|
95
|
+
export type ViewOptionsProps<T> = {
|
|
96
|
+
view: ViewOptionsState<T>;
|
|
97
|
+
/** How many rows pass the filter, and how many there are; for "82 of 140". Omit with no filter. */
|
|
98
|
+
shown?: number;
|
|
99
|
+
total?: number;
|
|
100
|
+
/** Names the toolbar. Default "View options". */
|
|
101
|
+
label?: string;
|
|
102
|
+
className?: string;
|
|
103
|
+
};
|
|
104
|
+
/** The one toolbar for a `useViewOptions` state: sort menu and direction, group menu, size slider (`-`/`+` keys), aspect, grid or list, and a filter with its count. One tab stop; on a phone all but the filter fold into a "View" popover. */
|
|
105
|
+
export declare function ViewOptions<T>({ view, shown, total, label, className }: ViewOptionsProps<T>): React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as Tooltip$1, u as cn } from "./field-DeKNvGox.js";
|
|
2
|
-
import "react";
|
|
2
|
+
import * as React from "react";
|
|
3
3
|
import { Button } from "react-aria-components";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -41,9 +41,17 @@ var buttonVariants = cva("inline-flex max-w-full shrink-0 cursor-pointer items-c
|
|
|
41
41
|
* `outline`; ask for the filled accent (`variant="default"`) once per view. `type` defaults to `button`.
|
|
42
42
|
* `onClick` and `disabled` are the DOM names and keep working; `onPress` is also accepted.
|
|
43
43
|
*/
|
|
44
|
-
function Button$1({ className, variant, size, type = "button", disabled, children, ...props }) {
|
|
44
|
+
function Button$1({ className, variant, size, type = "button", disabled, children, "aria-busy": ariaBusy, ...props }) {
|
|
45
|
+
const ref = React.useRef(null);
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
const el = ref.current;
|
|
48
|
+
if (!el) return;
|
|
49
|
+
if (ariaBusy) el.setAttribute("aria-busy", String(ariaBusy));
|
|
50
|
+
else el.removeAttribute("aria-busy");
|
|
51
|
+
}, [ariaBusy]);
|
|
45
52
|
if (isDev()) warnOnLoss(props, children);
|
|
46
53
|
return /* @__PURE__ */ jsx(Button, {
|
|
54
|
+
ref,
|
|
47
55
|
type,
|
|
48
56
|
isDisabled: disabled,
|
|
49
57
|
"data-variant": variant ?? "outline",
|
|
@@ -176,4 +184,4 @@ function fieldErrorsOf(error) {
|
|
|
176
184
|
}
|
|
177
185
|
export { readErrorBody as a, RowAction as c, fieldErrorsOf as i, buttonVariants as l, describeActionError as n, Button$1 as o, describeHttpError as r, IconButton as s, HttpError as t, isDev as u };
|
|
178
186
|
|
|
179
|
-
//# sourceMappingURL=errors-
|
|
187
|
+
//# sourceMappingURL=errors-BXSbhx2s.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-BXSbhx2s.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};\n\n/** Thrown by `fetchJson` on a non-2xx response; carries the status, the response body and the server's reason for `describeHttpError` and `describeActionError`. */\nexport class HttpError extends Error {\n /** The server's sentence for why it refused, from the body (`detail`, `message`, `error`), if it gave one. */\n readonly reason?: string;\n /** Messages for individual fields from the body (FastAPI's 422 `detail: [{loc, msg}]`), keyed by field name. Empty when there are none. */\n readonly fieldErrors: Readonly<Record<string, string>>;\n\n constructor(\n readonly status: number,\n readonly statusText: string,\n readonly url: string,\n /** The response body: parsed JSON when it was JSON, else its text; undefined when empty. */\n readonly body?: unknown,\n found: ErrorBody = readErrorBody(body),\n ) {\n super(`${status} ${statusText} from ${url}`);\n this.name = \"HttpError\";\n this.reason = found.reason;\n this.fieldErrors = found.fields ?? {};\n }\n}\n\nconst text = (value: unknown) => (typeof value === \"string\" && value.trim() ? value.trim() : undefined);\n\n/** A field name from a FastAPI/pydantic `loc`: the path after where it came from (`[\"body\", \"address\", \"city\"]` is `\"address.city\"`). */\nfunction fieldName(loc: unknown) {\n if (!Array.isArray(loc)) return undefined;\n const path = loc.map(String);\n if ([\"body\", \"query\", \"path\", \"header\", \"cookie\", \"form\"].includes(path[0]) && path.length > 1) path.shift();\n return path.join(\".\") || undefined;\n}\n\n/**\n * The default reading of an error body, for the shapes most JSON APIs use: `{ detail: \"…\" }`\n * (FastAPI), `{ message: \"…\" }`, `{ error: \"…\" }` or `{ error: { message: \"…\" } }` for the reason,\n * and FastAPI's validation list `{ detail: [{ loc, msg }] }` for per-field messages. A short\n * plain-text body (not HTML) is taken as the reason too. Pass your own to `fetchJson` for other APIs.\n */\nexport function readErrorBody(body: unknown): ErrorBody {\n if (typeof body === \"string\") {\n const t = text(body);\n return t && t.length <= 300 && !t.startsWith(\"<\") ? { reason: t } : {};\n }\n if (!body || typeof body !== \"object\") return {};\n const b = body as Record<string, unknown>;\n if (Array.isArray(b.detail)) {\n const fields: Record<string, string> = {};\n for (const item of b.detail as unknown[]) {\n const entry = item as { loc?: unknown; msg?: unknown } | null;\n const name = fieldName(entry?.loc);\n const msg = text(entry?.msg);\n if (name && msg && !fields[name]) fields[name] = msg;\n }\n return { fields };\n }\n const nested = b.error && typeof b.error === \"object\" ? text((b.error as Record<string, unknown>).message) : undefined;\n return { reason: text(b.detail) ?? text(b.message) ?? text(b.error) ?? nested };\n}\n\n/** Writes an error for a person: what happened, in a sentence. A product passes its own words. */\nexport type DescribeError = (error: unknown) => string;\n\n/** A sentence ends once: \"…absolute path\" and \"…absolute path.\" both end in one full stop. */\nconst sentence = (s: string) => (/[.!?…]$/.test(s) ? s : `${s}.`);\n\nfunction refused(error: HttpError) {\n if (error.reason) return `The request was refused: ${sentence(error.reason)}`;\n if (Object.keys(error.fieldErrors).length) return \"The request was refused: check the fields marked.\";\n return `The request was refused (${error.status}): ${error.statusText || \"no reason given\"}.`;\n}\n\n/** The default `DescribeError` for loads: the HTTP status in a sentence (with the server's reason for a 4xx), else the error's message, else a plain fallback. */\nexport const describeHttpError: DescribeError = (error) =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}). Nothing was changed.`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : \"The data could not be loaded. Nothing was changed.\";\n\n/** The default for `useAsyncAction`: the HTTP status in a sentence (with the server's reason for a 4xx), else the thrown Error's message, else undefined (the retry label alone). */\nexport const describeActionError = (error: unknown): string | undefined =>\n error instanceof HttpError\n ? error.status >= 500\n ? `The server could not answer (${error.status}).`\n : refused(error)\n : error instanceof Error && error.message\n ? error.message\n : undefined;\n\n/** Messages for individual fields carried by what was thrown: an `HttpError`'s `fieldErrors`, else none. */\nexport function fieldErrorsOf(error: unknown): Readonly<Record<string, string>> {\n return error instanceof HttpError ? error.fieldErrors : {};\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,QAAiB;CAC/B,IAAI;EACF,OAAA,QAAA,IAAA,aAAgC;CAClC,QAAQ;EACN,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,OAAO,IAAI,OAAO,GAAG;EACrD,OAAO,IAAI,OAAO;EAClB,QAAQ,KAAK,kMAAkM;CACjN;CACA,MAAM,QAAQ,OAAO,aAAa,WAAW,SAAS,KAAK,IAAI;CAC/D,IAAI,SAAS,MAAM,KAAK,KAAK,CAAC,CAAC,WAAW,KAAK,CAAC,gBAAgB,KAAK,KAAK,KAAK,CAAC,MAAM,iBAAiB,CAAC,MAAM,sBAAsB,CAAC,OAAO,IAAI,OAAO,GAAG;EACxJ,OAAO,IAAI,OAAO;EAClB,QAAQ,KAAK,iDAAiD,MAAM,oFAAoF;CAC1J;AACF;AACA,IAAM,yBAAS,IAAI,IAAY;;AAgB/B,SAAgB,WAAW,EAAE,MAAM,MAAM,OAAO,MAAM,UAAU,SAAS,OAAO,WAAW,GAAG,SAA0B;CACtH,OACE,oBAACC,WAAD;EAAgB;EAAa;EAC3B,UAAA,oBAACF,UAAD;GAAQ,MAAM,SAAS,OAAO,YAAY;GAAiB;GAAS,cAAY;GAAO,GAAI;GACzF,UAAA,oBAAC,MAAD,EAAM,eAAA,KAAa,CAAA;EACb,CAAA;CACD,CAAA;AAEb;;AAmBA,SAAgB,UAAU,EAAE,OAAO,SAAS,MAAM,MAAM,UAAU,SAAS,OAAO,MAAM,WAAW,GAAG,SAAyB;CAG7H,OACE,qBAACA,UAAD;EAAiB;EAAe;EAAM,cAAY,GAAG,MAAM,GAAG;EAAW,WAAW,GAAG,WAAW,SAAS;EAAG,GAAI;EAAlH,UAAA,CACG,QAAQ,oBAAC,MAAD,EAAM,eAAA,KAAa,CAAA,GAC3B,KACK;;AAEZ;;;ACrIA,IAAa,YAAb,cAA+B,MAAM;CAOxB;CACA;CACA;CAEA;;CATX;;CAEA;CAEA,YACE,QACA,YACA,KAEA,MACA,QAAmB,cAAc,IAAI,GACrC;EACA,MAAM,GAAG,OAAO,GAAG,WAAW,QAAQ,KAAK;EAPlC,KAAA,SAAA;EACA,KAAA,aAAA;EACA,KAAA,MAAA;EAEA,KAAA,OAAA;EAIT,KAAK,OAAO;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,cAAc,MAAM,UAAU,CAAC;CACtC;AACF;AAEA,IAAM,QAAQ,UAAoB,OAAO,UAAU,YAAY,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,KAAA;;AAG7F,SAAS,UAAU,KAAc;CAC/B,IAAI,CAAC,MAAM,QAAQ,GAAG,GAAG,OAAO,KAAA;CAChC,MAAM,OAAO,IAAI,IAAI,MAAM;CAC3B,IAAI;EAAC;EAAQ;EAAS;EAAQ;EAAU;EAAU;CAAM,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,KAAK,SAAS,GAAG,KAAK,MAAM;CAC3G,OAAO,KAAK,KAAK,GAAG,KAAK,KAAA;AAC3B;;;;;;;AAQA,SAAgB,cAAc,MAA0B;CACtD,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,IAAI,KAAK,IAAI;EACnB,OAAO,KAAK,EAAE,UAAU,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC;CACvE;CACA,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO,CAAC;CAC/C,MAAM,IAAI;CACV,IAAI,MAAM,QAAQ,EAAE,MAAM,GAAG;EAC3B,MAAM,SAAiC,CAAC;EACxC,KAAK,MAAM,QAAQ,EAAE,QAAqB;GACxC,MAAM,QAAQ;GACd,MAAM,OAAO,UAAU,OAAO,GAAG;GACjC,MAAM,MAAM,KAAK,OAAO,GAAG;GAC3B,IAAI,QAAQ,OAAO,CAAC,OAAO,OAAO,OAAO,QAAQ;EACnD;EACA,OAAO,EAAE,OAAO;CAClB;CACA,MAAM,SAAS,EAAE,SAAS,OAAO,EAAE,UAAU,WAAW,KAAM,EAAE,MAAkC,OAAO,IAAI,KAAA;CAC7G,OAAO,EAAE,QAAQ,KAAK,EAAE,MAAM,KAAK,KAAK,EAAE,OAAO,KAAK,KAAK,EAAE,KAAK,KAAK,OAAO;AAChF;;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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,8 @@ export { SecretField, type SecretFieldProps, type SecretTestResult } from './com
|
|
|
33
33
|
export { Alert, type AlertProps } from './components/alert';
|
|
34
34
|
export { toast, toastTimeout, StrataToastRegion, type ToastContentProps, type StrataToastRegionProps } from './components/toast';
|
|
35
35
|
export { useClientWork, type ClientWork, type WorkContext, type WorkPhase } from './lib/client-work';
|
|
36
|
-
export { JobStatus, type JobStatusProps, type JobFailure, type JobWords } from './components/job-status';
|
|
36
|
+
export { JobStatus, jobProgressText, type JobStatusProps, type JobFailure, type JobProgress, type JobWords } from './components/job-status';
|
|
37
|
+
export { useJobAction, type JobAction, type JobActionOptions } from './components/job-action';
|
|
37
38
|
export { Thumbnail, ThumbnailSkeleton, type ThumbnailProps, type AspectRatio } from './components/thumbnail';
|
|
38
39
|
export { DataTable, TableSkeleton, parseSort, serialiseSort, type CellValue, type Column, type Sort, type DataTableProps, type RowSelection, type RowExpansion, } from './components/data-table';
|
|
39
40
|
export { MediaPlayer, useMediaElement, useAttachedSource, SPEECH_RATES, type MediaPlayerProps, type MediaElementState, type MediaElementOptions, type MediaWindow, type StreamContext, type StreamAttachment, type SourceAttacher, type MediaProblem, type MediaSource, type MediaSession } from './components/media-player';
|
|
@@ -54,6 +55,7 @@ export { Disclosure, useExpanded, type DisclosureProps, type DisclosureOpenProps
|
|
|
54
55
|
export { BulkBar, useSelection, useChoices, type InitialSelection, type Choices, type ChoiceCounts } from './components/selection';
|
|
55
56
|
export type { Implies } from './lib/choice';
|
|
56
57
|
export { SelectableGrid, type SelectableGridProps, type TileAspect, type TileSize, } from './components/selectable-grid';
|
|
58
|
+
export { ViewOptions, useViewOptions, sortRows, type ViewOptionsProps, type ViewOptionsConfig, type ViewOptionsState, type ViewSort, type ViewGroup, type ViewGroupRows } from './components/view-options';
|
|
57
59
|
export { TileGrid, TileGridSkeleton, type TileGridProps } from './components/tile-grid';
|
|
58
60
|
export { VirtualList } from './components/virtual-list';
|
|
59
61
|
export { InfiniteList, LoadMore, type InfiniteListProps, type LoadMoreProps } from './components/infinite-list';
|