@builder.io/mitosis 0.0.56-13 → 0.0.56-14

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.
Files changed (68) hide show
  1. package/dist/src/__tests__/data/basic-context.raw.d.ts +1 -0
  2. package/dist/src/__tests__/data/basic-context.raw.jsx +29 -0
  3. package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.d.ts +1 -0
  4. package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.jsx +12 -0
  5. package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.d.ts +5 -0
  6. package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.jsx +17 -0
  7. package/dist/src/__tests__/data/basic-forwardRef.raw.d.ts +5 -0
  8. package/dist/src/__tests__/data/basic-forwardRef.raw.jsx +14 -0
  9. package/dist/src/__tests__/data/basic-onChange.raw.d.ts +1 -0
  10. package/dist/src/__tests__/data/basic-onChange.raw.jsx +17 -0
  11. package/dist/src/__tests__/data/basic-onUpdate-deps.raw.d.ts +4 -0
  12. package/dist/src/__tests__/data/basic-onUpdate-deps.raw.jsx +25 -0
  13. package/dist/src/__tests__/data/basic-onUpdate-return.raw.d.ts +1 -0
  14. package/dist/src/__tests__/data/basic-onUpdate-return.raw.jsx +24 -0
  15. package/dist/src/__tests__/data/basic-ref-assignment.raw.d.ts +4 -0
  16. package/dist/src/__tests__/data/basic-ref-assignment.raw.jsx +15 -0
  17. package/dist/src/__tests__/data/basic-ref-usePrevious.raw.d.ts +5 -0
  18. package/dist/src/__tests__/data/basic-ref-usePrevious.raw.jsx +35 -0
  19. package/dist/src/__tests__/data/basic-ref.raw.d.ts +4 -0
  20. package/dist/src/__tests__/data/basic-ref.raw.jsx +36 -0
  21. package/dist/src/__tests__/data/basic.raw.d.ts +3 -0
  22. package/dist/src/__tests__/data/basic.raw.jsx +5 -1
  23. package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +1 -1
  24. package/dist/src/__tests__/data/blocks/embed.raw.jsx +1 -1
  25. package/dist/src/__tests__/data/blocks/form.raw.jsx +1 -1
  26. package/dist/src/__tests__/data/blocks/onInit.raw.d.ts +8 -1
  27. package/dist/src/__tests__/data/blocks/onInit.raw.jsx +13 -3
  28. package/dist/src/__tests__/data/types/component-props-interface.raw.d.ts +6 -0
  29. package/dist/src/__tests__/data/types/component-props-interface.raw.jsx +6 -0
  30. package/dist/src/__tests__/data/types/component-props-type.raw.d.ts +6 -0
  31. package/dist/src/__tests__/data/types/component-props-type.raw.jsx +6 -0
  32. package/dist/src/__tests__/data/types/preserve-typing.raw.d.ts +8 -0
  33. package/dist/src/__tests__/data/types/preserve-typing.raw.jsx +6 -0
  34. package/dist/src/generators/angular.js +49 -14
  35. package/dist/src/generators/html.js +198 -99
  36. package/dist/src/generators/mitosis.js +28 -9
  37. package/dist/src/generators/react.d.ts +3 -1
  38. package/dist/src/generators/react.js +68 -32
  39. package/dist/src/generators/solid.js +5 -2
  40. package/dist/src/generators/svelte.js +12 -2
  41. package/dist/src/generators/vue.js +21 -0
  42. package/dist/src/helpers/create-mitosis-component.d.ts +1 -1
  43. package/dist/src/helpers/create-mitosis-component.js +1 -1
  44. package/dist/src/helpers/get-bindings.d.ts +2 -0
  45. package/dist/src/helpers/get-bindings.js +18 -0
  46. package/dist/src/helpers/get-props-ref.d.ts +2 -0
  47. package/dist/src/helpers/get-props-ref.js +32 -0
  48. package/dist/src/helpers/has-bindings-text.d.ts +2 -0
  49. package/dist/src/helpers/has-bindings-text.js +21 -0
  50. package/dist/src/helpers/has-stateful-dom.d.ts +2 -0
  51. package/dist/src/helpers/has-stateful-dom.js +21 -0
  52. package/dist/src/helpers/is-html-attribute.d.ts +1 -1
  53. package/dist/src/helpers/is-html-attribute.js +2 -1
  54. package/dist/src/helpers/map-refs.js +4 -1
  55. package/dist/src/helpers/render-imports.d.ts +3 -1
  56. package/dist/src/helpers/render-imports.js +8 -2
  57. package/dist/src/helpers/strip-state-and-props-refs.d.ts +2 -1
  58. package/dist/src/helpers/strip-state-and-props-refs.js +3 -2
  59. package/dist/src/index.d.ts +2 -2
  60. package/dist/src/index.js +1 -1
  61. package/dist/src/parsers/builder.d.ts +23 -23
  62. package/dist/src/parsers/jsx.d.ts +2 -1
  63. package/dist/src/parsers/jsx.js +145 -15
  64. package/dist/src/symbols/symbol-processor.js +3 -3
  65. package/dist/src/types/mitosis-component.d.ts +30 -10
  66. package/dist/tsconfig.build.tsbuildinfo +1 -1
  67. package/dist/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +2 -3
