@builder.io/mitosis 0.7.1 → 0.7.3
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/generators/angular/blocks.js +15 -14
- package/dist/src/generators/stencil/component.js +1 -11
- package/dist/src/generators/stencil/helpers/index.js +17 -9
- package/dist/src/generators/stencil/plugins/get-code-processor-plugins.d.ts +1 -1
- package/dist/src/generators/stencil/plugins/get-code-processor-plugins.js +2 -2
- package/dist/src/generators/svelte/blocks.js +11 -0
- package/dist/src/parsers/builder/builder.js +0 -3
- package/package.json +1 -1
|
@@ -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
|
|
@@ -7,7 +7,6 @@ const helpers_1 = require("../../generators/stencil/helpers");
|
|
|
7
7
|
const get_code_processor_plugins_1 = require("../../generators/stencil/plugins/get-code-processor-plugins");
|
|
8
8
|
const dash_case_1 = require("../../helpers/dash-case");
|
|
9
9
|
const dedent_1 = require("../../helpers/dedent");
|
|
10
|
-
const event_handlers_1 = require("../../helpers/event-handlers");
|
|
11
10
|
const fast_clone_1 = require("../../helpers/fast-clone");
|
|
12
11
|
const get_child_components_1 = require("../../helpers/get-child-components");
|
|
13
12
|
const get_props_1 = require("../../helpers/get-props");
|
|
@@ -41,16 +40,7 @@ const componentToStencil = (_options = {
|
|
|
41
40
|
const defaultProps = json.defaultProps;
|
|
42
41
|
const childComponents = (0, get_child_components_1.getChildComponents)(json);
|
|
43
42
|
const processBindingOptions = { events };
|
|
44
|
-
props = props
|
|
45
|
-
.map((prop) => {
|
|
46
|
-
// Stencil adds "on" to every `@Event` so we need to remove "on" from event props
|
|
47
|
-
// https://stenciljs.com/docs/events#using-events-in-jsx
|
|
48
|
-
if ((0, helpers_1.isEvent)(prop)) {
|
|
49
|
-
return (0, event_handlers_1.getEventNameWithoutOn)(prop);
|
|
50
|
-
}
|
|
51
|
-
return prop;
|
|
52
|
-
})
|
|
53
|
-
.filter((prop) => {
|
|
43
|
+
props = props.filter((prop) => {
|
|
54
44
|
// Stencil doesn't need children as a prop
|
|
55
45
|
return prop !== 'children';
|
|
56
46
|
});
|
|
@@ -14,7 +14,10 @@ const appendEmits = (str, events) => {
|
|
|
14
14
|
let code = str;
|
|
15
15
|
if (events.length) {
|
|
16
16
|
for (const event of events) {
|
|
17
|
-
|
|
17
|
+
const eventWithoutOn = (0, event_handlers_1.getEventNameWithoutOn)(event);
|
|
18
|
+
code = code
|
|
19
|
+
.replaceAll(`props.${event}(`, `props.${eventWithoutOn}.emit(`)
|
|
20
|
+
.replaceAll(`props.${event}`, `props.${eventWithoutOn}`);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
return code;
|
|
@@ -53,17 +56,21 @@ const getPropsAsCode = ({ props, propOptions, defaultProps, json, }) => {
|
|
|
53
56
|
const defaultProp = defaultProps ? (_a = defaultProps[item]) === null || _a === void 0 ? void 0 : _a.code : undefined;
|
|
54
57
|
const defaultPropString = defaultProp ? ` = ${defaultProp}` : '';
|
|
55
58
|
const propOption = propOptions[item];
|
|
56
|
-
|
|
57
|
-
return `@Event() ${item}: any${defaultPropString}`;
|
|
58
|
-
}
|
|
59
|
-
const type = propsTypeRef &&
|
|
59
|
+
const hasTyping = propsTypeRef &&
|
|
60
60
|
propsTypeRef !== 'any' &&
|
|
61
61
|
propsTypeRef !== 'unknown' &&
|
|
62
62
|
propsTypeRef !== 'never' &&
|
|
63
|
-
!isInternalType
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
!isInternalType;
|
|
64
|
+
if ((0, exports.isEvent)(item)) {
|
|
65
|
+
// Stencil adds "on" to every `@Event` so we need to remove "on" from event props
|
|
66
|
+
// https://stenciljs.com/docs/events#using-events-in-jsx
|
|
67
|
+
const eventType = hasTyping
|
|
68
|
+
? `EventEmitter<ReturnType<Required<${propsTypeRef}>["${item}"]>>`
|
|
69
|
+
: 'any';
|
|
70
|
+
return `@Event() ${(0, event_handlers_1.getEventNameWithoutOn)(item)}: ${eventType}${defaultPropString}`;
|
|
71
|
+
}
|
|
72
|
+
const propType = hasTyping ? `${propsTypeRef}["${item}"]` : 'any';
|
|
73
|
+
return `@Prop(${propOption ? JSON.stringify(propOption) : ''}) ${item}: ${propType}${defaultPropString}`;
|
|
67
74
|
})
|
|
68
75
|
.join(';\n');
|
|
69
76
|
};
|
|
@@ -101,6 +108,7 @@ const getStencilCoreImportsAsString = ({ wrap, events, props, dataString, watch,
|
|
|
101
108
|
Host: wrap,
|
|
102
109
|
Watch: watch,
|
|
103
110
|
Event: events.length > 0,
|
|
111
|
+
EventEmitter: events.length > 0,
|
|
104
112
|
Prop: props.length > 0,
|
|
105
113
|
State: dataString.length > 0,
|
|
106
114
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProcessBindingOptions } from '../../../generators/stencil/helpers
|
|
1
|
+
import { ProcessBindingOptions } from '../../../generators/stencil/helpers';
|
|
2
2
|
import { ToStencilOptions } from '../../../generators/stencil/types';
|
|
3
3
|
import { MitosisComponent } from '../../../types/mitosis-component';
|
|
4
4
|
export declare const getCodeProcessorPlugins: (json: MitosisComponent, options: ToStencilOptions, processBindingOptions: ProcessBindingOptions) => import("../../..").MitosisPlugin[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCodeProcessorPlugins = void 0;
|
|
4
|
-
const
|
|
4
|
+
const helpers_1 = require("../../../generators/stencil/helpers");
|
|
5
5
|
const process_code_1 = require("../../../helpers/plugins/process-code");
|
|
6
6
|
const getCodeProcessorPlugins = (json, options, processBindingOptions) => {
|
|
7
7
|
return [
|
|
@@ -16,7 +16,7 @@ const getCodeProcessorPlugins = (json, options, processBindingOptions) => {
|
|
|
16
16
|
case 'context-set':
|
|
17
17
|
case 'dynamic-jsx-elements':
|
|
18
18
|
case 'types':
|
|
19
|
-
return (code) => (0,
|
|
19
|
+
return (code) => (0, helpers_1.processBinding)(json, code, processBindingOptions);
|
|
20
20
|
}
|
|
21
21
|
}),
|
|
22
22
|
];
|
|
@@ -208,6 +208,17 @@ const stringifyBinding = (node, options) => ([key, binding]) => {
|
|
|
208
208
|
};
|
|
209
209
|
const blockToSvelte = ({ json, options, parentComponent }) => {
|
|
210
210
|
var _a, _b, _c, _d;
|
|
211
|
+
// Handling key binding by wrapping the element in a #key block
|
|
212
|
+
if (json.bindings.key) {
|
|
213
|
+
const keyCode = json.bindings.key.code;
|
|
214
|
+
delete json.bindings.key;
|
|
215
|
+
const str = `
|
|
216
|
+
{#key ${keyCode}}
|
|
217
|
+
${(0, exports.blockToSvelte)({ json, options, parentComponent })}
|
|
218
|
+
{/key}
|
|
219
|
+
`;
|
|
220
|
+
return str;
|
|
221
|
+
}
|
|
211
222
|
if (mappers[json.name]) {
|
|
212
223
|
return mappers[json.name]({
|
|
213
224
|
json: json,
|
|
@@ -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);
|