@builder.io/sdk-react-native 0.0.1-34 → 0.0.1-38
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 +86 -0
- package/src/blocks/button.lite.tsx +25 -0
- package/src/blocks/columns.js +265 -0
- package/src/blocks/columns.lite.tsx +40 -0
- package/src/blocks/custom-code.js +85 -0
- package/src/blocks/custom-code.lite.tsx +67 -0
- package/src/blocks/embed.js +78 -0
- package/src/blocks/embed.lite.tsx +65 -0
- package/src/blocks/form.js +522 -0
- package/src/blocks/form.lite.tsx +253 -0
- package/src/blocks/fragment.js +21 -0
- package/src/blocks/fragment.lite.tsx +10 -0
- package/src/blocks/image.js +129 -0
- package/src/blocks/image.lite.tsx +68 -0
- package/src/blocks/img.js +64 -0
- package/src/blocks/img.lite.tsx +18 -0
- package/src/blocks/input.js +113 -0
- package/src/blocks/input.lite.tsx +20 -0
- package/src/blocks/raw-text.js +21 -0
- package/src/blocks/raw-text.lite.tsx +11 -0
- package/src/blocks/section.js +84 -0
- package/src/blocks/section.lite.tsx +19 -0
- package/src/blocks/select.js +91 -0
- package/src/blocks/select.lite.tsx +23 -0
- package/src/blocks/submit-button.js +60 -0
- package/src/blocks/submit-button.lite.tsx +10 -0
- package/src/blocks/symbol.js +22 -0
- package/src/blocks/symbol.lite.tsx +20 -0
- package/src/blocks/text.js +100 -0
- package/src/blocks/text.lite.tsx +11 -0
- package/src/blocks/textarea.js +73 -0
- package/src/blocks/textarea.lite.tsx +14 -0
- package/src/blocks/video.js +100 -0
- package/src/blocks/video.lite.tsx +27 -0
- 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 +169 -0
- package/src/components/render-block.lite.tsx +129 -0
- package/src/components/render-blocks.js +73 -0
- package/src/components/render-blocks.lite.tsx +59 -0
- package/src/components/render-content.js +215 -0
- package/src/components/render-content.lite.tsx +207 -0
- package/src/constants/device-sizes.js +37 -0
- package/src/context/builder.context.js +3 -0
- package/src/functions/evaluate.js +29 -0
- package/src/functions/event-handler-name.js +6 -0
- package/src/functions/get-block-actions.js +23 -0
- package/src/functions/get-block-component-options.js +31 -0
- package/src/functions/get-block-properties.js +47 -0
- package/src/functions/get-block-styles.js +78 -0
- package/src/functions/get-block-tag.js +6 -0
- package/src/functions/get-content.js +150 -0
- package/src/functions/get-content.test.js +58 -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 +51 -0
- package/src/functions/get-processed-block.test.js +31 -0
- package/src/functions/get-target.js +5 -0
- package/src/functions/if-target.js +5 -0
- package/src/functions/is-browser.js +10 -0
- package/src/functions/is-editing.js +8 -0
- package/src/functions/is-iframe.js +6 -0
- package/src/functions/is-previewing.js +13 -0
- package/src/functions/is-react-native.js +5 -0
- package/src/functions/macro-eval.js +3 -0
- package/src/functions/on-change.js +25 -0
- package/src/functions/on-change.test.js +21 -0
- package/src/functions/previewing-model-name.js +10 -0
- package/src/functions/register-component.js +65 -0
- package/src/functions/register.js +28 -0
- package/src/functions/set-editor-settings.js +14 -0
- package/src/functions/set.js +21 -0
- package/src/functions/set.test.js +18 -0
- package/src/functions/track.js +17 -0
- package/src/functions/transform-block.js +40 -0
- package/src/index.js +30 -0
- package/src/scripts/init-editing.js +95 -0
- package/src/types/builder-block.js +1 -0
- package/src/types/builder-content.js +1 -0
- package/src/types/deep-partial.js +1 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import ReactVideo from 'react-native-video';
|
|
4
|
+
import { registerComponent } from '../functions/register-component';
|
|
5
|
+
function Video(props) {
|
|
6
|
+
return /* @__PURE__ */ React.createElement(
|
|
7
|
+
View,
|
|
8
|
+
{
|
|
9
|
+
style: { position: 'relative' },
|
|
10
|
+
},
|
|
11
|
+
/* @__PURE__ */ React.createElement(ReactVideo, {
|
|
12
|
+
paused: !props.autoPlay,
|
|
13
|
+
controls: props.controls,
|
|
14
|
+
muted: props.muted,
|
|
15
|
+
repeat: props.loop,
|
|
16
|
+
poster: props.posterImage,
|
|
17
|
+
posterResizeMode: props.fit || 'contain',
|
|
18
|
+
resizeMode: props.fit || 'contain',
|
|
19
|
+
style: {
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
top: 0,
|
|
22
|
+
bottom: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
right: 0,
|
|
25
|
+
zIndex: 1,
|
|
26
|
+
},
|
|
27
|
+
source: { uri: props.video },
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ React.createElement(View, {
|
|
30
|
+
style: {
|
|
31
|
+
width: '100%',
|
|
32
|
+
paddingTop: `${props.aspectRatio * 100}%`,
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
registerComponent(Video, {
|
|
38
|
+
name: 'Video',
|
|
39
|
+
static: true,
|
|
40
|
+
builtIn: true,
|
|
41
|
+
image:
|
|
42
|
+
'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4',
|
|
43
|
+
defaultStyles: {
|
|
44
|
+
position: 'relative',
|
|
45
|
+
minHeight: '20px',
|
|
46
|
+
minWidth: '20px',
|
|
47
|
+
overflow: 'hidden',
|
|
48
|
+
},
|
|
49
|
+
canHaveChildren: true,
|
|
50
|
+
inputs: [
|
|
51
|
+
{
|
|
52
|
+
name: 'video',
|
|
53
|
+
type: 'file',
|
|
54
|
+
allowedFileTypes: ['mp4'],
|
|
55
|
+
bubble: true,
|
|
56
|
+
defaultValue:
|
|
57
|
+
'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f',
|
|
58
|
+
required: true,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'posterImage',
|
|
62
|
+
type: 'file',
|
|
63
|
+
allowedFileTypes: ['jpeg', 'png'],
|
|
64
|
+
helperText: 'Image to show before the video plays',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'autoPlay',
|
|
68
|
+
type: 'boolean',
|
|
69
|
+
defaultValue: true,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'controls',
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
defaultValue: false,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'muted',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
defaultValue: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'loop',
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
defaultValue: true,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'fit',
|
|
88
|
+
type: 'text',
|
|
89
|
+
defaultValue: 'cover',
|
|
90
|
+
enum: ['contain', 'cover', 'stretch'],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'aspectRatio',
|
|
94
|
+
type: 'number',
|
|
95
|
+
advanced: true,
|
|
96
|
+
defaultValue: 0.7004048582995948,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
export { Video as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet, Image, Text } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export default function Video(props) {
|
|
5
|
+
return (
|
|
6
|
+
<View
|
|
7
|
+
{...props.attributes}
|
|
8
|
+
preload="none"
|
|
9
|
+
style={{
|
|
10
|
+
width: '100%',
|
|
11
|
+
height: '100%',
|
|
12
|
+
...props.attributes?.style,
|
|
13
|
+
objectFit: props.fit,
|
|
14
|
+
objectPosition: props.position,
|
|
15
|
+
// Hack to get object fit to work as expected and
|
|
16
|
+
// not have the video overflow
|
|
17
|
+
borderRadius: 1,
|
|
18
|
+
}}
|
|
19
|
+
key={props.video || 'no-src'}
|
|
20
|
+
poster={props.posterImage}
|
|
21
|
+
autoPlay={props.autoPlay}
|
|
22
|
+
muted={props.muted}
|
|
23
|
+
controls={props.controls}
|
|
24
|
+
loop={props.loop}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
class ErrorBoundary extends React.Component {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.state = { hasError: false };
|
|
7
|
+
}
|
|
8
|
+
static getDerivedStateFromError(error) {
|
|
9
|
+
return { hasError: true };
|
|
10
|
+
}
|
|
11
|
+
componentDidCatch(error, errorInfo) {
|
|
12
|
+
console.error('Error rendering Builder.io block', error, errorInfo);
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
if (this.state.hasError) {
|
|
16
|
+
return /* @__PURE__ */ React.createElement(
|
|
17
|
+
Text,
|
|
18
|
+
{
|
|
19
|
+
style: { color: 'gray' },
|
|
20
|
+
},
|
|
21
|
+
'Error rendering Builder.io block'
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return this.props.children;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export { ErrorBoundary as default };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) =>
|
|
8
|
+
key in obj
|
|
9
|
+
? __defProp(obj, key, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value,
|
|
14
|
+
})
|
|
15
|
+
: (obj[key] = value);
|
|
16
|
+
var __spreadValues = (a, b) => {
|
|
17
|
+
for (var prop in b || (b = {}))
|
|
18
|
+
if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
19
|
+
if (__getOwnPropSymbols)
|
|
20
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
21
|
+
if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
+
import * as React from 'react';
|
|
27
|
+
import { useContext } from 'react';
|
|
28
|
+
import { getBlockComponentOptions } from '../functions/get-block-component-options';
|
|
29
|
+
import { getBlockProperties } from '../functions/get-block-properties';
|
|
30
|
+
import { getBlockStyles } from '../functions/get-block-styles';
|
|
31
|
+
import { getBlockTag } from '../functions/get-block-tag';
|
|
32
|
+
import { components } from '../functions/register-component';
|
|
33
|
+
import BuilderContext from '../context/builder.context';
|
|
34
|
+
import { getBlockActions } from '../functions/get-block-actions';
|
|
35
|
+
import { getProcessedBlock } from '../functions/get-processed-block';
|
|
36
|
+
import BlockStyles from './block-styles';
|
|
37
|
+
import RenderBlocks from './render-blocks';
|
|
38
|
+
function RenderBlock(props) {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
function component() {
|
|
41
|
+
var _a2, _b2;
|
|
42
|
+
const componentName =
|
|
43
|
+
(_a2 = useBlock().component) == null ? void 0 : _a2.name;
|
|
44
|
+
if (!componentName) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const ref =
|
|
48
|
+
components[(_b2 = useBlock().component) == null ? void 0 : _b2.name];
|
|
49
|
+
if (componentName && !ref) {
|
|
50
|
+
console.warn(`
|
|
51
|
+
Could not find a registered component named "${componentName}".
|
|
52
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
53
|
+
}
|
|
54
|
+
return ref;
|
|
55
|
+
}
|
|
56
|
+
function componentInfo() {
|
|
57
|
+
var _a2;
|
|
58
|
+
return (_a2 = component == null ? void 0 : component()) == null
|
|
59
|
+
? void 0
|
|
60
|
+
: _a2.info;
|
|
61
|
+
}
|
|
62
|
+
function componentRef() {
|
|
63
|
+
var _a2;
|
|
64
|
+
return (_a2 = component == null ? void 0 : component()) == null
|
|
65
|
+
? void 0
|
|
66
|
+
: _a2.component;
|
|
67
|
+
}
|
|
68
|
+
function tagName() {
|
|
69
|
+
return getBlockTag(useBlock());
|
|
70
|
+
}
|
|
71
|
+
function properties() {
|
|
72
|
+
return getBlockProperties(useBlock());
|
|
73
|
+
}
|
|
74
|
+
function useBlock() {
|
|
75
|
+
return getProcessedBlock({
|
|
76
|
+
block: props.block,
|
|
77
|
+
state: builderContext.state,
|
|
78
|
+
context: builderContext.context,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function propertiesAndActions() {
|
|
82
|
+
return __spreadValues(__spreadValues({}, properties()), actions());
|
|
83
|
+
}
|
|
84
|
+
function actions() {
|
|
85
|
+
return getBlockActions({
|
|
86
|
+
block: useBlock(),
|
|
87
|
+
state: builderContext.state,
|
|
88
|
+
context: builderContext.context,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function css() {
|
|
92
|
+
return getBlockStyles(useBlock());
|
|
93
|
+
}
|
|
94
|
+
function componentOptions() {
|
|
95
|
+
return getBlockComponentOptions(useBlock());
|
|
96
|
+
}
|
|
97
|
+
const builderContext = useContext(BuilderContext);
|
|
98
|
+
const ComponentRefRef = componentRef();
|
|
99
|
+
const TagNameRef = tagName();
|
|
100
|
+
return /* @__PURE__ */ React.createElement(
|
|
101
|
+
React.Fragment,
|
|
102
|
+
null,
|
|
103
|
+
!((_a = componentInfo == null ? void 0 : componentInfo()) == null
|
|
104
|
+
? void 0
|
|
105
|
+
: _a.noWrap)
|
|
106
|
+
? /* @__PURE__ */ React.createElement(
|
|
107
|
+
React.Fragment,
|
|
108
|
+
null,
|
|
109
|
+
/* @__PURE__ */ React.createElement(
|
|
110
|
+
TagNameRef,
|
|
111
|
+
__spreadProps(__spreadValues({}, propertiesAndActions()), {
|
|
112
|
+
style: css(),
|
|
113
|
+
}),
|
|
114
|
+
/* @__PURE__ */ React.createElement(BlockStyles, {
|
|
115
|
+
block: useBlock(),
|
|
116
|
+
}),
|
|
117
|
+
componentRef()
|
|
118
|
+
? /* @__PURE__ */ React.createElement(
|
|
119
|
+
ComponentRefRef,
|
|
120
|
+
__spreadProps(__spreadValues({}, componentOptions()), {
|
|
121
|
+
builderBlock: useBlock(),
|
|
122
|
+
}),
|
|
123
|
+
useBlock().children
|
|
124
|
+
? /* @__PURE__ */ React.createElement(
|
|
125
|
+
React.Fragment,
|
|
126
|
+
null,
|
|
127
|
+
/* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
128
|
+
path: 'children',
|
|
129
|
+
blocks: useBlock().children,
|
|
130
|
+
})
|
|
131
|
+
)
|
|
132
|
+
: null
|
|
133
|
+
)
|
|
134
|
+
: null,
|
|
135
|
+
!componentRef() && useBlock().children && useBlock().children.length
|
|
136
|
+
? /* @__PURE__ */ React.createElement(
|
|
137
|
+
React.Fragment,
|
|
138
|
+
null,
|
|
139
|
+
(_b = useBlock().children) == null
|
|
140
|
+
? void 0
|
|
141
|
+
: _b.map((child) =>
|
|
142
|
+
/* @__PURE__ */ React.createElement(RenderBlock, {
|
|
143
|
+
block: child,
|
|
144
|
+
})
|
|
145
|
+
)
|
|
146
|
+
)
|
|
147
|
+
: null
|
|
148
|
+
)
|
|
149
|
+
)
|
|
150
|
+
: /* @__PURE__ */ React.createElement(
|
|
151
|
+
ComponentRefRef,
|
|
152
|
+
__spreadProps(
|
|
153
|
+
__spreadValues(
|
|
154
|
+
{},
|
|
155
|
+
(_c = componentInfo == null ? void 0 : componentInfo()) == null
|
|
156
|
+
? void 0
|
|
157
|
+
: _c.options
|
|
158
|
+
),
|
|
159
|
+
{
|
|
160
|
+
attributes: propertiesAndActions(),
|
|
161
|
+
builderBlock: useBlock(),
|
|
162
|
+
style: css(),
|
|
163
|
+
children: useBlock().children,
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
)
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
export { RenderBlock as default };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet, Image, Text } from 'react-native';
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
import { getBlockComponentOptions } from '../functions/get-block-component-options';
|
|
5
|
+
import { getBlockProperties } from '../functions/get-block-properties';
|
|
6
|
+
import { getBlockStyles } from '../functions/get-block-styles';
|
|
7
|
+
import { getBlockTag } from '../functions/get-block-tag';
|
|
8
|
+
import { components } from '../functions/register-component';
|
|
9
|
+
import BuilderContext from '../context/builder.context.lite';
|
|
10
|
+
import { getBlockActions } from '../functions/get-block-actions';
|
|
11
|
+
import { getProcessedBlock } from '../functions/get-processed-block';
|
|
12
|
+
import BlockStyles from './block-styles.lite';
|
|
13
|
+
import RenderBlocks from './render-blocks.lite';
|
|
14
|
+
|
|
15
|
+
export default function RenderBlock(props) {
|
|
16
|
+
function component() {
|
|
17
|
+
const componentName = useBlock().component?.name;
|
|
18
|
+
|
|
19
|
+
if (!componentName) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ref = components[useBlock().component?.name];
|
|
24
|
+
|
|
25
|
+
if (componentName && !ref) {
|
|
26
|
+
// TODO: Public doc page with more info about this message
|
|
27
|
+
console.warn(`
|
|
28
|
+
Could not find a registered component named "${componentName}".
|
|
29
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return ref;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function componentInfo() {
|
|
36
|
+
return component?.()?.info;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function componentRef() {
|
|
40
|
+
return component?.()?.component;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function tagName() {
|
|
44
|
+
return getBlockTag(useBlock());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function properties() {
|
|
48
|
+
return getBlockProperties(useBlock());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function useBlock() {
|
|
52
|
+
return getProcessedBlock({
|
|
53
|
+
block: props.block,
|
|
54
|
+
state: builderContext.state,
|
|
55
|
+
context: builderContext.context,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function propertiesAndActions() {
|
|
60
|
+
return { ...properties(), ...actions() };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function actions() {
|
|
64
|
+
return getBlockActions({
|
|
65
|
+
block: useBlock(),
|
|
66
|
+
state: builderContext.state,
|
|
67
|
+
context: builderContext.context,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function css() {
|
|
72
|
+
return getBlockStyles(useBlock());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function componentOptions() {
|
|
76
|
+
return getBlockComponentOptions(useBlock());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const builderContext = useContext(BuilderContext);
|
|
80
|
+
|
|
81
|
+
const ComponentRefRef = componentRef();
|
|
82
|
+
const TagNameRef = tagName();
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
{!componentInfo?.()?.noWrap ? (
|
|
87
|
+
<>
|
|
88
|
+
<TagNameRef {...propertiesAndActions()} style={css()}>
|
|
89
|
+
<BlockStyles block={useBlock()} />
|
|
90
|
+
|
|
91
|
+
{componentRef() ? (
|
|
92
|
+
<ComponentRefRef
|
|
93
|
+
{...componentOptions()}
|
|
94
|
+
builderBlock={useBlock()}
|
|
95
|
+
>
|
|
96
|
+
{useBlock().children ? (
|
|
97
|
+
<>
|
|
98
|
+
<RenderBlocks
|
|
99
|
+
path="children"
|
|
100
|
+
blocks={useBlock().children}
|
|
101
|
+
/>
|
|
102
|
+
</>
|
|
103
|
+
) : null}
|
|
104
|
+
</ComponentRefRef>
|
|
105
|
+
) : null}
|
|
106
|
+
|
|
107
|
+
{!componentRef() &&
|
|
108
|
+
useBlock().children &&
|
|
109
|
+
useBlock().children.length ? (
|
|
110
|
+
<>
|
|
111
|
+
{useBlock().children?.map((child) => (
|
|
112
|
+
<RenderBlock block={child} />
|
|
113
|
+
))}
|
|
114
|
+
</>
|
|
115
|
+
) : null}
|
|
116
|
+
</TagNameRef>
|
|
117
|
+
</>
|
|
118
|
+
) : (
|
|
119
|
+
<ComponentRefRef
|
|
120
|
+
{...componentInfo?.()?.options}
|
|
121
|
+
attributes={propertiesAndActions()}
|
|
122
|
+
builderBlock={useBlock()}
|
|
123
|
+
style={css()}
|
|
124
|
+
children={useBlock().children}
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
</>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import { isEditing } from '../functions/is-editing';
|
|
4
|
+
import RenderBlock from './render-block';
|
|
5
|
+
function RenderBlocks(props) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
function onClick() {
|
|
8
|
+
var _a2, _b2;
|
|
9
|
+
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
10
|
+
(_b2 = window.parent) == null
|
|
11
|
+
? void 0
|
|
12
|
+
: _b2.postMessage(
|
|
13
|
+
{
|
|
14
|
+
type: 'builder.clickEmptyBlocks',
|
|
15
|
+
data: {
|
|
16
|
+
parentElementId: props.parent,
|
|
17
|
+
dataPath: props.path,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
'*'
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function onMouseEnter() {
|
|
25
|
+
var _a2, _b2;
|
|
26
|
+
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
27
|
+
(_b2 = window.parent) == null
|
|
28
|
+
? void 0
|
|
29
|
+
: _b2.postMessage(
|
|
30
|
+
{
|
|
31
|
+
type: 'builder.hoverEmptyBlocks',
|
|
32
|
+
data: {
|
|
33
|
+
parentElementId: props.parent,
|
|
34
|
+
dataPath: props.path,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
'*'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ React.createElement(
|
|
42
|
+
View,
|
|
43
|
+
{
|
|
44
|
+
'builder-path': props.path,
|
|
45
|
+
'builder-parent-id': props.parent,
|
|
46
|
+
onClick: (event) => onClick,
|
|
47
|
+
onMouseEnter: (event) => onMouseEnter,
|
|
48
|
+
className:
|
|
49
|
+
'builder-blocks' +
|
|
50
|
+
(!((_a = props.blocks) == null ? void 0 : _a.length)
|
|
51
|
+
? ' no-blocks'
|
|
52
|
+
: ''),
|
|
53
|
+
style: styles.view1,
|
|
54
|
+
},
|
|
55
|
+
props.blocks
|
|
56
|
+
? /* @__PURE__ */ React.createElement(
|
|
57
|
+
React.Fragment,
|
|
58
|
+
null,
|
|
59
|
+
(_b = props.blocks) == null
|
|
60
|
+
? void 0
|
|
61
|
+
: _b.map((block) =>
|
|
62
|
+
/* @__PURE__ */ React.createElement(RenderBlock, {
|
|
63
|
+
block,
|
|
64
|
+
})
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
: null
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const styles = StyleSheet.create({
|
|
71
|
+
view1: { display: 'flex', flexDirection: 'column', alignItems: 'stretch' },
|
|
72
|
+
});
|
|
73
|
+
export { RenderBlocks as default };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet, Image, Text } from 'react-native';
|
|
3
|
+
import { isEditing } from '../functions/is-editing';
|
|
4
|
+
import RenderBlock from './render-block.lite';
|
|
5
|
+
|
|
6
|
+
export default function RenderBlocks(props) {
|
|
7
|
+
function onClick() {
|
|
8
|
+
if (isEditing() && !props.blocks?.length) {
|
|
9
|
+
window.parent?.postMessage(
|
|
10
|
+
{
|
|
11
|
+
type: 'builder.clickEmptyBlocks',
|
|
12
|
+
data: {
|
|
13
|
+
parentElementId: props.parent,
|
|
14
|
+
dataPath: props.path,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
'*'
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function onMouseEnter() {
|
|
23
|
+
if (isEditing() && !props.blocks?.length) {
|
|
24
|
+
window.parent?.postMessage(
|
|
25
|
+
{
|
|
26
|
+
type: 'builder.hoverEmptyBlocks',
|
|
27
|
+
data: {
|
|
28
|
+
parentElementId: props.parent,
|
|
29
|
+
dataPath: props.path,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
'*'
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View
|
|
39
|
+
builder-path={props.path}
|
|
40
|
+
builder-parent-id={props.parent}
|
|
41
|
+
onClick={(event) => onClick}
|
|
42
|
+
onMouseEnter={(event) => onMouseEnter}
|
|
43
|
+
className={'builder-blocks' + (!props.blocks?.length ? ' no-blocks' : '')}
|
|
44
|
+
style={styles.view1}
|
|
45
|
+
>
|
|
46
|
+
{props.blocks ? (
|
|
47
|
+
<>
|
|
48
|
+
{props.blocks?.map((block) => (
|
|
49
|
+
<RenderBlock block={block} />
|
|
50
|
+
))}
|
|
51
|
+
</>
|
|
52
|
+
) : null}
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const styles = StyleSheet.create({
|
|
58
|
+
view1: { display: 'flex', flexDirection: 'column', alignItems: 'stretch' },
|
|
59
|
+
});
|