@webstudio-is/css-data 0.19.0 → 0.20.0
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/lib/__generated__/keyword-values.js +507 -2315
- package/lib/__generated__/properties.js +494 -165
- package/lib/__generated__/units.js +62 -31
- package/lib/cjs/__generated__/keyword-values.cjs +507 -2315
- package/lib/cjs/__generated__/properties.cjs +494 -165
- package/lib/cjs/__generated__/units.cjs +62 -31
- package/lib/cjs/schema.cjs +22 -5
- package/lib/schema.js +22 -5
- package/package.json +4 -3
- package/src/__generated__/keyword-values.ts +495 -2303
- package/src/__generated__/properties.ts +493 -164
- package/src/__generated__/units.ts +63 -32
- package/src/schema.ts +38 -3
|
@@ -1,32 +1,63 @@
|
|
|
1
|
-
// This file was generated by
|
|
2
|
-
export const units =
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
"deg",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
// This file was generated by pnpm mdn-data
|
|
2
|
+
export const units = {
|
|
3
|
+
number: [],
|
|
4
|
+
percentage: ["%"],
|
|
5
|
+
angle: ["deg", "grad", "rad", "turn"],
|
|
6
|
+
decibel: ["db"],
|
|
7
|
+
flex: ["fr"],
|
|
8
|
+
frequency: ["hz", "khz"],
|
|
9
|
+
length: [
|
|
10
|
+
"cm",
|
|
11
|
+
"mm",
|
|
12
|
+
"q",
|
|
13
|
+
"in",
|
|
14
|
+
"pt",
|
|
15
|
+
"pc",
|
|
16
|
+
"px",
|
|
17
|
+
"em",
|
|
18
|
+
"rem",
|
|
19
|
+
"ex",
|
|
20
|
+
"rex",
|
|
21
|
+
"cap",
|
|
22
|
+
"rcap",
|
|
23
|
+
"ch",
|
|
24
|
+
"rch",
|
|
25
|
+
"ic",
|
|
26
|
+
"ric",
|
|
27
|
+
"lh",
|
|
28
|
+
"rlh",
|
|
29
|
+
"vw",
|
|
30
|
+
"svw",
|
|
31
|
+
"lvw",
|
|
32
|
+
"dvw",
|
|
33
|
+
"vh",
|
|
34
|
+
"svh",
|
|
35
|
+
"lvh",
|
|
36
|
+
"dvh",
|
|
37
|
+
"vi",
|
|
38
|
+
"svi",
|
|
39
|
+
"lvi",
|
|
40
|
+
"dvi",
|
|
41
|
+
"vb",
|
|
42
|
+
"svb",
|
|
43
|
+
"lvb",
|
|
44
|
+
"dvb",
|
|
45
|
+
"vmin",
|
|
46
|
+
"svmin",
|
|
47
|
+
"lvmin",
|
|
48
|
+
"dvmin",
|
|
49
|
+
"vmax",
|
|
50
|
+
"svmax",
|
|
51
|
+
"lvmax",
|
|
52
|
+
"dvmax",
|
|
53
|
+
"cqw",
|
|
54
|
+
"cqh",
|
|
55
|
+
"cqi",
|
|
56
|
+
"cqb",
|
|
57
|
+
"cqmin",
|
|
58
|
+
"cqmax",
|
|
59
|
+
],
|
|
60
|
+
resolution: ["dpi", "dpcm", "dppx", "x"],
|
|
61
|
+
semitones: ["st"],
|
|
62
|
+
time: ["s", "ms"],
|
|
63
|
+
} as const;
|
package/src/schema.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { units } from "./__generated__/units";
|
|
2
2
|
import { properties } from "./__generated__/properties";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { ImageAsset } from "@webstudio-is/asset-uploader";
|
|
4
5
|
|
|
5
6
|
type Properties = typeof properties & {
|
|
6
7
|
[custom: CustomProperty]: {
|
|
@@ -16,7 +17,16 @@ type CustomProperty = `--${string}`;
|
|
|
16
17
|
|
|
17
18
|
export type AppliesTo = Properties[StyleProperty]["appliesTo"];
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
export type UnitGroup = keyof typeof units;
|
|
21
|
+
|
|
22
|
+
type UnitEnum = typeof units[UnitGroup][number];
|
|
23
|
+
|
|
24
|
+
const Unit = z.union([
|
|
25
|
+
// expected tuple with at least single element
|
|
26
|
+
// so cast to tuple with single union element to get correct inference
|
|
27
|
+
z.enum(Object.values(units).flat() as [UnitEnum]),
|
|
28
|
+
z.literal("number"),
|
|
29
|
+
]);
|
|
20
30
|
|
|
21
31
|
export type Unit = z.infer<typeof Unit>;
|
|
22
32
|
|
|
@@ -50,6 +60,13 @@ const RgbValue = z.object({
|
|
|
50
60
|
});
|
|
51
61
|
export type RgbValue = z.infer<typeof RgbValue>;
|
|
52
62
|
|
|
63
|
+
export const ImageValue = z.object({
|
|
64
|
+
type: z.literal("image"),
|
|
65
|
+
value: z.array(z.object({ type: z.literal("asset"), value: ImageAsset })),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export type ImageValue = z.infer<typeof ImageValue>;
|
|
69
|
+
|
|
53
70
|
// We want to be able to render the invalid value
|
|
54
71
|
// and show it is invalid visually, without saving it to the db
|
|
55
72
|
const InvalidValue = z.object({
|
|
@@ -69,14 +86,22 @@ export const validStaticValueTypes = [
|
|
|
69
86
|
"keyword",
|
|
70
87
|
"fontFamily",
|
|
71
88
|
"rgb",
|
|
89
|
+
"image",
|
|
72
90
|
] as const;
|
|
73
91
|
|
|
74
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Shared zod types with DB types.
|
|
94
|
+
* ImageValue in DB has a different type
|
|
95
|
+
*/
|
|
96
|
+
const SharedStaticStyleValue = z.union([
|
|
75
97
|
UnitValue,
|
|
76
98
|
KeywordValue,
|
|
77
99
|
FontFamilyValue,
|
|
78
100
|
RgbValue,
|
|
79
101
|
]);
|
|
102
|
+
|
|
103
|
+
const ValidStaticStyleValue = z.union([ImageValue, SharedStaticStyleValue]);
|
|
104
|
+
|
|
80
105
|
export type ValidStaticStyleValue = z.infer<typeof ValidStaticStyleValue>;
|
|
81
106
|
|
|
82
107
|
const VarValue = z.object({
|
|
@@ -91,8 +116,18 @@ const StyleValue = z.union([
|
|
|
91
116
|
InvalidValue,
|
|
92
117
|
UnsetValue,
|
|
93
118
|
VarValue,
|
|
94
|
-
RgbValue,
|
|
95
119
|
]);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Shared types with DB types
|
|
123
|
+
*/
|
|
124
|
+
export const SharedStyleValue = z.union([
|
|
125
|
+
SharedStaticStyleValue,
|
|
126
|
+
InvalidValue,
|
|
127
|
+
UnsetValue,
|
|
128
|
+
VarValue,
|
|
129
|
+
]);
|
|
130
|
+
|
|
96
131
|
export type StyleValue = z.infer<typeof StyleValue>;
|
|
97
132
|
|
|
98
133
|
const Style = z.record(z.string(), StyleValue);
|