@webstudio-is/sdk 0.214.0 → 0.216.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.
@@ -39,7 +39,6 @@ var html = [
39
39
  // src/core-metas.ts
40
40
  var rootComponent = "ws:root";
41
41
  var rootMeta = {
42
- type: "container",
43
42
  label: "Global Root",
44
43
  icon: SettingsIcon,
45
44
  presetStyle: {
@@ -51,7 +50,6 @@ var rootPropsMeta = {
51
50
  };
52
51
  var elementComponent = "ws:element";
53
52
  var elementMeta = {
54
- type: "container",
55
53
  label: "Element",
56
54
  icon: HtmlElementIcon
57
55
  };
@@ -60,9 +58,12 @@ var elementPropsMeta = {
60
58
  };
61
59
  var collectionComponent = "ws:collection";
62
60
  var collectionMeta = {
63
- type: "container",
64
61
  label: "Collection",
65
- icon: ListViewIcon
62
+ icon: ListViewIcon,
63
+ contentModel: {
64
+ category: "instance",
65
+ children: ["instance"]
66
+ }
66
67
  };
67
68
  var collectionPropsMeta = {
68
69
  props: {
@@ -76,12 +77,11 @@ var collectionPropsMeta = {
76
77
  };
77
78
  var descendantComponent = "ws:descendant";
78
79
  var descendantMeta = {
79
- type: "control",
80
80
  label: "Descendant",
81
81
  icon: PaintBrushIcon,
82
82
  contentModel: {
83
83
  category: "none",
84
- children: ["empty"]
84
+ children: []
85
85
  },
86
86
  // @todo infer possible presets
87
87
  presetStyle: {}
@@ -117,7 +117,6 @@ var descendantPropsMeta = {
117
117
  var blockComponent = "ws:block";
118
118
  var blockTemplateComponent = "ws:block-template";
119
119
  var blockTemplateMeta = {
120
- type: "container",
121
120
  icon: AddTemplateInstanceIcon,
122
121
  contentModel: {
123
122
  category: "none",
@@ -128,7 +127,6 @@ var blockTemplatePropsMeta = {
128
127
  props: {}
129
128
  };
130
129
  var blockMeta = {
131
- type: "container",
132
130
  label: "Content Block",
133
131
  icon: ContentBlockIcon,
134
132
  contentModel: {
package/lib/index.js CHANGED
@@ -991,19 +991,14 @@ var ContentModel = z16.object({
991
991
  * transparent - pass through possible children from parent
992
992
  * rich-text - can be edited as rich text
993
993
  * instance - other instances accepted
994
- * empty - no children accepted
995
994
  * ComponentName - accept specific components with none category
996
995
  */
997
- children: z16.array(
998
- z16.string()
999
- )
996
+ children: z16.array(z16.string())
1000
997
  });
1001
998
  var WsComponentMeta = z16.object({
1002
999
  category: z16.enum(componentCategories).optional(),
1003
- // container - can accept other components with dnd or be edited as text
1004
- // control - usually form controls like inputs, without children
1005
- // embed - images, videos or other embeddable components, without children
1006
- type: z16.enum(["container", "control", "embed"]),
1000
+ // container - can accept other components with dnd or be edited as text ..
1001
+ type: z16.enum(["container"]).optional(),
1007
1002
  /**
1008
1003
  * a property used as textual placeholder when no content specified while in builder
1009
1004
  * also signals to not insert components inside unless dropped explicitly
@@ -1056,7 +1051,6 @@ var html = [
1056
1051
  // src/core-metas.ts
1057
1052
  var rootComponent = "ws:root";
1058
1053
  var rootMeta = {
1059
- type: "container",
1060
1054
  label: "Global Root",
1061
1055
  icon: SettingsIcon,
1062
1056
  presetStyle: {
@@ -1068,7 +1062,6 @@ var rootPropsMeta = {
1068
1062
  };
1069
1063
  var elementComponent = "ws:element";
1070
1064
  var elementMeta = {
1071
- type: "container",
1072
1065
  label: "Element",
1073
1066
  icon: HtmlElementIcon
1074
1067
  };
@@ -1078,9 +1071,12 @@ var elementPropsMeta = {
1078
1071
  var portalComponent = "Slot";
1079
1072
  var collectionComponent = "ws:collection";
1080
1073
  var collectionMeta = {
1081
- type: "container",
1082
1074
  label: "Collection",
1083
- icon: ListViewIcon
1075
+ icon: ListViewIcon,
1076
+ contentModel: {
1077
+ category: "instance",
1078
+ children: ["instance"]
1079
+ }
1084
1080
  };
1085
1081
  var collectionPropsMeta = {
1086
1082
  props: {
@@ -1094,12 +1090,11 @@ var collectionPropsMeta = {
1094
1090
  };
1095
1091
  var descendantComponent = "ws:descendant";
1096
1092
  var descendantMeta = {
1097
- type: "control",
1098
1093
  label: "Descendant",
1099
1094
  icon: PaintBrushIcon,
1100
1095
  contentModel: {
1101
1096
  category: "none",
1102
- children: ["empty"]
1097
+ children: []
1103
1098
  },
1104
1099
  // @todo infer possible presets
1105
1100
  presetStyle: {}
@@ -1135,7 +1130,6 @@ var descendantPropsMeta = {
1135
1130
  var blockComponent = "ws:block";
1136
1131
  var blockTemplateComponent = "ws:block-template";
1137
1132
  var blockTemplateMeta = {
1138
- type: "container",
1139
1133
  icon: AddTemplateInstanceIcon,
1140
1134
  contentModel: {
1141
1135
  category: "none",
@@ -1146,7 +1140,6 @@ var blockTemplatePropsMeta = {
1146
1140
  props: {}
1147
1141
  };
1148
1142
  var blockMeta = {
1149
- type: "container",
1150
1143
  label: "Content Block",
1151
1144
  icon: ContentBlockIcon,
1152
1145
  contentModel: {
@@ -2064,7 +2057,30 @@ var generateCss = ({
2064
2057
  presetSheet.addMediaRule("presets");
2065
2058
  const presetClasses = /* @__PURE__ */ new Map();
2066
2059
  const scope = createScope([], normalizeClassName, "-");
2060
+ const tagsByComponent = /* @__PURE__ */ new Map();
2061
+ tagsByComponent.set(rootComponent, /* @__PURE__ */ new Set(["html"]));
2062
+ const tagByInstanceId = /* @__PURE__ */ new Map();
2063
+ for (const prop of props.values()) {
2064
+ if (prop.type === "string" && prop.name === "tag") {
2065
+ tagByInstanceId.set(prop.instanceId, prop.value);
2066
+ }
2067
+ }
2068
+ for (const instance of instances.values()) {
2069
+ const propTag = tagByInstanceId.get(instance.id);
2070
+ const meta = componentMetas.get(instance.component);
2071
+ const metaTag = Object.keys(meta?.presetStyle ?? {}).at(0);
2072
+ let componentTags = tagsByComponent.get(instance.component);
2073
+ if (componentTags === void 0) {
2074
+ componentTags = /* @__PURE__ */ new Set();
2075
+ tagsByComponent.set(instance.component, componentTags);
2076
+ }
2077
+ const tag = instance.tag ?? propTag ?? metaTag;
2078
+ if (tag) {
2079
+ componentTags.add(tag);
2080
+ }
2081
+ }
2067
2082
  for (const [component, meta] of componentMetas) {
2083
+ const componentTags = tagsByComponent.get(component);
2068
2084
  const [_namespace, componentName] = parseComponentName(component);
2069
2085
  const className = `w-${scope.getName(component, meta.label ?? componentName)}`;
2070
2086
  const presetStyle = Object.entries(meta.presetStyle ?? {});
@@ -2072,6 +2088,9 @@ var generateCss = ({
2072
2088
  presetClasses.set(component, className);
2073
2089
  }
2074
2090
  for (const [tag, styles2] of presetStyle) {
2091
+ if (!componentTags?.has(tag)) {
2092
+ continue;
2093
+ }
2075
2094
  const selector = component === rootComponent ? ":root" : `${tag}.${className}`;
2076
2095
  const rule = presetSheet.addNestingRule(selector);
2077
2096
  for (const declaration of styles2) {
@@ -5916,21 +5916,20 @@ export declare const ContentModel: z.ZodObject<{
5916
5916
  * transparent - pass through possible children from parent
5917
5917
  * rich-text - can be edited as rich text
5918
5918
  * instance - other instances accepted
5919
- * empty - no children accepted
5920
5919
  * ComponentName - accept specific components with none category
5921
5920
  */
5922
- children: z.ZodArray<z.ZodType<"instance" | (string & {}) | "transparent" | "rich-text" | "empty", z.ZodTypeDef, "instance" | (string & {}) | "transparent" | "rich-text" | "empty">, "many">;
5921
+ children: z.ZodType<Array<"transparent" | "instance" | "rich-text" | (string & {})>>;
5923
5922
  }, "strip", z.ZodTypeAny, {
5924
- children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
5923
+ children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
5925
5924
  category: "none" | "instance";
5926
5925
  }, {
5927
- children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
5926
+ children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
5928
5927
  category: "none" | "instance";
5929
5928
  }>;
5930
5929
  export type ContentModel = z.infer<typeof ContentModel>;
5931
5930
  export declare const WsComponentMeta: z.ZodObject<{
5932
5931
  category: z.ZodOptional<z.ZodEnum<["general", "typography", "media", "animations", "data", "forms", "localization", "radix", "xml", "hidden", "internal"]>>;
5933
- type: z.ZodEnum<["container", "control", "embed"]>;
5932
+ type: z.ZodOptional<z.ZodEnum<["container"]>>;
5934
5933
  /**
5935
5934
  * a property used as textual placeholder when no content specified while in builder
5936
5935
  * also signals to not insert components inside unless dropped explicitly
@@ -6073,15 +6072,14 @@ export declare const WsComponentMeta: z.ZodObject<{
6073
6072
  * transparent - pass through possible children from parent
6074
6073
  * rich-text - can be edited as rich text
6075
6074
  * instance - other instances accepted
6076
- * empty - no children accepted
6077
6075
  * ComponentName - accept specific components with none category
6078
6076
  */
6079
- children: z.ZodArray<z.ZodType<"instance" | (string & {}) | "transparent" | "rich-text" | "empty", z.ZodTypeDef, "instance" | (string & {}) | "transparent" | "rich-text" | "empty">, "many">;
6077
+ children: z.ZodType<Array<"transparent" | "instance" | "rich-text" | (string & {})>>;
6080
6078
  }, "strip", z.ZodTypeAny, {
6081
- children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
6079
+ children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
6082
6080
  category: "none" | "instance";
6083
6081
  }, {
6084
- children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
6082
+ children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
6085
6083
  category: "none" | "instance";
6086
6084
  }>>;
6087
6085
  indexWithinAncestor: z.ZodOptional<z.ZodString>;
@@ -11159,9 +11157,9 @@ export declare const WsComponentMeta: z.ZodObject<{
11159
11157
  }>, "many">>;
11160
11158
  order: z.ZodOptional<z.ZodNumber>;
11161
11159
  }, "strip", z.ZodTypeAny, {
11162
- type: "embed" | "control" | "container";
11163
11160
  icon: string;
11164
11161
  order?: number | undefined;
11162
+ type?: "container" | undefined;
11165
11163
  label?: string | undefined;
11166
11164
  description?: string | undefined;
11167
11165
  placeholder?: string | undefined;
@@ -11203,7 +11201,7 @@ export declare const WsComponentMeta: z.ZodObject<{
11203
11201
  } | undefined;
11204
11202
  }[] | undefined;
11205
11203
  contentModel?: {
11206
- children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
11204
+ children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
11207
11205
  category: "none" | "instance";
11208
11206
  } | undefined;
11209
11207
  indexWithinAncestor?: string | undefined;
@@ -11814,9 +11812,9 @@ export declare const WsComponentMeta: z.ZodObject<{
11814
11812
  state?: string | undefined;
11815
11813
  }[]> | undefined;
11816
11814
  }, {
11817
- type: "embed" | "control" | "container";
11818
11815
  icon: string;
11819
11816
  order?: number | undefined;
11817
+ type?: "container" | undefined;
11820
11818
  label?: string | undefined;
11821
11819
  description?: string | undefined;
11822
11820
  placeholder?: string | undefined;
@@ -11858,7 +11856,7 @@ export declare const WsComponentMeta: z.ZodObject<{
11858
11856
  } | undefined;
11859
11857
  }[] | undefined;
11860
11858
  contentModel?: {
11861
- children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
11859
+ children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
11862
11860
  category: "none" | "instance";
11863
11861
  } | undefined;
11864
11862
  indexWithinAncestor?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk",
3
- "version": "0.214.0",
3
+ "version": "0.216.0",
4
4
  "description": "Webstudio project data schema",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -40,15 +40,15 @@
40
40
  "reserved-identifiers": "^1.0.0",
41
41
  "type-fest": "^4.37.0",
42
42
  "zod": "^3.24.2",
43
- "@webstudio-is/fonts": "0.214.0",
44
- "@webstudio-is/css-engine": "0.214.0",
45
- "@webstudio-is/icons": "0.214.0"
43
+ "@webstudio-is/css-engine": "0.216.0",
44
+ "@webstudio-is/fonts": "0.216.0",
45
+ "@webstudio-is/icons": "0.216.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "html-tags": "^4.0.0",
49
49
  "vitest": "^3.0.8",
50
50
  "@webstudio-is/css-data": "0.0.0",
51
- "@webstudio-is/template": "0.214.0",
51
+ "@webstudio-is/template": "0.216.0",
52
52
  "@webstudio-is/tsconfig": "1.0.7"
53
53
  },
54
54
  "scripts": {