@cdx-ui/styles 0.0.1-beta.54 → 0.0.1-beta.56

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.
Files changed (46) hide show
  1. package/css/theme.css +2 -2
  2. package/lib/commonjs/applyThemeOverride.js +154 -0
  3. package/lib/commonjs/applyThemeOverride.js.map +1 -0
  4. package/lib/commonjs/index.js +69 -73
  5. package/lib/commonjs/index.js.map +1 -1
  6. package/lib/commonjs/palette.js +180 -0
  7. package/lib/commonjs/palette.js.map +1 -0
  8. package/lib/commonjs/theming.js +218 -0
  9. package/lib/commonjs/theming.js.map +1 -0
  10. package/lib/commonjs/types.js +75 -0
  11. package/lib/commonjs/types.js.map +1 -0
  12. package/lib/module/applyThemeOverride.js +149 -0
  13. package/lib/module/applyThemeOverride.js.map +1 -0
  14. package/lib/module/index.js +8 -62
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/module/palette.js +176 -0
  17. package/lib/module/palette.js.map +1 -0
  18. package/lib/module/theming.js +202 -0
  19. package/lib/module/theming.js.map +1 -0
  20. package/lib/module/types.js +71 -0
  21. package/lib/module/types.js.map +1 -0
  22. package/lib/runtime/prestige-vs-default.json +1 -0
  23. package/lib/runtime/pulse-vs-default.json +1 -0
  24. package/lib/runtime/token-to-css-var.json +632 -0
  25. package/lib/typescript/applyThemeOverride.d.ts +26 -0
  26. package/lib/typescript/applyThemeOverride.d.ts.map +1 -0
  27. package/lib/typescript/index.d.ts +7 -89
  28. package/lib/typescript/index.d.ts.map +1 -1
  29. package/lib/typescript/palette.d.ts +48 -0
  30. package/lib/typescript/palette.d.ts.map +1 -0
  31. package/lib/typescript/theming.d.ts +40 -0
  32. package/lib/typescript/theming.d.ts.map +1 -0
  33. package/lib/typescript/types.d.ts +90 -0
  34. package/lib/typescript/types.d.ts.map +1 -0
  35. package/package.json +27 -8
  36. package/runtime/prestige-vs-default.json +1 -0
  37. package/runtime/pulse-vs-default.json +1 -0
  38. package/runtime/token-to-css-var.json +632 -0
  39. package/src/__tests__/applyThemeOverride.test.ts +488 -0
  40. package/src/__tests__/generateColorScale.test.ts +202 -0
  41. package/src/__tests__/theming.test.ts +525 -0
  42. package/src/applyThemeOverride.ts +139 -0
  43. package/src/index.ts +33 -103
  44. package/src/palette.ts +226 -0
  45. package/src/theming.ts +230 -0
  46. package/src/types.ts +112 -0
