@designtools/tokens 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,12 +8,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
8
8
  * and a ramp is changed while looking at it. Every change is a change to the generator's seed.
9
9
  */
10
10
  import { Popover } from "@base-ui/react/popover";
11
- import { getAPCAContrast, getContrastRatio, isAPCAAvailable, VALID_SHADES, } from "@designtools/tokens";
12
- import { ColorInput, Field, POPUP, readStored, Row, Segmented, Select, subscribeStored, THEME_KEY, Tip, TipProvider, ToolRoot, usePortalContainer, writeStored } from "@designtools/widgets";
13
- import { Bot, Check, Moon, Palette, Plus, RotateCcw, SlidersHorizontal, Sun, Trash2 } from "lucide-react";
11
+ import { getAPCAContrast, getContrastRatio, VALID_SHADES, } from "@designtools/tokens";
12
+ import { ColorInput, Field, POPUP, readStored, Segmented, Select, subscribeStored, THEME_KEY, Tip, TipProvider, ToolRoot, usePortalContainer, writeStored } from "@designtools/widgets";
13
+ import { Bot, Check, Gauge, Moon, Palette, Plus, RotateCcw, SlidersHorizontal, Sun, Trash2 } from "lucide-react";
14
14
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
15
15
  import { createPortal } from "react-dom";
16
- import { ACTION, Compare, FamilyShapeControls, Hint, Pins, SystemShape, Versions } from "./colour-controls.js";
16
+ import { ACTION, Compare, FamilyShapeControls, Hint, Pins, Versions } from "./colour-controls.js";
17
+ import { AddGround, Checks, GroundControls, MadeFrom, Overrides, overrideCount, PageColours, RampShape } from "./ground-controls.js";
17
18
  import { css, properties } from "./css.js";
18
19
  import { generateFromSeed } from "./seed.js";
19
20
  import { copyText } from "./clipboard.js";
@@ -27,7 +28,8 @@ const FLOORS = {
27
28
  apca: { "aa-large": 45, aa: 60, aaa: 75 },
28
29
  };
29
30
  const SHADES = VALID_SHADES.map((s) => ({ value: String(s), label: String(s) }));
30
- const BUTTON = "inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-md border border-edge bg-page px-2.5 text-[12px] font-medium text-ink shadow-xs hover:bg-scrim data-popup-open:bg-scrim outline-none focus-visible:outline-2 focus-visible:outline-sel";
31
+ /** A button set into the page: solid shades for hover and open, since the page under it may be white */
32
+ const BUTTON = "inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-md border border-edge bg-page px-2.5 text-[12px] font-medium text-ink shadow-xs hover:bg-[color-mix(in_oklab,var(--dt-ink)_10%,var(--dt-page))] data-popup-open:bg-[color-mix(in_oklab,var(--dt-ink)_14%,var(--dt-page))] outline-none focus-visible:outline-2 focus-visible:outline-sel";
31
33
  /** A button in the floating bar: no border of its own, the bar is the frame. */
32
34
  const BAR = "inline-flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg px-2.5 text-[12px] font-medium text-ink hover:bg-scrim data-popup-open:bg-scrim outline-none focus-visible:outline-2 focus-visible:outline-sel";
33
35
  /** An icon on its own in the bar. */
@@ -55,13 +57,15 @@ function Sealed({ children, style }) {
55
57
  return (_jsx(ToolRoot, { styles: STYLES, style: style ?? { display: "inline-block", verticalAlign: "middle", lineHeight: 0 }, children: _jsx(TipProvider, { children: children }) }));
56
58
  }
57
59
  /** A button that opens its settings in place, in a popover beside it. */
58
- function InPlace({ trigger, title, label, children, width = 288, bare = false, icon = false, side = "bottom", }) {
60
+ function InPlace({ trigger, title, label, children, width = 288, bare = false, icon = false, bar = false, side = "bottom", }) {
59
61
  const container = usePortalContainer();
60
62
  return (_jsxs(Popover.Root, { children: [_jsx(Popover.Trigger, { "aria-label": label, className: bare
61
63
  ? "flex size-6 cursor-pointer items-center justify-center rounded-md text-ink3 outline-none hover:bg-scrim hover:text-ink focus-visible:outline-2 focus-visible:outline-sel data-popup-open:bg-scrim data-popup-open:text-ink"
62
64
  : icon
63
65
  ? ICON
64
- : BUTTON, children: trigger }), _jsx(Popover.Portal, { container: container, children: _jsx(Popover.Positioner, { side: side, align: "end", sideOffset: side === "top" ? 10 : 6, collisionPadding: 12, positionMethod: "fixed", className: "z-50", children: _jsxs(Popover.Popup, { className: `${POPUP} flex max-h-[min(560px,calc(100vh-96px))] flex-col gap-3 overflow-y-auto p-3.5`, style: { width }, children: [_jsx(Popover.Title, { className: "text-[11px] font-semibold text-ink", children: title }), children] }) }) })] }));
66
+ : bar
67
+ ? BAR
68
+ : BUTTON, children: trigger }), _jsx(Popover.Portal, { container: container, children: _jsx(Popover.Positioner, { side: side, align: "end", sideOffset: side === "top" ? 10 : 6, collisionPadding: 12, positionMethod: "fixed", className: "z-50", children: _jsxs(Popover.Popup, { className: `${POPUP} flex max-h-[min(560px,calc(100vh-96px))] flex-col gap-3 overflow-y-auto p-3.5`, style: { width: `min(${width}px, calc(100vw - 24px))` }, children: [_jsx(Popover.Title, { className: "text-[11px] font-semibold text-ink", children: title }), children] }) }) })] }));
65
69
  }
66
70
  /** A pairing's contrast in the chosen algorithm, and whether it reaches the target. */
