strata-react 1.0.39 → 1.0.40

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.
@@ -0,0 +1,29 @@
1
+ /** What a chosen key brings with it: keys, or nothing. */
2
+ export type Implies = (key: string) => Iterable<string> | null | undefined;
3
+ /** The derived sets for one explicit choice. */
4
+ export type Resolved = {
5
+ /** Explicit and implied keys. */
6
+ all: Set<string>;
7
+ /** Keys some chosen key implies: cannot be cleared on their own. */
8
+ locked: Set<string>;
9
+ /** Implied keys that were not chosen themselves. */
10
+ dependents: Set<string>;
11
+ /** For each locked key, the chosen keys that bring it (directly or through others). */
12
+ because: Map<string, string[]>;
13
+ };
14
+ export declare function resolve(explicit: ReadonlySet<string>, implies?: Implies): Resolved;
15
+ /** What a change did, for the sentence that announces it. */
16
+ export type ChoiceChange = {
17
+ explicit: Set<string>;
18
+ added: number;
19
+ dropped: number;
20
+ refused: number;
21
+ };
22
+ /**
23
+ * Apply a surface's request for the set it wants shown chosen (`next`, what a tree or table gives
24
+ * back) to the explicit choice. A dependent (implied, not chosen) in `next` is not made explicit
25
+ * (it is already in), and one missing from `next` is put back, not cleared.
26
+ */
27
+ export declare function applyChange(explicit: ReadonlySet<string>, next: ReadonlySet<string>, implies?: Implies): ChoiceChange;
28
+ /** The sentence a screen reader hears for a change, or "" when nothing worth saying happened. */
29
+ export declare function noteFor({ added, dropped, refused }: Pick<ChoiceChange, "added" | "dropped" | "refused">): string;
@@ -3,6 +3,16 @@ export type TranscriptWord = {
3
3
  text: string;
4
4
  start: number;
5
5
  end: number;
6
+ /** How sure the recogniser was, 0 to 1. Below the view's `doubtfulBelow` (default 0.6) the word is doubtful. */
7
+ confidence?: number;
8
+ /** The recogniser's own verdict, when it gives one instead of a number. Wins over `confidence`. */
9
+ doubtful?: boolean;
10
+ };
11
+ /** A mark an app puts on a phrase ("Not sung", "Not a lyric"): a word, always, and the tone it is drawn in. */
12
+ export type TranscriptPhraseState = {
13
+ id: string;
14
+ label: string;
15
+ tone: "neutral" | "info" | "success" | "warning" | "danger";
6
16
  };
7
17
  /** A phrase: timed words, who said it, and its other texts (a translation) by mode. */
8
18
  export type TranscriptPhrase = {
@@ -13,7 +23,13 @@ export type TranscriptPhrase = {
13
23
  speaker?: string;
14
24
  /** Other texts for the phrase by mode name: `{ translated: "…" }`. */
15
25
  alt?: Readonly<Record<string, string>>;
26
+ /** The mark the person (or the app) put on it. */
27
+ state?: TranscriptPhraseState;
16
28
  };
29
+ /** Whether a word is doubtful: the recogniser said so, or its confidence is under `below`. */
30
+ export declare function isDoubtful(word: Pick<TranscriptWord, "confidence" | "doubtful">, below?: number): boolean;
31
+ /** Whether any word of a phrase is doubtful. */
32
+ export declare function phraseDoubtful(phrase: Pick<TranscriptPhrase, "words">, below?: number): boolean;
17
33
  /** Phrases that belong together (a clip), with a heading. */
18
34
  export type TranscriptGroup = {
19
35
  id: string;
package/dist/map.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as useColorScheme, c as Tooltip$1 } from "./theme-CFNi6WUO.js";
2
- import { c as cn } from "./field-7Z4N5r5g.js";
1
+ import { a as useColorScheme } from "./theme-DVaIxyNn.js";
2
+ import { c as Tooltip$1, u as cn } from "./field-DeKNvGox.js";
3
3
  import { i as format } from "./format-B32-PVi2.js";
4
4
  import { n as useSharedCursor, r as geo } from "./cursor-DDGBPiTJ.js";
5
5
  import * as React from "react";
package/dist/panorama.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i as useInView, r as Slider } from "./value-controls-D6O9TsM6.js";
2
- import { c as cn } from "./field-7Z4N5r5g.js";
1
+ import { d as useInView, r as Slider } from "./value-controls-FO4zQiHP.js";
2
+ import { u as cn } from "./field-DeKNvGox.js";
3
3
  import * as React from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { VisuallyHidden } from "react-aria";
