@builder.io/mitosis 0.2.7 → 0.2.9
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.
|
@@ -175,7 +175,10 @@ var processEventBinding = function (key, code, nodeName, customArg) {
|
|
|
175
175
|
var regexp = new RegExp('(^|\\n|\\r| |;|\\(|\\[|!)' + eventName + '(\\?\\.|\\.|\\(| |;|\\)|$)', 'g');
|
|
176
176
|
var replacer = '$1$event$2';
|
|
177
177
|
var finalValue = (0, remove_surrounding_block_1.removeSurroundingBlock)(code.replace(regexp, replacer));
|
|
178
|
-
return
|
|
178
|
+
return {
|
|
179
|
+
event: event,
|
|
180
|
+
value: finalValue,
|
|
181
|
+
};
|
|
179
182
|
};
|
|
180
183
|
var stringifyBinding = function (node, options, blockOptions) {
|
|
181
184
|
return function (_a) {
|
|
@@ -193,7 +196,8 @@ var stringifyBinding = function (node, options, blockOptions) {
|
|
|
193
196
|
var _b = binding, code = _b.code, _c = _b.arguments, cusArgs = _c === void 0 ? ['event'] : _c;
|
|
194
197
|
// TODO: proper babel transform to replace. Util for this
|
|
195
198
|
if (keyToUse.startsWith('on')) {
|
|
196
|
-
|
|
199
|
+
var _d = processEventBinding(keyToUse, code, node.name, cusArgs[0]), event_1 = _d.event, value = _d.value;
|
|
200
|
+
return " (".concat(event_1, ")=\"").concat(value, "\"");
|
|
197
201
|
}
|
|
198
202
|
else if (keyToUse === 'class') {
|
|
199
203
|
return " [class]=\"".concat(code, "\" ");
|
|
@@ -214,7 +218,16 @@ var stringifyBinding = function (node, options, blockOptions) {
|
|
|
214
218
|
};
|
|
215
219
|
var handleNgOutletBindings = function (node) {
|
|
216
220
|
var allProps = '';
|
|
217
|
-
var
|
|
221
|
+
for (var key in node.properties) {
|
|
222
|
+
if (key.startsWith('$')) {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (key === 'key') {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
var value = node.properties[key];
|
|
229
|
+
allProps += "".concat(key, ": '").concat(value, "', ");
|
|
230
|
+
}
|
|
218
231
|
for (var key in node.bindings) {
|
|
219
232
|
if (key.startsWith('"')) {
|
|
220
233
|
continue;
|
|
@@ -228,10 +241,11 @@ var handleNgOutletBindings = function (node) {
|
|
|
228
241
|
}
|
|
229
242
|
else if (key.includes('.')) {
|
|
230
243
|
// TODO: handle arbitrary spread props
|
|
231
|
-
allProps += "".concat(key.split('.')[1], ": ").concat(code, ",");
|
|
244
|
+
allProps += "".concat(key.split('.')[1], ": ").concat(code, ", ");
|
|
232
245
|
}
|
|
233
246
|
else if (key.startsWith('on')) {
|
|
234
|
-
|
|
247
|
+
var _c = processEventBinding(key, code, node.name, cusArgs[0]), event_2 = _c.event, value = _c.value;
|
|
248
|
+
allProps += "on".concat(event_2.charAt(0).toUpperCase() + event_2.slice(1), ": ").concat(value.replace(/\(.*?\)/g, ''), ", ");
|
|
235
249
|
}
|
|
236
250
|
else {
|
|
237
251
|
var codeToUse = processCodeBlockInTemplate(code);
|
|
@@ -245,7 +259,7 @@ var handleNgOutletBindings = function (node) {
|
|
|
245
259
|
if (allProps.startsWith(', ')) {
|
|
246
260
|
allProps = allProps.slice(2);
|
|
247
261
|
}
|
|
248
|
-
return
|
|
262
|
+
return allProps;
|
|
249
263
|
};
|
|
250
264
|
var blockToAngular = function (json, options, blockOptions) {
|
|
251
265
|
var _a, _b, _c, _d;
|
|
@@ -302,8 +316,8 @@ var blockToAngular = function (json, options, blockOptions) {
|
|
|
302
316
|
var elSelector = childComponents.find(function (impName) { return impName === json.name; })
|
|
303
317
|
? (0, lodash_1.kebabCase)(json.name)
|
|
304
318
|
: json.name;
|
|
305
|
-
var
|
|
306
|
-
str += "<ng-container
|
|
319
|
+
var allProps = handleNgOutletBindings(json);
|
|
320
|
+
str += "<ng-container *ngComponentOutlet=\"\n ".concat(elSelector.replace('state.', '').replace('props.', ''), ";\n inputs: { ").concat(allProps, " };\n content: myContent;\n \"> ");
|
|
307
321
|
str += "</ng-container>";
|
|
308
322
|
}
|
|
309
323
|
else {
|
|
@@ -97,6 +97,7 @@ var onUpdatePlugin = function (options) { return ({
|
|
|
97
97
|
var BASE_OPTIONS = {
|
|
98
98
|
api: 'options',
|
|
99
99
|
defineComponent: true,
|
|
100
|
+
casing: 'pascal',
|
|
100
101
|
};
|
|
101
102
|
var componentToVue = function (userOptions) {
|
|
102
103
|
return function (_a) {
|
|
@@ -181,7 +182,12 @@ var componentToVue = function (userOptions) {
|
|
|
181
182
|
prefix: (_d = (_c = options.cssNamespace) === null || _c === void 0 ? void 0 : _c.call(options)) !== null && _d !== void 0 ? _d : undefined,
|
|
182
183
|
});
|
|
183
184
|
(0, strip_meta_properties_1.stripMetaProperties)(component);
|
|
184
|
-
var
|
|
185
|
+
var templateStrBody = component.children
|
|
186
|
+
.map(function (item) { return (0, blocks_1.blockToVue)(item, options, { isRootNode: true }); })
|
|
187
|
+
.join('\n');
|
|
188
|
+
var template = options.casing === 'kebab'
|
|
189
|
+
? (0, helpers_1.renameMitosisComponentsToKebabCase)(templateStrBody)
|
|
190
|
+
: templateStrBody;
|
|
185
191
|
var onUpdateWithDeps = ((_e = component.hooks.onUpdate) === null || _e === void 0 ? void 0 : _e.filter(function (hook) { var _a; return (_a = hook.deps) === null || _a === void 0 ? void 0 : _a.length; })) || [];
|
|
186
192
|
var onUpdateWithoutDeps = ((_f = component.hooks.onUpdate) === null || _f === void 0 ? void 0 : _f.filter(function (hook) { var _a; return !((_a = hook.deps) === null || _a === void 0 ? void 0 : _a.length); })) || [];
|
|
187
193
|
var getterKeys = Object.keys((0, lodash_1.pickBy)(component.state, function (i) { return (i === null || i === void 0 ? void 0 : i.type) === 'getter'; }));
|