@builder.io/mitosis 0.2.3 → 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.
|
@@ -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
|
-
|
|
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)) {
|