@webstudio-is/css-data 0.40.0 → 0.41.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.
@@ -57,7 +57,7 @@ const RgbValue = import_zod.z.object({
57
57
  });
58
58
  const ImageValue = import_zod.z.object({
59
59
  type: import_zod.z.literal("image"),
60
- value: import_zod.z.array(import_zod.z.object({ type: import_zod.z.literal("asset"), value: import_asset_uploader.ImageAsset }))
60
+ value: import_zod.z.object({ type: import_zod.z.literal("asset"), value: import_asset_uploader.ImageAsset })
61
61
  });
62
62
  const InvalidValue = import_zod.z.object({
63
63
  type: import_zod.z.literal("invalid"),
@@ -67,20 +67,26 @@ const UnsetValue = import_zod.z.object({
67
67
  type: import_zod.z.literal("unset"),
68
68
  value: import_zod.z.literal("")
69
69
  });
70
+ const ArrayValue = import_zod.z.object({
71
+ type: import_zod.z.literal("layers"),
72
+ value: import_zod.z.array(import_zod.z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue]))
73
+ });
70
74
  const validStaticValueTypes = [
71
75
  "unit",
72
76
  "keyword",
73
77
  "fontFamily",
74
78
  "rgb",
75
79
  "image",
76
- "unparsed"
80
+ "unparsed",
81
+ "array"
77
82
  ];
78
83
  const SharedStaticStyleValue = import_zod.z.union([
79
84
  UnitValue,
80
85
  KeywordValue,
81
86
  FontFamilyValue,
82
87
  RgbValue,
83
- UnparsedValue
88
+ UnparsedValue,
89
+ ArrayValue
84
90
  ]);
85
91
  const ValidStaticStyleValue = import_zod.z.union([ImageValue, SharedStaticStyleValue]);
86
92
  const VarValue = import_zod.z.object({
package/lib/schema.js CHANGED
@@ -31,7 +31,7 @@ const RgbValue = z.object({
31
31
  });
32
32
  const ImageValue = z.object({
33
33
  type: z.literal("image"),
34
- value: z.array(z.object({ type: z.literal("asset"), value: ImageAsset }))
34
+ value: z.object({ type: z.literal("asset"), value: ImageAsset })
35
35
  });
36
36
  const InvalidValue = z.object({
37
37
  type: z.literal("invalid"),
@@ -41,20 +41,26 @@ const UnsetValue = z.object({
41
41
  type: z.literal("unset"),
42
42
  value: z.literal("")
43
43
  });
44
+ const ArrayValue = z.object({
45
+ type: z.literal("layers"),
46
+ value: z.array(z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue]))
47
+ });
44
48
  const validStaticValueTypes = [
45
49
  "unit",
46
50
  "keyword",
47
51
  "fontFamily",
48
52
  "rgb",
49
53
  "image",
50
- "unparsed"
54
+ "unparsed",
55
+ "array"
51
56
  ];
52
57
  const SharedStaticStyleValue = z.union([
53
58
  UnitValue,
54
59
  KeywordValue,
55
60
  FontFamilyValue,
56
61
  RgbValue,
57
- UnparsedValue
62
+ UnparsedValue,
63
+ ArrayValue
58
64
  ]);
59
65
  const ValidStaticStyleValue = z.union([ImageValue, SharedStaticStyleValue]);
60
66
  const VarValue = z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-data",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "CSS Data",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -12,7 +12,7 @@
12
12
  "mdn-data": "2.0.30",
13
13
  "typescript": "4.9.5",
14
14
  "zod": "^3.19.1",
15
- "@webstudio-is/asset-uploader": "^0.40.0",
15
+ "@webstudio-is/asset-uploader": "^0.41.0",
16
16
  "@webstudio-is/scripts": "^0.0.0",
17
17
  "@webstudio-is/tsconfig": "^1.0.1"
18
18
  },
package/src/schema.ts CHANGED
@@ -19,7 +19,7 @@ export type AppliesTo = Properties[StyleProperty]["appliesTo"];
19
19
 
20
20
  export type UnitGroup = keyof typeof units;
21
21
 
22
- type UnitEnum = typeof units[UnitGroup][number];
22
+ type UnitEnum = (typeof units)[UnitGroup][number];
23
23
 
24
24
  const Unit = z.union([
25
25
  // expected tuple with at least single element
@@ -70,7 +70,7 @@ export type RgbValue = z.infer<typeof RgbValue>;
70
70
 
71
71
  export const ImageValue = z.object({
72
72
  type: z.literal("image"),
73
- value: z.array(z.object({ type: z.literal("asset"), value: ImageAsset })),
73
+ value: z.object({ type: z.literal("asset"), value: ImageAsset }),
74
74
  });
75
75
 
76
76
  export type ImageValue = z.infer<typeof ImageValue>;
@@ -89,6 +89,14 @@ const UnsetValue = z.object({
89
89
  });
90
90
  export type UnsetValue = z.infer<typeof UnsetValue>;
91
91
 
92
+ // To support background layers https://developer.mozilla.org/en-US/docs/Web/CSS/background
93
+ // and similar comma separated css properties
94
+ const ArrayValue = z.object({
95
+ type: z.literal("layers"),
96
+ value: z.array(z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue])),
97
+ });
98
+ export type ArrayValue = z.infer<typeof ArrayValue>;
99
+
92
100
  export const validStaticValueTypes = [
93
101
  "unit",
94
102
  "keyword",
@@ -96,6 +104,7 @@ export const validStaticValueTypes = [
96
104
  "rgb",
97
105
  "image",
98
106
  "unparsed",
107
+ "array",
99
108
  ] as const;
100
109
 
101
110
  /**
@@ -108,6 +117,7 @@ const SharedStaticStyleValue = z.union([
108
117
  FontFamilyValue,
109
118
  RgbValue,
110
119
  UnparsedValue,
120
+ ArrayValue,
111
121
  ]);
112
122
 
113
123
  const ValidStaticStyleValue = z.union([ImageValue, SharedStaticStyleValue]);