@webstudio-is/css-data 0.4.0 → 0.16.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.
@@ -21,16 +21,6 @@ __export(schema_exports, {
21
21
  Breakpoint: () => Breakpoint,
22
22
  Breakpoints: () => Breakpoints,
23
23
  CssRule: () => CssRule,
24
- FontFamilyValue: () => FontFamilyValue,
25
- InvalidValue: () => InvalidValue,
26
- KeywordValue: () => KeywordValue,
27
- Style: () => Style,
28
- StyleValue: () => StyleValue,
29
- Unit: () => Unit,
30
- UnitValue: () => UnitValue,
31
- UnsetValue: () => UnsetValue,
32
- ValidStaticStyleValue: () => ValidStaticStyleValue,
33
- VarValue: () => VarValue,
34
24
  validStaticValueTypes: () => validStaticValueTypes
35
25
  });
36
26
  module.exports = __toCommonJS(schema_exports);
@@ -50,6 +40,13 @@ const FontFamilyValue = import_zod.z.object({
50
40
  type: import_zod.z.literal("fontFamily"),
51
41
  value: import_zod.z.array(import_zod.z.string())
52
42
  });
43
+ const RgbValue = import_zod.z.object({
44
+ type: import_zod.z.literal("rgb"),
45
+ r: import_zod.z.number(),
46
+ g: import_zod.z.number(),
47
+ b: import_zod.z.number(),
48
+ alpha: import_zod.z.number()
49
+ });
53
50
  const InvalidValue = import_zod.z.object({
54
51
  type: import_zod.z.literal("invalid"),
55
52
  value: import_zod.z.string()
@@ -58,11 +55,17 @@ const UnsetValue = import_zod.z.object({
58
55
  type: import_zod.z.literal("unset"),
59
56
  value: import_zod.z.literal("")
60
57
  });
61
- const validStaticValueTypes = ["unit", "keyword", "fontFamily"];
58
+ const validStaticValueTypes = [
59
+ "unit",
60
+ "keyword",
61
+ "fontFamily",
62
+ "rgb"
63
+ ];
62
64
  const ValidStaticStyleValue = import_zod.z.union([
63
65
  UnitValue,
64
66
  KeywordValue,
65
- FontFamilyValue
67
+ FontFamilyValue,
68
+ RgbValue
66
69
  ]);
67
70
  const VarValue = import_zod.z.object({
68
71
  type: import_zod.z.literal("var"),
@@ -73,7 +76,8 @@ const StyleValue = import_zod.z.union([
73
76
  ValidStaticStyleValue,
74
77
  InvalidValue,
75
78
  UnsetValue,
76
- VarValue
79
+ VarValue,
80
+ RgbValue
77
81
  ]);
78
82
  const Style = import_zod.z.record(import_zod.z.string(), StyleValue);
79
83
  const CssRule = import_zod.z.object({
package/lib/schema.js CHANGED
@@ -14,6 +14,13 @@ const FontFamilyValue = z.object({
14
14
  type: z.literal("fontFamily"),
15
15
  value: z.array(z.string())
16
16
  });
17
+ const RgbValue = z.object({
18
+ type: z.literal("rgb"),
19
+ r: z.number(),
20
+ g: z.number(),
21
+ b: z.number(),
22
+ alpha: z.number()
23
+ });
17
24
  const InvalidValue = z.object({
18
25
  type: z.literal("invalid"),
19
26
  value: z.string()
@@ -22,11 +29,17 @@ const UnsetValue = z.object({
22
29
  type: z.literal("unset"),
23
30
  value: z.literal("")
24
31
  });
25
- const validStaticValueTypes = ["unit", "keyword", "fontFamily"];
32
+ const validStaticValueTypes = [
33
+ "unit",
34
+ "keyword",
35
+ "fontFamily",
36
+ "rgb"
37
+ ];
26
38
  const ValidStaticStyleValue = z.union([
27
39
  UnitValue,
28
40
  KeywordValue,
29
- FontFamilyValue
41
+ FontFamilyValue,
42
+ RgbValue
30
43
  ]);
31
44
  const VarValue = z.object({
32
45
  type: z.literal("var"),
@@ -37,7 +50,8 @@ const StyleValue = z.union([
37
50
  ValidStaticStyleValue,
38
51
  InvalidValue,
39
52
  UnsetValue,
40
- VarValue
53
+ VarValue,
54
+ RgbValue
41
55
  ]);
42
56
  const Style = z.record(z.string(), StyleValue);
43
57
  const CssRule = z.object({
@@ -54,15 +68,5 @@ export {
54
68
  Breakpoint,
55
69
  Breakpoints,
56
70
  CssRule,
57
- FontFamilyValue,
58
- InvalidValue,
59
- KeywordValue,
60
- Style,
61
- StyleValue,
62
- Unit,
63
- UnitValue,
64
- UnsetValue,
65
- ValidStaticStyleValue,
66
- VarValue,
67
71
  validStaticValueTypes
68
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-data",
3
- "version": "0.4.0",
3
+ "version": "0.16.0",
4
4
  "description": "CSS Data",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
package/src/schema.ts CHANGED
@@ -16,11 +16,11 @@ type CustomProperty = `--${string}`;
16
16
 
17
17
  export type AppliesTo = Properties[StyleProperty]["appliesTo"];
18
18
 
19
- export const Unit = z.union([z.enum(units), z.literal("number")]);
19
+ const Unit = z.union([z.enum(units), z.literal("number")]);
20
20
 
21
21
  export type Unit = z.infer<typeof Unit>;
22
22
 
23
- export const UnitValue = z.object({
23
+ const UnitValue = z.object({
24
24
  type: z.literal("unit"),
25
25
  unit: Unit,
26
26
  value: z.number(),
@@ -28,58 +28,74 @@ export const UnitValue = z.object({
28
28
 
29
29
  export type UnitValue = z.infer<typeof UnitValue>;
30
30
 
31
- export const KeywordValue = z.object({
31
+ const KeywordValue = z.object({
32
32
  type: z.literal("keyword"),
33
33
  // @todo use exact type
34
34
  value: z.string(),
35
35
  });
36
36
  export type KeywordValue = z.infer<typeof KeywordValue>;
37
37
 
38
- export const FontFamilyValue = z.object({
38
+ const FontFamilyValue = z.object({
39
39
  type: z.literal("fontFamily"),
40
40
  value: z.array(z.string()),
41
41
  });
42
42
  export type FontFamilyValue = z.infer<typeof FontFamilyValue>;
43
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
+
44
53
  // We want to be able to render the invalid value
45
54
  // and show it is invalid visually, without saving it to the db
46
- export const InvalidValue = z.object({
55
+ const InvalidValue = z.object({
47
56
  type: z.literal("invalid"),
48
57
  value: z.string(),
49
58
  });
50
59
  export type InvalidValue = z.infer<typeof InvalidValue>;
51
60
 
52
- export const UnsetValue = z.object({
61
+ const UnsetValue = z.object({
53
62
  type: z.literal("unset"),
54
63
  value: z.literal(""),
55
64
  });
56
65
  export type UnsetValue = z.infer<typeof UnsetValue>;
57
66
 
58
- export const validStaticValueTypes = ["unit", "keyword", "fontFamily"] as const;
67
+ export const validStaticValueTypes = [
68
+ "unit",
69
+ "keyword",
70
+ "fontFamily",
71
+ "rgb",
72
+ ] as const;
59
73
 
60
- export const ValidStaticStyleValue = z.union([
74
+ const ValidStaticStyleValue = z.union([
61
75
  UnitValue,
62
76
  KeywordValue,
63
77
  FontFamilyValue,
78
+ RgbValue,
64
79
  ]);
65
80
  export type ValidStaticStyleValue = z.infer<typeof ValidStaticStyleValue>;
66
81
 
67
- export const VarValue = z.object({
82
+ const VarValue = z.object({
68
83
  type: z.literal("var"),
69
84
  value: z.string(),
70
85
  fallbacks: z.array(ValidStaticStyleValue),
71
86
  });
72
87
  export type VarValue = z.infer<typeof VarValue>;
73
88
 
74
- export const StyleValue = z.union([
89
+ const StyleValue = z.union([
75
90
  ValidStaticStyleValue,
76
91
  InvalidValue,
77
92
  UnsetValue,
78
93
  VarValue,
94
+ RgbValue,
79
95
  ]);
80
96
  export type StyleValue = z.infer<typeof StyleValue>;
81
97
 
82
- export const Style = z.record(z.string(), StyleValue);
98
+ const Style = z.record(z.string(), StyleValue);
83
99
 
84
100
  export type Style = {
85
101
  [property in StyleProperty]?: StyleValue;