@builder.io/mitosis 0.4.0 → 0.4.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.
- package/dist/src/constants/media-sizes.js +4 -5
- package/dist/src/generators/alpine/generate.js +114 -132
- package/dist/src/generators/alpine/render-mount-hook.js +8 -5
- package/dist/src/generators/alpine/render-update-hooks.js +13 -13
- package/dist/src/generators/angular/helpers.js +19 -9
- package/dist/src/generators/angular/index.js +599 -584
- package/dist/src/generators/builder.js +200 -165
- package/dist/src/generators/context/angular.js +32 -26
- package/dist/src/generators/context/helpers/context-with-symbol-key.js +25 -21
- package/dist/src/generators/context/qwik.js +21 -21
- package/dist/src/generators/context/react.js +22 -22
- package/dist/src/generators/context/rsc.js +20 -22
- package/dist/src/generators/context/solid.js +22 -22
- package/dist/src/generators/context/svelte.js +33 -28
- package/dist/src/generators/context/vue.js +1 -1
- package/dist/src/generators/helpers/context.js +6 -13
- package/dist/src/generators/helpers/functions.js +8 -8
- package/dist/src/generators/helpers/on-mount.js +9 -5
- package/dist/src/generators/helpers/rsc.js +7 -9
- package/dist/src/generators/html.js +995 -534
- package/dist/src/generators/liquid.js +81 -79
- package/dist/src/generators/lit/collect-class-string.js +10 -12
- package/dist/src/generators/lit/generate.js +204 -159
- package/dist/src/generators/marko/generate.js +193 -183
- package/dist/src/generators/minify.js +5 -9
- package/dist/src/generators/mitosis.js +135 -134
- package/dist/src/generators/qwik/component-generator.js +159 -154
- package/dist/src/generators/qwik/component.js +51 -81
- package/dist/src/generators/qwik/directives.js +68 -84
- package/dist/src/generators/qwik/helpers/add-prevent-default.js +6 -7
- package/dist/src/generators/qwik/helpers/convert-method-to-function.js +38 -38
- package/dist/src/generators/qwik/helpers/handlers.js +16 -25
- package/dist/src/generators/qwik/helpers/stable-inject.js +7 -8
- package/dist/src/generators/qwik/helpers/stable-serialize.js +7 -8
- package/dist/src/generators/qwik/helpers/state.js +36 -43
- package/dist/src/generators/qwik/helpers/styles.js +19 -40
- package/dist/src/generators/qwik/jsx.js +63 -75
- package/dist/src/generators/qwik/src-generator.js +134 -167
- package/dist/src/generators/react/blocks.js +122 -127
- package/dist/src/generators/react/generator.js +314 -259
- package/dist/src/generators/react/helpers.js +23 -28
- package/dist/src/generators/react/state.js +34 -51
- package/dist/src/generators/react-native/index.js +72 -84
- package/dist/src/generators/react-native/sanitize-react-native-block-styles.js +14 -26
- package/dist/src/generators/rsc.js +30 -36
- package/dist/src/generators/solid/blocks.js +46 -43
- package/dist/src/generators/solid/helpers/styles.js +11 -11
- package/dist/src/generators/solid/index.js +199 -190
- package/dist/src/generators/solid/state/helpers.js +76 -90
- package/dist/src/generators/solid/state/signals.js +30 -37
- package/dist/src/generators/solid/state/state.js +35 -48
- package/dist/src/generators/solid/state/store.js +40 -46
- package/dist/src/generators/stencil/collect-class-string.js +10 -12
- package/dist/src/generators/stencil/generate.js +158 -145
- package/dist/src/generators/svelte/blocks.js +146 -144
- package/dist/src/generators/svelte/helpers.js +10 -17
- package/dist/src/generators/svelte/svelte.js +321 -287
- package/dist/src/generators/swift-ui.js +162 -101
- package/dist/src/generators/taro.js +32 -36
- package/dist/src/generators/template.js +71 -74
- package/dist/src/generators/vue/blocks.js +116 -107
- package/dist/src/generators/vue/compositionApi.js +67 -50
- package/dist/src/generators/vue/helpers.js +71 -96
- package/dist/src/generators/vue/optionsApi.js +134 -105
- package/dist/src/generators/vue/vue.js +210 -207
- package/dist/src/helpers/babel-transform.js +40 -63
- package/dist/src/helpers/bindings.js +4 -12
- package/dist/src/helpers/camel-case.js +4 -5
- package/dist/src/helpers/capitalize.js +1 -1
- package/dist/src/helpers/component-file-extensions.js +23 -35
- package/dist/src/helpers/create-mitosis-component.js +22 -26
- package/dist/src/helpers/create-mitosis-context.js +5 -12
- package/dist/src/helpers/create-mitosis-node.js +10 -12
- package/dist/src/helpers/dash-case.js +2 -2
- package/dist/src/helpers/dedent.js +18 -22
- package/dist/src/helpers/event-handlers.js +1 -1
- package/dist/src/helpers/fast-clone.js +1 -1
- package/dist/src/helpers/filter-empty-text-nodes.js +2 -2
- package/dist/src/helpers/generic-format.js +7 -8
- package/dist/src/helpers/get-bindings.js +4 -4
- package/dist/src/helpers/get-components-used.js +3 -3
- package/dist/src/helpers/get-components.js +4 -4
- package/dist/src/helpers/get-custom-imports.js +10 -12
- package/dist/src/helpers/get-prop-functions.js +7 -8
- package/dist/src/helpers/get-props-ref.js +8 -8
- package/dist/src/helpers/get-props.js +12 -13
- package/dist/src/helpers/get-refs.js +4 -4
- package/dist/src/helpers/get-state-object-string.js +42 -61
- package/dist/src/helpers/get-state-used.js +7 -8
- package/dist/src/helpers/get-styles.js +6 -6
- package/dist/src/helpers/getters-to-functions.js +8 -12
- package/dist/src/helpers/handle-missing-state.js +3 -3
- package/dist/src/helpers/has-bindings-text.js +6 -6
- package/dist/src/helpers/has-component.js +4 -4
- package/dist/src/helpers/has-props.js +3 -3
- package/dist/src/helpers/has-stateful-dom.js +4 -4
- package/dist/src/helpers/has.js +3 -3
- package/dist/src/helpers/indent.js +2 -3
- package/dist/src/helpers/is-children.js +4 -5
- package/dist/src/helpers/is-component.js +1 -1
- package/dist/src/helpers/is-html-attribute.js +2 -11
- package/dist/src/helpers/is-mitosis-node.js +1 -1
- package/dist/src/helpers/is-root-text-node.js +1 -1
- package/dist/src/helpers/is-upper-case.js +1 -1
- package/dist/src/helpers/is-valid-attribute-name.js +1 -1
- package/dist/src/helpers/json.js +2 -2
- package/dist/src/helpers/map-refs.js +29 -40
- package/dist/src/helpers/merge-options.js +20 -31
- package/dist/src/helpers/mitosis-imports.js +5 -6
- package/dist/src/helpers/nodes/for.js +2 -3
- package/dist/src/helpers/nullable.js +1 -3
- package/dist/src/helpers/on-event.js +32 -36
- package/dist/src/helpers/output.js +4 -5
- package/dist/src/helpers/parse-node.js +13 -5
- package/dist/src/helpers/parsers.js +10 -14
- package/dist/src/helpers/patterns.js +6 -8
- package/dist/src/helpers/plugins/process-code/index.js +114 -120
- package/dist/src/helpers/plugins/process-signals.js +114 -125
- package/dist/src/helpers/plugins/process-target-blocks.js +18 -20
- package/dist/src/helpers/process-http-requests.js +8 -4
- package/dist/src/helpers/remove-surrounding-block.js +2 -2
- package/dist/src/helpers/render-imports.js +99 -111
- package/dist/src/helpers/replace-identifiers.js +40 -49
- package/dist/src/helpers/replace-new-lines-in-strings.js +3 -3
- package/dist/src/helpers/signals/signals.js +27 -35
- package/dist/src/helpers/slots.js +11 -20
- package/dist/src/helpers/state.js +1 -3
- package/dist/src/helpers/strip-meta-properties.js +6 -6
- package/dist/src/helpers/strip-state-and-props-refs.js +21 -32
- package/dist/src/helpers/styles/collect-css.js +39 -44
- package/dist/src/helpers/styles/collect-styled-components.js +30 -28
- package/dist/src/helpers/styles/helpers.js +23 -29
- package/dist/src/helpers/trace-reference-to-module-path.js +3 -4
- package/dist/src/helpers/transform-state-setters.js +16 -19
- package/dist/src/helpers/traverse-nodes.js +2 -2
- package/dist/src/helpers/try-prettier-format.js +3 -3
- package/dist/src/helpers/typescript-project.js +25 -25
- package/dist/src/helpers/typescript.js +1 -3
- package/dist/src/modules/plugins.js +20 -28
- package/dist/src/parsers/angular.js +49 -57
- package/dist/src/parsers/builder/builder.js +448 -343
- package/dist/src/parsers/builder/helpers.js +10 -10
- package/dist/src/parsers/context.js +15 -17
- package/dist/src/parsers/jsx/ast.js +11 -11
- package/dist/src/parsers/jsx/component-types.js +22 -32
- package/dist/src/parsers/jsx/context.js +12 -12
- package/dist/src/parsers/jsx/element-parser.js +43 -54
- package/dist/src/parsers/jsx/exports.js +12 -14
- package/dist/src/parsers/jsx/function-parser.js +108 -119
- package/dist/src/parsers/jsx/helpers.js +11 -13
- package/dist/src/parsers/jsx/hooks/helpers.js +14 -16
- package/dist/src/parsers/jsx/hooks/index.js +34 -44
- package/dist/src/parsers/jsx/hooks/use-target.js +27 -27
- package/dist/src/parsers/jsx/imports.js +7 -17
- package/dist/src/parsers/jsx/jsx.js +92 -91
- package/dist/src/parsers/jsx/props-types.js +8 -10
- package/dist/src/parsers/jsx/props.js +15 -23
- package/dist/src/parsers/jsx/signals.js +28 -29
- package/dist/src/parsers/jsx/state.d.ts +2 -4
- package/dist/src/parsers/jsx/state.js +59 -93
- package/dist/src/parsers/svelte/css/index.js +1 -1
- package/dist/src/parsers/svelte/helpers/bindings.js +18 -19
- package/dist/src/parsers/svelte/helpers/children.js +5 -6
- package/dist/src/parsers/svelte/helpers/expressions.js +7 -9
- package/dist/src/parsers/svelte/helpers/hooks.js +2 -2
- package/dist/src/parsers/svelte/helpers/post-process.js +49 -70
- package/dist/src/parsers/svelte/helpers/string.js +5 -5
- package/dist/src/parsers/svelte/html/actions.js +17 -10
- package/dist/src/parsers/svelte/html/each.js +11 -16
- package/dist/src/parsers/svelte/html/element.js +68 -78
- package/dist/src/parsers/svelte/html/fragment.js +3 -3
- package/dist/src/parsers/svelte/html/if-else.js +11 -18
- package/dist/src/parsers/svelte/html/index.js +14 -14
- package/dist/src/parsers/svelte/html/mustache-tag.js +5 -5
- package/dist/src/parsers/svelte/html/slot.js +5 -5
- package/dist/src/parsers/svelte/html/text.js +7 -14
- package/dist/src/parsers/svelte/index.js +23 -72
- package/dist/src/parsers/svelte/instance/context.js +17 -17
- package/dist/src/parsers/svelte/instance/expressions.js +2 -2
- package/dist/src/parsers/svelte/instance/functions.js +35 -30
- package/dist/src/parsers/svelte/instance/hooks.js +4 -5
- package/dist/src/parsers/svelte/instance/imports.js +11 -21
- package/dist/src/parsers/svelte/instance/index.js +22 -22
- package/dist/src/parsers/svelte/instance/properties.js +11 -23
- package/dist/src/parsers/svelte/instance/reactive.js +11 -11
- package/dist/src/parsers/svelte/instance/references.js +13 -13
- package/dist/src/parsers/svelte/instance/statements.js +3 -3
- package/dist/src/parsers/svelte/module/index.js +14 -26
- package/dist/src/parsers/svelte/typescript/index.js +27 -36
- package/dist/src/plugins/compile-away-builder-components.js +223 -156
- package/dist/src/plugins/compile-away-components.js +13 -21
- package/dist/src/plugins/map-styles.js +7 -7
- package/dist/src/symbols/symbol-processor.js +44 -62
- package/dist/src/targets.js +19 -19
- package/dist/src/types/mitosis-node.js +1 -1
- package/package.json +1 -1
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
6
|
exports.componentToRsc = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
8
|
+
const is_mitosis_node_1 = require("../helpers/is-mitosis-node");
|
|
9
|
+
const merge_options_1 = require("../helpers/merge-options");
|
|
10
|
+
const nullable_1 = require("../helpers/nullable");
|
|
11
|
+
const rsc_1 = require("./helpers/rsc");
|
|
12
|
+
const react_1 = require("./react");
|
|
24
13
|
/**
|
|
25
14
|
* Transform react to be RSC compatible, such as
|
|
26
15
|
* - remove event listeners
|
|
@@ -28,18 +17,18 @@ var react_1 = require("./react");
|
|
|
28
17
|
* - remove refs
|
|
29
18
|
* - transform context to prop drilling
|
|
30
19
|
*/
|
|
31
|
-
|
|
20
|
+
const RSC_TRANSFORM_PLUGIN = () => ({
|
|
32
21
|
json: {
|
|
33
|
-
pre:
|
|
22
|
+
pre: (json) => {
|
|
34
23
|
json.hooks.onMount = [];
|
|
35
24
|
delete json.hooks.onUnMount;
|
|
36
25
|
delete json.hooks.onUpdate;
|
|
37
26
|
json.refs = {};
|
|
38
27
|
json.context.get = {};
|
|
39
28
|
json.context.set = {};
|
|
40
|
-
(0, legacy_1.default)(json).forEach(
|
|
29
|
+
(0, legacy_1.default)(json).forEach((node) => {
|
|
41
30
|
if ((0, is_mitosis_node_1.isMitosisNode)(node)) {
|
|
42
|
-
|
|
31
|
+
const isComponent = node.name.match(/[A-Z]/);
|
|
43
32
|
// if (isComponent) {
|
|
44
33
|
// // Drill context down, aka
|
|
45
34
|
// // function (props) { return <Component _context{props._context} /> }
|
|
@@ -61,23 +50,28 @@ var RSC_TRANSFORM_PLUGIN = function () { return ({
|
|
|
61
50
|
});
|
|
62
51
|
},
|
|
63
52
|
},
|
|
64
|
-
});
|
|
65
|
-
|
|
53
|
+
});
|
|
54
|
+
const RscOptions = {
|
|
66
55
|
plugins: [RSC_TRANSFORM_PLUGIN],
|
|
67
56
|
stateType: 'variables',
|
|
68
57
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
58
|
+
const componentToRsc = (_options = {}) => ({ component, path }) => {
|
|
59
|
+
var _a, _b, _c, _d, _e;
|
|
60
|
+
if (!(0, nullable_1.checkIsDefined)((_b = (_a = component.meta.useMetadata) === null || _a === void 0 ? void 0 : _a.rsc) === null || _b === void 0 ? void 0 : _b.componentType) &&
|
|
61
|
+
!(0, rsc_1.checkIfIsClientComponent)(component)) {
|
|
62
|
+
component.meta.useMetadata = {
|
|
63
|
+
...component.meta.useMetadata,
|
|
64
|
+
rsc: {
|
|
65
|
+
...(_c = component.meta.useMetadata) === null || _c === void 0 ? void 0 : _c.rsc,
|
|
66
|
+
componentType: 'server',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const isRSC = ((_e = (_d = component.meta.useMetadata) === null || _d === void 0 ? void 0 : _d.rsc) === null || _e === void 0 ? void 0 : _e.componentType) === 'server';
|
|
71
|
+
const options = (0, merge_options_1.mergeOptions)({
|
|
72
|
+
rsc: true,
|
|
73
|
+
...(isRSC ? RscOptions : {}),
|
|
74
|
+
}, _options);
|
|
75
|
+
return (0, react_1.componentToReact)(options)({ component, path });
|
|
82
76
|
};
|
|
83
77
|
exports.componentToRsc = componentToRsc;
|
|
@@ -1,74 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blockToSolid = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
const babel_transform_1 = require("../../helpers/babel-transform");
|
|
5
|
+
const filter_empty_text_nodes_1 = require("../../helpers/filter-empty-text-nodes");
|
|
6
|
+
const typescript_1 = require("../../helpers/typescript");
|
|
7
|
+
const mitosis_node_1 = require("../../types/mitosis-node");
|
|
8
|
+
const core_1 = require("@babel/core");
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
const html_tags_1 = require("../../constants/html_tags");
|
|
11
|
+
const styles_1 = require("./helpers/styles");
|
|
12
|
+
const ATTTRIBUTE_MAPPERS = {
|
|
13
13
|
// for: 'htmlFor',
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
const transformAttributeName = (name) => {
|
|
16
16
|
if ((0, typescript_1.objectHasKey)(ATTTRIBUTE_MAPPERS, name))
|
|
17
17
|
return ATTTRIBUTE_MAPPERS[name];
|
|
18
18
|
return name;
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
var json = _a.json, options = _a.options, component = _a.component;
|
|
20
|
+
const blockToSolid = ({ json, options, component, }) => {
|
|
21
|
+
var _a, _b;
|
|
23
22
|
if (json.properties._text) {
|
|
24
23
|
return json.properties._text;
|
|
25
24
|
}
|
|
26
|
-
if ((
|
|
27
|
-
return
|
|
25
|
+
if ((_a = json.bindings._text) === null || _a === void 0 ? void 0 : _a.code) {
|
|
26
|
+
return `{${json.bindings._text.code}}`;
|
|
28
27
|
}
|
|
29
28
|
if ((0, mitosis_node_1.checkIsForNode)(json)) {
|
|
30
|
-
|
|
29
|
+
const needsWrapper = json.children.length !== 1;
|
|
31
30
|
// The SolidJS `<For>` component has a special index() signal function.
|
|
32
31
|
// https://www.solidjs.com/docs/latest#%3Cfor%3E
|
|
33
|
-
return
|
|
32
|
+
return `<For each={${(_b = json.bindings.each) === null || _b === void 0 ? void 0 : _b.code}}>
|
|
33
|
+
{(${json.scope.forName}, _index) => {
|
|
34
|
+
const ${json.scope.indexName || 'index'} = _index();
|
|
35
|
+
return ${needsWrapper ? '<>' : ''}${json.children
|
|
34
36
|
.filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
|
|
35
|
-
.map(
|
|
37
|
+
.map((child) => (0, exports.blockToSolid)({ component, json: child, options }))}}}
|
|
38
|
+
${needsWrapper ? '</>' : ''}
|
|
39
|
+
</For>`;
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
let str = '';
|
|
38
42
|
if (json.name === 'Fragment') {
|
|
39
43
|
str += '<';
|
|
40
44
|
}
|
|
41
45
|
else {
|
|
42
|
-
str +=
|
|
46
|
+
str += `<${json.name} `;
|
|
43
47
|
}
|
|
44
48
|
if (json.name === 'Show' && json.meta.else) {
|
|
45
|
-
str +=
|
|
49
|
+
str += `fallback={${(0, exports.blockToSolid)({ component, json: json.meta.else, options })}}`;
|
|
46
50
|
}
|
|
47
|
-
|
|
51
|
+
const classString = (0, styles_1.collectClassString)(json, options);
|
|
48
52
|
if (classString) {
|
|
49
|
-
str +=
|
|
53
|
+
str += ` class=${classString} `;
|
|
50
54
|
}
|
|
51
|
-
for (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
str +=
|
|
55
|
+
for (const key in json.properties) {
|
|
56
|
+
const value = json.properties[key];
|
|
57
|
+
const newKey = transformAttributeName(key);
|
|
58
|
+
str += ` ${newKey}="${value}" `;
|
|
55
59
|
}
|
|
56
|
-
for (
|
|
57
|
-
|
|
60
|
+
for (const key in json.bindings) {
|
|
61
|
+
const { code, arguments: cusArg = ['event'], type } = json.bindings[key];
|
|
58
62
|
if (!code)
|
|
59
63
|
continue;
|
|
60
64
|
if (type === 'spread') {
|
|
61
|
-
str +=
|
|
65
|
+
str += ` {...(${code})} `;
|
|
62
66
|
}
|
|
63
67
|
else if (key.startsWith('on')) {
|
|
64
|
-
|
|
65
|
-
str +=
|
|
68
|
+
const useKey = key === 'onChange' && json.name === 'input' ? 'onInput' : key;
|
|
69
|
+
str += ` ${useKey}={(${cusArg.join(',')}) => ${code}} `;
|
|
66
70
|
}
|
|
67
71
|
else if (key === 'ref' && options.typescript) {
|
|
68
|
-
str +=
|
|
72
|
+
str += ` ${key}={${code}!} `;
|
|
69
73
|
}
|
|
70
74
|
else {
|
|
71
|
-
|
|
75
|
+
let useValue = code;
|
|
72
76
|
if (key === 'style') {
|
|
73
77
|
// Convert camelCase keys to kebab-case
|
|
74
78
|
// TODO: support more than top level objects, may need
|
|
@@ -76,24 +80,23 @@ var blockToSolid = function (_a) {
|
|
|
76
80
|
// object literal, such as ternaries and other expression
|
|
77
81
|
// types
|
|
78
82
|
useValue = (0, babel_transform_1.babelTransformExpression)(code, {
|
|
79
|
-
ObjectExpression
|
|
83
|
+
ObjectExpression(path) {
|
|
80
84
|
// TODO: limit to top level objects only
|
|
81
|
-
for (
|
|
82
|
-
var property = _a[_i];
|
|
85
|
+
for (const property of path.node.properties) {
|
|
83
86
|
if (core_1.types.isObjectProperty(property)) {
|
|
84
87
|
if (core_1.types.isIdentifier(property.key) || core_1.types.isStringLiteral(property.key)) {
|
|
85
|
-
|
|
88
|
+
const key = core_1.types.isIdentifier(property.key)
|
|
86
89
|
? property.key.name
|
|
87
90
|
: property.key.value;
|
|
88
|
-
property.key = core_1.types.stringLiteral((0, lodash_1.kebabCase)(
|
|
91
|
+
property.key = core_1.types.stringLiteral((0, lodash_1.kebabCase)(key));
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
},
|
|
93
96
|
});
|
|
94
97
|
}
|
|
95
|
-
|
|
96
|
-
str +=
|
|
98
|
+
const newKey = transformAttributeName(key);
|
|
99
|
+
str += ` ${newKey}={${useValue}} `;
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
if (html_tags_1.SELF_CLOSING_HTML_TAGS.has(json.name)) {
|
|
@@ -103,14 +106,14 @@ var blockToSolid = function (_a) {
|
|
|
103
106
|
if (json.children) {
|
|
104
107
|
str += json.children
|
|
105
108
|
.filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
|
|
106
|
-
.map(
|
|
109
|
+
.map((item) => (0, exports.blockToSolid)({ component, json: item, options }))
|
|
107
110
|
.join('\n');
|
|
108
111
|
}
|
|
109
112
|
if (json.name === 'Fragment') {
|
|
110
113
|
str += '</>';
|
|
111
114
|
}
|
|
112
115
|
else {
|
|
113
|
-
str +=
|
|
116
|
+
str += `</${json.name}>`;
|
|
114
117
|
}
|
|
115
118
|
return str;
|
|
116
119
|
};
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.collectClassString = void 0;
|
|
4
4
|
// This should really be a preprocessor mapping the `class` attribute binding based on what other values have
|
|
5
5
|
// to make this more pluggable
|
|
6
|
-
|
|
6
|
+
const collectClassString = (json, options) => {
|
|
7
7
|
var _a, _b, _c;
|
|
8
|
-
|
|
8
|
+
const staticClasses = [];
|
|
9
9
|
if (json.properties.class) {
|
|
10
10
|
staticClasses.push(json.properties.class);
|
|
11
11
|
delete json.properties.class;
|
|
@@ -14,7 +14,7 @@ var collectClassString = function (json, options) {
|
|
|
14
14
|
staticClasses.push(json.properties.className);
|
|
15
15
|
delete json.properties.className;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
const dynamicClasses = [];
|
|
18
18
|
if (typeof ((_a = json.bindings.class) === null || _a === void 0 ? void 0 : _a.code) === 'string') {
|
|
19
19
|
dynamicClasses.push(json.bindings.class.code);
|
|
20
20
|
delete json.bindings.class;
|
|
@@ -26,21 +26,21 @@ var collectClassString = function (json, options) {
|
|
|
26
26
|
if (typeof ((_c = json.bindings.css) === null || _c === void 0 ? void 0 : _c.code) === 'string' &&
|
|
27
27
|
json.bindings.css.code.trim().length > 4 &&
|
|
28
28
|
options.stylesType === 'styled-components') {
|
|
29
|
-
dynamicClasses.push(
|
|
29
|
+
dynamicClasses.push(`css(${json.bindings.css.code})`);
|
|
30
30
|
}
|
|
31
31
|
delete json.bindings.css;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const staticClassesString = staticClasses.join(' ');
|
|
33
|
+
const dynamicClassesString = dynamicClasses.join(" + ' ' + ");
|
|
34
|
+
const hasStaticClasses = Boolean(staticClasses.length);
|
|
35
|
+
const hasDynamicClasses = Boolean(dynamicClasses.length);
|
|
36
36
|
if (hasStaticClasses && !hasDynamicClasses) {
|
|
37
|
-
return "
|
|
37
|
+
return `"${staticClassesString}"`;
|
|
38
38
|
}
|
|
39
39
|
if (hasDynamicClasses && !hasStaticClasses) {
|
|
40
|
-
return
|
|
40
|
+
return `{${dynamicClassesString}}`;
|
|
41
41
|
}
|
|
42
42
|
if (hasDynamicClasses && hasStaticClasses) {
|
|
43
|
-
return "{
|
|
43
|
+
return `{"${staticClassesString} " + ${dynamicClassesString}}`;
|
|
44
44
|
}
|
|
45
45
|
return null;
|
|
46
46
|
};
|