@builder.io/mitosis 0.2.8 → 0.2.10

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.
@@ -175,7 +175,10 @@ var processEventBinding = function (key, code, nodeName, customArg) {
175
175
  var regexp = new RegExp('(^|\\n|\\r| |;|\\(|\\[|!)' + eventName + '(\\?\\.|\\.|\\(| |;|\\)|$)', 'g');
176
176
  var replacer = '$1$event$2';
177
177
  var finalValue = (0, remove_surrounding_block_1.removeSurroundingBlock)(code.replace(regexp, replacer));
178
- return " (".concat(event, ")=\"").concat(finalValue, "\" ");
178
+ return {
179
+ event: event,
180
+ value: finalValue,
181
+ };
179
182
  };
180
183
  var stringifyBinding = function (node, options, blockOptions) {
181
184
  return function (_a) {
@@ -193,7 +196,8 @@ var stringifyBinding = function (node, options, blockOptions) {
193
196
  var _b = binding, code = _b.code, _c = _b.arguments, cusArgs = _c === void 0 ? ['event'] : _c;
194
197
  // TODO: proper babel transform to replace. Util for this
195
198
  if (keyToUse.startsWith('on')) {
196
- return processEventBinding(keyToUse, code, node.name, cusArgs[0]);
199
+ var _d = processEventBinding(keyToUse, code, node.name, cusArgs[0]), event_1 = _d.event, value = _d.value;
200
+ return " (".concat(event_1, ")=\"").concat(value, "\"");
197
201
  }
198
202
  else if (keyToUse === 'class') {
199
203
  return " [class]=\"".concat(code, "\" ");
@@ -214,7 +218,16 @@ var stringifyBinding = function (node, options, blockOptions) {
214
218
  };
215
219
  var handleNgOutletBindings = function (node) {
216
220
  var allProps = '';
217
- var events = '';
221
+ for (var key in node.properties) {
222
+ if (key.startsWith('$')) {
223
+ continue;
224
+ }
225
+ if (key === 'key') {
226
+ continue;
227
+ }
228
+ var value = node.properties[key];
229
+ allProps += "".concat(key, ": '").concat(value, "', ");
230
+ }
218
231
  for (var key in node.bindings) {
219
232
  if (key.startsWith('"')) {
220
233
  continue;
@@ -228,10 +241,11 @@ var handleNgOutletBindings = function (node) {
228
241
  }
229
242
  else if (key.includes('.')) {
230
243
  // TODO: handle arbitrary spread props
231
- allProps += "".concat(key.split('.')[1], ": ").concat(code, ",");
244
+ allProps += "".concat(key.split('.')[1], ": ").concat(code, ", ");
232
245
  }
233
246
  else if (key.startsWith('on')) {
234
- events += processEventBinding(key, code, node.name, cusArgs[0]);
247
+ var _c = processEventBinding(key, code, node.name, cusArgs[0]), event_2 = _c.event, value = _c.value;
248
+ allProps += "on".concat(event_2.charAt(0).toUpperCase() + event_2.slice(1), ": ").concat(value.replace(/\(.*?\)/g, ''), ", ");
235
249
  }
236
250
  else {
237
251
  var codeToUse = processCodeBlockInTemplate(code);
@@ -245,7 +259,7 @@ var handleNgOutletBindings = function (node) {
245
259
  if (allProps.startsWith(', ')) {
246
260
  allProps = allProps.slice(2);
247
261
  }
248
- return [allProps, events];
262
+ return allProps;
249
263
  };
250
264
  var blockToAngular = function (json, options, blockOptions) {
251
265
  var _a, _b, _c, _d;
@@ -302,8 +316,8 @@ var blockToAngular = function (json, options, blockOptions) {
302
316
  var elSelector = childComponents.find(function (impName) { return impName === json.name; })
303
317
  ? (0, lodash_1.kebabCase)(json.name)
304
318
  : json.name;
305
- var _e = handleNgOutletBindings(json), allProps = _e[0], events = _e[1];
306
- str += "<ng-container ".concat(events, " *ngComponentOutlet=\"\n ").concat(elSelector.replace('state.', '').replace('props.', ''), ";\n inputs: { ").concat(allProps, " };\n content: myContent;\n \"> ");
319
+ var allProps = handleNgOutletBindings(json);
320
+ str += "<ng-container *ngComponentOutlet=\"\n ".concat(elSelector.replace('state.', '').replace('props.', ''), ";\n inputs: { ").concat(allProps, " };\n content: myContent;\n \"> ");
307
321
  str += "</ng-container>";
308
322
  }
309
323
  else {
@@ -1,4 +1,5 @@
1
1
  import type { ParseMitosisOptions } from '../parsers/jsx/types';
2
+ import { targets } from '../targets';
2
3
  import type { MitosisComponent } from './mitosis-component';
3
4
  import { BaseTranspilerOptions } from './transpiler';
4
5
  export type Format = 'esm' | 'cjs';
@@ -6,14 +7,18 @@ export type Language = 'js' | 'ts';
6
7
  interface TranspilerOptions {
7
8
  format?: Format;
8
9
  }
9
- type Targets = typeof import('../targets').targets;
10
+ type Targets = typeof targets;
10
11
  export type Target = keyof Targets;
11
12
  export type GeneratorOptions = {
12
13
  [K in Target]: NonNullable<Parameters<Targets[K]>[0]> & {
13
14
  transpiler?: TranspilerOptions;
14
15
  };
15
16
  };
17
+ export type generatorsOption = {
18
+ [K in Target]: NonNullable<Targets[K]>;
19
+ };
16
20
  export type MitosisConfig = {
21
+ generators?: generatorsOption;
17
22
  commonOptions?: Omit<BaseTranspilerOptions, 'experimental'>;
18
23
  /**
19
24
  * List of targets to compile to.
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.2.8",
25
+ "version": "0.2.10",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {