@dloizides/design-tokens 1.0.1 → 1.2.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,100 @@
2
2
 
3
3
  All notable changes to `@dloizides/design-tokens` are documented here.
4
4
 
5
+ ## [1.2.0]
6
+
7
+ ### Added
8
+
9
+ `DesignTokens` was a **lossy carrier**. Two RN-web apps (ichnos, kefi) discovered this
10
+ independently and wrote the *same* private workaround: the shape had no slot for the muted
11
+ inset surface, the on-brand foreground, or the three status background tints, so each app
12
+ smuggled those five values into free slots of the broadcast theme via a hand-rolled overlay.
13
+ Two independent uses of one workaround is the trigger to extract it. These are now
14
+ first-class slots, and the overlay is a shipped emitter.
15
+
16
+ - **`ModeColors.surfaceMuted?`** — the subtle inset surface (table header rows, chips, wells).
17
+ Distinct from `surface` (cards) and `surfaceElevated` (modals): it recedes rather than lifts.
18
+ - **`DesignTokens.onBrand?`** — the foreground for content sitting ON a `primary`-filled
19
+ surface. It is a *contrast partner* of `primary`, not a mode colour, so it lives beside it.
20
+ - **`SemanticColors.successBg?` / `warningBg?` / `errorBg?` / `infoBg?`** — the soft fill a
21
+ status badge, banner or row-highlight paints behind text of the base colour. A tint is NOT
22
+ derivable from its base (it is hand-picked for contrast), so it needs its own slot; without
23
+ one a status surface could not be themed at all.
24
+ - **`toUiTheme(tokens, mode?)`** — a fourth emitter: the shared RN UI kit's `UiTheme` (what
25
+ `@dloizides/ui-feedback`'s `UiProvider` broadcasts). It is **lossless** — every token the
26
+ shape can express lands in an addressable slot (`palette.onBrand`, `palette.surfaceMuted`,
27
+ each status tint at the `100` step), so an app can round-trip its entire palette back out
28
+ of the live provider instead of keeping a parallel static copy that can never follow a
29
+ dark-mode toggle or a per-tenant brand. The theme type is declared **structurally** here,
30
+ exactly as `RnThemeConfig` declares the `TenantThemeConfig` shape, so the package keeps its
31
+ zero-dependency / zero-peer guarantee and takes no dependency on the kit it feeds.
32
+ - **`UI_TINT_STEP` / `UI_MAIN_STEP` / `UI_DEEP_STEP`** — the step names, exported so a consumer
33
+ addresses a scale by name rather than by a magic `'500'`.
34
+ - CSS-variable names (`--on-brand`, `--surface-muted`, `--success-bg`, …) and Tailwind colour
35
+ keys (`on-brand`, `surface-muted`, `success-bg`, …) for the new tokens.
36
+
37
+ ### Fixed
38
+
39
+ - **Scale collapse.** The naive `value => ({ '100': v, '500': v, '700': v })` projection that
40
+ both apps used writes ONE value into every step, silently discarding the deeper brand step
41
+ and every status tint — a theme built that way cannot reproduce the palette it came from.
42
+ `toUiTheme` emits `secondary` as its own scale and each status tint at the `100` step, so
43
+ the values survive. The package's own emitters (`toCssVars`, `toRnTheme`,
44
+ `toTailwindPreset`) were checked and carry no equivalent collapse.
45
+
46
+ ### Compatibility
47
+
48
+ Entirely additive. Every new token is optional and every new emitted key appears **only** when
49
+ a preset declares the token, so `AML_TOKENS`, `EREVNA_TOKENS` and `KATALOGOS_TOKENS` emit
50
+ byte-identical CSS, RN-theme and Tailwind output — verified by the pre-existing emitter test
51
+ suites passing unmodified.
52
+
53
+ ## [1.1.0]
54
+
55
+ ### Fixed
56
+
57
+ - **WCAG AA contrast (UX-11)**: `light.textSecondary` in `EREVNA_TOKENS` and `KATALOGOS_TOKENS`
58
+ was `#777777`, which measures **4.48:1 on `#ffffff` and 4.18:1 on the `#f7f7f7` card surface** —
59
+ both under the AA 4.5:1 floor for normal text, and form-field labels render in this colour.
60
+ Now `#717171` (**4.88:1** and **4.56:1** against those same two surfaces, verified against each
61
+ preset's ACTUAL surfaces rather than assumed from another package's).
62
+ `AML_TOKENS` was already compliant (`#4a5567`, worst case 6.97:1) and is unchanged.
63
+
64
+ This is the same defect `@dloizides/theme-web@1.2.0` fixed in its `DEFAULT_THEME_CONFIG`, but
65
+ that fix does NOT reach these presets — apps resolving colours through a preset bypass
66
+ theme-web's defaults entirely. The bad value survived here independently.
67
+
68
+ ### Added
69
+
70
+ - **`src/contrast.ts`** — a correct WCAG 2.1 contrast implementation (sRGB gamma linearization +
71
+ ITU-R BT.709 weighting; NOT a naive channel average, which mis-scores exactly the mid-greys that
72
+ matter). Deliberately a COPY of theme-web's, not an import: this package ships **zero
73
+ dependencies and zero peers** by design, and depending on a React theming package for pure
74
+ arithmetic would invert the layering (theme-web already depends on this package).
75
+ Exported (`contrastRatio`, `relativeLuminance`, `meetsContrast`, `isHexColor`, and the
76
+ `AA_*_RATIO` thresholds) so consumers that let users override tokens at runtime can validate
77
+ those overrides with the same maths that guards the shipped presets.
78
+ - **`src/contrast.test.ts`** — pins the calculator against external reference pairs
79
+ (`#767676`/white = 4.54:1, `#777777`/white = 4.48:1, black/white = 21:1, and `#808080`'s true
80
+ luminance of 0.2159 vs a channel-average's 0.502) so the guard cannot silently be wrong.
81
+ - **`src/presets/presets.contrast.test.ts`** — a permanent guard measuring every text-role colour
82
+ in EVERY preset against every surface it renders on, in BOTH modes. Failures must be registered
83
+ in `KNOWN_GAPS` with their exact measured ratio, and the registry is asserted to be exactly
84
+ accurate — so a gap cannot be added silently, a stale entry fails once the colour is fixed, and
85
+ a newly failing colour nobody registered fails the suite outright. Non-hex token values (AML's
86
+ `rgba()` dark border, which has no fixed luminance) are excluded by an asserted explicit list
87
+ rather than silently skipped.
88
+
89
+ ### Notes
90
+
91
+ - Only TEXT and essential-boundary roles are asserted. Decorative fills (`primary`/`secondary`/
92
+ `accent`, and the `success`/`warning`/`info` semantic bases) carry no contrast requirement;
93
+ asserting them would turn a compliance guard into a brand redesign.
94
+ - 8 pre-existing gaps are registered, all one root cause: a single token serving both a text role
95
+ and a fill/decorative role across both modes (`border`/`divider`, `semantic.error`). These need
96
+ the roles split before any value can move — a design change, not a colour nudge. They mirror the
97
+ gaps already registered in `@dloizides/theme-web`.
98
+
5
99
  ## [1.0.0]
6
100
 
7
101
  ### Added
package/README.md CHANGED
@@ -12,20 +12,21 @@ values**, emitted in **three forms from one source**.
12
12
  Values only — **no components**. (Shared React components live in `@dloizides/ui-layout`,
13
13
  `ui-forms`, `ui-feedback`, `ui-icons`, `ui-tables`.)
14
14
 
15
- ## The three output forms
15
+ ## The four output forms
16
16
 
17
- One `DesignTokens` object per app feeds three pure emitters:
17
+ One `DesignTokens` object per app feeds four pure emitters:
18
18
 
19
19
  | Form | Emitter | Consumer stack | Output |
20
20
  |------|---------|----------------|--------|
21
21
  | **(a) CSS custom properties** | `toCssVars(tokens, names, opts?)` | Stack-A vanilla-JS (AML console) | a `:root { --…: …; }` string (+ optional dark-mode block) |
22
22
  | **(b) RN-web theme object** | `toRnTheme(tokens)` | RN-web (erevna, katalogos) | a `TenantThemeConfig`-compatible object |
23
23
  | **(c) Tailwind preset** | `toTailwindPreset(tokens)` | DOM-React (SyncfusionThemeStudio) | `{ theme: { extend: { colors, borderRadius, boxShadow, fontFamily } } }` |
24
+ | **(d) Shared UI kit theme** | `toUiTheme(tokens, mode?)` | RN-web on the `@dloizides/ui-*` kit (ichnos, kefi) | a `UiTheme` for `ui-feedback`'s `UiProvider` |
24
25
 
25
26
  ```ts
26
27
  import {
27
28
  AML_TOKENS, EREVNA_TOKENS, KATALOGOS_TOKENS, PRESETS,
28
- toCssVars, toRnTheme, toTailwindPreset,
29
+ toCssVars, toRnTheme, toTailwindPreset, toUiTheme,
29
30
  AML_CSS_VAR_NAMES, DEFAULT_CSS_VAR_NAMES,
30
31
  } from '@dloizides/design-tokens';
31
32
 
@@ -37,8 +38,34 @@ const rnDefault = toRnTheme(EREVNA_TOKENS);
37
38
 
38
39
  // (c) DOM-React ThemeStudio — spread into tailwind.config.presets
39
40
  const tw = toTailwindPreset(KATALOGOS_TOKENS);
41
+
42
+ // (d) Shared UI kit — hand straight to <UiProvider theme={…}>
43
+ const uiTheme = toUiTheme(MY_TOKENS);
40
44
  ```
41
45
 
46
+ ### `toUiTheme` is a LOSSLESS carrier
47
+
48
+ `toUiTheme` exists because the naive projection an app writes by hand —
49
+ `value => ({ '100': v, '500': v, '700': v })` — collapses a scale to one value, silently
50
+ discarding the deeper brand step and every status background tint. A provider fed that way
51
+ cannot reproduce the palette it was built from, which is what stops a shared component
52
+ (`StatCard`, `ThemedTextInput`, `Field`) from rendering on-brand in a consuming app.
53
+
54
+ Every token lands in an addressable slot, so an app can project its whole palette back out of
55
+ the live provider rather than keeping a static parallel copy:
56
+
57
+ | Token | Slot |
58
+ |-------|------|
59
+ | `primary` / `secondary` / `accent` | `palette.primary` / `.secondary` / `.accent` at `UI_MAIN_STEP` |
60
+ | `onBrand` | `palette.onBrand` |
61
+ | `light.surfaceMuted` (or `dark.*`, per `mode`) | `palette.surfaceMuted` |
62
+ | `semantic.success` … | `semantic.success` at `UI_MAIN_STEP` |
63
+ | `semantic.successBg` … | `semantic.success` at `UI_TINT_STEP` |
64
+
65
+ The `UiTheme` shape is declared **structurally** in this package (as `RnThemeConfig` declares
66
+ `TenantThemeConfig`), so the zero-dependency / zero-peer guarantee holds: the token source
67
+ never depends on the kit it feeds.
68
+
42
69
  ## The per-app presets
43
70
 
44
71
  Each preset is seeded from that app's current source of truth:
@@ -63,6 +90,18 @@ the same field names. Fields the core cannot express (a dark app-shell, an ink s
63
90
  verdict triads) live in an optional `extensions` group and are documented as **Stack-A supersets**,
64
91
  not part of the `TenantThemeConfig` contract.
65
92
 
93
+ Three additions (1.2.0) are core rather than extensions, because they are needed by any app with
94
+ a status badge or a filled brand button — not by one stack:
95
+
96
+ | Field | Why it needs its own slot |
97
+ |-------|---------------------------|
98
+ | `light.surfaceMuted` / `dark.surfaceMuted` | The inset surface (table header rows, chips, wells) *recedes*; `surface` and `surfaceElevated` both lift. Neither substitutes. |
99
+ | `onBrand` | The foreground on a `primary` fill. A contrast partner of `primary`, so it sits beside it, not in a mode block. Defaults to white; a **pale** primary must set it. |
100
+ | `semantic.successBg` / `warningBg` / `errorBg` / `infoBg` | A status tint is hand-picked for contrast, not derivable from its base — so it cannot be computed and must be carried. |
101
+
102
+ All optional, and every emitter emits them **only** when a preset declares them, so presets that
103
+ predate 1.2.0 produce byte-identical output.
104
+
66
105
  ## The cross-stack naming contract (#78b)
67
106
 
68
107
  Different stacks use different CSS-variable names for the same token. `toCssVars` takes a
package/dist/index.d.mts CHANGED
@@ -35,13 +35,36 @@ interface ModeColors {
35
35
  border: string;
36
36
  /** Divider lines */
37
37
  divider: string;
38
+ /**
39
+ * Subtle inset surface — table header rows, chips, wells. Distinct from both
40
+ * `surface` (cards) and `surfaceElevated` (modals): it recedes rather than
41
+ * lifts. Optional; consumers fall back to `surface` when a preset omits it.
42
+ */
43
+ surfaceMuted?: string;
38
44
  }
39
- /** Semantic/status colours. Field names match `TenantThemeConfig`'s `SemanticColorOverrides`. */
45
+ /**
46
+ * Semantic/status colours. The four base fields match `TenantThemeConfig`'s
47
+ * `SemanticColorOverrides` exactly.
48
+ *
49
+ * Each base colour may also carry a `*Bg` **background tint** — the soft fill a
50
+ * status badge, banner or row-highlight paints behind text of the base colour.
51
+ * A tint is NOT derivable from its base (it is hand-picked for contrast), so it
52
+ * needs its own slot; without one a status surface cannot be themed at all.
53
+ * Optional, so existing presets are unchanged.
54
+ */
40
55
  interface SemanticColors {
41
56
  success: string;
42
57
  warning: string;
43
58
  error: string;
44
59
  info: string;
60
+ /** Soft background tint behind `success` content. */
61
+ successBg?: string;
62
+ /** Soft background tint behind `warning` content. */
63
+ warningBg?: string;
64
+ /** Soft background tint behind `error` content. */
65
+ errorBg?: string;
66
+ /** Soft background tint behind `info` content. */
67
+ infoBg?: string;
45
68
  }
46
69
  /** Typography tokens. `fontFamily` mirrors `TenantThemeConfig`; `monoFamily` is an optional superset. */
47
70
  interface Typography {
@@ -152,6 +175,14 @@ interface DesignTokens {
152
175
  secondary: string;
153
176
  /** Accent/highlight colour */
154
177
  accent: string;
178
+ /**
179
+ * Foreground colour for content sitting ON a `primary`-filled surface — a
180
+ * filled button's label, a brand header's text. It is a *contrast partner* of
181
+ * `primary`, not a mode colour, so it lives beside it rather than in
182
+ * `light`/`dark`. Optional; consumers fall back to white, the safe default for
183
+ * a saturated brand. A preset with a pale `primary` MUST set it explicitly.
184
+ */
185
+ onBrand?: string;
155
186
  /** Semantic/status colours */
156
187
  semantic: SemanticColors;
157
188
  /** Light-mode colours */
@@ -193,13 +224,19 @@ interface CssVarNames {
193
224
  primary?: string;
194
225
  secondary?: string;
195
226
  accent?: string;
227
+ onBrand?: string;
196
228
  success?: string;
197
229
  warning?: string;
198
230
  error?: string;
199
231
  info?: string;
232
+ successBg?: string;
233
+ warningBg?: string;
234
+ errorBg?: string;
235
+ infoBg?: string;
200
236
  lightBackground?: string;
201
237
  lightSurface?: string;
202
238
  lightSurfaceElevated?: string;
239
+ lightSurfaceMuted?: string;
203
240
  lightText?: string;
204
241
  lightTextSecondary?: string;
205
242
  lightBorder?: string;
@@ -207,6 +244,7 @@ interface CssVarNames {
207
244
  darkBackground?: string;
208
245
  darkSurface?: string;
209
246
  darkSurfaceElevated?: string;
247
+ darkSurfaceMuted?: string;
210
248
  darkText?: string;
211
249
  darkTextSecondary?: string;
212
250
  darkBorder?: string;
@@ -325,13 +363,22 @@ interface TailwindColors {
325
363
  primary: string;
326
364
  secondary: string;
327
365
  accent: string;
366
+ /** Emitted only when the preset declares `onBrand`. */
367
+ 'on-brand'?: string;
328
368
  success: string;
329
369
  warning: string;
330
370
  error: string;
331
371
  info: string;
372
+ /** Status background tints. Emitted only when the preset declares them. */
373
+ 'success-bg'?: string;
374
+ 'warning-bg'?: string;
375
+ 'error-bg'?: string;
376
+ 'info-bg'?: string;
332
377
  background: string;
333
378
  surface: string;
334
379
  'surface-elevated': string;
380
+ /** Emitted only when the preset declares `light.surfaceMuted`. */
381
+ 'surface-muted'?: string;
335
382
  text: string;
336
383
  'text-secondary': string;
337
384
  border: string;
@@ -340,6 +387,8 @@ interface TailwindColors {
340
387
  background: string;
341
388
  surface: string;
342
389
  'surface-elevated': string;
390
+ /** Emitted only when the preset declares `dark.surfaceMuted`. */
391
+ 'surface-muted'?: string;
343
392
  text: string;
344
393
  'text-secondary': string;
345
394
  border: string;
@@ -359,11 +408,89 @@ interface TailwindPreset {
359
408
  }
360
409
  /**
361
410
  * Emit a {@link DesignTokens} as a Tailwind preset for the DOM-React ThemeStudio.
362
- * Colours are always present; `borderRadius`/`boxShadow`/`fontFamily` are emitted
363
- * only when the preset defines the corresponding token group.
411
+ * The core colours are always present; the optional colour slots,
412
+ * `borderRadius`/`boxShadow`/`fontFamily` are emitted only when the preset
413
+ * defines the corresponding token.
364
414
  */
365
415
  declare function toTailwindPreset(tokens: DesignTokens): TailwindPreset;
366
416
 
417
+ /**
418
+ * Emit a {@link DesignTokens} as the shared RN UI kit's theme object — the value
419
+ * `@dloizides/ui-feedback`'s `UiProvider` broadcasts and every kit component
420
+ * (NavShell, DataTable, Filters, Pager, StatusBadge, ThemedTextInput, StatCard)
421
+ * reads via `useUi()`.
422
+ *
423
+ * WHY THIS LIVES HERE
424
+ * -------------------
425
+ * Two apps (ichnos, kefi) independently wrote the same adapter, and both hit the
426
+ * same wall: a naive projection assigns ONE value to every step of a scale, which
427
+ * silently discards the deeper brand step and the status background tints. Each
428
+ * then bolted a private overlay onto the result to smuggle the lost values into
429
+ * free slots. That overlay is this function, done twice — so it belongs in the
430
+ * token package, where the token shape that lost the values is defined.
431
+ *
432
+ * The emitted theme is a LOSSLESS carrier: every token the shape can express has
433
+ * an addressable slot, so an app can round-trip its whole palette back out
434
+ * (see the `*Colors` accessors in each app) instead of keeping a parallel static
435
+ * copy that cannot follow a dark-mode toggle or a per-tenant brand.
436
+ *
437
+ * The type is declared structurally here rather than imported, exactly as
438
+ * {@link RnThemeConfig} declares the `TenantThemeConfig` shape: this package
439
+ * stays framework-agnostic and takes no dependency on the kit it feeds.
440
+ */
441
+
442
+ /** Flat colour fields the kit reads directly. Mirrors `ui-feedback`'s `FeedbackThemeColors`. */
443
+ interface UiThemeColors {
444
+ background: string;
445
+ surface: string;
446
+ surfaceElevated: string;
447
+ text: string;
448
+ textSecondary: string;
449
+ border: string;
450
+ }
451
+ /** A colour scale. The `500` step is guaranteed; other steps are addressable. */
452
+ interface UiColorScale {
453
+ '500': string;
454
+ [step: string]: string;
455
+ }
456
+ /** Brand scales. `primary` is guaranteed; other names are addressable. */
457
+ interface UiThemePalette {
458
+ primary: UiColorScale;
459
+ [name: string]: UiColorScale;
460
+ }
461
+ /** Status scales. `error` is guaranteed; other names are addressable. */
462
+ interface UiThemeSemantic {
463
+ error: UiColorScale;
464
+ [name: string]: UiColorScale;
465
+ }
466
+ /** The kit theme. Structurally identical to `@dloizides/ui-feedback`'s `UiTheme`. */
467
+ interface UiThemeConfig {
468
+ colors: UiThemeColors;
469
+ palette: UiThemePalette;
470
+ semantic: UiThemeSemantic;
471
+ }
472
+ /** Which mode block ({@link DesignTokens.light} / {@link DesignTokens.dark}) to project. */
473
+ type UiThemeMode = 'light' | 'dark';
474
+ /** The soft/tint step of a scale — status background tints, muted brand fills. */
475
+ declare const UI_TINT_STEP = "100";
476
+ /** The step every shipped kit component reads. */
477
+ declare const UI_MAIN_STEP = "500";
478
+ /** The deep/pressed step of a scale. */
479
+ declare const UI_DEEP_STEP = "700";
480
+ /**
481
+ * Project a token set onto the shared kit's theme shape.
482
+ *
483
+ * Every value is carried into an addressable slot:
484
+ * - `palette.primary` / `secondary` / `accent` — the brand scales.
485
+ * - `palette.onBrand` — {@link DesignTokens.onBrand}, the primary's contrast partner.
486
+ * - `palette.surfaceMuted` — the mode's {@link ModeColors.surfaceMuted}.
487
+ * - `semantic.*` — each status colour at `500`, its `*Bg` tint at `100`.
488
+ *
489
+ * @param tokens the app's token set
490
+ * @param mode which mode block to project (default `'light'`)
491
+ */
492
+ declare function toUiTheme(tokens: DesignTokens, mode?: UiThemeMode): UiThemeConfig;
493
+
367
494
  /**
368
495
  * PROOViD AML console (Stack A — vanilla JS) tokens.
369
496
  *
@@ -389,10 +516,17 @@ declare const AML_TOKENS: DesignTokens;
389
516
  *
390
517
  * Seeded byte-for-byte from `erevna-web/src/theme/presets/default.ts`
391
518
  * (`DEFAULT_THEME_CONFIG`) and `erevna-web/src/theme/utils/palette.ts`
392
- * (`basePalette`). Adopting this preset via `toRnTheme(EREVNA_TOKENS)` yields the
393
- * app's current `DEFAULT_THEME_CONFIG` unchanged. No `typography`/`radii`/
394
- * `shadows` — the RN theme has no centralized tokens for those today, so they are
395
- * omitted (nothing to emit → zero visual change).
519
+ * (`basePalette`). No `typography`/`radii`/`shadows` — the RN theme has no
520
+ * centralized tokens for those today, so they are omitted (nothing to emit →
521
+ * zero visual change).
522
+ *
523
+ * ONE deliberate divergence from that seed (UX-11): `light.textSecondary` is
524
+ * `#717171`, not the app's `#777777`. `#777777` measures 4.48:1 on `#ffffff` and
525
+ * 4.18:1 on the `#f7f7f7` card surface — both under the WCAG AA 4.5:1 floor for
526
+ * normal text, and form-field labels render in this colour. `#717171` measures
527
+ * 4.88:1 and 4.56:1 against those same two surfaces. Do not "restore" it to
528
+ * match the app; `presets.contrast.test.ts` will fail if you do. The app's own
529
+ * local preset still carries `#777777` and needs the same fix separately.
396
530
  */
397
531
  declare const EREVNA_TOKENS: DesignTokens;
398
532
 
@@ -402,12 +536,74 @@ declare const EREVNA_TOKENS: DesignTokens;
402
536
  * Seeded byte-for-byte from `katalogos-web/src/theme/presets/default.ts`
403
537
  * (`DEFAULT_THEME_CONFIG`), which is currently identical to Erevna's default.
404
538
  * Kept as a separate preset so the two apps can diverge later without touching
405
- * the other. Adopting via `toRnTheme(KATALOGOS_TOKENS)` yields the app's current
406
- * `DEFAULT_THEME_CONFIG` unchanged.
539
+ * the other.
540
+ *
541
+ * ONE deliberate divergence from that seed (UX-11): `light.textSecondary` is
542
+ * `#717171`, not the app's `#777777`. `#777777` measures 4.48:1 on `#ffffff` and
543
+ * 4.18:1 on the `#f7f7f7` card surface — both under the WCAG AA 4.5:1 floor for
544
+ * normal text, and form-field labels render in this colour. `#717171` measures
545
+ * 4.88:1 and 4.56:1 against those same two surfaces. Do not "restore" it to
546
+ * match the app; `presets.contrast.test.ts` will fail if you do. The app's own
547
+ * local preset still carries `#777777` and needs the same fix separately.
407
548
  */
408
549
  declare const KATALOGOS_TOKENS: DesignTokens;
409
550
 
410
551
  /** Every shipped app preset keyed by app slug. */
411
552
  declare const PRESETS: Readonly<Record<string, DesignTokens>>;
412
553
 
413
- export { AML_CSS_VAR_NAMES, AML_TOKENS, type BrandExtras, type Branding, type CssVarNames, DEFAULT_CSS_VAR_NAMES, type DesignTokens, EREVNA_TOKENS, type InkScale, KATALOGOS_TOKENS, type ModeColors, PRESETS, type Radii, type RnThemeConfig, type SemanticColors, type Shadows, type ShellColors, type TailwindColors, type TailwindPreset, type ToCssVarsOptions, type TokenExtensions, type Typography, type VerdictColors, type WorkspaceExtras, toCssVars, toRnTheme, toTailwindPreset };
554
+ /**
555
+ * WCAG 2.1 contrast-ratio maths.
556
+ *
557
+ * Exists so every packaged preset can be *proved* accessible instead of
558
+ * eyeballed. `presets/presets.contrast.test.ts` uses it as a permanent guard:
559
+ * any future edit to a text-role colour that drops it under the AA floor fails
560
+ * the build.
561
+ *
562
+ * This is a deliberate COPY of the same function in `@dloizides/theme-web`, not
563
+ * an import. `@dloizides/design-tokens` ships zero dependencies and zero peers
564
+ * by design — it is framework-agnostic values only — so taking a dependency on
565
+ * a React theming package to borrow ~60 lines of pure arithmetic would invert
566
+ * the layering (theme-web already depends on this package). The duplication is
567
+ * bounded, pure, and pinned by `contrast.test.ts` against external reference
568
+ * pairs, so the two copies cannot silently disagree.
569
+ *
570
+ * The relative-luminance formula is the real one from WCAG 2.1 §"relative
571
+ * luminance" — sRGB channels are linearized through the gamma transfer function
572
+ * before the ITU-R BT.709 weighting. A naive channel average (or an HSL
573
+ * lightness comparison) is NOT equivalent and will silently pass colours that
574
+ * fail in a browser, which is exactly how `#777777` shipped at 4.48:1.
575
+ *
576
+ * @see https://www.w3.org/TR/WCAG21/#dfn-relative-luminance
577
+ * @see https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio
578
+ */
579
+ /** WCAG 1.4.3 Contrast (Minimum), AA, normal-size text. */
580
+ declare const AA_NORMAL_TEXT_RATIO = 4.5;
581
+ /** WCAG 1.4.3 AA for large text (>=18.66px bold, or >=24px). */
582
+ declare const AA_LARGE_TEXT_RATIO = 3;
583
+ /** WCAG 1.4.11 Non-text Contrast — UI-component boundaries and graphical objects. */
584
+ declare const AA_NON_TEXT_RATIO = 3;
585
+ /**
586
+ * True when `value` is an `#rgb` / `#rrggbb` colour this module can score.
587
+ *
588
+ * Tokens may legitimately hold `rgba()` (AML's dark border is a white overlay),
589
+ * which has no fixed luminance without knowing the backdrop. The guard uses this
590
+ * to EXCLUDE such values explicitly rather than let them throw or, worse, be
591
+ * silently skipped.
592
+ */
593
+ declare function isHexColor(value: string): boolean;
594
+ /**
595
+ * WCAG relative luminance (0 = black, 1 = white) of an `#rgb` / `#rrggbb` colour.
596
+ *
597
+ * @throws if the value is not a parseable hex colour — a typo must be loud, not
598
+ * silently scored as black (which would make every ratio look compliant).
599
+ */
600
+ declare function relativeLuminance(hex: string): number;
601
+ /**
602
+ * WCAG contrast ratio between two colours, in the range 1 (identical) to 21
603
+ * (black on white). Order-independent.
604
+ */
605
+ declare function contrastRatio(foreground: string, background: string): number;
606
+ /** True when `foreground` on `background` meets `requiredRatio`. */
607
+ declare function meetsContrast(foreground: string, background: string, requiredRatio: number): boolean;
608
+
609
+ export { AA_LARGE_TEXT_RATIO, AA_NON_TEXT_RATIO, AA_NORMAL_TEXT_RATIO, AML_CSS_VAR_NAMES, AML_TOKENS, type BrandExtras, type Branding, type CssVarNames, DEFAULT_CSS_VAR_NAMES, type DesignTokens, EREVNA_TOKENS, type InkScale, KATALOGOS_TOKENS, type ModeColors, PRESETS, type Radii, type RnThemeConfig, type SemanticColors, type Shadows, type ShellColors, type TailwindColors, type TailwindPreset, type ToCssVarsOptions, type TokenExtensions, type Typography, UI_DEEP_STEP, UI_MAIN_STEP, UI_TINT_STEP, type UiColorScale, type UiThemeColors, type UiThemeConfig, type UiThemeMode, type UiThemePalette, type UiThemeSemantic, type VerdictColors, type WorkspaceExtras, contrastRatio, isHexColor, meetsContrast, relativeLuminance, toCssVars, toRnTheme, toTailwindPreset, toUiTheme };