@webstudio-is/react-sdk 0.194.0 → 0.196.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
@@ -82,7 +82,7 @@ import {
82
82
 
83
83
  // src/core-components.ts
84
84
  import {
85
- EditIcon,
85
+ ContentBlockIcon,
86
86
  ListViewIcon,
87
87
  PaintBrushIcon,
88
88
  SettingsIcon,
@@ -166,7 +166,7 @@ var descendantMeta = {
166
166
  icon: PaintBrushIcon,
167
167
  constraints: {
168
168
  relation: "parent",
169
- component: { $eq: "HtmlEmbed" }
169
+ component: { $in: ["HtmlEmbed", "MarkdownEmbed"] }
170
170
  }
171
171
  };
172
172
  var descendantPropsMeta = {
@@ -214,11 +214,10 @@ var blockTemplatePropsMeta = {
214
214
  initialProps: []
215
215
  };
216
216
  var blockMeta = {
217
- category: "data",
218
- order: 2,
217
+ category: "typography",
219
218
  type: "container",
220
219
  label: "Content Block",
221
- icon: EditIcon,
220
+ icon: ContentBlockIcon,
222
221
  constraints: [
223
222
  {
224
223
  relation: "ancestor",
@@ -237,59 +236,184 @@ var blockMeta = {
237
236
  props: [],
238
237
  children: [
239
238
  {
239
+ component: blockTemplateComponent,
240
240
  type: "instance",
241
241
  label: "Templates",
242
- component: blockTemplateComponent,
243
242
  children: [
244
243
  {
245
- type: "instance",
246
244
  component: "Paragraph",
247
- children: [
245
+ type: "instance",
246
+ children: []
247
+ },
248
+ {
249
+ component: "Heading",
250
+ type: "instance",
251
+ label: "Heading 1",
252
+ props: [
248
253
  {
249
- type: "text",
250
- value: "Paragraph text you can edit",
251
- placeholder: true
254
+ name: "tag",
255
+ type: "string",
256
+ value: "h1"
252
257
  }
253
- ]
258
+ ],
259
+ children: []
254
260
  },
255
261
  {
262
+ component: "Heading",
256
263
  type: "instance",
264
+ label: "Heading 2",
265
+ props: [
266
+ {
267
+ name: "tag",
268
+ type: "string",
269
+ value: "h2"
270
+ }
271
+ ],
272
+ children: []
273
+ },
274
+ {
275
+ component: "Heading",
276
+ type: "instance",
277
+ label: "Heading 3",
278
+ props: [
279
+ {
280
+ name: "tag",
281
+ type: "string",
282
+ value: "h3"
283
+ }
284
+ ],
285
+ children: []
286
+ },
287
+ {
288
+ component: "Heading",
289
+ type: "instance",
290
+ label: "Heading 4",
291
+ props: [
292
+ {
293
+ name: "tag",
294
+ type: "string",
295
+ value: "h4"
296
+ }
297
+ ],
298
+ children: []
299
+ },
300
+ {
301
+ component: "Heading",
302
+ type: "instance",
303
+ label: "Heading 5",
304
+ props: [
305
+ {
306
+ name: "tag",
307
+ type: "string",
308
+ value: "h5"
309
+ }
310
+ ],
311
+ children: []
312
+ },
313
+ {
314
+ component: "Heading",
315
+ type: "instance",
316
+ label: "Heading 6",
317
+ props: [
318
+ {
319
+ name: "tag",
320
+ type: "string",
321
+ value: "h6"
322
+ }
323
+ ],
324
+ children: []
325
+ },
326
+ {
257
327
  component: "List",
328
+ type: "instance",
329
+ label: "List (Unordered)",
258
330
  children: [
259
331
  {
332
+ component: "ListItem",
260
333
  type: "instance",
334
+ children: []
335
+ }
336
+ ]
337
+ },
338
+ {
339
+ component: "List",
340
+ type: "instance",
341
+ label: "List (Ordered)",
342
+ props: [
343
+ {
344
+ name: "ordered",
345
+ type: "boolean",
346
+ value: true
347
+ }
348
+ ],
349
+ children: [
350
+ {
261
351
  component: "ListItem",
262
- children: [
263
- {
264
- type: "text",
265
- value: "List Item text you can edit",
266
- placeholder: true
267
- }
268
- ]
352
+ type: "instance",
353
+ children: []
354
+ }
355
+ ]
356
+ },
357
+ {
358
+ component: "Link",
359
+ type: "instance",
360
+ children: []
361
+ },
362
+ {
363
+ component: "Image",
364
+ type: "instance",
365
+ styles: [
366
+ {
367
+ property: "marginRight",
368
+ value: {
369
+ type: "keyword",
370
+ value: "auto"
371
+ }
269
372
  },
270
373
  {
271
- type: "instance",
272
- component: "ListItem",
273
- children: [
274
- {
275
- type: "text",
276
- value: "List Item text you can edit",
277
- placeholder: true
278
- }
279
- ]
374
+ property: "marginLeft",
375
+ value: {
376
+ type: "keyword",
377
+ value: "auto"
378
+ }
280
379
  },
281
380
  {
282
- type: "instance",
283
- component: "ListItem",
284
- children: [
285
- {
286
- type: "text",
287
- value: "List Item text you can edit",
288
- placeholder: true
289
- }
290
- ]
381
+ property: "width",
382
+ value: {
383
+ type: "unit",
384
+ unit: "%",
385
+ value: 100
386
+ }
387
+ },
388
+ {
389
+ property: "height",
390
+ value: {
391
+ type: "keyword",
392
+ value: "auto"
393
+ }
291
394
  }
292
- ]
395
+ ],
396
+ children: []
397
+ },
398
+ {
399
+ component: "Separator",
400
+ type: "instance",
401
+ children: []
402
+ },
403
+ {
404
+ component: "Blockquote",
405
+ type: "instance",
406
+ children: []
407
+ },
408
+ {
409
+ component: "HtmlEmbed",
410
+ type: "instance",
411
+ children: []
412
+ },
413
+ {
414
+ component: "CodeText",
415
+ type: "instance",
416
+ children: []
293
417
  }
294
418
  ]
295
419
  },
@@ -628,6 +752,8 @@ var showAttribute = "data-ws-show";
628
752
  var indexAttribute = "data-ws-index";
629
753
  var collapsedAttribute = "data-ws-collapsed";
630
754
  var textContentAttribute = "data-ws-text-content";
755
+ var editablePlaceholderVariable = "--data-ws-editable-placeholder";
756
+ var editingPlaceholderVariable = "--data-ws-editing-placeholder";
631
757
  var attributeNameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
632
758
  var attributeNameChar = attributeNameStartChar + ":\\-0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
633
759
  var validAttributeNameRegex = new RegExp(
@@ -1081,13 +1207,14 @@ var createInstancesFromTemplate = (treeTemplate, instances, props, dataSourceByR
1081
1207
  }
1082
1208
  return parentChildren;
1083
1209
  };
1084
- var generateDataFromEmbedTemplate = (treeTemplate, metas, defaultBreakpointId, generateId = nanoid) => {
1210
+ var generateDataFromEmbedTemplate = (treeTemplate, metas, generateId = nanoid) => {
1085
1211
  const instances = [];
1086
1212
  const props = [];
1087
1213
  const dataSourceByRef = /* @__PURE__ */ new Map();
1088
1214
  const styleSourceSelections = [];
1089
1215
  const styleSources = [];
1090
1216
  const styles = [];
1217
+ const baseBreakpointId = generateId();
1091
1218
  const children = createInstancesFromTemplate(
1092
1219
  treeTemplate,
1093
1220
  instances,
@@ -1097,9 +1224,16 @@ var generateDataFromEmbedTemplate = (treeTemplate, metas, defaultBreakpointId, g
1097
1224
  styleSources,
1098
1225
  styles,
1099
1226
  metas,
1100
- defaultBreakpointId,
1227
+ baseBreakpointId,
1101
1228
  generateId
1102
1229
  );
1230
+ const breakpoints = [];
1231
+ if (styles.length > 0) {
1232
+ breakpoints.push({
1233
+ id: baseBreakpointId,
1234
+ label: ""
1235
+ });
1236
+ }
1103
1237
  return {
1104
1238
  children,
1105
1239
  instances,
@@ -1108,8 +1242,8 @@ var generateDataFromEmbedTemplate = (treeTemplate, metas, defaultBreakpointId, g
1108
1242
  styleSourceSelections,
1109
1243
  styleSources,
1110
1244
  styles,
1245
+ breakpoints,
1111
1246
  assets: [],
1112
- breakpoints: [],
1113
1247
  resources: []
1114
1248
  };
1115
1249
  };
@@ -1189,10 +1323,11 @@ var WsComponentPropsMeta = z3.object({
1189
1323
  });
1190
1324
  var componentCategories = [
1191
1325
  "general",
1192
- "text",
1193
- "data",
1326
+ "typography",
1194
1327
  "media",
1328
+ "data",
1195
1329
  "forms",
1330
+ "localization",
1196
1331
  "radix",
1197
1332
  "xml",
1198
1333
  "hidden",
@@ -1674,6 +1809,8 @@ export {
1674
1809
  createImageValueTransformer,
1675
1810
  defaultStates,
1676
1811
  descendantComponent,
1812
+ editablePlaceholderVariable,
1813
+ editingPlaceholderVariable,
1677
1814
  generateCss,
1678
1815
  generateDataFromEmbedTemplate,
1679
1816
  generateJsxChildren,
@@ -723,7 +723,7 @@ declare const WsComponentPropsMeta: z.ZodObject<{
723
723
  initialProps?: string[] | undefined;
724
724
  }>;
725
725
  export type WsComponentPropsMeta = z.infer<typeof WsComponentPropsMeta>;
726
- export declare const componentCategories: readonly ["general", "text", "data", "media", "forms", "radix", "xml", "hidden", "internal"];
726
+ export declare const componentCategories: readonly ["general", "typography", "media", "data", "forms", "localization", "radix", "xml", "hidden", "internal"];
727
727
  export declare const stateCategories: readonly ["states", "component-states"];
728
728
  export declare const ComponentState: z.ZodObject<{
729
729
  category: z.ZodOptional<z.ZodEnum<["states", "component-states"]>>;
@@ -741,7 +741,7 @@ export declare const ComponentState: z.ZodObject<{
741
741
  export type ComponentState = z.infer<typeof ComponentState>;
742
742
  export declare const defaultStates: ComponentState[];
743
743
  export declare const WsComponentMeta: z.ZodObject<{
744
- category: z.ZodOptional<z.ZodEnum<["general", "text", "data", "media", "forms", "radix", "xml", "hidden", "internal"]>>;
744
+ category: z.ZodOptional<z.ZodEnum<["general", "typography", "media", "data", "forms", "localization", "radix", "xml", "hidden", "internal"]>>;
745
745
  type: z.ZodEnum<["container", "control", "embed", "rich-text-child"]>;
746
746
  constraints: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
747
747
  relation: z.ZodUnion<[z.ZodLiteral<"ancestor">, z.ZodLiteral<"parent">, z.ZodLiteral<"self">, z.ZodLiteral<"child">, z.ZodLiteral<"descendant">]>;
@@ -1463,7 +1463,7 @@ export declare const WsComponentMeta: z.ZodObject<{
1463
1463
  }, "strip", z.ZodTypeAny, {
1464
1464
  type: "control" | "embed" | "container" | "rich-text-child";
1465
1465
  icon: string;
1466
- category?: "data" | "xml" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | "internal" | undefined;
1466
+ category?: "data" | "xml" | "hidden" | "media" | "general" | "typography" | "forms" | "radix" | "internal" | "localization" | undefined;
1467
1467
  constraints?: {
1468
1468
  relation: "ancestor" | "parent" | "self" | "child" | "descendant";
1469
1469
  component?: {
@@ -1790,7 +1790,7 @@ export declare const WsComponentMeta: z.ZodObject<{
1790
1790
  }, {
1791
1791
  type: "control" | "embed" | "container" | "rich-text-child";
1792
1792
  icon: string;
1793
- category?: "data" | "xml" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | "internal" | undefined;
1793
+ category?: "data" | "xml" | "hidden" | "media" | "general" | "typography" | "forms" | "radix" | "internal" | "localization" | undefined;
1794
1794
  constraints?: {
1795
1795
  relation: "ancestor" | "parent" | "self" | "child" | "descendant";
1796
1796
  component?: {
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import type { Simplify } from "type-fest";
3
- import type { Instance, Breakpoint, WebstudioFragment } from "@webstudio-is/sdk";
3
+ import type { Instance, WebstudioFragment } from "@webstudio-is/sdk";
4
4
  import { StyleValue, type StyleProperty } from "@webstudio-is/css-engine";
5
5
  import type { WsComponentMeta } from "./components/component-meta";
6
6
  declare const EmbedTemplateText: z.ZodObject<{
@@ -2249,11 +2249,11 @@ export declare const WsEmbedTemplate: z.ZodLazy<z.ZodArray<z.ZodUnion<[z.ZodType
2249
2249
  type: "expression";
2250
2250
  }>]>, "many">>;
2251
2251
  export type WsEmbedTemplate = z.infer<typeof WsEmbedTemplate>;
2252
- export declare const generateDataFromEmbedTemplate: (treeTemplate: WsEmbedTemplate, metas: Map<Instance["component"], WsComponentMeta>, defaultBreakpointId: Breakpoint["id"], generateId?: () => string) => WebstudioFragment;
2252
+ export declare const generateDataFromEmbedTemplate: (treeTemplate: WsEmbedTemplate, metas: Map<Instance["component"], WsComponentMeta>, generateId?: () => string) => WebstudioFragment;
2253
2253
  export declare const namespaceMeta: (meta: WsComponentMeta, namespace: string, components: Set<EmbedTemplateInstance["component"]>) => {
2254
2254
  type: "control" | "embed" | "container" | "rich-text-child";
2255
2255
  description?: string | undefined;
2256
- category?: "data" | "xml" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | "internal" | undefined;
2256
+ category?: "data" | "xml" | "hidden" | "media" | "general" | "typography" | "forms" | "radix" | "internal" | "localization" | undefined;
2257
2257
  label?: string | undefined;
2258
2258
  order?: number | undefined;
2259
2259
  template?: ({
@@ -2264,6 +2264,7 @@ export declare const namespaceMeta: (meta: WsComponentMeta, namespace: string, c
2264
2264
  value: string;
2265
2265
  type: "expression";
2266
2266
  } | EmbedTemplateInstance)[] | undefined;
2267
+ icon: string;
2267
2268
  constraints?: {
2268
2269
  relation: "ancestor" | "parent" | "self" | "child" | "descendant";
2269
2270
  component?: {
@@ -2295,7 +2296,6 @@ export declare const namespaceMeta: (meta: WsComponentMeta, namespace: string, c
2295
2296
  }[] | undefined;
2296
2297
  indexWithinAncestor?: string | undefined;
2297
2298
  stylable?: boolean | undefined;
2298
- icon: string;
2299
2299
  states?: {
2300
2300
  label: string;
2301
2301
  selector: string;
@@ -101,4 +101,6 @@ export declare const showAttribute: "data-ws-show";
101
101
  export declare const indexAttribute: "data-ws-index";
102
102
  export declare const collapsedAttribute: "data-ws-collapsed";
103
103
  export declare const textContentAttribute: "data-ws-text-content";
104
+ export declare const editablePlaceholderVariable: "--data-ws-editable-placeholder";
105
+ export declare const editingPlaceholderVariable: "--data-ws-editing-placeholder";
104
106
  export declare const isAttributeNameSafe: (attributeName: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/react-sdk",
3
- "version": "0.194.0",
3
+ "version": "0.196.0",
4
4
  "description": "Webstudio JavaScript / TypeScript API",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -14,6 +14,7 @@
14
14
  "type-fest": "^4.28.0",
15
15
  "vitest": "^2.1.8",
16
16
  "zod": "^3.22.4",
17
+ "@webstudio-is/template": "0.196.0",
17
18
  "@webstudio-is/tsconfig": "1.0.7"
18
19
  },
19
20
  "peerDependencies": {
@@ -25,11 +26,11 @@
25
26
  "change-case": "^5.4.4",
26
27
  "html-tags": "^4.0.0",
27
28
  "nanoid": "^5.0.8",
28
- "@webstudio-is/css-engine": "0.194.0",
29
- "@webstudio-is/icons": "^0.194.0",
30
- "@webstudio-is/fonts": "0.194.0",
31
- "@webstudio-is/sdk": "0.194.0",
32
- "@webstudio-is/image": "0.194.0"
29
+ "@webstudio-is/css-engine": "0.196.0",
30
+ "@webstudio-is/icons": "^0.196.0",
31
+ "@webstudio-is/fonts": "0.196.0",
32
+ "@webstudio-is/sdk": "0.196.0",
33
+ "@webstudio-is/image": "0.196.0"
33
34
  },
34
35
  "exports": {
35
36
  ".": {