@builder.io/sdk-react-native 0.0.7 → 0.0.9-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/blocks/BaseText.js +31 -0
- package/src/blocks/button/button.js +4 -3
- package/src/blocks/columns/columns.js +5 -2
- package/src/blocks/custom-code/custom-code.js +1 -1
- package/src/blocks/embed/embed.js +2 -0
- package/src/blocks/form/form.js +3 -2
- package/src/blocks/fragment/fragment.js +3 -2
- package/src/blocks/image/image.js +26 -12
- package/src/blocks/section/section.js +3 -2
- package/src/blocks/select/select.js +3 -2
- package/src/blocks/submit-button/submit-button.js +3 -2
- package/src/components/render-block/block-styles.js +18 -11
- package/src/components/render-block/render-block.js +61 -33
- package/src/components/render-block/render-component-with-context.js +46 -0
- package/src/components/render-block/render-repeated-block.js +3 -0
- package/src/components/render-blocks.js +2 -2
- package/src/context/builder.context.js +2 -1
- package/src/functions/extract-text-styles.js +22 -0
- package/src/functions/get-block-actions-handler.js +12 -0
- package/src/functions/get-block-actions.js +2 -7
- package/src/functions/get-block-properties.js +1 -1
- package/src/functions/get-block-styles.js +10 -4
- package/src/functions/get-content/ab-testing.js +2 -1
- package/src/helpers/css.js +17 -1
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
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 { Text } from "react-native";
|
|
22
|
+
import BuilderContext from "../context/builder.context";
|
|
23
|
+
function BaseText(props) {
|
|
24
|
+
const builderContext = React.useContext(BuilderContext);
|
|
25
|
+
return /* @__PURE__ */ React.createElement(Text, __spreadProps(__spreadValues({}, props), {
|
|
26
|
+
style: __spreadValues(__spreadValues({}, builderContext.inheritedStyles), props.style)
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
BaseText as default
|
|
31
|
+
};
|
|
@@ -17,16 +17,17 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import BaseText from "../BaseText";
|
|
20
21
|
import * as React from "react";
|
|
21
|
-
import { View, StyleSheet
|
|
22
|
+
import { View, StyleSheet } from "react-native";
|
|
22
23
|
function Button(props) {
|
|
23
24
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.link ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
24
25
|
role: "button",
|
|
25
26
|
href: props.link,
|
|
26
27
|
target: props.openLinkInNewTab ? "_blank" : void 0
|
|
27
|
-
}), /* @__PURE__ */ React.createElement(
|
|
28
|
+
}), /* @__PURE__ */ React.createElement(BaseText, null, props.text))) : /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
28
29
|
style: styles.view1
|
|
29
|
-
}), /* @__PURE__ */ React.createElement(
|
|
30
|
+
}), /* @__PURE__ */ React.createElement(BaseText, null, props.text)));
|
|
30
31
|
}
|
|
31
32
|
const styles = StyleSheet.create({ view1: { all: "unset" } });
|
|
32
33
|
export {
|
|
@@ -50,12 +50,15 @@ function Columns(props) {
|
|
|
50
50
|
}, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
51
51
|
blocks: markMutable(column.blocks),
|
|
52
52
|
path: `component.options.columns.${index}.blocks`,
|
|
53
|
-
parent: props.builderBlock.id
|
|
53
|
+
parent: props.builderBlock.id,
|
|
54
|
+
style: {
|
|
55
|
+
flexGrow: "1"
|
|
56
|
+
}
|
|
54
57
|
}))));
|
|
55
58
|
}
|
|
56
59
|
const styles = StyleSheet.create({
|
|
57
60
|
view1: { display: "flex", alignItems: "stretch" },
|
|
58
|
-
view2: {
|
|
61
|
+
view2: { display: "flex", flexDirection: "column", alignItems: "stretch" }
|
|
59
62
|
});
|
|
60
63
|
export {
|
|
61
64
|
Columns as default
|
|
@@ -6,7 +6,7 @@ function CustomCode(props) {
|
|
|
6
6
|
const [scriptsInserted, setScriptsInserted] = useState(() => []);
|
|
7
7
|
const [scriptsRun, setScriptsRun] = useState(() => []);
|
|
8
8
|
function findAndRunScripts() {
|
|
9
|
-
if (elem.current && typeof window !== "undefined") {
|
|
9
|
+
if (elem.current && elem.current.getElementsByTagName && typeof window !== "undefined") {
|
|
10
10
|
const scripts = elem.current.getElementsByTagName("script");
|
|
11
11
|
for (let i = 0; i < scripts.length; i++) {
|
|
12
12
|
const script = scripts[i];
|
|
@@ -8,6 +8,8 @@ function Embed(props) {
|
|
|
8
8
|
const [scriptsRun, setScriptsRun] = useState(() => []);
|
|
9
9
|
const [ranInitFn, setRanInitFn] = useState(() => false);
|
|
10
10
|
function findAndRunScripts() {
|
|
11
|
+
if (!elem.current || !elem.current.getElementsByTagName)
|
|
12
|
+
return;
|
|
11
13
|
const scripts = elem.current.getElementsByTagName("script");
|
|
12
14
|
for (let i = 0; i < scripts.length; i++) {
|
|
13
15
|
const script = scripts[i];
|
package/src/blocks/form/form.js
CHANGED
|
@@ -37,8 +37,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
37
37
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
+
import BaseText from "../BaseText";
|
|
40
41
|
import * as React from "react";
|
|
41
|
-
import { View, StyleSheet
|
|
42
|
+
import { View, StyleSheet } from "react-native";
|
|
42
43
|
import { useState, useContext, useRef } from "react";
|
|
43
44
|
import RenderBlock from "../../components/render-block/render-block.js";
|
|
44
45
|
import BuilderBlocks from "../../components/render-blocks.js";
|
|
@@ -211,7 +212,7 @@ function FormComponent(props) {
|
|
|
211
212
|
blocks: props.sendingMessage
|
|
212
213
|
})) : null, " ", submissionState() === "error" && responseData ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
|
|
213
214
|
style: styles.view1
|
|
214
|
-
}, " ", /* @__PURE__ */ React.createElement(
|
|
215
|
+
}, " ", /* @__PURE__ */ React.createElement(BaseText, null, JSON.stringify(responseData, null, 2)), " ")) : null, " ", submissionState() === "success" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
|
|
215
216
|
dataPath: "successMessage",
|
|
216
217
|
blocks: props.successMessage
|
|
217
218
|
})) : null, " ");
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import BaseText from "../BaseText";
|
|
1
2
|
import * as React from "react";
|
|
2
|
-
import { View
|
|
3
|
+
import { View } from "react-native";
|
|
3
4
|
function FragmentComponent(props) {
|
|
4
|
-
return /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(
|
|
5
|
+
return /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(BaseText, null, props.children));
|
|
5
6
|
}
|
|
6
7
|
export {
|
|
7
8
|
FragmentComponent as default
|
|
@@ -17,24 +17,38 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
import * as React from "react";
|
|
18
18
|
import { Image as ReactImage, View } from "react-native";
|
|
19
19
|
function Image(props) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const shouldRenderUnwrappedChildren = props.fitContent && ((_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.length);
|
|
22
|
+
const imageStyle = props.aspectRatio ? {
|
|
23
|
+
position: "absolute",
|
|
24
|
+
top: 0,
|
|
25
|
+
bottom: 0,
|
|
26
|
+
left: 0,
|
|
27
|
+
right: 0
|
|
28
|
+
} : __spreadValues(__spreadValues({
|
|
29
|
+
position: "relative"
|
|
30
|
+
}, props.width ? { width: props.width } : {}), props.height ? { height: props.height } : {});
|
|
31
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ReactImage, {
|
|
23
32
|
resizeMode: props.backgroundSize || "contain",
|
|
24
|
-
style:
|
|
33
|
+
style: imageStyle,
|
|
25
34
|
source: { uri: props.image }
|
|
26
|
-
}), /* @__PURE__ */ React.createElement(View, {
|
|
35
|
+
}), props.aspectRatio && !shouldRenderUnwrappedChildren ? /* @__PURE__ */ React.createElement(View, {
|
|
27
36
|
style: {
|
|
28
37
|
width: "100%",
|
|
29
38
|
paddingTop: props.aspectRatio * 100 + "%"
|
|
30
39
|
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
}) : null), shouldRenderUnwrappedChildren && props.children, !props.fitContent && props.children && /* @__PURE__ */ React.createElement(View, {
|
|
41
|
+
css: {
|
|
42
|
+
display: "flex",
|
|
43
|
+
flexDirection: "column",
|
|
44
|
+
alignItems: "stretch",
|
|
45
|
+
position: "absolute",
|
|
46
|
+
top: "0",
|
|
47
|
+
left: "0",
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: "100%"
|
|
50
|
+
}
|
|
51
|
+
}, props.children));
|
|
38
52
|
}
|
|
39
53
|
export {
|
|
40
54
|
Image as default
|
|
@@ -17,14 +17,15 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import BaseText from "../BaseText";
|
|
20
21
|
import * as React from "react";
|
|
21
|
-
import { View
|
|
22
|
+
import { View } from "react-native";
|
|
22
23
|
function SectionComponent(props) {
|
|
23
24
|
return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
24
25
|
style: props.maxWidth && typeof props.maxWidth === "number" ? {
|
|
25
26
|
maxWidth: props.maxWidth
|
|
26
27
|
} : void 0
|
|
27
|
-
}), /* @__PURE__ */ React.createElement(
|
|
28
|
+
}), /* @__PURE__ */ React.createElement(BaseText, null, props.children));
|
|
28
29
|
}
|
|
29
30
|
export {
|
|
30
31
|
SectionComponent as default
|
|
@@ -17,8 +17,9 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import BaseText from "../BaseText";
|
|
20
21
|
import * as React from "react";
|
|
21
|
-
import { View
|
|
22
|
+
import { View } from "react-native";
|
|
22
23
|
import { isEditing } from "../../functions/is-editing.js";
|
|
23
24
|
function SelectComponent(props) {
|
|
24
25
|
var _a;
|
|
@@ -29,7 +30,7 @@ function SelectComponent(props) {
|
|
|
29
30
|
name: props.name
|
|
30
31
|
}), (_a = props.options) == null ? void 0 : _a.map((option) => /* @__PURE__ */ React.createElement(View, {
|
|
31
32
|
value: option.value
|
|
32
|
-
}, /* @__PURE__ */ React.createElement(
|
|
33
|
+
}, /* @__PURE__ */ React.createElement(BaseText, null, option.name || option.value))));
|
|
33
34
|
}
|
|
34
35
|
export {
|
|
35
36
|
SelectComponent as default
|
|
@@ -17,12 +17,13 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import BaseText from "../BaseText";
|
|
20
21
|
import * as React from "react";
|
|
21
|
-
import { View
|
|
22
|
+
import { View } from "react-native";
|
|
22
23
|
function SubmitButton(props) {
|
|
23
24
|
return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
24
25
|
type: "submit"
|
|
25
|
-
}), /* @__PURE__ */ React.createElement(
|
|
26
|
+
}), /* @__PURE__ */ React.createElement(BaseText, null, props.text));
|
|
26
27
|
}
|
|
27
28
|
export {
|
|
28
29
|
SubmitButton as default
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
|
|
3
3
|
import { TARGET } from "../../constants/target.js";
|
|
4
4
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
5
|
-
import {
|
|
5
|
+
import { createCssClass } from "../../helpers/css.js";
|
|
6
6
|
import RenderInlinedStyles from "../render-inlined-styles.js";
|
|
7
7
|
function BlockStyles(props) {
|
|
8
8
|
function useBlock() {
|
|
@@ -18,17 +18,24 @@ function BlockStyles(props) {
|
|
|
18
18
|
const largeStyles = styles == null ? void 0 : styles.large;
|
|
19
19
|
const mediumStyles = styles == null ? void 0 : styles.medium;
|
|
20
20
|
const smallStyles = styles == null ? void 0 : styles.small;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
const className = useBlock().id;
|
|
22
|
+
const largeStylesClass = largeStyles ? createCssClass({
|
|
23
|
+
className,
|
|
24
|
+
styles: largeStyles
|
|
25
|
+
}) : "";
|
|
26
|
+
const mediumStylesClass = mediumStyles ? createCssClass({
|
|
27
|
+
className,
|
|
28
|
+
styles: mediumStyles,
|
|
29
|
+
mediaQuery: getMaxWidthQueryForSize("medium")
|
|
30
|
+
}) : "";
|
|
31
|
+
const smallStylesClass = smallStyles ? createCssClass({
|
|
32
|
+
className,
|
|
33
|
+
styles: smallStyles,
|
|
34
|
+
mediaQuery: getMaxWidthQueryForSize("small")
|
|
35
|
+
}) : "";
|
|
36
|
+
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
30
37
|
}
|
|
31
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET
|
|
38
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET !== "reactNative" && css() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
|
|
32
39
|
styles: css()
|
|
33
40
|
})) : null);
|
|
34
41
|
}
|
|
@@ -30,6 +30,8 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
import * as React from "react";
|
|
33
|
+
import { View } from "react-native";
|
|
34
|
+
import { useState } from "react";
|
|
33
35
|
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
34
36
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
35
37
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
@@ -39,10 +41,13 @@ import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
|
39
41
|
import { evaluate } from "../../functions/evaluate.js";
|
|
40
42
|
import BlockStyles from "./block-styles.js";
|
|
41
43
|
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
42
|
-
import RenderComponent from "./render-component.js";
|
|
43
44
|
import RenderRepeatedBlock from "./render-repeated-block.js";
|
|
45
|
+
import { TARGET } from "../../constants/target.js";
|
|
46
|
+
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
47
|
+
import RenderComponentWithContext from "./render-component-with-context.js";
|
|
48
|
+
import RenderComponent from "./render-component.js";
|
|
44
49
|
function RenderBlock(props) {
|
|
45
|
-
var _a, _b, _c;
|
|
50
|
+
var _a, _b, _c, _d;
|
|
46
51
|
function component() {
|
|
47
52
|
var _a2;
|
|
48
53
|
const componentName = (_a2 = getProcessedBlock({
|
|
@@ -64,18 +69,6 @@ function RenderBlock(props) {
|
|
|
64
69
|
return ref;
|
|
65
70
|
}
|
|
66
71
|
}
|
|
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
72
|
function tagName() {
|
|
80
73
|
return getBlockTag(useBlock());
|
|
81
74
|
}
|
|
@@ -93,24 +86,25 @@ function RenderBlock(props) {
|
|
|
93
86
|
state: props.context.state,
|
|
94
87
|
context: props.context.context
|
|
95
88
|
})), {
|
|
96
|
-
style: getBlockStyles(
|
|
89
|
+
style: getBlockStyles({
|
|
90
|
+
block: useBlock(),
|
|
91
|
+
context: props.context
|
|
92
|
+
})
|
|
97
93
|
});
|
|
98
94
|
}
|
|
99
95
|
function shouldWrap() {
|
|
100
96
|
var _a2;
|
|
101
|
-
return !((_a2 =
|
|
102
|
-
}
|
|
103
|
-
function componentOptions() {
|
|
104
|
-
return __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
|
|
105
|
-
attributes: attributes()
|
|
106
|
-
});
|
|
97
|
+
return !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.noWrap);
|
|
107
98
|
}
|
|
108
99
|
function renderComponentProps() {
|
|
100
|
+
var _a2;
|
|
109
101
|
return {
|
|
110
102
|
blockChildren: children(),
|
|
111
|
-
componentRef:
|
|
112
|
-
componentOptions:
|
|
113
|
-
|
|
103
|
+
componentRef: (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component,
|
|
104
|
+
componentOptions: __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
|
|
105
|
+
attributes: attributes()
|
|
106
|
+
}),
|
|
107
|
+
context: childrenContext()
|
|
114
108
|
};
|
|
115
109
|
}
|
|
116
110
|
function children() {
|
|
@@ -118,7 +112,8 @@ function RenderBlock(props) {
|
|
|
118
112
|
return (_a2 = useBlock().children) != null ? _a2 : [];
|
|
119
113
|
}
|
|
120
114
|
function childrenWithoutParentComponent() {
|
|
121
|
-
|
|
115
|
+
var _a2;
|
|
116
|
+
const shouldRenderChildrenOutsideRef = !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component) && !repeatItemData();
|
|
122
117
|
return shouldRenderChildrenOutsideRef ? children() : [];
|
|
123
118
|
}
|
|
124
119
|
function repeatItemData() {
|
|
@@ -149,22 +144,55 @@ function RenderBlock(props) {
|
|
|
149
144
|
}));
|
|
150
145
|
return repeatArray;
|
|
151
146
|
}
|
|
147
|
+
function inheritedTextStyles() {
|
|
148
|
+
if (TARGET !== "reactNative") {
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
const styles = getBlockStyles({
|
|
152
|
+
block: useBlock(),
|
|
153
|
+
context: props.context
|
|
154
|
+
});
|
|
155
|
+
return extractTextStyles(styles);
|
|
156
|
+
}
|
|
157
|
+
function childrenContext() {
|
|
158
|
+
return {
|
|
159
|
+
apiKey: props.context.apiKey,
|
|
160
|
+
state: props.context.state,
|
|
161
|
+
content: props.context.content,
|
|
162
|
+
context: props.context.context,
|
|
163
|
+
registeredComponents: props.context.registeredComponents,
|
|
164
|
+
inheritedStyles: inheritedTextStyles()
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function renderComponentTag() {
|
|
168
|
+
if (TARGET === "reactNative") {
|
|
169
|
+
return RenderComponentWithContext;
|
|
170
|
+
} else if (TARGET === "vue3") {
|
|
171
|
+
return "RenderComponent";
|
|
172
|
+
} else {
|
|
173
|
+
return RenderComponent;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const [componentInfo, setComponentInfo] = useState(() => null);
|
|
177
|
+
const RenderComponentTagRef = renderComponentTag();
|
|
152
178
|
const TagNameRef = tagName();
|
|
153
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null,
|
|
179
|
+
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()))) : null, !isEmptyHtmlElement(tagName()) && TARGET === "vue2" && repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
|
|
180
|
+
key: index,
|
|
181
|
+
repeatContext: data.context,
|
|
182
|
+
block: data.block
|
|
183
|
+
})))) : null, !isEmptyHtmlElement(tagName()) && TARGET !== "vue2" && repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = repeatItemData()) == null ? void 0 : _b.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
|
|
154
184
|
key: index,
|
|
155
185
|
repeatContext: data.context,
|
|
156
186
|
block: data.block
|
|
157
|
-
}))) : null, !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
187
|
+
}))) : null, !isEmptyHtmlElement(tagName()) && !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()), /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())), (_c = childrenWithoutParentComponent()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
158
188
|
key: "render-block-" + child.id,
|
|
159
189
|
block: child,
|
|
160
|
-
context:
|
|
161
|
-
})), (
|
|
190
|
+
context: childrenContext()
|
|
191
|
+
})), (_d = childrenWithoutParentComponent()) == null ? void 0 : _d.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
162
192
|
key: "block-style-" + child.id,
|
|
163
193
|
block: child,
|
|
164
|
-
context:
|
|
165
|
-
})))) :
|
|
166
|
-
context: props.context
|
|
167
|
-
})));
|
|
194
|
+
context: childrenContext()
|
|
195
|
+
})))) : null) : /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())));
|
|
168
196
|
}
|
|
169
197
|
export {
|
|
170
198
|
RenderBlock as default
|
|
@@ -0,0 +1,46 @@
|
|
|
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 BuilderContext from "../../context/builder.context.js";
|
|
19
|
+
import RenderComponent from "./render-component.js";
|
|
20
|
+
function RenderComponentWithContext(props) {
|
|
21
|
+
return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
|
|
22
|
+
value: {
|
|
23
|
+
get content() {
|
|
24
|
+
return props.context.content;
|
|
25
|
+
},
|
|
26
|
+
get state() {
|
|
27
|
+
return props.context.state;
|
|
28
|
+
},
|
|
29
|
+
get context() {
|
|
30
|
+
return props.context.context;
|
|
31
|
+
},
|
|
32
|
+
get apiKey() {
|
|
33
|
+
return props.context.apiKey;
|
|
34
|
+
},
|
|
35
|
+
get registeredComponents() {
|
|
36
|
+
return props.context.registeredComponents;
|
|
37
|
+
},
|
|
38
|
+
get inheritedStyles() {
|
|
39
|
+
return props.context.inheritedStyles;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, /* @__PURE__ */ React.createElement(RenderComponent, __spreadValues({}, props)));
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
RenderComponentWithContext as default
|
|
46
|
+
};
|
|
@@ -18,6 +18,9 @@ function RenderRepeatedBlock(props) {
|
|
|
18
18
|
},
|
|
19
19
|
get registeredComponents() {
|
|
20
20
|
return props.repeatContext.registeredComponents;
|
|
21
|
+
},
|
|
22
|
+
get inheritedStyles() {
|
|
23
|
+
return props.repeatContext.inheritedStyles;
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
}, /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
@@ -42,9 +42,9 @@ function RenderBlocks(props) {
|
|
|
42
42
|
dataSet: {
|
|
43
43
|
class: className()
|
|
44
44
|
},
|
|
45
|
+
style: styles.view1,
|
|
45
46
|
onClick: (event) => onClick(),
|
|
46
|
-
onMouseEnter: (event) => onMouseEnter()
|
|
47
|
-
style: styles.view1
|
|
47
|
+
onMouseEnter: (event) => onMouseEnter()
|
|
48
48
|
}, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
49
49
|
key: "render-block-" + block.id,
|
|
50
50
|
block,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const TEXT_STYLE_KEYS = [
|
|
2
|
+
"color",
|
|
3
|
+
"whiteSpace",
|
|
4
|
+
"direction",
|
|
5
|
+
"hyphens",
|
|
6
|
+
"overflowWrap"
|
|
7
|
+
];
|
|
8
|
+
const isTextStyle = (key) => {
|
|
9
|
+
return TEXT_STYLE_KEYS.includes(key) || key.startsWith("font") || key.startsWith("text") || key.startsWith("letter") || key.startsWith("line") || key.startsWith("word") || key.startsWith("writing");
|
|
10
|
+
};
|
|
11
|
+
const extractTextStyles = (styles) => {
|
|
12
|
+
const textStyles = {};
|
|
13
|
+
Object.entries(styles).forEach(([key, value]) => {
|
|
14
|
+
if (isTextStyle(key)) {
|
|
15
|
+
textStyles[key] = value;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return textStyles;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
extractTextStyles
|
|
22
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { evaluate } from "./evaluate.js";
|
|
2
1
|
import { getEventHandlerName } from "./event-handler-name.js";
|
|
2
|
+
import { crateEventHandler } from "./get-block-actions-handler.js";
|
|
3
3
|
function getBlockActions(options) {
|
|
4
4
|
var _a;
|
|
5
5
|
const obj = {};
|
|
@@ -9,12 +9,7 @@ function getBlockActions(options) {
|
|
|
9
9
|
continue;
|
|
10
10
|
}
|
|
11
11
|
const value = optionActions[key];
|
|
12
|
-
obj[getEventHandlerName(key)] = (
|
|
13
|
-
code: value,
|
|
14
|
-
context: options.context,
|
|
15
|
-
state: options.state,
|
|
16
|
-
event
|
|
17
|
-
});
|
|
12
|
+
obj[getEventHandlerName(key)] = crateEventHandler(value, options);
|
|
18
13
|
}
|
|
19
14
|
return obj;
|
|
20
15
|
}
|
|
@@ -17,7 +17,7 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { isEditing } from "./is-editing";
|
|
20
|
+
import { isEditing } from "./is-editing.js";
|
|
21
21
|
import { findDOMNode } from "react-dom";
|
|
22
22
|
function getBlockProperties(block) {
|
|
23
23
|
return __spreadProps(__spreadValues({}, block.properties), {
|
|
@@ -18,10 +18,13 @@ import { getMaxWidthQueryForSize } from "../constants/device-sizes.js";
|
|
|
18
18
|
import { TARGET } from "../constants/target.js";
|
|
19
19
|
import { convertStyleObject } from "./convert-style-object.js";
|
|
20
20
|
import { sanitizeBlockStyles } from "./sanitize-styles.js";
|
|
21
|
-
const getStyleForTarget = (
|
|
21
|
+
const getStyleForTarget = ({
|
|
22
|
+
styles,
|
|
23
|
+
context
|
|
24
|
+
}) => {
|
|
22
25
|
switch (TARGET) {
|
|
23
26
|
case "reactNative": {
|
|
24
|
-
return __spreadValues(__spreadValues(__spreadValues({}, styles.large ? convertStyleObject(styles.large) : {}), styles.medium ? convertStyleObject(styles.medium) : {}), styles.small ? convertStyleObject(styles.small) : {});
|
|
27
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, context.inheritedStyles), styles.large ? convertStyleObject(styles.large) : {}), styles.medium ? convertStyleObject(styles.medium) : {}), styles.small ? convertStyleObject(styles.small) : {});
|
|
25
28
|
}
|
|
26
29
|
default:
|
|
27
30
|
return __spreadValues(__spreadValues(__spreadValues({}, styles.large ? convertStyleObject(styles.large) : {}), styles.medium ? {
|
|
@@ -31,11 +34,14 @@ const getStyleForTarget = (styles) => {
|
|
|
31
34
|
} : {});
|
|
32
35
|
}
|
|
33
36
|
};
|
|
34
|
-
function getBlockStyles(
|
|
37
|
+
function getBlockStyles({
|
|
38
|
+
block,
|
|
39
|
+
context
|
|
40
|
+
}) {
|
|
35
41
|
if (!block.responsiveStyles) {
|
|
36
42
|
return {};
|
|
37
43
|
}
|
|
38
|
-
const styles = getStyleForTarget(block.responsiveStyles);
|
|
44
|
+
const styles = getStyleForTarget({ styles: block.responsiveStyles, context });
|
|
39
45
|
const newStyles = sanitizeBlockStyles(styles);
|
|
40
46
|
return newStyles;
|
|
41
47
|
}
|
|
@@ -22,7 +22,8 @@ import {
|
|
|
22
22
|
getContentVariationCookie,
|
|
23
23
|
setContentVariationCookie
|
|
24
24
|
} from "../../helpers/ab-tests.js";
|
|
25
|
-
|
|
25
|
+
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
26
|
+
const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
26
27
|
const getRandomVariationId = ({
|
|
27
28
|
id,
|
|
28
29
|
variations
|
package/src/helpers/css.js
CHANGED
|
@@ -7,6 +7,22 @@ const convertStyleMaptoCSS = (style) => {
|
|
|
7
7
|
});
|
|
8
8
|
return cssProps.join("\n");
|
|
9
9
|
};
|
|
10
|
+
const createCssClass = ({
|
|
11
|
+
mediaQuery,
|
|
12
|
+
className,
|
|
13
|
+
styles
|
|
14
|
+
}) => {
|
|
15
|
+
const cssClass = `.${className} {
|
|
16
|
+
${convertStyleMaptoCSS(styles)}
|
|
17
|
+
}`;
|
|
18
|
+
if (mediaQuery) {
|
|
19
|
+
return `${mediaQuery} {
|
|
20
|
+
${cssClass}
|
|
21
|
+
}`;
|
|
22
|
+
} else {
|
|
23
|
+
return cssClass;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
10
26
|
export {
|
|
11
|
-
|
|
27
|
+
createCssClass
|
|
12
28
|
};
|