@formepdf/react 0.4.0 → 0.4.1
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/dist/serialize.js +21 -1
- package/package.json +1 -1
package/dist/serialize.js
CHANGED
|
@@ -868,7 +868,7 @@ function serializeTemplateChild(child, parent = null) {
|
|
|
868
868
|
}
|
|
869
869
|
// Check for expr marker
|
|
870
870
|
if (isExprMarker(child)) {
|
|
871
|
-
return getExpr(child);
|
|
871
|
+
return serializeExprValues(getExpr(child), parent);
|
|
872
872
|
}
|
|
873
873
|
// Check for ref sentinel strings
|
|
874
874
|
if (typeof child === 'string') {
|
|
@@ -1058,6 +1058,26 @@ function flattenTemplateChildren(children) {
|
|
|
1058
1058
|
result.push(children);
|
|
1059
1059
|
return result;
|
|
1060
1060
|
}
|
|
1061
|
+
// ─── Expression value serialization ─────────────────────────────────
|
|
1062
|
+
/**
|
|
1063
|
+
* Recursively process an expression object, serializing any React elements
|
|
1064
|
+
* found in its values (e.g. $if then/else branches).
|
|
1065
|
+
*/
|
|
1066
|
+
function serializeExprValues(expr, parent) {
|
|
1067
|
+
const result = {};
|
|
1068
|
+
for (const [key, val] of Object.entries(expr)) {
|
|
1069
|
+
if (isValidElement(val)) {
|
|
1070
|
+
result[key] = serializeTemplateChild(val, parent);
|
|
1071
|
+
}
|
|
1072
|
+
else if (Array.isArray(val)) {
|
|
1073
|
+
result[key] = val.map(v => isValidElement(v) ? serializeTemplateChild(v, parent) : v);
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
result[key] = val;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
return result;
|
|
1080
|
+
}
|
|
1061
1081
|
// ─── Template value processing ──────────────────────────────────────
|
|
1062
1082
|
/**
|
|
1063
1083
|
* Process a value that may contain ref markers, expr markers, or proxy objects.
|