strata-react 0.1.17 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +13 -10
  2. package/dist/components/async-button.d.ts +15 -3
  3. package/dist/components/button.d.ts +17 -7
  4. package/dist/components/checkbox.d.ts +3 -3
  5. package/dist/components/commands.d.ts +104 -0
  6. package/dist/components/composition.d.ts +1 -1
  7. package/dist/components/data-table.d.ts +16 -3
  8. package/dist/components/data-view.d.ts +12 -1
  9. package/dist/components/dialog.d.ts +45 -0
  10. package/dist/components/field.d.ts +3 -1
  11. package/dist/components/infinite-list.d.ts +35 -2
  12. package/dist/components/job-status.d.ts +36 -0
  13. package/dist/components/popover.d.ts +20 -0
  14. package/dist/components/switch.d.ts +14 -0
  15. package/dist/components/thumbnail.d.ts +17 -7
  16. package/dist/components/toggle.d.ts +43 -0
  17. package/dist/components/toolbar.d.ts +15 -0
  18. package/dist/components/tooltip.d.ts +19 -0
  19. package/dist/index.d.ts +17 -7
  20. package/dist/index.js +1380 -355
  21. package/dist/index.js.map +1 -1
  22. package/dist/lib/chords.d.ts +20 -0
  23. package/dist/lib/errors.d.ts +28 -4
  24. package/dist/lib/format.d.ts +57 -6
  25. package/dist/lib/overlay.d.ts +1 -0
  26. package/dist/lib/utils.d.ts +1 -1
  27. package/dist/query/index.d.ts +13 -4
  28. package/dist/query/job.d.ts +22 -0
  29. package/dist/{query-BlPgaCBG.js → query-BVh4zv7Y.js} +146 -41
  30. package/dist/query-BVh4zv7Y.js.map +1 -0
  31. package/dist/{run-N6Juz-kN.js → run-DFf1BBA3.js} +13 -3
  32. package/dist/run-DFf1BBA3.js.map +1 -0
  33. package/dist/strata.css +17 -0
  34. package/dist/testing/buttons.d.ts +7 -0
  35. package/dist/testing/index.d.ts +1 -0
  36. package/dist/testing.js +31 -2
  37. package/dist/testing.js.map +1 -1
  38. package/dist/visual-cli.js +1 -1
  39. package/dist/visual.js +1 -1
  40. package/package.json +8 -7
  41. package/dist/query-BlPgaCBG.js.map +0 -1
  42. package/dist/run-N6Juz-kN.js.map +0 -1
@@ -0,0 +1,20 @@
1
+ /** `"mac"` or `"other"`: which modifier glyphs to draw and what `Mod` means. */
2
+ export type Platform = "mac" | "other";
3
+ /** The platform this page runs on, read from the browser (`mac` for macOS and iOS). Server and test default: `other`. */
4
+ export declare function detectPlatform(): Platform;
5
+ type Parsed = {
6
+ ctrl: boolean;
7
+ meta: boolean;
8
+ alt: boolean;
9
+ shift: boolean;
10
+ key: string;
11
+ };
12
+ /** Splits "Mod+Shift+Z" into modifiers and key for a platform. A bare "+" key is written "Mod++". */
13
+ export declare function parseChord(chord: string, platform?: Platform): Parsed;
14
+ /** Whether a key event is this chord. Exact on Ctrl, Meta and Alt; Shift is exact for letters and named keys. */
15
+ export declare function matchesChord(e: Pick<KeyboardEvent, "key" | "code" | "ctrlKey" | "metaKey" | "altKey" | "shiftKey">, chord: string, platform?: Platform): boolean;
16
+ /** A chord as a person reads it on this platform: "⌘⇧Z" on macOS, "Ctrl+Shift+Z" elsewhere. */
17
+ export declare function formatChord(chord: string, platform?: Platform): string;
18
+ /** Whether the browser uses this chord for itself, so a command may take it only with `claim`. */
19
+ export declare function isReservedChord(chord: string, platform?: Platform): boolean;
20
+ export {};
@@ -1,13 +1,37 @@
1
- /** Thrown by `fetchJson` on a non-2xx response; carries the status for `describeHttpError` and `describeActionError`. */
1
+ /** What `readErrorBody` finds in an error response: the server's sentence, and messages per field. */
2
+ export type ErrorBody = {
3
+ /** Why the server refused, in its own words. */
4
+ reason?: string;
5
+ /** Messages for individual fields, keyed by field name (`"name"`, `"address.city"`). */
6
+ fields?: Record<string, string>;
7
+ };
8
+ /** Thrown by `fetchJson` on a non-2xx response; carries the status, the response body and the server's reason for `describeHttpError` and `describeActionError`. */
2
9
  export declare class HttpError extends Error {
3
10
  readonly status: number;
4
11
  readonly statusText: string;
5
12
  readonly url: string;
6
- constructor(status: number, statusText: string, url: string);
13
+ /** The response body: parsed JSON when it was JSON, else its text; undefined when empty. */
14
+ readonly body?: unknown | undefined;
15
+ /** The server's sentence for why it refused, from the body (`detail`, `message`, `error`), if it gave one. */
16
+ readonly reason?: string;
17
+ /** Messages for individual fields from the body (FastAPI's 422 `detail: [{loc, msg}]`), keyed by field name. Empty when there are none. */
18
+ readonly fieldErrors: Readonly<Record<string, string>>;
19
+ constructor(status: number, statusText: string, url: string,
20
+ /** The response body: parsed JSON when it was JSON, else its text; undefined when empty. */
21
+ body?: unknown | undefined, found?: ErrorBody);
7
22
  }
23
+ /**
24
+ * The default reading of an error body, for the shapes most JSON APIs use: `{ detail: "…" }`
25
+ * (FastAPI), `{ message: "…" }`, `{ error: "…" }` or `{ error: { message: "…" } }` for the reason,
26
+ * and FastAPI's validation list `{ detail: [{ loc, msg }] }` for per-field messages. A short
27
+ * plain-text body (not HTML) is taken as the reason too. Pass your own to `fetchJson` for other APIs.
28
+ */
29
+ export declare function readErrorBody(body: unknown): ErrorBody;
8
30
  /** Writes an error for a person: what happened, in a sentence. A product passes its own words. */
9
31
  export type DescribeError = (error: unknown) => string;
10
- /** The default `DescribeError` for loads: the HTTP status in a sentence, else the error's message, else a plain fallback. */
32
+ /** 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. */
11
33
  export declare const describeHttpError: DescribeError;
12
- /** The default for `useAsyncAction`: the HTTP status in a sentence, else the thrown Error's message, else undefined (the retry label alone). */
34
+ /** 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). */
13
35
  export declare const describeActionError: (error: unknown) => string | undefined;
36
+ /** Messages for individual fields carried by what was thrown: an `HttpError`'s `fieldErrors`, else none. */
37
+ export declare function fieldErrorsOf(error: unknown): Readonly<Record<string, string>>;
@@ -1,13 +1,17 @@
1
1
  export declare const NBSP = "\u00A0";
2
+ /** The placeholder printed for a value that is not known: an en dash. */
3
+ export declare const MISSING = "\u2013";
2
4
  /** The decimal byte units `format.bytes` writes. */
3
5
  export type ByteUnit = "B" | "kB" | "MB" | "GB" | "TB" | "PB";
