@webstudio-is/css-data 0.44.0 → 0.46.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.
@@ -20,7 +20,14 @@ var schema_exports = {};
20
20
  __export(schema_exports, {
21
21
  CssRule: () => CssRule,
22
22
  ImageValue: () => ImageValue,
23
+ InvalidValue: () => InvalidValue,
24
+ KeywordValue: () => KeywordValue,
25
+ LayersValue: () => LayersValue,
23
26
  SharedStyleValue: () => SharedStyleValue,
27
+ TupleValue: () => TupleValue,
28
+ TupleValueItem: () => TupleValueItem,
29
+ UnitValue: () => UnitValue,
30
+ UnparsedValue: () => UnparsedValue,
24
31
  validStaticValueTypes: () => validStaticValueTypes
25
32
  });
26
33
  module.exports = __toCommonJS(schema_exports);
@@ -67,9 +74,16 @@ const UnsetValue = import_zod.z.object({
67
74
  type: import_zod.z.literal("unset"),
68
75
  value: import_zod.z.literal("")
69
76
  });
70
- const ArrayValue = import_zod.z.object({
77
+ const LayersValue = import_zod.z.object({
71
78
  type: import_zod.z.literal("layers"),
72
- value: import_zod.z.array(import_zod.z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue]))
79
+ value: import_zod.z.array(
80
+ import_zod.z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue, InvalidValue])
81
+ )
82
+ });
83
+ const TupleValueItem = import_zod.z.union([UnitValue, KeywordValue, UnparsedValue]);
84
+ const TupleValue = import_zod.z.object({
85
+ type: import_zod.z.literal("tuple"),
86
+ value: import_zod.z.array(TupleValueItem)
73
87
  });
74
88
  const validStaticValueTypes = [
75
89
  "unit",
@@ -78,7 +92,8 @@ const validStaticValueTypes = [
78
92
  "rgb",
79
93
  "image",
80
94
  "unparsed",
81
- "array"
95
+ "layers",
96
+ "tuple"
82
97
  ];
83
98
  const SharedStaticStyleValue = import_zod.z.union([
84
99
  UnitValue,
@@ -86,9 +101,13 @@ const SharedStaticStyleValue = import_zod.z.union([
86
101
  FontFamilyValue,
87
102
  RgbValue,
88
103
  UnparsedValue,
89
- ArrayValue
104
+ TupleValue
105
+ ]);
106
+ const ValidStaticStyleValue = import_zod.z.union([
107
+ ImageValue,
108
+ LayersValue,
109
+ SharedStaticStyleValue
90
110
  ]);
91
- const ValidStaticStyleValue = import_zod.z.union([ImageValue, SharedStaticStyleValue]);
92
111
  const VarValue = import_zod.z.object({
93
112
  type: import_zod.z.literal("var"),
94
113
  value: import_zod.z.string(),
package/lib/schema.js CHANGED
@@ -41,9 +41,16 @@ const UnsetValue = z.object({
41
41
  type: z.literal("unset"),
42
42
  value: z.literal("")
43
43
  });
44
- const ArrayValue = z.object({
44
+ const LayersValue = z.object({
45
45
  type: z.literal("layers"),
46
- value: z.array(z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue]))
46
+ value: z.array(
47
+ z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue, InvalidValue])
48
+ )
49
+ });
50
+ const TupleValueItem = z.union([UnitValue, KeywordValue, UnparsedValue]);
51
+ const TupleValue = z.object({
52
+ type: z.literal("tuple"),
53
+ value: z.array(TupleValueItem)
47
54
  });
48
55
  const validStaticValueTypes = [
49
56
  "unit",
@@ -52,7 +59,8 @@ const validStaticValueTypes = [
52
59
  "rgb",
53
60
  "image",
54
61
  "unparsed",
55
- "array"
62
+ "layers",
63
+ "tuple"
56
64
  ];
57
65
  const SharedStaticStyleValue = z.union([
58
66
  UnitValue,
@@ -60,9 +68,13 @@ const SharedStaticStyleValue = z.union([
60
68
  FontFamilyValue,
61
69
  RgbValue,
62
70
  UnparsedValue,
63
- ArrayValue
71
+ TupleValue
72
+ ]);
73
+ const ValidStaticStyleValue = z.union([
74
+ ImageValue,
75
+ LayersValue,
76
+ SharedStaticStyleValue
64
77
  ]);
65
- const ValidStaticStyleValue = z.union([ImageValue, SharedStaticStyleValue]);
66
78
  const VarValue = z.object({
67
79
  type: z.literal("var"),
68
80
  value: z.string(),
@@ -88,6 +100,13 @@ const CssRule = z.object({
88
100
  export {
89
101
  CssRule,
90
102
  ImageValue,
103
+ InvalidValue,
104
+ KeywordValue,
105
+ LayersValue,
91
106
  SharedStyleValue,
107
+ TupleValue,
108
+ TupleValueItem,
109
+ UnitValue,
110
+ UnparsedValue,
92
111
  validStaticValueTypes
93
112
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-data",
3
- "version": "0.44.0",
3
+ "version": "0.46.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.44.0",
15
+ "@webstudio-is/asset-uploader": "^0.46.0",
16
16
  "@webstudio-is/scripts": "^0.0.0",
17
17
  "@webstudio-is/tsconfig": "^1.0.1"
18
18
  },
package/src/schema.ts CHANGED
@@ -30,7 +30,7 @@ const Unit = z.union([
30
30
 
31
31
  export type Unit = z.infer<typeof Unit>;
32
32
 
33
- const UnitValue = z.object({
33
+ export const UnitValue = z.object({
34
34
  type: z.literal("unit"),
35
35
  unit: Unit,
36
36
  value: z.number(),
@@ -38,7 +38,7 @@ const UnitValue = z.object({
38
38
 
39
39
  export type UnitValue = z.infer<typeof UnitValue>;
40
40
 
41
- const KeywordValue = z.object({
41
+ export const KeywordValue = z.object({
42
42
  type: z.literal("keyword"),
43
43
  // @todo use exact type
44
44
  value: z.string(),
@@ -48,7 +48,7 @@ export type KeywordValue = z.infer<typeof KeywordValue>;
48
48
  /**
49
49
  * Valid unparsed css value
50
50
  **/
51
- const UnparsedValue = z.object({
51
+ export const UnparsedValue = z.object({
52
52
  type: z.literal("unparsed"),
53
53
  value: z.string(),
54
54
  });
@@ -77,7 +77,7 @@ export type ImageValue = z.infer<typeof ImageValue>;
77
77
 
78
78
  // We want to be able to render the invalid value
79
79
  // and show it is invalid visually, without saving it to the db
80
- const InvalidValue = z.object({
80
+ export const InvalidValue = z.object({
81
81
  type: z.literal("invalid"),
82
82
  value: z.string(),
83
83
  });
@@ -91,12 +91,31 @@ export type UnsetValue = z.infer<typeof UnsetValue>;
91
91
 
92
92
  // To support background layers https://developer.mozilla.org/en-US/docs/Web/CSS/background
93
93
  // and similar comma separated css properties
94
- const ArrayValue = z.object({
94
+ // InvalidValue used in case of asset not found
95
+ export const LayersValue = z.object({
95
96
  type: z.literal("layers"),
96
- value: z.array(z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue])),
97
+ value: z.array(
98
+ z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue, InvalidValue])
99
+ ),
97
100
  });
98
- export type ArrayValue = z.infer<typeof ArrayValue>;
99
101
 
102
+ export type LayersValue = z.infer<typeof LayersValue>;
103
+
104
+ export const TupleValueItem = z.union([UnitValue, KeywordValue, UnparsedValue]);
105
+ export type TupleValueItem = z.infer<typeof TupleValueItem>;
106
+
107
+ export const TupleValue = z.object({
108
+ type: z.literal("tuple"),
109
+ value: z.array(TupleValueItem),
110
+ });
111
+
112
+ export type TupleValue = z.infer<typeof TupleValue>;
113
+
114
+ /**
115
+ * All StyleValue types that going to need wrapping into a CSS variable when rendered
116
+ * on canvas inside builder.
117
+ * Values like InvalidValue, UnsetValue, VarValue don't need to be wrapped
118
+ */
100
119
  export const validStaticValueTypes = [
101
120
  "unit",
102
121
  "keyword",
@@ -104,7 +123,8 @@ export const validStaticValueTypes = [
104
123
  "rgb",
105
124
  "image",
106
125
  "unparsed",
107
- "array",
126
+ "layers",
127
+ "tuple",
108
128
  ] as const;
109
129
 
110
130
  /**
@@ -117,10 +137,14 @@ const SharedStaticStyleValue = z.union([
117
137
  FontFamilyValue,
118
138
  RgbValue,
119
139
  UnparsedValue,
120
- ArrayValue,
140
+ TupleValue,
121
141
  ]);
122
142
 
123
- const ValidStaticStyleValue = z.union([ImageValue, SharedStaticStyleValue]);
143
+ const ValidStaticStyleValue = z.union([
144
+ ImageValue,
145
+ LayersValue,
146
+ SharedStaticStyleValue,
147
+ ]);
124
148
 
125
149
  export type ValidStaticStyleValue = z.infer<typeof ValidStaticStyleValue>;
126
150