@builder.io/sdk-react-native 0.0.1-7 → 0.0.1-70
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 +42 -0
- package/README.md +19 -0
- package/package.json +6 -4
- package/src/blocks/button/button.js +34 -0
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/columns/columns.js +61 -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.lite.tsx → custom-code/custom-code.js} +16 -33
- package/src/blocks/embed/component-info.js +44 -0
- package/src/blocks/embed/embed.js +43 -0
- package/src/blocks/embed/helpers.js +9 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/form/form.js +224 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/fragment/fragment.js +8 -0
- package/src/blocks/image/component-info.js +151 -0
- package/src/blocks/image/image.helpers.js +48 -0
- package/src/blocks/image/image.js +40 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/img/img.js +36 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/input.js +36 -0
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/raw-text.js +10 -0
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/section.js +31 -0
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/select.js +36 -0
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/submit-button.js +29 -0
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.js +69 -0
- package/src/blocks/{text.js → text/component-info.js} +4 -11
- package/src/blocks/text/text.js +64 -0
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/textarea.js +32 -0
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/video.js +32 -0
- package/src/components/render-block/block-styles.js +37 -0
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.js +171 -0
- package/src/components/render-block/render-component.js +35 -0
- package/src/components/render-block/render-repeated-block.js +30 -0
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-blocks.js +29 -13
- package/src/components/render-content/components/render-styles.js +58 -0
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.js +277 -0
- package/src/components/render-inlined-styles.js +18 -0
- package/src/constants/builder-registered-components.js +42 -0
- package/src/constants/device-sizes.js +3 -22
- package/src/constants/target.js +4 -0
- package/src/context/builder.context.js +7 -1
- package/src/functions/camel-to-kebab-case.js +4 -0
- package/src/functions/convert-style-object.js +6 -0
- package/src/functions/evaluate.js +17 -9
- package/src/functions/event-handler-name.js +7 -0
- package/src/functions/get-block-actions.js +14 -14
- package/src/functions/get-block-component-options.js +22 -2
- package/src/functions/get-block-properties.js +2 -4
- package/src/functions/get-block-styles.js +9 -28
- package/src/functions/get-block-tag.js +1 -2
- 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 +22 -10
- package/src/functions/get-processed-block.test.js +14 -9
- package/src/functions/if-target.js +11 -3
- package/src/functions/is-browser.js +1 -3
- package/src/functions/is-editing.js +1 -2
- package/src/functions/is-iframe.js +1 -2
- package/src/functions/is-previewing.js +14 -0
- package/src/functions/is-react-native.js +1 -2
- package/src/functions/on-change.js +0 -1
- package/src/functions/on-change.test.js +1 -3
- package/src/functions/register-component.js +46 -27
- package/src/functions/register.js +29 -0
- package/src/functions/sanitize-styles.js +32 -0
- package/src/functions/set-editor-settings.js +15 -0
- package/src/functions/set.js +0 -1
- package/src/functions/set.test.js +1 -3
- package/src/functions/track.js +109 -13
- package/src/functions/transform-block.js +37 -0
- package/src/helpers/cookie.js +59 -0
- package/src/helpers/css.js +12 -0
- package/src/helpers/flatten.js +34 -0
- package/src/helpers/localStorage.js +34 -0
- package/src/helpers/nullable.js +4 -0
- package/src/helpers/sessionId.js +26 -0
- package/src/helpers/time.js +5 -0
- package/src/helpers/url.js +10 -0
- package/src/helpers/url.test.js +15 -0
- package/src/helpers/uuid.js +13 -0
- package/src/helpers/visitorId.js +33 -0
- package/src/index-helpers/blocks-exports.js +18 -0
- package/src/index-helpers/top-of-file.js +1 -0
- package/src/index.js +10 -24
- package/src/scripts/init-editing.js +73 -51
- package/src/types/builder-block.js +0 -1
- package/src/types/builder-content.js +0 -1
- package/src/types/can-track.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/index.js +0 -11
- package/src/blocks/button.js +0 -37
- package/src/blocks/button.lite.tsx +0 -29
- package/src/blocks/columns.js +0 -42
- package/src/blocks/columns.lite.tsx +0 -41
- package/src/blocks/custom-code.js +0 -56
- package/src/blocks/embed.js +0 -56
- package/src/blocks/embed.lite.tsx +0 -65
- package/src/blocks/form.js +0 -229
- package/src/blocks/form.lite.tsx +0 -257
- package/src/blocks/image.js +0 -123
- package/src/blocks/image.lite.tsx +0 -35
- package/src/blocks/img.js +0 -41
- package/src/blocks/img.lite.tsx +0 -19
- package/src/blocks/input.js +0 -41
- package/src/blocks/input.lite.tsx +0 -23
- package/src/blocks/raw-text.js +0 -17
- package/src/blocks/raw-text.lite.tsx +0 -12
- package/src/blocks/section.js +0 -36
- package/src/blocks/section.lite.tsx +0 -20
- package/src/blocks/select.js +0 -40
- package/src/blocks/select.lite.tsx +0 -24
- package/src/blocks/submit-button.js +0 -34
- package/src/blocks/submit-button.lite.tsx +0 -11
- package/src/blocks/symbol.js +0 -20
- package/src/blocks/symbol.lite.tsx +0 -20
- package/src/blocks/text.lite.tsx +0 -12
- package/src/blocks/textarea.js +0 -37
- package/src/blocks/textarea.lite.tsx +0 -15
- package/src/blocks/video.js +0 -49
- package/src/blocks/video.lite.tsx +0 -28
- package/src/components/render-block.js +0 -84
- package/src/components/render-block.lite.tsx +0 -92
- package/src/components/render-blocks.lite.tsx +0 -56
- package/src/components/render-content.js +0 -66
- package/src/components/render-content.lite.tsx +0 -95
- package/src/functions/get-content.js +0 -103
- package/src/functions/get-target.js +0 -7
- package/src/functions/macro-eval.js +0 -6
- package/src/package.json +0 -18
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import HTML from "react-native-render-html";
|
|
18
|
+
function camelToKebabCase(string) {
|
|
19
|
+
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
function pick(object, keys) {
|
|
22
|
+
return keys.reduce((obj, key) => {
|
|
23
|
+
if (object && object.hasOwnProperty(key)) {
|
|
24
|
+
obj[key] = object[key];
|
|
25
|
+
}
|
|
26
|
+
return obj;
|
|
27
|
+
}, {});
|
|
28
|
+
}
|
|
29
|
+
const PICK_STYLES = ["textAlign"];
|
|
30
|
+
function getBlockStyles(block) {
|
|
31
|
+
var _a, _b, _c;
|
|
32
|
+
const styles = __spreadValues(__spreadValues({}, (_a = block.responsiveStyles) == null ? void 0 : _a.large), block.styles);
|
|
33
|
+
if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
|
|
34
|
+
Object.assign(styles, block.responsiveStyles.medium);
|
|
35
|
+
}
|
|
36
|
+
if ((_c = block.responsiveStyles) == null ? void 0 : _c.small) {
|
|
37
|
+
Object.assign(styles, block.responsiveStyles.small);
|
|
38
|
+
}
|
|
39
|
+
return styles;
|
|
40
|
+
}
|
|
41
|
+
function getCss(block) {
|
|
42
|
+
const styleObject = pick(getBlockStyles(block), PICK_STYLES);
|
|
43
|
+
if (!styleObject) {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
let str = ``;
|
|
47
|
+
for (const key in styleObject) {
|
|
48
|
+
const value = styleObject[key];
|
|
49
|
+
if (typeof value === "string") {
|
|
50
|
+
str += `${camelToKebabCase(key)}: ${value};`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return str;
|
|
54
|
+
}
|
|
55
|
+
function Text(props) {
|
|
56
|
+
return /* @__PURE__ */ React.createElement(HTML, {
|
|
57
|
+
source: {
|
|
58
|
+
html: `<div style="${getCss(props.builderBlock)}">${props.text || ""}</div>`
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
Text as default
|
|
64
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Form:TextArea",
|
|
3
|
+
builtIn: true,
|
|
4
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3",
|
|
5
|
+
inputs: [
|
|
6
|
+
{
|
|
7
|
+
advanced: true,
|
|
8
|
+
name: "value",
|
|
9
|
+
type: "string"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "name",
|
|
13
|
+
type: "string",
|
|
14
|
+
required: true,
|
|
15
|
+
helperText: 'Every input in a form needs a unique name describing what it gets, e.g. "email"'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "defaultValue",
|
|
19
|
+
type: "string"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "placeholder",
|
|
23
|
+
type: "string",
|
|
24
|
+
defaultValue: "Hello there"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "required",
|
|
28
|
+
type: "boolean",
|
|
29
|
+
defaultValue: false
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
defaultStyles: {
|
|
33
|
+
paddingTop: "10px",
|
|
34
|
+
paddingBottom: "10px",
|
|
35
|
+
paddingLeft: "10px",
|
|
36
|
+
paddingRight: "10px",
|
|
37
|
+
borderRadius: "3px",
|
|
38
|
+
borderWidth: "1px",
|
|
39
|
+
borderStyle: "solid",
|
|
40
|
+
borderColor: "#ccc"
|
|
41
|
+
},
|
|
42
|
+
static: true,
|
|
43
|
+
noWrap: true
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
componentInfo
|
|
47
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import { View } from "react-native";
|
|
22
|
+
function Textarea(props) {
|
|
23
|
+
return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
24
|
+
placeholder: props.placeholder,
|
|
25
|
+
name: props.name,
|
|
26
|
+
value: props.value,
|
|
27
|
+
defaultValue: props.defaultValue
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
Textarea as default
|
|
32
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const componentInfo = {
|
|
2
|
+
name: "Video",
|
|
3
|
+
canHaveChildren: true,
|
|
4
|
+
builtIn: true,
|
|
5
|
+
defaultStyles: {
|
|
6
|
+
minHeight: "20px",
|
|
7
|
+
minWidth: "20px"
|
|
8
|
+
},
|
|
9
|
+
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",
|
|
10
|
+
inputs: [
|
|
11
|
+
{
|
|
12
|
+
name: "video",
|
|
13
|
+
type: "file",
|
|
14
|
+
allowedFileTypes: ["mp4"],
|
|
15
|
+
bubble: true,
|
|
16
|
+
defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "posterImage",
|
|
21
|
+
type: "file",
|
|
22
|
+
allowedFileTypes: ["jpeg", "png"],
|
|
23
|
+
helperText: "Image to show before the video plays"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "autoPlay",
|
|
27
|
+
type: "boolean",
|
|
28
|
+
defaultValue: true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "controls",
|
|
32
|
+
type: "boolean",
|
|
33
|
+
defaultValue: false
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "muted",
|
|
37
|
+
type: "boolean",
|
|
38
|
+
defaultValue: true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "loop",
|
|
42
|
+
type: "boolean",
|
|
43
|
+
defaultValue: true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "playsInline",
|
|
47
|
+
type: "boolean",
|
|
48
|
+
defaultValue: true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "fit",
|
|
52
|
+
type: "text",
|
|
53
|
+
defaultValue: "cover",
|
|
54
|
+
enum: ["contain", "cover", "fill", "auto"]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "fitContent",
|
|
58
|
+
type: "boolean",
|
|
59
|
+
helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
|
|
60
|
+
defaultValue: true,
|
|
61
|
+
advanced: true
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "position",
|
|
65
|
+
type: "text",
|
|
66
|
+
defaultValue: "center",
|
|
67
|
+
enum: [
|
|
68
|
+
"center",
|
|
69
|
+
"top",
|
|
70
|
+
"left",
|
|
71
|
+
"right",
|
|
72
|
+
"bottom",
|
|
73
|
+
"top left",
|
|
74
|
+
"top right",
|
|
75
|
+
"bottom left",
|
|
76
|
+
"bottom right"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "height",
|
|
81
|
+
type: "number",
|
|
82
|
+
advanced: true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "width",
|
|
86
|
+
type: "number",
|
|
87
|
+
advanced: true
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "aspectRatio",
|
|
91
|
+
type: "number",
|
|
92
|
+
advanced: true,
|
|
93
|
+
defaultValue: 0.7004048582995948
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "lazyLoad",
|
|
97
|
+
type: "boolean",
|
|
98
|
+
helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
99
|
+
defaultValue: true,
|
|
100
|
+
advanced: true
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
};
|
|
104
|
+
export {
|
|
105
|
+
componentInfo
|
|
106
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { View } from "react-native";
|
|
2
|
+
import ReactVideo from "react-native-video";
|
|
3
|
+
function Video(props) {
|
|
4
|
+
return /* @__PURE__ */ React.createElement(View, {
|
|
5
|
+
style: { position: "relative" }
|
|
6
|
+
}, /* @__PURE__ */ React.createElement(ReactVideo, {
|
|
7
|
+
paused: !props.autoPlay,
|
|
8
|
+
controls: props.controls,
|
|
9
|
+
muted: props.muted,
|
|
10
|
+
repeat: props.loop,
|
|
11
|
+
poster: props.posterImage,
|
|
12
|
+
posterResizeMode: props.fit || "contain",
|
|
13
|
+
resizeMode: props.fit || "contain",
|
|
14
|
+
style: {
|
|
15
|
+
position: "absolute",
|
|
16
|
+
top: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
zIndex: 1
|
|
21
|
+
},
|
|
22
|
+
source: { uri: props.video }
|
|
23
|
+
}), /* @__PURE__ */ React.createElement(View, {
|
|
24
|
+
style: {
|
|
25
|
+
width: "100%",
|
|
26
|
+
paddingTop: `${props.aspectRatio * 100}%`
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
Video as default
|
|
32
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
|
|
3
|
+
import { TARGET } from "../../constants/target.js";
|
|
4
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
5
|
+
import { convertStyleMaptoCSS } from "../../helpers/css.js";
|
|
6
|
+
import RenderInlinedStyles from "../render-inlined-styles.js";
|
|
7
|
+
function BlockStyles(props) {
|
|
8
|
+
function useBlock() {
|
|
9
|
+
return getProcessedBlock({
|
|
10
|
+
block: props.block,
|
|
11
|
+
state: props.context.state,
|
|
12
|
+
context: props.context.context,
|
|
13
|
+
shouldEvaluateBindings: true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function css() {
|
|
17
|
+
const styles = useBlock().responsiveStyles;
|
|
18
|
+
const largeStyles = styles == null ? void 0 : styles.large;
|
|
19
|
+
const mediumStyles = styles == null ? void 0 : styles.medium;
|
|
20
|
+
const smallStyles = styles == null ? void 0 : styles.small;
|
|
21
|
+
return `
|
|
22
|
+
${largeStyles ? `.${useBlock().id} {${convertStyleMaptoCSS(largeStyles)}}` : ""}
|
|
23
|
+
${mediumStyles ? `${getMaxWidthQueryForSize("medium")} {
|
|
24
|
+
.${useBlock().id} {${convertStyleMaptoCSS(mediumStyles)}}
|
|
25
|
+
}` : ""}
|
|
26
|
+
${smallStyles ? `${getMaxWidthQueryForSize("small")} {
|
|
27
|
+
.${useBlock().id} {${convertStyleMaptoCSS(smallStyles)}}
|
|
28
|
+
}` : ""}
|
|
29
|
+
}`;
|
|
30
|
+
}
|
|
31
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
|
|
32
|
+
styles: css()
|
|
33
|
+
})) : null);
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
BlockStyles as default
|
|
37
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const EMPTY_HTML_ELEMENTS = [
|
|
2
|
+
"area",
|
|
3
|
+
"base",
|
|
4
|
+
"br",
|
|
5
|
+
"col",
|
|
6
|
+
"embed",
|
|
7
|
+
"hr",
|
|
8
|
+
"img",
|
|
9
|
+
"input",
|
|
10
|
+
"keygen",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"param",
|
|
14
|
+
"source",
|
|
15
|
+
"track",
|
|
16
|
+
"wbr"
|
|
17
|
+
];
|
|
18
|
+
const isEmptyHtmlElement = (tagName) => {
|
|
19
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
isEmptyHtmlElement
|
|
23
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import * as React from "react";
|
|
33
|
+
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
34
|
+
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
35
|
+
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
36
|
+
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
37
|
+
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
38
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
39
|
+
import { evaluate } from "../../functions/evaluate.js";
|
|
40
|
+
import BlockStyles from "./block-styles.js";
|
|
41
|
+
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
42
|
+
import RenderComponent from "./render-component.js";
|
|
43
|
+
import RenderRepeatedBlock from "./render-repeated-block.js";
|
|
44
|
+
function RenderBlock(props) {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
function component() {
|
|
47
|
+
var _a2;
|
|
48
|
+
const componentName = (_a2 = getProcessedBlock({
|
|
49
|
+
block: props.block,
|
|
50
|
+
state: props.context.state,
|
|
51
|
+
context: props.context.context,
|
|
52
|
+
shouldEvaluateBindings: false
|
|
53
|
+
}).component) == null ? void 0 : _a2.name;
|
|
54
|
+
if (!componentName) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const ref = props.context.registeredComponents[componentName];
|
|
58
|
+
if (!ref) {
|
|
59
|
+
console.warn(`
|
|
60
|
+
Could not find a registered component named "${componentName}".
|
|
61
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
62
|
+
return void 0;
|
|
63
|
+
} else {
|
|
64
|
+
return ref;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function componentInfo() {
|
|
68
|
+
if (component()) {
|
|
69
|
+
const _a2 = component(), { component: _ } = _a2, info = __objRest(_a2, ["component"]);
|
|
70
|
+
return info;
|
|
71
|
+
} else {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function componentRef() {
|
|
76
|
+
var _a2;
|
|
77
|
+
return (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component;
|
|
78
|
+
}
|
|
79
|
+
function tagName() {
|
|
80
|
+
return getBlockTag(useBlock());
|
|
81
|
+
}
|
|
82
|
+
function useBlock() {
|
|
83
|
+
return repeatItemData() ? props.block : getProcessedBlock({
|
|
84
|
+
block: props.block,
|
|
85
|
+
state: props.context.state,
|
|
86
|
+
context: props.context.context,
|
|
87
|
+
shouldEvaluateBindings: true
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function attributes() {
|
|
91
|
+
return __spreadProps(__spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
|
|
92
|
+
block: useBlock(),
|
|
93
|
+
state: props.context.state,
|
|
94
|
+
context: props.context.context
|
|
95
|
+
})), {
|
|
96
|
+
style: getBlockStyles(useBlock())
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function shouldWrap() {
|
|
100
|
+
var _a2;
|
|
101
|
+
return !((_a2 = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _a2.noWrap);
|
|
102
|
+
}
|
|
103
|
+
function componentOptions() {
|
|
104
|
+
return __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
|
|
105
|
+
attributes: attributes()
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function renderComponentProps() {
|
|
109
|
+
return {
|
|
110
|
+
blockChildren: children(),
|
|
111
|
+
componentRef: componentRef(),
|
|
112
|
+
componentOptions: componentOptions(),
|
|
113
|
+
context: props.context
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function children() {
|
|
117
|
+
var _a2;
|
|
118
|
+
return (_a2 = useBlock().children) != null ? _a2 : [];
|
|
119
|
+
}
|
|
120
|
+
function childrenWithoutParentComponent() {
|
|
121
|
+
const shouldRenderChildrenOutsideRef = !componentRef() && !repeatItemData();
|
|
122
|
+
return shouldRenderChildrenOutsideRef ? children() : [];
|
|
123
|
+
}
|
|
124
|
+
function repeatItemData() {
|
|
125
|
+
const _a2 = props.block, { repeat } = _a2, blockWithoutRepeat = __objRest(_a2, ["repeat"]);
|
|
126
|
+
if (!(repeat == null ? void 0 : repeat.collection)) {
|
|
127
|
+
return void 0;
|
|
128
|
+
}
|
|
129
|
+
const itemsArray = evaluate({
|
|
130
|
+
code: repeat.collection,
|
|
131
|
+
state: props.context.state,
|
|
132
|
+
context: props.context.context
|
|
133
|
+
});
|
|
134
|
+
if (!Array.isArray(itemsArray)) {
|
|
135
|
+
return void 0;
|
|
136
|
+
}
|
|
137
|
+
const collectionName = repeat.collection.split(".").pop();
|
|
138
|
+
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
139
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
140
|
+
context: __spreadProps(__spreadValues({}, props.context), {
|
|
141
|
+
state: __spreadProps(__spreadValues({}, props.context.state), {
|
|
142
|
+
$index: index,
|
|
143
|
+
$item: item,
|
|
144
|
+
[itemNameToUse]: item,
|
|
145
|
+
[`$${itemNameToUse}Index`]: index
|
|
146
|
+
})
|
|
147
|
+
}),
|
|
148
|
+
block: blockWithoutRepeat
|
|
149
|
+
}));
|
|
150
|
+
return repeatArray;
|
|
151
|
+
}
|
|
152
|
+
const TagNameRef = tagName();
|
|
153
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, !isEmptyHtmlElement(tagName()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()), repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
|
|
154
|
+
key: index,
|
|
155
|
+
repeatContext: data.context,
|
|
156
|
+
block: data.block
|
|
157
|
+
}))) : null, !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderComponent, __spreadValues({}, renderComponentProps()))) : null, (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
158
|
+
key: "render-block-" + child.id,
|
|
159
|
+
block: child,
|
|
160
|
+
context: props.context
|
|
161
|
+
})), (_c = childrenWithoutParentComponent()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
162
|
+
key: "block-style-" + child.id,
|
|
163
|
+
block: child,
|
|
164
|
+
context: props.context
|
|
165
|
+
})))) : /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()))) : /* @__PURE__ */ React.createElement(RenderComponent, __spreadProps(__spreadValues({}, renderComponentProps()), {
|
|
166
|
+
context: props.context
|
|
167
|
+
})));
|
|
168
|
+
}
|
|
169
|
+
export {
|
|
170
|
+
RenderBlock as default
|
|
171
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import BlockStyles from "./block-styles.js";
|
|
19
|
+
import RenderBlock from "./render-block.js";
|
|
20
|
+
function RenderComponent(props) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const ComponentRefRef = props.componentRef;
|
|
23
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.componentRef ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadValues({}, props.componentOptions), (_a = props.blockChildren) == null ? void 0 : _a.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
24
|
+
key: "render-block-" + child.id,
|
|
25
|
+
block: child,
|
|
26
|
+
context: props.context
|
|
27
|
+
})), (_b = props.blockChildren) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
28
|
+
key: "block-style-" + child.id,
|
|
29
|
+
block: child,
|
|
30
|
+
context: props.context
|
|
31
|
+
})))) : null);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
RenderComponent as default
|
|
35
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import BuilderContext from "../../context/builder.context.js";
|
|
3
|
+
import RenderBlock from "./render-block.js";
|
|
4
|
+
function RenderRepeatedBlock(props) {
|
|
5
|
+
return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
|
|
6
|
+
value: {
|
|
7
|
+
get content() {
|
|
8
|
+
return props.repeatContext.content;
|
|
9
|
+
},
|
|
10
|
+
get state() {
|
|
11
|
+
return props.repeatContext.state;
|
|
12
|
+
},
|
|
13
|
+
get context() {
|
|
14
|
+
return props.repeatContext.context;
|
|
15
|
+
},
|
|
16
|
+
get apiKey() {
|
|
17
|
+
return props.repeatContext.apiKey;
|
|
18
|
+
},
|
|
19
|
+
get registeredComponents() {
|
|
20
|
+
return props.repeatContext.registeredComponents;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}, /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
24
|
+
block: props.block,
|
|
25
|
+
context: props.repeatContext
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
RenderRepeatedBlock as default
|
|
30
|
+
};
|
|
File without changes
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import BuilderContext from "../context/builder.context.js";
|
|
5
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
6
|
+
import BlockStyles from "./render-block/block-styles.js";
|
|
7
|
+
import RenderBlock from "./render-block/render-block.js";
|
|
5
8
|
function RenderBlocks(props) {
|
|
6
|
-
var _a;
|
|
9
|
+
var _a, _b;
|
|
10
|
+
function className() {
|
|
11
|
+
var _a2;
|
|
12
|
+
return "builder-blocks" + (!((_a2 = props.blocks) == null ? void 0 : _a2.length) ? " no-blocks" : "");
|
|
13
|
+
}
|
|
7
14
|
function onClick() {
|
|
8
|
-
var _a2,
|
|
15
|
+
var _a2, _b2;
|
|
9
16
|
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
10
|
-
(
|
|
17
|
+
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
11
18
|
type: "builder.clickEmptyBlocks",
|
|
12
19
|
data: {
|
|
13
20
|
parentElementId: props.parent,
|
|
@@ -17,9 +24,9 @@ function RenderBlocks(props) {
|
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
function onMouseEnter() {
|
|
20
|
-
var _a2,
|
|
27
|
+
var _a2, _b2;
|
|
21
28
|
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
22
|
-
(
|
|
29
|
+
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
23
30
|
type: "builder.hoverEmptyBlocks",
|
|
24
31
|
data: {
|
|
25
32
|
parentElementId: props.parent,
|
|
@@ -28,16 +35,25 @@ function RenderBlocks(props) {
|
|
|
28
35
|
}, "*");
|
|
29
36
|
}
|
|
30
37
|
}
|
|
38
|
+
const builderContext = useContext(BuilderContext);
|
|
31
39
|
return /* @__PURE__ */ React.createElement(View, {
|
|
32
|
-
className: "builder-blocks" + (!((_a = props.blocks) == null ? void 0 : _a.length) ? " no-blocks" : ""),
|
|
33
40
|
"builder-path": props.path,
|
|
34
41
|
"builder-parent-id": props.parent,
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
dataSet: {
|
|
43
|
+
class: className()
|
|
44
|
+
},
|
|
45
|
+
onClick: (event) => onClick(),
|
|
46
|
+
onMouseEnter: (event) => onMouseEnter(),
|
|
37
47
|
style: styles.view1
|
|
38
|
-
}, props.blocks.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
39
|
-
block
|
|
40
|
-
|
|
48
|
+
}, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
49
|
+
key: "render-block-" + block.id,
|
|
50
|
+
block,
|
|
51
|
+
context: builderContext
|
|
52
|
+
}))) : null, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
53
|
+
key: "block-style-" + block.id,
|
|
54
|
+
block,
|
|
55
|
+
context: builderContext
|
|
56
|
+
}))) : null);
|
|
41
57
|
}
|
|
42
58
|
const styles = StyleSheet.create({
|
|
43
59
|
view1: { display: "flex", flexDirection: "column", alignItems: "stretch" }
|