4
- /** An `Intl.NumberFormat` that can also be called directly: `f(n)` is `f.format(n)`. */
5
- export type NumberFormatter = ((value: number | bigint) => string) & Pick<Intl.NumberFormat, "format" | "formatToParts" | "resolvedOptions">;
6
+ /** An `Intl.NumberFormat` that can also be called directly: `f(n)` is `f.format(n)`. `null` or `undefined` prints the placeholder. */
7
+ export type NumberFormatter = ((value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string) & {
8
+ format: (value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string;
9
+ } & Pick<Intl.NumberFormat, "formatToParts" | "resolvedOptions">;
6
10
  /** What a date formatter accepts: a Date, an ISO 8601 string, or epoch milliseconds. */
7
11
  export type DateInput = Date | string | number;
8
12
  /** An `Intl.DateTimeFormat` that can also be called directly, with a Date, an ISO string or epoch milliseconds. */
9
- export type DateFormatter = ((value: DateInput) => string) & {
10
- format: (value: DateInput) => string;
13
+ export type DateFormatter = ((value: DateInput | null | undefined) => string) & {
14
+ format: (value: DateInput | null | undefined) => string;
11
15
  formatToParts: (value: DateInput) => Intl.DateTimeFormatPart[];
12
16
  formatRange: (start: DateInput, end: DateInput) => string;
13
17
  } & Pick<Intl.DateTimeFormat, "resolvedOptions">;
@@ -15,6 +19,13 @@ export type DateFormatter = ((value: DateInput) => string) & {
15
19
  export interface FormatOptions {
16
20
  /** An IANA zone ("Europe/London", "UTC") to show times in. Left out, times are the viewer's own. */
17
21
  timeZone?: string;
22
+ /** What a missing value (`null`, `undefined`) prints as. Default an en dash (`MISSING`). */
23
+ missing?: string;
24
+ }
25
+ /** Options for `format.count`. */
26
+ export interface CountOptions {
27
+ /** Write the figure compactly: "1.2k views". The noun still agrees with the exact count. */
28
+ compact?: boolean;
18
29
  }
19
30
  /** A Date from a Date, an ISO string or epoch milliseconds; throws a RangeError naming the input when it is not a date. */
20
31
  export declare function toDate(value: DateInput): Date;
@@ -29,6 +40,26 @@ export declare function createFormat(locale: string, options?: FormatOptions): {
29
40
  decimal: NumberFormatter;
30
41
  /** A ratio as a whole percent: `format.percent(0.42)` is "42%". */
31
42
  percent: NumberFormatter;
43
+ /**
44
+ * A part's share of a whole, as `percent` but never misleading at the ends: a part above 0 that
45
+ * rounds to 0 is "<1%", and one short of the whole that rounds to 100 is ">99%".
46
+ * `format.share(2.4 / 512)` is "<1%".
47
+ */
48
+ share: (value: number | null | undefined) => string;
49
+ /** A figure in short form for counts that run to thousands: `format.compact(1234)` is "1.2k" in en-GB, "1.2K" in en-US. */
50
+ compact: NumberFormatter;
51
+ /**
52
+ * How long ago (or how far ahead) a time is, in the largest unit it reaches:
53
+ * "3 weeks ago", "yesterday", "in 2 hours", "now" under a minute. Pass `now` in tests.
54
+ */
55
+ ago: (value: DateInput | null | undefined, now?: DateInput) => string;
56
+ /**
57
+ * A media running time from seconds, as a player shows it: "4:05", "1:02:09". Unknown
58
+ * (null, negative, not finite) prints the placeholder. Set it in `tabular-nums`.
59
+ */
60
+ runningTime: (seconds: number | null | undefined) => string;
61
+ /** What a missing value prints as: an en dash unless `createFormat`'s `missing` says otherwise. */
62
+ missing: string;
32
63
  /** A time of day: `format.clock(at)` is "06:05". */
33
64
  clock: DateFormatter;
34
65
  /** A day without its year, for this week's things: `format.day(at)` is "Sunday 8 November". */
@@ -56,7 +87,7 @@ export declare function createFormat(locale: string, options?: FormatOptions): {
56
87
  * joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same
57
88
  * call or a `\s` regex, not a typed "6 pieces" string in a role's `name`.
58
89
  */
59
- count: (value: number, one: string, many?: string) => string;
90
+ count: (value: number | null | undefined, one: string, many?: string, { compact: short }?: CountOptions) => string;
60
91
  };
61
92
  export type Format = ReturnType<typeof createFormat>;
62
93
  /** The en-GB formatters. */
@@ -70,6 +101,26 @@ export declare const format: {
70
101
  decimal: NumberFormatter;
71
102
  /** A ratio as a whole percent: `format.percent(0.42)` is "42%". */
72
103
  percent: NumberFormatter;
104
+ /**
105
+ * A part's share of a whole, as `percent` but never misleading at the ends: a part above 0 that
106
+ * rounds to 0 is "<1%", and one short of the whole that rounds to 100 is ">99%".
107
+ * `format.share(2.4 / 512)` is "<1%".
108
+ */
109
+ share: (value: number | null | undefined) => string;
110
+ /** A figure in short form for counts that run to thousands: `format.compact(1234)` is "1.2k" in en-GB, "1.2K" in en-US. */
111
+ compact: NumberFormatter;
112
+ /**
113
+ * How long ago (or how far ahead) a time is, in the largest unit it reaches:
114
+ * "3 weeks ago", "yesterday", "in 2 hours", "now" under a minute. Pass `now` in tests.
115
+ */
116
+ ago: (value: DateInput | null | undefined, now?: DateInput) => string;
117
+ /**
118
+ * A media running time from seconds, as a player shows it: "4:05", "1:02:09". Unknown
119
+ * (null, negative, not finite) prints the placeholder. Set it in `tabular-nums`.
120
+ */
121
+ runningTime: (seconds: number | null | undefined) => string;
122
+ /** What a missing value prints as: an en dash unless `createFormat`'s `missing` says otherwise. */
123
+ missing: string;
73
124
  /** A time of day: `format.clock(at)` is "06:05". */
74
125
  clock: DateFormatter;
75
126
  /** A day without its year, for this week's things: `format.day(at)` is "Sunday 8 November". */
@@ -97,5 +148,5 @@ export declare const format: {
97
148
  * joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same
98
149
  * call or a `\s` regex, not a typed "6 pieces" string in a role's `name`.
99
150
  */
100
- count: (value: number, one: string, many?: string) => string;
151
+ count: (value: number | null | undefined, one: string, many?: string, { compact: short }?: CountOptions) => string;
101
152
  };
@@ -0,0 +1 @@
1
+ export declare const overlaySurface = "rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay";
@@ -1,4 +1,4 @@
1
1
  import { ClassValue } from 'clsx';
2
2
  export declare const typeSteps: readonly ["caption", "label", "body-sm", "body", "heading", "title", "figure", "display"];
3
- /** clsx + tailwind-merge, taught that `type-*` utilities are font sizes. */
3
+ /** clsx + tailwind-merge, taught that `type-*` utilities are font sizes and `rounded-control`, `-surface`, `-overlay`, `-pill` are radii. */
4
4
  export declare function cn(...inputs: ClassValue[]): string;
@@ -1,8 +1,8 @@
1
1
  import { QueryClient, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
2
  import { Load, Stale } from '../components/data-view';
3
- import { HttpError, describeHttpError, DescribeError } from '../lib/errors';
3
+ import { HttpError, describeHttpError, readErrorBody, DescribeError, ErrorBody } from '../lib/errors';
4
4
  import * as React from "react";
5
- export { HttpError, describeHttpError, type DescribeError };
5
+ export { HttpError, describeHttpError, readErrorBody, type DescribeError, type ErrorBody };
6
6
  /** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */
7
7
  export declare function createQueryClient(overrides?: ConstructorParameters<typeof QueryClient>[0]): QueryClient;
8
8
  /** Provides a query client (Strata's defaults unless one is passed) to the app. */
@@ -26,6 +26,15 @@ export declare function staleOf(query: {
26
26
  export declare function useLoad<T, K extends QueryKey = QueryKey>(options: UseQueryOptions<T, Error, T, K> & {
27
27
  describeError?: DescribeError;
28
28
  }): Load<T>;
29
- /** fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write. A 204 or empty body resolves to undefined. */
30
- export declare function fetchJson<T>(input: string | URL, init?: RequestInit): Promise<T>;
29
+ /** Options for `fetchJson` beyond `fetch`'s own. */
30
+ export type FetchJsonOptions = {
31
+ /** Finds the server's reason and per-field messages in an error body. Default `readErrorBody` (FastAPI's `detail`, `message`, `error`). */
32
+ readError?: (body: unknown) => ErrorBody;
33
+ };
34
+ /**
35
+ * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.
36
+ * A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).
37
+ */
38
+ export declare function fetchJson<T>(input: string | URL, init?: RequestInit, { readError }?: FetchJsonOptions): Promise<T>;
31
39
  export { useInfiniteLoad, type InfiniteLoad, type InfiniteLoadOptions, type More } from './infinite';
40
+ export { useJob, type Job, type JobOptions } from './job';
@@ -0,0 +1,22 @@
1
+ import { QueryKey, UseQueryOptions } from '@tanstack/react-query';
2
+ import { Load } from '../components/data-view';
3
+ import { DescribeError } from '../lib/errors';
4
+ /** Options for `useJob`: a query's, plus how to tell the job is running, how often to poll, and what it changes. */
5
+ export type JobOptions<T, K extends QueryKey = QueryKey> = UseQueryOptions<T, Error, T, K> & {
6
+ /** Whether the status says the job is still going. */
7
+ isRunning: (data: T) => boolean;
8
+ /** Milliseconds between polls while it runs. Default 2000. */
9
+ every?: number;
10
+ /** Query keys the job changes, invalidated once when it ends. */
11
+ invalidates?: QueryKey[];
12
+ describeError?: DescribeError;
13
+ };
14
+ /** What `useJob` returns: the status as a `Load<T>`, whether the job is running, and `poll` to read it now. */
15
+ export type Job<T> = Load<T> & {
16
+ /** The latest status says the job is going. */
17
+ running: boolean;
18
+ /** Read the status now, as after starting the job. */
19
+ poll: () => void;
20
+ };
21
+ /** A long-running job's status: polled every `every` ms while `isRunning`, with the `invalidates` queries read again once when it ends. */
22
+ export declare function useJob<T, K extends QueryKey = QueryKey>({ isRunning, every, invalidates, describeError, ...options }: JobOptions<T, K>): Job<T>;
@@ -1,6 +1,7 @@
1
1
  import { clsx } from "clsx";
2
2
  import { extendTailwindMerge } from "tailwind-merge";
3
3
  import * as React from "react";
4
+ import { Label, Radio, RadioGroup, Tooltip, TooltipTrigger } from "react-aria-components";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
6
  import { CircleAlert, Monitor, Moon, Sun } from "lucide-react";
6
7
  import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query";
@@ -15,32 +16,115 @@ var typeSteps = [
15
16
  "figure",
16
17
  "display"
17
18
  ];
18
- var twMerge = extendTailwindMerge({ extend: { classGroups: { "font-size": [{ type: [...typeSteps] }] } } });
19
- /** clsx + tailwind-merge, taught that `type-*` utilities are font sizes. */
19
+ var twMerge = extendTailwindMerge({ extend: {
20
+ theme: { radius: [...[
21
+ "control",
22
+ "surface",
23
+ "overlay",
24
+ "pill"
25
+ ]] },
26
+ classGroups: { "font-size": [{ type: [...typeSteps] }] }
27
+ } });
28
+ /** clsx + tailwind-merge, taught that `type-*` utilities are font sizes and `rounded-control`, `-surface`, `-overlay`, `-pill` are radii. */
20
29
  function cn(...inputs) {
21
30
  return twMerge(clsx(inputs));
22
31
  }
32
+ // src/components/tooltip.tsx
33
+ /** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */
34
+ function Tooltip$1({ label, hint, children, side = "top", delay = 500, open, className }) {
35
+ return /* @__PURE__ */ jsxs(TooltipTrigger, {
36
+ delay,
37
+ closeDelay: 0,
38
+ isOpen: open,
39
+ children: [children, /* @__PURE__ */ jsxs(Tooltip, {
40
+ placement: side,
41
+ offset: 6,
42
+ className: cn("layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background", className),
43
+ children: [label, hint != null && /* @__PURE__ */ jsx("span", {
44
+ className: "ml-2 opacity-70",
45
+ children: hint
46
+ })]
47
+ })]
48
+ });
49
+ }
23
50
  // src/lib/errors.ts
24
- /** Thrown by `fetchJson` on a non-2xx response; carries the status for `describeHttpError` and `describeActionError`. */
51
+ /** Thrown by `fetchJson` on a non-2xx response; carries the status, the response body and the server's reason for `describeHttpError` and `describeActionError`. */
25
52
  var HttpError = class extends Error {
26
53
  status;
27
54
  statusText;
28
55
  url;
29
- constructor(status, statusText, url) {
56
+ body;
57
+ /** The server's sentence for why it refused, from the body (`detail`, `message`, `error`), if it gave one. */
58
+ reason;
59
+ /** Messages for individual fields from the body (FastAPI's 422 `detail: [{loc, msg}]`), keyed by field name. Empty when there are none. */
60
+ fieldErrors;
61
+ constructor(status, statusText, url, body, found = readErrorBody(body)) {
30
62
  super(`${status} ${statusText} from ${url}`);
31
63
  this.status = status;
32
64
  this.statusText = statusText;
33
65
  this.url = url;
66
+ this.body = body;
34
67
  this.name = "HttpError";
68
+ this.reason = found.reason;
69
+ this.fieldErrors = found.fields ?? {};
35
70
  }
36
71
  };
72
+ var text = (value) => typeof value === "string" && value.trim() ? value.trim() : void 0;
73
+ /** A field name from a FastAPI/pydantic `loc`: the path after where it came from (`["body", "address", "city"]` is `"address.city"`). */
74
+ function fieldName(loc) {
75
+ if (!Array.isArray(loc)) return void 0;
76
+ const path = loc.map(String);
77
+ if ([
78
+ "body",
79
+ "query",
80
+ "path",
81
+ "header",
82
+ "cookie",
83
+ "form"
84
+ ].includes(path[0]) && path.length > 1) path.shift();
85
+ return path.join(".") || void 0;
86
+ }
87
+ /**
88
+ * The default reading of an error body, for the shapes most JSON APIs use: `{ detail: "…" }`
89
+ * (FastAPI), `{ message: "…" }`, `{ error: "…" }` or `{ error: { message: "…" } }` for the reason,
90
+ * and FastAPI's validation list `{ detail: [{ loc, msg }] }` for per-field messages. A short
91
+ * plain-text body (not HTML) is taken as the reason too. Pass your own to `fetchJson` for other APIs.
92
+ */
93
+ function readErrorBody(body) {
94
+ if (typeof body === "string") {
95
+ const t = text(body);
96
+ return t && t.length <= 300 && !t.startsWith("<") ? { reason: t } : {};
97
+ }
98
+ if (!body || typeof body !== "object") return {};
99
+ const b = body;
100
+ if (Array.isArray(b.detail)) {
101
+ const fields = {};
102
+ for (const item of b.detail) {
103
+ const entry = item;
104
+ const name = fieldName(entry?.loc);
105
+ const msg = text(entry?.msg);
106
+ if (name && msg && !fields[name]) fields[name] = msg;
107
+ }
108
+ return { fields };
109
+ }
110
+ const nested = b.error && typeof b.error === "object" ? text(b.error.message) : void 0;
111
+ return { reason: text(b.detail) ?? text(b.message) ?? text(b.error) ?? nested };
112
+ }
113
+ /** A sentence ends once: "…absolute path" and "…absolute path." both end in one full stop. */
114
+ var sentence = (s) => /[.!?…]$/.test(s) ? s : `${s}.`;
37
115
  function refused(error) {
116
+ if (error.reason) return `The request was refused: ${sentence(error.reason)}`;
117
+ if (Object.keys(error.fieldErrors).length) return "The request was refused: check the fields marked.";
38
118
  return `The request was refused (${error.status}): ${error.statusText || "no reason given"}.`;
39
119
  }
40
- /** The default `DescribeError` for loads: the HTTP status in a sentence, else the error's message, else a plain fallback. */
120
+ /** 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. */
41
121
  var describeHttpError = (error) => error instanceof HttpError ? error.status >= 500 ? `The server could not answer (${error.status}). Nothing was changed.` : refused(error) : error instanceof Error && error.message ? error.message : "The data could not be loaded. Nothing was changed.";
42
- /** The default for `useAsyncAction`: the HTTP status in a sentence, else the thrown Error's message, else undefined (the retry label alone). */
122
+ /** 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). */
43
123
  var describeActionError = (error) => error instanceof HttpError ? error.status >= 500 ? `The server could not answer (${error.status}).` : refused(error) : error instanceof Error && error.message ? error.message : void 0;
124
+ /** Messages for individual fields carried by what was thrown: an `HttpError`'s `fieldErrors`, else none. */
125
+ function fieldErrorsOf(error) {
126
+ return error instanceof HttpError ? error.fieldErrors : {};
127
+ }
44
128
  // src/components/field.tsx
45
129
  var FieldContext = React.createContext(null);
46
130
  function useField(id) {
@@ -52,7 +136,7 @@ function useField(id) {
52
136
  };
53
137
  }
54
138
  /** A labelled form field: wires the label, hint, error, `aria-describedby` and `aria-invalid` into the one control it wraps. */
55
- function Field({ label, id: idProp, hint, error, children, className }) {
139
+ function Field({ label, id: idProp, hint, error, action, children, className }) {
56
140
  const generated = React.useId();
57
141
  const id = idProp ?? generated;
58
142
  const hintId = hint ? `${id}-hint` : void 0;
@@ -72,7 +156,16 @@ function Field({ label, id: idProp, hint, error, children, className }) {
72
156
  className: "type-label text-foreground",
73
157
  children: label
74
158
  }),
75
- children,
159
+ action ? /* @__PURE__ */ jsxs("div", {
160
+ className: "flex flex-wrap items-start gap-2",
161
+ children: [/* @__PURE__ */ jsx("div", {
162
+ className: "min-w-56 flex-1",
163
+ children
164
+ }), /* @__PURE__ */ jsx("div", {
165
+ className: "flex shrink-0 items-center",
166
+ children: action
167
+ })]
168
+ }) : children,
76
169
  error && /* @__PURE__ */ jsxs("p", {
77
170
  id: errorId,
78
171
  className: "flex items-start gap-1.5 type-body-sm text-danger",
@@ -92,7 +185,7 @@ function Field({ label, id: idProp, hint, error, children, className }) {
92
185
  }
93
186
  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";
94
187
  /** A text input that picks up its id and descriptions from the surrounding `Field`. */
95
- function Input({ className, id, ...props }) {
188
+ function Input$1({ className, id, ...props }) {
96
189
  return /* @__PURE__ */ jsx("input", {
97
190
  ...useField(id),
98
191
  className: cn(control, "h-(--control-h)", className),
@@ -118,23 +211,24 @@ function NativeSelect({ className, id, ...props }) {
118
211
  /** 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. */
119
212
  function ChoiceGroup({ legend, name, choices, value, onChange, error }) {
120
213
  const errorId = React.useId();
121
- return /* @__PURE__ */ jsxs("fieldset", {
122
- className: "grid gap-2",
214
+ return /* @__PURE__ */ jsxs(RadioGroup, {
215
+ name,
216
+ value,
217
+ onChange,
123
218
  "aria-describedby": error ? errorId : void 0,
219
+ className: "grid gap-2",
124
220
  children: [
125
- /* @__PURE__ */ jsx("legend", {
221
+ /* @__PURE__ */ jsx(Label, {
126
222
  className: "mb-1.5 type-label text-foreground",
127
223
  children: legend
128
224
  }),
129
- choices.map((c) => /* @__PURE__ */ jsxs("label", {
130
- className: "flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1",
131
- children: [/* @__PURE__ */ jsx("input", {
132
- type: "radio",
133
- name,
134
- value: c.value,
135
- checked: value === c.value,
136
- onChange: () => onChange(c.value),
137
- className: "mt-1 size-4 shrink-0 accent-primary"
225
+ choices.map((c) => /* @__PURE__ */ jsxs(Radio, {
226
+ value: c.value,
227
+ className: "group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1",
228
+ children: [/* @__PURE__ */ jsx("span", {
229
+ "aria-hidden": true,
230
+ className: "mt-1 grid size-4 shrink-0 place-items-center rounded-pill border border-input bg-background transition-state group-data-[selected]:border-primary group-data-[focus-visible]:outline-2 group-data-[focus-visible]:outline-offset-2 group-data-[focus-visible]:outline-ring",
231
+ children: /* @__PURE__ */ jsx("span", { className: "size-2 rounded-pill bg-primary opacity-0 group-data-[selected]:opacity-100" })
138
232
  }), /* @__PURE__ */ jsxs("span", {
139
233
  className: "grid",
140
234
  children: [/* @__PURE__ */ jsx("span", {
@@ -279,27 +373,28 @@ function ColorSchemeChoice({ legend, labels = defaultLabels, compact = false, cl
279
373
  ...defaultLabels,
280
374
  ...labels
281
375
  };
282
- if (compact) return /* @__PURE__ */ jsx("div", {
283
- role: "radiogroup",
376
+ if (compact) return /* @__PURE__ */ jsx(RadioGroup, {
284
377
  "aria-label": legend ?? "Appearance",
378
+ orientation: "horizontal",
379
+ name,
380
+ value: preference,
381
+ onChange: (value) => {
382
+ if (isPreference(value)) setPreference(value);
383
+ },
285
384
  className: cn("inline-flex gap-0.5 rounded-surface border border-border bg-background p-0.5", className),
286
385
  children: PREFERENCES.map((value) => {
287
386
  const Icon = icons[value];
288
- return /* @__PURE__ */ jsxs("label", {
289
- title: words[value].label,
290
- className: cn("grid size-(--control-h-sm) cursor-pointer place-items-center rounded-control text-muted-foreground transition-state", "hover:text-foreground has-checked:bg-muted has-checked:text-foreground", "has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ring"),
291
- children: [/* @__PURE__ */ jsx("input", {
292
- type: "radio",
293
- name,
387
+ return /* @__PURE__ */ jsx(Tooltip$1, {
388
+ label: words[value].label,
389
+ children: /* @__PURE__ */ jsx(Radio, {
294
390
  value,
295
- checked: preference === value,
296
- onChange: () => setPreference(value),
297
391
  "aria-label": words[value].label,
298
- className: "sr-only"
299
- }), /* @__PURE__ */ jsx(Icon, {
300
- "aria-hidden": true,
301
- className: "size-4"
302
- })]
392
+ className: cn("grid size-(--control-h-sm) cursor-pointer place-items-center rounded-control text-muted-foreground transition-state", "data-[hovered]:text-foreground data-[selected]:bg-muted data-[selected]:text-foreground", "data-[focus-visible]:outline-2 data-[focus-visible]:outline-offset-2 data-[focus-visible]:outline-ring"),
393
+ children: /* @__PURE__ */ jsx(Icon, {
394
+ "aria-hidden": true,
395
+ className: "size-4"
396
+ })
397
+ })
303
398
  }, value);
304
399
  })
305
400
  });
@@ -375,18 +470,28 @@ function useLoad(options) {
375
470
  const { describeError, ...rest } = options;
376
471
  return toLoad(useQuery(rest), describeError);
377
472
  }
378
- /** fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write. A 204 or empty body resolves to undefined. */
379
- async function fetchJson(input, init) {
473
+ /**
474
+ * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.
475
+ * A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).
476
+ */
477
+ async function fetchJson(input, init, { readError = readErrorBody } = {}) {
380
478
  const headers = new Headers(init?.headers);
381
479
  if (!headers.has("Accept")) headers.set("Accept", "application/json");
382
480
  const res = await fetch(input, {
383
481
  ...init,
384
482
  headers
385
483
  });
386
- if (!res.ok) throw new HttpError(res.status, res.statusText, String(input));
484
+ if (!res.ok) {
485
+ const raw = await res.text().catch(() => "");
486
+ let body = raw || void 0;
487
+ try {
488
+ if (raw) body = JSON.parse(raw);
489
+ } catch {}
490
+ throw new HttpError(res.status, res.statusText, String(input), body, readError(body));
491
+ }
387
492
  const text = res.status === 204 ? "" : await res.text();
388
493
  return text ? JSON.parse(text) : void 0;
389
494
  }
390
- export { typeSteps as S, Textarea as _, toLoad as a, describeHttpError as b, ColorSchemeChoice as c, useColorScheme as d, useSystemColorScheme as f, NativeSelect as g, Input as h, staleOf as i, ThemeProvider as l, Field as m, createQueryClient as n, useLoad as o, ChoiceGroup as p, fetchJson as r, COLOR_SCHEME_STORAGE_KEY as s, StrataQueryProvider as t, colorSchemeScript as u, HttpError as v, cn as x, describeActionError as y };
495
+ export { Tooltip$1 as C, readErrorBody as S, typeSteps as T, Textarea as _, toLoad as a, describeHttpError as b, ColorSchemeChoice as c, useColorScheme as d, useSystemColorScheme as f, NativeSelect as g, Input$1 as h, staleOf as i, ThemeProvider as l, Field as m, createQueryClient as n, useLoad as o, ChoiceGroup as p, fetchJson as r, COLOR_SCHEME_STORAGE_KEY as s, StrataQueryProvider as t, colorSchemeScript as u, HttpError as v, cn as w, fieldErrorsOf as x, describeActionError as y };
391
496
 
392
- //# sourceMappingURL=query-BlPgaCBG.js.map
497
+ //# sourceMappingURL=query-BVh4zv7Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-BVh4zv7Y.js","names":["Tooltip","AriaTooltip","Input","Tooltip"],"sources":["../src/lib/utils.ts","../src/components/tooltip.tsx","../src/lib/errors.ts","../src/components/field.tsx","../src/components/theme.tsx","../src/query/index.tsx"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\n// Teach tailwind-merge that `type-*` utilities are font sizes. Without this, cn() cannot tell\n// `type-label` from a colour and may drop one of two classes that both survive in CSS; with stock\n// shadcn the same bug drops `text-muted-foreground` next to a custom `text-*` size.\nexport const typeSteps = [\"caption\", \"label\", \"body-sm\", \"body\", \"heading\", \"title\", \"figure\", \"display\"] as const;\n\n// The radius roles too, so `rounded-pill` at a call site (a round avatar Thumbnail) replaces a\n// component's `rounded-control` instead of both surviving and CSS order picking one.\nconst radiusRoles = [\"control\", \"surface\", \"overlay\", \"pill\"] as const;\n\nconst twMerge = extendTailwindMerge({\n extend: {\n theme: { radius: [...radiusRoles] },\n classGroups: {\n \"font-size\": [{ type: [...typeSteps] }],\n },\n },\n});\n\n/** clsx + tailwind-merge, taught that `type-*` utilities are font sizes and `rounded-control`, `-surface`, `-overlay`, `-pill` are radii. */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import * as React from \"react\";\nimport { Tooltip as AriaTooltip, TooltipTrigger } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\n\n// A tooltip names or explains a control; it is never the only place information lives. React Aria\n// opens it on keyboard focus as well as hover (strata-vid's old hover-only tooltip hid it from\n// keyboard users), after a short delay so a pointer crossing a toolbar does not flash every tip,\n// and shares the delay between neighbouring tips. It holds only words: anything interactive is a\n// Popover. It is portalled to the body, so a parent's overflow cannot clip it, and sits on the\n// `layer-tip` layer above dialogs, since it can name a control inside one.\n//\n// `IconButton` uses it for its required `label`, so the name and the visible hint come from one\n// string and cannot drift.\n\n/** Props for `Tooltip`. */\nexport type TooltipProps = {\n /** The words: a control's name or one sentence about it. Not interactive. */\n label: React.ReactNode;\n /** A shortcut or other aside shown after the label, muted (\"Ctrl+Z\"). */\n hint?: React.ReactNode;\n /** The element that gets the tip. It must be a React Aria pressable or focusable (a Strata `Button` is). */\n children: React.ReactElement;\n /** Which side of the trigger it prefers; it flips when there is no room. Default `top`. */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n /** Milliseconds before it opens on hover. Focus opens it at once. Default 500. */\n delay?: number;\n /** A controlled open state, for a story or test that needs it shown. */\n open?: boolean;\n className?: string;\n};\n\n/** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */\nexport function Tooltip({ label, hint, children, side = \"top\", delay = 500, open, className }: TooltipProps) {\n return (\n <TooltipTrigger delay={delay} closeDelay={0} isOpen={open}>\n {children}\n <AriaTooltip\n placement={side}\n offset={6}\n className={cn(\"layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background\", className)}\n >\n {label}\n {hint != null && <span className=\"ml-2 opacity-70\">{hint}</span>}\n </AriaTooltip>\n </TooltipTrigger>\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","import * as React from \"react\";\nimport { CircleAlert } from \"lucide-react\";\nimport { Label, Radio, RadioGroup } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\n\n// Field owns the wiring a generated form usually forgets: the label's htmlFor, aria-describedby\n// pointing at the hint and the error, and aria-invalid. Controls read it from context, so a control\n// inside a Field cannot end up unlabelled or silently invalid.\n//\n// A one-field form (\"paste a link, Add\", a search box, \"invite by email\") puts its button on the\n// control's row, not beside the whole field (strata-react issue #46, from the Tubes Library\n// screen): in a plain flex row the button lines up with label, hint and error together and drifts\n// off the input whenever one shows. `action` is drawn on the control's row, both at --control-h,\n// with the hint and the error under both across the full width. It wraps under the control only\n// when the row cannot keep the control 14rem wide beside it: on a phone a short \"Add\" stays on the\n// row, as a search box's button does, and a long label or a narrow column wraps. The error and hint stay the input's description; the\n// button is not described by them. Field messages for a form come from `useAsyncAction`'s\n// `fieldErrors` (its `validate`, or the server's 422), so no `problem` state is kept by hand.\n\ntype FieldState = { id: string; describedBy?: string; invalid: boolean };\nconst FieldContext = React.createContext<FieldState | null>(null);\n\nfunction useField(id?: string) {\n const field = React.useContext(FieldContext);\n return {\n // Inside a Field the Field's id wins, so the label always points at the control. To choose the\n // id yourself, pass it to Field.\n id: field?.id ?? id,\n \"aria-describedby\": field?.describedBy,\n \"aria-invalid\": field?.invalid || undefined,\n };\n}\n\nexport type FieldProps = {\n label: string;\n /** The control's id, when the page needs a known one (an anchor, a test). Generated otherwise. */\n id?: string;\n /** What the person needs to know before typing, such as limits or units. */\n hint?: React.ReactNode;\n /** What went wrong and how to fix it, in one sentence. Shown under the control, never in a toast. */\n error?: string;\n /** A button on the control's row, for a one-field form (an `AsyncButton` \"Add\"). The hint and error run under both; on a narrow screen it wraps under the control. */\n action?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n};\n\n/** A labelled form field: wires the label, hint, error, `aria-describedby` and `aria-invalid` into the one control it wraps. */\nexport function Field({ label, id: idProp, hint, error, action, children, className }: FieldProps) {\n const generated = React.useId();\n const id = idProp ?? generated;\n const hintId = hint ? `${id}-hint` : undefined;\n const errorId = error ? `${id}-error` : undefined;\n const describedBy = [errorId, hintId].filter(Boolean).join(\" \") || undefined;\n\n return (\n <FieldContext.Provider value={{ id, describedBy, invalid: Boolean(error) }}>\n <div className={cn(\"grid min-w-0 content-start gap-1.5\", className)}>\n <label htmlFor={id} className=\"type-label text-foreground\">\n {label}\n </label>\n {action ? (\n <div className=\"flex flex-wrap items-start gap-2\">\n <div className=\"min-w-56 flex-1\">{children}</div>\n <div className=\"flex shrink-0 items-center\">{action}</div>\n </div>\n ) : (\n children\n )}\n {error && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {error}\n </p>\n )}\n {hint && (\n <p id={hintId} className=\"type-body-sm text-muted-foreground\">\n {hint}\n </p>\n )}\n </div>\n </FieldContext.Provider>\n );\n}\n\nconst control =\n \"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\";\n\n/** A text input that picks up its id and descriptions from the surrounding `Field`. */\nexport function Input({ className, id, ...props }: React.ComponentProps<\"input\">) {\n return <input {...useField(id)} className={cn(control, \"h-(--control-h)\", className)} {...props} />;\n}\n\n/** A multi-line input that picks up its id and descriptions from the surrounding `Field`. */\nexport function Textarea({ className, id, ...props }: React.ComponentProps<\"textarea\">) {\n return <textarea {...useField(id)} className={cn(control, \"min-h-24 py-2\", className)} {...props} />;\n}\n\n// A native select, styled. For short option lists on a touch screen it beats a custom listbox:\n// the platform picker, typeahead and form autofill all work with no code.\n/** The platform select, styled. The default for short lists, especially on touch screens. */\nexport function NativeSelect({ className, id, ...props }: React.ComponentProps<\"select\">) {\n return <select {...useField(id)} className={cn(control, \"h-(--control-h) pr-8\", className)} {...props} />;\n}\n\n// Radio choices: React Aria's RadioGroup (a group named by its label, arrow-key movement, one tab\n// stop), and each row wraps its control so the whole row is one hit target. The dot is drawn from\n// tokens, not the platform's accent-color radio.\nexport type Choice = { value: string; label: string; detail?: string };\n\n/** 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. */\nexport function ChoiceGroup({\n legend,\n name,\n choices,\n value,\n onChange,\n error,\n}: {\n legend: string;\n name: string;\n choices: Choice[];\n value: string;\n onChange: (value: string) => void;\n error?: string;\n}) {\n const errorId = React.useId();\n return (\n <RadioGroup name={name} value={value} onChange={onChange} aria-describedby={error ? errorId : undefined} className=\"grid gap-2\">\n <Label className=\"mb-1.5 type-label text-foreground\">{legend}</Label>\n {choices.map((c) => (\n <Radio key={c.value} value={c.value} className=\"group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1\">\n <span\n aria-hidden\n className=\"mt-1 grid size-4 shrink-0 place-items-center rounded-pill border border-input bg-background transition-state group-data-[selected]:border-primary group-data-[focus-visible]:outline-2 group-data-[focus-visible]:outline-offset-2 group-data-[focus-visible]:outline-ring\"\n >\n <span className=\"size-2 rounded-pill bg-primary opacity-0 group-data-[selected]:opacity-100\" />\n </span>\n <span className=\"grid\">\n <span className=\"type-body\">{c.label}</span>\n {c.detail && <span className=\"type-body-sm text-muted-foreground\">{c.detail}</span>}\n </span>\n </Radio>\n ))}\n {error && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {error}\n </p>\n )}\n </RadioGroup>\n );\n}\n","import * as React from \"react\";\nimport { Radio, RadioGroup } from \"react-aria-components\";\nimport { Tooltip } from \"./tooltip\";\nimport { Monitor, Moon, Sun } from \"lucide-react\";\nimport type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\nimport { ChoiceGroup } from \"./field\";\n\n// strata.css keys dark mode on a `.dark` ancestor (`@custom-variant dark (&:is(.dark *))`) and\n// gives `.dark` its `color-scheme`, but nothing in the library set the class, so every app wrote\n// the same matchMedia listener by hand (strata-listory did, in web/src/main.tsx). This is that\n// listener, once:\n// - Three choices, not two. \"system\" follows the operating system and keeps following it when it\n// changes at dusk; \"light\" and \"dark\" are a person's override. A toggle with only light and dark\n// loses the system setting the first time it is pressed.\n// - The choice persists in localStorage, read and written inside try/catch. Storage throws in\n// private windows, with blocked site data and in sandboxed frames; the theme then simply does\n// not persist, and the page still renders. A stored value that is not one of the three is\n// ignored.\n// - Another tab changing the choice changes this one too (the `storage` event).\n// - The first render uses the default preference, as a server render would, and the stored choice\n// is applied in a layout effect, so server-rendered markup hydrates cleanly and nothing paints\n// with the wrong scheme (found in review).\n// - The class is set in a layout effect, before paint. A page that must not flash light on first\n// load before React runs puts `colorSchemeScript()` in an inline script in its `<head>`.\n// - `ColorSchemeChoice` is the picker for a settings page: a `ChoiceGroup` of the three, with\n// \"Match this device\" first because it is the default and the one most people should keep. A\n// product that wants the choice elsewhere (a menu item, a header button) builds it from\n// `useColorScheme`. Changing theme is rare, so the picker has no motion and no icon flourish.\n// - `compact` is the same choice for an app with no settings page (a homepage, a single-page\n// tool), sized to sit in a header or footer: three segments with an icon each, named\n// \"Appearance\" (strata-react issue #25). They are still native radio buttons, so arrow keys move\n// the choice and a screen reader hears \"Match this device, radio button, 1 of 3, Appearance\".\n// Each segment is named by `aria-label` on its radio and shows the same words as a tooltip; the\n// icons are the familiar three (screen, sun, moon), and none of them is a toggle that loses the\n// system setting. The visible words are left out only because the icons are that well known.\n// - Storybook's decorator and `renderWithStrata({ colorScheme })` run through this provider, so\n// stories and tests see the same class, in the same place, as an app.\n\n/** What a person chose: follow the operating system, or a fixed light or dark theme. */\nexport type ColorSchemePreference = \"system\" | \"light\" | \"dark\";\n/** The scheme in effect after \"system\" is resolved. */\nexport type ColorScheme = \"light\" | \"dark\";\n\n/** The localStorage key `ThemeProvider` uses unless given another. */\nexport const COLOR_SCHEME_STORAGE_KEY = \"strata-color-scheme\";\n\nconst QUERY = \"(prefers-color-scheme: dark)\";\nconst PREFERENCES: readonly ColorSchemePreference[] = [\"system\", \"light\", \"dark\"];\n\nfunction isPreference(value: unknown): value is ColorSchemePreference {\n return typeof value === \"string\" && (PREFERENCES as readonly string[]).includes(value);\n}\n\nfunction readStored(key: string | null): ColorSchemePreference | null {\n if (key === null) return null;\n try {\n const value = window.localStorage.getItem(key);\n return isPreference(value) ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction writeStored(key: string | null, value: ColorSchemePreference) {\n if (key === null) return;\n try {\n window.localStorage.setItem(key, value);\n } catch {\n // Storage unavailable (private window, blocked site data): the choice lasts this visit only.\n }\n}\n\nfunction media(): MediaQueryList | null {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" ? window.matchMedia(QUERY) : null;\n}\n\nfunction subscribeSystem(onChange: () => void) {\n const list = media();\n if (!list) return () => undefined;\n list.addEventListener(\"change\", onChange);\n return () => list.removeEventListener(\"change\", onChange);\n}\n\nconst systemSnapshot = (): ColorScheme => (media()?.matches ? \"dark\" : \"light\");\nconst serverSnapshot = (): ColorScheme => \"light\";\n\n/** The operating system's colour scheme, kept current as it changes. Light where it cannot be read (the server, jsdom). */\nexport function useSystemColorScheme(): ColorScheme {\n return React.useSyncExternalStore(subscribeSystem, systemSnapshot, serverSnapshot);\n}\n\n/** What `useColorScheme` returns: the chosen preference, the scheme in effect, and a setter that persists the choice. */\nexport type ColorSchemeState = {\n preference: ColorSchemePreference;\n scheme: ColorScheme;\n setPreference: (preference: ColorSchemePreference) => void;\n};\n\nconst Context = React.createContext<ColorSchemeState | null>(null);\n\n/** Sets the `.dark` class strata.css keys on, from a system, light or dark preference that persists in localStorage when it can. */\nexport function ThemeProvider({\n children,\n defaultPreference = \"system\",\n storageKey = COLOR_SCHEME_STORAGE_KEY,\n target,\n}: {\n children: React.ReactNode;\n /** The preference before a person has chosen one. */\n defaultPreference?: ColorSchemePreference;\n /** Where the choice is kept in localStorage; `null` keeps it for this visit only. */\n storageKey?: string | null;\n /**\n * The element that gets the `.dark` class; the document's root element when left out. A nested\n * target can turn a light page's panel dark, not the reverse: strata.css keys dark on any\n * `.dark` ancestor. Pass the element itself (keep it in state with a callback ref, since a\n * wrapping element's ref is not attached yet when this provider's effect first runs); `null`\n * means it has not mounted yet, and nothing is set until it has.\n */\n target?: HTMLElement | null;\n}) {\n // The first render uses the default, as the server does, so a server-rendered tree hydrates\n // without a mismatch; the stored choice is read in a layout effect, which re-renders before the\n // browser paints, so a client-only app still never shows the default first.\n const [preference, setState] = React.useState<ColorSchemePreference>(defaultPreference);\n React.useLayoutEffect(() => {\n const stored = readStored(storageKey);\n if (stored) setState(stored);\n }, [storageKey]);\n const system = useSystemColorScheme();\n const scheme: ColorScheme = preference === \"system\" ? system : preference;\n\n const setPreference = React.useCallback(\n (next: ColorSchemePreference) => {\n setState(next);\n writeStored(storageKey, next);\n },\n [storageKey],\n );\n\n // Another tab changed the choice. A cleared key (`newValue` null) falls back to the default.\n React.useEffect(() => {\n if (storageKey === null) return;\n const onStorage = (event: StorageEvent) => {\n if (event.key !== storageKey && event.key !== null) return;\n const value = event.key === null ? null : event.newValue;\n setState(isPreference(value) ? value : defaultPreference);\n };\n window.addEventListener(\"storage\", onStorage);\n return () => window.removeEventListener(\"storage\", onStorage);\n }, [storageKey, defaultPreference]);\n\n React.useLayoutEffect(() => {\n const element = target === undefined ? document.documentElement : target;\n if (!element) return;\n element.classList.toggle(\"dark\", scheme === \"dark\");\n return () => element.classList.remove(\"dark\");\n }, [scheme, target]);\n\n const value = React.useMemo(() => ({ preference, scheme, setPreference }), [preference, scheme, setPreference]);\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\n/** The person's colour-scheme preference, the scheme in effect, and a setter that persists it. Must be inside `ThemeProvider`. */\nexport function useColorScheme(): ColorSchemeState {\n const value = React.useContext(Context);\n if (!value) throw new Error(\"useColorScheme must be used inside a ThemeProvider.\");\n return value;\n}\n\n/**\n * The body of an inline `<script>` for the page's `<head>` that sets `.dark` before the first\n * paint, from the stored choice or the operating system, so a dark page does not flash light while\n * the bundle loads. Pass the same key and default as the `ThemeProvider`.\n */\nexport function colorSchemeScript(\n storageKey: string = COLOR_SCHEME_STORAGE_KEY,\n defaultPreference: ColorSchemePreference = \"system\",\n): string {\n const key = JSON.stringify(storageKey);\n const fallback = JSON.stringify(defaultPreference);\n return (\n `(function(){var p=${fallback};try{var s=localStorage.getItem(${key});` +\n `if(s===\"system\"||s===\"light\"||s===\"dark\")p=s}catch(e){}` +\n `var d=p===\"dark\"||(p===\"system\"&&window.matchMedia&&matchMedia(${JSON.stringify(QUERY)}).matches);` +\n `document.documentElement.classList.toggle(\"dark\",!!d)})()`\n );\n}\n\n/** The words `ColorSchemeChoice` shows for each preference. */\nexport type ColorSchemeLabels = Record<ColorSchemePreference, { label: string; detail?: string }>;\n\nconst defaultLabels: ColorSchemeLabels = {\n system: { label: \"Match this device\", detail: \"Light or dark as your system setting changes\" },\n light: { label: \"Light\" },\n dark: { label: \"Dark\" },\n};\n\nconst icons: Record<ColorSchemePreference, IconComponent> = { system: Monitor, light: Sun, dark: Moon };\n\n/** The three colour-scheme preferences as radio buttons, bound to the nearest `ThemeProvider`. A list for a settings page, or `compact` icon segments named \"Appearance\" for a header. */\nexport function ColorSchemeChoice({\n legend,\n labels = defaultLabels,\n compact = false,\n className,\n}: {\n /** The group's name, as the page words it. Defaults to \"Theme\", or \"Appearance\" when `compact`. */\n legend?: string;\n /** Overrides the words for each choice, in the product's voice. */\n labels?: Partial<ColorSchemeLabels>;\n /** Three icon segments for a header or footer, for an app with no settings page. */\n compact?: boolean;\n /** Layout at the call site (compact only). */\n className?: string;\n}) {\n const { preference, setPreference } = useColorScheme();\n const name = React.useId();\n const words = { ...defaultLabels, ...labels };\n if (compact) {\n return (\n <RadioGroup\n aria-label={legend ?? \"Appearance\"}\n orientation=\"horizontal\"\n name={name}\n value={preference}\n onChange={(value) => {\n if (isPreference(value)) setPreference(value);\n }}\n className={cn(\"inline-flex gap-0.5 rounded-surface border border-border bg-background p-0.5\", className)}\n >\n {PREFERENCES.map((value) => {\n const Icon = icons[value];\n return (\n <Tooltip key={value} label={words[value].label}>\n <Radio\n value={value}\n aria-label={words[value].label}\n className={cn(\n // Outer 6px less 2px padding: the segments are 4px, as optical nesting asks.\n \"grid size-(--control-h-sm) cursor-pointer place-items-center rounded-control text-muted-foreground transition-state\",\n \"data-[hovered]:text-foreground data-[selected]:bg-muted data-[selected]:text-foreground\",\n \"data-[focus-visible]:outline-2 data-[focus-visible]:outline-offset-2 data-[focus-visible]:outline-ring\",\n )}\n >\n <Icon aria-hidden className=\"size-4\" />\n </Radio>\n </Tooltip>\n );\n })}\n </RadioGroup>\n );\n }\n return (\n <ChoiceGroup\n legend={legend ?? \"Theme\"}\n name={name}\n value={preference}\n onChange={(value) => {\n if (isPreference(value)) setPreference(value);\n }}\n choices={PREFERENCES.map((value) => ({ value, ...words[value] }))}\n />\n );\n}\n","import * as React from \"react\";\nimport {\n QueryClient,\n QueryClientProvider,\n useQuery,\n type QueryKey,\n type UseQueryOptions,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport type { Load, Stale } from \"../components/data-view\";\nimport { HttpError, describeHttpError, readErrorBody, type DescribeError, type ErrorBody } from \"../lib/errors\";\n\nexport { HttpError, describeHttpError, readErrorBody, type DescribeError, type ErrorBody };\n\n// Data loading, the Strata way: TanStack Query fetches and caches, and every view of the result\n// goes through DataView, which takes a Load<T>. `toLoad` is the one bridge between them, so a\n// screen never re-derives loading/error/ready from a query's flags and never forgets one.\n//\n// Opinions in createQueryClient: one retry (a second failure is real and the person should see\n// it with a \"Try again\"), 30 s stale time (dashboards are read many times a minute but change\n// over minutes), and no refetch on window focus (a table that reorders itself while someone reads\n// it is worse than one that is 30 s old). Override per query when the data says otherwise.\n\n/** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */\nexport function createQueryClient(overrides?: ConstructorParameters<typeof QueryClient>[0]) {\n return new QueryClient({\n ...overrides,\n defaultOptions: {\n ...overrides?.defaultOptions,\n queries: { retry: 1, staleTime: 30_000, refetchOnWindowFocus: false, ...overrides?.defaultOptions?.queries },\n },\n });\n}\n\n/** Provides a query client (Strata's defaults unless one is passed) to the app. */\nexport function StrataQueryProvider({ client, children }: { client?: QueryClient; children: React.ReactNode }) {\n const [fallback] = React.useState(() => client ?? createQueryClient());\n return <QueryClientProvider client={client ?? fallback}>{children}</QueryClientProvider>;\n}\n\n/**\n * Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.\n * A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.\n */\nexport function toLoad<T>(query: UseQueryResult<T>, describe: DescribeError = describeHttpError): Load<T> {\n if (query.status === \"success\") return { status: \"ready\", data: query.data };\n // TanStack keeps the last good data when a refetch fails and sets status \"error\" (isRefetchError).\n // That is old data, not no data: keep it on screen and say how old it is.\n if (query.status === \"error\" && query.data !== undefined) return { status: \"ready\", data: query.data, stale: staleOf(query, describe) };\n if (query.status === \"error\") return { status: \"error\", message: describe(query.error), retry: () => void query.refetch() };\n return { status: \"loading\" };\n}\n\n/** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */\nexport function staleOf(\n query: { error: unknown; dataUpdatedAt: number; isFetching: boolean; refetch: () => unknown },\n describe: DescribeError = describeHttpError,\n): Stale {\n return { message: describe(query.error), readAt: new Date(query.dataUpdatedAt), retry: () => void query.refetch(), retrying: query.isFetching };\n}\n\n/** `useQuery`, returned as a `Load<T>` for `DataView`. */\nexport function useLoad<T, K extends QueryKey = QueryKey>(\n options: UseQueryOptions<T, Error, T, K> & { describeError?: DescribeError },\n): Load<T> {\n const { describeError, ...rest } = options;\n return toLoad(useQuery(rest), describeError);\n}\n\n/** Options for `fetchJson` beyond `fetch`'s own. */\nexport type FetchJsonOptions = {\n /** Finds the server's reason and per-field messages in an error body. Default `readErrorBody` (FastAPI's `detail`, `message`, `error`). */\n readError?: (body: unknown) => ErrorBody;\n};\n\n/**\n * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.\n * A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).\n */\nexport async function fetchJson<T>(input: string | URL, init?: RequestInit, { readError = readErrorBody }: FetchJsonOptions = {}): Promise<T> {\n // Headers, tuple arrays and plain objects are all valid HeadersInit; normalise before adding the\n // default so a caller's Authorization (or their own Accept) is never dropped.\n const headers = new Headers(init?.headers);\n if (!headers.has(\"Accept\")) headers.set(\"Accept\", \"application/json\");\n const res = await fetch(input, { ...init, headers });\n if (!res.ok) {\n // The body is read as text and parsed only when it parses: a proxy's HTML 502 page or an empty\n // body must still throw the HttpError, never a JSON SyntaxError in its place.\n const raw = await res.text().catch(() => \"\");\n let body: unknown = raw || undefined;\n try {\n if (raw) body = JSON.parse(raw);\n } catch {\n // Not JSON: keep the text.\n }\n throw new HttpError(res.status, res.statusText, String(input), body, readError(body));\n }\n // Writes (DELETE, a PUT that returns nothing) answer 204 or an empty body; that is success, not a\n // JSON parse error.\n const text = res.status === 204 ? \"\" : await res.text();\n return (text ? JSON.parse(text) : undefined) as T;\n}\n\nexport { useInfiniteLoad, type InfiniteLoad, type InfiniteLoadOpt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