@webstudio-is/react-sdk 0.274.4 → 0.275.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 +8 -3
- package/lib/types/props.d.ts +418 -418
- package/package.json +14 -9
package/lib/index.js
CHANGED
|
@@ -200,14 +200,19 @@ var getCollectionEntries = (data) => {
|
|
|
200
200
|
}
|
|
201
201
|
return entries;
|
|
202
202
|
};
|
|
203
|
+
var isStaticCollectionExpression = (expression) => {
|
|
204
|
+
const trimmedExpression = expression.trim();
|
|
205
|
+
return trimmedExpression.startsWith("[") && trimmedExpression.endsWith("]") || trimmedExpression.startsWith("{") && trimmedExpression.endsWith("}") || trimmedExpression.startsWith("({") && trimmedExpression.endsWith("})");
|
|
206
|
+
};
|
|
203
207
|
var generateCollectionIterationCode = ({
|
|
204
208
|
dataExpression,
|
|
205
209
|
keyVariable,
|
|
206
210
|
itemVariable
|
|
207
211
|
}) => {
|
|
212
|
+
const safeDataExpression = isStaticCollectionExpression(dataExpression) ? dataExpression : `${dataExpression} ?? {}`;
|
|
208
213
|
return `Object.entries(
|
|
209
214
|
// @ts-ignore
|
|
210
|
-
${
|
|
215
|
+
${safeDataExpression}
|
|
211
216
|
).map(([_key, ${itemVariable}]: any) => {
|
|
212
217
|
const ${keyVariable} = Array.isArray(${dataExpression}) ? Number(_key) : _key;
|
|
213
218
|
return`;
|
|
@@ -608,7 +613,7 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
|
|
|
608
613
|
}
|
|
609
614
|
continue;
|
|
610
615
|
}
|
|
611
|
-
if (name === "className" && propValue !== void 0) {
|
|
616
|
+
if ((name === "className" || name === "class" && meta === void 0) && propValue !== void 0) {
|
|
612
617
|
classNameValue = propValue;
|
|
613
618
|
continue;
|
|
614
619
|
}
|
|
@@ -660,7 +665,7 @@ ${name}={${propValue}}`;
|
|
|
660
665
|
} else {
|
|
661
666
|
let componentVariable;
|
|
662
667
|
if (instance.component === elementComponent) {
|
|
663
|
-
componentVariable = instance.tag ?? "div";
|
|
668
|
+
componentVariable = instance.tag === "" ? "div" : instance.tag ?? "div";
|
|
664
669
|
const componentDescriptor = tagsOverrides?.[componentVariable];
|
|
665
670
|
if (componentDescriptor !== void 0) {
|
|
666
671
|
const [_importSource, importSpecifier] = componentDescriptor.split(":");
|