@webstudio-is/css-data 0.18.1 → 0.20.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,34 +21,65 @@ __export(units_exports, {
21
21
  units: () => units
22
22
  });
23
23
  module.exports = __toCommonJS(units_exports);
24
- const units = [
25
- "ch",
26
- "cm",
27
- "deg",
28
- "dpcm",
29
- "dpi",
30
- "dppx",
31
- "em",
32
- "ex",
33
- "fr",
34
- "grad",
35
- "Hz",
36
- "in",
37
- "kHz",
38
- "mm",
39
- "ms",
40
- "pc",
41
- "pt",
42
- "px",
43
- "Q",
44
- "rad",
45
- "rem",
46
- "s",
47
- "turn",
48
- "vh",
49
- "vmax",
50
- "vmin",
51
- "vw",
52
- "x",
53
- "%"
54
- ];
24
+ const units = {
25
+ number: [],
26
+ percentage: ["%"],
27
+ angle: ["deg", "grad", "rad", "turn"],
28
+ decibel: ["db"],
29
+ flex: ["fr"],
30
+ frequency: ["hz", "khz"],
31
+ length: [
32
+ "cm",
33
+ "mm",
34
+ "q",
35
+ "in",
36
+ "pt",
37
+ "pc",
38
+ "px",
39
+ "em",
40
+ "rem",
41
+ "ex",
42
+ "rex",
43
+ "cap",
44
+ "rcap",
45
+ "ch",
46
+ "rch",
47
+ "ic",
48
+ "ric",
49
+ "lh",
50
+ "rlh",
51
+ "vw",
52
+ "svw",
53
+ "lvw",
54
+ "dvw",
55
+ "vh",
56
+ "svh",
57
+ "lvh",
58
+ "dvh",
59
+ "vi",
60
+ "svi",
61
+ "lvi",
62
+ "dvi",
63
+ "vb",
64
+ "svb",
65
+ "lvb",
66
+ "dvb",
67
+ "vmin",
68
+ "svmin",
69
+ "lvmin",
70
+ "dvmin",
71
+ "vmax",
72
+ "svmax",
73
+ "lvmax",
74
+ "dvmax",
75
+ "cqw",
76
+ "cqh",
77
+ "cqi",
78
+ "cqb",
79
+ "cqmin",
80
+ "cqmax"
81
+ ],
82
+ resolution: ["dpi", "dpcm", "dppx", "x"],
83
+ semitones: ["st"],
84
+ time: ["s", "ms"]
85
+ };
@@ -21,12 +21,18 @@ __export(schema_exports, {
21
21
  Breakpoint: () => Breakpoint,
22
22
  Breakpoints: () => Breakpoints,
23
23
  CssRule: () => CssRule,
24
+ ImageValue: () => ImageValue,
25
+ SharedStyleValue: () => SharedStyleValue,
24
26
  validStaticValueTypes: () => validStaticValueTypes
25
27
  });
26
28
  module.exports = __toCommonJS(schema_exports);
27
29
  var import_units = require("./__generated__/units");
28
30
  var import_zod = require("zod");
