@builder.io/mitosis 0.6.1 → 0.6.3
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.
|
@@ -393,7 +393,7 @@ const mapBoundStyles = (bindings) => {
|
|
|
393
393
|
if (!styles) {
|
|
394
394
|
return;
|
|
395
395
|
}
|
|
396
|
-
const { parsed } = parseJSObject(styles.code);
|
|
396
|
+
const { parsed, unparsed } = parseJSObject(styles.code);
|
|
397
397
|
for (const key in parsed) {
|
|
398
398
|
const mediaQueryMatch = key.match(media_sizes_1.mediaQueryRegex);
|
|
399
399
|
if (mediaQueryMatch) {
|
|
@@ -424,6 +424,29 @@ const mapBoundStyles = (bindings) => {
|
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
delete bindings['style'];
|
|
427
|
+
// unparsed data could be something else such as a function call
|
|
428
|
+
if (unparsed) {
|
|
429
|
+
try {
|
|
430
|
+
const ast = (0, parser_1.parseExpression)(`(${unparsed})`, {
|
|
431
|
+
plugins: ['jsx', 'typescript'],
|
|
432
|
+
sourceType: 'module',
|
|
433
|
+
});
|
|
434
|
+
// style={state.getStyles()}
|
|
435
|
+
if (ast.type === 'CallExpression') {
|
|
436
|
+
bindings['style'] = {
|
|
437
|
+
code: unparsed,
|
|
438
|
+
bindingType: 'expression',
|
|
439
|
+
type: 'single',
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
throw 'unsupported style';
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
catch (_a) {
|
|
447
|
+
console.warn(`The following bound styles are invalid and have been removed: ${unparsed}`);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
427
450
|
};
|
|
428
451
|
function isGlobalStyle(key) {
|
|
429
452
|
// These are mapped to their respective responsiveStyle and support bindings
|
|
@@ -1112,16 +1112,13 @@ function mapBuilderBindingsToMitosisBindingWithCode(bindings) {
|
|
|
1112
1112
|
});
|
|
1113
1113
|
return result;
|
|
1114
1114
|
}
|
|
1115
|
-
function removeFalsey(obj) {
|
|
1116
|
-
return (0, lodash_1.omitBy)(obj, (value) => !value || value === '0' || value === '0px' || value === 'none' || value === '0%');
|
|
1117
|
-
}
|
|
1118
1115
|
function combineStyles(parent, child) {
|
|
1119
1116
|
const marginStyles = ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'];
|
|
1120
1117
|
const paddingStyles = ['paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight'];
|
|
1121
1118
|
const distanceStylesToCombine = [...paddingStyles, ...marginStyles];
|
|
1122
1119
|
const merged = {
|
|
1123
|
-
...(0, lodash_1.omit)(
|
|
1124
|
-
...
|
|
1120
|
+
...(0, lodash_1.omit)(child, distanceStylesToCombine),
|
|
1121
|
+
...parent,
|
|
1125
1122
|
};
|
|
1126
1123
|
for (const key of distanceStylesToCombine) {
|
|
1127
1124
|
// Funky things happen if different alignment
|