@builder.io/sdk-solid 0.4.5 → 0.5.1
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/blocks/BaseText.jsx +1 -1
- package/src/blocks/button/button.jsx +5 -3
- package/src/blocks/button/component-info.js +16 -22
- package/src/blocks/columns/columns.jsx +12 -21
- package/src/blocks/columns/component-info.js +203 -226
- package/src/blocks/custom-code/component-info.js +19 -25
- package/src/blocks/embed/component-info.js +31 -37
- package/src/blocks/embed/helpers.js +3 -9
- package/src/blocks/form/component-info.js +174 -212
- package/src/blocks/form/form.jsx +1 -268
- package/src/blocks/fragment/component-info.js +1 -3
- package/src/blocks/helpers.js +27 -0
- package/src/blocks/image/component-info.js +105 -133
- package/src/blocks/image/image.helpers.js +3 -5
- package/src/blocks/img/component-info.js +8 -12
- package/src/blocks/img/img.jsx +2 -0
- package/src/blocks/input/component-info.js +29 -57
- package/src/blocks/input/input.jsx +2 -0
- package/src/blocks/raw-text/component-info.js +7 -11
- package/src/blocks/raw-text/raw-text.jsx +2 -2
- package/src/blocks/section/component-info.js +24 -31
- package/src/blocks/section/section.jsx +3 -0
- package/src/blocks/select/component-info.js +34 -48
- package/src/blocks/select/select.jsx +2 -0
- package/src/blocks/submit-button/component-info.js +6 -10
- package/src/blocks/submit-button/submit-button.jsx +3 -1
- package/src/blocks/symbol/component-info.js +30 -37
- package/src/blocks/symbol/symbol.helpers.js +60 -0
- package/src/blocks/symbol/symbol.jsx +31 -68
- package/src/blocks/text/component-info.js +10 -13
- package/src/blocks/text/text.jsx +1 -1
- package/src/blocks/textarea/component-info.js +22 -30
- package/src/blocks/textarea/textarea.jsx +3 -0
- package/src/blocks/video/component-info.js +74 -96
- package/src/blocks/video/video.jsx +1 -0
- package/src/components/{render-block/render-block.helpers.js → block/block.helpers.js} +26 -44
- package/src/components/{render-block/render-block.jsx → block/block.jsx} +65 -80
- package/src/components/{render-block → block/components}/block-styles.jsx +16 -16
- package/src/components/block/components/block-wrapper.jsx +50 -0
- package/src/components/block/components/component-ref/component-ref.helpers.js +41 -0
- package/src/components/block/components/component-ref/component-ref.jsx +58 -0
- package/src/components/block/components/interactive-element.jsx +30 -0
- package/src/components/block/components/repeated-block.jsx +20 -0
- package/src/components/blocks/blocks-wrapper.jsx +66 -0
- package/src/components/blocks/blocks.jsx +57 -0
- package/src/components/{render-content/render-content.jsx → content/components/enable-editor.jsx} +86 -175
- package/src/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +6 -7
- package/src/components/{render-content/components/render-styles.jsx → content/components/styles.jsx} +4 -4
- package/src/components/{render-content/render-content.helpers.js → content/content.helpers.js} +15 -15
- package/src/components/content/content.jsx +136 -0
- package/src/components/content/index.js +2 -0
- package/src/components/content/wrap-component-ref.js +2 -0
- package/src/components/{render-content-variants/render-content-variants.jsx → content-variants/content-variants.jsx} +19 -22
- package/src/components/{render-content-variants → content-variants}/helpers.js +28 -40
- package/src/constants/builder-registered-components.js +34 -25
- package/src/constants/device-sizes.js +6 -6
- package/src/constants/sdk-version.js +1 -1
- package/src/context/builder.context.js +1 -1
- package/src/context/components.context.js +5 -0
- package/src/functions/apply-patch-with-mutation.js +66 -0
- package/src/functions/camel-to-kebab-case.js +2 -4
- package/src/functions/evaluate/acorn.js +1595 -0
- package/src/functions/{evaluate.js → evaluate/evaluate.js} +36 -10
- package/src/functions/evaluate/index.js +2 -0
- package/src/functions/evaluate/interpreter.js +2801 -0
- package/src/functions/evaluate/non-node-runtime.js +92 -0
- package/src/functions/evaluate/types.js +0 -0
- package/src/functions/event-handler-name.js +2 -4
- package/src/functions/extract-text-styles.js +4 -12
- package/src/functions/fast-clone.js +2 -4
- package/src/functions/get-block-actions-handler.js +3 -5
- package/src/functions/get-block-actions.js +15 -4
- package/src/functions/get-block-component-options.js +11 -12
- package/src/functions/get-block-properties.js +29 -19
- package/src/functions/get-builder-search-params/index.js +5 -10
- package/src/functions/get-content/generate-content-url.js +17 -19
- package/src/functions/get-content/index.js +43 -29
- package/src/functions/get-fetch.js +1 -3
- package/src/functions/get-global-this.js +1 -3
- package/src/functions/get-processed-block.js +12 -13
- package/src/functions/get-react-native-block-styles.js +11 -12
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +1 -3
- package/src/functions/is-editing.js +1 -3
- package/src/functions/is-iframe.js +1 -3
- package/src/functions/is-non-node-server.js +9 -0
- package/src/functions/is-previewing.js +1 -3
- package/src/functions/on-change.js +1 -4
- package/src/functions/register-component.js +34 -42
- package/src/functions/register.js +1 -3
- package/src/functions/sanitize-react-native-block-styles.js +22 -17
- package/src/functions/set-editor-settings.js +1 -3
- package/src/functions/set.js +1 -3
- package/src/functions/track/helpers.js +3 -5
- package/src/functions/track/index.js +45 -43
- package/src/functions/track/interaction.js +11 -7
- package/src/functions/transform-block-properties.js +1 -3
- package/src/functions/transform-block.js +1 -3
- package/src/helpers/ab-tests.js +45 -28
- package/src/helpers/canTrack.js +3 -5
- package/src/helpers/cookie.js +15 -24
- package/src/helpers/css.js +3 -7
- package/src/helpers/flatten.js +15 -18
- package/src/helpers/localStorage.js +1 -4
- package/src/helpers/logger.js +1 -3
- package/src/helpers/nullable.js +2 -4
- package/src/helpers/preview-lru-cache/get.js +8 -0
- package/src/helpers/preview-lru-cache/helpers.js +10 -0
- package/src/helpers/preview-lru-cache/init.js +10 -0
- package/src/helpers/preview-lru-cache/set.js +35 -0
- package/src/helpers/preview-lru-cache/types.js +0 -0
- package/src/helpers/sessionId.js +14 -11
- package/src/helpers/time.js +1 -3
- package/src/helpers/url.js +2 -4
- package/src/helpers/uuid.js +4 -6
- package/src/helpers/visitorId.js +8 -7
- package/src/index-helpers/blocks-exports.js +3 -14
- package/src/index-helpers/top-of-file.js +1 -3
- package/src/index.js +2 -17
- package/src/scripts/init-editing.js +62 -48
- package/src/types/api-version.js +1 -3
- package/src/types/builder-props.js +0 -0
- package/src/blocks/util.js +0 -8
- package/src/components/render-block/render-component.jsx +0 -40
- package/src/components/render-block/render-repeated-block.jsx +0 -16
- package/src/components/render-blocks.jsx +0 -100
- package/src/components/render-content/builder-editing.jsx +0 -5
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/wrap-component-ref.js +0 -4
- package/src/functions/evaluate.test.js +0 -17
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-content/generate-content-url.test.js +0 -97
- package/src/functions/get-processed-block.test.js +0 -34
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/set.test.js +0 -16
- package/src/helpers/url.test.js +0 -21
- /package/src/components/{render-block → block}/types.js +0 -0
- /package/src/components/{render-content/render-content.types.js → content/content.types.js} +0 -0
- /package/src/components/{render-content-variants/render-content-variants.types.js → content-variants/content-variants.types.js} +0 -0
|
@@ -1,33 +1,27 @@
|
|
|
1
1
|
const componentInfo = {
|
|
2
2
|
name: "Form:TextArea",
|
|
3
3
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3",
|
|
4
|
-
inputs: [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
name: "required",
|
|
27
|
-
type: "boolean",
|
|
28
|
-
defaultValue: false
|
|
29
|
-
}
|
|
30
|
-
],
|
|
4
|
+
inputs: [{
|
|
5
|
+
advanced: true,
|
|
6
|
+
name: "value",
|
|
7
|
+
type: "string"
|
|
8
|
+
}, {
|
|
9
|
+
name: "name",
|
|
10
|
+
type: "string",
|
|
11
|
+
required: true,
|
|
12
|
+
helperText: 'Every input in a form needs a unique name describing what it gets, e.g. "email"'
|
|
13
|
+
}, {
|
|
14
|
+
name: "defaultValue",
|
|
15
|
+
type: "string"
|
|
16
|
+
}, {
|
|
17
|
+
name: "placeholder",
|
|
18
|
+
type: "string",
|
|
19
|
+
defaultValue: "Hello there"
|
|
20
|
+
}, {
|
|
21
|
+
name: "required",
|
|
22
|
+
type: "boolean",
|
|
23
|
+
defaultValue: false
|
|
24
|
+
}],
|
|
31
25
|
defaultStyles: {
|
|
32
26
|
paddingTop: "10px",
|
|
33
27
|
paddingBottom: "10px",
|
|
@@ -41,6 +35,4 @@ const componentInfo = {
|
|
|
41
35
|
static: true,
|
|
42
36
|
noWrap: true
|
|
43
37
|
};
|
|
44
|
-
export {
|
|
45
|
-
componentInfo
|
|
46
|
-
};
|
|
38
|
+
export { componentInfo }
|
|
@@ -6,100 +6,78 @@ const componentInfo = {
|
|
|
6
6
|
minWidth: "20px"
|
|
7
7
|
},
|
|
8
8
|
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
|
|
9
|
-
inputs: [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: "width",
|
|
85
|
-
type: "number",
|
|
86
|
-
advanced: true
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: "aspectRatio",
|
|
90
|
-
type: "number",
|
|
91
|
-
advanced: true,
|
|
92
|
-
defaultValue: 0.7004048582995948
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: "lazyLoad",
|
|
96
|
-
type: "boolean",
|
|
97
|
-
helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
98
|
-
defaultValue: true,
|
|
99
|
-
advanced: true
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
};
|
|
103
|
-
export {
|
|
104
|
-
componentInfo
|
|
9
|
+
inputs: [{
|
|
10
|
+
name: "video",
|
|
11
|
+
type: "file",
|
|
12
|
+
allowedFileTypes: ["mp4"],
|
|
13
|
+
bubble: true,
|
|
14
|
+
defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
|
|
15
|
+
required: true
|
|
16
|
+
}, {
|
|
17
|
+
name: "posterImage",
|
|
18
|
+
type: "file",
|
|
19
|
+
allowedFileTypes: ["jpeg", "png"],
|
|
20
|
+
helperText: "Image to show before the video plays"
|
|
21
|
+
}, {
|
|
22
|
+
name: "autoPlay",
|
|
23
|
+
type: "boolean",
|
|
24
|
+
defaultValue: true
|
|
25
|
+
}, {
|
|
26
|
+
name: "controls",
|
|
27
|
+
type: "boolean",
|
|
28
|
+
defaultValue: false
|
|
29
|
+
}, {
|
|
30
|
+
name: "muted",
|
|
31
|
+
type: "boolean",
|
|
32
|
+
defaultValue: true
|
|
33
|
+
}, {
|
|
34
|
+
name: "loop",
|
|
35
|
+
type: "boolean",
|
|
36
|
+
defaultValue: true
|
|
37
|
+
}, {
|
|
38
|
+
name: "playsInline",
|
|
39
|
+
type: "boolean",
|
|
40
|
+
defaultValue: true
|
|
41
|
+
}, {
|
|
42
|
+
name: "fit",
|
|
43
|
+
type: "text",
|
|
44
|
+
defaultValue: "cover",
|
|
45
|
+
enum: ["contain", "cover", "fill", "auto"]
|
|
46
|
+
}, {
|
|
47
|
+
name: "preload",
|
|
48
|
+
type: "text",
|
|
49
|
+
defaultValue: "metadata",
|
|
50
|
+
enum: ["auto", "metadata", "none"]
|
|
51
|
+
}, {
|
|
52
|
+
name: "fitContent",
|
|
53
|
+
type: "boolean",
|
|
54
|
+
helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
|
|
55
|
+
defaultValue: true,
|
|
56
|
+
advanced: true
|
|
57
|
+
}, {
|
|
58
|
+
name: "position",
|
|
59
|
+
type: "text",
|
|
60
|
+
defaultValue: "center",
|
|
61
|
+
enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
|
|
62
|
+
}, {
|
|
63
|
+
name: "height",
|
|
64
|
+
type: "number",
|
|
65
|
+
advanced: true
|
|
66
|
+
}, {
|
|
67
|
+
name: "width",
|
|
68
|
+
type: "number",
|
|
69
|
+
advanced: true
|
|
70
|
+
}, {
|
|
71
|
+
name: "aspectRatio",
|
|
72
|
+
type: "number",
|
|
73
|
+
advanced: true,
|
|
74
|
+
defaultValue: 0.7004048582995948
|
|
75
|
+
}, {
|
|
76
|
+
name: "lazyLoad",
|
|
77
|
+
type: "boolean",
|
|
78
|
+
helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
79
|
+
defaultValue: true,
|
|
80
|
+
advanced: true
|
|
81
|
+
}]
|
|
105
82
|
};
|
|
83
|
+
export { componentInfo }
|
|
@@ -4,56 +4,38 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value
|
|
12
|
+
}) : obj[key] = value;
|
|
8
13
|
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
14
|
+
for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
17
18
|
return a;
|
|
18
19
|
};
|
|
19
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
21
|
var __objRest = (source, exclude) => {
|
|
21
22
|
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
23
|
+
for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
|
|
24
|
+
if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
|
|
25
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
|
|
26
|
+
}
|
|
30
27
|
return target;
|
|
31
28
|
};
|
|
32
29
|
import { evaluate } from "../../functions/evaluate";
|
|
33
|
-
import { getProcessedBlock } from "../../functions/get-processed-block";
|
|
34
|
-
const EMPTY_HTML_ELEMENTS = [
|
|
35
|
-
|
|
36
|
-
"base",
|
|
37
|
-
"br",
|
|
38
|
-
"col",
|
|
39
|
-
"embed",
|
|
40
|
-
"hr",
|
|
41
|
-
"img",
|
|
42
|
-
"input",
|
|
43
|
-
"keygen",
|
|
44
|
-
"link",
|
|
45
|
-
"meta",
|
|
46
|
-
"param",
|
|
47
|
-
"source",
|
|
48
|
-
"track",
|
|
49
|
-
"wbr"
|
|
50
|
-
];
|
|
51
|
-
const isEmptyHtmlElement = (tagName) => {
|
|
30
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
31
|
+
const EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
32
|
+
const isEmptyHtmlElement = tagName => {
|
|
52
33
|
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
53
34
|
};
|
|
54
35
|
const getComponent = ({
|
|
55
36
|
block,
|
|
56
|
-
context
|
|
37
|
+
context,
|
|
38
|
+
registeredComponents
|
|
57
39
|
}) => {
|
|
58
40
|
var _a;
|
|
59
41
|
const componentName = (_a = getProcessedBlock({
|
|
@@ -67,7 +49,7 @@ const getComponent = ({
|
|
|
67
49
|
if (!componentName) {
|
|
68
50
|
return null;
|
|
69
51
|
}
|
|
70
|
-
const ref =
|
|
52
|
+
const ref = registeredComponents[componentName];
|
|
71
53
|
if (!ref) {
|
|
72
54
|
console.warn(`
|
|
73
55
|
Could not find a registered component named "${componentName}".
|
|
@@ -81,7 +63,11 @@ const getRepeatItemData = ({
|
|
|
81
63
|
block,
|
|
82
64
|
context
|
|
83
65
|
}) => {
|
|
84
|
-
const _a = block,
|
|
66
|
+
const _a = block,
|
|
67
|
+
{
|
|
68
|
+
repeat
|
|
69
|
+
} = _a,
|
|
70
|
+
blockWithoutRepeat = __objRest(_a, ["repeat"]);
|
|
85
71
|
if (!(repeat == null ? void 0 : repeat.collection)) {
|
|
86
72
|
return void 0;
|
|
87
73
|
}
|
|
@@ -110,8 +96,4 @@ const getRepeatItemData = ({
|
|
|
110
96
|
}));
|
|
111
97
|
return repeatArray;
|
|
112
98
|
};
|
|
113
|
-
export {
|
|
114
|
-
getComponent,
|
|
115
|
-
getRepeatItemData,
|
|
116
|
-
isEmptyHtmlElement
|
|
117
|
-
};
|
|
99
|
+
export { getComponent, getRepeatItemData, isEmptyHtmlElement }
|
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
import { Show, For, createSignal } from "solid-js";
|
|
2
|
-
import { Dynamic } from "solid-js/web";
|
|
3
2
|
|
|
4
|
-
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
5
3
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
6
4
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
7
5
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
8
|
-
import BlockStyles from "./block-styles.jsx";
|
|
6
|
+
import BlockStyles from "./components/block-styles.jsx";
|
|
9
7
|
import {
|
|
10
8
|
getComponent,
|
|
11
9
|
getRepeatItemData,
|
|
12
10
|
isEmptyHtmlElement,
|
|
13
|
-
} from "./
|
|
14
|
-
import
|
|
15
|
-
import { TARGET } from "../../constants/target.js";
|
|
11
|
+
} from "./block.helpers.js";
|
|
12
|
+
import RepeatedBlock from "./components/repeated-block.jsx";
|
|
16
13
|
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
17
|
-
import
|
|
18
|
-
import
|
|
14
|
+
import ComponentRef from "./components/component-ref/component-ref.jsx";
|
|
15
|
+
import BlockWrapper from "./components/block-wrapper.jsx";
|
|
19
16
|
|
|
20
|
-
function
|
|
21
|
-
const [
|
|
22
|
-
|
|
17
|
+
function Block(props) {
|
|
18
|
+
const [childrenContext, setChildrenContext] = createSignal(props.context);
|
|
19
|
+
|
|
20
|
+
function blockComponent() {
|
|
21
|
+
return getComponent({
|
|
23
22
|
block: props.block,
|
|
24
23
|
context: props.context,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const [Tag, setTag] = createSignal(props.block.tagName || "div");
|
|
29
|
-
|
|
30
|
-
const [childrenContext, setChildrenContext] = createSignal(props.context);
|
|
24
|
+
registeredComponents: props.registeredComponents,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
31
27
|
|
|
32
28
|
function repeatItem() {
|
|
33
29
|
return getRepeatItemData({
|
|
@@ -36,7 +32,7 @@ function RenderBlock(props) {
|
|
|
36
32
|
});
|
|
37
33
|
}
|
|
38
34
|
|
|
39
|
-
function
|
|
35
|
+
function processedBlock() {
|
|
40
36
|
return repeatItem()
|
|
41
37
|
? props.block
|
|
42
38
|
: getProcessedBlock({
|
|
@@ -49,42 +45,20 @@ function RenderBlock(props) {
|
|
|
49
45
|
});
|
|
50
46
|
}
|
|
51
47
|
|
|
48
|
+
function Tag() {
|
|
49
|
+
return props.block.tagName || "div";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
52
|
function canShowBlock() {
|
|
53
|
-
if ("hide" in
|
|
54
|
-
return !
|
|
53
|
+
if ("hide" in processedBlock()) {
|
|
54
|
+
return !processedBlock().hide;
|
|
55
55
|
}
|
|
56
|
-
if ("show" in
|
|
57
|
-
return
|
|
56
|
+
if ("show" in processedBlock()) {
|
|
57
|
+
return processedBlock().show;
|
|
58
58
|
}
|
|
59
59
|
return true;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function actions() {
|
|
63
|
-
return getBlockActions({
|
|
64
|
-
block: useBlock(),
|
|
65
|
-
rootState: props.context.rootState,
|
|
66
|
-
rootSetState: props.context.rootSetState,
|
|
67
|
-
localState: props.context.localState,
|
|
68
|
-
context: props.context.context,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function attributes() {
|
|
73
|
-
const blockProperties = getBlockProperties(useBlock());
|
|
74
|
-
return {
|
|
75
|
-
...blockProperties,
|
|
76
|
-
...(TARGET === "reactNative"
|
|
77
|
-
? {
|
|
78
|
-
style: getReactNativeBlockStyles({
|
|
79
|
-
block: useBlock(),
|
|
80
|
-
context: props.context,
|
|
81
|
-
blockStyles: blockProperties.style,
|
|
82
|
-
}),
|
|
83
|
-
}
|
|
84
|
-
: {}),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
62
|
function childrenWithoutParentComponent() {
|
|
89
63
|
/**
|
|
90
64
|
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
@@ -93,70 +67,81 @@ function RenderBlock(props) {
|
|
|
93
67
|
* blocks, and the children will be repeated within those blocks.
|
|
94
68
|
*/
|
|
95
69
|
const shouldRenderChildrenOutsideRef =
|
|
96
|
-
!
|
|
97
|
-
return shouldRenderChildrenOutsideRef
|
|
70
|
+
!blockComponent()?.component && !repeatItem();
|
|
71
|
+
return shouldRenderChildrenOutsideRef
|
|
72
|
+
? processedBlock().children ?? []
|
|
73
|
+
: [];
|
|
98
74
|
}
|
|
99
75
|
|
|
100
|
-
function
|
|
76
|
+
function componentRefProps() {
|
|
101
77
|
return {
|
|
102
|
-
blockChildren:
|
|
103
|
-
componentRef:
|
|
78
|
+
blockChildren: processedBlock().children ?? [],
|
|
79
|
+
componentRef: blockComponent()?.component,
|
|
104
80
|
componentOptions: {
|
|
105
|
-
...getBlockComponentOptions(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
: {
|
|
113
|
-
attributes: {
|
|
114
|
-
...attributes(),
|
|
115
|
-
...actions(),
|
|
116
|
-
},
|
|
117
|
-
}),
|
|
81
|
+
...getBlockComponentOptions(processedBlock()),
|
|
82
|
+
builderContext: props.context,
|
|
83
|
+
...(blockComponent()?.name === "Symbol" ||
|
|
84
|
+
blockComponent()?.name === "Columns"
|
|
85
|
+
? {
|
|
86
|
+
builderComponents: props.registeredComponents,
|
|
87
|
+
}
|
|
88
|
+
: {}),
|
|
118
89
|
},
|
|
119
90
|
context: childrenContext(),
|
|
91
|
+
registeredComponents: props.registeredComponents,
|
|
92
|
+
builderBlock: processedBlock(),
|
|
93
|
+
includeBlockProps: blockComponent()?.noWrap === true,
|
|
94
|
+
isInteractive: !blockComponent()?.isRSC,
|
|
120
95
|
};
|
|
121
96
|
}
|
|
122
97
|
|
|
123
98
|
return (
|
|
124
99
|
<Show when={canShowBlock()}>
|
|
125
100
|
<Show
|
|
126
|
-
fallback={
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
when={!component()?.noWrap}
|
|
101
|
+
fallback={<ComponentRef {...componentRefProps()}></ComponentRef>}
|
|
102
|
+
when={!blockComponent()?.noWrap}
|
|
130
103
|
>
|
|
131
104
|
<Show when={isEmptyHtmlElement(Tag())}>
|
|
132
|
-
<
|
|
105
|
+
<BlockWrapper
|
|
106
|
+
Wrapper={Tag()}
|
|
107
|
+
block={processedBlock()}
|
|
108
|
+
context={props.context}
|
|
109
|
+
hasChildren={false}
|
|
110
|
+
></BlockWrapper>
|
|
133
111
|
</Show>
|
|
134
112
|
<Show when={!isEmptyHtmlElement(Tag()) && repeatItem()}>
|
|
135
113
|
<For each={repeatItem()}>
|
|
136
114
|
{(data, _index) => {
|
|
137
115
|
const index = _index();
|
|
138
116
|
return (
|
|
139
|
-
<
|
|
117
|
+
<RepeatedBlock
|
|
140
118
|
key={index}
|
|
141
119
|
repeatContext={data.context}
|
|
142
120
|
block={data.block}
|
|
143
|
-
|
|
121
|
+
registeredComponents={props.registeredComponents}
|
|
122
|
+
></RepeatedBlock>
|
|
144
123
|
);
|
|
145
124
|
}}
|
|
146
125
|
</For>
|
|
147
126
|
</Show>
|
|
148
127
|
<Show when={!isEmptyHtmlElement(Tag()) && !repeatItem()}>
|
|
149
|
-
<
|
|
150
|
-
|
|
128
|
+
<BlockWrapper
|
|
129
|
+
Wrapper={Tag()}
|
|
130
|
+
block={processedBlock()}
|
|
131
|
+
context={props.context}
|
|
132
|
+
hasChildren={true}
|
|
133
|
+
>
|
|
134
|
+
<ComponentRef {...componentRefProps()}></ComponentRef>
|
|
151
135
|
<For each={childrenWithoutParentComponent()}>
|
|
152
136
|
{(child, _index) => {
|
|
153
137
|
const index = _index();
|
|
154
138
|
return (
|
|
155
|
-
<
|
|
156
|
-
key={"
|
|
139
|
+
<Block
|
|
140
|
+
key={"block-" + child.id}
|
|
157
141
|
block={child}
|
|
158
142
|
context={childrenContext()}
|
|
159
|
-
|
|
143
|
+
registeredComponents={props.registeredComponents}
|
|
144
|
+
></Block>
|
|
160
145
|
);
|
|
161
146
|
}}
|
|
162
147
|
</For>
|
|
@@ -172,11 +157,11 @@ function RenderBlock(props) {
|
|
|
172
157
|
);
|
|
173
158
|
}}
|
|
174
159
|
</For>
|
|
175
|
-
</
|
|
160
|
+
</BlockWrapper>
|
|
176
161
|
</Show>
|
|
177
162
|
</Show>
|
|
178
163
|
</Show>
|
|
179
164
|
);
|
|
180
165
|
}
|
|
181
166
|
|
|
182
|
-
export default
|
|
167
|
+
export default Block;
|
|
@@ -3,38 +3,38 @@ import { Show, createSignal } from "solid-js";
|
|
|
3
3
|
import {
|
|
4
4
|
getMaxWidthQueryForSize,
|
|
5
5
|
getSizesForBreakpoints,
|
|
6
|
-
} from "
|
|
7
|
-
import { TARGET } from "
|
|
8
|
-
import { getProcessedBlock } from "
|
|
9
|
-
import { createCssClass } from "
|
|
10
|
-
import { checkIsDefined } from "
|
|
11
|
-
import InlinedStyles from "
|
|
6
|
+
} from "../../../constants/device-sizes.js";
|
|
7
|
+
import { TARGET } from "../../../constants/target.js";
|
|
8
|
+
import { getProcessedBlock } from "../../../functions/get-processed-block.js";
|
|
9
|
+
import { createCssClass } from "../../../helpers/css.js";
|
|
10
|
+
import { checkIsDefined } from "../../../helpers/nullable.js";
|
|
11
|
+
import InlinedStyles from "../../inlined-styles.jsx";
|
|
12
12
|
|
|
13
13
|
function BlockStyles(props) {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const [processedBlock, setProcessedBlock] = createSignal(
|
|
15
|
+
getProcessedBlock({
|
|
16
16
|
block: props.block,
|
|
17
17
|
localState: props.context.localState,
|
|
18
18
|
rootState: props.context.rootState,
|
|
19
19
|
rootSetState: props.context.rootSetState,
|
|
20
20
|
context: props.context.context,
|
|
21
21
|
shouldEvaluateBindings: true,
|
|
22
|
-
})
|
|
23
|
-
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
24
|
|
|
25
25
|
function canShowBlock() {
|
|
26
26
|
// only render styles for blocks that are visible
|
|
27
|
-
if (checkIsDefined(
|
|
28
|
-
return !
|
|
27
|
+
if (checkIsDefined(processedBlock().hide)) {
|
|
28
|
+
return !processedBlock().hide;
|
|
29
29
|
}
|
|
30
|
-
if (checkIsDefined(
|
|
31
|
-
return
|
|
30
|
+
if (checkIsDefined(processedBlock().show)) {
|
|
31
|
+
return processedBlock().show;
|
|
32
32
|
}
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function css() {
|
|
37
|
-
const styles =
|
|
37
|
+
const styles = processedBlock().responsiveStyles;
|
|
38
38
|
const content = props.context.content;
|
|
39
39
|
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
|
|
40
40
|
content?.meta?.breakpoints || {}
|
|
@@ -42,7 +42,7 @@ function BlockStyles(props) {
|
|
|
42
42
|
const largeStyles = styles?.large;
|
|
43
43
|
const mediumStyles = styles?.medium;
|
|
44
44
|
const smallStyles = styles?.small;
|
|
45
|
-
const className =
|
|
45
|
+
const className = processedBlock().id;
|
|
46
46
|
if (!className) {
|
|
47
47
|
return "";
|
|
48
48
|
}
|