@digdir/designsystemet 1.0.8 → 1.1.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 +20 -19
- package/dist/bin/designsystemet.js +421 -359
- package/dist/src/colors/index.d.ts +2 -2
- package/dist/src/colors/index.d.ts.map +1 -1
- package/dist/src/colors/index.js +143 -143
- package/dist/src/colors/theme.d.ts +1 -2
- package/dist/src/colors/theme.d.ts.map +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +20 -19
- package/dist/src/index.js +394 -394
- package/dist/src/scripts/createJsonSchema.js +19 -19
- package/dist/src/scripts/update-template.d.ts.map +1 -1
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +89 -28
- package/dist/src/tokens/create/generators/$designsystemet.js +12 -13
- package/dist/src/tokens/create/generators/color.js +21 -21
- package/dist/src/tokens/create/write.js +13 -14
- package/dist/src/tokens/create.d.ts +1 -0
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +22 -21
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +883 -884
- package/dist/src/tokens/index.d.ts +2 -2
- package/dist/src/tokens/index.d.ts.map +1 -1
- package/dist/src/tokens/index.js +271 -271
- package/dist/src/tokens/process/configs/color.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/color.js +5 -5
- package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/semantic.js +5 -5
- package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/storefront.js +1 -1
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/typography.js +5 -5
- package/dist/src/tokens/process/configs.d.ts.map +1 -1
- package/dist/src/tokens/process/configs.js +5 -5
- package/dist/src/tokens/process/formats/css/color.js +2 -2
- package/dist/src/tokens/process/formats/css/semantic.js +2 -2
- package/dist/src/tokens/process/formats/css/typography.js +1 -1
- package/dist/src/tokens/process/formats/css.js +5 -5
- package/dist/src/tokens/process/formats/js-tokens.js +1 -1
- package/dist/src/tokens/process/output/tailwind.d.ts +3 -0
- package/dist/src/tokens/process/output/tailwind.d.ts.map +1 -0
- package/dist/src/tokens/process/output/tailwind.js +59 -0
- package/dist/src/tokens/process/{theme.d.ts → output/theme.d.ts} +2 -2
- package/dist/src/tokens/process/output/theme.d.ts.map +1 -0
- package/dist/src/tokens/process/{theme.js → output/theme.js} +15 -16
- package/dist/src/tokens/process/platform.d.ts +3 -1
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +5 -5
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +5 -5
- package/dist/src/tokens/types.d.ts +1 -1
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/package.json +12 -13
- package/dist/src/tokens/process/theme.d.ts.map +0 -1
package/dist/src/tokens/index.js
CHANGED
|
@@ -992,27 +992,6 @@ var getDefaultToken = (tokenPath) => {
|
|
|
992
992
|
// src/tokens/create/generators/color.ts
|
|
993
993
|
import * as R4 from "ramda";
|
|
994
994
|
|
|
995
|
-
// src/colors/utils.ts
|
|
996
|
-
import chroma from "chroma-js";
|
|
997
|
-
import Colorjs from "colorjs.io";
|
|
998
|
-
import { Hsluv } from "hsluv";
|
|
999
|
-
var getLuminanceFromLightness = (lightness) => {
|
|
1000
|
-
const conv = new Hsluv();
|
|
1001
|
-
conv.hsluv_l = lightness;
|
|
1002
|
-
conv.hsluvToHex();
|
|
1003
|
-
return chroma(conv.hex).luminance();
|
|
1004
|
-
};
|
|
1005
|
-
var getLightnessFromHex = (hex) => {
|
|
1006
|
-
const conv = new Hsluv();
|
|
1007
|
-
conv.hex = hex;
|
|
1008
|
-
conv.hexToHsluv();
|
|
1009
|
-
return conv.hsluv_l;
|
|
1010
|
-
};
|
|
1011
|
-
|
|
1012
|
-
// src/colors/theme.ts
|
|
1013
|
-
import chroma2 from "chroma-js";
|
|
1014
|
-
import * as R3 from "ramda";
|
|
1015
|
-
|
|
1016
995
|
// src/colors/colorMetadata.ts
|
|
1017
996
|
import * as R2 from "ramda";
|
|
1018
997
|
var baseColors = {
|
|
@@ -1266,6 +1245,27 @@ var colorMetadata = {
|
|
|
1266
1245
|
};
|
|
1267
1246
|
var colorMetadataByNumber = R2.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
1268
1247
|
|
|
1248
|
+
// src/colors/theme.ts
|
|
1249
|
+
import chroma2 from "chroma-js";
|
|
1250
|
+
import * as R3 from "ramda";
|
|
1251
|
+
|
|
1252
|
+
// src/colors/utils.ts
|
|
1253
|
+
import chroma from "chroma-js";
|
|
1254
|
+
import Colorjs from "colorjs.io";
|
|
1255
|
+
import { Hsluv } from "hsluv";
|
|
1256
|
+
var getLuminanceFromLightness = (lightness) => {
|
|
1257
|
+
const conv = new Hsluv();
|
|
1258
|
+
conv.hsluv_l = lightness;
|
|
1259
|
+
conv.hsluvToHex();
|
|
1260
|
+
return chroma(conv.hex).luminance();
|
|
1261
|
+
};
|
|
1262
|
+
var getLightnessFromHex = (hex) => {
|
|
1263
|
+
const conv = new Hsluv();
|
|
1264
|
+
conv.hex = hex;
|
|
1265
|
+
conv.hexToHsluv();
|
|
1266
|
+
return conv.hsluv_l;
|
|
1267
|
+
};
|
|
1268
|
+
|
|
1269
1269
|
// src/colors/theme.ts
|
|
1270
1270
|
var generateColorScale = (color, colorScheme2) => {
|
|
1271
1271
|
let interpolationColor = color;
|
|
@@ -2043,6 +2043,7 @@ var generateTypography = (themeName, { fontFamily }) => {
|
|
|
2043
2043
|
var cliOptions = {
|
|
2044
2044
|
outDir: "out-dir",
|
|
2045
2045
|
clean: "clean",
|
|
2046
|
+
tailwind: "tailwind",
|
|
2046
2047
|
theme: {
|
|
2047
2048
|
colors: {
|
|
2048
2049
|
main: "main-colors",
|
|
@@ -2421,9 +2422,176 @@ function generateTypographyGroup(themes) {
|
|
|
2421
2422
|
];
|
|
2422
2423
|
}
|
|
2423
2424
|
|
|
2425
|
+
// src/tokens/process/output/theme.ts
|
|
2426
|
+
import chalk from "chalk";
|
|
2427
|
+
import * as R7 from "ramda";
|
|
2428
|
+
|
|
2429
|
+
// package.json
|
|
2430
|
+
var package_default = {
|
|
2431
|
+
name: "@digdir/designsystemet",
|
|
2432
|
+
version: "1.1.0",
|
|
2433
|
+
description: "CLI for Designsystemet",
|
|
2434
|
+
author: "Designsystemet team",
|
|
2435
|
+
engines: {
|
|
2436
|
+
node: ">=22.16.0"
|
|
2437
|
+
},
|
|
2438
|
+
repository: {
|
|
2439
|
+
type: "git",
|
|
2440
|
+
url: "git+https://github.com/digdir/designsystemet.git"
|
|
2441
|
+
},
|
|
2442
|
+
homepage: "https://github.com/digdir/designsystemet/tree/main/packages/cli",
|
|
2443
|
+
license: "MIT",
|
|
2444
|
+
type: "module",
|
|
2445
|
+
main: "./dist/src/index.js",
|
|
2446
|
+
files: [
|
|
2447
|
+
"./dist/**",
|
|
2448
|
+
"./configs/**"
|
|
2449
|
+
],
|
|
2450
|
+
bin: "dist/bin/designsystemet.js",
|
|
2451
|
+
exports: {
|
|
2452
|
+
".": {
|
|
2453
|
+
import: "./dist/src/index.js"
|
|
2454
|
+
},
|
|
2455
|
+
"./color": {
|
|
2456
|
+
import: "./dist/src/colors/index.js"
|
|
2457
|
+
},
|
|
2458
|
+
"./tokens": {
|
|
2459
|
+
import: "./dist/src/tokens/index.js"
|
|
2460
|
+
}
|
|
2461
|
+
},
|
|
2462
|
+
publishConfig: {
|
|
2463
|
+
access: "public"
|
|
2464
|
+
},
|
|
2465
|
+
scripts: {
|
|
2466
|
+
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
2467
|
+
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
2468
|
+
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
2469
|
+
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
2470
|
+
types: "tsc --noEmit",
|
|
2471
|
+
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
|
|
2472
|
+
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
|
|
2473
|
+
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
2474
|
+
"test:tokens-build-tailwind": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean --experimental-tailwind",
|
|
2475
|
+
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
2476
|
+
"test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
|
|
2477
|
+
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
2478
|
+
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
2479
|
+
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
2480
|
+
"digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
|
|
2481
|
+
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
2482
|
+
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
2483
|
+
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
|
|
2484
|
+
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
2485
|
+
},
|
|
2486
|
+
dependencies: {
|
|
2487
|
+
"@commander-js/extra-typings": "^14.0.0",
|
|
2488
|
+
"@tokens-studio/sd-transforms": "1.3.0",
|
|
2489
|
+
"apca-w3": "^0.1.9",
|
|
2490
|
+
chalk: "^5.4.1",
|
|
2491
|
+
"change-case": "^5.4.4",
|
|
2492
|
+
"chroma-js": "^3.1.2",
|
|
2493
|
+
"colorjs.io": "^0.6.0-alpha.1",
|
|
2494
|
+
commander: "^13.1.0",
|
|
2495
|
+
"fast-glob": "^3.3.3",
|
|
2496
|
+
hsluv: "^1.0.1",
|
|
2497
|
+
"object-hash": "^3.0.0",
|
|
2498
|
+
postcss: "^8.5.5",
|
|
2499
|
+
ramda: "^0.30.1",
|
|
2500
|
+
"style-dictionary": "^4.4.0",
|
|
2501
|
+
zod: "^3.25.64",
|
|
2502
|
+
"zod-validation-error": "^3.5.0"
|
|
2503
|
+
},
|
|
2504
|
+
devDependencies: {
|
|
2505
|
+
"@tokens-studio/types": "0.5.2",
|
|
2506
|
+
"@types/apca-w3": "^0.1.3",
|
|
2507
|
+
"@types/chroma-js": "^3.1.1",
|
|
2508
|
+
"@types/fs-extra": "^11.0.4",
|
|
2509
|
+
"@types/glob": "^8.1.0",
|
|
2510
|
+
"@types/node": "^22.15.31",
|
|
2511
|
+
"@types/object-hash": "^3.0.6",
|
|
2512
|
+
"@types/ramda": "^0.30.2",
|
|
2513
|
+
"fs-extra": "^11.3.0",
|
|
2514
|
+
tslib: "^2.8.1",
|
|
2515
|
+
tsup: "^8.5.0",
|
|
2516
|
+
tsx: "^4.20.3",
|
|
2517
|
+
typescript: "^5.8.3"
|
|
2518
|
+
}
|
|
2519
|
+
};
|
|
2520
|
+
|
|
2521
|
+
// src/tokens/process/output/theme.ts
|
|
2522
|
+
var defaultFileHeader = `build: v${package_default.version}`;
|
|
2523
|
+
var createThemeCSSFiles = ({
|
|
2524
|
+
processedBuilds,
|
|
2525
|
+
fileHeader: fileHeader2 = defaultFileHeader
|
|
2526
|
+
}) => {
|
|
2527
|
+
const groupedByTheme = {};
|
|
2528
|
+
for (const [_, buildResults] of Object.entries(R7.dissoc("types", processedBuilds))) {
|
|
2529
|
+
for (const buildResult of buildResults) {
|
|
2530
|
+
const themeName = buildResult.permutation.theme;
|
|
2531
|
+
const newOutputs = buildResult.formatted;
|
|
2532
|
+
if (R7.isNotEmpty(newOutputs)) {
|
|
2533
|
+
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
2534
|
+
groupedByTheme[themeName] = R7.concat(currentOutputs, newOutputs);
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
const sortOrder = [
|
|
2539
|
+
"color-scheme/light",
|
|
2540
|
+
"typography/secondary",
|
|
2541
|
+
"semantic",
|
|
2542
|
+
"color-scheme/dark",
|
|
2543
|
+
"color-scheme/contrast",
|
|
2544
|
+
"typography/primary",
|
|
2545
|
+
"color/"
|
|
2546
|
+
];
|
|
2547
|
+
const sortByDefinedOrder = R7.sortBy((file) => {
|
|
2548
|
+
const filePath = file.destination || "";
|
|
2549
|
+
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
2550
|
+
if (sortElement.endsWith("/")) {
|
|
2551
|
+
return filePath.includes(sortElement);
|
|
2552
|
+
}
|
|
2553
|
+
return filePath.includes(`${sortElement}.css`);
|
|
2554
|
+
});
|
|
2555
|
+
if (sortIndex === -1) {
|
|
2556
|
+
console.error(
|
|
2557
|
+
chalk.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
|
|
2558
|
+
);
|
|
2559
|
+
console.log(
|
|
2560
|
+
chalk.dim(
|
|
2561
|
+
`
|
|
2562
|
+
The section will currently be added to the end of the entry file, but the exact
|
|
2563
|
+
order may change due to nondeterminism.`.trim()
|
|
2564
|
+
)
|
|
2565
|
+
);
|
|
2566
|
+
return Infinity;
|
|
2567
|
+
}
|
|
2568
|
+
return sortIndex;
|
|
2569
|
+
});
|
|
2570
|
+
const header = `@charset "UTF-8";
|
|
2571
|
+
/*
|
|
2572
|
+
${fileHeader2}
|
|
2573
|
+
*/
|
|
2574
|
+
|
|
2575
|
+
`;
|
|
2576
|
+
const sortAlphabetically = R7.sort(R7.ascend((x) => x.destination || ""));
|
|
2577
|
+
const pickOutputs = R7.map(R7.view(R7.lensProp("output")));
|
|
2578
|
+
const themeCSSFile = R7.pipe(
|
|
2579
|
+
sortAlphabetically,
|
|
2580
|
+
sortByDefinedOrder,
|
|
2581
|
+
pickOutputs,
|
|
2582
|
+
R7.join("\n"),
|
|
2583
|
+
(content) => header + content
|
|
2584
|
+
);
|
|
2585
|
+
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
2586
|
+
destination: `${theme}.css`,
|
|
2587
|
+
output: themeCSSFile(files)
|
|
2588
|
+
}));
|
|
2589
|
+
return themeCSSFiles;
|
|
2590
|
+
};
|
|
2591
|
+
|
|
2424
2592
|
// src/tokens/process/platform.ts
|
|
2425
|
-
import
|
|
2426
|
-
import * as
|
|
2593
|
+
import chalk3 from "chalk";
|
|
2594
|
+
import * as R19 from "ramda";
|
|
2427
2595
|
import StyleDictionary2 from "style-dictionary";
|
|
2428
2596
|
|
|
2429
2597
|
// src/tokens/types.ts
|
|
@@ -2434,30 +2602,30 @@ var colorCategories = {
|
|
|
2434
2602
|
|
|
2435
2603
|
// src/tokens/process/configs.ts
|
|
2436
2604
|
import { register } from "@tokens-studio/sd-transforms";
|
|
2437
|
-
import * as
|
|
2605
|
+
import * as R18 from "ramda";
|
|
2438
2606
|
import StyleDictionary from "style-dictionary";
|
|
2439
2607
|
|
|
2440
2608
|
// src/tokens/utils.ts
|
|
2441
|
-
import * as
|
|
2442
|
-
var mapToLowerCase =
|
|
2443
|
-
var hasAnyTruth =
|
|
2609
|
+
import * as R8 from "ramda";
|
|
2610
|
+
var mapToLowerCase = R8.map(R8.toLower);
|
|
2611
|
+
var hasAnyTruth = R8.any(R8.equals(true));
|
|
2444
2612
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2445
2613
|
var getValue = (token) => token.$value ?? token.value;
|
|
2446
|
-
var typeEquals =
|
|
2614
|
+
var typeEquals = R8.curry(
|
|
2447
2615
|
(types, token) => {
|
|
2448
|
-
if (
|
|
2616
|
+
if (R8.isNil(token)) {
|
|
2449
2617
|
return false;
|
|
2450
2618
|
}
|
|
2451
|
-
return
|
|
2619
|
+
return R8.includes(R8.toLower(getType(token)), R8.map(R8.toLower, Array.isArray(types) ? types : [types]));
|
|
2452
2620
|
}
|
|
2453
2621
|
);
|
|
2454
|
-
var pathStartsWithOneOf =
|
|
2622
|
+
var pathStartsWithOneOf = R8.curry(
|
|
2455
2623
|
(paths, token) => {
|
|
2456
|
-
if (
|
|
2624
|
+
if (R8.isNil(token)) {
|
|
2457
2625
|
return false;
|
|
2458
2626
|
}
|
|
2459
2627
|
const tokenPath = mapToLowerCase(token.path);
|
|
2460
|
-
const matchPathsStartingWith =
|
|
2628
|
+
const matchPathsStartingWith = R8.map((path) => R8.startsWith([path], tokenPath), mapToLowerCase(paths));
|
|
2461
2629
|
return hasAnyTruth(matchPathsStartingWith);
|
|
2462
2630
|
}
|
|
2463
2631
|
);
|
|
@@ -2465,7 +2633,7 @@ function isSemanticToken(token) {
|
|
|
2465
2633
|
return token.filePath.includes("semantic/");
|
|
2466
2634
|
}
|
|
2467
2635
|
function isSemanticColorToken(token, color) {
|
|
2468
|
-
return token.filePath.includes("semantic/") &&
|
|
2636
|
+
return token.filePath.includes("semantic/") && R8.startsWith(["color", color], token.path);
|
|
2469
2637
|
}
|
|
2470
2638
|
function isGlobalColorToken(token) {
|
|
2471
2639
|
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
@@ -2476,7 +2644,7 @@ function isColorCategoryToken(token, category) {
|
|
|
2476
2644
|
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
2477
2645
|
);
|
|
2478
2646
|
}
|
|
2479
|
-
return
|
|
2647
|
+
return R8.startsWith(["color", category], token.path);
|
|
2480
2648
|
}
|
|
2481
2649
|
var isDigit = (s) => /^\d+$/.test(s);
|
|
2482
2650
|
function traverseObj(obj, fn) {
|
|
@@ -2492,7 +2660,7 @@ function traverseObj(obj, fn) {
|
|
|
2492
2660
|
return obj;
|
|
2493
2661
|
}
|
|
2494
2662
|
function inlineTokens(shouldInline, tokens) {
|
|
2495
|
-
const [inlineableTokens, otherTokens] =
|
|
2663
|
+
const [inlineableTokens, otherTokens] = R8.partition(shouldInline, tokens);
|
|
2496
2664
|
return otherTokens.map((token) => {
|
|
2497
2665
|
let transformed = getValue(token.original);
|
|
2498
2666
|
for (const ref of inlineableTokens) {
|
|
@@ -2501,16 +2669,16 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
2501
2669
|
transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
|
|
2502
2670
|
}
|
|
2503
2671
|
}
|
|
2504
|
-
const tokenWithInlinedRefs =
|
|
2672
|
+
const tokenWithInlinedRefs = R8.set(R8.lensPath(["original", "$value"]), transformed, token);
|
|
2505
2673
|
return tokenWithInlinedRefs;
|
|
2506
2674
|
});
|
|
2507
2675
|
}
|
|
2508
2676
|
|
|
2509
2677
|
// src/tokens/process/configs/color.ts
|
|
2510
|
-
import * as
|
|
2678
|
+
import * as R13 from "ramda";
|
|
2511
2679
|
|
|
2512
2680
|
// src/tokens/process/formats/css/color.ts
|
|
2513
|
-
import * as
|
|
2681
|
+
import * as R9 from "ramda";
|
|
2514
2682
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
2515
2683
|
var prefersColorScheme = (colorScheme2, content) => `
|
|
2516
2684
|
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
@@ -2519,7 +2687,7 @@ var prefersColorScheme = (colorScheme2, content) => `
|
|
|
2519
2687
|
`;
|
|
2520
2688
|
var colorScheme = {
|
|
2521
2689
|
name: "ds/css-colorscheme",
|
|
2522
|
-
format: async ({ dictionary,
|
|
2690
|
+
format: async ({ dictionary, options, platform }) => {
|
|
2523
2691
|
const { allTokens } = dictionary;
|
|
2524
2692
|
const { outputReferences, usesDtcg } = options;
|
|
2525
2693
|
const { selector, colorScheme: colorScheme2, layer } = platform;
|
|
@@ -2534,8 +2702,8 @@ var colorScheme = {
|
|
|
2534
2702
|
color-scheme: ${colorScheme_};
|
|
2535
2703
|
` : "";
|
|
2536
2704
|
const filteredAllTokens = allTokens.filter(
|
|
2537
|
-
|
|
2538
|
-
|
|
2705
|
+
R9.allPass([
|
|
2706
|
+
R9.anyPass([
|
|
2539
2707
|
// Include semantic tokens in the output
|
|
2540
2708
|
isSemanticToken,
|
|
2541
2709
|
// Include global color tokens
|
|
@@ -2551,7 +2719,7 @@ ${formattedTokens}
|
|
|
2551
2719
|
${colorSchemeProperty}}
|
|
2552
2720
|
`;
|
|
2553
2721
|
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
2554
|
-
const body =
|
|
2722
|
+
const body = R9.isNotNil(layer) ? `@layer ${layer} {
|
|
2555
2723
|
${selector} ${content} ${autoSelectorContent}
|
|
2556
2724
|
}
|
|
2557
2725
|
` : `${selector} ${content} ${autoSelectorContent}
|
|
@@ -2561,10 +2729,10 @@ ${selector} ${content} ${autoSelectorContent}
|
|
|
2561
2729
|
};
|
|
2562
2730
|
var colorCategory = {
|
|
2563
2731
|
name: "ds/css-colorcategory",
|
|
2564
|
-
format: async ({ dictionary,
|
|
2732
|
+
format: async ({ dictionary, options, platform }) => {
|
|
2565
2733
|
const { outputReferences, usesDtcg } = options;
|
|
2566
2734
|
const { selector, layer } = platform;
|
|
2567
|
-
const format =
|
|
2735
|
+
const format = R9.compose(
|
|
2568
2736
|
createPropertyFormatter({
|
|
2569
2737
|
outputReferences,
|
|
2570
2738
|
dictionary,
|
|
@@ -2585,7 +2753,7 @@ var colorCategory = {
|
|
|
2585
2753
|
${formattedTokens}
|
|
2586
2754
|
}
|
|
2587
2755
|
`;
|
|
2588
|
-
const body =
|
|
2756
|
+
const body = R9.isNotNil(layer) ? `@layer ${layer} {
|
|
2589
2757
|
${selector} ${content}
|
|
2590
2758
|
}
|
|
2591
2759
|
` : `${selector} ${content}
|
|
@@ -2595,16 +2763,16 @@ ${selector} ${content}
|
|
|
2595
2763
|
};
|
|
2596
2764
|
|
|
2597
2765
|
// src/tokens/process/formats/css/semantic.ts
|
|
2598
|
-
import * as
|
|
2766
|
+
import * as R10 from "ramda";
|
|
2599
2767
|
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
2600
2768
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
2601
2769
|
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
2602
2770
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
2603
|
-
var isInlineTokens =
|
|
2771
|
+
var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
2604
2772
|
var overrideSizingFormula = (format, token) => {
|
|
2605
2773
|
const [name, value] = format(token).split(":");
|
|
2606
2774
|
const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
|
|
2607
|
-
const round = `round(down, ${calc},
|
|
2775
|
+
const round = `round(down, ${calc}, 1px)`;
|
|
2608
2776
|
return {
|
|
2609
2777
|
name,
|
|
2610
2778
|
round,
|
|
@@ -2612,7 +2780,7 @@ var overrideSizingFormula = (format, token) => {
|
|
|
2612
2780
|
};
|
|
2613
2781
|
};
|
|
2614
2782
|
var formatSizingTokens = (format, tokens) => {
|
|
2615
|
-
const { round, calc } =
|
|
2783
|
+
const { round, calc } = R10.reduce(
|
|
2616
2784
|
(acc, token) => {
|
|
2617
2785
|
const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
|
|
2618
2786
|
return {
|
|
@@ -2632,7 +2800,7 @@ ${round.join("\n")}
|
|
|
2632
2800
|
};
|
|
2633
2801
|
var semantic = {
|
|
2634
2802
|
name: "ds/css-semantic",
|
|
2635
|
-
format: async ({ dictionary,
|
|
2803
|
+
format: async ({ dictionary, options, platform }) => {
|
|
2636
2804
|
const { outputReferences, usesDtcg } = options;
|
|
2637
2805
|
const { selector, layer } = platform;
|
|
2638
2806
|
const format = createPropertyFormatter2({
|
|
@@ -2642,17 +2810,17 @@ var semantic = {
|
|
|
2642
2810
|
usesDtcg
|
|
2643
2811
|
});
|
|
2644
2812
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2645
|
-
const filteredTokens =
|
|
2646
|
-
const [sizingTokens, restTokens] =
|
|
2813
|
+
const filteredTokens = R10.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
|
|
2814
|
+
const [sizingTokens, restTokens] = R10.partition(
|
|
2647
2815
|
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
2648
2816
|
filteredTokens
|
|
2649
2817
|
);
|
|
2650
|
-
const formattedTokens = [
|
|
2818
|
+
const formattedTokens = [R10.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
|
|
2651
2819
|
const content = `{
|
|
2652
2820
|
${formattedTokens.join("\n")}
|
|
2653
2821
|
}
|
|
2654
2822
|
`;
|
|
2655
|
-
const body =
|
|
2823
|
+
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
2656
2824
|
${selector} ${content}
|
|
2657
2825
|
}
|
|
2658
2826
|
` : `${selector} ${content}
|
|
@@ -2662,15 +2830,15 @@ ${selector} ${content}
|
|
|
2662
2830
|
};
|
|
2663
2831
|
|
|
2664
2832
|
// src/tokens/process/formats/css/typography.ts
|
|
2665
|
-
import * as
|
|
2833
|
+
import * as R11 from "ramda";
|
|
2666
2834
|
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
2667
|
-
var typographyFontFamilyPredicate =
|
|
2668
|
-
|
|
2669
|
-
|
|
2835
|
+
var typographyFontFamilyPredicate = R11.allPass([
|
|
2836
|
+
R11.pathSatisfies(R11.includes("typography"), ["path"]),
|
|
2837
|
+
R11.pathSatisfies(R11.includes("fontFamily"), ["path"])
|
|
2670
2838
|
]);
|
|
2671
2839
|
var typography = {
|
|
2672
2840
|
name: "ds/css-typography",
|
|
2673
|
-
format: async ({ dictionary,
|
|
2841
|
+
format: async ({ dictionary, options, platform }) => {
|
|
2674
2842
|
const { outputReferences, usesDtcg } = options;
|
|
2675
2843
|
const { selector, layer } = platform;
|
|
2676
2844
|
const format = createPropertyFormatter3({
|
|
@@ -2679,12 +2847,12 @@ var typography = {
|
|
|
2679
2847
|
format: "css",
|
|
2680
2848
|
usesDtcg
|
|
2681
2849
|
});
|
|
2682
|
-
const filteredTokens =
|
|
2683
|
-
const formattedTokens =
|
|
2850
|
+
const filteredTokens = R11.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
2851
|
+
const formattedTokens = R11.pipe(R11.map(format), R11.join("\n"))(filteredTokens);
|
|
2684
2852
|
const content = selector ? `${selector} {
|
|
2685
2853
|
${formattedTokens}
|
|
2686
2854
|
}` : formattedTokens;
|
|
2687
|
-
const body =
|
|
2855
|
+
const body = R11.isNotNil(layer) ? `@layer ${layer} {
|
|
2688
2856
|
${content}
|
|
2689
2857
|
}` : content;
|
|
2690
2858
|
return body;
|
|
@@ -2701,8 +2869,8 @@ var formats = {
|
|
|
2701
2869
|
|
|
2702
2870
|
// src/tokens/process/transformers.ts
|
|
2703
2871
|
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
2704
|
-
import * as
|
|
2705
|
-
var isPx =
|
|
2872
|
+
import * as R12 from "ramda";
|
|
2873
|
+
var isPx = R12.test(/\b\d+px\b/g);
|
|
2706
2874
|
var sizeRem = {
|
|
2707
2875
|
name: "ds/size/toRem",
|
|
2708
2876
|
type: "value",
|
|
@@ -2792,7 +2960,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
|
|
|
2792
2960
|
{
|
|
2793
2961
|
destination: `color-scheme/${colorScheme2}.css`,
|
|
2794
2962
|
format: formats.colorScheme.name,
|
|
2795
|
-
filter: (token) => typeEquals("color", token) && !
|
|
2963
|
+
filter: (token) => typeEquals("color", token) && !R13.startsWith(["global"], token.path)
|
|
2796
2964
|
}
|
|
2797
2965
|
],
|
|
2798
2966
|
options: {
|
|
@@ -2843,7 +3011,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
2843
3011
|
};
|
|
2844
3012
|
|
|
2845
3013
|
// src/tokens/process/configs/semantic.ts
|
|
2846
|
-
import * as
|
|
3014
|
+
import * as R14 from "ramda";
|
|
2847
3015
|
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
2848
3016
|
var semanticVariables = ({ theme }) => {
|
|
2849
3017
|
const selector = `:root`;
|
|
@@ -2866,8 +3034,8 @@ var semanticVariables = ({ theme }) => {
|
|
|
2866
3034
|
destination: `semantic.css`,
|
|
2867
3035
|
format: formats.semantic.name,
|
|
2868
3036
|
filter: (token) => {
|
|
2869
|
-
const isUwantedToken =
|
|
2870
|
-
const isPrivateToken =
|
|
3037
|
+
const isUwantedToken = R14.anyPass([R14.includes("primitives/global")])(token.filePath);
|
|
3038
|
+
const isPrivateToken = R14.includes("_", token.path);
|
|
2871
3039
|
const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
|
|
2872
3040
|
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
2873
3041
|
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
@@ -2888,20 +3056,20 @@ var semanticVariables = ({ theme }) => {
|
|
|
2888
3056
|
};
|
|
2889
3057
|
|
|
2890
3058
|
// src/tokens/process/configs/storefront.ts
|
|
2891
|
-
import * as
|
|
3059
|
+
import * as R16 from "ramda";
|
|
2892
3060
|
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
2893
3061
|
|
|
2894
3062
|
// src/tokens/process/formats/js-tokens.ts
|
|
2895
|
-
import * as
|
|
3063
|
+
import * as R15 from "ramda";
|
|
2896
3064
|
import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
|
|
2897
|
-
var groupByType =
|
|
2898
|
-
var removeUnwatedTokens =
|
|
2899
|
-
|
|
2900
|
-
|
|
3065
|
+
var groupByType = R15.groupBy((token) => getType(token));
|
|
3066
|
+
var removeUnwatedTokens = R15.pipe(
|
|
3067
|
+
R15.reject((token) => isColorCategoryToken(token)),
|
|
3068
|
+
R15.reject((token) => R15.any((path) => path.startsWith("_"))(token.path))
|
|
2901
3069
|
);
|
|
2902
|
-
var dissocExtensions =
|
|
2903
|
-
var removeUnwatedProps =
|
|
2904
|
-
var toCssVarName =
|
|
3070
|
+
var dissocExtensions = R15.pipe(R15.dissoc("$extensions"), R15.dissocPath(["original", "$extensions"]));
|
|
3071
|
+
var removeUnwatedProps = R15.map((token) => dissocExtensions(token));
|
|
3072
|
+
var toCssVarName = R15.pipe(R15.split(":"), R15.head, R15.trim);
|
|
2905
3073
|
var jsTokens = {
|
|
2906
3074
|
name: "ds/js-tokens",
|
|
2907
3075
|
format: async ({ dictionary, file, options }) => {
|
|
@@ -2912,7 +3080,7 @@ var jsTokens = {
|
|
|
2912
3080
|
format: "css",
|
|
2913
3081
|
usesDtcg
|
|
2914
3082
|
});
|
|
2915
|
-
const formatTokens2 =
|
|
3083
|
+
const formatTokens2 = R15.map((token) => {
|
|
2916
3084
|
if (pathStartsWithOneOf(["size", "_size"], token)) {
|
|
2917
3085
|
const { calc, name } = overrideSizingFormula(format, token);
|
|
2918
3086
|
return {
|
|
@@ -2926,7 +3094,7 @@ var jsTokens = {
|
|
|
2926
3094
|
name: toCssVarName(format(token))
|
|
2927
3095
|
};
|
|
2928
3096
|
});
|
|
2929
|
-
const processTokens =
|
|
3097
|
+
const processTokens = R15.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens2, groupByType);
|
|
2930
3098
|
const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
|
|
2931
3099
|
const content = Object.entries(tokens).map(
|
|
2932
3100
|
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
@@ -2951,9 +3119,9 @@ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
|
|
|
2951
3119
|
destination: `${colorScheme2}.ts`,
|
|
2952
3120
|
format: jsTokens.name,
|
|
2953
3121
|
filter: (token) => {
|
|
2954
|
-
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !
|
|
3122
|
+
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R16.includes("semantic", token.filePath))
|
|
2955
3123
|
return false;
|
|
2956
|
-
const isSemanticColor =
|
|
3124
|
+
const isSemanticColor = R16.includes("semantic", token.filePath) && typeEquals(["color"], token);
|
|
2957
3125
|
const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
|
|
2958
3126
|
return isSemanticColor || wantedTypes;
|
|
2959
3127
|
}
|
|
@@ -3019,19 +3187,19 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3019
3187
|
};
|
|
3020
3188
|
|
|
3021
3189
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
3022
|
-
import
|
|
3190
|
+
import chalk2 from "chalk";
|
|
3023
3191
|
import { kebabCase } from "change-case";
|
|
3024
|
-
import * as
|
|
3192
|
+
import * as R17 from "ramda";
|
|
3025
3193
|
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
3026
3194
|
const verboseLogging = buildOptions?.verbose;
|
|
3027
3195
|
const grouped$themes = groupThemes(processed$themes);
|
|
3028
3196
|
const permutations = permutateThemes(grouped$themes);
|
|
3029
3197
|
const ALL_DEPENDENT_ON = ["theme"];
|
|
3030
|
-
const keys2 =
|
|
3198
|
+
const keys2 = R17.keys(grouped$themes);
|
|
3031
3199
|
const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
3032
3200
|
if (verboseLogging) {
|
|
3033
|
-
console.log(
|
|
3034
|
-
console.log(
|
|
3201
|
+
console.log(chalk2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
3202
|
+
console.log(chalk2.cyan(` (ignoring permutations for ${nonDependentKeys})`));
|
|
3035
3203
|
}
|
|
3036
3204
|
return permutations.filter((val) => {
|
|
3037
3205
|
const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
|
|
@@ -3067,7 +3235,7 @@ function groupThemes(themes) {
|
|
|
3067
3235
|
}
|
|
3068
3236
|
return groups;
|
|
3069
3237
|
}
|
|
3070
|
-
var hasUnknownProps =
|
|
3238
|
+
var hasUnknownProps = R17.pipe(R17.values, R17.none(R17.equals("unknown")), R17.not);
|
|
3071
3239
|
function permutateThemes(groups) {
|
|
3072
3240
|
const separator = "_";
|
|
3073
3241
|
const permutations = cartesian(Object.values(groups));
|
|
@@ -3077,8 +3245,8 @@ function permutateThemes(groups) {
|
|
|
3077
3245
|
const { group, name, selectedTokenSets } = theme;
|
|
3078
3246
|
let updatedPermutation = acc.permutation;
|
|
3079
3247
|
if (group) {
|
|
3080
|
-
const groupProp =
|
|
3081
|
-
updatedPermutation =
|
|
3248
|
+
const groupProp = R17.lensProp(group);
|
|
3249
|
+
updatedPermutation = R17.set(groupProp, name, updatedPermutation);
|
|
3082
3250
|
}
|
|
3083
3251
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3084
3252
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -3162,7 +3330,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3162
3330
|
obj.filePath = tokenSet;
|
|
3163
3331
|
}
|
|
3164
3332
|
});
|
|
3165
|
-
tokenSource.tokens =
|
|
3333
|
+
tokenSource.tokens = R18.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3166
3334
|
}
|
|
3167
3335
|
}
|
|
3168
3336
|
} else {
|
|
@@ -3259,35 +3427,35 @@ async function processPlatform(options) {
|
|
|
3259
3427
|
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3260
3428
|
if (UNSAFE_DEFAULT_COLOR) {
|
|
3261
3429
|
console.warn(
|
|
3262
|
-
|
|
3430
|
+
chalk3.yellow(
|
|
3263
3431
|
`
|
|
3264
|
-
\u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${
|
|
3432
|
+
\u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk3.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
|
|
3265
3433
|
)
|
|
3266
3434
|
);
|
|
3267
3435
|
}
|
|
3268
3436
|
const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
|
|
3269
3437
|
if (UNSAFE_COLOR_GROUPS.length > 0) {
|
|
3270
3438
|
console.warn(
|
|
3271
|
-
|
|
3439
|
+
chalk3.yellow(
|
|
3272
3440
|
`
|
|
3273
|
-
\u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${
|
|
3441
|
+
\u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk3.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
|
|
3274
3442
|
)
|
|
3275
3443
|
);
|
|
3276
3444
|
}
|
|
3277
3445
|
const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
|
|
3278
3446
|
buildOptions = options;
|
|
3279
3447
|
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3280
|
-
const processed$themes = $themes.map(processThemeObject).filter((theme) =>
|
|
3448
|
+
const processed$themes = $themes.map(processThemeObject).filter((theme) => R19.not(theme.group === "size" && theme.name !== "medium"));
|
|
3281
3449
|
const customColors = getCustomColors(processed$themes, colorGroups);
|
|
3282
3450
|
if (!buildOptions.defaultColor) {
|
|
3283
|
-
const firstMainColor =
|
|
3451
|
+
const firstMainColor = R19.head(customColors);
|
|
3284
3452
|
buildOptions.defaultColor = firstMainColor;
|
|
3285
3453
|
}
|
|
3286
3454
|
if (buildOptions.defaultColor) {
|
|
3287
3455
|
console.log(`
|
|
3288
|
-
\u{1F3A8} Using ${
|
|
3456
|
+
\u{1F3A8} Using ${chalk3.blue(buildOptions.defaultColor)} as default color`);
|
|
3289
3457
|
}
|
|
3290
|
-
const buildAndSdConfigs =
|
|
3458
|
+
const buildAndSdConfigs = R19.map((buildConfig) => {
|
|
3291
3459
|
const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
|
|
3292
3460
|
tokensDir,
|
|
3293
3461
|
tokenSets
|
|
@@ -3319,19 +3487,19 @@ async function processPlatform(options) {
|
|
|
3319
3487
|
types: [initResult]
|
|
3320
3488
|
};
|
|
3321
3489
|
try {
|
|
3322
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
3490
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R19.toPairs(buildAndSdConfigs)) {
|
|
3323
3491
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3324
3492
|
continue;
|
|
3325
3493
|
}
|
|
3326
3494
|
if (sdConfigs.length > 0) {
|
|
3327
3495
|
console.log(`
|
|
3328
|
-
\u{1F371} Building ${
|
|
3496
|
+
\u{1F371} Building ${chalk3.green(buildConfig.name ?? buildName)}`);
|
|
3329
3497
|
const results = await Promise.all(
|
|
3330
3498
|
sdConfigs.map(async (sdConfig) => {
|
|
3331
3499
|
const { config, permutation } = sdConfig;
|
|
3332
3500
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
3333
3501
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3334
|
-
const logMessage =
|
|
3502
|
+
const logMessage = R19.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3335
3503
|
console.log(logMessage);
|
|
3336
3504
|
const sdOptions = { cache: true };
|
|
3337
3505
|
const sdExtended = await sd.extend(config);
|
|
@@ -3363,7 +3531,7 @@ async function processPlatform(options) {
|
|
|
3363
3531
|
}
|
|
3364
3532
|
async function createColorTypeDeclaration(colors) {
|
|
3365
3533
|
console.log(`
|
|
3366
|
-
\u{1F371} Building ${
|
|
3534
|
+
\u{1F371} Building ${chalk3.green("type declarations")}`);
|
|
3367
3535
|
const typeDeclaration = `
|
|
3368
3536
|
import type {} from '@digdir/designsystemet-react/colors';
|
|
3369
3537
|
|
|
@@ -3376,174 +3544,6 @@ ${colors.map((color) => ` ${color}: never;`).join("\n")}
|
|
|
3376
3544
|
return typeDeclaration;
|
|
3377
3545
|
}
|
|
3378
3546
|
|
|
3379
|
-
// src/tokens/process/theme.ts
|
|
3380
|
-
import * as R19 from "ramda";
|
|
3381
|
-
import chalk3 from "chalk";
|
|
3382
|
-
|
|
3383
|
-
// package.json
|
|
3384
|
-
var package_default = {
|
|
3385
|
-
name: "@digdir/designsystemet",
|
|
3386
|
-
version: "1.0.8",
|
|
3387
|
-
description: "CLI for Designsystemet",
|
|
3388
|
-
author: "Designsystemet team",
|
|
3389
|
-
engines: {
|
|
3390
|
-
node: ">=22.16.0"
|
|
3391
|
-
},
|
|
3392
|
-
repository: {
|
|
3393
|
-
type: "git",
|
|
3394
|
-
url: "git+https://github.com/digdir/designsystemet.git"
|
|
3395
|
-
},
|
|
3396
|
-
homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
|
|
3397
|
-
license: "MIT",
|
|
3398
|
-
type: "module",
|
|
3399
|
-
main: "./dist/src/index.js",
|
|
3400
|
-
files: [
|
|
3401
|
-
"./dist/**",
|
|
3402
|
-
"./configs/**"
|
|
3403
|
-
],
|
|
3404
|
-
bin: "dist/bin/designsystemet.js",
|
|
3405
|
-
exports: {
|
|
3406
|
-
".": {
|
|
3407
|
-
import: "./dist/src/index.js"
|
|
3408
|
-
},
|
|
3409
|
-
"./color": {
|
|
3410
|
-
import: "./dist/src/colors/index.js"
|
|
3411
|
-
},
|
|
3412
|
-
"./tokens": {
|
|
3413
|
-
import: "./dist/src/tokens/index.js"
|
|
3414
|
-
}
|
|
3415
|
-
},
|
|
3416
|
-
publishConfig: {
|
|
3417
|
-
access: "public"
|
|
3418
|
-
},
|
|
3419
|
-
scripts: {
|
|
3420
|
-
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
3421
|
-
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
3422
|
-
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
3423
|
-
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
3424
|
-
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
3425
|
-
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
3426
|
-
types: "tsc --noEmit",
|
|
3427
|
-
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
|
|
3428
|
-
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
|
|
3429
|
-
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
3430
|
-
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
3431
|
-
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
3432
|
-
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
3433
|
-
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
3434
|
-
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
3435
|
-
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
3436
|
-
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
3437
|
-
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
3438
|
-
},
|
|
3439
|
-
dependencies: {
|
|
3440
|
-
"@commander-js/extra-typings": "^13.1.0",
|
|
3441
|
-
"@tokens-studio/sd-transforms": "1.3.0",
|
|
3442
|
-
"apca-w3": "^0.1.9",
|
|
3443
|
-
chalk: "^5.4.1",
|
|
3444
|
-
"change-case": "^5.4.4",
|
|
3445
|
-
"chroma-js": "^3.1.2",
|
|
3446
|
-
"colorjs.io": "^0.6.0-alpha.1",
|
|
3447
|
-
commander: "^13.1.0",
|
|
3448
|
-
"fast-glob": "^3.3.3",
|
|
3449
|
-
hsluv: "^1.0.1",
|
|
3450
|
-
"object-hash": "^3.0.0",
|
|
3451
|
-
postcss: "^8.5.3",
|
|
3452
|
-
ramda: "^0.30.1",
|
|
3453
|
-
"style-dictionary": "^4.4.0",
|
|
3454
|
-
zod: "^3.25.30",
|
|
3455
|
-
"zod-validation-error": "^3.4.1"
|
|
3456
|
-
},
|
|
3457
|
-
devDependencies: {
|
|
3458
|
-
"@tokens-studio/types": "0.5.2",
|
|
3459
|
-
"@types/apca-w3": "^0.1.3",
|
|
3460
|
-
"@types/chroma-js": "^3.1.1",
|
|
3461
|
-
"@types/fs-extra": "^11.0.4",
|
|
3462
|
-
"@types/glob": "^8.1.0",
|
|
3463
|
-
"@types/jscodeshift": "^0.12.0",
|
|
3464
|
-
"@types/node": "^22.15.21",
|
|
3465
|
-
"@types/object-hash": "^3.0.6",
|
|
3466
|
-
"@types/ramda": "^0.30.2",
|
|
3467
|
-
"fs-extra": "^11.3.0",
|
|
3468
|
-
"ts-toolbelt": "^9.6.0",
|
|
3469
|
-
tslib: "^2.8.1",
|
|
3470
|
-
tsup: "^8.5.0",
|
|
3471
|
-
tsx: "^4.19.4",
|
|
3472
|
-
typescript: "^5.8.3"
|
|
3473
|
-
}
|
|
3474
|
-
};
|
|
3475
|
-
|
|
3476
|
-
// src/tokens/process/theme.ts
|
|
3477
|
-
var defaultFileHeader = `build: v${package_default.version}`;
|
|
3478
|
-
var createThemeCSSFiles = ({
|
|
3479
|
-
processedBuilds,
|
|
3480
|
-
fileHeader: fileHeader2 = defaultFileHeader
|
|
3481
|
-
}) => {
|
|
3482
|
-
const groupedByTheme = {};
|
|
3483
|
-
for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
|
|
3484
|
-
for (const buildResult of buildResults) {
|
|
3485
|
-
const themeName = buildResult.permutation.theme;
|
|
3486
|
-
const newOutputs = buildResult.formatted;
|
|
3487
|
-
if (R19.isNotEmpty(newOutputs)) {
|
|
3488
|
-
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
3489
|
-
groupedByTheme[themeName] = R19.concat(currentOutputs, newOutputs);
|
|
3490
|
-
}
|
|
3491
|
-
}
|
|
3492
|
-
}
|
|
3493
|
-
const sortOrder = [
|
|
3494
|
-
"color-scheme/light",
|
|
3495
|
-
"typography/secondary",
|
|
3496
|
-
"semantic",
|
|
3497
|
-
"color-scheme/dark",
|
|
3498
|
-
"color-scheme/contrast",
|
|
3499
|
-
"typography/primary",
|
|
3500
|
-
"color/"
|
|
3501
|
-
];
|
|
3502
|
-
const sortByDefinedOrder = R19.sortBy((file) => {
|
|
3503
|
-
const filePath = file.destination || "";
|
|
3504
|
-
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
3505
|
-
if (sortElement.endsWith("/")) {
|
|
3506
|
-
return filePath.includes(sortElement);
|
|
3507
|
-
}
|
|
3508
|
-
return filePath.includes(`${sortElement}.css`);
|
|
3509
|
-
});
|
|
3510
|
-
if (sortIndex === -1) {
|
|
3511
|
-
console.error(
|
|
3512
|
-
chalk3.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
|
|
3513
|
-
);
|
|
3514
|
-
console.log(
|
|
3515
|
-
chalk3.dim(
|
|
3516
|
-
`
|
|
3517
|
-
The section will currently be added to the end of the entry file, but the exact
|
|
3518
|
-
order may change due to nondeterminism.`.trim()
|
|
3519
|
-
)
|
|
3520
|
-
);
|
|
3521
|
-
return Infinity;
|
|
3522
|
-
}
|
|
3523
|
-
return sortIndex;
|
|
3524
|
-
});
|
|
3525
|
-
const header = `@charset "UTF-8";
|
|
3526
|
-
/*
|
|
3527
|
-
${fileHeader2}
|
|
3528
|
-
*/
|
|
3529
|
-
|
|
3530
|
-
`;
|
|
3531
|
-
const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
|
|
3532
|
-
const pickOutputs = R19.map(R19.view(R19.lensProp("output")));
|
|
3533
|
-
const themeCSSFile = R19.pipe(
|
|
3534
|
-
sortAlphabetically,
|
|
3535
|
-
sortByDefinedOrder,
|
|
3536
|
-
pickOutputs,
|
|
3537
|
-
R19.join("\n"),
|
|
3538
|
-
(content) => header + content
|
|
3539
|
-
);
|
|
3540
|
-
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
3541
|
-
destination: `${theme}.css`,
|
|
3542
|
-
output: themeCSSFile(files)
|
|
3543
|
-
}));
|
|
3544
|
-
return themeCSSFiles;
|
|
3545
|
-
};
|
|
3546
|
-
|
|
3547
3547
|
// src/tokens/format.ts
|
|
3548
3548
|
var formatTokens = async (options) => {
|
|
3549
3549
|
const processedBuilds = await processPlatform({
|