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

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
package/src/types.ts ADDED
@@ -0,0 +1,112 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Types
3
+ // ---------------------------------------------------------------------------
4
+
5
+ /** A DTCG token leaf node. */
6
+ export interface TokenValue {
7
+ $type: string;
8
+ $value: string | number;
9
+ $extensions?: Record<string, unknown>;
10
+ }
11
+
12
+ /** Recursive token group — every non-leaf node in a theme object. */
13
+ export interface TokenGroup {
14
+ [key: string]: TokenValue | TokenGroup;
15
+ }
16
+
17
+ /** The three built-in Forge UI theme presets. */
18
+ export type Preset = 'poise' | 'prestige' | 'pulse';
19
+
20
+ /** Theme metadata stored under `$extensions.com.forge.ui.theme`. */
21
+ export interface ThemeMetadata {
22
+ name: string;
23
+ preset: Preset;
24
+ schemaVersion: string;
25
+ }
26
+
27
+ /** Override metadata stored under `$extensions.com.forge.ui.themeOverride`. */
28
+ export interface ThemeOverrideMetadata {
29
+ basePreset: Preset;
30
+ schemaVersion: string;
31
+ }
32
+
33
+ /**
34
+ * A complete Forge UI theme object (DTCG-compatible).
35
+ *
36
+ * Presets (Poise, Prestige, Pulse) are full theme objects. At runtime the
37
+ * build-time default preset is augmented by FI overrides via
38
+ * `applyThemeOverrides`.
39
+ */
40
+ export type ThemeObject = TokenGroup & {
41
+ $extensions: {
42
+ 'com.forge.ui.theme': ThemeMetadata;
43
+ [key: string]: unknown;
44
+ };
45
+ modes: {
46
+ light: TokenGroup;
47
+ dark: TokenGroup;
48
+ };
49
+ platform: {
50
+ web: TokenGroup;
51
+ ios: TokenGroup;
52
+ android: TokenGroup;
53
+ };
54
+ };
55
+
56
+ /**
57
+ * A theme override using the hybrid input + semantic structure.
58
+ *
59
+ * - `inputs` — flat map of abstract FI-selected brand values (e.g.
60
+ * `brandPrimary`, `displayFont`). Palette generation expands these into
61
+ * full token scales at runtime.
62
+ * - `overrides` — per-mode flat maps of token dot-paths to resolved values
63
+ * for direct semantic token overrides beyond what inputs generate.
64
+ * - `$extensions` — required metadata including base preset and schema version.
65
+ */
66
+ export interface ThemeOverride {
67
+ $extensions: {
68
+ 'com.forge.ui.themeOverride': ThemeOverrideMetadata;
69
+ [key: string]: unknown;
70
+ };
71
+ inputs?: Record<string, string | number>;
72
+ overrides?: Partial<Record<Mode, Record<string, string | number>>>;
73
+ }
74
+
75
+ export type Mode = 'light' | 'dark';
76
+ export type Platform = 'web' | 'ios' | 'android';
77
+
78
+ // ---------------------------------------------------------------------------
79
+ // Constants
80
+ // ---------------------------------------------------------------------------
81
+
82
+ /** Current override schema version. Consuming apps gate compatibility on this. */
83
+ export const OVERRIDE_SCHEMA_VERSION = '1.0.0' as const;
84
+
85
+ /**
86
+ * Schema versions that consuming apps accept. Includes the current version and
87
+ * may include the immediately prior version during transition windows.
88
+ * @see docs/internal/token-architecture/16-override-structure.md § 4
89
+ */
90
+ export const SUPPORTED_OVERRIDE_SCHEMA_VERSIONS: readonly string[] = ['1.0.0'] as const;
91
+
92
+ /**
93
+ * Schema-level mapping from known input keys to the token path pattern each
94
+ * affects. Used by override application (S5) to route inputs to the correct
95
+ * palette/token namespace. Distinct from the full runtime map (S3).
96
+ */
97
+ export const INPUT_TOKEN_MAP = {
98
+ brandPrimary: 'color.brand',
99
+ accentPrimary: 'color.accent',
100
+ basePrimary: 'color.base',
101
+ displayFont: 'font.display',
102
+ } as const satisfies Record<string, string>;
103
+
104
+ /**
105
+ * Allowed display font families per preset, consumed by the theme editor for
106
+ * font selection and by consuming apps for validation.
107
+ */
108
+ export const presetFonts: Record<Preset, readonly string[]> = {
109
+ poise: ['Crimson Pro', 'Bitter', 'DM Sans'],
110
+ prestige: ['Libre Caslon Text', 'Cormorant', 'Libre Franklin'],
111
+ pulse: ['Outfit', 'Manrope', 'Public Sans'],
112
+ } as const;