@builder.io/mitosis 0.11.0 → 0.11.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.
|
@@ -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),
|
|
@@ -380,7 +380,7 @@ const _componentToReact = (json, options, isSubComponent = false) => {
|
|
|
380
380
|
${componentBody}
|
|
381
381
|
}${isForwardRef ? ')' : ''}
|
|
382
382
|
|
|
383
|
-
${reactNativeStyles
|
|
383
|
+
${reactNativeStyles && Object.keys(reactNativeStyles).length > 0
|
|
384
384
|
? `const styles = StyleSheet.create(${json5_1.default.stringify(reactNativeStyles)});`
|
|
385
385
|
: ''}
|
|
386
386
|
|
|
@@ -10,12 +10,11 @@ const get_state_object_string_1 = require("../../../helpers/get-state-object-str
|
|
|
10
10
|
const get_typed_function_1 = require("../../../helpers/get-typed-function");
|
|
11
11
|
const is_mitosis_node_1 = require("../../../helpers/is-mitosis-node");
|
|
12
12
|
const patterns_1 = require("../../../helpers/patterns");
|
|
13
|
-
const helpers_1 = require("../../../helpers/styles/helpers");
|
|
14
13
|
const transform_state_setters_1 = require("../../../helpers/transform-state-setters");
|
|
15
14
|
const core_1 = require("@babel/core");
|
|
16
15
|
const function_1 = require("fp-ts/lib/function");
|
|
17
16
|
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
18
|
-
const
|
|
17
|
+
const helpers_1 = require("../helpers");
|
|
19
18
|
/**
|
|
20
19
|
* Removes all `this.` references.
|
|
21
20
|
*/
|
|
@@ -25,7 +24,7 @@ const stripThisRefs = (str, options) => {
|
|
|
25
24
|
}
|
|
26
25
|
return str.replace(/this\.([a-zA-Z_\$0-9]+)/g, '$1');
|
|
27
26
|
};
|
|
28
|
-
const processHookCode = ({ str, options }) => (0,
|
|
27
|
+
const processHookCode = ({ str, options }) => (0, helpers_1.processBinding)((0, exports.updateStateSettersInCode)(str, options), options);
|
|
29
28
|
exports.processHookCode = processHookCode;
|
|
30
29
|
const valueMapper = (options) => (val) => {
|
|
31
30
|
const x = (0, exports.processHookCode)({ str: val, options });
|
|
@@ -150,9 +149,6 @@ const getDefaultImport = (options, json) => {
|
|
|
150
149
|
});
|
|
151
150
|
}
|
|
152
151
|
});
|
|
153
|
-
if ((0, helpers_1.hasCss)(json)) {
|
|
154
|
-
namesUsed.add('StyleSheet');
|
|
155
|
-
}
|
|
156
152
|
(0, legacy_1.default)(json).forEach((node) => {
|
|
157
153
|
var _a, _b, _c, _d;
|
|
158
154
|
if (!(0, is_mitosis_node_1.isMitosisNode)(node)) {
|
|
@@ -162,6 +158,9 @@ const getDefaultImport = (options, json) => {
|
|
|
162
158
|
if (((_a = node.properties._text) === null || _a === void 0 ? void 0 : _a.trim().length) || ((_d = (_c = (_b = node.bindings._text) === null || _b === void 0 ? void 0 : _b.code) === null || _c === void 0 ? void 0 : _c.trim()) === null || _d === void 0 ? void 0 : _d.length)) {
|
|
163
159
|
namesUsed.add('Text');
|
|
164
160
|
}
|
|
161
|
+
if (node.properties.style || node.bindings.style) {
|
|
162
|
+
namesUsed.add('StyleSheet');
|
|
163
|
+
}
|
|
165
164
|
if (node.name === 'TouchableOpacity' &&
|
|
166
165
|
('href' in node.bindings || 'href' in node.properties)) {
|
|
167
166
|
namesUsed.add('Linking');
|
|
@@ -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,
|