@designtools/tokens 0.16.2 → 0.17.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  Notable changes to `@designtools/tokens`. Dates are release dates; versions follow semver, with breaking changes in the minor slot while the package is pre-1.0.
4
4
 
5
+ ## 0.17.0
6
+
7
+ ### Minor Changes
8
+
9
+ - 07c46bb: Ground settings you can read, and every ground's contrast at a glance.
10
+
11
+ - **docs:** the colour page's Grounds section shows each ground as the project has it. The Treatment menu is gone: it replaced every ground's own text and lines in the samples, so changing a ground's settings looked broken while one was on. Beside each ground's name, a ring for how many of its pairings read, with how many fall short in red; hover, focus or click it for every pairing in words (text and secondary text on the ground and on a card, lines on a card, input edge, focus ring, the button and its label), its ratio, and what it needs. The editor's settings for a ground open beneath its own sample, rather than over the next one, and a ramp's beneath the ramp (a `colour:ramp-panel` anchor under each). `ScoreRing` takes an optional `label` and `title`. The docs' popovers, menus and tooltips no longer show a square of the page's background past their rounded corners.
12
+ - **tokens (studio):** a ground's settings in plain words: its background (ramp and step, explained), then Text, Lines, Cards and Button as tabs, a red dot on a tab where something falls short, each tab's choice labelled by what it sets (Text colour, Line colour) and marked *Default* or *Set here* with a way back, a menu where every option says the contrast it comes to on that ground, and under it the steps each part landed on with their contrast. A custom step is picked off the ramp itself, its steps as swatches with each one's contrast on the ground; text set to a step can pick its secondary text the same way, or have it found. Where no shade of the ground's own ramp reads on it, that option isn't offered for its text; where it's already set, the tab says what it falls back to. `groundVariant` searches one ground with other choices, without generating the whole system again.
13
+ - **tokens:** `--ground-text` set to one step (`pink=pink-800`) searches a quieter step of the same ramp for secondary text, where it used to repeat the body colour; or name both after a slash, `pink=pink-900/pink-700`. A pairing that falls short on a ground (a text step chosen by hand: salmon 700 on salmon 400 is 3.39:1) is now a warning on stderr every run, not only under `--report`; the run still writes and exits 0. `groundChecks(ground, target)` lists every pairing a ground relies on with its ratio and floor. New type `GroundText`.
14
+
5
15
  ## 0.16.2
6
16
 
7
17
  ### Patch Changes
package/README.md CHANGED
@@ -191,7 +191,9 @@ A **ground** is a section painted one step of a ramp: a deep green band, a lime
191
191
  | --- | --- | --- | --- |
192
192
  | `page` | the page's text wherever it reads on the ground; white or black where it doesn't. Muted text the page's, or the neutral's nearest that reads | the page's own lines, input and ring | the page's card and quiet panel |
193
193
  | `own` | steps from the ground's ramp, searched to the text floors | steps from the ground's ramp, each searched to its floor: a deeper green line on green | a step off the ground on its ramp, as far from it as the page's card is from the page: a lighter green card on deep green |
194
- | one colour: `white`, `black`, or a step (`sage-100`) | that colour for body and secondary text both (the report says secondary text is then no quieter) | as `own`, with that colour for every line, edge and ring: white lines on deep green | that colour for the card and the quiet panel, their text the ground's where it reads and white or black where it doesn't. The report notes a card that doesn't draw against the ground |
194
+ | one colour: `white`, `black`, or a step (`sage-100`) | that colour for body text. Under a step, secondary text is a quieter step of the same ramp that still reads (`pink-800` on pink 300: pink 700); under white or black it is that colour too (the report says it is then no quieter). Or name both, body then secondary: `pink-900/pink-700` | as `own`, with that colour for every line, edge and ring: white lines on deep green | that colour for the card and the quiet panel, their text the ground's where it reads and white or black where it doesn't. The report notes a card that doesn't draw against the ground |
195
+
196
+ **A colour chosen by hand is written as asked, and measured.** Every pairing a ground's content relies on (text and secondary text on the ground and its card, the hairline on the card, the input edge and ring, the main button and its label) is checked against its floor on every run, and one that falls short is a warning on stderr, `--report` or not: `warning: ground salmon: text (--canvas-foreground) is 3.39:1 on --canvas, under 4.5:1`. The run still writes the file and exits 0. `groundChecks(ground, target)` returns the same list, for a tool to show.
195
197
 
196
198
  **A ground's hairline reads on its card.** Under `tint own` the border keeps the separation the page's has from the page, and then at least 1.5:1 against the ground's card, so a card's edge and a rule inside it still show: on a deep navy band with a navy-700 card, navy-500 rather than 600 (1.39:1, all but gone). It is the gentlest step of its ramp that reaches that, never fading on the ground to do it, so it stays a hairline, well under an input's 3:1. Under `tint page` or one colour the lines are as asked, and the report notes a border under 1.5:1 on the card.
197
199
 
