@builder.io/mitosis 0.0.146 → 0.0.147

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.
@@ -128,6 +128,7 @@ var BINDING_MAPPERS = __assign({ ref: function (ref, value, options) {
128
128
  } }, ATTTRIBUTE_MAPPERS);
129
129
  var blockToReact = function (json, options, component, parentSlots) {
130
130
  var _a, _b, _c;
131
+ if (parentSlots === void 0) { parentSlots = []; }
131
132
  if (NODE_MAPPERS[json.name]) {
132
133
  return NODE_MAPPERS[json.name](json, options, component, parentSlots);
133
134
  }
@@ -223,7 +223,7 @@ var componentToReact = function (reactOptions) {
223
223
  .replace(/;\n\nimport\s/g, ';\nimport ');
224
224
  }
225
225
  catch (err) {
226
- console.error('Format error for file:');
226
+ console.error('Format error for file:', str);
227
227
  throw err;
228
228
  }
229
229
  }
@@ -11,6 +11,7 @@ type BuilderToMitosisOptions = {
11
11
  };
12
12
  includeBuilderExtras?: boolean;
13
13
  preserveTextBlocks?: boolean;
14
+ includeSpecialBindings?: boolean;
14
15
  };
15
16
  export declare const builderElementToMitosisNode: (block: BuilderElement, options: BuilderToMitosisOptions, _internalOptions?: InternalOptions) => MitosisNode;
16
17
  /**
@@ -417,6 +417,7 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
417
417
  var _a;
418
418
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
419
419
  if (_internalOptions === void 0) { _internalOptions = {}; }
420
+ var _x = options.includeSpecialBindings, includeSpecialBindings = _x === void 0 ? true : _x;
420
421
  if (((_b = block.component) === null || _b === void 0 ? void 0 : _b.name) === 'Core:Fragment') {
421
422
  block.component.name = 'Fragment';
422
423
  }
@@ -501,9 +502,9 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
501
502
  }
502
503
  var useKey = key.replace(/^(component\.)?options\./, '');
503
504
  if (!useKey.includes('.')) {
504
- bindings[useKey] = {
505
+ bindings[useKey] = (0, bindings_1.createSingleBinding)({
505
506
  code: blockBindings[key].code || blockBindings[key],
506
- };
507
+ });
507
508
  }
508
509
  else if (useKey.includes('style') && useKey.includes('.')) {
509
510
  var styleProperty = useKey.split('.')[1];
@@ -538,19 +539,18 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
538
539
  }
539
540
  return true;
540
541
  })
541
- .map(function (item) { return (0, exports.builderElementToMitosisNode)(item, options); });
542
- children.push({
543
- '@type': '@builder.io/mitosis/node',
544
- name: 'Slot',
545
- meta: {},
546
- scope: {},
547
- bindings: {},
548
- properties: { name: key },
549
- children: childrenElements,
542
+ .map(function (item) {
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);
550
548
  });
549
+ var strVal = childrenElements.length === 1 ? childrenElements[0] : "<>".concat(childrenElements.join(''), "</>");
550
+ bindings[key] = (0, bindings_1.createSingleBinding)({ code: strVal });
551
551
  }
552
552
  else {
553
- bindings[key] = { code: json5_1.default.stringify(value) };
553
+ bindings[key] = (0, bindings_1.createSingleBinding)({ code: json5_1.default.stringify(value) });
554
554
  }
555
555
  }
556
556
  }
@@ -564,19 +564,19 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
564
564
  if (binding.startsWith('component.options') || binding.startsWith('options')) {
565
565
  var value = blockBindings[binding];
566
566
  var useKey = binding.replace(/^(component\.options\.|options\.)/, '');
567
- bindings[useKey] = { code: value };
567
+ bindings[useKey] = (0, bindings_1.createSingleBinding)({ code: value });
568
568
  }
569
569
  }
570
570
  var node = (0, create_mitosis_node_1.createMitosisNode)({
571
571
  name: ((_r = (_q = block.component) === null || _q === void 0 ? void 0 : _q.name) === null || _r === void 0 ? void 0 : _r.replace(/[^a-z0-9]/gi, '')) ||
572
572
  block.tagName ||
573
573
  (block.linkUrl ? 'a' : 'div'),
574
- properties: __assign(__assign(__assign({}, (block.component && { $tagName: block.tagName })), (block.class && { class: block.class })), properties),
574
+ properties: __assign(__assign(__assign({}, (block.component && includeSpecialBindings && { $tagName: block.tagName })), (block.class && { class: block.class })), properties),
575
575
  bindings: __assign(__assign(__assign(__assign({}, bindings), actionBindings), (styleString && {
576
- style: { code: styleString },
576
+ style: (0, bindings_1.createSingleBinding)({ code: styleString }),
577
577
  })), (css &&
578
578
  Object.keys(css).length && {
579
- css: { code: JSON.stringify(css) },
579
+ css: (0, bindings_1.createSingleBinding)({ code: JSON.stringify(css) }),
580
580
  })),
581
581
  });
582
582
  // Has single text node child
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.0.146",
25
+ "version": "0.0.147",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {