@webstudio-is/react-sdk 0.193.0 → 0.194.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.
- package/lib/index.js +20 -46
- package/lib/runtime.js +0 -1
- package/lib/types/components/component-meta.d.ts +23 -1694
- package/lib/types/context.d.ts +0 -11
- package/lib/types/core-components.d.ts +2 -2
- package/lib/types/embed-template.d.ts +0 -281
- package/package.json +6 -7
package/lib/index.js
CHANGED
|
@@ -164,7 +164,10 @@ var descendantMeta = {
|
|
|
164
164
|
type: "control",
|
|
165
165
|
label: "Descendant",
|
|
166
166
|
icon: PaintBrushIcon,
|
|
167
|
-
|
|
167
|
+
constraints: {
|
|
168
|
+
relation: "parent",
|
|
169
|
+
component: { $eq: "HtmlEmbed" }
|
|
170
|
+
}
|
|
168
171
|
};
|
|
169
172
|
var descendantPropsMeta = {
|
|
170
173
|
props: {
|
|
@@ -194,29 +197,38 @@ var descendantPropsMeta = {
|
|
|
194
197
|
},
|
|
195
198
|
initialProps: ["selector"]
|
|
196
199
|
};
|
|
200
|
+
var blockComponent = "ws:block";
|
|
197
201
|
var blockTemplateComponent = "ws:block-template";
|
|
198
202
|
var blockTemplateMeta = {
|
|
199
203
|
category: "hidden",
|
|
200
|
-
detachable: false,
|
|
201
204
|
type: "container",
|
|
202
205
|
icon: AddTemplateInstanceIcon,
|
|
203
|
-
stylable: false
|
|
206
|
+
stylable: false,
|
|
207
|
+
constraints: {
|
|
208
|
+
relation: "parent",
|
|
209
|
+
component: { $eq: blockComponent }
|
|
210
|
+
}
|
|
204
211
|
};
|
|
205
212
|
var blockTemplatePropsMeta = {
|
|
206
213
|
props: {},
|
|
207
214
|
initialProps: []
|
|
208
215
|
};
|
|
209
|
-
var blockComponent = "ws:block";
|
|
210
216
|
var blockMeta = {
|
|
211
217
|
category: "data",
|
|
212
218
|
order: 2,
|
|
213
219
|
type: "container",
|
|
214
220
|
label: "Content Block",
|
|
215
221
|
icon: EditIcon,
|
|
216
|
-
constraints:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
constraints: [
|
|
223
|
+
{
|
|
224
|
+
relation: "ancestor",
|
|
225
|
+
component: { $nin: [collectionComponent, blockComponent] }
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
relation: "child",
|
|
229
|
+
component: { $eq: blockTemplateComponent }
|
|
230
|
+
}
|
|
231
|
+
],
|
|
220
232
|
stylable: false,
|
|
221
233
|
template: [
|
|
222
234
|
{
|
|
@@ -805,8 +817,6 @@ import { Matchers } from "@webstudio-is/sdk";
|
|
|
805
817
|
// src/embed-template.ts
|
|
806
818
|
import { z as z2 } from "zod";
|
|
807
819
|
import { nanoid } from "nanoid";
|
|
808
|
-
import { titleCase } from "title-case";
|
|
809
|
-
import { noCase } from "change-case";
|
|
810
820
|
import {
|
|
811
821
|
encodeDataSourceVariable,
|
|
812
822
|
transpileExpression
|
|
@@ -888,7 +898,6 @@ var EmbedTemplateInstance = z2.lazy(
|
|
|
888
898
|
label: z2.optional(z2.string()),
|
|
889
899
|
variables: z2.optional(z2.record(z2.string(), EmbedTemplateVariable)),
|
|
890
900
|
props: z2.optional(z2.array(EmbedTemplateProp)),
|
|
891
|
-
tokens: z2.optional(z2.array(z2.string())),
|
|
892
901
|
styles: z2.optional(z2.array(EmbedTemplateStyleDecl)),
|
|
893
902
|
children: WsEmbedTemplate
|
|
894
903
|
})
|
|
@@ -1001,32 +1010,6 @@ var createInstancesFromTemplate = (treeTemplate, instances, props, dataSourceByR
|
|
|
1001
1010
|
}
|
|
1002
1011
|
}
|
|
1003
1012
|
const styleSourceIds = [];
|
|
1004
|
-
if (item.tokens) {
|
|
1005
|
-
const meta = metas.get(item.component);
|
|
1006
|
-
if (meta?.presetTokens) {
|
|
1007
|
-
for (const name of item.tokens) {
|
|
1008
|
-
const tokenValue = meta.presetTokens[name];
|
|
1009
|
-
if (tokenValue) {
|
|
1010
|
-
const styleSourceId = `${item.component}:${name}`;
|
|
1011
|
-
styleSourceIds.push(styleSourceId);
|
|
1012
|
-
styleSources.push({
|
|
1013
|
-
type: "token",
|
|
1014
|
-
id: styleSourceId,
|
|
1015
|
-
name: titleCase(noCase(name))
|
|
1016
|
-
});
|
|
1017
|
-
for (const styleDecl of tokenValue.styles) {
|
|
1018
|
-
styles.push({
|
|
1019
|
-
breakpointId: defaultBreakpointId,
|
|
1020
|
-
styleSourceId,
|
|
1021
|
-
state: styleDecl.state,
|
|
1022
|
-
property: styleDecl.property,
|
|
1023
|
-
value: styleDecl.value
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
1013
|
if (item.styles) {
|
|
1031
1014
|
const styleSourceId = generateId();
|
|
1032
1015
|
styleSources.push({
|
|
@@ -1221,10 +1204,6 @@ var ComponentState = z3.object({
|
|
|
1221
1204
|
selector: z3.string(),
|
|
1222
1205
|
label: z3.string()
|
|
1223
1206
|
});
|
|
1224
|
-
var ComponentToken = z3.object({
|
|
1225
|
-
variant: z3.optional(z3.string()),
|
|
1226
|
-
styles: z3.array(EmbedTemplateStyleDecl)
|
|
1227
|
-
});
|
|
1228
1207
|
var defaultStates = [
|
|
1229
1208
|
{ selector: ":hover", label: "Hover" },
|
|
1230
1209
|
{ selector: ":active", label: "Active" },
|
|
@@ -1246,17 +1225,12 @@ var WsComponentMeta = z3.object({
|
|
|
1246
1225
|
// naming every item manually
|
|
1247
1226
|
indexWithinAncestor: z3.optional(z3.string()),
|
|
1248
1227
|
stylable: z3.optional(z3.boolean()),
|
|
1249
|
-
// specifies whether the instance can be deleted,
|
|
1250
|
-
// copied or dragged out of its parent instance
|
|
1251
|
-
// true by default
|
|
1252
|
-
detachable: z3.optional(z3.boolean()),
|
|
1253
1228
|
label: z3.optional(z3.string()),
|
|
1254
1229
|
description: z3.string().optional(),
|
|
1255
1230
|
icon: z3.string(),
|
|
1256
1231
|
presetStyle: z3.optional(
|
|
1257
1232
|
z3.record(z3.string(), z3.array(EmbedTemplateStyleDecl))
|
|
1258
1233
|
),
|
|
1259
|
-
presetTokens: z3.optional(z3.record(z3.string(), ComponentToken)),
|
|
1260
1234
|
states: z3.optional(z3.array(ComponentState)),
|
|
1261
1235
|
template: z3.optional(WsEmbedTemplate),
|
|
1262
1236
|
order: z3.number().optional()
|