@builder.io/mitosis 0.0.56-3 → 0.0.56-4
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/__tests__/data/basic-for.raw.d.ts +1 -0
- package/dist/src/__tests__/data/basic-for.raw.jsx +21 -0
- package/dist/src/__tests__/data/blocks/img-state.raw.d.ts +1 -0
- package/dist/src/__tests__/data/blocks/img-state.raw.jsx +17 -0
- package/dist/src/__tests__/data/blocks/section-state.raw.d.ts +6 -0
- package/dist/src/__tests__/data/blocks/section-state.raw.jsx +17 -0
- package/dist/src/__tests__/html.test.js +126 -0
- package/dist/src/__tests__/react.test.js +6 -0
- package/dist/src/__tests__/webcomponent.test.js +132 -0
- package/dist/src/generators/html.js +72 -56
- package/dist/src/generators/react.js +3 -1
- package/dist/src/helpers/render-imports.d.ts +1 -1
- package/dist/src/parsers/jsx.js +11 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MyBasicForComponent(): JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var mitosis_1 = require("@builder.io/mitosis");
|
|
4
|
+
function MyBasicForComponent() {
|
|
5
|
+
var state = (0, mitosis_1.useState)({
|
|
6
|
+
name: 'PatrickJS',
|
|
7
|
+
names: ['Steve', 'PatrickJS'],
|
|
8
|
+
});
|
|
9
|
+
return (<div>
|
|
10
|
+
<mitosis_1.For each={state.names}>
|
|
11
|
+
{function (person) { return (<>
|
|
12
|
+
<input value={state.name} onChange={function (event) {
|
|
13
|
+
state.name = event.target.value + ' and ' + person;
|
|
14
|
+
}}/>
|
|
15
|
+
Hello {person}! I can run in Qwik, Web Component, React, Vue, Solid,
|
|
16
|
+
or Liquid!
|
|
17
|
+
</>); }}
|
|
18
|
+
</mitosis_1.For>
|
|
19
|
+
</div>);
|
|
20
|
+
}
|
|
21
|
+
exports.default = MyBasicForComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ImgStateComponent(): 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 ImgStateComponent() {
|
|
5
|
+
var state = (0, mitosis_1.useState)({
|
|
6
|
+
canShow: true,
|
|
7
|
+
images: ['http://example.com/qwik.png'],
|
|
8
|
+
});
|
|
9
|
+
return (<div>
|
|
10
|
+
<mitosis_1.For each={state.images}>
|
|
11
|
+
{function (item, itemIndex) { return (<>
|
|
12
|
+
<img class={'custom-class'} src={item} key={itemIndex}/>
|
|
13
|
+
</>); }}
|
|
14
|
+
</mitosis_1.For>
|
|
15
|
+
</div>);
|
|
16
|
+
}
|
|
17
|
+
exports.default = ImgStateComponent;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var mitosis_1 = require("@builder.io/mitosis");
|
|
4
|
+
function SectionStateComponent(props) {
|
|
5
|
+
var state = (0, mitosis_1.useState)({
|
|
6
|
+
max: 42,
|
|
7
|
+
items: [42],
|
|
8
|
+
});
|
|
9
|
+
return (<mitosis_1.Show when={state.max}>
|
|
10
|
+
<mitosis_1.For each={state.items}>
|
|
11
|
+
{function (item) { return (<section {...props.attributes} style={{ maxWidth: item + state.max }}>
|
|
12
|
+
{props.children}
|
|
13
|
+
</section>); }}
|
|
14
|
+
</mitosis_1.For>
|
|
15
|
+
</mitosis_1.Show>);
|
|
16
|
+
}
|
|
17
|
+
exports.default = SectionStateComponent;
|
|
@@ -2,9 +2,135 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var html_1 = require("../generators/html");
|
|
4
4
|
var jsx_1 = require("../parsers/jsx");
|
|
5
|
+
var basic = require('./data/basic.raw');
|
|
6
|
+
var basicFor = require('./data/basic-for.raw');
|
|
7
|
+
var submitButtonBlock = require('./data/blocks/submit-button.raw');
|
|
8
|
+
var inputBlock = require('./data/blocks/input.raw');
|
|
9
|
+
var selectBlock = require('./data/blocks/select.raw');
|
|
10
|
+
// const formBlock = require('./data/blocks/form.raw');
|
|
11
|
+
var button = require('./data/blocks/button.raw');
|
|
12
|
+
var textarea = require('./data/blocks/textarea.raw');
|
|
13
|
+
var img = require('./data/blocks/img.raw');
|
|
14
|
+
var video = require('./data/blocks/video.raw');
|
|
15
|
+
var section = require('./data/blocks/section.raw');
|
|
16
|
+
var sectionState = require('./data/blocks/section-state.raw');
|
|
17
|
+
var text = require('./data/blocks/text.raw');
|
|
18
|
+
var image = require('./data/blocks/image.raw');
|
|
19
|
+
var imageState = require('./data/blocks/img-state.raw');
|
|
20
|
+
var columns = require('./data/blocks/columns.raw');
|
|
21
|
+
var onUpdate = require('./data/blocks/onUpdate.raw');
|
|
22
|
+
var onUpdateWithDeps = require('./data/blocks/onUpdateWithDeps.raw');
|
|
23
|
+
var multipleOnUpdate = require('./data/blocks/multiple-onUpdate.raw');
|
|
24
|
+
var multipleOnUpdateWithDeps = require('./data/blocks/multiple-onUpdateWithDeps.raw');
|
|
25
|
+
var onMount = require('./data/blocks/onMount.raw');
|
|
5
26
|
var stamped = require('./data/blocks/stamped-io.raw');
|
|
6
27
|
var shadowDom = require('./data/blocks/shadow-dom.raw');
|
|
7
28
|
describe('Html', function () {
|
|
29
|
+
test('Basic', function () {
|
|
30
|
+
var component = (0, jsx_1.parseJsx)(basic);
|
|
31
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
32
|
+
expect(output).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
test('BasicFor', function () {
|
|
35
|
+
var component = (0, jsx_1.parseJsx)(basicFor);
|
|
36
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
37
|
+
expect(output).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
test('Input block', function () {
|
|
40
|
+
var component = (0, jsx_1.parseJsx)(inputBlock);
|
|
41
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
42
|
+
expect(output).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
test('Submit button block', function () {
|
|
45
|
+
var component = (0, jsx_1.parseJsx)(submitButtonBlock);
|
|
46
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
47
|
+
expect(output).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
test('Select block', function () {
|
|
50
|
+
var component = (0, jsx_1.parseJsx)(selectBlock);
|
|
51
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
52
|
+
expect(output).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
// test('Form block', () => {
|
|
55
|
+
// const component = parseJsx(formBlock);
|
|
56
|
+
// const output = componentToHtml()({ component });
|
|
57
|
+
// expect(output).toMatchSnapshot();
|
|
58
|
+
// });
|
|
59
|
+
test('Button', function () {
|
|
60
|
+
var component = (0, jsx_1.parseJsx)(button);
|
|
61
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
62
|
+
expect(output).toMatchSnapshot();
|
|
63
|
+
});
|
|
64
|
+
test('Textarea', function () {
|
|
65
|
+
var component = (0, jsx_1.parseJsx)(textarea);
|
|
66
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
67
|
+
expect(output).toMatchSnapshot();
|
|
68
|
+
});
|
|
69
|
+
test('Img', function () {
|
|
70
|
+
var component = (0, jsx_1.parseJsx)(img);
|
|
71
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
72
|
+
expect(output).toMatchSnapshot();
|
|
73
|
+
});
|
|
74
|
+
test('ImageState', function () {
|
|
75
|
+
var component = (0, jsx_1.parseJsx)(imageState);
|
|
76
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
77
|
+
expect(output).toMatchSnapshot();
|
|
78
|
+
});
|
|
79
|
+
test('Video', function () {
|
|
80
|
+
var component = (0, jsx_1.parseJsx)(video);
|
|
81
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
82
|
+
expect(output).toMatchSnapshot();
|
|
83
|
+
});
|
|
84
|
+
test('Section', function () {
|
|
85
|
+
var component = (0, jsx_1.parseJsx)(section);
|
|
86
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
87
|
+
expect(output).toMatchSnapshot();
|
|
88
|
+
});
|
|
89
|
+
test('SectionState', function () {
|
|
90
|
+
var component = (0, jsx_1.parseJsx)(sectionState);
|
|
91
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
92
|
+
expect(output).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
test('Text', function () {
|
|
95
|
+
var component = (0, jsx_1.parseJsx)(text);
|
|
96
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
97
|
+
expect(output).toMatchSnapshot();
|
|
98
|
+
});
|
|
99
|
+
test('Image', function () {
|
|
100
|
+
var component = (0, jsx_1.parseJsx)(image);
|
|
101
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
102
|
+
expect(output).toMatchSnapshot();
|
|
103
|
+
});
|
|
104
|
+
test('Columns', function () {
|
|
105
|
+
var component = (0, jsx_1.parseJsx)(columns);
|
|
106
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
107
|
+
expect(output).toMatchSnapshot();
|
|
108
|
+
});
|
|
109
|
+
test('onUpdate', function () {
|
|
110
|
+
var component = (0, jsx_1.parseJsx)(onUpdate);
|
|
111
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
112
|
+
expect(output).toMatchSnapshot();
|
|
113
|
+
});
|
|
114
|
+
test('onUpdateWithDeps', function () {
|
|
115
|
+
var component = (0, jsx_1.parseJsx)(onUpdateWithDeps);
|
|
116
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
117
|
+
expect(output).toMatchSnapshot();
|
|
118
|
+
});
|
|
119
|
+
test('multipleOnUpdate', function () {
|
|
120
|
+
var component = (0, jsx_1.parseJsx)(multipleOnUpdate);
|
|
121
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
122
|
+
expect(output).toMatchSnapshot();
|
|
123
|
+
});
|
|
124
|
+
test('multipleOnnUpdateWithDeps', function () {
|
|
125
|
+
var component = (0, jsx_1.parseJsx)(multipleOnUpdateWithDeps);
|
|
126
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
127
|
+
expect(output).toMatchSnapshot();
|
|
128
|
+
});
|
|
129
|
+
test('onMount & onUnMount', function () {
|
|
130
|
+
var component = (0, jsx_1.parseJsx)(onMount);
|
|
131
|
+
var output = (0, html_1.componentToHtml)()({ component: component });
|
|
132
|
+
expect(output).toMatchSnapshot();
|
|
133
|
+
});
|
|
8
134
|
test('Stamped', function () {
|
|
9
135
|
var component = (0, jsx_1.parseJsx)(stamped);
|
|
10
136
|
var html = (0, html_1.componentToHtml)()({ component: component });
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var react_1 = require("../generators/react");
|
|
4
4
|
var jsx_1 = require("../parsers/jsx");
|
|
5
5
|
var basic = require('./data/basic.raw');
|
|
6
|
+
var basicFor = require('./data/basic-for.raw');
|
|
6
7
|
var submitButtonBlock = require('./data/blocks/submit-button.raw');
|
|
7
8
|
var inputBlock = require('./data/blocks/input.raw');
|
|
8
9
|
var selectBlock = require('./data/blocks/select.raw');
|
|
@@ -31,6 +32,11 @@ describe('React', function () {
|
|
|
31
32
|
var output = (0, react_1.componentToReact)()({ component: component });
|
|
32
33
|
expect(output).toMatchSnapshot();
|
|
33
34
|
});
|
|
35
|
+
test('BasicFor', function () {
|
|
36
|
+
var component = (0, jsx_1.parseJsx)(basicFor);
|
|
37
|
+
var output = (0, react_1.componentToReact)()({ component: component });
|
|
38
|
+
expect(output).toMatchSnapshot();
|
|
39
|
+
});
|
|
34
40
|
test('Input block', function () {
|
|
35
41
|
var component = (0, jsx_1.parseJsx)(inputBlock);
|
|
36
42
|
var output = (0, react_1.componentToReact)()({ component: component });
|
|
@@ -2,11 +2,143 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var html_1 = require("../generators/html");
|
|
4
4
|
var jsx_1 = require("../parsers/jsx");
|
|
5
|
+
var basic = require('./data/basic.raw');
|
|
6
|
+
var basicFor = require('./data/basic-for.raw');
|
|
7
|
+
var submitButtonBlock = require('./data/blocks/submit-button.raw');
|
|
8
|
+
var inputBlock = require('./data/blocks/input.raw');
|
|
9
|
+
var selectBlock = require('./data/blocks/select.raw');
|
|
10
|
+
// const formBlock = require('./data/blocks/form.raw');
|
|
11
|
+
var button = require('./data/blocks/button.raw');
|
|
12
|
+
var textarea = require('./data/blocks/textarea.raw');
|
|
13
|
+
var img = require('./data/blocks/img.raw');
|
|
14
|
+
var video = require('./data/blocks/video.raw');
|
|
15
|
+
var section = require('./data/blocks/section.raw');
|
|
16
|
+
var sectionState = require('./data/blocks/section-state.raw');
|
|
17
|
+
var text = require('./data/blocks/text.raw');
|
|
18
|
+
var image = require('./data/blocks/image.raw');
|
|
19
|
+
var imageState = require('./data/blocks/img-state.raw');
|
|
20
|
+
var columns = require('./data/blocks/columns.raw');
|
|
21
|
+
var onUpdate = require('./data/blocks/onUpdate.raw');
|
|
22
|
+
var onUpdateWithDeps = require('./data/blocks/onUpdateWithDeps.raw');
|
|
23
|
+
var multipleOnUpdate = require('./data/blocks/multiple-onUpdate.raw');
|
|
24
|
+
var multipleOnUpdateWithDeps = require('./data/blocks/multiple-onUpdateWithDeps.raw');
|
|
25
|
+
var onMount = require('./data/blocks/onMount.raw');
|
|
5
26
|
var stamped = require('./data/blocks/stamped-io.raw');
|
|
27
|
+
var shadowDom = require('./data/blocks/shadow-dom.raw');
|
|
6
28
|
describe('webcomponent', function () {
|
|
29
|
+
test('Basic', function () {
|
|
30
|
+
var component = (0, jsx_1.parseJsx)(basic);
|
|
31
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
32
|
+
expect(output).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
test('BasicFor', function () {
|
|
35
|
+
var component = (0, jsx_1.parseJsx)(basicFor);
|
|
36
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
37
|
+
expect(output).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
test('Input block', function () {
|
|
40
|
+
var component = (0, jsx_1.parseJsx)(inputBlock);
|
|
41
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
42
|
+
expect(output).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
test('Submit button block', function () {
|
|
45
|
+
var component = (0, jsx_1.parseJsx)(submitButtonBlock);
|
|
46
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
47
|
+
expect(output).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
test('Select block', function () {
|
|
50
|
+
var component = (0, jsx_1.parseJsx)(selectBlock);
|
|
51
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
52
|
+
expect(output).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
// test('Form block', () => {
|
|
55
|
+
// const component = parseJsx(formBlock);
|
|
56
|
+
// const output = componentToCustomElement()({ component });
|
|
57
|
+
// expect(output).toMatchSnapshot();
|
|
58
|
+
// });
|
|
59
|
+
test('Button', function () {
|
|
60
|
+
var component = (0, jsx_1.parseJsx)(button);
|
|
61
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
62
|
+
expect(output).toMatchSnapshot();
|
|
63
|
+
});
|
|
64
|
+
test('Textarea', function () {
|
|
65
|
+
var component = (0, jsx_1.parseJsx)(textarea);
|
|
66
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
67
|
+
expect(output).toMatchSnapshot();
|
|
68
|
+
});
|
|
69
|
+
test('Img', function () {
|
|
70
|
+
var component = (0, jsx_1.parseJsx)(img);
|
|
71
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
72
|
+
expect(output).toMatchSnapshot();
|
|
73
|
+
});
|
|
74
|
+
test('Video', function () {
|
|
75
|
+
var component = (0, jsx_1.parseJsx)(video);
|
|
76
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
77
|
+
expect(output).toMatchSnapshot();
|
|
78
|
+
});
|
|
79
|
+
test('Section', function () {
|
|
80
|
+
var component = (0, jsx_1.parseJsx)(section);
|
|
81
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
82
|
+
expect(output).toMatchSnapshot();
|
|
83
|
+
});
|
|
84
|
+
test('SectionState', function () {
|
|
85
|
+
var component = (0, jsx_1.parseJsx)(sectionState);
|
|
86
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
87
|
+
expect(output).toMatchSnapshot();
|
|
88
|
+
});
|
|
89
|
+
test('Text', function () {
|
|
90
|
+
var component = (0, jsx_1.parseJsx)(text);
|
|
91
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
92
|
+
expect(output).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
test('Image', function () {
|
|
95
|
+
var component = (0, jsx_1.parseJsx)(image);
|
|
96
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
97
|
+
expect(output).toMatchSnapshot();
|
|
98
|
+
});
|
|
99
|
+
test('ImageState', function () {
|
|
100
|
+
var component = (0, jsx_1.parseJsx)(imageState);
|
|
101
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
102
|
+
expect(output).toMatchSnapshot();
|
|
103
|
+
});
|
|
104
|
+
test('Columns', function () {
|
|
105
|
+
var component = (0, jsx_1.parseJsx)(columns);
|
|
106
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
107
|
+
expect(output).toMatchSnapshot();
|
|
108
|
+
});
|
|
109
|
+
test('onUpdate', function () {
|
|
110
|
+
var component = (0, jsx_1.parseJsx)(onUpdate);
|
|
111
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
112
|
+
expect(output).toMatchSnapshot();
|
|
113
|
+
});
|
|
114
|
+
test('onUpdateWithDeps', function () {
|
|
115
|
+
var component = (0, jsx_1.parseJsx)(onUpdateWithDeps);
|
|
116
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
117
|
+
expect(output).toMatchSnapshot();
|
|
118
|
+
});
|
|
119
|
+
test('multipleOnUpdate', function () {
|
|
120
|
+
var component = (0, jsx_1.parseJsx)(multipleOnUpdate);
|
|
121
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
122
|
+
expect(output).toMatchSnapshot();
|
|
123
|
+
});
|
|
124
|
+
test('multipleOnnUpdateWithDeps', function () {
|
|
125
|
+
var component = (0, jsx_1.parseJsx)(multipleOnUpdateWithDeps);
|
|
126
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
127
|
+
expect(output).toMatchSnapshot();
|
|
128
|
+
});
|
|
129
|
+
test('onMount & onUnMount', function () {
|
|
130
|
+
var component = (0, jsx_1.parseJsx)(onMount);
|
|
131
|
+
var output = (0, html_1.componentToCustomElement)()({ component: component });
|
|
132
|
+
expect(output).toMatchSnapshot();
|
|
133
|
+
});
|
|
7
134
|
test('Stamped', function () {
|
|
8
135
|
var component = (0, jsx_1.parseJsx)(stamped);
|
|
9
136
|
var html = (0, html_1.componentToCustomElement)()({ component: component });
|
|
10
137
|
expect(html).toMatchSnapshot();
|
|
11
138
|
});
|
|
139
|
+
test('Shadow DOM', function () {
|
|
140
|
+
var component = (0, jsx_1.parseJsx)(shadowDom);
|
|
141
|
+
var html = (0, html_1.componentToCustomElement)()({ component: component });
|
|
142
|
+
expect(html).toMatchSnapshot();
|
|
143
|
+
});
|
|
12
144
|
});
|