@builder.io/mitosis 0.9.0 → 0.9.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.
|
@@ -79,6 +79,12 @@ const componentMappers = {
|
|
|
79
79
|
block.children = [];
|
|
80
80
|
return block;
|
|
81
81
|
},
|
|
82
|
+
Fragment(node, options) {
|
|
83
|
+
const block = (0, exports.blockToBuilder)(node, options, { skipMapper: true });
|
|
84
|
+
block.component = { name: 'Core:Fragment' };
|
|
85
|
+
block.tagName = undefined;
|
|
86
|
+
return block;
|
|
87
|
+
},
|
|
82
88
|
PersonalizationContainer(node, options) {
|
|
83
89
|
const block = (0, exports.blockToBuilder)(node, options, { skipMapper: true });
|
|
84
90
|
const variants = [];
|
|
@@ -149,6 +149,7 @@ const componentToReact = (reactOptions = {}) => ({ component, path }) => {
|
|
|
149
149
|
addUseClientDirectiveIfNeeded: true,
|
|
150
150
|
stateType,
|
|
151
151
|
stylesType: 'styled-jsx',
|
|
152
|
+
styleTagsPlacement: 'bottom',
|
|
152
153
|
type: 'dom',
|
|
153
154
|
plugins: [
|
|
154
155
|
(0, on_event_1.processOnEventHooksPlugin)({ setBindings: false }),
|
|
@@ -236,6 +237,17 @@ const checkShouldAddUseClientDirective = (json, options) => {
|
|
|
236
237
|
return false;
|
|
237
238
|
return !isRSC(json, options);
|
|
238
239
|
};
|
|
240
|
+
const generateStyleTags = (placement, json, options, componentHasStyles, css, shouldInjectCustomStyles) => {
|
|
241
|
+
if (placement !== options.styleTagsPlacement)
|
|
242
|
+
return '';
|
|
243
|
+
return (0, dedent_1.dedent) `
|
|
244
|
+
${componentHasStyles && options.stylesType === 'styled-jsx'
|
|
245
|
+
? `<style jsx>{\`${css}\`}</style>`
|
|
246
|
+
: ''}
|
|
247
|
+
${componentHasStyles && options.stylesType === 'style-tag' ? `<style>{\`${css}\`}</style>` : ''}
|
|
248
|
+
${shouldInjectCustomStyles ? `<style>{\`${json.style}\`}</style>` : ''}
|
|
249
|
+
`;
|
|
250
|
+
};
|
|
239
251
|
const _componentToReact = (json, options, isSubComponent = false) => {
|
|
240
252
|
var _a, _b, _c, _d, _e, _f;
|
|
241
253
|
(0, process_http_requests_1.processHttpRequests)(json);
|
|
@@ -338,14 +350,9 @@ const _componentToReact = (json, options, isSubComponent = false) => {
|
|
|
338
350
|
|
|
339
351
|
return (
|
|
340
352
|
${wrap ? (0, helpers_2.openFrag)(options) : ''}
|
|
353
|
+
${generateStyleTags('top', json, options, componentHasStyles, css, shouldInjectCustomStyles)}
|
|
341
354
|
${json.children.map((item) => (0, blocks_1.blockToReact)(item, options, json, wrap, [])).join('\n')}
|
|
342
|
-
${
|
|
343
|
-
? `<style jsx>{\`${css}\`}</style>`
|
|
344
|
-
: ''}
|
|
345
|
-
${componentHasStyles && options.stylesType === 'style-tag'
|
|
346
|
-
? `<style>{\`${css}\`}</style>`
|
|
347
|
-
: ''}
|
|
348
|
-
${shouldInjectCustomStyles ? `<style>{\`${json.style}\`}</style>` : ''}
|
|
355
|
+
${generateStyleTags('bottom', json, options, componentHasStyles, css, shouldInjectCustomStyles)}
|
|
349
356
|
${wrap ? (0, helpers_2.closeFrag)(options) : ''}
|
|
350
357
|
);
|
|
351
358
|
`;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseTranspilerOptions } from '../../types/transpiler';
|
|
2
2
|
export interface ToReactOptions extends BaseTranspilerOptions {
|
|
3
3
|
stylesType: 'emotion' | 'styled-components' | 'styled-jsx' | 'react-native' | 'style-tag' | 'twrnc' | 'native-wind';
|
|
4
|
+
styleTagsPlacement?: 'top' | 'bottom';
|
|
4
5
|
stateType: 'useState' | 'mobx' | 'valtio' | 'solid' | 'builder' | 'variables';
|
|
5
6
|
format?: 'lite' | 'safe';
|
|
6
7
|
type: 'dom' | 'native' | 'taro';
|