@builder.io/sdk-react-native 0.0.1-35 → 0.0.1-39
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.js +73 -22
- package/src/blocks/button.lite.tsx +4 -4
- package/src/blocks/columns.js +258 -36
- package/src/blocks/columns.lite.tsx +5 -6
- package/src/blocks/custom-code.js +76 -47
- package/src/blocks/custom-code.lite.tsx +12 -12
- package/src/blocks/embed.js +69 -47
- package/src/blocks/embed.lite.tsx +11 -11
- package/src/blocks/form.js +491 -195
- package/src/blocks/form.lite.tsx +49 -49
- package/src/blocks/fragment.js +16 -8
- package/src/blocks/fragment.lite.tsx +2 -3
- package/src/blocks/image.js +88 -80
- package/src/blocks/image.lite.tsx +15 -14
- package/src/blocks/img.js +51 -28
- package/src/blocks/img.lite.tsx +6 -7
- package/src/blocks/input.js +100 -28
- package/src/blocks/input.lite.tsx +4 -5
- package/src/blocks/raw-text.js +16 -12
- package/src/blocks/raw-text.lite.tsx +2 -3
- package/src/blocks/section.js +71 -23
- package/src/blocks/section.lite.tsx +3 -4
- package/src/blocks/select.js +78 -28
- package/src/blocks/select.lite.tsx +4 -5
- package/src/blocks/submit-button.js +47 -21
- package/src/blocks/submit-button.lite.tsx +2 -3
- package/src/blocks/symbol.js +18 -16
- package/src/blocks/symbol.lite.tsx +5 -5
- package/src/blocks/text.js +41 -26
- package/src/blocks/text.lite.tsx +3 -4
- package/src/blocks/textarea.js +60 -24
- package/src/blocks/textarea.lite.tsx +2 -3
- package/src/blocks/video.js +72 -60
- package/src/blocks/video.lite.tsx +5 -6
- package/src/components/block-styles.js +2 -4
- package/src/components/block-styles.lite.tsx +2 -3
- package/src/components/error-boundary.js +11 -9
- package/src/components/error-boundary.lite.tsx +2 -3
- package/src/components/render-block.js +107 -43
- package/src/components/render-block.lite.tsx +19 -15
- package/src/components/render-blocks.js +58 -32
- package/src/components/render-blocks.lite.tsx +10 -11
- package/src/components/render-content.js +124 -52
- package/src/components/render-content.lite.tsx +27 -27
- package/src/constants/device-sizes.js +8 -11
- package/src/context/builder.context.js +2 -4
- package/src/functions/evaluate.js +18 -9
- package/src/functions/event-handler-name.js +6 -0
- package/src/functions/get-block-actions.js +13 -13
- package/src/functions/get-block-component-options.js +16 -9
- package/src/functions/get-block-properties.js +19 -15
- package/src/functions/get-block-styles.js +34 -17
- package/src/functions/get-block-tag.js +2 -4
- package/src/functions/get-content.js +48 -26
- package/src/functions/get-content.test.js +37 -26
- package/src/functions/get-fetch.js +5 -7
- package/src/functions/get-global-this.js +5 -7
- package/src/functions/get-processed-block.js +19 -13
- package/src/functions/get-processed-block.test.js +18 -14
- package/src/functions/get-target.js +2 -4
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +7 -5
- package/src/functions/is-editing.js +5 -5
- package/src/functions/is-iframe.js +2 -4
- package/src/functions/is-previewing.js +4 -6
- 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 +3 -5
- package/src/functions/register-component.js +38 -27
- package/src/functions/register.js +8 -10
- package/src/functions/set-editor-settings.js +5 -7
- package/src/functions/set.js +14 -5
- package/src/functions/set.test.js +14 -14
- package/src/functions/track.js +6 -8
- package/src/functions/transform-block.js +40 -0
- package/src/index.js +23 -18
- package/src/scripts/init-editing.js +64 -40
- package/src/package.json +0 -18
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-39",
|
|
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"
|
package/src/blocks/button.js
CHANGED
|
@@ -1,35 +1,86 @@
|
|
|
1
1
|
import { registerComponent } from '../functions/register-component';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
4
|
var __defProps = Object.defineProperties;
|
|
5
5
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
6
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) =>
|
|
9
|
+
var __defNormalProp = (obj, key, value) =>
|
|
10
|
+
key in obj
|
|
11
|
+
? __defProp(obj, key, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value,
|
|
16
|
+
})
|
|
17
|
+
: (obj[key] = value);
|
|
10
18
|
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
19
|
+
for (var prop in b || (b = {}))
|
|
20
|
+
if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
21
|
+
if (__getOwnPropSymbols)
|
|
22
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
23
|
+
if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
20
26
|
};
|
|
21
27
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
import * as React from
|
|
23
|
-
import { View, Text } from
|
|
28
|
+
import * as React from 'react';
|
|
29
|
+
import { View, Text } from 'react-native';
|
|
24
30
|
function Button(props) {
|
|
25
|
-
return /* @__PURE__ */ React.createElement(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
return /* @__PURE__ */ React.createElement(
|
|
32
|
+
React.Fragment,
|
|
33
|
+
null,
|
|
34
|
+
props.link
|
|
35
|
+
? /* @__PURE__ */ React.createElement(
|
|
36
|
+
React.Fragment,
|
|
37
|
+
null,
|
|
38
|
+
/* @__PURE__ */ React.createElement(
|
|
39
|
+
View,
|
|
40
|
+
__spreadProps(__spreadValues({}, props.attributes), {
|
|
41
|
+
role: 'button',
|
|
42
|
+
href: props.link,
|
|
43
|
+
target: props.openLinkInNewTab ? '_blank' : void 0,
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ React.createElement(Text, null, props.text)
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
: /* @__PURE__ */ React.createElement(
|
|
49
|
+
View,
|
|
50
|
+
__spreadValues({}, props.attributes),
|
|
51
|
+
/* @__PURE__ */ React.createElement(Text, null, props.text)
|
|
52
|
+
)
|
|
53
|
+
);
|
|
29
54
|
}
|
|
30
|
-
export {
|
|
31
|
-
Button as default
|
|
32
|
-
};
|
|
33
|
-
|
|
55
|
+
export { Button as default };
|
|
34
56
|
|
|
35
|
-
|
|
57
|
+
registerComponent(Button, {
|
|
58
|
+
name: 'Core:Button',
|
|
59
|
+
builtIn: true,
|
|
60
|
+
image:
|
|
61
|
+
'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13',
|
|
62
|
+
defaultStyles: {
|
|
63
|
+
appearance: 'none',
|
|
64
|
+
paddingTop: '15px',
|
|
65
|
+
paddingBottom: '15px',
|
|
66
|
+
paddingLeft: '25px',
|
|
67
|
+
paddingRight: '25px',
|
|
68
|
+
backgroundColor: '#000000',
|
|
69
|
+
color: 'white',
|
|
70
|
+
borderRadius: '4px',
|
|
71
|
+
textAlign: 'center',
|
|
72
|
+
cursor: 'pointer',
|
|
73
|
+
},
|
|
74
|
+
inputs: [
|
|
75
|
+
{ name: 'text', type: 'text', defaultValue: 'Click me!', bubble: true },
|
|
76
|
+
{ name: 'link', type: 'url', bubble: true },
|
|
77
|
+
{
|
|
78
|
+
name: 'openLinkInNewTab',
|
|
79
|
+
type: 'boolean',
|
|
80
|
+
defaultValue: false,
|
|
81
|
+
friendlyName: 'Open link in new tab',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
static: true,
|
|
85
|
+
noWrap: true,
|
|
86
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
3
|
-
import { useContext } from "react";
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet, Image, Text } from 'react-native';
|
|
4
3
|
|
|
5
4
|
export default function Button(props) {
|
|
6
5
|
return (
|
|
@@ -9,8 +8,9 @@ export default function Button(props) {
|
|
|
9
8
|
<>
|
|
10
9
|
<View
|
|
11
10
|
{...props.attributes}
|
|
11
|
+
role="button"
|
|
12
12
|
href={props.link}
|
|
13
|
-
target={props.openLinkInNewTab ?
|
|
13
|
+
target={props.openLinkInNewTab ? '_blank' : undefined}
|
|
14
14
|
>
|
|
15
15
|
<Text>{props.text}</Text>
|
|
16
16
|
</View>
|
package/src/blocks/columns.js
CHANGED
|
@@ -1,43 +1,265 @@
|
|
|
1
1
|
import { registerComponent } from '../functions/register-component';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { View, StyleSheet } from
|
|
5
|
-
import RenderBlocks from
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { View, StyleSheet } from 'react-native';
|
|
5
|
+
import RenderBlocks from '../components/render-blocks';
|
|
6
6
|
function Columns(props) {
|
|
7
|
-
var _a;
|
|
8
|
-
function getGutterSize() {
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
function getColumns() {
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
function getWidth(index) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
function getColumnCssWidth(index) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
return /* @__PURE__ */ React.createElement(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
const columns = this.getColumns();
|
|
16
|
+
return (columns[index] && columns[index].width) || 100 / columns.length;
|
|
17
|
+
}
|
|
18
|
+
function getColumnCssWidth(index) {
|
|
19
|
+
const columns = this.getColumns();
|
|
20
|
+
const gutterSize = this.getGutterSize();
|
|
21
|
+
const subtractWidth = (gutterSize * (columns.length - 1)) / columns.length;
|
|
22
|
+
return `calc(${this.getWidth(index)}% - ${subtractWidth}px)`;
|
|
23
|
+
}
|
|
24
|
+
return /* @__PURE__ */ React.createElement(
|
|
25
|
+
View,
|
|
26
|
+
{
|
|
27
|
+
className: 'builder-columns',
|
|
28
|
+
style: styles.view1,
|
|
29
|
+
},
|
|
30
|
+
(_a = props.columns) == null
|
|
31
|
+
? void 0
|
|
32
|
+
: _a.map((column) =>
|
|
33
|
+
/* @__PURE__ */ React.createElement(
|
|
34
|
+
View,
|
|
35
|
+
{
|
|
36
|
+
className: 'builder-column',
|
|
37
|
+
style: styles.view2,
|
|
38
|
+
},
|
|
39
|
+
/* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
40
|
+
blocks: column.blocks,
|
|
41
|
+
})
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
);
|
|
33
45
|
}
|
|
34
46
|
const styles = StyleSheet.create({
|
|
35
|
-
view1: { display:
|
|
36
|
-
view2: { flexGrow: 1 }
|
|
47
|
+
view1: { display: 'flex', alignItems: 'stretch' },
|
|
48
|
+
view2: { flexGrow: 1 },
|
|
37
49
|
});
|
|
38
|
-
export {
|
|
39
|
-
Columns as default
|
|
40
|
-
};
|
|
41
|
-
|
|
50
|
+
export { Columns as default };
|
|
42
51
|
|
|
43
|
-
|
|
52
|
+
registerComponent(Columns, {
|
|
53
|
+
name: 'Columns',
|
|
54
|
+
builtIn: true,
|
|
55
|
+
inputs: [
|
|
56
|
+
{
|
|
57
|
+
name: 'columns',
|
|
58
|
+
type: 'array',
|
|
59
|
+
broadcast: true,
|
|
60
|
+
subFields: [
|
|
61
|
+
{
|
|
62
|
+
name: 'blocks',
|
|
63
|
+
type: 'array',
|
|
64
|
+
hideFromUI: true,
|
|
65
|
+
defaultValue: [
|
|
66
|
+
{
|
|
67
|
+
'@type': '@builder.io/sdk:Element',
|
|
68
|
+
responsiveStyles: {
|
|
69
|
+
large: {
|
|
70
|
+
display: 'flex',
|
|
71
|
+
flexDirection: 'column',
|
|
72
|
+
alignItems: 'stretch',
|
|
73
|
+
flexShrink: '0',
|
|
74
|
+
position: 'relative',
|
|
75
|
+
marginTop: '30px',
|
|
76
|
+
textAlign: 'center',
|
|
77
|
+
lineHeight: 'normal',
|
|
78
|
+
height: 'auto',
|
|
79
|
+
minHeight: '20px',
|
|
80
|
+
minWidth: '20px',
|
|
81
|
+
overflow: 'hidden',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
component: {
|
|
85
|
+
name: 'Image',
|
|
86
|
+
options: {
|
|
87
|
+
image:
|
|
88
|
+
'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
|
|
89
|
+
backgroundPosition: 'center',
|
|
90
|
+
backgroundSize: 'cover',
|
|
91
|
+
aspectRatio: 0.7004048582995948,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
'@type': '@builder.io/sdk:Element',
|
|
97
|
+
responsiveStyles: {
|
|
98
|
+
large: {
|
|
99
|
+
display: 'flex',
|
|
100
|
+
flexDirection: 'column',
|
|
101
|
+
alignItems: 'stretch',
|
|
102
|
+
flexShrink: '0',
|
|
103
|
+
position: 'relative',
|
|
104
|
+
marginTop: '30px',
|
|
105
|
+
textAlign: 'center',
|
|
106
|
+
lineHeight: 'normal',
|
|
107
|
+
height: 'auto',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
component: {
|
|
111
|
+
name: 'Text',
|
|
112
|
+
options: { text: '<p>Enter some text...</p>' },
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'width',
|
|
119
|
+
type: 'number',
|
|
120
|
+
hideFromUI: true,
|
|
121
|
+
helperText: 'Width %, e.g. set to 50 to fill half of the space',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: 'link',
|
|
125
|
+
type: 'url',
|
|
126
|
+
helperText:
|
|
127
|
+
'Optionally set a url that clicking this column will link to',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
defaultValue: [
|
|
131
|
+
{
|
|
132
|
+
blocks: [
|
|
133
|
+
{
|
|
134
|
+
'@type': '@builder.io/sdk:Element',
|
|
135
|
+
responsiveStyles: {
|
|
136
|
+
large: {
|
|
137
|
+
display: 'flex',
|
|
138
|
+
flexDirection: 'column',
|
|
139
|
+
alignItems: 'stretch',
|
|
140
|
+
flexShrink: '0',
|
|
141
|
+
position: 'relative',
|
|
142
|
+
marginTop: '30px',
|
|
143
|
+
textAlign: 'center',
|
|
144
|
+
lineHeight: 'normal',
|
|
145
|
+
height: 'auto',
|
|
146
|
+
minHeight: '20px',
|
|
147
|
+
minWidth: '20px',
|
|
148
|
+
overflow: 'hidden',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
component: {
|
|
152
|
+
name: 'Image',
|
|
153
|
+
options: {
|
|
154
|
+
image:
|
|
155
|
+
'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
|
|
156
|
+
backgroundPosition: 'center',
|
|
157
|
+
backgroundSize: 'cover',
|
|
158
|
+
aspectRatio: 0.7004048582995948,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
'@type': '@builder.io/sdk:Element',
|
|
164
|
+
responsiveStyles: {
|
|
165
|
+
large: {
|
|
166
|
+
display: 'flex',
|
|
167
|
+
flexDirection: 'column',
|
|
168
|
+
alignItems: 'stretch',
|
|
169
|
+
flexShrink: '0',
|
|
170
|
+
position: 'relative',
|
|
171
|
+
marginTop: '30px',
|
|
172
|
+
textAlign: 'center',
|
|
173
|
+
lineHeight: 'normal',
|
|
174
|
+
height: 'auto',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
component: {
|
|
178
|
+
name: 'Text',
|
|
179
|
+
options: { text: '<p>Enter some text...</p>' },
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
blocks: [
|
|
186
|
+
{
|
|
187
|
+
'@type': '@builder.io/sdk:Element',
|
|
188
|
+
responsiveStyles: {
|
|
189
|
+
large: {
|
|
190
|
+
display: 'flex',
|
|
191
|
+
flexDirection: 'column',
|
|
192
|
+
alignItems: 'stretch',
|
|
193
|
+
flexShrink: '0',
|
|
194
|
+
position: 'relative',
|
|
195
|
+
marginTop: '30px',
|
|
196
|
+
textAlign: 'center',
|
|
197
|
+
lineHeight: 'normal',
|
|
198
|
+
height: 'auto',
|
|
199
|
+
minHeight: '20px',
|
|
200
|
+
minWidth: '20px',
|
|
201
|
+
overflow: 'hidden',
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
component: {
|
|
205
|
+
name: 'Image',
|
|
206
|
+
options: {
|
|
207
|
+
image:
|
|
208
|
+
'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
|
|
209
|
+
backgroundPosition: 'center',
|
|
210
|
+
backgroundSize: 'cover',
|
|
211
|
+
aspectRatio: 0.7004048582995948,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
'@type': '@builder.io/sdk:Element',
|
|
217
|
+
responsiveStyles: {
|
|
218
|
+
large: {
|
|
219
|
+
display: 'flex',
|
|
220
|
+
flexDirection: 'column',
|
|
221
|
+
alignItems: 'stretch',
|
|
222
|
+
flexShrink: '0',
|
|
223
|
+
position: 'relative',
|
|
224
|
+
marginTop: '30px',
|
|
225
|
+
textAlign: 'center',
|
|
226
|
+
lineHeight: 'normal',
|
|
227
|
+
height: 'auto',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
component: {
|
|
231
|
+
name: 'Text',
|
|
232
|
+
options: { text: '<p>Enter some text...</p>' },
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
|
+
onChange:
|
|
239
|
+
" 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(); } } } } ",
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: 'space',
|
|
243
|
+
type: 'number',
|
|
244
|
+
defaultValue: 20,
|
|
245
|
+
helperText: 'Size of gap between columns',
|
|
246
|
+
advanced: true,
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: 'stackColumnsAt',
|
|
250
|
+
type: 'string',
|
|
251
|
+
defaultValue: 'tablet',
|
|
252
|
+
helperText: 'Convert horizontal columns to vertical at what device size',
|
|
253
|
+
enum: ['tablet', 'mobile', 'never'],
|
|
254
|
+
advanced: true,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: 'reverseColumnsWhenStacked',
|
|
258
|
+
type: 'boolean',
|
|
259
|
+
defaultValue: false,
|
|
260
|
+
helperText:
|
|
261
|
+
'When stacking columns for mobile devices, reverse the ordering',
|
|
262
|
+
advanced: true,
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
3
|
-
import
|
|
4
|
-
import RenderBlocks from "../components/render-blocks.lite";
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet, Image, Text } from 'react-native';
|
|
3
|
+
import RenderBlocks from '../components/render-blocks.lite';
|
|
5
4
|
|
|
6
5
|
export default function Columns(props) {
|
|
7
6
|
function getGutterSize() {
|
|
8
|
-
return typeof props.space ===
|
|
7
|
+
return typeof props.space === 'number' ? props.space || 0 : 20;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
function getColumns() {
|
|
@@ -36,6 +35,6 @@ export default function Columns(props) {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
const styles = StyleSheet.create({
|
|
39
|
-
view1: { display:
|
|
38
|
+
view1: { display: 'flex', alignItems: 'stretch' },
|
|
40
39
|
view2: { flexGrow: 1 },
|
|
41
40
|
});
|
|
@@ -1,56 +1,85 @@
|
|
|
1
1
|
import { registerComponent } from '../functions/register-component';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { View } from
|
|
5
|
-
import { useState, useRef, useEffect } from
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { useState, useRef, useEffect } from 'react';
|
|
6
6
|
function CustomCode(props) {
|
|
7
|
-
const [scriptsInserted, setScriptsInserted] = useState(() => []);
|
|
8
|
-
const [scriptsRun, setScriptsRun] = useState(() => []);
|
|
9
|
-
function findAndRunScripts() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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 (
|
|
24
|
+
!script.type ||
|
|
25
|
+
[
|
|
26
|
+
'text/javascript',
|
|
27
|
+
'application/javascript',
|
|
28
|
+
'application/ecmascript',
|
|
29
|
+
].includes(script.type)
|
|
30
|
+
) {
|
|
31
|
+
if (scriptsRun.includes(script.innerText)) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
scriptsRun.push(script.innerText);
|
|
36
|
+
new Function(script.innerText)();
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.warn('`CustomCode`: Error running script:', error);
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
}
|
|
44
|
+
const elem = useRef();
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
findAndRunScripts();
|
|
47
|
+
}, []);
|
|
48
|
+
return /* @__PURE__ */ React.createElement(View, {
|
|
49
|
+
ref: elem,
|
|
50
|
+
className:
|
|
51
|
+
'builder-custom-code' + (props.replaceNodes ? ' replace-nodes' : ''),
|
|
52
|
+
dangerouslySetInnerHTML: { __html: 'props.code' },
|
|
53
|
+
});
|
|
40
54
|
}
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
findAndRunScripts();
|
|
44
|
-
}, []);
|
|
45
|
-
return /* @__PURE__ */ React.createElement(View, {
|
|
46
|
-
ref: elem,
|
|
47
|
-
className: "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""),
|
|
48
|
-
dangerouslySetInnerHTML: { __html: "props.code" }
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
CustomCode as default
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
+
export { CustomCode as default };
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
registerComponent(CustomCode, {
|
|
58
|
+
name: 'Custom Code',
|
|
59
|
+
static: true,
|
|
60
|
+
builtIn: true,
|
|
61
|
+
requiredPermissions: ['editCode'],
|
|
62
|
+
inputs: [
|
|
63
|
+
{
|
|
64
|
+
name: 'code',
|
|
65
|
+
type: 'html',
|
|
66
|
+
required: true,
|
|
67
|
+
defaultValue: '<p>Hello there, I am custom HTML code!</p>',
|
|
68
|
+
code: true,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'replaceNodes',
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
helperText: 'Preserve server rendered dom nodes',
|
|
74
|
+
advanced: true,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'scriptsClientOnly',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
defaultValue: false,
|
|
80
|
+
helperText:
|
|
81
|
+
'Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads',
|
|
82
|
+
advanced: true,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
});
|