@@ -0,0 +1,26 @@
1
+ import type { Platform, Preset, ThemeOverride } from './types';
2
+ import { type RuntimeMap } from './theming';
3
+ /** The build-time default preset. Apps ship with Poise baked into CSS. */
4
+ export declare const DEFAULT_PRESET: Preset;
5
+ export type ApplyThemeOverrideResult = {
6
+ applied: true;
7
+ light: Record<string, string>;
8
+ dark: Record<string, string>;
9
+ } | {
10
+ applied: false;
11
+ reason: 'unsupported_schema_version' | 'no_theme_changes';
12
+ };
13
+ export interface ApplyThemeOverrideOptions {
14
+ runtimeMap?: RuntimeMap;
15
+ runtimePlatform?: Platform;
16
+ }
17
+ /**
18
+ * Apply a `ThemeOverride` end-to-end: schema version gate, preset patch
19
+ * selection, palette generation, and `Uniwind.updateCSSVariables` calls.
20
+ *
21
+ * Encapsulates the full runtime theme application sequence so consuming
22
+ * apps don't need to orchestrate lower-level utilities or import Uniwind
23
+ * directly.
24
+ */
25
+ export declare function applyThemeOverride(override: ThemeOverride, options?: ApplyThemeOverrideOptions): ApplyThemeOverrideResult;
26
+ //# sourceMappingURL=applyThemeOverride.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyThemeOverride.d.ts","sourceRoot":"","sources":["../../src/applyThemeOverride.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAc,MAAM,SAAS,CAAC;AAC3E,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AAMnB,0EAA0E;AAC1E,eAAO,MAAM,cAAc,EAAE,MAAgB,CAAC;AAgC9C,MAAM,MAAM,wBAAwB,GAChC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC9E;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,4BAA4B,GAAG,kBAAkB,CAAA;CAAE,CAAC;AAMlF,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,QAAQ,CAAC;CAC5B;AAMD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CA6D1B"}
@@ -1,92 +1,10 @@
1
- /** A DTCG token leaf node. */
2
- export interface TokenValue {
3
- $type: string;
4
- $value: string | number;
5
- $extensions?: Record<string, unknown>;
6
- }
7
- /** Recursive token group every non-leaf node in a theme object. */
8
- export interface TokenGroup {
9
- [key: string]: TokenValue | TokenGroup;
10
- }
11
- /** The three built-in Forge UI theme presets. */
12
- export type Preset = 'poise' | 'prestige' | 'pulse';
13
- /** Theme metadata stored under `$extensions.com.forge.ui.theme`. */
14
- export interface ThemeMetadata {
15
- name: string;
16
- preset: Preset;
17
- schemaVersion: string;
18
- }
19
- /** Override metadata stored under `$extensions.com.forge.ui.themeOverride`. */
20
- export interface ThemeOverrideMetadata {
21
- basePreset: Preset;
22
- schemaVersion: string;
23
- }
24
- /**
25
- * A complete Forge UI theme object (DTCG-compatible).
26
- *
27
- * Presets (Poise, Prestige, Pulse) are full theme objects. At runtime the
28
- * build-time default preset is augmented by FI overrides via
29
- * `applyThemeOverrides`.
30
- */
31
- export type ThemeObject = TokenGroup & {
32
- $extensions: {
33
- 'com.forge.ui.theme': ThemeMetadata;
34
- [key: string]: unknown;
35
- };
36
- modes: {
37
- light: TokenGroup;
38
- dark: TokenGroup;
39
- };
40
- platform: {
41
- web: TokenGroup;
42
- ios: TokenGroup;
43
- android: TokenGroup;
44
- };
45
- };
46
- /**
47
- * A theme override using the hybrid input + semantic structure.
48
- *
49
- * - `inputs` — flat map of abstract FI-selected brand values (e.g.
50
- * `brandPrimary`, `displayFont`). Palette generation expands these into
51
- * full token scales at runtime.
52
- * - `overrides` — per-mode flat maps of token dot-paths to resolved values
53
- * for direct semantic token overrides beyond what inputs generate.
54
- * - `$extensions` — required metadata including base preset and schema version.
55
- */
56
- export interface ThemeOverride {
57
- $extensions: {
58
- 'com.forge.ui.themeOverride': ThemeOverrideMetadata;
59
- [key: string]: unknown;
60
- };
61
- inputs?: Record<string, string | number>;
62
- overrides?: Partial<Record<Mode, Record<string, string | number>>>;
63
- }
64
- export type Mode = 'light' | 'dark';
65
- export type Platform = 'web' | 'ios' | 'android';
66
- /** Current override schema version. Consuming apps gate compatibility on this. */
67
- export declare const OVERRIDE_SCHEMA_VERSION: "1.0.0";
68
- /**
69
- * Schema versions that consuming apps accept. Includes the current version and
70
- * may include the immediately prior version during transition windows.
71
- * @see docs/internal/token-architecture/16-override-structure.md § 4
72
- */
73
- export declare const SUPPORTED_OVERRIDE_SCHEMA_VERSIONS: readonly string[];
74
- /**
75
- * Schema-level mapping from known input keys to the token path pattern each
76
- * affects. Used by override application (S5) to route inputs to the correct
77
- * palette/token namespace. Distinct from the full runtime map (S3).
78
- */
79
- export declare const INPUT_TOKEN_MAP: {
80
- readonly brandPrimary: "color.brand";
81
- readonly accentPrimary: "color.accent";
82
- readonly basePrimary: "color.base";
83
- readonly displayFont: "font.display";
84
- };
85
- /**
86
- * Allowed display font families per preset, consumed by the theme editor for
87
- * font selection and by consuming apps for validation.
88
- */
89
- export declare const presetFonts: Record<Preset, readonly string[]>;
1
+ export { OVERRIDE_SCHEMA_VERSION, SUPPORTED_OVERRIDE_SCHEMA_VERSIONS, INPUT_TOKEN_MAP, presetFonts, } from './types';
2
+ export type { TokenValue, TokenGroup, Preset, ThemeMetadata, ThemeOverrideMetadata, ThemeObject, ThemeOverride, Mode, Platform, } from './types';
3
+ export { generateColorScale, generatePalettesFromInputs } from './palette';
4
+ export type { PaletteCategory, PaletteScale, PaletteStep, PaletteTokenMap } from './palette';
5
+ export { isSchemaVersionSupported, presetPatchToUniwindMaps, themeOverrideToUniwindMaps, applyThemeOverride, DEFAULT_PRESET, } from './theming';
6
+ export type { CssVariableMaps, RuntimeMap } from './theming';
7
+ export type { ApplyThemeOverrideOptions, ApplyThemeOverrideResult } from './applyThemeOverride';
90
8
  export { useForgeFonts } from './useForgeFonts';
