@webstudio-is/css-data 0.47.0 → 0.49.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.
@@ -485,6 +485,7 @@ const keywordValues = {
485
485
  ],
486
486
  backgroundImage: ["none"],
487
487
  backgroundOrigin: ["border-box", "padding-box", "content-box"],
488
+ backgroundPosition: ["left", "center", "right", "top", "bottom"],
488
489
  backgroundPositionX: ["center", "left", "right", "x-start", "x-end"],
489
490
  backgroundPositionY: ["center", "top", "bottom", "y-start", "y-end"],
490
491
  backgroundRepeat: [
@@ -252,6 +252,16 @@ const properties = {
252
252
  popularity: 0.0847006,
253
253
  appliesTo: "allElements"
254
254
  },
255
+ backgroundPosition: {
256
+ unitGroups: ["length", "percentage"],
257
+ inherited: false,
258
+ initial: {
259
+ type: "keyword",
260
+ value: "0% 0%"
261
+ },
262
+ popularity: 0.76724967,
263
+ appliesTo: "allElements"
264
+ },
255
265
  backgroundPositionX: {
256
266
  unitGroups: ["length", "percentage"],
257
267
  inherited: false,
@@ -508,6 +508,7 @@ const keywordValues = {
508
508
  ],
509
509
  backgroundImage: ["none"],
510
510
  backgroundOrigin: ["border-box", "padding-box", "content-box"],
511
+ backgroundPosition: ["left", "center", "right", "top", "bottom"],
511
512
  backgroundPositionX: ["center", "left", "right", "x-start", "x-end"],
512
513
  backgroundPositionY: ["center", "top", "bottom", "y-start", "y-end"],
513
514
  backgroundRepeat: [
@@ -275,6 +275,16 @@ const properties = {
275
275
  popularity: 0.0847006,
276
276
  appliesTo: "allElements"
277
277
  },
278
+ backgroundPosition: {
279
+ unitGroups: ["length", "percentage"],
280
+ inherited: false,
281
+ initial: {
282
+ type: "keyword",
283
+ value: "0% 0%"
284
+ },
285
+ popularity: 0.76724967,
286
+ appliesTo: "allElements"
287
+ },
278
288
  backgroundPositionX: {
279
289
  unitGroups: ["length", "percentage"],
280
290
  inherited: false,
@@ -49,7 +49,8 @@ const KeywordValue = import_zod.z.object({
49
49
  });
50
50
  const UnparsedValue = import_zod.z.object({
51
51
  type: import_zod.z.literal("unparsed"),
52
- value: import_zod.z.string()
52
+ value: import_zod.z.string(),
53
+ hidden: import_zod.z.boolean().optional()
53
54
  });
54
55
  const FontFamilyValue = import_zod.z.object({
55
56
  type: import_zod.z.literal("fontFamily"),
@@ -64,7 +65,8 @@ const RgbValue = import_zod.z.object({
64
65
  });
65
66
  const ImageValue = import_zod.z.object({
66
67
  type: import_zod.z.literal("image"),
67
- value: import_zod.z.object({ type: import_zod.z.literal("asset"), value: import_asset_uploader.ImageAsset })
68
+ value: import_zod.z.object({ type: import_zod.z.literal("asset"), value: import_asset_uploader.ImageAsset }),
69
+ hidden: import_zod.z.boolean().optional()
68
70
  });
69
71
  const InvalidValue = import_zod.z.object({
70
72
  type: import_zod.z.literal("invalid"),
@@ -74,17 +76,24 @@ const UnsetValue = import_zod.z.object({
74
76
  type: import_zod.z.literal("unset"),
75
77
  value: import_zod.z.literal("")
76
78
  });
77
- const LayersValue = import_zod.z.object({
78
- type: import_zod.z.literal("layers"),
79
- value: import_zod.z.array(
80
- import_zod.z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue, InvalidValue])
81
- )
82
- });
83
79
  const TupleValueItem = import_zod.z.union([UnitValue, KeywordValue, UnparsedValue]);
84
80
  const TupleValue = import_zod.z.object({
85
81
  type: import_zod.z.literal("tuple"),
86
82
  value: import_zod.z.array(TupleValueItem)
87
83
  });
84
+ const LayersValue = import_zod.z.object({
85
+ type: import_zod.z.literal("layers"),
86
+ value: import_zod.z.array(
87
+ import_zod.z.union([
88
+ UnitValue,
89
+ KeywordValue,
90
+ UnparsedValue,
91
+ ImageValue,
92
+ TupleValue,
93
+ InvalidValue
94
+ ])
95
+ )
96
+ });
88
97
  const validStaticValueTypes = [
89
98
  "unit",
90
99
  "keyword",
package/lib/schema.js CHANGED
@@ -16,7 +16,8 @@ const KeywordValue = z.object({
16
16
  });
17
17
  const UnparsedValue = z.object({
18
18
  type: z.literal("unparsed"),
19
- value: z.string()
19
+ value: z.string(),
20
+ hidden: z.boolean().optional()
20
21
  });
21
22
  const FontFamilyValue = z.object({
22
23
  type: z.literal("fontFamily"),
@@ -31,7 +32,8 @@ const RgbValue = z.object({
31
32
  });
32
33
  const ImageValue = z.object({
33
34
  type: z.literal("image"),
34
- value: z.object({ type: z.literal("asset"), value: ImageAsset })
35
+ value: z.object({ type: z.literal("asset"), value: ImageAsset }),
36
+ hidden: z.boolean().optional()
35
37
  });
36
38
  const InvalidValue = z.object({
37
39
  type: z.literal("invalid"),
@@ -41,17 +43,24 @@ const UnsetValue = z.object({
41
43
  type: z.literal("unset"),
42
44
  value: z.literal("")
43
45
  });
44
- const LayersValue = z.object({
45
- type: z.literal("layers"),
46
- value: z.array(
47
- z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue, InvalidValue])
48
- )
49
- });
50
46
  const TupleValueItem = z.union([UnitValue, KeywordValue, UnparsedValue]);
51
47
  const TupleValue = z.object({
52
48
  type: z.literal("tuple"),
53
49
  value: z.array(TupleValueItem)
54
50
  });
51
+ const LayersValue = z.object({
52
+ type: z.literal("layers"),
53
+ value: z.array(
54
+ z.union([
55
+ UnitValue,
56
+ KeywordValue,
57
+ UnparsedValue,
58
+ ImageValue,
59
+ TupleValue,
60
+ InvalidValue
61
+ ])
62
+ )
63
+ });
55
64
  const validStaticValueTypes = [
56
65
  "unit",
57
66
  "keyword",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-data",
3
- "version": "0.47.0",
3
+ "version": "0.49.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.47.0",
15
+ "@webstudio-is/asset-uploader": "^0.49.0",
16
16
  "@webstudio-is/scripts": "^0.0.0",
17
17
  "@webstudio-is/tsconfig": "^1.0.1"
18
18
  },
@@ -20,6 +20,7 @@
20
20
  "zod": "^3.19.1"
21
21
  },
22
22
  "exports": {
23
+ "source": "./src/index.ts",
23
24
  "import": "./lib/index.js",
24
25
  "require": "./lib/cjs/index.cjs"
25
26
  },
@@ -486,6 +486,7 @@ export const keywordValues = {
486
486
  ],
487
487
  backgroundImage: ["none"],
488
488
  backgroundOrigin: ["border-box", "padding-box", "content-box"],
489
+ backgroundPosition: ["left", "center", "right", "top", "bottom"],
489
490
  backgroundPositionX: ["center", "left", "right", "x-start", "x-end"],
490
491
  backgroundPositionY: ["center", "top", "bottom", "y-start", "y-end"],
491
492
  backgroundRepeat: [
@@ -253,6 +253,16 @@ export const properties = {
253
253
  popularity: 0.0847006,
254
254
  appliesTo: "allElements",
255
255
  },
256
+ backgroundPosition: {
257
+ unitGroups: ["length", "percentage"],
258
+ inherited: false,
259
+ initial: {
260
+ type: "keyword",
261
+ value: "0% 0%",
262
+ },
263
+ popularity: 0.76724967,
264
+ appliesTo: "allElements",
265
+ },
256
266
  backgroundPositionX: {
257
267
  unitGroups: ["length", "percentage"],
258
268
  inherited: false,
package/src/schema.ts CHANGED
@@ -51,8 +51,12 @@ export type KeywordValue = z.infer<typeof KeywordValue>;
51
51
  export const UnparsedValue = z.object({
52
52
  type: z.literal("unparsed"),
53
53
  value: z.string(),
54
+ // For the builder we want to be able to hide background-image
55
+ hidden: z.boolean().optional(),
54
56
  });
55
57
 
58
+ export type UnparsedValue = z.infer<typeof UnparsedValue>;
59
+
56
60
  const FontFamilyValue = z.object({
57
61
  type: z.literal("fontFamily"),
58
62
  value: z.array(z.string()),
@@ -71,6 +75,8 @@ export type RgbValue = z.infer<typeof RgbValue>;
71
75
  export const ImageValue = z.object({
72
76
  type: z.literal("image"),
73
77
  value: z.object({ type: z.literal("asset"), value: ImageAsset }),
78
+ // For the builder we want to be able to hide images
79
+ hidden: z.boolean().optional(),
74
80
  });
75
81
 
76
82
  export type ImageValue = z.infer<typeof ImageValue>;
@@ -89,28 +95,35 @@ const UnsetValue = z.object({
89
95
  });
90
96
  export type UnsetValue = z.infer<typeof UnsetValue>;
91
97
 
98
+ export const TupleValueItem = z.union([UnitValue, KeywordValue, UnparsedValue]);
99
+ export type TupleValueItem = z.infer<typeof TupleValueItem>;
100
+
101
+ export const TupleValue = z.object({
102
+ type: z.literal("tuple"),
103
+ value: z.array(TupleValueItem),
104
+ });
105
+
106
+ export type TupleValue = z.infer<typeof TupleValue>;
107
+
92
108
  // To support background layers https://developer.mozilla.org/en-US/docs/Web/CSS/background
93
109
  // and similar comma separated css properties
94
110
  // InvalidValue used in case of asset not found
95
111
  export const LayersValue = z.object({
96
112
  type: z.literal("layers"),
97
113
  value: z.array(
98
- z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue, InvalidValue])
114
+ z.union([
115
+ UnitValue,
116
+ KeywordValue,
117
+ UnparsedValue,
118
+ ImageValue,
119
+ TupleValue,
120
+ InvalidValue,
121
+ ])
99
122
  ),
100
123
  });
101
124
 
102
125
  export type LayersValue = z.infer<typeof LayersValue>;
103
126
 
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
127
  /**
115
128
  * All StyleValue types that going to need wrapping into a CSS variable when rendered
116
129
  * on canvas inside builder.