@builder.io/mitosis 0.2.2 → 0.2.4

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.
@@ -68,7 +68,7 @@ var NODE_MAPPERS = {
68
68
  return "<>{".concat(slotProp, " ").concat(hasChildren ? "|| (".concat(renderChildren(), ")") : '', "}</>");
69
69
  },
70
70
  Fragment: function (json, options, component) {
71
- var wrap = (0, helpers_1.wrapInFragment)(json);
71
+ var wrap = (0, helpers_1.wrapInFragment)(json) || (0, is_root_text_node_1.isRootTextNode)(json);
72
72
  return "".concat(wrap ? (0, helpers_1.getFragment)('open', options) : '').concat(json.children
73
73
  .map(function (item) { return (0, exports.blockToReact)(item, options, component); })
74
74
  .join('\n')).concat(wrap ? (0, helpers_1.getFragment)('close', options) : '');
@@ -126,6 +126,9 @@ var BINDING_MAPPERS = __assign({ ref: function (ref, value, options) {
126
126
  }, innerHTML: function (_key, value) {
127
127
  return ['dangerouslySetInnerHTML', "{__html: ".concat(value.replace(/\s+/g, ' '), "}")];
128
128
  } }, ATTTRIBUTE_MAPPERS);
129
+ var NATIVE_EVENT_MAPPER = {
130
+ onClick: 'onPress',
131
+ };
129
132
  var blockToReact = function (json, options, component, parentSlots) {
130
133
  var _a, _b, _c;
131
134
  if (parentSlots === void 0) { parentSlots = []; }
@@ -182,7 +185,8 @@ var blockToReact = function (json, options, component, parentSlots) {
182
185
  }
183
186
  else if (key.startsWith('on')) {
184
187
  var _e = json.bindings[key].arguments, cusArgs = _e === void 0 ? ['event'] : _e;
185
- str += " ".concat(key, "={(").concat(cusArgs.join(','), ") => ").concat((0, state_1.updateStateSettersInCode)(useBindingValue, options), " } ");
188
+ var eventName = options.type === 'native' ? NATIVE_EVENT_MAPPER[key] || key : key;
189
+ str += " ".concat(eventName, "={(").concat(cusArgs.join(','), ") => ").concat((0, state_1.updateStateSettersInCode)(useBindingValue, options), " } ");
186
190
  }
187
191
  else if (key.startsWith('slot')) {
188
192
  // <Component slotProjected={<AnotherComponent />} />
@@ -241,7 +241,7 @@ var getDefaultImport = function (json, options) {
241
241
  return "\n /** @jsx h */\n import { h, Fragment } from 'preact';\n ";
242
242
  }
243
243
  if (type === 'native') {
244
- return "\n import * as React from 'react';\n import { FlatList, ScrollView, View, StyleSheet, Image, Text } from 'react-native';\n ";
244
+ return "\n import * as React from 'react';\n import { FlatList, ScrollView, View, StyleSheet, Image, Text, Pressable } from 'react-native';\n ";
245
245
  }
246
246
  if (type === 'taro') {
247
247
  return "\n import * as React from 'react';\n ";
@@ -117,6 +117,9 @@ var PROCESS_REACT_NATIVE_PLUGIN = function () { return ({
117
117
  }
118
118
  else if (node.name.toLowerCase() === node.name && html_tags_1.VALID_HTML_TAGS.includes(node.name)) {
119
119
  node.name = 'View';
120
+ if (node.bindings.onClick) {
121
+ node.name = 'Pressable';
122
+ }
120
123
  }
121
124
  else if (((_a = node.properties._text) === null || _a === void 0 ? void 0 : _a.trim().length) ||
122
125
  ((_d = (_c = (_b = node.bindings._text) === null || _b === void 0 ? void 0 : _b.code) === null || _c === void 0 ? void 0 : _c.trim()) === null || _d === void 0 ? void 0 : _d.length)) {
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.2",
25
+ "version": "0.2.4",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {