@builder.io/sdk-react-native 0.0.1-4 → 0.0.1-49
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 +13 -0
- package/README.md +15 -0
- package/package.json +6 -4
- package/src/blocks/button.js +73 -24
- package/src/blocks/button.lite.tsx +10 -14
- package/src/blocks/columns.js +286 -40
- package/src/blocks/columns.lite.tsx +43 -20
- package/src/blocks/custom-code.js +74 -47
- package/src/blocks/custom-code.lite.tsx +11 -19
- package/src/blocks/embed.js +68 -47
- package/src/blocks/embed.lite.tsx +11 -15
- package/src/blocks/form.js +490 -198
- package/src/blocks/form.lite.tsx +54 -58
- package/src/blocks/fragment.js +21 -0
- package/src/blocks/fragment.lite.tsx +10 -0
- package/src/blocks/image.js +125 -83
- package/src/blocks/image.lite.tsx +46 -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 -7
- package/src/blocks/raw-text.js +12 -12
- package/src/blocks/raw-text.lite.tsx +3 -9
- package/src/blocks/section.js +71 -23
- package/src/blocks/section.lite.tsx +4 -5
- package/src/blocks/select.js +78 -27
- package/src/blocks/select.lite.tsx +8 -9
- package/src/blocks/submit-button.js +47 -21
- package/src/blocks/submit-button.lite.tsx +3 -4
- package/src/blocks/symbol.js +16 -16
- package/src/blocks/symbol.lite.tsx +6 -6
- package/src/blocks/text.js +85 -16
- package/src/blocks/text.lite.tsx +3 -9
- package/src/blocks/textarea.js +60 -24
- package/src/blocks/textarea.lite.tsx +2 -3
- package/src/blocks/video.js +97 -46
- package/src/blocks/video.lite.tsx +5 -6
- package/src/components/block-styles.js +5 -0
- package/src/components/block-styles.lite.tsx +6 -0
- package/src/components/error-boundary.js +27 -0
- package/src/components/error-boundary.lite.tsx +6 -0
- package/src/components/render-block.js +119 -39
- package/src/components/render-block.lite.tsx +76 -36
- package/src/components/render-blocks.js +65 -32
- package/src/components/render-blocks.lite.tsx +25 -16
- package/src/components/render-content.js +190 -36
- package/src/components/render-content.lite.tsx +143 -32
- 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 +27 -4
- package/src/functions/get-block-properties.js +23 -16
- package/src/functions/get-block-styles.js +56 -9
- package/src/functions/get-block-tag.js +2 -4
- package/src/functions/get-builder-search-params/fn.test.js +18 -0
- package/src/functions/get-builder-search-params/index.js +20 -0
- package/src/functions/get-content/fn.test.js +34 -0
- package/src/functions/get-content/index.js +156 -0
- package/src/functions/get-fetch.js +11 -0
- package/src/functions/get-global-this.js +17 -0
- package/src/functions/get-processed-block.js +19 -13
- package/src/functions/get-processed-block.test.js +32 -16
- package/src/functions/get-target.js +3 -5
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +2 -5
- package/src/functions/is-editing.js +5 -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 +39 -27
- package/src/functions/register.js +28 -0
- package/src/functions/set-editor-settings.js +14 -0
- package/src/functions/set.js +14 -5
- package/src/functions/set.test.js +14 -14
- package/src/functions/track.js +7 -9
- package/src/functions/transform-block.js +42 -0
- package/src/index-helpers/blocks-exports.js +19 -0
- package/src/index-helpers/top-of-file.js +2 -0
- package/src/index.js +10 -21
- package/src/scripts/init-editing.js +67 -29
- package/src/types/deep-partial.js +1 -0
- package/index.js +0 -11
- package/src/functions/get-content.js +0 -103
- package/src/package.json +0 -18
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View } from
|
|
3
|
-
import { useState, useEffect } from
|
|
4
|
-
import { isBrowser } from
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, Text } from 'react-native';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { isBrowser } from '../functions/is-browser';
|
|
5
|
+
import BuilderContext from '../context/builder.context';
|
|
6
|
+
import { track } from '../functions/track';
|
|
7
|
+
import { isReactNative } from '../functions/is-react-native';
|
|
8
|
+
import { isEditing } from '../functions/is-editing';
|
|
9
|
+
import { isPreviewing } from '../functions/is-previewing';
|
|
10
|
+
import { previewingModelName } from '../functions/previewing-model-name';
|
|
11
|
+
import { getContent } from '../functions/get-content';
|
|
12
|
+
import {
|
|
13
|
+
convertSearchParamsToQueryObject,
|
|
14
|
+
getBuilderSearchParams,
|
|
15
|
+
} from '../functions/get-builder-search-params';
|
|
16
|
+
import RenderBlocks from './render-blocks';
|
|
8
17
|
function RenderContent(props) {
|
|
9
|
-
var _a, _b, _c, _d, _e;
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10
19
|
function useContent() {
|
|
11
20
|
return overrideContent || props.content;
|
|
12
21
|
}
|
|
@@ -14,19 +23,78 @@ function RenderContent(props) {
|
|
|
14
23
|
const [state, setState] = useState(() => ({}));
|
|
15
24
|
const [context, setContext] = useState(() => ({}));
|
|
16
25
|
const [overrideContent, setOverrideContent] = useState(() => null);
|
|
26
|
+
function getCssFromFont(font, data) {
|
|
27
|
+
var _a2, _b2;
|
|
28
|
+
const family =
|
|
29
|
+
font.family +
|
|
30
|
+
(font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
|
|
31
|
+
const name = family.split(',')[0];
|
|
32
|
+
const url =
|
|
33
|
+
(_b2 = font.fileUrl) != null
|
|
34
|
+
? _b2
|
|
35
|
+
: (_a2 = font == null ? void 0 : font.files) == null
|
|
36
|
+
? void 0
|
|
37
|
+
: _a2.regular;
|
|
38
|
+
let str = '';
|
|
39
|
+
if (url && family && name) {
|
|
40
|
+
str += `
|
|
41
|
+
@font-face {
|
|
42
|
+
font-family: "${family}";
|
|
43
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
44
|
+
font-display: fallback;
|
|
45
|
+
font-weight: 400;
|
|
46
|
+
}
|
|
47
|
+
`.trim();
|
|
48
|
+
}
|
|
49
|
+
if (font.files) {
|
|
50
|
+
for (const weight in font.files) {
|
|
51
|
+
const isNumber = String(Number(weight)) === weight;
|
|
52
|
+
if (!isNumber) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const weightUrl = font.files[weight];
|
|
56
|
+
if (weightUrl && weightUrl !== url) {
|
|
57
|
+
str += `
|
|
58
|
+
@font-face {
|
|
59
|
+
font-family: "${family}";
|
|
60
|
+
src: url('${weightUrl}') format('woff2');
|
|
61
|
+
font-display: fallback;
|
|
62
|
+
font-weight: ${weight};
|
|
63
|
+
}
|
|
64
|
+
`.trim();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return str;
|
|
69
|
+
}
|
|
70
|
+
function getFontCss(data) {
|
|
71
|
+
var _a2, _b2;
|
|
72
|
+
return (
|
|
73
|
+
((_b2 =
|
|
74
|
+
(_a2 = data == null ? void 0 : data.customFonts) == null
|
|
75
|
+
? void 0
|
|
76
|
+
: _a2.map((font) => getCssFromFont(font, data))) == null
|
|
77
|
+
? void 0
|
|
78
|
+
: _b2.join(' ')) || ''
|
|
79
|
+
);
|
|
80
|
+
}
|
|
17
81
|
function processMessage(event) {
|
|
18
82
|
const { data } = event;
|
|
19
83
|
if (data) {
|
|
20
84
|
switch (data.type) {
|
|
21
|
-
case
|
|
22
|
-
const key =
|
|
85
|
+
case 'builder.contentUpdate': {
|
|
86
|
+
const key =
|
|
87
|
+
data.data.key ||
|
|
88
|
+
data.data.alias ||
|
|
89
|
+
data.data.entry ||
|
|
90
|
+
data.data.modelName;
|
|
23
91
|
const contentData = data.data.data;
|
|
24
92
|
if (key === props.model) {
|
|
25
93
|
setOverrideContent(contentData);
|
|
26
94
|
}
|
|
27
95
|
break;
|
|
28
96
|
}
|
|
29
|
-
case
|
|
97
|
+
case 'builder.patchUpdates': {
|
|
30
98
|
break;
|
|
31
99
|
}
|
|
32
100
|
}
|
|
@@ -34,33 +102,119 @@ function RenderContent(props) {
|
|
|
34
102
|
}
|
|
35
103
|
useEffect(() => {
|
|
36
104
|
if (isBrowser()) {
|
|
37
|
-
|
|
105
|
+
if (isEditing()) {
|
|
106
|
+
window.addEventListener('message', processMessage);
|
|
107
|
+
}
|
|
108
|
+
if (useContent() && !isEditing()) {
|
|
109
|
+
track('impression', {
|
|
110
|
+
contentId: useContent().id,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (isPreviewing()) {
|
|
114
|
+
if (props.model && previewingModelName() === props.model) {
|
|
115
|
+
const currentUrl = new URL(location.href);
|
|
116
|
+
const apiKey = currentUrl.searchParams.get('apiKey');
|
|
117
|
+
if (apiKey) {
|
|
118
|
+
getContent({
|
|
119
|
+
model: props.model,
|
|
120
|
+
apiKey,
|
|
121
|
+
options: getBuilderSearchParams(
|
|
122
|
+
convertSearchParamsToQueryObject(currentUrl.searchParams)
|
|
123
|
+
),
|
|
124
|
+
}).then((content) => {
|
|
125
|
+
if (content) {
|
|
126
|
+
setOverrideContent(content);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
38
132
|
}
|
|
39
133
|
}, []);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
get state() {
|
|
46
|
-
return state;
|
|
47
|
-
},
|
|
48
|
-
get context() {
|
|
49
|
-
return context;
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
return () => {
|
|
136
|
+
if (isBrowser()) {
|
|
137
|
+
window.removeEventListener('message', processMessage);
|
|
50
138
|
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
139
|
+
};
|
|
140
|
+
}, []);
|
|
141
|
+
return /* @__PURE__ */ React.createElement(
|
|
142
|
+
BuilderContext.Provider,
|
|
143
|
+
{
|
|
144
|
+
value: {
|
|
145
|
+
get content() {
|
|
146
|
+
return useContent();
|
|
147
|
+
},
|
|
148
|
+
get state() {
|
|
149
|
+
return state;
|
|
150
|
+
},
|
|
151
|
+
get context() {
|
|
152
|
+
return context;
|
|
153
|
+
},
|
|
154
|
+
},
|
|
57
155
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
156
|
+
useContent()
|
|
157
|
+
? /* @__PURE__ */ React.createElement(
|
|
158
|
+
React.Fragment,
|
|
159
|
+
null,
|
|
160
|
+
/* @__PURE__ */ React.createElement(
|
|
161
|
+
View,
|
|
162
|
+
{
|
|
163
|
+
onClick: (event) => {
|
|
164
|
+
if (!isEditing()) {
|
|
165
|
+
track('click', {
|
|
166
|
+
contentId: useContent().id,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
'data-builder-content-id':
|
|
171
|
+
(_a = useContent == null ? void 0 : useContent()) == null
|
|
172
|
+
? void 0
|
|
173
|
+
: _a.id,
|
|
174
|
+
},
|
|
175
|
+
(((_c =
|
|
176
|
+
(_b = useContent == null ? void 0 : useContent()) == null
|
|
177
|
+
? void 0
|
|
178
|
+
: _b.data) == null
|
|
179
|
+
? void 0
|
|
180
|
+
: _c.cssCode) ||
|
|
181
|
+
((_f =
|
|
182
|
+
(_e =
|
|
183
|
+
(_d = useContent == null ? void 0 : useContent()) == null
|
|
184
|
+
? void 0
|
|
185
|
+
: _d.data) == null
|
|
186
|
+
? void 0
|
|
187
|
+
: _e.customFonts) == null
|
|
188
|
+
? void 0
|
|
189
|
+
: _f.length)) &&
|
|
190
|
+
!isReactNative()
|
|
191
|
+
? /* @__PURE__ */ React.createElement(
|
|
192
|
+
View,
|
|
193
|
+
null,
|
|
194
|
+
/* @__PURE__ */ React.createElement(
|
|
195
|
+
Text,
|
|
196
|
+
null,
|
|
197
|
+
useContent().data.cssCode
|
|
198
|
+
),
|
|
199
|
+
/* @__PURE__ */ React.createElement(
|
|
200
|
+
Text,
|
|
201
|
+
null,
|
|
202
|
+
getFontCss(useContent().data)
|
|
203
|
+
)
|
|
204
|
+
)
|
|
205
|
+
: null,
|
|
206
|
+
/* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
207
|
+
blocks:
|
|
208
|
+
(_h =
|
|
209
|
+
(_g = useContent == null ? void 0 : useContent()) == null
|
|
210
|
+
? void 0
|
|
211
|
+
: _g.data) == null
|
|
212
|
+
? void 0
|
|
213
|
+
: _h.blocks,
|
|
214
|
+
})
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
: null
|
|
218
|
+
);
|
|
63
219
|
}
|
|
64
|
-
export {
|
|
65
|
-
RenderContent as default
|
|
66
|
-
};
|
|
220
|
+
export { RenderContent as default };
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
3
|
-
import { useState, useContext, useEffect } from
|
|
4
|
-
import { isBrowser } from
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet, Image, Text } from 'react-native';
|
|
3
|
+
import { useState, useContext, useEffect } from 'react';
|
|
4
|
+
import { isBrowser } from '../functions/is-browser';
|
|
5
|
+
import BuilderContext from '../context/builder.context.lite';
|
|
6
|
+
import { track } from '../functions/track';
|
|
7
|
+
import { ifTarget } from '../functions/if-target';
|
|
8
|
+
import { onChange } from '../functions/on-change';
|
|
9
|
+
import { isReactNative } from '../functions/is-react-native';
|
|
10
|
+
import { isEditing } from '../functions/is-editing';
|
|
11
|
+
import { isPreviewing } from '../functions/is-previewing';
|
|
12
|
+
import { previewingModelName } from '../functions/previewing-model-name';
|
|
13
|
+
import { getContent } from '../functions/get-content';
|
|
14
|
+
import {
|
|
15
|
+
convertSearchParamsToQueryObject,
|
|
16
|
+
getBuilderSearchParams,
|
|
17
|
+
} from '../functions/get-builder-search-params';
|
|
18
|
+
import RenderBlocks from './render-blocks.lite';
|
|
10
19
|
|
|
11
20
|
export default function RenderContent(props) {
|
|
12
21
|
function useContent() {
|
|
@@ -21,12 +30,70 @@ export default function RenderContent(props) {
|
|
|
21
30
|
|
|
22
31
|
const [overrideContent, setOverrideContent] = useState(() => null);
|
|
23
32
|
|
|
33
|
+
function getCssFromFont(font, data) {
|
|
34
|
+
// TODO: compute what font sizes are used and only load those.......
|
|
35
|
+
const family =
|
|
36
|
+
font.family +
|
|
37
|
+
(font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
|
|
38
|
+
const name = family.split(',')[0];
|
|
39
|
+
const url = font.fileUrl ?? font?.files?.regular;
|
|
40
|
+
let str = '';
|
|
41
|
+
|
|
42
|
+
if (url && family && name) {
|
|
43
|
+
str += `
|
|
44
|
+
@font-face {
|
|
45
|
+
font-family: "${family}";
|
|
46
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
47
|
+
font-display: fallback;
|
|
48
|
+
font-weight: 400;
|
|
49
|
+
}
|
|
50
|
+
`.trim();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (font.files) {
|
|
54
|
+
for (const weight in font.files) {
|
|
55
|
+
const isNumber = String(Number(weight)) === weight;
|
|
56
|
+
|
|
57
|
+
if (!isNumber) {
|
|
58
|
+
continue;
|
|
59
|
+
} // TODO: maybe limit number loaded
|
|
60
|
+
|
|
61
|
+
const weightUrl = font.files[weight];
|
|
62
|
+
|
|
63
|
+
if (weightUrl && weightUrl !== url) {
|
|
64
|
+
str += `
|
|
65
|
+
@font-face {
|
|
66
|
+
font-family: "${family}";
|
|
67
|
+
src: url('${weightUrl}') format('woff2');
|
|
68
|
+
font-display: fallback;
|
|
69
|
+
font-weight: ${weight};
|
|
70
|
+
}
|
|
71
|
+
`.trim();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return str;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getFontCss(data) {
|
|
80
|
+
// TODO: flag for this
|
|
81
|
+
// if (!builder.allowCustomFonts) {
|
|
82
|
+
// return '';
|
|
83
|
+
// }
|
|
84
|
+
// TODO: separate internal data from external
|
|
85
|
+
return (
|
|
86
|
+
data?.customFonts?.map((font) => getCssFromFont(font, data))?.join(' ') ||
|
|
87
|
+
''
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
24
91
|
function processMessage(event) {
|
|
25
92
|
const { data } = event;
|
|
26
93
|
|
|
27
94
|
if (data) {
|
|
28
95
|
switch (data.type) {
|
|
29
|
-
case
|
|
96
|
+
case 'builder.contentUpdate': {
|
|
30
97
|
const key =
|
|
31
98
|
data.data.key ||
|
|
32
99
|
data.data.alias ||
|
|
@@ -41,7 +108,7 @@ export default function RenderContent(props) {
|
|
|
41
108
|
break;
|
|
42
109
|
}
|
|
43
110
|
|
|
44
|
-
case
|
|
111
|
+
case 'builder.patchUpdates': {
|
|
45
112
|
// TODO
|
|
46
113
|
break;
|
|
47
114
|
}
|
|
@@ -51,18 +118,52 @@ export default function RenderContent(props) {
|
|
|
51
118
|
|
|
52
119
|
useEffect(() => {
|
|
53
120
|
if (isBrowser()) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
121
|
+
if (isEditing()) {
|
|
122
|
+
window.addEventListener('message', processMessage);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (useContent() && !isEditing()) {
|
|
126
|
+
track('impression', {
|
|
127
|
+
contentId: useContent().id,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (isPreviewing()) {
|
|
132
|
+
if (props.model && previewingModelName() === props.model) {
|
|
133
|
+
const currentUrl = new URL(location.href);
|
|
134
|
+
const apiKey = currentUrl.searchParams.get('apiKey');
|
|
135
|
+
|
|
136
|
+
if (apiKey) {
|
|
137
|
+
getContent({
|
|
138
|
+
model: props.model,
|
|
139
|
+
apiKey,
|
|
140
|
+
options: getBuilderSearchParams(
|
|
141
|
+
convertSearchParamsToQueryObject(currentUrl.searchParams)
|
|
142
|
+
),
|
|
143
|
+
}).then((content) => {
|
|
144
|
+
if (content) {
|
|
145
|
+
setOverrideContent(content);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
58
151
|
}
|
|
59
152
|
}, []);
|
|
60
153
|
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
return () => {
|
|
156
|
+
if (isBrowser()) {
|
|
157
|
+
window.removeEventListener('message', processMessage);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}, []);
|
|
161
|
+
|
|
61
162
|
return (
|
|
62
163
|
<BuilderContext.Provider
|
|
63
164
|
value={{
|
|
64
165
|
get content() {
|
|
65
|
-
return
|
|
166
|
+
return useContent();
|
|
66
167
|
},
|
|
67
168
|
|
|
68
169
|
get state() {
|
|
@@ -74,22 +175,32 @@ export default function RenderContent(props) {
|
|
|
74
175
|
},
|
|
75
176
|
}}
|
|
76
177
|
>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
178
|
+
{useContent() ? (
|
|
179
|
+
<>
|
|
180
|
+
<View
|
|
181
|
+
onClick={(event) => {
|
|
182
|
+
if (!isEditing()) {
|
|
183
|
+
track('click', {
|
|
184
|
+
contentId: useContent().id,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}}
|
|
188
|
+
data-builder-content-id={useContent?.()?.id}
|
|
189
|
+
>
|
|
190
|
+
{(useContent?.()?.data?.cssCode ||
|
|
191
|
+
useContent?.()?.data?.customFonts?.length) &&
|
|
192
|
+
!isReactNative() ? (
|
|
193
|
+
<View>
|
|
194
|
+
<Text>{useContent().data.cssCode}</Text>
|
|
195
|
+
|
|
196
|
+
<Text>{getFontCss(useContent().data)}</Text>
|
|
197
|
+
</View>
|
|
198
|
+
) : null}
|
|
199
|
+
|
|
200
|
+
<RenderBlocks blocks={useContent?.()?.data?.blocks} />
|
|
201
|
+
</View>
|
|
202
|
+
</>
|
|
203
|
+
) : null}
|
|
93
204
|
</BuilderContext.Provider>
|
|
94
205
|
);
|
|
95
206
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
const sizeNames = [
|
|
2
|
+
const sizeNames = ['xsmall', 'small', 'medium', 'large'];
|
|
3
3
|
const sizes = {
|
|
4
4
|
xsmall: {
|
|
5
5
|
min: 0,
|
|
6
6
|
default: 0,
|
|
7
|
-
max: 0
|
|
7
|
+
max: 0,
|
|
8
8
|
},
|
|
9
9
|
small: {
|
|
10
10
|
min: 320,
|
|
11
11
|
default: 321,
|
|
12
|
-
max: 640
|
|
12
|
+
max: 640,
|
|
13
13
|
},
|
|
14
14
|
medium: {
|
|
15
15
|
min: 641,
|
|
16
16
|
default: 642,
|
|
17
|
-
max: 991
|
|
17
|
+
max: 991,
|
|
18
18
|
},
|
|
19
19
|
large: {
|
|
20
20
|
min: 990,
|
|
21
21
|
default: 991,
|
|
22
|
-
max: 1200
|
|
22
|
+
max: 1200,
|
|
23
23
|
},
|
|
24
24
|
getWidthForSize(size) {
|
|
25
25
|
return this[size].default;
|
|
@@ -31,10 +31,7 @@ const sizes = {
|
|
|
31
31
|
return size;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
sizeNames,
|
|
39
|
-
sizes
|
|
34
|
+
return 'large';
|
|
35
|
+
},
|
|
40
36
|
};
|
|
37
|
+
export { sizeNames, sizes };
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { isBrowser } from
|
|
3
|
-
import { isEditing } from
|
|
2
|
+
import { isBrowser } from './is-browser';
|
|
3
|
+
import { isEditing } from './is-editing';
|
|
4
4
|
function evaluate(options) {
|
|
5
5
|
const { code } = options;
|
|
6
6
|
const builder = {
|
|
7
7
|
isEditing: isEditing(),
|
|
8
|
-
isBrowser: isBrowser()
|
|
8
|
+
isBrowser: isBrowser(),
|
|
9
9
|
};
|
|
10
|
-
const useReturn = !(
|
|
10
|
+
const useReturn = !(
|
|
11
|
+
code.includes(';') ||
|
|
12
|
+
code.includes(' return ') ||
|
|
13
|
+
code.trim().startsWith('return ')
|
|
14
|
+
);
|
|
11
15
|
const useCode = `${useReturn ? `return (${code});` : code}`;
|
|
12
16
|
try {
|
|
13
|
-
return new Function(
|
|
17
|
+
return new Function(
|
|
18
|
+
'builder',
|
|
19
|
+
'Builder',
|
|
20
|
+
'state',
|
|
21
|
+
'context',
|
|
22
|
+
'event',
|
|
23
|
+
useCode
|
|
24
|
+
)(builder, builder, options.state, options.context, options.event);
|
|
14
25
|
} catch (e) {
|
|
15
|
-
console.warn(
|
|
26
|
+
console.warn('Builder custom code error: ', e);
|
|
16
27
|
}
|
|
17
28
|
}
|
|
18
|
-
export {
|
|
19
|
-
evaluate
|
|
20
|
-
};
|
|
29
|
+
export { evaluate };
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { evaluate } from
|
|
3
|
-
|
|
4
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
5
|
-
}
|
|
2
|
+
import { evaluate } from './evaluate';
|
|
3
|
+
import { getEventHandlerName } from './event-handler-name';
|
|
6
4
|
function getBlockActions(options) {
|
|
7
5
|
const obj = {};
|
|
8
6
|
if (options.block.actions) {
|
|
9
7
|
for (const key in options.block.actions) {
|
|
8
|
+
if (!options.block.actions.hasOwnProperty(key)) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
10
11
|
const value = options.block.actions[key];
|
|
11
|
-
obj[
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
obj[getEventHandlerName(key)] = (event) =>
|
|
13
|
+
evaluate({
|
|
14
|
+
code: value,
|
|
15
|
+
context: options.context,
|
|
16
|
+
state: options.state,
|
|
17
|
+
event,
|
|
18
|
+
});
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
return obj;
|
|
20
22
|
}
|
|
21
|
-
export {
|
|
22
|
-
getBlockActions
|
|
23
|
-
};
|
|
23
|
+
export { getBlockActions };
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
6
|
+
var __defNormalProp = (obj, key, value) =>
|
|
7
|
+
key in obj
|
|
8
|
+
? __defProp(obj, key, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value,
|
|
13
|
+
})
|
|
14
|
+
: (obj[key] = value);
|
|
15
|
+
var __spreadValues = (a, b) => {
|
|
16
|
+
for (var prop in b || (b = {}))
|
|
17
|
+
if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
18
|
+
if (__getOwnPropSymbols)
|
|
19
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
+
if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
2
24
|
function getBlockComponentOptions(block) {
|
|
3
25
|
var _a;
|
|
4
|
-
return (
|
|
26
|
+
return __spreadValues(
|
|
27
|
+
__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options),
|
|
28
|
+
block.options
|
|
29
|
+
);
|
|
5
30
|
}
|
|
6
|
-
export {
|
|
7
|
-
getBlockComponentOptions
|
|
8
|
-
};
|
|
31
|
+
export { getBlockComponentOptions };
|