@@ -0,0 +1 @@
1
+ export default function MyBasicComponent(): JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ var injection_js_1 = require("@dummy/injection-js");
5
+ function MyBasicComponent() {
6
+ (0, mitosis_1.setContext)(injection_js_1.Injector, (0, injection_js_1.createInjector)());
7
+ var myService = (0, mitosis_1.useContext)(injection_js_1.MyService);
8
+ var state = (0, mitosis_1.useState)({
9
+ name: 'PatrickJS',
10
+ });
11
+ (0, mitosis_1.onInit)(function () {
12
+ var hi = myService.method('hi');
13
+ console.log(hi);
14
+ });
15
+ (0, mitosis_1.onMount)(function () {
16
+ var bye = myService.method('hi');
17
+ console.log(bye);
18
+ });
19
+ function onChange() {
20
+ var change = myService.method('change');
21
+ console.log(change);
22
+ }
23
+ return (<div>
24
+ {myService.method('hello') + state.name}
25
+ Hello! I can run in React, Vue, Solid, or Liquid!
26
+ <input onChange={onChange}></input>
27
+ </div>);
28
+ }
29
+ exports.default = MyBasicComponent;
@@ -0,0 +1 @@
1
+ export default function MyBasicComponent(): JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var custom_mitosis_1 = require("@dummy/custom-mitosis");
4
+ function MyBasicComponent() {
5
+ var state = (0, custom_mitosis_1.useState)({
6
+ name: 'PatrickJS',
7
+ });
8
+ return (<div>
9
+ Hello {state.name}! I can run in React, Qwik, Vue, Solid, or Liquid!
10
+ </div>);
11
+ }
12
+ exports.default = MyBasicComponent;
@@ -0,0 +1,5 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ inputRef: any;
4
+ }
5
+ export default function MyBasicForwardRefComponent(props: Props): JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ (0, mitosis_1.useMetadata)({
5
+ forwardRef: 'inputRef',
6
+ });
7
+ function MyBasicForwardRefComponent(props) {
8
+ var state = (0, mitosis_1.useState)({
9
+ name: 'PatrickJS',
10
+ });
11
+ return (<div>
12
+ <input ref={props.inputRef} css={{
13
+ color: 'red',
14
+ }} value={state.name} onChange={function (event) { return (state.name = event.target.value); }}/>
15
+ </div>);
16
+ }
17
+ exports.default = MyBasicForwardRefComponent;
@@ -0,0 +1,5 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ inputRef: any;
4
+ }
5
+ export default function MyBasicForwardRefComponent(props: Props): JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicForwardRefComponent(props) {
5
+ var state = (0, mitosis_1.useState)({
6
+ name: 'PatrickJS',
7
+ });
8
+ return (<div>
9
+ <input ref={props.inputRef} css={{
10
+ color: 'red',
11
+ }} value={state.name} onChange={function (event) { return (state.name = event.target.value); }}/>
12
+ </div>);
13
+ }
14
+ exports.default = MyBasicForwardRefComponent;
@@ -0,0 +1 @@
1
+ export default function MyBasicComponent(): JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicComponent() {
5
+ var state = (0, mitosis_1.useState)({
6
+ name: 'Steve',
7
+ });
8
+ return (<div class="test" css={{
9
+ padding: '10px',
10
+ }}>
11
+ <input value={state.name} onChange={function (myEvent) {
12
+ state.name = myEvent.target.value;
13
+ }}/>
14
+ Hello! I can run in React, Vue, Solid, or Liquid!
15
+ </div>);
16
+ }
17
+ exports.default = MyBasicComponent;
@@ -0,0 +1,4 @@
1
+ export interface Props {
2
+ name: string;
3
+ }
4
+ export default function MyBasicComponent(props: Props): JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicComponent(props) {
5
+ var state = (0, mitosis_1.useState)({
6
+ name: 'Steve',
7
+ });
8
+ (0, mitosis_1.onUpdate)(function () {
9
+ console.log('name 1');
10
+ if (state.name === 'Steve') {
11
+ state.name = 'PatrickJS';
12
+ }
13
+ }, [state.name]);
14
+ (0, mitosis_1.onUpdate)(function () {
15
+ console.log('name 2');
16
+ if (state.name === 'PatrickJS') {
17
+ state.name = 'Hi';
18
+ }
19
+ }, [props.name]);
20
+ return (<div>
21
+ <input value={state.name} onChange={function (myEvent) { return (state.name = myEvent.target.value); }}/>
22
+ Hello! I can run in React, Vue, Solid, or Liquid!
23
+ </div>);
24
+ }
25
+ exports.default = MyBasicComponent;
@@ -0,0 +1 @@
1
+ export default function MyBasicOnUpdateReturnComponent(): JSX.Element;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicOnUpdateReturnComponent() {
5
+ var state = (0, mitosis_1.useState)({
6
+ name: 'PatrickJS',
7
+ });
8
+ (0, mitosis_1.onUpdate)(function () {
9
+ var controller = new AbortController();
10
+ var signal = controller.signal;
11
+ fetch('https://patrickjs.com/api/resource.json', { signal: signal })
12
+ .then(function (response) { return response.json(); })
13
+ .then(function (data) {
14
+ state.name = data.name;
15
+ });
16
+ return function () {
17
+ if (!signal.aborted) {
18
+ controller.abort();
19
+ }
20
+ };
21
+ }, [state.name]);
22
+ return <div>Hello! {state.name}</div>;
23
+ }
24
+ exports.default = MyBasicOnUpdateReturnComponent;
@@ -0,0 +1,4 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ }
4
+ export default function MyBasicRefAssignmentComponent(props: Props): JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicRefAssignmentComponent(props) {
5
+ var holdValueRef = (0, mitosis_1.useRef)('Patrick');
6
+ function handlerClick(event) {
7
+ event.preventDefault();
8
+ console.log('current value', holdValueRef);
9
+ holdValueRef = holdValueRef + 'JS';
10
+ }
11
+ return (<div>
12
+ <button onClick={function (evt) { return handlerClick(evt); }}>Click</button>
13
+ </div>);
14
+ }
15
+ exports.default = MyBasicRefAssignmentComponent;
@@ -0,0 +1,5 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ }
4
+ export declare function usePrevious<T>(value: T): T;
5
+ export default function MyPreviousComponent(props: Props): JSX.Element;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePrevious = void 0;
4
+ var mitosis_1 = require("@builder.io/mitosis");
5
+ function usePrevious(value) {
6
+ // The ref object is a generic container whose current property is mutable ...
7
+ // ... and can hold any value, similar to an instance property on a class
8
+ var ref = (0, mitosis_1.useRef)(null);
9
+ // Store current value in ref
10
+ (0, mitosis_1.onUpdate)(function () {
11
+ ref = value;
12
+ }, [value]); // Only re-run if value changes
13
+ // Return previous value (happens before update in useEffect above)
14
+ return ref;
15
+ }
16
+ exports.usePrevious = usePrevious;
17
+ function MyPreviousComponent(props) {
18
+ var state = (0, mitosis_1.useState)({
19
+ count: 0,
20
+ });
21
+ var prevCount = (0, mitosis_1.useRef)(state.count);
22
+ (0, mitosis_1.onUpdate)(function () {
23
+ prevCount = state.count;
24
+ }, [state.count]); //
25
+ // Get the previous value (was passed into hook on last render)
26
+ // const prevCount = usePrevious(state.count);
27
+ // Display both current and previous count value
28
+ return (<div>
29
+ <h1>
30
+ Now: {state.count}, before: {prevCount}
31
+ </h1>
32
+ <button onClick={function () { return (state.count += 1); }}>Increment</button>
33
+ </div>);
34
+ }
35
+ exports.default = MyPreviousComponent;
@@ -0,0 +1,4 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ }
4
+ export default function MyBasicRefComponent(props: Props): JSX.Element;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicRefComponent(props) {
5
+ var inputRef = (0, mitosis_1.useRef)(null);
6
+ var inputNoArgRef = (0, mitosis_1.useRef)(null);
7
+ var state = (0, mitosis_1.useState)({
8
+ name: 'PatrickJS',
9
+ });
10
+ function onBlur() {
11
+ // Maintain focus
12
+ inputRef.focus();
13
+ }
14
+ function lowerCaseName() {
15
+ return state.name.toLowerCase();
16
+ }
17
+ return (<div>
18
+ {props.showInput && (<>
19
+ <input ref={inputRef} css={{
20
+ color: 'red',
21
+ }} value={state.name} onBlur={function (event) { return onBlur(); }} onChange={function (event) { return (state.name = event.target.value); }}/>
22
+
23
+ <label ref={inputNoArgRef} for="cars">
24
+ Choose a car:
25
+ </label>
26
+
27
+ <select name="cars" id="cars">
28
+ <option value="supra">GR Supra</option>
29
+ <option value="86">GR 86</option>
30
+ </select>
31
+ </>)}
32
+ Hello
33
+ {lowerCaseName()}! I can run in React, Qwik, Vue, Solid, or Web Component!
34
+ </div>);
35
+ }
36
+ exports.default = MyBasicRefComponent;
@@ -1 +1,4 @@
1
+ export declare const DEFAULT_VALUES: {
2
+ name: string;
3
+ };
1
4
  export default function MyBasicComponent(): JSX.Element;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_VALUES = void 0;
