@digdir/designsystemet 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/designsystemet.js +130 -186
- package/dist/src/index.js +88 -145
- package/dist/src/scripts/update-preview-tokens.d.ts +3 -0
- package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -0
- package/dist/src/scripts/update-preview-tokens.js +3446 -0
- package/dist/src/tokens/build.d.ts +1 -1
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +98 -154
- package/dist/src/tokens/create/generators/$designsystemet.js +6 -6
- package/dist/src/tokens/create/write.js +6 -6
- package/dist/src/tokens/format.d.ts +1 -1
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +88 -145
- package/dist/src/tokens/index.js +88 -145
- package/dist/src/tokens/process/configs/color.js +234 -293
- package/dist/src/tokens/process/configs/semantic.js +509 -113
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/typography.js +504 -110
- package/dist/src/tokens/process/configs.d.ts +0 -1
- package/dist/src/tokens/process/configs.d.ts.map +1 -1
- package/dist/src/tokens/process/configs.js +231 -290
- package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/color.js +644 -12
- package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/semantic.js +679 -23
- package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/typography.js +741 -8
- package/dist/src/tokens/process/formats/css.js +549 -38
- package/dist/src/tokens/process/output/declarations.js +60 -121
- package/dist/src/tokens/process/output/theme.js +6 -6
- package/dist/src/tokens/process/platform.d.ts +9 -4
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +76 -133
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +62 -123
- package/package.json +6 -6
- package/dist/src/tokens/process/configs/storefront.d.ts +0 -3
- package/dist/src/tokens/process/configs/storefront.d.ts.map +0 -1
- package/dist/src/tokens/process/configs/storefront.js +0 -234
- package/dist/src/tokens/process/formats/js-tokens.d.ts +0 -6
- package/dist/src/tokens/process/formats/js-tokens.d.ts.map +0 -1
- package/dist/src/tokens/process/formats/js-tokens.js +0 -123
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/tokens/process/formats/css/color.ts
|
|
2
|
-
import * as
|
|
2
|
+
import * as R8 from "ramda";
|
|
3
3
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
4
4
|
|
|
5
5
|
// src/tokens/types.ts
|
|
@@ -35,6 +35,9 @@ var pathStartsWithOneOf = R.curry(
|
|
|
35
35
|
function isSemanticToken(token) {
|
|
36
36
|
return token.filePath.includes("semantic/");
|
|
37
37
|
}
|
|
38
|
+
function isSemanticColorToken(token, color) {
|
|
39
|
+
return token.filePath.includes("semantic/") && R.startsWith(["color", color], token.path);
|
|
40
|
+
}
|
|
38
41
|
function isGlobalColorToken(token) {
|
|
39
42
|
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
40
43
|
}
|
|
@@ -62,6 +65,487 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
62
65
|
});
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
// src/tokens/process/platform.ts
|
|
69
|
+
import chalk2 from "chalk";
|
|
70
|
+
import * as R7 from "ramda";
|
|
71
|
+
import StyleDictionary2 from "style-dictionary";
|
|
72
|
+
|
|
73
|
+
// src/tokens/process/configs.ts
|
|
74
|
+
import { register } from "@tokens-studio/sd-transforms";
|
|
75
|
+
import * as R6 from "ramda";
|
|
76
|
+
import StyleDictionary from "style-dictionary";
|
|
77
|
+
|
|
78
|
+
// src/tokens/process/configs/color.ts
|
|
79
|
+
import * as R3 from "ramda";
|
|
80
|
+
|
|
81
|
+
// src/tokens/process/transformers.ts
|
|
82
|
+
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
83
|
+
import * as R2 from "ramda";
|
|
84
|
+
var isPx = R2.test(/\b\d+px\b/g);
|
|
85
|
+
var sizeRem = {
|
|
86
|
+
name: "ds/size/toRem",
|
|
87
|
+
type: "value",
|
|
88
|
+
transitive: true,
|
|
89
|
+
filter: (token) => {
|
|
90
|
+
const hasWantedType = typeEquals(["dimension", "fontsize"], token);
|
|
91
|
+
const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
|
|
92
|
+
return hasWantedType && hasWantedPath;
|
|
93
|
+
},
|
|
94
|
+
transform: (token, config) => {
|
|
95
|
+
const value = getValue(token);
|
|
96
|
+
if (isPx(value)) {
|
|
97
|
+
const baseFont = config.basePxFontSize || 16;
|
|
98
|
+
const size = parseInt(value);
|
|
99
|
+
if (size === 0) {
|
|
100
|
+
return "0";
|
|
101
|
+
}
|
|
102
|
+
return `${size / baseFont}rem`;
|
|
103
|
+
}
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var typographyName = {
|
|
108
|
+
name: "name/typography",
|
|
109
|
+
type: "name",
|
|
110
|
+
transitive: true,
|
|
111
|
+
// expanded tokens have different type so we match on path instead
|
|
112
|
+
filter: (token) => pathStartsWithOneOf(["typography"], token),
|
|
113
|
+
transform: (token) => {
|
|
114
|
+
return token.name.replace("-typography", "");
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var resolveMath = {
|
|
118
|
+
name: "ds/resolveMath",
|
|
119
|
+
type: "value",
|
|
120
|
+
transitive: true,
|
|
121
|
+
filter: (token) => {
|
|
122
|
+
const isValidValue = ["string", "object"].includes(typeof getValue(token));
|
|
123
|
+
const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
|
|
124
|
+
return isValidValue && isTokenOfInterest;
|
|
125
|
+
},
|
|
126
|
+
transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
|
|
127
|
+
};
|
|
128
|
+
var unitless = {
|
|
129
|
+
name: "ds/unitless",
|
|
130
|
+
type: "value",
|
|
131
|
+
transitive: true,
|
|
132
|
+
filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
|
|
133
|
+
transform: (token) => parseInt(getValue(token))
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// src/tokens/process/configs/shared.ts
|
|
137
|
+
var prefix = "ds";
|
|
138
|
+
var basePxFontSize = 16;
|
|
139
|
+
var dsTransformers = [
|
|
140
|
+
"name/kebab",
|
|
141
|
+
resolveMath.name,
|
|
142
|
+
"ts/size/px",
|
|
143
|
+
sizeRem.name,
|
|
144
|
+
unitless.name,
|
|
145
|
+
"ts/typography/fontWeight",
|
|
146
|
+
typographyName.name,
|
|
147
|
+
"ts/color/modifiers",
|
|
148
|
+
"ts/color/css/hexrgba",
|
|
149
|
+
"ts/size/lineheight",
|
|
150
|
+
"shadow/css/shorthand"
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
// src/tokens/process/configs/color.ts
|
|
154
|
+
var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
|
|
155
|
+
const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
|
|
156
|
+
const layer = `ds.theme.color-scheme.${colorScheme2}`;
|
|
157
|
+
return {
|
|
158
|
+
preprocessors: ["tokens-studio"],
|
|
159
|
+
platforms: {
|
|
160
|
+
css: {
|
|
161
|
+
// custom
|
|
162
|
+
colorScheme: colorScheme2,
|
|
163
|
+
theme,
|
|
164
|
+
selector,
|
|
165
|
+
layer,
|
|
166
|
+
//
|
|
167
|
+
prefix,
|
|
168
|
+
buildPath: `${theme}/`,
|
|
169
|
+
transforms: dsTransformers,
|
|
170
|
+
files: [
|
|
171
|
+
{
|
|
172
|
+
destination: `color-scheme/${colorScheme2}.css`,
|
|
173
|
+
format: formats.colorScheme.name,
|
|
174
|
+
filter: (token) => typeEquals("color", token) && !R3.startsWith(["global"], token.path)
|
|
175
|
+
}
|
|
176
|
+
],
|
|
177
|
+
options: {
|
|
178
|
+
outputReferences: false
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, ...permutation }) => {
|
|
185
|
+
const category = opts.category;
|
|
186
|
+
const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
|
|
187
|
+
if (!color) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
const layer = `ds.theme.color`;
|
|
193
|
+
const isRootColor = color === buildOptions?.defaultColor;
|
|
194
|
+
const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
|
|
195
|
+
const config = {
|
|
196
|
+
preprocessors: ["tokens-studio"],
|
|
197
|
+
platforms: {
|
|
198
|
+
css: {
|
|
199
|
+
// custom
|
|
200
|
+
colorScheme: colorScheme2,
|
|
201
|
+
theme,
|
|
202
|
+
selector,
|
|
203
|
+
layer,
|
|
204
|
+
//
|
|
205
|
+
prefix,
|
|
206
|
+
buildPath: `${theme}/`,
|
|
207
|
+
transforms: dsTransformers,
|
|
208
|
+
files: [
|
|
209
|
+
{
|
|
210
|
+
destination: `color/${color}.css`,
|
|
211
|
+
format: formats.colorCategory.name,
|
|
212
|
+
filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
options: {
|
|
216
|
+
outputReferences: true
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
return config;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// src/tokens/process/configs/semantic.ts
|
|
225
|
+
import * as R4 from "ramda";
|
|
226
|
+
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
227
|
+
var semanticVariables = ({ theme }) => {
|
|
228
|
+
const selector = `:root`;
|
|
229
|
+
const layer = `ds.theme.semantic`;
|
|
230
|
+
return {
|
|
231
|
+
preprocessors: ["tokens-studio"],
|
|
232
|
+
platforms: {
|
|
233
|
+
css: {
|
|
234
|
+
// custom
|
|
235
|
+
theme,
|
|
236
|
+
basePxFontSize,
|
|
237
|
+
selector,
|
|
238
|
+
layer,
|
|
239
|
+
//
|
|
240
|
+
prefix,
|
|
241
|
+
buildPath: `${theme}/`,
|
|
242
|
+
transforms: dsTransformers,
|
|
243
|
+
files: [
|
|
244
|
+
{
|
|
245
|
+
destination: `semantic.css`,
|
|
246
|
+
format: formats.semantic.name,
|
|
247
|
+
filter: (token) => {
|
|
248
|
+
const isUwantedToken = R4.anyPass([R4.includes("primitives/global")])(token.filePath);
|
|
249
|
+
const isPrivateToken = R4.includes("_", token.path);
|
|
250
|
+
const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
|
|
251
|
+
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
252
|
+
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
253
|
+
return unwantedTokens;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
options: {
|
|
258
|
+
outputReferences: (token, options) => {
|
|
259
|
+
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
260
|
+
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
|
|
261
|
+
return (include || isWantedSize) && outputReferencesFilter(token, options);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// src/tokens/process/configs/typography.ts
|
|
270
|
+
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
271
|
+
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
272
|
+
const selector = `${typography2 === "primary" ? ":root, " : ""}[data-typography="${typography2}"]`;
|
|
273
|
+
const layer = `ds.theme.typography.${typography2}`;
|
|
274
|
+
return {
|
|
275
|
+
usesDtcg: true,
|
|
276
|
+
preprocessors: ["tokens-studio"],
|
|
277
|
+
expand: {
|
|
278
|
+
include: ["typography"],
|
|
279
|
+
typesMap: { ...expandTypesMap, typography: { ...expandTypesMap.typography, letterSpacing: "dimension" } }
|
|
280
|
+
},
|
|
281
|
+
platforms: {
|
|
282
|
+
css: {
|
|
283
|
+
prefix,
|
|
284
|
+
typography: typography2,
|
|
285
|
+
selector,
|
|
286
|
+
layer,
|
|
287
|
+
buildPath: `${theme}/`,
|
|
288
|
+
basePxFontSize,
|
|
289
|
+
transforms: [
|
|
290
|
+
"name/kebab",
|
|
291
|
+
"ts/size/px",
|
|
292
|
+
sizeRem.name,
|
|
293
|
+
"ts/size/lineheight",
|
|
294
|
+
"ts/typography/fontWeight",
|
|
295
|
+
"ts/size/css/letterspacing",
|
|
296
|
+
typographyName.name
|
|
297
|
+
],
|
|
298
|
+
files: [
|
|
299
|
+
{
|
|
300
|
+
destination: `typography/${typography2}.css`,
|
|
301
|
+
format: formats.typography.name,
|
|
302
|
+
filter: (token) => {
|
|
303
|
+
const included = typeEquals(
|
|
304
|
+
["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
|
|
305
|
+
token
|
|
306
|
+
);
|
|
307
|
+
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
308
|
+
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
318
|
+
var BoxShadowTypes;
|
|
319
|
+
(function(BoxShadowTypes2) {
|
|
320
|
+
BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
|
|
321
|
+
BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
|
|
322
|
+
})(BoxShadowTypes || (BoxShadowTypes = {}));
|
|
323
|
+
|
|
324
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
|
|
325
|
+
var ColorModifierTypes;
|
|
326
|
+
(function(ColorModifierTypes2) {
|
|
327
|
+
ColorModifierTypes2["LIGHTEN"] = "lighten";
|
|
328
|
+
ColorModifierTypes2["DARKEN"] = "darken";
|
|
329
|
+
ColorModifierTypes2["MIX"] = "mix";
|
|
330
|
+
ColorModifierTypes2["ALPHA"] = "alpha";
|
|
331
|
+
})(ColorModifierTypes || (ColorModifierTypes = {}));
|
|
332
|
+
|
|
333
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
|
|
334
|
+
var ColorSpaceTypes;
|
|
335
|
+
(function(ColorSpaceTypes2) {
|
|
336
|
+
ColorSpaceTypes2["LCH"] = "lch";
|
|
337
|
+
ColorSpaceTypes2["SRGB"] = "srgb";
|
|
338
|
+
ColorSpaceTypes2["P3"] = "p3";
|
|
339
|
+
ColorSpaceTypes2["HSL"] = "hsl";
|
|
340
|
+
})(ColorSpaceTypes || (ColorSpaceTypes = {}));
|
|
341
|
+
|
|
342
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js
|
|
343
|
+
var Properties;
|
|
344
|
+
(function(Properties2) {
|
|
345
|
+
Properties2["sizing"] = "sizing";
|
|
346
|
+
Properties2["height"] = "height";
|
|
347
|
+
Properties2["width"] = "width";
|
|
348
|
+
Properties2["spacing"] = "spacing";
|
|
349
|
+
Properties2["verticalPadding"] = "verticalPadding";
|
|
350
|
+
Properties2["horizontalPadding"] = "horizontalPadding";
|
|
351
|
+
Properties2["paddingTop"] = "paddingTop";
|
|
352
|
+
Properties2["paddingRight"] = "paddingRight";
|
|
353
|
+
Properties2["paddingBottom"] = "paddingBottom";
|
|
354
|
+
Properties2["paddingLeft"] = "paddingLeft";
|
|
355
|
+
Properties2["itemSpacing"] = "itemSpacing";
|
|
356
|
+
Properties2["fill"] = "fill";
|
|
357
|
+
Properties2["backgroundBlur"] = "backgroundBlur";
|
|
358
|
+
Properties2["border"] = "border";
|
|
359
|
+
Properties2["borderTop"] = "borderTop";
|
|
360
|
+
Properties2["borderRight"] = "borderRight";
|
|
361
|
+
Properties2["borderBottom"] = "borderBottom";
|
|
362
|
+
Properties2["borderLeft"] = "borderLeft";
|
|
363
|
+
Properties2["borderColor"] = "borderColor";
|
|
364
|
+
Properties2["borderRadius"] = "borderRadius";
|
|
365
|
+
Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
|
|
366
|
+
Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
|
|
367
|
+
Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
|
|
368
|
+
Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
|
|
369
|
+
Properties2["borderWidth"] = "borderWidth";
|
|
370
|
+
Properties2["borderWidthTop"] = "borderWidthTop";
|
|
371
|
+
Properties2["borderWidthRight"] = "borderWidthRight";
|
|
372
|
+
Properties2["borderWidthBottom"] = "borderWidthBottom";
|
|
373
|
+
Properties2["borderWidthLeft"] = "borderWidthLeft";
|
|
374
|
+
Properties2["boxShadow"] = "boxShadow";
|
|
375
|
+
Properties2["opacity"] = "opacity";
|
|
376
|
+
Properties2["fontFamilies"] = "fontFamilies";
|
|
377
|
+
Properties2["fontWeights"] = "fontWeights";
|
|
378
|
+
Properties2["fontSizes"] = "fontSizes";
|
|
379
|
+
Properties2["lineHeights"] = "lineHeights";
|
|
380
|
+
Properties2["typography"] = "typography";
|
|
381
|
+
Properties2["composition"] = "composition";
|
|
382
|
+
Properties2["letterSpacing"] = "letterSpacing";
|
|
383
|
+
Properties2["paragraphSpacing"] = "paragraphSpacing";
|
|
384
|
+
Properties2["textCase"] = "textCase";
|
|
385
|
+
Properties2["dimension"] = "dimension";
|
|
386
|
+
Properties2["textDecoration"] = "textDecoration";
|
|
387
|
+
Properties2["asset"] = "asset";
|
|
388
|
+
Properties2["tokenValue"] = "tokenValue";
|
|
389
|
+
Properties2["value"] = "value";
|
|
390
|
+
Properties2["tokenName"] = "tokenName";
|
|
391
|
+
Properties2["description"] = "description";
|
|
392
|
+
})(Properties || (Properties = {}));
|
|
393
|
+
|
|
394
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
|
|
395
|
+
var TokenSetStatus;
|
|
396
|
+
(function(TokenSetStatus2) {
|
|
397
|
+
TokenSetStatus2["DISABLED"] = "disabled";
|
|
398
|
+
TokenSetStatus2["SOURCE"] = "source";
|
|
399
|
+
TokenSetStatus2["ENABLED"] = "enabled";
|
|
400
|
+
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
401
|
+
|
|
402
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
|
|
403
|
+
var TokenTypes;
|
|
404
|
+
(function(TokenTypes2) {
|
|
405
|
+
TokenTypes2["OTHER"] = "other";
|
|
406
|
+
TokenTypes2["COLOR"] = "color";
|
|
407
|
+
TokenTypes2["BORDER_RADIUS"] = "borderRadius";
|
|
408
|
+
TokenTypes2["SIZING"] = "sizing";
|
|
409
|
+
TokenTypes2["SPACING"] = "spacing";
|
|
410
|
+
TokenTypes2["TEXT"] = "text";
|
|
411
|
+
TokenTypes2["TYPOGRAPHY"] = "typography";
|
|
412
|
+
TokenTypes2["OPACITY"] = "opacity";
|
|
413
|
+
TokenTypes2["BORDER_WIDTH"] = "borderWidth";
|
|
414
|
+
TokenTypes2["STROKE_STYLE"] = "strokeStyle";
|
|
415
|
+
TokenTypes2["BOX_SHADOW"] = "boxShadow";
|
|
416
|
+
TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
|
|
417
|
+
TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
|
|
418
|
+
TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
|
|
419
|
+
TokenTypes2["FONT_SIZES"] = "fontSizes";
|
|
420
|
+
TokenTypes2["LETTER_SPACING"] = "letterSpacing";
|
|
421
|
+
TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
422
|
+
TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
423
|
+
TokenTypes2["TEXT_DECORATION"] = "textDecoration";
|
|
424
|
+
TokenTypes2["TEXT_CASE"] = "textCase";
|
|
425
|
+
TokenTypes2["COMPOSITION"] = "composition";
|
|
426
|
+
TokenTypes2["DIMENSION"] = "dimension";
|
|
427
|
+
TokenTypes2["BORDER"] = "border";
|
|
428
|
+
TokenTypes2["ASSET"] = "asset";
|
|
429
|
+
TokenTypes2["BOOLEAN"] = "boolean";
|
|
430
|
+
TokenTypes2["NUMBER"] = "number";
|
|
431
|
+
})(TokenTypes || (TokenTypes = {}));
|
|
432
|
+
|
|
433
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js
|
|
434
|
+
var BorderValues;
|
|
435
|
+
(function(BorderValues2) {
|
|
436
|
+
BorderValues2["BORDER_COLOR"] = "color";
|
|
437
|
+
BorderValues2["BORDER_WIDTH"] = "width";
|
|
438
|
+
BorderValues2["BORDER_STYLE"] = "style";
|
|
439
|
+
})(BorderValues || (BorderValues = {}));
|
|
440
|
+
|
|
441
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
|
|
442
|
+
var StrokeStyleValues;
|
|
443
|
+
(function(StrokeStyleValues2) {
|
|
444
|
+
StrokeStyleValues2["SOLID"] = "solid";
|
|
445
|
+
StrokeStyleValues2["DASHED"] = "dashed";
|
|
446
|
+
StrokeStyleValues2["DOTTED"] = "dotted";
|
|
447
|
+
StrokeStyleValues2["DOUBLE"] = "double";
|
|
448
|
+
StrokeStyleValues2["GROOVE"] = "groove";
|
|
449
|
+
StrokeStyleValues2["RIDGE"] = "ridge";
|
|
450
|
+
StrokeStyleValues2["OUTSET"] = "outset";
|
|
451
|
+
StrokeStyleValues2["INSET"] = "inset";
|
|
452
|
+
})(StrokeStyleValues || (StrokeStyleValues = {}));
|
|
453
|
+
|
|
454
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
|
|
455
|
+
var BoxShadowValues;
|
|
456
|
+
(function(BoxShadowValues2) {
|
|
457
|
+
BoxShadowValues2["TYPE"] = "type";
|
|
458
|
+
BoxShadowValues2["COLOR"] = "color";
|
|
459
|
+
BoxShadowValues2["X"] = "x";
|
|
460
|
+
BoxShadowValues2["Y"] = "y";
|
|
461
|
+
BoxShadowValues2["BLUR"] = "blur";
|
|
462
|
+
BoxShadowValues2["SPREAD"] = "spread";
|
|
463
|
+
BoxShadowValues2["BLEND_MODE"] = "blendMode";
|
|
464
|
+
})(BoxShadowValues || (BoxShadowValues = {}));
|
|
465
|
+
|
|
466
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
|
|
467
|
+
var TypographyValues;
|
|
468
|
+
(function(TypographyValues2) {
|
|
469
|
+
TypographyValues2["FONT_FAMILY"] = "fontFamily";
|
|
470
|
+
TypographyValues2["FONT_WEIGHT"] = "fontWeight";
|
|
471
|
+
TypographyValues2["LINE_HEIGHT"] = "lineHeight";
|
|
472
|
+
TypographyValues2["FONT_SIZE"] = "fontSize";
|
|
473
|
+
TypographyValues2["LETTER_SPACING"] = "letterSpacing";
|
|
474
|
+
TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
475
|
+
TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
476
|
+
TypographyValues2["TEXT_DECORATION"] = "textDecoration";
|
|
477
|
+
TypographyValues2["TEXT_CASE"] = "textCase";
|
|
478
|
+
})(TypographyValues || (TypographyValues = {}));
|
|
479
|
+
|
|
480
|
+
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
481
|
+
import chalk from "chalk";
|
|
482
|
+
import { kebabCase } from "change-case";
|
|
483
|
+
import * as R5 from "ramda";
|
|
484
|
+
var processed = Symbol("Type brand for ProcessedThemeObject");
|
|
485
|
+
var hasUnknownProps = R5.pipe(R5.values, R5.none(R5.equals("unknown")), R5.not);
|
|
486
|
+
|
|
487
|
+
// src/tokens/process/configs.ts
|
|
488
|
+
void register(StyleDictionary, { withSDBuiltins: false });
|
|
489
|
+
StyleDictionary.registerTransform(sizeRem);
|
|
490
|
+
StyleDictionary.registerTransform(typographyName);
|
|
491
|
+
StyleDictionary.registerTransform(resolveMath);
|
|
492
|
+
StyleDictionary.registerTransform(unitless);
|
|
493
|
+
for (const format of Object.values(formats)) {
|
|
494
|
+
StyleDictionary.registerFormat(format);
|
|
495
|
+
}
|
|
496
|
+
var configs = {
|
|
497
|
+
colorSchemeVariables,
|
|
498
|
+
mainColorVariables: colorCategoryVariables({ category: "main" }),
|
|
499
|
+
supportColorVariables: colorCategoryVariables({ category: "support" }),
|
|
500
|
+
neutralColorVariables: colorCategoryVariables({ category: "builtin", color: "neutral" }),
|
|
501
|
+
successColorVariables: colorCategoryVariables({ category: "builtin", color: "success" }),
|
|
502
|
+
dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
|
|
503
|
+
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
504
|
+
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
505
|
+
typographyVariables,
|
|
506
|
+
semanticVariables
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
// src/tokens/process/platform.ts
|
|
510
|
+
var buildOptions = {
|
|
511
|
+
verbose: false,
|
|
512
|
+
processed$themes: [],
|
|
513
|
+
buildTokenFormats: {}
|
|
514
|
+
};
|
|
515
|
+
var sd = new StyleDictionary2();
|
|
516
|
+
var buildConfigs = {
|
|
517
|
+
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
518
|
+
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
519
|
+
"main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
|
|
520
|
+
"support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
|
|
521
|
+
"neutral-color": {
|
|
522
|
+
getConfig: configs.neutralColorVariables,
|
|
523
|
+
dimensions: ["semantic"],
|
|
524
|
+
log: ({ permutation: { theme } }) => `${theme} - neutral`
|
|
525
|
+
},
|
|
526
|
+
"success-color": {
|
|
527
|
+
getConfig: configs.successColorVariables,
|
|
528
|
+
dimensions: ["semantic"],
|
|
529
|
+
log: ({ permutation: { theme } }) => `${theme} - success`
|
|
530
|
+
},
|
|
531
|
+
"danger-color": {
|
|
532
|
+
getConfig: configs.dangerColorVariables,
|
|
533
|
+
dimensions: ["semantic"],
|
|
534
|
+
log: ({ permutation: { theme } }) => `${theme} - danger`
|
|
535
|
+
},
|
|
536
|
+
"warning-color": {
|
|
537
|
+
getConfig: configs.warningColorVariables,
|
|
538
|
+
dimensions: ["semantic"],
|
|
539
|
+
log: ({ permutation: { theme } }) => `${theme} - warning`
|
|
540
|
+
},
|
|
541
|
+
"info-color": {
|
|
542
|
+
getConfig: configs.infoColorVariables,
|
|
543
|
+
dimensions: ["semantic"],
|
|
544
|
+
log: ({ permutation: { theme } }) => `${theme} - info`
|
|
545
|
+
},
|
|
546
|
+
semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
|
|
547
|
+
};
|
|
548
|
+
|
|
65
549
|
// src/tokens/process/formats/css/color.ts
|
|
66
550
|
var prefersColorScheme = (colorScheme2, content) => `
|
|
67
551
|
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
@@ -85,8 +569,8 @@ var colorScheme = {
|
|
|
85
569
|
color-scheme: ${colorScheme_};
|
|
86
570
|
` : "";
|
|
87
571
|
const filteredAllTokens = allTokens.filter(
|
|
88
|
-
|
|
89
|
-
|
|
572
|
+
R8.allPass([
|
|
573
|
+
R8.anyPass([
|
|
90
574
|
// Include semantic tokens in the output
|
|
91
575
|
isSemanticToken,
|
|
92
576
|
// Include global color tokens
|
|
@@ -96,13 +580,17 @@ var colorScheme = {
|
|
|
96
580
|
(t) => !isColorCategoryToken(t)
|
|
97
581
|
])
|
|
98
582
|
);
|
|
99
|
-
const
|
|
583
|
+
const formattedMap = filteredAllTokens.map((token) => ({
|
|
584
|
+
token,
|
|
585
|
+
formatted: format(token)
|
|
586
|
+
}));
|
|
587
|
+
const formattedTokens = formattedMap.map(R8.view(R8.lensProp("formatted"))).join("\n");
|
|
100
588
|
const content = `{
|
|
101
589
|
${formattedTokens}
|
|
102
590
|
${colorSchemeProperty}}
|
|
103
591
|
`;
|
|
104
592
|
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
105
|
-
const body =
|
|
593
|
+
const body = R8.isNotNil(layer) ? `@layer ${layer} {
|
|
106
594
|
${selector} ${content} ${autoSelectorContent}
|
|
107
595
|
}
|
|
108
596
|
` : `${selector} ${content} ${autoSelectorContent}
|
|
@@ -114,8 +602,9 @@ var colorCategory = {
|
|
|
114
602
|
name: "ds/css-colorcategory",
|
|
115
603
|
format: async ({ dictionary, options, platform }) => {
|
|
116
604
|
const { outputReferences, usesDtcg } = options;
|
|
117
|
-
const { selector, layer } = platform;
|
|
118
|
-
const
|
|
605
|
+
const { selector, layer, files } = platform;
|
|
606
|
+
const destination = files?.[0]?.destination;
|
|
607
|
+
const format = R8.compose(
|
|
119
608
|
createPropertyFormatter({
|
|
120
609
|
outputReferences,
|
|
121
610
|
dictionary,
|
|
@@ -131,12 +620,17 @@ var colorCategory = {
|
|
|
131
620
|
}
|
|
132
621
|
})
|
|
133
622
|
);
|
|
134
|
-
const
|
|
623
|
+
const formattedMap = dictionary.allTokens.map((token) => ({
|
|
624
|
+
token,
|
|
625
|
+
formatted: format(token)
|
|
626
|
+
}));
|
|
627
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
628
|
+
const formattedTokens = formattedMap.map(R8.view(R8.lensProp("formatted"))).join("\n");
|
|
135
629
|
const content = `{
|
|
136
630
|
${formattedTokens}
|
|
137
631
|
}
|
|
138
632
|
`;
|
|
139
|
-
const body =
|
|
633
|
+
const body = R8.isNotNil(layer) ? `@layer ${layer} {
|
|
140
634
|
${selector} ${content}
|
|
141
635
|
}
|
|
142
636
|
` : `${selector} ${content}
|
|
@@ -146,12 +640,12 @@ ${selector} ${content}
|
|
|
146
640
|
};
|
|
147
641
|
|
|
148
642
|
// src/tokens/process/formats/css/semantic.ts
|
|
149
|
-
import * as
|
|
643
|
+
import * as R9 from "ramda";
|
|
150
644
|
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
151
645
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
152
646
|
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
153
647
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
154
|
-
var isInlineTokens =
|
|
648
|
+
var isInlineTokens = R9.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
155
649
|
var overrideSizingFormula = (format, token) => {
|
|
156
650
|
const [name, value] = format(token).split(":");
|
|
157
651
|
const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
|
|
@@ -162,30 +656,30 @@ var overrideSizingFormula = (format, token) => {
|
|
|
162
656
|
calc
|
|
163
657
|
};
|
|
164
658
|
};
|
|
165
|
-
var formatSizingTokens = (format, tokens) =>
|
|
166
|
-
|
|
167
|
-
(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
659
|
+
var formatSizingTokens = (format, tokens) => R9.reduce(
|
|
660
|
+
(acc, token) => {
|
|
661
|
+
const { round, calc, name } = overrideSizingFormula(format, token);
|
|
662
|
+
return {
|
|
663
|
+
tokens: [...acc.tokens, token],
|
|
664
|
+
round: [...acc.round, `${name}: ${round};`],
|
|
665
|
+
calc: [...acc.calc, `${name}: ${calc};`]
|
|
666
|
+
};
|
|
667
|
+
},
|
|
668
|
+
{ tokens: [], round: [], calc: [] },
|
|
669
|
+
tokens
|
|
670
|
+
);
|
|
671
|
+
var sizingTemplate = ({ round, calc }) => `
|
|
178
672
|
${calc.join("\n")}
|
|
179
673
|
|
|
180
674
|
@supports (width: round(down, .1em, 1px)) {
|
|
181
675
|
${round.join("\n")}
|
|
182
676
|
}`;
|
|
183
|
-
};
|
|
184
677
|
var semantic = {
|
|
185
678
|
name: "ds/css-semantic",
|
|
186
679
|
format: async ({ dictionary, options, platform }) => {
|
|
187
680
|
const { outputReferences, usesDtcg } = options;
|
|
188
|
-
const { selector, layer } = platform;
|
|
681
|
+
const { selector, layer, files } = platform;
|
|
682
|
+
const destination = files?.[0]?.destination;
|
|
189
683
|
const format = createPropertyFormatter2({
|
|
190
684
|
outputReferences,
|
|
191
685
|
dictionary,
|
|
@@ -193,17 +687,28 @@ var semantic = {
|
|
|
193
687
|
usesDtcg
|
|
194
688
|
});
|
|
195
689
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
196
|
-
const filteredTokens =
|
|
197
|
-
const [sizingTokens, restTokens] =
|
|
690
|
+
const filteredTokens = R9.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
|
|
691
|
+
const [sizingTokens, restTokens] = R9.partition(
|
|
198
692
|
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
199
693
|
filteredTokens
|
|
200
694
|
);
|
|
201
|
-
const
|
|
695
|
+
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
696
|
+
const formattedMap = restTokens.map((token) => ({
|
|
697
|
+
token,
|
|
698
|
+
formatted: format(token)
|
|
699
|
+
}));
|
|
700
|
+
const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
|
|
701
|
+
token: formattedSizingTokens.tokens[i],
|
|
702
|
+
formatted: t
|
|
703
|
+
}));
|
|
704
|
+
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
705
|
+
const sizingSnippet = sizingTemplate(formattedSizingTokens);
|
|
706
|
+
const formattedTokens = formattedMap.map(R9.view(R9.lensProp("formatted"))).concat(sizingSnippet);
|
|
202
707
|
const content = `{
|
|
203
708
|
${formattedTokens.join("\n")}
|
|
204
709
|
}
|
|
205
710
|
`;
|
|
206
|
-
const body =
|
|
711
|
+
const body = R9.isNotNil(layer) ? `@layer ${layer} {
|
|
207
712
|
${selector} ${content}
|
|
208
713
|
}
|
|
209
714
|
` : `${selector} ${content}
|
|
@@ -213,29 +718,35 @@ ${selector} ${content}
|
|
|
213
718
|
};
|
|
214
719
|
|
|
215
720
|
// src/tokens/process/formats/css/typography.ts
|
|
216
|
-
import * as
|
|
721
|
+
import * as R10 from "ramda";
|
|
217
722
|
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
218
|
-
var typographyFontFamilyPredicate =
|
|
219
|
-
|
|
220
|
-
|
|
723
|
+
var typographyFontFamilyPredicate = R10.allPass([
|
|
724
|
+
R10.pathSatisfies(R10.includes("typography"), ["path"]),
|
|
725
|
+
R10.pathSatisfies(R10.includes("fontFamily"), ["path"])
|
|
221
726
|
]);
|
|
222
727
|
var typography = {
|
|
223
728
|
name: "ds/css-typography",
|
|
224
729
|
format: async ({ dictionary, options, platform }) => {
|
|
225
730
|
const { outputReferences, usesDtcg } = options;
|
|
226
|
-
const { selector, layer } = platform;
|
|
731
|
+
const { selector, layer, files } = platform;
|
|
732
|
+
const destination = files?.[0]?.destination;
|
|
227
733
|
const format = createPropertyFormatter3({
|
|
228
734
|
outputReferences,
|
|
229
735
|
dictionary,
|
|
230
736
|
format: "css",
|
|
231
737
|
usesDtcg
|
|
232
738
|
});
|
|
233
|
-
const filteredTokens =
|
|
234
|
-
const
|
|
739
|
+
const filteredTokens = R10.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
740
|
+
const formattedMap = filteredTokens.map((token) => ({
|
|
741
|
+
token,
|
|
742
|
+
formatted: format(token)
|
|
743
|
+
}));
|
|
744
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
745
|
+
const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).join("\n");
|
|
235
746
|
const content = selector ? `${selector} {
|
|
236
747
|
${formattedTokens}
|
|
237
748
|
}` : formattedTokens;
|
|
238
|
-
const body =
|
|
749
|
+
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
239
750
|
${content}
|
|
240
751
|
}` : content;
|
|
241
752
|
return body;
|