@builder.io/sdk-qwik 0.0.8 → 0.0.11
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/README.md +65 -2
- package/lib/index.qwik.cjs +259 -216
- package/lib/index.qwik.mjs +260 -217
- package/package.json +4 -4
- package/src/blocks/button/button.jsx +22 -0
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/columns/columns.jsx +97 -0
- package/src/blocks/columns/component-info.js +242 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/custom-code/custom-code.jsx +71 -0
- package/src/blocks/embed/component-info.js +44 -0
- package/src/blocks/embed/embed.jsx +63 -0
- package/src/blocks/embed/helpers.js +9 -0
- package/src/blocks/form/builder-blocks.jsx +11 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/form/form.jsx +303 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/fragment/fragment.jsx +11 -0
- package/src/blocks/image/component-info.js +151 -0
- package/src/blocks/image/image.helpers.js +48 -0
- package/src/blocks/image/image.jsx +110 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/img/img.jsx +19 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/input.jsx +21 -0
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/raw-text.jsx +12 -0
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/section.jsx +20 -0
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/select.jsx +24 -0
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/submit-button.jsx +11 -0
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.jsx +77 -0
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/text/text.jsx +7 -0
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/textarea.jsx +15 -0
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/video.jsx +53 -0
- package/src/components/render-block/block-styles.jsx +60 -0
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.jsx +221 -0
- package/src/components/render-block/render-component.jsx +34 -0
- package/src/components/render-block/render-repeated-block.jsx +37 -0
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-blocks.jsx +93 -0
- package/src/components/render-content/components/render-styles.jsx +76 -0
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.jsx +351 -0
- package/src/components/render-inlined-styles.jsx +25 -0
- package/src/constants/builder-registered-components.js +48 -0
- package/src/constants/device-sizes.js +21 -0
- package/src/constants/target.js +4 -0
- package/src/context/builder.context.js +5 -0
- package/src/functions/camel-to-kebab-case.js +4 -0
- package/src/functions/convert-style-object.js +6 -0
- package/src/functions/evaluate.js +28 -0
- package/src/functions/event-handler-name.js +7 -0
- package/src/functions/get-block-actions.js +23 -0
- package/src/functions/get-block-component-options.js +28 -0
- package/src/functions/get-block-properties.js +29 -0
- package/src/functions/get-block-styles.js +34 -0
- package/src/functions/get-block-tag.js +6 -0
- package/src/functions/get-builder-search-params/fn.test.js +13 -0
- package/src/functions/get-builder-search-params/index.js +33 -0
- package/src/functions/get-content/ab-testing.js +38 -0
- package/src/functions/get-content/fn.test.js +31 -0
- package/src/functions/get-content/index.js +96 -0
- package/src/functions/get-content/types.js +0 -0
- package/src/functions/get-fetch.js +34 -0
- package/src/functions/get-global-this.js +18 -0
- package/src/functions/get-processed-block.js +53 -0
- package/src/functions/get-processed-block.test.js +32 -0
- package/src/functions/if-target.js +15 -0
- package/src/functions/is-browser.js +6 -0
- package/src/functions/is-editing.js +7 -0
- package/src/functions/is-iframe.js +7 -0
- package/src/functions/is-previewing.js +14 -0
- package/src/functions/on-change.js +27 -0
- package/src/functions/on-change.test.js +19 -0
- package/src/functions/register-component.js +72 -0
- package/src/functions/register.js +29 -0
- package/src/functions/sanitize-styles.js +5 -0
- package/src/functions/set-editor-settings.js +15 -0
- package/src/functions/set.js +11 -0
- package/src/functions/set.test.js +16 -0
- package/src/functions/track.js +22 -0
- package/src/functions/transform-block.js +6 -0
- package/src/helpers/css.js +12 -0
- package/src/helpers/flatten.js +34 -0
- package/src/index-helpers/blocks-exports.js +22 -0
- package/src/index-helpers/top-of-file.js +4 -0
- package/src/index.js +10 -0
- package/src/scripts/init-editing.js +79 -0
- package/src/types/builder-block.js +0 -0
- package/src/types/builder-content.js +0 -0
- package/src/types/components.js +0 -0
- package/src/types/deep-partial.js +0 -0
- package/src/types/element.js +0 -0
- package/src/types/targets.js +0 -0
- package/src/types/typescript.js +0 -0
- package/types.d.ts +7 -12
- package/root.json +0 -1176
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.11",
|
|
4
4
|
"description": "Builder.io Qwik SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.qwik.cjs",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build.lib": "vite build --mode lib",
|
|
17
|
-
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag
|
|
17
|
+
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag latest --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
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import { Fragment, component$, h } from "@builder.io/qwik";
|
|
4
|
+
export const Button = component$((props) => {
|
|
5
|
+
return (
|
|
6
|
+
<Fragment>
|
|
7
|
+
{props.link ? (
|
|
8
|
+
<a
|
|
9
|
+
role="button"
|
|
10
|
+
{...props.attributes}
|
|
11
|
+
href={props.link}
|
|
12
|
+
target={props.openLinkInNewTab ? "_blank" : undefined}
|
|
13
|
+
>
|
|
14
|
+
{props.text}
|
|
15
|
+
</a>
|
|
16
|
+
) : (
|
|
17
|
+
<span {...props.attributes}>{props.text}</span>
|
|
18
|
+
)}
|
|
19
|
+
</Fragment>
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
export default Button;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Core:Button",
|
|
3
|
+
builtIn: true,
|
|
4
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
|
|
5
|
+
defaultStyles: {
|
|
6
|
+
appearance: "none",
|
|
7
|
+
paddingTop: "15px",
|
|
8
|
+
paddingBottom: "15px",
|
|
9
|
+
paddingLeft: "25px",
|
|
10
|
+
paddingRight: "25px",
|
|
11
|
+
backgroundColor: "#000000",
|
|
12
|
+
color: "white",
|
|
13
|
+
borderRadius: "4px",
|
|
14
|
+
textAlign: "center",
|
|
15
|
+
cursor: "pointer"
|
|
16
|
+
},
|
|
17
|
+
inputs: [
|
|
18
|
+
{
|
|
19
|
+
name: "text",
|
|
20
|
+
type: "text",
|
|
21
|
+
defaultValue: "Click me!",
|
|
22
|
+
bubble: true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "link",
|
|
26
|
+
type: "url",
|
|
27
|
+
bubble: true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "openLinkInNewTab",
|
|
31
|
+
type: "boolean",
|
|
32
|
+
defaultValue: false,
|
|
33
|
+
friendlyName: "Open link in new tab"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
static: true,
|
|
37
|
+
noWrap: true
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
componentInfo
|
|
41
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import RenderBlocks from "../../components/render-blocks";
|
|
4
|
+
import { Fragment, component$, h, useStylesScoped$ } from "@builder.io/qwik";
|
|
5
|
+
export const getGutterSize = function getGutterSize(props, state) {
|
|
6
|
+
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
7
|
+
};
|
|
8
|
+
export const getColumns = function getColumns(props, state) {
|
|
9
|
+
return props.columns || [];
|
|
10
|
+
};
|
|
11
|
+
export const getWidth = function getWidth(props, state, index) {
|
|
12
|
+
const columns = getColumns(props, state);
|
|
13
|
+
return columns[index]?.width || 100 / columns.length;
|
|
14
|
+
};
|
|
15
|
+
export const getColumnCssWidth = function getColumnCssWidth(
|
|
16
|
+
props,
|
|
17
|
+
state,
|
|
18
|
+
index
|
|
19
|
+
) {
|
|
20
|
+
const columns = getColumns(props, state);
|
|
21
|
+
const gutterSize = getGutterSize(props, state);
|
|
22
|
+
const subtractWidth = (gutterSize * (columns.length - 1)) / columns.length;
|
|
23
|
+
return `calc(${getWidth(props, state, index)}% - ${subtractWidth}px)`;
|
|
24
|
+
};
|
|
25
|
+
export const maybeApplyForTablet = function maybeApplyForTablet(
|
|
26
|
+
props,
|
|
27
|
+
state,
|
|
28
|
+
prop
|
|
29
|
+
) {
|
|
30
|
+
const _stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
31
|
+
|
|
32
|
+
return _stackColumnsAt === "tablet" ? prop : "inherit";
|
|
33
|
+
};
|
|
34
|
+
export const columnsCssVars = function columnsCssVars(props, state) {
|
|
35
|
+
const flexDir =
|
|
36
|
+
props.stackColumnsAt === "never"
|
|
37
|
+
? "inherit"
|
|
38
|
+
: props.reverseColumnsWhenStacked
|
|
39
|
+
? "column-reverse"
|
|
40
|
+
: "column";
|
|
41
|
+
return {
|
|
42
|
+
"--flex-dir": flexDir,
|
|
43
|
+
"--flex-dir-tablet": maybeApplyForTablet(props, state, flexDir),
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export const columnCssVars = function columnCssVars(props, state) {
|
|
47
|
+
const width = "100%";
|
|
48
|
+
const marginLeft = "0";
|
|
49
|
+
return {
|
|
50
|
+
"--column-width": width,
|
|
51
|
+
"--column-margin-left": marginLeft,
|
|
52
|
+
"--column-width-tablet": maybeApplyForTablet(props, state, width),
|
|
53
|
+
"--column-margin-left-tablet": maybeApplyForTablet(
|
|
54
|
+
props,
|
|
55
|
+
state,
|
|
56
|
+
marginLeft
|
|
57
|
+
),
|
|
58
|
+
};
|
|
59
|
+
};
|
|
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
|
+
});
|
|
86
|
+
export default Columns;
|
|
87
|
+
export const STYLES = `.div-Columns {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: stretch;
|
|
90
|
+
line-height: normal; }@media (max-width: 999px) { .div-Columns {
|
|
91
|
+
flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-Columns {
|
|
92
|
+
flex-direction: var(--flex-dir); } }.div-Columns-2 {
|
|
93
|
+
flex-grow: 1; }@media (max-width: 999px) { .div-Columns-2 {
|
|
94
|
+
width: var(--column-width-tablet) !important;
|
|
95
|
+
margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-Columns-2 {
|
|
96
|
+
width: var(--column-width) !important;
|
|
97
|
+
margin-left: var(--column-margin-left) !important; } }`;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { markSerializable } from "../util";
|
|
2
|
+
const componentInfo = {
|
|
3
|
+
name: "Columns",
|
|
4
|
+
builtIn: true,
|
|
5
|
+
inputs: [
|
|
6
|
+
{
|
|
7
|
+
name: "columns",
|
|
8
|
+
type: "array",
|
|
9
|
+
broadcast: true,
|
|
10
|
+
subFields: [
|
|
11
|
+
{
|
|
12
|
+
name: "blocks",
|
|
13
|
+
type: "array",
|
|
14
|
+
hideFromUI: true,
|
|
15
|
+
defaultValue: [
|
|
16
|
+
{
|
|
17
|
+
"@type": "@builder.io/sdk:Element",
|
|
18
|
+
responsiveStyles: {
|
|
19
|
+
large: {
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "column",
|
|
22
|
+
alignItems: "stretch",
|
|
23
|
+
flexShrink: "0",
|
|
24
|
+
position: "relative",
|
|
25
|
+
marginTop: "30px",
|
|
26
|
+
textAlign: "center",
|
|
27
|
+
lineHeight: "normal",
|
|
28
|
+
height: "auto",
|
|
29
|
+
minHeight: "20px",
|
|
30
|
+
minWidth: "20px",
|
|
31
|
+
overflow: "hidden"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
component: {
|
|
35
|
+
name: "Image",
|
|
36
|
+
options: {
|
|
37
|
+
image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
38
|
+
backgroundPosition: "center",
|
|
39
|
+
backgroundSize: "cover",
|
|
40
|
+
aspectRatio: 0.7004048582995948
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"@type": "@builder.io/sdk:Element",
|
|
46
|
+
responsiveStyles: {
|
|
47
|
+
large: {
|
|
48
|
+
display: "flex",
|
|
49
|
+
flexDirection: "column",
|
|
50
|
+
alignItems: "stretch",
|
|
51
|
+
flexShrink: "0",
|
|
52
|
+
position: "relative",
|
|
53
|
+
marginTop: "30px",
|
|
54
|
+
textAlign: "center",
|
|
55
|
+
lineHeight: "normal",
|
|
56
|
+
height: "auto"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
component: {
|
|
60
|
+
name: "Text",
|
|
61
|
+
options: {
|
|
62
|
+
text: "<p>Enter some text...</p>"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "width",
|
|
70
|
+
type: "number",
|
|
71
|
+
hideFromUI: true,
|
|
72
|
+
helperText: "Width %, e.g. set to 50 to fill half of the space"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "link",
|
|
76
|
+
type: "url",
|
|
77
|
+
helperText: "Optionally set a url that clicking this column will link to"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
defaultValue: [
|
|
81
|
+
{
|
|
82
|
+
blocks: [
|
|
83
|
+
{
|
|
84
|
+
"@type": "@builder.io/sdk:Element",
|
|
85
|
+
responsiveStyles: {
|
|
86
|
+
large: {
|
|
87
|
+
display: "flex",
|
|
88
|
+
flexDirection: "column",
|
|
89
|
+
alignItems: "stretch",
|
|
90
|
+
flexShrink: "0",
|
|
91
|
+
position: "relative",
|
|
92
|
+
marginTop: "30px",
|
|
93
|
+
textAlign: "center",
|
|
94
|
+
lineHeight: "normal",
|
|
95
|
+
height: "auto",
|
|
96
|
+
minHeight: "20px",
|
|
97
|
+
minWidth: "20px",
|
|
98
|
+
overflow: "hidden"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
component: {
|
|
102
|
+
name: "Image",
|
|
103
|
+
options: {
|
|
104
|
+
image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
105
|
+
backgroundPosition: "center",
|
|
106
|
+
backgroundSize: "cover",
|
|
107
|
+
aspectRatio: 0.7004048582995948
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"@type": "@builder.io/sdk:Element",
|
|
113
|
+
responsiveStyles: {
|
|
114
|
+
large: {
|
|
115
|
+
display: "flex",
|
|
116
|
+
flexDirection: "column",
|
|
117
|
+
alignItems: "stretch",
|
|
118
|
+
flexShrink: "0",
|
|
119
|
+
position: "relative",
|
|
120
|
+
marginTop: "30px",
|
|
121
|
+
textAlign: "center",
|
|
122
|
+
lineHeight: "normal",
|
|
123
|
+
height: "auto"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
component: {
|
|
127
|
+
name: "Text",
|
|
128
|
+
options: {
|
|
129
|
+
text: "<p>Enter some text...</p>"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
blocks: [
|
|
137
|
+
{
|
|
138
|
+
"@type": "@builder.io/sdk:Element",
|
|
139
|
+
responsiveStyles: {
|
|
140
|
+
large: {
|
|
141
|
+
display: "flex",
|
|
142
|
+
flexDirection: "column",
|
|
143
|
+
alignItems: "stretch",
|
|
144
|
+
flexShrink: "0",
|
|
145
|
+
position: "relative",
|
|
146
|
+
marginTop: "30px",
|
|
147
|
+
textAlign: "center",
|
|
148
|
+
lineHeight: "normal",
|
|
149
|
+
height: "auto",
|
|
150
|
+
minHeight: "20px",
|
|
151
|
+
minWidth: "20px",
|
|
152
|
+
overflow: "hidden"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
component: {
|
|
156
|
+
name: "Image",
|
|
157
|
+
options: {
|
|
158
|
+
image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
159
|
+
backgroundPosition: "center",
|
|
160
|
+
backgroundSize: "cover",
|
|
161
|
+
aspectRatio: 0.7004048582995948
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"@type": "@builder.io/sdk:Element",
|
|
167
|
+
responsiveStyles: {
|
|
168
|
+
large: {
|
|
169
|
+
display: "flex",
|
|
170
|
+
flexDirection: "column",
|
|
171
|
+
alignItems: "stretch",
|
|
172
|
+
flexShrink: "0",
|
|
173
|
+
position: "relative",
|
|
174
|
+
marginTop: "30px",
|
|
175
|
+
textAlign: "center",
|
|
176
|
+
lineHeight: "normal",
|
|
177
|
+
height: "auto"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
component: {
|
|
181
|
+
name: "Text",
|
|
182
|
+
options: {
|
|
183
|
+
text: "<p>Enter some text...</p>"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
onChange: markSerializable((options) => {
|
|
191
|
+
function clearWidths() {
|
|
192
|
+
columns.forEach((col) => {
|
|
193
|
+
col.delete("width");
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const columns = options.get("columns");
|
|
197
|
+
if (Array.isArray(columns)) {
|
|
198
|
+
const containsColumnWithWidth = !!columns.find((col) => col.get("width"));
|
|
199
|
+
if (containsColumnWithWidth) {
|
|
200
|
+
const containsColumnWithoutWidth = !!columns.find((col) => !col.get("width"));
|
|
201
|
+
if (containsColumnWithoutWidth) {
|
|
202
|
+
clearWidths();
|
|
203
|
+
} else {
|
|
204
|
+
const sumWidths = columns.reduce((memo, col) => {
|
|
205
|
+
return memo + col.get("width");
|
|
206
|
+
}, 0);
|
|
207
|
+
const widthsDontAddUp = sumWidths !== 100;
|
|
208
|
+
if (widthsDontAddUp) {
|
|
209
|
+
clearWidths();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: "space",
|
|
218
|
+
type: "number",
|
|
219
|
+
defaultValue: 20,
|
|
220
|
+
helperText: "Size of gap between columns",
|
|
221
|
+
advanced: true
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "stackColumnsAt",
|
|
225
|
+
type: "string",
|
|
226
|
+
defaultValue: "tablet",
|
|
227
|
+
helperText: "Convert horizontal columns to vertical at what device size",
|
|
228
|
+
enum: ["tablet", "mobile", "never"],
|
|
229
|
+
advanced: true
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "reverseColumnsWhenStacked",
|
|
233
|
+
type: "boolean",
|
|
234
|
+
defaultValue: false,
|
|
235
|
+
helperText: "When stacking columns for mobile devices, reverse the ordering",
|
|
236
|
+
advanced: true
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
};
|
|
240
|
+
export {
|
|
241
|
+
componentInfo
|
|
242
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Custom Code",
|
|
3
|
+
static: true,
|
|
4
|
+
builtIn: true,
|
|
5
|
+
requiredPermissions: ["editCode"],
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "code",
|
|
9
|
+
type: "html",
|
|
10
|
+
required: true,
|
|
11
|
+
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
12
|
+
code: true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "replaceNodes",
|
|
16
|
+
type: "boolean",
|
|
17
|
+
helperText: "Preserve server rendered dom nodes",
|
|
18
|
+
advanced: true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "scriptsClientOnly",
|
|
22
|
+
type: "boolean",
|
|
23
|
+
defaultValue: false,
|
|
24
|
+
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
25
|
+
advanced: true
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
componentInfo
|
|
31
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Fragment,
|
|
5
|
+
component$,
|
|
6
|
+
h,
|
|
7
|
+
useClientEffect$,
|
|
8
|
+
useRef,
|
|
9
|
+
useStore,
|
|
10
|
+
} from "@builder.io/qwik";
|
|
11
|
+
export const findAndRunScripts = function findAndRunScripts(
|
|
12
|
+
props,
|
|
13
|
+
state,
|
|
14
|
+
elem
|
|
15
|
+
) {
|
|
16
|
+
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
17
|
+
if (elem && typeof window !== "undefined") {
|
|
18
|
+
const scripts = elem.getElementsByTagName("script");
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
21
|
+
const script = scripts[i];
|
|
22
|
+
|
|
23
|
+
if (script.src) {
|
|
24
|
+
if (state.scriptsInserted.includes(script.src)) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
state.scriptsInserted.push(script.src);
|
|
29
|
+
const newScript = document.createElement("script");
|
|
30
|
+
newScript.async = true;
|
|
31
|
+
newScript.src = script.src;
|
|
32
|
+
document.head.appendChild(newScript);
|
|
33
|
+
} else if (
|
|
34
|
+
!script.type ||
|
|
35
|
+
[
|
|
36
|
+
"text/javascript",
|
|
37
|
+
"application/javascript",
|
|
38
|
+
"application/ecmascript",
|
|
39
|
+
].includes(script.type)
|
|
40
|
+
) {
|
|
41
|
+
if (state.scriptsRun.includes(script.innerText)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
state.scriptsRun.push(script.innerText);
|
|
47
|
+
new Function(script.innerText)();
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.warn("`CustomCode`: Error running script:", error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
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
|
+
});
|
|
71
|
+
export default CustomCode;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { markSerializable } from "../util";
|
|
2
|
+
const componentInfo = {
|
|
3
|
+
name: "Embed",
|
|
4
|
+
static: true,
|
|
5
|
+
builtIn: true,
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "url",
|
|
9
|
+
type: "url",
|
|
10
|
+
required: true,
|
|
11
|
+
defaultValue: "",
|
|
12
|
+
helperText: "e.g. enter a youtube url, google map, etc",
|
|
13
|
+
onChange: markSerializable((options) => {
|
|
14
|
+
const url = options.get("url");
|
|
15
|
+
if (url) {
|
|
16
|
+
options.set("content", "Loading...");
|
|
17
|
+
const apiKey = "ae0e60e78201a3f2b0de4b";
|
|
18
|
+
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
|
|
19
|
+
if (options.get("url") === url) {
|
|
20
|
+
if (data.html) {
|
|
21
|
+
options.set("content", data.html);
|
|
22
|
+
} else {
|
|
23
|
+
options.set("content", "Invalid url, please try another");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}).catch((_err) => {
|
|
27
|
+
options.set("content", "There was an error embedding this URL, please try again or another URL");
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
options.delete("content");
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "content",
|
|
36
|
+
type: "html",
|
|
37
|
+
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
38
|
+
hideFromUI: true
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
componentInfo
|
|
44
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import { isJsScript } from "./helpers";
|
|
4
|
+
import {
|
|
5
|
+
Fragment,
|
|
6
|
+
component$,
|
|
7
|
+
h,
|
|
8
|
+
useRef,
|
|
9
|
+
useStore,
|
|
10
|
+
useWatch$,
|
|
11
|
+
} from "@builder.io/qwik";
|
|
12
|
+
export const findAndRunScripts = function findAndRunScripts(
|
|
13
|
+
props,
|
|
14
|
+
state,
|
|
15
|
+
elem
|
|
16
|
+
) {
|
|
17
|
+
const scripts = elem.getElementsByTagName("script");
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
20
|
+
const script = scripts[i];
|
|
21
|
+
|
|
22
|
+
if (script.src && !state.scriptsInserted.includes(script.src)) {
|
|
23
|
+
state.scriptsInserted.push(script.src);
|
|
24
|
+
const newScript = document.createElement("script");
|
|
25
|
+
newScript.async = true;
|
|
26
|
+
newScript.src = script.src;
|
|
27
|
+
document.head.appendChild(newScript);
|
|
28
|
+
} else if (
|
|
29
|
+
isJsScript(script) &&
|
|
30
|
+
!state.scriptsRun.includes(script.innerText)
|
|
31
|
+
) {
|
|
32
|
+
try {
|
|
33
|
+
state.scriptsRun.push(script.innerText);
|
|
34
|
+
new Function(script.innerText)();
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.warn("`Embed`: Error running script:", error);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export const Embed = component$((props) => {
|
|
42
|
+
const elem = useRef();
|
|
43
|
+
const state = useStore({
|
|
44
|
+
scriptsInserted: [],
|
|
45
|
+
scriptsRun: [],
|
|
46
|
+
ranInitFn: false,
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// GENERATED BY MITOSIS
|
|
2
|
+
|
|
3
|
+
import { Fragment, component$, h } from "@builder.io/qwik";
|
|
4
|
+
export const BuilderBlocks = component$((props) => {
|
|
5
|
+
return (
|
|
6
|
+
<Fragment>
|
|
7
|
+
NOT YET IMPLEMENTED: <code>BuilderBlocks</code>
|
|
8
|
+
</Fragment>
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
export default BuilderBlocks;
|