91
9
  export { useCdxFonts } from './useCdxFonts';
92
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,8BAA8B;AAC9B,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,qEAAqE;AACrE,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;CACxC;AAED,iDAAiD;AACjD,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;AAEpD,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,+EAA+E;AAC/E,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC,WAAW,EAAE;QACX,oBAAoB,EAAE,aAAa,CAAC;QACpC,CAAC,GAAG,EAAE,MAAM,GAA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eAAe,EACf,WAAW,GACZ,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,UAAU,EACV,UAAU,EACV,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,IAAI,EACJ,QAAQ,GACT,MAAM,SAAS,CAAC;AAMjB,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAC3E,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAM7F,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7D,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAMhG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,48 @@
1
+ /** Palette step keys produced by `generateColorScale`. */
2
+ export type PaletteStep = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950' | 'input';
3
+ /** Token category that supports palette generation. */
4
+ export type PaletteCategory = 'brand' | 'accent';
5
+ /** Map of palette step → resolved hex color. */
6
+ export type PaletteScale = Record<PaletteStep, string>;
7
+ /** Map of token dot-path → resolved hex color (e.g. `color.brand.500` → `#548cdc`). */
8
+ export type PaletteTokenMap = Record<string, string>;
9
+ /**
10
+ * Generate an 11-step contrast-based color scale from a single hex color.
11
+ *
12
+ * Uses `@adobe/leonardo-contrast-colors` internally. The generation algorithm
13
+ * is wrapped behind this function so the underlying library is swappable
14
+ * without changing the public API.
15
+ *
16
+ * @param hex - A valid hex color string (`#RGB` or `#RRGGBB`).
17
+ * @param category - The token namespace (`'brand'` or `'accent'`).
18
+ * @returns A `PaletteTokenMap` keyed by token dot-paths
19
+ * (e.g. `"color.brand.50"` through `"color.brand.950"` plus `"color.brand.input"`).
20
+ */
21
+ export declare function generateColorScale(hex: string, category: PaletteCategory): PaletteTokenMap;
22
+ /**
23
+ * Generate palettes for all colour inputs in a theme override `inputs` object.
24
+ *
25
+ * Iterates over known colour-input keys that map to a `color.*` token
26
+ * namespace. For each matching key present in `inputs`, runs
27
+ * `generateColorScale` and merges the results into a single flat map of
28
+ * token dot-paths to hex values — ready for the S5 override application
29
+ * merge step.
30
+ *
31
+ * Non-colour inputs (e.g. `displayFont`) are silently skipped.
32
+ *
33
+ * @param inputs - The `inputs` object from a `ThemeOverride`.
34
+ * @returns A merged `Record<string, string>` of all generated token
35
+ * dot-paths to hex values.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const inputs = { brandPrimary: '#0052cc', accentPrimary: '#FF8C42', displayFont: 'Poppins' };
40
+ * const result = generatePalettesFromInputs(inputs);
41
+ * // {
42
+ * // "color.brand.50": "#...", …, "color.brand.input": "#0052cc",
43
+ * // "color.accent.50": "#...", …, "color.accent.input": "#ff8c42"
44
+ * // }
45
+ * ```
46
+ */
47
+ export declare function generatePalettesFromInputs(inputs: Record<string, string | number>): PaletteTokenMap;
48
+ //# sourceMappingURL=palette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/palette.ts"],"names":[],"mappings":"AAMA,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GACnB,IAAI,GACJ,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,OAAO,CAAC;AAEZ,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEjD,gDAAgD;AAChD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAEvD,uFAAuF;AACvF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AA8ErD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,eAAe,CAgD1F;AAkBD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACtC,eAAe,CAcjB"}
@@ -0,0 +1,40 @@
1
+ import { type Platform, type ThemeOverride, type TokenGroup } from './types';
2
+ export { applyThemeOverride, DEFAULT_PRESET } from './applyThemeOverride';
3
+ export type { ApplyThemeOverrideOptions, ApplyThemeOverrideResult } from './applyThemeOverride';
4
+ /** Per-mode CSS variable maps ready for `Uniwind.updateCSSVariables`. */
5
+ export interface CssVariableMaps {
6
+ light: Record<string, string>;
7
+ dark: Record<string, string>;
8
+ }
9
+ /** Runtime map: token dot-paths → CSS custom property names. */
10
+ export type RuntimeMap = Record<string, string>;
11
+ /**
12
+ * Check whether a `ThemeOverride`'s schema version is supported by the current
13
+ * build of `@cdx-ui/styles`.
14
+ */
15
+ export declare function isSchemaVersionSupported(override: ThemeOverride): boolean;
16
+ /**
17
+ * Convert a nested DTCG preset patch (sparse, `$type`/`$value` leaves) into
18
+ * per-mode CSS variable maps suitable for `Uniwind.updateCSSVariables`.
19
+ *
20
+ * @param patch - A sparse DTCG token object (preset patch).
21
+ * @param runtimeMap - The generated token-to-CSS-var mapping.
22
+ * @param runtimePlatform - Current platform (`'web' | 'ios' | 'android'`).
23
+ */
24
+ export declare function presetPatchToUniwindMaps(patch: TokenGroup, runtimeMap: RuntimeMap, runtimePlatform: Platform): CssVariableMaps;
25
+ /**
26
+ * Convert a hybrid FI override (`ThemeOverride`) into per-mode CSS variable
27
+ * maps suitable for `Uniwind.updateCSSVariables`.
28
+ *
29
+ * Processing:
30
+ * 1. Generate palettes from color `inputs` (via S4).
31
+ * 2. Map font inputs to token paths.
32
+ * 3. For each mode, merge palette + fonts + explicit `overrides.{mode}` entries.
33
+ * 4. Map all token dot-paths to CSS variable names via runtime map.
34
+ *
35
+ * @param override - A `ThemeOverride` object.
36
+ * @param runtimeMap - The generated token-to-CSS-var mapping.
37
+ * @param runtimePlatform - Current platform (`'web' | 'ios' | 'android'`).
38
+ */
39
+ export declare function themeOverrideToUniwindMaps(override: ThemeOverride, runtimeMap: RuntimeMap): CssVariableMaps;
40
+ //# sourceMappingURL=theming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theming.d.ts","sourceRoot":"","sources":["../../src/theming.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,UAAU,EAEhB,MAAM,SAAS,CAAC;AAMjB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1E,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAMhG,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAMhD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAGzE;AAgFD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,QAAQ,GACxB,eAAe,CAIjB;AAcD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,UAAU,GAErB,eAAe,CA2DjB"}
@@ -0,0 +1,90 @@
1
+ /** A DTCG token leaf node. */
2
+ export interface TokenValue {
3
+ $type: string;
4
+ $value: string | number;
5
+ $extensions?: Record<string, unknown>;
6
+ }
7
+ /** Recursive token group — every non-leaf node in a theme object. */
8
+ export interface TokenGroup {
9
+ [key: string]: TokenValue | TokenGroup;
10
+ }
11
+ /** The three built-in Forge UI theme presets. */
12
+ export type Preset = 'poise' | 'prestige' | 'pulse';
13
+ /** Theme metadata stored under `$extensions.com.forge.ui.theme`. */
14
+ export interface ThemeMetadata {
15
+ name: string;
16
+ preset: Preset;
17
+ schemaVersion: string;
18
+ }
19
+ /** Override metadata stored under `$extensions.com.forge.ui.themeOverride`. */
20
+ export interface ThemeOverrideMetadata {
21
+ basePreset: Preset;
22
+ schemaVersion: string;
23
+ }
24
+ /**
25
+ * A complete Forge UI theme object (DTCG-compatible).
26
+ *
27
+ * Presets (Poise, Prestige, Pulse) are full theme objects. At runtime the
28
+ * build-time default preset is augmented by FI overrides via
29
+ * `applyThemeOverrides`.
30
+ */
31
+ export type ThemeObject = TokenGroup & {
32
+ $extensions: {
33
+ 'com.forge.ui.theme': ThemeMetadata;
34
+ [key: string]: unknown;
35
+ };
36
+ modes: {
37
+ light: TokenGroup;
38
+ dark: TokenGroup;
39
+ };
40
+ platform: {
41
+ web: TokenGroup;
42
+ ios: TokenGroup;
43
+ android: TokenGroup;
44
+ };
45
+ };
46
+ /**
47
+ * A theme override using the hybrid input + semantic structure.
48
+ *
49
+ * - `inputs` — flat map of abstract FI-selected brand values (e.g.
50
+ * `brandPrimary`, `displayFont`). Palette generation expands these into
51
+ * full token scales at runtime.
52
+ * - `overrides` — per-mode flat maps of token dot-paths to resolved values
53
+ * for direct semantic token overrides beyond what inputs generate.
54
+ * - `$extensions` — required metadata including base preset and schema version.
55
+ */
56
+ export interface ThemeOverride {
57
+ $extensions: {
58
+ 'com.forge.ui.themeOverride': ThemeOverrideMetadata;
59
+ [key: string]: unknown;
60
+ };
61
+ inputs?: Record<string, string | number>;
62
+ overrides?: Partial<Record<Mode, Record<string, string | number>>>;
63
+ }
64
+ export type Mode = 'light' | 'dark';
65
+ export type Platform = 'web' | 'ios' | 'android';
66
+ /** Current override schema version. Consuming apps gate compatibility on this. */
67
+ export declare const OVERRIDE_SCHEMA_VERSION: "1.0.0";
68
+ /**
69
+ * Schema versions that consuming apps accept. Includes the current version and
70
+ * may include the immediately prior version during transition windows.
71
+ * @see docs/internal/token-architecture/16-override-structure.md § 4
72
+ */
73
+ export declare const SUPPORTED_OVERRIDE_SCHEMA_VERSIONS: readonly string[];
74
+ /**
75
+ * Schema-level mapping from known input keys to the token path pattern each
76
+ * affects. Used by override application (S5) to route inputs to the correct
77
+ * palette/token namespace. Distinct from the full runtime map (S3).
78
+ */
79
+ export declare const INPUT_TOKEN_MAP: {
80
+ readonly brandPrimary: "color.brand";
81
+ readonly accentPrimary: "color.accent";
82
+ readonly basePrimary: "color.base";
83
+ readonly displayFont: "font.display";
84
+ };
85
+ /**
86
+ * Allowed display font families per preset, consumed by the theme editor for
87
+ * font selection and by consuming apps for validation.
88
+ */
89
+ export declare const presetFonts: Record<Preset, readonly string[]>;
90
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAIA,8BAA8B;AAC9B,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,qEAAqE;AACrE,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;CACxC;AAED,iDAAiD;AACjD,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;AAEpD,oEA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AC;AAExF;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;CAKe,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAIhD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdx-ui/styles",
3
- "version": "0.0.1-beta.54",
3
+ "version": "0.0.1-beta.56",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "module": "lib/module/index.js",
6
6
  "react-native": "src/index.ts",
