@designtools/tokens 0.11.0 → 0.12.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/dist/index.d.ts CHANGED
@@ -26,7 +26,6 @@ interface SemanticTokens {
26
26
  success: ExtendedSemanticColor;
27
27
  destructive: ExtendedSemanticColor;
28
28
  warning: ExtendedSemanticColor;
29
- muted: SemanticColorPair;
30
29
  [key: string]: ExtendedSemanticColor | SemanticColorPair;
31
30
  }
32
31
  interface ExtendedSemanticColor {
@@ -61,27 +60,31 @@ interface SemanticColorPair {
61
60
  foreground: ShadeNumber;
62
61
  };
63
62
  }
64
- /** Tracks which neutral primitive a surface value references */
63
+ /** Tracks which primitive a surface value references: the neutral's step unless `colorName` says otherwise */
65
64
  type SurfaceRef = {
66
65
  type: "shade";
67
66
  shade: ShadeNumber;
67
+ colorName?: string;
68
68
  } | {
69
69
  type: "white";
70
70
  } | {
71
71
  type: "black";
72
72
  }
73
- /** A colour passed in as it is (a brand background), emitted as a literal */
73
+ /** A colour passed in as it is (`--canvas "#F2F2F0"`), emitted as a literal */
74
74
  | {
75
75
  type: "value";
76
76
  value: string;
77
77
  };