@@ -0,0 +1,178 @@
1
+ import { u as cn } from "./field-DeKNvGox.js";
2
+ import { a as readErrorBody, o as Button$1, r as describeHttpError, t as HttpError } from "./errors-BunUBqpA.js";
3
+ import * as React from "react";
4
+ import { Button, Text, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion } from "react-aria-components";
5
+ import { CircleCheck, Info, TriangleAlert, X } from "lucide-react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query";
8
+ // src/lib/overlay.ts
9
+ var overlaySurface = "rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay";
10
+ // src/components/toast.tsx
11
+ var queue = new UNSTABLE_ToastQueue({ maxVisibleToasts: 3 });
12
+ /** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */
13
+ function toastTimeout(content) {
14
+ if (content.timeout !== void 0) return content.timeout;
15
+ const chars = content.title.length + (content.description?.length ?? 0) + (content.action?.label.length ?? 0);
16
+ return Math.max(content.action ? 8e3 : 0, Math.min(15e3, 5e3 + 40 * chars));
17
+ }
18
+ /** The toast queue: `toast.show({ title })` from anywhere; `toast.close(key)`; `toast.clear()`. */
19
+ var toast = {
20
+ /** Shows a toast and returns its key. */
21
+ show(content) {
22
+ return queue.add(content, { timeout: toastTimeout(content) });
23
+ },
24
+ close(key) {
25
+ queue.close(key);
26
+ },
27
+ clear() {
28
+ queue.clear();
29
+ }
30
+ };
31
+ var marks = {
32
+ info: {
33
+ icon: Info,
34
+ color: "text-info"
35
+ },
36
+ success: {
37
+ icon: CircleCheck,
38
+ color: "text-success"
39
+ },
40
+ warning: {
41
+ icon: TriangleAlert,
42
+ color: "text-warning"
43
+ }
44
+ };
45
+ /** The one place toasts appear. Render it once at the app root. A labelled landmark (F6), polite, above panes and the undo bar. */
46
+ function StrataToastRegion({ label = "Notifications", className }) {
47
+ return /* @__PURE__ */ jsx(UNSTABLE_ToastRegion, {
48
+ queue,
49
+ "aria-label": label,
50
+ className: cn("layer-bar fixed inset-x-4 top-4 grid justify-items-end gap-2 outline-none sm:inset-x-auto sm:top-auto sm:right-4 sm:bottom-4", className),
51
+ children: ({ toast: t }) => /* @__PURE__ */ jsxs(UNSTABLE_Toast, {
52
+ toast: t,
53
+ className: cn("flex w-full max-w-sm items-start gap-3 p-3 outline-none focus-visible:outline-2 focus-visible:outline-ring", overlaySurface),
54
+ children: [
55
+ (() => {
56
+ const { icon: Icon, color } = marks[t.content.tone ?? "info"];
57
+ return /* @__PURE__ */ jsx(Icon, {
58
+ "aria-hidden": true,
59
+ className: cn("mt-0.5 size-4 shrink-0", color)
60
+ });
61
+ })(),
62
+ /* @__PURE__ */ jsxs(UNSTABLE_ToastContent, {
63
+ className: "grid min-w-0 flex-1 gap-0.5",
64
+ children: [/* @__PURE__ */ jsx(Text, {
65
+ slot: "title",
66
+ className: "type-label",
67
+ children: t.content.title
68
+ }), t.content.description && /* @__PURE__ */ jsx(Text, {
69
+ slot: "description",
70
+ className: "type-body-sm text-muted-foreground",
71
+ children: t.content.description
72
+ })]
73
+ }),
74
+ t.content.action && /* @__PURE__ */ jsx(Button$1, {
75
+ size: "sm",
76
+ onPress: () => {
77
+ t.content.action?.onPress();
78
+ queue.close(t.key);
79
+ },
80
+ children: t.content.action.label
81
+ }),
82
+ /* @__PURE__ */ jsx(Button, {
83
+ slot: "close",
84
+ "aria-label": "Dismiss",
85
+ className: "grid size-6 shrink-0 cursor-pointer place-items-center rounded-control text-muted-foreground transition-state hover:bg-muted hover:text-foreground",
86
+ children: /* @__PURE__ */ jsx(X, {
87
+ "aria-hidden": true,
88
+ className: "size-4"
89
+ })
90
+ })
91
+ ]
92
+ })
93
+ });
94
+ }
95
+ // src/query/index.tsx
96
+ /** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */
97
+ function createQueryClient(overrides) {
98
+ return new QueryClient({
99
+ ...overrides,
100
+ defaultOptions: {
101
+ ...overrides?.defaultOptions,
102
+ queries: {
103
+ retry: 1,
104
+ staleTime: 3e4,
105
+ refetchOnWindowFocus: false,
106
+ ...overrides?.defaultOptions?.queries
107
+ }
108
+ }
109
+ });
110
+ }
111
+ /** Provides a query client (Strata's defaults unless one is passed) to the app. */
112
+ function StrataQueryProvider({ client, children }) {
113
+ const [fallback] = React.useState(() => client ?? createQueryClient());
114
+ return /* @__PURE__ */ jsx(QueryClientProvider, {
115
+ client: client ?? fallback,
116
+ children
117
+ });
118
+ }
119
+ /**
120
+ * Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.
121
+ * A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.
122
+ */
123
+ function toLoad(query, describe = describeHttpError) {
124
+ if (query.status === "success") return {
125
+ status: "ready",
126
+ data: query.data
127
+ };
128
+ if (query.status === "error" && query.data !== void 0) return {
129
+ status: "ready",
130
+ data: query.data,
131
+ stale: staleOf(query, describe)
132
+ };
133
+ if (query.status === "error") return {
134
+ status: "error",
135
+ message: describe(query.error),
136
+ retry: () => void query.refetch()
137
+ };
138
+ return { status: "loading" };
139
+ }
140
+ /** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */
141
+ function staleOf(query, describe = describeHttpError) {
142
+ return {
143
+ message: describe(query.error),
144
+ readAt: new Date(query.dataUpdatedAt),
145
+ retry: () => void query.refetch(),
146
+ retrying: query.isFetching
147
+ };
148
+ }
149
+ /** `useQuery`, returned as a `Load<T>` for `DataView`. */
150
+ function useLoad(options) {
151
+ const { describeError, ...rest } = options;
152
+ return toLoad(useQuery(rest), describeError);
153
+ }
154
+ /**
155
+ * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.
156
+ * A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).
157
+ */
158
+ async function fetchJson(input, init, { readError = readErrorBody } = {}) {
159
+ const headers = new Headers(init?.headers);
160
+ if (!headers.has("Accept")) headers.set("Accept", "application/json");
161
+ const res = await fetch(input, {
162
+ ...init,
163
+ headers
164
+ });
165
+ if (!res.ok) {
166
+ const raw = await res.text().catch(() => "");
167
+ let body = raw || void 0;
168
+ try {
169
+ if (raw) body = JSON.parse(raw);
170
+ } catch {}
171
+ throw new HttpError(res.status, res.statusText, String(input), body, readError(body));
172
+ }
173
+ const text = res.status === 204 ? "" : await res.text();
174
+ return text ? JSON.parse(text) : void 0;
175
+ }
176
+ export { toLoad as a, toast as c, staleOf as i, toastTimeout as l, createQueryClient as n, useLoad as o, fetchJson as r, StrataToastRegion as s, StrataQueryProvider as t, overlaySurface as u };
177
+
178
+ //# sourceMappingURL=query-D163gXXZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-D163gXXZ.js","names":["ToastQueue","ToastRegion","AriaToast","ToastContent","Button","AriaButton"],"sources":["../src/lib/overlay.ts","../src/components/toast.tsx","../src/query/index.tsx"],"sourcesContent":["// The look every floating surface shares (Dialog, Popover, and later Menu and Toast): the popover\n// role pair, an overlay radius, one hairline and the one shadow that exists for what floats\n// (components.md §3.11). One string, so a menu and a popover cannot drift apart.\nexport const overlaySurface =\n \"rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay\";\n","import { UNSTABLE_Toast as AriaToast, UNSTABLE_ToastContent as ToastContent, UNSTABLE_ToastQueue as ToastQueue, UNSTABLE_ToastRegion as ToastRegion, Button as AriaButton, Text } from \"react-aria-components\";\nimport { CircleCheck, Info, TriangleAlert, X } from \"lucide-react\";\nimport { Button } from \"./button\";\nimport { cn } from \"../lib/utils\";\nimport { overlaySurface } from \"../lib/overlay\";\n\n// A toast confirms background work that finished (\"Export finished\", \"3 pieces synced\"). It is a\n// polite live region; it never carries an error a person must act on, which goes inline as an\n// `Alert` with its recovery (components.md §3.13, patterns.md §7), so there is no danger tone:\n// the type refuses it. `warning` is for a fact worth a glance (\"Kiln 2 is 40 min behind\").\n//\n// Rules the component owns so an app does not have to:\n// - One region, once, at the app root (`ToastRegion`), on the `layer-bar` layer: bottom end of the\n// window on a wide screen, the top on a phone, so it does not sit on the undo bar or cover the\n// focused control. It is a labelled landmark the keyboard reaches with F6 (React Aria).\n// - It stays long enough to read: 5 s plus 40 ms a character, up to 15 s, at least 8 s with an\n// action. The timer pauses while the pointer or focus is on it. There is always a dismiss control.\n// - At most one action, a button (\"Open file\"); content is words, not a form.\n// - Announcements are React Aria's: the toast's text is read when it appears and not again.\n// - The queue is module-level, so `toast.show()` works from a mutation's `onSuccess` outside any\n// component; `toast.clear()` empties it for a test. React Aria marks its toast API unstable; it\n// is used only here, behind this small surface, so a change upstream stays in this file.\n// Toasts are rare and brief, so they get the overlay entrance and nothing else (character.md §3).\n\n/** What a toast says. */\nexport type ToastContentProps = {\n /** What finished, past tense, in the product's words: \"Export finished\". */\n title: string;\n /** One more sentence: what and where (\"run.mp4, 2:31 at 1080p, in your Downloads folder.\"). */\n description?: string;\n /** `info` by default. There is no danger tone: an error the person must act on is an `Alert`. */\n tone?: \"info\" | \"success\" | \"warning\";\n /** One action beside the words. */\n action?: { label: string; onPress: () => void };\n /** Milliseconds before it goes. Defaults to enough to read the words. */\n timeout?: number;\n};\n\nconst queue = new ToastQueue<ToastContentProps>({ maxVisibleToasts: 3 });\n\n/** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */\nexport function toastTimeout(content: Pick<ToastContentProps, \"title\" | \"description\" | \"action\" | \"timeout\">): number {\n if (content.timeout !== undefined) return content.timeout;\n const chars = content.title.length + (content.description?.length ?? 0) + (content.action?.label.length ?? 0);\n return Math.max(content.action ? 8000 : 0, Math.min(15000, 5000 + 40 * chars));\n}\n\n/** The toast queue: `toast.show({ title })` from anywhere; `toast.close(key)`; `toast.clear()`. */\nexport const toast = {\n /** Shows a toast and returns its key. */\n show(content: ToastContentProps): string {\n return queue.add(content, { timeout: toastTimeout(content) });\n },\n close(key: string) {\n queue.close(key);\n },\n clear() {\n queue.clear();\n },\n};\n\nconst marks = { info: { icon: Info, color: \"text-info\" }, success: { icon: CircleCheck, color: \"text-success\" }, warning: { icon: TriangleAlert, color: \"text-warning\" } } as const;\n\n/** Props for `ToastRegion`. */\nexport type StrataToastRegionProps = {\n /** Names the landmark. Default \"Notifications\". */\n label?: string;\n className?: string;\n};\n\n/** The one place toasts appear. Render it once at the app root. A labelled landmark (F6), polite, above panes and the undo bar. */\nexport function StrataToastRegion({ label = \"Notifications\", className }: StrataToastRegionProps) {\n return (\n <ToastRegion\n queue={queue}\n aria-label={label}\n className={cn(\"layer-bar fixed inset-x-4 top-4 grid justify-items-end gap-2 outline-none sm:inset-x-auto sm:top-auto sm:right-4 sm:bottom-4\", className)}\n >\n {({ toast: t }) => (\n <AriaToast\n toast={t}\n className={cn(\"flex w-full max-w-sm items-start gap-3 p-3 outline-none focus-visible:outline-2 focus-visible:outline-ring\", overlaySurface)}\n >\n {(() => {\n const { icon: Icon, color } = marks[t.content.tone ?? \"info\"];\n return <Icon aria-hidden className={cn(\"mt-0.5 size-4 shrink-0\", color)} />;\n })()}\n <ToastContent className=\"grid min-w-0 flex-1 gap-0.5\">\n <Text slot=\"title\" className=\"type-label\">\n {t.content.title}\n </Text>\n {t.content.description && <Text slot=\"description\" className=\"type-body-sm text-muted-foreground\">{t.content.description}</Text>}\n </ToastContent>\n {t.content.action && (\n <Button size=\"sm\" onPress={() => { t.content.action?.onPress(); queue.close(t.key); }}>\n {t.content.action.label}\n </Button>\n )}\n <AriaButton slot=\"close\" aria-label=\"Dismiss\" className=\"grid size-6 shrink-0 cursor-pointer place-items-center rounded-control text-muted-foreground transition-state hover:bg-muted hover:text-foreground\">\n <X aria-hidden className=\"size-4\" />\n </AriaButton>\n </AriaToast>\n )}\n </ToastRegion>\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 InfiniteLoadOptions, type More } from \"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CAAE;CAC1H,OAAO,EAAE,QAAQ,UAAU;AAC7B;;AAGA,SAAgB,QACd,OACA,WAA0B,mBACnB;CACP,OAAO;EAAE,SAAS,SAAS,MAAM,KAAK;EAAG,QAAQ,IAAI,KAAK,MAAM,aAAa;EAAG,aAAa,KAAK,MAAM,QAAQ;EAAG,UAAU,MAAM;CAAW;AAChJ;;AAGA,SAAgB,QACd,SACS;CACT,MAAM,EAAE,eAAe,GAAG,SAAS;CACnC,OAAO,OAAO,SAAS,IAAI,GAAG,aAAa;AAC7C;;;;;AAYA,eAAsB,UAAa,OAAqB,MAAoB,EAAE,YAAY,kBAAoC,CAAC,GAAe;CAG5I,MAAM,UAAU,IAAI,QAAQ,MAAM,OAAO;CACzC,IAAI,CAAC,QAAQ,IAAI,QAAQ,GAAG,QAAQ,IAAI,UAAU,kBAAkB;CACpE,MAAM,MAAM,MAAM,MAAM,OAAO;EAAE,GAAG;EAAM;CAAQ,CAAC;CACnD,IAAI,CAAC,IAAI,IAAI;EAGX,MAAM,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,YAAY,EAAE;EAC3C,IAAI,OAAgB,OAAO,KAAA;EAC3B,IAAI;GACF,IAAI,KAAK,OAAO,KAAK,MAAM,GAAG;EAChC,QAAQ,CAER;EACA,MAAM,IAAI,UAAU,IAAI,QAAQ,IAAI,YAAY,OAAO,KAAK,GAAG,MAAM,UAAU,IAAI,CAAC;CACtF;CAGA,MAAM,OAAO,IAAI,WAAW,MAAM,KAAK,MAAM,IAAI,KAAK;CACtD,OAAQ,OAAO,KAAK,MAAM,IAAI,IAAI,KAAA;AACpC"}
package/dist/testing.js CHANGED
@@ -1,5 +1,5 @@
1
- import { c as toast, n as createQueryClient, s as StrataToastRegion, t as StrataQueryProvider } from "./query-CJ1pSPiC.js";
2
- import { r as ThemeProvider } from "./theme-CFNi6WUO.js";
1
+ import { c as toast, n as createQueryClient, s as StrataToastRegion, t as StrataQueryProvider } from "./query-D163gXXZ.js";
2
+ import { r as ThemeProvider } from "./theme-DVaIxyNn.js";
3
3
  import "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { MemoryRouter, RouterProvider, createMemoryRouter } from "react-router";
