@builder.io/sdk-solid 0.0.5 → 0.0.8-0
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/package.json +9 -2
- package/src/blocks/button/button.jsx +13 -0
- package/src/blocks/button/button.lite.tsx +20 -0
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/button/index.js +7 -0
- package/src/blocks/columns/columns.jsx +91 -0
- package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +32 -26
- package/src/blocks/columns/component-info.js +217 -0
- package/src/blocks/columns/index.js +7 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/{custom-code.js → custom-code/custom-code.jsx} +5 -26
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +3 -1
- package/src/blocks/custom-code/index.js +7 -0
- package/src/blocks/embed/component-info.js +24 -0
- package/src/blocks/embed/embed.jsx +51 -0
- package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +3 -1
- package/src/blocks/embed/index.js +7 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/form/form.jsx +253 -0
- package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +14 -8
- package/src/blocks/form/index.js +7 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/fragment/fragment.jsx +5 -0
- package/src/blocks/fragment/fragment.lite.tsx +5 -0
- package/src/blocks/fragment/index.js +7 -0
- package/src/blocks/image/component-info.js +104 -0
- package/src/blocks/image/image.jsx +54 -0
- package/src/blocks/image/image.lite.tsx +83 -0
- package/src/blocks/image/index.js +7 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/img/img.jsx +10 -0
- package/src/blocks/{img.lite.tsx → img/img.lite.tsx} +4 -2
- package/src/blocks/img/index.js +7 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/index.js +7 -0
- package/src/blocks/input/input.jsx +7 -0
- package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +4 -2
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/index.js +7 -0
- package/src/blocks/raw-text/raw-text.jsx +5 -0
- package/src/blocks/{raw-text.lite.tsx → raw-text/raw-text.lite.tsx} +3 -1
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/index.js +7 -0
- package/src/blocks/section/section.jsx +9 -0
- package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +3 -1
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/index.js +7 -0
- package/src/blocks/select/select.jsx +16 -0
- package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +10 -5
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/index.js +7 -0
- package/src/blocks/submit-button/submit-button.jsx +7 -0
- package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +3 -1
- package/src/blocks/symbol/component-info.js +42 -0
- package/src/blocks/symbol/index.js +7 -0
- package/src/blocks/symbol/symbol.jsx +24 -0
- package/src/blocks/{symbol.lite.tsx → symbol/symbol.lite.tsx} +6 -4
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/text/index.js +7 -0
- package/src/blocks/{text.lite.tsx → text/text.jsx} +3 -1
- package/src/blocks/text/text.lite.tsx +5 -0
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/index.js +7 -0
- package/src/blocks/textarea/textarea.jsx +5 -0
- package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +3 -1
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/index.js +7 -0
- package/src/blocks/video/video.jsx +14 -0
- package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +3 -1
- package/src/components/error-boundary.jsx +5 -0
- package/src/components/error-boundary.lite.tsx +3 -1
- package/src/components/render-block/block-styles.jsx +36 -0
- package/src/components/render-block/block-styles.lite.tsx +38 -0
- package/src/components/render-block/render-block.jsx +117 -0
- package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +24 -13
- package/src/components/render-blocks.jsx +57 -0
- package/src/components/render-blocks.lite.tsx +9 -6
- package/src/components/render-content/components/{render-styles.js → render-styles.jsx} +8 -15
- package/src/components/render-content/components/render-styles.lite.tsx +10 -4
- package/src/components/render-content/{render-content.js → render-content.jsx} +42 -94
- package/src/components/render-content/render-content.lite.tsx +23 -20
- package/src/components/render-inlined-styles.jsx +23 -0
- package/src/components/render-inlined-styles.lite.tsx +26 -0
- package/src/functions/evaluate.js +2 -2
- package/src/functions/get-block-actions.js +2 -2
- package/src/functions/get-builder-search-params/fn.test.js +1 -1
- package/src/functions/get-content/index.js +3 -2
- package/src/functions/get-fetch.js +29 -7
- package/src/functions/get-processed-block.js +3 -3
- package/src/functions/get-processed-block.test.js +1 -1
- package/src/functions/if-target.js +1 -1
- package/src/functions/is-editing.js +1 -1
- package/src/functions/is-iframe.js +1 -1
- package/src/functions/is-previewing.js +2 -2
- package/src/functions/on-change.test.js +1 -1
- package/src/functions/previewing-model-name.js +1 -1
- package/src/functions/register-component.js +1 -1
- package/src/functions/register.js +1 -1
- package/src/functions/set-editor-settings.js +1 -1
- package/src/functions/set.test.js +1 -1
- package/src/functions/track.js +3 -3
- package/src/index-helpers/blocks-exports.js +8 -8
- package/src/index.js +10 -13
- package/src/scripts/init-editing.js +72 -63
- package/src/blocks/button.js +0 -32
- package/src/blocks/button.lite.tsx +0 -12
- package/src/blocks/columns.js +0 -133
- package/src/blocks/embed.js +0 -62
- package/src/blocks/form.js +0 -355
- package/src/blocks/fragment.js +0 -15
- package/src/blocks/fragment.lite.tsx +0 -3
- package/src/blocks/image.js +0 -211
- package/src/blocks/image.lite.tsx +0 -169
- package/src/blocks/img.js +0 -39
- package/src/blocks/input.js +0 -45
- package/src/blocks/raw-text.js +0 -25
- package/src/blocks/section.js +0 -24
- package/src/blocks/select.js +0 -57
- package/src/blocks/submit-button.js +0 -18
- package/src/blocks/symbol.js +0 -69
- package/src/blocks/text.js +0 -15
- package/src/blocks/textarea.js +0 -34
- package/src/blocks/video.js +0 -54
- package/src/components/block-styles.js +0 -3
- package/src/components/block-styles.lite.tsx +0 -3
- package/src/components/error-boundary.js +0 -3
- package/src/components/render-block.js +0 -154
- package/src/components/render-blocks.js +0 -104
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { getGlobalThis } from "./get-global-this.js";
|
|
2
22
|
function getFetch() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
23
|
+
return __async(this, null, function* () {
|
|
24
|
+
const globalFetch = getGlobalThis().fetch;
|
|
25
|
+
if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
|
|
26
|
+
const nodeFetch = import("node-fetch").then((d) => d.default);
|
|
27
|
+
return nodeFetch;
|
|
28
|
+
}
|
|
29
|
+
return globalFetch;
|
|
30
|
+
});
|
|
9
31
|
}
|
|
10
32
|
export {
|
|
11
33
|
getFetch
|
|
@@ -17,9 +17,9 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { evaluate } from "./evaluate";
|
|
21
|
-
import { set } from "./set";
|
|
22
|
-
import { transformBlock } from "./transform-block";
|
|
20
|
+
import { evaluate } from "./evaluate.js";
|
|
21
|
+
import { set } from "./set.js";
|
|
22
|
+
import { transformBlock } from "./transform-block.js";
|
|
23
23
|
function getProcessedBlock(options) {
|
|
24
24
|
const { state, context } = options;
|
|
25
25
|
const block = transformBlock(options.block);
|
|
@@ -17,7 +17,7 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { isBrowser } from "./is-browser";
|
|
20
|
+
import { isBrowser } from "./is-browser.js";
|
|
21
21
|
const components = {};
|
|
22
22
|
function registerComponent(component, info) {
|
|
23
23
|
var _a;
|
package/src/functions/track.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TARGET } from "../constants/target";
|
|
2
|
-
import { isBrowser } from "./is-browser";
|
|
3
|
-
import { isEditing } from "./is-editing";
|
|
1
|
+
import { TARGET } from "../constants/target.js";
|
|
2
|
+
import { isBrowser } from "./is-browser.js";
|
|
3
|
+
import { isEditing } from "./is-editing.js";
|
|
4
4
|
function track(event, properties) {
|
|
5
5
|
if (isEditing()) {
|
|
6
6
|
return;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { default as default2 } from "../blocks/columns";
|
|
2
|
-
import { default as default3 } from "../blocks/image";
|
|
3
|
-
import { default as default4 } from "../blocks/text";
|
|
4
|
-
import { default as default5 } from "../blocks/video";
|
|
5
|
-
import { default as default6 } from "../blocks/symbol";
|
|
6
|
-
import { default as default7 } from "../blocks/button";
|
|
7
|
-
import { default as default8 } from "../blocks/section";
|
|
8
|
-
import { default as default9 } from "../blocks/fragment";
|
|
1
|
+
import { default as default2 } from "../blocks/columns/index.js";
|
|
2
|
+
import { default as default3 } from "../blocks/image/index.js";
|
|
3
|
+
import { default as default4 } from "../blocks/text/index.js";
|
|
4
|
+
import { default as default5 } from "../blocks/video/index.js";
|
|
5
|
+
import { default as default6 } from "../blocks/symbol/index.js";
|
|
6
|
+
import { default as default7 } from "../blocks/button/index.js";
|
|
7
|
+
import { default as default8 } from "../blocks/section/index.js";
|
|
8
|
+
import { default as default9 } from "../blocks/fragment/index.js";
|
|
9
9
|
import { default as default10 } from "../components/render-content/render-content";
|
|
10
10
|
export {
|
|
11
11
|
default7 as Button,
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./functions/
|
|
8
|
-
export * from "./functions/
|
|
9
|
-
export * from "./functions/
|
|
10
|
-
export * from "./functions/
|
|
11
|
-
export * from "./functions/set-editor-settings";
|
|
12
|
-
export * from "./functions/get-content";
|
|
13
|
-
export * from "./functions/get-builder-search-params";
|
|
1
|
+
import "./index-helpers/top-of-file.js";
|
|
2
|
+
import "./scripts/init-editing.js";
|
|
3
|
+
export * from "./index-helpers/blocks-exports.js";
|
|
4
|
+
export * from "./functions/is-editing.js";
|
|
5
|
+
export * from "./functions/is-previewing.js";
|
|
6
|
+
export * from "./functions/register-component.js";
|
|
7
|
+
export * from "./functions/register.js";
|
|
8
|
+
export * from "./functions/set-editor-settings.js";
|
|
9
|
+
export * from "./functions/get-content/index.js";
|
|
10
|
+
export * from "./functions/get-builder-search-params/index.js";
|
|
@@ -1,71 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { register } from "../functions/register";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { TARGET } from "../constants/target.js";
|
|
2
|
+
import { isBrowser } from "../functions/is-browser.js";
|
|
3
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
4
|
+
import { register } from "../functions/register.js";
|
|
5
|
+
const registerInsertMenu = () => {
|
|
6
|
+
register("insertMenu", {
|
|
7
|
+
name: "_default",
|
|
8
|
+
default: true,
|
|
9
|
+
items: [
|
|
10
|
+
{ name: "Box" },
|
|
11
|
+
{ name: "Text" },
|
|
12
|
+
{ name: "Image" },
|
|
13
|
+
{ name: "Columns" },
|
|
14
|
+
...TARGET === "reactNative" ? [] : [
|
|
15
|
+
{ name: "Core:Section" },
|
|
16
|
+
{ name: "Core:Button" },
|
|
17
|
+
{ name: "Embed" },
|
|
18
|
+
{ name: "Custom Code" }
|
|
19
|
+
]
|
|
18
20
|
]
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const setupBrowserForEditing = () => {
|
|
24
|
+
var _a;
|
|
25
|
+
if (isBrowser()) {
|
|
26
|
+
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
27
|
+
type: "builder.sdkInfo",
|
|
28
|
+
data: {
|
|
29
|
+
target: TARGET,
|
|
30
|
+
supportsPatchUpdates: false
|
|
31
|
+
}
|
|
32
|
+
}, "*");
|
|
33
|
+
window.addEventListener("message", ({ data }) => {
|
|
34
|
+
var _a2, _b;
|
|
35
|
+
if (data) {
|
|
36
|
+
switch (data.type) {
|
|
37
|
+
case "builder.evaluate": {
|
|
38
|
+
const text = data.data.text;
|
|
39
|
+
const args = data.data.arguments || [];
|
|
40
|
+
const id = data.data.id;
|
|
41
|
+
const fn = new Function(text);
|
|
42
|
+
let result;
|
|
43
|
+
let error = null;
|
|
44
|
+
try {
|
|
45
|
+
result = fn.apply(null, args);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
error = err;
|
|
48
|
+
}
|
|
49
|
+
if (error) {
|
|
50
|
+
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
51
|
+
type: "builder.evaluateError",
|
|
52
|
+
data: { id, error: error.message }
|
|
53
|
+
}, "*");
|
|
54
|
+
} else {
|
|
55
|
+
if (result && typeof result.then === "function") {
|
|
56
|
+
result.then((finalResult) => {
|
|
57
|
+
var _a3;
|
|
58
|
+
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
59
|
+
type: "builder.evaluateResult",
|
|
60
|
+
data: { id, result: finalResult }
|
|
61
|
+
}, "*");
|
|
62
|
+
}).catch(console.error);
|
|
63
|
+
} else {
|
|
64
|
+
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
55
65
|
type: "builder.evaluateResult",
|
|
56
|
-
data: {
|
|
66
|
+
data: { result, id }
|
|
57
67
|
}, "*");
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
61
|
-
type: "builder.evaluateResult",
|
|
62
|
-
data: { result, id }
|
|
63
|
-
}, "*");
|
|
68
|
+
}
|
|
64
69
|
}
|
|
70
|
+
break;
|
|
65
71
|
}
|
|
66
|
-
break;
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
if (isEditing()) {
|
|
78
|
+
registerInsertMenu();
|
|
79
|
+
setupBrowserForEditing();
|
|
71
80
|
}
|
package/src/blocks/button.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { template as _$template } from "solid-js/web";
|
|
2
|
-
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
3
|
-
import { effect as _$effect } from "solid-js/web";
|
|
4
|
-
import { insert as _$insert } from "solid-js/web";
|
|
5
|
-
import { spread as _$spread } from "solid-js/web";
|
|
6
|
-
|
|
7
|
-
const _tmpl$ = /*#__PURE__*/_$template(`<a role="button"></a>`, 2);
|
|
8
|
-
|
|
9
|
-
export default function Button(props) {
|
|
10
|
-
return (() => {
|
|
11
|
-
const _el$ = _tmpl$.cloneNode(true);
|
|
12
|
-
|
|
13
|
-
_$spread(_el$, () => props.attributes, false, true);
|
|
14
|
-
|
|
15
|
-
_$insert(_el$, () => props.text);
|
|
16
|
-
|
|
17
|
-
_$effect(_p$ => {
|
|
18
|
-
const _v$ = props.link,
|
|
19
|
-
_v$2 = props.openLinkInNewTab ? "_blank" : undefined;
|
|
20
|
-
|
|
21
|
-
_v$ !== _p$._v$ && _$setAttribute(_el$, "href", _p$._v$ = _v$);
|
|
22
|
-
_v$2 !== _p$._v$2 && _$setAttribute(_el$, "target", _p$._v$2 = _v$2);
|
|
23
|
-
return _p$;
|
|
24
|
-
}, {
|
|
25
|
-
_v$: undefined,
|
|
26
|
-
_v$2: undefined
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return _el$;
|
|
30
|
-
})();
|
|
31
|
-
}import { registerComponent } from '../functions/register-component';
|
|
32
|
-
registerComponent(Button, {name:'Core:Button',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13',defaultStyles:{appearance:'none',paddingTop:'15px',paddingBottom:'15px',paddingLeft:'25px',paddingRight:'25px',backgroundColor:'#000000',color:'white',borderRadius:'4px',textAlign:'center',cursor:'pointer'},inputs:[{name:'text',type:'text',defaultValue:'Click me!',bubble:true},{name:'link',type:'url',bubble:true},{name:'openLinkInNewTab',type:'boolean',defaultValue:false,friendlyName:'Open link in new tab'}],static:true,noWrap:true});
|
package/src/blocks/columns.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { template as _$template } from "solid-js/web";
|
|
2
|
-
import { style as _$style } from "solid-js/web";
|
|
3
|
-
import { effect as _$effect } from "solid-js/web";
|
|
4
|
-
import { insert as _$insert } from "solid-js/web";
|
|
5
|
-
import { createComponent as _$createComponent } from "solid-js/web";
|
|
6
|
-
|
|
7
|
-
const _tmpl$ = /*#__PURE__*/_$template(`<div></div>`, 2);
|
|
8
|
-
|
|
9
|
-
import { For } from "solid-js";
|
|
10
|
-
import { createMutable } from "solid-js/store";
|
|
11
|
-
import { css } from "solid-styled-components";
|
|
12
|
-
import RenderBlocks from "../components/render-blocks";
|
|
13
|
-
export default function Columns(props) {
|
|
14
|
-
const state = createMutable({
|
|
15
|
-
getGutterSize() {
|
|
16
|
-
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
getColumns() {
|
|
20
|
-
return props.columns || [];
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
getWidth(index) {
|
|
24
|
-
const columns = this.getColumns();
|
|
25
|
-
return columns[index]?.width || 100 / columns.length;
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
getColumnCssWidth(index) {
|
|
29
|
-
const columns = this.getColumns();
|
|
30
|
-
const gutterSize = this.getGutterSize();
|
|
31
|
-
const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
|
|
32
|
-
return `calc(${this.getWidth(index)}% - ${subtractWidth}px)`;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
maybeApplyForTablet(prop) {
|
|
36
|
-
const stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
37
|
-
return stackColumnsAt === "tablet" ? prop : "inherit";
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
get columnsCssVars() {
|
|
41
|
-
const flexDir = props.stackColumnsAt === "never" ? "inherit" : props.reverseColumnsWhenStacked ? "column-reverse" : "column";
|
|
42
|
-
return {
|
|
43
|
-
"--flex-dir": flexDir,
|
|
44
|
-
"--flex-dir-tablet": this.maybeApplyForTablet(flexDir)
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
get columnCssVars() {
|
|
49
|
-
const width = "100%";
|
|
50
|
-
const marginLeft = "0";
|
|
51
|
-
return {
|
|
52
|
-
"--column-width": width,
|
|
53
|
-
"--column-margin-left": marginLeft,
|
|
54
|
-
"--column-width-tablet": this.maybeApplyForTablet(width),
|
|
55
|
-
"--column-margin-left-tablet": this.maybeApplyForTablet(marginLeft)
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
return (() => {
|
|
61
|
-
const _el$ = _tmpl$.cloneNode(true);
|
|
62
|
-
|
|
63
|
-
_$insert(_el$, _$createComponent(For, {
|
|
64
|
-
get each() {
|
|
65
|
-
return props.columns;
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
children: (column, index) => (() => {
|
|
69
|
-
const _el$2 = _tmpl$.cloneNode(true);
|
|
70
|
-
|
|
71
|
-
_$insert(_el$2, _$createComponent(RenderBlocks, {
|
|
72
|
-
get blocks() {
|
|
73
|
-
return column.blocks;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
}));
|
|
77
|
-
|
|
78
|
-
_$effect(_p$ => {
|
|
79
|
-
const _v$3 = css({
|
|
80
|
-
flexGrow: "1",
|
|
81
|
-
"@media (max-width: 999px)": {
|
|
82
|
-
width: "var(--column-width-tablet) !important",
|
|
83
|
-
marginLeft: "var(--column-margin-left-tablet) !important"
|
|
84
|
-
},
|
|
85
|
-
"@media (max-width: 639px)": {
|
|
86
|
-
width: "var(--column-width) !important",
|
|
87
|
-
marginLeft: "var(--column-margin-left) !important"
|
|
88
|
-
}
|
|
89
|
-
}),
|
|
90
|
-
_v$4 = {
|
|
91
|
-
width: state.getColumnCssWidth(index),
|
|
92
|
-
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
93
|
-
...state.columnCssVars
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
_v$3 !== _p$._v$3 && (_el$2.className = _p$._v$3 = _v$3);
|
|
97
|
-
_p$._v$4 = _$style(_el$2, _v$4, _p$._v$4);
|
|
98
|
-
return _p$;
|
|
99
|
-
}, {
|
|
100
|
-
_v$3: undefined,
|
|
101
|
-
_v$4: undefined
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
return _el$2;
|
|
105
|
-
})()
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
_$effect(_p$ => {
|
|
109
|
-
const _v$ = css({
|
|
110
|
-
display: "flex",
|
|
111
|
-
alignItems: "stretch",
|
|
112
|
-
lineHeight: "normal",
|
|
113
|
-
"@media (max-width: 999px)": {
|
|
114
|
-
flexDirection: "var(--flex-dir-tablet)"
|
|
115
|
-
},
|
|
116
|
-
"@media (max-width: 639px)": {
|
|
117
|
-
flexDirection: "var(--flex-dir)"
|
|
118
|
-
}
|
|
119
|
-
}),
|
|
120
|
-
_v$2 = state.columnsCssVars;
|
|
121
|
-
|
|
122
|
-
_v$ !== _p$._v$ && (_el$.className = _p$._v$ = _v$);
|
|
123
|
-
_p$._v$2 = _$style(_el$, _v$2, _p$._v$2);
|
|
124
|
-
return _p$;
|
|
125
|
-
}, {
|
|
126
|
-
_v$: undefined,
|
|
127
|
-
_v$2: undefined
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
return _el$;
|
|
131
|
-
})();
|
|
132
|
-
}import { registerComponent } from '../functions/register-component';
|
|
133
|
-
registerComponent(Columns, {name:'Columns',builtIn:true,inputs:[{name:'columns',type:'array',broadcast:true,subFields:[{name:'blocks',type:'array',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]},{name:'width',type:'number',hideFromUI:true,helperText:'Width %, e.g. set to 50 to fill half of the space'},{name:'link',type:'url',helperText:'Optionally set a url that clicking this column will link to'}],defaultValue:[{blocks:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]},{blocks:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]}],onChange:" function clearWidths() { columns.forEach(col => { col.delete('width'); }); } const columns = options.get('columns') as Array<Map<String, any>>; if (Array.isArray(columns)) { const containsColumnWithWidth = !!columns.find(col => col.get('width')); if (containsColumnWithWidth) { const containsColumnWithoutWidth = !!columns.find(col => !col.get('width')); if (containsColumnWithoutWidth) { clearWidths(); } else { const sumWidths = columns.reduce((memo, col) => { return memo + col.get('width'); }, 0); const widthsDontAddUp = sumWidths !== 100; if (widthsDontAddUp) { clearWidths(); } } } } "},{name:'space',type:'number',defaultValue:20,helperText:'Size of gap between columns',advanced:true},{name:'stackColumnsAt',type:'string',defaultValue:'tablet',helperText:'Convert horizontal columns to vertical at what device size',enum:['tablet','mobile','never'],advanced:true},{name:'reverseColumnsWhenStacked',type:'boolean',defaultValue:false,helperText:'When stacking columns for mobile devices, reverse the ordering',advanced:true}]});
|
package/src/blocks/embed.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { template as _$template } from "solid-js/web";
|
|
2
|
-
import { effect as _$effect } from "solid-js/web";
|
|
3
|
-
|
|
4
|
-
const _tmpl$ = /*#__PURE__*/_$template(`<div></div>`, 2);
|
|
5
|
-
|
|
6
|
-
import { createMutable } from "solid-js/store";
|
|
7
|
-
export default function Embed(props) {
|
|
8
|
-
const state = createMutable({
|
|
9
|
-
scriptsInserted: [],
|
|
10
|
-
scriptsRun: [],
|
|
11
|
-
|
|
12
|
-
findAndRunScripts() {
|
|
13
|
-
// TODO: Move this function to standalone one in '@builder.io/utils'
|
|
14
|
-
if (elem && typeof window !== "undefined") {
|
|
15
|
-
/** @type {HTMLScriptElement[]} */
|
|
16
|
-
const scripts = elem.getElementsByTagName("script");
|
|
17
|
-
|
|
18
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
19
|
-
const script = scripts[i];
|
|
20
|
-
|
|
21
|
-
if (script.src) {
|
|
22
|
-
if (state.scriptsInserted.includes(script.src)) {
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
state.scriptsInserted.push(script.src);
|
|
27
|
-
const newScript = document.createElement("script");
|
|
28
|
-
newScript.async = true;
|
|
29
|
-
newScript.src = script.src;
|
|
30
|
-
document.head.appendChild(newScript);
|
|
31
|
-
} else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
|
|
32
|
-
if (state.scriptsRun.includes(script.innerText)) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
state.scriptsRun.push(script.innerText);
|
|
38
|
-
new Function(script.innerText)();
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.warn("`Embed`: Error running script:", error);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
const elem = useRef();
|
|
49
|
-
onMount(() => {
|
|
50
|
-
state.findAndRunScripts();
|
|
51
|
-
});
|
|
52
|
-
return (() => {
|
|
53
|
-
const _el$ = _tmpl$.cloneNode(true);
|
|
54
|
-
|
|
55
|
-
elem(_el$);
|
|
56
|
-
|
|
57
|
-
_$effect(() => _el$.innerHTML = props.content);
|
|
58
|
-
|
|
59
|
-
return _el$;
|
|
60
|
-
})();
|
|
61
|
-
}import { registerComponent } from '../functions/register-component';
|
|
62
|
-
registerComponent(Embed, {name:'Embed',static:true,builtIn:true,inputs:[{name:'url',type:'url',required:true,defaultValue:'',helperText:'e.g. enter a youtube url, google map, etc',onChange:" const url = options.get('url'); if (url) { options.set('content', 'Loading...'); // TODO: get this out of here! const apiKey = 'ae0e60e78201a3f2b0de4b'; return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`) .then(res => res.json()) .then(data => { if (options.get('url') === url) { if (data.html) { options.set('content', data.html); } else { options.set('content', 'Invalid url, please try another'); } } }) .catch(err => { options.set( 'content', 'There was an error embedding this URL, please try again or another URL' ); }); } else { options.delete('content'); } "},{name:'content',type:'html',defaultValue:'<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',hideFromUI:true}]});
|