@digdir/designsystemet 1.0.4 → 1.0.6
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/LICENSE +7 -0
- package/dist/bin/designsystemet.js +623 -593
- package/dist/src/colors/index.js +32 -0
- package/dist/src/colors/theme.js +1 -0
- package/dist/src/colors/utils.d.ts +13 -0
- package/dist/src/colors/utils.d.ts.map +1 -1
- package/dist/src/colors/utils.js +32 -0
- package/dist/src/config.js +1 -0
- package/dist/src/index.js +196 -142
- package/dist/src/scripts/createJsonSchema.js +39 -38
- package/dist/src/scripts/update-design-tokens.js +1 -0
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +353 -590
- package/dist/src/tokens/create/generators/$designsystemet.js +22 -19
- package/dist/src/tokens/create/generators/$themes.js +10 -10
- package/dist/src/tokens/create/generators/color.js +1 -0
- package/dist/src/tokens/create/write.js +32 -29
- package/dist/src/tokens/create.js +1 -0
- package/dist/src/tokens/format.d.ts +4 -5
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +165 -143
- package/dist/src/tokens/index.js +165 -142
- package/dist/src/tokens/process/configs/color.js +26 -22
- package/dist/src/tokens/process/configs/semantic.js +16 -12
- package/dist/src/tokens/process/configs/shared.js +16 -12
- package/dist/src/tokens/process/configs/storefront.js +16 -12
- package/dist/src/tokens/process/configs/typography.js +16 -12
- package/dist/src/tokens/process/configs.js +26 -22
- package/dist/src/tokens/process/formats/css/color.js +16 -12
- package/dist/src/tokens/process/formats/css/semantic.js +16 -12
- package/dist/src/tokens/process/formats/css.js +16 -12
- package/dist/src/tokens/process/formats/js-tokens.js +16 -12
- package/dist/src/tokens/process/platform.js +27 -23
- package/dist/src/tokens/process/theme.d.ts +27 -0
- package/dist/src/tokens/process/theme.d.ts.map +1 -0
- package/dist/src/tokens/process/theme.js +174 -0
- package/dist/src/tokens/process/transformers.js +16 -12
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +26 -22
- package/dist/src/tokens/types.d.ts +4 -0
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/utils.d.ts +2 -2
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +16 -12
- package/package.json +31 -28
package/dist/src/colors/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/colors/utils.ts
|
|
2
2
|
import chroma from "chroma-js";
|
|
3
|
+
import Colorjs from "colorjs.io";
|
|
3
4
|
import { Hsluv } from "hsluv";
|
|
4
5
|
var hexToCssHsl = (hex, valuesOnly = false) => {
|
|
5
6
|
const [h, s, l] = chroma(hex).hsl();
|
|
@@ -72,6 +73,9 @@ var getLuminanceFromLightness = (lightness) => {
|
|
|
72
73
|
conv.hsluvToHex();
|
|
73
74
|
return chroma(conv.hex).luminance();
|
|
74
75
|
};
|
|
76
|
+
var getLuminanceFromColor = (color) => {
|
|
77
|
+
return chroma(color).luminance();
|
|
78
|
+
};
|
|
75
79
|
var getLightnessFromHex = (hex) => {
|
|
76
80
|
const conv = new Hsluv();
|
|
77
81
|
conv.hex = hex;
|
|
@@ -106,6 +110,32 @@ var rgbToHex = (rgb) => {
|
|
|
106
110
|
return hex.length === 1 ? "0" + hex : hex;
|
|
107
111
|
}).join("")}`;
|
|
108
112
|
};
|
|
113
|
+
var convertColor = (cssColor, format) => {
|
|
114
|
+
const color = new Colorjs(cssColor);
|
|
115
|
+
switch (format) {
|
|
116
|
+
case "rgb":
|
|
117
|
+
case "rgba":
|
|
118
|
+
return color.toString({
|
|
119
|
+
format: {
|
|
120
|
+
name: format,
|
|
121
|
+
coords: ["<number>[0, 255]", "<number>[0, 255]", "<number>[0, 255]"]
|
|
122
|
+
},
|
|
123
|
+
precision: 3
|
|
124
|
+
});
|
|
125
|
+
case "hex":
|
|
126
|
+
return color.toString({ format, precision: 3 });
|
|
127
|
+
case "hct":
|
|
128
|
+
return color.to(format).toString({
|
|
129
|
+
format: {
|
|
130
|
+
name: format,
|
|
131
|
+
coords: ["<number>", "<number>", "<number>"]
|
|
132
|
+
},
|
|
133
|
+
precision: 3
|
|
134
|
+
});
|
|
135
|
+
default:
|
|
136
|
+
return color.to(format).toString({ precision: 3 });
|
|
137
|
+
}
|
|
138
|
+
};
|
|
109
139
|
|
|
110
140
|
// src/colors/theme.ts
|
|
111
141
|
import chroma2 from "chroma-js";
|
|
@@ -450,6 +480,7 @@ export {
|
|
|
450
480
|
baseColors,
|
|
451
481
|
canTextBeUsedOnColors,
|
|
452
482
|
colorMetadata,
|
|
483
|
+
convertColor,
|
|
453
484
|
convertToHex,
|
|
454
485
|
generateColorContrast,
|
|
455
486
|
generateColorScale,
|
|
@@ -459,6 +490,7 @@ export {
|
|
|
459
490
|
getContrastFromLightness,
|
|
460
491
|
getCssVariable,
|
|
461
492
|
getLightnessFromHex,
|
|
493
|
+
getLuminanceFromColor,
|
|
462
494
|
getLuminanceFromLightness,
|
|
463
495
|
hexToCssHsl,
|
|
464
496
|
hexToHSL,
|
package/dist/src/colors/theme.js
CHANGED
|
@@ -253,6 +253,7 @@ var getColorMetadataByNumber = (number) => {
|
|
|
253
253
|
|
|
254
254
|
// src/colors/utils.ts
|
|
255
255
|
import chroma from "chroma-js";
|
|
256
|
+
import Colorjs from "colorjs.io";
|
|
256
257
|
import { Hsluv } from "hsluv";
|
|
257
258
|
var getLuminanceFromLightness = (lightness) => {
|
|
258
259
|
const conv = new Hsluv();
|
|
@@ -86,6 +86,12 @@ export declare const isHexColor: (hex: string) => boolean;
|
|
|
86
86
|
* @param lightness The lightness value
|
|
87
87
|
*/
|
|
88
88
|
export declare const getLuminanceFromLightness: (lightness: number) => number;
|
|
89
|
+
/**
|
|
90
|
+
* Get the relative luminance from any valid css color
|
|
91
|
+
*
|
|
92
|
+
* @param color
|
|
93
|
+
*/
|
|
94
|
+
export declare const getLuminanceFromColor: (color: string) => number;
|
|
89
95
|
/**
|
|
90
96
|
* Get the HSLuv lightness from a HEX color
|
|
91
97
|
*
|
|
@@ -112,4 +118,11 @@ export declare const rgbToHex: (rgb: {
|
|
|
112
118
|
g: number;
|
|
113
119
|
b: number;
|
|
114
120
|
}) => HexColor;
|
|
121
|
+
/**
|
|
122
|
+
* Convert a color to a different format
|
|
123
|
+
*
|
|
124
|
+
* @param cssColor Any valid css color
|
|
125
|
+
* @param format Color space/format supported here https://colorjs.io/docs/spaces
|
|
126
|
+
*/
|
|
127
|
+
export declare const convertColor: (cssColor: string, format: string) => string;
|
|
115
128
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/colors/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/colors/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,QAAQ,EAAE,oBAAkB,WAO5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,QAAQ,aAGrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,QAAQ,aAKvC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,WAExC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,QAE1D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,OAAM,KAAK,GAAG,GAAW;;;;CAO9D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,QAAQ,EAAE,QAAQ,QAAQ,WAIpE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,WAAW,MAAM,EAAE,WAAW,QAAQ,EAAE,iBAAiB,QAAQ,WAYzG,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,QAAQ,EAAE,QAAQ,QAAQ,EAAE,OAAM,YAAY,GAAG,IAAI,GAAG,KAAY,YAYhH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,YAErC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,WAAW,MAAM,WAM1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,WAElD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,QAAQ,WAMhD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,kBAAkB,QAAQ,EAAE,iBAAiB,QAAQ,YAe1F,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,QAQ7C,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,KAAK;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,KAAG,QAOnE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,WA0B5D,CAAC"}
|
package/dist/src/colors/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/colors/utils.ts
|
|
2
2
|
import chroma from "chroma-js";
|
|
3
|
+
import Colorjs from "colorjs.io";
|
|
3
4
|
import { Hsluv } from "hsluv";
|
|
4
5
|
var hexToCssHsl = (hex, valuesOnly = false) => {
|
|
5
6
|
const [h, s, l] = chroma(hex).hsl();
|
|
@@ -72,6 +73,9 @@ var getLuminanceFromLightness = (lightness) => {
|
|
|
72
73
|
conv.hsluvToHex();
|
|
73
74
|
return chroma(conv.hex).luminance();
|
|
74
75
|
};
|
|
76
|
+
var getLuminanceFromColor = (color) => {
|
|
77
|
+
return chroma(color).luminance();
|
|
78
|
+
};
|
|
75
79
|
var getLightnessFromHex = (hex) => {
|
|
76
80
|
const conv = new Hsluv();
|
|
77
81
|
conv.hex = hex;
|
|
@@ -106,14 +110,42 @@ var rgbToHex = (rgb) => {
|
|
|
106
110
|
return hex.length === 1 ? "0" + hex : hex;
|
|
107
111
|
}).join("")}`;
|
|
108
112
|
};
|
|
113
|
+
var convertColor = (cssColor, format) => {
|
|
114
|
+
const color = new Colorjs(cssColor);
|
|
115
|
+
switch (format) {
|
|
116
|
+
case "rgb":
|
|
117
|
+
case "rgba":
|
|
118
|
+
return color.toString({
|
|
119
|
+
format: {
|
|
120
|
+
name: format,
|
|
121
|
+
coords: ["<number>[0, 255]", "<number>[0, 255]", "<number>[0, 255]"]
|
|
122
|
+
},
|
|
123
|
+
precision: 3
|
|
124
|
+
});
|
|
125
|
+
case "hex":
|
|
126
|
+
return color.toString({ format, precision: 3 });
|
|
127
|
+
case "hct":
|
|
128
|
+
return color.to(format).toString({
|
|
129
|
+
format: {
|
|
130
|
+
name: format,
|
|
131
|
+
coords: ["<number>", "<number>", "<number>"]
|
|
132
|
+
},
|
|
133
|
+
precision: 3
|
|
134
|
+
});
|
|
135
|
+
default:
|
|
136
|
+
return color.to(format).toString({ precision: 3 });
|
|
137
|
+
}
|
|
138
|
+
};
|
|
109
139
|
export {
|
|
110
140
|
HSLToHex,
|
|
111
141
|
areColorsContrasting,
|
|
112
142
|
canTextBeUsedOnColors,
|
|
143
|
+
convertColor,
|
|
113
144
|
convertToHex,
|
|
114
145
|
getContrastFromHex,
|
|
115
146
|
getContrastFromLightness,
|
|
116
147
|
getLightnessFromHex,
|
|
148
|
+
getLuminanceFromColor,
|
|
117
149
|
getLuminanceFromLightness,
|
|
118
150
|
hexToCssHsl,
|
|
119
151
|
hexToHSL,
|
package/dist/src/config.js
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/colors/utils.ts
|
|
2
2
|
import chroma from "chroma-js";
|
|
3
|
+
import Colorjs from "colorjs.io";
|
|
3
4
|
import { Hsluv } from "hsluv";
|
|
4
5
|
var hexToCssHsl = (hex, valuesOnly = false) => {
|
|
5
6
|
const [h, s, l] = chroma(hex).hsl();
|
|
@@ -72,6 +73,9 @@ var getLuminanceFromLightness = (lightness) => {
|
|
|
72
73
|
conv.hsluvToHex();
|
|
73
74
|
return chroma(conv.hex).luminance();
|
|
74
75
|
};
|
|
76
|
+
var getLuminanceFromColor = (color) => {
|
|
77
|
+
return chroma(color).luminance();
|
|
78
|
+
};
|
|
75
79
|
var getLightnessFromHex = (hex) => {
|
|
76
80
|
const conv = new Hsluv();
|
|
77
81
|
conv.hex = hex;
|
|
@@ -106,6 +110,32 @@ var rgbToHex = (rgb) => {
|
|
|
106
110
|
return hex.length === 1 ? "0" + hex : hex;
|
|
107
111
|
}).join("")}`;
|
|
108
112
|
};
|
|
113
|
+
var convertColor = (cssColor, format) => {
|
|
114
|
+
const color = new Colorjs(cssColor);
|
|
115
|
+
switch (format) {
|
|
116
|
+
case "rgb":
|
|
117
|
+
case "rgba":
|
|
118
|
+
return color.toString({
|
|
119
|
+
format: {
|
|
120
|
+
name: format,
|
|
121
|
+
coords: ["<number>[0, 255]", "<number>[0, 255]", "<number>[0, 255]"]
|
|
122
|
+
},
|
|
123
|
+
precision: 3
|
|
124
|
+
});
|
|
125
|
+
case "hex":
|
|
126
|
+
return color.toString({ format, precision: 3 });
|
|
127
|
+
case "hct":
|
|
128
|
+
return color.to(format).toString({
|
|
129
|
+
format: {
|
|
130
|
+
name: format,
|
|
131
|
+
coords: ["<number>", "<number>", "<number>"]
|
|
132
|
+
},
|
|
133
|
+
precision: 3
|
|
134
|
+
});
|
|
135
|
+
default:
|
|
136
|
+
return color.to(format).toString({ precision: 3 });
|
|
137
|
+
}
|
|
138
|
+
};
|
|
109
139
|
|
|
110
140
|
// src/colors/theme.ts
|
|
111
141
|
import chroma2 from "chroma-js";
|
|
@@ -2201,107 +2231,16 @@ var createTokens = async (opts) => {
|
|
|
2201
2231
|
};
|
|
2202
2232
|
|
|
2203
2233
|
// src/tokens/format.ts
|
|
2204
|
-
import * as
|
|
2205
|
-
import chalk3 from "chalk";
|
|
2234
|
+
import * as R20 from "ramda";
|
|
2206
2235
|
|
|
2207
|
-
//
|
|
2208
|
-
var package_default = {
|
|
2209
|
-
name: "@digdir/designsystemet",
|
|
2210
|
-
version: "1.0.4",
|
|
2211
|
-
description: "CLI for Designsystemet",
|
|
2212
|
-
author: "Designsystemet team",
|
|
2213
|
-
engines: {
|
|
2214
|
-
node: ">=22.14.0"
|
|
2215
|
-
},
|
|
2216
|
-
repository: {
|
|
2217
|
-
type: "git",
|
|
2218
|
-
url: "git+https://github.com/digdir/designsystemet.git"
|
|
2219
|
-
},
|
|
2220
|
-
homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
|
|
2221
|
-
license: "MIT",
|
|
2222
|
-
type: "module",
|
|
2223
|
-
main: "./dist/src/index.js",
|
|
2224
|
-
files: [
|
|
2225
|
-
"./dist/**"
|
|
2226
|
-
],
|
|
2227
|
-
bin: "dist/bin/designsystemet.js",
|
|
2228
|
-
exports: {
|
|
2229
|
-
".": {
|
|
2230
|
-
import: "./dist/src/index.js"
|
|
2231
|
-
},
|
|
2232
|
-
"./color": {
|
|
2233
|
-
import: "./dist/src/colors/index.js"
|
|
2234
|
-
},
|
|
2235
|
-
"./tokens": {
|
|
2236
|
-
import: "./dist/src/tokens/index.js"
|
|
2237
|
-
}
|
|
2238
|
-
},
|
|
2239
|
-
publishConfig: {
|
|
2240
|
-
access: "public"
|
|
2241
|
-
},
|
|
2242
|
-
scripts: {
|
|
2243
|
-
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
2244
|
-
"build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
2245
|
-
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
2246
|
-
build: "tsup && yarn build:types && yarn build:json-schema",
|
|
2247
|
-
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
2248
|
-
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
2249
|
-
types: "tsc --noEmit",
|
|
2250
|
-
"test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens-create --theme options-test --clean",
|
|
2251
|
-
"test:tokens-create-config": "yarn designsystemet tokens create --config ./test-tokens-create-complex.config.json",
|
|
2252
|
-
"test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens-create -o ./test-tokens-build --clean",
|
|
2253
|
-
"test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
|
|
2254
|
-
"test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
|
|
2255
|
-
test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
|
|
2256
|
-
"internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
|
|
2257
|
-
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
2258
|
-
"update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
2259
|
-
verify: "yarn test && yarn update:template && yarn update:design-tokens"
|
|
2260
|
-
},
|
|
2261
|
-
dependencies: {
|
|
2262
|
-
"@commander-js/extra-typings": "^13.1.0",
|
|
2263
|
-
"@tokens-studio/sd-transforms": "1.2.12",
|
|
2264
|
-
"apca-w3": "^0.1.9",
|
|
2265
|
-
chalk: "^5.4.1",
|
|
2266
|
-
"change-case": "^5.4.4",
|
|
2267
|
-
"chroma-js": "^3.1.2",
|
|
2268
|
-
commander: "^13.1.0",
|
|
2269
|
-
"fast-glob": "^3.3.3",
|
|
2270
|
-
hsluv: "^1.0.1",
|
|
2271
|
-
"object-hash": "^3.0.0",
|
|
2272
|
-
postcss: "^8.5.3",
|
|
2273
|
-
ramda: "^0.30.1",
|
|
2274
|
-
"style-dictionary": "^4.3.3",
|
|
2275
|
-
zod: "^3.24.2",
|
|
2276
|
-
"zod-validation-error": "^3.4.0"
|
|
2277
|
-
},
|
|
2278
|
-
devDependencies: {
|
|
2279
|
-
"@types/apca-w3": "^0.1.3",
|
|
2280
|
-
"@types/chroma-js": "^3.1.1",
|
|
2281
|
-
"@types/fs-extra": "^11.0.4",
|
|
2282
|
-
"@types/glob": "^8.1.0",
|
|
2283
|
-
"@types/jscodeshift": "^0.12.0",
|
|
2284
|
-
"@types/node": "^22.14.0",
|
|
2285
|
-
"@types/object-hash": "^3.0.6",
|
|
2286
|
-
"@types/ramda": "^0.30.2",
|
|
2287
|
-
"fs-extra": "^11.3.0",
|
|
2288
|
-
"ts-toolbelt": "^9.6.0",
|
|
2289
|
-
tslib: "^2.8.1",
|
|
2290
|
-
tsup: "^8.4.0",
|
|
2291
|
-
tsx: "^4.19.3",
|
|
2292
|
-
typescript: "^5.8.2",
|
|
2293
|
-
"zod-to-json-schema": "^3.24.5"
|
|
2294
|
-
}
|
|
2295
|
-
};
|
|
2296
|
-
|
|
2297
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
2236
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
2298
2237
|
var BoxShadowTypes;
|
|
2299
2238
|
(function(BoxShadowTypes2) {
|
|
2300
2239
|
BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
|
|
2301
2240
|
BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
|
|
2302
2241
|
})(BoxShadowTypes || (BoxShadowTypes = {}));
|
|
2303
2242
|
|
|
2304
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
|
|
2243
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
|
|
2305
2244
|
var ColorModifierTypes;
|
|
2306
2245
|
(function(ColorModifierTypes2) {
|
|
2307
2246
|
ColorModifierTypes2["LIGHTEN"] = "lighten";
|
|
@@ -2310,7 +2249,7 @@ var ColorModifierTypes;
|
|
|
2310
2249
|
ColorModifierTypes2["ALPHA"] = "alpha";
|
|
2311
2250
|
})(ColorModifierTypes || (ColorModifierTypes = {}));
|
|
2312
2251
|
|
|
2313
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
|
|
2252
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
|
|
2314
2253
|
var ColorSpaceTypes;
|
|
2315
2254
|
(function(ColorSpaceTypes2) {
|
|
2316
2255
|
ColorSpaceTypes2["LCH"] = "lch";
|
|
@@ -2319,7 +2258,7 @@ var ColorSpaceTypes;
|
|
|
2319
2258
|
ColorSpaceTypes2["HSL"] = "hsl";
|
|
2320
2259
|
})(ColorSpaceTypes || (ColorSpaceTypes = {}));
|
|
2321
2260
|
|
|
2322
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/Properties.js
|
|
2261
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js
|
|
2323
2262
|
var Properties;
|
|
2324
2263
|
(function(Properties2) {
|
|
2325
2264
|
Properties2["sizing"] = "sizing";
|
|
@@ -2371,7 +2310,7 @@ var Properties;
|
|
|
2371
2310
|
Properties2["description"] = "description";
|
|
2372
2311
|
})(Properties || (Properties = {}));
|
|
2373
2312
|
|
|
2374
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
|
|
2313
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
|
|
2375
2314
|
var TokenSetStatus;
|
|
2376
2315
|
(function(TokenSetStatus2) {
|
|
2377
2316
|
TokenSetStatus2["DISABLED"] = "disabled";
|
|
@@ -2379,7 +2318,7 @@ var TokenSetStatus;
|
|
|
2379
2318
|
TokenSetStatus2["ENABLED"] = "enabled";
|
|
2380
2319
|
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
2381
2320
|
|
|
2382
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
|
|
2321
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
|
|
2383
2322
|
var TokenTypes;
|
|
2384
2323
|
(function(TokenTypes2) {
|
|
2385
2324
|
TokenTypes2["OTHER"] = "other";
|
|
@@ -2410,7 +2349,7 @@ var TokenTypes;
|
|
|
2410
2349
|
TokenTypes2["NUMBER"] = "number";
|
|
2411
2350
|
})(TokenTypes || (TokenTypes = {}));
|
|
2412
2351
|
|
|
2413
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js
|
|
2352
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js
|
|
2414
2353
|
var BorderValues;
|
|
2415
2354
|
(function(BorderValues2) {
|
|
2416
2355
|
BorderValues2["BORDER_COLOR"] = "color";
|
|
@@ -2418,7 +2357,7 @@ var BorderValues;
|
|
|
2418
2357
|
BorderValues2["BORDER_STYLE"] = "style";
|
|
2419
2358
|
})(BorderValues || (BorderValues = {}));
|
|
2420
2359
|
|
|
2421
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
|
|
2360
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
|
|
2422
2361
|
var StrokeStyleValues;
|
|
2423
2362
|
(function(StrokeStyleValues2) {
|
|
2424
2363
|
StrokeStyleValues2["SOLID"] = "solid";
|
|
@@ -2431,7 +2370,7 @@ var StrokeStyleValues;
|
|
|
2431
2370
|
StrokeStyleValues2["INSET"] = "inset";
|
|
2432
2371
|
})(StrokeStyleValues || (StrokeStyleValues = {}));
|
|
2433
2372
|
|
|
2434
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
|
|
2373
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
|
|
2435
2374
|
var BoxShadowValues;
|
|
2436
2375
|
(function(BoxShadowValues2) {
|
|
2437
2376
|
BoxShadowValues2["TYPE"] = "type";
|
|
@@ -2443,7 +2382,7 @@ var BoxShadowValues;
|
|
|
2443
2382
|
BoxShadowValues2["BLEND_MODE"] = "blendMode";
|
|
2444
2383
|
})(BoxShadowValues || (BoxShadowValues = {}));
|
|
2445
2384
|
|
|
2446
|
-
// ../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
|
|
2385
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
|
|
2447
2386
|
var TypographyValues;
|
|
2448
2387
|
(function(TypographyValues2) {
|
|
2449
2388
|
TypographyValues2["FONT_FAMILY"] = "fontFamily";
|
|
@@ -2647,20 +2586,24 @@ var mapToLowerCase = R7.map(R7.toLower);
|
|
|
2647
2586
|
var hasAnyTruth = R7.any(R7.equals(true));
|
|
2648
2587
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2649
2588
|
var getValue = (token) => token.$value ?? token.value;
|
|
2650
|
-
var typeEquals = R7.curry(
|
|
2651
|
-
|
|
2652
|
-
|
|
2589
|
+
var typeEquals = R7.curry(
|
|
2590
|
+
(types, token) => {
|
|
2591
|
+
if (R7.isNil(token)) {
|
|
2592
|
+
return false;
|
|
2593
|
+
}
|
|
2594
|
+
return R7.includes(R7.toLower(getType(token)), R7.map(R7.toLower, Array.isArray(types) ? types : [types]));
|
|
2653
2595
|
}
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2596
|
+
);
|
|
2597
|
+
var pathStartsWithOneOf = R7.curry(
|
|
2598
|
+
(paths, token) => {
|
|
2599
|
+
if (R7.isNil(token)) {
|
|
2600
|
+
return false;
|
|
2601
|
+
}
|
|
2602
|
+
const tokenPath = mapToLowerCase(token.path);
|
|
2603
|
+
const matchPathsStartingWith = R7.map((path) => R7.startsWith([path], tokenPath), mapToLowerCase(paths));
|
|
2604
|
+
return hasAnyTruth(matchPathsStartingWith);
|
|
2659
2605
|
}
|
|
2660
|
-
|
|
2661
|
-
const matchPathsStartingWith = R7.map((path) => R7.startsWith([path], tokenPath), mapToLowerCase(paths));
|
|
2662
|
-
return hasAnyTruth(matchPathsStartingWith);
|
|
2663
|
-
});
|
|
2606
|
+
);
|
|
2664
2607
|
function isSemanticToken(token) {
|
|
2665
2608
|
return token.filePath.includes("semantic/");
|
|
2666
2609
|
}
|
|
@@ -3448,7 +3391,7 @@ var buildConfigs = {
|
|
|
3448
3391
|
// },
|
|
3449
3392
|
};
|
|
3450
3393
|
async function processPlatform(options) {
|
|
3451
|
-
const {
|
|
3394
|
+
const { process, $themes } = options;
|
|
3452
3395
|
const platform = "css";
|
|
3453
3396
|
const tokenSets = process === "format" ? options.tokenSets : void 0;
|
|
3454
3397
|
const tokensDir = process === "build" ? options.tokensDir : void 0;
|
|
@@ -3549,36 +3492,118 @@ ${colors.map((color) => ` ${color}: never;`).join("\n")}
|
|
|
3549
3492
|
return typeDeclaration;
|
|
3550
3493
|
}
|
|
3551
3494
|
|
|
3552
|
-
// src/tokens/
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
}
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3495
|
+
// src/tokens/process/theme.ts
|
|
3496
|
+
import * as R19 from "ramda";
|
|
3497
|
+
import chalk3 from "chalk";
|
|
3498
|
+
|
|
3499
|
+
// package.json
|
|
3500
|
+
var package_default = {
|
|
3501
|
+
name: "@digdir/designsystemet",
|
|
3502
|
+
version: "1.0.6",
|
|
3503
|
+
description: "CLI for Designsystemet",
|
|
3504
|
+
author: "Designsystemet team",
|
|
3505
|
+
engines: {
|
|
3506
|
+
node: ">=22.15.0"
|
|
3507
|
+
},
|
|
3508
|
+
repository: {
|
|
3509
|
+
type: "git",
|
|
3510
|
+
url: "git+https://github.com/digdir/designsystemet.git"
|
|
3511
|
+
},
|
|
3512
|
+
homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
|
|
3513
|
+
license: "MIT",
|
|
3514
|
+
type: "module",
|
|
3515
|
+
main: "./dist/src/index.js",
|
|
3516
|
+
files: [
|
|
3517
|
+
"./dist/**"
|
|
3518
|
+
],
|
|
3519
|
+
bin: "dist/bin/designsystemet.js",
|
|
3520
|
+
exports: {
|
|
3521
|
+
".": {
|
|
3522
|
+
import: "./dist/src/index.js"
|
|
3523
|
+
},
|
|
3524
|
+
"./color": {
|
|
3525
|
+
import: "./dist/src/colors/index.js"
|
|
3526
|
+
},
|
|
3527
|
+
"./tokens": {
|
|
3528
|
+
import: "./dist/src/tokens/index.js"
|
|
3529
|
+
}
|
|
3530
|
+
},
|
|
3531
|
+
publishConfig: {
|
|
3532
|
+
access: "public"
|
|
3533
|
+
},
|
|
3534
|
+
scripts: {
|
|
3535
|
+
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
3536
|
+
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
3537
|
+
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
3538
|
+
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
3539
|
+
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
3540
|
+
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
3541
|
+
types: "tsc --noEmit",
|
|
3542
|
+
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./test-tokens/options --theme options --clean',
|
|
3543
|
+
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./test/test-tokens.config.json",
|
|
3544
|
+
"test:tokens-build": "pnpm run designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
|
|
3545
|
+
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
|
|
3546
|
+
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
3547
|
+
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
3548
|
+
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
3549
|
+
"internal:tokens-create": "pnpm run designsystemet tokens create --config ./internal.config.json",
|
|
3550
|
+
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
3551
|
+
"update:design-tokens": "pnpm internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
3552
|
+
verify: "pnpm test && pnpm update:template && pnpm update:design-tokens"
|
|
3553
|
+
},
|
|
3554
|
+
dependencies: {
|
|
3555
|
+
"@commander-js/extra-typings": "^13.1.0",
|
|
3556
|
+
"@tokens-studio/sd-transforms": "1.3.0",
|
|
3557
|
+
"apca-w3": "^0.1.9",
|
|
3558
|
+
chalk: "^5.4.1",
|
|
3559
|
+
"change-case": "^5.4.4",
|
|
3560
|
+
"chroma-js": "^3.1.2",
|
|
3561
|
+
"colorjs.io": "^0.6.0-alpha.1",
|
|
3562
|
+
commander: "^13.1.0",
|
|
3563
|
+
"fast-glob": "^3.3.3",
|
|
3564
|
+
hsluv: "^1.0.1",
|
|
3565
|
+
"object-hash": "^3.0.0",
|
|
3566
|
+
postcss: "^8.5.3",
|
|
3567
|
+
ramda: "^0.30.1",
|
|
3568
|
+
"style-dictionary": "^4.4.0",
|
|
3569
|
+
zod: "^3.24.4",
|
|
3570
|
+
"zod-validation-error": "^3.4.0"
|
|
3571
|
+
},
|
|
3572
|
+
devDependencies: {
|
|
3573
|
+
"@tokens-studio/types": "0.5.2",
|
|
3574
|
+
"@types/apca-w3": "^0.1.3",
|
|
3575
|
+
"@types/chroma-js": "^3.1.1",
|
|
3576
|
+
"@types/fs-extra": "^11.0.4",
|
|
3577
|
+
"@types/glob": "^8.1.0",
|
|
3578
|
+
"@types/jscodeshift": "^0.12.0",
|
|
3579
|
+
"@types/node": "^22.15.3",
|
|
3580
|
+
"@types/object-hash": "^3.0.6",
|
|
3581
|
+
"@types/ramda": "^0.30.2",
|
|
3582
|
+
"fs-extra": "^11.3.0",
|
|
3583
|
+
"ts-toolbelt": "^9.6.0",
|
|
3584
|
+
tslib: "^2.8.1",
|
|
3585
|
+
tsup: "^8.4.0",
|
|
3586
|
+
tsx: "^4.19.4",
|
|
3587
|
+
typescript: "^5.8.3",
|
|
3588
|
+
"zod-to-json-schema": "^3.24.5"
|
|
3589
|
+
}
|
|
3575
3590
|
};
|
|
3576
|
-
|
|
3591
|
+
|
|
3592
|
+
// src/tokens/process/theme.ts
|
|
3593
|
+
var defaultFileHeader = `build: v${package_default.version}`;
|
|
3594
|
+
var createThemeCSSFiles = ({
|
|
3595
|
+
processedBuilds,
|
|
3596
|
+
fileHeader: fileHeader2 = defaultFileHeader
|
|
3597
|
+
}) => {
|
|
3577
3598
|
const groupedByTheme = {};
|
|
3578
3599
|
for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
|
|
3579
3600
|
for (const buildResult of buildResults) {
|
|
3580
|
-
const
|
|
3581
|
-
|
|
3601
|
+
const themeName = buildResult.permutation.theme;
|
|
3602
|
+
const newOutputs = buildResult.formatted;
|
|
3603
|
+
if (R19.isNotEmpty(newOutputs)) {
|
|
3604
|
+
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
3605
|
+
groupedByTheme[themeName] = R19.concat(currentOutputs, newOutputs);
|
|
3606
|
+
}
|
|
3582
3607
|
}
|
|
3583
3608
|
}
|
|
3584
3609
|
const sortOrder = [
|
|
@@ -3617,7 +3642,9 @@ order may change due to nondeterminism.`.trim()
|
|
|
3617
3642
|
|
|
3618
3643
|
@layer ds.theme, ds.base, ds.utilities, ds.components;
|
|
3619
3644
|
|
|
3620
|
-
/*
|
|
3645
|
+
/*
|
|
3646
|
+
${fileHeader2}
|
|
3647
|
+
*/
|
|
3621
3648
|
|
|
3622
3649
|
`;
|
|
3623
3650
|
const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
|
|
@@ -3635,6 +3662,31 @@ order may change due to nondeterminism.`.trim()
|
|
|
3635
3662
|
}));
|
|
3636
3663
|
return themeCSSFiles;
|
|
3637
3664
|
};
|
|
3665
|
+
|
|
3666
|
+
// src/tokens/format.ts
|
|
3667
|
+
var formatTokens = async (options) => {
|
|
3668
|
+
const processedBuilds = await processPlatform({
|
|
3669
|
+
process: "format",
|
|
3670
|
+
...options
|
|
3671
|
+
});
|
|
3672
|
+
return processedBuilds;
|
|
3673
|
+
};
|
|
3674
|
+
var formatTheme = async (themeConfig) => {
|
|
3675
|
+
const { tokenSets } = await createTokens(themeConfig);
|
|
3676
|
+
const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
|
|
3677
|
+
const processedBuilds = await formatTokens({
|
|
3678
|
+
tokenSets,
|
|
3679
|
+
$themes,
|
|
3680
|
+
verbose: false,
|
|
3681
|
+
preview: false
|
|
3682
|
+
});
|
|
3683
|
+
return processedBuilds;
|
|
3684
|
+
};
|
|
3685
|
+
var formatThemeCSS = async (themeConfig) => {
|
|
3686
|
+
const processedBuilds = await formatTheme(themeConfig);
|
|
3687
|
+
const themeCSSFiles = createThemeCSSFiles({ processedBuilds });
|
|
3688
|
+
return R20.head(themeCSSFiles)?.output ?? "";
|
|
3689
|
+
};
|
|
3638
3690
|
export {
|
|
3639
3691
|
HSLToHex,
|
|
3640
3692
|
RESERVED_COLORS,
|
|
@@ -3643,6 +3695,7 @@ export {
|
|
|
3643
3695
|
canTextBeUsedOnColors,
|
|
3644
3696
|
cliOptions,
|
|
3645
3697
|
colorMetadata,
|
|
3698
|
+
convertColor,
|
|
3646
3699
|
convertToHex,
|
|
3647
3700
|
createTokens,
|
|
3648
3701
|
formatThemeCSS,
|
|
@@ -3655,6 +3708,7 @@ export {
|
|
|
3655
3708
|
getContrastFromLightness,
|
|
3656
3709
|
getCssVariable,
|
|
3657
3710
|
getLightnessFromHex,
|
|
3711
|
+
getLuminanceFromColor,
|
|
3658
3712
|
getLuminanceFromLightness,
|
|
3659
3713
|
hexToCssHsl,
|
|
3660
3714
|
hexToHSL,
|