@digdir/designsystemet 0.100.51 → 0.100.52
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 +16 -16
- package/dist/bin/config.d.ts.map +1 -1
- package/dist/bin/config.js +17 -2
- package/dist/config.schema.json +4 -2
- package/dist/src/colors/theme.d.ts +1 -0
- package/dist/src/colors/theme.d.ts.map +1 -1
- package/dist/src/colors/theme.js +13 -0
- package/package.json +1 -1
package/dist/bin/config.d.ts
CHANGED
|
@@ -9,16 +9,16 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
9
9
|
clean: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
themes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
11
11
|
colors: z.ZodObject<{
|
|
12
|
-
main: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>;
|
|
13
|
-
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>>>;
|
|
12
|
+
main: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>, Record<string, `#${string}`>, Record<string, string>>;
|
|
13
|
+
support: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>, Record<string, `#${string}`>, Record<string, string>>>>;
|
|
14
14
|
neutral: z.ZodEffects<z.ZodString, `#${string}`, string>;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
main: Record<string, `#${string}`>;
|
|
17
16
|
neutral: `#${string}`;
|
|
17
|
+
main: Record<string, `#${string}`>;
|
|
18
18
|
support: Record<string, `#${string}`>;
|
|
19
19
|
}, {
|
|
20
|
-
main: Record<string, string>;
|
|
21
20
|
neutral: string;
|
|
21
|
+
main: Record<string, string>;
|
|
22
22
|
support?: Record<string, string> | undefined;
|
|
23
23
|
}>;
|
|
24
24
|
typography: z.ZodOptional<z.ZodObject<{
|
|
@@ -31,8 +31,8 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
31
31
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
32
32
|
}, "strip", z.ZodTypeAny, {
|
|
33
33
|
colors: {
|
|
34
|
-
main: Record<string, `#${string}`>;
|
|
35
34
|
neutral: `#${string}`;
|
|
35
|
+
main: Record<string, `#${string}`>;
|
|
36
36
|
support: Record<string, `#${string}`>;
|
|
37
37
|
};
|
|
38
38
|
typography?: {
|
|
@@ -41,8 +41,8 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
41
41
|
borderRadius?: number | undefined;
|
|
42
42
|
}, {
|
|
43
43
|
colors: {
|
|
44
|
-
main: Record<string, string>;
|
|
45
44
|
neutral: string;
|
|
45
|
+
main: Record<string, string>;
|
|
46
46
|
support?: Record<string, string> | undefined;
|
|
47
47
|
};
|
|
48
48
|
typography?: {
|
|
@@ -53,8 +53,8 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
53
53
|
}, "strip", z.ZodTypeAny, {
|
|
54
54
|
themes: Record<string, {
|
|
55
55
|
colors: {
|
|
56
|
-
main: Record<string, `#${string}`>;
|
|
57
56
|
neutral: `#${string}`;
|
|
57
|
+
main: Record<string, `#${string}`>;
|
|
58
58
|
support: Record<string, `#${string}`>;
|
|
59
59
|
};
|
|
60
60
|
typography?: {
|
|
@@ -67,8 +67,8 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
67
67
|
}, {
|
|
68
68
|
themes: Record<string, {
|
|
69
69
|
colors: {
|
|
70
|
-
main: Record<string, string>;
|
|
71
70
|
neutral: string;
|
|
71
|
+
main: Record<string, string>;
|
|
72
72
|
support?: Record<string, string> | undefined;
|
|
73
73
|
};
|
|
74
74
|
typography?: {
|
|
@@ -88,16 +88,16 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
88
88
|
clean: z.ZodBoolean;
|
|
89
89
|
themes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
90
90
|
colors: z.ZodObject<{
|
|
91
|
-
main: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>;
|
|
92
|
-
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>>>;
|
|
91
|
+
main: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>, Record<string, `#${string}`>, Record<string, string>>;
|
|
92
|
+
support: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>, Record<string, `#${string}`>, Record<string, string>>>>;
|
|
93
93
|
neutral: z.ZodEffects<z.ZodString, `#${string}`, string>;
|
|
94
94
|
}, "strip", z.ZodTypeAny, {
|
|
95
|
-
main: Record<string, `#${string}`>;
|
|
96
95
|
neutral: `#${string}`;
|
|
96
|
+
main: Record<string, `#${string}`>;
|
|
97
97
|
support: Record<string, `#${string}`>;
|
|
98
98
|
}, {
|
|
99
|
-
main: Record<string, string>;
|
|
100
99
|
neutral: string;
|
|
100
|
+
main: Record<string, string>;
|
|
101
101
|
support?: Record<string, string> | undefined;
|
|
102
102
|
}>;
|
|
103
103
|
typography: z.ZodOptional<z.ZodObject<{
|
|
@@ -110,8 +110,8 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
110
110
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
111
111
|
}, "strip", z.ZodTypeAny, {
|
|
112
112
|
colors: {
|
|
113
|
-
main: Record<string, `#${string}`>;
|
|
114
113
|
neutral: `#${string}`;
|
|
114
|
+
main: Record<string, `#${string}`>;
|
|
115
115
|
support: Record<string, `#${string}`>;
|
|
116
116
|
};
|
|
117
117
|
typography?: {
|
|
@@ -120,8 +120,8 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
120
120
|
borderRadius?: number | undefined;
|
|
121
121
|
}, {
|
|
122
122
|
colors: {
|
|
123
|
-
main: Record<string, string>;
|
|
124
123
|
neutral: string;
|
|
124
|
+
main: Record<string, string>;
|
|
125
125
|
support?: Record<string, string> | undefined;
|
|
126
126
|
};
|
|
127
127
|
typography?: {
|
|
@@ -133,8 +133,8 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
133
133
|
clean: boolean;
|
|
134
134
|
themes: Record<string, {
|
|
135
135
|
colors: {
|
|
136
|
-
main: Record<string, `#${string}`>;
|
|
137
136
|
neutral: `#${string}`;
|
|
137
|
+
main: Record<string, `#${string}`>;
|
|
138
138
|
support: Record<string, `#${string}`>;
|
|
139
139
|
};
|
|
140
140
|
typography?: {
|
|
@@ -147,8 +147,8 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
147
147
|
clean: boolean;
|
|
148
148
|
themes: Record<string, {
|
|
149
149
|
colors: {
|
|
150
|
-
main: Record<string, string>;
|
|
151
150
|
neutral: string;
|
|
151
|
+
main: Record<string, string>;
|
|
152
152
|
support?: Record<string, string> | undefined;
|
|
153
153
|
};
|
|
154
154
|
typography?: {
|
package/dist/bin/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../bin/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../bin/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,sBAQ5D;AAWD,eAAO,MAAM,UAAU,QAA2C,CAAC;AA+CnE;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA8B,CAAC;AAChE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/bin/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { convertToHex } from "../src/colors/index.js";
|
|
4
|
+
import { RESERVED_COLORS } from "../src/colors/theme.js";
|
|
4
5
|
import { cliOptions } from "../src/tokens/create.js";
|
|
5
6
|
function mapPathToOptionName(path) {
|
|
6
7
|
const normalisedPath = path[0] === "themes" ? ["theme", ...R.drop(2, path)] : path;
|
|
@@ -17,9 +18,23 @@ const hexPatterns = [
|
|
|
17
18
|
`#[0-9a-fA-F]{6}`,
|
|
18
19
|
`#[0-9a-fA-F]{8}`
|
|
19
20
|
];
|
|
21
|
+
const reservedColorsPattern = `^(?!(?:${RESERVED_COLORS.join("|")})$)`;
|
|
20
22
|
const colorRegex = new RegExp(`^${hexPatterns.join("|")}$`);
|
|
21
|
-
const colorSchema = z.string({
|
|
22
|
-
|
|
23
|
+
const colorSchema = z.string({
|
|
24
|
+
description: `A hex color, which is used for creating a color scale. Invalid color names: ${RESERVED_COLORS.join(", ")}`
|
|
25
|
+
}).regex(colorRegex).transform(convertToHex);
|
|
26
|
+
const colorCategorySchema = z.record(
|
|
27
|
+
z.string().regex(new RegExp(reservedColorsPattern, "i"), {
|
|
28
|
+
message: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
29
|
+
}),
|
|
30
|
+
colorSchema,
|
|
31
|
+
{
|
|
32
|
+
description: "One or more color definitions",
|
|
33
|
+
invalid_type_error: "Color definitions must be hex color values"
|
|
34
|
+
}
|
|
35
|
+
).refine((colors) => !Object.keys(colors).some((key) => RESERVED_COLORS.includes(key.toLowerCase())), {
|
|
36
|
+
message: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
37
|
+
});
|
|
23
38
|
const themeSchema = z.object(
|
|
24
39
|
{
|
|
25
40
|
colors: z.object(
|
package/dist/config.schema.json
CHANGED
|
@@ -25,13 +25,15 @@
|
|
|
25
25
|
"additionalProperties": {
|
|
26
26
|
"type": "string",
|
|
27
27
|
"pattern": "^#[0-9a-fA-F]{3}|#[0-9a-fA-F]{4}|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{8}$",
|
|
28
|
-
"description": "A hex color, which is used for creating a color scale"
|
|
28
|
+
"description": "A hex color, which is used for creating a color scale. Invalid color names: neutral, success, warning, danger, info, blue, green, orange, purple, red"
|
|
29
|
+
},
|
|
30
|
+
"propertyNames": {
|
|
31
|
+
"pattern": "^(?!(?:neutral|success|warning|danger|info|blue|green|orange|purple|red)$)"
|
|
29
32
|
},
|
|
30
33
|
"description": "One or more color definitions"
|
|
31
34
|
},
|
|
32
35
|
"support": {
|
|
33
36
|
"$ref": "#/properties/themes/additionalProperties/properties/colors/properties/main",
|
|
34
|
-
"description": "One or more color definitions",
|
|
35
37
|
"default": {}
|
|
36
38
|
},
|
|
37
39
|
"neutral": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/colors/theme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7E;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAW,QAAQ,eAAe,WAAW,KAAG,KAAK,EAwBnF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,UAAW,QAAQ,KAAG,SAIrD,CAAC;AAgCH;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,UAAW,QAAQ,QAAQ,SAAS,GAAG,QAAQ,KAAG,QAgBnF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,cAAe,MAAM,eAAe,WAAW,WAEzE,CAAC"}
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/colors/theme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7E,eAAO,MAAM,eAAe,UAW3B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAW,QAAQ,eAAe,WAAW,KAAG,KAAK,EAwBnF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,UAAW,QAAQ,KAAG,SAIrD,CAAC;AAgCH;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,UAAW,QAAQ,QAAQ,SAAS,GAAG,QAAQ,KAAG,QAgBnF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,cAAe,MAAM,eAAe,WAAW,WAEzE,CAAC"}
|
package/dist/src/colors/theme.js
CHANGED
|
@@ -2,6 +2,18 @@ import chroma from "chroma-js";
|
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { colorMetadata, getColorMetadataByNumber } from "./colorMetadata.js";
|
|
4
4
|
import { getLightnessFromHex, getLuminanceFromLightness } from "./utils.js";
|
|
5
|
+
const RESERVED_COLORS = [
|
|
6
|
+
"neutral",
|
|
7
|
+
"success",
|
|
8
|
+
"warning",
|
|
9
|
+
"danger",
|
|
10
|
+
"info",
|
|
11
|
+
"blue",
|
|
12
|
+
"green",
|
|
13
|
+
"orange",
|
|
14
|
+
"purple",
|
|
15
|
+
"red"
|
|
16
|
+
];
|
|
5
17
|
const generateColorScale = (color, colorScheme) => {
|
|
6
18
|
const colors = R.mapObjIndexed((colorData) => {
|
|
7
19
|
const luminance = colorData.luminance[colorScheme];
|
|
@@ -60,6 +72,7 @@ const getCssVariable = (colorType, colorNumber) => {
|
|
|
60
72
|
return `--ds-color-${colorType}-${getColorMetadataByNumber(colorNumber).displayName.toLowerCase().replace(/\s/g, "-")}`;
|
|
61
73
|
};
|
|
62
74
|
export {
|
|
75
|
+
RESERVED_COLORS,
|
|
63
76
|
generateColorContrast,
|
|
64
77
|
generateColorScale,
|
|
65
78
|
generateColorSchemes,
|