@@ -1,77 +1,8 @@
1
- import { c as cn, t as ChoiceGroup } from "./field-7Z4N5r5g.js";
1
+ import { c as Tooltip$1, t as ChoiceGroup, u as cn } from "./field-DeKNvGox.js";
2
2
  import * as React from "react";
3
- import { Radio, RadioGroup, Tooltip, TooltipTrigger } from "react-aria-components";
4
- import { ArrowBigUp, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ChevronUp, Command, Monitor, Moon, Option, Sun } from "lucide-react";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- // src/components/key-glyphs.tsx
7
- var GLYPHS = {
8
- "←": {
9
- icon: ArrowLeft,
10
- name: "left arrow"
11
- },
12
- "→": {
13
- icon: ArrowRight,
14
- name: "right arrow"
15
- },
16
- "↑": {
17
- icon: ArrowUp,
18
- name: "up arrow"
19
- },
20
- "↓": {
21
- icon: ArrowDown,
22
- name: "down arrow"
23
- },
24
- "⌘": {
25
- icon: Command,
26
- name: "Command"
27
- },
28
- "⌃": {
29
- icon: ChevronUp,
30
- name: "Control"
31
- },
32
- "⌥": {
33
- icon: Option,
34
- name: "Option"
35
- },
36
- "⇧": {
37
- icon: ArrowBigUp,
38
- name: "Shift"
39
- }
40
- };
41
- var PATTERN = new RegExp(`([${Object.keys(GLYPHS).join("")}])`);
42
- /** 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. */
43
- function KeyText({ children }) {
44
- return /* @__PURE__ */ jsx(Fragment, { children: children.split(PATTERN).map((part, i) => {
45
- const glyph = GLYPHS[part];
46
- if (!glyph) return part ? /* @__PURE__ */ jsx(React.Fragment, { children: part }, i) : null;
47
- const Icon = glyph.icon;
48
- return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
49
- "aria-hidden": true,
50
- className: "inline size-[1em] align-[-0.125em]"
51
- }), /* @__PURE__ */ jsxs("span", {
52
- className: "sr-only",
53
- children: [glyph.name, " "]
54
- })] }, i);
55
- }) });
56
- }
57
- // src/components/tooltip.tsx
58
- /** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */
59
- function Tooltip$1({ label, hint, children, side = "top", delay = 500, open, className }) {
60
- return /* @__PURE__ */ jsxs(TooltipTrigger, {
61
- delay,
62
- closeDelay: 0,
63
- isOpen: open,
64
- children: [children, /* @__PURE__ */ jsxs(Tooltip, {
65
- placement: side,
66
- offset: 6,
67
- className: cn("layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background", className),
68
- children: [label, hint != null && /* @__PURE__ */ jsx("span", {
69
- className: "ml-2 opacity-70",
70
- children: typeof hint === "string" ? /* @__PURE__ */ jsx(KeyText, { children: hint }) : hint
71
- })]
72
- })]
73
- });
74
- }
3
+ import { Radio, RadioGroup } from "react-aria-components";
4
+ import { Monitor, Moon, Sun } from "lucide-react";
5
+ import { Fragment, jsx } from "react/jsx-runtime";
75
6
  // src/components/density.tsx
