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