@ttoss/fsl-theme 1.1.13 → 1.1.14

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 (91) hide show
  1. package/dist/Types-BiBa17RL.d.cts +1427 -0
  2. package/dist/Types-BiBa17RL.d.mts +1427 -0
  3. package/dist/baseBundle-DxvXyhGa.mjs +17 -0
  4. package/dist/baseBundle-iEFf5nqT.cjs +22 -0
  5. package/dist/{esm/chunk-SE5Z52RE.js → createTheme-BLNYztZU.mjs} +76 -172
  6. package/dist/createTheme-Cv6RP9D6.cjs +1825 -0
  7. package/dist/css.cjs +48 -0
  8. package/dist/{css.d.ts → css.d.cts} +67 -63
  9. package/dist/css.d.mts +168 -0
  10. package/dist/css.mjs +42 -0
  11. package/dist/dataviz/index.cjs +45 -0
  12. package/dist/dataviz/{index.d.ts → index.d.cts} +9 -5
  13. package/dist/dataviz/index.d.mts +66 -0
  14. package/dist/dataviz/index.mjs +39 -0
  15. package/dist/dtcg.cjs +115 -0
  16. package/dist/{dtcg.d.ts → dtcg.d.cts} +9 -7
  17. package/dist/dtcg.d.mts +51 -0
  18. package/dist/dtcg.mjs +112 -0
  19. package/dist/helpers-4p4-QVt_.cjs +258 -0
  20. package/dist/helpers-CaswNJMy.mjs +211 -0
  21. package/dist/{index.d.ts → index-CsIjfw86.d.cts} +42 -34
  22. package/dist/index-nJrjI0BA.d.mts +94 -0
  23. package/dist/index.cjs +16 -0
  24. package/dist/index.d.cts +6 -0
  25. package/dist/index.d.mts +6 -0
  26. package/dist/index.mjs +7 -0
  27. package/dist/{react.d.ts → react-CGa6FlNL.d.cts} +130 -106
  28. package/dist/react-DnKxR2gK.d.mts +370 -0
  29. package/dist/react-EUwpdvY7.cjs +481 -0
  30. package/dist/react.cjs +12 -0
  31. package/dist/react.d.cts +4 -0
  32. package/dist/react.d.mts +4 -0
  33. package/dist/react.mjs +412 -0
  34. package/dist/runtime-entry.cjs +9 -0
  35. package/dist/runtime-entry.d.cts +3 -0
  36. package/dist/runtime-entry.d.mts +3 -0
  37. package/dist/runtime-entry.mjs +3 -0
  38. package/dist/{runtime-entry.d.ts → ssrScript-BVysxDws.d.cts} +26 -23
  39. package/dist/ssrScript-BVysxDws.d.mts +98 -0
  40. package/dist/ssrScript-CRfrN8Pm.cjs +202 -0
  41. package/dist/ssrScript-D3kGPQpi.mjs +179 -0
  42. package/dist/themes/bruttal.cjs +75 -0
  43. package/dist/themes/bruttal.d.cts +3 -0
  44. package/dist/themes/bruttal.d.mts +3 -0
  45. package/dist/themes/bruttal.mjs +72 -0
  46. package/dist/themes/corporate.cjs +34 -0
  47. package/dist/themes/corporate.d.cts +3 -0
  48. package/dist/themes/corporate.d.mts +3 -0
  49. package/dist/{esm/chunk-TPMN75JM.js → themes/corporate.mjs} +7 -5
  50. package/dist/themes/oca.cjs +34 -0
  51. package/dist/themes/oca.d.cts +3 -0
  52. package/dist/themes/oca.d.mts +3 -0
  53. package/dist/{esm/chunk-DU4QDQUC.js → themes/oca.mjs} +7 -5
  54. package/dist/themes/ventures.cjs +34 -0
  55. package/dist/themes/ventures.d.cts +3 -0
  56. package/dist/themes/ventures.d.mts +3 -0
  57. package/dist/{esm/chunk-BXKVVQEP.js → themes/ventures.mjs} +7 -5
  58. package/dist/toCssVars-CYZCe-on.mjs +286 -0
  59. package/dist/toCssVars-DudHKvt2.cjs +297 -0
  60. package/dist/{esm/chunk-4Q4P3JBB.js → tokenRegistry-DjgSN3oU.mjs} +23 -20
  61. package/dist/tokenRegistry-OhaJ9sPJ.cjs +199 -0
  62. package/dist/vars.cjs +127 -0
  63. package/dist/{vars.d.ts → vars.d.cts} +8 -7
  64. package/dist/vars.d.mts +128 -0
  65. package/dist/vars.mjs +123 -0
  66. package/dist/withDataviz-B4pVsOwV.cjs +192 -0
  67. package/dist/{esm/chunk-FBVUI2PK.js → withDataviz-DY5s7R51.mjs} +40 -12
  68. package/package.json +6 -6
  69. package/dist/Types-6tR0_2Ss.d.ts +0 -1452
  70. package/dist/esm/chunk-5PWPAQMC.js +0 -9
  71. package/dist/esm/chunk-HRNXVRS3.js +0 -54
  72. package/dist/esm/chunk-IJGA42O6.js +0 -141
  73. package/dist/esm/chunk-PQPQNZ73.js +0 -262
  74. package/dist/esm/chunk-UMRQ4OTX.js +0 -11
  75. package/dist/esm/chunk-VL6EGE6Z.js +0 -222
  76. package/dist/esm/chunk-WVQSTQD5.js +0 -192
  77. package/dist/esm/css.js +0 -6
  78. package/dist/esm/dataviz/index.js +0 -19
  79. package/dist/esm/dtcg.js +0 -65
  80. package/dist/esm/index.js +0 -10
  81. package/dist/esm/react.js +0 -8
  82. package/dist/esm/runtime-entry.js +0 -4
  83. package/dist/esm/themes/bruttal.js +0 -6
  84. package/dist/esm/themes/corporate.js +0 -6
  85. package/dist/esm/themes/oca.js +0 -6
  86. package/dist/esm/themes/ventures.js +0 -6
  87. package/dist/esm/vars.js +0 -28
  88. package/dist/themes/bruttal.d.ts +0 -5
  89. package/dist/themes/corporate.d.ts +0 -5
  90. package/dist/themes/oca.d.ts +0 -5
  91. package/dist/themes/ventures.d.ts +0 -5
