@webstudio-is/react-sdk 0.193.0 → 0.195.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 CHANGED
@@ -164,7 +164,10 @@ var descendantMeta = {
164
164
  type: "control",
165
165
  label: "Descendant",
166
166
  icon: PaintBrushIcon,
167
- detachable: false
167
+ constraints: {
168
+ relation: "parent",
169
+ component: { $in: ["HtmlEmbed", "MarkdownEmbed"] }
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
- relation: "ancestor",
218
- component: { $nin: [collectionComponent, blockComponent] }
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
  {
@@ -225,59 +237,204 @@ var blockMeta = {
225
237
  props: [],
226
238
  children: [
227
239
  {
240
+ component: blockTemplateComponent,
228
241
  type: "instance",
229
242
  label: "Templates",
230
- component: blockTemplateComponent,
231
243
  children: [
232
244
  {
233
- type: "instance",
234
245
  component: "Paragraph",
235
- children: [
246
+ type: "instance",
247
+ children: []
248
+ },
249
+ {
250
+ component: "Heading",
251
+ type: "instance",
252
+ label: "Heading 1",
253
+ props: [
236
254
  {
237
- type: "text",
238
- value: "Paragraph text you can edit",
239
- placeholder: true
255
+ name: "tag",
256
+ type: "string",
257
+ value: "h1"
240
258
  }
241
- ]
259
+ ],
260
+ children: []
242
261
  },
243
262
  {
263
+ component: "Heading",
244
264
  type: "instance",
265
+ label: "Heading 2",
266
+ props: [
267
+ {
268
+ name: "tag",
269
+ type: "string",
270
+ value: "h2"
271
+ }
272
+ ],
273
+ children: []
274
+ },
275
+ {
276
+ component: "Heading",
277
+ type: "instance",
278
+ label: "Heading 3",
279
+ props: [
280
+ {
281
+ name: "tag",
282
+ type: "string",
283
+ value: "h3"
284
+ }
285
+ ],
286
+ children: []
287
+ },
288
+ {
289
+ component: "Heading",
290
+ type: "instance",
291
+ label: "Heading 4",
292
+ props: [
293
+ {
294
+ name: "tag",
295
+ type: "string",
296
+ value: "h4"
297
+ }
298
+ ],
299
+ children: []
300
+ },
301
+ {
302
+ component: "Heading",
303
+ type: "instance",
304
+ label: "Heading 5",
305
+ props: [
306
+ {
307
+ name: "tag",
308
+ type: "string",
309
+ value: "h5"
310
+ }
311
+ ],
312
+ children: []
313
+ },
314
+ {
315
+ component: "Heading",
316
+ type: "instance",
317
+ label: "Heading 6",
318
+ props: [
319
+ {
320
+ name: "tag",
321
+ type: "string",
322
+ value: "h6"
323
+ }
324
+ ],
325
+ children: []
326
+ },
327
+ {
245
328
  component: "List",
329
+ type: "instance",
330
+ label: "List (Unordered)",
246
331
  children: [
247
332
  {
333
+ component: "ListItem",
248
334
  type: "instance",
335
+ children: [{ type: "text", value: "list item you can edit" }]
336
+ },
337
+ {
249
338
  component: "ListItem",
250
- children: [
251
- {
252
- type: "text",
253
- value: "List Item text you can edit",
254
- placeholder: true
255
- }
256
- ]
339
+ type: "instance",
340
+ children: [{ type: "text", value: "list item you can edit" }]
257
341
  },
258
342
  {
343
+ component: "ListItem",
259
344
  type: "instance",
345
+ children: [{ type: "text", value: "list item you can edit" }]
346
+ }
347
+ ]
348
+ },
349
+ {
350
+ component: "List",
351
+ type: "instance",
352
+ label: "List (Ordered)",
353
+ props: [
354
+ {
355
+ name: "ordered",
356
+ type: "boolean",
357
+ value: true
358
+ }
359
+ ],
360
+ children: [
361
+ {
260
362
  component: "ListItem",
261
- children: [
262
- {
263
- type: "text",
264
- value: "List Item text you can edit",
265
- placeholder: true
266
- }
267
- ]
363
+ type: "instance",
364
+ children: [{ type: "text", value: "list item you can edit" }]
268
365
  },
269
366
  {
367
+ component: "ListItem",
270
368
  type: "instance",
369
+ children: [{ type: "text", value: "list item you can edit" }]
370
+ },
371
+ {
271
372
  component: "ListItem",
272
- children: [
273
- {
274
- type: "text",
275
- value: "List Item text you can edit",
276
- placeholder: true
277
- }
278
- ]
373
+ type: "instance",
374
+ children: [{ type: "text", value: "list item you can edit" }]
279
375
  }
280
376
  ]
377
+ },
378
+ {
379
+ component: "Link",
380
+ type: "instance",
381
+ children: []
382
+ },
383
+ {
384
+ component: "Image",
385
+ type: "instance",
386
+ styles: [
387
+ {
388
+ property: "marginRight",
389
+ value: {
390
+ type: "keyword",
391
+ value: "auto"
392
+ }
393
+ },
394
+ {
395
+ property: "marginLeft",
396
+ value: {
397
+ type: "keyword",
398
+ value: "auto"
399
+ }
400
+ },
401
+ {
402
+ property: "width",
403
+ value: {
404
+ type: "unit",
405
+ unit: "%",
406
+ value: 100
407
+ }
408
+ },
409
+ {
410
+ property: "height",
411
+ value: {
412
+ type: "keyword",
413
+ value: "auto"
414
+ }
415
+ }
416
+ ],
417
+ children: []
418
+ },
419
+ {
420
+ component: "Separator",
421
+ type: "instance",
422
+ children: []
423
+ },
424
+ {
425
+ component: "Blockquote",
426
+ type: "instance",
427
+ children: []
428
+ },
429
+ {
430
+ component: "HtmlEmbed",
431
+ type: "instance",
432
+ children: []
433
+ },
434
+ {
435
+ component: "CodeText",
436
+ type: "instance",
437
+ children: []
281
438
  }
282
439
  ]
283
440
  },
@@ -805,8 +962,6 @@ import { Matchers } from "@webstudio-is/sdk";
805
962
  // src/embed-template.ts
806
963
  import { z as z2 } from "zod";
807
964
  import { nanoid } from "nanoid";
808
- import { titleCase } from "title-case";
809
- import { noCase } from "change-case";
810
965
  import {
811
966
  encodeDataSourceVariable,
812
967
  transpileExpression
@@ -888,7 +1043,6 @@ var EmbedTemplateInstance = z2.lazy(
888
1043
  label: z2.optional(z2.string()),
889
1044
  variables: z2.optional(z2.record(z2.string(), EmbedTemplateVariable)),
890
1045
  props: z2.optional(z2.array(EmbedTemplateProp)),
891
- tokens: z2.optional(z2.array(z2.string())),
892
1046
  styles: z2.optional(z2.array(EmbedTemplateStyleDecl)),
893
1047
  children: WsEmbedTemplate
894
1048
  })
@@ -1001,32 +1155,6 @@ var createInstancesFromTemplate = (treeTemplate, instances, props, dataSourceByR
1001
1155
  }
1002
1156
  }
1003
1157
  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
1158
  if (item.styles) {
1031
1159
  const styleSourceId = generateId();
1032
1160
  styleSources.push({
@@ -1221,10 +1349,6 @@ var ComponentState = z3.object({
1221
1349
  selector: z3.string(),
1222
1350
  label: z3.string()
1223
1351
  });
1224
- var ComponentToken = z3.object({
1225
- variant: z3.optional(z3.string()),
1226
- styles: z3.array(EmbedTemplateStyleDecl)
1227
- });
1228
1352
  var defaultStates = [
1229
1353
  { selector: ":hover", label: "Hover" },
1230
1354
  { selector: ":active", label: "Active" },
@@ -1246,17 +1370,12 @@ var WsComponentMeta = z3.object({
1246
1370
  // naming every item manually
1247
1371
  indexWithinAncestor: z3.optional(z3.string()),
1248
1372
  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
1373
  label: z3.optional(z3.string()),
1254
1374
  description: z3.string().optional(),
1255
1375
  icon: z3.string(),
1256
1376
  presetStyle: z3.optional(
1257
1377
  z3.record(z3.string(), z3.array(EmbedTemplateStyleDecl))
1258
1378
  ),
1259
- presetTokens: z3.optional(z3.record(z3.string(), ComponentToken)),
1260
1379
  states: z3.optional(z3.array(ComponentState)),
1261
1380
  template: z3.optional(WsEmbedTemplate),
1262
1381
  order: z3.number().optional()
package/lib/runtime.js CHANGED
@@ -6,7 +6,6 @@ import {
6
6
  } from "@webstudio-is/sdk/runtime";
7
7
  var ReactSdkContext = createContext({
8
8
  assetBaseUrl: "/",
9
- imageBaseUrl: "/",
10
9
  imageLoader: ({ src }) => src,
11
10
  resources: {}
12
11
  });