29
- const Unit = import_zod.z.union([import_zod.z.enum(import_units.units), import_zod.z.literal("number")]);
31
+ var import_asset_uploader = require("@webstudio-is/asset-uploader");
32
+ const Unit = import_zod.z.union([
33
+ import_zod.z.enum(Object.values(import_units.units).flat()),
34
+ import_zod.z.literal("number")
35
+ ]);
30
36
  const UnitValue = import_zod.z.object({
31
37
  type: import_zod.z.literal("unit"),
32
38
  unit: Unit,
@@ -47,6 +53,10 @@ const RgbValue = import_zod.z.object({
47
53
  b: import_zod.z.number(),
48
54
  alpha: import_zod.z.number()
49
55
  });
56
+ const ImageValue = import_zod.z.object({
57
+ type: import_zod.z.literal("image"),
58
+ value: import_zod.z.array(import_zod.z.object({ type: import_zod.z.literal("asset"), value: import_asset_uploader.ImageAsset }))
59
+ });
50
60
  const InvalidValue = import_zod.z.object({
51
61
  type: import_zod.z.literal("invalid"),
52
62
  value: import_zod.z.string()
@@ -59,14 +69,16 @@ const validStaticValueTypes = [
59
69
  "unit",
60
70
  "keyword",
61
71
  "fontFamily",
62
- "rgb"
72
+ "rgb",
73
+ "image"
63
74
  ];
64
- const ValidStaticStyleValue = import_zod.z.union([
75
+ const SharedStaticStyleValue = import_zod.z.union([
65
76
  UnitValue,
66
77
  KeywordValue,
67
78
  FontFamilyValue,
68
79
  RgbValue
69
80
  ]);
81
+ const ValidStaticStyleValue = import_zod.z.union([ImageValue, SharedStaticStyleValue]);
70
82
  const VarValue = import_zod.z.object({
71
83
  type: import_zod.z.literal("var"),
72
84
  value: import_zod.z.string(),
@@ -76,8 +88,13 @@ const StyleValue = import_zod.z.union([
76
88
  ValidStaticStyleValue,
77
89
  InvalidValue,
78
90
  UnsetValue,
79
- VarValue,
80
- RgbValue
91
+ VarValue
92
+ ]);
93
+ const SharedStyleValue = import_zod.z.union([
94
+ SharedStaticStyleValue,
95
+ InvalidValue,
96
+ UnsetValue,
97
+ VarValue
81
98
  ]);
82
99
  const Style = import_zod.z.record(import_zod.z.string(), StyleValue);
83
100
  const CssRule = import_zod.z.object({
package/lib/schema.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import { units } from "./__generated__/units";
2
2
  import { z } from "zod";
3
- const Unit = z.union([z.enum(units), z.literal("number")]);
3
+ import { ImageAsset } from "@webstudio-is/asset-uploader";
4
+ const Unit = z.union([
5
+ z.enum(Object.values(units).flat()),
6
+ z.literal("number")
7
+ ]);
4
8
  const UnitValue = z.object({
5
9
  type: z.literal("unit"),
6
10
  unit: Unit,
@@ -21,6 +25,10 @@ const RgbValue = z.object({
21
25
  b: z.number(),
22
26
  alpha: z.number()
23
27
  });
28
+ const ImageValue = z.object({
29
+ type: z.literal("image"),
30
+ value: z.array(z.object({ type: z.literal("asset"), value: ImageAsset }))
31
+ });
24
32
  const InvalidValue = z.object({
25
33
  type: z.literal("invalid"),
26
34
  value: z.string()
@@ -33,14 +41,16 @@ const validStaticValueTypes = [
33
41
  "unit",
34
42
  "keyword",
35
43
  "fontFamily",
36
- "rgb"
44
+ "rgb",
45
+ "image"
37
46
  ];
38
- const ValidStaticStyleValue = z.union([
47
+ const SharedStaticStyleValue = z.union([
39
48
  UnitValue,
40
49
  KeywordValue,
41
50
  FontFamilyValue,
42
51
  RgbValue
43
52
  ]);
53
+ const ValidStaticStyleValue = z.union([ImageValue, SharedStaticStyleValue]);
44
54
  const VarValue = z.object({
45
55
  type: z.literal("var"),
46
56
  value: z.string(),
@@ -50,8 +60,13 @@ const StyleValue = z.union([
50
60
  ValidStaticStyleValue,
51
61
  InvalidValue,
52
62
  UnsetValue,
53
- VarValue,
54
- RgbValue
63
+ VarValue
64
+ ]);
65
+ const SharedStyleValue = z.union([
66
+ SharedStaticStyleValue,
67
+ InvalidValue,
68
+ UnsetValue,
69
+ VarValue
55
70
  ]);
56
71
  const Style = z.record(z.string(), StyleValue);
57
72
  const CssRule = z.object({
@@ -68,5 +83,7 @@ export {
68
83
  Breakpoint,
69
84
  Breakpoints,
70
85
  CssRule,
86
+ ImageValue,
87
+ SharedStyleValue,
71
88
  validStaticValueTypes
72
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-data",
3
- "version": "0.18.1",
3
+ "version": "0.20.0",
4
4
  "description": "CSS Data",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -10,11 +10,12 @@
10
10
  "@types/css-tree": "^2.0.0",
11
11
  "camelcase": "^6.3.0",
12
12
  "css-tree": "^2.3.0",
13
- "mdn-data": "2.0.23",
13
+ "mdn-data": "2.0.30",
14
14
  "typescript": "4.7.4",
15
15
  "zod": "^3.19.1",
16
16
  "@webstudio-is/scripts": "^0.0.0",
17
- "@webstudio-is/tsconfig": "^1.0.1"
17
+ "@webstudio-is/tsconfig": "^1.0.1",
18
+ "@webstudio-is/asset-uploader": "^0.20.0"
18
19
  },
19
20
  "peerDependencies": {
20
21
  "zod": "^3.19.1"