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