@builder.io/mitosis 0.3.15 → 0.3.16
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.
|
@@ -264,10 +264,10 @@ var handleNgOutletBindings = function (node, options) {
|
|
|
264
264
|
return allProps;
|
|
265
265
|
};
|
|
266
266
|
var blockToAngular = function (_a) {
|
|
267
|
-
var _b, _c, _d, _e, _f;
|
|
268
|
-
var root = _a.root, json = _a.json,
|
|
267
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
268
|
+
var root = _a.root, json = _a.json, _l = _a.options, options = _l === void 0 ? {} : _l, _m = _a.blockOptions, blockOptions = _m === void 0 ? {
|
|
269
269
|
nativeAttributes: [],
|
|
270
|
-
} :
|
|
270
|
+
} : _m;
|
|
271
271
|
var childComponents = (blockOptions === null || blockOptions === void 0 ? void 0 : blockOptions.childComponents) || [];
|
|
272
272
|
if (mappers[json.name]) {
|
|
273
273
|
return mappers[json.name](root, json, options);
|
|
@@ -292,14 +292,29 @@ var blockToAngular = function (_a) {
|
|
|
292
292
|
var str = '';
|
|
293
293
|
if ((0, mitosis_node_1.checkIsForNode)(json)) {
|
|
294
294
|
var indexName = json.scope.indexName;
|
|
295
|
-
|
|
295
|
+
var forName = json.scope.forName;
|
|
296
|
+
// Check if "key" is present for the first child of the for loop
|
|
297
|
+
if (json.children[0].bindings && ((_c = json.children[0].bindings.key) === null || _c === void 0 ? void 0 : _c.code)) {
|
|
298
|
+
var fnIndex = ((_d = root.meta) === null || _d === void 0 ? void 0 : _d._trackByForIndex) || 0;
|
|
299
|
+
var trackByFnName = "trackBy".concat(forName ? forName.charAt(0).toUpperCase() + forName.slice(1) : '').concat(fnIndex);
|
|
300
|
+
root.meta._trackByForIndex = fnIndex + 1;
|
|
301
|
+
var code = (_e = json.children[0].bindings.key) === null || _e === void 0 ? void 0 : _e.code;
|
|
302
|
+
root.state[trackByFnName] = {
|
|
303
|
+
code: "".concat(trackByFnName, "(").concat(indexName !== null && indexName !== void 0 ? indexName : '_', ", ").concat(forName, ") { return ").concat(code, "; }"),
|
|
304
|
+
type: 'method',
|
|
305
|
+
};
|
|
306
|
+
str += "<ng-container *ngFor=\"let ".concat(forName, " of ").concat((_f = json.bindings.each) === null || _f === void 0 ? void 0 : _f.code).concat(indexName ? "; let ".concat(indexName, " = index") : '', "; trackBy: ").concat(trackByFnName, "\">");
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
str += "<ng-container *ngFor=\"let ".concat(forName, " of ").concat((_g = json.bindings.each) === null || _g === void 0 ? void 0 : _g.code).concat(indexName ? "; let ".concat(indexName, " = index") : '', "\">");
|
|
310
|
+
}
|
|
296
311
|
str += json.children
|
|
297
312
|
.map(function (item) { return (0, exports.blockToAngular)({ root: root, json: item, options: options, blockOptions: blockOptions }); })
|
|
298
313
|
.join('\n');
|
|
299
314
|
str += "</ng-container>";
|
|
300
315
|
}
|
|
301
316
|
else if (json.name === 'Show') {
|
|
302
|
-
var condition = (
|
|
317
|
+
var condition = (_h = json.bindings.when) === null || _h === void 0 ? void 0 : _h.code;
|
|
303
318
|
if (options.state === 'inline-with-wrappers' && (condition === null || condition === void 0 ? void 0 : condition.includes('typeof'))) {
|
|
304
319
|
var wordAfterTypeof = condition.split('typeof')[1].trim().split(' ')[0];
|
|
305
320
|
condition = condition.replace("typeof ".concat(wordAfterTypeof), "useTypeOf(".concat(wordAfterTypeof, ")"));
|
|
@@ -310,7 +325,7 @@ var blockToAngular = function (_a) {
|
|
|
310
325
|
.join('\n');
|
|
311
326
|
str += "</ng-container>";
|
|
312
327
|
// else condition
|
|
313
|
-
if ((0, is_mitosis_node_1.isMitosisNode)((
|
|
328
|
+
if ((0, is_mitosis_node_1.isMitosisNode)((_j = json.meta) === null || _j === void 0 ? void 0 : _j.else)) {
|
|
314
329
|
str += "<ng-container *ngIf=\"!(".concat(condition, ")\">");
|
|
315
330
|
str += (0, exports.blockToAngular)({ root: root, json: json.meta.else, options: options, blockOptions: blockOptions });
|
|
316
331
|
str += "</ng-container>";
|
|
@@ -327,7 +342,7 @@ var blockToAngular = function (_a) {
|
|
|
327
342
|
code: 'null',
|
|
328
343
|
type: 'property',
|
|
329
344
|
};
|
|
330
|
-
if (!((
|
|
345
|
+
if (!((_k = root.hooks.onInit) === null || _k === void 0 ? void 0 : _k.code.includes(inputsPropsStateName))) {
|
|
331
346
|
if (!root.hooks.onInit) {
|
|
332
347
|
root.hooks.onInit = { code: '' };
|
|
333
348
|
}
|
|
@@ -437,6 +452,8 @@ var handleBindings = function (json, item, index, forName, indexName) {
|
|
|
437
452
|
if (forName) {
|
|
438
453
|
if (item.name === 'For')
|
|
439
454
|
continue;
|
|
455
|
+
if (key === 'key')
|
|
456
|
+
continue;
|
|
440
457
|
if (key.startsWith('on')) {
|
|
441
458
|
var _j = item.bindings[key].arguments, cusArgs = _j === void 0 ? ['event'] : _j;
|
|
442
459
|
var eventBindingName = "".concat(generateNewBindingName(index, item.name), "_event");
|
|
@@ -713,6 +730,10 @@ var componentToAngular = function (userOptions) {
|
|
|
713
730
|
template = tryFormat(template, 'html');
|
|
714
731
|
}
|
|
715
732
|
(0, strip_meta_properties_1.stripMetaProperties)(json);
|
|
733
|
+
var _p = traverseToGetAllDynamicComponents(json, options, {
|
|
734
|
+
childComponents: childComponents,
|
|
735
|
+
nativeAttributes: (_e = (_d = useMetadata === null || useMetadata === void 0 ? void 0 : useMetadata.angular) === null || _d === void 0 ? void 0 : _d.nativeAttributes) !== null && _e !== void 0 ? _e : [],
|
|
736
|
+
}), dynamicComponents = _p.components, dynamicTemplate = _p.dynamicTemplate;
|
|
716
737
|
var dataString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
|
|
717
738
|
format: 'class',
|
|
718
739
|
valueMapper: processAngularCode({
|
|
@@ -723,10 +744,6 @@ var componentToAngular = function (userOptions) {
|
|
|
723
744
|
stateVars: stateVars,
|
|
724
745
|
}),
|
|
725
746
|
});
|
|
726
|
-
var _p = traverseToGetAllDynamicComponents(json, options, {
|
|
727
|
-
childComponents: childComponents,
|
|
728
|
-
nativeAttributes: (_e = (_d = useMetadata === null || useMetadata === void 0 ? void 0 : useMetadata.angular) === null || _d === void 0 ? void 0 : _d.nativeAttributes) !== null && _e !== void 0 ? _e : [],
|
|
729
|
-
}), dynamicComponents = _p.components, dynamicTemplate = _p.dynamicTemplate;
|
|
730
747
|
var hostDisplayCss = options.visuallyIgnoreHostElement ? ':host { display: contents; }' : '';
|
|
731
748
|
var styles = css.length ? [hostDisplayCss, css].join('\n') : hostDisplayCss;
|
|
732
749
|
// Preparing built in component metadata parameters
|