3
4
  var mitosis_1 = require("@builder.io/mitosis");
5
+ exports.DEFAULT_VALUES = {
6
+ name: 'Steve',
7
+ };
4
8
  function MyBasicComponent() {
5
9
  var state = (0, mitosis_1.useState)({
6
10
  name: 'Steve',
@@ -8,7 +12,7 @@ function MyBasicComponent() {
8
12
  return (<div class="test" css={{
9
13
  padding: '10px',
10
14
  }}>
11
- <input value={state.name} onChange={function (myEvent) { return (state.name = myEvent.target.value); }}/>
15
+ <input value={exports.DEFAULT_VALUES.name || state.name} onChange={function (myEvent) { return (state.name = myEvent.target.value); }}/>
12
16
  Hello! I can run in React, Vue, Solid, or Liquid!
13
17
  </div>);
14
18
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var mitosis_1 = require("@builder.io/mitosis");
4
4
  function CustomCode(props) {
5
- var elem = (0, mitosis_1.useRef)();
5
+ var elem = (0, mitosis_1.useRef)(null);
6
6
  var state = (0, mitosis_1.useState)({
7
7
  scriptsInserted: [],
8
8
  scriptsRun: [],
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var mitosis_1 = require("@builder.io/mitosis");
4
4
  function Embed(props) {
5
- var elem = (0, mitosis_1.useRef)();
5
+ var elem = (0, mitosis_1.useRef)(null);
6
6
  var state = (0, mitosis_1.useState)({
7
7
  scriptsInserted: [],
8
8
  scriptsRun: [],
@@ -242,7 +242,7 @@ function FormComponent(props) {
242
242
  }
243
243
  },
244
244
  });
245
- var formRef = (0, mitosis_1.useRef)();
245
+ var formRef = (0, mitosis_1.useRef)(null);
246
246
  return (<form validate={props.validate} ref={formRef} action={!props.sendWithJs && props.action} method={props.method} name={props.name} onSubmit={function (event) { return state.onSubmit(event); }} {...props.attributes}>
247
247
  <mitosis_1.Show when={props.builderBlock && props.builderBlock.children}>
248
248
  <mitosis_1.For each={(_a = props.builderBlock) === null || _a === void 0 ? void 0 : _a.children}>
@@ -1 +1,8 @@
1
- export default function OnInit(): JSX.Element;
1
+ declare type Props = {
2
+ name: string;
3
+ };
4
+ export declare const defaultValues: {
5
+ name: string;
6
+ };
7
+ export default function OnInit(props: Props): JSX.Element;
8
+ export {};
@@ -1,10 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultValues = void 0;
3
4
  var mitosis_1 = require("@builder.io/mitosis");
4
- function OnInit() {
5
+ exports.defaultValues = {
6
+ name: 'PatrickJS',
7
+ };
8
+ function OnInit(props) {
9
+ var state = (0, mitosis_1.useState)({
10
+ // name: props.name
11
+ // name: defaultValues.name || props.name,
12
+ name: '',
13
+ });
5
14
  (0, mitosis_1.onInit)(function () {
6
- console.log('Runs once every update/rerender');
15
+ state.name = exports.defaultValues.name || props.name;
16
+ console.log('set defaults with props');
7
17
  });
8
- return <div />;
18
+ return <div>Default name defined by parent {state.name}</div>;
9
19
  }
10
20
  exports.default = OnInit;
@@ -0,0 +1,6 @@
1
+ interface Person {
2
+ name: string;
3
+ age?: number;
4
+ }
5
+ export default function MyBasicComponent(props: Person | never): JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function MyBasicComponent(props) {
4
+ return (<div>Hello! I can run in React, Vue, Solid, or Liquid! {props.name}</div>);
5
+ }
6
+ exports.default = MyBasicComponent;
@@ -0,0 +1,6 @@
1
+ declare type Person = {
2
+ name: string;
3
+ age?: number;
4
+ };
5
+ export default function MyBasicComponent(props: Person): JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function MyBasicComponent(props) {
4
+ return (<div>Hello! I can run in React, Vue, Solid, or Liquid! {props.name}</div>);
5
+ }
6
+ exports.default = MyBasicComponent;
@@ -0,0 +1,8 @@
1
+ export declare type A = 'test';
2
+ export interface C {
3
+ n: 'test';
4
+ }
5
+ export default function MyBasicComponent(props: {
6
+ name: string;
7
+ age?: number;
8
+ }): JSX.Element;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function MyBasicComponent(props) {
4
+ return (<div>Hello! I can run in React, Vue, Solid, or Liquid! {props.name}</div>);
5
+ }
6
+ exports.default = MyBasicComponent;
@@ -30,6 +30,7 @@ var jsx_1 = require("../parsers/jsx");
30
30
  var plugins_1 = require("../modules/plugins");
31
31
  var is_children_1 = __importDefault(require("../helpers/is-children"));
32
32
  var get_props_1 = require("../helpers/get-props");
33
+ var get_props_ref_1 = require("../helpers/get-props-ref");
33
34
  var get_prop_functions_1 = require("../helpers/get-prop-functions");
34
35
  var lodash_1 = require("lodash");
35
36
  var strip_meta_properties_1 = require("../helpers/strip-meta-properties");
@@ -80,7 +81,8 @@ var blockToAngular = function (json, options, blockOptions) {
80
81
  }
81
82
  if ((_d = json.bindings._text) === null || _d === void 0 ? void 0 : _d.code) {
82
83
  return "{{".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings._text.code, {
83
- contextVars: contextVars,
84
+ // the context is the class
85
+ contextVars: [],
84
86
  outputVars: outputVars,
85
87
  }), "}}");
86
88
  }
@@ -141,7 +143,12 @@ var blockToAngular = function (json, options, blockOptions) {
141
143
  event_1 = 'input';
142
144
  }
143
145
  // TODO: proper babel transform to replace. Util for this
144
- var finalValue = (0, remove_surrounding_block_1.removeSurroundingBlock)(useValue.replace(new RegExp("".concat(cusArgs[0], "\\."), 'g'), '$event.'));
146
+ var eventName = cusArgs[0];
147
+ var regexp = new RegExp('(^|\\n|\\r| |;|\\(|\\[|!)' +
148
+ eventName +
149
+ '(\\?\\.|\\.|\\(| |;|\\)|$)', 'g');
150
+ var replacer = '$1$event$2';
151
+ var finalValue = (0, remove_surrounding_block_1.removeSurroundingBlock)(useValue.replace(regexp, replacer));
145
152
  str += " (".concat(event_1, ")=\"").concat(finalValue, "\" ");
146
153
  }
147
154
  else if (key === 'class') {
@@ -189,6 +196,7 @@ var componentToAngular = function (options) {
189
196
  if (options.plugins) {
190
197
  json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
191
198
  }
199
+ var _o = (0, get_props_ref_1.getPropsRef)(json, true), forwardProp = _o[0], hasPropRef = _o[1];
192
200
  var childComponents = [];
193
201
  json.imports.forEach(function (_a) {
194
202
  var imports = _a.imports;
@@ -198,9 +206,12 @@ var componentToAngular = function (options) {
198
206
  }
199
207
  });
200
208
  });
209
+ var _p = component.exports, localExports = _p === void 0 ? {} : _p;
210
+ var localExportVars = Object.keys(localExports)
211
+ .filter(function (key) { return localExports[key].usedInLocal; })
212
+ .map(function (key) { return "".concat(key, " = ").concat(key, ";"); });
201
213
  var metaOutputVars = ((_c = (_b = json.meta) === null || _b === void 0 ? void 0 : _b.useMetadata) === null || _c === void 0 ? void 0 : _c.outputs) || [];
202
214
  var contextVars = Object.keys(((_d = json === null || json === void 0 ? void 0 : json.context) === null || _d === void 0 ? void 0 : _d.get) || {});
203
- var hasInjectable = Boolean(contextVars.length);
204
215
  var injectables = contextVars.map(function (variableName) {
205
216
  var _a, _b, _c, _d;
206
217
  var variableType = (_a = json === null || json === void 0 ? void 0 : json.context) === null || _a === void 0 ? void 0 : _a.get[variableName].name;
@@ -212,7 +223,13 @@ var componentToAngular = function (options) {
212
223
  }
213
224
  return "public ".concat(variableName, " : ").concat(variableType);
214
225
  });
226
+ var hasConstructor = Boolean(injectables.length || ((_e = component.hooks) === null || _e === void 0 ? void 0 : _e.onInit));
215
227
  var props = (0, get_props_1.getProps)(component);
228
+ // prevent jsx props from showing up as @Input
229
+ if (hasPropRef) {
230
+ props.delete(forwardProp);
231
+ }
232
+ props.delete('children');
216
233
  var outputVars = (0, lodash_1.uniq)(__spreadArray(__spreadArray([], metaOutputVars, true), (0, get_prop_functions_1.getPropFunctions)(component), true));
217
234
  // remove props for outputs
218
235
  outputVars.forEach(function (variableName) {
@@ -225,9 +242,13 @@ var componentToAngular = function (options) {
225
242
  }
226
243
  return "@Output() ".concat(variableName, " = new EventEmitter()");
227
244
  });
228
- var hasOnInit = Boolean(((_e = component.hooks) === null || _e === void 0 ? void 0 : _e.onInit) || ((_f = component.hooks) === null || _f === void 0 ? void 0 : _f.onMount));
229
- var refs = Array.from((0, get_refs_1.getRefs)(json));
230
- (0, map_refs_1.mapRefs)(json, function (refName) { return "this.".concat(refName, ".nativeElement"); });
245
+ var hasOnMount = Boolean((_f = component.hooks) === null || _f === void 0 ? void 0 : _f.onMount);
246
+ var domRefs = (0, get_refs_1.getRefs)(json);
247
+ var jsRefs = Object.keys(json.refs).filter(function (ref) { return !domRefs.has(ref); });
248
+ (0, map_refs_1.mapRefs)(json, function (refName) {
249
+ var isDomRef = domRefs.has(refName);
250
+ return "this.".concat(isDomRef ? '' : '_').concat(refName).concat(isDomRef ? '.nativeElement' : '');
251
+ });
231
252
  if (options.plugins) {
232
253
  json = (0, plugins_1.runPostJsonPlugins)(json, options.plugins);
233
254
  }
@@ -258,22 +279,36 @@ var componentToAngular = function (options) {
258
279
  });
259
280
  },
260
281
  });
261
- var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { ", " ", " Component ", "", " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: `\n ", "\n `,\n ", "\n })\n export default class ", " {\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n }\n "], ["\n import { ", " ", " Component ", "", " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: \\`\n ", "\n \\`,\n ", "\n })\n export default class ", " {\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n }\n "])), outputs.length ? 'Output, EventEmitter, \n' : '', ((_g = options === null || options === void 0 ? void 0 : options.experimental) === null || _g === void 0 ? void 0 : _g.inject) ? 'Inject, forwardRef,' : '', refs.length ? ', ViewChild, ElementRef' : '', props.size ? ', Input' : '', (0, render_imports_1.renderPreComponent)(json), (0, lodash_1.kebabCase)(json.name || 'my-component'), (0, indent_1.indent)(template, 8).replace(/`/g, '\\`').replace(/\$\{/g, '\\${'), css.length
282
+ var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { ", " ", " Component ", "", " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: `\n ", "\n `,\n ", "\n })\n export default class ", " {\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n }\n "], ["\n import { ", " ", " Component ", "", " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: \\`\n ", "\n \\`,\n ", "\n })\n export default class ", " {\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n }\n "])), outputs.length ? 'Output, EventEmitter, \n' : '', ((_g = options === null || options === void 0 ? void 0 : options.experimental) === null || _g === void 0 ? void 0 : _g.inject) ? 'Inject, forwardRef,' : '', domRefs.size ? ', ViewChild, ElementRef' : '', props.size ? ', Input' : '', (0, render_imports_1.renderPreComponent)(json), (0, lodash_1.kebabCase)(json.name || 'my-component'), (0, indent_1.indent)(template, 8).replace(/`/g, '\\`').replace(/\$\{/g, '\\${'), css.length
262
283
  ? "styles: [\n `".concat((0, indent_1.indent)(css, 8), "`\n ],")
