@webstudio-is/css-data 0.2.0 → 0.4.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 +6618 -0
- package/lib/__generated__/properties.js +3201 -0
- package/lib/__generated__/units.js +34 -0
- package/lib/cjs/__generated__/keyword-values.cjs +6638 -0
- package/lib/cjs/__generated__/properties.cjs +3221 -0
- package/lib/cjs/__generated__/units.cjs +54 -0
- package/lib/cjs/index.cjs +19 -18
- package/lib/cjs/popularity-index.cjs +4631 -4612
- package/lib/cjs/schema.cjs +83 -53
- package/lib/index.js +3 -3
- package/lib/popularity-index.js +4612 -4610
- package/lib/schema.js +63 -50
- 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/src/index.ts +4 -0
- package/src/popularity-index.ts +4611 -0
- package/src/schema.ts +103 -0
- package/lib/cjs/index.d.ts +0 -5
- package/lib/cjs/index.d.ts.map +0 -1
- package/lib/cjs/keyword-values.cjs +0 -6619
- package/lib/cjs/keyword-values.d.ts +0 -302
- package/lib/cjs/keyword-values.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/properties.cjs +0 -3202
- package/lib/cjs/properties.d.ts +0 -3199
- package/lib/cjs/properties.d.ts.map +0 -1
- package/lib/cjs/schema.d.ts +0 -598
- package/lib/cjs/schema.d.ts.map +0 -1
- package/lib/cjs/units.cjs +0 -35
- package/lib/cjs/units.d.ts +0 -2
- package/lib/cjs/units.d.ts.map +0 -1
- package/lib/index.d.ts +0 -5
- package/lib/index.d.ts.map +0 -1
- package/lib/keyword-values.d.ts +0 -302
- package/lib/keyword-values.d.ts.map +0 -1
- package/lib/keyword-values.js +0 -6616
- package/lib/popularity-index.d.ts +0 -7
- package/lib/popularity-index.d.ts.map +0 -1
- package/lib/properties.d.ts +0 -3199
- package/lib/properties.d.ts.map +0 -1
- package/lib/properties.js +0 -3199
- package/lib/schema.d.ts +0 -598
- package/lib/schema.d.ts.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/units.d.ts +0 -2
- package/lib/units.d.ts.map +0 -1
- package/lib/units.js +0 -32
package/src/schema.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
export const Unit = z.union([z.enum(units), z.literal("number")]);
|
|
20
|
+
|
|
21
|
+
export type Unit = z.infer<typeof Unit>;
|
|
22
|
+
|
|
23
|
+
export 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
|
+
export 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
|
+
export 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
|
+
// We want to be able to render the invalid value
|
|
45
|
+
// and show it is invalid visually, without saving it to the db
|
|
46
|
+
export const InvalidValue = z.object({
|
|
47
|
+
type: z.literal("invalid"),
|
|
48
|
+
value: z.string(),
|
|
49
|
+
});
|
|
50
|
+
export type InvalidValue = z.infer<typeof InvalidValue>;
|
|
51
|
+
|
|
52
|
+
export const UnsetValue = z.object({
|
|
53
|
+
type: z.literal("unset"),
|
|
54
|
+
value: z.literal(""),
|
|
55
|
+
});
|
|
56
|
+
export type UnsetValue = z.infer<typeof UnsetValue>;
|
|
57
|
+
|
|
58
|
+
export const validStaticValueTypes = ["unit", "keyword", "fontFamily"] as const;
|
|
59
|
+
|
|
60
|
+
export const ValidStaticStyleValue = z.union([
|
|
61
|
+
UnitValue,
|
|
62
|
+
KeywordValue,
|
|
63
|
+
FontFamilyValue,
|
|
64
|
+
]);
|
|
65
|
+
export type ValidStaticStyleValue = z.infer<typeof ValidStaticStyleValue>;
|
|
66
|
+
|
|
67
|
+
export const VarValue = z.object({
|
|
68
|
+
type: z.literal("var"),
|
|
69
|
+
value: z.string(),
|
|
70
|
+
fallbacks: z.array(ValidStaticStyleValue),
|
|
71
|
+
});
|
|
72
|
+
export type VarValue = z.infer<typeof VarValue>;
|
|
73
|
+
|
|
74
|
+
export const StyleValue = z.union([
|
|
75
|
+
ValidStaticStyleValue,
|
|
76
|
+
InvalidValue,
|
|
77
|
+
UnsetValue,
|
|
78
|
+
VarValue,
|
|
79
|
+
]);
|
|
80
|
+
export type StyleValue = z.infer<typeof StyleValue>;
|
|
81
|
+
|
|
82
|
+
export const Style = z.record(z.string(), StyleValue);
|
|
83
|
+
|
|
84
|
+
export type Style = {
|
|
85
|
+
[property in StyleProperty]?: StyleValue;
|
|
86
|
+
} & { [property: CustomProperty]: StyleValue };
|
|
87
|
+
|
|
88
|
+
export const CssRule = z.object({
|
|
89
|
+
style: Style,
|
|
90
|
+
breakpoint: z.optional(z.string()),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export type CssRule = z.infer<typeof CssRule>;
|
|
94
|
+
|
|
95
|
+
export const Breakpoint = z.object({
|
|
96
|
+
id: z.string(),
|
|
97
|
+
label: z.string(),
|
|
98
|
+
minWidth: z.number(),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const Breakpoints = z.array(Breakpoint);
|
|
102
|
+
|
|
103
|
+
export type Breakpoint = z.infer<typeof Breakpoint>;
|
package/lib/cjs/index.d.ts
DELETED
package/lib/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|