76
7
  /** The density attribute's page-level setter, shared by `ThemeProvider`. @internal */
77
8
  function useDensityOn(value, target) {
@@ -258,6 +189,6 @@ function ColorSchemeChoice({ legend, labels = defaultLabels, compact = false, cl
258
189
  }))
259
190
  });
260
191
  }
261
- export { useColorScheme as a, Tooltip$1 as c, colorSchemeScript as i, KeyText as l, ColorSchemeChoice as n, useSystemColorScheme as o, ThemeProvider as r, Density as s, COLOR_SCHEME_STORAGE_KEY as t };
192
+ export { useColorScheme as a, colorSchemeScript as i, ColorSchemeChoice as n, useSystemColorScheme as o, ThemeProvider as r, Density as s, COLOR_SCHEME_STORAGE_KEY as t };
262
193
 
263
- //# sourceMappingURL=theme-CFNi6WUO.js.map
194
+ //# sourceMappingURL=theme-DVaIxyNn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-DVaIxyNn.js","names":["_Fragment","Tooltip"],"sources":["../src/components/density.tsx","../src/components/theme.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// Density is how much a screen packs in: `default` for forms and pages, `compact` for a tool screen\n// worked for hours (an editor, an inspector, a timeline). strata.css moves --control-h and\n// --control-h-sm together on `[data-density]`; this is how an app says which (issue #117, from\n// strata-vid, whose export dialog came out at default density over a compact editor).\n//\n// There are two places it can live, and they are different on purpose:\n// - the page (`ThemeProvider density` or `<Density page>`): the attribute goes on the document's\n// root element, so everything Strata renders sees it, including `Dialog`, `Menu`, `ContextMenu`,\n// `Popover` and `CommandMenu`, which portal to <body> and so are never inside the app's own root.\n// An app chooses it once, here.\n// - a region (`<Density value=\"compact\">`): a wrapper element, for a dense inspector inside an\n// ordinary app. Its overlays portal out of it and stay at the page's density, which is right: a\n// confirm opened from a dense panel is still the app's confirm.\n//\n// `default` exists as a value so a region can step back inside a compact page. A coarse pointer\n// still gets 44px targets in every density (strata.css).\n\n/** How much a screen packs in: `default`, or `compact` for a tool screen. */\nexport type DensityName = \"default\" | \"compact\";\n\n/** The density attribute's page-level setter, shared by `ThemeProvider`. @internal */\nexport function useDensityOn(value: DensityName | undefined, target?: HTMLElement | null) {\n React.useLayoutEffect(() => {\n if (value === undefined) return;\n const element = target === undefined ? document.documentElement : target;\n if (!element) return;\n const before = element.getAttribute(\"data-density\");\n element.setAttribute(\"data-density\", value);\n return () => {\n if (before === null) element.removeAttribute(\"data-density\");\n else element.setAttribute(\"data-density\", before);\n };\n }, [value, target]);\n}\n\n/** Props for `Density`. */\nexport type DensityProps = {\n value: DensityName;\n /** Set it on the document's root element for the whole page, overlays included, instead of wrapping a region. Renders only its children. */\n page?: boolean;\n /** For the wrapper of a region: layout classes (the wrapper is a plain `div`; `contents` takes it out of layout). */\n className?: string;\n children?: React.ReactNode;\n};\n\n/** Sets the density of a region (a wrapper `div`), or of the whole page with `page`, where overlays are reached too. */\nexport function Density({ value, page = false, className, children }: DensityProps) {\n useDensityOn(page ? value : undefined);\n if (page) return <>{children}</>;\n return (\n <div data-density={value} className={cn(className)}>\n {children}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { useDensityOn, type DensityName } from \"./density\";\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 density,\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 * How much the screen packs in, set on the same element as the colour scheme (the root, so\n * overlays are reached): `compact` for a tool screen. See `Density`. Left out, nothing is set.\n */\n density?: DensityName;\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 useDensityOn(density, 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 \"hover:text-foreground selected:bg-muted selected:text-foreground\",\n \"focus-visible:outline-2 focus-visible:outline-offset-2 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"],"mappings":";;;;;;;AAwBA,SAAgB,aAAa,OAAgC,QAA6B;CACxF,MAAM,sBAAsB;EAC1B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,UAAU,WAAW,KAAA,IAAY,SAAS,kBAAkB;EAClE,IAAI,CAAC,SAAS;EACd,MAAM,SAAS,QAAQ,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