@builder.io/mitosis 0.0.120 → 0.0.121
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/svelte/blocks.js +24 -9
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +3 -1
- package/dist/src/parsers/builder/builder.d.ts +1 -6
- package/dist/src/parsers/builder/builder.js +79 -17
- package/dist/src/plugins/compile-away-builder-components.d.ts +1 -1
- package/dist/src/plugins/compile-away-builder-components.js +62 -157
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -3
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.blockToSvelte = void 0;
|
|
7
7
|
var html_tags_1 = require("../../constants/html_tags");
|
|
8
|
-
var html_tags_2 = require("../../constants/html_tags");
|
|
9
8
|
var bindings_1 = require("../../helpers/bindings");
|
|
10
9
|
var is_children_1 = __importDefault(require("../../helpers/is-children"));
|
|
11
10
|
var is_upper_case_1 = require("../../helpers/is-upper-case");
|
|
@@ -20,6 +19,26 @@ var helpers_1 = require("./helpers");
|
|
|
20
19
|
*/
|
|
21
20
|
var SLOT_PREFIX = '$$slots.';
|
|
22
21
|
var mappers = {
|
|
22
|
+
style: function (_a) {
|
|
23
|
+
var _b;
|
|
24
|
+
var json = _a.json, options = _a.options, parentComponent = _a.parentComponent;
|
|
25
|
+
var props = '';
|
|
26
|
+
for (var key in json.properties) {
|
|
27
|
+
var value = json.properties[key];
|
|
28
|
+
props += " ".concat(key, "=\"").concat(value, "\" ");
|
|
29
|
+
}
|
|
30
|
+
var bindings = '';
|
|
31
|
+
for (var key in json.bindings) {
|
|
32
|
+
var value = json.bindings[key];
|
|
33
|
+
if (value && key !== 'innerHTML') {
|
|
34
|
+
bindings += " ".concat(key, "=${").concat(value.code, "} ");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
var innerText = ((_b = json.bindings.innerHTML) === null || _b === void 0 ? void 0 : _b.code) || '';
|
|
38
|
+
// We have to obfuscate `"style"` due to a limitation in the svelte-preprocessor plugin.
|
|
39
|
+
// https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
|
|
40
|
+
return "{@html `<${'style'} ".concat(bindings, " ").concat(props, ">${").concat(innerText, "}<${'/style'}>`}");
|
|
41
|
+
},
|
|
23
42
|
Fragment: function (_a) {
|
|
24
43
|
var _b;
|
|
25
44
|
var json = _a.json, options = _a.options, parentComponent = _a.parentComponent;
|
|
@@ -96,18 +115,14 @@ var getTagName = function (_a) {
|
|
|
96
115
|
/**
|
|
97
116
|
* These are special HTML tags that svelte requires `<svelte:element this={TAG}>`
|
|
98
117
|
*/
|
|
99
|
-
var SPECIAL_HTML_TAGS = ['
|
|
118
|
+
var SPECIAL_HTML_TAGS = ['script', 'template'];
|
|
100
119
|
if (SPECIAL_HTML_TAGS.includes(json.name)) {
|
|
101
120
|
json.bindings.this = (0, bindings_1.createSingleBinding)({
|
|
102
|
-
code: json.name
|
|
103
|
-
? // We have to obfuscate `"style"` due to a limitation in the svelte-preprocessor plugin.
|
|
104
|
-
// https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
|
|
105
|
-
"\"sty\" + \"le\""
|
|
106
|
-
: "\"".concat(json.name, "\""),
|
|
121
|
+
code: "\"".concat(json.name, "\""),
|
|
107
122
|
});
|
|
108
123
|
return SVELTE_SPECIAL_TAGS.ELEMENT;
|
|
109
124
|
}
|
|
110
|
-
var isValidHtmlTag =
|
|
125
|
+
var isValidHtmlTag = html_tags_1.VALID_HTML_TAGS.includes(json.name);
|
|
111
126
|
var isSpecialSvelteTag = json.name.startsWith('svelte:');
|
|
112
127
|
// Check if any import matches `json.name`
|
|
113
128
|
var hasMatchingImport = parentComponent.imports.some(function (_a) {
|
|
@@ -132,7 +147,7 @@ var stringifyBinding = function (node, options) {
|
|
|
132
147
|
return '';
|
|
133
148
|
}
|
|
134
149
|
var code = binding.code, _b = binding.arguments, cusArgs = _b === void 0 ? ['event'] : _b, type = binding.type;
|
|
135
|
-
var isValidHtmlTag =
|
|
150
|
+
var isValidHtmlTag = html_tags_1.VALID_HTML_TAGS.includes(node.name);
|
|
136
151
|
if (type === 'spread') {
|
|
137
152
|
var spreadValue = key === 'props' ? '$$props' : code;
|
|
138
153
|
return " {...".concat(spreadValue, "} ");
|
package/dist/src/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from './generators/taro';
|
|
|
29
29
|
export * from './generators/template';
|
|
30
30
|
export * from './generators/vue';
|
|
31
31
|
export { checkIsLiteComponentFilePath, checkIsMitosisComponentFilePath, checkIsSvelteComponentFilePath, getComponentFileExtensionForTarget, renameComponentFile, renameImport, } from './helpers/component-file-extensions';
|
|
32
|
+
export { createMitosisNode } from './helpers/create-mitosis-node';
|
|
32
33
|
export * from './helpers/is-mitosis-node';
|
|
33
34
|
export { checkShouldOutputTypeScript } from './helpers/output';
|
|
34
35
|
export * from './helpers/signals';
|
package/dist/src/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.checkShouldOutputTypeScript = exports.renameImport = exports.renameComponentFile = exports.getComponentFileExtensionForTarget = exports.checkIsSvelteComponentFilePath = exports.checkIsMitosisComponentFilePath = exports.checkIsLiteComponentFilePath = void 0;
|
|
17
|
+
exports.checkShouldOutputTypeScript = exports.createMitosisNode = exports.renameImport = exports.renameComponentFile = exports.getComponentFileExtensionForTarget = exports.checkIsSvelteComponentFilePath = exports.checkIsMitosisComponentFilePath = exports.checkIsLiteComponentFilePath = void 0;
|
|
18
18
|
__exportStar(require("./flow"), exports);
|
|
19
19
|
__exportStar(require("./generators/alpine"), exports);
|
|
20
20
|
__exportStar(require("./generators/angular"), exports);
|
|
@@ -48,6 +48,8 @@ Object.defineProperty(exports, "checkIsSvelteComponentFilePath", { enumerable: t
|
|
|
48
48
|
Object.defineProperty(exports, "getComponentFileExtensionForTarget", { enumerable: true, get: function () { return component_file_extensions_1.getComponentFileExtensionForTarget; } });
|
|
49
49
|
Object.defineProperty(exports, "renameComponentFile", { enumerable: true, get: function () { return component_file_extensions_1.renameComponentFile; } });
|
|
50
50
|
Object.defineProperty(exports, "renameImport", { enumerable: true, get: function () { return component_file_extensions_1.renameImport; } });
|
|
51
|
+
var create_mitosis_node_1 = require("./helpers/create-mitosis-node");
|
|
52
|
+
Object.defineProperty(exports, "createMitosisNode", { enumerable: true, get: function () { return create_mitosis_node_1.createMitosisNode; } });
|
|
51
53
|
__exportStar(require("./helpers/is-mitosis-node"), exports);
|
|
52
54
|
var output_1 = require("./helpers/output");
|
|
53
55
|
Object.defineProperty(exports, "checkShouldOutputTypeScript", { enumerable: true, get: function () { return output_1.checkShouldOutputTypeScript; } });
|
|
@@ -5,18 +5,13 @@ declare type InternalOptions = {
|
|
|
5
5
|
skipMapper?: boolean;
|
|
6
6
|
};
|
|
7
7
|
export declare const symbolBlocksAsChildren = false;
|
|
8
|
-
|
|
8
|
+
declare type BuilderToMitosisOptions = {
|
|
9
9
|
context?: {
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
};
|
|
12
12
|
includeBuilderExtras?: boolean;
|
|
13
13
|
preserveTextBlocks?: boolean;
|
|
14
14
|
};
|
|
15
|
-
export declare type InternalBuilderToMitosisOptions = BuilderToMitosisOptions & {
|
|
16
|
-
context: {
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
15
|
export declare const builderElementToMitosisNode: (block: BuilderElement, options: BuilderToMitosisOptions, _internalOptions?: InternalOptions) => MitosisNode;
|
|
21
16
|
/**
|
|
22
17
|
* Take Builder custom jsCode and extract the contents of the useState hook
|
|
@@ -33,6 +33,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
33
|
__setModuleDefault(result, mod);
|
|
34
34
|
return result;
|
|
35
35
|
};
|
|
36
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
+
if (ar || !(i in from)) {
|
|
39
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
+
ar[i] = from[i];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
|
+
};
|
|
36
45
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
47
|
};
|
|
@@ -287,8 +296,9 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
|
|
|
287
296
|
delete node.properties.columns;
|
|
288
297
|
node.children =
|
|
289
298
|
((_b = (_a = block.component) === null || _a === void 0 ? void 0 : _a.options.columns) === null || _b === void 0 ? void 0 : _b.map(function (col, index) {
|
|
299
|
+
var _a;
|
|
290
300
|
return (0, create_mitosis_node_1.createMitosisNode)(__assign(__assign({ name: 'Column', bindings: {
|
|
291
|
-
width: { code: col.width },
|
|
301
|
+
width: { code: (_a = col.width) === null || _a === void 0 ? void 0 : _a.toString() },
|
|
292
302
|
} }, (col.link && {
|
|
293
303
|
properties: {
|
|
294
304
|
link: col.link,
|
|
@@ -331,7 +341,7 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
|
|
|
331
341
|
css: { code: JSON.stringify(css) },
|
|
332
342
|
}));
|
|
333
343
|
var properties = __assign({}, block.properties);
|
|
334
|
-
if (block.id)
|
|
344
|
+
if (options.includeBuilderExtras && block.id)
|
|
335
345
|
properties['builder-id'] = block.id;
|
|
336
346
|
if (block.class)
|
|
337
347
|
properties['class'] = block.class;
|
|
@@ -345,8 +355,9 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
|
|
|
345
355
|
code: wrapBindingIfNeeded(componentOptionsText.code, options),
|
|
346
356
|
});
|
|
347
357
|
}
|
|
358
|
+
var text = block.component.options.text;
|
|
348
359
|
var innerProperties = (_a = {},
|
|
349
|
-
_a[options.preserveTextBlocks ? 'innerHTML' : '_text'] =
|
|
360
|
+
_a[options.preserveTextBlocks ? 'innerHTML' : '_text'] = text,
|
|
350
361
|
_a);
|
|
351
362
|
if (options.preserveTextBlocks) {
|
|
352
363
|
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
@@ -361,11 +372,19 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
|
|
|
361
372
|
],
|
|
362
373
|
});
|
|
363
374
|
}
|
|
375
|
+
// Disabling for now
|
|
376
|
+
var assumeLink = false;
|
|
377
|
+
var finalProperties = __assign(__assign({}, (assumeLink
|
|
378
|
+
? {
|
|
379
|
+
href: '...',
|
|
380
|
+
}
|
|
381
|
+
: {})), properties);
|
|
382
|
+
var finalTagname = block.tagName || (assumeLink ? 'a' : 'div');
|
|
364
383
|
if ((block.tagName && block.tagName !== 'div') || hasStyles(block)) {
|
|
365
384
|
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
366
|
-
name:
|
|
385
|
+
name: finalTagname,
|
|
367
386
|
bindings: bindings,
|
|
368
|
-
properties:
|
|
387
|
+
properties: finalProperties,
|
|
369
388
|
children: [
|
|
370
389
|
(0, create_mitosis_node_1.createMitosisNode)({
|
|
371
390
|
bindings: innerBindings,
|
|
@@ -375,14 +394,14 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
|
|
|
375
394
|
});
|
|
376
395
|
}
|
|
377
396
|
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
378
|
-
name:
|
|
379
|
-
properties: __assign(__assign({}, properties), innerProperties),
|
|
397
|
+
name: finalTagname,
|
|
398
|
+
properties: __assign(__assign(__assign({}, finalProperties), properties), innerProperties),
|
|
380
399
|
bindings: __assign(__assign({}, bindings), innerBindings),
|
|
381
400
|
});
|
|
382
401
|
} });
|
|
383
402
|
var builderElementToMitosisNode = function (block, options, _internalOptions) {
|
|
384
403
|
var _a;
|
|
385
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
404
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
386
405
|
if (_internalOptions === void 0) { _internalOptions = {}; }
|
|
387
406
|
if (((_b = block.component) === null || _b === void 0 ? void 0 : _b.name) === 'Core:Fragment') {
|
|
388
407
|
block.component.name = 'Fragment';
|
|
@@ -525,16 +544,29 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
|
|
|
525
544
|
})),
|
|
526
545
|
});
|
|
527
546
|
// Has single text node child
|
|
528
|
-
|
|
529
|
-
|
|
547
|
+
var firstChild = (_s = block.children) === null || _s === void 0 ? void 0 : _s[0];
|
|
548
|
+
if (((_t = block.children) === null || _t === void 0 ? void 0 : _t.length) === 1 &&
|
|
549
|
+
((_u = firstChild === null || firstChild === void 0 ? void 0 : firstChild.component) === null || _u === void 0 ? void 0 : _u.name) === 'Text' &&
|
|
530
550
|
!options.preserveTextBlocks) {
|
|
531
|
-
var textProperties = (0, exports.builderElementToMitosisNode)(
|
|
532
|
-
var
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
551
|
+
var textProperties = (0, exports.builderElementToMitosisNode)(firstChild, options);
|
|
552
|
+
var parsedNodeCss = json5_1.default.parse(((_v = node.bindings.css) === null || _v === void 0 ? void 0 : _v.code) || '{}');
|
|
553
|
+
var parsedTextCss = json5_1.default.parse(((_w = textProperties.bindings.css) === null || _w === void 0 ? void 0 : _w.code) || '{}');
|
|
554
|
+
var mergedCss = combineStyles(parsedNodeCss, parsedTextCss);
|
|
555
|
+
// Don't merge if text has styling that matters
|
|
556
|
+
var doNotMerge =
|
|
557
|
+
// Text has flex alignment
|
|
558
|
+
['end', 'right', 'center'].includes(parsedTextCss.alignSelf) ||
|
|
559
|
+
// Text has specific styling
|
|
560
|
+
parsedTextCss.backgroundColor ||
|
|
561
|
+
parsedTextCss.opacity ||
|
|
562
|
+
parsedTextCss.background;
|
|
563
|
+
if (!doNotMerge) {
|
|
564
|
+
return (0, lodash_1.merge)({}, textProperties, node, {
|
|
565
|
+
bindings: __assign({}, (Object.keys(mergedCss).length && {
|
|
566
|
+
css: { code: json5_1.default.stringify(mergedCss) },
|
|
567
|
+
})),
|
|
568
|
+
});
|
|
569
|
+
}
|
|
538
570
|
}
|
|
539
571
|
node.children = (block.children || []).map(function (item) { return (0, exports.builderElementToMitosisNode)(item, options); });
|
|
540
572
|
return node;
|
|
@@ -771,3 +803,33 @@ function mapBuilderBindingsToMitosisBindingWithCode(bindings) {
|
|
|
771
803
|
});
|
|
772
804
|
return result;
|
|
773
805
|
}
|
|
806
|
+
function removeFalsey(obj) {
|
|
807
|
+
return (0, lodash_1.omitBy)(obj, function (value) { return !value || value === '0' || value === '0px' || value === 'none' || value === '0%'; });
|
|
808
|
+
}
|
|
809
|
+
function combineStyles(parent, child) {
|
|
810
|
+
var marginStyles = ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'];
|
|
811
|
+
var paddingStyles = ['paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight'];
|
|
812
|
+
var distanceStylesToCombine = __spreadArray(__spreadArray([], paddingStyles, true), marginStyles, true);
|
|
813
|
+
var merged = __assign(__assign({}, (0, lodash_1.omit)(removeFalsey(child), distanceStylesToCombine)), removeFalsey(parent));
|
|
814
|
+
for (var _i = 0, distanceStylesToCombine_1 = distanceStylesToCombine; _i < distanceStylesToCombine_1.length; _i++) {
|
|
815
|
+
var key = distanceStylesToCombine_1[_i];
|
|
816
|
+
// Funky things happen if different alignment
|
|
817
|
+
if (parent.alignSelf !== child.alignSelf && (key === 'marginLeft' || key === 'marginRight')) {
|
|
818
|
+
merged[key] = parent[key];
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
var childNum = parseFloat(child[key]) || 0;
|
|
822
|
+
var parentKeyToUse = key.replace(/margin/, 'padding');
|
|
823
|
+
var parentNum = parseFloat(parent[parentKeyToUse]) || 0;
|
|
824
|
+
if (childNum || parentNum) {
|
|
825
|
+
merged[parentKeyToUse] = "".concat(childNum + parentNum, "px");
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
for (var _a = 0, _b = Object.entries(merged); _a < _b.length; _a++) {
|
|
829
|
+
var _c = _b[_a], key = _c[0], value = _c[1];
|
|
830
|
+
if (value && typeof value === 'object') {
|
|
831
|
+
merged[key] = combineStyles(parent[key] || {}, child[key] || {});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
return merged;
|
|
835
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type Plugin } from '@builder.io/mitosis';
|
|
1
2
|
import { TraverseContext } from 'traverse';
|
|
2
|
-
import { Plugin } from '..';
|
|
3
3
|
import { MitosisComponent } from '../types/mitosis-component';
|
|
4
4
|
import { MitosisNode } from '../types/mitosis-node';
|
|
5
5
|
declare type CompileAwayComponentsMap = {
|
|
@@ -10,29 +10,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
13
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
14
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
15
|
if (ar || !(i in from)) {
|
|
@@ -47,8 +24,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
47
24
|
};
|
|
48
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
26
|
exports.compileAwayBuilderComponents = exports.compileAwayBuilderComponentsFromTree = exports.components = void 0;
|
|
50
|
-
var
|
|
51
|
-
var json5_1 =
|
|
27
|
+
var sdk_1 = require("@builder.io/sdk");
|
|
28
|
+
var json5_1 = __importDefault(require("json5"));
|
|
52
29
|
var lodash_1 = require("lodash");
|
|
53
30
|
var traverse_1 = __importDefault(require("traverse"));
|
|
54
31
|
var bindings_1 = require("../helpers/bindings");
|
|
@@ -56,9 +33,17 @@ var create_mitosis_node_1 = require("../helpers/create-mitosis-node");
|
|
|
56
33
|
var filter_empty_text_nodes_1 = require("../helpers/filter-empty-text-nodes");
|
|
57
34
|
var is_mitosis_node_1 = require("../helpers/is-mitosis-node");
|
|
58
35
|
var builder_1 = require("../parsers/builder");
|
|
36
|
+
var getCssFromNode = function (node) {
|
|
37
|
+
var _a;
|
|
38
|
+
var css = (_a = node.bindings.css) === null || _a === void 0 ? void 0 : _a.code;
|
|
39
|
+
if (css) {
|
|
40
|
+
return json5_1.default.parse(css);
|
|
41
|
+
}
|
|
42
|
+
return {};
|
|
43
|
+
};
|
|
59
44
|
function getComponentInputNames(componentName) {
|
|
60
45
|
var _a;
|
|
61
|
-
var componentInfo =
|
|
46
|
+
var componentInfo = sdk_1.Builder.components.find(function (item) { return item.name === componentName; });
|
|
62
47
|
return ((_a = componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.inputs) === null || _a === void 0 ? void 0 : _a.map(function (item) { return item.name; })) || [];
|
|
63
48
|
}
|
|
64
49
|
var wrapOutput = function (node, child, components) {
|
|
@@ -122,7 +107,7 @@ exports.components = {
|
|
|
122
107
|
BuilderAccordion: function (node, context, components) {
|
|
123
108
|
var _a;
|
|
124
109
|
var itemsJSON = ((_a = node.bindings.items) === null || _a === void 0 ? void 0 : _a.code) || '[]';
|
|
125
|
-
var accordionItems =
|
|
110
|
+
var accordionItems = json5_1.default.parse(itemsJSON);
|
|
126
111
|
var children = accordionItems.map(function (accordionItem) {
|
|
127
112
|
var titleChildren = accordionItem.title.map(function (element) {
|
|
128
113
|
return (0, builder_1.builderElementToMitosisNode)(element, {
|
|
@@ -198,6 +183,7 @@ exports.components = {
|
|
|
198
183
|
},
|
|
199
184
|
CoreSection: function (node, context, components) {
|
|
200
185
|
var _a, _b;
|
|
186
|
+
var css = getCssFromNode(node);
|
|
201
187
|
return wrapOutput(node, (0, create_mitosis_node_1.createMitosisNode)({
|
|
202
188
|
name: 'section',
|
|
203
189
|
properties: __assign(__assign(__assign({}, node.properties), { $name: 'section' }), (((_a = node.bindings.lazyLoad) === null || _a === void 0 ? void 0 : _a.code) === 'true' && {
|
|
@@ -205,18 +191,7 @@ exports.components = {
|
|
|
205
191
|
})),
|
|
206
192
|
bindings: {
|
|
207
193
|
css: (0, bindings_1.createSingleBinding)({
|
|
208
|
-
code: JSON.stringify({
|
|
209
|
-
width: '100%',
|
|
210
|
-
alignSelf: 'stretch',
|
|
211
|
-
flexGrow: '1',
|
|
212
|
-
boxSizing: 'border-box',
|
|
213
|
-
maxWidth: "".concat((((_b = node.bindings.maxWidth) === null || _b === void 0 ? void 0 : _b.code) && Number(node.bindings.maxWidth.code)) || 1200, "px"),
|
|
214
|
-
display: 'flex',
|
|
215
|
-
flexDirection: 'column',
|
|
216
|
-
alignItems: 'stretch',
|
|
217
|
-
marginLeft: 'auto',
|
|
218
|
-
marginRight: 'auto',
|
|
219
|
-
}),
|
|
194
|
+
code: JSON.stringify(__assign(__assign({}, css), { width: '100%', alignSelf: 'stretch', flexGrow: '1', boxSizing: 'border-box', maxWidth: "".concat((((_b = node.bindings.maxWidth) === null || _b === void 0 ? void 0 : _b.code) && Number(node.bindings.maxWidth.code)) || 1200, "px"), display: 'flex', flexDirection: 'column', alignItems: 'stretch', marginLeft: 'auto', marginRight: 'auto' })),
|
|
220
195
|
}),
|
|
221
196
|
},
|
|
222
197
|
children: node.children,
|
|
@@ -236,25 +211,22 @@ exports.components = {
|
|
|
236
211
|
return (columns[index] && columns[index].width) || 100 / columns.length;
|
|
237
212
|
}
|
|
238
213
|
function getColumnWidth(index) {
|
|
239
|
-
|
|
240
|
-
return "calc(".concat(getWidth(index), "% - ").concat(subtractWidth, "px)");
|
|
214
|
+
return "".concat(Math.round(getWidth(index)), "%");
|
|
241
215
|
}
|
|
242
216
|
var properties = node.properties;
|
|
243
217
|
return wrapOutput(node, (0, create_mitosis_node_1.createMitosisNode)({
|
|
244
218
|
name: 'div',
|
|
245
|
-
properties: {
|
|
246
|
-
class: 'builder-columns',
|
|
247
|
-
},
|
|
248
219
|
bindings: {
|
|
249
220
|
css: (0, bindings_1.createSingleBinding)({
|
|
250
|
-
code: JSON.stringify(__assign({ display: 'flex' }, (properties.stackColumnsAt === 'never'
|
|
221
|
+
code: JSON.stringify(__assign({ gap: "".concat(gutterSize, "px"), display: 'flex' }, (properties.stackColumnsAt === 'never'
|
|
251
222
|
? {}
|
|
252
223
|
: (_a = {},
|
|
253
|
-
_a["@media (max-width: ".concat(properties.stackColumnsAt
|
|
224
|
+
_a["@media (max-width: ".concat(properties.stackColumnsAt === 'mobile' ? 640 : 991, "px)")] = {
|
|
254
225
|
flexDirection: properties.reverseColumnsWhenStacked === 'true'
|
|
255
226
|
? 'column-reverse'
|
|
256
227
|
: 'column',
|
|
257
228
|
alignItems: 'stretch',
|
|
229
|
+
gap: "0px",
|
|
258
230
|
},
|
|
259
231
|
_a)))),
|
|
260
232
|
}),
|
|
@@ -265,14 +237,13 @@ exports.components = {
|
|
|
265
237
|
name: 'div',
|
|
266
238
|
properties: {
|
|
267
239
|
$name: 'column',
|
|
268
|
-
class: 'builder-column',
|
|
269
240
|
},
|
|
270
241
|
bindings: {
|
|
271
242
|
css: (0, bindings_1.createSingleBinding)({
|
|
272
243
|
code: JSON.stringify(__assign({ display: 'flex', flexDirection: 'column', alignItems: 'stretch', lineHeight: 'normal', width: "".concat(getColumnWidth(index)), marginLeft: "".concat(index === 0 ? 0 : gutterSize, "px") }, (properties.stackColumnsAt === 'never'
|
|
273
244
|
? {}
|
|
274
245
|
: (_a = {},
|
|
275
|
-
_a["@media (max-width: ".concat(properties.stackColumnsAt
|
|
246
|
+
_a["@media (max-width: ".concat(properties.stackColumnsAt === 'mobile' ? 640 : 991, "px)")] = {
|
|
276
247
|
width: '100%',
|
|
277
248
|
marginLeft: 0,
|
|
278
249
|
},
|
|
@@ -296,107 +267,57 @@ exports.components = {
|
|
|
296
267
|
}
|
|
297
268
|
var image = node.properties.image;
|
|
298
269
|
var srcSet = srcset || generateBuilderIoSrcSet(image);
|
|
299
|
-
var
|
|
300
|
-
|
|
301
|
-
name: 'source',
|
|
302
|
-
properties: {
|
|
303
|
-
srcset: srcSet.replace(/\?/g, '?format=webp&'),
|
|
304
|
-
type: 'image/webp',
|
|
305
|
-
},
|
|
306
|
-
});
|
|
270
|
+
var css = getCssFromNode(node);
|
|
271
|
+
var noWebp = ((_b = node.bindings.noWebp) === null || _b === void 0 ? void 0 : _b.code) === 'true';
|
|
307
272
|
var img = (0, create_mitosis_node_1.createMitosisNode)({
|
|
308
273
|
name: 'img',
|
|
309
|
-
properties: noUndefined({
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
274
|
+
properties: noUndefined(__assign({ loading: 'lazy', sizes: node.properties.sizes, alt: node.properties.altText }, (noWebp
|
|
275
|
+
? {
|
|
276
|
+
src: image,
|
|
277
|
+
}
|
|
278
|
+
: {
|
|
279
|
+
srcSet: srcSet || null,
|
|
280
|
+
}))),
|
|
316
281
|
bindings: noUndefined({
|
|
317
282
|
src: ((_c = node.bindings.image) === null || _c === void 0 ? void 0 : _c.code) && { code: (_d = node.bindings.image) === null || _d === void 0 ? void 0 : _d.code },
|
|
318
283
|
sizes: ((_e = node.bindings.sizes) === null || _e === void 0 ? void 0 : _e.code) && { code: (_f = node.bindings.sizes) === null || _f === void 0 ? void 0 : _f.code },
|
|
319
284
|
css: (0, bindings_1.createSingleBinding)({
|
|
320
|
-
code: JSON.stringify(__assign({ objectFit: backgroundSize || 'cover', objectPosition: backgroundPosition || '
|
|
321
|
-
? {
|
|
322
|
-
position: 'absolute',
|
|
323
|
-
height: '100%',
|
|
324
|
-
width: '100%',
|
|
325
|
-
top: '0',
|
|
326
|
-
left: '0',
|
|
327
|
-
}
|
|
328
|
-
: {}))),
|
|
285
|
+
code: JSON.stringify(__assign(__assign({ aspectRatio: aspectRatio ? String((0, lodash_1.round)(1 / aspectRatio, 2)) : undefined, objectFit: backgroundSize || 'cover', objectPosition: backgroundPosition || 'center', width: '100%' }, css), { display: undefined, flexDirection: undefined, position: css.position === 'relative' ? undefined : css.position })),
|
|
329
286
|
}),
|
|
330
287
|
}),
|
|
331
288
|
});
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
children: source ? [source, img] : [img],
|
|
335
|
-
});
|
|
336
|
-
var imgSizer = aspectRatio &&
|
|
337
|
-
(0, create_mitosis_node_1.createMitosisNode)({
|
|
338
|
-
name: 'div',
|
|
339
|
-
properties: {
|
|
340
|
-
$name: 'image-sizer',
|
|
341
|
-
class: 'builder-image-sizer',
|
|
342
|
-
},
|
|
343
|
-
bindings: {
|
|
344
|
-
css: (0, bindings_1.createSingleBinding)({
|
|
345
|
-
code: JSON.stringify({
|
|
346
|
-
width: '100%',
|
|
347
|
-
paddingTop: aspectRatio * 100 + '%',
|
|
348
|
-
pointerEvents: 'none',
|
|
349
|
-
fontSize: '0',
|
|
350
|
-
}),
|
|
351
|
-
}),
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
var children = node.children &&
|
|
355
|
-
node.children.length &&
|
|
356
|
-
(0, create_mitosis_node_1.createMitosisNode)({
|
|
357
|
-
name: 'div',
|
|
358
|
-
properties: {
|
|
359
|
-
$name: 'image-contents',
|
|
360
|
-
},
|
|
361
|
-
bindings: {
|
|
362
|
-
css: (0, bindings_1.createSingleBinding)({
|
|
363
|
-
code: JSON.stringify({
|
|
364
|
-
display: 'flex',
|
|
365
|
-
flexDirection: 'column',
|
|
366
|
-
alignItems: 'stretch',
|
|
367
|
-
position: 'absolute',
|
|
368
|
-
top: '0',
|
|
369
|
-
left: '0',
|
|
370
|
-
width: '100%',
|
|
371
|
-
height: '100%',
|
|
372
|
-
}),
|
|
373
|
-
}),
|
|
374
|
-
},
|
|
375
|
-
children: node.children,
|
|
376
|
-
});
|
|
377
|
-
var imageNodes = [picture];
|
|
378
|
-
imgSizer && imageNodes.push(imgSizer);
|
|
379
|
-
children && imageNodes.push(children);
|
|
380
|
-
var href = node.properties.href;
|
|
381
|
-
var hrefBinding = (_g = node.bindings.href) === null || _g === void 0 ? void 0 : _g.code;
|
|
382
|
-
if (href || hrefBinding) {
|
|
383
|
-
var aHref = (0, create_mitosis_node_1.createMitosisNode)({
|
|
384
|
-
name: 'a',
|
|
385
|
-
properties: {
|
|
386
|
-
href: href,
|
|
387
|
-
},
|
|
388
|
-
bindings: hrefBinding
|
|
389
|
-
? {
|
|
390
|
-
href: (0, bindings_1.createSingleBinding)({ code: hrefBinding }),
|
|
391
|
-
}
|
|
392
|
-
: undefined,
|
|
393
|
-
children: imageNodes,
|
|
394
|
-
});
|
|
395
|
-
return wrapOutput(node, aHref, components);
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
return wrapOutput(node, imageNodes, components);
|
|
289
|
+
if (!((_g = node.children) === null || _g === void 0 ? void 0 : _g.length)) {
|
|
290
|
+
return img;
|
|
399
291
|
}
|
|
292
|
+
// TODO: deal with links: anchor tag and href
|
|
293
|
+
var root = (0, create_mitosis_node_1.createMitosisNode)({
|
|
294
|
+
name: 'div',
|
|
295
|
+
bindings: noUndefined({
|
|
296
|
+
css: (0, bindings_1.createSingleBinding)({
|
|
297
|
+
code: JSON.stringify(__assign(__assign({ disply: 'flex', flexDirection: 'column' }, css), { position: 'relative' })),
|
|
298
|
+
}),
|
|
299
|
+
}),
|
|
300
|
+
children: __spreadArray([
|
|
301
|
+
__assign(__assign({}, img), { bindings: __assign(__assign({}, img.bindings), { css: (0, bindings_1.createSingleBinding)({
|
|
302
|
+
code: JSON.stringify({
|
|
303
|
+
position: 'absolute',
|
|
304
|
+
inset: 0,
|
|
305
|
+
zIndex: -1,
|
|
306
|
+
height: '100%',
|
|
307
|
+
width: '100%',
|
|
308
|
+
objectFit: backgroundSize || 'cover',
|
|
309
|
+
objectPosition: backgroundPosition || 'center',
|
|
310
|
+
}),
|
|
311
|
+
}) }) })
|
|
312
|
+
], node.children.map(function (child) {
|
|
313
|
+
var newChild = __assign(__assign({}, child), { bindings: __assign(__assign({}, child.bindings), { css: (0, bindings_1.createSingleBinding)({
|
|
314
|
+
code: JSON.stringify(__assign({ position: 'relative' }, getCssFromNode(child))),
|
|
315
|
+
}) }) });
|
|
316
|
+
(0, exports.compileAwayBuilderComponentsFromTree)(newChild, components);
|
|
317
|
+
return newChild;
|
|
318
|
+
}), true),
|
|
319
|
+
});
|
|
320
|
+
return root;
|
|
400
321
|
},
|
|
401
322
|
Video: function (node, context, components) {
|
|
402
323
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
@@ -407,10 +328,10 @@ exports.components = {
|
|
|
407
328
|
aspectRatio = null;
|
|
408
329
|
}
|
|
409
330
|
var videoContainerNodes = [];
|
|
331
|
+
var css = getCssFromNode(node);
|
|
410
332
|
videoContainerNodes.push((0, create_mitosis_node_1.createMitosisNode)({
|
|
411
333
|
name: 'video',
|
|
412
334
|
properties: noUndefined({
|
|
413
|
-
$name: 'builder-video',
|
|
414
335
|
poster: node.properties.posterImage,
|
|
415
336
|
autoplay: node.properties.autoPlay,
|
|
416
337
|
muted: node.properties.muted,
|
|
@@ -437,14 +358,7 @@ exports.components = {
|
|
|
437
358
|
},
|
|
438
359
|
loop: ((_m = node.bindings.loop) === null || _m === void 0 ? void 0 : _m.code) && { code: (_o = node.bindings.loop) === null || _o === void 0 ? void 0 : _o.code },
|
|
439
360
|
css: (0, bindings_1.createSingleBinding)({
|
|
440
|
-
code: JSON.stringify({
|
|
441
|
-
width: '100%',
|
|
442
|
-
height: '100%',
|
|
443
|
-
objectFit: node.properties.fit,
|
|
444
|
-
objectPosition: node.properties.position,
|
|
445
|
-
borderRadius: '1',
|
|
446
|
-
position: aspectRatio ? 'absolute' : '',
|
|
447
|
-
}),
|
|
361
|
+
code: JSON.stringify(__assign({ width: '100%', height: '100%', objectFit: node.properties.fit, objectPosition: node.properties.position, borderRadius: '1', position: aspectRatio ? 'absolute' : '' }, css)),
|
|
448
362
|
}),
|
|
449
363
|
}),
|
|
450
364
|
children: [
|
|
@@ -465,9 +379,6 @@ exports.components = {
|
|
|
465
379
|
aspectRatio &&
|
|
466
380
|
videoContainerNodes.push((0, create_mitosis_node_1.createMitosisNode)({
|
|
467
381
|
name: 'div',
|
|
468
|
-
properties: {
|
|
469
|
-
$name: 'builder-video-sizer',
|
|
470
|
-
},
|
|
471
382
|
bindings: {
|
|
472
383
|
css: (0, bindings_1.createSingleBinding)({
|
|
473
384
|
code: JSON.stringify({
|
|
@@ -483,9 +394,6 @@ exports.components = {
|
|
|
483
394
|
node.children.length &&
|
|
484
395
|
videoContainerNodes.push((0, create_mitosis_node_1.createMitosisNode)({
|
|
485
396
|
name: 'div',
|
|
486
|
-
properties: {
|
|
487
|
-
$name: 'image-contents',
|
|
488
|
-
},
|
|
489
397
|
bindings: {
|
|
490
398
|
css: (0, bindings_1.createSingleBinding)({
|
|
491
399
|
code: JSON.stringify({
|
|
@@ -504,9 +412,6 @@ exports.components = {
|
|
|
504
412
|
}));
|
|
505
413
|
var videoContainer = (0, create_mitosis_node_1.createMitosisNode)({
|
|
506
414
|
name: 'div',
|
|
507
|
-
properties: {
|
|
508
|
-
$name: 'video-container',
|
|
509
|
-
},
|
|
510
415
|
bindings: {
|
|
511
416
|
css: (0, bindings_1.createSingleBinding)({ code: JSON.stringify({ position: 'relative' }) }),
|
|
512
417
|
},
|