@@ -19,13 +19,24 @@
19
19
  "./vanilla.css": "./css/vanilla.css",
20
20
  "./presets/poise.json": "./tokens/presets/poise.json",
21
21
  "./presets/prestige.json": "./tokens/presets/prestige.json",
22
- "./presets/pulse.json": "./tokens/presets/pulse.json"
22
+ "./presets/pulse.json": "./tokens/presets/pulse.json",
23
+ "./theming": {
24
+ "react-native": "./src/theming.ts",
25
+ "types": "./lib/typescript/theming.d.ts",
26
+ "import": "./lib/module/theming.js",
27
+ "require": "./lib/commonjs/theming.js",
28
+ "default": "./lib/module/theming.js"
29
+ },
30
+ "./runtime/token-to-css-var.json": "./runtime/token-to-css-var.json",
31
+ "./runtime/prestige-vs-default.json": "./runtime/prestige-vs-default.json",
32
+ "./runtime/pulse-vs-default.json": "./runtime/pulse-vs-default.json"
23
33
  },
24
34
  "files": [
25
35
  "lib",
26
36
  "src",
27
37
  "css",
28
- "tokens"
38
+ "tokens",
39
+ "runtime"
29
40
  ],
30
41
  "react-native-builder-bob": {
31
42
  "source": "src",
@@ -42,6 +53,7 @@
42
53
  ]