263
- : '', component.name, outputs.join('\n'), Array.from(props)
264
- .filter(function (item) { return !item.startsWith('slot'); })
284
+ : '', component.name, localExportVars.join('\n'), Array.from(props)
285
+ .filter(function (item) { return !item.startsWith('slot') && item !== 'children'; })
265
286
  .map(function (item) { return "@Input() ".concat(item, ": any"); })
266
- .join('\n'), refs
287
+ .join('\n'), outputs.join('\n'), Array.from(domRefs)
267
288
  .map(function (refName) { return "@ViewChild('".concat(refName, "') ").concat(refName, ": ElementRef"); })
268
- .join('\n'), dataString, !hasInjectable ? '' : "constructor(\n".concat(injectables.join(',\n'), ") {}"), !hasOnInit
289
+ .join('\n'), dataString, jsRefs
290
+ .map(function (ref) {
291
+ var argument = component.refs[ref].argument;
292
+ var typeParameter = component.refs[ref].typeParameter;
293
+ return "private _".concat(ref).concat(typeParameter ? ": ".concat(typeParameter) : '').concat(argument
294
+ ? " = ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(argument, {
295
+ replaceWith: 'this.',
296
+ contextVars: contextVars,
297
+ outputVars: outputVars,
298
+ }))
299
+ : '', ";");
300
+ })
301
+ .join('\n'), !hasConstructor
269
302
  ? ''
270
- : "ngOnInit() {\n ".concat(!((_h = component.hooks) === null || _h === void 0 ? void 0 : _h.onInit)
303
+ : "constructor(\n".concat(injectables.join(',\n'), ") {\n ").concat(!((_h = component.hooks) === null || _h === void 0 ? void 0 : _h.onInit)
271
304
  ? ''
272
- : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_j = component.hooks.onInit) === null || _j === void 0 ? void 0 : _j.code, {
305
+ : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_j = component.hooks.onInit) === null || _j === void 0 ? void 0 : _j.code, {
273
306
  replaceWith: 'this.',
274
307
  contextVars: contextVars,
275
308
  outputVars: outputVars,
276
- }), "\n "), "\n ").concat(!((_k = component.hooks) === null || _k === void 0 ? void 0 : _k.onMount)
309
+ }), "\n "), "\n }\n "), !hasOnMount
310
+ ? ''
311
+ : "ngOnInit() {\n \n ".concat(!((_k = component.hooks) === null || _k === void 0 ? void 0 : _k.onMount)
277
312
  ? ''
278
313
  : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_l = component.hooks.onMount) === null || _l === void 0 ? void 0 : _l.code, {
279
314
  replaceWith: 'this.',