@webstudio-is/react-sdk 0.195.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
|
-
|
|
85
|
+
ContentBlockIcon,
|
|
86
86
|
ListViewIcon,
|
|
87
87
|
PaintBrushIcon,
|
|
88
88
|
SettingsIcon,
|
|
@@ -214,11 +214,10 @@ var blockTemplatePropsMeta = {
|
|
|
214
214
|
initialProps: []
|
|
215
215
|
};
|
|
216
216
|
var blockMeta = {
|
|
217
|
-
category: "
|
|
218
|
-
order: 2,
|
|
217
|
+
category: "typography",
|
|
219
218
|
type: "container",
|
|
220
219
|
label: "Content Block",
|
|
221
|
-
icon:
|
|
220
|
+
icon: ContentBlockIcon,
|
|
222
221
|
constraints: [
|
|
223
222
|
{
|
|
224
223
|
relation: "ancestor",
|
|
@@ -332,17 +331,7 @@ var blockMeta = {
|
|
|
332
331
|
{
|
|
333
332
|
component: "ListItem",
|
|
334
333
|
type: "instance",
|
|
335
|
-
children: [
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
component: "ListItem",
|
|
339
|
-
type: "instance",
|
|
340
|
-
children: [{ type: "text", value: "list item you can edit" }]
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
component: "ListItem",
|
|
344
|
-
type: "instance",
|
|
345
|
-
children: [{ type: "text", value: "list item you can edit" }]
|
|
334
|
+
children: []
|
|
346
335
|
}
|
|
347
336
|
]
|
|
348
337
|
},
|
|
@@ -361,17 +350,7 @@ var blockMeta = {
|
|
|
361
350
|
{
|
|
362
351
|
component: "ListItem",
|
|
363
352
|
type: "instance",
|
|
364
|
-
children: [
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
component: "ListItem",
|
|
368
|
-
type: "instance",
|
|
369
|
-
children: [{ type: "text", value: "list item you can edit" }]
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
component: "ListItem",
|
|
373
|
-
type: "instance",
|
|
374
|
-
children: [{ type: "text", value: "list item you can edit" }]
|
|
353
|
+
children: []
|
|
375
354
|
}
|
|
376
355
|
]
|
|
377
356
|
},
|
|
@@ -773,6 +752,8 @@ var showAttribute = "data-ws-show";
|
|
|
773
752
|
var indexAttribute = "data-ws-index";
|
|
774
753
|
var collapsedAttribute = "data-ws-collapsed";
|
|
775
754
|
var textContentAttribute = "data-ws-text-content";
|
|
755
|
+
var editablePlaceholderVariable = "--data-ws-editable-placeholder";
|
|
756
|
+
var editingPlaceholderVariable = "--data-ws-editing-placeholder";
|
|
776
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";
|
|
777
758
|
var attributeNameChar = attributeNameStartChar + ":\\-0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
|
778
759
|
var validAttributeNameRegex = new RegExp(
|
|
@@ -1226,13 +1207,14 @@ var createInstancesFromTemplate = (treeTemplate, instances, props, dataSourceByR
|
|
|
1226
1207
|
}
|
|
1227
1208
|
return parentChildren;
|
|
1228
1209
|
};
|
|
1229
|
-
var generateDataFromEmbedTemplate = (treeTemplate, metas,
|
|
1210
|
+
var generateDataFromEmbedTemplate = (treeTemplate, metas, generateId = nanoid) => {
|
|
1230
1211
|
const instances = [];
|
|
1231
1212
|
const props = [];
|
|
1232
1213
|
const dataSourceByRef = /* @__PURE__ */ new Map();
|
|
1233
1214
|
const styleSourceSelections = [];
|
|
1234
1215
|
const styleSources = [];
|
|
1235
1216
|
const styles = [];
|
|
1217
|
+
const baseBreakpointId = generateId();
|
|
1236
1218
|
const children = createInstancesFromTemplate(
|
|
1237
1219
|
treeTemplate,
|
|
1238
1220
|
instances,
|
|
@@ -1242,9 +1224,16 @@ var generateDataFromEmbedTemplate = (treeTemplate, metas, defaultBreakpointId, g
|
|
|
1242
1224
|
styleSources,
|
|
1243
1225
|
styles,
|
|
1244
1226
|
metas,
|
|
1245
|
-
|
|
1227
|
+
baseBreakpointId,
|
|
1246
1228
|
generateId
|
|
1247
1229
|
);
|
|
1230
|
+
const breakpoints = [];
|
|
1231
|
+
if (styles.length > 0) {
|
|
1232
|
+
breakpoints.push({
|
|
1233
|
+
id: baseBreakpointId,
|
|
1234
|
+
label: ""
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1248
1237
|
return {
|
|
1249
1238
|
children,
|
|
1250
1239
|
instances,
|
|
@@ -1253,8 +1242,8 @@ var generateDataFromEmbedTemplate = (treeTemplate, metas, defaultBreakpointId, g
|
|
|
1253
1242
|
styleSourceSelections,
|
|
1254
1243
|
styleSources,
|
|
1255
1244
|
styles,
|
|
1245
|
+
breakpoints,
|
|
1256
1246
|
assets: [],
|
|
1257
|
-
breakpoints: [],
|
|
1258
1247
|
resources: []
|
|
1259
1248
|
};
|
|
1260
1249
|
};
|
|
@@ -1334,10 +1323,11 @@ var WsComponentPropsMeta = z3.object({
|
|
|
1334
1323
|
});
|
|
1335
1324
|
var componentCategories = [
|
|
1336
1325
|
"general",
|
|
1337
|
-
"
|
|
1338
|
-
"data",
|
|
1326
|
+
"typography",
|
|
1339
1327
|
"media",
|
|
1328
|
+
"data",
|
|
1340
1329
|
"forms",
|
|
1330
|
+
"localization",
|
|
1341
1331
|
"radix",
|
|
1342
1332
|
"xml",
|
|
1343
1333
|
"hidden",
|
|
@@ -1819,6 +1809,8 @@ export {
|
|
|
1819
1809
|
createImageValueTransformer,
|
|
1820
1810
|
defaultStates,
|
|
1821
1811
|
descendantComponent,
|
|
1812
|
+
editablePlaceholderVariable,
|
|
1813
|
+
editingPlaceholderVariable,
|
|
1822
1814
|
generateCss,
|
|
1823
1815
|
generateDataFromEmbedTemplate,
|
|
1824
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", "
|
|
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", "
|
|
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" | "
|
|
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" | "
|
|
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,
|
|
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>,
|
|
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" | "
|
|
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;
|
package/lib/types/props.d.ts
CHANGED
|
@@ -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.
|
|
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,12 +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.
|
|
29
|
-
"@webstudio-is/
|
|
30
|
-
"@webstudio-is/
|
|
31
|
-
"@webstudio-is/
|
|
32
|
-
"@webstudio-is/
|
|
33
|
-
"@webstudio-is/sdk": "0.195.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"
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|