@builder.io/sdk-react-native 0.0.1-50 → 0.0.1-53
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 +14 -0
- package/package.json +1 -1
- package/src/blocks/button/button.js +31 -0
- package/src/blocks/{button.lite.tsx → button/button.lite.tsx} +0 -0
- 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} +5 -4
- 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} +1 -1
- 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} +1 -1
- 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} +8 -7
- 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} +0 -0
- package/src/blocks/{image.js → image/component-info.js} +4 -42
- package/src/blocks/image/image.js +41 -0
- package/src/blocks/{image.lite.tsx → image/image.lite.tsx} +1 -1
- package/src/blocks/img/component-info.js +21 -0
- package/src/blocks/img/img.js +36 -0
- package/src/blocks/{img.lite.tsx → img/img.lite.tsx} +1 -1
- 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} +1 -1
- 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.lite.tsx → raw-text/raw-text.lite.tsx} +1 -1
- 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} +0 -0
- 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} +2 -2
- 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} +0 -0
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.js +68 -0
- package/src/blocks/{symbol.lite.tsx → symbol/symbol.lite.tsx} +7 -7
- package/src/blocks/text/component-info.js +25 -0
- package/src/blocks/{text.js → text/text.js} +0 -22
- package/src/blocks/{text.lite.tsx → text/text.lite.tsx} +1 -1
- 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} +0 -0
- package/src/blocks/{video.js → video/component-info.js} +52 -40
- package/src/blocks/video/video.js +33 -0
- package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +0 -0
- 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.js → render-block/render-block.js} +28 -20
- package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +43 -31
- package/src/components/render-blocks.js +3 -3
- package/src/components/render-blocks.lite.tsx +3 -3
- 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.js → render-content/render-content.js} +57 -69
- package/src/components/{render-content.lite.tsx → render-content/render-content.lite.tsx} +67 -92
- 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/target.js +5 -0
- package/src/context/builder.context.js +2 -1
- package/src/functions/evaluate.js +2 -2
- package/src/functions/fast-clone.js +5 -0
- package/src/functions/get-block-actions.js +2 -2
- package/src/functions/get-block-properties.js +1 -1
- package/src/functions/get-builder-search-params/fn.test.js +1 -1
- package/src/functions/get-content/index.js +3 -2
- package/src/functions/get-fetch.js +29 -7
- package/src/functions/get-processed-block.js +3 -3
- package/src/functions/get-processed-block.test.js +1 -1
- package/src/functions/if-target.js +11 -2
- package/src/functions/is-editing.js +1 -1
- package/src/functions/is-iframe.js +1 -1
- package/src/functions/is-previewing.js +2 -2
- package/src/functions/on-change.test.js +1 -1
- package/src/functions/previewing-model-name.js +1 -1
- package/src/functions/register-component.js +30 -13
- package/src/functions/register.js +1 -1
- package/src/functions/set-editor-settings.js +1 -1
- package/src/functions/set.test.js +1 -1
- package/src/functions/track.js +4 -4
- package/src/index-helpers/blocks-exports.js +8 -8
- package/src/index.js +10 -13
- package/src/scripts/init-editing.js +72 -62
- package/src/types/components.js +1 -0
- package/src/types/element.js +1 -0
- package/src/types/targets.js +1 -0
- package/src/blocks/button.js +0 -36
- package/src/blocks/columns.js +0 -63
- package/src/blocks/custom-code.js +0 -55
- package/src/blocks/embed.js +0 -55
- package/src/blocks/form.js +0 -225
- package/src/blocks/fragment.js +0 -13
- package/src/blocks/img.js +0 -41
- package/src/blocks/input.js +0 -41
- package/src/blocks/raw-text.js +0 -15
- package/src/blocks/section.js +0 -36
- package/src/blocks/select.js +0 -41
- package/src/blocks/submit-button.js +0 -34
- package/src/blocks/symbol.js +0 -73
- package/src/blocks/textarea.js +0 -37
- package/src/components/block-styles.js +0 -7
- package/src/components/block-styles.lite.tsx +0 -6
- package/src/functions/get-target.js +0 -7
|
@@ -16,7 +16,6 @@ var __spreadValues = (a, b) => {
|
|
|
16
16
|
return a;
|
|
17
17
|
};
|
|
18
18
|
import HTML from "react-native-render-html";
|
|
19
|
-
import { registerComponent } from "../functions/register-component";
|
|
20
19
|
function camelToKebabCase(string) {
|
|
21
20
|
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
22
21
|
}
|
|
@@ -61,27 +60,6 @@ function Text(props) {
|
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
62
|
}
|
|
64
|
-
registerComponent(Text, {
|
|
65
|
-
name: "Text",
|
|
66
|
-
static: true,
|
|
67
|
-
builtIn: true,
|
|
68
|
-
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
|
|
69
|
-
inputs: [
|
|
70
|
-
{
|
|
71
|
-
name: "text",
|
|
72
|
-
type: "html",
|
|
73
|
-
required: true,
|
|
74
|
-
autoFocus: true,
|
|
75
|
-
bubble: true,
|
|
76
|
-
defaultValue: "Enter some text..."
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
defaultStyles: {
|
|
80
|
-
lineHeight: "normal",
|
|
81
|
-
height: "auto",
|
|
82
|
-
textAlign: "center"
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
63
|
export {
|
|
86
64
|
Text as default
|
|
87
65
|
};
|
|
@@ -2,5 +2,5 @@ import * as React from "react";
|
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
4
|
export default function Text(props) {
|
|
5
|
-
return <View dangerouslySetInnerHTML={{ __html:
|
|
5
|
+
return <View dangerouslySetInnerHTML={{ __html: props.text }} />;
|
|
6
6
|
}
|
|
@@ -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
|
+
};
|
|
File without changes
|
|
@@ -1,46 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import ReactVideo from "react-native-video";
|
|
4
|
-
import { registerComponent } from "../functions/register-component";
|
|
5
|
-
function Video(props) {
|
|
6
|
-
return /* @__PURE__ */ React.createElement(View, {
|
|
7
|
-
style: { position: "relative" }
|
|
8
|
-
}, /* @__PURE__ */ React.createElement(ReactVideo, {
|
|
9
|
-
paused: !props.autoPlay,
|
|
10
|
-
controls: props.controls,
|
|
11
|
-
muted: props.muted,
|
|
12
|
-
repeat: props.loop,
|
|
13
|
-
poster: props.posterImage,
|
|
14
|
-
posterResizeMode: props.fit || "contain",
|
|
15
|
-
resizeMode: props.fit || "contain",
|
|
16
|
-
style: {
|
|
17
|
-
position: "absolute",
|
|
18
|
-
top: 0,
|
|
19
|
-
bottom: 0,
|
|
20
|
-
left: 0,
|
|
21
|
-
right: 0,
|
|
22
|
-
zIndex: 1
|
|
23
|
-
},
|
|
24
|
-
source: { uri: props.video }
|
|
25
|
-
}), /* @__PURE__ */ React.createElement(View, {
|
|
26
|
-
style: {
|
|
27
|
-
width: "100%",
|
|
28
|
-
paddingTop: `${props.aspectRatio * 100}%`
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
registerComponent(Video, {
|
|
2
|
+
const componentInfo = {
|
|
33
3
|
name: "Video",
|
|
34
|
-
|
|
4
|
+
canHaveChildren: true,
|
|
35
5
|
builtIn: true,
|
|
36
|
-
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
|
|
37
6
|
defaultStyles: {
|
|
38
|
-
position: "relative",
|
|
39
7
|
minHeight: "20px",
|
|
40
|
-
minWidth: "20px"
|
|
41
|
-
overflow: "hidden"
|
|
8
|
+
minWidth: "20px"
|
|
42
9
|
},
|
|
43
|
-
|
|
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",
|
|
44
11
|
inputs: [
|
|
45
12
|
{
|
|
46
13
|
name: "video",
|
|
@@ -76,20 +43,65 @@ registerComponent(Video, {
|
|
|
76
43
|
type: "boolean",
|
|
77
44
|
defaultValue: true
|
|
78
45
|
},
|
|
46
|
+
{
|
|
47
|
+
name: "playsInline",
|
|
48
|
+
type: "boolean",
|
|
49
|
+
defaultValue: true
|
|
50
|
+
},
|
|
79
51
|
{
|
|
80
52
|
name: "fit",
|
|
81
53
|
type: "text",
|
|
82
54
|
defaultValue: "cover",
|
|
83
|
-
enum: ["contain", "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
|
|
84
89
|
},
|
|
85
90
|
{
|
|
86
91
|
name: "aspectRatio",
|
|
87
92
|
type: "number",
|
|
88
93
|
advanced: true,
|
|
89
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
|
|
90
102
|
}
|
|
91
103
|
]
|
|
92
|
-
}
|
|
104
|
+
};
|
|
93
105
|
export {
|
|
94
|
-
|
|
106
|
+
componentInfo
|
|
95
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
|
+
};
|
|
File without changes
|
|
@@ -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
|
+
};
|
|
@@ -19,30 +19,33 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import * as React from "react";
|
|
21
21
|
import { useContext } from "react";
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import
|
|
28
|
-
import {
|
|
29
|
-
import { getProcessedBlock } from "
|
|
30
|
-
import BlockStyles from "./block-styles";
|
|
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";
|
|
31
32
|
function RenderBlock(props) {
|
|
32
33
|
var _a, _b, _c, _d;
|
|
33
34
|
function component() {
|
|
34
|
-
var _a2
|
|
35
|
+
var _a2;
|
|
35
36
|
const componentName = (_a2 = useBlock().component) == null ? void 0 : _a2.name;
|
|
36
37
|
if (!componentName) {
|
|
37
38
|
return null;
|
|
38
39
|
}
|
|
39
|
-
const ref =
|
|
40
|
-
if (
|
|
40
|
+
const ref = builderContext.registeredComponents[componentName];
|
|
41
|
+
if (!ref) {
|
|
41
42
|
console.warn(`
|
|
42
43
|
Could not find a registered component named "${componentName}".
|
|
43
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;
|
|
44
48
|
}
|
|
45
|
-
return ref;
|
|
46
49
|
}
|
|
47
50
|
function componentInfo() {
|
|
48
51
|
var _a2;
|
|
@@ -85,21 +88,26 @@ function RenderBlock(props) {
|
|
|
85
88
|
const builderContext = useContext(BuilderContext);
|
|
86
89
|
const ComponentRefRef = componentRef();
|
|
87
90
|
const TagNameRef = tagName();
|
|
88
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, !((_a = componentInfo == null ? void 0 : componentInfo()) == null ? void 0 : _a.noWrap) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadProps(__spreadValues({}, propertiesAndActions()), {
|
|
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()), {
|
|
89
92
|
style: css()
|
|
90
|
-
}), /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
93
|
+
}), TARGET === "vue" || TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
91
94
|
block: useBlock()
|
|
92
|
-
}), componentRef() ? /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, componentOptions()), {
|
|
95
|
+
})) : null, componentRef() ? /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, componentOptions()), {
|
|
93
96
|
builderBlock: useBlock()
|
|
94
|
-
}), (_b = children()) == null ? void 0 : _b.map((child
|
|
97
|
+
}), (_b = children()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
98
|
+
key: child.id,
|
|
95
99
|
block: child
|
|
96
|
-
}))) : null, (_c = noCompRefChildren()) == null ? void 0 : _c.map((child
|
|
100
|
+
}))) : null, (_c = noCompRefChildren()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
101
|
+
key: child.id,
|
|
97
102
|
block: child
|
|
98
|
-
})))) : /* @__PURE__ */ React.createElement(
|
|
103
|
+
})))) : /* @__PURE__ */ React.createElement(TagNameRef, __spreadProps(__spreadValues({}, propertiesAndActions()), {
|
|
104
|
+
style: css()
|
|
105
|
+
}))) : /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, componentOptions()), {
|
|
99
106
|
attributes: propertiesAndActions(),
|
|
100
107
|
builderBlock: useBlock(),
|
|
101
108
|
style: css()
|
|
102
|
-
}), (_d = children()) == null ? void 0 : _d.map((child
|
|
109
|
+
}), (_d = children()) == null ? void 0 : _d.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
110
|
+
key: child.id,
|
|
103
111
|
block: child
|
|
104
112
|
}))));
|
|
105
113
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
import { useContext } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import { getProcessedBlock } from "
|
|
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
12
|
import BlockStyles from "./block-styles.lite";
|
|
13
|
+
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
13
14
|
|
|
14
15
|
export default function RenderBlock(props) {
|
|
15
16
|
function component() {
|
|
@@ -19,16 +20,17 @@ export default function RenderBlock(props) {
|
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
const ref =
|
|
23
|
+
const ref = builderContext.registeredComponents[componentName];
|
|
23
24
|
|
|
24
|
-
if (
|
|
25
|
+
if (!ref) {
|
|
25
26
|
// TODO: Public doc page with more info about this message
|
|
26
27
|
console.warn(`
|
|
27
28
|
Could not find a registered component named "${componentName}".
|
|
28
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;
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
return ref;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
function componentInfo() {
|
|
@@ -91,24 +93,34 @@ export default function RenderBlock(props) {
|
|
|
91
93
|
<>
|
|
92
94
|
{!componentInfo?.()?.noWrap ? (
|
|
93
95
|
<>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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} />
|
|
104
118
|
))}
|
|
105
|
-
</
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
))}
|
|
111
|
-
</TagNameRef>
|
|
119
|
+
</TagNameRef>
|
|
120
|
+
</>
|
|
121
|
+
) : (
|
|
122
|
+
<TagNameRef {...propertiesAndActions()} style={css()} />
|
|
123
|
+
)}
|
|
112
124
|
</>
|
|
113
125
|
) : (
|
|
114
126
|
<ComponentRefRef
|
|
@@ -117,8 +129,8 @@ export default function RenderBlock(props) {
|
|
|
117
129
|
builderBlock={useBlock()}
|
|
118
130
|
style={css()}
|
|
119
131
|
>
|
|
120
|
-
{children()?.map((child
|
|
121
|
-
<RenderBlock block={child} />
|
|
132
|
+
{children()?.map((child) => (
|
|
133
|
+
<RenderBlock key={child.id} block={child} />
|
|
122
134
|
))}
|
|
123
135
|
</ComponentRefRef>
|
|
124
136
|
)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
|
-
import { isEditing } from "../functions/is-editing";
|
|
4
|
-
import RenderBlock from "./render-block";
|
|
3
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
4
|
+
import RenderBlock from "./render-block/render-block.js";
|
|
5
5
|
function RenderBlocks(props) {
|
|
6
6
|
var _a;
|
|
7
7
|
function className() {
|
|
@@ -41,7 +41,7 @@ function RenderBlocks(props) {
|
|
|
41
41
|
onClick: (event) => onClick(),
|
|
42
42
|
onMouseEnter: (event) => onMouseEnter(),
|
|
43
43
|
style: styles.view1
|
|
44
|
-
}, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block
|
|
44
|
+
}, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
45
45
|
key: block.id,
|
|
46
46
|
block
|
|
47
47
|
}))) : null);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
-
import { isEditing } from "../functions/is-editing";
|
|
4
|
-
import RenderBlock from "./render-block.lite";
|
|
3
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
4
|
+
import RenderBlock from "./render-block/render-block.lite";
|
|
5
5
|
|
|
6
6
|
export default function RenderBlocks(props) {
|
|
7
7
|
function className() {
|
|
@@ -51,7 +51,7 @@ export default function RenderBlocks(props) {
|
|
|
51
51
|
>
|
|
52
52
|
{props.blocks ? (
|
|
53
53
|
<>
|
|
54
|
-
{props.blocks?.map((block
|
|
54
|
+
{props.blocks?.map((block) => (
|
|
55
55
|
<RenderBlock key={block.id} block={block} />
|
|
56
56
|
))}
|
|
57
57
|
</>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import RenderInlinedStyles from "../../render-inlined-styles.js";
|
|
3
|
+
function RenderContentStyles(props) {
|
|
4
|
+
function getCssFromFont(font) {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
7
|
+
const name = family.split(",")[0];
|
|
8
|
+
const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
|
|
9
|
+
let str = "";
|
|
10
|
+
if (url && family && name) {
|
|
11
|
+
str += `
|
|
12
|
+
@font-face {
|
|
13
|
+
font-family: "${family}";
|
|
14
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
15
|
+
font-display: fallback;
|
|
16
|
+
font-weight: 400;
|
|
17
|
+
}
|
|
18
|
+
`.trim();
|
|
19
|
+
}
|
|
20
|
+
if (font.files) {
|
|
21
|
+
for (const weight in font.files) {
|
|
22
|
+
const isNumber = String(Number(weight)) === weight;
|
|
23
|
+
if (!isNumber) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const weightUrl = font.files[weight];
|
|
27
|
+
if (weightUrl && weightUrl !== url) {
|
|
28
|
+
str += `
|
|
29
|
+
@font-face {
|
|
30
|
+
font-family: "${family}";
|
|
31
|
+
src: url('${weightUrl}') format('woff2');
|
|
32
|
+
font-display: fallback;
|
|
33
|
+
font-weight: ${weight};
|
|
34
|
+
}
|
|
35
|
+
`.trim();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return str;
|
|
40
|
+
}
|
|
41
|
+
function getFontCss({ customFonts }) {
|
|
42
|
+
var _a;
|
|
43
|
+
return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
|
|
44
|
+
}
|
|
45
|
+
function injectedStyles() {
|
|
46
|
+
return `
|
|
47
|
+
${props.cssCode || ""}
|
|
48
|
+
${getFontCss({
|
|
49
|
+
customFonts: props.customFonts
|
|
50
|
+
})}`;
|
|
51
|
+
}
|
|
52
|
+
return /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
|
|
53
|
+
styles: injectedStyles()
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
RenderContentStyles as default
|
|
58
|
+
};
|