@webstudio-is/react-sdk 0.87.0 → 0.88.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/cjs/component-renderer.js +1 -1
- package/lib/cjs/components/component-meta.js +5 -0
- package/lib/cjs/embed-template.js +41 -6
- package/lib/cjs/generator.js +1 -1
- package/lib/cjs/props.js +35 -35
- package/lib/component-renderer.js +1 -1
- package/lib/components/component-meta.js +5 -0
- package/lib/embed-template.js +41 -6
- package/lib/generator.js +1 -1
- package/lib/props.js +35 -35
- package/lib/types/components/component-meta.d.ts +1426 -136
- package/lib/types/embed-template.d.ts +219 -2
- package/package.json +9 -7
- package/src/component-renderer.tsx +1 -1
- package/src/components/component-meta.ts +6 -0
- package/src/embed-template.test.ts +106 -0
- package/src/embed-template.ts +46 -4
- package/src/generator.test.ts +1 -1
- package/src/generator.ts +1 -1
- package/src/props.test.ts +29 -0
- package/src/props.ts +45 -41
package/src/props.ts
CHANGED
|
@@ -31,7 +31,6 @@ export const useInstanceProps = (instanceId: Instance["id"]) => {
|
|
|
31
31
|
dataSourceValuesStore,
|
|
32
32
|
executeEffectfulExpression,
|
|
33
33
|
setDataSourceValues,
|
|
34
|
-
renderer,
|
|
35
34
|
indexesWithinAncestors,
|
|
36
35
|
} = useContext(ReactSdkContext);
|
|
37
36
|
const index = indexesWithinAncestors.get(instanceId);
|
|
@@ -61,10 +60,6 @@ export const useInstanceProps = (instanceId: Instance["id"]) => {
|
|
|
61
60
|
}
|
|
62
61
|
if (prop.type === "action") {
|
|
63
62
|
instancePropsObject[prop.name] = (...args: unknown[]) => {
|
|
64
|
-
// prevent all actions in canvas mode
|
|
65
|
-
if (renderer === "canvas") {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
63
|
for (const value of prop.value) {
|
|
69
64
|
if (value.type === "execute") {
|
|
70
65
|
const argsMap = new Map<string, unknown>();
|
|
@@ -91,7 +86,6 @@ export const useInstanceProps = (instanceId: Instance["id"]) => {
|
|
|
91
86
|
propsByInstanceIdStore,
|
|
92
87
|
dataSourceValuesStore,
|
|
93
88
|
instanceId,
|
|
94
|
-
renderer,
|
|
95
89
|
executeEffectfulExpression,
|
|
96
90
|
setDataSourceValues,
|
|
97
91
|
index,
|
|
@@ -147,54 +141,64 @@ export const resolveUrlProp = (
|
|
|
147
141
|
if (instanceProps === undefined) {
|
|
148
142
|
return;
|
|
149
143
|
}
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
|
|
145
|
+
let prop = undefined;
|
|
146
|
+
|
|
147
|
+
// We had a bug that some props were duplicated https://github.com/webstudio-is/webstudio-builder/pull/2170
|
|
148
|
+
// Use the latest prop to ensure consistency with the builder settings panel.
|
|
149
|
+
for (const intanceProp of instanceProps) {
|
|
150
|
+
if (intanceProp.name !== name) {
|
|
152
151
|
continue;
|
|
153
152
|
}
|
|
153
|
+
prop = intanceProp;
|
|
154
|
+
}
|
|
154
155
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return page && { type: "page", page };
|
|
159
|
-
}
|
|
156
|
+
if (prop === undefined) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
160
159
|
|
|
161
|
-
|
|
160
|
+
if (prop.type === "page") {
|
|
161
|
+
if (typeof prop.value === "string") {
|
|
162
|
+
const page = pages.get(prop.value);
|
|
163
|
+
return page && { type: "page", page };
|
|
164
|
+
}
|
|
162
165
|
|
|
163
|
-
|
|
166
|
+
const { instanceId, pageId } = prop.value;
|
|
164
167
|
|
|
165
|
-
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
+
const page = pages.get(pageId);
|
|
168
169
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
type: "page",
|
|
173
|
-
page,
|
|
174
|
-
instanceId,
|
|
175
|
-
hash:
|
|
176
|
-
idProp === undefined || idProp.type !== "string"
|
|
177
|
-
? undefined
|
|
178
|
-
: idProp.value,
|
|
179
|
-
};
|
|
170
|
+
if (page === undefined) {
|
|
171
|
+
return;
|
|
180
172
|
}
|
|
181
173
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
174
|
+
const idProp = props.get(instanceId)?.find((prop) => prop.name === "id");
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
type: "page",
|
|
178
|
+
page,
|
|
179
|
+
instanceId,
|
|
180
|
+
hash:
|
|
181
|
+
idProp === undefined || idProp.type !== "string"
|
|
182
|
+
? undefined
|
|
183
|
+
: idProp.value,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
190
186
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
if (prop.type === "string") {
|
|
188
|
+
for (const page of pages.values()) {
|
|
189
|
+
if (page.path === prop.value) {
|
|
190
|
+
return { type: "page", page };
|
|
191
|
+
}
|
|
194
192
|
}
|
|
193
|
+
return { type: "string", url: prop.value };
|
|
194
|
+
}
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
if (prop.type === "asset") {
|
|
197
|
+
const asset = assets.get(prop.value);
|
|
198
|
+
return asset && { type: "asset", asset };
|
|
197
199
|
}
|
|
200
|
+
|
|
201
|
+
return;
|
|
198
202
|
};
|
|
199
203
|
|
|
200
204
|
// this utility is used for link component in both builder and preview
|