@builder.io/sdk-react-native 0.0.1-50 → 0.0.1-51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -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 +13 -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { convertSearchParamsToQueryObject, getBuilderSearchParams } from ".";
|
|
3
3
|
const querystring = "someotherValue=jklsjfdal&abc=klfdjklgfds&builder.cachebust=true&builder.preview=page&builder.noCache=true&__builder_editing__=true&builder.overrides.page=037948e52eaf4743afed464f02c70da4&builder.overrides.037948e52eaf4743afed464f02c70da4=037948e52eaf4743afed464f02c70da4&builder.overrides.page%3A%2F=037948e52eaf4743afed464f02c70da4&preview_theme_id=128854393017";
|
|
4
4
|
const url = new URL(`localhost:3000/about-us?${querystring}`);
|
|
5
5
|
describe("Get Builder SearchParams", () => {
|
|
@@ -38,8 +38,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
38
38
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
-
import { getFetch } from "../get-fetch";
|
|
42
|
-
const fetch = getFetch();
|
|
41
|
+
import { getFetch } from "../get-fetch.js";
|
|
42
|
+
const fetch$ = getFetch();
|
|
43
43
|
function flatten(object, path = null, separator = ".") {
|
|
44
44
|
return Object.keys(object).reduce((acc, key) => {
|
|
45
45
|
const value = object[key];
|
|
@@ -124,6 +124,7 @@ const handleABTesting = (content, testGroups) => {
|
|
|
124
124
|
function getAllContent(options) {
|
|
125
125
|
return __async(this, null, function* () {
|
|
126
126
|
const url = generateContentUrl(options);
|
|
127
|
+
const fetch = yield fetch$;
|
|
127
128
|
const content = yield fetch(url.href).then((res) => res.json());
|
|
128
129
|
if (options.testGroups) {
|
|
129
130
|
handleABTesting(content, options.testGroups);
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
var __async = (__this, __arguments, generator) => {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
var fulfilled = (value) => {
|
|
5
|
+
try {
|
|
6
|
+
step(generator.next(value));
|
|
7
|
+
} catch (e) {
|
|
8
|
+
reject(e);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var rejected = (value) => {
|
|
12
|
+
try {
|
|
13
|
+
step(generator.throw(value));
|
|
14
|
+
} catch (e) {
|
|
15
|
+
reject(e);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
19
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
import { getGlobalThis } from "./get-global-this.js";
|
|
3
23
|
function getFetch() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
24
|
+
return __async(this, null, function* () {
|
|
25
|
+
const globalFetch = getGlobalThis().fetch;
|
|
26
|
+
if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
|
|
27
|
+
const nodeFetch = import("node-fetch").then((d) => d.default);
|
|
28
|
+
return nodeFetch;
|
|
29
|
+
}
|
|
30
|
+
return globalFetch;
|
|
31
|
+
});
|
|
10
32
|
}
|
|
11
33
|
export {
|
|
12
34
|
getFetch
|
|
@@ -18,9 +18,9 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
return a;
|
|
19
19
|
};
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
import { evaluate } from "./evaluate";
|
|
22
|
-
import { set } from "./set";
|
|
23
|
-
import { transformBlock } from "./transform-block";
|
|
21
|
+
import { evaluate } from "./evaluate.js";
|
|
22
|
+
import { set } from "./set.js";
|
|
23
|
+
import { transformBlock } from "./transform-block.js";
|
|
24
24
|
function getProcessedBlock(options) {
|
|
25
25
|
const { state, context } = options;
|
|
26
26
|
const block = transformBlock(options.block);
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { TARGET } from "../constants/target.js";
|
|
3
|
+
function ifTarget({
|
|
4
|
+
targets,
|
|
5
|
+
doThing,
|
|
6
|
+
elseThing
|
|
7
|
+
}) {
|
|
8
|
+
if (TARGET && targets.includes(TARGET)) {
|
|
9
|
+
return doThing();
|
|
10
|
+
} else {
|
|
11
|
+
return elseThing == null ? void 0 : elseThing();
|
|
12
|
+
}
|
|
4
13
|
}
|
|
5
14
|
export {
|
|
6
15
|
ifTarget
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { isBrowser } from "./is-browser";
|
|
3
|
-
import { isEditing } from "./is-editing";
|
|
2
|
+
import { isBrowser } from "./is-browser.js";
|
|
3
|
+
import { isEditing } from "./is-editing.js";
|
|
4
4
|
function isPreviewing() {
|
|
5
5
|
if (!isBrowser()) {
|
|
6
6
|
return false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { onChange } from "./on-change";
|
|
2
|
+
import { onChange } from "./on-change.js";
|
|
3
3
|
test("onChange can observe a shallow change", () => {
|
|
4
4
|
let changeHappend = false;
|
|
5
5
|
const obj = onChange({ foo: "hi" }, () => changeHappend = true);
|
|
@@ -18,27 +18,26 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
return a;
|
|
19
19
|
};
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
import {
|
|
22
|
-
const components =
|
|
21
|
+
import { fastClone } from "./fast-clone.js";
|
|
22
|
+
const components = [];
|
|
23
23
|
function registerComponent(component, info) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (isBrowser()) {
|
|
27
|
-
const sendInfo = prepareComponentInfoToSend(info);
|
|
28
|
-
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
29
|
-
type: "builder.registerComponent",
|
|
30
|
-
data: sendInfo
|
|
31
|
-
}, "*");
|
|
32
|
-
}
|
|
24
|
+
components.push({ component, info });
|
|
25
|
+
console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
|
|
33
26
|
return component;
|
|
34
27
|
}
|
|
28
|
+
const createRegisterComponentMessage = ({
|
|
29
|
+
info
|
|
30
|
+
}) => ({
|
|
31
|
+
type: "builder.registerComponent",
|
|
32
|
+
data: prepareComponentInfoToSend(fastClone(info))
|
|
33
|
+
});
|
|
35
34
|
function prepareComponentInfoToSend(info) {
|
|
36
35
|
return __spreadValues(__spreadValues({}, info), info.inputs && {
|
|
37
36
|
inputs: info.inputs.map((input) => {
|
|
38
37
|
const keysToConvertFnToString = ["onChange", "showIf"];
|
|
39
38
|
for (const key of keysToConvertFnToString) {
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const fn = input[key];
|
|
40
|
+
if (fn && typeof fn === "function") {
|
|
42
41
|
input = __spreadProps(__spreadValues({}, input), {
|
|
43
42
|
[key]: `return (${fn.toString()}).apply(this, arguments)`
|
|
44
43
|
});
|
|
@@ -50,5 +49,6 @@ function prepareComponentInfoToSend(info) {
|
|
|
50
49
|
}
|
|
51
50
|
export {
|
|
52
51
|
components,
|
|
52
|
+
createRegisterComponentMessage,
|
|
53
53
|
registerComponent
|
|
54
54
|
};
|
package/src/functions/track.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { TARGET } from "../constants/target.js";
|
|
3
|
+
import { isBrowser } from "./is-browser.js";
|
|
4
|
+
import { isEditing } from "./is-editing.js";
|
|
5
5
|
function track(event, properties) {
|
|
6
6
|
if (isEditing()) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
-
if (!(isBrowser() ||
|
|
9
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
return fetch(`https://builder.io/api/v1/track`, {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { default as default2 } from "../blocks/columns";
|
|
3
|
-
import { default as default3 } from "../blocks/image";
|
|
4
|
-
import { default as default4 } from "../blocks/text";
|
|
5
|
-
import { default as default5 } from "../blocks/symbol";
|
|
6
|
-
import { default as default6 } from "../blocks/button";
|
|
7
|
-
import { default as default7 } from "../blocks/section";
|
|
8
|
-
import { default as default8 } from "../blocks/fragment";
|
|
9
|
-
import { default as default9 } from "../components/render-content";
|
|
2
|
+
import { default as default2 } from "../blocks/columns/columns.js";
|
|
3
|
+
import { default as default3 } from "../blocks/image/image.js";
|
|
4
|
+
import { default as default4 } from "../blocks/text/text.js";
|
|
5
|
+
import { default as default5 } from "../blocks/symbol/symbol.js";
|
|
6
|
+
import { default as default6 } from "../blocks/button/button.js";
|
|
7
|
+
import { default as default7 } from "../blocks/section/section.js";
|
|
8
|
+
import { default as default8 } from "../blocks/fragment/fragment.js";
|
|
9
|
+
import { default as default9 } from "../components/render-content/render-content.js";
|
|
10
10
|
export {
|
|
11
11
|
default6 as Button,
|
|
12
12
|
default2 as Columns,
|
package/src/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./functions/
|
|
9
|
-
export * from "./functions/
|
|
10
|
-
export * from "./functions/
|
|
11
|
-
export * from "./functions/
|
|
12
|
-
export * from "./functions/set-editor-settings";
|
|
13
|
-
export * from "./functions/get-content";
|
|
14
|
-
export * from "./functions/get-builder-search-params";
|
|
2
|
+
import "./index-helpers/top-of-file.js";
|
|
3
|
+
import "./scripts/init-editing.js";
|
|
4
|
+
export * from "./index-helpers/blocks-exports.js";
|
|
5
|
+
export * from "./functions/is-editing.js";
|
|
6
|
+
export * from "./functions/is-previewing.js";
|
|
7
|
+
export * from "./functions/register-component.js";
|
|
8
|
+
export * from "./functions/register.js";
|
|
9
|
+
export * from "./functions/set-editor-settings.js";
|
|
10
|
+
export * from "./functions/get-content/index.js";
|
|
11
|
+
export * from "./functions/get-builder-search-params/index.js";
|
|
@@ -1,71 +1,81 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { isBrowser } from "../functions/is-browser";
|
|
4
|
-
import {
|
|
5
|
-
register
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{ name: "
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import { TARGET } from "../constants/target.js";
|
|
3
|
+
import { isBrowser } from "../functions/is-browser.js";
|
|
4
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
5
|
+
import { register } from "../functions/register.js";
|
|
6
|
+
const registerInsertMenu = () => {
|
|
7
|
+
register("insertMenu", {
|
|
8
|
+
name: "_default",
|
|
9
|
+
default: true,
|
|
10
|
+
items: [
|
|
11
|
+
{ name: "Box" },
|
|
12
|
+
{ name: "Text" },
|
|
13
|
+
{ name: "Image" },
|
|
14
|
+
{ name: "Columns" },
|
|
15
|
+
...TARGET === "reactNative" ? [] : [
|
|
16
|
+
{ name: "Core:Section" },
|
|
17
|
+
{ name: "Core:Button" },
|
|
18
|
+
{ name: "Embed" },
|
|
19
|
+
{ name: "Custom Code" }
|
|
20
|
+
]
|
|
18
21
|
]
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const setupBrowserForEditing = () => {
|
|
25
|
+
var _a;
|
|
26
|
+
if (isBrowser()) {
|
|
27
|
+
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
28
|
+
type: "builder.sdkInfo",
|
|
29
|
+
data: {
|
|
30
|
+
target: TARGET,
|
|
31
|
+
supportsPatchUpdates: false
|
|
32
|
+
}
|
|
33
|
+
}, "*");
|
|
34
|
+
window.addEventListener("message", ({ data }) => {
|
|
35
|
+
var _a2, _b;
|
|
36
|
+
if (data) {
|
|
37
|
+
switch (data.type) {
|
|
38
|
+
case "builder.evaluate": {
|
|
39
|
+
const text = data.data.text;
|
|
40
|
+
const args = data.data.arguments || [];
|
|
41
|
+
const id = data.data.id;
|
|
42
|
+
const fn = new Function(text);
|
|
43
|
+
let result;
|
|
44
|
+
let error = null;
|
|
45
|
+
try {
|
|
46
|
+
result = fn.apply(null, args);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
error = err;
|
|
49
|
+
}
|
|
50
|
+
if (error) {
|
|
51
|
+
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
52
|
+
type: "builder.evaluateError",
|
|
53
|
+
data: { id, error: error.message }
|
|
54
|
+
}, "*");
|
|
55
|
+
} else {
|
|
56
|
+
if (result && typeof result.then === "function") {
|
|
57
|
+
result.then((finalResult) => {
|
|
58
|
+
var _a3;
|
|
59
|
+
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
60
|
+
type: "builder.evaluateResult",
|
|
61
|
+
data: { id, result: finalResult }
|
|
62
|
+
}, "*");
|
|
63
|
+
}).catch(console.error);
|
|
64
|
+
} else {
|
|
65
|
+
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
55
66
|
type: "builder.evaluateResult",
|
|
56
|
-
data: {
|
|
67
|
+
data: { result, id }
|
|
57
68
|
}, "*");
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
61
|
-
type: "builder.evaluateResult",
|
|
62
|
-
data: { result, id }
|
|
63
|
-
}, "*");
|
|
69
|
+
}
|
|
64
70
|
}
|
|
71
|
+
break;
|
|
65
72
|
}
|
|
66
|
-
break;
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
if (isEditing()) {
|
|
79
|
+
registerInsertMenu();
|
|
80
|
+
setupBrowserForEditing();
|
|
71
81
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
package/src/blocks/button.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from '../functions/register-component';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
import * as React from "react";
|
|
23
|
-
import { View, Text } from "react-native";
|
|
24
|
-
function Button(props) {
|
|
25
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.link ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
26
|
-
role: "button",
|
|
27
|
-
href: props.link,
|
|
28
|
-
target: props.openLinkInNewTab ? "_blank" : void 0
|
|
29
|
-
}), /* @__PURE__ */ React.createElement(Text, null, props.text))) : /* @__PURE__ */ React.createElement(View, __spreadValues({}, props.attributes), /* @__PURE__ */ React.createElement(Text, null, props.text)));
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
Button as default
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
registerComponent(Button, {name:'Core:Button',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13',defaultStyles:{appearance:'none',paddingTop:'15px',paddingBottom:'15px',paddingLeft:'25px',paddingRight:'25px',backgroundColor:'#000000',color:'white',borderRadius:'4px',textAlign:'center',cursor:'pointer'},inputs:[{name:'text',type:'text',defaultValue:'Click me!',bubble:true},{name:'link',type:'url',bubble:true},{name:'openLinkInNewTab',type:'boolean',defaultValue:false,friendlyName:'Open link in new tab'}],static:true,noWrap:true});
|
package/src/blocks/columns.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from '../functions/register-component';
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { View, StyleSheet } from "react-native";
|
|
5
|
-
import RenderBlocks from "../components/render-blocks";
|
|
6
|
-
function Columns(props) {
|
|
7
|
-
var _a;
|
|
8
|
-
function getGutterSize() {
|
|
9
|
-
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
10
|
-
}
|
|
11
|
-
function getColumns() {
|
|
12
|
-
return props.columns || [];
|
|
13
|
-
}
|
|
14
|
-
function getWidth(index) {
|
|
15
|
-
var _a2;
|
|
16
|
-
const columns = getColumns();
|
|
17
|
-
return ((_a2 = columns[index]) == null ? void 0 : _a2.width) || 100 / columns.length;
|
|
18
|
-
}
|
|
19
|
-
function getColumnCssWidth(index) {
|
|
20
|
-
const columns = getColumns();
|
|
21
|
-
const gutterSize = getGutterSize();
|
|
22
|
-
const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
|
|
23
|
-
return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
|
|
24
|
-
}
|
|
25
|
-
function maybeApplyForTablet(prop) {
|
|
26
|
-
const stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
27
|
-
return stackColumnsAt === "tablet" ? prop : "inherit";
|
|
28
|
-
}
|
|
29
|
-
function columnsCssVars() {
|
|
30
|
-
const flexDir = props.stackColumnsAt === "never" ? "inherit" : props.reverseColumnsWhenStacked ? "column-reverse" : "column";
|
|
31
|
-
return {
|
|
32
|
-
"--flex-dir": flexDir,
|
|
33
|
-
"--flex-dir-tablet": maybeApplyForTablet(flexDir)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function columnCssVars() {
|
|
37
|
-
const width = "100%";
|
|
38
|
-
const marginLeft = "0";
|
|
39
|
-
return {
|
|
40
|
-
"--column-width": width,
|
|
41
|
-
"--column-margin-left": marginLeft,
|
|
42
|
-
"--column-width-tablet": maybeApplyForTablet(width),
|
|
43
|
-
"--column-margin-left-tablet": maybeApplyForTablet(marginLeft)
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return /* @__PURE__ */ React.createElement(View, {
|
|
47
|
-
style: styles.view1
|
|
48
|
-
}, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement(View, {
|
|
49
|
-
style: styles.view2
|
|
50
|
-
}, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
51
|
-
blocks: column.blocks
|
|
52
|
-
}))));
|
|
53
|
-
}
|
|
54
|
-
const styles = StyleSheet.create({
|
|
55
|
-
view1: { display: "flex", alignItems: "stretch" },
|
|
56
|
-
view2: { flexGrow: 1 }
|
|
57
|
-
});
|
|
58
|
-
export {
|
|
59
|
-
Columns as default
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
registerComponent(Columns, {name:'Columns',builtIn:true,inputs:[{name:'columns',type:'array',broadcast:true,subFields:[{name:'blocks',type:'array',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]},{name:'width',type:'number',hideFromUI:true,helperText:'Width %, e.g. set to 50 to fill half of the space'},{name:'link',type:'url',helperText:'Optionally set a url that clicking this column will link to'}],defaultValue:[{blocks:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]},{blocks:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]}],onChange:" function clearWidths() { columns.forEach(col => { col.delete('width'); }); } const columns = options.get('columns') as Array<Map<String, any>>; if (Array.isArray(columns)) { const containsColumnWithWidth = !!columns.find(col => col.get('width')); if (containsColumnWithWidth) { const containsColumnWithoutWidth = !!columns.find(col => !col.get('width')); if (containsColumnWithoutWidth) { clearWidths(); } else { const sumWidths = columns.reduce((memo, col) => { return memo + col.get('width'); }, 0); const widthsDontAddUp = sumWidths !== 100; if (widthsDontAddUp) { clearWidths(); } } } } "},{name:'space',type:'number',defaultValue:20,helperText:'Size of gap between columns',advanced:true},{name:'stackColumnsAt',type:'string',defaultValue:'tablet',helperText:'Convert horizontal columns to vertical at what device size',enum:['tablet','mobile','never'],advanced:true},{name:'reverseColumnsWhenStacked',type:'boolean',defaultValue:false,helperText:'When stacking columns for mobile devices, reverse the ordering',advanced:true}]});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from '../functions/register-component';
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { View } from "react-native";
|
|
5
|
-
import { useState, useRef, useEffect } from "react";
|
|
6
|
-
function CustomCode(props) {
|
|
7
|
-
const [scriptsInserted, setScriptsInserted] = useState(() => []);
|
|
8
|
-
const [scriptsRun, setScriptsRun] = useState(() => []);
|
|
9
|
-
function findAndRunScripts() {
|
|
10
|
-
if (elem.current && typeof window !== "undefined") {
|
|
11
|
-
const scripts = elem.current.getElementsByTagName("script");
|
|
12
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
13
|
-
const script = scripts[i];
|
|
14
|
-
if (script.src) {
|
|
15
|
-
if (scriptsInserted.includes(script.src)) {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
scriptsInserted.push(script.src);
|
|
19
|
-
const newScript = document.createElement("script");
|
|
20
|
-
newScript.async = true;
|
|
21
|
-
newScript.src = script.src;
|
|
22
|
-
document.head.appendChild(newScript);
|
|
23
|
-
} else if (!script.type || [
|
|
24
|
-
"text/javascript",
|
|
25
|
-
"application/javascript",
|
|
26
|
-
"application/ecmascript"
|
|
27
|
-
].includes(script.type)) {
|
|
28
|
-
if (scriptsRun.includes(script.innerText)) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
scriptsRun.push(script.innerText);
|
|
33
|
-
new Function(script.innerText)();
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.warn("`CustomCode`: Error running script:", error);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const elem = useRef();
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
findAndRunScripts();
|
|
44
|
-
}, []);
|
|
45
|
-
return /* @__PURE__ */ React.createElement(View, {
|
|
46
|
-
ref: elem,
|
|
47
|
-
dangerouslySetInnerHTML: { __html: "props.code" }
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
export {
|
|
51
|
-
CustomCode as default
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
registerComponent(CustomCode, {name:'Custom Code',static:true,builtIn:true,requiredPermissions:['editCode'],inputs:[{name:'code',type:'html',required:true,defaultValue:'<p>Hello there, I am custom HTML code!</p>',code:true},{name:'replaceNodes',type:'boolean',helperText:'Preserve server rendered dom nodes',advanced:true},{name:'scriptsClientOnly',type:'boolean',defaultValue:false,helperText:'Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads',advanced:true}]});
|