@embeddable.com/sdk-react 2.2.25 → 2.2.27
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.esm.js +21 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +21 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -565,7 +565,27 @@ const validateComponentProps = (metaInfo) => {
|
|
|
565
565
|
// There is no props defined
|
|
566
566
|
if (!propsNode)
|
|
567
567
|
return;
|
|
568
|
-
|
|
568
|
+
let functionBody;
|
|
569
|
+
// if propsNode is a function defined elsewhere
|
|
570
|
+
if (propsNode.value.type === "Identifier") {
|
|
571
|
+
const functionName = propsNode.value.name;
|
|
572
|
+
path
|
|
573
|
+
.findParent((path) => path.isProgram())
|
|
574
|
+
.traverse({
|
|
575
|
+
VariableDeclarator(path) {
|
|
576
|
+
if (path.node.id.name === functionName &&
|
|
577
|
+
(path.node.init.type === "FunctionExpression" ||
|
|
578
|
+
path.node.init.type === "ArrowFunctionExpression")) {
|
|
579
|
+
functionBody = path.node.init.body.body;
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
// assume that propsNode is anonymous function
|
|
586
|
+
functionBody = propsNode.value.body.body;
|
|
587
|
+
}
|
|
588
|
+
const propsReturnStatement = functionBody.find((x) => x.type === "ReturnStatement");
|
|
569
589
|
const results = (_b = propsReturnStatement === null || propsReturnStatement === void 0 ? void 0 : propsReturnStatement.argument) === null || _b === void 0 ? void 0 : _b.properties.find((x) => { var _a; return ((_a = x === null || x === void 0 ? void 0 : x.key) === null || _a === void 0 ? void 0 : _a.name) === "results"; });
|
|
570
590
|
// There is no results defined inside props
|
|
571
591
|
if (results === undefined) {
|