@digdir/designsystemet 1.0.5 → 1.0.7
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/configs/digdir.config.json +59 -0
- package/configs/test-tokens.config.json +45 -0
- package/dist/bin/designsystemet.js +82 -88
- package/dist/config.schema.json +38 -27
- 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.d.ts +24 -176
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +23 -32
- package/dist/src/index.js +85 -50
- package/dist/src/migrations/beta-to-v1.js +2 -2
- package/dist/src/migrations/codemods/css/run.js +2 -2
- package/dist/src/migrations/color-rename-next49.js +2 -2
- package/dist/src/migrations/index.js +2 -2
- package/dist/src/scripts/createJsonSchema.js +33 -1292
- package/dist/src/scripts/update-design-tokens.js +4 -4
- package/dist/src/scripts/update-template.js +7 -7
- package/dist/src/tokens/build.js +56 -53
- package/dist/src/tokens/create/generators/$designsystemet.js +27 -25
- 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 +39 -37
- package/dist/src/tokens/create.js +1 -0
- package/dist/src/tokens/format.js +54 -50
- package/dist/src/tokens/index.js +54 -50
- 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 +26 -22
- package/dist/src/tokens/process/theme.d.ts.map +1 -1
- package/dist/src/tokens/process/theme.js +27 -28
- package/dist/src/tokens/process/transformers.js +16 -12
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +26 -22
- 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/dist/src/utils.js +1 -1
- package/package.json +35 -33
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.d.ts
CHANGED
|
@@ -1,49 +1,17 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
2
|
export declare function mapPathToOptionName(path: (string | number)[]): string | undefined;
|
|
3
3
|
export declare const colorRegex: RegExp;
|
|
4
4
|
declare const themeSchema: z.ZodObject<{
|
|
5
5
|
colors: z.ZodObject<{
|
|
6
|
-
main: z.
|
|
7
|
-
support: z.ZodDefault<z.ZodOptional<z.
|
|
8
|
-
neutral: z.
|
|
9
|
-
},
|
|
10
|
-
neutral: `#${string}`;
|
|
11
|
-
main: Record<string, `#${string}`>;
|
|
12
|
-
support: Record<string, `#${string}`>;
|
|
13
|
-
}, {
|
|
14
|
-
neutral: string;
|
|
15
|
-
main: Record<string, string>;
|
|
16
|
-
support?: Record<string, string> | undefined;
|
|
17
|
-
}>;
|
|
6
|
+
main: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
7
|
+
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>>>;
|
|
8
|
+
neutral: z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
18
10
|
typography: z.ZodOptional<z.ZodObject<{
|
|
19
11
|
fontFamily: z.ZodString;
|
|
20
|
-
},
|
|
21
|
-
fontFamily: string;
|
|
22
|
-
}, {
|
|
23
|
-
fontFamily: string;
|
|
24
|
-
}>>;
|
|
12
|
+
}, z.core.$strip>>;
|
|
25
13
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
26
|
-
},
|
|
27
|
-
colors: {
|
|
28
|
-
neutral: `#${string}`;
|
|
29
|
-
main: Record<string, `#${string}`>;
|
|
30
|
-
support: Record<string, `#${string}`>;
|
|
31
|
-
};
|
|
32
|
-
typography?: {
|
|
33
|
-
fontFamily: string;
|
|
34
|
-
} | undefined;
|
|
35
|
-
borderRadius?: number | undefined;
|
|
36
|
-
}, {
|
|
37
|
-
colors: {
|
|
38
|
-
neutral: string;
|
|
39
|
-
main: Record<string, string>;
|
|
40
|
-
support?: Record<string, string> | undefined;
|
|
41
|
-
};
|
|
42
|
-
typography?: {
|
|
43
|
-
fontFamily: string;
|
|
44
|
-
} | undefined;
|
|
45
|
-
borderRadius?: number | undefined;
|
|
46
|
-
}>;
|
|
14
|
+
}, z.core.$strip>;
|
|
47
15
|
/**
|
|
48
16
|
* This defines the structure of the JSON config file
|
|
49
17
|
*/
|
|
@@ -52,155 +20,35 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
52
20
|
clean: z.ZodOptional<z.ZodBoolean>;
|
|
53
21
|
themes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
54
22
|
colors: z.ZodObject<{
|
|
55
|
-
main: z.
|
|
56
|
-
support: z.ZodDefault<z.ZodOptional<z.
|
|
57
|
-
neutral: z.
|
|
58
|
-
},
|
|
59
|
-
neutral: `#${string}`;
|
|
60
|
-
main: Record<string, `#${string}`>;
|
|
61
|
-
support: Record<string, `#${string}`>;
|
|
62
|
-
}, {
|
|
63
|
-
neutral: string;
|
|
64
|
-
main: Record<string, string>;
|
|
65
|
-
support?: Record<string, string> | undefined;
|
|
66
|
-
}>;
|
|
23
|
+
main: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
24
|
+
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>>>;
|
|
25
|
+
neutral: z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
67
27
|
typography: z.ZodOptional<z.ZodObject<{
|
|
68
28
|
fontFamily: z.ZodString;
|
|
69
|
-
},
|
|
70
|
-
fontFamily: string;
|
|
71
|
-
}, {
|
|
72
|
-
fontFamily: string;
|
|
73
|
-
}>>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
74
30
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
neutral: `#${string}`;
|
|
78
|
-
main: Record<string, `#${string}`>;
|
|
79
|
-
support: Record<string, `#${string}`>;
|
|
80
|
-
};
|
|
81
|
-
typography?: {
|
|
82
|
-
fontFamily: string;
|
|
83
|
-
} | undefined;
|
|
84
|
-
borderRadius?: number | undefined;
|
|
85
|
-
}, {
|
|
86
|
-
colors: {
|
|
87
|
-
neutral: string;
|
|
88
|
-
main: Record<string, string>;
|
|
89
|
-
support?: Record<string, string> | undefined;
|
|
90
|
-
};
|
|
91
|
-
typography?: {
|
|
92
|
-
fontFamily: string;
|
|
93
|
-
} | undefined;
|
|
94
|
-
borderRadius?: number | undefined;
|
|
95
|
-
}>>;
|
|
96
|
-
}, "strip", z.ZodTypeAny, {
|
|
97
|
-
themes: Record<string, {
|
|
98
|
-
colors: {
|
|
99
|
-
neutral: `#${string}`;
|
|
100
|
-
main: Record<string, `#${string}`>;
|
|
101
|
-
support: Record<string, `#${string}`>;
|
|
102
|
-
};
|
|
103
|
-
typography?: {
|
|
104
|
-
fontFamily: string;
|
|
105
|
-
} | undefined;
|
|
106
|
-
borderRadius?: number | undefined;
|
|
107
|
-
}>;
|
|
108
|
-
clean?: boolean | undefined;
|
|
109
|
-
outDir?: string | undefined;
|
|
110
|
-
}, {
|
|
111
|
-
themes: Record<string, {
|
|
112
|
-
colors: {
|
|
113
|
-
neutral: string;
|
|
114
|
-
main: Record<string, string>;
|
|
115
|
-
support?: Record<string, string> | undefined;
|
|
116
|
-
};
|
|
117
|
-
typography?: {
|
|
118
|
-
fontFamily: string;
|
|
119
|
-
} | undefined;
|
|
120
|
-
borderRadius?: number | undefined;
|
|
121
|
-
}>;
|
|
122
|
-
clean?: boolean | undefined;
|
|
123
|
-
outDir?: string | undefined;
|
|
124
|
-
}>;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
}, z.core.$strip>;
|
|
125
33
|
/**
|
|
126
34
|
* This defines the structure of the final configuration after combining the config file,
|
|
127
35
|
* command-line options and default values.
|
|
128
36
|
*/
|
|
129
37
|
export declare const combinedConfigSchema: z.ZodObject<{
|
|
130
|
-
outDir: z.ZodString
|
|
131
|
-
clean: z.ZodBoolean
|
|
132
|
-
themes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
38
|
+
outDir: z.ZodNonOptional<z.ZodOptional<z.ZodString>>;
|
|
39
|
+
clean: z.ZodNonOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
40
|
+
themes: z.ZodNonOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
133
41
|
colors: z.ZodObject<{
|
|
134
|
-
main: z.
|
|
135
|
-
support: z.ZodDefault<z.ZodOptional<z.
|
|
136
|
-
neutral: z.
|
|
137
|
-
},
|
|
138
|
-
neutral: `#${string}`;
|
|
139
|
-
main: Record<string, `#${string}`>;
|
|
140
|
-
support: Record<string, `#${string}`>;
|
|
141
|
-
}, {
|
|
142
|
-
neutral: string;
|
|
143
|
-
main: Record<string, string>;
|
|
144
|
-
support?: Record<string, string> | undefined;
|
|
145
|
-
}>;
|
|
42
|
+
main: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
43
|
+
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>>>;
|
|
44
|
+
neutral: z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
146
46
|
typography: z.ZodOptional<z.ZodObject<{
|
|
147
47
|
fontFamily: z.ZodString;
|
|
148
|
-
},
|
|
149
|
-
fontFamily: string;
|
|
150
|
-
}, {
|
|
151
|
-
fontFamily: string;
|
|
152
|
-
}>>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
153
49
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
neutral: `#${string}`;
|
|
157
|
-
main: Record<string, `#${string}`>;
|
|
158
|
-
support: Record<string, `#${string}`>;
|
|
159
|
-
};
|
|
160
|
-
typography?: {
|
|
161
|
-
fontFamily: string;
|
|
162
|
-
} | undefined;
|
|
163
|
-
borderRadius?: number | undefined;
|
|
164
|
-
}, {
|
|
165
|
-
colors: {
|
|
166
|
-
neutral: string;
|
|
167
|
-
main: Record<string, string>;
|
|
168
|
-
support?: Record<string, string> | undefined;
|
|
169
|
-
};
|
|
170
|
-
typography?: {
|
|
171
|
-
fontFamily: string;
|
|
172
|
-
} | undefined;
|
|
173
|
-
borderRadius?: number | undefined;
|
|
174
|
-
}>>;
|
|
175
|
-
}, "strip", z.ZodTypeAny, {
|
|
176
|
-
clean: boolean;
|
|
177
|
-
themes: Record<string, {
|
|
178
|
-
colors: {
|
|
179
|
-
neutral: `#${string}`;
|
|
180
|
-
main: Record<string, `#${string}`>;
|
|
181
|
-
support: Record<string, `#${string}`>;
|
|
182
|
-
};
|
|
183
|
-
typography?: {
|
|
184
|
-
fontFamily: string;
|
|
185
|
-
} | undefined;
|
|
186
|
-
borderRadius?: number | undefined;
|
|
187
|
-
}>;
|
|
188
|
-
outDir: string;
|
|
189
|
-
}, {
|
|
190
|
-
clean: boolean;
|
|
191
|
-
themes: Record<string, {
|
|
192
|
-
colors: {
|
|
193
|
-
neutral: string;
|
|
194
|
-
main: Record<string, string>;
|
|
195
|
-
support?: Record<string, string> | undefined;
|
|
196
|
-
};
|
|
197
|
-
typography?: {
|
|
198
|
-
fontFamily: string;
|
|
199
|
-
} | undefined;
|
|
200
|
-
borderRadius?: number | undefined;
|
|
201
|
-
}>;
|
|
202
|
-
outDir: string;
|
|
203
|
-
}>;
|
|
50
|
+
}, z.core.$strip>>>;
|
|
51
|
+
}, z.core.$strip>;
|
|
204
52
|
export type Config = z.infer<typeof combinedConfigSchema>;
|
|
205
53
|
export type ThemeConfig = z.infer<typeof themeSchema>;
|
|
206
54
|
export {};
|
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAK3B,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,sBAQ5D;AAWD,eAAO,MAAM,UAAU,QAA2C,CAAC;AAyBnE,QAAA,MAAM,WAAW;;;;;;;;;;iBAiBmG,CAAC;AAErH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;iBAO3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;iBAA8B,CAAC;AAChE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
package/dist/src/config.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// src/config.ts
|
|
2
2
|
import * as R7 from "ramda";
|
|
3
|
-
import { z } from "zod";
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
4
|
|
|
5
5
|
// src/colors/utils.ts
|
|
6
6
|
import chroma from "chroma-js";
|
|
7
|
+
import Colorjs from "colorjs.io";
|
|
7
8
|
import { Hsluv } from "hsluv";
|
|
8
9
|
var convertToHex = (color) => {
|
|
9
10
|
if (!color) {
|
|
@@ -326,45 +327,35 @@ var hexPatterns = [
|
|
|
326
327
|
];
|
|
327
328
|
var reservedColorsPattern = `^(?!(?:${RESERVED_COLORS.join("|")})$)`;
|
|
328
329
|
var colorRegex = new RegExp(`^${hexPatterns.join("|")}$`);
|
|
329
|
-
var colorSchema = z.string(
|
|
330
|
-
|
|
331
|
-
|
|
330
|
+
var colorSchema = z.string().regex(colorRegex).transform(convertToHex).describe(
|
|
331
|
+
`A hex color, which is used for creating a color scale. Invalid color names: ${RESERVED_COLORS.join(", ")}`
|
|
332
|
+
);
|
|
332
333
|
var colorCategorySchema = z.record(
|
|
333
334
|
z.string().regex(new RegExp(reservedColorsPattern, "i"), {
|
|
334
|
-
|
|
335
|
+
error: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
335
336
|
}),
|
|
336
337
|
colorSchema,
|
|
337
338
|
{
|
|
338
|
-
|
|
339
|
-
invalid_type_error: "Color definitions must be hex color values"
|
|
339
|
+
error: "Color definitions must be hex color values"
|
|
340
340
|
}
|
|
341
341
|
).refine((colors) => !Object.keys(colors).some((key) => RESERVED_COLORS.includes(key.toLowerCase())), {
|
|
342
|
-
|
|
343
|
-
});
|
|
344
|
-
var themeSchema = z.object(
|
|
345
|
-
{
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
{
|
|
356
|
-
fontFamily: z.string({ description: "Sets the font-family for this theme" })
|
|
357
|
-
},
|
|
358
|
-
{ description: "Defines the typography for a given theme" }
|
|
359
|
-
).optional(),
|
|
360
|
-
borderRadius: z.number({ description: "Defines the border-radius for this theme" }).optional()
|
|
361
|
-
},
|
|
362
|
-
{ description: "An object defining a theme. The property name holding the object becomes the theme name." }
|
|
363
|
-
);
|
|
342
|
+
error: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
343
|
+
}).describe("An object with one or more color definitions. The property name is used as the color name.");
|
|
344
|
+
var themeSchema = z.object({
|
|
345
|
+
colors: z.object({
|
|
346
|
+
main: colorCategorySchema,
|
|
347
|
+
support: colorCategorySchema.optional().default({}),
|
|
348
|
+
neutral: colorSchema
|
|
349
|
+
}).meta({ description: "Defines the colors for this theme" }),
|
|
350
|
+
typography: z.object({
|
|
351
|
+
fontFamily: z.string().meta({ description: "Sets the font-family for this theme" })
|
|
352
|
+
}).describe("Defines the typography for a given theme").optional(),
|
|
353
|
+
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional()
|
|
354
|
+
}).meta({ description: "An object defining a theme. The property name holding the object becomes the theme name." });
|
|
364
355
|
var configFileSchema = z.object({
|
|
365
|
-
outDir: z.string({ description: "Path to the output directory for the created design tokens" }).optional(),
|
|
366
|
-
clean: z.boolean({ description: "Delete the output directory before building or creating tokens" }).optional(),
|
|
367
|
-
themes: z.record(
|
|
356
|
+
outDir: z.string().meta({ description: "Path to the output directory for the created design tokens" }).optional(),
|
|
357
|
+
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional(),
|
|
358
|
+
themes: z.record(z.string(), themeSchema).meta({
|
|
368
359
|
description: "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name."
|
|
369
360
|
})
|
|
370
361
|
});
|