@builder.io/mitosis 0.7.0 → 0.7.2
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.
|
@@ -297,24 +297,25 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
297
297
|
str += `</ng-container>`;
|
|
298
298
|
}
|
|
299
299
|
else {
|
|
300
|
-
let element, classNames = [], attributes;
|
|
300
|
+
let element = null, classNames = [], attributes;
|
|
301
301
|
const isComponent = childComponents.find((impName) => impName === json.name);
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
catch (_r) {
|
|
309
|
-
element = (0, lodash_1.kebabCase)(json.name);
|
|
310
|
-
}
|
|
302
|
+
const tagName = json.properties.$tagName;
|
|
303
|
+
const selector = json.meta.selector || (blockOptions === null || blockOptions === void 0 ? void 0 : blockOptions.selector);
|
|
304
|
+
if (selector) {
|
|
305
|
+
try {
|
|
306
|
+
({ element, classNames, attributes } = (0, parse_selector_1.parse)(`${selector}`));
|
|
311
307
|
}
|
|
312
|
-
|
|
313
|
-
element = (0, lodash_1.kebabCase)(json.name);
|
|
308
|
+
catch (_r) {
|
|
309
|
+
element = tagName !== null && tagName !== void 0 ? tagName : (0, lodash_1.kebabCase)(json.name);
|
|
314
310
|
}
|
|
315
311
|
}
|
|
316
|
-
|
|
317
|
-
|
|
312
|
+
if (!element) {
|
|
313
|
+
if (isComponent) {
|
|
314
|
+
element = tagName !== null && tagName !== void 0 ? tagName : (0, lodash_1.kebabCase)(json.name);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
element = tagName !== null && tagName !== void 0 ? tagName : json.name;
|
|
318
|
+
}
|
|
318
319
|
}
|
|
319
320
|
str += `<${element} `;
|
|
320
321
|
// TODO: merge with existing classes/bindings
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
@@ -19,6 +42,8 @@ const render_imports_1 = require("../../helpers/render-imports");
|
|
|
19
42
|
const state_1 = require("../../helpers/state");
|
|
20
43
|
const plugins_1 = require("../../modules/plugins");
|
|
21
44
|
const mitosis_node_1 = require("../../types/mitosis-node");
|
|
45
|
+
const babel = __importStar(require("@babel/core"));
|
|
46
|
+
const plugin_syntax_typescript_1 = __importDefault(require("@babel/plugin-syntax-typescript"));
|
|
22
47
|
const json5_1 = __importDefault(require("json5"));
|
|
23
48
|
const standalone_1 = require("prettier/standalone");
|
|
24
49
|
const react_1 = require("../react");
|
|
@@ -87,11 +112,35 @@ const blockToMitosis = (json, toMitosisOptions = {}, component, insideJsx) => {
|
|
|
87
112
|
</For>`;
|
|
88
113
|
}
|
|
89
114
|
if (json.properties._text) {
|
|
115
|
+
let text = json.properties._text
|
|
116
|
+
// Convert HTML <br> to JSX-valid <br />
|
|
117
|
+
.replace(/<br\s*>/g, '<br />');
|
|
118
|
+
let isInvalidJsx = text.includes('{') || text.includes('}');
|
|
119
|
+
if (text.includes('<') || text.includes('>')) {
|
|
120
|
+
// test if this can parse as jsx
|
|
121
|
+
try {
|
|
122
|
+
babel.parse(`let _ = <>${text}</>;`, {
|
|
123
|
+
plugins: [[plugin_syntax_typescript_1.default, { isTSX: true }]],
|
|
124
|
+
});
|
|
125
|
+
isInvalidJsx = false;
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
isInvalidJsx = true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (isInvalidJsx) {
|
|
132
|
+
text = text
|
|
133
|
+
.replace(/>/g, '>')
|
|
134
|
+
.replace(/</g, '<')
|
|
135
|
+
.replace(/{/g, '{')
|
|
136
|
+
.replace(/}/g, '}')
|
|
137
|
+
.replace(/&/g, '&');
|
|
138
|
+
}
|
|
90
139
|
if (insideJsx) {
|
|
91
|
-
return `${
|
|
140
|
+
return `${text}`;
|
|
92
141
|
}
|
|
93
142
|
else {
|
|
94
|
-
return `<>${
|
|
143
|
+
return `<>${text}</>`;
|
|
95
144
|
}
|
|
96
145
|
}
|
|
97
146
|
if ((_d = json.bindings._text) === null || _d === void 0 ? void 0 : _d.code) {
|
|
@@ -756,9 +756,6 @@ const builderElementToMitosisNode = (block, options, _internalOptions = {}) => {
|
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
|
-
if (block.component && block.tagName && block.tagName !== 'div') {
|
|
760
|
-
properties.builderTag = block.tagName;
|
|
761
|
-
}
|
|
762
759
|
const css = getCssFromBlock(block);
|
|
763
760
|
let styleString = getStyleStringFromBlock(block, options);
|
|
764
761
|
const actionBindings = getActionBindingsFromBlock(block, options);
|