@builder.io/sdk-react-native 0.0.1-49 → 0.0.1-51
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 +11 -2
- package/package.json +1 -1
- package/src/blocks/button/button.js +31 -0
- package/src/blocks/{button.lite.tsx → button/button.lite.tsx} +3 -3
- package/src/blocks/button/component-info.js +42 -0
- package/src/blocks/columns/columns.js +59 -0
- package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +22 -21
- package/src/blocks/columns/component-info.js +218 -0
- package/src/blocks/custom-code/component-info.js +32 -0
- package/src/blocks/custom-code/custom-code.js +50 -0
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +11 -11
- package/src/blocks/embed/component-info.js +25 -0
- package/src/blocks/embed/embed.js +50 -0
- package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +11 -11
- package/src/blocks/form/component-info.js +263 -0
- package/src/blocks/form/form.js +221 -0
- package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +51 -50
- package/src/blocks/fragment/component-info.js +12 -0
- package/src/blocks/fragment/fragment.js +8 -0
- package/src/blocks/{fragment.lite.tsx → fragment/fragment.lite.tsx} +2 -2
- package/src/blocks/image/component-info.js +105 -0
- package/src/blocks/image/image.js +41 -0
- package/src/blocks/{image.lite.tsx → image/image.lite.tsx} +11 -11
- package/src/blocks/img/component-info.js +21 -0
- package/src/blocks/img/img.js +36 -0
- package/src/blocks/img/img.lite.tsx +18 -0
- package/src/blocks/input/component-info.js +75 -0
- package/src/blocks/input/input.js +36 -0
- package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +4 -4
- package/src/blocks/raw-text/component-info.js +17 -0
- package/src/blocks/raw-text/raw-text.js +10 -0
- package/src/blocks/raw-text/raw-text.lite.tsx +6 -0
- package/src/blocks/section/component-info.js +50 -0
- package/src/blocks/section/section.js +31 -0
- package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +3 -3
- package/src/blocks/select/component-info.js +60 -0
- package/src/blocks/select/select.js +36 -0
- package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +4 -4
- package/src/blocks/submit-button/component-info.js +29 -0
- package/src/blocks/submit-button/submit-button.js +29 -0
- package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +2 -2
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.js +68 -0
- package/src/blocks/symbol/symbol.lite.tsx +60 -0
- package/src/blocks/text/component-info.js +25 -0
- package/src/blocks/text/text.js +65 -0
- package/src/blocks/text/text.lite.tsx +6 -0
- package/src/blocks/textarea/component-info.js +48 -0
- package/src/blocks/textarea/textarea.js +32 -0
- package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +2 -2
- package/src/blocks/video/component-info.js +107 -0
- package/src/blocks/video/video.js +33 -0
- package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +5 -5
- package/src/components/error-boundary.js +9 -11
- package/src/components/error-boundary.lite.tsx +2 -2
- package/src/components/render-block/block-styles.js +29 -0
- package/src/components/render-block/block-styles.lite.tsx +35 -0
- package/src/components/render-block/render-block.helpers.js +24 -0
- package/src/components/render-block/render-block.js +116 -0
- package/src/components/render-block/render-block.lite.tsx +139 -0
- package/src/components/render-blocks.js +35 -61
- package/src/components/render-blocks.lite.tsx +11 -11
- package/src/components/render-content/components/render-styles.js +58 -0
- package/src/components/render-content/components/render-styles.lite.tsx +70 -0
- package/src/components/render-content/index.js +5 -0
- package/src/components/render-content/render-content.js +254 -0
- package/src/components/render-content/render-content.lite.tsx +283 -0
- package/src/components/render-inlined-styles.js +18 -0
- package/src/components/render-inlined-styles.lite.tsx +31 -0
- package/src/constants/builder-registered-components.js +27 -0
- package/src/constants/device-sizes.js +11 -8
- package/src/constants/target.js +5 -0
- package/src/context/builder.context.js +11 -3
- package/src/functions/evaluate.js +20 -20
- package/src/functions/event-handler-name.js +3 -1
- package/src/functions/fast-clone.js +5 -0
- package/src/functions/get-block-actions.js +17 -16
- package/src/functions/get-block-component-options.js +9 -16
- package/src/functions/get-block-properties.js +14 -18
- package/src/functions/get-block-styles.js +17 -34
- package/src/functions/get-block-tag.js +4 -2
- package/src/functions/get-builder-search-params/fn.test.js +6 -10
- package/src/functions/get-builder-search-params/index.js +6 -3
- package/src/functions/get-content/fn.test.js +15 -17
- package/src/functions/get-content/index.js +25 -42
- package/src/functions/get-fetch.js +32 -8
- package/src/functions/get-global-this.js +7 -5
- package/src/functions/get-processed-block.js +13 -17
- package/src/functions/get-processed-block.test.js +16 -27
- package/src/functions/if-target.js +14 -3
- package/src/functions/is-browser.js +4 -2
- package/src/functions/is-editing.js +5 -5
- package/src/functions/is-iframe.js +4 -2
- package/src/functions/is-previewing.js +6 -4
- package/src/functions/is-react-native.js +3 -1
- package/src/functions/macro-eval.js +5 -2
- package/src/functions/on-change.js +7 -4
- package/src/functions/on-change.test.js +9 -10
- package/src/functions/previewing-model-name.js +5 -3
- package/src/functions/register-component.js +33 -44
- package/src/functions/register.js +10 -8
- package/src/functions/set-editor-settings.js +7 -5
- package/src/functions/set.js +5 -14
- package/src/functions/set.test.js +13 -14
- package/src/functions/track.js +13 -7
- package/src/functions/transform-block.js +13 -17
- package/src/index-helpers/blocks-exports.js +9 -9
- package/src/index-helpers/top-of-file.js +1 -1
- package/src/index.js +10 -12
- package/src/scripts/init-editing.js +74 -88
- package/src/types/components.js +1 -0
- package/src/types/element.js +1 -0
- package/src/types/targets.js +1 -0
- package/src/types/typescript.js +1 -0
- package/src/blocks/button.js +0 -86
- package/src/blocks/columns.js +0 -293
- package/src/blocks/custom-code.js +0 -83
- package/src/blocks/embed.js +0 -77
- package/src/blocks/form.js +0 -521
- package/src/blocks/fragment.js +0 -21
- package/src/blocks/image.js +0 -165
- package/src/blocks/img.js +0 -64
- package/src/blocks/img.lite.tsx +0 -18
- package/src/blocks/input.js +0 -113
- package/src/blocks/raw-text.js +0 -17
- package/src/blocks/raw-text.lite.tsx +0 -6
- package/src/blocks/section.js +0 -84
- package/src/blocks/select.js +0 -91
- package/src/blocks/submit-button.js +0 -60
- package/src/blocks/symbol.js +0 -20
- package/src/blocks/symbol.lite.tsx +0 -20
- package/src/blocks/text.js +0 -100
- package/src/blocks/text.lite.tsx +0 -6
- package/src/blocks/textarea.js +0 -73
- package/src/blocks/video.js +0 -100
- package/src/components/block-styles.js +0 -5
- package/src/components/block-styles.lite.tsx +0 -6
- package/src/components/render-block.js +0 -164
- package/src/components/render-block.lite.tsx +0 -132
- package/src/components/render-content.js +0 -220
- package/src/components/render-content.lite.tsx +0 -206
- package/src/functions/get-target.js +0 -5
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const componentInfo = {
|
|
3
|
+
name: "Form:TextArea",
|
|
4
|
+
builtIn: true,
|
|
5
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3",
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
advanced: true,
|
|
9
|
+
name: "value",
|
|
10
|
+
type: "string"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: "name",
|
|
14
|
+
type: "string",
|
|
15
|
+
required: true,
|
|
16
|
+
helperText: 'Every input in a form needs a unique name describing what it gets, e.g. "email"'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "defaultValue",
|
|
20
|
+
type: "string"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "placeholder",
|
|
24
|
+
type: "string",
|
|
25
|
+
defaultValue: "Hello there"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "required",
|
|
29
|
+
type: "boolean",
|
|
30
|
+
defaultValue: false
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
defaultStyles: {
|
|
34
|
+
paddingTop: "10px",
|
|
35
|
+
paddingBottom: "10px",
|
|
36
|
+
paddingLeft: "10px",
|
|
37
|
+
paddingRight: "10px",
|
|
38
|
+
borderRadius: "3px",
|
|
39
|
+
borderWidth: "1px",
|
|
40
|
+
borderStyle: "solid",
|
|
41
|
+
borderColor: "#ccc"
|
|
42
|
+
},
|
|
43
|
+
static: true,
|
|
44
|
+
noWrap: true
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
componentInfo
|
|
48
|
+
};
|
|
@@ -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,107 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const componentInfo = {
|
|
3
|
+
name: "Video",
|
|
4
|
+
canHaveChildren: true,
|
|
5
|
+
builtIn: true,
|
|
6
|
+
defaultStyles: {
|
|
7
|
+
minHeight: "20px",
|
|
8
|
+
minWidth: "20px"
|
|
9
|
+
},
|
|
10
|
+
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",
|
|
11
|
+
inputs: [
|
|
12
|
+
{
|
|
13
|
+
name: "video",
|
|
14
|
+
type: "file",
|
|
15
|
+
allowedFileTypes: ["mp4"],
|
|
16
|
+
bubble: true,
|
|
17
|
+
defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "posterImage",
|
|
22
|
+
type: "file",
|
|
23
|
+
allowedFileTypes: ["jpeg", "png"],
|
|
24
|
+
helperText: "Image to show before the video plays"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "autoPlay",
|
|
28
|
+
type: "boolean",
|
|
29
|
+
defaultValue: true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "controls",
|
|
33
|
+
type: "boolean",
|
|
34
|
+
defaultValue: false
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "muted",
|
|
38
|
+
type: "boolean",
|
|
39
|
+
defaultValue: true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "loop",
|
|
43
|
+
type: "boolean",
|
|
44
|
+
defaultValue: true
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "playsInline",
|
|
48
|
+
type: "boolean",
|
|
49
|
+
defaultValue: true
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "fit",
|
|
53
|
+
type: "text",
|
|
54
|
+
defaultValue: "cover",
|
|
55
|
+
enum: ["contain", "cover", "fill", "auto"]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "fitContent",
|
|
59
|
+
type: "boolean",
|
|
60
|
+
helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
|
|
61
|
+
defaultValue: true,
|
|
62
|
+
advanced: true
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "position",
|
|
66
|
+
type: "text",
|
|
67
|
+
defaultValue: "center",
|
|
68
|
+
enum: [
|
|
69
|
+
"center",
|
|
70
|
+
"top",
|
|
71
|
+
"left",
|
|
72
|
+
"right",
|
|
73
|
+
"bottom",
|
|
74
|
+
"top left",
|
|
75
|
+
"top right",
|
|
76
|
+
"bottom left",
|
|
77
|
+
"bottom right"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "height",
|
|
82
|
+
type: "number",
|
|
83
|
+
advanced: true
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "width",
|
|
87
|
+
type: "number",
|
|
88
|
+
advanced: true
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "aspectRatio",
|
|
92
|
+
type: "number",
|
|
93
|
+
advanced: true,
|
|
94
|
+
defaultValue: 0.7004048582995948
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "lazyLoad",
|
|
98
|
+
type: "boolean",
|
|
99
|
+
helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
100
|
+
defaultValue: true,
|
|
101
|
+
advanced: true
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
};
|
|
105
|
+
export {
|
|
106
|
+
componentInfo
|
|
107
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import ReactVideo from "react-native-video";
|
|
4
|
+
function Video(props) {
|
|
5
|
+
return /* @__PURE__ */ React.createElement(View, {
|
|
6
|
+
style: { position: "relative" }
|
|
7
|
+
}, /* @__PURE__ */ React.createElement(ReactVideo, {
|
|
8
|
+
paused: !props.autoPlay,
|
|
9
|
+
controls: props.controls,
|
|
10
|
+
muted: props.muted,
|
|
11
|
+
repeat: props.loop,
|
|
12
|
+
poster: props.posterImage,
|
|
13
|
+
posterResizeMode: props.fit || "contain",
|
|
14
|
+
resizeMode: props.fit || "contain",
|
|
15
|
+
style: {
|
|
16
|
+
position: "absolute",
|
|
17
|
+
top: 0,
|
|
18
|
+
bottom: 0,
|
|
19
|
+
left: 0,
|
|
20
|
+
right: 0,
|
|
21
|
+
zIndex: 1
|
|
22
|
+
},
|
|
23
|
+
source: { uri: props.video }
|
|
24
|
+
}), /* @__PURE__ */ React.createElement(View, {
|
|
25
|
+
style: {
|
|
26
|
+
width: "100%",
|
|
27
|
+
paddingTop: `${props.aspectRatio * 100}%`
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
Video as default
|
|
33
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
4
|
export default function Video(props) {
|
|
5
5
|
return (
|
|
@@ -7,8 +7,8 @@ export default function Video(props) {
|
|
|
7
7
|
{...props.attributes}
|
|
8
8
|
preload="none"
|
|
9
9
|
style={{
|
|
10
|
-
width:
|
|
11
|
-
height:
|
|
10
|
+
width: "100%",
|
|
11
|
+
height: "100%",
|
|
12
12
|
...props.attributes?.style,
|
|
13
13
|
objectFit: props.fit,
|
|
14
14
|
objectPosition: props.position,
|
|
@@ -16,7 +16,7 @@ export default function Video(props) {
|
|
|
16
16
|
// not have the video overflow
|
|
17
17
|
borderRadius: 1,
|
|
18
18
|
}}
|
|
19
|
-
key={props.video ||
|
|
19
|
+
key={props.video || "no-src"}
|
|
20
20
|
poster={props.posterImage}
|
|
21
21
|
autoPlay={props.autoPlay}
|
|
22
22
|
muted={props.muted}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Text } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Text } from "react-native";
|
|
3
3
|
class ErrorBoundary extends React.Component {
|
|
4
4
|
constructor(props) {
|
|
5
5
|
super(props);
|
|
@@ -9,19 +9,17 @@ class ErrorBoundary extends React.Component {
|
|
|
9
9
|
return { hasError: true };
|
|
10
10
|
}
|
|
11
11
|
componentDidCatch(error, errorInfo) {
|
|
12
|
-
console.error(
|
|
12
|
+
console.error("Error rendering Builder.io block", error, errorInfo);
|
|
13
13
|
}
|
|
14
14
|
render() {
|
|
15
15
|
if (this.state.hasError) {
|
|
16
|
-
return /* @__PURE__ */ React.createElement(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
style: { color: 'gray' },
|
|
20
|
-
},
|
|
21
|
-
'Error rendering Builder.io block'
|
|
22
|
-
);
|
|
16
|
+
return /* @__PURE__ */ React.createElement(Text, {
|
|
17
|
+
style: { color: "gray" }
|
|
18
|
+
}, "Error rendering Builder.io block");
|
|
23
19
|
}
|
|
24
20
|
return this.props.children;
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
|
-
export {
|
|
23
|
+
export {
|
|
24
|
+
ErrorBoundary as default
|
|
25
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import RenderInlinedStyles from "../render-inlined-styles.js";
|
|
3
|
+
function BlockStyles(props) {
|
|
4
|
+
function camelToKebabCase(string) {
|
|
5
|
+
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
6
|
+
}
|
|
7
|
+
function css() {
|
|
8
|
+
var _a;
|
|
9
|
+
const styleObject = (_a = props.block.responsiveStyles) == null ? void 0 : _a.large;
|
|
10
|
+
if (!styleObject) {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
let str = `.${props.block.id} {`;
|
|
14
|
+
for (const key in styleObject) {
|
|
15
|
+
const value = styleObject[key];
|
|
16
|
+
if (typeof value === "string") {
|
|
17
|
+
str += `${camelToKebabCase(key)}: ${value};`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
str += "}";
|
|
21
|
+
return str;
|
|
22
|
+
}
|
|
23
|
+
return /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
|
|
24
|
+
styles: css()
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
BlockStyles as default
|
|
29
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
import RenderInlinedStyles from "../render-inlined-styles.lite";
|
|
4
|
+
|
|
5
|
+
export default function BlockStyles(props) {
|
|
6
|
+
function camelToKebabCase(string) {
|
|
7
|
+
return string
|
|
8
|
+
.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2")
|
|
9
|
+
.toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function css() {
|
|
13
|
+
// TODO: media queries
|
|
14
|
+
const styleObject = props.block.responsiveStyles?.large;
|
|
15
|
+
|
|
16
|
+
if (!styleObject) {
|
|
17
|
+
return "";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let str = `.${props.block.id} {`;
|
|
21
|
+
|
|
22
|
+
for (const key in styleObject) {
|
|
23
|
+
const value = styleObject[key];
|
|
24
|
+
|
|
25
|
+
if (typeof value === "string") {
|
|
26
|
+
str += `${camelToKebabCase(key)}: ${value};`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
str += "}";
|
|
31
|
+
return str;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return <RenderInlinedStyles styles={css()} />;
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const EMPTY_HTML_ELEMENTS = [
|
|
3
|
+
"area",
|
|
4
|
+
"base",
|
|
5
|
+
"br",
|
|
6
|
+
"col",
|
|
7
|
+
"embed",
|
|
8
|
+
"hr",
|
|
9
|
+
"img",
|
|
10
|
+
"input",
|
|
11
|
+
"keygen",
|
|
12
|
+
"link",
|
|
13
|
+
"meta",
|
|
14
|
+
"param",
|
|
15
|
+
"source",
|
|
16
|
+
"track",
|
|
17
|
+
"wbr"
|
|
18
|
+
];
|
|
19
|
+
const isEmptyHtmlElement = (tagName) => {
|
|
20
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
isEmptyHtmlElement
|
|
24
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
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 { useContext } from "react";
|
|
22
|
+
import { TARGET } from "../../constants/target.js";
|
|
23
|
+
import BuilderContext from "../../context/builder.context";
|
|
24
|
+
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
25
|
+
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
26
|
+
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
27
|
+
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
28
|
+
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
29
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
30
|
+
import BlockStyles from "./block-styles.js";
|
|
31
|
+
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
32
|
+
function RenderBlock(props) {
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
|
+
function component() {
|
|
35
|
+
var _a2;
|
|
36
|
+
const componentName = (_a2 = useBlock().component) == null ? void 0 : _a2.name;
|
|
37
|
+
if (!componentName) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const ref = builderContext.registeredComponents[componentName];
|
|
41
|
+
if (!ref) {
|
|
42
|
+
console.warn(`
|
|
43
|
+
Could not find a registered component named "${componentName}".
|
|
44
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
45
|
+
return void 0;
|
|
46
|
+
} else {
|
|
47
|
+
return ref;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function componentInfo() {
|
|
51
|
+
var _a2;
|
|
52
|
+
return (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.info;
|
|
53
|
+
}
|
|
54
|
+
function componentRef() {
|
|
55
|
+
var _a2;
|
|
56
|
+
return (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component;
|
|
57
|
+
}
|
|
58
|
+
function tagName() {
|
|
59
|
+
return getBlockTag(useBlock());
|
|
60
|
+
}
|
|
61
|
+
function useBlock() {
|
|
62
|
+
return getProcessedBlock({
|
|
63
|
+
block: props.block,
|
|
64
|
+
state: builderContext.state,
|
|
65
|
+
context: builderContext.context
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function propertiesAndActions() {
|
|
69
|
+
return __spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
|
|
70
|
+
block: useBlock(),
|
|
71
|
+
state: builderContext.state,
|
|
72
|
+
context: builderContext.context
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
function css() {
|
|
76
|
+
return getBlockStyles(useBlock());
|
|
77
|
+
}
|
|
78
|
+
function componentOptions() {
|
|
79
|
+
return getBlockComponentOptions(useBlock());
|
|
80
|
+
}
|
|
81
|
+
function children() {
|
|
82
|
+
var _a2;
|
|
83
|
+
return (_a2 = useBlock().children) != null ? _a2 : [];
|
|
84
|
+
}
|
|
85
|
+
function noCompRefChildren() {
|
|
86
|
+
return componentRef() ? [] : children();
|
|
87
|
+
}
|
|
88
|
+
const builderContext = useContext(BuilderContext);
|
|
89
|
+
const ComponentRefRef = componentRef();
|
|
90
|
+
const TagNameRef = tagName();
|
|
91
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, !((_a = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _a.noWrap) ? /* @__PURE__ */ React.createElement(React.Fragment, null, !isEmptyHtmlElement(tagName()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadProps(__spreadValues({}, propertiesAndActions()), {
|
|
92
|
+
style: css()
|
|
93
|
+
}), TARGET === "vue" || TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
94
|
+
block: useBlock()
|
|
95
|
+
})) : null, componentRef() ? /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, componentOptions()), {
|
|
96
|
+
builderBlock: useBlock()
|
|
97
|
+
}), (_b = children()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
98
|
+
key: child.id,
|
|
99
|
+
block: child
|
|
100
|
+
}))) : null, (_c = noCompRefChildren()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
101
|
+
key: child.id,
|
|
102
|
+
block: child
|
|
103
|
+
})))) : /* @__PURE__ */ React.createElement(TagNameRef, __spreadProps(__spreadValues({}, propertiesAndActions()), {
|
|
104
|
+
style: css()
|
|
105
|
+
}))) : /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, componentOptions()), {
|
|
106
|
+
attributes: propertiesAndActions(),
|
|
107
|
+
builderBlock: useBlock(),
|
|
108
|
+
style: css()
|
|
109
|
+
}), (_d = children()) == null ? void 0 : _d.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
110
|
+
key: child.id,
|
|
111
|
+
block: child
|
|
112
|
+
}))));
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
RenderBlock as default
|
|
116
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { TARGET } from "../../constants/target.js";
|
|
5
|
+
import BuilderContext from "../../context/builder.context";
|
|
6
|
+
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
7
|
+
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
8
|
+
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
9
|
+
import { getBlockStyles } from "../../functions/get-block-styles.js";
|
|
10
|
+
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
11
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
12
|
+
import BlockStyles from "./block-styles.lite";
|
|
13
|
+
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
14
|
+
|
|
15
|
+
export default function RenderBlock(props) {
|
|
16
|
+
function component() {
|
|
17
|
+
const componentName = useBlock().component?.name;
|
|
18
|
+
|
|
19
|
+
if (!componentName) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ref = builderContext.registeredComponents[componentName];
|
|
24
|
+
|
|
25
|
+
if (!ref) {
|
|
26
|
+
// TODO: Public doc page with more info about this message
|
|
27
|
+
console.warn(`
|
|
28
|
+
Could not find a registered component named "${componentName}".
|
|
29
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
30
|
+
return undefined;
|
|
31
|
+
} else {
|
|
32
|
+
return ref;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function componentInfo() {
|
|
37
|
+
return component?.()?.info;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function componentRef() {
|
|
41
|
+
return component?.()?.component;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function tagName() {
|
|
45
|
+
return getBlockTag(useBlock());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function useBlock() {
|
|
49
|
+
return getProcessedBlock({
|
|
50
|
+
block: props.block,
|
|
51
|
+
state: builderContext.state,
|
|
52
|
+
context: builderContext.context,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function propertiesAndActions() {
|
|
57
|
+
return {
|
|
58
|
+
...getBlockProperties(useBlock()),
|
|
59
|
+
...getBlockActions({
|
|
60
|
+
block: useBlock(),
|
|
61
|
+
state: builderContext.state,
|
|
62
|
+
context: builderContext.context,
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function css() {
|
|
68
|
+
return getBlockStyles(useBlock());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function componentOptions() {
|
|
72
|
+
return getBlockComponentOptions(useBlock());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function children() {
|
|
76
|
+
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
77
|
+
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
78
|
+
// but still receive and need to render children.
|
|
79
|
+
// return componentInfo?.()?.canHaveChildren ? useBlock().children : [];
|
|
80
|
+
return useBlock().children ?? [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function noCompRefChildren() {
|
|
84
|
+
return componentRef() ? [] : children();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const builderContext = useContext(BuilderContext);
|
|
88
|
+
|
|
89
|
+
const ComponentRefRef = componentRef();
|
|
90
|
+
const TagNameRef = tagName();
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
{!componentInfo?.()?.noWrap ? (
|
|
95
|
+
<>
|
|
96
|
+
{!isEmptyHtmlElement(tagName()) ? (
|
|
97
|
+
<>
|
|
98
|
+
<TagNameRef {...propertiesAndActions()} style={css()}>
|
|
99
|
+
{TARGET === "vue" || TARGET === "svelte" ? (
|
|
100
|
+
<>
|
|
101
|
+
<BlockStyles block={useBlock()} />
|
|
102
|
+
</>
|
|
103
|
+
) : null}
|
|
104
|
+
|
|
105
|
+
{componentRef() ? (
|
|
106
|
+
<ComponentRefRef
|
|
107
|
+
{...componentOptions()}
|
|
108
|
+
builderBlock={useBlock()}
|
|
109
|
+
>
|
|
110
|
+
{children()?.map((child) => (
|
|
111
|
+
<RenderBlock key={child.id} block={child} />
|
|
112
|
+
))}
|
|
113
|
+
</ComponentRefRef>
|
|
114
|
+
) : null}
|
|
115
|
+
|
|
116
|
+
{noCompRefChildren()?.map((child) => (
|
|
117
|
+
<RenderBlock key={child.id} block={child} />
|
|
118
|
+
))}
|
|
119
|
+
</TagNameRef>
|
|
120
|
+
</>
|
|
121
|
+
) : (
|
|
122
|
+
<TagNameRef {...propertiesAndActions()} style={css()} />
|
|
123
|
+
)}
|
|
124
|
+
</>
|
|
125
|
+
) : (
|
|
126
|
+
<ComponentRefRef
|
|
127
|
+
{...componentOptions()}
|
|
128
|
+
attributes={propertiesAndActions()}
|
|
129
|
+
builderBlock={useBlock()}
|
|
130
|
+
style={css()}
|
|
131
|
+
>
|
|
132
|
+
{children()?.map((child) => (
|
|
133
|
+
<RenderBlock key={child.id} block={child} />
|
|
134
|
+
))}
|
|
135
|
+
</ComponentRefRef>
|
|
136
|
+
)}
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
}
|