@builder.io/sdk-solid 0.0.7 → 0.0.8-2
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 +8 -1
- 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} +4 -3
- 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.jsx → custom-code/custom-code.jsx} +1 -2
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +0 -0
- package/src/blocks/custom-code/index.js +7 -0
- package/src/blocks/embed/component-info.js +24 -0
- package/src/blocks/{embed.jsx → embed/embed.jsx} +1 -2
- package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +0 -0
- package/src/blocks/embed/index.js +7 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/{form.jsx → form/form.jsx} +8 -8
- package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +7 -6
- 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.lite.tsx → fragment/fragment.lite.tsx} +0 -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} +1 -1
- 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} +1 -1
- 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} +0 -0
- 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} +0 -0
- 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} +1 -1
- 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} +0 -0
- 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} +3 -3
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/text/index.js +7 -0
- package/src/blocks/text/text.jsx +5 -0
- package/src/blocks/{text.lite.tsx → text/text.lite.tsx} +0 -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} +0 -0
- 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} +0 -0
- 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.jsx → render-block/render-block.jsx} +14 -13
- package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +13 -10
- package/src/components/render-blocks.jsx +2 -2
- package/src/components/render-blocks.lite.tsx +2 -2
- package/src/components/render-content/components/render-styles.jsx +6 -5
- package/src/components/render-content/components/render-styles.lite.tsx +9 -5
- package/src/components/render-content/render-content.jsx +19 -18
- package/src/components/render-content/render-content.lite.tsx +20 -19
- 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.jsx +0 -8
- package/src/blocks/button.lite.tsx +0 -14
- package/src/blocks/columns.jsx +0 -96
- package/src/blocks/fragment.jsx +0 -6
- package/src/blocks/image.jsx +0 -120
- package/src/blocks/image.lite.tsx +0 -171
- package/src/blocks/img.jsx +0 -11
- package/src/blocks/input.jsx +0 -8
- package/src/blocks/raw-text.jsx +0 -6
- package/src/blocks/section.jsx +0 -10
- package/src/blocks/select.jsx +0 -17
- package/src/blocks/submit-button.jsx +0 -8
- package/src/blocks/symbol.jsx +0 -25
- package/src/blocks/text.jsx +0 -6
- package/src/blocks/textarea.jsx +0 -6
- package/src/blocks/video.jsx +0 -15
- package/src/components/block-styles.jsx +0 -5
- package/src/components/block-styles.lite.tsx +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { convertSearchParamsToQueryObject, getBuilderSearchParams } from ".";
|
|
2
2
|
const querystring = "someotherValue=jklsjfdal&abc=klfdjklgfds&builder.cachebust=true&builder.preview=page&builder.noCache=true&__builder_editing__=true&builder.overrides.page=037948e52eaf4743afed464f02c70da4&builder.overrides.037948e52eaf4743afed464f02c70da4=037948e52eaf4743afed464f02c70da4&builder.overrides.page%3A%2F=037948e52eaf4743afed464f02c70da4&preview_theme_id=128854393017";
|
|
3
3
|
const url = new URL(`localhost:3000/about-us?${querystring}`);
|
|
4
4
|
describe("Get Builder SearchParams", () => {
|
|
@@ -37,8 +37,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
37
37
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
-
import { getFetch } from "../get-fetch";
|
|
41
|
-
const fetch = getFetch();
|
|
40
|
+
import { getFetch } from "../get-fetch.js";
|
|
41
|
+
const fetch$ = getFetch();
|
|
42
42
|
function flatten(object, path = null, separator = ".") {
|
|
43
43
|
return Object.keys(object).reduce((acc, key) => {
|
|
44
44
|
const value = object[key];
|
|
@@ -123,6 +123,7 @@ const handleABTesting = (content, testGroups) => {
|
|
|
123
123
|
function getAllContent(options) {
|
|
124
124
|
return __async(this, null, function* () {
|
|
125
125
|
const url = generateContentUrl(options);
|
|
126
|
+
const fetch = yield fetch$;
|
|
126
127
|
const content = yield fetch(url.href).then((res) => res.json());
|
|
127
128
|
if (options.testGroups) {
|
|
128
129
|
handleABTesting(content, options.testGroups);
|
|
@@ -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.jsx
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
function Button(props) {
|
|
2
|
-
return <a {...props.attributes} role="button" href={props.link} target={props.openLinkInNewTab ? "_blank" : undefined}>
|
|
3
|
-
{props.text}
|
|
4
|
-
</a>;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default Button;import { registerComponent } from '../functions/register-component';
|
|
8
|
-
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.jsx
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { For } from "solid-js";
|
|
2
|
-
import { createMutable } from "solid-js/store";
|
|
3
|
-
import { css } from "solid-styled-components";
|
|
4
|
-
import RenderBlocks from "../components/render-blocks";
|
|
5
|
-
|
|
6
|
-
function Columns(props) {
|
|
7
|
-
console.log('columns')
|
|
8
|
-
const state = createMutable({
|
|
9
|
-
getGutterSize() {
|
|
10
|
-
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
getColumns() {
|
|
14
|
-
return props.columns || [];
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
getWidth(index) {
|
|
18
|
-
const columns = this.getColumns();
|
|
19
|
-
return columns[index]?.width || 100 / columns.length;
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
getColumnCssWidth(index) {
|
|
23
|
-
const columns = this.getColumns();
|
|
24
|
-
const gutterSize = this.getGutterSize();
|
|
25
|
-
const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
|
|
26
|
-
return `calc(${this.getWidth(index)}% - ${subtractWidth}px)`;
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
maybeApplyForTablet(prop) {
|
|
30
|
-
const stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
31
|
-
return stackColumnsAt === "tablet" ? prop : "inherit";
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
get columnsCssVars() {
|
|
35
|
-
const flexDir = props.stackColumnsAt === "never" ? "inherit" : props.reverseColumnsWhenStacked ? "column-reverse" : "column";
|
|
36
|
-
return {
|
|
37
|
-
"--flex-dir": flexDir,
|
|
38
|
-
"--flex-dir-tablet": this.maybeApplyForTablet(flexDir)
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
get columnCssVars() {
|
|
43
|
-
const width = "100%";
|
|
44
|
-
const marginLeft = "0";
|
|
45
|
-
return {
|
|
46
|
-
"--column-width": width,
|
|
47
|
-
"--column-margin-left": marginLeft,
|
|
48
|
-
"--column-width-tablet": this.maybeApplyForTablet(width),
|
|
49
|
-
"--column-margin-left-tablet": this.maybeApplyForTablet(marginLeft)
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
console.log('props.columns', props.columns, props.builderBlock.component.options.columns)
|
|
56
|
-
return <div class={css({
|
|
57
|
-
display: "flex",
|
|
58
|
-
alignItems: "stretch",
|
|
59
|
-
lineHeight: "normal",
|
|
60
|
-
"@media (max-width: 999px)": {
|
|
61
|
-
flexDirection: "var(--flex-dir-tablet)"
|
|
62
|
-
},
|
|
63
|
-
"@media (max-width: 639px)": {
|
|
64
|
-
flexDirection: "var(--flex-dir)"
|
|
65
|
-
}
|
|
66
|
-
}) + " builder-columns"} style={state.columnsCssVars}>
|
|
67
|
-
<For each={props.columns}>
|
|
68
|
-
{(column, _index) => {
|
|
69
|
-
const index = _index();
|
|
70
|
-
|
|
71
|
-
console.log('column', column)
|
|
72
|
-
|
|
73
|
-
return <div class={css({
|
|
74
|
-
flexGrow: "1",
|
|
75
|
-
"@media (max-width: 999px)": {
|
|
76
|
-
width: "var(--column-width-tablet) !important",
|
|
77
|
-
marginLeft: "var(--column-margin-left-tablet) !important"
|
|
78
|
-
},
|
|
79
|
-
"@media (max-width: 639px)": {
|
|
80
|
-
width: "var(--column-width) !important",
|
|
81
|
-
marginLeft: "var(--column-margin-left) !important"
|
|
82
|
-
}
|
|
83
|
-
}) + "builder-column"} style={{
|
|
84
|
-
width: state.getColumnCssWidth(index),
|
|
85
|
-
"margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
|
|
86
|
-
...state.columnCssVars
|
|
87
|
-
}}>
|
|
88
|
-
<RenderBlocks blocks={column.blocks}></RenderBlocks>
|
|
89
|
-
</div>;
|
|
90
|
-
}}
|
|
91
|
-
</For>
|
|
92
|
-
</div>;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export default Columns;import { registerComponent } from '../functions/register-component';
|
|
96
|
-
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/fragment.jsx
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
function FragmentComponent(props) {
|
|
2
|
-
return <span>{props.children}</span>;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export default FragmentComponent;import { registerComponent } from '../functions/register-component';
|
|
6
|
-
registerComponent(FragmentComponent, {name:'Fragment',static:true,hidden:true,builtIn:true,canHaveChildren:true,noWrap:true});
|
package/src/blocks/image.jsx
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { Show } from "solid-js";
|
|
2
|
-
import { createMutable } from "solid-js/store";
|
|
3
|
-
import { css } from "solid-styled-components";
|
|
4
|
-
|
|
5
|
-
function Image(props) {
|
|
6
|
-
const state = createMutable({
|
|
7
|
-
updateQueryParam: function updateQueryParam(uri = "", key, value) {
|
|
8
|
-
const re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
|
9
|
-
const separator = uri.indexOf("?") !== -1 ? "&" : "?";
|
|
10
|
-
|
|
11
|
-
if (uri.match(re)) {
|
|
12
|
-
return uri.replace(re, "$1" + key + "=" + encodeURIComponent(value) + "$2");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return uri + separator + key + "=" + encodeURIComponent(value);
|
|
16
|
-
},
|
|
17
|
-
removeProtocol: function removeProtocol(path) {
|
|
18
|
-
return path.replace(/http(s)?:/, "");
|
|
19
|
-
},
|
|
20
|
-
getShopifyImageUrl: function getShopifyImageUrl(src, size) {
|
|
21
|
-
if (!src || !src?.match(/cdn\.shopify\.com/) || !size) {
|
|
22
|
-
return src;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (size === "master") {
|
|
26
|
-
return state.removeProtocol(src);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const match = src.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
|
|
30
|
-
|
|
31
|
-
if (match) {
|
|
32
|
-
const prefix = src.split(match[0]);
|
|
33
|
-
const suffix = match[3];
|
|
34
|
-
const useSize = size.match("x") ? size : `${size}x`;
|
|
35
|
-
return state.removeProtocol(`${prefix[0]}_${useSize}${suffix}`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return null;
|
|
39
|
-
},
|
|
40
|
-
getSrcSet: function getSrcSet(url) {
|
|
41
|
-
if (!url) {
|
|
42
|
-
return url;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const sizes = [100, 200, 400, 800, 1200, 1600, 2000];
|
|
46
|
-
|
|
47
|
-
if (url.match(/builder\.io/)) {
|
|
48
|
-
let srcUrl = url;
|
|
49
|
-
const widthInSrc = Number(url.split("?width=")[1]);
|
|
50
|
-
|
|
51
|
-
if (!isNaN(widthInSrc)) {
|
|
52
|
-
srcUrl = `${srcUrl} ${widthInSrc}w`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return sizes.filter(size => size !== widthInSrc).map(size => `${state.updateQueryParam(url, "width", size)} ${size}w`).concat([srcUrl]).join(", ");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (url.match(/cdn\.shopify\.com/)) {
|
|
59
|
-
return sizes.map(size => [state.getShopifyImageUrl(url, `${size}x${size}`), size]).filter(([sizeUrl]) => !!sizeUrl).map(([sizeUrl, size]) => `${sizeUrl} ${size}w`).concat([url]).join(", ");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return url;
|
|
63
|
-
},
|
|
64
|
-
useSrcSet: function useSrcSet() {
|
|
65
|
-
return props.srcset || state.getSrcSet(props.image) || "";
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return <div class={css({
|
|
69
|
-
position: "relative"
|
|
70
|
-
})}>
|
|
71
|
-
<picture>
|
|
72
|
-
<img class={"builder-image" + (props.class ? " " + props.class : "") + " " + css({
|
|
73
|
-
opacity: "1",
|
|
74
|
-
transition: "opacity 0.2s ease-in-out",
|
|
75
|
-
position: "absolute",
|
|
76
|
-
height: "100%",
|
|
77
|
-
width: "100%",
|
|
78
|
-
top: "0px",
|
|
79
|
-
left: "0px"
|
|
80
|
-
})} loading="lazy" alt={props.altText} aria-role={props.altText ? "presentation" : undefined} style={{
|
|
81
|
-
"object-position": props.backgroundSize || "center",
|
|
82
|
-
"object-fit": props.backgroundSize || "cover"
|
|
83
|
-
}} src={props.image} srcset={props.srcset || state.getSrcSet(props.image)} sizes={props.sizes} />
|
|
84
|
-
<Show when={!props.noWebp && state.useSrcSet().includes("builder.io")}>
|
|
85
|
-
<source type="image/webp" srcSet={state.useSrcSet().replace(/\?/g, "?format=webp&")} />
|
|
86
|
-
</Show>
|
|
87
|
-
</picture>
|
|
88
|
-
<Show when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}>
|
|
89
|
-
<div class={css({
|
|
90
|
-
width: "100%",
|
|
91
|
-
pointerEvents: "none",
|
|
92
|
-
fontSize: "0"
|
|
93
|
-
})} style={{
|
|
94
|
-
"padding-top": props.aspectRatio * 100 + "%"
|
|
95
|
-
}}>
|
|
96
|
-
{" "}
|
|
97
|
-
</div>
|
|
98
|
-
</Show>
|
|
99
|
-
<Show when={props.builderBlock?.children?.length && props.fitContent}>
|
|
100
|
-
{props.children}
|
|
101
|
-
</Show>
|
|
102
|
-
<Show when={!props.fitContent}>
|
|
103
|
-
<div class={css({
|
|
104
|
-
display: "flex",
|
|
105
|
-
flexDirection: "column",
|
|
106
|
-
alignItems: "stretch",
|
|
107
|
-
position: "absolute",
|
|
108
|
-
top: "0",
|
|
109
|
-
left: "0",
|
|
110
|
-
width: "100%",
|
|
111
|
-
height: "100%"
|
|
112
|
-
})}>
|
|
113
|
-
{props.children}
|
|
114
|
-
</div>
|
|
115
|
-
</Show>
|
|
116
|
-
</div>;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default Image;import { registerComponent } from '../functions/register-component';
|
|
120
|
-
registerComponent(Image, {name:'Image',static:true,builtIn:true,image:'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',defaultStyles:{position:'relative',minHeight:'20px',minWidth:'20px',overflow:'hidden'},canHaveChildren:true,inputs:[{name:'image',type:'file',bubble:true,allowedFileTypes:['jpeg','jpg','png','svg'],required:true,defaultValue:'https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',onChange:" const DEFAULT_ASPECT_RATIO = 0.7041; options.delete('srcset'); options.delete('noWebp'); function loadImage(url, timeout) { return new Promise((resolve, reject) => { const img = document.createElement('img'); let loaded = false; img.onload = () => { loaded = true; resolve(img); }; img.addEventListener('error', event => { console.warn('Image load failed', event.error); reject(event.error); }); img.src = url; setTimeout(() => { if (!loaded) { reject(new Error('Image load timed out')); } }, timeout); }); } function round(num) { return Math.round(num * 1000) / 1000; } const value = options.get('image'); const aspectRatio = options.get('aspectRatio'); // For SVG images - don't render as webp, keep them as SVG fetch(value) .then(res => res.blob()) .then(blob => { if (blob.type.includes('svg')) { options.set('noWebp', true); } }); if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) { return loadImage(value).then(img => { const possiblyUpdatedAspectRatio = options.get('aspectRatio'); if ( options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO) ) { if (img.width && img.height) { options.set('aspectRatio', round(img.height / img.width)); options.set('height', img.height); options.set('width', img.width); } } }); }"},{name:'backgroundSize',type:'text',defaultValue:'cover',enum:[{label:'contain',value:'contain',helperText:'The image should never get cropped'},{label:'cover',value:'cover',helperText:"The image should fill it's box, cropping when needed"}]},{name:'backgroundPosition',type:'text',defaultValue:'center',enum:['center','top','left','right','bottom','top left','top right','bottom left','bottom right']},{name:'altText',type:'string',helperText:'Text to display when the user has images off'},{name:'height',type:'number',hideFromUI:true},{name:'width',type:'number',hideFromUI:true},{name:'sizes',type:'string',hideFromUI:true},{name:'srcset',type:'string',hideFromUI:true},{name:'lazy',type:'boolean',defaultValue:true,hideFromUI:true},{name:'fitContent',type:'boolean',helperText:"When child blocks are provided, fit to them instead of using the image's aspect ratio",defaultValue:true},{name:'aspectRatio',type:'number',helperText:"This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",advanced:true,defaultValue:0.7041}]});
|