@@ -1372,6 +1372,7 @@ function buildGround(name, given, tiers, views, options) {
1372
1372
  const tint = given.tint ?? options?.groundTint ?? "own";
1373
1373
  const panels = given.panels ?? options?.groundPanels ?? (tint === "page" ? "page" : "own");
1374
1374
  const text = given.text ?? options?.groundText ?? "page";
1375
+ const [bodyText, secondaryText] = text.split("/");
1375
1376
  const action = given.action ?? options?.groundAction;
1376
1377
  const notes = [];
1377
1378
  const bestEnd = (on) => cr({ type: "white" }, on) >= cr({ type: "black" }, on) ? { type: "white" } : { type: "black" };
@@ -1379,7 +1380,8 @@ function buildGround(name, given, tiers, views, options) {
1379
1380
  const colors = semanticColors(tier.semantic);
1380
1381
  const page = baseRefs(tier, colors, active);
1381
1382
  const base = colors.includes(given.ramp) ? page : { ...page, ...rampRefs(given.ramp, step, light, srgb, active) };
1382
- const rampSteps = active.filter((s) => scale[s] !== void 0).map((s) => shade(given.ramp, s));
1383
+ const steps = (colorName) => active.filter((s) => srgb[colorName]?.[s] !== void 0).map((s) => shade(colorName, s));
1384
+ const rampSteps = steps(given.ramp);
1383
1385
  let body;
1384
1386
  if (text === "page") {
1385
1387
  body = cr(page["canvas-foreground"], ground) >= textFloor ? page["canvas-foreground"] : bestEnd(ground);
@@ -1387,9 +1389,9 @@ function buildGround(name, given, tiers, views, options) {
1387
1389
  const reads = rampSteps.filter((r) => cr(r, ground) >= BODY_AIM);
1388
1390
  body = reads.sort((a, b) => cr(a, ground) - cr(b, ground))[0] ?? rampSteps.filter((r) => cr(r, ground) >= textFloor).sort((a, b) => cr(b, ground) - cr(a, ground))[0] ?? bestEnd(ground);
1389
1391
  } else {
1390
- body = fillRef(text, srgb);
1392
+ body = fillRef(bodyText, srgb);
1391
1393
  }
1392
- if (cr(body, ground) < textFloor) notes.push(`canvas-foreground: ${cr(body, ground).toFixed(2)}:1, under ${textFloor}:1`);
1394
+ if (cr(body, ground) < textFloor) notes.push(`canvas-foreground: ${bodyText === "page" || bodyText === "own" ? "" : `${bodyText} is `}${cr(body, ground).toFixed(2)}:1 on the ground, under ${textFloor}:1`);
1393
1395
  const search = (family) => searchGround(
1394
1396
  { name, canvas: ground, foreground: body, family, textFamily: text === "own" ? given.ramp : "neutral", ramp: given.ramp, ...action ? { action } : {} },
1395
1397
  base,
@@ -1453,20 +1455,29 @@ function buildGround(name, given, tiers, views, options) {
1453
1455
  refs.canvas = ground;
1454
1456
  refs["canvas-foreground"] = body;
1455
1457
  refs["surface-foreground"] = cr(body, refs.surface) >= textFloor ? body : bestEnd(refs.surface);
1456
- const textPool = text === "own" ? rampSteps : active.map((s) => shade("neutral", s));
1458
+ const bodyRamp = body.type === "shade" && bodyText !== "page" && bodyText !== "own" ? body.colorName : void 0;
1459
+ const textPool = text === "own" ? rampSteps : bodyRamp ? steps(bodyRamp) : active.map((s) => shade("neutral", s));
1460
+ const givenSecondary = secondaryText ? fillRef(secondaryText, srgb) : void 0;
1457
1461
  const secondary = (key, on) => {
1458
1462
  const token = `${key}-foreground-secondary`;
1459
1463
  const bodyOn = refs[`${key}-foreground`];
1460
- if (text !== "page" && text !== "own") {
1464
+ const bodyContrast = cr(bodyOn, on);
1465
+ const reads = (r) => cr(r, on) >= secondaryFloor && cr(r, on) < bodyContrast;
1466
+ if (givenSecondary) {
1467
+ if (key === "canvas" || cr(givenSecondary, on) >= secondaryFloor) {
1468
+ refs[token] = givenSecondary;
1469
+ if (cr(givenSecondary, on) < secondaryFloor) notes.push(`${token}: ${secondaryText} is ${cr(givenSecondary, on).toFixed(2)}:1 on the ${key === "canvas" ? "ground" : "card"}, under ${secondaryFloor}:1`);
1470
+ return;
1471
+ }
1472
+ } else if (bodyText === "white" || bodyText === "black") {
1461
1473
  refs[token] = bodyOn;
1462
- notes.push(`${token}: one colour (${text}) for all text, so secondary text is no quieter than body text`);
1474
+ notes.push(`${token}: one colour (${bodyText}) for all text, so secondary text is no quieter than body text`);
1463
1475
  return;
1464
1476
  }
1465
- const bodyContrast = cr(bodyOn, on);
1466
- const reads = (r) => cr(r, on) >= secondaryFloor && cr(r, on) < bodyContrast;
1467
1477
  const aim = Math.max(secondaryFloor, Math.min(7, bodyContrast * 0.65));
1468
1478
  const kept = text === "page" && reads(page[token]) ? page[token] : void 0;
1469
- const found = kept ?? textPool.filter(reads).sort((a, b) => Math.abs(cr(a, on) - aim) - Math.abs(cr(b, on) - aim))[0];
1479
+ const pool = givenSecondary?.type === "shade" ? steps(givenSecondary.colorName) : textPool;
1480
+ const found = kept ?? pool.filter(reads).sort((a, b) => Math.abs(cr(a, on) - aim) - Math.abs(cr(b, on) - aim))[0];
1470
1481
  if (found) refs[token] = found;
1471
1482
  else {
1472
1483
  refs[token] = bodyOn;
@@ -1500,6 +1511,26 @@ function buildGround(name, given, tiers, views, options) {
1500
1511
  notes
1501
1512
  };
1502
1513
  }
1514
+ function groundChecks(ground, target = "aa") {
1515
+ const textFloor = TEXT_FLOOR[target];
1516
+ const secondaryFloor = target === "aaa" ? 7 : 4.5;
1517
+ const t2 = ground.tokens;
1518
+ const pairs = [
1519
+ ["Text", "canvas-foreground", "canvas", textFloor],
1520
+ ["Secondary text", "canvas-foreground-secondary", "canvas", secondaryFloor],
1521
+ ["Text on a card", "surface-foreground", "surface", textFloor],
1522
+ ["Secondary text on a card", "surface-foreground-secondary", "surface", secondaryFloor],
1523
+ ["Lines on a card", "border", "surface", BORDER_FLOOR],
1524
+ ["An input's edge", "input", "canvas", FILL_FLOOR],
1525
+ ["Focus ring", "ring", "canvas", FILL_FLOOR],
1526
+ ["The button", "primary", "canvas", FILL_FLOOR],
1527
+ ["The button's label", "primary-foreground", "primary", textFloor]
1528
+ ];
1529
+ return pairs.filter(([, token, on]) => t2[token] && t2[on]).map(([job, token, on, floor]) => {
1530
+ const ratio = getContrastRatio(t2[token], t2[on]);
1531
+ return { job, token, on, ratio, floor, pass: ratio >= floor };
1532
+ });
1533
+ }
1503
1534
  function assertGroundsShape(options) {
1504
1535
  if (typeof options?.grounds === "string") {
1505
1536
  throw new Error(`grounds: "${options.grounds}" is 0.11's setting. From 0.12 grounds are declared one by one, { pine: { ramp: "pine", step: 800 } }; "text" is groundTint: "page"`);
@@ -3264,6 +3295,7 @@ export {
3264
3295
  RESERVED_COLOR_NAMES,
3265
3296
  reservedColorReason,
3266
3297
  suggestStep,
3298
+ groundChecks,
3267
3299
  generateGroundTokens,
3268
3300
  generateTokens,
3269
3301
  usageReport,
package/dist/cli.js CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  familiesOf,
26
26
  generateTokens,
27
27
  getContrastRatio,
28
+ groundChecks,
28
29
  isAPCAAvailable,
29
30
  isInGamut,
30
31
  isOwnedScale,
@@ -48,7 +49,7 @@ import {
48
49
  usageReport,
49
50
  verifyScale,
50
51
  withJsonProvenance
51
- } from "./chunk-PG4SXPRL.js";
52
+ } from "./chunk-C3Y7QA7F.js";
52
53
 
53
54
  // src/cli.ts
54
55
  import { parseArgs as parseArgs2 } from "util";
@@ -387,8 +388,11 @@ Seeds:
387
388
  --ground-text <fill> or <name>=<fill>
388
389
  Where a ground's body and secondary text come from. page
389
390
  (default): the page's, where it reads; white or black
390
- where it doesn't. own: steps on its ramp. Or one
391
- colour for both. Repeatable, as --ground-tint.
391
+ where it doesn't. own: steps on its ramp. Or a step
392
+ (pink-800), with secondary text searched along its
393
+ ramp, a quieter step that still reads; or body and
394
+ secondary after a slash (pink-800/pink-700); or white
395
+ or black for both. Repeatable, as --ground-tint.
392
396
  --ground-action <action> or <name>=<action>
393
397
  Where a ground's main button (--primary, its label and
394
398
  states) comes from. Unset, it follows the tint. page:
@@ -771,6 +775,14 @@ function validateFill(flag, raw) {
771
775
  if (v === "page" || v === "own" || v === "white" || v === "black" || /^[a-z][a-z0-9-]*-\d+$/.test(v)) return v;
772
776
  fail(`--${flag} must be page, own, white, black or a step such as sage-100 (got "${raw}")`);
773
777
  }
778
+ function validateText(flag, raw) {
779
+ const v = raw.trim();
780
+ const colour = (c) => c === "white" || c === "black" || /^[a-z][a-z0-9-]*-\d+$/.test(c);
781
+ const [body, secondary, extra] = v.split("/");
782
+ if (secondary !== void 0 && colour(body) && colour(secondary) && extra === void 0) return v;
783
+ if (secondary === void 0) return validateFill(flag, v);
784
+ fail(`--${flag} must be page, own, white, black, a step such as sage-100, or body and secondary text after a slash (pink-800/pink-700) (got "${raw}")`);
785
+ }
774
786
  function validateAction(flag, raw) {
775
787
  const v = raw.trim();
776
788
  const colour = (c) => c === "white" || c === "black" || /^[a-z][a-z0-9-]*-\d+$/.test(c);
@@ -805,16 +817,17 @@ for (const entry of values.ground ?? []) {
805
817
  grounds[name] = { ...rampStep(`--ground ${name}`, entry.slice(eq + 1)), ...tint ? { tint } : {}, ...panels ? { panels } : {}, ...text ? { text } : {}, ...action ? { action } : {} };
806
818
  }
807
819
  function fills(flag, key, seeded, fallback) {
820
+ const validate = (f, raw) => key === "text" ? validateText(f, raw) : validateFill(f, raw);
808
821
  let all = seeded ?? fallback;
809
822
  for (const entry of values[flag] ?? []) {
810
823
  const eq = entry.indexOf("=");
811
824
  if (eq === -1) {
812
- all = validateFill(flag, entry);
825
+ all = validate(flag, entry);
813
826
  continue;
814
827
  }
815
828
  const name = entry.slice(0, eq).trim();
816
829
  if (!grounds[name]) fail(`--${flag} names no ground: ${name} (grounds: ${Object.keys(grounds).join(", ") || "none"})`);
817
- grounds[name] = { ...grounds[name], [key]: validateFill(`${flag} ${name}`, entry.slice(eq + 1)) };
830
+ grounds[name] = { ...grounds[name], [key]: validate(`${flag} ${name}`, entry.slice(eq + 1)) };
818
831
  }
819
832
  return all;
820
833
  }
@@ -1035,6 +1048,13 @@ try {
1035
1048
  if (error instanceof APCAUnavailableError) throw error;
1036
1049
  fail(error.message);
1037
1050
  }
1051
+ for (const [name, ground] of Object.entries(tokens.grounds ?? {})) {
1052
+ for (const c of groundChecks(ground, contrastTarget)) {
1053
+ if (c.pass) continue;
1054
+ process.stderr.write(`warning: ground ${name}: ${c.job.toLowerCase()} (--${c.token}) is ${c.ratio.toFixed(2)}:1 on --${c.on}, under ${c.floor}:1
1055
+ `);
1056
+ }
1057
+ }
1038
1058
  if (families.length > 0) {
1039
1059
  const known = tokenFamilies(tokens);
1040
1060
  const unknown = families.filter((f) => !known.includes(f));
package/dist/index.d.ts CHANGED
@@ -209,6 +209,13 @@ type GroundColour = "white" | "black" | `${string}-${number}`;
209
209
  * label measured on it, or given after a slash (`neutral-950/primary-400`).
210
210
  */
211
211
  type GroundAction = "page" | "own" | GroundColour | `${GroundColour}/${GroundColour}`;
212
+ /**
213
+ * Where a ground's text comes from: a `GroundFill`, or two colours, body text then secondary text
214
+ * after a slash (`pink-800/pink-700`). One step alone (`pink-800`) is the body text, and secondary
215
+ * text is searched along the same ramp: a quieter step that still reads, or the body colour where
216
+ * none does.
217
+ */
218
+ type GroundText = GroundFill | `${GroundColour}/${GroundColour}`;
212
219
  /** A ground as declared: the ramp and step it is painted, and where its tokens come from */
213
220
  interface GroundSpec {
214
221
  ramp: string;
@@ -218,7 +225,7 @@ interface GroundSpec {
218
225
  /** Panels: the card (`--surface`) and the quiet panel (`--neutral-subdued`). Default: the page's under `tint: "page"`, else `own` */
219
226
  panels?: GroundFill;
220
227
  /** Body and secondary text. Default: `page` */
221
- text?: GroundFill;
228
+ text?: GroundText;
222
229
  /** The main button. Default: unset, following the tint */
223
230
  action?: GroundAction;
224
231
  }
@@ -243,7 +250,7 @@ interface GroundTokens {
243
250
  polarity: "light" | "dark";
244
251
  tint: GroundFill;
245
252
  panels: GroundFill;
246
- text: GroundFill;
253
+ text: GroundText;
247
254
  /** Where its main button comes from, when it doesn't follow the tint */
248
255
  action?: GroundAction;
249
256
  tokens: Record<string, string>;
@@ -454,7 +461,7 @@ interface GenerationOptions {
454
461
  /** Where every ground's panels come from, unless it says otherwise. Default: as its lines, the page's or `own` */
455
462
  groundPanels?: GroundFill;
456
463
  /** Where every ground's text comes from, unless it says otherwise. Default `page` */
457
- groundText?: GroundFill;
464
+ groundText?: GroundText;
458
465
  /** Where every ground's main button comes from, unless it says otherwise. Default: the tint's */
459
466
  groundAction?: GroundAction;
460
467
  /**
@@ -533,7 +540,7 @@ interface SavedConfig {
533
540
  grounds?: GenerationOptions["grounds"];
534
541
  groundTint?: GroundFill;
535
542
  groundPanels?: GroundFill;
536
- groundText?: GroundFill;
543
+ groundText?: GroundText;
537
544
  groundAction?: GroundAction;
538
545
  shadeOverrides: SemanticShadeOverrides;
539
546
  surfaceShadeOverrides?: GenerationOptions["surfaceShadeOverrides"];
@@ -1175,7 +1182,9 @@ declare function isAPCAAvailable(): boolean;
1175
1182
  * lines, the page's with the page's lines and the ground's own otherwise;
1176
1183
  * - text, for body and secondary text.
1177
1184
  * Each is `page` (the page's tokens, where they read), `own` (steps on the ground's ramp, each
1178
- * searched to its floor) or one colour (`white`, `black`, `sage-100`). Any other colour (accent,
1185
+ * searched to its floor) or one colour (`white`, `black`, `sage-100`). Text can also name two,
1186
+ * body then secondary (`pink-800/pink-700`); one step alone has its secondary text searched along
1187
+ * its own ramp, a quieter step that still reads. Any other colour (accent,
1179
1188
  * success, a brand's own) keeps the page's value unless that fails on the ground, and is then
1180
1189
  * searched along its own ramp.
1181
1190
  */
@@ -1207,6 +1216,24 @@ declare function reservedColorReason(name: string): string | undefined;
1207
1216
  * `--background`.
1208
1217
  */
1209
1218
  declare function suggestStep(color: string, options?: Partial<GenerationOptions>): ShadeNumber;
1219
+ /** One pairing inside a ground, measured: what it is, the two tokens, the ratio and the floor it needs */
1220
+ interface GroundCheck {
1221
+ /** What the pairing is, in words: "Text", "Secondary text on a card" */
1222
+ job: string;
1223
+ token: string;
1224
+ on: string;
1225
+ ratio: number;
1226
+ floor: number;
1227
+ pass: boolean;
1228
+ }
1229
+ /**
1230
+ * Every pairing a ground's content relies on, measured on the values it writes (sRGB): its text
1231
+ * and secondary text on the ground and on its card, the hairline on the card, the input edge and
1232
+ * the ring on the ground, and the main button on the ground with its label on it. The same floors
1233
+ * the generator searches to, so a choice made by hand (a text colour, a button) that misses one
1234
+ * shows here.
1235
+ */
1236
+ declare function groundChecks(ground: GroundTokens, target?: ContrastTarget): GroundCheck[];
1210
1237
  /**
1211
1238
  * Every ground's tokens. `views` is the palette the tokens resolve against, then any other
1212
1239
  * gamut's: a pairing must pass on every display the system is generated for.
@@ -1403,4 +1430,4 @@ interface ScaleVerdict {
1403
1430
  */
1404
1431
  declare function verifyScale(css: string): ScaleVerdict;
1405
1432
 
1406
- export { ALIAS_PAIRS, type APCAContrastResult, APCAUnavailableError, type BrandColors, type CVDType, type ChromaProfile, type ChromaShape, type ColorFormat, type ColorScale, type ContractBreak, type ContrastAlgorithm, type ContrastTarget, DEFAULT_NEUTRAL_COLOR, DEFAULT_SEED_SHADE, type Declaration, type ExportFormat, type ExportOptions, type ExtendedSemanticColor, type FamilyShape, type ForegroundRef, GENERATOR_NAME, GROUND_BASE_TOKENS, GROUND_COLOR_PARTS, GROUND_SELECTOR, type Gamut, type GamutTokens, type GenerationOptions, type GroundAction, type GroundColour, type GroundFill, type GroundRef, type GroundSpec, type GroundTokens, type HueDrift, LOCAL_TEMPLATE, type LightnessStrategy, type LocalOverride, type LocalProblem, type LocalReport, type MergeResult, OFF_SCALE_ADVICE, OWNED_SCALE_MARK, type PageContrast, type PageSurface, type PaletteOptions, type PrimitivePalette, type Provenance, RESERVED_COLOR_NAMES, SECTIONED_FORMATS, SHADE_PRESETS, type SavedConfig, type ScaleFormat, type ScaleOptions, type ScaleOverride, type ScaleTier, type ScaleTierId, type ScaleToken, type ScaleVerdict, type SeedFile, type SelectedTokens, type SemanticColorPair, type SemanticGamuts, type SemanticShadeOverrides, type SemanticTokens, type ShadeNumber, type SliceDiff, type SurfaceRef, type SurfaceShadeOverrides, type SurfaceTokens, TAILWIND_SHADES, TOKEN_SECTIONS, TYPE_STEPS, type TokenSection, type TokenSystem, type UsageReport, type UsageVerdict, type UtilityShadeOverrides, type UtilityTokens, VALID_SHADES, type VariantShadeOverrides, type WCAGContrastResult, WIDE_GAMUT_QUERY, adjustChroma, adjustLightness, aliasOf, applyScaleOverrides, checkLocalOverrides, checkRampChroma, checkSemanticContrast, checkSemanticContrastAPCA, checkSurfaceContrast, chromaShadeFor, classifyAPCALevel, computeAccessibilityScore, defaultScale, diffSlice, exportScale, exportToCss, exportToDtcg, exportToTailwindV3, exportToTailwindV4, exportTokens, externalReferences, familiesOf, familySeedShade, findContrastingColorAPCA, fingerprint, formatColorAs, formatColorShort, formatOklchInGamut, generateColorScale, generateColorScaleAPCA, generateGroundTokens, generatePrimitivePalette, generateSemanticTokens, generateSurfaceTokens, generateTokens, generateUtilityTokens, getAPCAContrast, getContrastRatio, getOklchString, getRelativeLuminance, getShade, groundTokenNames, isAPCAAvailable, isInGamut, isOwnedScale, meetsWCAG_AA, meetsWCAG_AAA, mergeSlice, modeSelectors, offScaleReason, oklchToHex, ownedScaleHeader, parseProvenance, parseToOklch, provenanceComment, rangeOf, readDeclarations, reanchorFactors, reservedColorReason, reservedSurfaceNames, resolveShades, seedFingerprint, selectTokenSections, serialiseUsage, simulateCVD, snapShade, stableStringify, stepContract, suggestStep, tokenFamilies, usageReport, verifyScale, withJsonProvenance };
1433
+ export { ALIAS_PAIRS, type APCAContrastResult, APCAUnavailableError, type BrandColors, type CVDType, type ChromaProfile, type ChromaShape, type ColorFormat, type ColorScale, type ContractBreak, type ContrastAlgorithm, type ContrastTarget, DEFAULT_NEUTRAL_COLOR, DEFAULT_SEED_SHADE, type Declaration, type ExportFormat, type ExportOptions, type ExtendedSemanticColor, type FamilyShape, type ForegroundRef, GENERATOR_NAME, GROUND_BASE_TOKENS, GROUND_COLOR_PARTS, GROUND_SELECTOR, type Gamut, type GamutTokens, type GenerationOptions, type GroundAction, type GroundCheck, type GroundColour, type GroundFill, type GroundRef, type GroundSpec, type GroundText, type GroundTokens, type HueDrift, LOCAL_TEMPLATE, type LightnessStrategy, type LocalOverride, type LocalProblem, type LocalReport, type MergeResult, OFF_SCALE_ADVICE, OWNED_SCALE_MARK, type PageContrast, type PageSurface, type PaletteOptions, type PrimitivePalette, type Provenance, RESERVED_COLOR_NAMES, SECTIONED_FORMATS, SHADE_PRESETS, type SavedConfig, type ScaleFormat, type ScaleOptions, type ScaleOverride, type ScaleTier, type ScaleTierId, type ScaleToken, type ScaleVerdict, type SeedFile, type SelectedTokens, type SemanticColorPair, type SemanticGamuts, type SemanticShadeOverrides, type SemanticTokens, type ShadeNumber, type SliceDiff, type SurfaceRef, type SurfaceShadeOverrides, type SurfaceTokens, TAILWIND_SHADES, TOKEN_SECTIONS, TYPE_STEPS, type TokenSection, type TokenSystem, type UsageReport, type UsageVerdict, type UtilityShadeOverrides, type UtilityTokens, VALID_SHADES, type VariantShadeOverrides, type WCAGContrastResult, WIDE_GAMUT_QUERY, adjustChroma, adjustLightness, aliasOf, applyScaleOverrides, checkLocalOverrides, checkRampChroma, checkSemanticContrast, checkSemanticContrastAPCA, checkSurfaceContrast, chromaShadeFor, classifyAPCALevel, computeAccessibilityScore, defaultScale, diffSlice, exportScale, exportToCss, exportToDtcg, exportToTailwindV3, exportToTailwindV4, exportTokens, externalReferences, familiesOf, familySeedShade, findContrastingColorAPCA, fingerprint, formatColorAs, formatColorShort, formatOklchInGamut, generateColorScale, generateColorScaleAPCA, generateGroundTokens, generatePrimitivePalette, generateSemanticTokens, generateSurfaceTokens, generateTokens, generateUtilityTokens, getAPCAContrast, getContrastRatio, getOklchString, getRelativeLuminance, getShade, groundChecks, groundTokenNames, isAPCAAvailable, isInGamut, isOwnedScale, meetsWCAG_AA, meetsWCAG_AAA, mergeSlice, modeSelectors, offScaleReason, oklchToHex, ownedScaleHeader, parseProvenance, parseToOklch, provenanceComment, rangeOf, readDeclarations, reanchorFactors, reservedColorReason, reservedSurfaceNames, resolveShades, seedFingerprint, selectTokenSections, serialiseUsage, simulateCVD, snapShade, stableStringify, stepContract, suggestStep, tokenFamilies, usageReport, verifyScale, withJsonProvenance };
package/dist/index.js CHANGED
@@ -59,6 +59,7 @@ import {
59
59
  getOklchString,
60
60
  getRelativeLuminance,
61
61
  getShade,
62
+ groundChecks,
62
63
  groundTokenNames,
63
64
  isAPCAAvailable,
64
65
  isInGamut,
@@ -91,7 +92,7 @@ import {
91
92
  usageReport,
92
93
  verifyScale,
93
94
  withJsonProvenance
94
- } from "./chunk-PG4SXPRL.js";
95
+ } from "./chunk-C3Y7QA7F.js";
95
96
  export {
96
97
  ALIAS_PAIRS,
97
98
  APCAUnavailableError,
@@ -153,6 +154,7 @@ export {
153
154
  getOklchString,
154
155
  getRelativeLuminance,
155
156
  getShade,
157
+ groundChecks,
156
158
  groundTokenNames,
157
159
  isAPCAAvailable,
158
160
  isInGamut,
@@ -10,11 +10,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
10
10
  import { Popover } from "@base-ui/react/popover";
11
11
  import { getAPCAContrast, getContrastRatio, VALID_SHADES, } from "@designtools/tokens";
12
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";
13
+ import { Bot, Check, Gauge, Moon, Palette, Plus, RotateCcw, SlidersHorizontal, Sun, Trash2, X } from "lucide-react";
14
14
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
15
15
  import { createPortal } from "react-dom";
16
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
+ import { AddGround, Checks, GroundControls, MadeFrom, Overrides, overrideCount, PageColours, PANEL, RampShape } from "./ground-controls.js";
18
18
  import { css, properties } from "./css.js";
19
19
  import { generateFromSeed } from "./seed.js";
20
20
  import { copyText } from "./clipboard.js";
@@ -82,8 +82,14 @@ export function InPlaceEditor({ edit, score, clear, prompt, changes, }) {
82
82
  const editing = useEditing();
83
83
  const pages = useAnchors("colour:page");
84
84
  const ramps = useAnchors("colour:ramp");
85
+ const rampPanels = useAnchors("colour:ramp-panel");
86
+ /** The ramp whose settings are open beneath it, where the page has room for them */
87
+ const [openRamp, setOpenRamp] = useState(null);
85
88
  const families = useAnchors("colour:family");
86
89
  const grounds = useAnchors("colour:ground");
90
+ const groundPanels = useAnchors("colour:ground-panel");
91
+ /** The ground whose settings are open beneath its sample, where the page has room for them */
92
+ const [openGround, setOpenGround] = useState(null);
87
93
  const addGround = useAnchors("colour:grounds");
88
94
  const surfaces = useAnchors("colour:surfaces");
89
95
  const barPlace = useBarPlace();
@@ -93,8 +99,17 @@ export function InPlaceEditor({ edit, score, clear, prompt, changes, }) {
93
99
  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 &&
94
100
  ramps.map((el, i) => {
95
101
  const family = el.dataset.family ?? "";
96
- return editable(family, edit.seed)
97
- ? createPortal(_jsx(Sealed, { children: _jsx(RampSettings, { family: family, edit: edit }) }), el, `ramp-${family}-${i}`)
102
+ if (!editable(family, edit.seed))
103
+ return null;
104
+ // a page with a place beneath each ramp opens the settings there, rather than over the ramp
105
+ const inline = rampPanels.some((p) => p.dataset.family === family);
106
+ const open = openRamp === family;
107
+ return createPortal(_jsx(Sealed, { children: inline ? (_jsx(Tip, { content: open ? "Close the settings" : "Settings", children: _jsx("button", { type: "button", "aria-expanded": open, "aria-label": `${family} ramp settings`, onClick: () => setOpenRamp(open ? null : family), "data-popup-open": open ? "" : undefined, className: "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", children: _jsx(SlidersHorizontal, { "aria-hidden": true, width: 14, height: 14 }) }) })) : (_jsx(RampSettings, { family: family, edit: edit })) }), el, `ramp-${family}-${i}`);
108
+ }), editing &&
109
+ rampPanels.map((el, i) => {
110
+ const family = el.dataset.family ?? "";
111
+ return openRamp === family && editable(family, edit.seed)
112
+ ? createPortal(_jsx(Sealed, { style: { display: "block" }, children: _jsx(RampPanel, { family: family, edit: edit, onClose: () => setOpenRamp(null) }) }), el, `ramp-panel-${family}-${i}`)
98
113
  : null;
99
114
  }), editing &&
100
115
  families.map((el, i) => {
@@ -102,8 +117,20 @@ export function InPlaceEditor({ edit, score, clear, prompt, changes, }) {
102
117
  return edit.system?.semantic.light[family] ? createPortal(_jsx(Sealed, { children: _jsx(Roles, { family: family, edit: edit }) }), el, `family-${family}-${i}`) : null;
103
118
  }), inPlace(grounds, "ground", (el) => {
104
119
  const name = el.dataset.ground ?? "";
120
+ // a page with a place beneath each sample opens the settings there, beside the sample they
121
+ // change, rather than in a popover over the next one
122
+ if (groundPanels.some((p) => p.dataset.ground === name)) {
123
+ const open = openGround === name;
124
+ return (_jsxs("button", { type: "button", "aria-expanded": open, "aria-label": `${name} ground settings`, onClick: () => setOpenGround(open ? null : name), className: BUTTON, "data-popup-open": open ? "" : undefined, children: [_jsx(SlidersHorizontal, { "aria-hidden": true, width: 13, height: 13 }), " ", open ? "Close" : "Settings"] }));
125
+ }
105
126
  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 }) })))] }));
127
+ }), editing &&
128
+ groundPanels.map((el, i) => {
129
+ const name = el.dataset.ground ?? "";
130
+ return openGround === name
131
+ ? createPortal(_jsx(Sealed, { style: { display: "block" }, children: _jsx("div", { className: PANEL, role: "region", "aria-label": `${name} ground settings`, children: _jsx(GroundControls, { name: name, edit: edit, onClose: () => setOpenGround(null) }) }) }), el, `ground-panel-${name}-${i}`)
132
+ : null;
133
+ }), 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
134
  }
108
135
  /** The gap between the bar and the page's edge, and between the bar and the design tools */
109
136
  const EDGE = 16;
@@ -240,8 +267,11 @@ function Refused({ error }) {
240
267
  return null;
241
268
  return _jsxs("p", { className: "rounded-md bg-fail/10 px-2.5 py-2 text-[11px] leading-snug text-fail", children: ["Not applied: ", error] });
242
269
  }
243
- /** One ramp: the colour it's made from, the step that colour lands on, and, for an added colour, its name. */
244
- function RampSettings({ family, edit }) {
270
+ /**
271
+ * One ramp's settings, in two parts: what it's made from (the colour, the step it lands on, and for
272
+ * an added colour its name), and its shape and exact steps. No hooks: called inside a component.
273
+ */
274
+ function rampSettingsParts({ family, edit }) {
245
275
  const { seed, set, system } = edit;
246
276
  const colours = seed.additionalColors ?? [];
247
277
  const entry = colours.find((c) => c.name === family);
@@ -265,10 +295,25 @@ function RampSettings({ family, edit }) {
265
295
  const without = colours.filter((c) => c.name !== family);
266
296
  const anchor = ((family === "primary" ? seed.seedShade : family === "neutral" ? seed.neutralSeedShade : entry?.seedShade) ?? 500);
267
297
  const refused = edit.error?.startsWith(`${family}:`) ? edit.error.slice(family.length + 1).trim() : null;
268
- return (_jsxs(InPlace, { title: `${family.charAt(0).toUpperCase()}${family.slice(1)} ramp`, label: `${family} ramp settings`, width: 320, trigger: _jsx(SlidersHorizontal, { "aria-hidden": true, width: 14, height: 14 }), bare: true, children: [_jsx(Refused, { error: refused }), _jsx(Compare, { family: family, edit: edit }), _jsx(Field, { label: "Made from", actions: _jsx(Hint, { text: derived ? "Made from the primary until you change it here. The colour lands exactly on the step below." : "The colour this ramp is built from. It lands exactly on the step below; every other step is worked out from it." }), children: (id) => _jsx(ColorInput, { label: `${family} colour`, labelledBy: id, value: shown ?? "", onChange: setColour }) }), _jsx(Field, { label: "Lands on step", actions: _jsx(Hint, { text: "Which step the colour sits on. A dark colour belongs low (700), a pale one high (200), so the ramp has room either side." }), children: (id) => _jsx(Select, { labelledBy: id, value: String(step ?? 500), options: SHADES, onChange: setStep }) }), entry && !status && (_jsx(Field, { label: "Name", actions: _jsx(Hint, { text: `Its name in the code: --${family}, and bg-${family} in Tailwind.` }), children: (id) => (_jsx("input", { "aria-labelledby": id, value: family, spellCheck: false, "aria-invalid": !NAME.test(family), onChange: (e) => {
269
- const name = e.target.value.toLowerCase().replace(/\s+/g, "-");
270
- set({ additionalColors: colours.map((c) => (c.name === family ? { ...c, name } : c)) });
271
- }, className: "h-7 w-full rounded-md bg-muted px-2 font-mono text-[11px] text-ink outline-none focus-visible:ring-1 focus-visible:ring-sel" })) })), entry && (_jsxs("button", { type: "button", onClick: () => set({ additionalColors: without.length ? without : undefined }), className: ACTION, children: [status ? _jsx(RotateCcw, { "aria-hidden": true, width: 13, height: 13 }) : _jsx(Trash2, { "aria-hidden": true, width: 13, height: 13 }), status ? "Made from the primary again" : "Remove this colour"] })), _jsx(FamilyShapeControls, { family: family, edit: edit }), _jsx(Pins, { family: family, anchor: anchor, edit: edit })] }));
298
+ return {
299
+ refused,
300
+ made: (_jsxs(_Fragment, { children: [_jsx(Compare, { family: family, edit: edit }), _jsx(Field, { label: "Made from", actions: _jsx(Hint, { text: derived ? "Made from the primary until you change it here. The colour lands exactly on the step below." : "The colour this ramp is built from. It lands exactly on the step below; every other step is worked out from it." }), children: (id) => _jsx(ColorInput, { label: `${family} colour`, labelledBy: id, value: shown ?? "", onChange: setColour }) }), _jsx(Field, { label: "Lands on step", actions: _jsx(Hint, { text: "Which step the colour sits on. A dark colour belongs low (700), a pale one high (200), so the ramp has room either side." }), children: (id) => _jsx(Select, { labelledBy: id, value: String(step ?? 500), options: SHADES, onChange: setStep }) }), entry && !status && (_jsx(Field, { label: "Name", actions: _jsx(Hint, { text: `Its name in the code: --${family}, and bg-${family} in Tailwind.` }), children: (id) => (_jsx("input", { "aria-labelledby": id, value: family, spellCheck: false, "aria-invalid": !NAME.test(family), onChange: (e) => {
301
+ const name = e.target.value.toLowerCase().replace(/\s+/g, "-");
302
+ set({ additionalColors: colours.map((c) => (c.name === family ? { ...c, name } : c)) });
303
+ }, className: "h-7 w-full rounded-md bg-muted px-2 font-mono text-[11px] text-ink outline-none focus-visible:ring-1 focus-visible:ring-sel" })) })), entry && (_jsxs("button", { type: "button", onClick: () => set({ additionalColors: without.length ? without : undefined }), className: ACTION, children: [status ? _jsx(RotateCcw, { "aria-hidden": true, width: 13, height: 13 }) : _jsx(Trash2, { "aria-hidden": true, width: 13, height: 13 }), status ? "Made from the primary again" : "Remove this colour"] }))] })),
304
+ shape: (_jsxs(_Fragment, { children: [_jsx(FamilyShapeControls, { family: family, edit: edit }), _jsx(Pins, { family: family, anchor: anchor, edit: edit })] })),
305
+ };
306
+ }
307
+ const rampTitle = (family) => `${family.charAt(0).toUpperCase()}${family.slice(1)} ramp`;
308
+ /** A ramp's settings in a popover from its heading: for docs with no place beneath the ramp */
309
+ function RampSettings({ family, edit }) {
310
+ const { refused, made, shape } = rampSettingsParts({ family, edit });
311
+ return (_jsxs(InPlace, { title: rampTitle(family), label: `${family} ramp settings`, width: 320, trigger: _jsx(SlidersHorizontal, { "aria-hidden": true, width: 14, height: 14 }), bare: true, children: [_jsx(Refused, { error: refused }), made, shape] }));
312
+ }
313
+ /** A ramp's settings set into the page beneath it: what it's made from beside its shape and exact steps */
314
+ function RampPanel({ family, edit, onClose }) {
315
+ const { refused, made, shape } = rampSettingsParts({ family, edit });
316
+ return (_jsxs("div", { className: PANEL, role: "region", "aria-label": `${family} ramp settings`, children: [_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsxs("p", { className: "text-[12px] font-semibold text-ink", children: [rampTitle(family), " settings"] }), _jsx("button", { type: "button", onClick: onClose, "aria-label": `Close ${family} ramp settings`, className: "flex size-7 cursor-pointer items-center justify-center rounded-md text-ink3 hover:bg-scrim hover:text-ink", children: _jsx(X, { "aria-hidden": true, width: 14, height: 14 }) })] }), _jsx(Refused, { error: refused }), _jsxs("div", { className: "grid grid-cols-[repeat(auto-fit,minmax(18rem,1fr))] items-start gap-x-6 gap-y-3", children: [_jsx("div", { className: "flex min-w-0 flex-col gap-3", children: made }), _jsx("div", { className: "flex min-w-0 flex-col gap-3", children: shape })] })] }));
272
317
  }
273
318
  const ROLES = [
274
319
  { key: "DEFAULT", label: "Fill", fg: "foreground" },
@@ -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-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";
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-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-wide:.025em;--leading-tight:1.25;--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}.ml-2{margin-left:8px}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.size-1\\.5{width:6px;height:6px}.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-12{width:48px}.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\\(16rem\\,1fr\\)\\)\\]{grid-template-columns:repeat(auto-fit,minmax(16rem,1fr))}.grid-cols-\\[repeat\\(auto-fit\\,minmax\\(18rem\\,1fr\\)\\)\\]{grid-template-columns:repeat(auto-fit,minmax(18rem,1fr))}.flex-col{flex-direction:column}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.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-2\\.5{gap:10px}.gap-3{gap:12px}.gap-3\\.5{gap:14px}.gap-4{gap:16px}.gap-x-6{column-gap:24px}.gap-y-3{row-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}.rounded-l-md{border-top-left-radius:6px;border-bottom-left-radius:6px}.rounded-r-md{border-top-right-radius:6px;border-bottom-right-radius:6px}.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,.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-ink\\/40{background-color:var(--dt-ink)}@supports (color:color-mix(in lab, red, red)){.bg-ink\\/40{background-color:color-mix(in oklab, var(--dt-ink) 40%, 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{padding-block:4px}.py-1\\.5{padding-block:6px}.py-2{padding-block:8px}.py-\\[7px\\]{padding-block:7px}.pt-1{padding-top:4px}.pt-2{padding-top:8px}.pt-2\\.5{padding-top:10px}.pt-3{padding-top:12px}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SF Mono,SFMono-Regular,Menlo,Consolas,monospace}.text-\\[8px\\]{font-size:8px}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.leading-5{--tw-leading:calc(4px * 5);line-height:20px}.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)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.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,.text-ink\\/50{color:var(--dt-ink)}@supports (color:color-mix(in lab, red, red)){.text-ink\\/50{color:color-mix(in oklab, var(--dt-ink) 50%, transparent)}}.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-\\[inset_0_0_0_2px_var\\(--dt-sel\\)\\,inset_0_0_0_3px_var\\(--dt-page\\)\\]{--tw-shadow:inset 0 0 0 2px var(--tw-shadow-color,var(--dt-sel)), inset 0 0 0 3px var(--tw-shadow-color,var(--dt-page));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){.group-hover\\:shadow-\\[inset_0_0_0_1px_var\\(--dt-page\\)\\]:is(:where(.group):hover *){--tw-shadow:inset 0 0 0 1px var(--tw-shadow-color,var(--dt-page));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}}.group-focus-visible\\:shadow-\\[inset_0_0_0_2px_var\\(--dt-sel\\)\\]:is(:where(.group):focus-visible *){--tw-shadow:inset 0 0 0 2px var(--tw-shadow-color,var(--dt-sel));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}@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,.hover\\:bg-scrim\\/50:hover{background-color:var(--dt-scrim)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-scrim\\/50:hover{background-color:color-mix(in oklab, var(--dt-scrim) 50%, transparent)}}.hover\\:text-ink:hover,.hover\\:text-ink\\/70:hover{color:var(--dt-ink)}@supports (color:color-mix(in lab, red, red)){.hover\\:text-ink\\/70:hover{color:color-mix(in oklab, var(--dt-ink) 70%, transparent)}}}.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}";
@@ -8,14 +8,18 @@ import { type ReactNode } from "react";
8
8
  import { type Edit } from "./colour-controls.js";
9
9
  /** A panel set into the page, rather than a popover: the same look as the bar's. */
10
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, its lines and its panels come from. */
11
+ /** The defaults every ground starts from: where its text, its lines, its cards and its button come from. */
12
12
  export declare function GroundDefaults({ edit }: {
13
13
  edit: Edit;
14
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 }: {
15
+ /**
16
+ * One ground's settings, set into the page beneath its sample: its colour and step, then its text,
17
+ * lines, cards and button, each saying whether it's the default or set here, and what it came to.
18
+ */
19
+ export declare function GroundControls({ name, edit, onClose }: {
17
20
  name: string;
18
21
  edit: Edit;
22
+ onClose?: () => void;
19
23
  }): import("react").JSX.Element | null;
20
24
  /** A new ground: a name, the ramp it's painted and the step. */
21
25
  export declare function AddGround({ edit }: {
@@ -5,12 +5,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
5
5
  * step of a ramp), the page's own colours and the surfaces a project adds, and the generator's
6
6
  * inputs set apart from the overrides laid on top of what it chooses. Each is a change to the seed.
7
7
  */
8
- import { isAPCAAvailable, reservedSurfaceNames, VALID_SHADES, } from "@designtools/tokens";
8
+ import { getContrastRatio, groundChecks, isAPCAAvailable, reservedSurfaceNames, VALID_SHADES, } from "@designtools/tokens";
9
9
  import { ColorInput, Field, Row, Segmented, Select, Switch } from "@designtools/widgets";
10
- import { Plus, RotateCcw, Trash2 } from "lucide-react";
11
- import { useState } from "react";
10
+ import { Tabs } from "@base-ui/react/tabs";
11
+ import { Plus, RotateCcw, Trash2, X } from "lucide-react";
12
+ import { useMemo, useState } from "react";
12
13
  import { ACTION, Hint, SystemShape } from "./colour-controls.js";
13
- import { panelsFollowing } from "./seed.js";
14
+ import { groundVariant } from "./seed.js";
14
15
  const SHADES = VALID_SHADES.map((s) => ({ value: String(s), label: String(s) }));
15
16
  const NAME = /^[a-z][a-z0-9-]*$/;
16
17
  const LABEL = "text-[10px] font-semibold tracking-wide text-ink3 uppercase";
@@ -22,51 +23,176 @@ function rampsOf(edit) {
22
23
  const p = edit.system?.primitives;
23
24
  return p ? Object.keys(p).filter((k) => p[k] && typeof p[k] === "object") : ["primary", "neutral"];
24
25
  }
25
- /* ---------------------------------------------------------------------------------------------- */
26
- /* Where a ground's text and lines come from */
27
- const FILL_WORDS = { own: "Own", page: "Page", white: "White", black: "Black", step: "A step" };
26
+ const STEP = /^([a-z][\w-]*)-(\d+)$/;
27
+ /** Each of a ground's choices, in plain words: what it is and what it decides */
28
+ const ROWS = [
29
+ { key: "text", title: "Text", colour: "Text colour" },
30
+ { key: "tint", title: "Lines", colour: "Line colour" },
31
+ { key: "panels", title: "Cards", colour: "Card colour" },
32
+ { key: "action", title: "Button", colour: "Button colour" },
33
+ ];
34
+ /** The parts each choice decides, as they're named in a row's result */
35
+ const PARTS = {
36
+ text: [
37
+ { token: "canvas-foreground", word: "Text" },
38
+ { token: "canvas-foreground-secondary", word: "Secondary" },
39
+ ],
40
+ tint: [
41
+ { token: "border", word: "Lines on a card" },
42
+ { token: "input", word: "Input edge" },
43
+ { token: "ring", word: "Focus ring" },
44
+ ],
45
+ panels: [
46
+ { token: "surface", word: "Card" },
47
+ { token: "surface-foreground", word: "Card text" },
48
+ { token: "surface-foreground-secondary", word: "Card secondary" },
49
+ ],
50
+ action: [
51
+ { token: "primary", word: "Button" },
52
+ { token: "primary-foreground", word: "Label" },
53
+ ],
54
+ };
55
+ /** A step as a reader says it: `pink-800` is "pink 800" */
56
+ const stepWords = (v) => v.replace(STEP, "$1 $2");
57
+ /** A choice in plain words */
58
+ function choiceWords(key, v) {
59
+ const what = key === "text" ? "text" : key === "tint" ? "lines" : key === "panels" ? "cards" : "button, as it is";
60
+ if (v === "page")
61
+ return `The page's ${what}`;
62
+ if (v === "own")
63
+ return key === "action" ? "The ground's own colour" : "A shade of the ground's colour";
64
+ if (v === "white" || v === "black")
65
+ return v === "white" ? "White" : "Black";
66
+ const [a, b] = v.split("/");
67
+ if (b)
68
+ return key === "action" ? `${stepWords(a)}, label ${stepWords(b)}` : `${stepWords(a)}, secondary ${stepWords(b)}`;
69
+ return stepWords(a);
70
+ }
71
+ /** What a reference names: a step, white or black */
72
+ function refName(ref) {
73
+ if (!ref)
74
+ return "";
75
+ return ref.type === "shade" ? `${ref.colorName}-${ref.shade}` : ref.type === "value" ? "mixed" : ref.type;
76
+ }
77
+ /** A choice's kind, as the menu lists it */
78
+ const kindOf = (key, v) => v === undefined ? "default" : v === "page" || v === "own" || (key !== "action" && (v === "white" || v === "black")) ? v : key === "action" ? "colour" : "step";
79
+ /** The kinds each choice offers, after "default" */
80
+ const KINDS = {
81
+ text: ["page", "own", "white", "black", "step"],
82
+ tint: ["own", "page", "white", "black", "step"],
83
+ panels: ["own", "page", "white", "black", "step"],
84
+ action: ["page", "own", "colour"],
85
+ };
86
+ /** The pairing that tells whether a choice works, the worst of a row's measured parts */
87
+ function headline(key, checks) {
88
+ const mine = checks.filter((c) => PARTS[key].some((p) => p.token === c.token));
89
+ return mine.sort((a, b) => a.ratio / a.floor - b.ratio / b.floor)[0];
90
+ }
91
+ /** What "default" means for a choice: every ground's setting, or the generator's */
92
+ function fallbackWords(key, seed) {
93
+ const every = key === "text" ? seed.groundText : key === "tint" ? seed.groundTint : key === "panels" ? seed.groundPanels : seed.groundAction;
94
+ if (every)
95
+ return `Every ground's: ${choiceWords(key, every)}`;
96
+ if (key === "panels" || key === "action")
97
+ return "Follow the lines";
98
+ return choiceWords(key, key === "text" ? "page" : "own");
99
+ }
100
+ /** A part as it came out: its step, and its contrast, red where it falls short (what it needs on hover) */
101
+ function Part({ word, step, check }) {
102
+ return (_jsxs("li", { className: "flex items-baseline justify-between gap-3 text-[11px] leading-5", children: [_jsx("span", { className: "text-ink2", children: word }), _jsxs("span", { className: "flex items-baseline gap-2.5 font-mono tabular-nums", children: [_jsx("span", { className: "text-ink", children: stepWords(step) }), check && (_jsxs("span", { className: `w-12 text-right ${check.pass ? "text-ink3" : "font-semibold text-fail"}`, title: `${check.ratio.toFixed(2)}:1 against --${check.on}; needs ${check.floor}:1`, children: [check.pass ? "" : "✕ ", check.ratio.toFixed(1), ":1"] }))] })] }));
103
+ }
104
+ /**
105
+ * A step picked off a ramp: which ramp, then its steps as swatches to click, each with its number and,
106
+ * where there's something to read it on, its contrast there, red under `floor`. `none` is a choice
107
+ * before the swatches that isn't a step (secondary text found automatically).
108
+ */
109
+ function SwatchPicker({ label, value, ramps, palette, on, floor, none, onChange, }) {
110
+ const m = value ? STEP.exec(value) : null;
111
+ const ramp = m?.[1] ?? none?.ramp ?? ramps[0] ?? "neutral";
112
+ const scale = (palette?.[ramp] ?? {});
113
+ const steps = VALID_SHADES.filter((n) => typeof scale[n] === "string");
114
+ return (_jsx(Field, { label: label, actions: none && (_jsxs("button", { type: "button", "aria-pressed": none.selected, onClick: none.onSelect, className: `cursor-pointer rounded-sm px-1 text-[10px] ${none.selected ? "font-medium text-ink" : "text-ink3 hover:text-ink"}`, children: [none.selected ? "✓ " : "", none.label] })), children: (id) => (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Select, { labelledBy: id, value: ramp, options: ramps.map((r) => ({ value: r, label: r })), onChange: (r) => onChange(`${r}-${m?.[2] ?? 500}`) }), _jsx("div", { role: "radiogroup", "aria-label": `${label}: step`, className: "grid", style: { gridTemplateColumns: `repeat(${steps.length || 12}, minmax(0, 1fr))` }, children: steps.map((n) => {
115
+ const colour = scale[n];
116
+ const chosen = !none?.selected && m?.[1] === ramp && Number(m?.[2]) === n;
117
+ const ratio = on ? getContrastRatio(colour, on) : undefined;
118
+ const short = ratio !== undefined && floor !== undefined && ratio < floor;
119
+ return (_jsxs("button", { type: "button", role: "radio", "aria-checked": chosen, "aria-label": `${ramp} ${n}${ratio !== undefined ? `, ${ratio.toFixed(1)}:1${short ? `, under ${floor}:1` : ""}` : ""}`, title: `${ramp} ${n}${ratio !== undefined ? ` · ${ratio.toFixed(2)}:1 on the ground${short ? `, needs ${floor}:1` : ""}` : ""}`, onClick: () => onChange(`${ramp}-${n}`), className: "group flex min-w-0 cursor-pointer flex-col items-stretch gap-0.5 outline-none", children: [_jsx("span", { className: `h-7 ${chosen ? "shadow-[inset_0_0_0_2px_var(--dt-sel),inset_0_0_0_3px_var(--dt-page)]" : "group-hover:shadow-[inset_0_0_0_1px_var(--dt-page)] group-focus-visible:shadow-[inset_0_0_0_2px_var(--dt-sel)]"}`, style: { background: colour } }), _jsx("span", { className: `truncate text-center font-mono text-[9px] leading-tight tabular-nums ${chosen ? "font-semibold text-ink" : "text-ink3"}`, children: n }), ratio !== undefined && (_jsx("span", { className: `truncate text-center font-mono text-[8px] leading-tight tabular-nums ${short ? "text-fail" : "text-ink3"}`, children: ratio.toFixed(1) }))] }, n));
120
+ }) })] })) }));
121
+ }
28
122
  /**
29
- * One of a ground's choices, its text, its lines or its panels: its own ramp, the page's, white,
30
- * black, or one step of any ramp. Shown as what applies, the default included.
123
+ * One of a ground's choices, as a tab's panel: its colour, marked as the default or set here, in a menu where each option says what it comes to (the worst
124
+ * of its parts' contrast); and the parts as they came out, each with its step and contrast.
31
125
  */
32
- function FillPicker({ label, hint, value, fallback, keepsChoice = false, ramps, onChange, }) {
33
- const shown = value ?? fallback;
34
- const step = /^([a-z][\w-]*)-(\d+)$/.exec(shown);
35
- const kind = step ? "step" : shown;
36
- const choose = (next) => onChange(next === fallback && !keepsChoice ? undefined : next);
37
- 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}`) })] }))] })) }));
126
+ function ChoiceRow({ row, value, fallback, ramps, hints, made, checks, firstStep, palette, ground, floor, offRamp, onChange, }) {
127
+ const { key } = row;
128
+ const kind = kindOf(key, value);
129
+ const options = [
130
+ { value: "default", label: `Default · ${fallback}` },
131
+ // a choice that can't be met here (no shade of the ground's ramp reads on it) isn't offered,
132
+ // unless it's what's set, so the menu can still say so
133
+ ...KINDS[key]
134
+ .filter((k) => offRamp?.kind !== k || kind === k)
135
+ .map((k) => ({ value: k, label: k === "step" || k === "colour" ? "Custom step from a ramp" : choiceWords(key, k) })),
136
+ ].map((o) => {
137
+ const h = hints[o.value];
138
+ return h ? { ...o, hint: `${h.ratio.toFixed(1)}:1`, warn: !h.pass } : o;
139
+ });
140
+ const [body, second] = (value ?? "").split("/");
141
+ const set = value !== undefined;
142
+ return (_jsx("div", { className: "flex flex-col gap-2.5", children: _jsx(Field, { label: row.colour, actions: _jsxs("span", { className: "flex items-center gap-1.5", children: [set ? (_jsxs("button", { type: "button", onClick: () => onChange(undefined), className: "inline-flex cursor-pointer items-center gap-1 rounded-sm px-1 text-[10px] font-medium text-ink hover:bg-scrim", title: "Back to the default", children: ["Set here ", _jsx(RotateCcw, { "aria-hidden": true, width: 10, height: 10 })] })) : (_jsx("span", { className: "px-1 text-[10px] text-ink3", children: "Default" })), _jsx(Hint, { text: "Default is what applies when nothing is set here; the menu says what that is. Where it can be measured, each option shows the contrast it comes to; red falls short." })] }), children: (id) => (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Select, { labelledBy: id, value: kind, options: options, onChange: (k) => onChange(k === "default" ? undefined : k === "step" || k === "colour" ? (STEP.test(body) ? value : firstStep) : k) }), (kind === "step" || kind === "colour") && (_jsxs(_Fragment, { children: [_jsx(SwatchPicker, { label: key === "text" ? "Text ramp" : key === "action" ? "Fill ramp" : "Ramp", value: body, ramps: ramps, palette: palette, on: key === "panels" ? undefined : ground, floor: floor, onChange: (b) => onChange(second ? `${b}/${second}` : b) }), key === "text" && (_jsx(SwatchPicker, { label: "Secondary text ramp", value: second, ramps: ramps, palette: palette, on: ground, floor: floor, none: { label: "Found for you", selected: !second, onSelect: () => onChange(body), ramp: STEP.exec(body)?.[1] ?? "neutral" }, onChange: (v) => onChange(`${body}/${v}`) })), key === "action" && (_jsx(Field, { label: "Label", children: (id) => (_jsx(Select, { labelledBy: id, value: second ?? "measured", options: [
143
+ { value: "measured", label: "White or black, measured" },
144
+ { value: "white", label: "White" },
145
+ { value: "black", label: "Black" },
146
+ ...ramps.flatMap((r) => VALID_SHADES.map((n) => ({ value: `${r}-${n}`, label: `${r} ${n}` }))),
147
+ ], onChange: (v) => onChange(v === "measured" ? body : `${body}/${v}`) })) }))] })), offRamp && kind === offRamp.kind && (_jsxs("p", { className: "text-[11px] leading-snug text-ink2", children: ["No shade of ", made?.ramp, " reads on ", stepWords(`${made?.ramp}-${made?.step}`), ", so this falls back to ", offRamp.fell, "."] })), made && (_jsx("ul", { className: "flex flex-col rounded-md bg-muted px-2 py-1", children: PARTS[key].map((p) => (_jsx(Part, { word: p.word, step: refName(made._refs[p.token]), check: checks.find((c) => c.token === p.token) }, p.token))) }))] })) }) }));
38
148
  }
39
- const ACTION_WORDS = { tint: "As the lines", page: "Page", own: "Own", colour: "A colour" };
40
- 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.";
41
149
  /**
42
- * Where a ground's main button comes from: unset (as the lines and panels), the page's, its own
43
- * colour, or one colour with its label measured on it or chosen. Shown as what applies.
150
+ * A ground's four choices as tabs: Text, Lines, Cards, Button. A tab says when it's set here, and
151
+ * carries a red dot when one of its parts falls short.
44
152
  */
45
- function ActionPicker({ value, fallback, ramps, onChange, }) {
46
- const shown = value ?? fallback;
47
- const [fill, label] = (shown ?? "").split("/");
48
- const step = /^([a-z][\w-]*)-(\d+)$/.exec(fill);
49
- const labelStep = label ? /^([a-z][\w-]*)-(\d+)$/.exec(label) : null;
50
- const kind = !shown ? "tint" : shown === "page" || shown === "own" ? shown : "colour";
51
- const choose = (next) => onChange(next === fallback ? undefined : next);
52
- const colour = (f, l) => choose((l ? `${f}/${l}` : f));
53
- 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}`) })] })] }))] })) }));
153
+ function ChoiceTabs({ label, panel, status }) {
154
+ const [tab, setTab] = useState("text");
155
+ return (_jsxs(Tabs.Root, { value: tab, onValueChange: (v) => setTab(v), className: "flex flex-col gap-3", children: [_jsx(Tabs.List, { "aria-label": label, className: "flex w-full rounded-md bg-muted", children: ROWS.map((row, i) => {
156
+ const st = status?.(row.key);
157
+ return (_jsxs(Tabs.Tab, { value: row.key, className: `flex min-w-0 flex-1 cursor-pointer items-center justify-center gap-1.5 py-[7px] text-[11px] transition-colors outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-sel ${i === 0 ? "rounded-l-md" : i === ROWS.length - 1 ? "rounded-r-md" : ""} ${tab === row.key ? "bg-scrim font-medium text-ink" : "text-ink/50 hover:bg-scrim/50 hover:text-ink/70"}`, children: [_jsx("span", { className: "truncate", children: row.title }), st?.failing && _jsx("span", { "aria-label": "falls short", title: "Something here falls short", className: "size-1.5 shrink-0 rounded-full bg-fail" }), st?.set && !st.failing && _jsx("span", { "aria-label": "set here", title: "Set for this ground, not the default", className: "size-1.5 shrink-0 rounded-full bg-ink/40" })] }, row.key));
158
+ }) }), ROWS.map((row) => (_jsx(Tabs.Panel, { value: row.key, children: panel(row) }, row.key)))] }));
54
159
  }