43
54
  },
44
55
  "dependencies": {
56
+ "@adobe/leonardo-contrast-colors": "1.1.0",
45
57
  "@expo-google-fonts/bitter": "0.4.1",
46
58
  "@expo-google-fonts/cormorant": "0.4.2",
47
59
  "@expo-google-fonts/crimson-pro": "0.4.2",
@@ -53,12 +65,13 @@
53
65
  "@expo-google-fonts/manrope": "0.4.2",
54
66
  "@expo-google-fonts/outfit": "0.4.3",
55
67
  "@expo-google-fonts/public-sans": "0.4.2",
56
- "@cdx-ui/utils": "0.0.1-beta.54"
68
+ "@cdx-ui/utils": "0.0.1-beta.56"
57
69
  },
58
70
  "peerDependencies": {
71
+ "expo-font": ">=13.0.0",
59
72
  "react": "^18.2.0 || ^19.0.0",
60
73
  "react-native": ">=0.76.0",
61
- "expo-font": ">=13.0.0"
74
+ "uniwind": ">=1.0.0"
62
75
  },
63
76
  "peerDependenciesMeta": {
64
77
  "react-native": {
@@ -66,15 +79,20 @@
66
79
  },
67
80
  "expo-font": {
68
81
  "optional": true
82
+ },
83
+ "uniwind": {
84
+ "optional": true
69
85
  }
70
86
  },
71
87
  "devDependencies": {
88
+ "@types/jest": "^29.5.14",
72
89
  "@types/react": "*",
73
90
  "expo-font": "*",
74
91
  "react": "*",
75
92
  "react-native": "*",
76
93
  "react-native-builder-bob": "^0.40.17",
77
94
  "style-dictionary": "^4.4.0",
95
+ "ts-jest": "29.4.11",
78
96
  "typescript": "~5.9.2"
79
97
  },
80
98
  "nx": {
@@ -90,10 +108,11 @@
90
108
  "access": "public"
91
109
  },
92
110
  "scripts": {
93
- "build": "bob build",
94
- "lint": "eslint src/",
111
+ "build": "bob build && cp -r runtime lib/runtime",
112
+ "lint": "eslint src/ --ignore-pattern '**/__tests__/**'",
95
113
  "tokens:fetch": "node scripts/figma-fetch-variables.mjs",
96
114
  "tokens:build": "node scripts/build-tokens.mjs",
97
- "fonts:validate": "node scripts/validate-font-tokens.mjs"
115
+ "fonts:validate": "node scripts/validate-font-tokens.mjs",
116
+ "test": "jest --config jest.config.js"
98
117
  }
99
118
  }
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ {}