@digdir/designsystemet 1.13.2 ā 1.14.0
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/config.js +50 -658
- package/dist/bin/designsystemet.d.ts.map +1 -1
- package/dist/bin/designsystemet.js +136 -4623
- package/dist/bin/options.js +22 -14
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js +9 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js +8 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js +13 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js +10 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js +10 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js +53 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js +14 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js +9 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js +32 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js +15 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/types/index.js +11 -0
- package/dist/package.js +5 -0
- package/dist/src/colors/colorMetadata.js +255 -261
- package/dist/src/colors/index.js +5 -522
- package/dist/src/colors/theme.js +104 -343
- package/dist/src/colors/types.js +22 -25
- package/dist/src/colors/utils.js +241 -154
- package/dist/src/config.js +103 -444
- package/dist/src/index.js +10 -3588
- package/dist/src/migrations/beta-to-v1.js +339 -537
- package/dist/src/migrations/codemods/css/plugins.js +31 -42
- package/dist/src/migrations/codemods/css/run.js +20 -151
- package/dist/src/migrations/color-rename-next49.js +44 -220
- package/dist/src/migrations/index.js +7 -577
- package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -1
- package/dist/src/tokens/build.js +39 -1816
- package/dist/src/tokens/create/files.d.ts +10 -5
- package/dist/src/tokens/create/files.d.ts.map +1 -1
- package/dist/src/tokens/create/files.js +44 -601
- package/dist/src/tokens/create/generators/$designsystemet.js +8 -97
- package/dist/src/tokens/create/generators/$metadata.d.ts +7 -3
- package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/$metadata.js +24 -21
- package/dist/src/tokens/create/generators/$themes.d.ts +2 -4
- package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/$themes.js +139 -312
- package/dist/src/tokens/create/generators/primitives/color-scheme.js +68 -443
- package/dist/src/tokens/create/generators/primitives/globals.js +141 -147
- package/dist/src/tokens/create/generators/primitives/size.js +146 -156
- package/dist/src/tokens/create/generators/primitives/typography.js +213 -217
- package/dist/src/tokens/create/generators/semantic/color-modes.js +24 -59
- package/dist/src/tokens/create/generators/semantic/color.js +42 -326
- package/dist/src/tokens/create/generators/semantic/style.js +379 -382
- package/dist/src/tokens/create/generators/themes/theme.js +108 -392
- package/dist/src/tokens/create.d.ts +2 -1
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +50 -1591
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +35 -3324
- package/dist/src/tokens/generate-config.js +155 -298
- package/dist/src/tokens/index.js +3 -3344
- package/dist/src/tokens/process/configs/color.js +50 -1085
- package/dist/src/tokens/process/configs/semantic.js +45 -1083
- package/dist/src/tokens/process/configs/shared.js +18 -109
- package/dist/src/tokens/process/configs/size-mode.js +27 -1082
- package/dist/src/tokens/process/configs/size.js +32 -1083
- package/dist/src/tokens/process/configs/type-scale.js +49 -1083
- package/dist/src/tokens/process/configs/typography.js +63 -1084
- package/dist/src/tokens/process/configs.js +91 -1224
- package/dist/src/tokens/process/formats/css/color.js +58 -1079
- package/dist/src/tokens/process/formats/css/semantic.js +27 -1081
- package/dist/src/tokens/process/formats/css/size-mode.js +43 -1077
- package/dist/src/tokens/process/formats/css/size.js +86 -1079
- package/dist/src/tokens/process/formats/css/type-scale.js +53 -1083
- package/dist/src/tokens/process/formats/css/typography.js +27 -1081
- package/dist/src/tokens/process/formats/css.js +18 -1081
- package/dist/src/tokens/process/output/declarations.js +18 -1201
- package/dist/src/tokens/process/output/tailwind.js +26 -40
- package/dist/src/tokens/process/output/theme.js +73 -206
- package/dist/src/tokens/process/platform.js +165 -1355
- package/dist/src/tokens/process/transformers.js +49 -89
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +100 -1183
- package/dist/src/tokens/process/utils/kebab-case.js +7 -5
- package/dist/src/tokens/types.d.ts +6 -0
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/types.js +6 -7
- package/dist/src/tokens/utils.d.ts +2 -1
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +107 -93
- package/dist/src/types.js +1 -5
- package/dist/src/utils/filesystem.js +112 -124
- package/package.json +12 -15
- package/configs/test-tokens.config.json +0 -82
- package/dist/src/scripts/createJsonSchema.js +0 -409
- package/dist/src/scripts/update-preview-tokens.js +0 -3353
|
@@ -1,1202 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
// package.json
|
|
5
|
-
var package_default = {
|
|
6
|
-
name: "@digdir/designsystemet",
|
|
7
|
-
version: "1.13.2",
|
|
8
|
-
description: "CLI for Designsystemet",
|
|
9
|
-
author: "Designsystemet team",
|
|
10
|
-
engines: {
|
|
11
|
-
node: ">=20.20.2"
|
|
12
|
-
},
|
|
13
|
-
repository: {
|
|
14
|
-
type: "git",
|
|
15
|
-
url: "git+https://github.com/digdir/designsystemet.git"
|
|
16
|
-
},
|
|
17
|
-
homepage: "https://github.com/digdir/designsystemet/tree/main/packages/cli",
|
|
18
|
-
license: "MIT",
|
|
19
|
-
type: "module",
|
|
20
|
-
main: "./dist/src/index.js",
|
|
21
|
-
files: [
|
|
22
|
-
"./dist/**",
|
|
23
|
-
"./configs/**"
|
|
24
|
-
],
|
|
25
|
-
bin: "dist/bin/designsystemet.js",
|
|
26
|
-
exports: {
|
|
27
|
-
".": {
|
|
28
|
-
import: "./dist/src/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./color": {
|
|
31
|
-
import: "./dist/src/colors/index.js"
|
|
32
|
-
},
|
|
33
|
-
"./tokens": {
|
|
34
|
-
import: "./dist/src/tokens/index.js"
|
|
35
|
-
},
|
|
36
|
-
"./types": {
|
|
37
|
-
import: "./dist/src/types.js"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
publishConfig: {
|
|
41
|
-
access: "public"
|
|
42
|
-
},
|
|
43
|
-
scripts: {
|
|
44
|
-
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
45
|
-
"designsystemet:inspect": "tsx --inspect-brk ./bin/designsystemet.ts",
|
|
46
|
-
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
47
|
-
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
48
|
-
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
49
|
-
types: "tsc --noEmit",
|
|
50
|
-
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
|
|
51
|
-
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
|
|
52
|
-
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
53
|
-
"test:tokens-build-tailwind": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean --experimental-tailwind",
|
|
54
|
-
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
55
|
-
"test:tokens-build-config:inspect": "pnpm run designsystemet:inspect tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
56
|
-
"test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
|
|
57
|
-
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
58
|
-
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
59
|
-
"test:generate-config-from-tokens": "pnpm run designsystemet generate-config-from-tokens -d ../../design-tokens --dry",
|
|
60
|
-
test: "node -v && pnpm test:tokens-create-and-build-options && pnpm test:generate-config-from-tokens && pnpm test:tokens-create-and-build-config",
|
|
61
|
-
"update:preview-tokens": "tsx ./src/scripts/update-preview-tokens.ts",
|
|
62
|
-
verify: "pnpm test && pnpm update:template && pnpm --filter @internal/digdir update:theme-digdir"
|
|
63
|
-
},
|
|
64
|
-
dependencies: {
|
|
65
|
-
"@commander-js/extra-typings": "^14.0.0",
|
|
66
|
-
"@digdir/designsystemet-types": "workspace:",
|
|
67
|
-
"@tokens-studio/sd-transforms": "2.0.3",
|
|
68
|
-
"chroma-js": "^3.2.0",
|
|
69
|
-
"colorjs.io": "^0.6.1",
|
|
70
|
-
commander: "^14.0.3",
|
|
71
|
-
"fast-glob": "^3.3.3",
|
|
72
|
-
hsluv: "^1.0.1",
|
|
73
|
-
"object-hash": "^3.0.0",
|
|
74
|
-
picocolors: "^1.1.1",
|
|
75
|
-
postcss: "^8.5.8",
|
|
76
|
-
ramda: "^0.32.0",
|
|
77
|
-
"style-dictionary": "^5.4.0",
|
|
78
|
-
zod: "^4.3.6",
|
|
79
|
-
"zod-validation-error": "^5.0.0"
|
|
80
|
-
},
|
|
81
|
-
devDependencies: {
|
|
82
|
-
"@tokens-studio/types": "0.5.2",
|
|
83
|
-
"@types/chroma-js": "3.1.2",
|
|
84
|
-
"@types/node": "24.12.2",
|
|
85
|
-
"@types/object-hash": "3.0.6",
|
|
86
|
-
"@types/ramda": "0.31.1",
|
|
87
|
-
tsup: "8.5.1",
|
|
88
|
-
tsx: "4.21.0",
|
|
89
|
-
typescript: "5.9.3"
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// src/tokens/process/platform.ts
|
|
94
|
-
import pc2 from "picocolors";
|
|
95
|
-
import * as R15 from "ramda";
|
|
96
|
-
import StyleDictionary2 from "style-dictionary";
|
|
97
|
-
|
|
98
|
-
// src/tokens/types.ts
|
|
99
|
-
var colorCategories = {
|
|
100
|
-
main: "main",
|
|
101
|
-
support: "support"
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// src/tokens/process/configs.ts
|
|
105
|
-
import { register } from "@tokens-studio/sd-transforms";
|
|
106
|
-
import * as R14 from "ramda";
|
|
107
|
-
import StyleDictionary from "style-dictionary";
|
|
108
|
-
|
|
109
|
-
// src/tokens/utils.ts
|
|
110
|
-
import * as R from "ramda";
|
|
111
|
-
var mapToLowerCase = R.map(R.toLower);
|
|
112
|
-
var hasAnyTruth = R.any(R.equals(true));
|
|
113
|
-
var getType = (token) => (token.$type ?? token.type) || "";
|
|
114
|
-
var getValue = (token) => token.$value ?? token.value;
|
|
115
|
-
var typeEquals = R.curry(
|
|
116
|
-
(types, token) => {
|
|
117
|
-
if (R.isNil(token)) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
return R.includes(R.toLower(getType(token)), R.map(R.toLower, Array.isArray(types) ? types : [types]));
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
var pathStartsWithOneOf = R.curry(
|
|
124
|
-
(paths, token) => {
|
|
125
|
-
if (R.isNil(token)) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
const tokenPath = mapToLowerCase(token.path);
|
|
129
|
-
const matchPathsStartingWith = R.map((pathOrString) => {
|
|
130
|
-
const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
|
|
131
|
-
return R.startsWith(mapToLowerCase(path), tokenPath);
|
|
132
|
-
}, paths);
|
|
133
|
-
return hasAnyTruth(matchPathsStartingWith);
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
function isSemanticToken(token) {
|
|
137
|
-
return token.filePath.includes("semantic/");
|
|
138
|
-
}
|
|
139
|
-
function isSemanticColorToken(token, color) {
|
|
140
|
-
return token.filePath.includes("semantic/") && R.startsWith(["color", color], token.path);
|
|
141
|
-
}
|
|
142
|
-
function isGlobalColorToken(token) {
|
|
143
|
-
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
144
|
-
}
|
|
145
|
-
function isColorCategoryToken(token, category) {
|
|
146
|
-
if (!category) {
|
|
147
|
-
return Object.keys(colorCategories).some(
|
|
148
|
-
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
return R.startsWith(["color", category], token.path);
|
|
152
|
-
}
|
|
153
|
-
var isDigit = (s) => /^\d+$/.test(s);
|
|
154
|
-
function inlineTokens(shouldInline, tokens) {
|
|
155
|
-
const [inlineableTokens, otherTokens] = R.partition(shouldInline, tokens);
|
|
156
|
-
return otherTokens.map((token) => {
|
|
157
|
-
let transformed = getValue(token.original);
|
|
158
|
-
for (const ref of inlineableTokens) {
|
|
159
|
-
const refName = ref.path.join(".");
|
|
160
|
-
if (typeof transformed === "string") {
|
|
161
|
-
transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
const tokenWithInlinedRefs = R.set(R.lensPath(["original", "$value"]), transformed, token);
|
|
165
|
-
return tokenWithInlinedRefs;
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
var sizeMap = {
|
|
169
|
-
xsmall: "xs",
|
|
170
|
-
small: "sm",
|
|
171
|
-
medium: "md",
|
|
172
|
-
large: "lg",
|
|
173
|
-
xlarge: "xl"
|
|
174
|
-
};
|
|
175
|
-
function shortSizeName(size2) {
|
|
176
|
-
return sizeMap[size2] ?? size2;
|
|
177
|
-
}
|
|
178
|
-
var sizeComparator = (size2) => {
|
|
179
|
-
const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
|
|
180
|
-
return sortIndex ?? 0;
|
|
181
|
-
};
|
|
182
|
-
function orderBySize(sizes) {
|
|
183
|
-
return R.sortBy(sizeComparator, sizes);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// src/tokens/process/configs/color.ts
|
|
187
|
-
import * as R9 from "ramda";
|
|
188
|
-
|
|
189
|
-
// src/tokens/process/formats/css/color.ts
|
|
190
|
-
import * as R2 from "ramda";
|
|
191
|
-
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
192
|
-
var prefersColorScheme = (colorScheme2, content) => `
|
|
193
|
-
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
194
|
-
[data-color-scheme="auto"] ${content}
|
|
195
|
-
}
|
|
196
|
-
`;
|
|
197
|
-
var colorScheme = {
|
|
198
|
-
name: "ds/css-colorscheme",
|
|
199
|
-
format: async ({ dictionary, options, platform }) => {
|
|
200
|
-
const { allTokens } = dictionary;
|
|
201
|
-
const { outputReferences, usesDtcg } = options;
|
|
202
|
-
const { selector, colorScheme: colorScheme2, layer } = platform;
|
|
203
|
-
const colorScheme_ = colorScheme2;
|
|
204
|
-
const format = createPropertyFormatter({
|
|
205
|
-
outputReferences,
|
|
206
|
-
dictionary,
|
|
207
|
-
format: "css",
|
|
208
|
-
usesDtcg
|
|
209
|
-
});
|
|
210
|
-
const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `
|
|
211
|
-
color-scheme: ${colorScheme_};
|
|
212
|
-
` : "";
|
|
213
|
-
const filteredAllTokens = allTokens.filter(
|
|
214
|
-
R2.allPass([
|
|
215
|
-
R2.anyPass([
|
|
216
|
-
// Include semantic tokens in the output
|
|
217
|
-
isSemanticToken,
|
|
218
|
-
// Include global color tokens
|
|
219
|
-
isGlobalColorToken
|
|
220
|
-
]),
|
|
221
|
-
// Don't include color category tokens -- they are exported separately
|
|
222
|
-
(t) => !isColorCategoryToken(t)
|
|
223
|
-
])
|
|
224
|
-
);
|
|
225
|
-
const formattedMap = filteredAllTokens.map((token) => ({
|
|
226
|
-
token,
|
|
227
|
-
formatted: format(token)
|
|
228
|
-
}));
|
|
229
|
-
const formattedTokens = formattedMap.map(R2.view(R2.lensProp("formatted"))).join("\n");
|
|
230
|
-
const content = `{
|
|
231
|
-
${formattedTokens}
|
|
232
|
-
${colorSchemeProperty}}
|
|
233
|
-
`;
|
|
234
|
-
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
235
|
-
const body = R2.isNotNil(layer) ? `@layer ${layer} {
|
|
236
|
-
${selector} ${content} ${autoSelectorContent}
|
|
237
|
-
}
|
|
238
|
-
` : `${selector} ${content} ${autoSelectorContent}
|
|
239
|
-
`;
|
|
240
|
-
return body;
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
var colorCategory = {
|
|
244
|
-
name: "ds/css-colorcategory",
|
|
245
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
246
|
-
const { outputReferences, usesDtcg } = options;
|
|
247
|
-
const { selector, layer } = platform;
|
|
248
|
-
const destination = file.destination;
|
|
249
|
-
const format = R2.compose(
|
|
250
|
-
createPropertyFormatter({
|
|
251
|
-
outputReferences,
|
|
252
|
-
dictionary,
|
|
253
|
-
format: "css",
|
|
254
|
-
usesDtcg
|
|
255
|
-
}),
|
|
256
|
-
(token) => ({
|
|
257
|
-
...token,
|
|
258
|
-
name: token.name.replace(/color-\w+-/, "color-"),
|
|
259
|
-
original: {
|
|
260
|
-
...token.original,
|
|
261
|
-
$value: new RegExp(`color-(${colorCategories.main}|${colorCategories.support})-`).test(token.name) ? token.original.$value : `{${token.path.join(".")}}`
|
|
262
|
-
}
|
|
263
|
-
})
|
|
264
|
-
);
|
|
265
|
-
const formattedMap = dictionary.allTokens.map((token) => ({
|
|
266
|
-
token,
|
|
267
|
-
formatted: format(token)
|
|
268
|
-
}));
|
|
269
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
270
|
-
const formattedTokens = formattedMap.map(R2.view(R2.lensProp("formatted"))).join("\n");
|
|
271
|
-
const content = `{
|
|
272
|
-
${formattedTokens}
|
|
273
|
-
}
|
|
274
|
-
`;
|
|
275
|
-
const body = R2.isNotNil(layer) ? `@layer ${layer} {
|
|
276
|
-
${selector} ${content}
|
|
277
|
-
}
|
|
278
|
-
` : `${selector} ${content}
|
|
279
|
-
`;
|
|
280
|
-
return body;
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
// src/tokens/process/formats/css/semantic.ts
|
|
285
|
-
import * as R4 from "ramda";
|
|
286
|
-
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
287
|
-
|
|
288
|
-
// src/tokens/process/formats/css/size.ts
|
|
289
|
-
import * as R3 from "ramda";
|
|
290
|
-
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
291
|
-
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
292
|
-
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
293
|
-
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
294
|
-
var isInlineTokens = R3.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
295
|
-
var overrideSizingFormula = (format, token) => {
|
|
296
|
-
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
297
|
-
let calc;
|
|
298
|
-
let round;
|
|
299
|
-
if (token.path[1] === "unit") {
|
|
300
|
-
calc = `calc(1rem * ${value})`;
|
|
301
|
-
} else if (value.startsWith("floor")) {
|
|
302
|
-
calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
|
|
303
|
-
round = `round(down, ${calc}, 1px)`;
|
|
304
|
-
} else {
|
|
305
|
-
calc = value.includes("*") ? `calc(${value})` : value;
|
|
306
|
-
}
|
|
307
|
-
return {
|
|
308
|
-
name,
|
|
309
|
-
round: round ?? calc,
|
|
310
|
-
calc
|
|
311
|
-
};
|
|
312
|
-
};
|
|
313
|
-
var formatSizingTokens = (format, tokens) => R3.reduce(
|
|
314
|
-
(acc, token) => {
|
|
315
|
-
const { round, calc, name } = overrideSizingFormula(format, token);
|
|
316
|
-
return {
|
|
317
|
-
tokens: [...acc.tokens, token],
|
|
318
|
-
round: [...acc.round, `${name}: ${round};`],
|
|
319
|
-
calc: [...acc.calc, `${name}: ${calc};`]
|
|
320
|
-
};
|
|
321
|
-
},
|
|
322
|
-
{ tokens: [], round: [], calc: [] },
|
|
323
|
-
tokens
|
|
324
|
-
);
|
|
325
|
-
var sizingTemplate = ({ round, calc }) => {
|
|
326
|
-
const usesRounding = round.filter((val, i) => val !== calc[i]);
|
|
327
|
-
return `
|
|
328
|
-
${calc.join("\n")}
|
|
329
|
-
|
|
330
|
-
@supports (width: round(down, .1em, 1px)) {
|
|
331
|
-
${usesRounding.join("\n ")}
|
|
332
|
-
}`;
|
|
333
|
-
};
|
|
334
|
-
var size = {
|
|
335
|
-
name: "ds/css-size",
|
|
336
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
337
|
-
const { outputReferences, usesDtcg } = options;
|
|
338
|
-
const { selector, layer } = platform;
|
|
339
|
-
const destination = file.destination;
|
|
340
|
-
const format = createPropertyFormatter2({
|
|
341
|
-
outputReferences,
|
|
342
|
-
dictionary,
|
|
343
|
-
format: "css",
|
|
344
|
-
usesDtcg
|
|
345
|
-
});
|
|
346
|
-
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
347
|
-
const filteredTokens = R3.reject((token) => R3.equals(["_size", "mode-font-size"], token.path), tokens);
|
|
348
|
-
const [sizingTokens, restTokens] = R3.partition(
|
|
349
|
-
(t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
|
|
350
|
-
filteredTokens
|
|
351
|
-
);
|
|
352
|
-
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
353
|
-
const formattedMap = restTokens.map((token) => ({
|
|
354
|
-
token,
|
|
355
|
-
formatted: format(token)
|
|
356
|
-
}));
|
|
357
|
-
const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
|
|
358
|
-
token: formattedSizingTokens.tokens[i],
|
|
359
|
-
formatted: t
|
|
360
|
-
}));
|
|
361
|
-
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
362
|
-
const formattedTokens = [formattedMap.map(R3.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
|
|
363
|
-
const content = `${selector} {
|
|
364
|
-
${formattedTokens.join("\n")}
|
|
365
|
-
}
|
|
366
|
-
`;
|
|
367
|
-
const body = R3.isNotNil(layer) ? `@layer ${layer} {
|
|
368
|
-
${content}
|
|
369
|
-
}
|
|
370
|
-
` : `${content}
|
|
371
|
-
`;
|
|
372
|
-
return body;
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
// src/tokens/process/formats/css/semantic.ts
|
|
377
|
-
var semantic = {
|
|
378
|
-
name: "ds/css-semantic",
|
|
379
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
380
|
-
const { outputReferences, usesDtcg } = options;
|
|
381
|
-
const { selector, layer } = platform;
|
|
382
|
-
const destination = file.destination;
|
|
383
|
-
const format = createPropertyFormatter3({
|
|
384
|
-
outputReferences,
|
|
385
|
-
dictionary,
|
|
386
|
-
format: "css",
|
|
387
|
-
usesDtcg
|
|
388
|
-
});
|
|
389
|
-
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
390
|
-
const formattedMap = tokens.map((token) => ({
|
|
391
|
-
token,
|
|
392
|
-
formatted: format(token)
|
|
393
|
-
}));
|
|
394
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
395
|
-
const formattedTokens = formattedMap.map(R4.prop("formatted")).join("\n");
|
|
396
|
-
const content = `${selector} {
|
|
397
|
-
${formattedTokens}
|
|
398
|
-
}
|
|
399
|
-
`;
|
|
400
|
-
const body = R4.isNotNil(layer) ? `@layer ${layer} {
|
|
401
|
-
${content}
|
|
402
|
-
}
|
|
403
|
-
` : `${content}
|
|
404
|
-
`;
|
|
405
|
-
return body;
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
// src/tokens/process/formats/css/size-mode.ts
|
|
410
|
-
import * as R6 from "ramda";
|
|
411
|
-
import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
|
|
412
|
-
|
|
413
|
-
// src/tokens/process/transformers.ts
|
|
414
|
-
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
415
|
-
import * as R5 from "ramda";
|
|
416
|
-
var isPx = R5.test(/\b\d+px\b/g);
|
|
417
|
-
var sizeRem = {
|
|
418
|
-
name: "ds/size/toRem",
|
|
419
|
-
type: "value",
|
|
420
|
-
transitive: true,
|
|
421
|
-
filter: (token) => {
|
|
422
|
-
const hasWantedType = typeEquals(["dimension", "fontsize"], token);
|
|
423
|
-
const hasWantedPath = pathStartsWithOneOf([
|
|
424
|
-
"border-radius",
|
|
425
|
-
"font-size"
|
|
426
|
-
/*, ['_size', 'mode-font-size']*/
|
|
427
|
-
], token);
|
|
428
|
-
return hasWantedType && hasWantedPath;
|
|
429
|
-
},
|
|
430
|
-
transform: (token, config) => {
|
|
431
|
-
const value = getValue(token);
|
|
432
|
-
if (isPx(value)) {
|
|
433
|
-
const baseFont = config.basePxFontSize || 16;
|
|
434
|
-
const size2 = parseInt(value, 10);
|
|
435
|
-
if (size2 === 0) {
|
|
436
|
-
return "0";
|
|
437
|
-
}
|
|
438
|
-
return `${size2 / baseFont}rem`;
|
|
439
|
-
}
|
|
440
|
-
return value;
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
var typographyName = {
|
|
444
|
-
name: "name/typography",
|
|
445
|
-
type: "name",
|
|
446
|
-
transitive: true,
|
|
447
|
-
// expanded tokens have different type so we match on path instead
|
|
448
|
-
filter: (token) => pathStartsWithOneOf(["typography"], token),
|
|
449
|
-
transform: (token) => {
|
|
450
|
-
return token.name.replace("-typography", "");
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
var resolveMath = {
|
|
454
|
-
name: "ds/resolveMath",
|
|
455
|
-
type: "value",
|
|
456
|
-
transitive: true,
|
|
457
|
-
filter: (token) => {
|
|
458
|
-
const isValidValue = ["string", "object"].includes(typeof getValue(token));
|
|
459
|
-
const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
|
|
460
|
-
return isValidValue && isTokenOfInterest;
|
|
461
|
-
},
|
|
462
|
-
transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
|
|
463
|
-
};
|
|
464
|
-
var unitless = {
|
|
465
|
-
name: "ds/unitless",
|
|
466
|
-
type: "value",
|
|
467
|
-
transitive: true,
|
|
468
|
-
filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
|
|
469
|
-
transform: (token) => parseInt(getValue(token), 10)
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
// src/tokens/process/configs/shared.ts
|
|
473
|
-
var prefix = "ds";
|
|
474
|
-
var basePxFontSize = 16;
|
|
475
|
-
var dsTransformers = [
|
|
476
|
-
"name/kebab",
|
|
477
|
-
resolveMath.name,
|
|
478
|
-
"ts/size/px",
|
|
479
|
-
sizeRem.name,
|
|
480
|
-
unitless.name,
|
|
481
|
-
"ts/typography/fontWeight",
|
|
482
|
-
typographyName.name,
|
|
483
|
-
"ts/color/modifiers",
|
|
484
|
-
"ts/color/css/hexrgba",
|
|
485
|
-
"ts/size/lineheight",
|
|
486
|
-
"shadow/css/shorthand"
|
|
487
|
-
];
|
|
488
|
-
|
|
489
|
-
// src/tokens/process/formats/css/size-mode.ts
|
|
490
|
-
var formatBaseSizeToken = (size2) => (token) => ({
|
|
491
|
-
...token,
|
|
492
|
-
originalName: token.name,
|
|
493
|
-
name: `${token.name}--${shortSizeName(size2)}`,
|
|
494
|
-
$value: token.$value / basePxFontSize
|
|
495
|
-
});
|
|
496
|
-
var sizeMode = {
|
|
497
|
-
name: "ds/css-size-mode",
|
|
498
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
499
|
-
const { outputReferences, usesDtcg } = options;
|
|
500
|
-
const { selector, layer, size: size2 } = platform;
|
|
501
|
-
const destination = file.destination;
|
|
502
|
-
const format = createPropertyFormatter4({
|
|
503
|
-
outputReferences,
|
|
504
|
-
dictionary,
|
|
505
|
-
format: "css",
|
|
506
|
-
usesDtcg
|
|
507
|
-
});
|
|
508
|
-
const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
|
|
509
|
-
const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
|
|
510
|
-
const formattedMap = sizeSpecificTokens.map((token) => ({
|
|
511
|
-
token,
|
|
512
|
-
formatted: format({
|
|
513
|
-
...token,
|
|
514
|
-
// Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
|
|
515
|
-
name: token.originalName
|
|
516
|
-
})
|
|
517
|
-
}));
|
|
518
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
519
|
-
const content = `${selector} /* ${size2} */ {
|
|
520
|
-
${sizeSpecificVariables}
|
|
521
|
-
}`;
|
|
522
|
-
const body = wrapInLayer(content, layer);
|
|
523
|
-
const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
|
|
524
|
-
const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
|
|
525
|
-
const sizingToggles = `:root, [data-size] {
|
|
526
|
-
--ds-size: var(--ds-size--${defaultSize});
|
|
527
|
-
${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
|
|
528
|
-
--ds-size-mode-font-size:
|
|
529
|
-
${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
|
|
530
|
-
}`;
|
|
531
|
-
const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
|
|
532
|
-
const sharedContent = `${sizingToggles}
|
|
533
|
-
|
|
534
|
-
${sizingHelpers}`;
|
|
535
|
-
const sharedBody = shortSizeName(size2) === R6.last(sizes) ? `
|
|
536
|
-
${wrapInLayer(sharedContent, layer)}` : "";
|
|
537
|
-
return body + sharedBody;
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
function wrapInLayer(content, layer) {
|
|
541
|
-
return R6.isNotNil(layer) ? `@layer ${layer} {
|
|
542
|
-
${content}
|
|
543
|
-
}
|
|
544
|
-
` : `${content}
|
|
545
|
-
`;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
// src/tokens/process/formats/css/typography.ts
|
|
549
|
-
import * as R7 from "ramda";
|
|
550
|
-
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
551
|
-
var typographyFontFamilyPredicate = R7.allPass([
|
|
552
|
-
R7.pathSatisfies(R7.includes("typography"), ["path"]),
|
|
553
|
-
R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
|
|
554
|
-
]);
|
|
555
|
-
var typography = {
|
|
556
|
-
name: "ds/css-typography",
|
|
557
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
558
|
-
const { outputReferences, usesDtcg } = options;
|
|
559
|
-
const { selector, layer } = platform;
|
|
560
|
-
const destination = file.destination;
|
|
561
|
-
const format = createPropertyFormatter5({
|
|
562
|
-
outputReferences,
|
|
563
|
-
dictionary,
|
|
564
|
-
format: "css",
|
|
565
|
-
usesDtcg
|
|
566
|
-
});
|
|
567
|
-
const filteredTokens = R7.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
568
|
-
const formattedMap = filteredTokens.map((token) => ({
|
|
569
|
-
token,
|
|
570
|
-
formatted: format(token)
|
|
571
|
-
}));
|
|
572
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
573
|
-
const formattedTokens = formattedMap.map(R7.view(R7.lensProp("formatted"))).join("\n");
|
|
574
|
-
const content = selector ? `${selector} {
|
|
575
|
-
${formattedTokens}
|
|
576
|
-
}` : formattedTokens;
|
|
577
|
-
const body = R7.isNotNil(layer) ? `@layer ${layer} {
|
|
578
|
-
${content}
|
|
579
|
-
}` : content;
|
|
580
|
-
return body;
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
// src/tokens/process/formats/css/type-scale.ts
|
|
585
|
-
import * as R8 from "ramda";
|
|
586
|
-
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
587
|
-
var isTypographyFontFamilyToken = R8.allPass([
|
|
588
|
-
R8.pathSatisfies(R8.includes("typography"), ["path"]),
|
|
589
|
-
R8.pathSatisfies(R8.includes("fontFamily"), ["path"])
|
|
590
|
-
]);
|
|
591
|
-
var formatTypographySizeToken = (format, token) => {
|
|
592
|
-
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
593
|
-
let calc;
|
|
594
|
-
let round;
|
|
595
|
-
if (R8.startsWith(["font-size"], token.path)) {
|
|
596
|
-
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
597
|
-
round = `round(${calc}, 1px)`;
|
|
598
|
-
} else {
|
|
599
|
-
calc = value;
|
|
600
|
-
}
|
|
601
|
-
return { name, calc, round: round ?? calc };
|
|
602
|
-
};
|
|
603
|
-
var formatTypographySizeTokens = (format, tokens) => R8.reduce(
|
|
604
|
-
(acc, token) => {
|
|
605
|
-
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
606
|
-
acc.tokens.push(token);
|
|
607
|
-
acc.calc.push(`${name}: ${calc};`);
|
|
608
|
-
acc.round.push(`${name}: ${round};`);
|
|
609
|
-
return acc;
|
|
610
|
-
},
|
|
611
|
-
{ tokens: [], calc: [], round: [] },
|
|
612
|
-
tokens
|
|
613
|
-
);
|
|
614
|
-
var typeScale = {
|
|
615
|
-
name: "ds/css-type-scale",
|
|
616
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
617
|
-
const { outputReferences, usesDtcg } = options;
|
|
618
|
-
const { selector, layer } = platform;
|
|
619
|
-
const destination = file.destination;
|
|
620
|
-
const format = createPropertyFormatter6({
|
|
621
|
-
outputReferences,
|
|
622
|
-
dictionary,
|
|
623
|
-
format: "css",
|
|
624
|
-
usesDtcg
|
|
625
|
-
});
|
|
626
|
-
const filteredTokens = R8.reject(R8.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
627
|
-
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
628
|
-
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
629
|
-
token: formattedTokens.tokens[i],
|
|
630
|
-
formatted: t
|
|
631
|
-
}));
|
|
632
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
633
|
-
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
634
|
-
const content = `${selector} {
|
|
635
|
-
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
636
|
-
}`;
|
|
637
|
-
const body = R8.isNotNil(layer) ? `@layer ${layer} {
|
|
638
|
-
${content}
|
|
639
|
-
}` : content;
|
|
640
|
-
return body;
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
// src/tokens/process/formats/css.ts
|
|
645
|
-
var formats = {
|
|
646
|
-
colorScheme,
|
|
647
|
-
colorCategory,
|
|
648
|
-
semantic,
|
|
649
|
-
sizeMode,
|
|
650
|
-
size,
|
|
651
|
-
typography,
|
|
652
|
-
typeScale
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
// src/tokens/process/configs/color.ts
|
|
656
|
-
var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
|
|
657
|
-
const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
|
|
658
|
-
const layer = `ds.theme.color-scheme.${colorScheme2}`;
|
|
659
|
-
return {
|
|
660
|
-
preprocessors: ["tokens-studio"],
|
|
661
|
-
platforms: {
|
|
662
|
-
css: {
|
|
663
|
-
// custom
|
|
664
|
-
colorScheme: colorScheme2,
|
|
665
|
-
theme,
|
|
666
|
-
selector,
|
|
667
|
-
layer,
|
|
668
|
-
//
|
|
669
|
-
prefix,
|
|
670
|
-
buildPath: `${theme}/`,
|
|
671
|
-
transforms: dsTransformers,
|
|
672
|
-
files: [
|
|
673
|
-
{
|
|
674
|
-
destination: `color-scheme/${colorScheme2}.css`,
|
|
675
|
-
format: formats.colorScheme.name,
|
|
676
|
-
filter: (token) => typeEquals("color", token) && !R9.startsWith(["global"], token.path)
|
|
677
|
-
}
|
|
678
|
-
],
|
|
679
|
-
options: {
|
|
680
|
-
outputReferences: false
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
};
|
|
686
|
-
var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, ...permutation }) => {
|
|
687
|
-
const category = opts.category;
|
|
688
|
-
const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
|
|
689
|
-
if (!color) {
|
|
690
|
-
throw new Error(
|
|
691
|
-
category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`
|
|
692
|
-
);
|
|
693
|
-
}
|
|
694
|
-
const layer = `ds.theme.color`;
|
|
695
|
-
const isRootColor = color === buildOptions?.defaultColor;
|
|
696
|
-
const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
|
|
697
|
-
const config = {
|
|
698
|
-
preprocessors: ["tokens-studio"],
|
|
699
|
-
platforms: {
|
|
700
|
-
css: {
|
|
701
|
-
// custom
|
|
702
|
-
colorScheme: colorScheme2,
|
|
703
|
-
theme,
|
|
704
|
-
selector,
|
|
705
|
-
layer,
|
|
706
|
-
//
|
|
707
|
-
prefix,
|
|
708
|
-
buildPath: `${theme}/`,
|
|
709
|
-
transforms: dsTransformers,
|
|
710
|
-
files: [
|
|
711
|
-
{
|
|
712
|
-
destination: `color/${color}.css`,
|
|
713
|
-
format: formats.colorCategory.name,
|
|
714
|
-
filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
|
|
715
|
-
}
|
|
716
|
-
],
|
|
717
|
-
options: {
|
|
718
|
-
outputReferences: true
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
};
|
|
723
|
-
return config;
|
|
724
|
-
};
|
|
725
|
-
|
|
726
|
-
// src/tokens/process/configs/semantic.ts
|
|
727
|
-
import * as R10 from "ramda";
|
|
728
|
-
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
729
|
-
var semanticVariables = ({ theme }) => {
|
|
730
|
-
const selector = `:root`;
|
|
731
|
-
const layer = `ds.theme.semantic`;
|
|
732
|
-
return {
|
|
733
|
-
preprocessors: ["tokens-studio"],
|
|
734
|
-
platforms: {
|
|
735
|
-
css: {
|
|
736
|
-
// custom
|
|
737
|
-
theme,
|
|
738
|
-
basePxFontSize,
|
|
739
|
-
selector,
|
|
740
|
-
layer,
|
|
741
|
-
//
|
|
742
|
-
prefix,
|
|
743
|
-
buildPath: `${theme}/`,
|
|
744
|
-
transforms: dsTransformers,
|
|
745
|
-
files: [
|
|
746
|
-
{
|
|
747
|
-
destination: `semantic.css`,
|
|
748
|
-
format: formats.semantic.name,
|
|
749
|
-
filter: (token) => {
|
|
750
|
-
const isUwantedToken = R10.anyPass([R10.includes("primitives/global")])(token.filePath);
|
|
751
|
-
const isPrivateToken = R10.includes("_", token.path);
|
|
752
|
-
const unwantedPaths = pathStartsWithOneOf(
|
|
753
|
-
["size", "_size", "font-size", "line-height", "letter-spacing"],
|
|
754
|
-
token
|
|
755
|
-
);
|
|
756
|
-
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
757
|
-
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
758
|
-
return unwantedTokens;
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
],
|
|
762
|
-
options: {
|
|
763
|
-
outputReferences: (token, options) => {
|
|
764
|
-
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
765
|
-
return include && outputReferencesFilter(token, options);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
};
|
|
772
|
-
|
|
773
|
-
// src/tokens/process/configs/size.ts
|
|
774
|
-
import * as R11 from "ramda";
|
|
775
|
-
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
776
|
-
var sizeVariables = ({ theme }) => {
|
|
777
|
-
const selector = `:root, [data-size]`;
|
|
778
|
-
const layer = `ds.theme.size`;
|
|
779
|
-
return {
|
|
780
|
-
preprocessors: ["tokens-studio"],
|
|
781
|
-
platforms: {
|
|
782
|
-
css: {
|
|
783
|
-
// custom
|
|
784
|
-
theme,
|
|
785
|
-
basePxFontSize,
|
|
786
|
-
selector,
|
|
787
|
-
layer,
|
|
788
|
-
//
|
|
789
|
-
prefix,
|
|
790
|
-
buildPath: `${theme}/`,
|
|
791
|
-
transforms: dsTransformers,
|
|
792
|
-
files: [
|
|
793
|
-
{
|
|
794
|
-
destination: `size.css`,
|
|
795
|
-
format: formats.size.name,
|
|
796
|
-
filter: (token) => {
|
|
797
|
-
const isUwantedToken = R11.anyPass([R11.includes("primitives/global")])(token.filePath);
|
|
798
|
-
const isPrivateToken = R11.includes("_", token.path);
|
|
799
|
-
return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
],
|
|
803
|
-
options: {
|
|
804
|
-
outputReferences: (token, options) => {
|
|
805
|
-
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
|
|
806
|
-
return isWantedSize && outputReferencesFilter2(token, options);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
};
|
|
812
|
-
};
|
|
813
|
-
|
|
814
|
-
// src/tokens/process/configs/size-mode.ts
|
|
815
|
-
import * as R12 from "ramda";
|
|
816
|
-
var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
817
|
-
const selector = `:root`;
|
|
818
|
-
const layer = `ds.theme.size-mode`;
|
|
819
|
-
return {
|
|
820
|
-
preprocessors: ["tokens-studio"],
|
|
821
|
-
platforms: {
|
|
822
|
-
css: {
|
|
823
|
-
// custom
|
|
824
|
-
size: size2,
|
|
825
|
-
theme,
|
|
826
|
-
basePxFontSize,
|
|
827
|
-
selector,
|
|
828
|
-
layer,
|
|
829
|
-
//
|
|
830
|
-
prefix,
|
|
831
|
-
buildPath: `${theme}/`,
|
|
832
|
-
transforms: dsTransformers,
|
|
833
|
-
files: [
|
|
834
|
-
{
|
|
835
|
-
destination: `size-mode/${size2}.css`,
|
|
836
|
-
format: formats.sizeMode.name,
|
|
837
|
-
filter: (token) => {
|
|
838
|
-
return R12.equals(["_size", "mode-font-size"], token.path);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
]
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
|
-
};
|
|
846
|
-
|
|
847
|
-
// src/tokens/process/configs/type-scale.ts
|
|
848
|
-
var typeScaleVariables = ({ theme }) => {
|
|
849
|
-
const selector = ":root, [data-size]";
|
|
850
|
-
const layer = `ds.theme.type-scale`;
|
|
851
|
-
return {
|
|
852
|
-
usesDtcg: true,
|
|
853
|
-
preprocessors: ["tokens-studio"],
|
|
854
|
-
expand: {
|
|
855
|
-
include: ["typography"]
|
|
856
|
-
},
|
|
857
|
-
platforms: {
|
|
858
|
-
css: {
|
|
859
|
-
prefix,
|
|
860
|
-
selector,
|
|
861
|
-
layer,
|
|
862
|
-
buildPath: `${theme}/`,
|
|
863
|
-
basePxFontSize,
|
|
864
|
-
transforms: [
|
|
865
|
-
"name/kebab",
|
|
866
|
-
"ts/size/px",
|
|
867
|
-
sizeRem.name,
|
|
868
|
-
"ts/size/lineheight",
|
|
869
|
-
"ts/typography/fontWeight",
|
|
870
|
-
typographyName.name
|
|
871
|
-
],
|
|
872
|
-
files: [
|
|
873
|
-
{
|
|
874
|
-
destination: `type-scale.css`,
|
|
875
|
-
format: formats.typeScale.name,
|
|
876
|
-
filter: (token) => {
|
|
877
|
-
const included = typeEquals(["typography", "dimension", "fontsize"], token);
|
|
878
|
-
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
879
|
-
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
],
|
|
883
|
-
options: {
|
|
884
|
-
outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
};
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
// src/tokens/process/configs/typography.ts
|
|
892
|
-
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
893
|
-
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
894
|
-
const selector = `${typography2 === "primary" ? ":root, " : ""}[data-typography="${typography2}"]`;
|
|
895
|
-
const layer = `ds.theme.typography.${typography2}`;
|
|
896
|
-
return {
|
|
897
|
-
usesDtcg: true,
|
|
898
|
-
preprocessors: ["tokens-studio"],
|
|
899
|
-
expand: {
|
|
900
|
-
include: ["typography"],
|
|
901
|
-
typesMap: { ...expandTypesMap, typography: { ...expandTypesMap.typography, letterSpacing: "dimension" } }
|
|
902
|
-
},
|
|
903
|
-
platforms: {
|
|
904
|
-
css: {
|
|
905
|
-
prefix,
|
|
906
|
-
typography: typography2,
|
|
907
|
-
selector,
|
|
908
|
-
layer,
|
|
909
|
-
buildPath: `${theme}/`,
|
|
910
|
-
basePxFontSize,
|
|
911
|
-
transforms: [
|
|
912
|
-
"name/kebab",
|
|
913
|
-
"ts/size/px",
|
|
914
|
-
sizeRem.name,
|
|
915
|
-
"ts/size/lineheight",
|
|
916
|
-
"ts/typography/fontWeight",
|
|
917
|
-
"ts/size/css/letterspacing",
|
|
918
|
-
typographyName.name
|
|
919
|
-
],
|
|
920
|
-
files: [
|
|
921
|
-
{
|
|
922
|
-
destination: `typography/${typography2}.css`,
|
|
923
|
-
format: formats.typography.name,
|
|
924
|
-
filter: (token) => {
|
|
925
|
-
const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
|
|
926
|
-
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
927
|
-
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
]
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
};
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
937
|
-
var BoxShadowTypes;
|
|
938
|
-
(function(BoxShadowTypes2) {
|
|
939
|
-
BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
|
|
940
|
-
BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
|
|
941
|
-
})(BoxShadowTypes || (BoxShadowTypes = {}));
|
|
942
|
-
|
|
943
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
|
|
944
|
-
var ColorModifierTypes;
|
|
945
|
-
(function(ColorModifierTypes2) {
|
|
946
|
-
ColorModifierTypes2["LIGHTEN"] = "lighten";
|
|
947
|
-
ColorModifierTypes2["DARKEN"] = "darken";
|
|
948
|
-
ColorModifierTypes2["MIX"] = "mix";
|
|
949
|
-
ColorModifierTypes2["ALPHA"] = "alpha";
|
|
950
|
-
})(ColorModifierTypes || (ColorModifierTypes = {}));
|
|
951
|
-
|
|
952
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
|
|
953
|
-
var ColorSpaceTypes;
|
|
954
|
-
(function(ColorSpaceTypes2) {
|
|
955
|
-
ColorSpaceTypes2["LCH"] = "lch";
|
|
956
|
-
ColorSpaceTypes2["SRGB"] = "srgb";
|
|
957
|
-
ColorSpaceTypes2["P3"] = "p3";
|
|
958
|
-
ColorSpaceTypes2["HSL"] = "hsl";
|
|
959
|
-
})(ColorSpaceTypes || (ColorSpaceTypes = {}));
|
|
960
|
-
|
|
961
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js
|
|
962
|
-
var Properties;
|
|
963
|
-
(function(Properties2) {
|
|
964
|
-
Properties2["sizing"] = "sizing";
|
|
965
|
-
Properties2["height"] = "height";
|
|
966
|
-
Properties2["width"] = "width";
|
|
967
|
-
Properties2["spacing"] = "spacing";
|
|
968
|
-
Properties2["verticalPadding"] = "verticalPadding";
|
|
969
|
-
Properties2["horizontalPadding"] = "horizontalPadding";
|
|
970
|
-
Properties2["paddingTop"] = "paddingTop";
|
|
971
|
-
Properties2["paddingRight"] = "paddingRight";
|
|
972
|
-
Properties2["paddingBottom"] = "paddingBottom";
|
|
973
|
-
Properties2["paddingLeft"] = "paddingLeft";
|
|
974
|
-
Properties2["itemSpacing"] = "itemSpacing";
|
|
975
|
-
Properties2["fill"] = "fill";
|
|
976
|
-
Properties2["backgroundBlur"] = "backgroundBlur";
|
|
977
|
-
Properties2["border"] = "border";
|
|
978
|
-
Properties2["borderTop"] = "borderTop";
|
|
979
|
-
Properties2["borderRight"] = "borderRight";
|
|
980
|
-
Properties2["borderBottom"] = "borderBottom";
|
|
981
|
-
Properties2["borderLeft"] = "borderLeft";
|
|
982
|
-
Properties2["borderColor"] = "borderColor";
|
|
983
|
-
Properties2["borderRadius"] = "borderRadius";
|
|
984
|
-
Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
|
|
985
|
-
Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
|
|
986
|
-
Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
|
|
987
|
-
Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
|
|
988
|
-
Properties2["borderWidth"] = "borderWidth";
|
|
989
|
-
Properties2["borderWidthTop"] = "borderWidthTop";
|
|
990
|
-
Properties2["borderWidthRight"] = "borderWidthRight";
|
|
991
|
-
Properties2["borderWidthBottom"] = "borderWidthBottom";
|
|
992
|
-
Properties2["borderWidthLeft"] = "borderWidthLeft";
|
|
993
|
-
Properties2["boxShadow"] = "boxShadow";
|
|
994
|
-
Properties2["opacity"] = "opacity";
|
|
995
|
-
Properties2["fontFamilies"] = "fontFamilies";
|
|
996
|
-
Properties2["fontWeights"] = "fontWeights";
|
|
997
|
-
Properties2["fontSizes"] = "fontSizes";
|
|
998
|
-
Properties2["lineHeights"] = "lineHeights";
|
|
999
|
-
Properties2["typography"] = "typography";
|
|
1000
|
-
Properties2["composition"] = "composition";
|
|
1001
|
-
Properties2["letterSpacing"] = "letterSpacing";
|
|
1002
|
-
Properties2["paragraphSpacing"] = "paragraphSpacing";
|
|
1003
|
-
Properties2["textCase"] = "textCase";
|
|
1004
|
-
Properties2["dimension"] = "dimension";
|
|
1005
|
-
Properties2["textDecoration"] = "textDecoration";
|
|
1006
|
-
Properties2["asset"] = "asset";
|
|
1007
|
-
Properties2["tokenValue"] = "tokenValue";
|
|
1008
|
-
Properties2["value"] = "value";
|
|
1009
|
-
Properties2["tokenName"] = "tokenName";
|
|
1010
|
-
Properties2["description"] = "description";
|
|
1011
|
-
})(Properties || (Properties = {}));
|
|
1012
|
-
|
|
1013
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
|
|
1014
|
-
var TokenSetStatus;
|
|
1015
|
-
(function(TokenSetStatus2) {
|
|
1016
|
-
TokenSetStatus2["DISABLED"] = "disabled";
|
|
1017
|
-
TokenSetStatus2["SOURCE"] = "source";
|
|
1018
|
-
TokenSetStatus2["ENABLED"] = "enabled";
|
|
1019
|
-
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
1020
|
-
|
|
1021
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
|
|
1022
|
-
var TokenTypes;
|
|
1023
|
-
(function(TokenTypes2) {
|
|
1024
|
-
TokenTypes2["OTHER"] = "other";
|
|
1025
|
-
TokenTypes2["COLOR"] = "color";
|
|
1026
|
-
TokenTypes2["BORDER_RADIUS"] = "borderRadius";
|
|
1027
|
-
TokenTypes2["SIZING"] = "sizing";
|
|
1028
|
-
TokenTypes2["SPACING"] = "spacing";
|
|
1029
|
-
TokenTypes2["TEXT"] = "text";
|
|
1030
|
-
TokenTypes2["TYPOGRAPHY"] = "typography";
|
|
1031
|
-
TokenTypes2["OPACITY"] = "opacity";
|
|
1032
|
-
TokenTypes2["BORDER_WIDTH"] = "borderWidth";
|
|
1033
|
-
TokenTypes2["STROKE_STYLE"] = "strokeStyle";
|
|
1034
|
-
TokenTypes2["BOX_SHADOW"] = "boxShadow";
|
|
1035
|
-
TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
|
|
1036
|
-
TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
|
|
1037
|
-
TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
|
|
1038
|
-
TokenTypes2["FONT_SIZES"] = "fontSizes";
|
|
1039
|
-
TokenTypes2["LETTER_SPACING"] = "letterSpacing";
|
|
1040
|
-
TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
1041
|
-
TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
1042
|
-
TokenTypes2["TEXT_DECORATION"] = "textDecoration";
|
|
1043
|
-
TokenTypes2["TEXT_CASE"] = "textCase";
|
|
1044
|
-
TokenTypes2["COMPOSITION"] = "composition";
|
|
1045
|
-
TokenTypes2["DIMENSION"] = "dimension";
|
|
1046
|
-
TokenTypes2["BORDER"] = "border";
|
|
1047
|
-
TokenTypes2["ASSET"] = "asset";
|
|
1048
|
-
TokenTypes2["BOOLEAN"] = "boolean";
|
|
1049
|
-
TokenTypes2["NUMBER"] = "number";
|
|
1050
|
-
})(TokenTypes || (TokenTypes = {}));
|
|
1051
|
-
|
|
1052
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js
|
|
1053
|
-
var BorderValues;
|
|
1054
|
-
(function(BorderValues2) {
|
|
1055
|
-
BorderValues2["BORDER_COLOR"] = "color";
|
|
1056
|
-
BorderValues2["BORDER_WIDTH"] = "width";
|
|
1057
|
-
BorderValues2["BORDER_STYLE"] = "style";
|
|
1058
|
-
})(BorderValues || (BorderValues = {}));
|
|
1059
|
-
|
|
1060
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
|
|
1061
|
-
var StrokeStyleValues;
|
|
1062
|
-
(function(StrokeStyleValues2) {
|
|
1063
|
-
StrokeStyleValues2["SOLID"] = "solid";
|
|
1064
|
-
StrokeStyleValues2["DASHED"] = "dashed";
|
|
1065
|
-
StrokeStyleValues2["DOTTED"] = "dotted";
|
|
1066
|
-
StrokeStyleValues2["DOUBLE"] = "double";
|
|
1067
|
-
StrokeStyleValues2["GROOVE"] = "groove";
|
|
1068
|
-
StrokeStyleValues2["RIDGE"] = "ridge";
|
|
1069
|
-
StrokeStyleValues2["OUTSET"] = "outset";
|
|
1070
|
-
StrokeStyleValues2["INSET"] = "inset";
|
|
1071
|
-
})(StrokeStyleValues || (StrokeStyleValues = {}));
|
|
1072
|
-
|
|
1073
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
|
|
1074
|
-
var BoxShadowValues;
|
|
1075
|
-
(function(BoxShadowValues2) {
|
|
1076
|
-
BoxShadowValues2["TYPE"] = "type";
|
|
1077
|
-
BoxShadowValues2["COLOR"] = "color";
|
|
1078
|
-
BoxShadowValues2["X"] = "x";
|
|
1079
|
-
BoxShadowValues2["Y"] = "y";
|
|
1080
|
-
BoxShadowValues2["BLUR"] = "blur";
|
|
1081
|
-
BoxShadowValues2["SPREAD"] = "spread";
|
|
1082
|
-
BoxShadowValues2["BLEND_MODE"] = "blendMode";
|
|
1083
|
-
})(BoxShadowValues || (BoxShadowValues = {}));
|
|
1084
|
-
|
|
1085
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
|
|
1086
|
-
var TypographyValues;
|
|
1087
|
-
(function(TypographyValues2) {
|
|
1088
|
-
TypographyValues2["FONT_FAMILY"] = "fontFamily";
|
|
1089
|
-
TypographyValues2["FONT_WEIGHT"] = "fontWeight";
|
|
1090
|
-
TypographyValues2["LINE_HEIGHT"] = "lineHeight";
|
|
1091
|
-
TypographyValues2["FONT_SIZE"] = "fontSize";
|
|
1092
|
-
TypographyValues2["LETTER_SPACING"] = "letterSpacing";
|
|
1093
|
-
TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
1094
|
-
TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
1095
|
-
TypographyValues2["TEXT_DECORATION"] = "textDecoration";
|
|
1096
|
-
TypographyValues2["TEXT_CASE"] = "textCase";
|
|
1097
|
-
})(TypographyValues || (TypographyValues = {}));
|
|
1098
|
-
|
|
1099
|
-
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
1
|
+
import { version } from "../../../../package.js";
|
|
2
|
+
import { getCustomColors } from "../utils/getMultidimensionalThemes.js";
|
|
3
|
+
import { buildOptions } from "../platform.js";
|
|
1100
4
|
import pc from "picocolors";
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
StyleDictionary.registerTransform(sizeRem);
|
|
1113
|
-
StyleDictionary.registerTransform(typographyName);
|
|
1114
|
-
StyleDictionary.registerTransform(resolveMath);
|
|
1115
|
-
StyleDictionary.registerTransform(unitless);
|
|
1116
|
-
for (const format of Object.values(formats)) {
|
|
1117
|
-
StyleDictionary.registerFormat(format);
|
|
1118
|
-
}
|
|
1119
|
-
var configs = {
|
|
1120
|
-
colorSchemeVariables,
|
|
1121
|
-
mainColorVariables: colorCategoryVariables({ category: "main" }),
|
|
1122
|
-
supportColorVariables: colorCategoryVariables({ category: "support" }),
|
|
1123
|
-
neutralColorVariables: colorCategoryVariables({ category: "builtin", color: "neutral" }),
|
|
1124
|
-
successColorVariables: colorCategoryVariables({ category: "builtin", color: "success" }),
|
|
1125
|
-
dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
|
|
1126
|
-
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
1127
|
-
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
1128
|
-
sizeModeVariables,
|
|
1129
|
-
sizeVariables,
|
|
1130
|
-
typographyVariables,
|
|
1131
|
-
typeScaleVariables,
|
|
1132
|
-
semanticVariables
|
|
1133
|
-
};
|
|
1134
|
-
|
|
1135
|
-
// src/tokens/process/platform.ts
|
|
1136
|
-
var buildOptions = {
|
|
1137
|
-
verbose: false,
|
|
1138
|
-
processed$themes: [],
|
|
1139
|
-
buildTokenFormats: {}
|
|
1140
|
-
};
|
|
1141
|
-
var sd = new StyleDictionary2();
|
|
1142
|
-
var buildConfigs = {
|
|
1143
|
-
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
1144
|
-
sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
|
|
1145
|
-
size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
|
|
1146
|
-
typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
|
|
1147
|
-
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
1148
|
-
"main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
|
|
1149
|
-
"support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
|
|
1150
|
-
"neutral-color": {
|
|
1151
|
-
getConfig: configs.neutralColorVariables,
|
|
1152
|
-
dimensions: ["semantic"],
|
|
1153
|
-
log: ({ permutation: { theme } }) => `${theme} - neutral`
|
|
1154
|
-
},
|
|
1155
|
-
"success-color": {
|
|
1156
|
-
getConfig: configs.successColorVariables,
|
|
1157
|
-
dimensions: ["semantic"],
|
|
1158
|
-
log: ({ permutation: { theme } }) => `${theme} - success`
|
|
1159
|
-
},
|
|
1160
|
-
"danger-color": {
|
|
1161
|
-
getConfig: configs.dangerColorVariables,
|
|
1162
|
-
dimensions: ["semantic"],
|
|
1163
|
-
log: ({ permutation: { theme } }) => `${theme} - danger`
|
|
1164
|
-
},
|
|
1165
|
-
"warning-color": {
|
|
1166
|
-
getConfig: configs.warningColorVariables,
|
|
1167
|
-
dimensions: ["semantic"],
|
|
1168
|
-
log: ({ permutation: { theme } }) => `${theme} - warning`
|
|
1169
|
-
},
|
|
1170
|
-
"info-color": {
|
|
1171
|
-
getConfig: configs.infoColorVariables,
|
|
1172
|
-
dimensions: ["semantic"],
|
|
1173
|
-
log: ({ permutation: { theme } }) => `${theme} - info`
|
|
1174
|
-
},
|
|
1175
|
-
semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
|
|
1176
|
-
};
|
|
1177
|
-
|
|
1178
|
-
// src/tokens/process/output/declarations.ts
|
|
1179
|
-
var defaultFileHeader = `build: v${package_default.version}`;
|
|
1180
|
-
var createTypeDeclarationFiles = (processed$themes) => {
|
|
1181
|
-
const colorGroups = buildOptions?.colorGroups || [];
|
|
1182
|
-
const customColors = getCustomColors(processed$themes, colorGroups);
|
|
1183
|
-
const typeDeclaration = createColorTypeDeclaration([...customColors, "neutral"]);
|
|
1184
|
-
return [
|
|
1185
|
-
{
|
|
1186
|
-
output: `/* This file is deprecated and will be removed in a future release. Use types.d.ts instead */
|
|
1187
|
-
${typeDeclaration}`,
|
|
1188
|
-
destination: "colors.d.ts"
|
|
1189
|
-
},
|
|
1190
|
-
{
|
|
1191
|
-
output: typeDeclaration,
|
|
1192
|
-
destination: "types.d.ts"
|
|
1193
|
-
}
|
|
1194
|
-
];
|
|
5
|
+
//#region src/tokens/process/output/declarations.ts
|
|
6
|
+
const defaultFileHeader = `build: v${version}`;
|
|
7
|
+
const createTypeDeclarationFiles = (processed$themes) => {
|
|
8
|
+
const typeDeclaration = createColorTypeDeclaration([...getCustomColors(processed$themes, buildOptions?.colorGroups || []), "neutral"]);
|
|
9
|
+
return [{
|
|
10
|
+
output: `/* This file is deprecated and will be removed in a future release. Use types.d.ts instead */\n${typeDeclaration}`,
|
|
11
|
+
destination: "colors.d.ts"
|
|
12
|
+
}, {
|
|
13
|
+
output: typeDeclaration,
|
|
14
|
+
destination: "types.d.ts"
|
|
15
|
+
}];
|
|
1195
16
|
};
|
|
1196
17
|
function createColorTypeDeclaration(colors) {
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
const typeDeclaration = `
|
|
18
|
+
console.log(`\nš± Building ${pc.green("type declarations")}`);
|
|
19
|
+
return `
|
|
1200
20
|
/* ${defaultFileHeader} */
|
|
1201
21
|
import type {} from '@digdir/designsystemet-types';
|
|
1202
22
|
|
|
@@ -1213,9 +33,6 @@ ${colors.map((color) => ` ${color.includes("-") ? `'${color}'` : color}: neve
|
|
|
1213
33
|
}
|
|
1214
34
|
}
|
|
1215
35
|
`.trimStart();
|
|
1216
|
-
return typeDeclaration;
|
|
1217
36
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
defaultFileHeader
|
|
1221
|
-
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { createTypeDeclarationFiles, defaultFileHeader };
|