55
- 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.";
56
- const TINT_HINT = "Borders, input edges, the focus ring and the buttons (unless the button says otherwise). Own: steps of the ground's ramp, in its hue. Page: the page's own lines. Or one colour for every line.";
57
- const PANELS_HINT = "Cards and quiet panels. Unset, they follow the lines: the page's with the page's lines, else the ground's own. Own: a step off the ground on its ramp. Page: the page's cards. Or one colour for both.";
58
- /** The defaults every ground starts from: where its text, its lines and its panels come from. */
160
+ /** Every ground's choices, as a seed holds them (every-ground) or a ground's own */
161
+ const SEED_KEY = { text: "groundText", tint: "groundTint", panels: "groundPanels", action: "groundAction" };
162
+ /** The defaults every ground starts from: where its text, its lines, its cards and its button come from. */
59
163
  export function GroundDefaults({ edit }) {
60
164
  const { seed, set } = edit;
61
165
  const ramps = rampsOf(edit);
62
- 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", hint: TINT_HINT, value: seed.groundTint, fallback: "own", ramps: ramps, onChange: (v) => set({ groundTint: v }) }), _jsx(FillPicker, { label: "Panels", hint: PANELS_HINT, value: seed.groundPanels, fallback: panelsFollowing(seed.groundTint ?? "own"), keepsChoice: true, ramps: ramps, onChange: (v) => set({ groundPanels: v }) })] }));
166
+ // here "default" is the generator's own
167
+ const bare = {};
168
+ 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 in its own settings." })] }), _jsx(ChoiceTabs, { label: "Every ground", status: (key) => ({ set: seed[SEED_KEY[key]] !== undefined, failing: false }), panel: (row) => (_jsx(ChoiceRow, { row: row, value: seed[SEED_KEY[row.key]], fallback: fallbackWords(row.key, bare), ramps: ramps, hints: {}, made: undefined, checks: [], firstStep: row.key === "action" ? "neutral-950" : `${ramps.includes("neutral") ? "neutral" : ramps[0]}-900`, palette: edit.system?.primitives, onChange: (v) => set({ [SEED_KEY[row.key]]: v }) })) })] }));
63
169
  }
