@builder.io/sdk-react-native 0.0.1-9 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +19 -0
- package/package.json +7 -4
- package/src/blocks/button/button.js +34 -0
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/columns/columns.js +62 -0
- package/src/blocks/columns/component-info.js +242 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.js} +16 -33
- package/src/blocks/embed/component-info.js +44 -0
- package/src/blocks/embed/embed.js +43 -0
- package/src/blocks/embed/helpers.js +9 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/form/form.js +224 -0
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/fragment/fragment.js +8 -0
- package/src/blocks/image/component-info.js +151 -0
- package/src/blocks/image/image.helpers.js +48 -0
- package/src/blocks/image/image.js +77 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/img/img.js +36 -0
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/input.js +36 -0
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/raw-text.js +10 -0
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/section.js +31 -0
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/select.js +36 -0
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/submit-button.js +29 -0
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.js +65 -0
- package/src/blocks/{text.js → text/component-info.js} +4 -11
- package/src/blocks/text/text.js +10 -0
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/textarea.js +32 -0
- package/src/blocks/util.js +7 -0
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/video.js +52 -0
- package/src/components/render-block/block-styles.js +37 -0
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.js +171 -0
- package/src/components/render-block/render-component.js +36 -0
- package/src/components/render-block/render-repeated-block.js +30 -0
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-blocks.js +29 -13
- package/src/components/render-content/components/render-styles.js +58 -0
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.js +262 -0
- package/src/components/render-inlined-styles.js +18 -0
- package/src/constants/builder-registered-components.js +42 -0
- package/src/constants/device-sizes.js +3 -22
- package/src/constants/target.js +4 -0
- package/src/context/builder.context.js +7 -1
- package/src/context/types.js +0 -0
- package/src/functions/camel-to-kebab-case.js +4 -0
- package/src/functions/convert-style-object.js +6 -0
- package/src/functions/evaluate.js +17 -9
- package/src/functions/event-handler-name.js +7 -0
- package/src/functions/get-block-actions.js +14 -14
- package/src/functions/get-block-component-options.js +22 -2
- package/src/functions/get-block-properties.js +2 -4
- package/src/functions/get-block-styles.js +9 -28
- package/src/functions/get-block-tag.js +1 -2
- package/src/functions/get-builder-search-params/fn.test.js +13 -0
- package/src/functions/get-builder-search-params/index.js +37 -0
- package/src/functions/get-content/ab-testing.js +38 -0
- package/src/functions/get-content/fn.test.js +31 -0
- package/src/functions/get-content/index.js +95 -0
- package/src/functions/get-content/types.js +0 -0
- package/src/functions/get-fetch.js +34 -0
- package/src/functions/get-global-this.js +18 -0
- package/src/functions/get-processed-block.js +22 -10
- package/src/functions/get-processed-block.test.js +14 -9
- package/src/functions/if-target.js +11 -3
- package/src/functions/is-browser.js +1 -3
- package/src/functions/is-editing.js +1 -2
- package/src/functions/is-iframe.js +1 -2
- package/src/functions/is-previewing.js +14 -0
- package/src/functions/mark-mutable.js +10 -0
- package/src/functions/on-change.js +0 -1
- package/src/functions/on-change.test.js +1 -3
- package/src/functions/register-component.js +46 -27
- package/src/functions/register.js +29 -0
- package/src/functions/sanitize-styles.js +32 -0
- package/src/functions/set-editor-settings.js +15 -0
- package/src/functions/set.js +0 -1
- package/src/functions/set.test.js +1 -3
- package/src/functions/track.js +109 -13
- package/src/functions/transform-block.js +37 -0
- package/src/helpers/cookie.js +59 -0
- package/src/helpers/css.js +12 -0
- package/src/helpers/flatten.js +34 -0
- package/src/helpers/localStorage.js +34 -0
- package/src/helpers/nullable.js +4 -0
- package/src/helpers/sessionId.js +26 -0
- package/src/helpers/time.js +5 -0
- package/src/helpers/url.js +10 -0
- package/src/helpers/url.test.js +15 -0
- package/src/helpers/uuid.js +13 -0
- package/src/helpers/visitorId.js +33 -0
- package/src/index-helpers/blocks-exports.js +18 -0
- package/src/index-helpers/top-of-file.js +1 -0
- package/src/index.js +10 -26
- package/src/scripts/init-editing.js +73 -51
- package/src/types/builder-block.js +0 -1
- package/src/types/builder-content.js +0 -1
- package/src/types/can-track.js +0 -0
- package/src/types/components.js +0 -0
- package/src/types/deep-partial.js +0 -0
- package/src/types/element.js +0 -0
- package/src/types/targets.js +0 -0
- package/src/types/typescript.js +0 -0
- package/src/blocks/button.js +0 -37
- package/src/blocks/button.lite.tsx +0 -29
- package/src/blocks/columns.js +0 -42
- package/src/blocks/columns.lite.tsx +0 -41
- package/src/blocks/custom-code.js +0 -56
- package/src/blocks/embed.js +0 -56
- package/src/blocks/embed.lite.tsx +0 -65
- package/src/blocks/form.js +0 -229
- package/src/blocks/form.lite.tsx +0 -257
- package/src/blocks/fragment.js +0 -16
- package/src/blocks/fragment.lite.tsx +0 -8
- package/src/blocks/image.js +0 -123
- package/src/blocks/image.lite.tsx +0 -35
- package/src/blocks/img.js +0 -41
- package/src/blocks/img.lite.tsx +0 -19
- package/src/blocks/input.js +0 -41
- package/src/blocks/input.lite.tsx +0 -23
- package/src/blocks/raw-text.js +0 -17
- package/src/blocks/raw-text.lite.tsx +0 -12
- package/src/blocks/section.js +0 -36
- package/src/blocks/section.lite.tsx +0 -20
- package/src/blocks/select.js +0 -40
- package/src/blocks/select.lite.tsx +0 -24
- package/src/blocks/submit-button.js +0 -34
- package/src/blocks/submit-button.lite.tsx +0 -11
- package/src/blocks/symbol.js +0 -20
- package/src/blocks/symbol.lite.tsx +0 -20
- package/src/blocks/text.lite.tsx +0 -12
- package/src/blocks/textarea.js +0 -37
- package/src/blocks/textarea.lite.tsx +0 -15
- package/src/blocks/video.js +0 -49
- package/src/blocks/video.lite.tsx +0 -28
- package/src/components/render-block.js +0 -84
- package/src/components/render-block.lite.tsx +0 -92
- package/src/components/render-blocks.lite.tsx +0 -56
- package/src/components/render-content.js +0 -66
- package/src/components/render-content.lite.tsx +0 -95
- package/src/functions/get-content.js +0 -103
- package/src/functions/get-target.js +0 -7
- package/src/functions/is-react-native.js +0 -7
- package/src/functions/macro-eval.js +0 -6
- package/src/package.json +0 -18
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
-
import { useState, useContext, useEffect } from "react";
|
|
4
|
-
import { isBrowser } from "../functions/is-browser";
|
|
5
|
-
import RenderBlock from "./render-block.lite";
|
|
6
|
-
import BuilderContext from "../context/builder.context.lite";
|
|
7
|
-
import { track } from "../functions/track";
|
|
8
|
-
import { ifTarget } from "../functions/if-target";
|
|
9
|
-
import { onChange } from "../functions/on-change";
|
|
10
|
-
|
|
11
|
-
export default function RenderContent(props) {
|
|
12
|
-
function useContent() {
|
|
13
|
-
return overrideContent || props.content;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const [update, setUpdate] = useState(() => 0);
|
|
17
|
-
|
|
18
|
-
const [state, setState] = useState(() => ({}));
|
|
19
|
-
|
|
20
|
-
const [context, setContext] = useState(() => ({}));
|
|
21
|
-
|
|
22
|
-
const [overrideContent, setOverrideContent] = useState(() => null);
|
|
23
|
-
|
|
24
|
-
function processMessage(event) {
|
|
25
|
-
const { data } = event;
|
|
26
|
-
|
|
27
|
-
if (data) {
|
|
28
|
-
switch (data.type) {
|
|
29
|
-
case "builder.contentUpdate": {
|
|
30
|
-
const key =
|
|
31
|
-
data.data.key ||
|
|
32
|
-
data.data.alias ||
|
|
33
|
-
data.data.entry ||
|
|
34
|
-
data.data.modelName;
|
|
35
|
-
const contentData = data.data.data; // oof
|
|
36
|
-
|
|
37
|
-
if (key === props.model) {
|
|
38
|
-
setOverrideContent(contentData);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
case "builder.patchUpdates": {
|
|
45
|
-
// TODO
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (isBrowser()) {
|
|
54
|
-
window.addEventListener("message", processMessage); // TODO: run this when content is defined
|
|
55
|
-
// track('impression', {
|
|
56
|
-
// contentId: props.content!.id,
|
|
57
|
-
// });
|
|
58
|
-
}
|
|
59
|
-
}, []);
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<BuilderContext.Provider
|
|
63
|
-
value={{
|
|
64
|
-
get content() {
|
|
65
|
-
return props.content;
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
get state() {
|
|
69
|
-
return state;
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
get context() {
|
|
73
|
-
return context;
|
|
74
|
-
},
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
<View
|
|
78
|
-
onClick={(event) => {
|
|
79
|
-
track("click", {
|
|
80
|
-
contentId: props.content.id,
|
|
81
|
-
});
|
|
82
|
-
}}
|
|
83
|
-
data-builder-content-id={props.content?.id}
|
|
84
|
-
>
|
|
85
|
-
{useContent?.()?.data?.cssCode && (
|
|
86
|
-
<View>{useContent().data.cssCode}</View>
|
|
87
|
-
)}
|
|
88
|
-
|
|
89
|
-
{useContent?.()?.data?.blocks.map((block) => (
|
|
90
|
-
<RenderBlock key={block.id} block={block} />
|
|
91
|
-
))}
|
|
92
|
-
</View>
|
|
93
|
-
</BuilderContext.Provider>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
var __async = (__this, __arguments, generator) => {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
var fulfilled = (value) => {
|
|
24
|
-
try {
|
|
25
|
-
step(generator.next(value));
|
|
26
|
-
} catch (e) {
|
|
27
|
-
reject(e);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
var rejected = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.throw(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
38
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
import { isBrowser } from "./is-browser";
|
|
42
|
-
import { isReactNative } from "./is-react-native";
|
|
43
|
-
if (!(isBrowser() || isReactNative())) {
|
|
44
|
-
import("node-fetch");
|
|
45
|
-
}
|
|
46
|
-
function getContent(options) {
|
|
47
|
-
return __async(this, null, function* () {
|
|
48
|
-
return (yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }))).results[0] || null;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function getAllContent(options) {
|
|
52
|
-
return __async(this, null, function* () {
|
|
53
|
-
const { model, apiKey } = options;
|
|
54
|
-
const { limit, testGroups, userAttributes } = __spreadValues({
|
|
55
|
-
limit: 1,
|
|
56
|
-
userAttributes: null,
|
|
57
|
-
testGroups: null
|
|
58
|
-
}, options);
|
|
59
|
-
const content = yield fetch(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&userAttributes=${JSON.stringify(userAttributes)}`).then((res) => res.json());
|
|
60
|
-
if (testGroups) {
|
|
61
|
-
for (const item of content) {
|
|
62
|
-
if (item.variations && Object.keys(item.variations).length) {
|
|
63
|
-
const testGroup = testGroups[item.id];
|
|
64
|
-
const variationValue = item.variations[testGroup];
|
|
65
|
-
if (testGroup && variationValue) {
|
|
66
|
-
item.data = variationValue.data;
|
|
67
|
-
item.testVariationId = variationValue.id;
|
|
68
|
-
item.testVariationName = variationValue.name;
|
|
69
|
-
} else {
|
|
70
|
-
let n = 0;
|
|
71
|
-
const random = Math.random();
|
|
72
|
-
let set = false;
|
|
73
|
-
for (const id in item.variations) {
|
|
74
|
-
const variation = item.variations[id];
|
|
75
|
-
const testRatio = variation.testRatio;
|
|
76
|
-
n += testRatio;
|
|
77
|
-
if (random < n) {
|
|
78
|
-
const variationName = variation.name || (variation.id === item.id ? "Default variation" : "");
|
|
79
|
-
set = true;
|
|
80
|
-
Object.assign(item, {
|
|
81
|
-
data: variation.data,
|
|
82
|
-
testVariationId: variation.id,
|
|
83
|
-
testVariationName: variationName
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (!set) {
|
|
88
|
-
Object.assign(item, {
|
|
89
|
-
testVariationId: item.id,
|
|
90
|
-
testVariationName: "Default"
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return content;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
export {
|
|
101
|
-
getAllContent,
|
|
102
|
-
getContent
|
|
103
|
-
};
|
package/src/package.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@builder.io/sdk-react-native",
|
|
3
|
-
"description": "Builder.io SDK for React Native",
|
|
4
|
-
"version": "0.0.1-1",
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"react-native-render-html": "^5.1.1"
|
|
11
|
-
},
|
|
12
|
-
"peerDependencies": {
|
|
13
|
-
"react-native": "^0.64.2"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"react-native": "^0.64.2"
|
|
17
|
-
}
|
|
18
|
-
}
|