@builder.io/mitosis 0.5.35 → 0.5.37

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.
@@ -405,15 +405,34 @@ const mapBoundStyles = (bindings) => {
405
405
  }
406
406
  }
407
407
  else {
408
- bindings[`style.${key}`] = {
409
- code: parsed[key],
410
- bindingType: 'expression',
411
- type: 'single',
412
- };
408
+ if (isGlobalStyle(key)) {
409
+ console.warn(`The following bound styles are not supported by Builder JSON and have been removed:
410
+ "${key}": ${parsed[key]}
411
+ `);
412
+ }
413
+ else {
414
+ bindings[`style.${key}`] = {
415
+ code: parsed[key],
416
+ bindingType: 'expression',
417
+ type: 'single',
418
+ };
419
+ }
413
420
  }
414
421
  }
415
422
  delete bindings['style'];
416
423
  };
424
+ function isGlobalStyle(key) {
425
+ // These are mapped to their respective responsiveStyle and support bindings
426
+ if (/max-width: (.*?)px/gm.exec(key)) {
427
+ return false;
428
+ }
429
+ return (
430
+ // pseudo class
431
+ key.startsWith('&:') ||
432
+ key.startsWith(':') ||
433
+ // @ rules
434
+ key.startsWith('@'));
435
+ }
417
436
  const blockToBuilder = (json, options = {}, _internalOptions = {}) => {
418
437
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
419
438
  const mapper = !_internalOptions.skipMapper && componentMappers[json.name];
@@ -912,6 +912,8 @@ function convertExportDefaultToReturn(code) {
912
912
  try {
913
913
  const { types } = babel;
914
914
  const body = (0, parsers_1.parseCode)(code);
915
+ if (body.length === 0)
916
+ return code;
915
917
  const newBody = body.slice();
916
918
  for (let i = 0; i < body.length; i++) {
917
919
  const statement = body[i];
@@ -273,11 +273,9 @@ const jsxElementToJson = (node) => {
273
273
  // <Foo myProp={"hello"} />
274
274
  memo.properties[key] = expression.value;
275
275
  }
276
- else if (types.isArrowFunctionExpression(expression)) {
276
+ else if (key.startsWith('on') && types.isArrowFunctionExpression(expression)) {
277
277
  // <Foo myProp={() => {}} />
278
- const args = key.startsWith('on')
279
- ? expression.params.map((node) => node === null || node === void 0 ? void 0 : node.name)
280
- : [];
278
+ const args = expression.params.map((node) => node === null || node === void 0 ? void 0 : node.name);
281
279
  memo.bindings[key] = (0, bindings_1.createSingleBinding)({
282
280
  code: (0, generator_1.default)(expression.body, { compact: true }).code,
283
281
  async: expression.async === true ? true : undefined,
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "name": "Builder.io",
23
23
  "url": "https://www.builder.io"
24
24
  },
25
- "version": "0.5.35",
25
+ "version": "0.5.37",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {