@builder.io/mitosis 0.11.1 → 0.11.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.
|
@@ -393,7 +393,7 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
393
393
|
// Add ref for passing attributes
|
|
394
394
|
str += `#${rootRef}`;
|
|
395
395
|
}
|
|
396
|
-
if (html_tags_1.SELF_CLOSING_HTML_TAGS.has(
|
|
396
|
+
if (html_tags_1.SELF_CLOSING_HTML_TAGS.has(element)) {
|
|
397
397
|
return str + ' />';
|
|
398
398
|
}
|
|
399
399
|
str += '>';
|
|
@@ -10,6 +10,7 @@ const parse_selector_1 = require("../../../generators/angular/helpers/parse-sele
|
|
|
10
10
|
const babel_transform_1 = require("../../../helpers/babel-transform");
|
|
11
11
|
const bindings_1 = require("../../../helpers/bindings");
|
|
12
12
|
const event_handlers_1 = require("../../../helpers/event-handlers");
|
|
13
|
+
const get_tag_name_1 = require("../../../helpers/get-tag-name");
|
|
13
14
|
const is_children_1 = __importDefault(require("../../../helpers/is-children"));
|
|
14
15
|
const is_mitosis_node_1 = require("../../../helpers/is-mitosis-node");
|
|
15
16
|
const slots_1 = require("../../../helpers/slots");
|
|
@@ -268,22 +269,23 @@ const getElementTag = (json, blockOptions) => {
|
|
|
268
269
|
const childComponents = (blockOptions === null || blockOptions === void 0 ? void 0 : blockOptions.childComponents) || [];
|
|
269
270
|
let element, classNames = [], attributes;
|
|
270
271
|
const isComponent = childComponents.find((impName) => impName === json.name);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
catch (_a) {
|
|
278
|
-
element = (0, lodash_1.kebabCase)(json.name);
|
|
279
|
-
}
|
|
272
|
+
const tagName = (0, get_tag_name_1.getBuilderTagName)(json);
|
|
273
|
+
const selector = json.meta.selector || (blockOptions === null || blockOptions === void 0 ? void 0 : blockOptions.selector);
|
|
274
|
+
if (selector) {
|
|
275
|
+
try {
|
|
276
|
+
({ element, classNames, attributes } = (0, parse_selector_1.parseSelector)(`${selector}`));
|
|
280
277
|
}
|
|
281
|
-
|
|
282
|
-
element = (0, lodash_1.kebabCase)(json.name);
|
|
278
|
+
catch (_a) {
|
|
279
|
+
element = tagName !== null && tagName !== void 0 ? tagName : (0, lodash_1.kebabCase)(json.name);
|
|
283
280
|
}
|
|
284
281
|
}
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
if (!element) {
|
|
283
|
+
if (isComponent) {
|
|
284
|
+
element = tagName !== null && tagName !== void 0 ? tagName : (0, lodash_1.kebabCase)(json.name);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
element = tagName !== null && tagName !== void 0 ? tagName : json.name;
|
|
288
|
+
}
|
|
287
289
|
}
|
|
288
290
|
let additionalString = '';
|
|
289
291
|
// TODO: merge with existing classes/bindings
|
|
@@ -362,7 +364,7 @@ const blockToAngularSignals = ({ root, json, options = {}, blockOptions = {
|
|
|
362
364
|
// Add ref for passing attributes
|
|
363
365
|
str += `#${rootRef}`;
|
|
364
366
|
}
|
|
365
|
-
if (html_tags_1.SELF_CLOSING_HTML_TAGS.has(
|
|
367
|
+
if (html_tags_1.SELF_CLOSING_HTML_TAGS.has(element)) {
|
|
366
368
|
return str + ' />';
|
|
367
369
|
}
|
|
368
370
|
str += '>';
|
|
@@ -583,6 +583,12 @@ const blockToBuilder = (json, options = {}, _internalOptions = {}) => {
|
|
|
583
583
|
responsiveStyles,
|
|
584
584
|
}),
|
|
585
585
|
layerName: json.properties.$name,
|
|
586
|
+
...(json.properties['data-builder-layerLocked'] !== undefined && {
|
|
587
|
+
layerLocked: json.properties['data-builder-layerLocked'] === 'true',
|
|
588
|
+
}),
|
|
589
|
+
...(json.properties['data-builder-groupLocked'] !== undefined && {
|
|
590
|
+
groupLocked: json.properties['data-builder-groupLocked'] === 'true',
|
|
591
|
+
}),
|
|
586
592
|
...(thisIsComponent && {
|
|
587
593
|
component: {
|
|
588
594
|
name: mapComponentName(json.name),
|
|
@@ -498,6 +498,14 @@ const componentMappers = {
|
|
|
498
498
|
if (block.layerName) {
|
|
499
499
|
properties.$name = block.layerName;
|
|
500
500
|
}
|
|
501
|
+
// Add data attributes for Builder layer properties
|
|
502
|
+
const dataAttributes = {};
|
|
503
|
+
if (block.layerLocked !== undefined) {
|
|
504
|
+
dataAttributes['data-builder-layerLocked'] = String(block.layerLocked);
|
|
505
|
+
}
|
|
506
|
+
if (block.groupLocked !== undefined) {
|
|
507
|
+
dataAttributes['data-builder-groupLocked'] = String(block.groupLocked);
|
|
508
|
+
}
|
|
501
509
|
const innerBindings = {};
|
|
502
510
|
const componentOptionsText = blockBindings['component.options.text'];
|
|
503
511
|
if (componentOptionsText) {
|
|
@@ -522,7 +530,10 @@ const componentMappers = {
|
|
|
522
530
|
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
523
531
|
name: block.tagName || 'div',
|
|
524
532
|
bindings,
|
|
525
|
-
properties
|
|
533
|
+
properties: {
|
|
534
|
+
...properties,
|
|
535
|
+
...dataAttributes,
|
|
536
|
+
},
|
|
526
537
|
meta: (0, exports.getMetaFromBlock)(block, options),
|
|
527
538
|
...(Object.keys(localizedValues).length && { localizedValues }),
|
|
528
539
|
children: [
|
|
@@ -546,6 +557,7 @@ const componentMappers = {
|
|
|
546
557
|
}
|
|
547
558
|
: {}),
|
|
548
559
|
...properties,
|
|
560
|
+
...dataAttributes,
|
|
549
561
|
};
|
|
550
562
|
const finalTagname = block.tagName || (assumeLink ? 'a' : 'div');
|
|
551
563
|
if ((block.tagName && block.tagName !== 'div') ||
|
|
@@ -817,6 +829,14 @@ const builderElementToMitosisNode = (block, options, _internalOptions = {}) => {
|
|
|
817
829
|
bindings[useKey] = (0, bindings_1.createSingleBinding)({ code: value });
|
|
818
830
|
}
|
|
819
831
|
}
|
|
832
|
+
// Add data attributes for Builder layer properties
|
|
833
|
+
const dataAttributes = {};
|
|
834
|
+
if (block.layerLocked !== undefined) {
|
|
835
|
+
dataAttributes['data-builder-layerLocked'] = String(block.layerLocked);
|
|
836
|
+
}
|
|
837
|
+
if (block.groupLocked !== undefined) {
|
|
838
|
+
dataAttributes['data-builder-groupLocked'] = String(block.groupLocked);
|
|
839
|
+
}
|
|
820
840
|
const node = (0, create_mitosis_node_1.createMitosisNode)({
|
|
821
841
|
name: ((_r = (_q = block.component) === null || _q === void 0 ? void 0 : _q.name) === null || _r === void 0 ? void 0 : _r.replace(/[^a-z0-9]/gi, '')) ||
|
|
822
842
|
block.tagName ||
|
|
@@ -825,6 +845,7 @@ const builderElementToMitosisNode = (block, options, _internalOptions = {}) => {
|
|
|
825
845
|
...(block.component && includeSpecialBindings && { $tagName: block.tagName }),
|
|
826
846
|
...(block.class && { class: block.class }),
|
|
827
847
|
...properties,
|
|
848
|
+
...dataAttributes,
|
|
828
849
|
},
|
|
829
850
|
bindings: {
|
|
830
851
|
...bindings,
|