67
71
  function measure(fg, bg, algorithm, target) {
@@ -79,7 +83,14 @@ export function InPlaceEditor({ edit, score, clear, prompt, changes, }) {
79
83
  const pages = useAnchors("colour:page");
80
84
  const ramps = useAnchors("colour:ramp");
81
85
  const families = useAnchors("colour:family");
82
- return (_jsxs(_Fragment, { children: [pages.length > 0 && (_jsx(Sealed, { style: { position: "fixed", right: 16, bottom: 16, zIndex: 2147482000, lineHeight: 0 }, children: _jsxs("div", { role: "toolbar", "aria-label": "Colour", className: "flex max-w-[calc(100vw-32px)] items-center gap-0.5 rounded-xl border border-edge bg-page p-1 text-ink shadow-lg shadow-black/15", children: [editing && (_jsxs(_Fragment, { children: [prompt && (_jsxs(_Fragment, { children: [_jsx(CopyPrompt, { prompt: prompt, changes: changes }), _jsx(Divider, {})] })), _jsx(InPlace, { title: "Add a colour", label: "Add a colour", icon: true, side: "top", trigger: _jsx(Plus, { "aria-hidden": true, width: 15, height: 15 }), width: 300, children: _jsx(AddColour, { edit: edit }) }), prompt && (_jsx(Tip, { content: "Back to the project's colours", side: "top", children: _jsx("button", { type: "button", "aria-label": "Back to the project's colours", onClick: clear, className: ICON, children: _jsx(RotateCcw, { "aria-hidden": true, width: 14, height: 14 }) }) })), _jsx(ModeSwitch, {}), _jsxs(InPlace, { title: "Colour settings", label: "Colour settings", icon: true, side: "top", trigger: _jsx(SlidersHorizontal, { "aria-hidden": true, width: 14, height: 14 }), width: 320, children: [_jsx(Refused, { error: edit.error }), score, _jsx(SystemSettings, { edit: edit }), _jsx(Versions, { edit: edit })] }), _jsx(Divider, {})] })), _jsxs("button", { type: "button", "aria-pressed": editing, onClick: () => writeStored(EDIT_KEY, editing ? undefined : true), className: BAR, children: [editing ? _jsx(Check, { "aria-hidden": true, width: 14, height: 14 }) : _jsx(Palette, { "aria-hidden": true, width: 14, height: 14 }), editing ? "Done" : "Edit colours"] })] }) })), editing &&
86
+ const grounds = useAnchors("colour:ground");
87
+ const addGround = useAnchors("colour:grounds");
88
+ const surfaces = useAnchors("colour:surfaces");
89
+ const barPlace = useBarPlace();
90
+ const overrides = overrideCount(edit.seed);
91
+ /** A control set into the page where it belongs: a button there, its settings in a popover */
92
+ const inPlace = (els, key, render) => editing ? els.map((el, i) => createPortal(_jsx(Sealed, { children: render(el) }), el, `${key}-${el.dataset.ground ?? ""}-${i}`)) : null;
93
+ return (_jsxs(_Fragment, { children: [pages.length > 0 && (_jsx(Sealed, { style: { position: "fixed", ...barPlace, zIndex: 2147482000, lineHeight: 0 }, children: _jsxs("div", { role: "toolbar", "aria-label": "Colour", className: "flex max-w-[calc(100vw-32px)] items-center gap-0.5 rounded-xl border border-edge bg-page p-1 text-ink shadow-lg shadow-black/15", children: [editing && (_jsxs(_Fragment, { children: [prompt && (_jsxs(_Fragment, { children: [_jsx(CopyPrompt, { prompt: prompt, changes: changes }), _jsx(Divider, {})] })), _jsxs(InPlace, { title: "Made from", label: "The colours it's made from", bar: true, side: "top", trigger: "Colours", width: 380, children: [_jsx(Refused, { error: edit.error }), _jsx(MadeFrom, { edit: edit, add: _jsx(AddColour, { edit: edit }) })] }), _jsx(InPlace, { title: "Checks", label: "How colours are checked", bar: true, side: "top", trigger: "Checks", width: 380, children: _jsx(Checks, { edit: edit }) }), _jsx(InPlace, { title: "Every ramp", label: "The shape of every ramp", bar: true, side: "top", trigger: "Ramps", width: 380, children: _jsx(RampShape, { edit: edit }) }), _jsx(InPlace, { title: "Overrides", label: "Choices made by hand", bar: true, side: "top", width: 440, trigger: _jsxs(_Fragment, { children: ["Overrides", overrides > 0 && _jsx("span", { className: "rounded-full bg-scrim px-1.5 text-[10px] leading-[16px] tabular-nums", children: overrides })] }), children: _jsx(Overrides, { edit: edit }) }), _jsx(Divider, {}), prompt && (_jsx(Tip, { content: "Back to the project's colours", side: "top", children: _jsx("button", { type: "button", "aria-label": "Back to the project's colours", onClick: clear, className: ICON, children: _jsx(RotateCcw, { "aria-hidden": true, width: 14, height: 14 }) }) })), _jsx(ModeSwitch, {}), _jsxs(InPlace, { title: "Contrast and versions", label: "Contrast and versions", icon: true, side: "top", trigger: _jsx(Gauge, { "aria-hidden": true, width: 14, height: 14 }), width: 320, children: [_jsx(Refused, { error: edit.error }), score, _jsx(Versions, { edit: edit })] }), _jsx(Divider, {})] })), _jsxs("button", { type: "button", "aria-pressed": editing, onClick: () => writeStored(EDIT_KEY, editing ? undefined : true), className: BAR, children: [editing ? _jsx(Check, { "aria-hidden": true, width: 14, height: 14 }) : _jsx(Palette, { "aria-hidden": true, width: 14, height: 14 }), editing ? "Done" : "Edit colours"] })] }) })), editing &&
83
94
  ramps.map((el, i) => {
84
95
  const family = el.dataset.family ?? "";
85
96
  return editable(family, edit.seed)
@@ -89,7 +100,51 @@ export function InPlaceEditor({ edit, score, clear, prompt, changes, }) {
89
100
  families.map((el, i) => {
90
101
  const family = el.dataset.family ?? "";
91
102
  return edit.system?.semantic.light[family] ? createPortal(_jsx(Sealed, { children: _jsx(Roles, { family: family, edit: edit }) }), el, `family-${family}-${i}`) : null;
92
- })] }));
103
+ }), inPlace(grounds, "ground", (el) => {
104
+ const name = el.dataset.ground ?? "";
105
+ return (_jsx(InPlace, { title: `The ${name} ground`, label: `${name} ground settings`, width: 760, trigger: _jsxs(_Fragment, { children: [_jsx(SlidersHorizontal, { "aria-hidden": true, width: 13, height: 13 }), " Settings"] }), children: _jsx(GroundControls, { name: name, edit: edit }) }));
106
+ }), inPlace(addGround, "grounds", () => (_jsx(InPlace, { title: "Add a ground", label: "Add a ground", width: 380, trigger: _jsxs(_Fragment, { children: [_jsx(Plus, { "aria-hidden": true, width: 13, height: 13 }), " Add a ground"] }), children: _jsx(AddGround, { edit: edit }) }))), inPlace(surfaces, "surfaces", () => (_jsx(InPlace, { title: "The page's colours", label: "The page's colours", width: 640, trigger: _jsxs(_Fragment, { children: [_jsx(SlidersHorizontal, { "aria-hidden": true, width: 13, height: 13 }), " Page colours"] }), children: _jsx(PageColours, { edit: edit }) })))] }));
107
+ }
108
+ /** The gap between the bar and the page's edge, and between the bar and the design tools */
109
+ const EDGE = 16;
110
+ const GAP = 8;
111
+ /**
112
+ * Where the colour bar sits: bottom right, above the design tools' pill when it's there, or to
113
+ * the left of their panel while it's open, so the two never cover each other. Follows the dock as
114
+ * it opens, closes, grows or goes.
115
+ */
116
+ function useBarPlace() {
117
+ const [dock, setDock] = useState(null);
118
+ useEffect(() => {
119
+ let watched = null;
120
+ const size = new ResizeObserver(() => measure());
121
+ const measure = () => {
122
+ const host = document.querySelector(".designtools-dock");
123
+ if (host !== watched) {
124
+ if (watched)
125
+ size.unobserve(watched);
126
+ if (host)
127
+ size.observe(host);
128
+ watched = host;
129
+ }
130
+ const r = host?.getBoundingClientRect();
131
+ setDock((was) => {
132
+ const next = r && r.height > 0 ? { width: Math.round(r.width), height: Math.round(r.height) } : null;
133
+ return was?.width === next?.width && was?.height === next?.height ? was : next;
134
+ });
135
+ };
136
+ measure();
137
+ const appears = new MutationObserver(measure);
138
+ appears.observe(document.body, { childList: true, subtree: true });
139
+ return () => {
140
+ appears.disconnect();
141
+ size.disconnect();
142
+ };
143
+ }, []);
144
+ if (!dock)
145
+ return { right: EDGE, bottom: EDGE };
146
+ // a pill is short; the open panel is tall and the bar goes beside it
147
+ return dock.height < 80 ? { right: EDGE, bottom: EDGE + dock.height + GAP } : { right: EDGE + dock.width + GAP, bottom: EDGE };
93
148
  }
94
149
  /** A thin line between groups in the bar. */
95
150
  function Divider() {
@@ -102,7 +157,7 @@ function Divider() {
102
157
  */
103
158
  function AddColour({ edit }) {
104
159
  const colours = edit.seed.additionalColors ?? [];
105
- const taken = new Set(["primary", "neutral", "black", "white", "muted", "canvas", "surface", "overlay", "border", "input", "ring", ...STATUS, "green", "red", "yellow", ...colours.map((c) => c.name)]);
160
+ const taken = new Set(["primary", "neutral", "black", "white", "canvas", "surface", "overlay", "border", "input", "ring", ...STATUS, "green", "red", "yellow", ...colours.map((c) => c.name)]);
106
161
  const suggest = () => ["accent", "info", "highlight", "brand", "extra"].find((n) => !taken.has(n)) ?? `colour-${colours.length + 1}`;
107
162
  const [name, setName] = useState(suggest);
108
163
  const [color, setColor] = useState("#8b5cf6");
@@ -117,13 +172,46 @@ function AddColour({ edit }) {
117
172
  };
118
173
  return (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-[11px] leading-snug text-ink2", children: "A new colour beside primary and neutral: its own ramp, and a fill, subdued, hover and press, each checked for contrast." }), _jsx(Field, { label: "Name", actions: _jsx(Hint, { text: `How it's written in the code: --${name || "accent"} and bg-${name || "accent"}.` }), children: (id) => (_jsx("input", { "aria-labelledby": id, value: name, spellCheck: false, "aria-invalid": Boolean(problem), onChange: (e) => setName(e.target.value.toLowerCase().replace(/\s+/g, "-")), onKeyDown: (e) => e.key === "Enter" && add(), className: `h-8 w-full rounded-md bg-muted px-2 font-mono text-[12px] text-ink outline-none focus-visible:ring-1 focus-visible:ring-sel ${problem ? "ring-1 ring-fail" : ""}` })) }), problem && _jsx("p", { className: "text-[11px] text-fail", children: problem }), _jsx(Field, { label: "Colour", actions: _jsx(Hint, { text: "The colour it's made from. It lands on step 500; change that on its ramp once it's added." }), children: (id) => _jsx(ColorInput, { label: "New colour", labelledBy: id, value: color, onChange: setColor }) }), _jsxs("button", { type: "button", onClick: add, disabled: Boolean(problem), className: ACTION, children: [_jsx(Plus, { "aria-hidden": true, width: 13, height: 13 }), " Add ", name || "colour"] }), added && _jsxs("p", { className: "text-[11px] text-ink2", children: ["Added ", added, ": it's on the page now, with its ramp and its settings."] })] }));
119
174
  }
120
- /** Light or dark, for the page and the tools together: the same switch as the dock's, in the widget's own button. */
175
+ /** Where the docs keep their own mode, beside the project's: on <html>, and remembered */
176
+ const DOCS_THEME = { attribute: "docsTheme", storage: "docs-theme" };
177
+ const watchHtml = (cb) => {
178
+ const observer = new MutationObserver(cb);
179
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme", "data-docs-theme", "class"] });
180
+ const media = matchMedia("(prefers-color-scheme: dark)");
181
+ media.addEventListener("change", cb);
182
+ return () => {
183
+ observer.disconnect();
184
+ media.removeEventListener("change", cb);
185
+ };
186
+ };
187
+ /** Whether the page reads dark now: the docs' own mode on a docs page, else the project's */
188
+ function pageIsDark() {
189
+ const html = document.documentElement;
190
+ const docs = document.querySelector("[data-designtools]") ? html.dataset[DOCS_THEME.attribute] : undefined;
191
+ const mode = docs ?? html.dataset.theme ?? (html.classList.contains("dark") ? "dark" : undefined);
192
+ return mode === "dark" || (mode !== "light" && matchMedia("(prefers-color-scheme: dark)").matches);
193
+ }
194
+ /**
195
+ * Light or dark for the page and the tools together, in the widget's own button: the project's
196
+ * mode (through the dock's switch) and, on a docs page, the docs' own as well, so the whole page turns.
197
+ */
121
198
  function ModeSwitch() {
122
- const chosen = useSyncExternalStore(useCallback((cb) => subscribeStored((k) => k === THEME_KEY && cb()), []), () => readStored(THEME_KEY, null), () => null);
123
- const dark = chosen === "dark" ||
124
- (chosen !== "light" && (document.documentElement.dataset.theme === "dark" || (!document.documentElement.dataset.theme && matchMedia("(prefers-color-scheme: dark)").matches)));
199
+ const dark = useSyncExternalStore(watchHtml, pageIsDark, () => false);
125
200
  const label = dark ? "Light mode" : "Dark mode";
126
- return (_jsx(Tip, { content: label, side: "top", children: _jsx("button", { type: "button", "aria-label": label, onClick: () => writeStored(THEME_KEY, dark ? "light" : "dark"), className: ICON, children: dark ? _jsx(Sun, { "aria-hidden": true, width: 14, height: 14 }) : _jsx(Moon, { "aria-hidden": true, width: 14, height: 14 }) }) }));
201
+ const turn = () => {
202
+ const next = dark ? "light" : "dark";
203
+ if (document.querySelector("[data-designtools]")) {
204
+ document.documentElement.dataset[DOCS_THEME.attribute] = next;
205
+ try {
206
+ localStorage.setItem(DOCS_THEME.storage, next);
207
+ }
208
+ catch {
209
+ // storage refused: this page only
210
+ }
211
+ }
212
+ writeStored(THEME_KEY, next);
213
+ };
214
+ return (_jsx(Tip, { content: label, side: "top", children: _jsx("button", { type: "button", "aria-label": label, onClick: turn, className: ICON, children: dark ? _jsx(Sun, { "aria-hidden": true, width: 14, height: 14 }) : _jsx(Moon, { "aria-hidden": true, width: 14, height: 14 }) }) }));
127
215
  }
128
216
  /** Copy prompt in the main widget: the changes on hover, the prompt shown to copy by hand when the clipboard refuses. */
129
217
  function CopyPrompt({ prompt, changes }) {
@@ -146,22 +234,6 @@ function CopyPrompt({ prompt, changes }) {
146
234
  function editable(family, seed) {
147
235
  return family === "primary" || family === "neutral" || STATUS.includes(family) || (seed.additionalColors ?? []).some((c) => c.name === family);
148
236
  }
149
- /** The whole system: how it measures and generates, and colours to add. */
150
- function SystemSettings({ edit }) {
151
- const { seed, set } = edit;
152
- const apca = isAPCAAvailable();
153
- return (_jsxs(_Fragment, { children: [_jsx(Field, { label: "Contrast", actions: _jsx(Hint, { text: "How contrast is measured. WCAG 2 is what audits check; APCA also weighs how text looks at its size, and is optional." }), children: (id) => (_jsx(Segmented, { labelledBy: id, value: seed.contrastAlgorithm ?? "wcag", onChange: (v) => set({ contrastAlgorithm: v }), options: [{ value: "wcag", label: "WCAG 2" }, ...(apca ? [{ value: "apca", label: "APCA" }] : [])] })) }), _jsx(Field, { label: "Target", actions: _jsx(Hint, { text: "The level every label has to reach on its fill: AA large 3:1, AA 4.5:1, AAA 7:1." }), children: (id) => (_jsx(Segmented, { labelledBy: id, value: seed.contrastTarget ?? "aa", onChange: (v) => set({ contrastTarget: v }), options: [
154
- { value: "aa-large", label: "AA large" },
155
- { value: "aa", label: "AA" },
156
- { value: "aaa", label: "AAA" },
157
- ] })) }), _jsxs(Row, { children: [_jsx(Field, { label: "Lightness", actions: _jsx(Hint, { text: "How the steps are spaced. Fixed: smooth at the light end, bigger jumps in the darks. Even: more evenly spaced as the eye sees them." }), children: (id) => (_jsx(Segmented, { labelledBy: id, value: seed.lightnessStrategy ?? "fixed", onChange: (v) => set({ lightnessStrategy: v }), options: [
158
- { value: "fixed", label: "Fixed" },
159
- { value: "perceptual", label: "Even" },
160
- ] })) }), _jsx(Field, { label: "Labels on fills", actions: _jsx(Hint, { text: "The text on a filled colour. Balanced: white, black, or a tint of the colour that keeps nearly all the contrast. Strongest: always white or black." }), children: (id) => (_jsx(Segmented, { labelledBy: id, value: seed.foreground ?? "balanced", onChange: (v) => set({ foreground: v }), options: [
161
- { value: "balanced", label: "Balanced" },
162
- { value: "max", label: "Strongest" },
163
- ] })) })] }), _jsx(SystemShape, { edit: edit })] }));
164
- }
165
237
  /** Why the settings can't be generated, when they can't: a refused pin, said plainly. */
166
238
  function Refused({ error }) {
167
239
  if (!error)
@@ -1,2 +1,2 @@
1
- export const css = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;--spacing:4px;--font-weight-medium:500;--font-weight-semibold:600;--tracking-wide:.025em;--leading-snug:1.375;--leading-relaxed:1.625;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1)}}@layer utilities{.visible{visibility:visible}.fixed{position:fixed}.relative{position:relative}.z-50{z-index:50}.container{width:100%}.mx-1{margin-inline:4px}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.size-6{width:24px;height:24px}.size-7{width:28px;height:28px}.size-8{width:32px;height:32px}.h-4{height:16px}.h-5{height:20px}.h-7{height:28px}.h-8{height:32px}.h-10{height:40px}.h-14{height:56px}.h-48{height:192px}.max-h-\\[min\\(560px\\,calc\\(100vh-96px\\)\\)\\]{max-height:min(560px,100vh - 96px)}.w-8{width:32px}.w-10{width:40px}.w-\\[84px\\]{width:84px}.w-\\[340px\\]{width:340px}.w-full{width:100%}.w-px{width:1px}.max-w-\\[calc\\(100vw-32px\\)\\]{max-width:calc(100vw - 32px)}.min-w-0{min-width:0}.flex-1{flex:1}.shrink-0{flex-shrink:0}.-rotate-90{rotate:-90deg}.cursor-help{cursor:help}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-0\\.5{gap:2px}.gap-1{gap:4px}.gap-1\\.5{gap:6px}.gap-2{gap:8px}.gap-3{gap:12px}.self-start{align-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-\\[4px\\]{border-radius:4px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:8px}.rounded-md{border-radius:6px}.rounded-sm{border-radius:4px}.rounded-xl{border-radius:12px}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-edge{border-color:var(--dt-edge)}.bg-edge{background-color:var(--dt-edge)}.bg-fail\\/10{background-color:var(--dt-fail)}@supports (color:color-mix(in lab, red, red)){.bg-fail\\/10{background-color:color-mix(in oklab, var(--dt-fail) 10%, transparent)}}.bg-muted{background-color:var(--dt-muted)}.bg-page{background-color:var(--dt-page)}.bg-sel{background-color:var(--dt-sel)}.p-1{padding:4px}.p-2{padding:8px}.p-2\\.5{padding:10px}.p-3\\.5{padding:14px}.px-0{padding-inline:0}.px-1{padding-inline:4px}.px-1\\.5{padding-inline:6px}.px-2{padding-inline:8px}.px-2\\.5{padding-inline:10px}.px-3{padding-inline:12px}.py-2{padding-block:8px}.pt-1{padding-top:4px}.pt-2{padding-top:8px}.font-mono{font-family:ui-monospace,SF Mono,SFMono-Regular,Menlo,Consolas,monospace}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.leading-\\[16px\\]{--tw-leading:16px;line-height:16px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.text-fail{color:var(--dt-fail)}.text-ink{color:var(--dt-ink)}.text-ink2{color:var(--dt-ink2)}.text-ink3{color:var(--dt-ink3)}.text-ok{color:var(--dt-ok)}.text-warn{color:var(--dt-warn)}.text-white{color:#fff}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-black\\/15{--tw-shadow-color:#00000026}@supports (color:color-mix(in lab, red, red)){.shadow-black\\/15{--tw-shadow-color:color-mix(in oklab, oklab(0% none none/.15) var(--tw-shadow-alpha), transparent)}}.ring-fail{--tw-ring-color:var(--dt-fail)}.outline-1{outline-style:var(--tw-outline-style);outline-width:1px}.outline-2{outline-style:var(--tw-outline-style);outline-width:2px}.-outline-offset-1{outline-offset:calc(1px * -1)}.outline-offset-1{outline-offset:1px}.outline-black\\/10{outline-color:oklab(0% none none/.1)}.outline-sel{outline-color:var(--dt-sel)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}@media (hover:hover){.hover\\:bg-scrim:hover{background-color:var(--dt-scrim)}.hover\\:text-ink:hover{color:var(--dt-ink)}}.focus-visible\\:ring-1:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus-visible\\:ring-sel:focus-visible{--tw-ring-color:var(--dt-sel)}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:-outline-offset-2:focus-visible{outline-offset:calc(2px * -1)}.focus-visible\\:outline-sel:focus-visible{outline-color:var(--dt-sel)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-35:disabled{opacity:.35}.disabled\\:opacity-40:disabled{opacity:.4}.data-popup-open\\:bg-scrim[data-popup-open]{background-color:var(--dt-scrim)}.data-popup-open\\:text-ink[data-popup-open]{color:var(--dt-ink)}}:host{all:initial}.dt-base{all:initial;--dt-page:#fff;--dt-raised:#f8f8f9;--dt-muted:#f0f0f2;--dt-edge:#e4e4e7;--dt-ink:#09090b;--dt-ink2:#71717a;--dt-ink3:#a1a1aa;--dt-sel:#3b82f6;--dt-scrim:#0000000f;--dt-ok:#16a34a;--dt-warn:#d97706;--dt-fail:#dc2626;--dt-icon:oklch(55% 0 0);color-scheme:light;font-family:var(--font-sans);letter-spacing:normal;text-align:left;cursor:auto;color:var(--dt-ink);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:11px;font-weight:400;line-height:1.4;display:contents}.dt-base[data-theme=dark]{--dt-page:#161618;--dt-raised:#18181b;--dt-muted:#27272a;--dt-edge:#2e2e33;--dt-ink:#fafafa;--dt-ink2:#b5b5be;--dt-ink3:#9494a0;--dt-scrim:#ffffff14;--dt-ok:#4ade80;--dt-warn:#fbbf24;--dt-fail:#f87171;color-scheme:dark}@media (prefers-color-scheme:dark){.dt-base:not([data-theme=light]){--dt-page:#161618;--dt-raised:#18181b;--dt-muted:#27272a;--dt-edge:#2e2e33;--dt-ink:#fafafa;--dt-ink2:#b5b5be;--dt-ink3:#9494a0;--dt-scrim:#ffffff14;--dt-ok:#4ade80;--dt-warn:#fbbf24;--dt-fail:#f87171;color-scheme:dark}}input[type=number]::-webkit-inner-spin-button{appearance:none;margin:0}input[type=number]::-webkit-outer-spin-button{appearance:none;margin:0}\n";
1
+ export const css = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;--spacing:4px;--font-weight-medium:500;--font-weight-semibold:600;--tracking-wide:.025em;--leading-snug:1.375;--leading-relaxed:1.625;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1)}}@layer utilities{.visible{visibility:visible}.fixed{position:fixed}.relative{position:relative}.z-50{z-index:50}.container{width:100%}.mx-1{margin-inline:4px}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.size-6{width:24px;height:24px}.size-7{width:28px;height:28px}.size-8{width:32px;height:32px}.h-4{height:16px}.h-5{height:20px}.h-7{height:28px}.h-8{height:32px}.h-10{height:40px}.h-14{height:56px}.h-48{height:192px}.max-h-\\[min\\(560px\\,calc\\(100vh-96px\\)\\)\\]{max-height:min(560px,100vh - 96px)}.w-8{width:32px}.w-10{width:40px}.w-36{width:144px}.w-\\[84px\\]{width:84px}.w-\\[340px\\]{width:340px}.w-full{width:100%}.w-px{width:1px}.max-w-\\[calc\\(100vw-32px\\)\\]{max-width:calc(100vw - 32px)}.min-w-0{min-width:0}.flex-1{flex:1}.shrink-0{flex-shrink:0}.-rotate-90{rotate:-90deg}.cursor-help{cursor:help}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.grid-cols-\\[minmax\\(0\\,1\\.4fr\\)_minmax\\(0\\,1fr\\)_minmax\\(0\\,0\\.8fr\\)\\]{grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) minmax(0,.8fr)}.grid-cols-\\[minmax\\(0\\,1fr\\)_5\\.5rem\\]{grid-template-columns:minmax(0,1fr) 5.5rem}.grid-cols-\\[repeat\\(auto-fit\\,minmax\\(13rem\\,1fr\\)\\)\\]{grid-template-columns:repeat(auto-fit,minmax(13rem,1fr))}.grid-cols-\\[repeat\\(auto-fit\\,minmax\\(16rem\\,1fr\\)\\)\\]{grid-template-columns:repeat(auto-fit,minmax(16rem,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-0\\.5{gap:2px}.gap-1{gap:4px}.gap-1\\.5{gap:6px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-4{gap:16px}.self-start{align-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-\\[4px\\]{border-radius:4px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:8px}.rounded-md{border-radius:6px}.rounded-sm{border-radius:4px}.rounded-xl{border-radius:12px}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-edge{border-color:var(--dt-edge)}.bg-edge{background-color:var(--dt-edge)}.bg-fail\\/10{background-color:var(--dt-fail)}@supports (color:color-mix(in lab, red, red)){.bg-fail\\/10{background-color:color-mix(in oklab, var(--dt-fail) 10%, transparent)}}.bg-muted{background-color:var(--dt-muted)}.bg-page{background-color:var(--dt-page)}.bg-scrim{background-color:var(--dt-scrim)}.bg-sel{background-color:var(--dt-sel)}.p-1{padding:4px}.p-2{padding:8px}.p-2\\.5{padding:10px}.p-3\\.5{padding:14px}.px-0{padding-inline:0}.px-1{padding-inline:4px}.px-1\\.5{padding-inline:6px}.px-2{padding-inline:8px}.px-2\\.5{padding-inline:10px}.px-3{padding-inline:12px}.py-1\\.5{padding-block:6px}.py-2{padding-block:8px}.pt-1{padding-top:4px}.pt-2{padding-top:8px}.pt-2\\.5{padding-top:10px}.pt-3{padding-top:12px}.font-mono{font-family:ui-monospace,SF Mono,SFMono-Regular,Menlo,Consolas,monospace}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.leading-\\[16px\\]{--tw-leading:16px;line-height:16px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.text-fail{color:var(--dt-fail)}.text-ink{color:var(--dt-ink)}.text-ink2{color:var(--dt-ink2)}.text-ink3{color:var(--dt-ink3)}.text-ok{color:var(--dt-ok)}.text-warn{color:var(--dt-warn)}.text-white{color:#fff}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-black\\/15{--tw-shadow-color:#00000026}@supports (color:color-mix(in lab, red, red)){.shadow-black\\/15{--tw-shadow-color:color-mix(in oklab, oklab(0% none none/.15) var(--tw-shadow-alpha), transparent)}}.ring-fail{--tw-ring-color:var(--dt-fail)}.outline-1{outline-style:var(--tw-outline-style);outline-width:1px}.outline-2{outline-style:var(--tw-outline-style);outline-width:2px}.-outline-offset-1{outline-offset:calc(1px * -1)}.outline-offset-1{outline-offset:1px}.outline-black\\/10{outline-color:oklab(0% none none/.1)}.outline-sel{outline-color:var(--dt-sel)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}@media (hover:hover){.hover\\:bg-\\[color-mix\\(in_oklab\\,var\\(--dt-ink\\)_10\\%\\,var\\(--dt-page\\)\\)\\]:hover{background-color:var(--dt-ink)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-\\[color-mix\\(in_oklab\\,var\\(--dt-ink\\)_10\\%\\,var\\(--dt-page\\)\\)\\]:hover{background-color:color-mix(in oklab,var(--dt-ink) 10%,var(--dt-page))}}.hover\\:bg-scrim:hover{background-color:var(--dt-scrim)}.hover\\:text-ink:hover{color:var(--dt-ink)}}.focus-visible\\:ring-1:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus-visible\\:ring-sel:focus-visible{--tw-ring-color:var(--dt-sel)}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:-outline-offset-2:focus-visible{outline-offset:calc(2px * -1)}.focus-visible\\:outline-sel:focus-visible{outline-color:var(--dt-sel)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-35:disabled{opacity:.35}.disabled\\:opacity-40:disabled{opacity:.4}.data-popup-open\\:bg-\\[color-mix\\(in_oklab\\,var\\(--dt-ink\\)_14\\%\\,var\\(--dt-page\\)\\)\\][data-popup-open]{background-color:var(--dt-ink)}@supports (color:color-mix(in lab, red, red)){.data-popup-open\\:bg-\\[color-mix\\(in_oklab\\,var\\(--dt-ink\\)_14\\%\\,var\\(--dt-page\\)\\)\\][data-popup-open]{background-color:color-mix(in oklab,var(--dt-ink) 14%,var(--dt-page))}}.data-popup-open\\:bg-scrim[data-popup-open]{background-color:var(--dt-scrim)}.data-popup-open\\:text-ink[data-popup-open]{color:var(--dt-ink)}}:host{all:initial}.dt-base{all:initial;--dt-page:#fff;--dt-raised:#f8f8f9;--dt-muted:#f0f0f2;--dt-edge:#e4e4e7;--dt-ink:#09090b;--dt-ink2:#71717a;--dt-ink3:#a1a1aa;--dt-sel:#3b82f6;--dt-scrim:#0000000f;--dt-ok:#16a34a;--dt-warn:#d97706;--dt-fail:#dc2626;--dt-icon:oklch(55% 0 0);color-scheme:light;font-family:var(--font-sans);letter-spacing:normal;text-align:left;cursor:auto;color:var(--dt-ink);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:11px;font-weight:400;line-height:1.4;display:contents}.dt-base[data-theme=dark]{--dt-page:#161618;--dt-raised:#18181b;--dt-muted:#27272a;--dt-edge:#2e2e33;--dt-ink:#fafafa;--dt-ink2:#b5b5be;--dt-ink3:#9494a0;--dt-scrim:#ffffff14;--dt-ok:#4ade80;--dt-warn:#fbbf24;--dt-fail:#f87171;color-scheme:dark}@media (prefers-color-scheme:dark){.dt-base:not([data-theme=light]){--dt-page:#161618;--dt-raised:#18181b;--dt-muted:#27272a;--dt-edge:#2e2e33;--dt-ink:#fafafa;--dt-ink2:#b5b5be;--dt-ink3:#9494a0;--dt-scrim:#ffffff14;--dt-ok:#4ade80;--dt-warn:#fbbf24;--dt-fail:#f87171;color-scheme:dark}}input[type=number]::-webkit-inner-spin-button{appearance:none;margin:0}input[type=number]::-webkit-outer-spin-button{appearance:none;margin:0}\n";
2
2
  export const properties = "@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}\n@property --tw-leading{syntax:\"*\";inherits:false}\n@property --tw-font-weight{syntax:\"*\";inherits:false}\n@property --tw-tracking{syntax:\"*\";inherits:false}\n@property --tw-ordinal{syntax:\"*\";inherits:false}\n@property --tw-slashed-zero{syntax:\"*\";inherits:false}\n@property --tw-numeric-figure{syntax:\"*\";inherits:false}\n@property --tw-numeric-spacing{syntax:\"*\";inherits:false}\n@property --tw-numeric-fraction{syntax:\"*\";inherits:false}\n@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-shadow-color{syntax:\"*\";inherits:false}\n@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}\n@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}\n@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}\n@property --tw-ring-color{syntax:\"*\";inherits:false}\n@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-inset-ring-color{syntax:\"*\";inherits:false}\n@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-ring-inset{syntax:\"*\";inherits:false}\n@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}\n@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}\n@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}\n@property --tw-outline-style{syntax:\"*\";inherits:false;initial-value:solid}";
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The colour editor's controls for what sits around the colours: grounds (a section painted one
3
+ * step of a ramp), the page's own colours and the surfaces a project adds, and the generator's
4
+ * inputs set apart from the overrides laid on top of what it chooses. Each is a change to the seed.
5
+ */
6
+ import { type SeedFile } from "@designtools/tokens";
7
+ import { type ReactNode } from "react";
8
+ import { type Edit } from "./colour-controls.js";
9
+ /** A panel set into the page, rather than a popover: the same look as the bar's. */
10
+ export declare const PANEL = "flex min-w-0 flex-col gap-3 rounded-xl border border-edge bg-page p-3.5 text-ink shadow-sm";
11
+ /** The defaults every ground starts from: where its text, and its lines and panels, come from. */
12
+ export declare function GroundDefaults({ edit }: {
13
+ edit: Edit;
14
+ }): import("react").JSX.Element;
15
+ /** One ground's settings, set into the page under its specimen: its colour and step, its text, its lines. */
16
+ export declare function GroundControls({ name, edit }: {
17
+ name: string;
18
+ edit: Edit;
19
+ }): import("react").JSX.Element | null;
20
+ /** A new ground: a name, the ramp it's painted and the step. */
21
+ export declare function AddGround({ edit }: {
22
+ edit: Edit;
23
+ }): import("react").JSX.Element;
24
+ /**
25
+ * The page's colours: canvas, surface and overlay in each mode, made from the neutral unless a
26
+ * colour is given; and the surfaces a project adds beside them, which follow the mode as they do.
27
+ */
28
+ export declare function PageColours({ edit }: {
29
+ edit: Edit;
30
+ }): import("react").JSX.Element;
31
+ /** The colours the generator is made from, each on its step, and a way to add one. In the bar's popover. */
32
+ export declare function MadeFrom({ edit, add }: {
33
+ edit: Edit;
34
+ add: ReactNode;
35
+ }): import("react").JSX.Element;
36
+ /** How every label is measured and what it has to reach, the screens, the everyday names, and every ground's defaults */
37
+ export declare function Checks({ edit }: {
38
+ edit: Edit;
39
+ }): import("react").JSX.Element;
40
+ /** How the twelve steps are spaced, and the shape every ramp shares */
41
+ export declare function RampShape({ edit }: {
42
+ edit: Edit;
43
+ }): import("react").JSX.Element;
44
+ /** How many choices are laid on top of the generator's, for the bar's count */
45
+ export declare const overrideCount: (seed: SeedFile) => number;
46
+ /** Every choice laid on top of the generator's, each with a way back */
47
+ export declare function Overrides({ edit }: {
48
+ edit: Edit;
49
+ }): import("react").JSX.Element;
@@ -0,0 +1,267 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ /**
4
+ * The colour editor's controls for what sits around the colours: grounds (a section painted one
5
+ * step of a ramp), the page's own colours and the surfaces a project adds, and the generator's
6
+ * inputs set apart from the overrides laid on top of what it chooses. Each is a change to the seed.
7
+ */
8
+ import { isAPCAAvailable, reservedSurfaceNames, VALID_SHADES, } from "@designtools/tokens";
9
+ import { ColorInput, Field, Row, Segmented, Select, Switch } from "@designtools/widgets";
10
+ import { Plus, RotateCcw, Trash2 } from "lucide-react";
11
+ import { useState } from "react";
12
+ import { ACTION, Hint, SystemShape } from "./colour-controls.js";
13
+ const SHADES = VALID_SHADES.map((s) => ({ value: String(s), label: String(s) }));
14
+ const NAME = /^[a-z][a-z0-9-]*$/;
15
+ const LABEL = "text-[10px] font-semibold tracking-wide text-ink3 uppercase";
16
+ const INPUT = "h-8 w-full rounded-md bg-muted px-2 font-mono text-[12px] text-ink outline-none focus-visible:ring-1 focus-visible:ring-sel";
17
+ /** A panel set into the page, rather than a popover: the same look as the bar's. */
18
+ export const PANEL = "flex min-w-0 flex-col gap-3 rounded-xl border border-edge bg-page p-3.5 text-ink shadow-sm";
19
+ /** The ramps the system has: every family with steps, decorative ones included. */
20
+ function rampsOf(edit) {
21
+ const p = edit.system?.primitives;
22
+ return p ? Object.keys(p).filter((k) => p[k] && typeof p[k] === "object") : ["primary", "neutral"];
23
+ }
24
+ /* ---------------------------------------------------------------------------------------------- */
25
+ /* Where a ground's text and lines come from */
26
+ const FILL_WORDS = { own: "Own", page: "Page", white: "White", black: "Black", step: "A step" };
27
+ /**
28
+ * One of a ground's two choices, text or lines and panels: its own ramp, the page's, white,
29
+ * black, or one step of any ramp. Shown as what applies, the default included.
30
+ */
31
+ function FillPicker({ label, hint, value, fallback, ramps, onChange, }) {
32
+ const shown = value ?? fallback;
33
+ const step = /^([a-z][\w-]*)-(\d+)$/.exec(shown);
34
+ const kind = step ? "step" : shown;
35
+ const choose = (next) => onChange(next === fallback ? undefined : next);
36
+ return (_jsx(Field, { label: label, actions: _jsx(Hint, { text: hint }), children: (id) => (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Segmented, { labelledBy: id, value: kind, onChange: (v) => choose(v === "step" ? `${ramps[0] ?? "neutral"}-500` : v), options: ["own", "page", "white", "black", "step"].map((v) => ({ value: v, label: FILL_WORDS[v] })) }), step && (_jsxs(Row, { children: [_jsx(Select, { label: `${label}: ramp`, value: step[1], options: ramps.map((r) => ({ value: r, label: r })), onChange: (r) => choose(`${r}-${step[2]}`) }), _jsx(Select, { label: `${label}: step`, value: step[2], options: SHADES, onChange: (s) => choose(`${step[1]}-${s}`) })] }))] })) }));
37
+ }
38
+ const ACTION_WORDS = { tint: "As the lines", page: "Page", own: "Own", colour: "A colour" };
39
+ const ACTION_HINT = "The main button. As the lines: it follows them. Page: the page's button as it is, a pale brand colour its label carries. Own: the ground's colour, turned over. Or one colour, with a label measured on it or chosen.";
40
+ /**
41
+ * Where a ground's main button comes from: unset (as the lines and panels), the page's, its own
42
+ * colour, or one colour with its label measured on it or chosen. Shown as what applies.
43
+ */
44
+ function ActionPicker({ value, fallback, ramps, onChange, }) {
45
+ const shown = value ?? fallback;
46
+ const [fill, label] = (shown ?? "").split("/");
47
+ const step = /^([a-z][\w-]*)-(\d+)$/.exec(fill);
48
+ const labelStep = label ? /^([a-z][\w-]*)-(\d+)$/.exec(label) : null;
49
+ const kind = !shown ? "tint" : shown === "page" || shown === "own" ? shown : "colour";
50
+ const choose = (next) => onChange(next === fallback ? undefined : next);
51
+ const colour = (f, l) => choose((l ? `${f}/${l}` : f));
52
+ return (_jsx(Field, { label: "Button", actions: _jsx(Hint, { text: ACTION_HINT }), children: (id) => (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Segmented, { labelledBy: id, value: kind, onChange: (v) => (v === "tint" ? choose(undefined) : v === "colour" ? colour("neutral-950") : choose(v)), options: ["tint", "page", "own", "colour"].map((v) => ({ value: v, label: ACTION_WORDS[v] })) }), step && (_jsxs(_Fragment, { children: [_jsxs(Row, { children: [_jsx(Select, { label: "Button: ramp", value: step[1], options: ramps.map((r) => ({ value: r, label: r })), onChange: (r) => colour(`${r}-${step[2]}`, label) }), _jsx(Select, { label: "Button: step", value: step[2], options: SHADES, onChange: (n) => colour(`${step[1]}-${n}`, label) })] }), _jsxs(Row, { children: [_jsx(Select, { label: "Button label: ramp", value: labelStep?.[1] ?? "measured", options: [{ value: "measured", label: "Label measured" }, ...ramps.map((r) => ({ value: r, label: `Label ${r}` }))], onChange: (r) => colour(fill, r === "measured" ? undefined : `${r}-${labelStep?.[2] ?? "400"}`) }), labelStep && _jsx(Select, { label: "Button label: step", value: labelStep[2], options: SHADES, onChange: (n) => colour(fill, `${labelStep[1]}-${n}`) })] })] }))] })) }));
53
+ }
54
+ const TEXT_HINT = "The text on it. Page: the page's own text, so every ground reads the same. Own: a step of the ground's ramp, its hue. Or one colour for all of it.";
55
+ const TINT_HINT = "Lines, input edges, the focus ring, cards and the buttons (unless the button says otherwise). Own: steps of the ground's ramp, in its hue. Page: the page's own lines and panels. Or one colour for every line.";
56
+ /** The defaults every ground starts from: where its text, and its lines and panels, come from. */
57
+ export function GroundDefaults({ edit }) {
58
+ const { seed, set } = edit;
59
+ const ramps = rampsOf(edit);
60
+ return (_jsxs(_Fragment, { children: [_jsxs("p", { className: `flex items-center gap-1.5 ${LABEL}`, children: ["Every ground ", _jsx(Hint, { text: "What each ground starts from. A ground can choose otherwise for itself." })] }), _jsx(FillPicker, { label: "Text", hint: TEXT_HINT, value: seed.groundText, fallback: "page", ramps: ramps, onChange: (v) => set({ groundText: v }) }), _jsx(FillPicker, { label: "Lines and panels", hint: TINT_HINT, value: seed.groundTint, fallback: "own", ramps: ramps, onChange: (v) => set({ groundTint: v }) })] }));
61
+ }
62
+ /** One ground's settings, set into the page under its specimen: its colour and step, its text, its lines. */
63
+ export function GroundControls({ name, edit }) {
64
+ const { seed, set, system } = edit;
65
+ const grounds = seed.grounds ?? {};
66
+ const spec = grounds[name];
67
+ const ramps = rampsOf(edit);
68
+ if (!spec)
69
+ return null;
70
+ const write = (patch) => {
71
+ const next = { ...spec, ...patch };
72
+ for (const k of ["tint", "text", "action"])
73
+ if (next[k] === undefined)
74
+ delete next[k];
75
+ set({ grounds: { ...grounds, [name]: next } });
76
+ };
77
+ const remove = () => {
78
+ const { [name]: _, ...rest } = grounds;
79
+ set({ grounds: Object.keys(rest).length ? rest : undefined });
80
+ };
81
+ const made = system?.grounds?.[name];
82
+ return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "grid grid-cols-[repeat(auto-fit,minmax(13rem,1fr))] gap-4", children: [_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(Field, { label: "Painted", actions: _jsx(Hint, { text: "The ramp and the step it's painted. The same in light and dark mode." }), children: (id) => (_jsxs(Row, { children: [_jsx(Select, { labelledBy: id, value: spec.ramp, options: ramps.map((r) => ({ value: r, label: r })), onChange: (ramp) => write({ ramp }) }), _jsx(Select, { label: "Step", value: String(spec.step), options: SHADES, onChange: (s) => write({ step: Number(s) }) })] })) }), _jsxs("button", { type: "button", onClick: remove, className: ACTION, children: [_jsx(Trash2, { "aria-hidden": true, width: 13, height: 13 }), " Remove ", name] })] }), _jsx(FillPicker, { label: "Text", hint: TEXT_HINT, value: spec.text, fallback: seed.groundText ?? "page", ramps: ramps, onChange: (text) => write({ text }) }), _jsx(FillPicker, { label: "Lines and panels", hint: TINT_HINT, value: spec.tint, fallback: seed.groundTint ?? "own", ramps: ramps, onChange: (tint) => write({ tint }) }), _jsx(ActionPicker, { value: spec.action, fallback: seed.groundAction, ramps: ramps, onChange: (action) => write({ action }) })] }), made?.notes.length ? (_jsx("ul", { className: "flex flex-col gap-0.5 border-t border-edge pt-2 text-[11px] leading-snug text-ink2", children: made.notes.map((n) => (_jsx("li", { children: n }, n))) })) : null] }));
83
+ }
84
+ /** A new ground: a name, the ramp it's painted and the step. */
85
+ export function AddGround({ edit }) {
86
+ const { seed, set } = edit;
87
+ const ramps = rampsOf(edit);
88
+ const grounds = seed.grounds ?? {};
89
+ const colours = ["primary", "neutral", ...(seed.additionalColors ?? []).filter((c) => !c.decorative).map((c) => c.name)];
90
+ const taken = new Set([...reservedSurfaceNames(colours), ...Object.keys(grounds), ...Object.keys(seed.pageSurfaces ?? {})]);
91
+ const free = (n) => ["band", "hero", "feature", "footer", "callout"].find((c) => !taken.has(c)) ?? `band-${n}`;
92
+ const [name, setName] = useState(() => free(Object.keys(grounds).length + 1));
93
+ const [ramp, setRamp] = useState(ramps[0] ?? "primary");
94
+ const [step, setStep] = useState(700);
95
+ const problem = !NAME.test(name) ? "Lower case letters, numbers and dashes, starting with a letter" : taken.has(name) ? "That name is taken" : null;
96
+ const add = () => {
97
+ if (problem)
98
+ return;
99
+ set({ grounds: { ...grounds, [name]: { ramp, step } } });
100
+ setName(["band", "hero", "feature", "footer", "callout"].find((c) => c !== name && !taken.has(c)) ?? `band-${Object.keys(grounds).length + 2}`);
101
+ };
102
+ return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("p", { className: `flex items-center gap-1.5 ${LABEL}`, children: ["Add a ground ", _jsx(Hint, { text: `A section painted one step of a ramp, the same in both modes. Mark it data-surface="${name || "band"}".` })] }), _jsxs("div", { className: "grid grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)_minmax(0,0.8fr)] gap-2", children: [_jsx("input", { "aria-label": "Ground name", value: name, spellCheck: false, "aria-invalid": Boolean(problem), onChange: (e) => setName(e.target.value.toLowerCase().replace(/\s+/g, "-")), onKeyDown: (e) => e.key === "Enter" && add(), className: `${INPUT} ${problem ? "ring-1 ring-fail" : ""}` }), _jsx(Select, { label: "Ramp", value: ramp, options: ramps.map((r) => ({ value: r, label: r })), onChange: setRamp }), _jsx(Select, { label: "Step", value: String(step), options: SHADES, onChange: (s) => setStep(Number(s)) })] }), problem && _jsx("p", { className: "text-[11px] text-fail", children: problem }), _jsxs("button", { type: "button", onClick: add, disabled: Boolean(problem), className: ACTION, children: [_jsx(Plus, { "aria-hidden": true, width: 13, height: 13 }), " Add ", name || "ground"] })] }));
103
+ }
104
+ /* ---------------------------------------------------------------------------------------------- */
105
+ /* The page's colours, and the surfaces a project adds */
106
+ /** `ramp@step`, read; anything else is a colour. */
107
+ const stepOf = (v) => (v ? /^([a-z][\w-]*)@(\d+)$/.exec(v) : null);
108
+ /** A page surface's value in one mode: a step of a ramp, or a colour as it is. */
109
+ function SurfaceValue({ label, value, ramps, onChange }) {
110
+ const m = stepOf(value);
111
+ return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Segmented, { label: `${label}: kind`, value: m ? "step" : "colour", onChange: (v) => onChange(v === "step" ? `${ramps.includes("neutral") ? "neutral" : ramps[0]}@100` : "#f5f5f4"), options: [
112
+ { value: "step", label: "A step" },
113
+ { value: "colour", label: "A colour" },
114
+ ] }), m ? (_jsxs(Row, { children: [_jsx(Select, { label: `${label}: ramp`, value: m[1], options: ramps.map((r) => ({ value: r, label: r })), onChange: (r) => onChange(`${r}@${m[2]}`) }), _jsx(Select, { label: `${label}: step`, value: m[2], options: SHADES, onChange: (s) => onChange(`${m[1]}@${s}`) })] })) : (_jsx(ColorInput, { label: label, value: value, onChange: onChange }))] }));
115
+ }
116
+ /**
117
+ * The page's colours: canvas, surface and overlay in each mode, made from the neutral unless a
118
+ * colour is given; and the surfaces a project adds beside them, which follow the mode as they do.
119
+ */
120
+ export function PageColours({ edit }) {
121
+ const { seed, set, system } = edit;
122
+ const ramps = rampsOf(edit);
123
+ const [mode, setMode] = useState("light");
124
+ const given = seed.surfaceColors?.[mode] ?? {};
125
+ const setColour = (key, colour) => {
126
+ const modeColours = { ...seed.surfaceColors?.[mode], [key]: colour };
127
+ if (colour === undefined)
128
+ delete modeColours[key];
129
+ const next = { ...seed.surfaceColors, [mode]: modeColours };
130
+ if (!Object.keys(modeColours).length)
131
+ delete next[mode];
132
+ set({ surfaceColors: Object.keys(next).length ? next : undefined });
133
+ };
134
+ const surfaces = seed.pageSurfaces ?? {};
135
+ const writeSurfaces = (next) => set({ pageSurfaces: Object.keys(next).length ? next : undefined });
136
+ const colours = ["primary", "neutral", ...(seed.additionalColors ?? []).filter((c) => !c.decorative).map((c) => c.name)];
137
+ const taken = new Set([...reservedSurfaceNames(colours), ...Object.keys(seed.grounds ?? {}), ...Object.keys(surfaces)]);
138
+ const nextName = ["sunken", "raised", "sidebar", "panel", "well"].find((n) => !taken.has(n)) ?? `surface-${Object.keys(surfaces).length + 1}`;
139
+ const generated = (key) => system?.semantic[mode]?.[key] ?? "#ffffff";
140
+ return (_jsx("div", { className: "flex flex-col gap-3", children: _jsxs("div", { className: "grid grid-cols-[repeat(auto-fit,minmax(16rem,1fr))] gap-4", children: [_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsxs("p", { className: `flex items-center gap-1.5 ${LABEL}`, children: ["The page ", _jsx(Hint, { text: "Made from the neutral ramp unless you give a colour. A colour given here is used as it is; the text on it is still chosen to pass." })] }), _jsx("div", { className: "w-36", children: _jsx(Segmented, { label: "Mode", value: mode, onChange: (v) => setMode(v), options: [
141
+ { value: "light", label: "Light" },
142
+ { value: "dark", label: "Dark" },
143
+ ] }) })] }), ["canvas", "surface", "overlay"].map((key) => (_jsx(Field, { label: key === "canvas" ? "Canvas, the page" : key === "surface" ? "Surface, a card" : "Overlay, a popup", actions: given[key] ? (_jsx("button", { type: "button", onClick: () => setColour(key, undefined), className: "cursor-pointer rounded-sm px-1 text-[10px] text-ink3 hover:text-ink", children: "Given \u00B7 use the generated one" })) : (_jsx("span", { className: "text-[10px] text-ink3", children: "Generated" })), children: (id) => _jsx(ColorInput, { label: key, labelledBy: id, value: given[key] ?? generated(key), onChange: (c) => setColour(key, c) }) }, key)))] }), _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("p", { className: `flex items-center gap-1.5 ${LABEL}`, children: ["Surfaces you add", " ", _jsx(Hint, { text: "More page surfaces beside canvas, surface and overlay: a sidebar, a sunken well. Each follows the mode and gets a text colour; the dark one is the mirror step unless you set it." })] }), Object.entries(surfaces).map(([name, v]) => (_jsxs("div", { className: "flex flex-col gap-2 border-t border-edge pt-2.5", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsxs("code", { className: "font-mono text-[12px]", children: ["--", name] }), _jsx("button", { type: "button", "aria-label": `Remove ${name}`, onClick: () => {
144
+ const { [name]: _, ...rest } = surfaces;
145
+ writeSurfaces(rest);
146
+ }, className: "flex size-7 cursor-pointer items-center justify-center rounded-md text-ink3 hover:bg-scrim hover:text-ink", children: _jsx(Trash2, { "aria-hidden": true, width: 13, height: 13 }) })] }), _jsx(Field, { label: "Light", children: () => _jsx(SurfaceValue, { label: `${name} light`, value: v.light, ramps: ramps, onChange: (light) => writeSurfaces({ ...surfaces, [name]: { ...v, light } }) }) }), _jsx(Switch, { label: "Its own dark value", checked: v.dark !== undefined, onChange: (on) => writeSurfaces({ ...surfaces, [name]: on ? { ...v, dark: mirror(v.light) } : { light: v.light } }) }), v.dark !== undefined && (_jsx(Field, { label: "Dark", children: () => _jsx(SurfaceValue, { label: `${name} dark`, value: v.dark, ramps: ramps, onChange: (dark) => writeSurfaces({ ...surfaces, [name]: { ...v, dark } }) }) }))] }, name))), _jsxs("button", { type: "button", onClick: () => writeSurfaces({ ...surfaces, [nextName]: { light: "neutral@100" } }), className: ACTION, children: [_jsx(Plus, { "aria-hidden": true, width: 13, height: 13 }), " Add a surface"] })] })] }) }));
147
+ }
148
+ /** The step across the ramp from this one, as the generator mirrors a surface into dark mode. */
149
+ function mirror(light) {
150
+ const m = stepOf(light);
151
+ if (!m)
152
+ return light;
153
+ const i = VALID_SHADES.indexOf(Number(m[2]));
154
+ return `${m[1]}@${VALID_SHADES[VALID_SHADES.length - 1 - (i < 0 ? 0 : i)]}`;
155
+ }
156
+ /* ---------------------------------------------------------------------------------------------- */
157
+ /* The generator: its inputs, and the overrides on top */
158
+ /** A colour the generator is made from: the colour, and the step it lands on. */
159
+ function SourceColour({ name, colour, step, onColour, onStep, decorative, onDecorative, }) {
160
+ return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_5.5rem] items-end gap-2", children: [_jsx(Field, { label: name, children: (id) => _jsx(ColorInput, { label: `${name} colour`, labelledBy: id, value: colour, onChange: onColour }) }), _jsx(Select, { label: `${name} lands on`, value: String(step ?? 500), options: SHADES, onChange: (s) => onStep(Number(s)) })] }), onDecorative && _jsx(Switch, { label: "A ramp only (no fill, subdued or label)", checked: Boolean(decorative), onChange: onDecorative })] }));
161
+ }
162
+ /** What's laid on top of the generator's choices, in words, each with a way back. */
163
+ function overridesOf(seed) {
164
+ const out = [];
165
+ for (const [family, steps] of Object.entries(seed.pins ?? {})) {
166
+ for (const [step, colour] of Object.entries(steps ?? {})) {
167
+ out.push({
168
+ label: `${family} ${step} is exactly ${colour}`,
169
+ reset: (s) => {
170
+ const { [Number(step)]: _, ...rest } = s.pins?.[family] ?? {};
171
+ const pins = { ...s.pins, [family]: rest };
172
+ if (!Object.keys(rest).length)
173
+ delete pins[family];
174
+ return { pins: Object.keys(pins).length ? pins : undefined };
175
+ },
176
+ });
177
+ }
178
+ }
179
+ for (const [family, modes] of Object.entries(seed.shadeOverrides ?? {})) {
180
+ for (const mode of ["light", "dark"]) {
181
+ for (const [role, step] of Object.entries(modes?.[mode] ?? {})) {
182
+ out.push({
183
+ label: `${family} ${role === "DEFAULT" ? "fill" : role} on ${step}, ${mode}`,
184
+ reset: (s) => {
185
+ const fam = { ...s.shadeOverrides?.[family] };
186
+ const m = { ...fam[mode] };
187
+ delete m[role];
188
+ if (Object.keys(m).length)
189
+ fam[mode] = m;
190
+ else
191
+ delete fam[mode];
192
+ const all = { ...s.shadeOverrides, [family]: fam };
193
+ if (!Object.keys(fam).length)
194
+ delete all[family];
195
+ return { shadeOverrides: all };
196
+ },
197
+ });
198
+ }
199
+ }
200
+ }
201
+ for (const key of ["surfaceShadeOverrides", "utilityShadeOverrides"]) {
202
+ for (const mode of ["light", "dark"]) {
203
+ for (const [token, step] of Object.entries(seed[key]?.[mode] ?? {})) {
204
+ out.push({
205
+ label: `${token} on ${step}, ${mode}`,
206
+ reset: (s) => {
207
+ const m = { ...s[key]?.[mode] };
208
+ delete m[token];
209
+ const all = { ...s[key], [mode]: m };
210
+ if (!Object.keys(m).length)
211
+ delete all[mode];
212
+ return { [key]: Object.keys(all).length ? all : undefined };
213
+ },
214
+ });
215
+ }
216
+ }
217
+ }
218
+ for (const family of Object.keys(seed.families ?? {})) {
219
+ out.push({
220
+ label: `${family} ramp has a shape of its own`,
221
+ reset: (s) => {
222
+ const { [family]: _, ...rest } = s.families ?? {};
223
+ return { families: Object.keys(rest).length ? rest : undefined };
224
+ },
225
+ });
226
+ }
227
+ return out;
228
+ }
229
+ /** The colours the generator is made from, each on its step, and a way to add one. In the bar's popover. */
230
+ export function MadeFrom({ edit, add }) {
231
+ const { seed, set } = edit;
232
+ const colours = seed.additionalColors ?? [];
233
+ const setColour = (name, patch) => set({ additionalColors: colours.map((c) => (c.name === name ? { ...c, ...patch } : c)) });
234
+ return (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-[11px] leading-snug text-ink2", children: "Each colour is one colour on one step; the other eleven are worked out from it. A pale colour belongs on a high step (200), a dark one low (800)." }), _jsx(SourceColour, { name: "primary", colour: seed.primaryColor ?? "#3b82f6", step: seed.seedShade, onColour: (c) => set({ primaryColor: c }), onStep: (s) => set({ seedShade: s }) }), _jsx(SourceColour, { name: "neutral", colour: seed.neutralColor ?? "#737373", step: seed.neutralSeedShade, onColour: (c) => set({ neutralColor: c }), onStep: (s) => set({ neutralSeedShade: s }) }), colours.map((c) => (_jsx(SourceColour, { name: c.name, colour: c.color, step: c.seedShade, onColour: (color) => setColour(c.name, { color }), onStep: (seedShade) => setColour(c.name, { seedShade }), decorative: c.decorative, onDecorative: (on) => setColour(c.name, { decorative: on || undefined }) }, c.name))), _jsx("div", { className: "flex flex-col gap-3 border-t border-edge pt-3", children: add })] }));
235
+ }
236
+ /** How every label is measured and what it has to reach, the screens, the everyday names, and every ground's defaults */
237
+ export function Checks({ edit }) {
238
+ const { seed, set } = edit;
239
+ const apca = isAPCAAvailable();
240
+ return (_jsxs(_Fragment, { children: [_jsx(Field, { label: "Contrast", actions: _jsx(Hint, { text: "How every label is measured. WCAG 2 is what audits check; APCA also weighs how text looks at its size." }), children: (id) => (_jsx(Segmented, { labelledBy: id, value: seed.contrastAlgorithm ?? "wcag", onChange: (v) => set({ contrastAlgorithm: v }), options: [{ value: "wcag", label: "WCAG 2" }, ...(apca ? [{ value: "apca", label: "APCA" }] : [])] })) }), _jsx(Field, { label: "Target", actions: _jsx(Hint, { text: "What every label has to reach on its fill: AA large 3:1, AA 4.5:1, AAA 7:1. Only steps that pass are picked." }), children: (id) => (_jsx(Segmented, { labelledBy: id, value: seed.contrastTarget ?? "aa", onChange: (v) => set({ contrastTarget: v }), options: [
241
+ { value: "aa-large", label: "AA large" },
242
+ { value: "aa", label: "AA" },
243
+ { value: "aaa", label: "AAA" },
244
+ ] })) }), _jsx(Field, { label: "Labels on fills", actions: _jsx(Hint, { text: "Balanced: white, black, or a tint of the colour that keeps nearly all the contrast. Strongest: always white or black." }), children: (id) => (_jsx(Segmented, { labelledBy: id, value: seed.foreground ?? "balanced", onChange: (v) => set({ foreground: v }), options: [
245
+ { value: "balanced", label: "Balanced" },
246
+ { value: "max", label: "Strongest" },
247
+ ] })) }), _jsx(Field, { label: "Screens", actions: _jsx(Hint, { text: "sRGB is every screen. P3 also writes wide-gamut colours for the phones and laptops that show them." }), children: (id) => (_jsx(Segmented, { labelledBy: id, value: seed.gamut ?? "srgb", onChange: (v) => set({ gamut: v === "srgb" ? undefined : v }), options: [
248
+ { value: "srgb", label: "sRGB" },
249
+ { value: "p3", label: "P3 too" },
250
+ ] })) }), _jsx(Switch, { label: "Everyday names too (green, red, yellow)", checked: seed.aliases === true, onChange: (on) => set({ aliases: on || undefined }) }), _jsx(GroundDefaults, { edit: edit })] }));
251
+ }
252
+ /** How the twelve steps are spaced, and the shape every ramp shares */
253
+ export function RampShape({ edit }) {
254
+ const { seed, set } = edit;
255
+ return (_jsxs(_Fragment, { children: [_jsx(Field, { label: "Steps", actions: _jsx(Hint, { text: "How the twelve steps are spaced. Fixed: smooth at the light end, bigger jumps in the darks. Even: evenly spaced as the eye sees them." }), children: (id) => (_jsx(Segmented, { labelledBy: id, value: seed.lightnessStrategy ?? "fixed", onChange: (v) => set({ lightnessStrategy: v }), options: [
256
+ { value: "fixed", label: "Fixed" },
257
+ { value: "perceptual", label: "Even" },
258
+ ] })) }), _jsx(SystemShape, { edit: edit })] }));
259
+ }
260
+ /** How many choices are laid on top of the generator's, for the bar's count */
261
+ export const overrideCount = (seed) => overridesOf(seed).length;
262
+ /** Every choice laid on top of the generator's, each with a way back */
263
+ export function Overrides({ edit }) {
264
+ const { seed, set } = edit;
265
+ const overrides = overridesOf(seed);
266
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsx("p", { className: "text-[11px] leading-snug text-ink2", children: "Choices made by hand on top of the generator's: an exact colour on a step, a role on another step, a ramp shaped on its own. Take one away and the generator chooses again." }), overrides.length > 1 && (_jsx("button", { type: "button", onClick: () => set({ pins: undefined, shadeOverrides: {}, surfaceShadeOverrides: undefined, utilityShadeOverrides: undefined, families: undefined }), className: "shrink-0 cursor-pointer rounded-sm px-1 text-[10px] text-ink3 hover:text-ink", children: "Take them all away" }))] }), overrides.length ? (_jsx("ul", { className: "flex flex-col", children: overrides.map((o) => (_jsxs("li", { className: "flex items-center justify-between gap-2 border-t border-edge py-1.5 text-[11px] text-ink2", children: [_jsx("span", { className: "min-w-0 truncate font-mono", children: o.label }), _jsx("button", { type: "button", "aria-label": `Back to the generator's choice: ${o.label}`, onClick: () => set(typeof o.reset === "function" ? o.reset(seed) : o.reset), className: "flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-ink3 hover:bg-scrim hover:text-ink", children: _jsx(RotateCcw, { "aria-hidden": true, width: 12, height: 12 }) })] }, o.label))) })) : (_jsx("p", { className: "text-[11px] text-ink3", children: "None: every step is the generator's choice." }))] }));
267
+ }
@@ -1,4 +1,4 @@
1
1
  export type { ProjectSeed } from "./next.js";
2
- export { generateFromSeed, mergeSeed, type OutputFlags, optionsFromSeed, type ParsedCommand, parseCommand, seedCommand, seedJson, splitCommand, studioCss } from "./seed.js";
2
+ export { generateFromSeed, groundChoices, groundPreviewCss, mergeSeed, type OutputFlags, optionsFromSeed, type ParsedCommand, parseCommand, seedCommand, seedJson, splitCommand, studioCss } from "./seed.js";
3
3
  export { ColourGenerator } from "./studio.js";
4
4
  export { TokenStudio } from "./studio.js";