@builder.io/sdk-react-native 0.4.5 → 0.5.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/dist/blocks/button/button.js +6 -2
- package/dist/blocks/button/component-info.js +4 -8
- package/dist/blocks/columns/columns.js +17 -21
- package/dist/blocks/columns/component-info.js +27 -48
- package/dist/blocks/custom-code/component-info.js +4 -8
- package/dist/blocks/custom-code/custom-code.js +1 -1
- package/dist/blocks/embed/component-info.js +7 -11
- package/dist/blocks/embed/embed.js +1 -1
- package/dist/blocks/embed/helpers.js +2 -6
- package/dist/blocks/form/component-info.js +33 -69
- package/dist/blocks/form/form.js +2 -203
- package/dist/blocks/fragment/fragment.js +1 -1
- package/dist/blocks/helpers.js +33 -0
- package/dist/blocks/image/component-info.js +21 -47
- package/dist/blocks/image/image.helpers.js +2 -2
- package/dist/blocks/img/component-info.js +2 -4
- package/dist/blocks/img/img.js +2 -1
- package/dist/blocks/input/component-info.js +8 -34
- package/dist/blocks/input/input.js +2 -1
- package/dist/blocks/raw-text/component-info.js +2 -4
- package/dist/blocks/raw-text/raw-text.js +3 -2
- package/dist/blocks/section/component-info.js +5 -10
- package/dist/blocks/section/section.js +2 -1
- package/dist/blocks/select/component-info.js +12 -24
- package/dist/blocks/select/select.js +2 -1
- package/dist/blocks/submit-button/component-info.js +2 -4
- package/dist/blocks/submit-button/submit-button.js +2 -1
- package/dist/blocks/symbol/component-info.js +7 -12
- package/dist/blocks/symbol/symbol.helpers.js +66 -0
- package/dist/blocks/symbol/symbol.js +23 -52
- package/dist/blocks/text/component-info.js +3 -4
- package/dist/blocks/textarea/component-info.js +6 -12
- package/dist/blocks/textarea/textarea.js +2 -1
- package/dist/blocks/video/component-info.js +21 -41
- package/dist/components/block/block.helpers.js +12 -23
- package/dist/components/block/block.js +40 -70
- package/dist/components/block/components/block-styles.js +1 -1
- package/dist/components/block/components/block-wrapper/block-wrapper.js +41 -0
- package/dist/components/block/components/block-wrapper.js +56 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.js +40 -0
- package/dist/components/block/components/component-ref/component-ref.js +63 -0
- package/dist/components/block/components/component-ref.js +81 -0
- package/dist/components/block/components/interactive-element/interactive-element.helpers.js +35 -0
- package/dist/components/block/components/interactive-element/interactive-element.js +36 -0
- package/dist/components/block/components/interactive-element.js +46 -0
- package/dist/components/block/components/repeated-block.js +4 -4
- package/dist/components/blocks/blocks-wrapper.js +5 -2
- package/dist/components/blocks/blocks.js +9 -3
- package/dist/components/content/builder-editing.js +32 -0
- package/dist/components/content/components/enable-editor.js +30 -33
- package/dist/components/content/components/styles.helpers.js +55 -0
- package/dist/components/content/components/styles.js +61 -0
- package/dist/components/content/content.helpers.js +10 -3
- package/dist/components/content/content.js +27 -40
- package/dist/components/content/wrap-component-ref.js +1 -1
- package/dist/components/content-variants/content-variants.js +38 -34
- package/dist/components/content-variants/content-variants.types.js +1 -0
- package/dist/components/content-variants/helpers.js +61 -25
- package/dist/components/inlined-script.js +1 -1
- package/dist/components/inlined-styles.js +1 -1
- package/dist/constants/device-sizes.js +2 -2
- package/dist/constants/sdk-version.js +1 -1
- package/dist/context/builder.context.js +1 -1
- package/dist/context/components.context.js +6 -0
- package/dist/functions/apply-patch-with-mutation.js +75 -0
- package/dist/functions/apply-patch-with-mutation.test.js +55 -0
- package/dist/functions/camel-to-kebab-case.js +1 -1
- package/dist/functions/evaluate/acorn.js +1691 -0
- package/dist/functions/evaluate/evaluate.js +72 -0
- package/dist/functions/evaluate/index.js +5 -0
- package/dist/functions/evaluate/interpreter.js +2903 -0
- package/dist/functions/evaluate/non-node-runtime.js +97 -0
- package/dist/functions/evaluate/types.js +1 -0
- package/dist/functions/evaluate.test.js +12 -6
- package/dist/functions/event-handler-name.js +1 -1
- package/dist/functions/extract-text-styles.js +3 -9
- package/dist/functions/fast-clone.js +1 -1
- package/dist/functions/get-block-actions-handler.js +2 -2
- package/dist/functions/get-block-actions.js +14 -1
- package/dist/functions/get-block-component-options.js +6 -1
- package/dist/functions/get-block-properties.js +21 -8
- package/dist/functions/get-builder-search-params/fn.test.js +3 -3
- package/dist/functions/get-builder-search-params/index.js +4 -4
- package/dist/functions/get-content/generate-content-url.js +12 -5
- package/dist/functions/get-content/generate-content-url.test.js +31 -17
- package/dist/functions/get-content/index.js +36 -12
- package/dist/functions/get-content/processCookies.js +7 -0
- package/dist/functions/get-processed-block.js +8 -3
- package/dist/functions/get-processed-block.test.js +3 -1
- package/dist/functions/get-react-native-block-styles.js +6 -1
- package/dist/functions/is-non-node-server.js +12 -0
- package/dist/functions/on-change.test.js +13 -3
- package/dist/functions/register-component.js +24 -19
- package/dist/functions/sanitize-react-native-block-styles.js +17 -6
- package/dist/functions/set.test.js +9 -3
- package/dist/functions/track/helpers.js +5 -5
- package/dist/functions/track/index.js +29 -18
- package/dist/functions/track/interaction.js +10 -4
- package/dist/functions/transform-block-properties.js +2 -0
- package/dist/helpers/ab-tests.js +35 -14
- package/dist/helpers/canTrack.js +2 -2
- package/dist/helpers/css.js +2 -2
- package/dist/helpers/flatten.js +10 -7
- package/dist/helpers/nullable.js +1 -1
- package/dist/helpers/preview-lru-cache/get.js +11 -0
- package/dist/helpers/preview-lru-cache/helpers.js +13 -0
- package/dist/helpers/preview-lru-cache/init.js +13 -0
- package/dist/helpers/preview-lru-cache/set.js +37 -0
- package/dist/helpers/preview-lru-cache/types.js +1 -0
- package/dist/helpers/sessionId.js +13 -6
- package/dist/helpers/url.js +1 -1
- package/dist/helpers/visitorId.js +4 -1
- package/dist/index-helpers/blocks-exports.js +2 -2
- package/dist/scripts/init-editing.js +61 -46
- package/package.json +2 -2
- package/src/blocks/button/button.jsx +11 -2
- package/src/blocks/button/component-info.js +16 -22
- package/src/blocks/columns/columns.jsx +27 -26
- package/src/blocks/columns/component-info.js +203 -226
- package/src/blocks/custom-code/component-info.js +19 -25
- package/src/blocks/custom-code/custom-code.jsx +1 -1
- package/src/blocks/embed/component-info.js +31 -37
- package/src/blocks/embed/embed.jsx +1 -1
- package/src/blocks/embed/helpers.js +3 -9
- package/src/blocks/form/component-info.js +174 -212
- package/src/blocks/form/form.jsx +3 -247
- package/src/blocks/fragment/component-info.js +1 -3
- package/src/blocks/fragment/fragment.jsx +1 -1
- package/src/blocks/helpers.js +27 -0
- package/src/blocks/image/component-info.js +105 -133
- package/src/blocks/image/image.helpers.js +3 -5
- package/src/blocks/img/component-info.js +8 -12
- package/src/blocks/img/img.jsx +3 -1
- package/src/blocks/input/component-info.js +29 -57
- package/src/blocks/input/input.jsx +3 -1
- package/src/blocks/raw-text/component-info.js +7 -11
- package/src/blocks/raw-text/raw-text.jsx +4 -2
- package/src/blocks/section/component-info.js +24 -31
- package/src/blocks/section/section.jsx +3 -1
- package/src/blocks/select/component-info.js +34 -48
- package/src/blocks/select/select.jsx +3 -1
- package/src/blocks/submit-button/component-info.js +6 -10
- package/src/blocks/submit-button/submit-button.jsx +3 -2
- package/src/blocks/symbol/component-info.js +30 -37
- package/src/blocks/symbol/symbol.helpers.js +60 -0
- package/src/blocks/symbol/symbol.jsx +33 -61
- package/src/blocks/text/component-info.js +10 -13
- package/src/blocks/textarea/component-info.js +22 -30
- package/src/blocks/textarea/textarea.jsx +3 -1
- package/src/blocks/video/component-info.js +74 -96
- package/src/components/{render-block/render-block.helpers.js → block/block.helpers.js} +26 -44
- package/src/components/{render-block/render-block.jsx → block/block.jsx} +68 -81
- package/src/components/{render-block → block/components}/block-styles.jsx +18 -17
- package/src/components/block/components/block-wrapper.jsx +58 -0
- package/src/components/block/components/component-ref/component-ref.helpers.js +41 -0
- package/src/components/block/components/component-ref/component-ref.jsx +72 -0
- package/src/components/block/components/interactive-element.jsx +37 -0
- package/src/components/{render-block/render-repeated-block.jsx → block/components/repeated-block.jsx} +10 -6
- package/src/components/blocks/blocks-wrapper.jsx +74 -0
- package/src/components/blocks/blocks.jsx +61 -0
- package/src/components/{render-content/render-content.jsx → content/components/enable-editor.jsx} +77 -163
- package/src/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +6 -7
- package/src/components/{render-content/components/render-styles.jsx → content/components/styles.jsx} +5 -5
- package/src/components/{render-content/render-content.helpers.js → content/content.helpers.js} +15 -15
- package/src/components/content/content.jsx +148 -0
- package/src/components/content/index.js +2 -0
- package/src/components/content/wrap-component-ref.js +2 -0
- package/src/components/{render-content-variants/render-content-variants.jsx → content-variants/content-variants.jsx} +20 -23
- package/src/components/{render-content-variants → content-variants}/helpers.js +28 -40
- package/src/components/inlined-script.jsx +1 -1
- package/src/components/inlined-styles.jsx +1 -1
- package/src/constants/device-sizes.js +6 -6
- package/src/constants/sdk-version.js +1 -1
- package/src/context/builder.context.js +1 -1
- package/src/context/components.context.js +5 -0
- package/src/functions/apply-patch-with-mutation.js +66 -0
- package/src/functions/camel-to-kebab-case.js +2 -4
- package/src/functions/evaluate/acorn.js +1595 -0
- package/src/functions/{evaluate.js → evaluate/evaluate.js} +36 -10
- package/src/functions/evaluate/index.js +2 -0
- package/src/functions/evaluate/interpreter.js +2801 -0
- package/src/functions/evaluate/non-node-runtime.js +92 -0
- package/src/functions/evaluate/types.js +0 -0
- package/src/functions/event-handler-name.js +2 -4
- package/src/functions/extract-text-styles.js +4 -12
- package/src/functions/fast-clone.js +2 -4
- package/src/functions/get-block-actions-handler.js +3 -5
- package/src/functions/get-block-actions.js +15 -4
- package/src/functions/get-block-component-options.js +11 -12
- package/src/functions/get-block-properties.js +29 -19
- package/src/functions/get-builder-search-params/index.js +5 -10
- package/src/functions/get-content/generate-content-url.js +17 -19
- package/src/functions/get-content/index.js +43 -29
- package/src/functions/get-fetch.js +1 -3
- package/src/functions/get-global-this.js +1 -3
- package/src/functions/get-processed-block.js +12 -13
- package/src/functions/get-react-native-block-styles.js +11 -12
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +1 -3
- package/src/functions/is-editing.js +1 -3
- package/src/functions/is-iframe.js +1 -3
- package/src/functions/is-non-node-server.js +9 -0
- package/src/functions/is-previewing.js +1 -3
- package/src/functions/on-change.js +1 -4
- package/src/functions/register-component.js +34 -42
- package/src/functions/register.js +1 -3
- package/src/functions/sanitize-react-native-block-styles.js +22 -17
- package/src/functions/set-editor-settings.js +1 -3
- package/src/functions/set.js +1 -3
- package/src/functions/track/helpers.js +3 -5
- package/src/functions/track/index.js +45 -43
- package/src/functions/track/interaction.js +11 -7
- package/src/functions/transform-block-properties.js +2 -0
- package/src/helpers/ab-tests.js +45 -28
- package/src/helpers/canTrack.js +3 -5
- package/src/helpers/css.js +3 -7
- package/src/helpers/flatten.js +15 -18
- package/src/helpers/localStorage.js +1 -4
- package/src/helpers/logger.js +1 -3
- package/src/helpers/nullable.js +2 -4
- package/src/helpers/preview-lru-cache/get.js +8 -0
- package/src/helpers/preview-lru-cache/helpers.js +10 -0
- package/src/helpers/preview-lru-cache/init.js +10 -0
- package/src/helpers/preview-lru-cache/set.js +35 -0
- package/src/helpers/preview-lru-cache/types.js +0 -0
- package/src/helpers/sessionId.js +14 -11
- package/src/helpers/time.js +1 -3
- package/src/helpers/url.js +2 -4
- package/src/helpers/uuid.js +4 -6
- package/src/helpers/visitorId.js +8 -7
- package/src/index-helpers/blocks-exports.js +1 -1
- package/src/index.js +2 -17
- package/src/scripts/init-editing.js +62 -48
- package/src/types/api-version.js +1 -3
- package/src/types/builder-props.js +0 -0
- package/src/blocks/util.js +0 -8
- package/src/components/render-block/render-component.jsx +0 -55
- package/src/components/render-blocks.jsx +0 -101
- package/src/components/render-content/builder-editing.jsx +0 -16
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/wrap-component-ref.js +0 -4
- package/src/functions/evaluate.test.js +0 -17
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-content/generate-content-url.test.js +0 -97
- package/src/functions/get-processed-block.test.js +0 -34
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/set.test.js +0 -16
- package/src/helpers/url.test.js +0 -21
- /package/src/components/{render-block → block}/types.js +0 -0
- /package/src/components/{render-content/render-content.types.js → content/content.types.js} +0 -0
- /package/src/components/{render-content-variants/render-content-variants.types.js → content-variants/content-variants.types.js} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postPreviewContent = void 0;
|
|
4
|
+
var __async = (__this, __arguments, generator) => {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
var fulfilled = value => {
|
|
7
|
+
try {
|
|
8
|
+
step(generator.next(value));
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
reject(e);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var rejected = value => {
|
|
15
|
+
try {
|
|
16
|
+
step(generator.throw(value));
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
reject(e);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var step = x => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
23
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
"use server";
|
|
27
|
+
const init_1 = require("./init");
|
|
28
|
+
function postPreviewContent(_0) {
|
|
29
|
+
return __async(this, arguments, function* ({ key, value }) {
|
|
30
|
+
(0, init_1.init)();
|
|
31
|
+
globalThis._BUILDER_PREVIEW_LRU_CACHE.set(key, value);
|
|
32
|
+
return {
|
|
33
|
+
[key]: value
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.postPreviewContent = postPreviewContent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setSessionId = exports.getSessionId = exports.createSessionId = void 0;
|
|
4
4
|
var __async = (__this, __arguments, generator) => {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
6
|
-
var fulfilled =
|
|
6
|
+
var fulfilled = value => {
|
|
7
7
|
try {
|
|
8
8
|
step(generator.next(value));
|
|
9
9
|
}
|
|
@@ -11,7 +11,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
11
11
|
reject(e);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
var rejected =
|
|
14
|
+
var rejected = value => {
|
|
15
15
|
try {
|
|
16
16
|
step(generator.throw(value));
|
|
17
17
|
}
|
|
@@ -19,7 +19,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
19
19
|
reject(e);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
var step =
|
|
22
|
+
var step = x => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
23
23
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
24
24
|
});
|
|
25
25
|
};
|
|
@@ -27,7 +27,7 @@ const cookie_js_1 = require("./cookie.js");
|
|
|
27
27
|
const nullable_js_1 = require("./nullable.js");
|
|
28
28
|
const uuid_js_1 = require("./uuid.js");
|
|
29
29
|
const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
30
|
-
const getSessionId =
|
|
30
|
+
const getSessionId = _0 => __async(void 0, [_0], function* ({ canTrack }) {
|
|
31
31
|
if (!canTrack) {
|
|
32
32
|
return void 0;
|
|
33
33
|
}
|
|
@@ -40,12 +40,19 @@ const getSessionId = (_0) => __async(void 0, [_0], function* ({ canTrack }) {
|
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
const newSessionId = createSessionId();
|
|
43
|
-
setSessionId({
|
|
43
|
+
setSessionId({
|
|
44
|
+
id: newSessionId,
|
|
45
|
+
canTrack
|
|
46
|
+
});
|
|
44
47
|
return newSessionId;
|
|
45
48
|
}
|
|
46
49
|
});
|
|
47
50
|
exports.getSessionId = getSessionId;
|
|
48
51
|
const createSessionId = () => (0, uuid_js_1.uuid)();
|
|
49
52
|
exports.createSessionId = createSessionId;
|
|
50
|
-
const setSessionId = ({ id, canTrack }) => (0, cookie_js_1.setCookie)({
|
|
53
|
+
const setSessionId = ({ id, canTrack }) => (0, cookie_js_1.setCookie)({
|
|
54
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
55
|
+
value: id,
|
|
56
|
+
canTrack
|
|
57
|
+
});
|
|
51
58
|
exports.setSessionId = setSessionId;
|
package/dist/helpers/url.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTopLevelDomain = void 0;
|
|
4
|
-
const getTopLevelDomain =
|
|
4
|
+
const getTopLevelDomain = host => {
|
|
5
5
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
6
6
|
return host;
|
|
7
7
|
}
|
|
@@ -18,5 +18,5 @@ const section_1 = __importDefault(require("../blocks/section/section"));
|
|
|
18
18
|
Object.defineProperty(exports, "Section", { enumerable: true, get: function () { return section_1.default; } });
|
|
19
19
|
const fragment_1 = __importDefault(require("../blocks/fragment/fragment"));
|
|
20
20
|
Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return fragment_1.default; } });
|
|
21
|
-
const
|
|
22
|
-
Object.defineProperty(exports, "RenderContent", { enumerable: true, get: function () { return
|
|
21
|
+
const content_1 = __importDefault(require("../components/content/content"));
|
|
22
|
+
Object.defineProperty(exports, "RenderContent", { enumerable: true, get: function () { return content_1.default; } });
|
|
@@ -9,18 +9,23 @@ const registerInsertMenu = () => {
|
|
|
9
9
|
(0, register_js_1.register)("insertMenu", {
|
|
10
10
|
name: "_default",
|
|
11
11
|
default: true,
|
|
12
|
-
items: [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
items: [{
|
|
13
|
+
name: "Box"
|
|
14
|
+
}, {
|
|
15
|
+
name: "Text"
|
|
16
|
+
}, {
|
|
17
|
+
name: "Image"
|
|
18
|
+
}, {
|
|
19
|
+
name: "Columns"
|
|
20
|
+
}, ...(target_js_1.TARGET === "reactNative" ? [] : [{
|
|
21
|
+
name: "Core:Section"
|
|
22
|
+
}, {
|
|
23
|
+
name: "Core:Button"
|
|
24
|
+
}, {
|
|
25
|
+
name: "Embed"
|
|
26
|
+
}, {
|
|
27
|
+
name: "Custom Code"
|
|
28
|
+
}])]
|
|
24
29
|
});
|
|
25
30
|
};
|
|
26
31
|
exports.registerInsertMenu = registerInsertMenu;
|
|
@@ -54,44 +59,54 @@ const setupBrowserForEditing = (options = {}) => {
|
|
|
54
59
|
return;
|
|
55
60
|
}
|
|
56
61
|
switch (data.type) {
|
|
57
|
-
case "builder.evaluate":
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
catch (err) {
|
|
68
|
-
error = err;
|
|
69
|
-
}
|
|
70
|
-
if (error) {
|
|
71
|
-
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
72
|
-
type: "builder.evaluateError",
|
|
73
|
-
data: { id, error: error.message }
|
|
74
|
-
}, "*");
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
if (result && typeof result.then === "function") {
|
|
78
|
-
result.then((finalResult) => {
|
|
79
|
-
var _a3;
|
|
80
|
-
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
81
|
-
type: "builder.evaluateResult",
|
|
82
|
-
data: { id, result: finalResult }
|
|
83
|
-
}, "*");
|
|
84
|
-
}).catch(console.error);
|
|
62
|
+
case "builder.evaluate":
|
|
63
|
+
{
|
|
64
|
+
const text = data.data.text;
|
|
65
|
+
const args = data.data.arguments || [];
|
|
66
|
+
const id = data.data.id;
|
|
67
|
+
const fn = new Function(text);
|
|
68
|
+
let result;
|
|
69
|
+
let error = null;
|
|
70
|
+
try {
|
|
71
|
+
result = fn.apply(null, args);
|
|
85
72
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
73
|
+
catch (err) {
|
|
74
|
+
error = err;
|
|
75
|
+
}
|
|
76
|
+
if (error) {
|
|
77
|
+
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
78
|
+
type: "builder.evaluateError",
|
|
79
|
+
data: {
|
|
80
|
+
id,
|
|
81
|
+
error: error.message
|
|
82
|
+
}
|
|
90
83
|
}, "*");
|
|
91
84
|
}
|
|
85
|
+
else {
|
|
86
|
+
if (result && typeof result.then === "function") {
|
|
87
|
+
result.then(finalResult => {
|
|
88
|
+
var _a3;
|
|
89
|
+
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
90
|
+
type: "builder.evaluateResult",
|
|
91
|
+
data: {
|
|
92
|
+
id,
|
|
93
|
+
result: finalResult
|
|
94
|
+
}
|
|
95
|
+
}, "*");
|
|
96
|
+
}).catch(console.error);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
100
|
+
type: "builder.evaluateResult",
|
|
101
|
+
data: {
|
|
102
|
+
result,
|
|
103
|
+
id
|
|
104
|
+
}
|
|
105
|
+
}, "*");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
92
109
|
}
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
110
|
}
|
|
96
111
|
});
|
|
97
112
|
}
|
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.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"@tsconfig/react-native": "^2.0.3",
|
|
30
30
|
"@types/react-native-video": "^5.0.9",
|
|
31
31
|
"react-native-url-polyfill": "^1.3.0",
|
|
32
|
-
"typescript": "^
|
|
32
|
+
"typescript": "^5.1.6"
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
import BaseText from "../BaseText";
|
|
2
|
+
("use client");
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import {
|
|
5
5
|
FlatList,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Image,
|
|
10
10
|
Text,
|
|
11
11
|
} from "react-native";
|
|
12
|
+
import { filterAttrs } from "../helpers.js";
|
|
12
13
|
|
|
13
14
|
function Button(props) {
|
|
14
15
|
return (
|
|
@@ -17,6 +18,7 @@ function Button(props) {
|
|
|
17
18
|
<>
|
|
18
19
|
<View
|
|
19
20
|
role="button"
|
|
21
|
+
{...{}}
|
|
20
22
|
{...props.attributes}
|
|
21
23
|
href={props.link}
|
|
22
24
|
target={props.openLinkInNewTab ? "_blank" : undefined}
|
|
@@ -26,7 +28,14 @@ function Button(props) {
|
|
|
26
28
|
</>
|
|
27
29
|
) : (
|
|
28
30
|
<>
|
|
29
|
-
<View
|
|
31
|
+
<View
|
|
32
|
+
{...{}}
|
|
33
|
+
{...props.attributes}
|
|
34
|
+
style={{
|
|
35
|
+
...styles.view1,
|
|
36
|
+
...props.attributes.style,
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
30
39
|
<BaseText>{props.text}</BaseText>
|
|
31
40
|
</View>
|
|
32
41
|
</>
|
|
@@ -13,28 +13,22 @@ const componentInfo = {
|
|
|
13
13
|
textAlign: "center",
|
|
14
14
|
cursor: "pointer"
|
|
15
15
|
},
|
|
16
|
-
inputs: [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
defaultValue: false,
|
|
32
|
-
friendlyName: "Open link in new tab"
|
|
33
|
-
}
|
|
34
|
-
],
|
|
16
|
+
inputs: [{
|
|
17
|
+
name: "text",
|
|
18
|
+
type: "text",
|
|
19
|
+
defaultValue: "Click me!",
|
|
20
|
+
bubble: true
|
|
21
|
+
}, {
|
|
22
|
+
name: "link",
|
|
23
|
+
type: "url",
|
|
24
|
+
bubble: true
|
|
25
|
+
}, {
|
|
26
|
+
name: "openLinkInNewTab",
|
|
27
|
+
type: "boolean",
|
|
28
|
+
defaultValue: false,
|
|
29
|
+
friendlyName: "Open link in new tab"
|
|
30
|
+
}],
|
|
35
31
|
static: true,
|
|
36
32
|
noWrap: true
|
|
37
33
|
};
|
|
38
|
-
export {
|
|
39
|
-
componentInfo
|
|
40
|
-
};
|
|
34
|
+
export { componentInfo }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {
|
|
4
4
|
FlatList,
|
|
@@ -8,12 +8,11 @@ import {
|
|
|
8
8
|
Image,
|
|
9
9
|
Text,
|
|
10
10
|
} from "react-native";
|
|
11
|
-
import { useState
|
|
12
|
-
import
|
|
13
|
-
import { getSizesForBreakpoints } from "../../constants/device-sizes";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import Blocks from "../../components/blocks/blocks";
|
|
13
|
+
import { getSizesForBreakpoints } from "../../constants/device-sizes.js";
|
|
14
14
|
import InlinedStyles from "../../components/inlined-styles";
|
|
15
15
|
import { TARGET } from "../../constants/target.js";
|
|
16
|
-
import BuilderContext from "../../context/builder.context.js";
|
|
17
16
|
|
|
18
17
|
function Columns(props) {
|
|
19
18
|
const [gutterSize, setGutterSize] = useState(() =>
|
|
@@ -52,17 +51,8 @@ function Columns(props) {
|
|
|
52
51
|
);
|
|
53
52
|
|
|
54
53
|
function columnsCssVars() {
|
|
55
|
-
if (TARGET === "reactNative") {
|
|
56
|
-
return {
|
|
57
|
-
flexDirection: flexDir,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
54
|
return {
|
|
61
|
-
|
|
62
|
-
"--flex-dir-tablet": getTabletStyle({
|
|
63
|
-
stackedStyle: flexDir,
|
|
64
|
-
desktopStyle: "row",
|
|
65
|
-
}),
|
|
55
|
+
flexDirection: flexDir,
|
|
66
56
|
};
|
|
67
57
|
}
|
|
68
58
|
|
|
@@ -77,9 +67,10 @@ function Columns(props) {
|
|
|
77
67
|
const gutterPixels = `${gutter}px`;
|
|
78
68
|
const mobileWidth = "100%";
|
|
79
69
|
const mobileMarginLeft = 0;
|
|
70
|
+
const marginLeftKey = "margin-left";
|
|
80
71
|
return {
|
|
81
72
|
width,
|
|
82
|
-
|
|
73
|
+
[marginLeftKey]: gutterPixels,
|
|
83
74
|
"--column-width-mobile": getMobileStyle({
|
|
84
75
|
stackedStyle: mobileWidth,
|
|
85
76
|
desktopStyle: width,
|
|
@@ -101,7 +92,7 @@ function Columns(props) {
|
|
|
101
92
|
|
|
102
93
|
function getWidthForBreakpointSize(size) {
|
|
103
94
|
const breakpointSizes = getSizesForBreakpoints(
|
|
104
|
-
builderContext.content?.meta?.breakpoints || {}
|
|
95
|
+
props.builderContext.content?.meta?.breakpoints || {}
|
|
105
96
|
);
|
|
106
97
|
return breakpointSizes[size].max;
|
|
107
98
|
}
|
|
@@ -134,13 +125,16 @@ function Columns(props) {
|
|
|
134
125
|
`;
|
|
135
126
|
}
|
|
136
127
|
|
|
137
|
-
const builderContext = useContext(BuilderContext);
|
|
138
|
-
|
|
139
128
|
return (
|
|
140
129
|
<View
|
|
141
|
-
style={
|
|
142
|
-
|
|
143
|
-
|
|
130
|
+
style={{
|
|
131
|
+
...styles.view1,
|
|
132
|
+
...columnsCssVars(),
|
|
133
|
+
}}
|
|
134
|
+
{...{
|
|
135
|
+
dataSet: {
|
|
136
|
+
"builder-block-name": "builder-columns",
|
|
137
|
+
},
|
|
144
138
|
}}
|
|
145
139
|
>
|
|
146
140
|
{TARGET !== "reactNative" ? (
|
|
@@ -151,19 +145,26 @@ function Columns(props) {
|
|
|
151
145
|
|
|
152
146
|
{props.columns?.map((column, index) => (
|
|
153
147
|
<View
|
|
154
|
-
style={
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
style={{
|
|
149
|
+
...styles.view2,
|
|
150
|
+
...columnCssVars(index),
|
|
151
|
+
}}
|
|
152
|
+
{...{
|
|
153
|
+
dataSet: {
|
|
154
|
+
"builder-block-name": "builder-column",
|
|
155
|
+
},
|
|
157
156
|
}}
|
|
158
157
|
key={index}
|
|
159
158
|
>
|
|
160
|
-
<
|
|
159
|
+
<Blocks
|
|
161
160
|
blocks={column.blocks}
|
|
162
161
|
path={`component.options.columns.${index}.blocks`}
|
|
163
162
|
parent={props.builderBlock.id}
|
|
164
163
|
styleProp={{
|
|
165
164
|
flexGrow: "1",
|
|
166
165
|
}}
|
|
166
|
+
context={props.builderContext}
|
|
167
|
+
registeredComponents={props.builderComponents}
|
|
167
168
|
/>
|
|
168
169
|
</View>
|
|
169
170
|
))}
|