@digdir/designsystemet 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/designsystemet.js +485 -163
- package/dist/global-Y35YADVH.json +100 -0
- package/dist/src/index.js +524 -200
- package/dist/src/scripts/update-preview-tokens.js +429 -118
- package/dist/src/tokens/build.js +426 -108
- package/dist/src/tokens/create/defaults.js +27 -23
- package/dist/src/tokens/create/generators/$designsystemet.js +3 -3
- package/dist/src/tokens/create/write.js +3 -3
- package/dist/src/tokens/create.js +27 -23
- package/dist/src/tokens/format.js +524 -200
- package/dist/src/tokens/index.js +524 -200
- package/dist/src/tokens/process/configs/color.js +366 -66
- package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/semantic.js +368 -68
- package/dist/src/tokens/process/configs/shared.js +9 -2
- package/dist/src/tokens/process/configs/size-mode.d.ts +3 -0
- package/dist/src/tokens/process/configs/size-mode.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/size-mode.js +1067 -0
- package/dist/src/tokens/process/configs/size.d.ts +3 -0
- package/dist/src/tokens/process/configs/size.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/size.js +1069 -0
- package/dist/src/tokens/process/configs/type-scale.d.ts +3 -0
- package/dist/src/tokens/process/configs/type-scale.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/type-scale.js +1067 -0
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/typography.js +364 -64
- package/dist/src/tokens/process/configs.d.ts +3 -0
- package/dist/src/tokens/process/configs.d.ts.map +1 -1
- package/dist/src/tokens/process/configs.js +373 -71
- package/dist/src/tokens/process/formats/css/color.js +381 -79
- package/dist/src/tokens/process/formats/css/semantic.d.ts +0 -14
- package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/semantic.js +407 -109
- package/dist/src/tokens/process/formats/css/size-mode.d.ts +4 -0
- package/dist/src/tokens/process/formats/css/size-mode.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/size-mode.js +1068 -0
- package/dist/src/tokens/process/formats/css/size.d.ts +17 -0
- package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/size.js +1069 -0
- package/dist/src/tokens/process/formats/css/type-scale.d.ts +3 -0
- package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/type-scale.js +1069 -0
- package/dist/src/tokens/process/formats/css/typography.js +365 -63
- package/dist/src/tokens/process/formats/css.d.ts +3 -0
- package/dist/src/tokens/process/formats/css.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css.js +364 -64
- package/dist/src/tokens/process/output/declarations.js +373 -71
- package/dist/src/tokens/process/output/theme.d.ts.map +1 -1
- package/dist/src/tokens/process/output/theme.js +60 -11
- package/dist/src/tokens/process/platform.d.ts +16 -0
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +402 -95
- package/dist/src/tokens/process/transformers.js +9 -2
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +373 -71
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +1 -1
- package/dist/src/tokens/utils.d.ts +4 -1
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +24 -1
- package/package.json +3 -3
- package/dist/global-XVXVBKM6.json +0 -96
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/tokens/format.ts
|
|
2
|
-
import * as
|
|
2
|
+
import * as R23 from "ramda";
|
|
3
3
|
|
|
4
4
|
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
5
5
|
var BoxShadowTypes;
|
|
@@ -485,95 +485,99 @@ var global_default = {
|
|
|
485
485
|
_size: {
|
|
486
486
|
"0": {
|
|
487
487
|
$type: "dimension",
|
|
488
|
-
$value: "floor({_size.
|
|
488
|
+
$value: "floor({_size.unit} * 0)"
|
|
489
489
|
},
|
|
490
490
|
"1": {
|
|
491
491
|
$type: "dimension",
|
|
492
|
-
$value: "floor({_size.
|
|
492
|
+
$value: "floor({_size.unit} * 1)"
|
|
493
493
|
},
|
|
494
494
|
"2": {
|
|
495
495
|
$type: "dimension",
|
|
496
|
-
$value: "floor({_size.
|
|
496
|
+
$value: "floor({_size.unit} * 2)"
|
|
497
497
|
},
|
|
498
498
|
"3": {
|
|
499
499
|
$type: "dimension",
|
|
500
|
-
$value: "floor({_size.
|
|
500
|
+
$value: "floor({_size.unit} * 3)"
|
|
501
501
|
},
|
|
502
502
|
"4": {
|
|
503
503
|
$type: "dimension",
|
|
504
|
-
$value: "floor({_size.
|
|
504
|
+
$value: "floor({_size.unit} * 4)"
|
|
505
505
|
},
|
|
506
506
|
"5": {
|
|
507
507
|
$type: "dimension",
|
|
508
|
-
$value: "floor({_size.
|
|
508
|
+
$value: "floor({_size.unit} * 5)"
|
|
509
509
|
},
|
|
510
510
|
"6": {
|
|
511
511
|
$type: "dimension",
|
|
512
|
-
$value: "floor({_size.
|
|
512
|
+
$value: "floor({_size.unit} * 6)"
|
|
513
513
|
},
|
|
514
514
|
"7": {
|
|
515
515
|
$type: "dimension",
|
|
516
|
-
$value: "floor({_size.
|
|
516
|
+
$value: "floor({_size.unit} * 7)"
|
|
517
517
|
},
|
|
518
518
|
"8": {
|
|
519
519
|
$type: "dimension",
|
|
520
|
-
$value: "floor({_size.
|
|
520
|
+
$value: "floor({_size.unit} * 8)"
|
|
521
521
|
},
|
|
522
522
|
"9": {
|
|
523
523
|
$type: "dimension",
|
|
524
|
-
$value: "floor({_size.
|
|
524
|
+
$value: "floor({_size.unit} * 9)"
|
|
525
525
|
},
|
|
526
526
|
"10": {
|
|
527
527
|
$type: "dimension",
|
|
528
|
-
$value: "floor({_size.
|
|
528
|
+
$value: "floor({_size.unit} * 10)"
|
|
529
529
|
},
|
|
530
530
|
"11": {
|
|
531
531
|
$type: "dimension",
|
|
532
|
-
$value: "floor({_size.
|
|
532
|
+
$value: "floor({_size.unit} * 11)"
|
|
533
533
|
},
|
|
534
534
|
"12": {
|
|
535
535
|
$type: "dimension",
|
|
536
|
-
$value: "floor({_size.
|
|
536
|
+
$value: "floor({_size.unit} * 12)"
|
|
537
537
|
},
|
|
538
538
|
"13": {
|
|
539
539
|
$type: "dimension",
|
|
540
|
-
$value: "floor({_size.
|
|
540
|
+
$value: "floor({_size.unit} * 13)"
|
|
541
541
|
},
|
|
542
542
|
"14": {
|
|
543
543
|
$type: "dimension",
|
|
544
|
-
$value: "floor({_size.
|
|
544
|
+
$value: "floor({_size.unit} * 14)"
|
|
545
545
|
},
|
|
546
546
|
"15": {
|
|
547
547
|
$type: "dimension",
|
|
548
|
-
$value: "floor({_size.
|
|
548
|
+
$value: "floor({_size.unit} * 15)"
|
|
549
549
|
},
|
|
550
550
|
"18": {
|
|
551
551
|
$type: "dimension",
|
|
552
|
-
$value: "floor({_size.
|
|
552
|
+
$value: "floor({_size.unit} * 18)"
|
|
553
553
|
},
|
|
554
554
|
"22": {
|
|
555
555
|
$type: "dimension",
|
|
556
|
-
$value: "floor({_size.
|
|
556
|
+
$value: "floor({_size.unit} * 22)"
|
|
557
557
|
},
|
|
558
558
|
"26": {
|
|
559
559
|
$type: "dimension",
|
|
560
|
-
$value: "floor({_size.
|
|
560
|
+
$value: "floor({_size.unit} * 26)"
|
|
561
561
|
},
|
|
562
562
|
"30": {
|
|
563
563
|
$type: "dimension",
|
|
564
|
-
$value: "floor({_size.
|
|
564
|
+
$value: "floor({_size.unit} * 30)"
|
|
565
565
|
},
|
|
566
566
|
"mode-font-size": {
|
|
567
|
-
$type: "
|
|
567
|
+
$type: "number",
|
|
568
568
|
$value: "{size._mode-font-size}"
|
|
569
569
|
},
|
|
570
570
|
base: {
|
|
571
|
-
$type: "
|
|
571
|
+
$type: "number",
|
|
572
572
|
$value: "{size._base}"
|
|
573
573
|
},
|
|
574
574
|
step: {
|
|
575
|
-
$type: "
|
|
575
|
+
$type: "number",
|
|
576
576
|
$value: "{size._step}"
|
|
577
|
+
},
|
|
578
|
+
unit: {
|
|
579
|
+
$type: "number",
|
|
580
|
+
$value: "{_size.step} / {_size.base} * {_size.mode-font-size}"
|
|
577
581
|
}
|
|
578
582
|
}
|
|
579
583
|
};
|
|
@@ -2408,12 +2412,12 @@ var createTokens = async (opts) => {
|
|
|
2408
2412
|
|
|
2409
2413
|
// src/tokens/process/output/theme.ts
|
|
2410
2414
|
import pc from "picocolors";
|
|
2411
|
-
import * as
|
|
2415
|
+
import * as R8 from "ramda";
|
|
2412
2416
|
|
|
2413
2417
|
// package.json
|
|
2414
2418
|
var package_default = {
|
|
2415
2419
|
name: "@digdir/designsystemet",
|
|
2416
|
-
version: "1.
|
|
2420
|
+
version: "1.5.1",
|
|
2417
2421
|
description: "CLI for Designsystemet",
|
|
2418
2422
|
author: "Designsystemet team",
|
|
2419
2423
|
engines: {
|
|
@@ -2496,9 +2500,9 @@ var package_default = {
|
|
|
2496
2500
|
"@types/apca-w3": "^0.1.3",
|
|
2497
2501
|
"@types/chroma-js": "^3.1.1",
|
|
2498
2502
|
"@types/fs-extra": "^11.0.4",
|
|
2499
|
-
"@types/node": "^22.18.
|
|
2503
|
+
"@types/node": "^22.18.1",
|
|
2500
2504
|
"@types/object-hash": "^3.0.6",
|
|
2501
|
-
"@types/ramda": "^0.31.
|
|
2505
|
+
"@types/ramda": "^0.31.1",
|
|
2502
2506
|
"fs-extra": "^11.3.1",
|
|
2503
2507
|
tslib: "^2.8.1",
|
|
2504
2508
|
tsup: "^8.5.0",
|
|
@@ -2507,8 +2511,109 @@ var package_default = {
|
|
|
2507
2511
|
}
|
|
2508
2512
|
};
|
|
2509
2513
|
|
|
2514
|
+
// src/tokens/utils.ts
|
|
2515
|
+
import * as R7 from "ramda";
|
|
2516
|
+
|
|
2517
|
+
// src/tokens/types.ts
|
|
2518
|
+
var colorCategories = {
|
|
2519
|
+
main: "main",
|
|
2520
|
+
support: "support"
|
|
2521
|
+
};
|
|
2522
|
+
|
|
2523
|
+
// src/tokens/utils.ts
|
|
2524
|
+
var mapToLowerCase = R7.map(R7.toLower);
|
|
2525
|
+
var hasAnyTruth = R7.any(R7.equals(true));
|
|
2526
|
+
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2527
|
+
var getValue = (token) => token.$value ?? token.value;
|
|
2528
|
+
var typeEquals = R7.curry(
|
|
2529
|
+
(types, token) => {
|
|
2530
|
+
if (R7.isNil(token)) {
|
|
2531
|
+
return false;
|
|
2532
|
+
}
|
|
2533
|
+
return R7.includes(R7.toLower(getType(token)), R7.map(R7.toLower, Array.isArray(types) ? types : [types]));
|
|
2534
|
+
}
|
|
2535
|
+
);
|
|
2536
|
+
var pathStartsWithOneOf = R7.curry(
|
|
2537
|
+
(paths, token) => {
|
|
2538
|
+
if (R7.isNil(token)) {
|
|
2539
|
+
return false;
|
|
2540
|
+
}
|
|
2541
|
+
const tokenPath = mapToLowerCase(token.path);
|
|
2542
|
+
const matchPathsStartingWith = R7.map((pathOrString) => {
|
|
2543
|
+
const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
|
|
2544
|
+
return R7.startsWith(mapToLowerCase(path), tokenPath);
|
|
2545
|
+
}, paths);
|
|
2546
|
+
return hasAnyTruth(matchPathsStartingWith);
|
|
2547
|
+
}
|
|
2548
|
+
);
|
|
2549
|
+
function isSemanticToken(token) {
|
|
2550
|
+
return token.filePath.includes("semantic/");
|
|
2551
|
+
}
|
|
2552
|
+
function isSemanticColorToken(token, color) {
|
|
2553
|
+
return token.filePath.includes("semantic/") && R7.startsWith(["color", color], token.path);
|
|
2554
|
+
}
|
|
2555
|
+
function isGlobalColorToken(token) {
|
|
2556
|
+
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
2557
|
+
}
|
|
2558
|
+
function isColorCategoryToken(token, category) {
|
|
2559
|
+
if (!category) {
|
|
2560
|
+
return Object.keys(colorCategories).some(
|
|
2561
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
2562
|
+
);
|
|
2563
|
+
}
|
|
2564
|
+
return R7.startsWith(["color", category], token.path);
|
|
2565
|
+
}
|
|
2566
|
+
var isDigit = (s) => /^\d+$/.test(s);
|
|
2567
|
+
function traverseObj(obj, fn) {
|
|
2568
|
+
for (const key in obj) {
|
|
2569
|
+
const prop4 = obj[key];
|
|
2570
|
+
if (prop4 != null) {
|
|
2571
|
+
fn.apply(null, [obj, key, prop4]);
|
|
2572
|
+
if (typeof prop4 === "object") {
|
|
2573
|
+
traverseObj(prop4, fn);
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
return obj;
|
|
2578
|
+
}
|
|
2579
|
+
function inlineTokens(shouldInline, tokens) {
|
|
2580
|
+
const [inlineableTokens, otherTokens] = R7.partition(shouldInline, tokens);
|
|
2581
|
+
return otherTokens.map((token) => {
|
|
2582
|
+
let transformed = getValue(token.original);
|
|
2583
|
+
for (const ref of inlineableTokens) {
|
|
2584
|
+
const refName = ref.path.join(".");
|
|
2585
|
+
if (typeof transformed === "string") {
|
|
2586
|
+
transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
const tokenWithInlinedRefs = R7.set(R7.lensPath(["original", "$value"]), transformed, token);
|
|
2590
|
+
return tokenWithInlinedRefs;
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
var sizeMap = {
|
|
2594
|
+
xsmall: "xs",
|
|
2595
|
+
small: "sm",
|
|
2596
|
+
medium: "md",
|
|
2597
|
+
large: "lg",
|
|
2598
|
+
xlarge: "xl"
|
|
2599
|
+
};
|
|
2600
|
+
function shortSizeName(size2) {
|
|
2601
|
+
return sizeMap[size2] ?? size2;
|
|
2602
|
+
}
|
|
2603
|
+
var sizeComparator = (size2) => {
|
|
2604
|
+
const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
|
|
2605
|
+
return sortIndex ?? 0;
|
|
2606
|
+
};
|
|
2607
|
+
function orderBySize(sizes) {
|
|
2608
|
+
return R7.sortBy(sizeComparator, sizes);
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2510
2611
|
// src/tokens/process/output/theme.ts
|
|
2511
2612
|
var defaultFileHeader = `build: v${package_default.version}`;
|
|
2613
|
+
var getFileNameWithoutExtension = (path) => {
|
|
2614
|
+
const pathSegments = path.split("/");
|
|
2615
|
+
return pathSegments[pathSegments.length - 1].split(".").slice(0, -1).join(".");
|
|
2616
|
+
};
|
|
2512
2617
|
var createThemeCSSFiles = ({
|
|
2513
2618
|
processedBuilds,
|
|
2514
2619
|
fileHeader = defaultFileHeader
|
|
@@ -2518,22 +2623,25 @@ var createThemeCSSFiles = ({
|
|
|
2518
2623
|
for (const buildResult of buildResults) {
|
|
2519
2624
|
const themeName = buildResult.permutation.theme;
|
|
2520
2625
|
const newOutputs = buildResult.formatted;
|
|
2521
|
-
if (
|
|
2626
|
+
if (R8.isNotEmpty(newOutputs)) {
|
|
2522
2627
|
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
2523
|
-
groupedByTheme[themeName] =
|
|
2628
|
+
groupedByTheme[themeName] = R8.concat(currentOutputs, newOutputs);
|
|
2524
2629
|
}
|
|
2525
2630
|
}
|
|
2526
2631
|
}
|
|
2527
2632
|
const sortOrder = [
|
|
2633
|
+
"size-mode/",
|
|
2634
|
+
"type-scale",
|
|
2528
2635
|
"color-scheme/light",
|
|
2529
2636
|
"typography/secondary",
|
|
2637
|
+
"size",
|
|
2530
2638
|
"semantic",
|
|
2531
2639
|
"color-scheme/dark",
|
|
2532
2640
|
"color-scheme/contrast",
|
|
2533
2641
|
"typography/primary",
|
|
2534
2642
|
"color/"
|
|
2535
2643
|
];
|
|
2536
|
-
const sortByDefinedOrder =
|
|
2644
|
+
const sortByDefinedOrder = R8.sortBy((file) => {
|
|
2537
2645
|
const filePath = file.destination || "";
|
|
2538
2646
|
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
2539
2647
|
if (sortElement.endsWith("/")) {
|
|
@@ -2562,13 +2670,17 @@ ${fileHeader}
|
|
|
2562
2670
|
*/
|
|
2563
2671
|
|
|
2564
2672
|
`;
|
|
2565
|
-
const sortAlphabetically =
|
|
2566
|
-
const
|
|
2567
|
-
|
|
2673
|
+
const sortAlphabetically = R8.sort(R8.ascend((x) => x.destination || ""));
|
|
2674
|
+
const sortBySize = R8.sortBy(
|
|
2675
|
+
R8.pipe((s) => getFileNameWithoutExtension(s.destination ?? ""), sizeComparator)
|
|
2676
|
+
);
|
|
2677
|
+
const pickOutputs = R8.map(R8.view(R8.lensProp("output")));
|
|
2678
|
+
const themeCSSFile = R8.pipe(
|
|
2568
2679
|
sortAlphabetically,
|
|
2680
|
+
sortBySize,
|
|
2569
2681
|
sortByDefinedOrder,
|
|
2570
2682
|
pickOutputs,
|
|
2571
|
-
|
|
2683
|
+
R8.join("\n"),
|
|
2572
2684
|
(content) => header + content
|
|
2573
2685
|
);
|
|
2574
2686
|
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
@@ -2580,91 +2692,16 @@ ${fileHeader}
|
|
|
2580
2692
|
|
|
2581
2693
|
// src/tokens/process/platform.ts
|
|
2582
2694
|
import pc3 from "picocolors";
|
|
2583
|
-
import * as
|
|
2695
|
+
import * as R22 from "ramda";
|
|
2584
2696
|
import StyleDictionary2 from "style-dictionary";
|
|
2585
2697
|
|
|
2586
|
-
// src/tokens/types.ts
|
|
2587
|
-
var colorCategories = {
|
|
2588
|
-
main: "main",
|
|
2589
|
-
support: "support"
|
|
2590
|
-
};
|
|
2591
|
-
|
|
2592
2698
|
// src/tokens/process/configs.ts
|
|
2593
2699
|
import { register } from "@tokens-studio/sd-transforms";
|
|
2594
|
-
import * as
|
|
2700
|
+
import * as R21 from "ramda";
|
|
2595
2701
|
import StyleDictionary from "style-dictionary";
|
|
2596
2702
|
|
|
2597
|
-
// src/tokens/utils.ts
|
|
2598
|
-
import * as R8 from "ramda";
|
|
2599
|
-
var mapToLowerCase = R8.map(R8.toLower);
|
|
2600
|
-
var hasAnyTruth = R8.any(R8.equals(true));
|
|
2601
|
-
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2602
|
-
var getValue = (token) => token.$value ?? token.value;
|
|
2603
|
-
var typeEquals = R8.curry(
|
|
2604
|
-
(types, token) => {
|
|
2605
|
-
if (R8.isNil(token)) {
|
|
2606
|
-
return false;
|
|
2607
|
-
}
|
|
2608
|
-
return R8.includes(R8.toLower(getType(token)), R8.map(R8.toLower, Array.isArray(types) ? types : [types]));
|
|
2609
|
-
}
|
|
2610
|
-
);
|
|
2611
|
-
var pathStartsWithOneOf = R8.curry(
|
|
2612
|
-
(paths, token) => {
|
|
2613
|
-
if (R8.isNil(token)) {
|
|
2614
|
-
return false;
|
|
2615
|
-
}
|
|
2616
|
-
const tokenPath = mapToLowerCase(token.path);
|
|
2617
|
-
const matchPathsStartingWith = R8.map((path) => R8.startsWith([path], tokenPath), mapToLowerCase(paths));
|
|
2618
|
-
return hasAnyTruth(matchPathsStartingWith);
|
|
2619
|
-
}
|
|
2620
|
-
);
|
|
2621
|
-
function isSemanticToken(token) {
|
|
2622
|
-
return token.filePath.includes("semantic/");
|
|
2623
|
-
}
|
|
2624
|
-
function isSemanticColorToken(token, color) {
|
|
2625
|
-
return token.filePath.includes("semantic/") && R8.startsWith(["color", color], token.path);
|
|
2626
|
-
}
|
|
2627
|
-
function isGlobalColorToken(token) {
|
|
2628
|
-
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
2629
|
-
}
|
|
2630
|
-
function isColorCategoryToken(token, category) {
|
|
2631
|
-
if (!category) {
|
|
2632
|
-
return Object.keys(colorCategories).some(
|
|
2633
|
-
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
2634
|
-
);
|
|
2635
|
-
}
|
|
2636
|
-
return R8.startsWith(["color", category], token.path);
|
|
2637
|
-
}
|
|
2638
|
-
var isDigit = (s) => /^\d+$/.test(s);
|
|
2639
|
-
function traverseObj(obj, fn) {
|
|
2640
|
-
for (const key in obj) {
|
|
2641
|
-
const prop = obj[key];
|
|
2642
|
-
if (prop != null) {
|
|
2643
|
-
fn.apply(null, [obj, key, prop]);
|
|
2644
|
-
if (typeof prop === "object") {
|
|
2645
|
-
traverseObj(prop, fn);
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
return obj;
|
|
2650
|
-
}
|
|
2651
|
-
function inlineTokens(shouldInline, tokens) {
|
|
2652
|
-
const [inlineableTokens, otherTokens] = R8.partition(shouldInline, tokens);
|
|
2653
|
-
return otherTokens.map((token) => {
|
|
2654
|
-
let transformed = getValue(token.original);
|
|
2655
|
-
for (const ref of inlineableTokens) {
|
|
2656
|
-
const refName = ref.path.join(".");
|
|
2657
|
-
if (typeof transformed === "string") {
|
|
2658
|
-
transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
const tokenWithInlinedRefs = R8.set(R8.lensPath(["original", "$value"]), transformed, token);
|
|
2662
|
-
return tokenWithInlinedRefs;
|
|
2663
|
-
});
|
|
2664
|
-
}
|
|
2665
|
-
|
|
2666
2703
|
// src/tokens/process/configs/color.ts
|
|
2667
|
-
import * as
|
|
2704
|
+
import * as R16 from "ramda";
|
|
2668
2705
|
|
|
2669
2706
|
// src/tokens/process/formats/css/color.ts
|
|
2670
2707
|
import * as R9 from "ramda";
|
|
@@ -2722,10 +2759,10 @@ ${selector} ${content} ${autoSelectorContent}
|
|
|
2722
2759
|
};
|
|
2723
2760
|
var colorCategory = {
|
|
2724
2761
|
name: "ds/css-colorcategory",
|
|
2725
|
-
format: async ({ dictionary, options, platform }) => {
|
|
2762
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2726
2763
|
const { outputReferences, usesDtcg } = options;
|
|
2727
|
-
const { selector, layer
|
|
2728
|
-
const destination =
|
|
2764
|
+
const { selector, layer } = platform;
|
|
2765
|
+
const destination = file.destination;
|
|
2729
2766
|
const format = R9.compose(
|
|
2730
2767
|
createPropertyFormatter({
|
|
2731
2768
|
outputReferences,
|
|
@@ -2762,6 +2799,10 @@ ${selector} ${content}
|
|
|
2762
2799
|
};
|
|
2763
2800
|
|
|
2764
2801
|
// src/tokens/process/formats/css/semantic.ts
|
|
2802
|
+
import * as R11 from "ramda";
|
|
2803
|
+
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
2804
|
+
|
|
2805
|
+
// src/tokens/process/formats/css/size.ts
|
|
2765
2806
|
import * as R10 from "ramda";
|
|
2766
2807
|
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
2767
2808
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
@@ -2769,12 +2810,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
|
|
|
2769
2810
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
2770
2811
|
var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
2771
2812
|
var overrideSizingFormula = (format, token) => {
|
|
2772
|
-
const [name, value] = format(token).split(":");
|
|
2773
|
-
|
|
2774
|
-
|
|
2813
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
2814
|
+
let calc;
|
|
2815
|
+
let round;
|
|
2816
|
+
if (token.path[1] === "unit") {
|
|
2817
|
+
calc = `calc(1rem * ${value})`;
|
|
2818
|
+
} else if (value.startsWith("floor")) {
|
|
2819
|
+
calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
|
|
2820
|
+
round = `round(down, ${calc}, 1px)`;
|
|
2821
|
+
} else {
|
|
2822
|
+
calc = value.includes("*") ? `calc(${value})` : value;
|
|
2823
|
+
}
|
|
2775
2824
|
return {
|
|
2776
2825
|
name,
|
|
2777
|
-
round,
|
|
2826
|
+
round: round ?? calc,
|
|
2778
2827
|
calc
|
|
2779
2828
|
};
|
|
2780
2829
|
};
|
|
@@ -2790,18 +2839,21 @@ var formatSizingTokens = (format, tokens) => R10.reduce(
|
|
|
2790
2839
|
{ tokens: [], round: [], calc: [] },
|
|
2791
2840
|
tokens
|
|
2792
2841
|
);
|
|
2793
|
-
var sizingTemplate = ({ round, calc }) =>
|
|
2842
|
+
var sizingTemplate = ({ round, calc }) => {
|
|
2843
|
+
const usesRounding = round.filter((val, i) => val !== calc[i]);
|
|
2844
|
+
return `
|
|
2794
2845
|
${calc.join("\n")}
|
|
2795
2846
|
|
|
2796
2847
|
@supports (width: round(down, .1em, 1px)) {
|
|
2797
|
-
${
|
|
2848
|
+
${usesRounding.join("\n ")}
|
|
2798
2849
|
}`;
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2850
|
+
};
|
|
2851
|
+
var size = {
|
|
2852
|
+
name: "ds/css-size",
|
|
2853
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2802
2854
|
const { outputReferences, usesDtcg } = options;
|
|
2803
|
-
const { selector, layer
|
|
2804
|
-
const destination =
|
|
2855
|
+
const { selector, layer } = platform;
|
|
2856
|
+
const destination = file.destination;
|
|
2805
2857
|
const format = createPropertyFormatter2({
|
|
2806
2858
|
outputReferences,
|
|
2807
2859
|
dictionary,
|
|
@@ -2809,9 +2861,9 @@ var semantic = {
|
|
|
2809
2861
|
usesDtcg
|
|
2810
2862
|
});
|
|
2811
2863
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2812
|
-
const filteredTokens = R10.reject((token) =>
|
|
2864
|
+
const filteredTokens = R10.reject((token) => R10.equals(["_size", "mode-font-size"], token.path), tokens);
|
|
2813
2865
|
const [sizingTokens, restTokens] = R10.partition(
|
|
2814
|
-
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
2866
|
+
(t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
|
|
2815
2867
|
filteredTokens
|
|
2816
2868
|
);
|
|
2817
2869
|
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
@@ -2824,64 +2876,56 @@ var semantic = {
|
|
|
2824
2876
|
formatted: t
|
|
2825
2877
|
}));
|
|
2826
2878
|
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
2827
|
-
const
|
|
2828
|
-
const
|
|
2829
|
-
const content = `{
|
|
2879
|
+
const formattedTokens = [formattedMap.map(R10.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
|
|
2880
|
+
const content = `${selector} {
|
|
2830
2881
|
${formattedTokens.join("\n")}
|
|
2831
2882
|
}
|
|
2832
2883
|
`;
|
|
2833
2884
|
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
2834
|
-
${
|
|
2885
|
+
${content}
|
|
2835
2886
|
}
|
|
2836
|
-
` : `${
|
|
2887
|
+
` : `${content}
|
|
2837
2888
|
`;
|
|
2838
2889
|
return body;
|
|
2839
2890
|
}
|
|
2840
2891
|
};
|
|
2841
2892
|
|
|
2842
|
-
// src/tokens/process/formats/css/
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
R11.pathSatisfies(R11.includes("typography"), ["path"]),
|
|
2847
|
-
R11.pathSatisfies(R11.includes("fontFamily"), ["path"])
|
|
2848
|
-
]);
|
|
2849
|
-
var typography = {
|
|
2850
|
-
name: "ds/css-typography",
|
|
2851
|
-
format: async ({ dictionary, options, platform }) => {
|
|
2893
|
+
// src/tokens/process/formats/css/semantic.ts
|
|
2894
|
+
var semantic = {
|
|
2895
|
+
name: "ds/css-semantic",
|
|
2896
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2852
2897
|
const { outputReferences, usesDtcg } = options;
|
|
2853
|
-
const { selector, layer
|
|
2854
|
-
const destination =
|
|
2898
|
+
const { selector, layer } = platform;
|
|
2899
|
+
const destination = file.destination;
|
|
2855
2900
|
const format = createPropertyFormatter3({
|
|
2856
2901
|
outputReferences,
|
|
2857
2902
|
dictionary,
|
|
2858
2903
|
format: "css",
|
|
2859
2904
|
usesDtcg
|
|
2860
2905
|
});
|
|
2861
|
-
const
|
|
2862
|
-
const formattedMap =
|
|
2906
|
+
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2907
|
+
const formattedMap = tokens.map((token) => ({
|
|
2863
2908
|
token,
|
|
2864
2909
|
formatted: format(token)
|
|
2865
2910
|
}));
|
|
2866
2911
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2867
|
-
const formattedTokens = formattedMap.map(R11.
|
|
2868
|
-
const content =
|
|
2912
|
+
const formattedTokens = formattedMap.map(R11.prop("formatted")).join("\n");
|
|
2913
|
+
const content = `${selector} {
|
|
2869
2914
|
${formattedTokens}
|
|
2870
|
-
}
|
|
2915
|
+
}
|
|
2916
|
+
`;
|
|
2871
2917
|
const body = R11.isNotNil(layer) ? `@layer ${layer} {
|
|
2872
2918
|
${content}
|
|
2873
|
-
}
|
|
2919
|
+
}
|
|
2920
|
+
` : `${content}
|
|
2921
|
+
`;
|
|
2874
2922
|
return body;
|
|
2875
2923
|
}
|
|
2876
2924
|
};
|
|
2877
2925
|
|
|
2878
|
-
// src/tokens/process/formats/css.ts
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
colorCategory,
|
|
2882
|
-
semantic,
|
|
2883
|
-
typography
|
|
2884
|
-
};
|
|
2926
|
+
// src/tokens/process/formats/css/size-mode.ts
|
|
2927
|
+
import * as R13 from "ramda";
|
|
2928
|
+
import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
|
|
2885
2929
|
|
|
2886
2930
|
// src/tokens/process/transformers.ts
|
|
2887
2931
|
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
@@ -2893,18 +2937,22 @@ var sizeRem = {
|
|
|
2893
2937
|
transitive: true,
|
|
2894
2938
|
filter: (token) => {
|
|
2895
2939
|
const hasWantedType = typeEquals(["dimension", "fontsize"], token);
|
|
2896
|
-
const hasWantedPath = pathStartsWithOneOf([
|
|
2940
|
+
const hasWantedPath = pathStartsWithOneOf([
|
|
2941
|
+
"border-radius",
|
|
2942
|
+
"font-size"
|
|
2943
|
+
/*, ['_size', 'mode-font-size']*/
|
|
2944
|
+
], token);
|
|
2897
2945
|
return hasWantedType && hasWantedPath;
|
|
2898
2946
|
},
|
|
2899
2947
|
transform: (token, config) => {
|
|
2900
2948
|
const value = getValue(token);
|
|
2901
2949
|
if (isPx(value)) {
|
|
2902
2950
|
const baseFont = config.basePxFontSize || 16;
|
|
2903
|
-
const
|
|
2904
|
-
if (
|
|
2951
|
+
const size2 = parseInt(value, 10);
|
|
2952
|
+
if (size2 === 0) {
|
|
2905
2953
|
return "0";
|
|
2906
2954
|
}
|
|
2907
|
-
return `${
|
|
2955
|
+
return `${size2 / baseFont}rem`;
|
|
2908
2956
|
}
|
|
2909
2957
|
return value;
|
|
2910
2958
|
}
|
|
@@ -2955,6 +3003,154 @@ var dsTransformers = [
|
|
|
2955
3003
|
"shadow/css/shorthand"
|
|
2956
3004
|
];
|
|
2957
3005
|
|
|
3006
|
+
// src/tokens/process/formats/css/size-mode.ts
|
|
3007
|
+
var formatBaseSizeToken = (size2) => (token) => ({
|
|
3008
|
+
...token,
|
|
3009
|
+
originalName: token.name,
|
|
3010
|
+
name: `${token.name}--${shortSizeName(size2)}`,
|
|
3011
|
+
$value: token.$value / basePxFontSize
|
|
3012
|
+
});
|
|
3013
|
+
var sizeMode = {
|
|
3014
|
+
name: "ds/css-size-mode",
|
|
3015
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
3016
|
+
const { outputReferences, usesDtcg } = options;
|
|
3017
|
+
const { selector, layer, size: size2 } = platform;
|
|
3018
|
+
const destination = file.destination;
|
|
3019
|
+
const format = createPropertyFormatter4({
|
|
3020
|
+
outputReferences,
|
|
3021
|
+
dictionary,
|
|
3022
|
+
format: "css",
|
|
3023
|
+
usesDtcg
|
|
3024
|
+
});
|
|
3025
|
+
const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
|
|
3026
|
+
const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
|
|
3027
|
+
const formattedMap = sizeSpecificTokens.map((token) => ({
|
|
3028
|
+
token,
|
|
3029
|
+
formatted: format({
|
|
3030
|
+
...token,
|
|
3031
|
+
// Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
|
|
3032
|
+
name: token.originalName
|
|
3033
|
+
})
|
|
3034
|
+
}));
|
|
3035
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
3036
|
+
const content = `${selector} /* ${size2} */ {
|
|
3037
|
+
${sizeSpecificVariables}
|
|
3038
|
+
}`;
|
|
3039
|
+
const body = wrapInLayer(content, layer);
|
|
3040
|
+
const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
|
|
3041
|
+
const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
|
|
3042
|
+
const sizingToggles = `:root, [data-size] {
|
|
3043
|
+
--ds-size: var(--ds-size--${defaultSize});
|
|
3044
|
+
${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
|
|
3045
|
+
--ds-size-mode-font-size:
|
|
3046
|
+
${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
|
|
3047
|
+
}`;
|
|
3048
|
+
const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
|
|
3049
|
+
const sharedContent = `${sizingToggles}
|
|
3050
|
+
|
|
3051
|
+
${sizingHelpers}`;
|
|
3052
|
+
const sharedBody = shortSizeName(size2) === R13.last(sizes) ? `
|
|
3053
|
+
${wrapInLayer(sharedContent, layer)}` : "";
|
|
3054
|
+
return body + sharedBody;
|
|
3055
|
+
}
|
|
3056
|
+
};
|
|
3057
|
+
function wrapInLayer(content, layer) {
|
|
3058
|
+
return R13.isNotNil(layer) ? `@layer ${layer} {
|
|
3059
|
+
${content}
|
|
3060
|
+
}
|
|
3061
|
+
` : `${content}
|
|
3062
|
+
`;
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
// src/tokens/process/formats/css/typography.ts
|
|
3066
|
+
import * as R14 from "ramda";
|
|
3067
|
+
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
3068
|
+
var typographyFontFamilyPredicate = R14.allPass([
|
|
3069
|
+
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
3070
|
+
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
3071
|
+
]);
|
|
3072
|
+
var typography = {
|
|
3073
|
+
name: "ds/css-typography",
|
|
3074
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
3075
|
+
const { outputReferences, usesDtcg } = options;
|
|
3076
|
+
const { selector, layer } = platform;
|
|
3077
|
+
const destination = file.destination;
|
|
3078
|
+
const format = createPropertyFormatter5({
|
|
3079
|
+
outputReferences,
|
|
3080
|
+
dictionary,
|
|
3081
|
+
format: "css",
|
|
3082
|
+
usesDtcg
|
|
3083
|
+
});
|
|
3084
|
+
const filteredTokens = R14.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
3085
|
+
const formattedMap = filteredTokens.map((token) => ({
|
|
3086
|
+
token,
|
|
3087
|
+
formatted: format(token)
|
|
3088
|
+
}));
|
|
3089
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
3090
|
+
const formattedTokens = formattedMap.map(R14.view(R14.lensProp("formatted"))).join("\n");
|
|
3091
|
+
const content = selector ? `${selector} {
|
|
3092
|
+
${formattedTokens}
|
|
3093
|
+
}` : formattedTokens;
|
|
3094
|
+
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
3095
|
+
${content}
|
|
3096
|
+
}` : content;
|
|
3097
|
+
return body;
|
|
3098
|
+
}
|
|
3099
|
+
};
|
|
3100
|
+
|
|
3101
|
+
// src/tokens/process/formats/css/type-scale.ts
|
|
3102
|
+
import * as R15 from "ramda";
|
|
3103
|
+
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
3104
|
+
var typographyFontFamilyPredicate2 = R15.allPass([
|
|
3105
|
+
R15.pathSatisfies(R15.includes("typography"), ["path"]),
|
|
3106
|
+
R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
|
|
3107
|
+
]);
|
|
3108
|
+
function formatTypographySizeToken(token) {
|
|
3109
|
+
return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
|
|
3110
|
+
}
|
|
3111
|
+
var typeScale = {
|
|
3112
|
+
name: "ds/css-type-scale",
|
|
3113
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
3114
|
+
const { outputReferences, usesDtcg } = options;
|
|
3115
|
+
const { selector, layer } = platform;
|
|
3116
|
+
const destination = file.destination;
|
|
3117
|
+
const format = createPropertyFormatter6({
|
|
3118
|
+
outputReferences,
|
|
3119
|
+
dictionary,
|
|
3120
|
+
format: "css",
|
|
3121
|
+
usesDtcg
|
|
3122
|
+
});
|
|
3123
|
+
const filteredTokens = R15.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
|
|
3124
|
+
const tokens = R15.map(formatTypographySizeToken, filteredTokens);
|
|
3125
|
+
const formattedMap = tokens.map((token) => ({
|
|
3126
|
+
token,
|
|
3127
|
+
formatted: format(token)
|
|
3128
|
+
}));
|
|
3129
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
3130
|
+
const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
|
|
3131
|
+
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
3132
|
+
const content = `${selector} {
|
|
3133
|
+
${sizeFactor}
|
|
3134
|
+
${formattedTokens}
|
|
3135
|
+
}`;
|
|
3136
|
+
const body = R15.isNotNil(layer) ? `@layer ${layer} {
|
|
3137
|
+
${content}
|
|
3138
|
+
}` : content;
|
|
3139
|
+
return body;
|
|
3140
|
+
}
|
|
3141
|
+
};
|
|
3142
|
+
|
|
3143
|
+
// src/tokens/process/formats/css.ts
|
|
3144
|
+
var formats = {
|
|
3145
|
+
colorScheme,
|
|
3146
|
+
colorCategory,
|
|
3147
|
+
semantic,
|
|
3148
|
+
sizeMode,
|
|
3149
|
+
size,
|
|
3150
|
+
typography,
|
|
3151
|
+
typeScale
|
|
3152
|
+
};
|
|
3153
|
+
|
|
2958
3154
|
// src/tokens/process/configs/color.ts
|
|
2959
3155
|
var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
|
|
2960
3156
|
const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
|
|
@@ -2976,7 +3172,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
|
|
|
2976
3172
|
{
|
|
2977
3173
|
destination: `color-scheme/${colorScheme2}.css`,
|
|
2978
3174
|
format: formats.colorScheme.name,
|
|
2979
|
-
filter: (token) => typeEquals("color", token) && !
|
|
3175
|
+
filter: (token) => typeEquals("color", token) && !R16.startsWith(["global"], token.path)
|
|
2980
3176
|
}
|
|
2981
3177
|
],
|
|
2982
3178
|
options: {
|
|
@@ -3027,7 +3223,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
3027
3223
|
};
|
|
3028
3224
|
|
|
3029
3225
|
// src/tokens/process/configs/semantic.ts
|
|
3030
|
-
import * as
|
|
3226
|
+
import * as R17 from "ramda";
|
|
3031
3227
|
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
3032
3228
|
var semanticVariables = ({ theme }) => {
|
|
3033
3229
|
const selector = `:root`;
|
|
@@ -3050,9 +3246,12 @@ var semanticVariables = ({ theme }) => {
|
|
|
3050
3246
|
destination: `semantic.css`,
|
|
3051
3247
|
format: formats.semantic.name,
|
|
3052
3248
|
filter: (token) => {
|
|
3053
|
-
const isUwantedToken =
|
|
3054
|
-
const isPrivateToken =
|
|
3055
|
-
const unwantedPaths = pathStartsWithOneOf(
|
|
3249
|
+
const isUwantedToken = R17.anyPass([R17.includes("primitives/global")])(token.filePath);
|
|
3250
|
+
const isPrivateToken = R17.includes("_", token.path);
|
|
3251
|
+
const unwantedPaths = pathStartsWithOneOf(
|
|
3252
|
+
["size", "_size", "font-size", "line-height", "letter-spacing"],
|
|
3253
|
+
token
|
|
3254
|
+
);
|
|
3056
3255
|
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
3057
3256
|
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
3058
3257
|
return unwantedTokens;
|
|
@@ -3062,8 +3261,48 @@ var semanticVariables = ({ theme }) => {
|
|
|
3062
3261
|
options: {
|
|
3063
3262
|
outputReferences: (token, options) => {
|
|
3064
3263
|
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
3065
|
-
|
|
3066
|
-
|
|
3264
|
+
return include && outputReferencesFilter(token, options);
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
};
|
|
3270
|
+
};
|
|
3271
|
+
|
|
3272
|
+
// src/tokens/process/configs/size.ts
|
|
3273
|
+
import * as R18 from "ramda";
|
|
3274
|
+
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
3275
|
+
var sizeVariables = ({ theme }) => {
|
|
3276
|
+
const selector = `:root, [data-size]`;
|
|
3277
|
+
const layer = `ds.theme.size`;
|
|
3278
|
+
return {
|
|
3279
|
+
preprocessors: ["tokens-studio"],
|
|
3280
|
+
platforms: {
|
|
3281
|
+
css: {
|
|
3282
|
+
// custom
|
|
3283
|
+
theme,
|
|
3284
|
+
basePxFontSize,
|
|
3285
|
+
selector,
|
|
3286
|
+
layer,
|
|
3287
|
+
//
|
|
3288
|
+
prefix,
|
|
3289
|
+
buildPath: `${theme}/`,
|
|
3290
|
+
transforms: dsTransformers,
|
|
3291
|
+
files: [
|
|
3292
|
+
{
|
|
3293
|
+
destination: `size.css`,
|
|
3294
|
+
format: formats.size.name,
|
|
3295
|
+
filter: (token) => {
|
|
3296
|
+
const isUwantedToken = R18.anyPass([R18.includes("primitives/global")])(token.filePath);
|
|
3297
|
+
const isPrivateToken = R18.includes("_", token.path);
|
|
3298
|
+
return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
],
|
|
3302
|
+
options: {
|
|
3303
|
+
outputReferences: (token, options) => {
|
|
3304
|
+
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
|
|
3305
|
+
return isWantedSize && outputReferencesFilter2(token, options);
|
|
3067
3306
|
}
|
|
3068
3307
|
}
|
|
3069
3308
|
}
|
|
@@ -3071,6 +3310,83 @@ var semanticVariables = ({ theme }) => {
|
|
|
3071
3310
|
};
|
|
3072
3311
|
};
|
|
3073
3312
|
|
|
3313
|
+
// src/tokens/process/configs/size-mode.ts
|
|
3314
|
+
import * as R19 from "ramda";
|
|
3315
|
+
var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
3316
|
+
const selector = `:root`;
|
|
3317
|
+
const layer = `ds.theme.size-mode`;
|
|
3318
|
+
return {
|
|
3319
|
+
preprocessors: ["tokens-studio"],
|
|
3320
|
+
platforms: {
|
|
3321
|
+
css: {
|
|
3322
|
+
// custom
|
|
3323
|
+
size: size2,
|
|
3324
|
+
theme,
|
|
3325
|
+
basePxFontSize,
|
|
3326
|
+
selector,
|
|
3327
|
+
layer,
|
|
3328
|
+
//
|
|
3329
|
+
prefix,
|
|
3330
|
+
buildPath: `${theme}/`,
|
|
3331
|
+
transforms: dsTransformers,
|
|
3332
|
+
files: [
|
|
3333
|
+
{
|
|
3334
|
+
destination: `size-mode/${size2}.css`,
|
|
3335
|
+
format: formats.sizeMode.name,
|
|
3336
|
+
filter: (token) => {
|
|
3337
|
+
return R19.equals(["_size", "mode-font-size"], token.path);
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
]
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
};
|
|
3344
|
+
};
|
|
3345
|
+
|
|
3346
|
+
// src/tokens/process/configs/type-scale.ts
|
|
3347
|
+
var typeScaleVariables = ({ theme }) => {
|
|
3348
|
+
const selector = ":root, [data-size]";
|
|
3349
|
+
const layer = `ds.theme.type-scale`;
|
|
3350
|
+
return {
|
|
3351
|
+
usesDtcg: true,
|
|
3352
|
+
preprocessors: ["tokens-studio"],
|
|
3353
|
+
expand: {
|
|
3354
|
+
include: ["typography"]
|
|
3355
|
+
},
|
|
3356
|
+
platforms: {
|
|
3357
|
+
css: {
|
|
3358
|
+
prefix,
|
|
3359
|
+
selector,
|
|
3360
|
+
layer,
|
|
3361
|
+
buildPath: `${theme}/`,
|
|
3362
|
+
basePxFontSize,
|
|
3363
|
+
transforms: [
|
|
3364
|
+
"name/kebab",
|
|
3365
|
+
"ts/size/px",
|
|
3366
|
+
sizeRem.name,
|
|
3367
|
+
"ts/size/lineheight",
|
|
3368
|
+
"ts/typography/fontWeight",
|
|
3369
|
+
typographyName.name
|
|
3370
|
+
],
|
|
3371
|
+
files: [
|
|
3372
|
+
{
|
|
3373
|
+
destination: `type-scale.css`,
|
|
3374
|
+
format: formats.typeScale.name,
|
|
3375
|
+
filter: (token) => {
|
|
3376
|
+
const included = typeEquals(["typography", "dimension", "fontsize"], token);
|
|
3377
|
+
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
3378
|
+
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
],
|
|
3382
|
+
options: {
|
|
3383
|
+
outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
};
|
|
3388
|
+
};
|
|
3389
|
+
|
|
3074
3390
|
// src/tokens/process/configs/typography.ts
|
|
3075
3391
|
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
3076
3392
|
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
@@ -3105,12 +3421,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3105
3421
|
destination: `typography/${typography2}.css`,
|
|
3106
3422
|
format: formats.typography.name,
|
|
3107
3423
|
filter: (token) => {
|
|
3108
|
-
const included = typeEquals(
|
|
3109
|
-
["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
|
|
3110
|
-
token
|
|
3111
|
-
);
|
|
3424
|
+
const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
|
|
3112
3425
|
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
3113
|
-
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
|
|
3426
|
+
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
|
|
3114
3427
|
}
|
|
3115
3428
|
}
|
|
3116
3429
|
]
|
|
@@ -3122,13 +3435,13 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3122
3435
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
3123
3436
|
import { kebabCase } from "change-case";
|
|
3124
3437
|
import pc2 from "picocolors";
|
|
3125
|
-
import * as
|
|
3438
|
+
import * as R20 from "ramda";
|
|
3126
3439
|
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
3127
3440
|
const verboseLogging = buildOptions?.verbose;
|
|
3128
3441
|
const grouped$themes = groupThemes(processed$themes);
|
|
3129
3442
|
const permutations = permutateThemes(grouped$themes);
|
|
3130
3443
|
const ALL_DEPENDENT_ON = ["theme"];
|
|
3131
|
-
const keys2 =
|
|
3444
|
+
const keys2 = R20.keys(grouped$themes);
|
|
3132
3445
|
const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
3133
3446
|
if (verboseLogging) {
|
|
3134
3447
|
console.log(pc2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
@@ -3168,7 +3481,7 @@ function groupThemes(themes) {
|
|
|
3168
3481
|
}
|
|
3169
3482
|
return groups;
|
|
3170
3483
|
}
|
|
3171
|
-
var hasUnknownProps =
|
|
3484
|
+
var hasUnknownProps = R20.pipe(R20.values, R20.none(R20.equals("unknown")), R20.not);
|
|
3172
3485
|
function permutateThemes(groups) {
|
|
3173
3486
|
const separator = "_";
|
|
3174
3487
|
const permutations = cartesian(Object.values(groups));
|
|
@@ -3178,8 +3491,8 @@ function permutateThemes(groups) {
|
|
|
3178
3491
|
const { group, name, selectedTokenSets } = theme;
|
|
3179
3492
|
let updatedPermutation = acc.permutation;
|
|
3180
3493
|
if (group) {
|
|
3181
|
-
const groupProp =
|
|
3182
|
-
updatedPermutation =
|
|
3494
|
+
const groupProp = R20.lensProp(group);
|
|
3495
|
+
updatedPermutation = R20.set(groupProp, name, updatedPermutation);
|
|
3183
3496
|
}
|
|
3184
3497
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3185
3498
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -3250,7 +3563,10 @@ var configs = {
|
|
|
3250
3563
|
dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
|
|
3251
3564
|
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
3252
3565
|
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
3566
|
+
sizeModeVariables,
|
|
3567
|
+
sizeVariables,
|
|
3253
3568
|
typographyVariables,
|
|
3569
|
+
typeScaleVariables,
|
|
3254
3570
|
semanticVariables
|
|
3255
3571
|
};
|
|
3256
3572
|
var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
|
|
@@ -3267,7 +3583,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3267
3583
|
obj.filePath = tokenSet;
|
|
3268
3584
|
}
|
|
3269
3585
|
});
|
|
3270
|
-
tokenSource.tokens =
|
|
3586
|
+
tokenSource.tokens = R21.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3271
3587
|
}
|
|
3272
3588
|
}
|
|
3273
3589
|
} else {
|
|
@@ -3318,6 +3634,9 @@ var buildOptions = {
|
|
|
3318
3634
|
var sd = new StyleDictionary2();
|
|
3319
3635
|
var buildConfigs = {
|
|
3320
3636
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
3637
|
+
sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
|
|
3638
|
+
size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
|
|
3639
|
+
typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
|
|
3321
3640
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
3322
3641
|
"main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
|
|
3323
3642
|
"support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
|
|
@@ -3353,9 +3672,6 @@ async function processPlatform(options) {
|
|
|
3353
3672
|
const platform = "css";
|
|
3354
3673
|
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3355
3674
|
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
3356
|
-
const filteredProcessed$themes = processed$themes.filter(
|
|
3357
|
-
(theme) => R17.not(theme.group === "size" && theme.name !== "medium")
|
|
3358
|
-
);
|
|
3359
3675
|
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3360
3676
|
if (UNSAFE_DEFAULT_COLOR) {
|
|
3361
3677
|
console.warn(
|
|
@@ -3379,24 +3695,29 @@ async function processPlatform(options) {
|
|
|
3379
3695
|
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3380
3696
|
buildOptions.colorGroups = colorGroups;
|
|
3381
3697
|
if (!buildOptions.defaultColor) {
|
|
3382
|
-
const customColors = getCustomColors(
|
|
3383
|
-
const firstMainColor =
|
|
3698
|
+
const customColors = getCustomColors(processed$themes, colorGroups);
|
|
3699
|
+
const firstMainColor = R22.head(customColors);
|
|
3384
3700
|
buildOptions.defaultColor = firstMainColor;
|
|
3385
3701
|
}
|
|
3386
3702
|
if (buildOptions.defaultColor) {
|
|
3387
3703
|
console.log(`
|
|
3388
3704
|
\u{1F3A8} Using ${pc3.blue(buildOptions.defaultColor)} as default color`);
|
|
3389
3705
|
}
|
|
3390
|
-
const
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3706
|
+
const sizeModes = processed$themes.filter((x) => x.group === "size").map((x) => x.name);
|
|
3707
|
+
buildOptions.sizeModes = sizeModes;
|
|
3708
|
+
if (!buildOptions.defaultSize) {
|
|
3709
|
+
const defaultSize = R22.head(sizeModes);
|
|
3710
|
+
buildOptions.defaultSize = defaultSize;
|
|
3711
|
+
}
|
|
3712
|
+
if (buildOptions.defaultSize) {
|
|
3713
|
+
console.log(`
|
|
3714
|
+
\u{1F4CF} Using ${pc3.blue(buildOptions.defaultSize)} as default size`);
|
|
3715
|
+
}
|
|
3716
|
+
const buildAndSdConfigs = R22.map((buildConfig) => {
|
|
3717
|
+
const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
|
|
3718
|
+
tokensDir,
|
|
3719
|
+
tokenSets
|
|
3720
|
+
});
|
|
3400
3721
|
const unknownConfigs = buildConfig.dimensions.map(
|
|
3401
3722
|
(dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
|
|
3402
3723
|
);
|
|
@@ -3420,10 +3741,13 @@ async function processPlatform(options) {
|
|
|
3420
3741
|
"warning-color": [initResult],
|
|
3421
3742
|
"info-color": [initResult],
|
|
3422
3743
|
semantic: [initResult],
|
|
3423
|
-
typography: [initResult]
|
|
3744
|
+
typography: [initResult],
|
|
3745
|
+
sizeMode: [initResult],
|
|
3746
|
+
size: [initResult],
|
|
3747
|
+
typeScale: [initResult]
|
|
3424
3748
|
};
|
|
3425
3749
|
try {
|
|
3426
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
3750
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R22.toPairs(buildAndSdConfigs)) {
|
|
3427
3751
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3428
3752
|
continue;
|
|
3429
3753
|
}
|
|
@@ -3435,7 +3759,7 @@ async function processPlatform(options) {
|
|
|
3435
3759
|
const { config, permutation } = sdConfig;
|
|
3436
3760
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
3437
3761
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3438
|
-
const logMessage =
|
|
3762
|
+
const logMessage = R22.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3439
3763
|
console.log(logMessage);
|
|
3440
3764
|
const sdOptions = { cache: true };
|
|
3441
3765
|
const sdExtended = await sd.extend(config);
|
|
@@ -3484,7 +3808,7 @@ var formatTheme = async (themeConfig) => {
|
|
|
3484
3808
|
var formatThemeCSS = async (themeConfig) => {
|
|
3485
3809
|
const processedBuilds = await formatTheme(themeConfig);
|
|
3486
3810
|
const themeCSSFiles = createThemeCSSFiles({ processedBuilds });
|
|
3487
|
-
return
|
|
3811
|
+
return R23.head(themeCSSFiles)?.output ?? "";
|
|
3488
3812
|
};
|
|
3489
3813
|
export {
|
|
3490
3814
|
formatTheme,
|