@builder.io/sdk-react-native 0.0.1-44 → 0.0.1-50
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 +14 -0
- package/package.json +1 -1
- package/src/blocks/button.js +23 -73
- package/src/blocks/button.lite.tsx +3 -3
- package/src/blocks/columns.js +56 -288
- package/src/blocks/columns.lite.tsx +22 -22
- package/src/blocks/custom-code.js +46 -76
- package/src/blocks/custom-code.lite.tsx +11 -19
- package/src/blocks/embed.js +46 -69
- package/src/blocks/embed.lite.tsx +11 -15
- package/src/blocks/form.js +194 -491
- package/src/blocks/form.lite.tsx +51 -51
- package/src/blocks/fragment.js +8 -16
- package/src/blocks/fragment.lite.tsx +2 -2
- package/src/blocks/image.js +91 -113
- package/src/blocks/image.lite.tsx +12 -13
- package/src/blocks/img.js +28 -51
- package/src/blocks/img.lite.tsx +6 -6
- package/src/blocks/input.js +28 -100
- package/src/blocks/input.lite.tsx +4 -4
- package/src/blocks/raw-text.js +10 -16
- package/src/blocks/raw-text.lite.tsx +3 -8
- package/src/blocks/section.js +23 -71
- package/src/blocks/section.lite.tsx +3 -3
- package/src/blocks/select.js +28 -78
- package/src/blocks/select.lite.tsx +5 -5
- package/src/blocks/submit-button.js +21 -47
- package/src/blocks/submit-button.lite.tsx +2 -2
- package/src/blocks/symbol.js +71 -20
- package/src/blocks/symbol.lite.tsx +48 -8
- package/src/blocks/text.js +27 -40
- package/src/blocks/text.lite.tsx +3 -8
- package/src/blocks/textarea.js +24 -60
- package/src/blocks/textarea.lite.tsx +2 -2
- package/src/blocks/video.js +66 -71
- package/src/blocks/video.lite.tsx +5 -5
- package/src/components/block-styles.js +4 -2
- package/src/components/block-styles.lite.tsx +2 -2
- package/src/components/error-boundary.js +9 -11
- package/src/components/error-boundary.lite.tsx +2 -2
- package/src/components/render-block.js +44 -100
- package/src/components/render-block.lite.tsx +23 -28
- package/src/components/render-blocks.js +41 -60
- package/src/components/render-blocks.lite.tsx +20 -14
- package/src/components/render-content.js +189 -142
- package/src/components/render-content.lite.tsx +166 -60
- package/src/constants/device-sizes.js +11 -8
- package/src/context/builder.context.js +10 -3
- package/src/functions/evaluate.js +20 -20
- package/src/functions/event-handler-name.js +3 -1
- package/src/functions/get-block-actions.js +17 -16
- package/src/functions/get-block-component-options.js +9 -16
- package/src/functions/get-block-properties.js +14 -18
- package/src/functions/get-block-styles.js +17 -34
- package/src/functions/get-block-tag.js +4 -2
- package/src/functions/get-builder-search-params/fn.test.js +14 -0
- package/src/functions/get-builder-search-params/index.js +23 -0
- package/src/functions/get-content/fn.test.js +32 -0
- package/src/functions/get-content/index.js +138 -0
- package/src/functions/get-fetch.js +7 -5
- package/src/functions/get-global-this.js +7 -5
- package/src/functions/get-processed-block.js +13 -17
- package/src/functions/get-processed-block.test.js +17 -16
- package/src/functions/get-target.js +4 -2
- package/src/functions/if-target.js +3 -1
- package/src/functions/is-browser.js +4 -2
- package/src/functions/is-editing.js +5 -5
- package/src/functions/is-iframe.js +4 -2
- package/src/functions/is-previewing.js +6 -4
- package/src/functions/is-react-native.js +3 -1
- package/src/functions/macro-eval.js +5 -2
- package/src/functions/on-change.js +7 -4
- package/src/functions/on-change.test.js +9 -10
- package/src/functions/previewing-model-name.js +5 -3
- package/src/functions/register-component.js +27 -38
- package/src/functions/register.js +10 -8
- package/src/functions/set-editor-settings.js +7 -5
- package/src/functions/set.js +5 -14
- package/src/functions/set.test.js +13 -14
- package/src/functions/track.js +12 -6
- package/src/functions/transform-block.js +13 -17
- package/src/index-helpers/blocks-exports.js +19 -0
- package/src/index-helpers/top-of-file.js +2 -0
- package/src/index.js +11 -26
- package/src/scripts/init-editing.js +40 -64
- package/src/types/typescript.js +1 -0
- package/src/functions/get-content.js +0 -152
- package/src/functions/get-content.test.js +0 -58
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
### 0.0.1-49
|
|
2
|
+
|
|
3
|
+
- Fix: show the "+ add block" button on empty pages https://github.com/BuilderIO/builder/pull/934
|
|
4
|
+
- Add `getBuilderSearchParams` helper export to easily view current drafts on your production site. https://github.com/BuilderIO/builder/pull/883
|
|
5
|
+
|
|
6
|
+
### 0.0.1-44
|
|
7
|
+
|
|
8
|
+
Changes:
|
|
9
|
+
|
|
10
|
+
- Fixes `getAllContent` to traverse all nested data from symbols/references https://github.com/BuilderIO/builder/pull/718
|
|
11
|
+
- Fixes `getContent` (broken due to missing URL polyfill) https://github.com/BuilderIO/builder/pull/880
|
|
12
|
+
- Strips invalid `this.` left from Mitosis compilation https://github.com/BuilderIO/builder/pull/717/commits/b1947c86db769f74a7408965dac70f22dfcc538d
|
|
13
|
+
- Fix identification of react-native environment https://github.com/BuilderIO/builder/pull/717/commits/9d2a207ceca39bf83d5bbdc4bd67351e86105d78
|
|
14
|
+
- Fix Aspect Ratio handling (this adds support for Pixel Tracking) https://github.com/BuilderIO/builder/pull/749, preceeded by https://github.com/BuilderIO/builder/pull/687
|
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-50",
|
|
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,86 +1,36 @@
|
|
|
1
1
|
import { registerComponent } from '../functions/register-component';
|
|
2
2
|
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
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) =>
|
|
10
|
-
key in obj
|
|
11
|
-
? __defProp(obj, key, {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true,
|
|
15
|
-
value,
|
|
16
|
-
})
|
|
17
|
-
: (obj[key] = value);
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18
10
|
var __spreadValues = (a, b) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
26
20
|
};
|
|
27
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
28
|
-
import * as React from
|
|
29
|
-
import { View, Text } from
|
|
22
|
+
import * as React from "react";
|
|
23
|
+
import { View, Text } from "react-native";
|
|
30
24
|
function Button(props) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
);
|
|
25
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.link ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
26
|
+
role: "button",
|
|
27
|
+
href: props.link,
|
|
28
|
+
target: props.openLinkInNewTab ? "_blank" : void 0
|
|
29
|
+
}), /* @__PURE__ */ React.createElement(Text, null, props.text))) : /* @__PURE__ */ React.createElement(View, __spreadValues({}, props.attributes), /* @__PURE__ */ React.createElement(Text, null, props.text)));
|
|
54
30
|
}
|
|
55
|
-
export {
|
|
31
|
+
export {
|
|
32
|
+
Button as default
|
|
33
|
+
};
|
|
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
|
-
});
|
|
36
|
+
registerComponent(Button, {name:'Core:Button',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13',defaultStyles:{appearance:'none',paddingTop:'15px',paddingBottom:'15px',paddingLeft:'25px',paddingRight:'25px',backgroundColor:'#000000',color:'white',borderRadius:'4px',textAlign:'center',cursor:'pointer'},inputs:[{name:'text',type:'text',defaultValue:'Click me!',bubble:true},{name:'link',type:'url',bubble:true},{name:'openLinkInNewTab',type:'boolean',defaultValue:false,friendlyName:'Open link in new tab'}],static:true,noWrap:true});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
4
|
export default function Button(props) {
|
|
5
5
|
return (
|
|
@@ -10,7 +10,7 @@ export default function Button(props) {
|
|
|
10
10
|
{...props.attributes}
|
|
11
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,295 +1,63 @@
|
|
|
1
1
|
import { registerComponent } from '../functions/register-component';
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
return /* @__PURE__ */ React.createElement(
|
|
55
|
-
View,
|
|
56
|
-
{
|
|
57
|
-
className: 'builder-columns',
|
|
58
|
-
style: styles.view1,
|
|
59
|
-
},
|
|
60
|
-
(_a = props.columns) == null
|
|
61
|
-
? void 0
|
|
62
|
-
: _a.map((column) =>
|
|
63
|
-
/* @__PURE__ */ React.createElement(
|
|
64
|
-
View,
|
|
65
|
-
{
|
|
66
|
-
className: 'builder-column',
|
|
67
|
-
style: styles.view2,
|
|
68
|
-
},
|
|
69
|
-
/* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
70
|
-
blocks: column.blocks,
|
|
71
|
-
})
|
|
72
|
-
)
|
|
73
|
-
)
|
|
74
|
-
);
|
|
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
|
+
var _a2;
|
|
16
|
+
const columns = getColumns();
|
|
17
|
+
return ((_a2 = columns[index]) == null ? void 0 : _a2.width) || 100 / columns.length;
|
|
18
|
+
}
|
|
19
|
+
function getColumnCssWidth(index) {
|
|
20
|
+
const columns = getColumns();
|
|
21
|
+
const gutterSize = getGutterSize();
|
|
22
|
+
const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
|
|
23
|
+
return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
|
|
24
|
+
}
|
|
25
|
+
function maybeApplyForTablet(prop) {
|
|
26
|
+
const stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
27
|
+
return stackColumnsAt === "tablet" ? prop : "inherit";
|
|
28
|
+
}
|
|
29
|
+
function columnsCssVars() {
|
|
30
|
+
const flexDir = props.stackColumnsAt === "never" ? "inherit" : props.reverseColumnsWhenStacked ? "column-reverse" : "column";
|
|
31
|
+
return {
|
|
32
|
+
"--flex-dir": flexDir,
|
|
33
|
+
"--flex-dir-tablet": maybeApplyForTablet(flexDir)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function columnCssVars() {
|
|
37
|
+
const width = "100%";
|
|
38
|
+
const marginLeft = "0";
|
|
39
|
+
return {
|
|
40
|
+
"--column-width": width,
|
|
41
|
+
"--column-margin-left": marginLeft,
|
|
42
|
+
"--column-width-tablet": maybeApplyForTablet(width),
|
|
43
|
+
"--column-margin-left-tablet": maybeApplyForTablet(marginLeft)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return /* @__PURE__ */ React.createElement(View, {
|
|
47
|
+
style: styles.view1
|
|
48
|
+
}, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement(View, {
|
|
49
|
+
style: styles.view2
|
|
50
|
+
}, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
51
|
+
blocks: column.blocks
|
|
52
|
+
}))));
|
|
75
53
|
}
|
|
76
54
|
const styles = StyleSheet.create({
|
|
77
|
-
|
|
78
|
-
|
|
55
|
+
view1: { display: "flex", alignItems: "stretch" },
|
|
56
|
+
view2: { flexGrow: 1 }
|
|
79
57
|
});
|
|
80
|
-
export {
|
|
58
|
+
export {
|
|
59
|
+
Columns as default
|
|
60
|
+
};
|
|
81
61
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
builtIn: true,
|
|
85
|
-
inputs: [
|
|
86
|
-
{
|
|
87
|
-
name: 'columns',
|
|
88
|
-
type: 'array',
|
|
89
|
-
broadcast: true,
|
|
90
|
-
subFields: [
|
|
91
|
-
{
|
|
92
|
-
name: 'blocks',
|
|
93
|
-
type: 'array',
|
|
94
|
-
hideFromUI: true,
|
|
95
|
-
defaultValue: [
|
|
96
|
-
{
|
|
97
|
-
'@type': '@builder.io/sdk:Element',
|
|
98
|
-
responsiveStyles: {
|
|
99
|
-
large: {
|
|
100
|
-
display: 'flex',
|
|
101
|
-
flexDirection: 'column',
|
|
102
|
-
alignItems: 'stretch',
|
|
103
|
-
flexShrink: '0',
|
|
104
|
-
position: 'relative',
|
|
105
|
-
marginTop: '30px',
|
|
106
|
-
textAlign: 'center',
|
|
107
|
-
lineHeight: 'normal',
|
|
108
|
-
height: 'auto',
|
|
109
|
-
minHeight: '20px',
|
|
110
|
-
minWidth: '20px',
|
|
111
|
-
overflow: 'hidden',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
component: {
|
|
115
|
-
name: 'Image',
|
|
116
|
-
options: {
|
|
117
|
-
image:
|
|
118
|
-
'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
|
|
119
|
-
backgroundPosition: 'center',
|
|
120
|
-
backgroundSize: 'cover',
|
|
121
|
-
aspectRatio: 0.7004048582995948,
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
'@type': '@builder.io/sdk:Element',
|
|
127
|
-
responsiveStyles: {
|
|
128
|
-
large: {
|
|
129
|
-
display: 'flex',
|
|
130
|
-
flexDirection: 'column',
|
|
131
|
-
alignItems: 'stretch',
|
|
132
|
-
flexShrink: '0',
|
|
133
|
-
position: 'relative',
|
|
134
|
-
marginTop: '30px',
|
|
135
|
-
textAlign: 'center',
|
|
136
|
-
lineHeight: 'normal',
|
|
137
|
-
height: 'auto',
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
component: {
|
|
141
|
-
name: 'Text',
|
|
142
|
-
options: { text: '<p>Enter some text...</p>' },
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'width',
|
|
149
|
-
type: 'number',
|
|
150
|
-
hideFromUI: true,
|
|
151
|
-
helperText: 'Width %, e.g. set to 50 to fill half of the space',
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: 'link',
|
|
155
|
-
type: 'url',
|
|
156
|
-
helperText:
|
|
157
|
-
'Optionally set a url that clicking this column will link to',
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
defaultValue: [
|
|
161
|
-
{
|
|
162
|
-
blocks: [
|
|
163
|
-
{
|
|
164
|
-
'@type': '@builder.io/sdk:Element',
|
|
165
|
-
responsiveStyles: {
|
|
166
|
-
large: {
|
|
167
|
-
display: 'flex',
|
|
168
|
-
flexDirection: 'column',
|
|
169
|
-
alignItems: 'stretch',
|
|
170
|
-
flexShrink: '0',
|
|
171
|
-
position: 'relative',
|
|
172
|
-
marginTop: '30px',
|
|
173
|
-
textAlign: 'center',
|
|
174
|
-
lineHeight: 'normal',
|
|
175
|
-
height: 'auto',
|
|
176
|
-
minHeight: '20px',
|
|
177
|
-
minWidth: '20px',
|
|
178
|
-
overflow: 'hidden',
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
component: {
|
|
182
|
-
name: 'Image',
|
|
183
|
-
options: {
|
|
184
|
-
image:
|
|
185
|
-
'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
|
|
186
|
-
backgroundPosition: 'center',
|
|
187
|
-
backgroundSize: 'cover',
|
|
188
|
-
aspectRatio: 0.7004048582995948,
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
'@type': '@builder.io/sdk:Element',
|
|
194
|
-
responsiveStyles: {
|
|
195
|
-
large: {
|
|
196
|
-
display: 'flex',
|
|
197
|
-
flexDirection: 'column',
|
|
198
|
-
alignItems: 'stretch',
|
|
199
|
-
flexShrink: '0',
|
|
200
|
-
position: 'relative',
|
|
201
|
-
marginTop: '30px',
|
|
202
|
-
textAlign: 'center',
|
|
203
|
-
lineHeight: 'normal',
|
|
204
|
-
height: 'auto',
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
component: {
|
|
208
|
-
name: 'Text',
|
|
209
|
-
options: { text: '<p>Enter some text...</p>' },
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
blocks: [
|
|
216
|
-
{
|
|
217
|
-
'@type': '@builder.io/sdk:Element',
|
|
218
|
-
responsiveStyles: {
|
|
219
|
-
large: {
|
|
220
|
-
display: 'flex',
|
|
221
|
-
flexDirection: 'column',
|
|
222
|
-
alignItems: 'stretch',
|
|
223
|
-
flexShrink: '0',
|
|
224
|
-
position: 'relative',
|
|
225
|
-
marginTop: '30px',
|
|
226
|
-
textAlign: 'center',
|
|
227
|
-
lineHeight: 'normal',
|
|
228
|
-
height: 'auto',
|
|
229
|
-
minHeight: '20px',
|
|
230
|
-
minWidth: '20px',
|
|
231
|
-
overflow: 'hidden',
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
component: {
|
|
235
|
-
name: 'Image',
|
|
236
|
-
options: {
|
|
237
|
-
image:
|
|
238
|
-
'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
|
|
239
|
-
backgroundPosition: 'center',
|
|
240
|
-
backgroundSize: 'cover',
|
|
241
|
-
aspectRatio: 0.7004048582995948,
|
|
242
|
-
},
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
'@type': '@builder.io/sdk:Element',
|
|
247
|
-
responsiveStyles: {
|
|
248
|
-
large: {
|
|
249
|
-
display: 'flex',
|
|
250
|
-
flexDirection: 'column',
|
|
251
|
-
alignItems: 'stretch',
|
|
252
|
-
flexShrink: '0',
|
|
253
|
-
position: 'relative',
|
|
254
|
-
marginTop: '30px',
|
|
255
|
-
textAlign: 'center',
|
|
256
|
-
lineHeight: 'normal',
|
|
257
|
-
height: 'auto',
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
component: {
|
|
261
|
-
name: 'Text',
|
|
262
|
-
options: { text: '<p>Enter some text...</p>' },
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
],
|
|
266
|
-
},
|
|
267
|
-
],
|
|
268
|
-
onChange:
|
|
269
|
-
" 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(); } } } } ",
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
name: 'space',
|
|
273
|
-
type: 'number',
|
|
274
|
-
defaultValue: 20,
|
|
275
|
-
helperText: 'Size of gap between columns',
|
|
276
|
-
advanced: true,
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
name: 'stackColumnsAt',
|
|
280
|
-
type: 'string',
|
|
281
|
-
defaultValue: 'tablet',
|
|
282
|
-
helperText: 'Convert horizontal columns to vertical at what device size',
|
|
283
|
-
enum: ['tablet', 'mobile', 'never'],
|
|
284
|
-
advanced: true,
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
name: 'reverseColumnsWhenStacked',
|
|
288
|
-
type: 'boolean',
|
|
289
|
-
defaultValue: false,
|
|
290
|
-
helperText:
|
|
291
|
-
'When stacking columns for mobile devices, reverse the ordering',
|
|
292
|
-
advanced: true,
|
|
293
|
-
},
|
|
294
|
-
],
|
|
295
|
-
});
|
|
62
|
+
|
|
63
|
+
registerComponent(Columns, {name:'Columns',builtIn:true,inputs:[{name:'columns',type:'array',broadcast:true,subFields:[{name:'blocks',type:'array',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]},{name:'width',type:'number',hideFromUI:true,helperText:'Width %, e.g. set to 50 to fill half of the space'},{name:'link',type:'url',helperText:'Optionally set a url that clicking this column will link to'}],defaultValue:[{blocks:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]},{blocks:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto',minHeight:'20px',minWidth:'20px',overflow:'hidden'}},component:{name:'Image',options:{image:'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',backgroundPosition:'center',backgroundSize:'cover',aspectRatio:0.7004048582995948}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{display:'flex',flexDirection:'column',alignItems:'stretch',flexShrink:'0',position:'relative',marginTop:'30px',textAlign:'center',lineHeight:'normal',height:'auto'}},component:{name:'Text',options:{text:'<p>Enter some text...</p>'}}}]}],onChange:" 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(); } } } } "},{name:'space',type:'number',defaultValue:20,helperText:'Size of gap between columns',advanced:true},{name:'stackColumnsAt',type:'string',defaultValue:'tablet',helperText:'Convert horizontal columns to vertical at what device size',enum:['tablet','mobile','never'],advanced:true},{name:'reverseColumnsWhenStacked',type:'boolean',defaultValue:false,helperText:'When stacking columns for mobile devices, reverse the ordering',advanced:true}]});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
3
|
-
import RenderBlocks from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
import RenderBlocks from "../components/render-blocks.lite";
|
|
4
4
|
|
|
5
5
|
export default function Columns(props) {
|
|
6
6
|
function getGutterSize() {
|
|
7
|
-
return typeof props.space ===
|
|
7
|
+
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
function getColumns() {
|
|
@@ -24,38 +24,38 @@ export default function Columns(props) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function maybeApplyForTablet(prop) {
|
|
27
|
-
const stackColumnsAt = props.stackColumnsAt ||
|
|
28
|
-
return stackColumnsAt ===
|
|
27
|
+
const stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
28
|
+
return stackColumnsAt === "tablet" ? prop : "inherit";
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function columnsCssVars() {
|
|
32
32
|
const flexDir =
|
|
33
|
-
props.stackColumnsAt ===
|
|
34
|
-
?
|
|
33
|
+
props.stackColumnsAt === "never"
|
|
34
|
+
? "inherit"
|
|
35
35
|
: props.reverseColumnsWhenStacked
|
|
36
|
-
?
|
|
37
|
-
:
|
|
36
|
+
? "column-reverse"
|
|
37
|
+
: "column";
|
|
38
38
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
"--flex-dir": flexDir,
|
|
40
|
+
"--flex-dir-tablet": maybeApplyForTablet(flexDir),
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function columnCssVars() {
|
|
45
|
-
const width =
|
|
46
|
-
const marginLeft =
|
|
45
|
+
const width = "100%";
|
|
46
|
+
const marginLeft = "0";
|
|
47
47
|
return {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
"--column-width": width,
|
|
49
|
+
"--column-margin-left": marginLeft,
|
|
50
|
+
"--column-width-tablet": maybeApplyForTablet(width),
|
|
51
|
+
"--column-margin-left-tablet": maybeApplyForTablet(marginLeft),
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
return (
|
|
56
|
-
<View
|
|
57
|
-
{props.columns?.map((column) => (
|
|
58
|
-
<View
|
|
56
|
+
<View style={styles.view1}>
|
|
57
|
+
{props.columns?.map((column, index) => (
|
|
58
|
+
<View style={styles.view2}>
|
|
59
59
|
<RenderBlocks blocks={column.blocks} />
|
|
60
60
|
</View>
|
|
61
61
|
))}
|
|
@@ -64,6 +64,6 @@ export default function Columns(props) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const styles = StyleSheet.create({
|
|
67
|
-
view1: { display:
|
|
67
|
+
view1: { display: "flex", alignItems: "stretch" },
|
|
68
68
|
view2: { flexGrow: 1 },
|
|
69
69
|
});
|