64
- /** One ground's settings, set into the page under its specimen: its colour and step, its text, its lines. */
65
- export function GroundControls({ name, edit }) {
170
+ /**
171
+ * One ground's settings, set into the page beneath its sample: its colour and step, then its text,
172
+ * lines, cards and button, each saying whether it's the default or set here, and what it came to.
173
+ */
174
+ export function GroundControls({ name, edit, onClose }) {
66
175
  const { seed, set, system } = edit;
67
176
  const grounds = seed.grounds ?? {};
68
177
  const spec = grounds[name];
69
178
  const ramps = rampsOf(edit);
179
+ const target = seed.contrastTarget ?? "aa";
180
+ const made = system?.grounds?.[name];
181
+ // what every option comes to on this ground: each searched once, the ground alone
182
+ const variants = useMemo(() => {
183
+ const out = { text: {}, tint: {}, panels: {}, action: {} };
184
+ if (!system || !spec)
185
+ return out;
186
+ for (const { key } of ROWS) {
187
+ out[key].default = groundVariant(system, seed, name, { [key]: undefined });
188
+ for (const kind of KINDS[key]) {
189
+ if (kind === "step" || kind === "colour")
190
+ continue;
191
+ out[key][kind] = groundVariant(system, seed, name, { [key]: kind });
192
+ }
193
+ }
194
+ return out;
195
+ }, [system, seed, name, spec]);
70
196
  if (!spec)
71
197
  return null;
72
198
  const write = (patch) => {
@@ -80,8 +206,23 @@ export function GroundControls({ name, edit }) {
80
206
  const { [name]: _, ...rest } = grounds;
81
207
  set({ grounds: Object.keys(rest).length ? rest : undefined });
82
208
  };
83
- const made = system?.grounds?.[name];
84
- 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", hint: TINT_HINT, value: spec.tint, fallback: seed.groundTint ?? "own", ramps: ramps, onChange: (tint) => write({ tint }) }), _jsx(FillPicker, { label: "Panels", hint: PANELS_HINT, value: spec.panels, fallback: seed.groundPanels ?? panelsFollowing(spec.tint ?? seed.groundTint ?? "own"), keepsChoice: !seed.groundPanels, ramps: ramps, onChange: (panels) => write({ panels }) }), _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] }));
209
+ const checks = made ? groundChecks(made, target) : [];
210
+ const textFloor = target === "aaa" ? 7 : target === "aa-large" ? 3 : 4.5;
211
+ // "a shade of the ground's colour" for text, where no step of its ramp reads: what it fell back to
212
+ const ownText = variants.text.own?._refs["canvas-foreground"];
213
+ const ownFell = ownText && !(ownText.type === "shade" && ownText.colorName === spec.ramp) ? { kind: "own", fell: refName(ownText) } : undefined;
214
+ const failing = checks.filter((c) => !c.pass).length;
215
+ /** The step "custom step from a ramp" starts on: what the ground's own shade came to */
216
+ const firstStep = (key) => {
217
+ const own = variants[key].own;
218
+ const token = key === "text" ? "canvas-foreground" : key === "tint" ? "border" : key === "panels" ? "surface" : "primary";
219
+ const ref = refName(own?._refs[token]);
220
+ return STEP.test(ref) ? ref : `${spec.ramp}-${key === "panels" ? 50 : 900}`;
221
+ };
222
+ return (_jsxs("div", { className: "flex flex-col gap-3.5", children: [_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsxs("p", { className: "text-[12px] font-semibold text-ink", children: [name, " settings", _jsx("span", { className: `ml-2 text-[11px] font-normal ${failing ? "text-fail" : "text-ink3"}`, children: checks.length ? (failing ? `${failing} of ${checks.length} pairings fall short` : `all ${checks.length} pairings read`) : "" })] }), onClose && (_jsx("button", { type: "button", onClick: onClose, "aria-label": `Close ${name} settings`, className: "flex size-7 cursor-pointer items-center justify-center rounded-md text-ink3 hover:bg-scrim hover:text-ink", children: _jsx(X, { "aria-hidden": true, width: 14, height: 14 }) }))] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("p", { className: LABEL, children: "Background" }), _jsxs("p", { className: "text-[11px] leading-snug text-ink2", children: ["The colour this section is painted: one step of a ramp (", stepWords(`${spec.ramp}-${spec.step}`), "). It stays the same in light and dark mode; everything below is chosen to work on it."] }), _jsxs(Row, { children: [_jsx(Field, { label: "Ramp", children: (id) => _jsx(Select, { labelledBy: id, value: spec.ramp, options: ramps.map((r) => ({ value: r, label: r })), onChange: (ramp) => write({ ramp }) }) }), _jsx(Field, { label: "Step", children: (id) => _jsx(Select, { labelledBy: id, value: String(spec.step), options: SHADES, onChange: (s) => write({ step: Number(s) }) }) })] })] }), _jsxs("div", { className: "flex flex-col gap-2 border-t border-edge pt-3", children: [_jsx("p", { className: LABEL, children: "On the background" }), _jsx(ChoiceTabs, { label: `What's on ${name}`, status: (key) => ({
223
+ set: spec[key] !== undefined,
224
+ failing: checks.some((c) => !c.pass && PARTS[key].some((p) => p.token === c.token)),
225
+ }), panel: (row) => (_jsx(ChoiceRow, { row: row, value: spec[row.key], fallback: fallbackWords(row.key, seed), ramps: ramps, hints: Object.fromEntries(Object.entries(variants[row.key]).map(([k, g]) => [k, g ? headline(row.key, groundChecks(g, target)) : undefined])), made: made, checks: checks, firstStep: firstStep(row.key), palette: system?.primitives, ground: made?.tokens.canvas, floor: row.key === "text" ? textFloor : row.key === "panels" ? undefined : 3, offRamp: row.key === "text" ? ownFell : undefined, onChange: (v) => write({ [row.key]: v }) })) })] }), _jsxs("button", { type: "button", onClick: remove, className: ACTION, children: [_jsx(Trash2, { "aria-hidden": true, width: 13, height: 13 }), " Remove ", name] })] }));
85
226
  }
