@builder.io/sdk-react-native 0.0.1-66 → 0.0.1-69
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/button/button.js +5 -2
- package/src/blocks/button/component-info.js +0 -1
- package/src/blocks/columns/columns.js +3 -1
- package/src/blocks/columns/component-info.js +3 -3
- package/src/blocks/custom-code/component-info.js +0 -1
- package/src/blocks/embed/component-info.js +3 -3
- package/src/blocks/embed/embed.js +1 -1
- package/src/blocks/embed/helpers.js +0 -1
- package/src/blocks/form/component-info.js +0 -1
- package/src/blocks/form/form.js +5 -2
- package/src/blocks/fragment/component-info.js +0 -1
- package/src/blocks/image/component-info.js +3 -3
- package/src/blocks/image/image.helpers.js +0 -1
- package/src/blocks/image/image.js +0 -1
- package/src/blocks/img/component-info.js +0 -1
- package/src/blocks/img/img.js +1 -1
- package/src/blocks/input/component-info.js +0 -1
- package/src/blocks/raw-text/component-info.js +0 -1
- package/src/blocks/section/component-info.js +0 -1
- package/src/blocks/select/component-info.js +0 -1
- package/src/blocks/submit-button/component-info.js +0 -1
- package/src/blocks/symbol/component-info.js +0 -1
- package/src/blocks/text/component-info.js +0 -1
- package/src/blocks/text/text.js +0 -1
- package/src/blocks/textarea/component-info.js +0 -1
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/component-info.js +0 -1
- package/src/blocks/video/video.js +0 -1
- package/src/components/render-block/block-styles.js +5 -8
- package/src/components/render-block/render-block.helpers.js +0 -1
- package/src/components/render-block/render-block.js +22 -20
- package/src/components/render-block/render-component.js +4 -2
- package/src/components/render-block/render-repeated-block.js +2 -1
- package/src/components/render-block/types.js +0 -1
- package/src/components/render-blocks.js +7 -2
- package/src/components/render-content/index.js +0 -1
- package/src/components/render-content/render-content.js +28 -8
- package/src/constants/builder-registered-components.js +0 -1
- package/src/constants/device-sizes.js +0 -1
- package/src/constants/target.js +0 -1
- package/src/functions/camel-to-kebab-case.js +0 -1
- package/src/functions/convert-style-object.js +0 -1
- package/src/functions/evaluate.js +0 -1
- package/src/functions/event-handler-name.js +0 -1
- package/src/functions/get-block-actions.js +0 -1
- package/src/functions/get-block-component-options.js +0 -1
- package/src/functions/get-block-properties.js +0 -1
- package/src/functions/get-block-styles.js +0 -1
- package/src/functions/get-block-tag.js +0 -1
- package/src/functions/get-builder-search-params/fn.test.js +0 -1
- package/src/functions/get-builder-search-params/index.js +0 -1
- package/src/functions/get-content/ab-testing.js +0 -1
- package/src/functions/get-content/fn.test.js +0 -1
- package/src/functions/get-content/index.js +0 -1
- package/src/functions/get-content/types.js +0 -1
- package/src/functions/get-fetch.js +2 -3
- package/src/functions/get-global-this.js +0 -1
- package/src/functions/get-processed-block.js +10 -7
- package/src/functions/get-processed-block.test.js +1 -2
- package/src/functions/if-target.js +0 -1
- package/src/functions/is-browser.js +0 -1
- package/src/functions/is-editing.js +0 -1
- package/src/functions/is-iframe.js +0 -1
- package/src/functions/is-previewing.js +0 -1
- package/src/functions/is-react-native.js +0 -1
- package/src/functions/on-change.js +0 -1
- package/src/functions/on-change.test.js +0 -1
- package/src/functions/register-component.js +0 -1
- package/src/functions/register.js +0 -1
- package/src/functions/sanitize-styles.js +0 -1
- package/src/functions/set-editor-settings.js +0 -1
- package/src/functions/set.js +0 -1
- package/src/functions/set.test.js +0 -1
- package/src/functions/track.js +71 -3
- package/src/functions/transform-block.js +0 -1
- package/src/helpers/cookie.js +59 -0
- package/src/helpers/css.js +0 -1
- package/src/helpers/flatten.js +0 -1
- 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 +0 -1
- package/src/index-helpers/top-of-file.js +0 -1
- package/src/index.js +0 -1
- package/src/scripts/init-editing.js +4 -6
- 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 -1
- package/src/types/deep-partial.js +0 -1
- package/src/types/element.js +0 -1
- package/src/types/targets.js +0 -1
- package/src/types/typescript.js +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react-native",
|
|
3
3
|
"description": "Builder.io SDK for React Native",
|
|
4
|
-
"version": "0.0.1-
|
|
4
|
+
"version": "0.0.1-69",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
@@ -18,14 +18,17 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import * as React from "react";
|
|
21
|
-
import { View, Text } from "react-native";
|
|
21
|
+
import { View, StyleSheet, Text } from "react-native";
|
|
22
22
|
function Button(props) {
|
|
23
23
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.link ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
24
24
|
role: "button",
|
|
25
25
|
href: props.link,
|
|
26
26
|
target: props.openLinkInNewTab ? "_blank" : void 0
|
|
27
|
-
}), /* @__PURE__ */ React.createElement(Text, null, props.text))) : /* @__PURE__ */ React.createElement(View, __spreadValues({}, props.attributes),
|
|
27
|
+
}), /* @__PURE__ */ React.createElement(Text, null, props.text))) : /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
28
|
+
style: styles.view1
|
|
29
|
+
}), /* @__PURE__ */ React.createElement(Text, null, props.text)));
|
|
28
30
|
}
|
|
31
|
+
const styles = StyleSheet.create({ view1: { all: "unset" } });
|
|
29
32
|
export {
|
|
30
33
|
Button as default
|
|
31
34
|
};
|
|
@@ -47,7 +47,9 @@ function Columns(props) {
|
|
|
47
47
|
style: styles.view2,
|
|
48
48
|
key: index
|
|
49
49
|
}, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
50
|
-
blocks: column.blocks
|
|
50
|
+
blocks: column.blocks,
|
|
51
|
+
path: `component.options.columns.${index}.blocks`,
|
|
52
|
+
parent: props.builderBlock.id
|
|
51
53
|
}))));
|
|
52
54
|
}
|
|
53
55
|
const styles = StyleSheet.create({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { markSerializable } from "../util";
|
|
2
2
|
const componentInfo = {
|
|
3
3
|
name: "Columns",
|
|
4
4
|
builtIn: true,
|
|
@@ -187,7 +187,7 @@ const componentInfo = {
|
|
|
187
187
|
]
|
|
188
188
|
}
|
|
189
189
|
],
|
|
190
|
-
onChange(options) {
|
|
190
|
+
onChange: markSerializable((options) => {
|
|
191
191
|
function clearWidths() {
|
|
192
192
|
columns.forEach((col) => {
|
|
193
193
|
col.delete("width");
|
|
@@ -211,7 +211,7 @@ const componentInfo = {
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
}
|
|
214
|
+
})
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
217
|
name: "space",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { markSerializable } from "../util";
|
|
2
2
|
const componentInfo = {
|
|
3
3
|
name: "Embed",
|
|
4
4
|
static: true,
|
|
@@ -10,7 +10,7 @@ const componentInfo = {
|
|
|
10
10
|
required: true,
|
|
11
11
|
defaultValue: "",
|
|
12
12
|
helperText: "e.g. enter a youtube url, google map, etc",
|
|
13
|
-
onChange(options) {
|
|
13
|
+
onChange: markSerializable((options) => {
|
|
14
14
|
const url = options.get("url");
|
|
15
15
|
if (url) {
|
|
16
16
|
options.set("content", "Loading...");
|
|
@@ -29,7 +29,7 @@ const componentInfo = {
|
|
|
29
29
|
} else {
|
|
30
30
|
options.delete("content");
|
|
31
31
|
}
|
|
32
|
-
}
|
|
32
|
+
})
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
name: "content",
|
package/src/blocks/form/form.js
CHANGED
|
@@ -39,8 +39,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
39
39
|
};
|
|
40
40
|
import * as React from "react";
|
|
41
41
|
import { View, StyleSheet, Text } from "react-native";
|
|
42
|
-
import { useState, useRef } from "react";
|
|
42
|
+
import { useState, useContext, useRef } from "react";
|
|
43
43
|
import RenderBlock from "../../components/render-block/render-block.js";
|
|
44
|
+
import BuilderBlocks from "../../components/render-blocks.js";
|
|
44
45
|
import { isEditing } from "../../functions/is-editing.js";
|
|
45
46
|
function FormComponent(props) {
|
|
46
47
|
var _a, _b;
|
|
@@ -191,6 +192,7 @@ function FormComponent(props) {
|
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
194
|
}
|
|
195
|
+
const builderContext = useContext(BuilderContext);
|
|
194
196
|
return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
195
197
|
validate: props.validate,
|
|
196
198
|
ref: formRef,
|
|
@@ -199,7 +201,8 @@ function FormComponent(props) {
|
|
|
199
201
|
name: props.name,
|
|
200
202
|
onSubmit: (event) => onSubmit(event)
|
|
201
203
|
}), " ", props.builderBlock && props.builderBlock.children ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
202
|
-
block
|
|
204
|
+
block,
|
|
205
|
+
context: builderContext
|
|
203
206
|
}))) : null, " ", submissionState() === "error" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
|
|
204
207
|
dataPath: "errorMessage",
|
|
205
208
|
blocks: props.errorMessage
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { markSerializable } from "../util";
|
|
2
2
|
const componentInfo = {
|
|
3
3
|
name: "Image",
|
|
4
4
|
static: true,
|
|
@@ -19,7 +19,7 @@ const componentInfo = {
|
|
|
19
19
|
allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
|
|
20
20
|
required: true,
|
|
21
21
|
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
22
|
-
onChange(options) {
|
|
22
|
+
onChange: markSerializable((options) => {
|
|
23
23
|
const DEFAULT_ASPECT_RATIO = 0.7041;
|
|
24
24
|
options.delete("srcset");
|
|
25
25
|
options.delete("noWebp");
|
|
@@ -65,7 +65,7 @@ const componentInfo = {
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
}
|
|
68
|
+
})
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
name: "backgroundSize",
|
package/src/blocks/img/img.js
CHANGED
package/src/blocks/text/text.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { getMaxWidthQueryForSize } from "../../constants/device-sizes.js";
|
|
3
3
|
import { TARGET } from "../../constants/target.js";
|
|
4
|
-
import BuilderContext from "../../context/builder.context";
|
|
5
4
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
6
|
-
import RenderInlinedStyles from "../render-inlined-styles.js";
|
|
7
5
|
import { convertStyleMaptoCSS } from "../../helpers/css.js";
|
|
8
|
-
import
|
|
6
|
+
import RenderInlinedStyles from "../render-inlined-styles.js";
|
|
9
7
|
function BlockStyles(props) {
|
|
10
8
|
function useBlock() {
|
|
11
9
|
return getProcessedBlock({
|
|
12
10
|
block: props.block,
|
|
13
|
-
state:
|
|
14
|
-
context:
|
|
15
|
-
|
|
11
|
+
state: props.context.state,
|
|
12
|
+
context: props.context.context,
|
|
13
|
+
shouldEvaluateBindings: true
|
|
16
14
|
});
|
|
17
15
|
}
|
|
18
16
|
function css() {
|
|
@@ -30,7 +28,6 @@ function BlockStyles(props) {
|
|
|
30
28
|
}` : ""}
|
|
31
29
|
}`;
|
|
32
30
|
}
|
|
33
|
-
const builderContext = useContext(BuilderContext);
|
|
34
31
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
|
|
35
32
|
styles: css()
|
|
36
33
|
})) : null);
|
|
@@ -30,8 +30,6 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
import * as React from "react";
|
|
33
|
-
import { useContext } from "react";
|
|
34
|
-
import BuilderContext from "../../context/builder.context";
|
|
35
33
|
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
36
34
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
37
35
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
@@ -49,14 +47,14 @@ function RenderBlock(props) {
|
|
|
49
47
|
var _a2;
|
|
50
48
|
const componentName = (_a2 = getProcessedBlock({
|
|
51
49
|
block: props.block,
|
|
52
|
-
state:
|
|
53
|
-
context:
|
|
54
|
-
|
|
50
|
+
state: props.context.state,
|
|
51
|
+
context: props.context.context,
|
|
52
|
+
shouldEvaluateBindings: false
|
|
55
53
|
}).component) == null ? void 0 : _a2.name;
|
|
56
54
|
if (!componentName) {
|
|
57
55
|
return null;
|
|
58
56
|
}
|
|
59
|
-
const ref =
|
|
57
|
+
const ref = props.context.registeredComponents[componentName];
|
|
60
58
|
if (!ref) {
|
|
61
59
|
console.warn(`
|
|
62
60
|
Could not find a registered component named "${componentName}".
|
|
@@ -84,16 +82,16 @@ function RenderBlock(props) {
|
|
|
84
82
|
function useBlock() {
|
|
85
83
|
return repeatItemData() ? props.block : getProcessedBlock({
|
|
86
84
|
block: props.block,
|
|
87
|
-
state:
|
|
88
|
-
context:
|
|
89
|
-
|
|
85
|
+
state: props.context.state,
|
|
86
|
+
context: props.context.context,
|
|
87
|
+
shouldEvaluateBindings: true
|
|
90
88
|
});
|
|
91
89
|
}
|
|
92
90
|
function attributes() {
|
|
93
91
|
return __spreadProps(__spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
|
|
94
92
|
block: useBlock(),
|
|
95
|
-
state:
|
|
96
|
-
context:
|
|
93
|
+
state: props.context.state,
|
|
94
|
+
context: props.context.context
|
|
97
95
|
})), {
|
|
98
96
|
style: getBlockStyles(useBlock())
|
|
99
97
|
});
|
|
@@ -111,7 +109,8 @@ function RenderBlock(props) {
|
|
|
111
109
|
return {
|
|
112
110
|
blockChildren: children(),
|
|
113
111
|
componentRef: componentRef(),
|
|
114
|
-
componentOptions: componentOptions()
|
|
112
|
+
componentOptions: componentOptions(),
|
|
113
|
+
context: props.context
|
|
115
114
|
};
|
|
116
115
|
}
|
|
117
116
|
function children() {
|
|
@@ -129,8 +128,8 @@ function RenderBlock(props) {
|
|
|
129
128
|
}
|
|
130
129
|
const itemsArray = evaluate({
|
|
131
130
|
code: repeat.collection,
|
|
132
|
-
state:
|
|
133
|
-
context:
|
|
131
|
+
state: props.context.state,
|
|
132
|
+
context: props.context.context
|
|
134
133
|
});
|
|
135
134
|
if (!Array.isArray(itemsArray)) {
|
|
136
135
|
return void 0;
|
|
@@ -138,8 +137,8 @@ function RenderBlock(props) {
|
|
|
138
137
|
const collectionName = repeat.collection.split(".").pop();
|
|
139
138
|
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
140
139
|
const repeatArray = itemsArray.map((item, index) => ({
|
|
141
|
-
context: __spreadProps(__spreadValues({},
|
|
142
|
-
state: __spreadProps(__spreadValues({},
|
|
140
|
+
context: __spreadProps(__spreadValues({}, props.context), {
|
|
141
|
+
state: __spreadProps(__spreadValues({}, props.context.state), {
|
|
143
142
|
$index: index,
|
|
144
143
|
$item: item,
|
|
145
144
|
[itemNameToUse]: item,
|
|
@@ -150,7 +149,6 @@ function RenderBlock(props) {
|
|
|
150
149
|
}));
|
|
151
150
|
return repeatArray;
|
|
152
151
|
}
|
|
153
|
-
const builderContext = useContext(BuilderContext);
|
|
154
152
|
const TagNameRef = tagName();
|
|
155
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, {
|
|
156
154
|
key: index,
|
|
@@ -158,11 +156,15 @@ function RenderBlock(props) {
|
|
|
158
156
|
block: data.block
|
|
159
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, {
|
|
160
158
|
key: "render-block-" + child.id,
|
|
161
|
-
block: child
|
|
159
|
+
block: child,
|
|
160
|
+
context: props.context
|
|
162
161
|
})), (_c = childrenWithoutParentComponent()) == null ? void 0 : _c.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
163
162
|
key: "block-style-" + child.id,
|
|
164
|
-
block: child
|
|
165
|
-
|
|
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
|
+
})));
|
|
166
168
|
}
|
|
167
169
|
export {
|
|
168
170
|
RenderBlock as default
|
|
@@ -22,10 +22,12 @@ function RenderComponent(props) {
|
|
|
22
22
|
const ComponentRefRef = props.componentRef;
|
|
23
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
24
|
key: "render-block-" + child.id,
|
|
25
|
-
block: child
|
|
25
|
+
block: child,
|
|
26
|
+
context: props.context
|
|
26
27
|
})), (_b = props.blockChildren) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
27
28
|
key: "block-style-" + child.id,
|
|
28
|
-
block: child
|
|
29
|
+
block: child,
|
|
30
|
+
context: props.context
|
|
29
31
|
})))) : null);
|
|
30
32
|
}
|
|
31
33
|
export {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import BuilderContext from "../context/builder.context";
|
|
3
5
|
import { isEditing } from "../functions/is-editing.js";
|
|
4
6
|
import BlockStyles from "./render-block/block-styles.js";
|
|
5
7
|
import RenderBlock from "./render-block/render-block.js";
|
|
@@ -33,6 +35,7 @@ function RenderBlocks(props) {
|
|
|
33
35
|
}, "*");
|
|
34
36
|
}
|
|
35
37
|
}
|
|
38
|
+
const builderContext = useContext(BuilderContext);
|
|
36
39
|
return /* @__PURE__ */ React.createElement(View, {
|
|
37
40
|
"builder-path": props.path,
|
|
38
41
|
"builder-parent-id": props.parent,
|
|
@@ -44,10 +47,12 @@ function RenderBlocks(props) {
|
|
|
44
47
|
style: styles.view1
|
|
45
48
|
}, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
46
49
|
key: "render-block-" + block.id,
|
|
47
|
-
block
|
|
50
|
+
block,
|
|
51
|
+
context: builderContext
|
|
48
52
|
}))) : null, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
49
53
|
key: "block-style-" + block.id,
|
|
50
|
-
block
|
|
54
|
+
block,
|
|
55
|
+
context: builderContext
|
|
51
56
|
}))) : null);
|
|
52
57
|
}
|
|
53
58
|
const styles = StyleSheet.create({
|
|
@@ -39,7 +39,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
39
39
|
};
|
|
40
40
|
import * as React from "react";
|
|
41
41
|
import { View } from "react-native";
|
|
42
|
-
import { useState, useEffect } from "react";
|
|
42
|
+
import { useState, useRef, useEffect } from "react";
|
|
43
43
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
44
44
|
import { TARGET } from "../../constants/target.js";
|
|
45
45
|
import BuilderContext from "../../context/builder.context";
|
|
@@ -56,8 +56,14 @@ import {
|
|
|
56
56
|
import { track } from "../../functions/track.js";
|
|
57
57
|
import RenderBlocks from "../render-blocks.js";
|
|
58
58
|
import RenderContentStyles from "./components/render-styles.js";
|
|
59
|
+
import {
|
|
60
|
+
registerInsertMenu,
|
|
61
|
+
setupBrowserForEditing
|
|
62
|
+
} from "../../scripts/init-editing.js";
|
|
59
63
|
function RenderContent(props) {
|
|
60
64
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
65
|
+
const elementRef = useRef(null);
|
|
66
|
+
const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
|
|
61
67
|
function useContent() {
|
|
62
68
|
var _a2;
|
|
63
69
|
const mergedContent = __spreadProps(__spreadValues(__spreadValues({}, props.content), overrideContent), {
|
|
@@ -67,6 +73,9 @@ function RenderContent(props) {
|
|
|
67
73
|
}
|
|
68
74
|
const [overrideContent, setOverrideContent] = useState(() => null);
|
|
69
75
|
const [update, setUpdate] = useState(() => 0);
|
|
76
|
+
function canTrackToUse() {
|
|
77
|
+
return props.canTrack || true;
|
|
78
|
+
}
|
|
70
79
|
const [overrideState, setOverrideState] = useState(() => ({}));
|
|
71
80
|
function contentState() {
|
|
72
81
|
var _a2, _b2;
|
|
@@ -118,9 +127,12 @@ function RenderContent(props) {
|
|
|
118
127
|
return {};
|
|
119
128
|
}
|
|
120
129
|
function onClick(_event) {
|
|
121
|
-
if (useContent()
|
|
122
|
-
track(
|
|
123
|
-
|
|
130
|
+
if (useContent()) {
|
|
131
|
+
track({
|
|
132
|
+
type: "click",
|
|
133
|
+
canTrack: canTrackToUse(),
|
|
134
|
+
contentId: useContent().id,
|
|
135
|
+
orgId: props.apiKey
|
|
124
136
|
});
|
|
125
137
|
}
|
|
126
138
|
}
|
|
@@ -173,6 +185,9 @@ function RenderContent(props) {
|
|
|
173
185
|
useEffect(() => {
|
|
174
186
|
if (isBrowser()) {
|
|
175
187
|
if (isEditing()) {
|
|
188
|
+
setForceReRenderCount(forceReRenderCount + 1);
|
|
189
|
+
registerInsertMenu();
|
|
190
|
+
setupBrowserForEditing();
|
|
176
191
|
Object.values(allRegisteredComponents()).forEach((registeredComponent) => {
|
|
177
192
|
var _a2;
|
|
178
193
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
@@ -181,9 +196,12 @@ function RenderContent(props) {
|
|
|
181
196
|
window.addEventListener("message", processMessage);
|
|
182
197
|
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
183
198
|
}
|
|
184
|
-
if (useContent()
|
|
185
|
-
track(
|
|
186
|
-
|
|
199
|
+
if (useContent()) {
|
|
200
|
+
track({
|
|
201
|
+
type: "impression",
|
|
202
|
+
canTrack: canTrackToUse(),
|
|
203
|
+
contentId: useContent().id,
|
|
204
|
+
orgId: props.apiKey
|
|
187
205
|
});
|
|
188
206
|
}
|
|
189
207
|
if (isPreviewing()) {
|
|
@@ -243,13 +261,15 @@ function RenderContent(props) {
|
|
|
243
261
|
}
|
|
244
262
|
}
|
|
245
263
|
}, useContent() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
|
|
264
|
+
ref: elementRef,
|
|
246
265
|
onClick: (event) => onClick(event),
|
|
247
266
|
"builder-content-id": (_e = useContent == null ? void 0 : useContent()) == null ? void 0 : _e.id
|
|
248
267
|
}, shouldRenderContentStyles() ? /* @__PURE__ */ React.createElement(RenderContentStyles, {
|
|
249
268
|
cssCode: (_g = (_f = useContent == null ? void 0 : useContent()) == null ? void 0 : _f.data) == null ? void 0 : _g.cssCode,
|
|
250
269
|
customFonts: (_i = (_h = useContent == null ? void 0 : useContent()) == null ? void 0 : _h.data) == null ? void 0 : _i.customFonts
|
|
251
270
|
}) : null, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
252
|
-
blocks: (_k = (_j = useContent == null ? void 0 : useContent()) == null ? void 0 : _j.data) == null ? void 0 : _k.blocks
|
|
271
|
+
blocks: (_k = (_j = useContent == null ? void 0 : useContent()) == null ? void 0 : _j.data) == null ? void 0 : _k.blocks,
|
|
272
|
+
key: forceReRenderCount
|
|
253
273
|
}))) : null);
|
|
254
274
|
}
|
|
255
275
|
export {
|
package/src/constants/target.js
CHANGED