@builder.io/mitosis 0.0.45-4 → 0.0.47
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.
- package/dist/src/__tests__/builder.test.js +73 -65
- package/dist/src/__tests__/context.test.js +13 -10
- package/dist/src/__tests__/data/basic.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/button-with-metadata.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/columns.raw.jsx +2 -2
- package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +3 -3
- package/dist/src/__tests__/data/blocks/embed.raw.jsx +3 -3
- package/dist/src/__tests__/data/blocks/form.raw.jsx +5 -5
- package/dist/src/__tests__/data/blocks/image.raw.jsx +4 -4
- package/dist/src/__tests__/data/blocks/stamped-io.raw.jsx +4 -4
- package/dist/src/__tests__/data/context/component-with-context.lite.jsx +2 -2
- package/dist/src/__tests__/data/context/simple.context.lite.js +1 -1
- package/dist/src/__tests__/html.test.js +2 -2
- package/dist/src/__tests__/liquid.test.js +34 -34
- package/dist/src/__tests__/parse-jsx.test.js +1 -1
- package/dist/src/__tests__/qwik.test.js +197 -50
- package/dist/src/__tests__/react-native.test.js +35 -35
- package/dist/src/__tests__/react.test.js +35 -35
- package/dist/src/__tests__/solid.test.js +32 -32
- package/dist/src/__tests__/vue.test.js +35 -34
- package/dist/src/generators/angular.d.ts +4 -7
- package/dist/src/generators/angular.js +77 -81
- package/dist/src/generators/builder.d.ts +4 -4
- package/dist/src/generators/builder.js +57 -57
- package/dist/src/generators/context/react.d.ts +3 -1
- package/dist/src/generators/context/react.js +20 -17
- package/dist/src/generators/html.d.ts +5 -9
- package/dist/src/generators/html.js +205 -199
- package/dist/src/generators/liquid.d.ts +5 -9
- package/dist/src/generators/liquid.js +62 -59
- package/dist/src/generators/mitosis.d.ts +6 -7
- package/dist/src/generators/mitosis.js +61 -63
- package/dist/src/generators/qwik/component.d.ts +20 -0
- package/dist/src/generators/qwik/component.js +117 -0
- package/dist/src/generators/qwik/directives.d.ts +2 -0
- package/dist/src/generators/qwik/directives.js +27 -0
- package/dist/src/generators/qwik/handlers.d.ts +4 -0
- package/dist/src/generators/qwik/handlers.js +80 -0
- package/dist/src/generators/qwik/index.d.ts +2 -0
- package/dist/src/generators/qwik/index.js +9 -0
- package/dist/src/generators/qwik/jsx.d.ts +4 -0
- package/dist/src/generators/qwik/jsx.js +124 -0
- package/dist/src/generators/qwik/src-generator.d.ts +79 -0
- package/dist/src/generators/qwik/src-generator.js +427 -0
- package/dist/src/generators/qwik/styles.d.ts +7 -0
- package/dist/src/generators/qwik/styles.js +94 -0
- package/dist/src/generators/react-native.d.ts +4 -7
- package/dist/src/generators/react-native.js +25 -22
- package/dist/src/generators/react.d.ts +4 -8
- package/dist/src/generators/react.js +118 -114
- package/dist/src/generators/solid.d.ts +4 -8
- package/dist/src/generators/solid.js +55 -54
- package/dist/src/generators/svelte.d.ts +4 -7
- package/dist/src/generators/svelte.js +120 -123
- package/dist/src/generators/swift-ui.d.ts +2 -2
- package/dist/src/generators/swift-ui.js +62 -62
- package/dist/src/generators/template.d.ts +4 -8
- package/dist/src/generators/template.js +48 -45
- package/dist/src/generators/vue.d.ts +9 -9
- package/dist/src/generators/vue.js +170 -169
- package/dist/src/helpers/babel-transform.js +9 -9
- package/dist/src/helpers/camel-case.d.ts +8 -0
- package/dist/src/helpers/camel-case.js +18 -0
- package/dist/src/helpers/collect-styles.js +39 -37
- package/dist/src/helpers/dash-case.js +1 -1
- package/dist/src/helpers/generic-format.test.js +2 -2
- package/dist/src/helpers/get-components-used.js +2 -2
- package/dist/src/helpers/get-components.js +3 -3
- package/dist/src/helpers/get-props.js +1 -1
- package/dist/src/helpers/get-refs.js +2 -2
- package/dist/src/helpers/get-state-object-string.js +52 -39
- package/dist/src/helpers/get-state-used.js +1 -1
- package/dist/src/helpers/get-styles.js +1 -1
- package/dist/src/helpers/getters-to-functions.js +4 -4
- package/dist/src/helpers/handle-missing-state.js +1 -1
- package/dist/src/helpers/has-component.js +2 -2
- package/dist/src/helpers/has-props.js +1 -1
- package/dist/src/helpers/is-children.js +1 -1
- package/dist/src/helpers/json.d.ts +1 -0
- package/dist/src/helpers/json.js +17 -0
- package/dist/src/helpers/map-refs.js +7 -6
- package/dist/src/helpers/map-to-attributes.js +4 -4
- package/dist/src/helpers/map-to-css.js +2 -2
- package/dist/src/helpers/parse-node.js +2 -2
- package/dist/src/helpers/parse-reactive-script.js +4 -4
- package/dist/src/helpers/patterns.d.ts +2 -0
- package/dist/src/helpers/patterns.js +5 -0
- package/dist/src/helpers/process-http-requests.js +1 -1
- package/dist/src/helpers/process-tag-references.js +4 -4
- package/dist/src/helpers/remove-surrounding-block.test.js +1 -1
- package/dist/src/helpers/render-imports.js +7 -7
- package/dist/src/helpers/replace-idenifiers.js +1 -1
- package/dist/src/helpers/strip-meta-properties.js +2 -2
- package/dist/src/helpers/trace-reference-to-module-path.js +1 -1
- package/dist/src/helpers/traverse-nodes.js +2 -2
- package/dist/src/helpers/try-prettier-format.js +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +3 -1
- package/dist/src/modules/plugins.d.ts +2 -10
- package/dist/src/parsers/angular.js +13 -13
- package/dist/src/parsers/builder.d.ts +1 -1
- package/dist/src/parsers/builder.js +56 -59
- package/dist/src/parsers/context.js +2 -2
- package/dist/src/parsers/jsx.js +59 -87
- package/dist/src/parsers/liquid.js +193 -195
- package/dist/src/plugins/compile-away-builder-components.d.ts +1 -1
- package/dist/src/plugins/compile-away-builder-components.js +337 -92
- package/dist/src/plugins/compile-away-components.js +3 -3
- package/dist/src/plugins/map-styles.js +3 -3
- package/dist/src/targets.d.ts +24 -0
- package/dist/src/targets.js +30 -0
- package/dist/src/types/config.d.ts +31 -0
- package/dist/src/types/{jsx-lite-component.js → config.js} +0 -0
- package/dist/src/types/generators.d.ts +0 -0
- package/dist/src/types/generators.js +1 -0
- package/dist/src/types/plugins.d.ts +11 -0
- package/dist/src/types/{jsx-lite-context.js → plugins.js} +0 -0
- package/dist/test/qwik/Accordion/high.jsx +1 -0
- package/dist/test/qwik/Accordion/low.jsx +92 -0
- package/dist/test/qwik/Accordion/med.jsx +9 -0
- package/dist/test/qwik/For/high.jsx +1 -0
- package/dist/test/qwik/For/low.jsx +55 -0
- package/dist/test/qwik/For/med.jsx +9 -0
- package/dist/test/qwik/Image/high.js +1 -0
- package/dist/test/qwik/Image/low.js +68 -0
- package/dist/test/qwik/Image/med.js +9 -0
- package/dist/test/qwik/Image.slow/high.js +1 -0
- package/dist/test/qwik/Image.slow/low.js +68 -0
- package/dist/test/qwik/Image.slow/med.js +9 -0
- package/dist/test/qwik/button/high.js +8 -0
- package/dist/test/qwik/button/low.js +34 -0
- package/dist/test/qwik/button/med.js +9 -0
- package/dist/test/qwik/hello_world/stylesheet/high.jsx +1 -0
- package/dist/test/qwik/hello_world/stylesheet/low.jsx +24 -0
- package/dist/test/qwik/hello_world/stylesheet/med.jsx +9 -0
- package/dist/test/qwik/page-with-symbol/high.js +1 -0
- package/dist/test/qwik/page-with-symbol/low.js +49 -0
- package/dist/test/qwik/page-with-symbol/med.js +9 -0
- package/dist/test/qwik/svg/high.js +1 -0
- package/dist/test/qwik/svg/low.js +30 -0
- package/dist/test/qwik/svg/med.js +9 -0
- package/dist/test/qwik/todo/Todo.cjs/high.cjs +31 -0
- package/dist/test/qwik/todo/Todo.cjs/low.cjs +1 -0
- package/dist/test/qwik/todo/Todo.cjs/med.cjs +59 -0
- package/dist/test/qwik/todo/Todo.js/high.js +5 -0
- package/dist/test/qwik/todo/Todo.js/low.js +0 -0
- package/dist/test/qwik/todo/Todo.js/med.js +1 -0
- package/dist/test/qwik/todo/Todo.tsx/high.tsx +30 -0
- package/dist/test/qwik/todo/Todo.tsx/low.tsx +1 -0
- package/dist/test/qwik/todo/Todo.tsx/med.tsx +34 -0
- package/dist/test/qwik/todos/Todo.tsx/high.tsx +12 -0
- package/dist/test/qwik/todos/Todo.tsx/low.tsx +25 -0
- package/dist/test/qwik/todos/Todo.tsx/med.tsx +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/CHANGELOG.md +0 -4
- package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +0 -11
- package/dist/src/__tests__/data/blocks/tabs.raw.jsx +0 -24
- package/dist/src/__tests__/qoot.test.d.ts +0 -1
- package/dist/src/__tests__/qoot.test.js +0 -115
- package/dist/src/generators/jsx-lite.d.ts +0 -10
- package/dist/src/generators/jsx-lite.js +0 -176
- package/dist/src/generators/qoot.d.ts +0 -21
- package/dist/src/generators/qoot.js +0 -442
- package/dist/src/generators/qwik.d.ts +0 -21
- package/dist/src/generators/qwik.js +0 -458
- package/dist/src/helpers/create-jsx-lite-component.d.ts +0 -2
- package/dist/src/helpers/create-jsx-lite-component.js +0 -16
- package/dist/src/helpers/create-jsx-lite-context.d.ts +0 -4
- package/dist/src/helpers/create-jsx-lite-context.js +0 -18
- package/dist/src/helpers/create-jsx-lite-node.d.ts +0 -2
- package/dist/src/helpers/create-jsx-lite-node.js +0 -16
- package/dist/src/helpers/is-jsx-lite-node.d.ts +0 -2
- package/dist/src/helpers/is-jsx-lite-node.js +0 -7
- package/dist/src/types/jsx-lite-component.d.ts +0 -63
- package/dist/src/types/jsx-lite-context.d.ts +0 -6
- package/dist/src/types/jsx-lite-node.d.ts +0 -13
- package/dist/src/types/jsx-lite-node.js +0 -2
- package/dist/src/types/jsx-lite-styles.d.ts +0 -1
- package/dist/src/types/jsx-lite-styles.js +0 -2
- package/dist/test/qoot/Todo/bundle.js +0 -88
- package/dist/test/qoot/Todo/component.ts +0 -17
- package/dist/test/qoot/Todo/onButtonClick.ts +0 -13
- package/dist/test/qoot/Todo/onInput2Blur.ts +0 -11
- package/dist/test/qoot/Todo/onInput2KeyUp.ts +0 -10
- package/dist/test/qoot/Todo/onInputClick.ts +0 -10
- package/dist/test/qoot/Todo/onLabelDblClick.ts +0 -11
- package/dist/test/qoot/Todo/public.ts +0 -4
- package/dist/test/qoot/Todo/template.tsx +0 -46
- package/dist/test/qoot/Todos/component.ts +0 -9
- package/dist/test/qoot/Todos/onInputClick.ts +0 -14
- package/dist/test/qoot/Todos/public.ts +0 -3
- package/dist/test/qoot/Todos/template.tsx +0 -30
- package/dist/test/qwik/Todo/bundle.js +0 -46
- package/dist/test/qwik/Todo/component.ts +0 -17
- package/dist/test/qwik/Todo/onButtonClick.ts +0 -10
- package/dist/test/qwik/Todo/onInput2Blur.ts +0 -14
- package/dist/test/qwik/Todo/onInput2KeyUp.ts +0 -10
- package/dist/test/qwik/Todo/onInputClick.ts +0 -13
- package/dist/test/qwik/Todo/onLabelDblClick.ts +0 -11
- package/dist/test/qwik/Todo/public.ts +0 -3
- package/dist/test/qwik/Todo/template.tsx +0 -46
- package/dist/test/qwik/Todo.ts +0 -4
- package/dist/test/qwik/Todo_component.ts +0 -14
- package/dist/test/qwik/Todo_onButtonClick.ts +0 -10
- package/dist/test/qwik/Todo_onInput2Blur.ts +0 -11
- package/dist/test/qwik/Todo_onInput2KeyUp.ts +0 -10
- package/dist/test/qwik/Todo_onInputClick.ts +0 -10
- package/dist/test/qwik/Todo_onLabelDblClick.ts +0 -11
- package/dist/test/qwik/Todo_template.tsx +0 -46
- package/dist/test/qwik/Todos/component.ts +0 -9
- package/dist/test/qwik/Todos/onInputClick.ts +0 -14
- package/dist/test/qwik/Todos/public.ts +0 -3
- package/dist/test/qwik/Todos/template.tsx +0 -30
- package/dist/test/qwik/Todos.ts +0 -3
- package/dist/test/qwik/Todos_component.ts +0 -9
- package/dist/test/qwik/Todos_onInputClick.ts +0 -14
- package/dist/test/qwik/Todos_template.tsx +0 -30
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.renderStyles = exports.collectStyles = void 0;
|
|
27
|
+
var json5_1 = __importDefault(require("json5"));
|
|
28
|
+
var dash_case_1 = require("../../helpers/dash-case");
|
|
29
|
+
var src_generator_1 = require("./src-generator");
|
|
30
|
+
function collectStyles(children, styleMap) {
|
|
31
|
+
var nodes = __spreadArray([], children, true);
|
|
32
|
+
while (nodes.length) {
|
|
33
|
+
var child = nodes.shift();
|
|
34
|
+
nodes.push.apply(nodes, child.children);
|
|
35
|
+
var css = child.bindings.css;
|
|
36
|
+
if (css && typeof css == 'string') {
|
|
37
|
+
var value = __assign({ CLASS_NAME: 'c' + hashCode(css) }, json5_1.default.parse(css));
|
|
38
|
+
styleMap.set(css, value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return styleMap;
|
|
42
|
+
}
|
|
43
|
+
exports.collectStyles = collectStyles;
|
|
44
|
+
function hashCode(text) {
|
|
45
|
+
var hash = 0, i, chr;
|
|
46
|
+
if (text.length === 0)
|
|
47
|
+
return hash;
|
|
48
|
+
for (i = 0; i < text.length; i++) {
|
|
49
|
+
chr = text.charCodeAt(i);
|
|
50
|
+
hash = (hash << 5) - hash + chr;
|
|
51
|
+
hash |= 0; // Convert to 32bit integer
|
|
52
|
+
}
|
|
53
|
+
return Number(Math.abs(hash)).toString(36);
|
|
54
|
+
}
|
|
55
|
+
function renderStyles(styles) {
|
|
56
|
+
return function () {
|
|
57
|
+
var _this = this;
|
|
58
|
+
this.emit('`', src_generator_1.NL, src_generator_1.INDENT);
|
|
59
|
+
var mediaStyles = [];
|
|
60
|
+
styles.forEach(function (styles) {
|
|
61
|
+
_this.emit('.', styles.CLASS_NAME, /*'.🏷️�', WS,*/ '{', src_generator_1.NL, src_generator_1.INDENT);
|
|
62
|
+
for (var key in styles) {
|
|
63
|
+
if (key !== 'CLASS_NAME' &&
|
|
64
|
+
Object.prototype.hasOwnProperty.call(styles, key)) {
|
|
65
|
+
var value = styles[key];
|
|
66
|
+
if (value && typeof value == 'object') {
|
|
67
|
+
mediaStyles.push(styles.CLASS_NAME, key, value);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
_this.emit((0, dash_case_1.dashCase)(key), ':', src_generator_1.WS, value, ';', src_generator_1.NL);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
_this.emit(src_generator_1.UNINDENT, '}', src_generator_1.NL);
|
|
75
|
+
});
|
|
76
|
+
while (mediaStyles.length) {
|
|
77
|
+
var className = mediaStyles.shift();
|
|
78
|
+
var mediaKey = mediaStyles.shift();
|
|
79
|
+
var mediaObj = mediaStyles.shift();
|
|
80
|
+
this.emit(mediaKey, src_generator_1.WS, '{', src_generator_1.INDENT, src_generator_1.NL);
|
|
81
|
+
this.emit('.', className, /*'.🏷️�', WS,*/ '{', src_generator_1.NL, src_generator_1.INDENT);
|
|
82
|
+
for (var key in mediaObj) {
|
|
83
|
+
if (Object.prototype.hasOwnProperty.call(mediaObj, key)) {
|
|
84
|
+
var value = mediaObj[key];
|
|
85
|
+
this.emit((0, dash_case_1.dashCase)(key), ':', src_generator_1.WS, value, ';', src_generator_1.NL);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
this.emit(src_generator_1.UNINDENT, '}', src_generator_1.NL);
|
|
89
|
+
this.emit(src_generator_1.UNINDENT, '}', src_generator_1.NL);
|
|
90
|
+
}
|
|
91
|
+
this.emit(src_generator_1.UNINDENT, '`');
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
exports.renderStyles = renderStyles;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { ClassStyleMap } from '../helpers/collect-styles';
|
|
2
|
-
import { Plugin } from '../modules/plugins';
|
|
3
2
|
import { MitosisComponent } from '../types/mitosis-component';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { BaseTranspilerOptions, Transpiler } from '../types/config';
|
|
4
|
+
export interface ToReactNativeOptions extends BaseTranspilerOptions {
|
|
6
5
|
stylesType?: 'emotion' | 'react-native';
|
|
7
6
|
stateType?: 'useState' | 'mobx' | 'valtio' | 'solid' | 'builder';
|
|
8
|
-
|
|
9
|
-
};
|
|
7
|
+
}
|
|
10
8
|
export declare const collectReactNativeStyles: (json: MitosisComponent) => ClassStyleMap;
|
|
11
|
-
export declare const componentToReactNative: (
|
|
12
|
-
export {};
|
|
9
|
+
export declare const componentToReactNative: (options?: ToReactNativeOptions) => Transpiler;
|
|
@@ -25,12 +25,12 @@ var stylePropertiesThatMustBeNumber = new Set(['lineHeight']);
|
|
|
25
25
|
var collectReactNativeStyles = function (json) {
|
|
26
26
|
var styleMap = {};
|
|
27
27
|
var componentIndexes = {};
|
|
28
|
-
traverse_1.default(json).forEach(function (item) {
|
|
29
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
28
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
29
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
30
30
|
if (typeof item.bindings.css === 'string') {
|
|
31
31
|
var value = json5_1.default.parse(item.bindings.css);
|
|
32
32
|
delete item.bindings.css;
|
|
33
|
-
if (!lodash_1.size(value)) {
|
|
33
|
+
if (!(0, lodash_1.size)(value)) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
// Style properties like `"20px"` need to be numbers like `20` for react native
|
|
@@ -44,15 +44,15 @@ var collectReactNativeStyles = function (json) {
|
|
|
44
44
|
}
|
|
45
45
|
if (stylePropertiesThatMustBeNumber.has(key) &&
|
|
46
46
|
typeof value[key] !== 'number') {
|
|
47
|
-
console.warn("Style key "
|
|
47
|
+
console.warn("Style key ".concat(key, " must be a number, but had value `").concat(value[key], "`"));
|
|
48
48
|
delete value[key];
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
var componentName = lodash_1.camelCase(item.name || 'view');
|
|
51
|
+
var componentName = (0, lodash_1.camelCase)(item.name || 'view');
|
|
52
52
|
var index = (componentIndexes[componentName] =
|
|
53
53
|
(componentIndexes[componentName] || 0) + 1);
|
|
54
|
-
var className = ""
|
|
55
|
-
item.bindings.style = "styles."
|
|
54
|
+
var className = "".concat(componentName).concat(index);
|
|
55
|
+
item.bindings.style = "styles.".concat(className);
|
|
56
56
|
styleMap[className] = value;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -60,22 +60,25 @@ var collectReactNativeStyles = function (json) {
|
|
|
60
60
|
return styleMap;
|
|
61
61
|
};
|
|
62
62
|
exports.collectReactNativeStyles = collectReactNativeStyles;
|
|
63
|
-
var componentToReactNative = function (
|
|
63
|
+
var componentToReactNative = function (options) {
|
|
64
64
|
if (options === void 0) { options = {}; }
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
node.
|
|
65
|
+
return function (_a) {
|
|
66
|
+
var component = _a.component, path = _a.path;
|
|
67
|
+
var json = (0, fast_clone_1.fastClone)(component);
|
|
68
|
+
(0, traverse_1.default)(json).forEach(function (node) {
|
|
69
|
+
var _a, _b, _c;
|
|
70
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(node)) {
|
|
71
|
+
// TODO: handle TextInput, Image, etc
|
|
72
|
+
if (node.name.toLowerCase() === node.name) {
|
|
73
|
+
node.name = 'View';
|
|
74
|
+
}
|
|
75
|
+
if (((_a = node.properties._text) === null || _a === void 0 ? void 0 : _a.trim().length) ||
|
|
76
|
+
((_c = (_b = node.bindings._text) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
77
|
+
node.name = 'Text';
|
|
78
|
+
}
|
|
76
79
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
});
|
|
81
|
+
return (0, react_1.componentToReact)(__assign(__assign({}, options), { stylesType: options.stylesType || 'react-native', type: 'native' }))({ component: json, path: path });
|
|
82
|
+
};
|
|
80
83
|
};
|
|
81
84
|
exports.componentToReactNative = componentToReactNative;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MitosisComponent } from '../types/mitosis-component';
|
|
1
|
+
import { BaseTranspilerOptions, Transpiler } from '../types/config';
|
|
3
2
|
import { MitosisNode } from '../types/mitosis-node';
|
|
4
|
-
|
|
5
|
-
prettier?: boolean;
|
|
3
|
+
export interface ToReactOptions extends BaseTranspilerOptions {
|
|
6
4
|
stylesType?: 'emotion' | 'styled-components' | 'styled-jsx' | 'react-native';
|
|
7
5
|
stateType?: 'useState' | 'mobx' | 'valtio' | 'solid' | 'builder';
|
|
8
6
|
format?: 'lite' | 'safe';
|
|
9
7
|
type?: 'dom' | 'native';
|
|
10
|
-
|
|
11
|
-
};
|
|
8
|
+
}
|
|
12
9
|
export declare const blockToReact: (json: MitosisNode, options: ToReactOptions) => string;
|
|
13
|
-
export declare const componentToReact: (
|
|
14
|
-
export {};
|
|
10
|
+
export declare const componentToReact: (reactOptions?: ToReactOptions) => Transpiler;
|