@breadstone-infrastructure/style-dictionary 0.0.205 → 0.0.209

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 (79) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/formats/index.d.ts +3 -0
  3. package/formats/index.d.ts.map +1 -0
  4. package/formats/{tailwind/index.js → index.js} +2 -2
  5. package/formats/index.js.map +1 -0
  6. package/formats/tailwind/v3/DesignTokenType.d.ts.map +1 -0
  7. package/formats/tailwind/v3/DesignTokenType.js.map +1 -0
  8. package/formats/tailwind/{TailwindPropertyMapping.d.ts → v3/TailwindV3PropertyMapping.d.ts} +15 -15
  9. package/formats/tailwind/v3/TailwindV3PropertyMapping.d.ts.map +1 -0
  10. package/formats/tailwind/{TailwindPropertyMapping.js → v3/TailwindV3PropertyMapping.js} +6 -6
  11. package/formats/tailwind/v3/TailwindV3PropertyMapping.js.map +1 -0
  12. package/formats/tailwind/{buildTailwindConfig.d.ts → v3/buildTailwindV3Config.d.ts} +5 -4
  13. package/formats/tailwind/v3/buildTailwindV3Config.d.ts.map +1 -0
  14. package/formats/tailwind/{buildTailwindConfig.js → v3/buildTailwindV3Config.js} +19 -17
  15. package/formats/tailwind/v3/buildTailwindV3Config.js.map +1 -0
  16. package/formats/tailwind/v3/index.d.ts +5 -0
  17. package/formats/tailwind/v3/index.d.ts.map +1 -0
  18. package/formats/tailwind/v3/index.js +21 -0
  19. package/formats/tailwind/v3/index.js.map +1 -0
  20. package/formats/tailwind/v3/tailwindV3Format.d.ts +32 -0
  21. package/formats/tailwind/v3/tailwindV3Format.d.ts.map +1 -0
  22. package/formats/tailwind/v3/tailwindV3Format.js +123 -0
  23. package/formats/tailwind/v3/tailwindV3Format.js.map +1 -0
  24. package/formats/tailwind/v4/DesignTokenType.d.ts +10 -0
  25. package/formats/tailwind/v4/DesignTokenType.d.ts.map +1 -0
  26. package/formats/tailwind/v4/DesignTokenType.js +3 -0
  27. package/formats/tailwind/v4/DesignTokenType.js.map +1 -0
  28. package/formats/tailwind/v4/TailwindV4PropertyMapping.d.ts +45 -0
  29. package/formats/tailwind/v4/TailwindV4PropertyMapping.d.ts.map +1 -0
  30. package/formats/tailwind/v4/TailwindV4PropertyMapping.js +322 -0
  31. package/formats/tailwind/v4/TailwindV4PropertyMapping.js.map +1 -0
  32. package/formats/tailwind/v4/buildTailwindV4Config.d.ts +83 -0
  33. package/formats/tailwind/v4/buildTailwindV4Config.d.ts.map +1 -0
  34. package/formats/tailwind/v4/buildTailwindV4Config.js +338 -0
  35. package/formats/tailwind/v4/buildTailwindV4Config.js.map +1 -0
  36. package/formats/tailwind/v4/buildTailwindV4Theme.d.ts +71 -0
  37. package/formats/tailwind/v4/buildTailwindV4Theme.d.ts.map +1 -0
  38. package/formats/tailwind/v4/buildTailwindV4Theme.js +247 -0
  39. package/formats/tailwind/v4/buildTailwindV4Theme.js.map +1 -0
  40. package/formats/tailwind/v4/index.d.ts +4 -0
  41. package/formats/tailwind/v4/index.d.ts.map +1 -0
  42. package/formats/tailwind/v4/index.js +20 -0
  43. package/formats/tailwind/v4/index.js.map +1 -0
  44. package/formats/tailwind/v4/tailwindV4Format.d.ts +119 -0
  45. package/formats/tailwind/v4/tailwindV4Format.d.ts.map +1 -0
  46. package/formats/tailwind/v4/tailwindV4Format.js +169 -0
  47. package/formats/tailwind/v4/tailwindV4Format.js.map +1 -0
  48. package/index.d.ts +3 -9
  49. package/index.d.ts.map +1 -1
  50. package/index.js +3 -17
  51. package/index.js.map +1 -1
  52. package/package.json +3 -3
  53. package/preprocessors/index.d.ts +3 -0
  54. package/preprocessors/index.d.ts.map +1 -0
  55. package/preprocessors/index.js +19 -0
  56. package/preprocessors/index.js.map +1 -0
  57. package/transforms/index.d.ts +7 -0
  58. package/transforms/index.d.ts.map +1 -0
  59. package/transforms/index.js +23 -0
  60. package/transforms/index.js.map +1 -0
  61. package/formats/tailwind/DesignTokenType.d.ts.map +0 -1
  62. package/formats/tailwind/DesignTokenType.js.map +0 -1
  63. package/formats/tailwind/TailwindPropertyMapping.d.ts.map +0 -1
  64. package/formats/tailwind/TailwindPropertyMapping.js.map +0 -1
  65. package/formats/tailwind/buildTailwindConfig.d.ts.map +0 -1
  66. package/formats/tailwind/buildTailwindConfig.js.map +0 -1
  67. package/formats/tailwind/index.d.ts +0 -3
  68. package/formats/tailwind/index.d.ts.map +0 -1
  69. package/formats/tailwind/index.js.map +0 -1
  70. package/formats/tailwind/tailwindFormat.d.ts +0 -13
  71. package/formats/tailwind/tailwindFormat.d.ts.map +0 -1
  72. package/formats/tailwind/tailwindFormat.js +0 -57
  73. package/formats/tailwind/tailwindFormat.js.map +0 -1
  74. package/formats/tailwind/tailwindFormat2.d.ts +0 -13
  75. package/formats/tailwind/tailwindFormat2.d.ts.map +0 -1
  76. package/formats/tailwind/tailwindFormat2.js +0 -65
  77. package/formats/tailwind/tailwindFormat2.js.map +0 -1
  78. /package/formats/tailwind/{DesignTokenType.d.ts → v3/DesignTokenType.d.ts} +0 -0
  79. /package/formats/tailwind/{DesignTokenType.js → v3/DesignTokenType.js} +0 -0
@@ -0,0 +1,338 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.buildTailwindV4Config = buildTailwindV4Config;
5
+ exports.formatTailwindV4ConfigAsJs = formatTailwindV4ConfigAsJs;
6
+ exports.formatTailwindV4ConfigAsTs = formatTailwindV4ConfigAsTs;
7
+ exports.buildTailwindV4ConfigJs = buildTailwindV4ConfigJs;
8
+ exports.buildTailwindV4ConfigTs = buildTailwindV4ConfigTs;
9
+ const utilities_1 = require("@breadstone-infrastructure/utilities");
10
+ const getType_js_1 = require("../../../utilities/getType.js");
11
+ const getValue_js_1 = require("../../../utilities/getValue.js");
12
+ const TailwindV4PropertyMapping_js_1 = require("./TailwindV4PropertyMapping.js");
13
+ // #endregion
14
+ // #region Fields
15
+ /**
16
+ * Auto-generated file header comment for JS files.
17
+ *
18
+ * @private
19
+ */
20
+ const JS_FILE_HEADER = `/* ------------------------------------------------------------------------------
21
+ * <auto-generated>
22
+ * This code was generated by a tool.
23
+ * Changes to this file may cause incorrect behavior and will be lost if
24
+ * the code is regenerated.
25
+ * </auto-generated>
26
+ * ------------------------------------------------------------------------------ */`;
27
+ /**
28
+ * Auto-generated file header comment for TS files.
29
+ *
30
+ * @private
31
+ */
32
+ const TS_FILE_HEADER = `/* ------------------------------------------------------------------------------
33
+ * <auto-generated>
34
+ * This code was generated by a tool.
35
+ * Changes to this file may cause incorrect behavior and will be lost if
36
+ * the code is regenerated.
37
+ * </auto-generated>
38
+ * ------------------------------------------------------------------------------ */`;
39
+ // #endregion
40
+ // #region Methods
41
+ /**
42
+ * Normalizes a raw token value into a JS value suitable for a Tailwind config.
43
+ *
44
+ * @param value Raw token value.
45
+ * @returns Normalized value (string, number, or array) that can be used in Tailwind config.
46
+ * @private
47
+ */
48
+ function normalizeValue(value) {
49
+ if (Array.isArray(value)) {
50
+ return value.map((v) => String(v));
51
+ }
52
+ if (typeof value === 'string' || typeof value === 'number') {
53
+ return value;
54
+ }
55
+ return String(value);
56
+ }
57
+ /**
58
+ * Deeply sets a value on an object via a path array. Similar to lodash.set.
59
+ *
60
+ * @param obj Target object.
61
+ * @param path Array of keys.
62
+ * @param value Value to set.
63
+ * @private
64
+ */
65
+ function deepSet(obj, path, value) {
66
+ let current = obj;
67
+ for (let i = 0; i < path.length; i++) {
68
+ const key = path[i];
69
+ if (i === path.length - 1) {
70
+ current[key] = value;
71
+ }
72
+ else {
73
+ if (!current[key] || typeof current[key] !== 'object') {
74
+ current[key] = {};
75
+ }
76
+ current = current[key];
77
+ }
78
+ }
79
+ }
80
+ /**
81
+ * Validates that tokens use supported logical types and logs warnings
82
+ * for those that cannot be mapped to Tailwind v4.
83
+ *
84
+ * @param tokens All transformed tokens.
85
+ * @param ignoredNames Optional substrings; tokens whose name contains any of them are ignored.
86
+ * @private
87
+ */
88
+ function validateTokenTypes(tokens, ignoredNames = []) {
89
+ const supported = new Set(TailwindV4PropertyMapping_js_1.SUPPORTED_TOKEN_TYPES);
90
+ tokens
91
+ .filter((token) => {
92
+ const lower = token.name.toLowerCase();
93
+ return !ignoredNames.some((substr) => lower.includes(substr.toLowerCase()));
94
+ })
95
+ .forEach((token) => {
96
+ // If token has a valid category mapping, skip type validation
97
+ const rawCategory = token.category;
98
+ if (rawCategory && rawCategory in TailwindV4PropertyMapping_js_1.CATEGORY_TO_V4_MAPPING) {
99
+ return;
100
+ }
101
+ const type = (0, getType_js_1.getType)(token);
102
+ if (!type) {
103
+ return;
104
+ }
105
+ if (!supported.has(type)) {
106
+ console.warn(`${(0, utilities_1.symbol)('warning')} ${(0, utilities_1.yellow)(`Type "${type}" is not supported in Tailwind v4 config builder for token "${token.path.join('.')}:${token.name}".`)}`);
107
+ }
108
+ });
109
+ }
110
+ /**
111
+ * Resolves the mapping for a token in Tailwind v4 format.
112
+ *
113
+ * @param token The token to resolve mapping for.
114
+ * @returns An IV4KeyMapping when resolvable, otherwise undefined.
115
+ * @private
116
+ */
117
+ function resolveMappingForToken(token) {
118
+ const rawCategory = token.category;
119
+ // 1. Category-based mapping (if present)
120
+ if (rawCategory) {
121
+ if (rawCategory in TailwindV4PropertyMapping_js_1.CATEGORY_TO_V4_MAPPING) {
122
+ return TailwindV4PropertyMapping_js_1.CATEGORY_TO_V4_MAPPING[rawCategory];
123
+ }
124
+ console.warn(`${(0, utilities_1.symbol)('warning')} ${(0, utilities_1.yellow)(`Token "${token.name}" specifies category "${rawCategory}", which is not mapped. Falling back to token type.`)}`);
125
+ }
126
+ // 2. Type-based mapping
127
+ const type = (token.type ?? token.$type ?? token.original.type ?? token.original.$type);
128
+ if (type) {
129
+ const byType = TailwindV4PropertyMapping_js_1.TOKEN_TYPE_TO_V4_MAPPING[type];
130
+ if (byType) {
131
+ return byType;
132
+ }
133
+ }
134
+ return undefined;
135
+ }
136
+ /**
137
+ * Maps v4 CSS variable namespace to Tailwind v4 theme key.
138
+ * In v4, the theme keys are more directly mapped to CSS variable namespaces.
139
+ *
140
+ * @param namespace The CSS variable namespace.
141
+ * @returns The corresponding theme key for v4 config.
142
+ * @private
143
+ */
144
+ function namespaceToThemeKey(namespace) {
145
+ // Remove leading '--' and convert to camelCase-ish theme key
146
+ // --color -> colors
147
+ // --font-family -> fontFamily
148
+ // --font-size -> fontSize
149
+ // --spacing -> spacing
150
+ // --radius -> borderRadius
151
+ // --shadow -> boxShadow
152
+ const mapping = {
153
+ '--color': 'colors',
154
+ '--font-family': 'fontFamily',
155
+ '--font-size': 'fontSize',
156
+ '--font-weight': 'fontWeight',
157
+ '--letter-spacing': 'letterSpacing',
158
+ '--line-height': 'lineHeight',
159
+ '--radius': 'borderRadius',
160
+ '--shadow': 'boxShadow',
161
+ '--spacing': 'spacing',
162
+ '--width': 'width',
163
+ '--height': 'height',
164
+ '--z': 'zIndex',
165
+ '--opacity': 'opacity',
166
+ '--transition-duration': 'transitionDuration',
167
+ '--border-width': 'borderWidth'
168
+ };
169
+ return mapping[namespace] ?? namespace.slice(2);
170
+ }
171
+ /**
172
+ * Builds a Tailwind v4 config object from Style-Dictionary tokens.
173
+ *
174
+ * In Tailwind v4, the configuration structure is flatter and works
175
+ * in conjunction with the CSS-first approach. This generates a config
176
+ * that can be used with the @config directive.
177
+ *
178
+ * @param allTokens All transformed tokens from Style-Dictionary.
179
+ * @param options Build options.
180
+ * @returns A Tailwind v4 config object.
181
+ * @public
182
+ */
183
+ function buildTailwindV4Config(allTokens, options = {}) {
184
+ const { ignoredTokenNameSubstrings = [], useExtend = false } = options;
185
+ validateTokenTypes(allTokens, ignoredTokenNameSubstrings);
186
+ const theme = {};
187
+ for (const token of allTokens) {
188
+ const lowerName = token.name.toLowerCase();
189
+ const tokenPath = token.path.join('.');
190
+ // Check if any ignored substring appears in the token name OR path
191
+ const isIgnored = ignoredTokenNameSubstrings.some((substr) => lowerName.includes(substr.toLowerCase()) || tokenPath.toLowerCase().includes(substr.toLowerCase()));
192
+ if (isIgnored) {
193
+ continue;
194
+ }
195
+ // Skip expanded shadow parts
196
+ const shadowPartPattern = /\.(offsetX|offsetY|blur|spread|color)\.\d+$/i;
197
+ if (shadowPartPattern.test(tokenPath)) {
198
+ continue;
199
+ }
200
+ // Skip duration tokens without values
201
+ if (token.path[0] === 'duration' && !token.value) {
202
+ continue;
203
+ }
204
+ const mapping = resolveMappingForToken(token);
205
+ if (!mapping) {
206
+ console.warn(`${(0, utilities_1.symbol)('warning')} ${(0, utilities_1.yellow)(`Token "${token.path.join('.')}:${token.name}" cannot be mapped to Tailwind v4 config (no valid category or type mapping). Skipping.`)}`);
207
+ continue;
208
+ }
209
+ const rawValue = (0, getValue_js_1.getValue)(token);
210
+ const normalizedValue = normalizeValue(rawValue);
211
+ const rawPath = token.path.length > 0 ? token.path : [token.name];
212
+ // Get the theme key from namespace
213
+ const themeKey = namespaceToThemeKey(mapping.namespace);
214
+ // Apply pathTransform if defined
215
+ const transformedName = mapping.pathTransform
216
+ ? mapping.pathTransform(rawPath)
217
+ : rawPath.join('-').toLowerCase();
218
+ // Initialize theme section if needed
219
+ if (!theme[themeKey]) {
220
+ theme[themeKey] = {};
221
+ }
222
+ // Handle nested paths for colors (e.g., primary.500)
223
+ if (themeKey === 'colors' && transformedName.includes('-')) {
224
+ const parts = transformedName.split('-');
225
+ // Check if it looks like a color scale (name-shade pattern)
226
+ const lastPart = parts[parts.length - 1];
227
+ const isShade = (/^(\d+|dark|light|DEFAULT)$/i).test(lastPart);
228
+ if (isShade && parts.length >= 2) {
229
+ const colorGroup = parts.slice(0, -1).join('-');
230
+ const shade = parts[parts.length - 1];
231
+ if (!theme[themeKey][colorGroup]) {
232
+ theme[themeKey][colorGroup] = {};
233
+ }
234
+ const group = theme[themeKey][colorGroup];
235
+ if (typeof group === 'object' && group !== null) {
236
+ group[shade] = normalizedValue;
237
+ }
238
+ }
239
+ else {
240
+ theme[themeKey][transformedName] = normalizedValue;
241
+ }
242
+ }
243
+ else if (themeKey === 'boxShadow' && Array.isArray(normalizedValue)) {
244
+ // Shadows need to be joined as strings
245
+ theme[themeKey][transformedName] = normalizedValue.map((v) => String(v)).join(', ');
246
+ }
247
+ else {
248
+ theme[themeKey][transformedName] = normalizedValue;
249
+ }
250
+ }
251
+ // Post-process: normalize single-entry objects
252
+ for (const [categoryKey, categoryValue] of Object.entries(theme)) {
253
+ if (typeof categoryValue === 'object' && categoryValue !== null) {
254
+ const keys = Object.keys(categoryValue);
255
+ if (keys.length === 1 && keys[0] !== 'DEFAULT') {
256
+ const value = categoryValue[keys[0]];
257
+ theme[categoryKey] = { DEFAULT: value };
258
+ }
259
+ else if (categoryKey === 'colors') {
260
+ // For colors, normalize nested single-entry objects
261
+ for (const [colorKey, colorValue] of Object.entries(categoryValue)) {
262
+ if (typeof colorValue === 'object' && colorValue !== null && !Array.isArray(colorValue)) {
263
+ const colorObj = colorValue;
264
+ const colorKeys = Object.keys(colorObj);
265
+ if (colorKeys.length === 1 && colorKeys[0] !== 'DEFAULT') {
266
+ categoryValue[colorKey] = { DEFAULT: colorObj[colorKeys[0]] };
267
+ }
268
+ }
269
+ }
270
+ }
271
+ }
272
+ }
273
+ if (useExtend) {
274
+ return {
275
+ theme: {
276
+ extend: theme
277
+ }
278
+ };
279
+ }
280
+ return { theme };
281
+ }
282
+ /**
283
+ * Formats a Tailwind v4 config object as a JavaScript module string.
284
+ *
285
+ * @param config The config object.
286
+ * @returns Formatted JavaScript string.
287
+ * @public
288
+ */
289
+ function formatTailwindV4ConfigAsJs(config) {
290
+ const parts = [JS_FILE_HEADER, ''];
291
+ parts.push('/** @type {import(\'tailwindcss\').Config} */');
292
+ parts.push(`export default ${JSON.stringify(config, null, 2).replace(/"([^"]+)":/g, '$1:')};`);
293
+ parts.push('');
294
+ return parts.join('\n');
295
+ }
296
+ /**
297
+ * Formats a Tailwind v4 config object as a TypeScript module string.
298
+ *
299
+ * @param config The config object.
300
+ * @returns Formatted TypeScript string.
301
+ * @public
302
+ */
303
+ function formatTailwindV4ConfigAsTs(config) {
304
+ const parts = [TS_FILE_HEADER, ''];
305
+ parts.push('import type { Config } from \'tailwindcss\';');
306
+ parts.push('');
307
+ parts.push(`const config: Config = ${JSON.stringify(config, null, 2).replace(/"([^"]+)":/g, '$1:')};`);
308
+ parts.push('');
309
+ parts.push('export default config;');
310
+ parts.push('');
311
+ return parts.join('\n');
312
+ }
313
+ /**
314
+ * Builds and formats a Tailwind v4 JavaScript config file from tokens.
315
+ *
316
+ * @param allTokens All transformed tokens from Style-Dictionary.
317
+ * @param options Build options.
318
+ * @returns Formatted JavaScript config file content.
319
+ * @public
320
+ */
321
+ function buildTailwindV4ConfigJs(allTokens, options = {}) {
322
+ const config = buildTailwindV4Config(allTokens, options);
323
+ return formatTailwindV4ConfigAsJs(config);
324
+ }
325
+ /**
326
+ * Builds and formats a Tailwind v4 TypeScript config file from tokens.
327
+ *
328
+ * @param allTokens All transformed tokens from Style-Dictionary.
329
+ * @param options Build options.
330
+ * @returns Formatted TypeScript config file content.
331
+ * @public
332
+ */
333
+ function buildTailwindV4ConfigTs(allTokens, options = {}) {
334
+ const config = buildTailwindV4Config(allTokens, options);
335
+ return formatTailwindV4ConfigAsTs(config);
336
+ }
337
+ // #endregion
338
+ //# sourceMappingURL=buildTailwindV4Config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildTailwindV4Config.js","sourceRoot":"","sources":["../../../../src/formats/tailwind/v4/buildTailwindV4Config.ts"],"names":[],"mappings":";AAAA,kBAAkB;;AAuPlB,sDAuHC;AASD,gEAQC;AASD,gEAWC;AAUD,0DAMC;AAUD,0DAMC;AAhbD,oEAAsE;AACtE,8DAAwD;AACxD,gEAA0D;AAE1D,iFAKwC;AA6CxC,aAAa;AAEb,iBAAiB;AAEjB;;;;GAIG;AACH,MAAM,cAAc,GAAG;;;;;;qFAM8D,CAAC;AAEtF;;;;GAIG;AACH,MAAM,cAAc,GAAG;;;;;;qFAM8D,CAAC;AAEtF,aAAa;AAEb,kBAAkB;AAElB;;;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1
+ import type { TransformedToken } from 'style-dictionary/types';
2
+ import { type TailwindV4Namespace } from './TailwindV4PropertyMapping.js';
3
+ /**
4
+ * Represents a CSS custom property with namespace and value.
5
+ *
6
+ * @public
7
+ */
8
+ export interface ICssVariable {
9
+ readonly namespace: TailwindV4Namespace;
10
+ readonly name: string;
11
+ readonly value: string;
12
+ }
13
+ /**
14
+ * Options for building the Tailwind v4 theme.
15
+ *
16
+ * @public
17
+ */
18
+ export interface IBuildTailwindV4ThemeOptions {
19
+ /**
20
+ * Token name substrings to ignore.
21
+ */
22
+ readonly ignoredTokenNameSubstrings?: ReadonlyArray<string>;
23
+ /**
24
+ * Whether to include a reference to tailwindcss in the output.
25
+ *
26
+ * @default true
27
+ */
28
+ readonly includeTailwindImport?: boolean;
29
+ /**
30
+ * Whether to wrap variables in @theme directive.
31
+ *
32
+ * @default true
33
+ */
34
+ readonly wrapInTheme?: boolean;
35
+ /**
36
+ * Custom layer name for the @theme directive.
37
+ *
38
+ * @default undefined (uses default @theme without layer)
39
+ */
40
+ readonly themeLayer?: string;
41
+ }
42
+ /**
43
+ * Builds an array of CSS custom properties from Style-Dictionary tokens
44
+ * for use in Tailwind v4's @theme directive.
45
+ *
46
+ * @param allTokens All transformed tokens from Style-Dictionary.
47
+ * @param ignoredTokenNameSubstrings Optional substrings; tokens whose name contains any are ignored.
48
+ * @returns Array of CSS variable definitions.
49
+ * @public
50
+ */
51
+ export declare function buildCssVariables(allTokens: ReadonlyArray<TransformedToken>, ignoredTokenNameSubstrings?: ReadonlyArray<string>): ReadonlyArray<ICssVariable>;
52
+ /**
53
+ * Builds a complete Tailwind v4 CSS theme file from Style-Dictionary tokens.
54
+ *
55
+ * @param allTokens All transformed tokens from Style-Dictionary.
56
+ * @param options Build options.
57
+ * @returns Complete CSS file content with @theme directive.
58
+ * @public
59
+ */
60
+ export declare function buildTailwindV4Theme(allTokens: ReadonlyArray<TransformedToken>, options?: IBuildTailwindV4ThemeOptions): string;
61
+ /**
62
+ * Builds a Tailwind v4 CSS theme as CSS custom properties only (no @import).
63
+ * Useful for creating theme presets that can be imported separately.
64
+ *
65
+ * @param allTokens All transformed tokens from Style-Dictionary.
66
+ * @param options Build options.
67
+ * @returns CSS file content with theme variables.
68
+ * @public
69
+ */
70
+ export declare function buildTailwindV4Preset(allTokens: ReadonlyArray<TransformedToken>, options?: IBuildTailwindV4ThemeOptions): string;
71
+ //# sourceMappingURL=buildTailwindV4Theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildTailwindV4Theme.d.ts","sourceRoot":"","sources":["../../../../src/formats/tailwind/v4/buildTailwindV4Theme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D,OAAO,EAIH,KAAK,mBAAmB,EAE3B,MAAM,gCAAgC,CAAC;AAMxC;;;;GAIG;AACH,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAEzC;;OAEG;IACH,QAAQ,CAAC,0BAA0B,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAE5D;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAChC;AA2GD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC7B,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC1C,0BAA0B,GAAE,aAAa,CAAC,MAAM,CAAM,GACvD,aAAa,CAAC,YAAY,CAAC,CAkD7B;AAuED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAChC,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC1C,OAAO,GAAE,4BAAiC,GAC3C,MAAM,CA+BR;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACjC,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC1C,OAAO,GAAE,4BAAiC,GAC3C,MAAM,CAKR"}
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.buildCssVariables = buildCssVariables;
5
+ exports.buildTailwindV4Theme = buildTailwindV4Theme;
6
+ exports.buildTailwindV4Preset = buildTailwindV4Preset;
7
+ const utilities_1 = require("@breadstone-infrastructure/utilities");
8
+ const getType_js_1 = require("../../../utilities/getType.js");
9
+ const getValue_js_1 = require("../../../utilities/getValue.js");
10
+ const TailwindV4PropertyMapping_js_1 = require("./TailwindV4PropertyMapping.js");
11
+ // #endregion
12
+ // #region Fields
13
+ /**
14
+ * Auto-generated file header comment.
15
+ *
16
+ * @private
17
+ */
18
+ const FILE_HEADER = `/* ------------------------------------------------------------------------------
19
+ * <auto-generated>
20
+ * This code was generated by a tool.
21
+ * Changes to this file may cause incorrect behavior and will be lost if
22
+ * the code is regenerated.
23
+ * </auto-generated>
24
+ * ------------------------------------------------------------------------------ */`;
25
+ // #endregion
26
+ // #region Methods
27
+ /**
28
+ * Normalizes a raw token value into a string suitable for CSS.
29
+ *
30
+ * @param value Raw token value.
31
+ * @returns Normalized string value for CSS.
32
+ * @private
33
+ */
34
+ function normalizeValue(value) {
35
+ if (Array.isArray(value)) {
36
+ return value.map((v) => String(v)).join(', ');
37
+ }
38
+ if (typeof value === 'string' || typeof value === 'number') {
39
+ return String(value);
40
+ }
41
+ return String(value);
42
+ }
43
+ /**
44
+ * Validates that tokens use supported logical types and logs warnings
45
+ * for those that cannot be mapped to Tailwind v4.
46
+ *
47
+ * @param tokens All transformed tokens.
48
+ * @param ignoredNames Optional substrings; tokens whose name contains any of them are ignored.
49
+ * @private
50
+ */
51
+ function validateTokenTypes(tokens, ignoredNames = []) {
52
+ const supported = new Set(TailwindV4PropertyMapping_js_1.SUPPORTED_TOKEN_TYPES);
53
+ tokens
54
+ .filter((token) => {
55
+ const lower = token.name.toLowerCase();
56
+ return !ignoredNames.some((substr) => lower.includes(substr.toLowerCase()));
57
+ })
58
+ .forEach((token) => {
59
+ // If token has a valid category mapping, skip type validation
60
+ const rawCategory = token.category;
61
+ if (rawCategory && rawCategory in TailwindV4PropertyMapping_js_1.CATEGORY_TO_V4_MAPPING) {
62
+ return;
63
+ }
64
+ const type = (0, getType_js_1.getType)(token);
65
+ if (!type) {
66
+ return;
67
+ }
68
+ if (!supported.has(type)) {
69
+ console.warn(`${(0, utilities_1.symbol)('warning')} ${(0, utilities_1.yellow)(`Type "${type}" is not supported in Tailwind v4 builder for token "${token.path.join('.')}:${token.name}".`)}`);
70
+ }
71
+ });
72
+ }
73
+ /**
74
+ * Resolves the mapping for a token in Tailwind v4 format.
75
+ *
76
+ * @param token The token to resolve mapping for.
77
+ * @returns An IV4KeyMapping when resolvable, otherwise undefined.
78
+ * @private
79
+ */
80
+ function resolveMappingForToken(token) {
81
+ const rawCategory = token.category;
82
+ // 1. Category-based mapping (if present)
83
+ if (rawCategory) {
84
+ if (rawCategory in TailwindV4PropertyMapping_js_1.CATEGORY_TO_V4_MAPPING) {
85
+ return TailwindV4PropertyMapping_js_1.CATEGORY_TO_V4_MAPPING[rawCategory];
86
+ }
87
+ console.warn(`${(0, utilities_1.symbol)('warning')} ${(0, utilities_1.yellow)(`Token "${token.name}" specifies category "${rawCategory}", which is not mapped. Falling back to token type.`)}`);
88
+ }
89
+ // 2. Type-based mapping
90
+ const type = (token.type ?? token.$type ?? token.original.type ?? token.original.$type);
91
+ if (type) {
92
+ const byType = TailwindV4PropertyMapping_js_1.TOKEN_TYPE_TO_V4_MAPPING[type];
93
+ if (byType) {
94
+ return byType;
95
+ }
96
+ }
97
+ return undefined;
98
+ }
99
+ /**
100
+ * Builds an array of CSS custom properties from Style-Dictionary tokens
101
+ * for use in Tailwind v4's @theme directive.
102
+ *
103
+ * @param allTokens All transformed tokens from Style-Dictionary.
104
+ * @param ignoredTokenNameSubstrings Optional substrings; tokens whose name contains any are ignored.
105
+ * @returns Array of CSS variable definitions.
106
+ * @public
107
+ */
108
+ function buildCssVariables(allTokens, ignoredTokenNameSubstrings = []) {
109
+ validateTokenTypes(allTokens, ignoredTokenNameSubstrings);
110
+ const variables = [];
111
+ for (const token of allTokens) {
112
+ const lowerName = token.name.toLowerCase();
113
+ const tokenPath = token.path.join('.');
114
+ // Check if any ignored substring appears in the token name OR path
115
+ const isIgnored = ignoredTokenNameSubstrings.some((substr) => lowerName.includes(substr.toLowerCase()) || tokenPath.toLowerCase().includes(substr.toLowerCase()));
116
+ if (isIgnored) {
117
+ continue;
118
+ }
119
+ // Skip expanded shadow parts
120
+ const shadowPartPattern = /\.(offsetX|offsetY|blur|spread|color)\.\d+$/i;
121
+ if (shadowPartPattern.test(tokenPath)) {
122
+ continue;
123
+ }
124
+ // Skip duration tokens without values
125
+ if (token.path[0] === 'duration' && !token.value) {
126
+ continue;
127
+ }
128
+ const mapping = resolveMappingForToken(token);
129
+ if (!mapping) {
130
+ console.warn(`${(0, utilities_1.symbol)('warning')} ${(0, utilities_1.yellow)(`Token "${token.path.join('.')}:${token.name}" cannot be mapped to Tailwind v4 (no valid category or type mapping). Skipping.`)}`);
131
+ continue;
132
+ }
133
+ const rawValue = (0, getValue_js_1.getValue)(token);
134
+ const normalizedValue = normalizeValue(rawValue);
135
+ const rawPath = token.path.length > 0 ? token.path : [token.name];
136
+ // Apply pathTransform if defined
137
+ const transformedName = mapping.pathTransform
138
+ ? mapping.pathTransform(rawPath)
139
+ : rawPath.join('-').toLowerCase();
140
+ variables.push({
141
+ namespace: mapping.namespace,
142
+ name: transformedName,
143
+ value: normalizedValue
144
+ });
145
+ }
146
+ return variables;
147
+ }
148
+ /**
149
+ * Groups CSS variables by their namespace for organized output.
150
+ *
151
+ * @param variables Array of CSS variables.
152
+ * @returns Map of namespace to variables.
153
+ * @private
154
+ */
155
+ function groupVariablesByNamespace(variables) {
156
+ const grouped = new Map();
157
+ for (const variable of variables) {
158
+ const existing = grouped.get(variable.namespace);
159
+ if (existing) {
160
+ existing.push(variable);
161
+ }
162
+ else {
163
+ grouped.set(variable.namespace, [variable]);
164
+ }
165
+ }
166
+ return grouped;
167
+ }
168
+ /**
169
+ * Formats CSS variables into a CSS string for the @theme directive.
170
+ *
171
+ * @param variables Array of CSS variables.
172
+ * @param indent Indentation string.
173
+ * @returns Formatted CSS string.
174
+ * @private
175
+ */
176
+ function formatCssVariables(variables, indent = ' ') {
177
+ const grouped = groupVariablesByNamespace(variables);
178
+ const lines = [];
179
+ // Sort namespaces for consistent output
180
+ const sortedNamespaces = Array.from(grouped.keys()).sort();
181
+ for (const namespace of sortedNamespaces) {
182
+ const vars = grouped.get(namespace);
183
+ if (!vars?.length) {
184
+ continue;
185
+ }
186
+ lines.push(`${indent}/* ${namespace.slice(2)} */`);
187
+ // Sort variables within each namespace
188
+ const sortedVars = [...vars].sort((a, b) => a.name.localeCompare(b.name));
189
+ for (const variable of sortedVars) {
190
+ const fullName = `${namespace}-${variable.name}`;
191
+ lines.push(`${indent}${fullName}: ${variable.value};`);
192
+ }
193
+ lines.push('');
194
+ }
195
+ // Remove trailing empty line
196
+ if (lines.length > 0 && lines[lines.length - 1] === '') {
197
+ lines.pop();
198
+ }
199
+ return lines.join('\n');
200
+ }
201
+ /**
202
+ * Builds a complete Tailwind v4 CSS theme file from Style-Dictionary tokens.
203
+ *
204
+ * @param allTokens All transformed tokens from Style-Dictionary.
205
+ * @param options Build options.
206
+ * @returns Complete CSS file content with @theme directive.
207
+ * @public
208
+ */
209
+ function buildTailwindV4Theme(allTokens, options = {}) {
210
+ const { ignoredTokenNameSubstrings = [], includeTailwindImport = true, wrapInTheme = true, themeLayer } = options;
211
+ const variables = buildCssVariables(allTokens, ignoredTokenNameSubstrings);
212
+ const formattedVariables = formatCssVariables(variables);
213
+ const parts = [FILE_HEADER, ''];
214
+ if (includeTailwindImport) {
215
+ parts.push('@import "tailwindcss";', '');
216
+ }
217
+ if (wrapInTheme) {
218
+ const themeDirective = themeLayer ? `@theme ${themeLayer}` : '@theme';
219
+ parts.push(`${themeDirective} {`);
220
+ parts.push(formattedVariables);
221
+ parts.push('}');
222
+ }
223
+ else {
224
+ parts.push(':root {');
225
+ parts.push(formattedVariables);
226
+ parts.push('}');
227
+ }
228
+ parts.push('');
229
+ return parts.join('\n');
230
+ }
231
+ /**
232
+ * Builds a Tailwind v4 CSS theme as CSS custom properties only (no @import).
233
+ * Useful for creating theme presets that can be imported separately.
234
+ *
235
+ * @param allTokens All transformed tokens from Style-Dictionary.
236
+ * @param options Build options.
237
+ * @returns CSS file content with theme variables.
238
+ * @public
239
+ */
240
+ function buildTailwindV4Preset(allTokens, options = {}) {
241
+ return buildTailwindV4Theme(allTokens, {
242
+ ...options,
243
+ includeTailwindImport: false
244
+ });
245
+ }
246
+ // #endregion
247
+ //# sourceMappingURL=buildTailwindV4Theme.js.map