@builder.io/mitosis 0.1.0 → 0.1.2
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.
|
@@ -198,7 +198,12 @@ var blockToReact = function (json, options, component, parentSlots) {
|
|
|
198
198
|
str += " ".concat(newKey, "={").concat(newValue, "} ");
|
|
199
199
|
}
|
|
200
200
|
else {
|
|
201
|
-
|
|
201
|
+
if (useBindingValue === 'true') {
|
|
202
|
+
str += " ".concat(BINDING_MAPPERS[key], " ");
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
str += " ".concat(BINDING_MAPPERS[key], "={").concat(useBindingValue, "} ");
|
|
206
|
+
}
|
|
202
207
|
}
|
|
203
208
|
}
|
|
204
209
|
else if (key === 'style' && options.type === 'native' && json.name === 'ScrollView') {
|
|
@@ -527,7 +527,17 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
|
|
|
527
527
|
for (var key in block.component.options) {
|
|
528
528
|
var value = block.component.options[key];
|
|
529
529
|
var valueIsArrayOfBuilderElements = Array.isArray(value) && value.every(exports.isBuilderElement);
|
|
530
|
-
|
|
530
|
+
var transformBldrElementToBinding = function (item) {
|
|
531
|
+
var node = (0, exports.builderElementToMitosisNode)(item, __assign(__assign({}, options), { includeSpecialBindings: false }));
|
|
532
|
+
// For now, stringify to Mitosis nodes even though that only really works in React, due to syntax overlap.
|
|
533
|
+
// the correct long term solution is to hold on to the Mitosis Node, and have a plugin for each framework
|
|
534
|
+
// which processes any Mitosis nodes set into the attribute and moves them as slots when relevant (Svelte/Vue)
|
|
535
|
+
return (0, __1.blockToMitosis)(node, {}, null);
|
|
536
|
+
};
|
|
537
|
+
if ((0, exports.isBuilderElement)(value)) {
|
|
538
|
+
bindings[key] = (0, bindings_1.createSingleBinding)({ code: transformBldrElementToBinding(value) });
|
|
539
|
+
}
|
|
540
|
+
else if (typeof value === 'string') {
|
|
531
541
|
properties[key] = value;
|
|
532
542
|
}
|
|
533
543
|
else if (valueIsArrayOfBuilderElements) {
|
|
@@ -539,13 +549,7 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
|
|
|
539
549
|
}
|
|
540
550
|
return true;
|
|
541
551
|
})
|
|
542
|
-
.map(
|
|
543
|
-
var node = (0, exports.builderElementToMitosisNode)(item, __assign(__assign({}, options), { includeSpecialBindings: false }));
|
|
544
|
-
// For now, stringify to Mitosis nodes even though that only really works in React, due to syntax overlap.
|
|
545
|
-
// the correct long term solution is to hold on to the Mitosis Node, and have a plugin for each framework
|
|
546
|
-
// which processes any Mitosis nodes set into the attribute and moves them as slots when relevant (Svelte/Vue)
|
|
547
|
-
return (0, __1.blockToMitosis)(node, {}, null);
|
|
548
|
-
});
|
|
552
|
+
.map(transformBldrElementToBinding);
|
|
549
553
|
var strVal = childrenElements.length === 1 ? childrenElements[0] : "<>".concat(childrenElements.join(''), "</>");
|
|
550
554
|
bindings[key] = (0, bindings_1.createSingleBinding)({ code: strVal });
|
|
551
555
|
}
|
|
@@ -256,8 +256,8 @@ exports.components = {
|
|
|
256
256
|
}), components);
|
|
257
257
|
},
|
|
258
258
|
Image: function (node, context, components) {
|
|
259
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
260
|
-
var
|
|
259
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
260
|
+
var _k = node.properties, backgroundSize = _k.backgroundSize, backgroundPosition = _k.backgroundPosition;
|
|
261
261
|
var srcset = node.properties.srcset;
|
|
262
262
|
var aspectRatio = ((_a = node.bindings.aspectRatio) === null || _a === void 0 ? void 0 : _a.code)
|
|
263
263
|
? parseFloat(node.bindings.aspectRatio.code)
|
|
@@ -281,12 +281,13 @@ exports.components = {
|
|
|
281
281
|
bindings: noUndefined({
|
|
282
282
|
src: ((_c = node.bindings.image) === null || _c === void 0 ? void 0 : _c.code) && { code: (_d = node.bindings.image) === null || _d === void 0 ? void 0 : _d.code },
|
|
283
283
|
sizes: ((_e = node.bindings.sizes) === null || _e === void 0 ? void 0 : _e.code) && { code: (_f = node.bindings.sizes) === null || _f === void 0 ? void 0 : _f.code },
|
|
284
|
+
style: ((_g = node.bindings.style) === null || _g === void 0 ? void 0 : _g.code) && { code: (_h = node.bindings.style) === null || _h === void 0 ? void 0 : _h.code },
|
|
284
285
|
css: (0, bindings_1.createSingleBinding)({
|
|
285
286
|
code: JSON.stringify(__assign(__assign({ aspectRatio: aspectRatio ? String((0, lodash_1.round)(1 / aspectRatio, 2)) : undefined, objectFit: backgroundSize || 'cover', objectPosition: backgroundPosition || 'center', width: '100%' }, css), { display: undefined, flexDirection: undefined, position: css.position === 'relative' ? undefined : css.position })),
|
|
286
287
|
}),
|
|
287
288
|
}),
|
|
288
289
|
});
|
|
289
|
-
if (!((
|
|
290
|
+
if (!((_j = node.children) === null || _j === void 0 ? void 0 : _j.length)) {
|
|
290
291
|
return img;
|
|
291
292
|
}
|
|
292
293
|
// TODO: deal with links: anchor tag and href
|