@builder.io/mitosis 0.9.1 → 0.9.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.
@@ -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
- ${componentHasStyles && options.stylesType === 'styled-jsx'
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';
@@ -299,15 +299,14 @@ const getBlockBindings = (block, options) => {
299
299
  exports.symbolBlocksAsChildren = false;
300
300
  const componentMappers = {
301
301
  Symbol(block, options) {
302
- var _a, _b;
302
+ var _a;
303
303
  let css = getCssFromBlock(block);
304
304
  const styleString = getStyleStringFromBlock(block, options);
305
305
  const actionBindings = getActionBindingsFromBlock(block, options);
306
306
  const bindings = {
307
307
  symbol: (0, bindings_1.createSingleBinding)({
308
308
  code: JSON.stringify({
309
- data: (_a = block.component) === null || _a === void 0 ? void 0 : _a.options.symbol.data,
310
- content: (_b = block.component) === null || _b === void 0 ? void 0 : _b.options.symbol.content,
309
+ ...(_a = block.component) === null || _a === void 0 ? void 0 : _a.options.symbol,
311
310
  }),
312
311
  }),
313
312
  ...actionBindings,
@@ -284,6 +284,15 @@ const jsxElementToJson = (node) => {
284
284
  bindingType: 'function',
285
285
  });
286
286
  }
287
+ else if (/^on[A-Z]/.test(key) && types.isExpression(expression)) {
288
+ // regex ignores props that happen to start with "on" but are not handlers
289
+ // <Foo onClick={state.handler} />
290
+ const call = types.callExpression(expression, []);
291
+ memo.bindings[key] = (0, bindings_1.createSingleBinding)({
292
+ code: (0, generator_1.default)(call, { compact: true }).code,
293
+ bindingType: 'function',
294
+ });
295
+ }
287
296
  else if (types.isJSXElement(expression) || types.isJSXFragment(expression)) {
288
297
  // <Foo myProp={<MoreMitosisNode><div /></MoreMitosisNode>} />
289
298
  // <Foo myProp={<><Node /><Node /></>} />
package/jsx-runtime.d.ts CHANGED
@@ -393,6 +393,9 @@ export declare namespace JSX {
393
393
  }
394
394
 
395
395
  interface DetailsHtmlAttributes<T> extends HTMLAttributes<T> {
396
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDetailsElement/name) */
397
+ name?: string;
398
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDetailsElement/open) */
396
399
  open?: boolean;
397
400
  }
398
401
 
@@ -500,6 +503,8 @@ export declare namespace JSX {
500
503
  // camelcase
501
504
  crossOrigin?: HTMLCrossorigin;
502
505
  formAction?: string;
506
+ autoComplete?: string;
507
+ autoFocus?: boolean;
503
508
  formEnctype?: HTMLFormEncType;
504
509
  formMethod?: HTMLFormMethod;
505
510
  formNoValidate?: boolean;
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "name": "Builder.io",
23
23
  "url": "https://www.builder.io"
24
24
  },
25
- "version": "0.9.1",
25
+ "version": "0.9.3",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {