@webstudio-is/react-sdk 0.124.0 → 0.126.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 +113 -50
- package/lib/types/component-generator.d.ts +8 -2
- package/lib/types/components/component-meta.d.ts +54 -4
- package/lib/types/context.d.ts +2 -0
- package/lib/types/core-components.d.ts +7 -0
- package/lib/types/embed-template.d.ts +36 -367
- package/lib/types/generator.d.ts +1 -1
- package/lib/types/hook.d.ts +4 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/instance-utils.d.ts +4 -1
- package/lib/types/prop-meta.d.ts +21 -0
- package/lib/types/props.d.ts +2 -2
- package/lib/types/tree/create-elements-tree.d.ts +8 -2
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -69,6 +69,10 @@ var addGlobalRules = (sheet, { assets, assetBaseUrl }) => {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
// src/props.ts
|
|
72
|
+
import {
|
|
73
|
+
getPagePath,
|
|
74
|
+
findPageByIdOrPath
|
|
75
|
+
} from "@webstudio-is/sdk";
|
|
72
76
|
var normalizeProps = ({
|
|
73
77
|
props,
|
|
74
78
|
assetBaseUrl,
|
|
@@ -94,22 +98,20 @@ var normalizeProps = ({
|
|
|
94
98
|
continue;
|
|
95
99
|
}
|
|
96
100
|
if (prop.type === "page") {
|
|
97
|
-
let page;
|
|
98
101
|
let idProp;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const pageId = typeof prop.value === "string" ? prop.value : prop.value.pageId;
|
|
103
|
+
const page = findPageByIdOrPath(pageId, pages);
|
|
104
|
+
if (page === void 0) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (typeof prop.value !== "string") {
|
|
108
|
+
const { instanceId } = prop.value;
|
|
105
109
|
idProp = props.find(
|
|
106
110
|
(prop2) => prop2.instanceId === instanceId && prop2.name === "id"
|
|
107
111
|
);
|
|
108
112
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
const url = new URL(page.path, "https://any-valid.url");
|
|
113
|
+
const path = getPagePath(page.id, pages);
|
|
114
|
+
const url = new URL(path, "https://any-valid.url");
|
|
113
115
|
let value = url.pathname;
|
|
114
116
|
if (idProp?.type === "string") {
|
|
115
117
|
const hash = idProp.value;
|
|
@@ -136,6 +138,7 @@ var componentAttribute = "data-ws-component";
|
|
|
136
138
|
var showAttribute = "data-ws-show";
|
|
137
139
|
var indexAttribute = "data-ws-index";
|
|
138
140
|
var collapsedAttribute = "data-ws-collapsed";
|
|
141
|
+
var textContentAttribute = "data-ws-text-content";
|
|
139
142
|
var getInstanceIdFromComponentProps = (props) => {
|
|
140
143
|
return props[idAttribute];
|
|
141
144
|
};
|
|
@@ -285,13 +288,18 @@ import {
|
|
|
285
288
|
} from "react";
|
|
286
289
|
|
|
287
290
|
// src/context.tsx
|
|
288
|
-
import { createContext } from "react";
|
|
291
|
+
import { createContext, useContext } from "react";
|
|
289
292
|
var ReactSdkContext = createContext({
|
|
290
293
|
assetBaseUrl: "/",
|
|
291
294
|
imageBaseUrl: "/",
|
|
292
295
|
imageLoader: ({ src }) => src,
|
|
293
|
-
pagesPaths: /* @__PURE__ */ new Set()
|
|
296
|
+
pagesPaths: /* @__PURE__ */ new Set(),
|
|
297
|
+
resources: {}
|
|
294
298
|
});
|
|
299
|
+
var useResource = (name) => {
|
|
300
|
+
const { resources } = useContext(ReactSdkContext);
|
|
301
|
+
return resources[name];
|
|
302
|
+
};
|
|
295
303
|
|
|
296
304
|
// src/tree/create-elements-tree.tsx
|
|
297
305
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -324,7 +332,8 @@ var createElementsTree = ({
|
|
|
324
332
|
imageLoader,
|
|
325
333
|
pagesPaths: /* @__PURE__ */ new Set(),
|
|
326
334
|
assetBaseUrl,
|
|
327
|
-
imageBaseUrl
|
|
335
|
+
imageBaseUrl,
|
|
336
|
+
resources: {}
|
|
328
337
|
},
|
|
329
338
|
children: root
|
|
330
339
|
}
|
|
@@ -350,18 +359,25 @@ var createInstanceChildrenElements = ({
|
|
|
350
359
|
elements.push(renderText(child.value));
|
|
351
360
|
continue;
|
|
352
361
|
}
|
|
353
|
-
|
|
354
|
-
if (childInstance === void 0) {
|
|
362
|
+
if (child.type === "expression") {
|
|
355
363
|
continue;
|
|
356
364
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
+
if (child.type === "id") {
|
|
366
|
+
const childInstance = instances.get(child.value);
|
|
367
|
+
if (childInstance === void 0) {
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
const childInstanceSelector = [child.value, ...instanceSelector];
|
|
371
|
+
const element = createInstanceElement({
|
|
372
|
+
instance: childInstance,
|
|
373
|
+
instanceSelector: childInstanceSelector,
|
|
374
|
+
Component,
|
|
375
|
+
components
|
|
376
|
+
});
|
|
377
|
+
elements.push(element);
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
child;
|
|
365
381
|
}
|
|
366
382
|
if (elements.length === 0) {
|
|
367
383
|
return;
|
|
@@ -403,15 +419,15 @@ var Root = ({
|
|
|
403
419
|
};
|
|
404
420
|
|
|
405
421
|
// src/core-components.ts
|
|
406
|
-
import {
|
|
422
|
+
import { ListViewIcon } from "@webstudio-is/icons/svg";
|
|
407
423
|
var portalComponent = "Slot";
|
|
408
424
|
var collectionComponent = "ws:collection";
|
|
409
425
|
var collectionMeta = {
|
|
410
|
-
category: "
|
|
426
|
+
category: "data",
|
|
411
427
|
order: 7,
|
|
412
428
|
type: "container",
|
|
413
429
|
label: "Collection",
|
|
414
|
-
icon:
|
|
430
|
+
icon: ListViewIcon,
|
|
415
431
|
stylable: false,
|
|
416
432
|
template: [
|
|
417
433
|
{
|
|
@@ -421,24 +437,24 @@ var collectionMeta = {
|
|
|
421
437
|
{
|
|
422
438
|
name: "data",
|
|
423
439
|
type: "json",
|
|
424
|
-
value: [
|
|
440
|
+
value: [
|
|
441
|
+
"Collection Item 1",
|
|
442
|
+
"Collection Item 2",
|
|
443
|
+
"Collection Item 3"
|
|
444
|
+
]
|
|
425
445
|
},
|
|
426
|
-
{
|
|
446
|
+
{
|
|
447
|
+
name: "item",
|
|
448
|
+
type: "parameter",
|
|
449
|
+
variableName: "collectionItem",
|
|
450
|
+
variableAlias: "Collection Item"
|
|
451
|
+
}
|
|
427
452
|
],
|
|
428
453
|
children: [
|
|
429
454
|
{
|
|
430
455
|
type: "instance",
|
|
431
456
|
component: "Box",
|
|
432
|
-
children: [
|
|
433
|
-
{
|
|
434
|
-
type: "instance",
|
|
435
|
-
component: "HtmlEmbed",
|
|
436
|
-
props: [
|
|
437
|
-
{ name: "code", type: "expression", code: "collectionItem" }
|
|
438
|
-
],
|
|
439
|
-
children: []
|
|
440
|
-
}
|
|
441
|
-
]
|
|
457
|
+
children: [{ type: "expression", value: "collectionItem" }]
|
|
442
458
|
}
|
|
443
459
|
]
|
|
444
460
|
}
|
|
@@ -590,6 +606,12 @@ var Action = z.object({
|
|
|
590
606
|
type: z.literal("action"),
|
|
591
607
|
defaultValue: z.undefined().optional()
|
|
592
608
|
});
|
|
609
|
+
var TextContent = z.object({
|
|
610
|
+
...common,
|
|
611
|
+
control: z.literal("textContent"),
|
|
612
|
+
type: z.literal("string"),
|
|
613
|
+
defaultValue: z.string().optional()
|
|
614
|
+
});
|
|
593
615
|
var PropMeta = z.union([
|
|
594
616
|
Number,
|
|
595
617
|
Range,
|
|
@@ -607,7 +629,8 @@ var PropMeta = z.union([
|
|
|
607
629
|
Url,
|
|
608
630
|
Json,
|
|
609
631
|
Date,
|
|
610
|
-
Action
|
|
632
|
+
Action,
|
|
633
|
+
TextContent
|
|
611
634
|
]);
|
|
612
635
|
|
|
613
636
|
// src/components/component-meta.ts
|
|
@@ -861,7 +884,12 @@ var EmbedTemplateText = z2.object({
|
|
|
861
884
|
type: z2.literal("text"),
|
|
862
885
|
value: z2.string()
|
|
863
886
|
});
|
|
887
|
+
var EmbedTemplateExpression = z2.object({
|
|
888
|
+
type: z2.literal("expression"),
|
|
889
|
+
value: z2.string()
|
|
890
|
+
});
|
|
864
891
|
var EmbedTemplateVariable = z2.object({
|
|
892
|
+
alias: z2.optional(z2.string()),
|
|
865
893
|
initialValue: z2.unknown()
|
|
866
894
|
});
|
|
867
895
|
var EmbedTemplateProp = z2.union([
|
|
@@ -898,7 +926,8 @@ var EmbedTemplateProp = z2.union([
|
|
|
898
926
|
z2.object({
|
|
899
927
|
type: z2.literal("parameter"),
|
|
900
928
|
name: z2.string(),
|
|
901
|
-
variableName: z2.string()
|
|
929
|
+
variableName: z2.string(),
|
|
930
|
+
variableAlias: z2.optional(z2.string())
|
|
902
931
|
}),
|
|
903
932
|
z2.object({
|
|
904
933
|
type: z2.literal("action"),
|
|
@@ -932,7 +961,9 @@ var EmbedTemplateInstance = z2.lazy(
|
|
|
932
961
|
})
|
|
933
962
|
);
|
|
934
963
|
var WsEmbedTemplate = z2.lazy(
|
|
935
|
-
() => z2.array(
|
|
964
|
+
() => z2.array(
|
|
965
|
+
z2.union([EmbedTemplateInstance, EmbedTemplateText, EmbedTemplateExpression])
|
|
966
|
+
)
|
|
936
967
|
);
|
|
937
968
|
var getVariablValue = (value) => {
|
|
938
969
|
if (typeof value === "string") {
|
|
@@ -963,7 +994,7 @@ var createInstancesFromTemplate = (treeTemplate, instances, props, dataSourceByR
|
|
|
963
994
|
type: "variable",
|
|
964
995
|
id: generateId(),
|
|
965
996
|
scopeInstanceId: instanceId,
|
|
966
|
-
name,
|
|
997
|
+
name: variable.alias ?? name,
|
|
967
998
|
value: getVariablValue(variable.initialValue)
|
|
968
999
|
});
|
|
969
1000
|
}
|
|
@@ -1020,7 +1051,7 @@ var createInstancesFromTemplate = (treeTemplate, instances, props, dataSourceByR
|
|
|
1020
1051
|
type: "parameter",
|
|
1021
1052
|
id: dataSourceId,
|
|
1022
1053
|
scopeInstanceId: instanceId,
|
|
1023
|
-
name: prop.variableName
|
|
1054
|
+
name: prop.variableAlias ?? prop.variableName
|
|
1024
1055
|
});
|
|
1025
1056
|
props.push({
|
|
1026
1057
|
id: propId,
|
|
@@ -1116,6 +1147,18 @@ var createInstancesFromTemplate = (treeTemplate, instances, props, dataSourceByR
|
|
|
1116
1147
|
value: item.value
|
|
1117
1148
|
});
|
|
1118
1149
|
}
|
|
1150
|
+
if (item.type === "expression") {
|
|
1151
|
+
parentChildren.push({
|
|
1152
|
+
type: "expression",
|
|
1153
|
+
// replace all references with variable names
|
|
1154
|
+
value: validateExpression(item.value, {
|
|
1155
|
+
transformIdentifier: (ref) => {
|
|
1156
|
+
const id = dataSourceByRef.get(ref)?.id ?? ref;
|
|
1157
|
+
return encodeDataSourceVariable(id);
|
|
1158
|
+
}
|
|
1159
|
+
})
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1119
1162
|
}
|
|
1120
1163
|
return parentChildren;
|
|
1121
1164
|
};
|
|
@@ -1145,7 +1188,10 @@ var generateDataFromEmbedTemplate = (treeTemplate, metas, defaultBreakpointId, g
|
|
|
1145
1188
|
dataSources: Array.from(dataSourceByRef.values()),
|
|
1146
1189
|
styleSourceSelections,
|
|
1147
1190
|
styleSources,
|
|
1148
|
-
styles
|
|
1191
|
+
styles,
|
|
1192
|
+
assets: [],
|
|
1193
|
+
breakpoints: [],
|
|
1194
|
+
resources: []
|
|
1149
1195
|
};
|
|
1150
1196
|
};
|
|
1151
1197
|
var namespaceEmbedTemplateComponents = (template, namespace, components) => {
|
|
@@ -1153,6 +1199,9 @@ var namespaceEmbedTemplateComponents = (template, namespace, components) => {
|
|
|
1153
1199
|
if (item.type === "text") {
|
|
1154
1200
|
return item;
|
|
1155
1201
|
}
|
|
1202
|
+
if (item.type === "expression") {
|
|
1203
|
+
return item;
|
|
1204
|
+
}
|
|
1156
1205
|
if (item.type === "instance") {
|
|
1157
1206
|
const prefix = components.has(item.component) ? `${namespace}:` : "";
|
|
1158
1207
|
return {
|
|
@@ -1203,6 +1252,7 @@ var WsComponentPropsMeta = z3.object({
|
|
|
1203
1252
|
var componentCategories = [
|
|
1204
1253
|
"general",
|
|
1205
1254
|
"text",
|
|
1255
|
+
"data",
|
|
1206
1256
|
"media",
|
|
1207
1257
|
"forms",
|
|
1208
1258
|
"radix",
|
|
@@ -1314,10 +1364,12 @@ var getClosestInstance = (instancePath, currentInstance, closestComponent) => {
|
|
|
1314
1364
|
};
|
|
1315
1365
|
|
|
1316
1366
|
// src/generator.ts
|
|
1367
|
+
import { getPagePath as getPagePath2 } from "@webstudio-is/sdk";
|
|
1317
1368
|
var generateUtilsExport = (siteData) => {
|
|
1318
1369
|
const pagesPaths = [siteData.pages.homePage.path];
|
|
1319
1370
|
for (const page of siteData.pages.pages) {
|
|
1320
|
-
|
|
1371
|
+
const path = getPagePath2(page.id, siteData.pages);
|
|
1372
|
+
pagesPaths.push(path);
|
|
1321
1373
|
}
|
|
1322
1374
|
const generatedPagesPaths = `export const pagesPaths = new Set(${JSON.stringify(
|
|
1323
1375
|
pagesPaths
|
|
@@ -1497,6 +1549,16 @@ var generateJsxChildren = ({
|
|
|
1497
1549
|
`);
|
|
1498
1550
|
continue;
|
|
1499
1551
|
}
|
|
1552
|
+
if (child.type === "expression") {
|
|
1553
|
+
const expression = generateExpression({
|
|
1554
|
+
expression: child.value,
|
|
1555
|
+
dataSources,
|
|
1556
|
+
scope
|
|
1557
|
+
});
|
|
1558
|
+
generatedChildren = `{${expression}}
|
|
1559
|
+
`;
|
|
1560
|
+
continue;
|
|
1561
|
+
}
|
|
1500
1562
|
if (child.type === "id") {
|
|
1501
1563
|
const instanceId = child.value;
|
|
1502
1564
|
const instance = instances.get(instanceId);
|
|
@@ -1571,7 +1633,8 @@ var generatePageComponent = ({
|
|
|
1571
1633
|
dataSource.resourceId,
|
|
1572
1634
|
dataSource.name
|
|
1573
1635
|
);
|
|
1574
|
-
|
|
1636
|
+
const resourceNameString = JSON.stringify(resourceName);
|
|
1637
|
+
generatedDataSources += `let ${valueName} = useResource(${resourceNameString})
|
|
1575
1638
|
`;
|
|
1576
1639
|
}
|
|
1577
1640
|
}
|
|
@@ -1596,9 +1659,7 @@ var generatePageComponent = ({
|
|
|
1596
1659
|
let generatedComponent = "";
|
|
1597
1660
|
generatedComponent += `type Params = Record<string, string | undefined>
|
|
1598
1661
|
`;
|
|
1599
|
-
generatedComponent += `
|
|
1600
|
-
`;
|
|
1601
|
-
generatedComponent += `const Page = (_props: { params: Params, resources: Resources }) => {
|
|
1662
|
+
generatedComponent += `const Page = (_props: { params: Params }) => {
|
|
1602
1663
|
`;
|
|
1603
1664
|
generatedComponent += `${generatedDataSources}`;
|
|
1604
1665
|
generatedComponent += `return ${generatedJsx}`;
|
|
@@ -1758,5 +1819,7 @@ export {
|
|
|
1758
1819
|
selectorIdAttribute,
|
|
1759
1820
|
showAttribute,
|
|
1760
1821
|
stateCategories,
|
|
1822
|
+
textContentAttribute,
|
|
1823
|
+
useResource,
|
|
1761
1824
|
validateExpression
|
|
1762
1825
|
};
|
|
@@ -127,14 +127,17 @@ export declare const generateJsxChildren: ({ scope, children, instances, props,
|
|
|
127
127
|
instances: Map<string, {
|
|
128
128
|
type: "instance";
|
|
129
129
|
id: string;
|
|
130
|
-
component: string;
|
|
131
130
|
children: ({
|
|
132
131
|
value: string;
|
|
133
132
|
type: "text";
|
|
134
133
|
} | {
|
|
135
134
|
value: string;
|
|
136
135
|
type: "id";
|
|
136
|
+
} | {
|
|
137
|
+
value: string;
|
|
138
|
+
type: "expression";
|
|
137
139
|
})[];
|
|
140
|
+
component: string;
|
|
138
141
|
label?: string | undefined;
|
|
139
142
|
}>;
|
|
140
143
|
props: Map<string, {
|
|
@@ -260,14 +263,17 @@ export declare const generatePageComponent: ({ scope, page, instances, props, da
|
|
|
260
263
|
instances: Map<string, {
|
|
261
264
|
type: "instance";
|
|
262
265
|
id: string;
|
|
263
|
-
component: string;
|
|
264
266
|
children: ({
|
|
265
267
|
value: string;
|
|
266
268
|
type: "text";
|
|
267
269
|
} | {
|
|
268
270
|
value: string;
|
|
269
271
|
type: "id";
|
|
272
|
+
} | {
|
|
273
|
+
value: string;
|
|
274
|
+
type: "expression";
|
|
270
275
|
})[];
|
|
276
|
+
component: string;
|
|
271
277
|
label?: string | undefined;
|
|
272
278
|
}>;
|
|
273
279
|
props: Map<string, {
|
|
@@ -387,6 +387,27 @@ declare const WsComponentPropsMeta: z.ZodObject<{
|
|
|
387
387
|
defaultValue?: undefined;
|
|
388
388
|
label?: string | undefined;
|
|
389
389
|
description?: string | undefined;
|
|
390
|
+
}>, z.ZodObject<{
|
|
391
|
+
control: z.ZodLiteral<"textContent">;
|
|
392
|
+
type: z.ZodLiteral<"string">;
|
|
393
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
394
|
+
label: z.ZodOptional<z.ZodString>;
|
|
395
|
+
description: z.ZodOptional<z.ZodString>;
|
|
396
|
+
required: z.ZodBoolean;
|
|
397
|
+
}, "strip", z.ZodTypeAny, {
|
|
398
|
+
type: "string";
|
|
399
|
+
required: boolean;
|
|
400
|
+
control: "textContent";
|
|
401
|
+
defaultValue?: string | undefined;
|
|
402
|
+
label?: string | undefined;
|
|
403
|
+
description?: string | undefined;
|
|
404
|
+
}, {
|
|
405
|
+
type: "string";
|
|
406
|
+
required: boolean;
|
|
407
|
+
control: "textContent";
|
|
408
|
+
defaultValue?: string | undefined;
|
|
409
|
+
label?: string | undefined;
|
|
410
|
+
description?: string | undefined;
|
|
390
411
|
}>]>>;
|
|
391
412
|
initialProps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
392
413
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -518,6 +539,13 @@ declare const WsComponentPropsMeta: z.ZodObject<{
|
|
|
518
539
|
defaultValue?: undefined;
|
|
519
540
|
label?: string | undefined;
|
|
520
541
|
description?: string | undefined;
|
|
542
|
+
} | {
|
|
543
|
+
type: "string";
|
|
544
|
+
required: boolean;
|
|
545
|
+
control: "textContent";
|
|
546
|
+
defaultValue?: string | undefined;
|
|
547
|
+
label?: string | undefined;
|
|
548
|
+
description?: string | undefined;
|
|
521
549
|
}>;
|
|
522
550
|
initialProps?: string[] | undefined;
|
|
523
551
|
}, {
|
|
@@ -649,11 +677,18 @@ declare const WsComponentPropsMeta: z.ZodObject<{
|
|
|
649
677
|
defaultValue?: undefined;
|
|
650
678
|
label?: string | undefined;
|
|
651
679
|
description?: string | undefined;
|
|
680
|
+
} | {
|
|
681
|
+
type: "string";
|
|
682
|
+
required: boolean;
|
|
683
|
+
control: "textContent";
|
|
684
|
+
defaultValue?: string | undefined;
|
|
685
|
+
label?: string | undefined;
|
|
686
|
+
description?: string | undefined;
|
|
652
687
|
}>;
|
|
653
688
|
initialProps?: string[] | undefined;
|
|
654
689
|
}>;
|
|
655
690
|
export type WsComponentPropsMeta = z.infer<typeof WsComponentPropsMeta>;
|
|
656
|
-
export declare const componentCategories: readonly ["general", "text", "media", "forms", "radix", "hidden"];
|
|
691
|
+
export declare const componentCategories: readonly ["general", "text", "data", "media", "forms", "radix", "hidden"];
|
|
657
692
|
export declare const stateCategories: readonly ["states", "component-states"];
|
|
658
693
|
export declare const ComponentState: z.ZodObject<{
|
|
659
694
|
category: z.ZodOptional<z.ZodEnum<["states", "component-states"]>>;
|
|
@@ -671,7 +706,7 @@ export declare const ComponentState: z.ZodObject<{
|
|
|
671
706
|
export type ComponentState = z.infer<typeof ComponentState>;
|
|
672
707
|
export declare const defaultStates: ComponentState[];
|
|
673
708
|
export declare const WsComponentMeta: z.ZodObject<{
|
|
674
|
-
category: z.ZodOptional<z.ZodEnum<["general", "text", "media", "forms", "radix", "hidden"]>>;
|
|
709
|
+
category: z.ZodOptional<z.ZodEnum<["general", "text", "data", "media", "forms", "radix", "hidden"]>>;
|
|
675
710
|
type: z.ZodEnum<["container", "control", "embed", "rich-text-child"]>;
|
|
676
711
|
requiredAncestors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
677
712
|
invalidAncestors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -1986,12 +2021,21 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
1986
2021
|
}, {
|
|
1987
2022
|
value: string;
|
|
1988
2023
|
type: "text";
|
|
2024
|
+
}>, z.ZodObject<{
|
|
2025
|
+
type: z.ZodLiteral<"expression">;
|
|
2026
|
+
value: z.ZodString;
|
|
2027
|
+
}, "strip", z.ZodTypeAny, {
|
|
2028
|
+
value: string;
|
|
2029
|
+
type: "expression";
|
|
2030
|
+
}, {
|
|
2031
|
+
value: string;
|
|
2032
|
+
type: "expression";
|
|
1989
2033
|
}>]>, "many">>>;
|
|
1990
2034
|
order: z.ZodOptional<z.ZodNumber>;
|
|
1991
2035
|
}, "strip", z.ZodTypeAny, {
|
|
1992
2036
|
type: "embed" | "control" | "container" | "rich-text-child";
|
|
1993
2037
|
icon: string;
|
|
1994
|
-
category?: "text" | "hidden" | "media" | "general" | "forms" | "radix" | undefined;
|
|
2038
|
+
category?: "data" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | undefined;
|
|
1995
2039
|
requiredAncestors?: string[] | undefined;
|
|
1996
2040
|
invalidAncestors?: string[] | undefined;
|
|
1997
2041
|
indexWithinAncestor?: string | undefined;
|
|
@@ -2436,12 +2480,15 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
2436
2480
|
template?: ({
|
|
2437
2481
|
value: string;
|
|
2438
2482
|
type: "text";
|
|
2483
|
+
} | {
|
|
2484
|
+
value: string;
|
|
2485
|
+
type: "expression";
|
|
2439
2486
|
} | import("../embed-template").EmbedTemplateInstance)[] | undefined;
|
|
2440
2487
|
order?: number | undefined;
|
|
2441
2488
|
}, {
|
|
2442
2489
|
type: "embed" | "control" | "container" | "rich-text-child";
|
|
2443
2490
|
icon: string;
|
|
2444
|
-
category?: "text" | "hidden" | "media" | "general" | "forms" | "radix" | undefined;
|
|
2491
|
+
category?: "data" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | undefined;
|
|
2445
2492
|
requiredAncestors?: string[] | undefined;
|
|
2446
2493
|
invalidAncestors?: string[] | undefined;
|
|
2447
2494
|
indexWithinAncestor?: string | undefined;
|
|
@@ -2886,6 +2933,9 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
2886
2933
|
template?: ({
|
|
2887
2934
|
value: string;
|
|
2888
2935
|
type: "text";
|
|
2936
|
+
} | {
|
|
2937
|
+
value: string;
|
|
2938
|
+
type: "expression";
|
|
2889
2939
|
} | import("../embed-template").EmbedTemplateInstance)[] | undefined;
|
|
2890
2940
|
order?: number | undefined;
|
|
2891
2941
|
}>;
|
package/lib/types/context.d.ts
CHANGED
|
@@ -35,4 +35,6 @@ export declare const ReactSdkContext: import("react").Context<Params & {
|
|
|
35
35
|
* always empty for builder which handle anchor clicks globally
|
|
36
36
|
*/
|
|
37
37
|
pagesPaths: Set<Page["path"]>;
|
|
38
|
+
resources: Record<string, any>;
|
|
38
39
|
}>;
|
|
40
|
+
export declare const useResource: (name: string) => any;
|
|
@@ -134,6 +134,13 @@ export declare const corePropsMetas: {
|
|
|
134
134
|
defaultValue?: undefined;
|
|
135
135
|
label?: string | undefined;
|
|
136
136
|
description?: string | undefined;
|
|
137
|
+
} | {
|
|
138
|
+
type: "string";
|
|
139
|
+
required: boolean;
|
|
140
|
+
control: "textContent";
|
|
141
|
+
defaultValue?: string | undefined;
|
|
142
|
+
label?: string | undefined;
|
|
143
|
+
description?: string | undefined;
|
|
137
144
|
}>;
|
|
138
145
|
initialProps?: string[] | undefined;
|
|
139
146
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type { Instance, Breakpoint } from "@webstudio-is/sdk";
|
|
2
|
+
import type { Instance, Breakpoint, WebstudioFragment } from "@webstudio-is/sdk";
|
|
3
3
|
import { type StyleProperty } from "@webstudio-is/css-engine";
|
|
4
4
|
import type { Simplify } from "type-fest";
|
|
5
5
|
import type { WsComponentMeta } from "./components/component-meta";
|
|
@@ -14,11 +14,25 @@ declare const EmbedTemplateText: z.ZodObject<{
|
|
|
14
14
|
type: "text";
|
|
15
15
|
}>;
|
|
16
16
|
type EmbedTemplateText = z.infer<typeof EmbedTemplateText>;
|
|
17
|
+
declare const EmbedTemplateExpression: z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"expression">;
|
|
19
|
+
value: z.ZodString;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
value: string;
|
|
22
|
+
type: "expression";
|
|
23
|
+
}, {
|
|
24
|
+
value: string;
|
|
25
|
+
type: "expression";
|
|
26
|
+
}>;
|
|
27
|
+
type EmbedTemplateExpression = z.infer<typeof EmbedTemplateExpression>;
|
|
17
28
|
declare const EmbedTemplateVariable: z.ZodObject<{
|
|
29
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
18
30
|
initialValue: z.ZodUnknown;
|
|
19
31
|
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
alias?: string | undefined;
|
|
20
33
|
initialValue?: unknown;
|
|
21
34
|
}, {
|
|
35
|
+
alias?: string | undefined;
|
|
22
36
|
initialValue?: unknown;
|
|
23
37
|
}>;
|
|
24
38
|
type EmbedTemplateVariable = z.infer<typeof EmbedTemplateVariable>;
|
|
@@ -98,14 +112,17 @@ export declare const EmbedTemplateProp: z.ZodUnion<[z.ZodObject<{
|
|
|
98
112
|
type: z.ZodLiteral<"parameter">;
|
|
99
113
|
name: z.ZodString;
|
|
100
114
|
variableName: z.ZodString;
|
|
115
|
+
variableAlias: z.ZodOptional<z.ZodString>;
|
|
101
116
|
}, "strip", z.ZodTypeAny, {
|
|
102
117
|
type: "parameter";
|
|
103
118
|
name: string;
|
|
104
119
|
variableName: string;
|
|
120
|
+
variableAlias?: string | undefined;
|
|
105
121
|
}, {
|
|
106
122
|
type: "parameter";
|
|
107
123
|
name: string;
|
|
108
124
|
variableName: string;
|
|
125
|
+
variableAlias?: string | undefined;
|
|
109
126
|
}>, z.ZodObject<{
|
|
110
127
|
type: z.ZodLiteral<"action">;
|
|
111
128
|
name: z.ZodString;
|
|
@@ -2191,7 +2208,7 @@ export type EmbedTemplateInstance = {
|
|
|
2191
2208
|
props?: EmbedTemplateProp[];
|
|
2192
2209
|
tokens?: string[];
|
|
2193
2210
|
styles?: EmbedTemplateStyleDecl[];
|
|
2194
|
-
children: Array<EmbedTemplateInstance | EmbedTemplateText>;
|
|
2211
|
+
children: Array<EmbedTemplateInstance | EmbedTemplateText | EmbedTemplateExpression>;
|
|
2195
2212
|
};
|
|
2196
2213
|
export declare const EmbedTemplateInstance: z.ZodType<EmbedTemplateInstance>;
|
|
2197
2214
|
export declare const WsEmbedTemplate: z.ZodLazy<z.ZodArray<z.ZodUnion<[z.ZodType<EmbedTemplateInstance, z.ZodTypeDef, EmbedTemplateInstance>, z.ZodObject<{
|
|
@@ -2203,375 +2220,24 @@ export declare const WsEmbedTemplate: z.ZodLazy<z.ZodArray<z.ZodUnion<[z.ZodType
|
|
|
2203
2220
|
}, {
|
|
2204
2221
|
value: string;
|
|
2205
2222
|
type: "text";
|
|
2223
|
+
}>, z.ZodObject<{
|
|
2224
|
+
type: z.ZodLiteral<"expression">;
|
|
2225
|
+
value: z.ZodString;
|
|
2226
|
+
}, "strip", z.ZodTypeAny, {
|
|
2227
|
+
value: string;
|
|
2228
|
+
type: "expression";
|
|
2229
|
+
}, {
|
|
2230
|
+
value: string;
|
|
2231
|
+
type: "expression";
|
|
2206
2232
|
}>]>, "many">>;
|
|
2207
2233
|
export type WsEmbedTemplate = z.infer<typeof WsEmbedTemplate>;
|
|
2208
2234
|
export declare const generateDataFromEmbedTemplate: (treeTemplate: ({
|
|
2209
2235
|
value: string;
|
|
2210
2236
|
type: "text";
|
|
2211
|
-
} |
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
} | {
|
|
2216
|
-
value: string;
|
|
2217
|
-
type: "id";
|
|
2218
|
-
})[];
|
|
2219
|
-
instances: {
|
|
2220
|
-
type: "instance";
|
|
2221
|
-
id: string;
|
|
2222
|
-
component: string;
|
|
2223
|
-
children: ({
|
|
2224
|
-
value: string;
|
|
2225
|
-
type: "text";
|
|
2226
|
-
} | {
|
|
2227
|
-
value: string;
|
|
2228
|
-
type: "id";
|
|
2229
|
-
})[];
|
|
2230
|
-
label?: string | undefined;
|
|
2231
|
-
}[];
|
|
2232
|
-
props: ({
|
|
2233
|
-
value: number;
|
|
2234
|
-
type: "number";
|
|
2235
|
-
name: string;
|
|
2236
|
-
id: string;
|
|
2237
|
-
instanceId: string;
|
|
2238
|
-
required?: boolean | undefined;
|
|
2239
|
-
} | {
|
|
2240
|
-
value: string;
|
|
2241
|
-
type: "string";
|
|
2242
|
-
name: string;
|
|
2243
|
-
id: string;
|
|
2244
|
-
instanceId: string;
|
|
2245
|
-
required?: boolean | undefined;
|
|
2246
|
-
} | {
|
|
2247
|
-
value: boolean;
|
|
2248
|
-
type: "boolean";
|
|
2249
|
-
name: string;
|
|
2250
|
-
id: string;
|
|
2251
|
-
instanceId: string;
|
|
2252
|
-
required?: boolean | undefined;
|
|
2253
|
-
} | {
|
|
2254
|
-
type: "json";
|
|
2255
|
-
name: string;
|
|
2256
|
-
id: string;
|
|
2257
|
-
instanceId: string;
|
|
2258
|
-
value?: unknown;
|
|
2259
|
-
required?: boolean | undefined;
|
|
2260
|
-
} | {
|
|
2261
|
-
value: string;
|
|
2262
|
-
type: "asset";
|
|
2263
|
-
name: string;
|
|
2264
|
-
id: string;
|
|
2265
|
-
instanceId: string;
|
|
2266
|
-
required?: boolean | undefined;
|
|
2267
|
-
} | {
|
|
2268
|
-
value: (string | {
|
|
2269
|
-
instanceId: string;
|
|
2270
|
-
pageId: string;
|
|
2271
|
-
}) & (string | {
|
|
2272
|
-
instanceId: string;
|
|
2273
|
-
pageId: string;
|
|
2274
|
-
} | undefined);
|
|
2275
|
-
type: "page";
|
|
2276
|
-
name: string;
|
|
2277
|
-
id: string;
|
|
2278
|
-
instanceId: string;
|
|
2279
|
-
required?: boolean | undefined;
|
|
2280
|
-
} | {
|
|
2281
|
-
value: string[];
|
|
2282
|
-
type: "string[]";
|
|
2283
|
-
name: string;
|
|
2284
|
-
id: string;
|
|
2285
|
-
instanceId: string;
|
|
2286
|
-
required?: boolean | undefined;
|
|
2287
|
-
} | {
|
|
2288
|
-
value: string;
|
|
2289
|
-
type: "parameter";
|
|
2290
|
-
name: string;
|
|
2291
|
-
id: string;
|
|
2292
|
-
instanceId: string;
|
|
2293
|
-
required?: boolean | undefined;
|
|
2294
|
-
} | {
|
|
2295
|
-
value: string;
|
|
2296
|
-
type: "expression";
|
|
2297
|
-
name: string;
|
|
2298
|
-
id: string;
|
|
2299
|
-
instanceId: string;
|
|
2300
|
-
required?: boolean | undefined;
|
|
2301
|
-
} | {
|
|
2302
|
-
value: {
|
|
2303
|
-
code: string;
|
|
2304
|
-
type: "execute";
|
|
2305
|
-
args: string[];
|
|
2306
|
-
}[];
|
|
2307
|
-
type: "action";
|
|
2308
|
-
name: string;
|
|
2309
|
-
id: string;
|
|
2310
|
-
instanceId: string;
|
|
2311
|
-
required?: boolean | undefined;
|
|
2312
|
-
})[];
|
|
2313
|
-
dataSources: ({
|
|
2314
|
-
value: {
|
|
2315
|
-
value: number;
|
|
2316
|
-
type: "number";
|
|
2317
|
-
} | {
|
|
2318
|
-
value: string;
|
|
2319
|
-
type: "string";
|
|
2320
|
-
} | {
|
|
2321
|
-
value: boolean;
|
|
2322
|
-
type: "boolean";
|
|
2323
|
-
} | {
|
|
2324
|
-
value: string[];
|
|
2325
|
-
type: "string[]";
|
|
2326
|
-
} | {
|
|
2327
|
-
type: "json";
|
|
2328
|
-
value?: unknown;
|
|
2329
|
-
};
|
|
2330
|
-
type: "variable";
|
|
2331
|
-
name: string;
|
|
2332
|
-
id: string;
|
|
2333
|
-
scopeInstanceId?: string | undefined;
|
|
2334
|
-
} | {
|
|
2335
|
-
type: "parameter";
|
|
2336
|
-
name: string;
|
|
2337
|
-
id: string;
|
|
2338
|
-
scopeInstanceId?: string | undefined;
|
|
2339
|
-
} | {
|
|
2340
|
-
type: "resource";
|
|
2341
|
-
name: string;
|
|
2342
|
-
id: string;
|
|
2343
|
-
resourceId: string;
|
|
2344
|
-
scopeInstanceId?: string | undefined;
|
|
2345
|
-
})[];
|
|
2346
|
-
styleSourceSelections: {
|
|
2347
|
-
values: string[];
|
|
2348
|
-
instanceId: string;
|
|
2349
|
-
}[];
|
|
2350
|
-
styleSources: ({
|
|
2351
|
-
type: "token";
|
|
2352
|
-
name: string;
|
|
2353
|
-
id: string;
|
|
2354
|
-
} | {
|
|
2355
|
-
type: "local";
|
|
2356
|
-
id: string;
|
|
2357
|
-
})[];
|
|
2358
|
-
styles: {
|
|
2359
|
-
value: {
|
|
2360
|
-
value: number;
|
|
2361
|
-
type: "unit";
|
|
2362
|
-
unit: "number" | "%" | "deg" | "grad" | "rad" | "turn" | "db" | "fr" | "hz" | "khz" | "cm" | "mm" | "q" | "in" | "pt" | "pc" | "px" | "em" | "rem" | "ex" | "rex" | "cap" | "rcap" | "ch" | "rch" | "ic" | "ric" | "lh" | "rlh" | "vw" | "svw" | "lvw" | "dvw" | "vh" | "svh" | "lvh" | "dvh" | "vi" | "svi" | "lvi" | "dvi" | "vb" | "svb" | "lvb" | "dvb" | "vmin" | "svmin" | "lvmin" | "dvmin" | "vmax" | "svmax" | "lvmax" | "dvmax" | "cqw" | "cqh" | "cqi" | "cqb" | "cqmin" | "cqmax" | "dpi" | "dpcm" | "dppx" | "x" | "st" | "s" | "ms";
|
|
2363
|
-
} | {
|
|
2364
|
-
value: string;
|
|
2365
|
-
type: "keyword";
|
|
2366
|
-
} | {
|
|
2367
|
-
value: string;
|
|
2368
|
-
type: "unparsed";
|
|
2369
|
-
hidden?: boolean | undefined;
|
|
2370
|
-
} | {
|
|
2371
|
-
value: string[];
|
|
2372
|
-
type: "fontFamily";
|
|
2373
|
-
} | {
|
|
2374
|
-
type: "rgb";
|
|
2375
|
-
r: number;
|
|
2376
|
-
g: number;
|
|
2377
|
-
b: number;
|
|
2378
|
-
alpha: number;
|
|
2379
|
-
} | {
|
|
2380
|
-
value: {
|
|
2381
|
-
value: string;
|
|
2382
|
-
type: "asset";
|
|
2383
|
-
} | {
|
|
2384
|
-
type: "url";
|
|
2385
|
-
url: string;
|
|
2386
|
-
};
|
|
2387
|
-
type: "image";
|
|
2388
|
-
hidden?: boolean | undefined;
|
|
2389
|
-
} | {
|
|
2390
|
-
value: string;
|
|
2391
|
-
type: "invalid";
|
|
2392
|
-
} | {
|
|
2393
|
-
value: "";
|
|
2394
|
-
type: "unset";
|
|
2395
|
-
} | {
|
|
2396
|
-
value: ({
|
|
2397
|
-
value: number;
|
|
2398
|
-
type: "unit";
|
|
2399
|
-
unit: "number" | "%" | "deg" | "grad" | "rad" | "turn" | "db" | "fr" | "hz" | "khz" | "cm" | "mm" | "q" | "in" | "pt" | "pc" | "px" | "em" | "rem" | "ex" | "rex" | "cap" | "rcap" | "ch" | "rch" | "ic" | "ric" | "lh" | "rlh" | "vw" | "svw" | "lvw" | "dvw" | "vh" | "svh" | "lvh" | "dvh" | "vi" | "svi" | "lvi" | "dvi" | "vb" | "svb" | "lvb" | "dvb" | "vmin" | "svmin" | "lvmin" | "dvmin" | "vmax" | "svmax" | "lvmax" | "dvmax" | "cqw" | "cqh" | "cqi" | "cqb" | "cqmin" | "cqmax" | "dpi" | "dpcm" | "dppx" | "x" | "st" | "s" | "ms";
|
|
2400
|
-
} | {
|
|
2401
|
-
value: string;
|
|
2402
|
-
type: "keyword";
|
|
2403
|
-
} | {
|
|
2404
|
-
value: string;
|
|
2405
|
-
type: "unparsed";
|
|
2406
|
-
hidden?: boolean | undefined;
|
|
2407
|
-
} | {
|
|
2408
|
-
type: "rgb";
|
|
2409
|
-
r: number;
|
|
2410
|
-
g: number;
|
|
2411
|
-
b: number;
|
|
2412
|
-
alpha: number;
|
|
2413
|
-
})[];
|
|
2414
|
-
type: "tuple";
|
|
2415
|
-
hidden?: boolean | undefined;
|
|
2416
|
-
} | {
|
|
2417
|
-
value: ({
|
|
2418
|
-
value: number;
|
|
2419
|
-
type: "unit";
|
|
2420
|
-
unit: "number" | "%" | "deg" | "grad" | "rad" | "turn" | "db" | "fr" | "hz" | "khz" | "cm" | "mm" | "q" | "in" | "pt" | "pc" | "px" | "em" | "rem" | "ex" | "rex" | "cap" | "rcap" | "ch" | "rch" | "ic" | "ric" | "lh" | "rlh" | "vw" | "svw" | "lvw" | "dvw" | "vh" | "svh" | "lvh" | "dvh" | "vi" | "svi" | "lvi" | "dvi" | "vb" | "svb" | "lvb" | "dvb" | "vmin" | "svmin" | "lvmin" | "dvmin" | "vmax" | "svmax" | "lvmax" | "dvmax" | "cqw" | "cqh" | "cqi" | "cqb" | "cqmin" | "cqmax" | "dpi" | "dpcm" | "dppx" | "x" | "st" | "s" | "ms";
|
|
2421
|
-
} | {
|
|
2422
|
-
value: string;
|
|
2423
|
-
type: "keyword";
|
|
2424
|
-
} | {
|
|
2425
|
-
value: string;
|
|
2426
|
-
type: "unparsed";
|
|
2427
|
-
hidden?: boolean | undefined;
|
|
2428
|
-
} | {
|
|
2429
|
-
value: {
|
|
2430
|
-
value: string;
|
|
2431
|
-
type: "asset";
|
|
2432
|
-
} | {
|
|
2433
|
-
type: "url";
|
|
2434
|
-
url: string;
|
|
2435
|
-
};
|
|
2436
|
-
type: "image";
|
|
2437
|
-
hidden?: boolean | undefined;
|
|
2438
|
-
} | {
|
|
2439
|
-
value: string;
|
|
2440
|
-
type: "invalid";
|
|
2441
|
-
} | {
|
|
2442
|
-
value: ({
|
|
2443
|
-
value: number;
|
|
2444
|
-
type: "unit";
|
|
2445
|
-
unit: "number" | "%" | "deg" | "grad" | "rad" | "turn" | "db" | "fr" | "hz" | "khz" | "cm" | "mm" | "q" | "in" | "pt" | "pc" | "px" | "em" | "rem" | "ex" | "rex" | "cap" | "rcap" | "ch" | "rch" | "ic" | "ric" | "lh" | "rlh" | "vw" | "svw" | "lvw" | "dvw" | "vh" | "svh" | "lvh" | "dvh" | "vi" | "svi" | "lvi" | "dvi" | "vb" | "svb" | "lvb" | "dvb" | "vmin" | "svmin" | "lvmin" | "dvmin" | "vmax" | "svmax" | "lvmax" | "dvmax" | "cqw" | "cqh" | "cqi" | "cqb" | "cqmin" | "cqmax" | "dpi" | "dpcm" | "dppx" | "x" | "st" | "s" | "ms";
|
|
2446
|
-
} | {
|
|
2447
|
-
value: string;
|
|
2448
|
-
type: "keyword";
|
|
2449
|
-
} | {
|
|
2450
|
-
value: string;
|
|
2451
|
-
type: "unparsed";
|
|
2452
|
-
hidden?: boolean | undefined;
|
|
2453
|
-
} | {
|
|
2454
|
-
type: "rgb";
|
|
2455
|
-
r: number;
|
|
2456
|
-
g: number;
|
|
2457
|
-
b: number;
|
|
2458
|
-
alpha: number;
|
|
2459
|
-
})[];
|
|
2460
|
-
type: "tuple";
|
|
2461
|
-
hidden?: boolean | undefined;
|
|
2462
|
-
})[];
|
|
2463
|
-
type: "layers";
|
|
2464
|
-
} | {
|
|
2465
|
-
value: string;
|
|
2466
|
-
type: "var";
|
|
2467
|
-
fallbacks: ({
|
|
2468
|
-
value: number;
|
|
2469
|
-
type: "unit";
|
|
2470
|
-
unit: "number" | "%" | "deg" | "grad" | "rad" | "turn" | "db" | "fr" | "hz" | "khz" | "cm" | "mm" | "q" | "in" | "pt" | "pc" | "px" | "em" | "rem" | "ex" | "rex" | "cap" | "rcap" | "ch" | "rch" | "ic" | "ric" | "lh" | "rlh" | "vw" | "svw" | "lvw" | "dvw" | "vh" | "svh" | "lvh" | "dvh" | "vi" | "svi" | "lvi" | "dvi" | "vb" | "svb" | "lvb" | "dvb" | "vmin" | "svmin" | "lvmin" | "dvmin" | "vmax" | "svmax" | "lvmax" | "dvmax" | "cqw" | "cqh" | "cqi" | "cqb" | "cqmin" | "cqmax" | "dpi" | "dpcm" | "dppx" | "x" | "st" | "s" | "ms";
|
|
2471
|
-
} | {
|
|
2472
|
-
value: string;
|
|
2473
|
-
type: "keyword";
|
|
2474
|
-
} | {
|
|
2475
|
-
value: string;
|
|
2476
|
-
type: "unparsed";
|
|
2477
|
-
hidden?: boolean | undefined;
|
|
2478
|
-
} | {
|
|
2479
|
-
value: string[];
|
|
2480
|
-
type: "fontFamily";
|
|
2481
|
-
} | {
|
|
2482
|
-
type: "rgb";
|
|
2483
|
-
r: number;
|
|
2484
|
-
g: number;
|
|
2485
|
-
b: number;
|
|
2486
|
-
alpha: number;
|
|
2487
|
-
} | {
|
|
2488
|
-
value: {
|
|
2489
|
-
value: string;
|
|
2490
|
-
type: "asset";
|
|
2491
|
-
} | {
|
|
2492
|
-
type: "url";
|
|
2493
|
-
url: string;
|
|
2494
|
-
};
|
|
2495
|
-
type: "image";
|
|
2496
|
-
hidden?: boolean | undefined;
|
|
2497
|
-
} | {
|
|
2498
|
-
value: ({
|
|
2499
|
-
value: number;
|
|
2500
|
-
type: "unit";
|
|
2501
|
-
unit: "number" | "%" | "deg" | "grad" | "rad" | "turn" | "db" | "fr" | "hz" | "khz" | "cm" | "mm" | "q" | "in" | "pt" | "pc" | "px" | "em" | "rem" | "ex" | "rex" | "cap" | "rcap" | "ch" | "rch" | "ic" | "ric" | "lh" | "rlh" | "vw" | "svw" | "lvw" | "dvw" | "vh" | "svh" | "lvh" | "dvh" | "vi" | "svi" | "lvi" | "dvi" | "vb" | "svb" | "lvb" | "dvb" | "vmin" | "svmin" | "lvmin" | "dvmin" | "vmax" | "svmax" | "lvmax" | "dvmax" | "cqw" | "cqh" | "cqi" | "cqb" | "cqmin" | "cqmax" | "dpi" | "dpcm" | "dppx" | "x" | "st" | "s" | "ms";
|
|
2502
|
-
} | {
|
|
2503
|
-
value: string;
|
|
2504
|
-
type: "keyword";
|
|
2505
|
-
} | {
|
|
2506
|
-
value: string;
|
|
2507
|
-
type: "unparsed";
|
|
2508
|
-
hidden?: boolean | undefined;
|
|
2509
|
-
} | {
|
|
2510
|
-
type: "rgb";
|
|
2511
|
-
r: number;
|
|
2512
|
-
g: number;
|
|
2513
|
-
b: number;
|
|
2514
|
-
alpha: number;
|
|
2515
|
-
})[];
|
|
2516
|
-
type: "tuple";
|
|
2517
|
-
hidden?: boolean | undefined;
|
|
2518
|
-
} | {
|
|
2519
|
-
value: ({
|
|
2520
|
-
value: number;
|
|
2521
|
-
type: "unit";
|
|
2522
|
-
unit: "number" | "%" | "deg" | "grad" | "rad" | "turn" | "db" | "fr" | "hz" | "khz" | "cm" | "mm" | "q" | "in" | "pt" | "pc" | "px" | "em" | "rem" | "ex" | "rex" | "cap" | "rcap" | "ch" | "rch" | "ic" | "ric" | "lh" | "rlh" | "vw" | "svw" | "lvw" | "dvw" | "vh" | "svh" | "lvh" | "dvh" | "vi" | "svi" | "lvi" | "dvi" | "vb" | "svb" | "lvb" | "dvb" | "vmin" | "svmin" | "lvmin" | "dvmin" | "vmax" | "svmax" | "lvmax" | "dvmax" | "cqw" | "cqh" | "cqi" | "cqb" | "cqmin" | "cqmax" | "dpi" | "dpcm" | "dppx" | "x" | "st" | "s" | "ms";
|
|
2523
|
-
} | {
|
|
2524
|
-
value: string;
|
|
2525
|
-
type: "keyword";
|
|
2526
|
-
} | {
|
|
2527
|
-
value: string;
|
|
2528
|
-
type: "unparsed";
|
|
2529
|
-
hidden?: boolean | undefined;
|
|
2530
|
-
} | {
|
|
2531
|
-
value: {
|
|
2532
|
-
value: string;
|
|
2533
|
-
type: "asset";
|
|
2534
|
-
} | {
|
|
2535
|
-
type: "url";
|
|
2536
|
-
url: string;
|
|
2537
|
-
};
|
|
2538
|
-
type: "image";
|
|
2539
|
-
hidden?: boolean | undefined;
|
|
2540
|
-
} | {
|
|
2541
|
-
value: string;
|
|
2542
|
-
type: "invalid";
|
|
2543
|
-
} | {
|
|
2544
|
-
value: ({
|
|
2545
|
-
value: number;
|
|
2546
|
-
type: "unit";
|
|
2547
|
-
unit: "number" | "%" | "deg" | "grad" | "rad" | "turn" | "db" | "fr" | "hz" | "khz" | "cm" | "mm" | "q" | "in" | "pt" | "pc" | "px" | "em" | "rem" | "ex" | "rex" | "cap" | "rcap" | "ch" | "rch" | "ic" | "ric" | "lh" | "rlh" | "vw" | "svw" | "lvw" | "dvw" | "vh" | "svh" | "lvh" | "dvh" | "vi" | "svi" | "lvi" | "dvi" | "vb" | "svb" | "lvb" | "dvb" | "vmin" | "svmin" | "lvmin" | "dvmin" | "vmax" | "svmax" | "lvmax" | "dvmax" | "cqw" | "cqh" | "cqi" | "cqb" | "cqmin" | "cqmax" | "dpi" | "dpcm" | "dppx" | "x" | "st" | "s" | "ms";
|
|
2548
|
-
} | {
|
|
2549
|
-
value: string;
|
|
2550
|
-
type: "keyword";
|
|
2551
|
-
} | {
|
|
2552
|
-
value: string;
|
|
2553
|
-
type: "unparsed";
|
|
2554
|
-
hidden?: boolean | undefined;
|
|
2555
|
-
} | {
|
|
2556
|
-
type: "rgb";
|
|
2557
|
-
r: number;
|
|
2558
|
-
g: number;
|
|
2559
|
-
b: number;
|
|
2560
|
-
alpha: number;
|
|
2561
|
-
})[];
|
|
2562
|
-
type: "tuple";
|
|
2563
|
-
hidden?: boolean | undefined;
|
|
2564
|
-
})[];
|
|
2565
|
-
type: "layers";
|
|
2566
|
-
})[];
|
|
2567
|
-
};
|
|
2568
|
-
styleSourceId: string;
|
|
2569
|
-
breakpointId: string;
|
|
2570
|
-
state?: string | undefined;
|
|
2571
|
-
property: StyleProperty;
|
|
2572
|
-
}[];
|
|
2573
|
-
};
|
|
2574
|
-
export type EmbedTemplateData = ReturnType<typeof generateDataFromEmbedTemplate>;
|
|
2237
|
+
} | {
|
|
2238
|
+
value: string;
|
|
2239
|
+
type: "expression";
|
|
2240
|
+
} | EmbedTemplateInstance)[], metas: Map<Instance["component"], WsComponentMeta>, defaultBreakpointId: Breakpoint["id"], generateId?: () => string) => WebstudioFragment;
|
|
2575
2241
|
export declare const namespaceMeta: (meta: WsComponentMeta, namespace: string, components: Set<EmbedTemplateInstance["component"]>) => {
|
|
2576
2242
|
type: "embed" | "control" | "container" | "rich-text-child";
|
|
2577
2243
|
description?: string | undefined;
|
|
@@ -2580,8 +2246,11 @@ export declare const namespaceMeta: (meta: WsComponentMeta, namespace: string, c
|
|
|
2580
2246
|
template?: ({
|
|
2581
2247
|
value: string;
|
|
2582
2248
|
type: "text";
|
|
2249
|
+
} | {
|
|
2250
|
+
value: string;
|
|
2251
|
+
type: "expression";
|
|
2583
2252
|
} | EmbedTemplateInstance)[] | undefined;
|
|
2584
|
-
category?: "text" | "hidden" | "media" | "general" | "forms" | "radix" | undefined;
|
|
2253
|
+
category?: "data" | "text" | "hidden" | "media" | "general" | "forms" | "radix" | undefined;
|
|
2585
2254
|
requiredAncestors?: string[] | undefined;
|
|
2586
2255
|
invalidAncestors?: string[] | undefined;
|
|
2587
2256
|
indexWithinAncestor?: string | undefined;
|
package/lib/types/generator.d.ts
CHANGED
package/lib/types/hook.d.ts
CHANGED
|
@@ -28,14 +28,17 @@ export type Hook = {
|
|
|
28
28
|
export declare const getClosestInstance: (instancePath: InstancePath, currentInstance: Instance, closestComponent: Instance["component"]) => {
|
|
29
29
|
type: "instance";
|
|
30
30
|
id: string;
|
|
31
|
-
component: string;
|
|
32
31
|
children: ({
|
|
33
32
|
value: string;
|
|
34
33
|
type: "text";
|
|
35
34
|
} | {
|
|
36
35
|
value: string;
|
|
37
36
|
type: "id";
|
|
37
|
+
} | {
|
|
38
|
+
value: string;
|
|
39
|
+
type: "expression";
|
|
38
40
|
})[];
|
|
41
|
+
component: string;
|
|
39
42
|
label?: string | undefined;
|
|
40
43
|
} | undefined;
|
|
41
44
|
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { PropMeta } from "./prop-meta";
|
|
|
8
8
|
export { type WsComponentPropsMeta, type ComponentState, type PresetStyle, WsComponentMeta, componentCategories, stateCategories, defaultStates, } from "./components/component-meta";
|
|
9
9
|
export * from "./embed-template";
|
|
10
10
|
export * from "./props";
|
|
11
|
-
export
|
|
11
|
+
export * from "./context";
|
|
12
12
|
export { validateExpression, encodeDataSourceVariable, decodeDataSourceVariable, generateDataSources, } from "./expression";
|
|
13
13
|
export { getIndexesWithinAncestors } from "./instance-utils";
|
|
14
14
|
export * from "./hook";
|
|
@@ -4,13 +4,16 @@ export type IndexesWithinAncestors = Map<Instance["id"], number>;
|
|
|
4
4
|
export declare const getIndexesWithinAncestors: (metas: Map<Instance["component"], WsComponentMeta>, instances: Map<string, {
|
|
5
5
|
type: "instance";
|
|
6
6
|
id: string;
|
|
7
|
-
component: string;
|
|
8
7
|
children: ({
|
|
9
8
|
value: string;
|
|
10
9
|
type: "text";
|
|
11
10
|
} | {
|
|
12
11
|
value: string;
|
|
13
12
|
type: "id";
|
|
13
|
+
} | {
|
|
14
|
+
value: string;
|
|
15
|
+
type: "expression";
|
|
14
16
|
})[];
|
|
17
|
+
component: string;
|
|
15
18
|
label?: string | undefined;
|
|
16
19
|
}>, rootIds: Instance["id"][]) => IndexesWithinAncestors;
|
package/lib/types/prop-meta.d.ts
CHANGED
|
@@ -392,5 +392,26 @@ export declare const PropMeta: z.ZodUnion<[z.ZodObject<{
|
|
|
392
392
|
defaultValue?: undefined;
|
|
393
393
|
label?: string | undefined;
|
|
394
394
|
description?: string | undefined;
|
|
395
|
+
}>, z.ZodObject<{
|
|
396
|
+
control: z.ZodLiteral<"textContent">;
|
|
397
|
+
type: z.ZodLiteral<"string">;
|
|
398
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
399
|
+
label: z.ZodOptional<z.ZodString>;
|
|
400
|
+
description: z.ZodOptional<z.ZodString>;
|
|
401
|
+
required: z.ZodBoolean;
|
|
402
|
+
}, "strip", z.ZodTypeAny, {
|
|
403
|
+
type: "string";
|
|
404
|
+
required: boolean;
|
|
405
|
+
control: "textContent";
|
|
406
|
+
defaultValue?: string | undefined;
|
|
407
|
+
label?: string | undefined;
|
|
408
|
+
description?: string | undefined;
|
|
409
|
+
}, {
|
|
410
|
+
type: "string";
|
|
411
|
+
required: boolean;
|
|
412
|
+
control: "textContent";
|
|
413
|
+
defaultValue?: string | undefined;
|
|
414
|
+
label?: string | undefined;
|
|
415
|
+
description?: string | undefined;
|
|
395
416
|
}>]>;
|
|
396
417
|
export type PropMeta = z.infer<typeof PropMeta>;
|
package/lib/types/props.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export type Pages = Map<Page["id"], Page>;
|
|
1
|
+
import { type Prop, type Assets, type Pages } from "@webstudio-is/sdk";
|
|
3
2
|
export declare const normalizeProps: ({ props, assetBaseUrl, assets, pages, }: {
|
|
4
3
|
props: Prop[];
|
|
5
4
|
assetBaseUrl: string;
|
|
@@ -139,5 +138,6 @@ export declare const componentAttribute: "data-ws-component";
|
|
|
139
138
|
export declare const showAttribute: "data-ws-show";
|
|
140
139
|
export declare const indexAttribute: "data-ws-index";
|
|
141
140
|
export declare const collapsedAttribute: "data-ws-collapsed";
|
|
141
|
+
export declare const textContentAttribute: "data-ws-text-content";
|
|
142
142
|
export declare const getInstanceIdFromComponentProps: (props: Record<string, unknown>) => string;
|
|
143
143
|
export declare const getIndexWithinAncestorFromComponentProps: (props: Record<string, unknown>) => string | undefined;
|
|
@@ -13,14 +13,17 @@ export declare const createElementsTree: ({ renderer, assetBaseUrl, imageBaseUrl
|
|
|
13
13
|
instances: Map<string, {
|
|
14
14
|
type: "instance";
|
|
15
15
|
id: string;
|
|
16
|
-
component: string;
|
|
17
16
|
children: ({
|
|
18
17
|
value: string;
|
|
19
18
|
type: "text";
|
|
20
19
|
} | {
|
|
21
20
|
value: string;
|
|
22
21
|
type: "id";
|
|
22
|
+
} | {
|
|
23
|
+
value: string;
|
|
24
|
+
type: "expression";
|
|
23
25
|
})[];
|
|
26
|
+
component: string;
|
|
24
27
|
label?: string | undefined;
|
|
25
28
|
}>;
|
|
26
29
|
imageLoader: ImageLoader;
|
|
@@ -32,14 +35,17 @@ export declare const createInstanceChildrenElements: ({ instances, instanceSelec
|
|
|
32
35
|
instances: Map<string, {
|
|
33
36
|
type: "instance";
|
|
34
37
|
id: string;
|
|
35
|
-
component: string;
|
|
36
38
|
children: ({
|
|
37
39
|
value: string;
|
|
38
40
|
type: "text";
|
|
39
41
|
} | {
|
|
40
42
|
value: string;
|
|
41
43
|
type: "id";
|
|
44
|
+
} | {
|
|
45
|
+
value: string;
|
|
46
|
+
type: "expression";
|
|
42
47
|
})[];
|
|
48
|
+
component: string;
|
|
43
49
|
label?: string | undefined;
|
|
44
50
|
}>;
|
|
45
51
|
instanceSelector: InstanceSelector;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.126.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"type-fest": "^4.3.1",
|
|
17
17
|
"typescript": "5.2.2",
|
|
18
18
|
"zod": "^3.21.4",
|
|
19
|
-
"@webstudio-is/
|
|
20
|
-
"@webstudio-is/
|
|
19
|
+
"@webstudio-is/jest-config": "1.0.7",
|
|
20
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@remix-run/react": "^1.19.1",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"jsep": "^1.3.8",
|
|
34
34
|
"nanoid": "^5.0.1",
|
|
35
35
|
"title-case": "^4.1.0",
|
|
36
|
-
"@webstudio-is/fonts": "0.
|
|
37
|
-
"@webstudio-is/
|
|
38
|
-
"@webstudio-is/
|
|
39
|
-
"@webstudio-is/icons": "^0.
|
|
40
|
-
"@webstudio-is/sdk": "0.
|
|
36
|
+
"@webstudio-is/fonts": "0.126.0",
|
|
37
|
+
"@webstudio-is/image": "0.126.0",
|
|
38
|
+
"@webstudio-is/css-engine": "0.126.0",
|
|
39
|
+
"@webstudio-is/icons": "^0.126.0",
|
|
40
|
+
"@webstudio-is/sdk": "0.126.0"
|
|
41
41
|
},
|
|
42
42
|
"exports": {
|
|
43
43
|
".": {
|