@builder.io/mitosis 0.6.1 → 0.6.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.
|
@@ -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
|