@builder.io/sdk-qwik 0.0.9 → 0.0.10
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/lib/index.qwik.cjs +151 -207
- package/lib/index.qwik.mjs +152 -208
- package/package.json +3 -3
- package/src/blocks/button/button.jsx +0 -175
- package/src/blocks/columns/columns.jsx +27 -197
- package/src/blocks/custom-code/custom-code.jsx +16 -75
- package/src/blocks/embed/embed.jsx +20 -87
- package/src/blocks/form/builder-blocks.jsx +0 -75
- package/src/blocks/form/form.jsx +57 -536
- package/src/blocks/fragment/fragment.jsx +8 -56
- package/src/blocks/image/image.jsx +49 -493
- package/src/blocks/img/img.jsx +15 -72
- package/src/blocks/input/input.jsx +17 -83
- package/src/blocks/raw-text/raw-text.jsx +9 -50
- package/src/blocks/section/section.jsx +17 -94
- package/src/blocks/select/select.jsx +20 -145
- package/src/blocks/submit-button/submit-button.jsx +8 -84
- package/src/blocks/symbol/symbol.jsx +60 -194
- package/src/blocks/text/text.jsx +4 -43
- package/src/blocks/textarea/textarea.jsx +12 -62
- package/src/blocks/video/video.jsx +21 -71
- package/src/components/render-block/block-styles.jsx +0 -114
- package/src/components/render-block/render-block.jsx +0 -514
- package/src/components/render-block/render-component.jsx +0 -211
- package/src/components/render-block/render-repeated-block.jsx +0 -67
- package/src/components/render-blocks.jsx +40 -334
- package/src/components/render-content/components/render-styles.jsx +0 -50
- package/src/components/render-content/render-content.jsx +86 -385
- package/src/components/render-inlined-styles.jsx +0 -116
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-qwik",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Builder.io Qwik SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.qwik.cjs",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@builder.io/qwik": "0.0.
|
|
20
|
+
"@builder.io/qwik": "0.0.100",
|
|
21
21
|
"@types/node": "latest",
|
|
22
22
|
"typescript": "4.7.4",
|
|
23
23
|
"vite": "3.0.2"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@builder.io/qwik": "^0.0.
|
|
26
|
+
"@builder.io/qwik": "^0.0.100"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -20,178 +20,3 @@ export const Button = component$((props) => {
|
|
|
20
20
|
);
|
|
21
21
|
});
|
|
22
22
|
export default Button;
|
|
23
|
-
export const COMPONENT = {
|
|
24
|
-
"@type": "@builder.io/mitosis/component",
|
|
25
|
-
imports: [],
|
|
26
|
-
exports: {},
|
|
27
|
-
inputs: [],
|
|
28
|
-
meta: {},
|
|
29
|
-
refs: {},
|
|
30
|
-
state: {},
|
|
31
|
-
children: [
|
|
32
|
-
{
|
|
33
|
-
"@type": "@builder.io/mitosis/node",
|
|
34
|
-
name: "Fragment",
|
|
35
|
-
meta: {},
|
|
36
|
-
scope: {},
|
|
37
|
-
properties: {},
|
|
38
|
-
bindings: {},
|
|
39
|
-
children: [
|
|
40
|
-
{
|
|
41
|
-
"@type": "@builder.io/mitosis/node",
|
|
42
|
-
name: "div",
|
|
43
|
-
meta: {},
|
|
44
|
-
scope: {},
|
|
45
|
-
properties: {
|
|
46
|
-
_text: "\n ",
|
|
47
|
-
},
|
|
48
|
-
bindings: {},
|
|
49
|
-
children: [],
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"@type": "@builder.io/mitosis/node",
|
|
53
|
-
name: "Show",
|
|
54
|
-
meta: {
|
|
55
|
-
else: {
|
|
56
|
-
"@type": "@builder.io/mitosis/node",
|
|
57
|
-
name: "span",
|
|
58
|
-
meta: {},
|
|
59
|
-
scope: {},
|
|
60
|
-
properties: {},
|
|
61
|
-
bindings: {
|
|
62
|
-
_spread: {
|
|
63
|
-
code: "props.attributes",
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
children: [
|
|
67
|
-
{
|
|
68
|
-
"@type": "@builder.io/mitosis/node",
|
|
69
|
-
name: "div",
|
|
70
|
-
meta: {},
|
|
71
|
-
scope: {},
|
|
72
|
-
properties: {},
|
|
73
|
-
bindings: {
|
|
74
|
-
_text: {
|
|
75
|
-
code: "props.text",
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
children: [],
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
scope: {},
|
|
84
|
-
properties: {},
|
|
85
|
-
bindings: {
|
|
86
|
-
when: {
|
|
87
|
-
code: "props.link",
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
children: [
|
|
91
|
-
{
|
|
92
|
-
"@type": "@builder.io/mitosis/node",
|
|
93
|
-
name: "div",
|
|
94
|
-
meta: {},
|
|
95
|
-
scope: {},
|
|
96
|
-
properties: {
|
|
97
|
-
_text: "\n ",
|
|
98
|
-
},
|
|
99
|
-
bindings: {},
|
|
100
|
-
children: [],
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"@type": "@builder.io/mitosis/node",
|
|
104
|
-
name: "a",
|
|
105
|
-
meta: {},
|
|
106
|
-
scope: {},
|
|
107
|
-
properties: {
|
|
108
|
-
role: "button",
|
|
109
|
-
},
|
|
110
|
-
bindings: {
|
|
111
|
-
_spread: {
|
|
112
|
-
code: "props.attributes",
|
|
113
|
-
},
|
|
114
|
-
href: {
|
|
115
|
-
code: "props.link",
|
|
116
|
-
},
|
|
117
|
-
target: {
|
|
118
|
-
code: "props.openLinkInNewTab ? '_blank' : undefined",
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
children: [
|
|
122
|
-
{
|
|
123
|
-
"@type": "@builder.io/mitosis/node",
|
|
124
|
-
name: "div",
|
|
125
|
-
meta: {},
|
|
126
|
-
scope: {},
|
|
127
|
-
properties: {
|
|
128
|
-
_text: "\n ",
|
|
129
|
-
},
|
|
130
|
-
bindings: {},
|
|
131
|
-
children: [],
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
"@type": "@builder.io/mitosis/node",
|
|
135
|
-
name: "div",
|
|
136
|
-
meta: {},
|
|
137
|
-
scope: {},
|
|
138
|
-
properties: {},
|
|
139
|
-
bindings: {
|
|
140
|
-
_text: {
|
|
141
|
-
code: "props.text",
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
children: [],
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
"@type": "@builder.io/mitosis/node",
|
|
148
|
-
name: "div",
|
|
149
|
-
meta: {},
|
|
150
|
-
scope: {},
|
|
151
|
-
properties: {
|
|
152
|
-
_text: "\n ",
|
|
153
|
-
},
|
|
154
|
-
bindings: {},
|
|
155
|
-
children: [],
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
"@type": "@builder.io/mitosis/node",
|
|
161
|
-
name: "div",
|
|
162
|
-
meta: {},
|
|
163
|
-
scope: {},
|
|
164
|
-
properties: {
|
|
165
|
-
_text: "\n ",
|
|
166
|
-
},
|
|
167
|
-
bindings: {},
|
|
168
|
-
children: [],
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"@type": "@builder.io/mitosis/node",
|
|
174
|
-
name: "div",
|
|
175
|
-
meta: {},
|
|
176
|
-
scope: {},
|
|
177
|
-
properties: {
|
|
178
|
-
_text: "\n ",
|
|
179
|
-
},
|
|
180
|
-
bindings: {},
|
|
181
|
-
children: [],
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
hooks: {},
|
|
187
|
-
context: {
|
|
188
|
-
get: {},
|
|
189
|
-
set: {},
|
|
190
|
-
},
|
|
191
|
-
name: "Button",
|
|
192
|
-
subComponents: [],
|
|
193
|
-
interfaces: [
|
|
194
|
-
"export interface ButtonProps {\n attributes?: any;\n text?: string;\n link?: string;\n openLinkInNewTab?: boolean;\n}",
|
|
195
|
-
],
|
|
196
|
-
propsTypeRef: "ButtonProps",
|
|
197
|
-
};
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
// GENERATED BY MITOSIS
|
|
2
2
|
|
|
3
3
|
import RenderBlocks from "../../components/render-blocks";
|
|
4
|
-
import {
|
|
5
|
-
Fragment,
|
|
6
|
-
Host,
|
|
7
|
-
component$,
|
|
8
|
-
h,
|
|
9
|
-
useStylesScoped$,
|
|
10
|
-
} from "@builder.io/qwik";
|
|
4
|
+
import { Fragment, component$, h, useStylesScoped$ } from "@builder.io/qwik";
|
|
11
5
|
export const getGutterSize = function getGutterSize(props, state) {
|
|
12
6
|
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
13
7
|
};
|
|
@@ -63,37 +57,32 @@ export const columnCssVars = function columnCssVars(props, state) {
|
|
|
63
57
|
),
|
|
64
58
|
};
|
|
65
59
|
};
|
|
66
|
-
export const Columns = component$(
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
</Host>
|
|
93
|
-
);
|
|
94
|
-
},
|
|
95
|
-
{ tagName: "div" }
|
|
96
|
-
);
|
|
60
|
+
export const Columns = component$((props) => {
|
|
61
|
+
useStylesScoped$(STYLES);
|
|
62
|
+
const state = {};
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
class="builder-columns div-Columns"
|
|
66
|
+
style={columnsCssVars(props, state)}
|
|
67
|
+
>
|
|
68
|
+
{(props.columns || []).map((column, index) => {
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
class="builder-column div-Columns-2"
|
|
72
|
+
style={{
|
|
73
|
+
width: getColumnCssWidth(props, state, index),
|
|
74
|
+
marginLeft: `${index === 0 ? 0 : getGutterSize(props, state)}px`,
|
|
75
|
+
...columnCssVars(props, state),
|
|
76
|
+
}}
|
|
77
|
+
key={index}
|
|
78
|
+
>
|
|
79
|
+
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
})}
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
});
|
|
97
86
|
export default Columns;
|
|
98
87
|
export const STYLES = `.div-Columns {
|
|
99
88
|
display: flex;
|
|
@@ -106,162 +95,3 @@ width: var(--column-width-tablet) !important;
|
|
|
106
95
|
margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-Columns-2 {
|
|
107
96
|
width: var(--column-width) !important;
|
|
108
97
|
margin-left: var(--column-margin-left) !important; } }`;
|
|
109
|
-
export const COMPONENT = {
|
|
110
|
-
"@type": "@builder.io/mitosis/component",
|
|
111
|
-
imports: [
|
|
112
|
-
{
|
|
113
|
-
imports: {
|
|
114
|
-
RenderBlocks: "default",
|
|
115
|
-
},
|
|
116
|
-
path: "../../components/render-blocks.lite",
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
exports: {},
|
|
120
|
-
inputs: [],
|
|
121
|
-
meta: {},
|
|
122
|
-
refs: {},
|
|
123
|
-
state: {
|
|
124
|
-
getGutterSize:
|
|
125
|
-
"@builder.io/mitosis/method:getGutterSize() {\n return typeof props.space === 'number' ? props.space || 0 : 20;\n}",
|
|
126
|
-
getColumns:
|
|
127
|
-
"@builder.io/mitosis/method:getColumns() {\n return props.columns || [];\n}",
|
|
128
|
-
getWidth:
|
|
129
|
-
"@builder.io/mitosis/method:getWidth(index: number) {\n const columns = getColumns(props,state,);\n return columns[index]?.width || 100 / columns.length;\n}",
|
|
130
|
-
getColumnCssWidth:
|
|
131
|
-
"@builder.io/mitosis/method:getColumnCssWidth(index: number) {\n const columns = getColumns(props,state,);\n const gutterSize = getGutterSize(props,state,);\n const subtractWidth = gutterSize * (columns.length - 1) / columns.length;\n return `calc(${getWidth(props,state,index)}% - ${subtractWidth}px)`;\n}",
|
|
132
|
-
maybeApplyForTablet:
|
|
133
|
-
"@builder.io/mitosis/method:maybeApplyForTablet(prop: JSX.CSS['flexDirection']) {\n const _stackColumnsAt = props.stackColumnsAt || 'tablet';\n\n return _stackColumnsAt === 'tablet' ? prop : 'inherit';\n}",
|
|
134
|
-
columnsCssVars:
|
|
135
|
-
"@builder.io/mitosis/method:get columnsCssVars() {\n const flexDir = props.stackColumnsAt === 'never' ? 'inherit' : props.reverseColumnsWhenStacked ? 'column-reverse' : 'column';\n return {\n '--flex-dir': flexDir,\n '--flex-dir-tablet': maybeApplyForTablet(props,state,flexDir)\n };\n}",
|
|
136
|
-
columnCssVars:
|
|
137
|
-
"@builder.io/mitosis/method:get columnCssVars() {\n const width = '100%';\n const marginLeft = '0';\n return {\n '--column-width': width,\n '--column-margin-left': marginLeft,\n '--column-width-tablet': maybeApplyForTablet(props,state,width),\n '--column-margin-left-tablet': maybeApplyForTablet(props,state,marginLeft)\n };\n}",
|
|
138
|
-
},
|
|
139
|
-
children: [
|
|
140
|
-
{
|
|
141
|
-
"@type": "@builder.io/mitosis/node",
|
|
142
|
-
name: "Host",
|
|
143
|
-
meta: {},
|
|
144
|
-
scope: {},
|
|
145
|
-
properties: {
|
|
146
|
-
class: "builder-columns div-Columns",
|
|
147
|
-
},
|
|
148
|
-
bindings: {
|
|
149
|
-
style: {
|
|
150
|
-
code: "columnsCssVars(props,state)",
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
children: [
|
|
154
|
-
{
|
|
155
|
-
"@type": "@builder.io/mitosis/node",
|
|
156
|
-
name: "div",
|
|
157
|
-
meta: {},
|
|
158
|
-
scope: {},
|
|
159
|
-
properties: {
|
|
160
|
-
_text: "\n ",
|
|
161
|
-
},
|
|
162
|
-
bindings: {},
|
|
163
|
-
children: [],
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
"@type": "@builder.io/mitosis/node",
|
|
167
|
-
name: "For",
|
|
168
|
-
meta: {},
|
|
169
|
-
scope: {
|
|
170
|
-
For: ["column", "index"],
|
|
171
|
-
},
|
|
172
|
-
properties: {
|
|
173
|
-
_forName: "column",
|
|
174
|
-
_indexName: "index",
|
|
175
|
-
},
|
|
176
|
-
bindings: {
|
|
177
|
-
each: {
|
|
178
|
-
code: "props.columns",
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
children: [
|
|
182
|
-
{
|
|
183
|
-
"@type": "@builder.io/mitosis/node",
|
|
184
|
-
name: "div",
|
|
185
|
-
meta: {},
|
|
186
|
-
scope: {},
|
|
187
|
-
properties: {
|
|
188
|
-
class: "builder-column div-Columns-2",
|
|
189
|
-
},
|
|
190
|
-
bindings: {
|
|
191
|
-
style: {
|
|
192
|
-
code: "{\n width: getColumnCssWidth(props,state,index),\n marginLeft: `${index === 0 ? 0 : getGutterSize(props,state,)}px`,\n ...columnCssVars(props,state)\n}",
|
|
193
|
-
},
|
|
194
|
-
key: {
|
|
195
|
-
code: "index",
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
children: [
|
|
199
|
-
{
|
|
200
|
-
"@type": "@builder.io/mitosis/node",
|
|
201
|
-
name: "div",
|
|
202
|
-
meta: {},
|
|
203
|
-
scope: {},
|
|
204
|
-
properties: {
|
|
205
|
-
_text: "\n ",
|
|
206
|
-
},
|
|
207
|
-
bindings: {},
|
|
208
|
-
children: [],
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
"@type": "@builder.io/mitosis/node",
|
|
212
|
-
name: "RenderBlocks",
|
|
213
|
-
meta: {},
|
|
214
|
-
scope: {},
|
|
215
|
-
properties: {},
|
|
216
|
-
bindings: {
|
|
217
|
-
blocks: {
|
|
218
|
-
code: "column.blocks",
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
children: [],
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
"@type": "@builder.io/mitosis/node",
|
|
225
|
-
name: "div",
|
|
226
|
-
meta: {},
|
|
227
|
-
scope: {},
|
|
228
|
-
properties: {
|
|
229
|
-
_text: "\n ",
|
|
230
|
-
},
|
|
231
|
-
bindings: {},
|
|
232
|
-
children: [],
|
|
233
|
-
},
|
|
234
|
-
],
|
|
235
|
-
},
|
|
236
|
-
],
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
"@type": "@builder.io/mitosis/node",
|
|
240
|
-
name: "div",
|
|
241
|
-
meta: {},
|
|
242
|
-
scope: {},
|
|
243
|
-
properties: {
|
|
244
|
-
_text: "\n ",
|
|
245
|
-
},
|
|
246
|
-
bindings: {},
|
|
247
|
-
children: [],
|
|
248
|
-
},
|
|
249
|
-
],
|
|
250
|
-
},
|
|
251
|
-
],
|
|
252
|
-
hooks: {},
|
|
253
|
-
context: {
|
|
254
|
-
get: {},
|
|
255
|
-
set: {},
|
|
256
|
-
},
|
|
257
|
-
name: "Columns",
|
|
258
|
-
subComponents: [],
|
|
259
|
-
types: [
|
|
260
|
-
"type Column = {\n blocks: any; // TODO: Implement this when support for dynamic CSS lands\n\n width?: number;\n};",
|
|
261
|
-
"type StackColumnsAt = 'tablet' | 'mobile' | 'never';",
|
|
262
|
-
],
|
|
263
|
-
interfaces: [
|
|
264
|
-
"export interface ColumnProps {\n columns?: Column[]; // TODO: Implement this when support for dynamic CSS lands\n\n space?: number; // TODO: Implement this when support for dynamic CSS lands\n\n stackColumnsAt?: StackColumnsAt; // TODO: Implement this when support for dynamic CSS lands\n\n reverseColumnsWhenStacked?: boolean;\n}",
|
|
265
|
-
],
|
|
266
|
-
propsTypeRef: "ColumnProps",
|
|
267
|
-
};
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
Fragment,
|
|
5
|
-
Host,
|
|
6
5
|
component$,
|
|
7
6
|
h,
|
|
8
7
|
useClientEffect$,
|
|
@@ -53,78 +52,20 @@ export const findAndRunScripts = function findAndRunScripts(
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
|
-
export const CustomCode = component$(
|
|
57
|
-
(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
{ tagName: "div" }
|
|
74
|
-
);
|
|
55
|
+
export const CustomCode = component$((props) => {
|
|
56
|
+
const elem = useRef();
|
|
57
|
+
const state = useStore({ scriptsInserted: [], scriptsRun: [] });
|
|
58
|
+
useClientEffect$(() => {
|
|
59
|
+
findAndRunScripts(props, state, elem);
|
|
60
|
+
});
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
ref={elem}
|
|
64
|
+
class={
|
|
65
|
+
"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")
|
|
66
|
+
}
|
|
67
|
+
dangerouslySetInnerHTML={props.code}
|
|
68
|
+
></div>
|
|
69
|
+
);
|
|
70
|
+
});
|
|
75
71
|
export default CustomCode;
|
|
76
|
-
export const COMPONENT = {
|
|
77
|
-
"@type": "@builder.io/mitosis/component",
|
|
78
|
-
imports: [],
|
|
79
|
-
exports: {},
|
|
80
|
-
inputs: [],
|
|
81
|
-
meta: {},
|
|
82
|
-
refs: {
|
|
83
|
-
elem: {
|
|
84
|
-
argument: "",
|
|
85
|
-
typeParameter: "HTMLDivElement",
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
state: {
|
|
89
|
-
scriptsInserted: [],
|
|
90
|
-
scriptsRun: [],
|
|
91
|
-
findAndRunScripts:
|
|
92
|
-
"@builder.io/mitosis/method:findAndRunScripts() {\n // TODO: Move this function to standalone one in '@builder.io/utils'\n if (elem && typeof window !== 'undefined') {\n const scripts = elem.getElementsByTagName('script');\n\n for (let i = 0; i < scripts.length; i++) {\n const script = scripts[i];\n\n if (script.src) {\n if (state.scriptsInserted.includes(script.src)) {\n continue;\n }\n\n state.scriptsInserted.push(script.src);\n const newScript = document.createElement('script');\n newScript.async = true;\n newScript.src = script.src;\n document.head.appendChild(newScript);\n } else if (!script.type || ['text/javascript', 'application/javascript', 'application/ecmascript'].includes(script.type)) {\n if (state.scriptsRun.includes(script.innerText)) {\n continue;\n }\n\n try {\n state.scriptsRun.push(script.innerText);\n new Function(script.innerText)();\n } catch (error) {\n console.warn('`CustomCode`: Error running script:', error);\n }\n }\n }\n }\n}",
|
|
93
|
-
},
|
|
94
|
-
children: [
|
|
95
|
-
{
|
|
96
|
-
"@type": "@builder.io/mitosis/node",
|
|
97
|
-
name: "Host",
|
|
98
|
-
meta: {},
|
|
99
|
-
scope: {},
|
|
100
|
-
properties: {},
|
|
101
|
-
bindings: {
|
|
102
|
-
ref: {
|
|
103
|
-
code: "elem",
|
|
104
|
-
},
|
|
105
|
-
class: {
|
|
106
|
-
code: "'builder-custom-code' + (props.replaceNodes ? ' replace-nodes' : '')",
|
|
107
|
-
},
|
|
108
|
-
innerHTML: {
|
|
109
|
-
code: "props.code",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
children: [],
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
hooks: {
|
|
116
|
-
onMount: {
|
|
117
|
-
code: "\n findAndRunScripts(props,state,elem,);\n",
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
context: {
|
|
121
|
-
get: {},
|
|
122
|
-
set: {},
|
|
123
|
-
},
|
|
124
|
-
name: "CustomCode",
|
|
125
|
-
subComponents: [],
|
|
126
|
-
interfaces: [
|
|
127
|
-
"export interface CustomCodeProps {\n code: string;\n replaceNodes?: boolean;\n}",
|
|
128
|
-
],
|
|
129
|
-
propsTypeRef: "CustomCodeProps",
|
|
130
|
-
};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { isJsScript } from "./helpers";
|
|
4
4
|
import {
|
|
5
5
|
Fragment,
|
|
6
|
-
Host,
|
|
7
6
|
component$,
|
|
8
7
|
h,
|
|
9
8
|
useRef,
|
|
@@ -39,92 +38,26 @@ export const findAndRunScripts = function findAndRunScripts(
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
|
-
export const Embed = component$(
|
|
43
|
-
(
|
|
44
|
-
|
|
45
|
-
const state = useStore({
|
|
46
|
-
scriptsInserted: [],
|
|
47
|
-
scriptsRun: [],
|
|
48
|
-
ranInitFn: false,
|
|
49
|
-
});
|
|
50
|
-
useWatch$(({ track }) => {
|
|
51
|
-
state && track(state, "ranInitFn");
|
|
52
|
-
if (elem && !state.ranInitFn) {
|
|
53
|
-
state.ranInitFn = true;
|
|
54
|
-
findAndRunScripts(props, state, elem);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
return (
|
|
58
|
-
<Host
|
|
59
|
-
class="builder-embed"
|
|
60
|
-
ref={elem}
|
|
61
|
-
dangerouslySetInnerHTML={props.content}
|
|
62
|
-
></Host>
|
|
63
|
-
);
|
|
64
|
-
},
|
|
65
|
-
{ tagName: "div" }
|
|
66
|
-
);
|
|
67
|
-
export default Embed;
|
|
68
|
-
export const COMPONENT = {
|
|
69
|
-
"@type": "@builder.io/mitosis/component",
|
|
70
|
-
imports: [
|
|
71
|
-
{
|
|
72
|
-
imports: {
|
|
73
|
-
isJsScript: "isJsScript",
|
|
74
|
-
},
|
|
75
|
-
path: "./helpers",
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
exports: {},
|
|
79
|
-
inputs: [],
|
|
80
|
-
meta: {},
|
|
81
|
-
refs: {
|
|
82
|
-
elem: {
|
|
83
|
-
argument: "",
|
|
84
|
-
typeParameter: "HTMLDivElement",
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
state: {
|
|
41
|
+
export const Embed = component$((props) => {
|
|
42
|
+
const elem = useRef();
|
|
43
|
+
const state = useStore({
|
|
88
44
|
scriptsInserted: [],
|
|
89
45
|
scriptsRun: [],
|
|
90
46
|
ranInitFn: false,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
code: "props.content",
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
children: [],
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
hooks: {
|
|
115
|
-
onUpdate: [
|
|
116
|
-
{
|
|
117
|
-
code: "\n if (elem && !state.ranInitFn) {\n state.ranInitFn = true;\n findAndRunScripts(props,state,elem,);\n }\n",
|
|
118
|
-
deps: "[elem, state.ranInitFn]",
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
},
|
|
122
|
-
context: {
|
|
123
|
-
get: {},
|
|
124
|
-
set: {},
|
|
125
|
-
},
|
|
126
|
-
name: "Embed",
|
|
127
|
-
subComponents: [],
|
|
128
|
-
interfaces: ["export interface EmbedProps {\n content: string;\n}"],
|
|
129
|
-
propsTypeRef: "EmbedProps",
|
|
130
|
-
};
|
|
47
|
+
});
|
|
48
|
+
useWatch$(({ track }) => {
|
|
49
|
+
state && track(state, "ranInitFn");
|
|
50
|
+
if (elem && !state.ranInitFn) {
|
|
51
|
+
state.ranInitFn = true;
|
|
52
|
+
findAndRunScripts(props, state, elem);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return (
|
|
56
|
+
<div
|
|
57
|
+
class="builder-embed"
|
|
58
|
+
ref={elem}
|
|
59
|
+
dangerouslySetInnerHTML={props.content}
|
|
60
|
+
></div>
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
export default Embed;
|