@digdir/designsystemet 1.0.8 → 1.1.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/config.d.ts +3 -3
- package/dist/bin/config.d.ts.map +1 -1
- package/dist/bin/config.js +45 -45
- package/dist/bin/designsystemet.js +827 -748
- package/dist/config.schema.json +4 -4
- 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 +6 -21
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +43 -40
- package/dist/src/index.js +418 -430
- package/dist/src/scripts/createJsonSchema.js +23 -24
- package/dist/src/scripts/update-template.d.ts.map +1 -1
- package/dist/src/tokens/build.d.ts +1 -1
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +359 -280
- package/dist/src/tokens/create/generators/$designsystemet.js +16 -15
- package/dist/src/tokens/create/generators/color.js +21 -21
- package/dist/src/tokens/create/write.js +17 -16
- 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 +931 -944
- 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 +295 -307
- 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/declarations.d.ts +4 -0
- package/dist/src/tokens/process/output/declarations.d.ts.map +1 -0
- package/dist/src/tokens/process/output/declarations.js +860 -0
- 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} +20 -19
- package/dist/src/tokens/process/platform.d.ts +8 -4
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +27 -56
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts +1 -0
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -1
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +12 -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 +16 -15
- package/dist/src/tokens/process/theme.d.ts.map +0 -1
package/dist/config.schema.json
CHANGED
|
@@ -9,10 +9,6 @@
|
|
|
9
9
|
"description": "Path to the output directory for the created design tokens",
|
|
10
10
|
"type": "string"
|
|
11
11
|
},
|
|
12
|
-
"clean": {
|
|
13
|
-
"description": "Delete the output directory before building or creating tokens",
|
|
14
|
-
"type": "boolean"
|
|
15
|
-
},
|
|
16
12
|
"themes": {
|
|
17
13
|
"description": "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name.",
|
|
18
14
|
"type": "object",
|
|
@@ -85,6 +81,10 @@
|
|
|
85
81
|
],
|
|
86
82
|
"additionalProperties": false
|
|
87
83
|
}
|
|
84
|
+
},
|
|
85
|
+
"clean": {
|
|
86
|
+
"description": "Delete the output directory before building or creating tokens",
|
|
87
|
+
"type": "boolean"
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
"required": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/colors/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/colors/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
package/dist/src/colors/index.js
CHANGED
|
@@ -1,146 +1,3 @@
|
|
|
1
|
-
// src/colors/utils.ts
|
|
2
|
-
import chroma from "chroma-js";
|
|
3
|
-
import Colorjs from "colorjs.io";
|
|
4
|
-
import { Hsluv } from "hsluv";
|
|
5
|
-
var hexToCssHsl = (hex, valuesOnly = false) => {
|
|
6
|
-
const [h, s, l] = chroma(hex).hsl();
|
|
7
|
-
const hRounded = Math.round(h);
|
|
8
|
-
const sRounded = Math.round(s * 100);
|
|
9
|
-
const lRounded = Math.round(l * 100);
|
|
10
|
-
const cssString = `${hRounded},${sRounded}%,${lRounded}%`;
|
|
11
|
-
return valuesOnly ? cssString : `hsl(${cssString})`;
|
|
12
|
-
};
|
|
13
|
-
var hexToHSL = (hex) => {
|
|
14
|
-
const [h, s, l] = chroma(hex).hsl();
|
|
15
|
-
return [Math.round(h), Math.round(s * 100), Math.round(l * 100)];
|
|
16
|
-
};
|
|
17
|
-
var hexToHsluv = (hex) => {
|
|
18
|
-
const conv = new Hsluv();
|
|
19
|
-
conv.hex = hex;
|
|
20
|
-
conv.hexToHsluv();
|
|
21
|
-
return [conv.hsluv_h, conv.hsluv_s, conv.hsluv_l];
|
|
22
|
-
};
|
|
23
|
-
var hslArrToCss = (HSL) => {
|
|
24
|
-
return "hsl(" + HSL[0] + "," + HSL[1] + "%," + HSL[2] + "%)";
|
|
25
|
-
};
|
|
26
|
-
var HSLToHex = (h, s, l) => {
|
|
27
|
-
return chroma.hsl(h, s / 100, l / 100).hex();
|
|
28
|
-
};
|
|
29
|
-
var hexToRgb = (hex, type = "255") => {
|
|
30
|
-
const rgb = chroma(hex).rgb();
|
|
31
|
-
return {
|
|
32
|
-
r: type === "255" ? rgb[0] : rgb[0] / 255,
|
|
33
|
-
g: type === "255" ? rgb[1] : rgb[1] / 255,
|
|
34
|
-
b: type === "255" ? rgb[2] : rgb[2] / 255
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
var getContrastFromHex = (color1, color2) => {
|
|
38
|
-
const lum1 = chroma(color1).luminance();
|
|
39
|
-
const lum2 = chroma(color2).luminance();
|
|
40
|
-
return (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
|
|
41
|
-
};
|
|
42
|
-
var getContrastFromLightness = (lightness, mainColor, backgroundColor) => {
|
|
43
|
-
const conv = new Hsluv();
|
|
44
|
-
conv.hex = mainColor;
|
|
45
|
-
conv.hexToHsluv();
|
|
46
|
-
conv.hsluv_l = lightness;
|
|
47
|
-
conv.hsluvToHex();
|
|
48
|
-
const lightMainColor = conv.hex;
|
|
49
|
-
const lum1 = chroma(lightMainColor).luminance();
|
|
50
|
-
const lum2 = chroma(backgroundColor).luminance();
|
|
51
|
-
const ratio = (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
|
|
52
|
-
return ratio;
|
|
53
|
-
};
|
|
54
|
-
var areColorsContrasting = (color1, color2, type = "aa") => {
|
|
55
|
-
const contrast = getContrastFromHex(color1, color2);
|
|
56
|
-
if (contrast !== null) {
|
|
57
|
-
if (type === "aaa") {
|
|
58
|
-
return contrast >= 7;
|
|
59
|
-
}
|
|
60
|
-
if (type === "aa") {
|
|
61
|
-
return contrast >= 4.5;
|
|
62
|
-
}
|
|
63
|
-
return contrast >= 3;
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
};
|
|
67
|
-
var isHexColor = (hex) => {
|
|
68
|
-
return typeof hex === "string" && hex.length === 6 && !Number.isNaN(Number("0x" + hex));
|
|
69
|
-
};
|
|
70
|
-
var getLuminanceFromLightness = (lightness) => {
|
|
71
|
-
const conv = new Hsluv();
|
|
72
|
-
conv.hsluv_l = lightness;
|
|
73
|
-
conv.hsluvToHex();
|
|
74
|
-
return chroma(conv.hex).luminance();
|
|
75
|
-
};
|
|
76
|
-
var getLuminanceFromColor = (color) => {
|
|
77
|
-
return chroma(color).luminance();
|
|
78
|
-
};
|
|
79
|
-
var getLightnessFromHex = (hex) => {
|
|
80
|
-
const conv = new Hsluv();
|
|
81
|
-
conv.hex = hex;
|
|
82
|
-
conv.hexToHsluv();
|
|
83
|
-
return conv.hsluv_l;
|
|
84
|
-
};
|
|
85
|
-
var canTextBeUsedOnColors = (baseDefaultColor, baseActiveColor) => {
|
|
86
|
-
const defaultAgainstWhite = getContrastFromHex(baseDefaultColor, "#ffffff");
|
|
87
|
-
const defaultAgainstBlack = getContrastFromHex(baseDefaultColor, "#000000");
|
|
88
|
-
const activeAgainstWhite = getContrastFromHex(baseActiveColor, "#ffffff");
|
|
89
|
-
const activeAgainstBlack = getContrastFromHex(baseActiveColor, "#000000");
|
|
90
|
-
if (defaultAgainstWhite >= 4.5 && activeAgainstWhite >= 4.5) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
if (defaultAgainstBlack >= 4.5 && activeAgainstBlack >= 4.5) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
};
|
|
98
|
-
var convertToHex = (color) => {
|
|
99
|
-
if (!color) {
|
|
100
|
-
return "#000000";
|
|
101
|
-
}
|
|
102
|
-
if (/^#[0-9A-Fa-f]{6}$/.test(color)) {
|
|
103
|
-
return color;
|
|
104
|
-
}
|
|
105
|
-
return chroma(color).hex();
|
|
106
|
-
};
|
|
107
|
-
var rgbToHex = (rgb) => {
|
|
108
|
-
return `#${[rgb.r, rgb.g, rgb.b].map((x) => {
|
|
109
|
-
const hex = Math.round(x * 255).toString(16);
|
|
110
|
-
return hex.length === 1 ? "0" + hex : hex;
|
|
111
|
-
}).join("")}`;
|
|
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
|
-
};
|
|
139
|
-
|
|
140
|
-
// src/colors/theme.ts
|
|
141
|
-
import chroma2 from "chroma-js";
|
|
142
|
-
import * as R2 from "ramda";
|
|
143
|
-
|
|
144
1
|
// src/colors/colorMetadata.ts
|
|
145
2
|
import * as R from "ramda";
|
|
146
3
|
var baseColors = {
|
|
@@ -397,6 +254,149 @@ var getColorMetadataByNumber = (number) => {
|
|
|
397
254
|
return colorMetadataByNumber[number];
|
|
398
255
|
};
|
|
399
256
|
|
|
257
|
+
// src/colors/theme.ts
|
|
258
|
+
import chroma2 from "chroma-js";
|
|
259
|
+
import * as R2 from "ramda";
|
|
260
|
+
|
|
261
|
+
// src/colors/utils.ts
|
|
262
|
+
import chroma from "chroma-js";
|
|
263
|
+
import Colorjs from "colorjs.io";
|
|
264
|
+
import { Hsluv } from "hsluv";
|
|
265
|
+
var hexToCssHsl = (hex, valuesOnly = false) => {
|
|
266
|
+
const [h, s, l] = chroma(hex).hsl();
|
|
267
|
+
const hRounded = Math.round(h);
|
|
268
|
+
const sRounded = Math.round(s * 100);
|
|
269
|
+
const lRounded = Math.round(l * 100);
|
|
270
|
+
const cssString = `${hRounded},${sRounded}%,${lRounded}%`;
|
|
271
|
+
return valuesOnly ? cssString : `hsl(${cssString})`;
|
|
272
|
+
};
|
|
273
|
+
var hexToHSL = (hex) => {
|
|
274
|
+
const [h, s, l] = chroma(hex).hsl();
|
|
275
|
+
return [Math.round(h), Math.round(s * 100), Math.round(l * 100)];
|
|
276
|
+
};
|
|
277
|
+
var hexToHsluv = (hex) => {
|
|
278
|
+
const conv = new Hsluv();
|
|
279
|
+
conv.hex = hex;
|
|
280
|
+
conv.hexToHsluv();
|
|
281
|
+
return [conv.hsluv_h, conv.hsluv_s, conv.hsluv_l];
|
|
282
|
+
};
|
|
283
|
+
var hslArrToCss = (HSL) => {
|
|
284
|
+
return "hsl(" + HSL[0] + "," + HSL[1] + "%," + HSL[2] + "%)";
|
|
285
|
+
};
|
|
286
|
+
var HSLToHex = (h, s, l) => {
|
|
287
|
+
return chroma.hsl(h, s / 100, l / 100).hex();
|
|
288
|
+
};
|
|
289
|
+
var hexToRgb = (hex, type = "255") => {
|
|
290
|
+
const rgb = chroma(hex).rgb();
|
|
291
|
+
return {
|
|
292
|
+
r: type === "255" ? rgb[0] : rgb[0] / 255,
|
|
293
|
+
g: type === "255" ? rgb[1] : rgb[1] / 255,
|
|
294
|
+
b: type === "255" ? rgb[2] : rgb[2] / 255
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
var getContrastFromHex = (color1, color2) => {
|
|
298
|
+
const lum1 = chroma(color1).luminance();
|
|
299
|
+
const lum2 = chroma(color2).luminance();
|
|
300
|
+
return (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
|
|
301
|
+
};
|
|
302
|
+
var getContrastFromLightness = (lightness, mainColor, backgroundColor) => {
|
|
303
|
+
const conv = new Hsluv();
|
|
304
|
+
conv.hex = mainColor;
|
|
305
|
+
conv.hexToHsluv();
|
|
306
|
+
conv.hsluv_l = lightness;
|
|
307
|
+
conv.hsluvToHex();
|
|
308
|
+
const lightMainColor = conv.hex;
|
|
309
|
+
const lum1 = chroma(lightMainColor).luminance();
|
|
310
|
+
const lum2 = chroma(backgroundColor).luminance();
|
|
311
|
+
const ratio = (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
|
|
312
|
+
return ratio;
|
|
313
|
+
};
|
|
314
|
+
var areColorsContrasting = (color1, color2, type = "aa") => {
|
|
315
|
+
const contrast = getContrastFromHex(color1, color2);
|
|
316
|
+
if (contrast !== null) {
|
|
317
|
+
if (type === "aaa") {
|
|
318
|
+
return contrast >= 7;
|
|
319
|
+
}
|
|
320
|
+
if (type === "aa") {
|
|
321
|
+
return contrast >= 4.5;
|
|
322
|
+
}
|
|
323
|
+
return contrast >= 3;
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
};
|
|
327
|
+
var isHexColor = (hex) => {
|
|
328
|
+
return typeof hex === "string" && hex.length === 6 && !Number.isNaN(Number("0x" + hex));
|
|
329
|
+
};
|
|
330
|
+
var getLuminanceFromLightness = (lightness) => {
|
|
331
|
+
const conv = new Hsluv();
|
|
332
|
+
conv.hsluv_l = lightness;
|
|
333
|
+
conv.hsluvToHex();
|
|
334
|
+
return chroma(conv.hex).luminance();
|
|
335
|
+
};
|
|
336
|
+
var getLuminanceFromColor = (color) => {
|
|
337
|
+
return chroma(color).luminance();
|
|
338
|
+
};
|
|
339
|
+
var getLightnessFromHex = (hex) => {
|
|
340
|
+
const conv = new Hsluv();
|
|
341
|
+
conv.hex = hex;
|
|
342
|
+
conv.hexToHsluv();
|
|
343
|
+
return conv.hsluv_l;
|
|
344
|
+
};
|
|
345
|
+
var canTextBeUsedOnColors = (baseDefaultColor, baseActiveColor) => {
|
|
346
|
+
const defaultAgainstWhite = getContrastFromHex(baseDefaultColor, "#ffffff");
|
|
347
|
+
const defaultAgainstBlack = getContrastFromHex(baseDefaultColor, "#000000");
|
|
348
|
+
const activeAgainstWhite = getContrastFromHex(baseActiveColor, "#ffffff");
|
|
349
|
+
const activeAgainstBlack = getContrastFromHex(baseActiveColor, "#000000");
|
|
350
|
+
if (defaultAgainstWhite >= 4.5 && activeAgainstWhite >= 4.5) {
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
if (defaultAgainstBlack >= 4.5 && activeAgainstBlack >= 4.5) {
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
return false;
|
|
357
|
+
};
|
|
358
|
+
var convertToHex = (color) => {
|
|
359
|
+
if (!color) {
|
|
360
|
+
return "#000000";
|
|
361
|
+
}
|
|
362
|
+
if (/^#[0-9A-Fa-f]{6}$/.test(color)) {
|
|
363
|
+
return color;
|
|
364
|
+
}
|
|
365
|
+
return chroma(color).hex();
|
|
366
|
+
};
|
|
367
|
+
var rgbToHex = (rgb) => {
|
|
368
|
+
return `#${[rgb.r, rgb.g, rgb.b].map((x) => {
|
|
369
|
+
const hex = Math.round(x * 255).toString(16);
|
|
370
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
371
|
+
}).join("")}`;
|
|
372
|
+
};
|
|
373
|
+
var convertColor = (cssColor, format) => {
|
|
374
|
+
const color = new Colorjs(cssColor);
|
|
375
|
+
switch (format) {
|
|
376
|
+
case "rgb":
|
|
377
|
+
case "rgba":
|
|
378
|
+
return color.toString({
|
|
379
|
+
format: {
|
|
380
|
+
name: format,
|
|
381
|
+
coords: ["<number>[0, 255]", "<number>[0, 255]", "<number>[0, 255]"]
|
|
382
|
+
},
|
|
383
|
+
precision: 3
|
|
384
|
+
});
|
|
385
|
+
case "hex":
|
|
386
|
+
return color.toString({ format, precision: 3 });
|
|
387
|
+
case "hct":
|
|
388
|
+
return color.to(format).toString({
|
|
389
|
+
format: {
|
|
390
|
+
name: format,
|
|
391
|
+
coords: ["<number>", "<number>", "<number>"]
|
|
392
|
+
},
|
|
393
|
+
precision: 3
|
|
394
|
+
});
|
|
395
|
+
default:
|
|
396
|
+
return color.to(format).toString({ precision: 3 });
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
400
400
|
// src/colors/theme.ts
|
|
401
401
|
var RESERVED_COLORS = [
|
|
402
402
|
"neutral",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { CssColor } from './types.js';
|
|
2
|
-
import type { Color, ColorNumber, ColorScheme, ThemeInfo } from './types.js';
|
|
1
|
+
import type { Color, ColorNumber, ColorScheme, CssColor, ThemeInfo } from './types.js';
|
|
3
2
|
export declare const RESERVED_COLORS: string[];
|
|
4
3
|
/**
|
|
5
4
|
* Generates a color scale based on a base color and a color mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/colors/theme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/colors/theme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvF,eAAO,MAAM,eAAe,UAW3B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,QAAQ,EAAE,aAAa,WAAW,KAAG,KAAK,EAiCnF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,QAAQ,KAAG,SAIrD,CAAC;AAgCH;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,QAAQ,EAAE,MAAM,SAAS,GAAG,QAAQ,KAAG,QAgBnF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,EAAE,aAAa,WAAW,WAEzE,CAAC"}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { z } from 'zod/v4';
|
|
|
9
9
|
* @throws Exits the process with code 1 if validation fails, after logging a friendly error message.
|
|
10
10
|
*/
|
|
11
11
|
export declare function validateConfig<T>(schema: z.ZodType<T>, unvalidatedConfig: Record<string, unknown>, configPath: string): T;
|
|
12
|
-
export declare function parseConfig<T>(
|
|
12
|
+
export declare function parseConfig<T>(configFile: string, configPath: string): T;
|
|
13
13
|
export declare const colorRegex: RegExp;
|
|
14
14
|
declare const themeSchema: z.ZodObject<{
|
|
15
15
|
colors: z.ZodObject<{
|
|
@@ -22,28 +22,13 @@ declare const themeSchema: z.ZodObject<{
|
|
|
22
22
|
}, z.core.$strip>>;
|
|
23
23
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
24
24
|
}, z.core.$strip>;
|
|
25
|
-
export declare const
|
|
25
|
+
export declare const commonConfig: z.ZodObject<{
|
|
26
26
|
clean: z.ZodOptional<z.ZodBoolean>;
|
|
27
27
|
}, z.core.$strip>;
|
|
28
|
-
export declare const configFileCreateSchema: z.ZodObject<{
|
|
29
|
-
outDir: z.ZodNonOptional<z.ZodString>;
|
|
30
|
-
clean: z.ZodNonOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
31
|
-
themes: z.ZodNonOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
32
|
-
colors: z.ZodObject<{
|
|
33
|
-
main: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
34
|
-
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>>>;
|
|
35
|
-
neutral: z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>;
|
|
36
|
-
}, z.core.$strip>;
|
|
37
|
-
typography: z.ZodOptional<z.ZodObject<{
|
|
38
|
-
fontFamily: z.ZodString;
|
|
39
|
-
}, z.core.$strip>>;
|
|
40
|
-
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
41
|
-
}, z.core.$strip>>>;
|
|
42
|
-
}, z.core.$strip>;
|
|
43
28
|
/**
|
|
44
29
|
* This defines the structure of the final configuration file
|
|
45
30
|
*/
|
|
46
|
-
export declare const
|
|
31
|
+
export declare const configFileCreateSchema: z.ZodObject<{
|
|
47
32
|
outDir: z.ZodNonOptional<z.ZodString>;
|
|
48
33
|
themes: z.ZodNonOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
49
34
|
colors: z.ZodObject<{
|
|
@@ -58,9 +43,9 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
58
43
|
}, z.core.$strip>>>;
|
|
59
44
|
clean: z.ZodOptional<z.ZodBoolean>;
|
|
60
45
|
}, z.core.$strip>;
|
|
61
|
-
export type
|
|
62
|
-
export type
|
|
63
|
-
export type
|
|
46
|
+
export type CommonConfigSchema = z.infer<typeof commonConfig>;
|
|
47
|
+
export type BuildConfigSchema = z.infer<typeof commonConfig>;
|
|
48
|
+
export type CreateConfigSchema = z.infer<typeof configFileCreateSchema>;
|
|
64
49
|
export type ConfigSchemaTheme = z.infer<typeof themeSchema>;
|
|
65
50
|
export {};
|
|
66
51
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAsC3B;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EACpB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,UAAU,EAAE,MAAM,GACjB,CAAC,CAUH;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,CAexE;AAWD,eAAO,MAAM,UAAU,QAA2C,CAAC;AAyBnE,QAAA,MAAM,WAAW;;;;;;;;;;iBAiBmG,CAAC;AAErH,eAAO,MAAM,YAAY;;iBAEvB,CAAC;AAYH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;iBAAqD,CAAC;AACzF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACxE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
package/dist/src/config.js
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
// src/config.ts
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import * as R7 from "ramda";
|
|
4
|
-
import { fromError } from "zod-validation-error";
|
|
5
4
|
import { z } from "zod/v4";
|
|
6
|
-
|
|
7
|
-
// src/colors/utils.ts
|
|
8
|
-
import chroma from "chroma-js";
|
|
9
|
-
import Colorjs from "colorjs.io";
|
|
10
|
-
import { Hsluv } from "hsluv";
|
|
11
|
-
var convertToHex = (color) => {
|
|
12
|
-
if (!color) {
|
|
13
|
-
return "#000000";
|
|
14
|
-
}
|
|
15
|
-
if (/^#[0-9A-Fa-f]{6}$/.test(color)) {
|
|
16
|
-
return color;
|
|
17
|
-
}
|
|
18
|
-
return chroma(color).hex();
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// src/colors/theme.ts
|
|
22
|
-
import chroma2 from "chroma-js";
|
|
23
|
-
import * as R2 from "ramda";
|
|
5
|
+
import { fromError } from "zod-validation-error/v4";
|
|
24
6
|
|
|
25
7
|
// src/colors/colorMetadata.ts
|
|
26
8
|
import * as R from "ramda";
|
|
@@ -268,6 +250,24 @@ var colorMetadata = {
|
|
|
268
250
|
};
|
|
269
251
|
var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
270
252
|
|
|
253
|
+
// src/colors/theme.ts
|
|
254
|
+
import chroma2 from "chroma-js";
|
|
255
|
+
import * as R2 from "ramda";
|
|
256
|
+
|
|
257
|
+
// src/colors/utils.ts
|
|
258
|
+
import chroma from "chroma-js";
|
|
259
|
+
import Colorjs from "colorjs.io";
|
|
260
|
+
import { Hsluv } from "hsluv";
|
|
261
|
+
var convertToHex = (color) => {
|
|
262
|
+
if (!color) {
|
|
263
|
+
return "#000000";
|
|
264
|
+
}
|
|
265
|
+
if (/^#[0-9A-Fa-f]{6}$/.test(color)) {
|
|
266
|
+
return color;
|
|
267
|
+
}
|
|
268
|
+
return chroma(color).hex();
|
|
269
|
+
};
|
|
270
|
+
|
|
271
271
|
// src/colors/theme.ts
|
|
272
272
|
var RESERVED_COLORS = [
|
|
273
273
|
"neutral",
|
|
@@ -298,6 +298,7 @@ import * as R6 from "ramda";
|
|
|
298
298
|
var cliOptions = {
|
|
299
299
|
outDir: "out-dir",
|
|
300
300
|
clean: "clean",
|
|
301
|
+
tailwind: "tailwind",
|
|
301
302
|
theme: {
|
|
302
303
|
colors: {
|
|
303
304
|
main: "main-colors",
|
|
@@ -321,16 +322,21 @@ function mapPathToOptionName(path2) {
|
|
|
321
322
|
return option;
|
|
322
323
|
}
|
|
323
324
|
function makeFriendlyError(err) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
325
|
+
try {
|
|
326
|
+
return fromError(err, {
|
|
327
|
+
messageBuilder: (issues) => issues.map((issue) => {
|
|
328
|
+
const issuePath = issue.path.join(".");
|
|
329
|
+
const optionName = mapPathToOptionName(issue.path);
|
|
330
|
+
const errorCode = `(error code: ${issue.code})`;
|
|
331
|
+
const optionMessage = optionName ? ` or CLI option --${optionName}` : "";
|
|
332
|
+
return ` - Error in JSON value ${chalk.red(issuePath)}${optionMessage}:
|
|
333
|
+
${issue.message} ${chalk.dim(errorCode)}`;
|
|
334
|
+
}).join("\n")
|
|
335
|
+
});
|
|
336
|
+
} catch (_err2) {
|
|
337
|
+
console.error(chalk.red(err instanceof Error ? err.message : "Unknown error occurred while parsing config file"));
|
|
338
|
+
console.error(err instanceof Error ? err.stack : "No stack trace available");
|
|
339
|
+
}
|
|
334
340
|
}
|
|
335
341
|
function validateConfig(schema, unvalidatedConfig, configPath) {
|
|
336
342
|
try {
|
|
@@ -338,21 +344,20 @@ function validateConfig(schema, unvalidatedConfig, configPath) {
|
|
|
338
344
|
} catch (err) {
|
|
339
345
|
console.error(chalk.redBright(`Invalid config file at ${chalk.red(configPath)}`));
|
|
340
346
|
const validationError = makeFriendlyError(err);
|
|
341
|
-
console.error(validationError
|
|
347
|
+
console.error(validationError?.toString());
|
|
342
348
|
process.exit(1);
|
|
343
349
|
}
|
|
344
350
|
}
|
|
345
|
-
function parseConfig(
|
|
351
|
+
function parseConfig(configFile, configPath) {
|
|
346
352
|
if (!configFile) {
|
|
347
353
|
return {};
|
|
348
354
|
}
|
|
349
355
|
try {
|
|
350
|
-
|
|
351
|
-
return schema.parse(parsedConfig);
|
|
356
|
+
return JSON.parse(configFile);
|
|
352
357
|
} catch (err) {
|
|
353
358
|
console.error(chalk.redBright(`Failed parsing config file at ${chalk.red(configPath)}`));
|
|
354
359
|
const validationError = makeFriendlyError(err);
|
|
355
|
-
console.error(validationError
|
|
360
|
+
console.error(validationError?.toString());
|
|
356
361
|
process.exit(1);
|
|
357
362
|
}
|
|
358
363
|
}
|
|
@@ -390,21 +395,19 @@ var themeSchema = z.object({
|
|
|
390
395
|
}).describe("Defines the typography for a given theme").optional(),
|
|
391
396
|
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional()
|
|
392
397
|
}).meta({ description: "An object defining a theme. The property name holding the object becomes the theme name." });
|
|
393
|
-
var
|
|
398
|
+
var commonConfig = z.object({
|
|
394
399
|
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional()
|
|
395
400
|
});
|
|
396
|
-
var
|
|
401
|
+
var _configFileCreateSchema = z.object({
|
|
397
402
|
outDir: z.string().meta({ description: "Path to the output directory for the created design tokens" }),
|
|
398
|
-
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional(),
|
|
399
403
|
themes: z.record(z.string(), themeSchema).meta({
|
|
400
404
|
description: "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name."
|
|
401
405
|
})
|
|
402
406
|
}).required();
|
|
403
|
-
var
|
|
407
|
+
var configFileCreateSchema = _configFileCreateSchema.extend(commonConfig.shape);
|
|
404
408
|
export {
|
|
405
409
|
colorRegex,
|
|
406
|
-
|
|
407
|
-
configFileBuildSchema,
|
|
410
|
+
commonConfig,
|
|
408
411
|
configFileCreateSchema,
|
|
409
412
|
parseConfig,
|
|
410
413
|
validateConfig
|