strata-react 1.3.16 → 1.3.18
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 +2 -2
- package/UPGRADING.md +2 -0
- package/dist/components/box-overlay.d.ts +3 -1
- package/dist/components/boxed-picture.d.ts +34 -0
- package/dist/components/thumbnail.d.ts +6 -1
- package/dist/{errors-D0TsKLwJ.js → errors-jep2voNI.js} +42 -3
- package/dist/errors-jep2voNI.js.map +1 -0
- package/dist/{format-BNkXVwFx.js → field-t4Hoer0d.js} +327 -2
- package/dist/field-t4Hoer0d.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +89 -325
- package/dist/index.js.map +1 -1
- package/dist/lib/boxes.d.ts +23 -0
- package/dist/map.js +2 -3
- package/dist/map.js.map +1 -1
- package/dist/microphone-B5ITwm4G.js +697 -0
- package/dist/microphone-B5ITwm4G.js.map +1 -0
- package/dist/panorama.js +3 -2
- package/dist/panorama.js.map +1 -1
- package/dist/testing.js +4 -2
- package/dist/testing.js.map +1 -1
- package/dist/{theme-CFBAYaiu.js → theme-DXacprlw.js} +2 -2
- package/dist/{theme-CFBAYaiu.js.map → theme-DXacprlw.js.map} +1 -1
- package/dist/{value-controls-WRXbtUp6.js → value-controls-DB5l5Qe2.js} +4 -44
- package/dist/value-controls-DB5l5Qe2.js.map +1 -0
- package/package.json +1 -1
- package/dist/errors-D0TsKLwJ.js.map +0 -1
- package/dist/field-jfhLD5XX.js +0 -328
- package/dist/field-jfhLD5XX.js.map +0 -1
- package/dist/format-BNkXVwFx.js.map +0 -1
- package/dist/microphone-CZy0bNEx.js +0 -339
- package/dist/microphone-CZy0bNEx.js.map +0 -1
- package/dist/value-controls-WRXbtUp6.js.map +0 -1
package/README.md
CHANGED
|
@@ -218,7 +218,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
|
|
|
218
218
|
| Streams | `MediaPlayer attach`/`growing`, `useAttachedSource`, `attachHls` (`strata-react/hls`) | A source the element cannot play is attached by an engine; a source still being made says so, shows what exists as ready, and waits at its end without ending |
|
|
219
219
|
| 360 | `PanoramaViewer` (`strata-react/panorama`), `project`, `unproject`, `describeView` | A 360 picture or video as a controlled window (yaw, pitch, field of view), drag, wheel, pinch and keys, an overlay in the picture's coordinates, said in words, a flat fallback with no WebGL2 |
|
|
220
220
|
| 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); answers can carry pictures (`images`, labelled, lazy, linked to full size) that stay visible beside the collapsed "looked up"; 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 |
|
|
221
|
-
| 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 |
|
|
221
|
+
| Pictures from a set | `Lightbox` (`useLightboxUrl`), `BookViewer` (`useBookUrl`), `TileGrid`, `BoxOverlay`/`BoxList`/`useBoxes`, `BoxedPicture`, `RegionEditor`; `regionStyle`, `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, and the picture opened zoomed to one of them (a face in its photo, `BoxedPicture`); one box of a picture shown on its own in a `Thumbnail` (`region`); `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 |
|
|
222
222
|
| 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 |
|
|
223
223
|
| 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 |
|
|
224
224
|
| 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 |
|
|
@@ -347,7 +347,7 @@ so an app that names none still loads a face. Anything that falls through to
|
|
|
347
347
|
Mac, and a glyph missing from a web font (an arrow, `⌘`) falls back the same way; no threshold
|
|
348
348
|
absorbs that. The runner asks Chromium which face drew each element's text and fails the shot
|
|
349
349
|
naming the face and an example (`"DejaVu Sans" in <kbd> "⌘"`). `systemFonts: "warn"` reports
|
|
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.
|
|
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 (the runner's Chromium also briefly resizes the window to 1×1 during a whole-page capture, so a component that measures its width re-renders then; `Thumbnail` and `FilmStrip` keep their pictures through it), 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.
|
|
351
351
|
Pages run in UTC and `en-US`; set `timezone`, `locale` or a frozen `time` in the config.
|
|
352
352
|
Strata's own suite (`strata-visual.config.ts`, with the kiln-room example app in
|
|
353
353
|
`examples/kiln-app/`) is a working reference.
|
package/UPGRADING.md
CHANGED
|
@@ -12,6 +12,8 @@ time. While the version is 0.x, any release may break.
|
|
|
12
12
|
Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Changelog").
|
|
13
13
|
|
|
14
14
|
## 2026-11-25 (latest)
|
|
15
|
+
- A `Thumbnail` for a picture the page has already loaded now asks for it at once when it mounts again, wherever it is, and shows it as soon as the image is there (a `FilmStrip` after a resize, a re-sorted list), instead of waiting near the screen as a skeleton (#352). `renderWithStrata` and `renderRoutes` reset this per test; a test using plain `render` that expects no request for a repeated `src` before it scrolls near sees one (call `forgetLoadedThumbnails`).
|
|
16
|
+
|
|
15
17
|
- `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
18
|
- `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
19
|
- Visual baselines: `status-and-figures-pausebutton`, `-scheduletable`, `-systempanel` and `navigation-linkcard--same-site` were recorded before the default look and moved to it.
|
|
@@ -26,9 +26,11 @@ export type BoxOverlayProps = {
|
|
|
26
26
|
state: BoxesState;
|
|
27
27
|
/** A box was chosen (a click, Enter or Space): zoom to it, scroll a text pane. The state already holds it. */
|
|
28
28
|
onChoose?: (box: PictureBox) => void;
|
|
29
|
+
/** Fill the pointed or chosen box with its tone's subtle colour. Default `true` (a line of text stays readable under it); `false` for what the box is about to be looked at, such as a face, which only a heavier outline marks. */
|
|
30
|
+
fillLit?: boolean;
|
|
29
31
|
};
|
|
30
32
|
/** Read-only boxes drawn as one SVG layer over a picture, inside `ViewportFrame` so they zoom with it: outline by tone, hover and choice shared with a `BoxList`, one tab stop with arrows in reading order. */
|
|
31
|
-
export declare function BoxOverlay({ label, of, boxes, state, onChoose }: BoxOverlayProps): React.JSX.Element;
|
|
33
|
+
export declare function BoxOverlay({ label, of, boxes, state, onChoose, fillLit }: BoxOverlayProps): React.JSX.Element;
|
|
32
34
|
export type BoxListProps = {
|
|
33
35
|
/** Names the list: "Lines on this page". */
|
|
34
36
|
label: string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BoxesState } from './box-overlay';
|
|
2
|
+
import { PictureBox } from '../lib/boxes';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export type BoxedPictureProps = {
|
|
5
|
+
/** Names the frame: "Photo 2026-03-14 09:12". */
|
|
6
|
+
label: string;
|
|
7
|
+
/** The picture; `null` when there is none (the boxes still show, on the `missing` words). */
|
|
8
|
+
src: string | readonly string[] | null;
|
|
9
|
+
/** What the picture shows, or `""` when `label` says it. */
|
|
10
|
+
alt: string;
|
|
11
|
+
/** The words when the picture cannot be shown: "Photo not kept". */
|
|
12
|
+
missing: string;
|
|
13
|
+
/** The picture's size in pixels; the boxes are in these units. */
|
|
14
|
+
of: {
|
|
15
|
+
w: number;
|
|
16
|
+
h: number;
|
|
17
|
+
};
|
|
18
|
+
boxes: readonly PictureBox[];
|
|
19
|
+
/** From `useBoxes`, shared with a `BoxList` if there is one; its `active` box is the one opened on. */
|
|
20
|
+
state: BoxesState;
|
|
21
|
+
/** Names the layer of boxes: "Faces in this photo". */
|
|
22
|
+
boxesLabel: string;
|
|
23
|
+
/** Zoom to the chosen box when it is chosen and when the picture opens on one. Default `true`. */
|
|
24
|
+
zoom?: boolean;
|
|
25
|
+
/** How much of the box's size to leave around it when zoomed, on every side. Default 0.75 (a face with its hair, shoulders and something of who is beside it). */
|
|
26
|
+
margin?: number;
|
|
27
|
+
/** The tallest the frame may be, as a CSS length. Default `"70svh"`. */
|
|
28
|
+
maxHeight?: string;
|
|
29
|
+
/** A box was chosen in the picture. */
|
|
30
|
+
onChoose?: (box: PictureBox) => void;
|
|
31
|
+
className?: string;
|
|
32
|
+
};
|
|
33
|
+
/** A picture with its boxes drawn on it, opened zoomed to the chosen one (a face in its photo): `ViewportFrame` + `BoxOverlay` + `zoomToBox`, with the picture's missing state. Pair it with a `BoxList` through one `useBoxes`. */
|
|
34
|
+
export declare function BoxedPicture({ label, src, alt, missing, of, boxes, state, boxesLabel, zoom, margin, maxHeight, onChoose, className }: BoxedPictureProps): React.JSX.Element;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { PictureRegion } from '../lib/boxes';
|
|
1
2
|
import * as React from "react";
|
|
3
|
+
/** Forgets which pictures `Thumbnail` has loaded, so a test that checks the loading state starts from nothing. `renderWithStrata` and `renderRoutes` call it. */
|
|
4
|
+
export declare function forgetLoadedThumbnails(): void;
|
|
2
5
|
/** A width-over-height ratio: a number (`1.5`) or a fraction (`"4/3"`). */
|
|
3
6
|
export type AspectRatio = number | `${number}/${number}`;
|
|
4
7
|
/** The thumbnail's props. Either `missing` (the words shown when there is no image) or a `fallback` drawing is required. */
|
|
@@ -23,6 +26,8 @@ export type ThumbnailProps = {
|
|
|
23
26
|
onLoad?: (image: HTMLImageElement, index: number) => boolean | void;
|
|
24
27
|
/** Called once when the thumbnail ends in its missing state after a request failed or was rejected, never for a record with no source. */
|
|
25
28
|
onMissing?: () => void;
|
|
29
|
+
/** Show one box of the picture, filling the thumbnail (a face from a photo): the picture's size, the box in its pixels and `pad`, how many times the box the crop is (default 1.6). `fit` does not apply. */
|
|
30
|
+
region?: PictureRegion;
|
|
26
31
|
/** Overlays drawn above the image in the same box (a running time, a "Saved" badge), in place whether the image has loaded, failed or is missing. */
|
|
27
32
|
children?: React.ReactNode;
|
|
28
33
|
} & ({
|
|
@@ -37,7 +42,7 @@ export type ThumbnailProps = {
|
|
|
37
42
|
fallback: React.ReactNode;
|
|
38
43
|
});
|
|
39
44
|
/** A box of fixed aspect ratio for a remote image: a skeleton until it loads, the `missing` words (or a `fallback`) if it cannot, a request only when it nears the screen, and `children` overlaid in its corners. `alt` and `missing` or `fallback` are required. */
|
|
40
|
-
export declare function Thumbnail({ src, alt, missing, aspect, fit, srcSet, sizes, eager, rootMargin, className, fallback, onLoad, onMissing, children, }: ThumbnailProps): React.JSX.Element;
|
|
45
|
+
export declare function Thumbnail({ src, alt, missing, aspect, fit, srcSet, sizes, eager, rootMargin, className, fallback, onLoad, onMissing, region, children, }: ThumbnailProps): React.JSX.Element;
|
|
41
46
|
/** The loading shape of a `Thumbnail`, for a `DataView` skeleton: the same box and aspect ratio, so nothing moves when the list arrives. */
|
|
42
47
|
export declare function ThumbnailSkeleton({ aspect, className }: {
|
|
43
48
|
aspect?: AspectRatio;
|
|
@@ -1,8 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as cn, l as Tooltip$1 } from "./field-t4Hoer0d.js";
|
|
2
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";
|
|
6
|
+
// src/lib/in-view.ts
|
|
7
|
+
/**
|
|
8
|
+
* Whether an element is within `rootMargin` of its scroll region (the nearest
|
|
9
|
+
* `[data-strata-scroll]` ancestor, else the viewport). Returns a callback ref, so it follows the
|
|
10
|
+
* element as it mounts and unmounts.
|
|
11
|
+
*/
|
|
12
|
+
function useInView({ active = true, rootMargin = "0px", once = false, unsupported = false } = {}) {
|
|
13
|
+
const [inView, setInView] = React.useState(false);
|
|
14
|
+
const [el, setEl] = React.useState(null);
|
|
15
|
+
const seen = once && inView;
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
if (seen) return;
|
|
18
|
+
if (!active || !el) {
|
|
19
|
+
setInView(false);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
23
|
+
setInView(unsupported);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const root = el.parentElement?.closest("[data-strata-scroll]") ?? null;
|
|
27
|
+
const observer = new IntersectionObserver((entries) => setInView(entries[entries.length - 1].isIntersecting), {
|
|
28
|
+
root,
|
|
29
|
+
rootMargin
|
|
30
|
+
});
|
|
31
|
+
observer.observe(el);
|
|
32
|
+
return () => observer.disconnect();
|
|
33
|
+
}, [
|
|
34
|
+
active,
|
|
35
|
+
el,
|
|
36
|
+
rootMargin,
|
|
37
|
+
seen,
|
|
38
|
+
unsupported
|
|
39
|
+
]);
|
|
40
|
+
return {
|
|
41
|
+
ref: setEl,
|
|
42
|
+
inView
|
|
43
|
+
};
|
|
44
|
+
}
|
|
6
45
|
// src/lib/dev.ts
|
|
7
46
|
/** Whether the app is running in development, decided by the app's bundler. */
|
|
8
47
|
function isDev() {
|
|
@@ -196,6 +235,6 @@ function fieldErrorsOf(error) {
|
|
|
196
235
|
function errorPayload(error) {
|
|
197
236
|
return error instanceof HttpError ? error.payload : void 0;
|
|
198
237
|
}
|
|
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 };
|
|
238
|
+
export { fieldErrorsOf as a, IconButton as c, isDev as d, useInView as f, 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
239
|
|
|
201
|
-
//# sourceMappingURL=errors-
|
|
240
|
+
//# sourceMappingURL=errors-jep2voNI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-jep2voNI.js","names":["Button","AriaButton","Tooltip"],"sources":["../src/lib/in-view.ts","../src/lib/dev.ts","../src/components/button.tsx","../src/lib/errors.ts"],"sourcesContent":["import * as React from \"react\";\n\n// One IntersectionObserver hook for everything that waits until it is near the screen: the\n// sentinel at the end of an InfiniteList and an image in a Thumbnail. Both watch from the nearest\n// `[data-strata-scroll]` region (a VirtualList's) or else the viewport, with a root\n// margin so the work starts before the element is reached. They differ in two ways, which are\n// options rather than two hooks:\n//\n// - `once`: an image, once asked for, stays asked for; scrolling it away again must not unload it.\n// A sentinel reports in and out of view every time.\n// - `unsupported`: where there is no IntersectionObserver (an old browser, a test without the\n// fake), an image loads at once, because a photo that never loads is worse than one loaded\n// early. A sentinel reports out of view, because InfiniteList's Show more button is the path\n// that always works.\n\n/** Options for {@link useInView}. */\nexport type InViewOptions = {\n /** Watch only while this is true. Default true. */\n active?: boolean;\n /** How far outside the scroll region still counts as in view (IntersectionObserver `rootMargin`). */\n rootMargin?: string;\n /** Stay in view after the first time, and stop watching. */\n once?: boolean;\n /** What to report where `IntersectionObserver` does not exist. Default false. */\n unsupported?: boolean;\n};\n\n/**\n * Whether an element is within `rootMargin` of its scroll region (the nearest\n * `[data-strata-scroll]` ancestor, else the viewport). Returns a callback ref, so it follows the\n * element as it mounts and unmounts.\n */\nexport function useInView({ active = true, rootMargin = \"0px\", once = false, unsupported = false }: InViewOptions = {}) {\n const [inView, setInView] = React.useState(false);\n const [el, setEl] = React.useState<Element | null>(null);\n const seen = once && inView;\n React.useEffect(() => {\n if (seen) return;\n if (!active || !el) {\n setInView(false);\n return;\n }\n if (typeof IntersectionObserver === \"undefined\") {\n setInView(unsupported);\n return;\n }\n const root = el.parentElement?.closest<HTMLElement>(\"[data-strata-scroll]\") ?? null;\n const observer = new IntersectionObserver((entries) => setInView(entries[entries.length - 1].isIntersecting), { root, rootMargin });\n observer.observe(el);\n return () => observer.disconnect();\n }, [active, el, rootMargin, seen, unsupported]);\n return { ref: setEl, inView };\n}\n","// 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":";;;;;;;;;;;AAgCA,SAAgB,UAAU,EAAE,SAAS,MAAM,aAAa,OAAO,OAAO,OAAO,cAAc,UAAyB,CAAC,GAAG;CACtH,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,KAAK;CAChD,MAAM,CAAC,IAAI,SAAS,MAAM,SAAyB,IAAI;CACvD,MAAM,OAAO,QAAQ;CACrB,MAAM,gBAAgB;EACpB,IAAI,MAAM;EACV,IAAI,CAAC,UAAU,CAAC,IAAI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|
+
import { Label, Radio, RadioGroup, Tooltip, TooltipTrigger } from "react-aria-components";
|
|
5
|
+
import { ArrowBigUp, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ChevronUp, CircleAlert, Command, Option } from "lucide-react";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useSearchParams } from "react-router";
|
|
8
|
+
// src/lib/utils.ts
|
|
9
|
+
var typeSteps = [
|
|
10
|
+
"caption",
|
|
11
|
+
"label",
|
|
12
|
+
"body-sm",
|
|
13
|
+
"body",
|
|
14
|
+
"heading",
|
|
15
|
+
"title",
|
|
16
|
+
"figure",
|
|
17
|
+
"display",
|
|
18
|
+
"picture"
|
|
19
|
+
];
|
|
20
|
+
var twMerge = extendTailwindMerge({ extend: {
|
|
21
|
+
theme: { radius: [...[
|
|
22
|
+
"control",
|
|
23
|
+
"surface",
|
|
24
|
+
"overlay",
|
|
25
|
+
"pill"
|
|
26
|
+
]] },
|
|
27
|
+
classGroups: { "font-size": [{ type: [...typeSteps] }] }
|
|
28
|
+
} });
|
|
29
|
+
/** clsx + tailwind-merge, taught that `type-*` utilities are font sizes and `rounded-control`, `-surface`, `-overlay`, `-pill` are radii. */
|
|
30
|
+
function cn(...inputs) {
|
|
31
|
+
return twMerge(clsx(inputs));
|
|
32
|
+
}
|
|
1
33
|
// src/lib/format.ts
|
|
2
34
|
var NBSP = "\xA0";
|
|
3
35
|
/** The placeholder printed for a value that is not known: an en dash. */
|
|
@@ -257,6 +289,299 @@ function createFormat(locale, options = {}) {
|
|
|
257
289
|
}
|
|
258
290
|
/** The en-GB formatters. */
|
|
259
291
|
var format = createFormat("en-GB");
|
|
260
|
-
|
|
292
|
+
// src/components/key-glyphs.tsx
|
|
293
|
+
var GLYPHS = {
|
|
294
|
+
"←": {
|
|
295
|
+
icon: ArrowLeft,
|
|
296
|
+
name: "left arrow"
|
|
297
|
+
},
|
|
298
|
+
"→": {
|
|
299
|
+
icon: ArrowRight,
|
|
300
|
+
name: "right arrow"
|
|
301
|
+
},
|
|
302
|
+
"↑": {
|
|
303
|
+
icon: ArrowUp,
|
|
304
|
+
name: "up arrow"
|
|
305
|
+
},
|
|
306
|
+
"↓": {
|
|
307
|
+
icon: ArrowDown,
|
|
308
|
+
name: "down arrow"
|
|
309
|
+
},
|
|
310
|
+
"⌘": {
|
|
311
|
+
icon: Command,
|
|
312
|
+
name: "Command"
|
|
313
|
+
},
|
|
314
|
+
"⌃": {
|
|
315
|
+
icon: ChevronUp,
|
|
316
|
+
name: "Control"
|
|
317
|
+
},
|
|
318
|
+
"⌥": {
|
|
319
|
+
icon: Option,
|
|
320
|
+
name: "Option"
|
|
321
|
+
},
|
|
322
|
+
"⇧": {
|
|
323
|
+
icon: ArrowBigUp,
|
|
324
|
+
name: "Shift"
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
var PATTERN = new RegExp(`([${Object.keys(GLYPHS).join("")}])`);
|
|
328
|
+
/** Key text with its arrows and modifier symbols drawn as icons, each with its name for screen readers. Other text is left as it is. */
|
|
329
|
+
function KeyText({ children }) {
|
|
330
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children.split(PATTERN).map((part, i) => {
|
|
331
|
+
const glyph = GLYPHS[part];
|
|
332
|
+
if (!glyph) return part ? /* @__PURE__ */ jsx(React.Fragment, { children: part }, i) : null;
|
|
333
|
+
const Icon = glyph.icon;
|
|
334
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
|
|
335
|
+
"aria-hidden": true,
|
|
336
|
+
className: "inline size-[1em] align-[-0.125em]"
|
|
337
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
338
|
+
className: "sr-only",
|
|
339
|
+
children: [glyph.name, " "]
|
|
340
|
+
})] }, i);
|
|
341
|
+
}) });
|
|
342
|
+
}
|
|
343
|
+
// src/components/tooltip.tsx
|
|
344
|
+
/** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */
|
|
345
|
+
function Tooltip$1({ label, hint, children, side = "top", delay = 500, open, className }) {
|
|
346
|
+
return /* @__PURE__ */ jsxs(TooltipTrigger, {
|
|
347
|
+
delay,
|
|
348
|
+
closeDelay: 0,
|
|
349
|
+
isOpen: open,
|
|
350
|
+
children: [children, /* @__PURE__ */ jsxs(Tooltip, {
|
|
351
|
+
placement: side,
|
|
352
|
+
offset: 6,
|
|
353
|
+
className: cn("layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background", className),
|
|
354
|
+
children: [label, hint != null && /* @__PURE__ */ jsx("span", {
|
|
355
|
+
className: "ml-2 opacity-70",
|
|
356
|
+
children: typeof hint === "string" ? /* @__PURE__ */ jsx(KeyText, { children: hint }) : hint
|
|
357
|
+
})]
|
|
358
|
+
})]
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
// src/lib/search-param.ts
|
|
362
|
+
/**
|
|
363
|
+
* One value held in a URL search parameter (React Router): `const [mode, setMode] = useSearchParam("mode", { default: "all", parse: isMode })`.
|
|
364
|
+
* Reads and validates it, drops the param when set to the default or `null`, keeps the others, and replaces the history entry by default.
|
|
365
|
+
*/
|
|
366
|
+
function useSearchParam(key, { default: fallback, parse, replace = true }) {
|
|
367
|
+
const [params, setParams] = useSearchParams();
|
|
368
|
+
const raw = params.get(key);
|
|
369
|
+
let value = fallback;
|
|
370
|
+
if (raw !== null) {
|
|
371
|
+
const parsed = parse ? parse(raw) : raw;
|
|
372
|
+
if (parsed === true) value = raw;
|
|
373
|
+
else if (typeof parsed === "string") value = parsed;
|
|
374
|
+
}
|
|
375
|
+
const set = React.useCallback((next) => setParams((p) => {
|
|
376
|
+
const out = new URLSearchParams(p);
|
|
377
|
+
if (next === null || next === fallback) out.delete(key);
|
|
378
|
+
else out.set(key, next);
|
|
379
|
+
return out;
|
|
380
|
+
}, { replace }), [
|
|
381
|
+
key,
|
|
382
|
+
fallback,
|
|
383
|
+
replace,
|
|
384
|
+
setParams
|
|
385
|
+
]);
|
|
386
|
+
return [value, set];
|
|
387
|
+
}
|
|
388
|
+
// src/lib/control.ts
|
|
389
|
+
/** The height class of each control size. */
|
|
390
|
+
var controlHeight = {
|
|
391
|
+
default: "h-(--control-h)",
|
|
392
|
+
sm: "h-(--control-h-sm)"
|
|
393
|
+
};
|
|
394
|
+
// src/components/field.tsx
|
|
395
|
+
var FieldContext = React.createContext(null);
|
|
396
|
+
/** @internal The surrounding Field, and where a control reports its own message. */
|
|
397
|
+
function useFieldControl() {
|
|
398
|
+
const field = React.useContext(FieldContext);
|
|
399
|
+
return {
|
|
400
|
+
field,
|
|
401
|
+
report: field?.report ?? noReport
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function useField(id) {
|
|
405
|
+
const field = React.useContext(FieldContext);
|
|
406
|
+
return {
|
|
407
|
+
id: field?.id ?? id,
|
|
408
|
+
"aria-describedby": field?.describedBy,
|
|
409
|
+
"aria-invalid": field?.invalid || void 0
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
var noReport = () => {};
|
|
413
|
+
/** A labelled form field: wires the label, hint, error, `aria-describedby` and `aria-invalid` into the one control it wraps. */
|
|
414
|
+
function Field({ label, id: idProp, hint, error, action, children, className }) {
|
|
415
|
+
const generated = React.useId();
|
|
416
|
+
const id = idProp ?? generated;
|
|
417
|
+
const hintId = hint ? `${id}-hint` : void 0;
|
|
418
|
+
const [reported, report] = React.useState();
|
|
419
|
+
const shown = error ?? reported;
|
|
420
|
+
const errorId = shown ? `${id}-error` : void 0;
|
|
421
|
+
const describedBy = [errorId, hintId].filter(Boolean).join(" ") || void 0;
|
|
422
|
+
return /* @__PURE__ */ jsx(FieldContext.Provider, {
|
|
423
|
+
value: {
|
|
424
|
+
id,
|
|
425
|
+
label,
|
|
426
|
+
describedBy,
|
|
427
|
+
invalid: Boolean(shown),
|
|
428
|
+
report
|
|
429
|
+
},
|
|
430
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
431
|
+
className: cn("grid min-w-0 content-start gap-1.5", className),
|
|
432
|
+
children: [
|
|
433
|
+
/* @__PURE__ */ jsx("label", {
|
|
434
|
+
htmlFor: id,
|
|
435
|
+
className: "type-label text-foreground",
|
|
436
|
+
children: label
|
|
437
|
+
}),
|
|
438
|
+
action ? /* @__PURE__ */ jsxs("div", {
|
|
439
|
+
className: "flex flex-wrap items-start gap-2",
|
|
440
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
441
|
+
className: "min-w-40 flex-1",
|
|
442
|
+
children
|
|
443
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
444
|
+
className: "flex shrink-0 items-center",
|
|
445
|
+
children: action
|
|
446
|
+
})]
|
|
447
|
+
}) : children,
|
|
448
|
+
shown && /* @__PURE__ */ jsxs("p", {
|
|
449
|
+
id: errorId,
|
|
450
|
+
className: "flex items-start gap-1.5 type-body-sm text-danger",
|
|
451
|
+
children: [/* @__PURE__ */ jsx(CircleAlert, {
|
|
452
|
+
"aria-hidden": true,
|
|
453
|
+
className: "mt-0.5 size-4 shrink-0"
|
|
454
|
+
}), shown]
|
|
455
|
+
}),
|
|
456
|
+
hint && /* @__PURE__ */ jsx("p", {
|
|
457
|
+
id: hintId,
|
|
458
|
+
className: "type-body-sm text-muted-foreground",
|
|
459
|
+
children: hint
|
|
460
|
+
})
|
|
461
|
+
]
|
|
462
|
+
})
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
var control = "w-full min-w-0 rounded-control border border-input bg-background px-3 type-body text-foreground transition-state placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-70 aria-invalid:border-danger";
|
|
466
|
+
/** A text input that picks up its id and descriptions from the surrounding `Field`. `size="sm"` is --control-h-sm; the native `size` (a width in characters) is not passed on. */
|
|
467
|
+
function Input$1({ className, id, size = "default", ...props }) {
|
|
468
|
+
return /* @__PURE__ */ jsx("input", {
|
|
469
|
+
...useField(id),
|
|
470
|
+
className: cn(control, controlHeight[size], className),
|
|
471
|
+
...props
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
/** A multi-line input that picks up its id and descriptions from the surrounding `Field`. */
|
|
475
|
+
function Textarea({ className, id, ...props }) {
|
|
476
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
477
|
+
...useField(id),
|
|
478
|
+
className: cn(control, "min-h-24 py-2", className),
|
|
479
|
+
...props
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
/** The platform select, styled. The default for short lists, especially on touch screens. `size="sm"` is --control-h-sm. */
|
|
483
|
+
function NativeSelect(props) {
|
|
484
|
+
return props.param === void 0 ? /* @__PURE__ */ jsx(PlainSelect, { ...props }) : /* @__PURE__ */ jsx(ParamSelect, { ...props });
|
|
485
|
+
}
|
|
486
|
+
function PlainSelect({ className, id, size = "default", ...props }) {
|
|
487
|
+
return /* @__PURE__ */ jsx("select", {
|
|
488
|
+
...useField(id),
|
|
489
|
+
className: cn(control, controlHeight[size], "pr-8", className),
|
|
490
|
+
...props
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
/** The values of every `<option>`, looking inside `<optgroup>`s and fragments. */
|
|
494
|
+
function optionValues(children) {
|
|
495
|
+
return React.Children.toArray(children).flatMap((c) => {
|
|
496
|
+
if (!React.isValidElement(c)) return [];
|
|
497
|
+
if (c.type === "option") return [c.props.value ?? String(c.props.children)];
|
|
498
|
+
return optionValues(c.props.children);
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
function ParamSelect({ param, paramDefault, onChange, children, ...props }) {
|
|
502
|
+
const options = optionValues(children);
|
|
503
|
+
const [value, setValue] = useSearchParam(param, {
|
|
504
|
+
default: paramDefault,
|
|
505
|
+
parse: (raw) => options.length === 0 || options.includes(raw)
|
|
506
|
+
});
|
|
507
|
+
return /* @__PURE__ */ jsx(PlainSelect, {
|
|
508
|
+
...props,
|
|
509
|
+
value,
|
|
510
|
+
onChange: (e) => {
|
|
511
|
+
setValue(e.target.value);
|
|
512
|
+
onChange?.(e.target.value);
|
|
513
|
+
},
|
|
514
|
+
children
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
/** 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. */
|
|
518
|
+
function ChoiceGroup(props) {
|
|
519
|
+
return props.param === void 0 ? /* @__PURE__ */ jsx(ChoiceGroupView, { ...props }) : /* @__PURE__ */ jsx(ParamChoiceGroup, { ...props });
|
|
520
|
+
}
|
|
521
|
+
function ParamChoiceGroup({ param, choices, onChange, ...props }) {
|
|
522
|
+
const [value, setValue] = useSearchParam(param, {
|
|
523
|
+
default: choices[0]?.value ?? "",
|
|
524
|
+
parse: (raw) => choices.some((c) => c.value === raw)
|
|
525
|
+
});
|
|
526
|
+
return /* @__PURE__ */ jsx(ChoiceGroupView, {
|
|
527
|
+
...props,
|
|
528
|
+
choices,
|
|
529
|
+
value,
|
|
530
|
+
onChange: (next) => {
|
|
531
|
+
setValue(next);
|
|
532
|
+
onChange?.(next);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
function ChoiceGroupView({ legend, name, choices, value, onChange, error }) {
|
|
537
|
+
const errorId = React.useId();
|
|
538
|
+
return /* @__PURE__ */ jsxs(RadioGroup, {
|
|
539
|
+
name,
|
|
540
|
+
value,
|
|
541
|
+
onChange,
|
|
542
|
+
"aria-describedby": error ? errorId : void 0,
|
|
543
|
+
className: "grid gap-2",
|
|
544
|
+
children: [
|
|
545
|
+
/* @__PURE__ */ jsx(Label, {
|
|
546
|
+
className: "mb-1.5 type-label text-foreground",
|
|
547
|
+
children: legend
|
|
548
|
+
}),
|
|
549
|
+
choices.map((c) => /* @__PURE__ */ jsxs(Radio, {
|
|
550
|
+
value: c.value,
|
|
551
|
+
className: "group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1",
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ jsx("span", {
|
|
554
|
+
"aria-hidden": true,
|
|
555
|
+
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",
|
|
556
|
+
children: /* @__PURE__ */ jsx("span", { className: "size-2 rounded-pill bg-primary opacity-0 group-selected:opacity-100" })
|
|
557
|
+
}),
|
|
558
|
+
c.leading && /* @__PURE__ */ jsx("span", {
|
|
559
|
+
className: "mt-0.5 shrink-0",
|
|
560
|
+
children: c.leading
|
|
561
|
+
}),
|
|
562
|
+
/* @__PURE__ */ jsxs("span", {
|
|
563
|
+
className: "grid",
|
|
564
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
565
|
+
className: "type-body",
|
|
566
|
+
children: c.label
|
|
567
|
+
}), c.detail && /* @__PURE__ */ jsx("span", {
|
|
568
|
+
className: "type-body-sm text-muted-foreground",
|
|
569
|
+
children: c.detail
|
|
570
|
+
})]
|
|
571
|
+
})
|
|
572
|
+
]
|
|
573
|
+
}, c.value)),
|
|
574
|
+
error && /* @__PURE__ */ jsxs("p", {
|
|
575
|
+
id: errorId,
|
|
576
|
+
className: "flex items-start gap-1.5 type-body-sm text-danger",
|
|
577
|
+
children: [/* @__PURE__ */ jsx(CircleAlert, {
|
|
578
|
+
"aria-hidden": true,
|
|
579
|
+
className: "mt-0.5 size-4 shrink-0"
|
|
580
|
+
}), error]
|
|
581
|
+
})
|
|
582
|
+
]
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
export { typeSteps as _, Textarea as a, useSearchParam as c, MISSING as d, NBSP as f, cn as g, toDate as h, NativeSelect as i, Tooltip$1 as l, format as m, Field as n, useFieldControl as o, createFormat as p, Input$1 as r, controlHeight as s, ChoiceGroup as t, KeyText as u };
|
|
261
586
|
|
|
262
|
-
//# sourceMappingURL=
|
|
587
|
+
//# sourceMappingURL=field-t4Hoer0d.js.map
|