@webstudio-is/css-data 0.3.0 → 0.15.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 +6617 -6615
- package/lib/__generated__/properties.js +3200 -3198
- package/lib/__generated__/units.js +33 -31
- package/lib/cjs/__generated__/keyword-values.cjs +6636 -6617
- package/lib/cjs/__generated__/properties.cjs +3219 -3200
- package/lib/cjs/__generated__/units.cjs +52 -33
- package/lib/cjs/index.cjs +19 -18
- package/lib/cjs/popularity-index.cjs +4631 -4612
- package/lib/cjs/schema.cjs +87 -53
- package/lib/popularity-index.js +4612 -4610
- package/lib/schema.js +66 -49
- package/package.json +11 -19
- package/src/__generated__/keyword-values.ts +6616 -0
- package/src/__generated__/properties.ts +3200 -0
- package/src/__generated__/units.ts +32 -0
- package/{lib/cjs/index.d.ts → src/index.ts} +0 -1
- package/src/popularity-index.ts +4611 -0
- package/src/schema.ts +119 -0
- package/lib/__generated__/keyword-values.d.ts +0 -302
- package/lib/__generated__/keyword-values.d.ts.map +0 -1
- package/lib/__generated__/properties.d.ts +0 -3199
- package/lib/__generated__/properties.d.ts.map +0 -1
- package/lib/__generated__/units.d.ts +0 -2
- package/lib/__generated__/units.d.ts.map +0 -1
- package/lib/cjs/__generated__/keyword-values.d.ts +0 -302
- package/lib/cjs/__generated__/keyword-values.d.ts.map +0 -1
- package/lib/cjs/__generated__/properties.d.ts +0 -3199
- package/lib/cjs/__generated__/properties.d.ts.map +0 -1
- package/lib/cjs/__generated__/units.d.ts +0 -2
- package/lib/cjs/__generated__/units.d.ts.map +0 -1
- package/lib/cjs/index.d.ts.map +0 -1
- package/lib/cjs/popularity-index.d.ts +0 -7
- package/lib/cjs/popularity-index.d.ts.map +0 -1
- package/lib/cjs/schema.d.ts +0 -607
- package/lib/cjs/schema.d.ts.map +0 -1
- package/lib/index.d.ts +0 -5
- package/lib/index.d.ts.map +0 -1
- package/lib/popularity-index.d.ts +0 -7
- package/lib/popularity-index.d.ts.map +0 -1
- package/lib/schema.d.ts +0 -607
- package/lib/schema.d.ts.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
package/src/schema.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { units } from "./__generated__/units";
|
|
2
|
+
import { properties } from "./__generated__/properties";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
type Properties = typeof properties & {
|
|
6
|
+
[custom: CustomProperty]: {
|
|
7
|
+
appliesTo: "allElements";
|
|
8
|
+
initial: string;
|
|
9
|
+
inherited: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type StyleProperty = keyof Properties;
|
|
14
|
+
|
|
15
|
+
type CustomProperty = `--${string}`;
|
|
16
|
+
|
|
17
|
+
export type AppliesTo = Properties[StyleProperty]["appliesTo"];
|
|
18
|
+
|
|
19
|
+
const Unit = z.union([z.enum(units), z.literal("number")]);
|
|
20
|
+
|
|
21
|
+
export type Unit = z.infer<typeof Unit>;
|
|
22
|
+
|
|
23
|
+
const UnitValue = z.object({
|
|
24
|
+
type: z.literal("unit"),
|
|
25
|
+
unit: Unit,
|
|
26
|
+
value: z.number(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type UnitValue = z.infer<typeof UnitValue>;
|
|
30
|
+
|
|
31
|
+
const KeywordValue = z.object({
|
|
32
|
+
type: z.literal("keyword"),
|
|
33
|
+
// @todo use exact type
|
|
34
|
+
value: z.string(),
|
|
35
|
+
});
|
|
36
|
+
export type KeywordValue = z.infer<typeof KeywordValue>;
|
|
37
|
+
|
|
38
|
+
const FontFamilyValue = z.object({
|
|
39
|
+
type: z.literal("fontFamily"),
|
|
40
|
+
value: z.array(z.string()),
|
|
41
|
+
});
|
|
42
|
+
export type FontFamilyValue = z.infer<typeof FontFamilyValue>;
|
|
43
|
+
|
|
44
|
+
const RgbValue = z.object({
|
|
45
|
+
type: z.literal("rgb"),
|
|
46
|
+
r: z.number(),
|
|
47
|
+
g: z.number(),
|
|
48
|
+
b: z.number(),
|
|
49
|
+
alpha: z.number(),
|
|
50
|
+
});
|
|
51
|
+
export type RgbValue = z.infer<typeof RgbValue>;
|
|
52
|
+
|
|
53
|
+
// We want to be able to render the invalid value
|
|
54
|
+
// and show it is invalid visually, without saving it to the db
|
|
55
|
+
const InvalidValue = z.object({
|
|
56
|
+
type: z.literal("invalid"),
|
|
57
|
+
value: z.string(),
|
|
58
|
+
});
|
|
59
|
+
export type InvalidValue = z.infer<typeof InvalidValue>;
|
|
60
|
+
|
|
61
|
+
const UnsetValue = z.object({
|
|
62
|
+
type: z.literal("unset"),
|
|
63
|
+
value: z.literal(""),
|
|
64
|
+
});
|
|
65
|
+
export type UnsetValue = z.infer<typeof UnsetValue>;
|
|
66
|
+
|
|
67
|
+
export const validStaticValueTypes = [
|
|
68
|
+
"unit",
|
|
69
|
+
"keyword",
|
|
70
|
+
"fontFamily",
|
|
71
|
+
"rgb",
|
|
72
|
+
] as const;
|
|
73
|
+
|
|
74
|
+
const ValidStaticStyleValue = z.union([
|
|
75
|
+
UnitValue,
|
|
76
|
+
KeywordValue,
|
|
77
|
+
FontFamilyValue,
|
|
78
|
+
RgbValue,
|
|
79
|
+
]);
|
|
80
|
+
export type ValidStaticStyleValue = z.infer<typeof ValidStaticStyleValue>;
|
|
81
|
+
|
|
82
|
+
const VarValue = z.object({
|
|
83
|
+
type: z.literal("var"),
|
|
84
|
+
value: z.string(),
|
|
85
|
+
fallbacks: z.array(ValidStaticStyleValue),
|
|
86
|
+
});
|
|
87
|
+
export type VarValue = z.infer<typeof VarValue>;
|
|
88
|
+
|
|
89
|
+
const StyleValue = z.union([
|
|
90
|
+
ValidStaticStyleValue,
|
|
91
|
+
InvalidValue,
|
|
92
|
+
UnsetValue,
|
|
93
|
+
VarValue,
|
|
94
|
+
RgbValue,
|
|
95
|
+
]);
|
|
96
|
+
export type StyleValue = z.infer<typeof StyleValue>;
|
|
97
|
+
|
|
98
|
+
const Style = z.record(z.string(), StyleValue);
|
|
99
|
+
|
|
100
|
+
export type Style = {
|
|
101
|
+
[property in StyleProperty]?: StyleValue;
|
|
102
|
+
} & { [property: CustomProperty]: StyleValue };
|
|
103
|
+
|
|
104
|
+
export const CssRule = z.object({
|
|
105
|
+
style: Style,
|
|
106
|
+
breakpoint: z.optional(z.string()),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export type CssRule = z.infer<typeof CssRule>;
|
|
110
|
+
|
|
111
|
+
export const Breakpoint = z.object({
|
|
112
|
+
id: z.string(),
|
|
113
|
+
label: z.string(),
|
|
114
|
+
minWidth: z.number(),
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const Breakpoints = z.array(Breakpoint);
|
|
118
|
+
|
|
119
|
+
export type Breakpoint = z.infer<typeof Breakpoint>;
|