@@ -1,9 +1,16 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
-
3
- // src/roots/tokenRegistry.ts
4
- var TOKEN_PATH_REGISTRY = [
5
- // -- Core dataviz (longer/more-specific entries first) --------------------
6
- {
2
+ //#region src/roots/tokenRegistry.ts
3
+ /**
4
+ * Ordered registry of token path prefixes → CSS var prefix + DTCG type.
5
+ *
6
+ * Convention:
7
+ * - Core tokens: `--tt-core-<family>-<subpath>`
8
+ * - Semantic tokens: `--tt-<family>-<subpath>`
9
+ *
10
+ * Longer (more specific) prefixes come first so that consumers using
11
+ * first-match lookup get the correct result.
12
+ */
13
+ const TOKEN_PATH_REGISTRY = [{
7
14
  path: "core.dataviz.color.",
8
15
  cssPrefix: "--tt-core-dataviz-color-",
9
16
  dtcgType: "color"
@@ -15,9 +22,7 @@ var TOKEN_PATH_REGISTRY = [
15
22
  path: "core.dataviz.",
16
23
  cssPrefix: "--tt-core-dataviz-",
17
24
  dtcgType: "string"
18
- },
19
- // -- Semantic dataviz (longer/more-specific entries first) ----------------
20
- {
25
+ }, {
21
26
  path: "semantic.dataviz.color.",
22
27
  cssPrefix: "--tt-dataviz-",
23
28
  dtcgType: "color"
@@ -37,9 +42,7 @@ var TOKEN_PATH_REGISTRY = [
37
42
  path: "semantic.dataviz.",
38
43
  cssPrefix: "--tt-dataviz-",
39
44
  dtcgType: "string"
40
- },
41
- // -- Core paths -----------------------------------------------------------
42
- {
45
+ }, {
43
46
  path: "core.colors.",
44
47
  cssPrefix: "--tt-core-colors-",
45
48
  dtcgType: "color"
@@ -83,9 +86,7 @@ var TOKEN_PATH_REGISTRY = [
83
86
  path: "core.spacing.",
84
87
  cssPrefix: "--tt-core-spacing-",
85
88
  dtcgType: "dimension"
86
- },
87
- // CSS keywords (auto, fit-content, etc.) are not DTCG dimensions — more-specific entry first.
88
- {
89
+ }, {
89
90
  path: "core.sizing.behavior.",
90
91
  cssPrefix: "--tt-core-sizing-behavior-",
91
92
  dtcgType: "string"
@@ -125,9 +126,7 @@ var TOKEN_PATH_REGISTRY = [
125
126
  path: "core.breakpoints.",
126
127
  cssPrefix: "--tt-core-breakpoints-",
127
128
  dtcgType: "dimension"
128
- },
129
- // -- Semantic paths -------------------------------------------------------
130
- {
129
+ }, {
131
130
  path: "semantic.colors.",
132
131
  cssPrefix: "--tt-colors-",
133
132
  dtcgType: "color"
@@ -176,10 +175,14 @@ var TOKEN_PATH_REGISTRY = [
176
175
  cssPrefix: "--tt-z-index-",
177
176
  dtcgType: "number"
178
177
  }];
179
- var CSS_PATH_PREFIXES = TOKEN_PATH_REGISTRY.map(e => {
178
+ /** Derived lookup table: `[path, cssPrefix]` pairs. */
179
+ const CSS_PATH_PREFIXES = TOKEN_PATH_REGISTRY.map(e => {
180
180
  return [e.path, e.cssPrefix];
181
181
  });
182
- var DTCG_TYPE_PREFIXES = TOKEN_PATH_REGISTRY.map(e => {
182
+ /** Derived lookup table: `[path, dtcgType]` pairs. */
183
+ const DTCG_TYPE_PREFIXES = TOKEN_PATH_REGISTRY.map(e => {
183
184
  return [e.path, e.dtcgType];
184
185
  });
185
- export { CSS_PATH_PREFIXES, DTCG_TYPE_PREFIXES };
186
+
187
+ //#endregion
188
+ export { DTCG_TYPE_PREFIXES as n, CSS_PATH_PREFIXES as t };
@@ -0,0 +1,199 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ //#region src/roots/tokenRegistry.ts
3
+ /**
4
+ * Ordered registry of token path prefixes → CSS var prefix + DTCG type.
5
+ *
6
+ * Convention:
7
+ * - Core tokens: `--tt-core-<family>-<subpath>`
8
+ * - Semantic tokens: `--tt-<family>-<subpath>`
9
+ *
10
+ * Longer (more specific) prefixes come first so that consumers using
11
+ * first-match lookup get the correct result.
12
+ */
13
+ const TOKEN_PATH_REGISTRY = [{
14
+ path: "core.dataviz.color.",
15
+ cssPrefix: "--tt-core-dataviz-color-",
16
+ dtcgType: "color"
17
+ }, {
18
+ path: "core.dataviz.opacity.",
19
+ cssPrefix: "--tt-core-dataviz-opacity-",
20
+ dtcgType: "number"
21
+ }, {
22
+ path: "core.dataviz.",
23
+ cssPrefix: "--tt-core-dataviz-",
24
+ dtcgType: "string"
25
+ }, {
26
+ path: "semantic.dataviz.color.",
27
+ cssPrefix: "--tt-dataviz-",
28
+ dtcgType: "color"
29
+ }, {
30
+ path: "semantic.dataviz.encoding.opacity.",
31
+ cssPrefix: "--tt-dataviz-",
32
+ dtcgType: "number"
33
+ }, {
34
+ path: "semantic.dataviz.geo.",
35
+ cssPrefix: "--tt-dataviz-",
36
+ dtcgType: "color"
37
+ }, {
38
+ path: "semantic.dataviz.encoding.",
39
+ cssPrefix: "--tt-dataviz-",
40
+ dtcgType: "string"
41
+ }, {
42
+ path: "semantic.dataviz.",
43
+ cssPrefix: "--tt-dataviz-",
44
+ dtcgType: "string"
45
+ }, {
46
+ path: "core.colors.",
47
+ cssPrefix: "--tt-core-colors-",
48
+ dtcgType: "color"
49
+ }, {
50
+ path: "core.elevation.emphatic.",
51
+ cssPrefix: "--tt-core-elevation-emphatic-",
52
+ dtcgType: "shadow"
53
+ }, {
54
+ path: "core.elevation.level.",
55
+ cssPrefix: "--tt-core-elevation-",
56
+ dtcgType: "shadow"
57
+ }, {
58
+ path: "core.font.family.",
59
+ cssPrefix: "--tt-core-font-family-",
60
+ dtcgType: "fontFamily"
61
+ }, {
62
+ path: "core.font.weight.",
63
+ cssPrefix: "--tt-core-font-weight-",
64
+ dtcgType: "fontWeight"
65
+ }, {
66
+ path: "core.font.leading.",
67
+ cssPrefix: "--tt-core-font-leading-",
68
+ dtcgType: "number"
69
+ }, {
70
+ path: "core.font.tracking.",
71
+ cssPrefix: "--tt-core-font-tracking-",
72
+ dtcgType: "dimension"
73
+ }, {
74
+ path: "core.font.optical.",
75
+ cssPrefix: "--tt-core-font-optical-",
76
+ dtcgType: "string"
77
+ }, {
78
+ path: "core.font.numeric.",
79
+ cssPrefix: "--tt-core-font-numeric-",
80
+ dtcgType: "string"
81
+ }, {
82
+ path: "core.font.scale.",
83
+ cssPrefix: "--tt-core-font-scale-",
84
+ dtcgType: "dimension"
85
+ }, {
86
+ path: "core.spacing.",
87
+ cssPrefix: "--tt-core-spacing-",
88
+ dtcgType: "dimension"
89
+ }, {
90
+ path: "core.sizing.behavior.",
91
+ cssPrefix: "--tt-core-sizing-behavior-",
92
+ dtcgType: "string"
93
+ }, {
94
+ path: "core.sizing.",
95
+ cssPrefix: "--tt-core-sizing-",
96
+ dtcgType: "dimension"
97
+ }, {
98
+ path: "core.radii.",
99
+ cssPrefix: "--tt-core-radii-",
100
+ dtcgType: "dimension"
101
+ }, {
102
+ path: "core.border.width.",
103
+ cssPrefix: "--tt-core-border-width-",
104
+ dtcgType: "dimension"
105
+ }, {
106
+ path: "core.border.style.",
107
+ cssPrefix: "--tt-core-border-style-",
108
+ dtcgType: "string"
109
+ }, {
110
+ path: "core.opacity.",
111
+ cssPrefix: "--tt-core-opacity-",
112
+ dtcgType: "number"
113
+ }, {
114
+ path: "core.motion.duration.",
115
+ cssPrefix: "--tt-core-motion-duration-",
116
+ dtcgType: "duration"
117
+ }, {
118
+ path: "core.motion.easing.",
119
+ cssPrefix: "--tt-core-motion-easing-",
120
+ dtcgType: "string"
121
+ }, {
122
+ path: "core.zIndex.level.",
123
+ cssPrefix: "--tt-core-z-index-",
124
+ dtcgType: "number"
125
+ }, {
126
+ path: "core.breakpoints.",
127
+ cssPrefix: "--tt-core-breakpoints-",
128
+ dtcgType: "dimension"
129
+ }, {
130
+ path: "semantic.colors.",
131
+ cssPrefix: "--tt-colors-",
132
+ dtcgType: "color"
133
+ }, {
134
+ path: "semantic.elevation.",
135
+ cssPrefix: "--tt-elevation-",
136
+ dtcgType: "shadow"
137
+ }, {
138
+ path: "semantic.text.",
139
+ cssPrefix: "--tt-text-",
140
+ dtcgType: "string"
141
+ }, {
142
+ path: "semantic.spacing.",
143
+ cssPrefix: "--tt-spacing-",
144
+ dtcgType: "dimension"
145
+ }, {
146
+ path: "semantic.sizing.",
147
+ cssPrefix: "--tt-sizing-",
148
+ dtcgType: "dimension"
149
+ }, {
150
+ path: "semantic.radii.",
151
+ cssPrefix: "--tt-radii-",
152
+ dtcgType: "dimension"
153
+ }, {
154
+ path: "semantic.focus.",
155
+ cssPrefix: "--tt-focus-",
156
+ dtcgType: "string"
157
+ }, {
158
+ path: "semantic.overlay.",
159
+ cssPrefix: "--tt-overlay-",
160
+ dtcgType: "color"
161
+ }, {
162
+ path: "semantic.border.",
163
+ cssPrefix: "--tt-border-",
164
+ dtcgType: "string"
165
+ }, {
166
+ path: "semantic.opacity.",
167
+ cssPrefix: "--tt-opacity-",
168
+ dtcgType: "number"
169
+ }, {
170
+ path: "semantic.motion.",
171
+ cssPrefix: "--tt-motion-",
172
+ dtcgType: "string"
173
+ }, {
174
+ path: "semantic.zIndex.layer.",
175
+ cssPrefix: "--tt-z-index-",
176
+ dtcgType: "number"
177
+ }];
178
+ /** Derived lookup table: `[path, cssPrefix]` pairs. */
179
+ const CSS_PATH_PREFIXES = TOKEN_PATH_REGISTRY.map(e => {
180
+ return [e.path, e.cssPrefix];
181
+ });
182
+ /** Derived lookup table: `[path, dtcgType]` pairs. */
183
+ const DTCG_TYPE_PREFIXES = TOKEN_PATH_REGISTRY.map(e => {
184
+ return [e.path, e.dtcgType];
185
+ });
186
+
187
+ //#endregion
188
+ Object.defineProperty(exports, 'CSS_PATH_PREFIXES', {
189
+ enumerable: true,
190
+ get: function () {
191
+ return CSS_PATH_PREFIXES;
192
+ }
193
+ });
194
+ Object.defineProperty(exports, 'DTCG_TYPE_PREFIXES', {
195
+ enumerable: true,
196
+ get: function () {
197
+ return DTCG_TYPE_PREFIXES;
198
+ }
199
+ });
package/dist/vars.cjs ADDED
@@ -0,0 +1,127 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ Object.defineProperty(exports, Symbol.toStringTag, {
3
+ value: 'Module'
4
+ });
5
+ const require_helpers = require('./helpers-4p4-QVt_.cjs');
6
+ const require_baseBundle = require('./baseBundle-iEFf5nqT.cjs');
7
+ const require_toCssVars = require('./toCssVars-DudHKvt2.cjs');
8
+
9
+ //#region src/roots/toVars.ts
10
+ /**
11
+ * Build a deeply-nested CSS var-reference map from a theme's semantic layer.
12
+ *
13
+ * Walks `theme.semantic` recursively and replaces every leaf value with the
14
+ * corresponding `var(--tt-*)` CSS custom property reference. The resulting
15
+ * object has the exact same shape as `theme.semantic` but with `string` leaves.
16
+ *
17
+ * Keys starting with `$` are skipped (deprecation metadata).
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { buildVarsMap } from './roots/toVars';
22
+ * import { baseTheme } from './baseTheme';
23
+ *
24
+ * const vars = buildVarsMap(baseTheme);
25
+ * vars.colors.action.primary.background.default
26
+ * // → 'var(--tt-action-primary-background-default)'
27
+ * ```
28
+ */
29
+ const buildVarsMap = theme => {
30
+ const walk = (obj, prefix) => {
31
+ const result = {};
32
+ for (const [key, value] of Object.entries(obj)) {
33
+ if (key.startsWith("$")) continue;
34
+ const fullPath = `${prefix}.${key}`;
35
+ if (require_helpers.isPlainObject(value)) result[key] = walk(value, fullPath);else if (typeof value === "string" || typeof value === "number") result[key] = `var(${require_toCssVars.toCssVarName(fullPath)})`;
36
+ }
37
+ return result;
38
+ };
39
+ return walk(theme.semantic, "semantic");
40
+ };
41
+
42
+ //#endregion
43
+ //#region src/vars.ts
44
+ /**
45
+ * Static map of all semantic tokens as typed CSS `var(--tt-*)` references.
46
+ *
47
+ * Every leaf value is a CSS Custom Property reference string — zero runtime
48
+ * overhead, full autocomplete, structural parity with `SemanticTokens`.
49
+ *
50
+ * The var names are stable across themes and modes: only the values behind
51
+ * the CSS vars change when the theme or mode switches. Components reference
52
+ * the vars; CSS (generated by `toCssVars`) carries the values.
53
+ *
54
+ * ## Usage with Ark UI / CSS-in-JS
55
+ *
56
+ * ```tsx
57
+ * import { vars } from '@ttoss/fsl-theme/vars';
58
+ *
59
+ * <Button style={{ background: vars.colors.action.primary.background.default }} />
60
+ * // → background: 'var(--tt-action-primary-background-default)'
61
+ * ```
62
+ *
63
+ * ## Usage in CSS / CSS Modules
64
+ *
65
+ * ```css
66
+ * .button {
67
+ * background: var(--tt-action-primary-background-default);
68
+ * color: var(--tt-action-primary-text-default);
69
+ * }
70
+ * ```
71
+ *
72
+ * (For plain CSS you can use the var names directly — `vars` is most valuable
73
+ * when you need TypeScript autocomplete in inline styles or CSS-in-JS.)
74
+ *
75
+ * ## Usage in Tailwind plugins / PostCSS
76
+ *
77
+ * ```ts
78
+ * import { toCssVarName } from '@ttoss/fsl-theme/css';
79
+ * // toCssVarName gives you the raw CSS property name without `var()`.
80
+ * ```
81
+ *
82
+ * ## Limitations
83
+ *
84
+ * `vars` reflects the semantic token shape of the **default theme**. If your
85
+ * project extends `SemanticTokens` with custom token families (e.g. a
86
+ * `dataviz` palette, project-specific component tokens), those extra leaves
87
+ * won't appear on this export.
88
+ *
89
+ * ### Typed extension recipe
90
+ *
91
+ * Build your own typed vars object using the public `buildVarsMap` helper
92
+ * together with `CssVarsMap`:
93
+ *
94
+ * ```ts
95
+ * // my-theme.ts
96
+ * import { createTheme, type SemanticTokens } from '@ttoss/fsl-theme';
97
+ * import { buildVarsMap, type CssVarsMap } from '@ttoss/fsl-theme/vars';
98
+ *
99
+ * // 1. Extend the semantic shape structurally.
100
+ * type MySemanticTokens = SemanticTokens & {
101
+ * colors: SemanticTokens['colors'] & {
102
+ * brandX: { primary: { default: string } };
103
+ * };
104
+ * };
105
+ *
106
+ * const myTheme = createTheme({ ... });
107
+ *
108
+ * // 2. Build a typed mirror of the extended shape.
109
+ * export const myVars: CssVarsMap<MySemanticTokens> =
110
+ * buildVarsMap(myTheme.base) as CssVarsMap<MySemanticTokens>;
111
+ *
112
+ * myVars.colors.brandX.primary.default;
113
+ * // → 'var(--tt-colors-brandx-primary-default)'
114
+ * ```
115
+ *
116
+ * For one-off custom keys where the extra structure is trivial, use
117
+ * `toCssVarName` from `'@ttoss/fsl-theme/css'` to construct individual var
118
+ * references without declaring a full extended type.
119
+ *
120
+ * @see {@link toCssVarName} — for raw CSS property names (without `var()`)
121
+ * @see {@link useResolvedTokens} — for resolved raw values in non-CSS environments (React Native, canvas, PDF)
122
+ */
123
+ const vars = buildVarsMap(require_baseBundle.baseBundle.base);
124
+
125
+ //#endregion
126
+ exports.buildVarsMap = buildVarsMap;
127
+ exports.vars = vars;
@@ -1,5 +1,7 @@
1
- import { T as ThemeTokens, S as SemanticTokens } from './Types-6tR0_2Ss.js';
2
1
 
2
+ import { i as ThemeTokens, n as SemanticTokens } from "./Types-BiBa17RL.cjs";
3
+
4
+ //#region src/roots/toVars.d.ts
3
5
  /**
4
6
  * Transforms a token-tree type into an identical structure where every leaf
5
7
  * value becomes `string` (a CSS `var(--tt-*)` reference).
@@ -19,9 +21,7 @@ import { T as ThemeTokens, S as SemanticTokens } from './Types-6tR0_2Ss.js';
19
21
  * // → { action: { primary: { background: { default: string } } } }
20
22
  * ```
21
23
  */
22
- type CssVarsMap<T> = {
23
- [K in keyof T as K extends `$${string}` ? never : K]: NonNullable<T[K]> extends string | number ? string : undefined extends T[K] ? CssVarsMap<NonNullable<T[K]>> | undefined : CssVarsMap<NonNullable<T[K]>>;
24
- };
24
+ type CssVarsMap<T> = { [K in keyof T as K extends `$${string}` ? never : K]: NonNullable<T[K]> extends string | number ? string : undefined extends T[K] ? CssVarsMap<NonNullable<T[K]>> | undefined : CssVarsMap<NonNullable<T[K]>> };
25
25
  /**
26
26
  * Build a deeply-nested CSS var-reference map from a theme's semantic layer.
27
27
  *
@@ -42,7 +42,8 @@ type CssVarsMap<T> = {
42
42
  * ```
43
43
  */
44
44
  declare const buildVarsMap: (theme: ThemeTokens) => CssVarsMap<ThemeTokens["semantic"]>;
45
-
45
+ //#endregion
46
+ //#region src/vars.d.ts
46
47
  /**
47
48
  * Static map of all semantic tokens as typed CSS `var(--tt-*)` references.
48
49
  *
@@ -123,5 +124,5 @@ declare const buildVarsMap: (theme: ThemeTokens) => CssVarsMap<ThemeTokens["sema
123
124
  * @see {@link useResolvedTokens} — for resolved raw values in non-CSS environments (React Native, canvas, PDF)
124
125
  */
125
126
  declare const vars: CssVarsMap<SemanticTokens>;
126
-
127
- export { type CssVarsMap, buildVarsMap, vars };
127
+ //#endregion
128
+ export { type CssVarsMap, buildVarsMap, vars };
@@ -0,0 +1,128 @@
1
+
2
+ import { i as ThemeTokens, n as SemanticTokens } from "./Types-BiBa17RL.mjs";
3
+
4
+ //#region src/roots/toVars.d.ts
5
+ /**
6
+ * Transforms a token-tree type into an identical structure where every leaf
7
+ * value becomes `string` (a CSS `var(--tt-*)` reference).
8
+ *
9
+ * Keys starting with `$` (e.g. `$deprecated`) are excluded — they are
10
+ * metadata, not consumable tokens.
11
+ *
12
+ * Optional keys in the source type remain optional in the mapped type, so
13
+ * theme extensions such as `dataviz?` are typed as `CssVarsMap<...> | undefined`
14
+ * and TypeScript will require callers to guard against `undefined` before
15
+ * accessing their members.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * type Colors = { action: { primary: { background: { default: TokenRef } } } };
20
+ * type ColorVars = CssVarsMap<Colors>;
21
+ * // → { action: { primary: { background: { default: string } } } }
22
+ * ```
23
+ */
24
+ type CssVarsMap<T> = { [K in keyof T as K extends `$${string}` ? never : K]: NonNullable<T[K]> extends string | number ? string : undefined extends T[K] ? CssVarsMap<NonNullable<T[K]>> | undefined : CssVarsMap<NonNullable<T[K]>> };
25
+ /**
26
+ * Build a deeply-nested CSS var-reference map from a theme's semantic layer.
27
+ *
28
+ * Walks `theme.semantic` recursively and replaces every leaf value with the
29
+ * corresponding `var(--tt-*)` CSS custom property reference. The resulting
30
+ * object has the exact same shape as `theme.semantic` but with `string` leaves.
31
+ *
32
+ * Keys starting with `$` are skipped (deprecation metadata).
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * import { buildVarsMap } from './roots/toVars';
37
+ * import { baseTheme } from './baseTheme';
38
+ *
39
+ * const vars = buildVarsMap(baseTheme);
40
+ * vars.colors.action.primary.background.default
41
+ * // → 'var(--tt-action-primary-background-default)'
42
+ * ```
43
+ */
44
+ declare const buildVarsMap: (theme: ThemeTokens) => CssVarsMap<ThemeTokens["semantic"]>;
45
+ //#endregion
46
+ //#region src/vars.d.ts
47
+ /**
48
+ * Static map of all semantic tokens as typed CSS `var(--tt-*)` references.
49
+ *
50
+ * Every leaf value is a CSS Custom Property reference string — zero runtime
51
+ * overhead, full autocomplete, structural parity with `SemanticTokens`.
52
+ *
53
+ * The var names are stable across themes and modes: only the values behind
54
+ * the CSS vars change when the theme or mode switches. Components reference
55
+ * the vars; CSS (generated by `toCssVars`) carries the values.
56
+ *
57
+ * ## Usage with Ark UI / CSS-in-JS
58
+ *
59
+ * ```tsx
60
+ * import { vars } from '@ttoss/fsl-theme/vars';
61
+ *
62
+ * <Button style={{ background: vars.colors.action.primary.background.default }} />
63
+ * // → background: 'var(--tt-action-primary-background-default)'
64
+ * ```
65
+ *
66
+ * ## Usage in CSS / CSS Modules
67
+ *
68
+ * ```css
69
+ * .button {
70
+ * background: var(--tt-action-primary-background-default);
71
+ * color: var(--tt-action-primary-text-default);
72
+ * }
73
+ * ```
74
+ *
75
+ * (For plain CSS you can use the var names directly — `vars` is most valuable
76
+ * when you need TypeScript autocomplete in inline styles or CSS-in-JS.)
77
+ *
78
+ * ## Usage in Tailwind plugins / PostCSS
79
+ *
80
+ * ```ts
81
+ * import { toCssVarName } from '@ttoss/fsl-theme/css';
82
+ * // toCssVarName gives you the raw CSS property name without `var()`.
83
+ * ```
84
+ *
85
+ * ## Limitations
86
+ *
87
+ * `vars` reflects the semantic token shape of the **default theme**. If your
88
+ * project extends `SemanticTokens` with custom token families (e.g. a
89
+ * `dataviz` palette, project-specific component tokens), those extra leaves
90
+ * won't appear on this export.
91
+ *
92
+ * ### Typed extension recipe
93
+ *
94
+ * Build your own typed vars object using the public `buildVarsMap` helper
95
+ * together with `CssVarsMap`:
96
+ *
97
+ * ```ts
98
+ * // my-theme.ts
99
+ * import { createTheme, type SemanticTokens } from '@ttoss/fsl-theme';
100
+ * import { buildVarsMap, type CssVarsMap } from '@ttoss/fsl-theme/vars';
101
+ *
102
+ * // 1. Extend the semantic shape structurally.
103
+ * type MySemanticTokens = SemanticTokens & {
104
+ * colors: SemanticTokens['colors'] & {
105
+ * brandX: { primary: { default: string } };
106
+ * };
107
+ * };
108
+ *
109
+ * const myTheme = createTheme({ ... });
110
+ *
111
+ * // 2. Build a typed mirror of the extended shape.
112
+ * export const myVars: CssVarsMap<MySemanticTokens> =
113
+ * buildVarsMap(myTheme.base) as CssVarsMap<MySemanticTokens>;
114
+ *
115
+ * myVars.colors.brandX.primary.default;
116
+ * // → 'var(--tt-colors-brandx-primary-default)'
117
+ * ```
118
+ *
119
+ * For one-off custom keys where the extra structure is trivial, use
120
+ * `toCssVarName` from `'@ttoss/fsl-theme/css'` to construct individual var
121
+ * references without declaring a full extended type.
122
+ *
123
+ * @see {@link toCssVarName} — for raw CSS property names (without `var()`)
124
+ * @see {@link useResolvedTokens} — for resolved raw values in non-CSS environments (React Native, canvas, PDF)
125
+ */
126
+ declare const vars: CssVarsMap<SemanticTokens>;
127
+ //#endregion
128
+ export { type CssVarsMap, buildVarsMap, vars };
package/dist/vars.mjs ADDED
@@ -0,0 +1,123 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ import { o as isPlainObject } from "./helpers-CaswNJMy.mjs";
3
+ import { t as baseBundle } from "./baseBundle-DxvXyhGa.mjs";
4
+ import { t as toCssVarName } from "./toCssVars-CYZCe-on.mjs";
5
+
6
+ //#region src/roots/toVars.ts
7
+ /**
8
+ * Build a deeply-nested CSS var-reference map from a theme's semantic layer.
9
+ *
10
+ * Walks `theme.semantic` recursively and replaces every leaf value with the
11
+ * corresponding `var(--tt-*)` CSS custom property reference. The resulting
12
+ * object has the exact same shape as `theme.semantic` but with `string` leaves.
13
+ *
14
+ * Keys starting with `$` are skipped (deprecation metadata).
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { buildVarsMap } from './roots/toVars';
19
+ * import { baseTheme } from './baseTheme';
20
+ *
21
+ * const vars = buildVarsMap(baseTheme);
22
+ * vars.colors.action.primary.background.default
23
+ * // → 'var(--tt-action-primary-background-default)'
24
+ * ```
25
+ */
26
+ const buildVarsMap = theme => {
27
+ const walk = (obj, prefix) => {
28
+ const result = {};
29
+ for (const [key, value] of Object.entries(obj)) {
30
+ if (key.startsWith("$")) continue;
31
+ const fullPath = `${prefix}.${key}`;
32
+ if (isPlainObject(value)) result[key] = walk(value, fullPath);else if (typeof value === "string" || typeof value === "number") result[key] = `var(${toCssVarName(fullPath)})`;
33
+ }
34
+ return result;
35
+ };
36
+ return walk(theme.semantic, "semantic");
37
+ };
38
+
39
+ //#endregion
40
+ //#region src/vars.ts
41
+ /**
42
+ * Static map of all semantic tokens as typed CSS `var(--tt-*)` references.
43
+ *
44
+ * Every leaf value is a CSS Custom Property reference string — zero runtime
45
+ * overhead, full autocomplete, structural parity with `SemanticTokens`.
46
+ *
47
+ * The var names are stable across themes and modes: only the values behind
48
+ * the CSS vars change when the theme or mode switches. Components reference
49
+ * the vars; CSS (generated by `toCssVars`) carries the values.
50
+ *
51
+ * ## Usage with Ark UI / CSS-in-JS
52
+ *
53
+ * ```tsx
54
+ * import { vars } from '@ttoss/fsl-theme/vars';
55
+ *
56
+ * <Button style={{ background: vars.colors.action.primary.background.default }} />
57
+ * // → background: 'var(--tt-action-primary-background-default)'
58
+ * ```
59
+ *
60
+ * ## Usage in CSS / CSS Modules
61
+ *
62
+ * ```css
63
+ * .button {
64
+ * background: var(--tt-action-primary-background-default);
65
+ * color: var(--tt-action-primary-text-default);
66
+ * }
67
+ * ```
68
+ *
69
+ * (For plain CSS you can use the var names directly — `vars` is most valuable
70
+ * when you need TypeScript autocomplete in inline styles or CSS-in-JS.)
71
+ *
72
+ * ## Usage in Tailwind plugins / PostCSS
73
+ *
74
+ * ```ts
75
+ * import { toCssVarName } from '@ttoss/fsl-theme/css';
76
+ * // toCssVarName gives you the raw CSS property name without `var()`.
77
+ * ```
78
+ *
79
+ * ## Limitations
80
+ *
81
+ * `vars` reflects the semantic token shape of the **default theme**. If your
82
+ * project extends `SemanticTokens` with custom token families (e.g. a
83
+ * `dataviz` palette, project-specific component tokens), those extra leaves
84
+ * won't appear on this export.
85
+ *
86
+ * ### Typed extension recipe
87
+ *
88
+ * Build your own typed vars object using the public `buildVarsMap` helper
89
+ * together with `CssVarsMap`:
90
+ *
91
+ * ```ts
92
+ * // my-theme.ts
93
+ * import { createTheme, type SemanticTokens } from '@ttoss/fsl-theme';
94
+ * import { buildVarsMap, type CssVarsMap } from '@ttoss/fsl-theme/vars';
95
+ *
96
+ * // 1. Extend the semantic shape structurally.
97
+ * type MySemanticTokens = SemanticTokens & {
98
+ * colors: SemanticTokens['colors'] & {
99
+ * brandX: { primary: { default: string } };
100
+ * };
101
+ * };
102
+ *
103
+ * const myTheme = createTheme({ ... });
104
+ *
105
+ * // 2. Build a typed mirror of the extended shape.
106
+ * export const myVars: CssVarsMap<MySemanticTokens> =
107
+ * buildVarsMap(myTheme.base) as CssVarsMap<MySemanticTokens>;
108
+ *
109
+ * myVars.colors.brandX.primary.default;
110
+ * // → 'var(--tt-colors-brandx-primary-default)'
111
+ * ```
112
+ *
113
+ * For one-off custom keys where the extra structure is trivial, use
114
+ * `toCssVarName` from `'@ttoss/fsl-theme/css'` to construct individual var
115
+ * references without declaring a full extended type.
116
+ *
117
+ * @see {@link toCssVarName} — for raw CSS property names (without `var()`)
118
+ * @see {@link useResolvedTokens} — for resolved raw values in non-CSS environments (React Native, canvas, PDF)
119
+ */
120
+ const vars = buildVarsMap(baseBundle.base);
121
+
122
+ //#endregion
123
+ export { buildVarsMap, vars };