86
227
  /** A new ground: a name, the ramp it's painted and the step. */
87
228
  export function AddGround({ edit }) {
@@ -2,7 +2,7 @@
2
2
  * The studio's plain logic, browser-safe: a project's generate-tokens command read into a seed, a
3
3
  * seed turned into the generator's inputs, and the command that regenerates from a seed.
4
4
  */
5
- import { type BrandColors, type GenerationOptions, type GroundAction, type GroundFill, type SeedFile, type TokenSystem } from "@designtools/tokens";
5
+ import { type BrandColors, type GenerationOptions, type GroundAction, type GroundFill, type GroundSpec, type GroundText, type GroundTokens, type SeedFile, type TokenSystem } from "@designtools/tokens";
6
6
  /** Flags that say where and how the output is written, kept when the colour moves into a seed. */
7
7
  export interface OutputFlags {
8
8
  format?: string;
@@ -49,7 +49,7 @@ export declare function studioCss(seed: SeedFile, tokens?: TokenSystem): string;
49
49
  * own; the button unset follows the lines)
50
50
  */
51
51
  export declare function groundChoices(seed: SeedFile): Record<string, {
52
- text: GroundFill;
52
+ text: GroundText;
53
53
  tint: GroundFill;
54
54
  panels: GroundFill;
55
55
  action?: GroundAction;
@@ -62,11 +62,17 @@ export declare const panelsFollowing: (tint: GroundFill) => GroundFill;
62
62
  * seed alone. Null when there's no such ground.
63
63
  */
64
64
  export declare function groundPreviewCss(seed: SeedFile, name: string, choice: {
65
- text?: GroundFill;
65
+ text?: GroundText;
66
66
  tint?: GroundFill;
67
67
  panels?: GroundFill;
68
68
  action?: GroundAction;
69
69
  }, selector: string): string | null;
70
+ /**
71
+ * One ground as it would be with other choices, searched on the system already generated: only
72
+ * the ground, not the whole system again, so a settings panel can show what each choice comes to.
73
+ * Measured on sRGB. Null when there's no such ground or the choice can't be generated.
74
+ */
75
+ export declare function groundVariant(system: TokenSystem, seed: SeedFile, name: string, choice: Partial<Pick<GroundSpec, "text" | "tint" | "panels" | "action">>): GroundTokens | null;
70
76
  /** The command that regenerates from a seed file, keeping how and where the output is written. */
71
77
  export declare function seedCommand({ seedPath, output, version }: {
72
78
  seedPath: string;
@@ -2,7 +2,7 @@
2
2
  * The studio's plain logic, browser-safe: a project's generate-tokens command read into a seed, a
3
3
  * seed turned into the generator's inputs, and the command that regenerates from a seed.
4
4
  */
5
- import { exportTokens, generateTokens, familiesOf, rangeOf, } from "@designtools/tokens";
5
+ import { exportTokens, generateGroundTokens, generateTokens, familiesOf, rangeOf, } from "@designtools/tokens";
6
6
  /** Split a command line on spaces outside quotes, unquoting as a shell would. */
7
7
  export function splitCommand(command) {
8
8
  const out = [];
@@ -124,8 +124,12 @@ export function parseCommand(command) {
124
124
  const key = name === "--ground-tint" ? "tint" : name === "--ground-panels" ? "panels" : "text";
125
125
  const entry = value();
126
126
  const at = entry.indexOf("=");
127
- if (at === -1)
128
- seed[key === "tint" ? "groundTint" : key === "panels" ? "groundPanels" : "groundText"] = entry;
127
+ if (at === -1) {
128
+ if (key === "text")
129
+ seed.groundText = entry;
130
+ else
131
+ seed[key === "tint" ? "groundTint" : "groundPanels"] = entry;
132
+ }
129
133
  else
130
134
  perGround.push({ name: entry.slice(0, at), key, fill: entry.slice(at + 1) });
131
135
  break;
@@ -329,6 +333,27 @@ export function groundPreviewCss(seed, name, choice, selector) {
329
333
  const rule = new RegExp(`^\\[data-surface="${key}"\\] \\{([^}]*)\\}`, "m").exec(css);
330
334
  return rule ? `${selector} {${rule[1]}}` : null;
331
335
  }
336
+ /**
337
+ * One ground as it would be with other choices, searched on the system already generated: only
338
+ * the ground, not the whole system again, so a settings panel can show what each choice comes to.
339
+ * Measured on sRGB. Null when there's no such ground or the choice can't be generated.
340
+ */
341
+ export function groundVariant(system, seed, name, choice) {
342
+ const spec = seed.grounds?.[name];
343
+ if (!spec)
344
+ return null;
345
+ const { options } = optionsFromSeed(seed);
346
+ const given = { ...spec, ...choice };
347
+ for (const k of ["text", "tint", "panels", "action"])
348
+ if (given[k] === undefined)
349
+ delete given[k];
350
+ try {
351
+ return generateGroundTokens(system, [{ palette: system.primitives, gamut: "srgb" }], { ...options, grounds: { [name]: given } })[name] ?? null;
352
+ }
353
+ catch {
354
+ return null;
355
+ }
356
+ }
332
357
  /** The command that regenerates from a seed file, keeping how and where the output is written. */
333
358
  export function seedCommand({ seedPath, output, version }) {
334
359
  const parts = [`npx @designtools/tokens${version ? `@${version}` : ""}`, `--seed ${seedPath}`];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@designtools/tokens",
3
- "version": "0.16.2",
3
+ "version": "0.17.0",
4
4
  "description": "Turn one brand colour into a complete design-token system: perceptual OKLCH ramps, contrast-checked semantic tokens (WCAG or APCA), light and dark, as CSS custom properties, Tailwind v4/v3 or DTCG. Deterministic CLI, safe for agents.",
5
5
  "type": "module",
6
6
  "license": "MIT",