@webstudio-is/sdk 0.212.0 → 0.214.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.
@@ -79,12 +79,12 @@ var descendantMeta = {
79
79
  type: "control",
80
80
  label: "Descendant",
81
81
  icon: PaintBrushIcon,
82
+ contentModel: {
83
+ category: "none",
84
+ children: ["empty"]
85
+ },
82
86
  // @todo infer possible presets
83
- presetStyle: {},
84
- constraints: {
85
- relation: "parent",
86
- component: { $in: ["HtmlEmbed", "MarkdownEmbed"] }
87
- }
87
+ presetStyle: {}
88
88
  };
89
89
  var descendantPropsMeta = {
90
90
  props: {
@@ -119,9 +119,9 @@ var blockTemplateComponent = "ws:block-template";
119
119
  var blockTemplateMeta = {
120
120
  type: "container",
121
121
  icon: AddTemplateInstanceIcon,
122
- constraints: {
123
- relation: "parent",
124
- component: { $eq: blockComponent }
122
+ contentModel: {
123
+ category: "none",
124
+ children: ["instance"]
125
125
  }
126
126
  };
127
127
  var blockTemplatePropsMeta = {
@@ -131,16 +131,11 @@ var blockMeta = {
131
131
  type: "container",
132
132
  label: "Content Block",
133
133
  icon: ContentBlockIcon,
134
- constraints: [
135
- {
136
- relation: "ancestor",
137
- component: { $nin: [collectionComponent, blockComponent] }
138
- },
139
- {
140
- relation: "child",
141
- component: { $eq: blockTemplateComponent }
142
- }
143
- ]
134
+ contentModel: {
135
+ category: "instance",
136
+ children: [blockTemplateComponent, "instance"]
137
+ // @todo prevent deleting block template
138
+ }
144
139
  };
145
140
  var blockPropsMeta = {
146
141
  props: {}
package/lib/index.js CHANGED
@@ -981,19 +981,36 @@ var defaultStates = [
981
981
  { selector: ":focus-visible", label: "Focus Visible" },
982
982
  { selector: ":focus-within", label: "Focus Within" }
983
983
  ];
984
+ var ContentModel = z16.object({
985
+ /*
986
+ * instance - accepted by any parent with "instance" in children categories
987
+ * none - accepted by parents with this component name in children categories
988
+ */
989
+ category: z16.union([z16.literal("instance"), z16.literal("none")]),
990
+ /**
991
+ * transparent - pass through possible children from parent
992
+ * rich-text - can be edited as rich text
993
+ * instance - other instances accepted
994
+ * empty - no children accepted
995
+ * ComponentName - accept specific components with none category
996
+ */
997
+ children: z16.array(
998
+ z16.string()
999
+ )
1000
+ });
984
1001
  var WsComponentMeta = z16.object({
985
1002
  category: z16.enum(componentCategories).optional(),
986
1003
  // container - can accept other components with dnd or be edited as text
987
1004
  // control - usually form controls like inputs, without children
988
1005
  // embed - images, videos or other embeddable components, without children
989
- // rich-text-child - formatted text fragment, not listed in components list
990
- type: z16.enum(["container", "control", "embed", "rich-text-child"]),
1006
+ type: z16.enum(["container", "control", "embed"]),
991
1007
  /**
992
1008
  * a property used as textual placeholder when no content specified while in builder
993
1009
  * also signals to not insert components inside unless dropped explicitly
994
1010
  */
995
1011
  placeholder: z16.string().optional(),
996
1012
  constraints: Matchers.optional(),
1013
+ contentModel: ContentModel.optional(),
997
1014
  // when this field is specified component receives
998
1015
  // prop with index of same components withiin specified ancestor
999
1016
  // important to automatically enumerate collections without
@@ -1080,12 +1097,12 @@ var descendantMeta = {
1080
1097
  type: "control",
1081
1098
  label: "Descendant",
1082
1099
  icon: PaintBrushIcon,
1100
+ contentModel: {
1101
+ category: "none",
1102
+ children: ["empty"]
1103
+ },
1083
1104
  // @todo infer possible presets
1084
- presetStyle: {},
1085
- constraints: {
1086
- relation: "parent",
1087
- component: { $in: ["HtmlEmbed", "MarkdownEmbed"] }
1088
- }
1105
+ presetStyle: {}
1089
1106
  };
1090
1107
  var descendantPropsMeta = {
1091
1108
  props: {
@@ -1120,9 +1137,9 @@ var blockTemplateComponent = "ws:block-template";
1120
1137
  var blockTemplateMeta = {
1121
1138
  type: "container",
1122
1139
  icon: AddTemplateInstanceIcon,
1123
- constraints: {
1124
- relation: "parent",
1125
- component: { $eq: blockComponent }
1140
+ contentModel: {
1141
+ category: "none",
1142
+ children: ["instance"]
1126
1143
  }
1127
1144
  };
1128
1145
  var blockTemplatePropsMeta = {
@@ -1132,16 +1149,11 @@ var blockMeta = {
1132
1149
  type: "container",
1133
1150
  label: "Content Block",
1134
1151
  icon: ContentBlockIcon,
1135
- constraints: [
1136
- {
1137
- relation: "ancestor",
1138
- component: { $nin: [collectionComponent, blockComponent] }
1139
- },
1140
- {
1141
- relation: "child",
1142
- component: { $eq: blockTemplateComponent }
1143
- }
1144
- ]
1152
+ contentModel: {
1153
+ category: "instance",
1154
+ children: [blockTemplateComponent, "instance"]
1155
+ // @todo prevent deleting block template
1156
+ }
1145
1157
  };
1146
1158
  var blockPropsMeta = {
1147
1159
  props: {}
@@ -2175,6 +2187,7 @@ export {
2175
2187
  Breakpoints,
2176
2188
  CompilerSettings,
2177
2189
  ComponentState,
2190
+ ContentModel,
2178
2191
  DataSource,
2179
2192
  DataSourceVariableValue,
2180
2193
  DataSources,
@@ -5910,9 +5910,27 @@ export declare const ComponentState: z.ZodObject<{
5910
5910
  }>;
5911
5911
  export type ComponentState = z.infer<typeof ComponentState>;
5912
5912
  export declare const defaultStates: ComponentState[];
5913
+ export declare const ContentModel: z.ZodObject<{
5914
+ category: z.ZodUnion<[z.ZodLiteral<"instance">, z.ZodLiteral<"none">]>;
5915
+ /**
5916
+ * transparent - pass through possible children from parent
5917
+ * rich-text - can be edited as rich text
5918
+ * instance - other instances accepted
5919
+ * empty - no children accepted
5920
+ * ComponentName - accept specific components with none category
5921
+ */
5922
+ children: z.ZodArray<z.ZodType<"instance" | (string & {}) | "transparent" | "rich-text" | "empty", z.ZodTypeDef, "instance" | (string & {}) | "transparent" | "rich-text" | "empty">, "many">;
5923
+ }, "strip", z.ZodTypeAny, {
5924
+ children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
5925
+ category: "none" | "instance";
5926
+ }, {
5927
+ children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
5928
+ category: "none" | "instance";
5929
+ }>;
5930
+ export type ContentModel = z.infer<typeof ContentModel>;
5913
5931
  export declare const WsComponentMeta: z.ZodObject<{
5914
5932
  category: z.ZodOptional<z.ZodEnum<["general", "typography", "media", "animations", "data", "forms", "localization", "radix", "xml", "hidden", "internal"]>>;
5915
- type: z.ZodEnum<["container", "control", "embed", "rich-text-child"]>;
5933
+ type: z.ZodEnum<["container", "control", "embed"]>;
5916
5934
  /**
5917
5935
  * a property used as textual placeholder when no content specified while in builder
5918
5936
  * also signals to not insert components inside unless dropped explicitly
@@ -6049,6 +6067,23 @@ export declare const WsComponentMeta: z.ZodObject<{
6049
6067
  $nin?: string[] | undefined;
6050
6068
  } | undefined;
6051
6069
  }>, "many">]>>;
6070
+ contentModel: z.ZodOptional<z.ZodObject<{
6071
+ category: z.ZodUnion<[z.ZodLiteral<"instance">, z.ZodLiteral<"none">]>;
6072
+ /**
6073
+ * transparent - pass through possible children from parent
6074
+ * rich-text - can be edited as rich text
6075
+ * instance - other instances accepted
6076
+ * empty - no children accepted
6077
+ * ComponentName - accept specific components with none category
6078
+ */
6079
+ children: z.ZodArray<z.ZodType<"instance" | (string & {}) | "transparent" | "rich-text" | "empty", z.ZodTypeDef, "instance" | (string & {}) | "transparent" | "rich-text" | "empty">, "many">;
6080
+ }, "strip", z.ZodTypeAny, {
6081
+ children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
6082
+ category: "none" | "instance";
6083
+ }, {
6084
+ children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
6085
+ category: "none" | "instance";
6086
+ }>>;
6052
6087
  indexWithinAncestor: z.ZodOptional<z.ZodString>;
6053
6088
  label: z.ZodOptional<z.ZodString>;
6054
6089
  description: z.ZodOptional<z.ZodString>;
@@ -11124,7 +11159,7 @@ export declare const WsComponentMeta: z.ZodObject<{
11124
11159
  }>, "many">>;
11125
11160
  order: z.ZodOptional<z.ZodNumber>;
11126
11161
  }, "strip", z.ZodTypeAny, {
11127
- type: "embed" | "control" | "container" | "rich-text-child";
11162
+ type: "embed" | "control" | "container";
11128
11163
  icon: string;
11129
11164
  order?: number | undefined;
11130
11165
  label?: string | undefined;
@@ -11167,6 +11202,10 @@ export declare const WsComponentMeta: z.ZodObject<{
11167
11202
  $nin?: string[] | undefined;
11168
11203
  } | undefined;
11169
11204
  }[] | undefined;
11205
+ contentModel?: {
11206
+ children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
11207
+ category: "none" | "instance";
11208
+ } | undefined;
11170
11209
  indexWithinAncestor?: string | undefined;
11171
11210
  presetStyle?: Record<string, {
11172
11211
  value: {
@@ -11775,7 +11814,7 @@ export declare const WsComponentMeta: z.ZodObject<{
11775
11814
  state?: string | undefined;
11776
11815
  }[]> | undefined;
11777
11816
  }, {
11778
- type: "embed" | "control" | "container" | "rich-text-child";
11817
+ type: "embed" | "control" | "container";
11779
11818
  icon: string;
11780
11819
  order?: number | undefined;
11781
11820
  label?: string | undefined;
@@ -11818,6 +11857,10 @@ export declare const WsComponentMeta: z.ZodObject<{
11818
11857
  $nin?: string[] | undefined;
11819
11858
  } | undefined;
11820
11859
  }[] | undefined;
11860
+ contentModel?: {
11861
+ children: ("instance" | (string & {}) | "transparent" | "rich-text" | "empty")[];
11862
+ category: "none" | "instance";
11863
+ } | undefined;
11821
11864
  indexWithinAncestor?: string | undefined;
11822
11865
  presetStyle?: Record<string, {
11823
11866
  value: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk",
3
- "version": "0.212.0",
3
+ "version": "0.214.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/css-engine": "0.212.0",
44
- "@webstudio-is/fonts": "0.212.0",
45
- "@webstudio-is/icons": "0.212.0"
43
+ "@webstudio-is/fonts": "0.214.0",
44
+ "@webstudio-is/css-engine": "0.214.0",
45
+ "@webstudio-is/icons": "0.214.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.212.0",
51
+ "@webstudio-is/template": "0.214.0",
52
52
  "@webstudio-is/tsconfig": "1.0.7"
53
53
  },
54
54
  "scripts": {