@builder.io/sdk-react-native 0.0.1-22 → 0.0.1-26
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 +3 -2
- package/src/blocks/button.js +66 -24
- package/src/blocks/button.lite.tsx +9 -13
- package/src/blocks/columns.js +247 -36
- package/src/blocks/columns.lite.tsx +7 -7
- package/src/blocks/custom-code.js +73 -47
- package/src/blocks/custom-code.lite.tsx +12 -16
- package/src/blocks/embed.js +66 -47
- package/src/blocks/embed.lite.tsx +11 -13
- package/src/blocks/form.js +436 -198
- package/src/blocks/form.lite.tsx +67 -78
- package/src/blocks/fragment.js +16 -11
- package/src/blocks/fragment.lite.tsx +8 -5
- package/src/blocks/image.js +89 -80
- package/src/blocks/image.lite.tsx +44 -13
- package/src/blocks/img.js +45 -28
- package/src/blocks/img.lite.tsx +7 -7
- package/src/blocks/input.js +93 -28
- package/src/blocks/input.lite.tsx +5 -9
- package/src/blocks/raw-text.js +16 -12
- package/src/blocks/raw-text.lite.tsx +3 -3
- package/src/blocks/section.js +66 -23
- package/src/blocks/section.lite.tsx +4 -4
- package/src/blocks/select.js +67 -28
- package/src/blocks/select.lite.tsx +6 -10
- package/src/blocks/submit-button.js +41 -21
- package/src/blocks/submit-button.lite.tsx +3 -3
- package/src/blocks/symbol.js +18 -16
- package/src/blocks/symbol.lite.tsx +5 -5
- package/src/blocks/text.js +29 -27
- package/src/blocks/text.lite.tsx +4 -9
- package/src/blocks/textarea.js +53 -24
- package/src/blocks/textarea.lite.tsx +3 -3
- package/src/blocks/video.js +112 -46
- package/src/blocks/video.lite.tsx +6 -6
- package/src/components/block-styles.js +2 -4
- package/src/components/block-styles.lite.tsx +3 -3
- package/src/components/error-boundary.js +11 -9
- package/src/components/error-boundary.lite.tsx +3 -3
- package/src/components/render-block.js +89 -36
- package/src/components/render-block.lite.tsx +47 -32
- package/src/components/render-blocks.js +56 -32
- package/src/components/render-blocks.lite.tsx +16 -16
- package/src/components/render-content.js +160 -36
- package/src/components/render-content.lite.tsx +139 -39
- package/src/constants/device-sizes.js +8 -11
- package/src/context/builder.context.js +2 -4
- package/src/functions/evaluate.js +17 -9
- package/src/functions/get-block-actions.js +9 -10
- package/src/functions/get-block-component-options.js +11 -10
- package/src/functions/get-block-properties.js +15 -17
- package/src/functions/get-block-styles.js +25 -17
- package/src/functions/get-block-tag.js +2 -4
- package/src/functions/get-content.js +54 -27
- package/src/functions/get-fetch.js +11 -0
- package/src/functions/get-global-this.js +17 -0
- package/src/functions/get-processed-block.js +11 -13
- package/src/functions/get-processed-block.test.js +14 -14
- package/src/functions/get-target.js +3 -5
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +3 -5
- package/src/functions/is-editing.js +3 -5
- package/src/functions/is-iframe.js +2 -4
- package/src/functions/is-previewing.js +13 -0
- package/src/functions/is-react-native.js +2 -4
- package/src/functions/macro-eval.js +2 -5
- package/src/functions/on-change.js +4 -7
- package/src/functions/on-change.test.js +10 -10
- package/src/functions/previewing-model-name.js +10 -0
- package/src/functions/register-component.js +34 -28
- package/src/functions/register.js +8 -10
- package/src/functions/set-editor-settings.js +5 -7
- package/src/functions/set.js +10 -4
- package/src/functions/set.test.js +14 -14
- package/src/functions/track.js +6 -8
- package/src/index.js +18 -20
- package/src/scripts/init-editing.js +65 -31
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { expect, test } from
|
|
3
|
-
import { set } from
|
|
4
|
-
test(
|
|
5
|
-
const obj = { foo:
|
|
6
|
-
set(obj,
|
|
7
|
-
expect(obj.foo).toBe(
|
|
2
|
+
import { expect, test } from '@jest/globals';
|
|
3
|
+
import { set } from './set';
|
|
4
|
+
test('can shallow set a property', () => {
|
|
5
|
+
const obj = { foo: 'bar' };
|
|
6
|
+
set(obj, 'foo', 'baz');
|
|
7
|
+
expect(obj.foo).toBe('baz');
|
|
8
8
|
});
|
|
9
|
-
test(
|
|
10
|
-
const obj = { foo:
|
|
11
|
-
set(obj,
|
|
12
|
-
expect(obj.foo.bar).toBe(
|
|
9
|
+
test('can deeply set a property', () => {
|
|
10
|
+
const obj = { foo: 'bar' };
|
|
11
|
+
set(obj, 'foo.bar', 'baz');
|
|
12
|
+
expect(obj.foo.bar).toBe('baz');
|
|
13
13
|
});
|
|
14
|
-
test(
|
|
15
|
-
const obj = { foo:
|
|
16
|
-
set(obj,
|
|
17
|
-
expect(obj.foo.bar).toEqual([
|
|
14
|
+
test('can deeply create arrays', () => {
|
|
15
|
+
const obj = { foo: 'bar' };
|
|
16
|
+
set(obj, 'foo.bar.0', 'hi');
|
|
17
|
+
expect(obj.foo.bar).toEqual(['hi']);
|
|
18
18
|
});
|
package/src/functions/track.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { isBrowser } from
|
|
3
|
-
import { isReactNative } from
|
|
2
|
+
import { isBrowser } from './is-browser';
|
|
3
|
+
import { isReactNative } from './is-react-native';
|
|
4
4
|
function track(event, properties) {
|
|
5
5
|
if (!isBrowser() || isReactNative()) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
return fetch(`https://builder.io/api/v1/track`, {
|
|
9
|
-
method:
|
|
9
|
+
method: 'POST',
|
|
10
10
|
body: JSON.stringify({ events: [{ type: event, data: properties }] }),
|
|
11
11
|
headers: {
|
|
12
|
-
|
|
12
|
+
'content-type': 'application/json',
|
|
13
13
|
},
|
|
14
|
-
mode:
|
|
14
|
+
mode: 'cors',
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
export {
|
|
18
|
-
track
|
|
19
|
-
};
|
|
17
|
+
export { track };
|
package/src/index.js
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { isEditing } from
|
|
2
|
+
import { isEditing } from './functions/is-editing';
|
|
3
3
|
if (isEditing()) {
|
|
4
|
-
import(
|
|
4
|
+
import('./scripts/init-editing');
|
|
5
5
|
}
|
|
6
|
-
import { default as default2 } from
|
|
7
|
-
import { default as default3 } from
|
|
8
|
-
import { default as default4 } from
|
|
9
|
-
import { default as default5 } from
|
|
10
|
-
import { default as default6 } from
|
|
11
|
-
import { default as default7 } from
|
|
12
|
-
import { default as default8 } from
|
|
13
|
-
import { default as default9 } from
|
|
14
|
-
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from "./functions/get-content";
|
|
6
|
+
import { default as default2 } from './blocks/columns';
|
|
7
|
+
import { default as default3 } from './blocks/image';
|
|
8
|
+
import { default as default4 } from './blocks/text';
|
|
9
|
+
import { default as default5 } from './blocks/video';
|
|
10
|
+
import { default as default6 } from './blocks/symbol';
|
|
11
|
+
import { default as default7 } from './blocks/section';
|
|
12
|
+
import { default as default8 } from './blocks/fragment';
|
|
13
|
+
import { default as default9 } from './components/render-content';
|
|
14
|
+
export * from './functions/register-component';
|
|
15
|
+
export * from './functions/register';
|
|
16
|
+
export * from './functions/set-editor-settings';
|
|
17
|
+
export * from './functions/get-content';
|
|
19
18
|
export {
|
|
20
|
-
default7 as Button,
|
|
21
19
|
default2 as Columns,
|
|
22
|
-
|
|
20
|
+
default8 as Fragment,
|
|
23
21
|
default3 as Image,
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
default9 as RenderContent,
|
|
23
|
+
default7 as Section,
|
|
26
24
|
default6 as Symbol,
|
|
27
25
|
default4 as Text,
|
|
28
|
-
default5 as Video
|
|
26
|
+
default5 as Video,
|
|
29
27
|
};
|
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
var _a;
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
name: "_default",
|
|
3
|
+
import { isBrowser } from '../functions/is-browser';
|
|
4
|
+
import { register } from '../functions/register';
|
|
5
|
+
register('insertMenu', {
|
|
6
|
+
name: '_default',
|
|
8
7
|
default: true,
|
|
9
|
-
items: [
|
|
8
|
+
items: [
|
|
9
|
+
{ name: 'Box' },
|
|
10
|
+
{ name: 'Text' },
|
|
11
|
+
{ name: 'Image' },
|
|
12
|
+
{ name: 'Columns' },
|
|
13
|
+
...(true
|
|
14
|
+
? []
|
|
15
|
+
: [
|
|
16
|
+
{ name: 'Core:Section' },
|
|
17
|
+
{ name: 'Core:Button' },
|
|
18
|
+
{ name: 'Embed' },
|
|
19
|
+
{ name: 'Custom Code' },
|
|
20
|
+
]),
|
|
21
|
+
],
|
|
10
22
|
});
|
|
11
23
|
if (isBrowser()) {
|
|
12
|
-
(_a = window.parent) == null
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
(_a = window.parent) == null
|
|
25
|
+
? void 0
|
|
26
|
+
: _a.postMessage(
|
|
27
|
+
{
|
|
28
|
+
type: 'builder.sdkInfo',
|
|
29
|
+
data: {
|
|
30
|
+
target: 'reactNative',
|
|
31
|
+
supportsPatchUpdates: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
'*'
|
|
35
|
+
);
|
|
36
|
+
window.addEventListener('message', ({ data }) => {
|
|
20
37
|
var _a2, _b;
|
|
21
38
|
if (data) {
|
|
22
39
|
switch (data.type) {
|
|
23
|
-
case
|
|
40
|
+
case 'builder.evaluate': {
|
|
24
41
|
const text = data.data.text;
|
|
25
42
|
const args = data.data.arguments || [];
|
|
26
43
|
const id = data.data.id;
|
|
@@ -33,24 +50,41 @@ if (isBrowser()) {
|
|
|
33
50
|
error = err;
|
|
34
51
|
}
|
|
35
52
|
if (error) {
|
|
36
|
-
(_a2 = window.parent) == null
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
53
|
+
(_a2 = window.parent) == null
|
|
54
|
+
? void 0
|
|
55
|
+
: _a2.postMessage(
|
|
56
|
+
{
|
|
57
|
+
type: 'builder.evaluateError',
|
|
58
|
+
data: { id, error: error.message },
|
|
59
|
+
},
|
|
60
|
+
'*'
|
|
61
|
+
);
|
|
40
62
|
} else {
|
|
41
|
-
if (result && typeof result.then ===
|
|
42
|
-
result
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
if (result && typeof result.then === 'function') {
|
|
64
|
+
result
|
|
65
|
+
.then(finalResult => {
|
|
66
|
+
var _a3;
|
|
67
|
+
(_a3 = window.parent) == null
|
|
68
|
+
? void 0
|
|
69
|
+
: _a3.postMessage(
|
|
70
|
+
{
|
|
71
|
+
type: 'builder.evaluateResult',
|
|
72
|
+
data: { id, result: finalResult },
|
|
73
|
+
},
|
|
74
|
+
'*'
|
|
75
|
+
);
|
|
76
|
+
})
|
|
77
|
+
.catch(console.error);
|
|
49
78
|
} else {
|
|
50
|
-
(_b = window.parent) == null
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
79
|
+
(_b = window.parent) == null
|
|
80
|
+
? void 0
|
|
81
|
+
: _b.postMessage(
|
|
82
|
+
{
|
|
83
|
+
type: 'builder.evaluateResult',
|
|
84
|
+
data: { result, id },
|
|
85
|
+
},
|
|
86
|
+
'*'
|
|
87
|
+
);
|
|
54
88
|
}
|
|
55
89
|
}
|
|
56
90
|
break;
|