strata-react 1.0.18 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/UPGRADING.md +5 -0
- package/dist/components/key-glyphs.d.ts +5 -0
- package/dist/components/line-chart.d.ts +3 -1
- package/dist/components/media-player.d.ts +90 -0
- package/dist/components/media.d.ts +3 -2
- package/dist/geo-C0jcFp4q.js +318 -0
- package/dist/geo-C0jcFp4q.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +524 -226
- package/dist/index.js.map +1 -1
- package/dist/lib/format.d.ts +12 -0
- package/dist/lib/geo.d.ts +44 -0
- package/dist/map/index.d.ts +1 -0
- package/dist/map/map-styles.d.ts +2 -0
- package/dist/map/route-map.d.ts +72 -0
- package/dist/map.js +400 -0
- package/dist/map.js.map +1 -0
- package/dist/query-CP78goXj.js +165 -0
- package/dist/query-CP78goXj.js.map +1 -0
- package/dist/{run-Yrgm5xIq.js → run-CKlcLpdN.js} +13 -2
- package/dist/run-CKlcLpdN.js.map +1 -0
- package/dist/strata.css +9 -0
- package/dist/testing.js +2 -1
- package/dist/testing.js.map +1 -1
- package/dist/{query-CIh1Dpgn.js → theme-BgTOESmN.js} +55 -164
- package/dist/theme-BgTOESmN.js.map +1 -0
- package/dist/visual/drop.d.ts +19 -0
- package/dist/visual/index.d.ts +1 -0
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +68 -1
- package/dist/visual.js.map +1 -0
- package/package.json +13 -1
- package/dist/query-CIh1Dpgn.js.map +0 -1
- package/dist/run-Yrgm5xIq.js.map +0 -1
|
@@ -2,9 +2,8 @@ import { clsx } from "clsx";
|
|
|
2
2
|
import { extendTailwindMerge } from "tailwind-merge";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Label, Radio, RadioGroup, Tooltip, TooltipTrigger } from "react-aria-components";
|
|
5
|
+
import { ArrowBigUp, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ChevronUp, CircleAlert, Command, Monitor, Moon, Option, Sun } from "lucide-react";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { CircleAlert, Monitor, Moon, Sun } from "lucide-react";
|
|
7
|
-
import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query";
|
|
8
7
|
// src/lib/utils.ts
|
|
9
8
|
var typeSteps = [
|
|
10
9
|
"caption",
|
|
@@ -29,6 +28,57 @@ var twMerge = extendTailwindMerge({ extend: {
|
|
|
29
28
|
function cn(...inputs) {
|
|
30
29
|
return twMerge(clsx(inputs));
|
|
31
30
|
}
|
|
31
|
+
// src/components/key-glyphs.tsx
|
|
32
|
+
var GLYPHS = {
|
|
33
|
+
"←": {
|
|
34
|
+
icon: ArrowLeft,
|
|
35
|
+
name: "left arrow"
|
|
36
|
+
},
|
|
37
|
+
"→": {
|
|
38
|
+
icon: ArrowRight,
|
|
39
|
+
name: "right arrow"
|
|
40
|
+
},
|
|
41
|
+
"↑": {
|
|
42
|
+
icon: ArrowUp,
|
|
43
|
+
name: "up arrow"
|
|
44
|
+
},
|
|
45
|
+
"↓": {
|
|
46
|
+
icon: ArrowDown,
|
|
47
|
+
name: "down arrow"
|
|
48
|
+
},
|
|
49
|
+
"⌘": {
|
|
50
|
+
icon: Command,
|
|
51
|
+
name: "Command"
|
|
52
|
+
},
|
|
53
|
+
"⌃": {
|
|
54
|
+
icon: ChevronUp,
|
|
55
|
+
name: "Control"
|
|
56
|
+
},
|
|
57
|
+
"⌥": {
|
|
58
|
+
icon: Option,
|
|
59
|
+
name: "Option"
|
|
60
|
+
},
|
|
61
|
+
"⇧": {
|
|
62
|
+
icon: ArrowBigUp,
|
|
63
|
+
name: "Shift"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var PATTERN = new RegExp(`([${Object.keys(GLYPHS).join("")}])`);
|
|
67
|
+
/** 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. */
|
|
68
|
+
function KeyText({ children }) {
|
|
69
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children.split(PATTERN).map((part, i) => {
|
|
70
|
+
const glyph = GLYPHS[part];
|
|
71
|
+
if (!glyph) return part ? /* @__PURE__ */ jsx(React.Fragment, { children: part }, i) : null;
|
|
72
|
+
const Icon = glyph.icon;
|
|
73
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
|
|
74
|
+
"aria-hidden": true,
|
|
75
|
+
className: "inline size-[1em] align-[-0.125em]"
|
|
76
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
77
|
+
className: "sr-only",
|
|
78
|
+
children: [glyph.name, " "]
|
|
79
|
+
})] }, i);
|
|
80
|
+
}) });
|
|
81
|
+
}
|
|
32
82
|
// src/components/tooltip.tsx
|
|
33
83
|
/** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */
|
|
34
84
|
function Tooltip$1({ label, hint, children, side = "top", delay = 500, open, className }) {
|
|
@@ -42,89 +92,11 @@ function Tooltip$1({ label, hint, children, side = "top", delay = 500, open, cla
|
|
|
42
92
|
className: cn("layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background", className),
|
|
43
93
|
children: [label, hint != null && /* @__PURE__ */ jsx("span", {
|
|
44
94
|
className: "ml-2 opacity-70",
|
|
45
|
-
children: hint
|
|
95
|
+
children: typeof hint === "string" ? /* @__PURE__ */ jsx(KeyText, { children: hint }) : hint
|
|
46
96
|
})]
|
|
47
97
|
})]
|
|
48
98
|
});
|
|
49
99
|
}
|
|
50
|
-
// src/lib/errors.ts
|
|
51
|
-
/** Thrown by `fetchJson` on a non-2xx response; carries the status, the response body and the server's reason for `describeHttpError` and `describeActionError`. */
|
|
52
|
-
var HttpError = class extends Error {
|
|
53
|
-
status;
|
|
54
|
-
statusText;
|
|
55
|
-
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)) {
|
|
62
|
-
super(`${status} ${statusText} from ${url}`);
|
|
63
|
-
this.status = status;
|
|
64
|
-
this.statusText = statusText;
|
|
65
|
-
this.url = url;
|
|
66
|
-
this.body = body;
|
|
67
|
-
this.name = "HttpError";
|
|
68
|
-
this.reason = found.reason;
|
|
69
|
-
this.fieldErrors = found.fields ?? {};
|
|
70
|
-
}
|
|
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}.`;
|
|
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.";
|
|
118
|
-
return `The request was refused (${error.status}): ${error.statusText || "no reason given"}.`;
|
|
119
|
-
}
|
|
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. */
|
|
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.";
|
|
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). */
|
|
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
|
-
}
|
|
128
100
|
// src/lib/control.ts
|
|
129
101
|
/** The height class of each control size. */
|
|
130
102
|
var controlHeight = {
|
|
@@ -456,87 +428,6 @@ function ColorSchemeChoice({ legend, labels = defaultLabels, compact = false, cl
|
|
|
456
428
|
}))
|
|
457
429
|
});
|
|
458
430
|
}
|
|
459
|
-
|
|
460
|
-
/** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */
|
|
461
|
-
function createQueryClient(overrides) {
|
|
462
|
-
return new QueryClient({
|
|
463
|
-
...overrides,
|
|
464
|
-
defaultOptions: {
|
|
465
|
-
...overrides?.defaultOptions,
|
|
466
|
-
queries: {
|
|
467
|
-
retry: 1,
|
|
468
|
-
staleTime: 3e4,
|
|
469
|
-
refetchOnWindowFocus: false,
|
|
470
|
-
...overrides?.defaultOptions?.queries
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
/** Provides a query client (Strata's defaults unless one is passed) to the app. */
|
|
476
|
-
function StrataQueryProvider({ client, children }) {
|
|
477
|
-
const [fallback] = React.useState(() => client ?? createQueryClient());
|
|
478
|
-
return /* @__PURE__ */ jsx(QueryClientProvider, {
|
|
479
|
-
client: client ?? fallback,
|
|
480
|
-
children
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.
|
|
485
|
-
* A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.
|
|
486
|
-
*/
|
|
487
|
-
function toLoad(query, describe = describeHttpError) {
|
|
488
|
-
if (query.status === "success") return {
|
|
489
|
-
status: "ready",
|
|
490
|
-
data: query.data
|
|
491
|
-
};
|
|
492
|
-
if (query.status === "error" && query.data !== void 0) return {
|
|
493
|
-
status: "ready",
|
|
494
|
-
data: query.data,
|
|
495
|
-
stale: staleOf(query, describe)
|
|
496
|
-
};
|
|
497
|
-
if (query.status === "error") return {
|
|
498
|
-
status: "error",
|
|
499
|
-
message: describe(query.error),
|
|
500
|
-
retry: () => void query.refetch()
|
|
501
|
-
};
|
|
502
|
-
return { status: "loading" };
|
|
503
|
-
}
|
|
504
|
-
/** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */
|
|
505
|
-
function staleOf(query, describe = describeHttpError) {
|
|
506
|
-
return {
|
|
507
|
-
message: describe(query.error),
|
|
508
|
-
readAt: new Date(query.dataUpdatedAt),
|
|
509
|
-
retry: () => void query.refetch(),
|
|
510
|
-
retrying: query.isFetching
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
/** `useQuery`, returned as a `Load<T>` for `DataView`. */
|
|
514
|
-
function useLoad(options) {
|
|
515
|
-
const { describeError, ...rest } = options;
|
|
516
|
-
return toLoad(useQuery(rest), describeError);
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.
|
|
520
|
-
* A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).
|
|
521
|
-
*/
|
|
522
|
-
async function fetchJson(input, init, { readError = readErrorBody } = {}) {
|
|
523
|
-
const headers = new Headers(init?.headers);
|
|
524
|
-
if (!headers.has("Accept")) headers.set("Accept", "application/json");
|
|
525
|
-
const res = await fetch(input, {
|
|
526
|
-
...init,
|
|
527
|
-
headers
|
|
528
|
-
});
|
|
529
|
-
if (!res.ok) {
|
|
530
|
-
const raw = await res.text().catch(() => "");
|
|
531
|
-
let body = raw || void 0;
|
|
532
|
-
try {
|
|
533
|
-
if (raw) body = JSON.parse(raw);
|
|
534
|
-
} catch {}
|
|
535
|
-
throw new HttpError(res.status, res.statusText, String(input), body, readError(body));
|
|
536
|
-
}
|
|
537
|
-
const text = res.status === 204 ? "" : await res.text();
|
|
538
|
-
return text ? JSON.parse(text) : void 0;
|
|
539
|
-
}
|
|
540
|
-
export { describeHttpError as C, cn as D, Tooltip$1 as E, typeSteps as O, describeActionError as S, readErrorBody as T, NativeSelect as _, toLoad as a, controlHeight as b, ColorSchemeChoice as c, useColorScheme as d, useSystemColorScheme as f, Input$1 as g, Field as h, staleOf as i, ThemeProvider as l, ChoiceGroup as m, createQueryClient as n, useLoad as o, Density as p, fetchJson as r, COLOR_SCHEME_STORAGE_KEY as s, StrataQueryProvider as t, colorSchemeScript as u, Textarea as v, fieldErrorsOf as w, HttpError as x, useFieldControl as y };
|
|
431
|
+
export { cn as _, useColorScheme as a, ChoiceGroup as c, NativeSelect as d, Textarea as f, KeyText as g, Tooltip$1 as h, colorSchemeScript as i, Field as l, controlHeight as m, ColorSchemeChoice as n, useSystemColorScheme as o, useFieldControl as p, ThemeProvider as r, Density as s, COLOR_SCHEME_STORAGE_KEY as t, Input$1 as u, typeSteps as v };
|
|
541
432
|
|
|
542
|
-
//# sourceMappingURL=
|
|
433
|
+
//# sourceMappingURL=theme-BgTOESmN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-BgTOESmN.js","names":["_Fragment","Tooltip","AriaTooltip","Input","_Fragment","Tooltip"],"sources":["../src/lib/utils.ts","../src/components/key-glyphs.tsx","../src/components/tooltip.tsx","../src/lib/control.ts","../src/components/field.tsx","../src/components/density.tsx","../src/components/theme.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 { ArrowBigUp, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ChevronUp, Command, Option, type LucideIcon } from \"lucide-react\";\n\n// Keys drawn as icons where a font cannot be trusted to have them (strata-react issue #136, from\n// strata-vid). The arrows (← → ↑ ↓) and the macOS modifiers (⌘ ⌃ ⌥ ⇧) are outside the latin subset of\n// the bundled variable fonts, so a legend drew them in whatever face the machine had: different on\n// every machine, and `strata-visual` fails a shot with text in a system font. Lucide's icons are\n// SVG, so they draw the same everywhere and take the text colour. Each is hidden from assistive\n// technology and followed by its name in screen-reader-only text (\"left arrow\", \"Command\"), so the\n// keycap reads as words rather than as a symbol each screen reader pronounces its own way.\n// Checked: React Aria has no keyboard-shortcut display beyond the `Keyboard` slot (which only\n// labels the text it is given), so this is the glyph mapping the slot's content needs.\n\nconst GLYPHS: Record<string, { icon: LucideIcon; name: string }> = {\n \"←\": { icon: ArrowLeft, name: \"left arrow\" },\n \"→\": { icon: ArrowRight, name: \"right arrow\" },\n \"↑\": { icon: ArrowUp, name: \"up arrow\" },\n \"↓\": { icon: ArrowDown, name: \"down arrow\" },\n \"⌘\": { icon: Command, name: \"Command\" },\n \"⌃\": { icon: ChevronUp, name: \"Control\" },\n \"⌥\": { icon: Option, name: \"Option\" },\n \"⇧\": { icon: ArrowBigUp, name: \"Shift\" },\n};\nconst PATTERN = new RegExp(`([${Object.keys(GLYPHS).join(\"\")}])`);\n\n/** 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. */\nexport function KeyText({ children }: { children: string }) {\n return (\n <>\n {children.split(PATTERN).map((part, i) => {\n const glyph = GLYPHS[part];\n if (!glyph) return part ? <React.Fragment key={i}>{part}</React.Fragment> : null;\n const Icon = glyph.icon;\n return (\n <React.Fragment key={i}>\n <Icon aria-hidden className=\"inline size-[1em] align-[-0.125em]\" />\n <span className=\"sr-only\">{glyph.name} </span>\n </React.Fragment>\n );\n })}\n </>\n );\n}\n","import { KeyText } from \"./key-glyphs\";\nimport * 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\">{typeof hint === \"string\" ? <KeyText>{hint}</KeyText> : hint}</span>}\n </AriaTooltip>\n </TooltipTrigger>\n );\n}\n","// Control sizes, one set for everything that sits in a toolbar or a property row: `default` is\n// --control-h and `sm` is --control-h-sm, so two controls of the same size name are the same height\n// in every density (issue #117). Button, IconButton, Toggle, ToggleGroup, Input, NativeSelect and\n// NumberField all take it as `size`.\n\n/** The size names a control takes: `default` (--control-h) or `sm` (--control-h-sm). */\nexport type ControlSize = \"default\" | \"sm\";\n\n/** The height class of each control size. */\nexport const controlHeight: Record<ControlSize, string> = {\n default: \"h-(--control-h)\",\n sm: \"h-(--control-h-sm)\",\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\";\nimport { controlHeight, type ControlSize } from \"../lib/control\";\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 10rem wide beside it (a 250px inspector body keeps a Reset beside its slider, issue #116): 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; label: string; describedBy?: string; invalid: boolean; report: (message: string | undefined) => void };\nconst FieldContext = React.createContext<FieldState | null>(null);\n\n// A control that checks what was typed (a number field, a colour field) reports its own message to\n// the Field it sits in, which draws it as the field's error, so a value outside the limits is\n// explained in the same place and way as a server's 422, with nothing for the screen to wire.\n// `error` from the screen wins over the control's own. Outside a Field `report` does nothing and\n// the control marks itself invalid without a message.\n/** @internal The surrounding Field, and where a control reports its own message. */\nexport function useFieldControl() {\n const field = React.useContext(FieldContext);\n return { field, report: field?.report ?? noReport };\n}\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\nconst noReport = () => {};\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 [reported, report] = React.useState<string>();\n const shown = error ?? reported;\n const errorId = shown ? `${id}-error` : undefined;\n const describedBy = [errorId, hintId].filter(Boolean).join(\" \") || undefined;\n\n return (\n <FieldContext.Provider value={{ id, label, describedBy, invalid: Boolean(shown), report }}>\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-40 flex-1\">{children}</div>\n <div className=\"flex shrink-0 items-center\">{action}</div>\n </div>\n ) : (\n children\n )}\n {shown && (\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 {shown}\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`. `size=\"sm\"` is --control-h-sm; the native `size` (a width in characters) is not passed on. */\nexport function Input({ className, id, size = \"default\", ...props }: Omit<React.ComponentProps<\"input\">, \"size\"> & { size?: ControlSize }) {\n return <input {...useField(id)} className={cn(control, controlHeight[size], 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. `size=\"sm\"` is --control-h-sm. */\nexport function NativeSelect({ className, id, size = \"default\", ...props }: Omit<React.ComponentProps<\"select\">, \"size\"> & { size?: ControlSize }) {\n return <select {...useField(id)} className={cn(control, controlHeight[size], \"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-selected:border-primary group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-ring\"\n >\n <span className=\"size-2 rounded-pill bg-primary opacity-0 group-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 { 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":";;;;;;;AAMA,IAAa,YAAY;CAAC;CAAW;CAAS;CAAW;CAAQ;CAAW;CAAS;CAAU;AAAS;AAMxG,IAAM,UAAU,oBAAoB,EAClC,QAAQ;CACN,OAAO,EAAE,QAAQ,CAAC,GAAG;EAJJ;EAAW;EAAW;EAAW;CAI7B,CAAW,EAAE;CAClC,aAAa,EACX,aAAa,CAAC,EAAE,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC,EACxC;AACF,EACF,CAAC;;AAGD,SAAgB,GAAG,GAAG,QAAsB;CAC1C,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;ACXA,IAAM,SAA6D;CACjE,KAAK;EAAE,MAAM;EAAW,MAAM;CAAa;CAC3C,KAAK;EAAE,MAAM;EAAY,MAAM;CAAc;CAC7C,KAAK;EAAE,MAAM;EAAS,MAAM;CAAW;CACvC,KAAK;EAAE,MAAM;EAAW,MAAM;CAAa;CAC3C,KAAK;EAAE,MAAM;EAAS,MAAM;CAAU;CACtC,KAAK;EAAE,MAAM;EAAW,MAAM;CAAU;CACxC,KAAK;EAAE,MAAM;EAAQ,MAAM;CAAS;CAC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,cAAc,KAAK;EAC9C;EACA,WAAW,GAAG,gFAAgF,SAAS;EAEtG,UAAA,YAAY,KAAK,UAAU;GAC1B,MAAM,OAAO,MAAM;GACnB,OACE,oBAACC,WAAD;IAAqB,OAAO,MAAM,MAAM,CAAC;IACzC,UAAA,oBAAC,OAAD;KACS;KACP,cAAY,MAAM,MAAM,CAAC;KACzB,WAAW,GAET,uHACA,oEACA,mFACF;KAEA,UAAA,oBAAC,MAAD;MAAM,eAAA;MAAY,WAAU;KAAU,CAAA;IACjC,CAAA;GACE,GAbK,KAaL;EAEb,CAAC;CACS,CAAA;CAGhB,OACE,oBAAC,aAAD;EACE,QAAQ,UAAU;EACZ;EACN,OAAO;EACP,WAAW,UAAU;GACnB,IAAI,aAAa,KAAK,GAAG,cAAc,KAAK;EAC9C;EACA,SAAS,YAAY,KAAK,WAAW;GAAE;GAAO,GAAG,MAAM;EAAO,EAAE;CACjE,CAAA;AAEL"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Locator, Page } from 'playwright';
|
|
2
|
+
/** A file to drop. */
|
|
3
|
+
export interface DroppedFile {
|
|
4
|
+
name: string;
|
|
5
|
+
/** The file's bytes, or its text. */
|
|
6
|
+
content: string | Uint8Array;
|
|
7
|
+
/** MIME type. Default "application/octet-stream". */
|
|
8
|
+
type?: string;
|
|
9
|
+
/** Milliseconds since the epoch. Fixed by default (2026-01-01 UTC), so a date shown from the file never changes between runs. */
|
|
10
|
+
lastModified?: number;
|
|
11
|
+
}
|
|
12
|
+
/** What `dropFiles` uses when a file gives no `lastModified`. */
|
|
13
|
+
export declare const DROPPED_FILE_MODIFIED: number;
|
|
14
|
+
/**
|
|
15
|
+
* Drops files on a target as a person dragging them in from the desktop would: `dragenter`,
|
|
16
|
+
* `dragover` and `drop`, with a data transfer that holds the files and file-system entries. The
|
|
17
|
+
* target is a selector or a Playwright `Locator`; it must be on screen.
|
|
18
|
+
*/
|
|
19
|
+
export declare function dropFiles(page: Page, target: string | Locator, files: DroppedFile[]): Promise<void>;
|
package/dist/visual/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
export { runVisual, defineVisualConfig, formatReport, pinWarnings, type RunOptions } from './run';
|
|
13
13
|
export { storybookShots, routeShots, defaultThemes } from './targets';
|
|
14
14
|
export { capture, resolveShotUrl, toFetchRequest, type CaptureOptions, type Capture } from './capture';
|
|
15
|
+
export { dropFiles, DROPPED_FILE_MODIFIED, type DroppedFile } from './drop';
|
|
15
16
|
export { serveStatic, type StaticServer } from './serve';
|
|
16
17
|
export { compare, decode, encode, boxBlur, THRESHOLD, BLUR, MAX_DIFF_PIXELS, type CompareOptions, type Image, type CompareResult } from './compare';
|
|
17
18
|
export { viewports, type Theme, type Viewport, type ViewportChoice, type Clip, type Setup, type Shot, type StorybookTarget, type RouteState, type Route, type AppTarget, type VisualConfig, type VisualReport, } from './types';
|
package/dist/visual-cli.js
CHANGED
package/dist/visual.js
CHANGED
|
@@ -1 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
import { _ as capture, a as defaultThemes, c as viewports, d as MAX_DIFF_PIXELS, f as THRESHOLD, g as encode, h as decode, i as runVisual, l as serveStatic, m as compare, n as formatReport, o as routeShots, p as boxBlur, r as pinWarnings, s as storybookShots, t as defineVisualConfig, u as BLUR, v as resolveShotUrl, y as toFetchRequest } from "./run-CKlcLpdN.js";
|
|
2
|
+
// src/visual/drop.ts
|
|
3
|
+
/** What `dropFiles` uses when a file gives no `lastModified`. */
|
|
4
|
+
var DROPPED_FILE_MODIFIED = Date.UTC(2026, 0, 1);
|
|
5
|
+
/**
|
|
6
|
+
* Drops files on a target as a person dragging them in from the desktop would: `dragenter`,
|
|
7
|
+
* `dragover` and `drop`, with a data transfer that holds the files and file-system entries. The
|
|
8
|
+
* target is a selector or a Playwright `Locator`; it must be on screen.
|
|
9
|
+
*/
|
|
10
|
+
async function dropFiles(page, target, files) {
|
|
11
|
+
const locator = typeof target === "string" ? page.locator(target).first() : target.first();
|
|
12
|
+
const payload = files.map((f) => ({
|
|
13
|
+
name: f.name,
|
|
14
|
+
type: f.type ?? "application/octet-stream",
|
|
15
|
+
lastModified: f.lastModified ?? DROPPED_FILE_MODIFIED,
|
|
16
|
+
bytes: Array.from(typeof f.content === "string" ? new TextEncoder().encode(f.content) : f.content)
|
|
17
|
+
}));
|
|
18
|
+
await locator.evaluate((element, list) => {
|
|
19
|
+
const made = list.map((f) => new File([new Uint8Array(f.bytes)], f.name, {
|
|
20
|
+
type: f.type,
|
|
21
|
+
lastModified: f.lastModified
|
|
22
|
+
}));
|
|
23
|
+
const transfer = {
|
|
24
|
+
dropEffect: "copy",
|
|
25
|
+
effectAllowed: "all",
|
|
26
|
+
types: ["Files"],
|
|
27
|
+
files: made,
|
|
28
|
+
items: made.map((file) => ({
|
|
29
|
+
kind: "file",
|
|
30
|
+
type: file.type,
|
|
31
|
+
getAsFile: () => file,
|
|
32
|
+
getAsString: () => {},
|
|
33
|
+
webkitGetAsEntry: () => ({
|
|
34
|
+
isFile: true,
|
|
35
|
+
isDirectory: false,
|
|
36
|
+
name: file.name,
|
|
37
|
+
fullPath: `/${file.name}`,
|
|
38
|
+
file: (ok) => ok(file)
|
|
39
|
+
})
|
|
40
|
+
})),
|
|
41
|
+
getData: () => "",
|
|
42
|
+
setData: () => {},
|
|
43
|
+
clearData: () => {},
|
|
44
|
+
setDragImage: () => {}
|
|
45
|
+
};
|
|
46
|
+
const rect = element.getBoundingClientRect();
|
|
47
|
+
const at = {
|
|
48
|
+
clientX: rect.left + rect.width / 2,
|
|
49
|
+
clientY: rect.top + rect.height / 2
|
|
50
|
+
};
|
|
51
|
+
for (const type of [
|
|
52
|
+
"dragenter",
|
|
53
|
+
"dragover",
|
|
54
|
+
"drop"
|
|
55
|
+
]) {
|
|
56
|
+
const event = new DragEvent(type, {
|
|
57
|
+
bubbles: true,
|
|
58
|
+
cancelable: true,
|
|
59
|
+
...at
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(event, "dataTransfer", { value: transfer });
|
|
62
|
+
element.dispatchEvent(event);
|
|
63
|
+
}
|
|
64
|
+
}, payload);
|
|
65
|
+
}
|
|
66
|
+
export { BLUR, DROPPED_FILE_MODIFIED, MAX_DIFF_PIXELS, THRESHOLD, boxBlur, capture, compare, decode, defaultThemes, defineVisualConfig, dropFiles, encode, formatReport, pinWarnings, resolveShotUrl, routeShots, runVisual, serveStatic, storybookShots, toFetchRequest, viewports };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=visual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visual.js","names":[],"sources":["../src/visual/drop.ts"],"sourcesContent":["// Dropping files on a target in a visual flow (strata-react issue #136, from strata-vid).\n// Why not the obvious ways: a `DataTransfer` built in the page has no file-system entry, and React\n// Aria's drop handling skips a file item whose `webkitGetAsEntry()` returns null (it reads the entry\n// to tell a file from a folder); the file chooser instead gives each file the `lastModified` of the\n// moment of the run, so any date the app shows from it changes every run. So the drop is built here:\n// the bytes, name, type and a fixed `lastModified` go into real `File`s, and the data transfer the\n// events carry answers `webkitGetAsEntry()` with a file entry. Native drag events are dispatched, so\n// the app's handlers (React's or React Aria's) see what a browser's drop gives them.\nimport type { Locator, Page } from \"playwright\";\n\n/** A file to drop. */\nexport interface DroppedFile {\n name: string;\n /** The file's bytes, or its text. */\n content: string | Uint8Array;\n /** MIME type. Default \"application/octet-stream\". */\n type?: string;\n /** Milliseconds since the epoch. Fixed by default (2026-01-01 UTC), so a date shown from the file never changes between runs. */\n lastModified?: number;\n}\n\n/** What `dropFiles` uses when a file gives no `lastModified`. */\nexport const DROPPED_FILE_MODIFIED = Date.UTC(2026, 0, 1);\n\n/**\n * Drops files on a target as a person dragging them in from the desktop would: `dragenter`,\n * `dragover` and `drop`, with a data transfer that holds the files and file-system entries. The\n * target is a selector or a Playwright `Locator`; it must be on screen.\n */\nexport async function dropFiles(page: Page, target: string | Locator, files: DroppedFile[]): Promise<void> {\n const locator = typeof target === \"string\" ? page.locator(target).first() : target.first();\n const payload = files.map((f) => ({\n name: f.name,\n type: f.type ?? \"application/octet-stream\",\n lastModified: f.lastModified ?? DROPPED_FILE_MODIFIED,\n bytes: Array.from(typeof f.content === \"string\" ? new TextEncoder().encode(f.content) : f.content),\n }));\n await locator.evaluate((element, list) => {\n const made = list.map((f) => new File([new Uint8Array(f.bytes)], f.name, { type: f.type, lastModified: f.lastModified }));\n const items = made.map((file) => ({\n kind: \"file\" as const,\n type: file.type,\n getAsFile: () => file,\n getAsString: () => {},\n webkitGetAsEntry: () => ({\n isFile: true,\n isDirectory: false,\n name: file.name,\n fullPath: `/${file.name}`,\n file: (ok: (f: File) => void) => ok(file),\n }),\n }));\n const transfer = { dropEffect: \"copy\", effectAllowed: \"all\", types: [\"Files\"], files: made, items, getData: () => \"\", setData: () => {}, clearData: () => {}, setDragImage: () => {} };\n const rect = element.getBoundingClientRect();\n const at = { clientX: rect.left + rect.width / 2, clientY: rect.top + rect.height / 2 };\n for (const type of [\"dragenter\", \"dragover\", \"drop\"]) {\n const event = new DragEvent(type, { bubbles: true, cancelable: true, ...at });\n Object.defineProperty(event, \"dataTransfer\", { value: transfer });\n element.dispatchEvent(event);\n }\n }, payload);\n}\n"],"mappings":";;;AAsBA,IAAa,wBAAwB,KAAK,IAAI,MAAM,GAAG,CAAC;;;;;;AAOxD,eAAsB,UAAU,MAAY,QAA0B,OAAqC;CACzG,MAAM,UAAU,OAAO,WAAW,WAAW,KAAK,QAAQ,MAAM,CAAC,CAAC,MAAM,IAAI,OAAO,MAAM;CACzF,MAAM,UAAU,MAAM,KAAK,OAAO;EAChC,MAAM,EAAE;EACR,MAAM,EAAE,QAAQ;EAChB,cAAc,EAAE,gBAAgB;EAChC,OAAO,MAAM,KAAK,OAAO,EAAE,YAAY,WAAW,IAAI,YAAY,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,OAAO;CACnG,EAAE;CACF,MAAM,QAAQ,UAAU,SAAS,SAAS;EACxC,MAAM,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,WAAW,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM;GAAE,MAAM,EAAE;GAAM,cAAc,EAAE;EAAa,CAAC,CAAC;EAcxH,MAAM,WAAW;GAAE,YAAY;GAAQ,eAAe;GAAO,OAAO,CAAC,OAAO;GAAG,OAAO;GAAM,OAb9E,KAAK,KAAK,UAAU;IAChC,MAAM;IACN,MAAM,KAAK;IACX,iBAAiB;IACjB,mBAAmB,CAAC;IACpB,yBAAyB;KACvB,QAAQ;KACR,aAAa;KACb,MAAM,KAAK;KACX,UAAU,IAAI,KAAK;KACnB,OAAO,OAA0B,GAAG,IAAI;IAC1C;GACF,EAC4F;GAAO,eAAe;GAAI,eAAe,CAAC;GAAG,iBAAiB,CAAC;GAAG,oBAAoB,CAAC;EAAE;EACrL,MAAM,OAAO,QAAQ,sBAAsB;EAC3C,MAAM,KAAK;GAAE,SAAS,KAAK,OAAO,KAAK,QAAQ;GAAG,SAAS,KAAK,MAAM,KAAK,SAAS;EAAE;EACtF,KAAK,MAAM,QAAQ;GAAC;GAAa;GAAY;EAAM,GAAG;GACpD,MAAM,QAAQ,IAAI,UAAU,MAAM;IAAE,SAAS;IAAM,YAAY;IAAM,GAAG;GAAG,CAAC;GAC5E,OAAO,eAAe,OAAO,gBAAgB,EAAE,OAAO,SAAS,CAAC;GAChE,QAAQ,cAAc,KAAK;EAC7B;CACF,GAAG,OAAO;AACZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strata-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "React + Tailwind v4 components that ship structure, behaviour, states and a token contract, and no look: each product brings a theme generated from its own subject.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"import": "./dist/visual.js",
|
|
30
30
|
"default": "./dist/visual.js"
|
|
31
31
|
},
|
|
32
|
+
"./map": {
|
|
33
|
+
"types": "./dist/map/index.d.ts",
|
|
34
|
+
"import": "./dist/map.js",
|
|
35
|
+
"default": "./dist/map.js"
|
|
36
|
+
},
|
|
32
37
|
"./strata.css": {
|
|
33
38
|
"style": "./dist/strata.css",
|
|
34
39
|
"default": "./dist/strata.css"
|
|
@@ -73,6 +78,7 @@
|
|
|
73
78
|
"peerDependencies": {
|
|
74
79
|
"@tanstack/react-query": "^5.0.0",
|
|
75
80
|
"@testing-library/react": "^16.0.0",
|
|
81
|
+
"leaflet": "^1.9.4",
|
|
76
82
|
"msw": "^2.7.0 || ^3.0.0",
|
|
77
83
|
"playwright": ">=1.49.0",
|
|
78
84
|
"react": "^19.0.0",
|
|
@@ -82,6 +88,9 @@
|
|
|
82
88
|
"vite": ">=6.1.0"
|
|
83
89
|
},
|
|
84
90
|
"peerDependenciesMeta": {
|
|
91
|
+
"leaflet": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
85
94
|
"@testing-library/react": {
|
|
86
95
|
"optional": true
|
|
87
96
|
},
|
|
@@ -121,6 +130,7 @@
|
|
|
121
130
|
"@testing-library/jest-dom": "^7.0.1",
|
|
122
131
|
"@testing-library/react": "^16.3.3",
|
|
123
132
|
"@testing-library/user-event": "^14.6.8",
|
|
133
|
+
"@types/leaflet": "^1.9.22",
|
|
124
134
|
"@types/node": "^26.6.6",
|
|
125
135
|
"@types/pngjs": "^6.0.5",
|
|
126
136
|
"@types/react": "^19.3.0",
|
|
@@ -128,6 +138,8 @@
|
|
|
128
138
|
"@vitejs/plugin-react": "^6.2.1",
|
|
129
139
|
"@vitest/coverage-v8": "^5.1.0",
|
|
130
140
|
"jsdom": "^31.0.0",
|
|
141
|
+
"leaflet": "^1.9.4",
|
|
142
|
+
"leaflet-node": "^3.0.2",
|
|
131
143
|
"msw": "^3.0.4",
|
|
132
144
|
"msw-storybook-addon": "^3.0.3",
|
|
133
145
|
"playwright": "1.65.0",
|