@builder.io/mitosis 0.5.17 → 0.5.18
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.
|
@@ -57,10 +57,10 @@ const NODE_MAPPERS = {
|
|
|
57
57
|
return `<>{${slotProp} ${hasChildren ? `|| (${renderChildren()})` : ''}}</>`;
|
|
58
58
|
},
|
|
59
59
|
Fragment(json, options, component) {
|
|
60
|
-
const wrap = (0, helpers_1.wrapInFragment)(json) || (0, is_root_text_node_1.isRootTextNode)(json);
|
|
61
|
-
return `${wrap ? (0, helpers_1.getFragment)('open', options) : ''}${json.children
|
|
60
|
+
const wrap = (0, helpers_1.isFragmentWithKey)(json) || (0, helpers_1.wrapInFragment)(json) || (0, is_root_text_node_1.isRootTextNode)(json);
|
|
61
|
+
return `${wrap ? (0, helpers_1.getFragment)('open', options, json) : ''}${json.children
|
|
62
62
|
.map((item) => (0, exports.blockToReact)(item, options, component, wrap))
|
|
63
|
-
.join('\n')}${wrap ? (0, helpers_1.getFragment)('close', options) : ''}`;
|
|
63
|
+
.join('\n')}${wrap ? (0, helpers_1.getFragment)('close', options, json) : ''}`;
|
|
64
64
|
},
|
|
65
65
|
For(_json, options, component, insideJsx) {
|
|
66
66
|
var _a;
|
|
@@ -4,6 +4,7 @@ import { ToReactOptions } from './types';
|
|
|
4
4
|
export declare const processBinding: (str: string, options: ToReactOptions) => string;
|
|
5
5
|
export declare const openFrag: (options: ToReactOptions) => string;
|
|
6
6
|
export declare const closeFrag: (options: ToReactOptions) => string;
|
|
7
|
-
export declare
|
|
7
|
+
export declare const isFragmentWithKey: (node?: MitosisNode) => boolean;
|
|
8
|
+
export declare function getFragment(type: 'open' | 'close', options: ToReactOptions, node?: MitosisNode): string;
|
|
8
9
|
export declare const wrapInFragment: (json: MitosisComponent | MitosisNode) => boolean;
|
|
9
10
|
export declare function processTagReferences(json: MitosisComponent, options: ToReactOptions): void;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.processTagReferences = exports.wrapInFragment = exports.getFragment = exports.closeFrag = exports.openFrag = exports.processBinding = void 0;
|
|
6
|
+
exports.processTagReferences = exports.wrapInFragment = exports.getFragment = exports.isFragmentWithKey = exports.closeFrag = exports.openFrag = exports.processBinding = void 0;
|
|
7
7
|
const is_mitosis_node_1 = require("../../helpers/is-mitosis-node");
|
|
8
8
|
const strip_state_and_props_refs_1 = require("../../helpers/strip-state-and-props-refs");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
@@ -23,9 +23,21 @@ const openFrag = (options) => getFragment('open', options);
|
|
|
23
23
|
exports.openFrag = openFrag;
|
|
24
24
|
const closeFrag = (options) => getFragment('close', options);
|
|
25
25
|
exports.closeFrag = closeFrag;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const isFragmentWithKey = (node) => (node === null || node === void 0 ? void 0 : node.name) === 'Fragment' && !!(node === null || node === void 0 ? void 0 : node.bindings['key']);
|
|
27
|
+
exports.isFragmentWithKey = isFragmentWithKey;
|
|
28
|
+
function getFragment(type, options, node) {
|
|
29
|
+
var _a;
|
|
30
|
+
let tag = '';
|
|
31
|
+
if (node && node.bindings && (0, exports.isFragmentWithKey)(node)) {
|
|
32
|
+
tag = options.preact ? 'Fragment' : 'React.Fragment';
|
|
33
|
+
if (type === 'open') {
|
|
34
|
+
tag += ` key={${(_a = node.bindings['key']) === null || _a === void 0 ? void 0 : _a.code}}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (options.preact) {
|
|
38
|
+
tag = 'Fragment';
|
|
39
|
+
}
|
|
40
|
+
return type === 'open' ? `<${tag}>` : `</${tag}>`;
|
|
29
41
|
}
|
|
30
42
|
exports.getFragment = getFragment;
|
|
31
43
|
const wrapInFragment = (json) => json.children.length !== 1;
|
|
@@ -50,7 +50,8 @@ const blockToSolid = (json, component, options, insideJsx) => {
|
|
|
50
50
|
</For>`;
|
|
51
51
|
}
|
|
52
52
|
let str = '';
|
|
53
|
-
|
|
53
|
+
const isFragmentWithoutKey = json.name === 'Fragment' && !json.bindings.key;
|
|
54
|
+
if (isFragmentWithoutKey) {
|
|
54
55
|
str += '<';
|
|
55
56
|
}
|
|
56
57
|
else {
|
|
@@ -121,7 +122,7 @@ const blockToSolid = (json, component, options, insideJsx) => {
|
|
|
121
122
|
.map((item) => (0, exports.blockToSolid)(item, component, options, true))
|
|
122
123
|
.join('\n');
|
|
123
124
|
}
|
|
124
|
-
if (
|
|
125
|
+
if (isFragmentWithoutKey) {
|
|
125
126
|
str += '</>';
|
|
126
127
|
}
|
|
127
128
|
else {
|
|
@@ -198,7 +198,8 @@ const processStateObjectSlice = (item) => {
|
|
|
198
198
|
type: 'function',
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
const
|
|
201
|
+
const method = (0, types_1.objectMethod)(item.kind, item.key, item.params, item.body, false, false, item.async);
|
|
202
|
+
const n = getCleanedStateCode((0, helpers_1.parseCode)({ ...method, returnType: null }));
|
|
202
203
|
const isGetter = item.kind === 'get';
|
|
203
204
|
return {
|
|
204
205
|
code: n,
|