78
- /** A named brand background passed in, with the text measured on it */
79
- interface NamedBackground {
78
+ /** A page surface a project adds (`--page-surface sunken=neutral@100/neutral@900`), with its measured text */
79
+ interface PageSurface {
80
80
  DEFAULT: string;
81
81
  foreground: string;
82
+ /** Secondary text on it: captions, dates, hints, quieter than its foreground and still reading */
83
+ "foreground-secondary": string;
82
84
  _refs: {
83
85
  DEFAULT: SurfaceRef;
84
86
  foreground: SurfaceRef;
87
+ "foreground-secondary": SurfaceRef;
85
88
  };
86
89
  }
87
90
  /** Each colour's WCAG ratio against each background, by mode: what can sit on the page, and where */
@@ -89,21 +92,28 @@ type PageContrast = Record<string, Record<string, number>>;
89
92
  interface SurfaceTokens {
90
93
  canvas: string;
91
94
  "canvas-foreground": string;
95
+ /** Secondary text on the page: captions, dates, hints. Each surface has its own, searched to read on it */
96
+ "canvas-foreground-secondary": string;
92
97
  surface: string;
93
98
  "surface-foreground": string;
99
+ "surface-foreground-secondary": string;
94
100
  overlay: string;
95
101
  "overlay-foreground": string;
102
+ "overlay-foreground-secondary": string;
96
103
  /** Primitive references for surface values (used by export layer) */
97
104
  _refs?: {
98
105
  canvas: SurfaceRef;
99
106
  "canvas-foreground": SurfaceRef;
107
+ "canvas-foreground-secondary": SurfaceRef;
100
108
  surface: SurfaceRef;
101
109
  "surface-foreground": SurfaceRef;
110
+ "surface-foreground-secondary": SurfaceRef;
102
111
  overlay: SurfaceRef;
103
112
  "overlay-foreground": SurfaceRef;
113
+ "overlay-foreground-secondary": SurfaceRef;
104
114
  };
105
- /** Brand backgrounds passed in by name (`--background stone=#E8E8DB`), each with measured text */
106
- backgrounds?: Record<string, NamedBackground>;
115
+ /** Page surfaces a project adds, by name, each with measured text: they follow the mode like the three above */
116
+ pageSurfaces?: Record<string, PageSurface>;
107
117
  }
108
118
  interface UtilityTokens {
109
119
  border: string;
@@ -151,9 +161,9 @@ interface TokenSystem {
151
161
  dark: UtilityTokens;
152
162
  };
153
163
  /**
154
- * Every semantic fill, and muted text, measured as WCAG ratios against every background
155
- * (canvas, surface, overlay and each named one), per mode. Labels are checked against
156
- * their own fills; this is the rest: red text on the page, a button on a dark section.
164
+ * Every semantic fill, and each surface's secondary text, measured as WCAG ratios against every background
165
+ * (canvas, surface, overlay, each page surface and each ground), per mode. Labels are checked
166
+ * against their own fills; this is the rest: red text on the page, a button on a dark band.
157
167
  */
158
168
  pageContrast?: {
159
169
  light: PageContrast;
@@ -173,42 +183,56 @@ interface TokenSystem {
173
183
  dark: Record<string, string>;
174
184
  };
175
185
  /**
176
- * Every token content needs, searched again against each ground it can sit on, per mode:
177
- * the canvas and surface (today's values), the status tints and each named background.
178
- * Emitted as `--on-<ground>-<token>`, and as a `[data-surface="<ground>"]` scope that points
179
- * the everyday names (`--primary`, `--muted-foreground`) at them. See `grounds.ts`.
186
+ * Each ground: a section painted one step of a ramp, the same in either mode, with the tokens
187
+ * content needs on it. Emitted as a `[data-surface="<ground>"]` scope that writes what differs
188
+ * from the page's tokens of the ground's polarity. See `grounds.ts`.
180
189
  */
181
- grounds?: {
182
- light: Record<string, GroundTokens>;
183
- dark: Record<string, GroundTokens>;
184
- };
190
+ grounds?: Record<string, GroundTokens>;
185
191
  /** The same system on wide-gamut ramps. Present only with `gamut: "p3"`. */
186
192
  p3?: GamutTokens;
187
193
  }
188
- /** How much each ground carries: every token, the background and its text, or nothing */
189
- type GroundsMode = "full" | "text" | "none";
190
- /** Where a ground token comes from: a ramp step, black or white, or a colour given as it is */
194
+ /**
195
+ * Where a ground's tokens come from, for its text and for everything else (its tint).
196
+ * `page`: the page's own tokens of the ground's polarity, wherever they read; `own`: steps on
197
+ * the ground's own ramp, searched to their floors; or one colour for all of them: `white`,
198
+ * `black`, or a step written `<ramp>-<step>` (`sage-100`).
199
+ */
200
+ type GroundFill = "page" | "own" | "white" | "black" | `${string}-${number}`;
201
+ /** A ground as declared: the ramp and step it is painted, and where its tokens come from */
202
+ interface GroundSpec {
203
+ ramp: string;
204
+ step: ShadeNumber;
205
+ /** Lines, panels, the card, the input edge, the ring and the buttons. Default: `own` */
206
+ tint?: GroundFill;
207
+ /** Body and secondary text. Default: `page` */
208
+ text?: GroundFill;
209
+ }
210
+ /** Where a ground token comes from: a ramp step, black or white (a page surface given as a colour stays a value) */
191
211
  type GroundRef = ForegroundRef | {
192
212
  type: "value";
193
213
  value: string;
194
214
  };
195
215
  /**
196
- * One ground's tokens: a background content sits on, and everything content needs on it.
216
+ * One ground: a section painted a step of a ramp, and the tokens content needs on it.
197
217
  *
198
- * Keys are the names the tokens take inside the ground, the page's own names: `canvas` and
199
- * `canvas-foreground` are the ground and its text, then `muted`, `muted-foreground`, `border`,
200
- * `input`, `ring`, and for every semantic colour its fill, `-foreground`, `-subdued`,
201
- * `-subdued-foreground`, `-hover` and `-active`. A token keeps its page value wherever that
202
- * still works on the ground; `changed` lists the ones that were searched again.
218
+ * `tokens` and `_refs` hold every token as it reads inside the ground, under the page's own
219
+ * names (`canvas`, `canvas-foreground`, `canvas-foreground-secondary`, `border`, `input`, `ring`,
220
+ * `surface`, `surface-foreground`, `surface-foreground-secondary`, and each semantic colour's fill, `-foreground`, `-subdued`,
221
+ * `-subdued-foreground`, `-hover`, `-active`). Everything the ground doesn't change is the page's
222
+ * token of the ground's polarity (`polarity`); `own` lists what the ground writes itself.
203
223
  */
204
224
  interface GroundTokens {
205
- /** `base` for the canvas and surface, `status` for a status tint, `background` for a named one */
206
- kind: "base" | "status" | "background";
225
+ ramp: string;
226
+ step: ShadeNumber;
227
+ /** Whether the ground reads as light (dark text) or dark (light text): which page mode it borrows */
228
+ polarity: "light" | "dark";
229
+ tint: GroundFill;
230
+ text: GroundFill;
207
231
  tokens: Record<string, string>;
208
232
  _refs: Record<string, GroundRef>;
209
- /** Tokens whose value differs from the page's in this mode */
210
- changed: string[];
211
- /** What the search could not reach, in words, for the report */
233
+ /** The tokens this ground writes, in order: those that differ from the page's of its polarity */
234
+ own: string[];
235
+ /** What a value can't reach, in words, for the report */
212
236
  notes: string[];
213
237
  }
214
238
  /** Contrast algorithm choice */
@@ -287,10 +311,13 @@ interface FamilyShape {
287
311
  interface SurfaceShadeOverrides {
288
312
  canvas?: ShadeNumber | "white" | "black";
289
313
  "canvas-foreground"?: ShadeNumber | "white" | "black";
314
+ "canvas-foreground-secondary"?: ShadeNumber;
290
315
  surface?: ShadeNumber | "white" | "black";
291
316
  "surface-foreground"?: ShadeNumber | "white" | "black";
317
+ "surface-foreground-secondary"?: ShadeNumber;
292
318
  overlay?: ShadeNumber | "white" | "black";
293
319
  "overlay-foreground"?: ShadeNumber | "white" | "black";
320
+ "overlay-foreground-secondary"?: ShadeNumber;
294
321
  }
295
322
  /** Per-utility-token shade overrides */
296
323
  interface UtilityShadeOverrides {
@@ -355,8 +382,8 @@ interface GenerationOptions {
355
382
  pins?: Record<string, Partial<Record<ShadeNumber, string>>>;
356
383
  /**
357
384
  * Whether the status ramps also get their everyday names: `green`, `red` and `yellow` as the same
358
- * ramps as `success`, `destructive` and `warning`, so `bg-red-500` matches. Default true; false
359
- * emits each ramp once, under its semantic name.
385
+ * ramps as `success`, `destructive` and `warning`, so `bg-red-500` matches. Default false: each
386
+ * ramp is emitted once, under its semantic name (before 0.12 the default was true).
360
387
  */
361
388
  aliases?: boolean;
362
389
  /**
@@ -387,22 +414,27 @@ interface GenerationOptions {
387
414
  dark?: Partial<Record<"canvas" | "surface" | "overlay", string>>;
388
415
  };
389
416
  /**
390
- * More backgrounds a brand paints sections with, by name: `{ stone: { light: "#E8E8DB" } }`.
391
- * Each becomes `--surface-<name>` with a measured `-foreground`; `dark` defaults to `light`.
392
- * Every semantic colour is measured against each of them (see `pageContrast`), and each is a
393
- * ground: content inside `data-surface="<name>"` gets its own searched tokens (see `grounds`).
394
- * A name a ground or token already uses (`canvas`, `primary`, `warning-subdued`) is refused.
417
+ * Page surfaces a project adds beside canvas, surface and overlay, by name: a sunken well, a
418
+ * raised panel, an alternate section. Each is a ramp step per mode, written `<ramp>@<step>`
419
+ * (`{ sunken: { light: "neutral@100", dark: "neutral@900" } }`); `dark` defaults to the light
420
+ * step's mirror on the same ramp (100 to 800). Emitted as `--<name>` with a measured
421
+ * `--<name>-foreground`, in the mode blocks, and every page token is searched to work on it.
395
422
  */
396
- backgrounds?: Record<string, {
423
+ pageSurfaces?: Record<string, {
397
424
  light: string;
398
425
  dark?: string;
399
426
  }>;
400
427
  /**
401
- * How much a ground carries (see `grounds.ts`). `full` (default): every token, tinted to the
402
- * ground and contrast-checked on it. `text`: the ground and its text only, so `data-surface`
403
- * paints a section and everything else on it keeps the page's tokens. `none`: no grounds at all.
428
+ * Grounds: sections painted one step of a ramp, the same in light and dark mode, by name:
429
+ * `{ pine: { ramp: "pine", step: 800, tint: "white" } }`. Inside `data-surface="<name>"` content
430
+ * reads tokens that work on it (see `grounds.ts`). The ramp is any colour's: a `--color`, often
431
+ * decorative, or `primary` for a brand band.
404
432
  */
405
- grounds?: GroundsMode;
433
+ grounds?: Record<string, GroundSpec>;
434
+ /** Where every ground's tint comes from, unless it says otherwise. Default `own` */
435
+ groundTint?: GroundFill;
436
+ /** Where every ground's text comes from, unless it says otherwise. Default `page` */
437
+ groundText?: GroundFill;
406
438
  /**
407
439
  * Which steps to emit. Default: all twelve (25–950).
408
440
  * Tokens naming a dropped step are snapped to the nearest emitted one.
@@ -475,8 +507,10 @@ interface SavedConfig {
475
507
  foreground?: GenerationOptions["foreground"];
476
508
  wcagFloor?: boolean;
477
509
  surfaceColors?: GenerationOptions["surfaceColors"];
478
- backgrounds?: GenerationOptions["backgrounds"];
479
- grounds?: GroundsMode;
510
+ pageSurfaces?: GenerationOptions["pageSurfaces"];
511
+ grounds?: GenerationOptions["grounds"];
512
+ groundTint?: GroundFill;
513
+ groundText?: GroundFill;
480
514
  shadeOverrides: SemanticShadeOverrides;
481
515
  surfaceShadeOverrides?: GenerationOptions["surfaceShadeOverrides"];
482
516
  utilityShadeOverrides?: GenerationOptions["utilityShadeOverrides"];
@@ -772,10 +806,12 @@ interface SemanticGamuts {
772
806
  declare function generateSemanticTokens(palette: PrimitivePalette, mode: "light" | "dark", options?: Partial<GenerationOptions>, gamuts?: SemanticGamuts,
773
807
  /** The backgrounds this mode paints (canvas, surface, overlay, named): status text must read on all */
774
808
  pageGrounds?: readonly string[]): SemanticTokens;
775
- declare function generateSurfaceTokens(palette: PrimitivePalette, mode: "light" | "dark", overrides?: Partial<SurfaceShadeOverrides>, shades?: readonly ShadeNumber[], colors?: Partial<Record<"canvas" | "surface" | "overlay", string>>, backgrounds?: Record<string, {
809
+ declare function generateSurfaceTokens(palette: PrimitivePalette, mode: "light" | "dark", overrides?: Partial<SurfaceShadeOverrides>, shades?: readonly ShadeNumber[], colors?: Partial<Record<"canvas" | "surface" | "overlay", string>>, pageSurfaces?: Record<string, {
776
810
  light: string;
777
811
  dark?: string;
778
- }>): SurfaceTokens;
812
+ }>,
813
+ /** The text floor secondary text is searched to: 4.5, or 7 at AAA */
814
+ textFloor?: number): SurfaceTokens;
779
815
  /**
780
816
  * Generate utility tokens for borders, rings, inputs, shadow
781
817
  */
@@ -799,7 +835,7 @@ declare function checkSemanticContrastAPCA(tokens: SemanticTokens, gamut?: Gamut
799
835
  /**
800
836
  * Contrast for the pairings the semantic check never looked at.
801
837
  *
802
- * `checkSemanticContrast` covers the extended families and `muted`. That leaves
838
+ * `checkSemanticContrast` covers the extended families. That leaves
803
839
  * the ground a page is actually painted on — canvas, surface, overlay — and the
804
840
  * focus ring, unmeasured. The ground is the thing projects most often override,
805
841
  * and an unreadable focus ring is an accessibility defect that no other check
@@ -836,7 +872,7 @@ declare function checkRampChroma(palette: PrimitivePalette): Record<string, {
836
872
  /**
837
873
  * Compute an overall accessibility score for the token system.
838
874
  *
839
- * Counts every extended-family pairing and excludes `muted` alone. Neutral is
875
+ * Counts every extended-family pairing. Neutral is
840
876
  * deliberately included: it is the pairing most likely to fail on a default
841
877
  * seed, and a score that quietly dropped it would flatter the palette exactly
842
878
  * where a reader most needs the warning.
@@ -865,6 +901,20 @@ declare function computeAccessibilityScore(tokens: SemanticTokens, algorithm: Co
865
901
  * keeps the sRGB values, which are complete and contrast-checked on their own.
866
902
  */
867
903
  declare const WIDE_GAMUT_QUERY = "@media (color-gamut: p3)";
904
+ /**
905
+ * The selectors each mode block is emitted under, with the grounds.
906
+ *
907
+ * A ground is the same colour in either mode, so everything inside it that it doesn't change is
908
+ * the page's token of the ground's polarity: a light ground's selector joins the light block, a
909
+ * dark ground's the dark block, and the right values apply inside it whatever the page's mode.
910
+ * `data-surface="canvas"` resets to the page as it is: on the light block plainly, and on the
911
+ * dark ones under a dark page, where the more specific selector wins.
912
+ */
913
+ declare function modeSelectors(tokens: TokenSystem): {
914
+ light: string;
915
+ dark: string;
916
+ systemDark: string;
917
+ };
868
918
  /** The selector a ground's scope is emitted under */
869
919
  declare const GROUND_SELECTOR: (ground: string) => string;
870
920
  /**
@@ -950,8 +1000,11 @@ declare function tokenFamilies(tokens: TokenSystem): string[];
950
1000
  * A family-scoped slice is not self-contained — a foreground search can land on
951
1001
  * a neutral shade or on black — so a caller splicing one needs to know which
952
1002
  * tokens have to already exist in the target.
1003
+ *
1004
+ * Pass the file a slice was merged into as `against`, and its definitions count
1005
+ * too: only what the merged file still lacks is reported.
953
1006
  */
954
- declare function externalReferences(css: string): string[];
1007
+ declare function externalReferences(css: string, against?: string): string[];
955
1008
  /**
956
1009
  * Narrow a TokenSystem to the requested sections, for the `json` output.
957
1010
  *
@@ -1078,28 +1131,30 @@ declare class APCAUnavailableError extends Error {
1078
1131
  declare function isAPCAAvailable(): boolean;
1079
1132
 
1080
1133
  /**
1081
- * Grounds: every background content sits on, each with the tokens content needs on it.
1134
+ * Grounds: sections painted one step of a ramp, and the tokens content needs on them.
1082
1135
  *
1083
- * The page tokens are searched against the canvas, the surface and the overlay. Content also
1084
- * sits on other backgrounds: a warning banner with a button in it, a brand-coloured band on a
1085
- * marketing page with a caption and a call to action. There the page tokens were only measured,
1086
- * never chosen: a primary button on a primary band is 1:1, a caption on a navy band 2.3:1.
1136
+ * The page's tokens are searched against the page's surfaces. A section painted a colour (a deep
1137
+ * green band, a lime page) is somewhere they may not work: a primary button on a primary band is
1138
+ * 1:1, a caption on a dark band unreadable. A ground is that section, declared as a ramp and a
1139
+ * step (`pine@800`), and it gets tokens that work on it.
1087
1140
  *
1088
- * So each ground gets the page's tokens again, searched against it. A token keeps its page value
1089
- * wherever that still works on the ground, so a pale banner changes little; anything that fails
1090
- * is searched again by the same rules the page uses. Markup names the ground once
1091
- * (`<section data-surface="brand">`) and every component inside reads the right values through
1092
- * the everyday names, `bg-primary` and `text-muted-foreground`, with no change to the component.
1141
+ * A ground is the same colour in light and dark mode, so it has one set of tokens, and they start
1142
+ * from the page's tokens of its own polarity: a light ground from the light page's, a dark one
1143
+ * from the dark page's. The exports put each ground's selector on that mode block, so everything
1144
+ * a ground doesn't change is already right inside it in either mode. The ground's own scope then
1145
+ * writes only what differs, every value a ramp step (or white or black), never a computed colour.
1093
1146
  *
1094
- * The grounds are the canvas and the surface (today's values, so a card inside a band can reset
1095
- * to them), the status tints, and every named background. The surface and overlay tokens
1096
- * themselves are not part of a ground: a card is still a card, on any band.
1147
+ * What differs comes from two choices per ground:
1148
+ * - tint, for lines, panels, the card, the input edge, the ring and the buttons;
1149
+ * - text, for body and secondary text.
1150
+ * Each is `page` (the page's tokens, where they read), `own` (steps on the ground's ramp, each
1151
+ * searched to its floor) or one colour (`white`, `black`, `sage-100`). Any other colour (accent,
1152
+ * success, a brand's own) keeps the page's value unless that fails on the ground, and is then
1153
+ * searched along its own ramp.
1097
1154
  */
1098
1155
 
1099
- /** The status colours whose tints are grounds by default: a banner, an alert, an inline message */
1100
- declare const STATUS_GROUNDS: readonly ["success", "warning", "destructive"];
1101
1156
  /** The non-colour tokens every ground carries, in the order they are emitted */
1102
- declare const GROUND_BASE_TOKENS: readonly ["canvas", "canvas-foreground", "muted", "muted-foreground", "border", "input", "ring"];
1157
+ declare const GROUND_BASE_TOKENS: readonly ["canvas", "canvas-foreground", "canvas-foreground-secondary", "border", "input", "ring", "surface", "surface-foreground", "surface-foreground-secondary"];
1103
1158
  /** What each semantic colour carries inside a ground */
1104
1159
  declare const GROUND_COLOR_PARTS: readonly ["", "-foreground", "-subdued", "-subdued-foreground", "-hover", "-active"];
1105
1160
  interface View {
@@ -1108,26 +1163,27 @@ interface View {
1108
1163
  }
1109
1164
  /** Every token name a ground carries, for these semantic colours */
1110
1165
  declare function groundTokenNames(colors: readonly string[]): string[];
1166
+ /** The page tokens a page surface's name can't take: it is emitted as `--<name>` beside them */
1167
+ declare function reservedSurfaceNames(colors: readonly string[]): string[];
1111
1168
  /**
1112
- * Names a `--background` cannot take: each ground is a `data-surface` value and the prefix of
1113
- * `--on-<ground>-*`, and `--surface-<name>` sits beside the surface tokens. A band called
1114
- * `primary` or `warning-subdued` would be two grounds under one name.
1169
+ * The step a colour lands on by its lightness, on a ramp anchored where the system anchors by
1170
+ * default: a deep green near 900, a pale blue-grey near 200. What `--color name=colour@step`
1171
+ * should say for a colour that is to be painted as it is, as the CLI suggests in place of a
1172
+ * `--background`.
1115
1173
  */
1116
- declare function reservedGroundNames(colors: readonly string[]): string[];
1174
+ declare function suggestStep(color: string, options?: Partial<GenerationOptions>): ShadeNumber;
1117
1175
  /**
1118
- * Every ground's tokens for one mode.
1119
- *
1120
- * `views` is the palette the tokens resolve against, then any other gamut's: a pairing must
1121
- * pass on every display the system is generated for.
1176
+ * Every ground's tokens. `views` is the palette the tokens resolve against, then any other
1177
+ * gamut's: a pairing must pass on every display the system is generated for.
1122
1178
  */
1123
1179
  declare function generateGroundTokens(tiers: {
1124
1180
  semantic: Record<"light" | "dark", SemanticTokens>;
1125
1181
  surface: Record<"light" | "dark", SurfaceTokens>;
1126
1182
  utility: Record<"light" | "dark", UtilityTokens>;
1127
- }, mode: "light" | "dark", views: readonly View[], options?: Partial<GenerationOptions>): Record<string, GroundTokens>;
1183
+ }, views: readonly View[], options?: Partial<GenerationOptions>): Record<string, GroundTokens>;
1128
1184
 
1129
1185
  /**
1130
- * Where each colour can go: every semantic fill, status text tone and muted text measured
1186
+ * Where each colour can go: every semantic fill, status text tone and secondary text measured
1131
1187
  * against every background a mode paints, with a verdict. Written beside the CSS with
1132
1188
  * `--usage <file>` for @designtools/manifest, which turns the failures into usage rules a
1133
1189
  * person reads on the rules page and an agent reads in rules.json. Deterministic: the same
@@ -1181,4 +1237,46 @@ interface ContractBreak {
1181
1237
  /** Every step whose promise differs between colours, light to dark. Empty when every step means the same everywhere. */
1182
1238
  declare function stepContract(palette: PrimitivePalette): ContractBreak[];
1183
1239
 
1184
- 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 GroundRef, type GroundTokens, type GroundsMode, type HueDrift, type LightnessStrategy, type MergeResult, type NamedBackground, type PageContrast, type PaletteOptions, type PrimitivePalette, type Provenance, SECTIONED_FORMATS, SHADE_PRESETS, STATUS_GROUNDS, type SavedConfig, type ScaleOptions, 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 TokenSection, type TokenSystem, type UsageReport, type UsageVerdict, type UtilityShadeOverrides, type UtilityTokens, VALID_SHADES, type VariantShadeOverrides, type WCAGContrastResult, WIDE_GAMUT_QUERY, adjustChroma, adjustLightness, aliasOf, checkRampChroma, checkSemanticContrast, checkSemanticContrastAPCA, checkSurfaceContrast, chromaShadeFor, classifyAPCALevel, computeAccessibilityScore, diffSlice, 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, meetsWCAG_AA, meetsWCAG_AAA, mergeSlice, oklchToHex, parseProvenance, parseToOklch, provenanceComment, rangeOf, readDeclarations, reanchorFactors, reservedGroundNames, resolveShades, seedFingerprint, selectTokenSections, serialiseUsage, simulateCVD, snapShade, stableStringify, stepContract, tokenFamilies, usageReport, withJsonProvenance };
1240
+ /**
1241
+ * The non-colour scale: space, size, type, radius, shadow, motion, screen sizes and widths. The colour
1242
+ * generator works a palette out from a seed; the scale has no seed, so this is a set of defaults, written
1243
+ * in every format the colour is, and retuned with overrides rather than by hand. The names are the
1244
+ * contract and the values are art direction: override the values, keep the names.
1245
+ *
1246
+ * The names are the CSS custom properties Tailwind v4 reads as theme namespaces (`--text-*`,
1247
+ * `--breakpoint-*`, `--container-*`), which makes each one a utility on Tailwind and a plain variable
1248
+ * everywhere else. Space is the gap between things (`--spacing`, one multiplier); size is the extent of a
1249
+ * thing (`--size-*`). Containers and screen sizes are scales too; a page's grid is composed from them and
1250
+ * from space, not named as tokens of its own.
1251
+ */
1252
+ type ScaleTierId = "spacing" | "size" | "text" | "leading" | "tracking" | "font-weight" | "radius" | "shadow" | "duration" | "ease" | "breakpoint" | "container";
1253
+ interface ScaleToken {
1254
+ /** The custom property: `--text-sm`, `--text-sm--line-height`. */
1255
+ name: string;
1256
+ value: string;
1257
+ description?: string;
1258
+ }
1259
+ interface ScaleTier {
1260
+ id: ScaleTierId;
1261
+ title: string;
1262
+ /** Whether Tailwind v4 has a theme namespace for it. Without one it is a plain variable in `:root`. */
1263
+ themed: boolean;
1264
+ tokens: ScaleToken[];
1265
+ }
1266
+ /** The defaults. Every value is art direction a project retunes with overrides; the names stay. */
1267
+ declare function defaultScale(): ScaleTier[];
1268
+ /** An override: a value, a value with its description, or `null` to remove the token. */
1269
+ type ScaleOverride = string | {
1270
+ value: string;
1271
+ description?: string;
1272
+ } | null;
1273
+ /**
1274
+ * The defaults with a project's overrides applied, by token name: a new value (and description) for a
1275
+ * token, a new token in the tier its name belongs to, or `null` to drop one. A name in no tier is an
1276
+ * error, so a typo can't quietly add nothing.
1277
+ */
1278
+ declare function applyScaleOverrides(tiers: ScaleTier[], overrides: Record<string, ScaleOverride>): ScaleTier[];
1279
+ type ScaleFormat = "css" | "tailwind-v4" | "tailwind-v3" | "dtcg" | "json";
1280
+ declare function exportScale(tiers: ScaleTier[], format: ScaleFormat, header?: string): string;
1281
+
1282
+ 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 GroundFill, type GroundRef, type GroundSpec, type GroundTokens, type HueDrift, type LightnessStrategy, type MergeResult, type PageContrast, type PageSurface, type PaletteOptions, type PrimitivePalette, type Provenance, SECTIONED_FORMATS, SHADE_PRESETS, type SavedConfig, type ScaleFormat, type ScaleOptions, type ScaleOverride, type ScaleTier, type ScaleTierId, type ScaleToken, 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 TokenSection, type TokenSystem, type UsageReport, type UsageVerdict, type UtilityShadeOverrides, type UtilityTokens, VALID_SHADES, type VariantShadeOverrides, type WCAGContrastResult, WIDE_GAMUT_QUERY, adjustChroma, adjustLightness, aliasOf, applyScaleOverrides, 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, meetsWCAG_AA, meetsWCAG_AAA, mergeSlice, modeSelectors, oklchToHex, parseProvenance, parseToOklch, provenanceComment, rangeOf, readDeclarations, reanchorFactors, reservedSurfaceNames, resolveShades, seedFingerprint, selectTokenSections, serialiseUsage, simulateCVD, snapShade, stableStringify, stepContract, suggestStep, tokenFamilies, usageReport, withJsonProvenance };
package/dist/index.js CHANGED
@@ -9,7 +9,6 @@ import {
9
9
  GROUND_SELECTOR,
10
10
  SECTIONED_FORMATS,
11
11
  SHADE_PRESETS,
12
- STATUS_GROUNDS,
13
12
  TAILWIND_SHADES,
14
13
  TOKEN_SECTIONS,
15
14
  VALID_SHADES,
@@ -17,6 +16,7 @@ import {
17
16
  adjustChroma,
18
17
  adjustLightness,
19
18
  aliasOf,
19
+ applyScaleOverrides,
20
20
  checkRampChroma,
21
21
  checkSemanticContrast,
22
22
  checkSemanticContrastAPCA,
@@ -24,7 +24,9 @@ import {
24
24
  chromaShadeFor,
25
25
  classifyAPCALevel,
26
26
  computeAccessibilityScore,
27
+ defaultScale,
27
28
  diffSlice,
29
+ exportScale,
28
30
  exportToCss,
29
31
  exportToDtcg,
30
32
  exportToTailwindV3,
@@ -57,6 +59,7 @@ import {
57
59
  meetsWCAG_AA,
58
60
  meetsWCAG_AAA,
59
61
  mergeSlice,
62
+ modeSelectors,
60
63
  oklchToHex,
61
64
  parseProvenance,
62
65
  parseToOklch,
@@ -64,7 +67,7 @@ import {
64
67
  rangeOf,
65
68
  readDeclarations,
66
69
  reanchorFactors,
67
- reservedGroundNames,
70
+ reservedSurfaceNames,
68
71
  resolveShades,
69
72
  seedFingerprint,
70
73
  selectTokenSections,
@@ -73,10 +76,11 @@ import {
73
76
  snapShade,
74
77
  stableStringify,
75
78
  stepContract,
79
+ suggestStep,
76
80
  tokenFamilies,
77
81
  usageReport,
78
82
  withJsonProvenance
79
- } from "./chunk-RQGC7LES.js";
83
+ } from "./chunk-TRGCDLOM.js";
80
84
  export {
81
85
  ALIAS_PAIRS,
82
86
  APCAUnavailableError,
@@ -88,7 +92,6 @@ export {
88
92
  GROUND_SELECTOR,
89
93
  SECTIONED_FORMATS,
90
94
  SHADE_PRESETS,
91
- STATUS_GROUNDS,
92
95
  TAILWIND_SHADES,
93
96
  TOKEN_SECTIONS,
94
97
  VALID_SHADES,
@@ -96,6 +99,7 @@ export {
96
99
  adjustChroma,
97
100
  adjustLightness,
98
101
  aliasOf,
102
+ applyScaleOverrides,
99
103
  checkRampChroma,
100
104
  checkSemanticContrast,
101
105
  checkSemanticContrastAPCA,
@@ -103,7 +107,9 @@ export {
103
107
  chromaShadeFor,
104
108
  classifyAPCALevel,
105
109
  computeAccessibilityScore,
110
+ defaultScale,
106
111
  diffSlice,
112
+ exportScale,
107
113
  exportToCss,
108
114
  exportToDtcg,
109
115
  exportToTailwindV3,
@@ -136,6 +142,7 @@ export {
136
142
  meetsWCAG_AA,
137
143
  meetsWCAG_AAA,
138
144
  mergeSlice,
145
+ modeSelectors,
139
146
  oklchToHex,
140
147
  parseProvenance,
141
148
  parseToOklch,
@@ -143,7 +150,7 @@ export {
143
150
  rangeOf,
144
151
  readDeclarations,
145
152
  reanchorFactors,
146
- reservedGroundNames,
153
+ reservedSurfaceNames,
147
154
  resolveShades,
148
155
  seedFingerprint,
149
156
  selectTokenSections,
@@ -152,6 +159,7 @@ export {
152
159
  snapShade,
153
160
  stableStringify,
154
161
  stepContract,
162
+ suggestStep,
155
163
  tokenFamilies,
156
164
  usageReport,
157
165
  withJsonProvenance
@@ -72,6 +72,62 @@ export function describeChanges(before, now) {
72
72
  }
73
73
  }
74
74
  }
75
+ for (const mode of ["light", "dark"]) {
76
+ for (const key of ["canvas", "surface", "overlay"]) {
77
+ const x = before.surfaceColors?.[mode]?.[key];
78
+ const y = now.surfaceColors?.[mode]?.[key];
79
+ if (x !== y)
80
+ out.push(y ? `${key} ${y} in ${mode}` : `${key} generated again in ${mode}`);
81
+ }
82
+ }
83
+ for (const key of ["surfaceShadeOverrides", "utilityShadeOverrides"]) {
84
+ for (const mode of ["light", "dark"]) {
85
+ const a = (before[key]?.[mode] ?? {});
86
+ const b = (now[key]?.[mode] ?? {});
87
+ for (const token of new Set([...Object.keys(a), ...Object.keys(b)])) {
88
+ if (a[token] !== b[token])
89
+ out.push(b[token] !== undefined ? `${token} on ${b[token]} in ${mode}` : `${token} back to the generator's choice in ${mode}`);
90
+ }
91
+ }
92
+ }
93
+ const surfaces = new Set([...Object.keys(before.pageSurfaces ?? {}), ...Object.keys(now.pageSurfaces ?? {})]);
94
+ for (const name of surfaces) {
95
+ const a = before.pageSurfaces?.[name];
96
+ const b = now.pageSurfaces?.[name];
97
+ if (same(a, b))
98
+ continue;
99
+ out.push(!b ? `${name} surface removed` : `${name} surface ${b.light}${b.dark ? `/${b.dark}` : ""}${a ? "" : " added"}`);
100
+ }
101
+ if (!same(before.groundText, now.groundText))
102
+ out.push(`every ground's text ${now.groundText ?? "page"}`);
103
+ if (!same(before.groundTint, now.groundTint))
104
+ out.push(`every ground's lines and panels ${now.groundTint ?? "own"}`);
105
+ const grounds = new Set([...Object.keys(before.grounds ?? {}), ...Object.keys(now.grounds ?? {})]);
106
+ for (const name of grounds) {
107
+ const a = before.grounds?.[name];
108
+ const b = now.grounds?.[name];
109
+ if (same(a, b))
110
+ continue;
111
+ if (!b)
112
+ out.push(`${name} ground removed`);
113
+ else if (!a)
114
+ out.push(`${name} ground added, ${b.ramp}@${b.step}`);
115
+ else {
116
+ if (a.ramp !== b.ramp || a.step !== b.step)
117
+ out.push(`${name} ground painted ${b.ramp}@${b.step}`);
118
+ if (a.text !== b.text)
119
+ out.push(`${name} ground's text ${b.text ?? "as every ground's"}`);
120
+ if (a.tint !== b.tint)
121
+ out.push(`${name} ground's lines and panels ${b.tint ?? "as every ground's"}`);
122
+ }
123
+ }
124
+ if (!same(before.aliases, now.aliases))
125
+ out.push(now.aliases ? "everyday names (green, red, yellow) on" : "everyday names off");
126
+ if (!same(before.gamut, now.gamut))
127
+ out.push(`screens ${now.gamut ?? "srgb"}`);
128
+ const decorative = (s) => (s.additionalColors ?? []).filter((c) => c.decorative).map((c) => c.name).sort();
129
+ if (!same(decorative(before), decorative(now)))
130
+ out.push(`ramps only: ${decorative(now).join(", ") || "none"}`);
75
131
  return out;
76
132
  }
77
133
  /** Where a link carries a seed: the page's hash, so nothing reaches the server. */