@builder.io/sdk-react-native 0.0.1-5 → 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/README.md +15 -0
- package/package.json +6 -4
- package/src/blocks/button.js +5 -6
- package/src/blocks/button.lite.tsx +7 -11
- package/src/blocks/columns.js +32 -16
- package/src/blocks/columns.lite.tsx +39 -16
- package/src/blocks/custom-code.js +1 -2
- package/src/blocks/custom-code.lite.tsx +2 -10
- package/src/blocks/embed.js +1 -2
- package/src/blocks/embed.lite.tsx +2 -6
- package/src/blocks/form.js +11 -15
- package/src/blocks/form.lite.tsx +18 -22
- package/src/blocks/fragment.js +13 -0
- package/src/blocks/fragment.lite.tsx +10 -0
- package/src/blocks/image.js +27 -7
- package/src/blocks/image.lite.tsx +42 -10
- package/src/blocks/img.js +3 -3
- package/src/blocks/img.lite.tsx +2 -3
- package/src/blocks/input.js +3 -3
- package/src/blocks/input.lite.tsx +2 -5
- package/src/blocks/raw-text.js +1 -3
- package/src/blocks/raw-text.lite.tsx +1 -7
- package/src/blocks/section.js +3 -3
- package/src/blocks/section.lite.tsx +1 -2
- package/src/blocks/select.js +7 -6
- package/src/blocks/select.lite.tsx +6 -7
- package/src/blocks/submit-button.js +3 -3
- package/src/blocks/submit-button.lite.tsx +1 -2
- package/src/blocks/symbol.js +65 -12
- package/src/blocks/symbol.lite.tsx +44 -4
- package/src/blocks/text.js +57 -1
- package/src/blocks/text.lite.tsx +1 -7
- package/src/blocks/textarea.js +1 -1
- package/src/blocks/textarea.lite.tsx +0 -1
- package/src/blocks/video.js +90 -44
- package/src/blocks/video.lite.tsx +0 -1
- package/src/components/block-styles.js +7 -0
- package/src/components/block-styles.lite.tsx +6 -0
- package/src/components/error-boundary.js +25 -0
- package/src/components/error-boundary.lite.tsx +6 -0
- package/src/components/render-block.js +43 -19
- package/src/components/render-block.lite.tsx +69 -34
- package/src/components/render-blocks.js +12 -5
- package/src/components/render-blocks.lite.tsx +16 -7
- package/src/components/render-content.js +224 -24
- package/src/components/render-content.lite.tsx +247 -34
- package/src/context/builder.context.js +6 -1
- package/src/functions/evaluate.js +15 -6
- package/src/functions/event-handler-name.js +8 -0
- package/src/functions/get-block-actions.js +13 -12
- package/src/functions/get-block-component-options.js +17 -1
- package/src/functions/get-block-properties.js +7 -4
- package/src/functions/get-block-styles.js +31 -1
- 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 +13 -0
- package/src/functions/get-global-this.js +19 -0
- package/src/functions/get-processed-block.js +3 -1
- package/src/functions/get-processed-block.test.js +12 -7
- package/src/functions/get-target.js +1 -1
- package/src/functions/is-browser.js +1 -2
- package/src/functions/is-previewing.js +15 -0
- package/src/functions/is-react-native.js +1 -1
- package/src/functions/on-change.test.js +0 -1
- package/src/functions/previewing-model-name.js +12 -0
- package/src/functions/register-component.js +1 -0
- package/src/functions/register.js +30 -0
- package/src/functions/set-editor-settings.js +16 -0
- package/src/functions/set.test.js +0 -1
- package/src/functions/track.js +5 -1
- package/src/functions/transform-block.js +38 -0
- package/src/index-helpers/blocks-exports.js +19 -0
- package/src/index-helpers/top-of-file.js +2 -0
- package/src/index.js +8 -18
- package/src/scripts/init-editing.js +18 -2
- package/src/types/deep-partial.js +1 -0
- package/src/types/typescript.js +1 -0
- package/index.js +0 -11
- package/src/functions/get-content.js +0 -103
- package/src/package.json +0 -18
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/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Builder.io React-native SDK (BETA)
|
|
2
|
+
|
|
3
|
+
This is the React-Native SDK. It is currently in beta.
|
|
4
|
+
|
|
5
|
+
## Feature Support
|
|
6
|
+
|
|
7
|
+
To check the status of the SDK, look at [these tables](../../README.md#feature-implementation).
|
|
8
|
+
|
|
9
|
+
## Getting Started
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install @builder.io/sdk-react-native@dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Take a look at [our example repo](/examples/react-native) for how to use this SDK.
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
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"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"react-native-render-html": "^
|
|
10
|
+
"react-native-render-html": "^6.3.4",
|
|
11
|
+
"react-native-video": "^5.1.1"
|
|
11
12
|
},
|
|
12
13
|
"peerDependencies": {
|
|
13
|
-
"react-native": "^0.64.
|
|
14
|
+
"react-native": "^0.64.3"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
|
-
"react-native": "^0.
|
|
17
|
+
"@types/react-native-video": "^5.0.9",
|
|
18
|
+
"react-native": "^0.64.3"
|
|
17
19
|
}
|
|
18
20
|
}
|
package/src/blocks/button.js
CHANGED
|
@@ -20,18 +20,17 @@ return a;
|
|
|
20
20
|
};
|
|
21
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
22
|
import * as React from "react";
|
|
23
|
-
import { View } from "react-native";
|
|
23
|
+
import { View, Text } from "react-native";
|
|
24
24
|
function Button(props) {
|
|
25
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.link
|
|
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",
|
|
26
27
|
href: props.link,
|
|
27
28
|
target: props.openLinkInNewTab ? "_blank" : void 0
|
|
28
|
-
}),
|
|
29
|
-
type: "button"
|
|
30
|
-
}), props.text)));
|
|
29
|
+
}), /* @__PURE__ */ React.createElement(Text, null, props.text))) : /* @__PURE__ */ React.createElement(View, __spreadValues({}, props.attributes), /* @__PURE__ */ React.createElement(Text, null, props.text)));
|
|
31
30
|
}
|
|
32
31
|
export {
|
|
33
32
|
Button as default
|
|
34
33
|
};
|
|
35
34
|
|
|
36
35
|
|
|
37
|
-
registerComponent(Button, {name:'Core:Button',image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13',defaultStyles:{appearance:'none',paddingTop:'15px',paddingBottom:'15px',paddingLeft:'25px',paddingRight:'25px',backgroundColor:'#
|
|
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,28 +1,24 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
-
import { useContext } from "react";
|
|
4
3
|
|
|
5
4
|
export default function Button(props) {
|
|
6
5
|
return (
|
|
7
6
|
<>
|
|
8
|
-
{props.link
|
|
7
|
+
{props.link ? (
|
|
9
8
|
<>
|
|
10
9
|
<View
|
|
11
10
|
{...props.attributes}
|
|
11
|
+
role="button"
|
|
12
12
|
href={props.link}
|
|
13
13
|
target={props.openLinkInNewTab ? "_blank" : undefined}
|
|
14
14
|
>
|
|
15
|
-
{props.text}
|
|
16
|
-
</View>
|
|
17
|
-
</>
|
|
18
|
-
)}
|
|
19
|
-
|
|
20
|
-
{!props.link && (
|
|
21
|
-
<>
|
|
22
|
-
<View {...props.attributes} type="button">
|
|
23
|
-
{props.text}
|
|
15
|
+
<Text>{props.text}</Text>
|
|
24
16
|
</View>
|
|
25
17
|
</>
|
|
18
|
+
) : (
|
|
19
|
+
<View {...props.attributes}>
|
|
20
|
+
<Text>{props.text}</Text>
|
|
21
|
+
</View>
|
|
26
22
|
)}
|
|
27
23
|
</>
|
|
28
24
|
);
|
package/src/blocks/columns.js
CHANGED
|
@@ -4,6 +4,7 @@ import { registerComponent } from '../functions/register-component';
|
|
|
4
4
|
import { View, StyleSheet } from "react-native";
|
|
5
5
|
import RenderBlocks from "../components/render-blocks";
|
|
6
6
|
function Columns(props) {
|
|
7
|
+
var _a;
|
|
7
8
|
function getGutterSize() {
|
|
8
9
|
return typeof props.space === "number" ? props.space || 0 : 20;
|
|
9
10
|
}
|
|
@@ -11,37 +12,52 @@ function getColumns() {
|
|
|
11
12
|
return props.columns || [];
|
|
12
13
|
}
|
|
13
14
|
function getWidth(index) {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
var _a2;
|
|
16
|
+
const columns = getColumns();
|
|
17
|
+
return ((_a2 = columns[index]) == null ? void 0 : _a2.width) || 100 / columns.length;
|
|
16
18
|
}
|
|
17
19
|
function getColumnCssWidth(index) {
|
|
18
|
-
const columns =
|
|
19
|
-
const gutterSize =
|
|
20
|
+
const columns = getColumns();
|
|
21
|
+
const gutterSize = getGutterSize();
|
|
20
22
|
const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
|
|
21
|
-
return `calc(${
|
|
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
|
+
};
|
|
22
45
|
}
|
|
23
46
|
return /* @__PURE__ */ React.createElement(View, {
|
|
24
|
-
className: "builder-columns",
|
|
25
47
|
style: styles.view1
|
|
26
|
-
}, props.columns.map((column) => /* @__PURE__ */ React.createElement(View, {
|
|
27
|
-
className: "builder-column",
|
|
48
|
+
}, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement(View, {
|
|
28
49
|
style: styles.view2
|
|
29
50
|
}, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
30
51
|
blocks: column.blocks
|
|
31
52
|
}))));
|
|
32
53
|
}
|
|
33
54
|
const styles = StyleSheet.create({
|
|
34
|
-
view1: {
|
|
35
|
-
|
|
36
|
-
flexDirection: "column",
|
|
37
|
-
alignItems: "stretch",
|
|
38
|
-
lineHeight: "normal"
|
|
39
|
-
},
|
|
40
|
-
view2: { flexGrow: "1" }
|
|
55
|
+
view1: { display: "flex", alignItems: "stretch" },
|
|
56
|
+
view2: { flexGrow: 1 }
|
|
41
57
|
});
|
|
42
58
|
export {
|
|
43
59
|
Columns as default
|
|
44
60
|
};
|
|
45
61
|
|
|
46
62
|
|
|
47
|
-
registerComponent(Columns, {name:'Columns',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}]});
|
|
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,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
-
import { useState, useContext } from "react";
|
|
4
3
|
import RenderBlocks from "../components/render-blocks.lite";
|
|
5
4
|
|
|
6
5
|
export default function Columns(props) {
|
|
@@ -13,21 +12,50 @@ export default function Columns(props) {
|
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
function getWidth(index) {
|
|
16
|
-
const columns =
|
|
17
|
-
return
|
|
15
|
+
const columns = getColumns();
|
|
16
|
+
return columns[index]?.width || 100 / columns.length;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
function getColumnCssWidth(index) {
|
|
21
|
-
const columns =
|
|
22
|
-
const gutterSize =
|
|
20
|
+
const columns = getColumns();
|
|
21
|
+
const gutterSize = getGutterSize();
|
|
23
22
|
const subtractWidth = (gutterSize * (columns.length - 1)) / columns.length;
|
|
24
|
-
return `calc(${
|
|
23
|
+
return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function maybeApplyForTablet(prop) {
|
|
27
|
+
const stackColumnsAt = props.stackColumnsAt || "tablet";
|
|
28
|
+
return stackColumnsAt === "tablet" ? prop : "inherit";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function columnsCssVars() {
|
|
32
|
+
const flexDir =
|
|
33
|
+
props.stackColumnsAt === "never"
|
|
34
|
+
? "inherit"
|
|
35
|
+
: props.reverseColumnsWhenStacked
|
|
36
|
+
? "column-reverse"
|
|
37
|
+
: "column";
|
|
38
|
+
return {
|
|
39
|
+
"--flex-dir": flexDir,
|
|
40
|
+
"--flex-dir-tablet": maybeApplyForTablet(flexDir),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function columnCssVars() {
|
|
45
|
+
const width = "100%";
|
|
46
|
+
const marginLeft = "0";
|
|
47
|
+
return {
|
|
48
|
+
"--column-width": width,
|
|
49
|
+
"--column-margin-left": marginLeft,
|
|
50
|
+
"--column-width-tablet": maybeApplyForTablet(width),
|
|
51
|
+
"--column-margin-left-tablet": maybeApplyForTablet(marginLeft),
|
|
52
|
+
};
|
|
25
53
|
}
|
|
26
54
|
|
|
27
55
|
return (
|
|
28
|
-
<View
|
|
29
|
-
{props.columns
|
|
30
|
-
<View
|
|
56
|
+
<View style={styles.view1}>
|
|
57
|
+
{props.columns?.map((column, index) => (
|
|
58
|
+
<View style={styles.view2}>
|
|
31
59
|
<RenderBlocks blocks={column.blocks} />
|
|
32
60
|
</View>
|
|
33
61
|
))}
|
|
@@ -36,11 +64,6 @@ export default function Columns(props) {
|
|
|
36
64
|
}
|
|
37
65
|
|
|
38
66
|
const styles = StyleSheet.create({
|
|
39
|
-
view1: {
|
|
40
|
-
|
|
41
|
-
flexDirection: "column",
|
|
42
|
-
alignItems: "stretch",
|
|
43
|
-
lineHeight: "normal",
|
|
44
|
-
},
|
|
45
|
-
view2: { flexGrow: "1" },
|
|
67
|
+
view1: { display: "flex", alignItems: "stretch" },
|
|
68
|
+
view2: { flexGrow: 1 },
|
|
46
69
|
});
|
|
@@ -44,7 +44,6 @@ useEffect(() => {
|
|
|
44
44
|
}, []);
|
|
45
45
|
return /* @__PURE__ */ React.createElement(View, {
|
|
46
46
|
ref: elem,
|
|
47
|
-
className: "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""),
|
|
48
47
|
dangerouslySetInnerHTML: { __html: "props.code" }
|
|
49
48
|
});
|
|
50
49
|
}
|
|
@@ -53,4 +52,4 @@ CustomCode as default
|
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
|
|
56
|
-
registerComponent(CustomCode, {name:'Custom Code',static:true,requiredPermissions:['editCode'],inputs:[{name:'code',type:'html',required:true,defaultValue:'<p>Hello there, I am custom HTML code!</p>',code:true},{name:'replaceNodes',type:'boolean',helperText:'Preserve server rendered dom nodes',advanced:true},{name:'scriptsClientOnly',type:'boolean',defaultValue:false,helperText:'Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads',advanced:true}]});
|
|
55
|
+
registerComponent(CustomCode, {name:'Custom Code',static:true,builtIn:true,requiredPermissions:['editCode'],inputs:[{name:'code',type:'html',required:true,defaultValue:'<p>Hello there, I am custom HTML code!</p>',code:true},{name:'replaceNodes',type:'boolean',helperText:'Preserve server rendered dom nodes',advanced:true},{name:'scriptsClientOnly',type:'boolean',defaultValue:false,helperText:'Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads',advanced:true}]});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
-
import { useState,
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
4
|
|
|
5
5
|
export default function CustomCode(props) {
|
|
6
6
|
const [scriptsInserted, setScriptsInserted] = useState(() => []);
|
|
@@ -55,13 +55,5 @@ export default function CustomCode(props) {
|
|
|
55
55
|
findAndRunScripts();
|
|
56
56
|
}, []);
|
|
57
57
|
|
|
58
|
-
return
|
|
59
|
-
<View
|
|
60
|
-
ref={elem}
|
|
61
|
-
className={
|
|
62
|
-
"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")
|
|
63
|
-
}
|
|
64
|
-
dangerouslySetInnerHTML={{ __html: "props.code" }}
|
|
65
|
-
/>
|
|
66
|
-
);
|
|
58
|
+
return <View ref={elem} dangerouslySetInnerHTML={{ __html: "props.code" }} />;
|
|
67
59
|
}
|
package/src/blocks/embed.js
CHANGED
|
@@ -43,7 +43,6 @@ useEffect(() => {
|
|
|
43
43
|
findAndRunScripts();
|
|
44
44
|
}, []);
|
|
45
45
|
return /* @__PURE__ */ React.createElement(View, {
|
|
46
|
-
className: "builder-embed",
|
|
47
46
|
ref: elem,
|
|
48
47
|
dangerouslySetInnerHTML: { __html: "props.content" }
|
|
49
48
|
});
|
|
@@ -53,4 +52,4 @@ Embed as default
|
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
|
|
56
|
-
registerComponent(Embed, {name:'Embed',static:true,inputs:[{name:'url',type:'url',required:true,defaultValue:'',helperText:'e.g. enter a youtube url, google map, etc',onChange:" const url = options.get('url'); if (url) { options.set('content', 'Loading...'); // TODO: get this out of here! const apiKey = 'ae0e60e78201a3f2b0de4b'; return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`) .then(res => res.json()) .then(data => { if (options.get('url') === url) { if (data.html) { options.set('content', data.html); } else { options.set('content', 'Invalid url, please try another'); } } }) .catch(err => { options.set( 'content', 'There was an error embedding this URL, please try again or another URL' ); }); } else { options.delete('content'); } "},{name:'content',type:'html',defaultValue:'<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',hideFromUI:true}]});
|
|
55
|
+
registerComponent(Embed, {name:'Embed',static:true,builtIn:true,inputs:[{name:'url',type:'url',required:true,defaultValue:'',helperText:'e.g. enter a youtube url, google map, etc',onChange:" const url = options.get('url'); if (url) { options.set('content', 'Loading...'); // TODO: get this out of here! const apiKey = 'ae0e60e78201a3f2b0de4b'; return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`) .then(res => res.json()) .then(data => { if (options.get('url') === url) { if (data.html) { options.set('content', data.html); } else { options.set('content', 'Invalid url, please try another'); } } }) .catch(err => { options.set( 'content', 'There was an error embedding this URL, please try again or another URL' ); }); } else { options.delete('content'); } "},{name:'content',type:'html',defaultValue:'<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',hideFromUI:true}]});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
-
import { useState,
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
4
|
|
|
5
5
|
export default function Embed(props) {
|
|
6
6
|
const [scriptsInserted, setScriptsInserted] = useState(() => []);
|
|
@@ -56,10 +56,6 @@ export default function Embed(props) {
|
|
|
56
56
|
}, []);
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
|
-
<View
|
|
60
|
-
className="builder-embed"
|
|
61
|
-
ref={elem}
|
|
62
|
-
dangerouslySetInnerHTML={{ __html: "props.content" }}
|
|
63
|
-
/>
|
|
59
|
+
<View ref={elem} dangerouslySetInnerHTML={{ __html: "props.content" }} />
|
|
64
60
|
);
|
|
65
61
|
}
|
package/src/blocks/form.js
CHANGED
|
@@ -40,14 +40,11 @@ return new Promise((resolve, reject) => {
|
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
42
|
import * as React from "react";
|
|
43
|
-
import { View, StyleSheet } from "react-native";
|
|
43
|
+
import { View, StyleSheet, Text } from "react-native";
|
|
44
44
|
import { useState, useRef } from "react";
|
|
45
|
-
import
|
|
46
|
-
import { BuilderBlocks } from "@dummy";
|
|
47
|
-
import { set } from "@dummy";
|
|
48
|
-
import { get } from "@dummy";
|
|
45
|
+
import RenderBlock from "../components/render-block";
|
|
49
46
|
function FormComponent(props) {
|
|
50
|
-
var _a;
|
|
47
|
+
var _a, _b;
|
|
51
48
|
const [state, setState] = useState(() => "unsubmitted");
|
|
52
49
|
const [responseData, setResponseData] = useState(() => null);
|
|
53
50
|
const [formErrorMessage, setFormErrorMessage] = useState(() => "");
|
|
@@ -202,28 +199,27 @@ return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}
|
|
|
202
199
|
method: props.method,
|
|
203
200
|
name: props.name,
|
|
204
201
|
onSubmit: (event) => onSubmit(event)
|
|
205
|
-
}), " ", props.builderBlock && props.builderBlock.children
|
|
202
|
+
}), " ", props.builderBlock && props.builderBlock.children ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.map((block, index) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
206
203
|
block
|
|
207
|
-
}))), " ", submissionState() === "error"
|
|
204
|
+
}))) : null, " ", submissionState() === "error" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
|
|
208
205
|
dataPath: "errorMessage",
|
|
209
206
|
blocks: props.errorMessage
|
|
210
|
-
})), " ", submissionState() === "sending"
|
|
207
|
+
})) : null, " ", submissionState() === "sending" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
|
|
211
208
|
dataPath: "sendingMessage",
|
|
212
209
|
blocks: props.sendingMessage
|
|
213
|
-
})), " ", submissionState() === "error" && responseData
|
|
214
|
-
className: "builder-form-error-text",
|
|
210
|
+
})) : null, " ", submissionState() === "error" && responseData ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
|
|
215
211
|
style: styles.view1
|
|
216
|
-
}, " ", JSON.stringify(responseData, null, 2), " ")), " ", submissionState() === "success"
|
|
212
|
+
}, " ", /* @__PURE__ */ React.createElement(Text, null, JSON.stringify(responseData, null, 2)), " ")) : null, " ", submissionState() === "success" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
|
|
217
213
|
dataPath: "successMessage",
|
|
218
214
|
blocks: props.successMessage
|
|
219
|
-
})), " ");
|
|
215
|
+
})) : null, " ");
|
|
220
216
|
}
|
|
221
217
|
const styles = StyleSheet.create({
|
|
222
|
-
view1: { padding:
|
|
218
|
+
view1: { padding: 10, color: "red", textAlign: "center" }
|
|
223
219
|
});
|
|
224
220
|
export {
|
|
225
221
|
FormComponent as default
|
|
226
222
|
};
|
|
227
223
|
|
|
228
224
|
|
|
229
|
-
registerComponent(FormComponent, {name:'Form:Form',defaults:{responsiveStyles:{large:{marginTop:'15px',paddingBottom:'15px'}}},image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fef36d2a846134910b64b88e6d18c5ca5',inputs:[{name:'sendSubmissionsTo',type:'string',enum:[{label:'Send to email',value:'email',helperText:'Send form submissions to the email address of your choosing'},{label:'Custom',value:'custom',helperText:'Handle where the form requests go manually with a little code, e.g. to your own custom backend'}],defaultValue:'email'},{name:'sendSubmissionsToEmail',type:'string',required:true,defaultValue:'your@email.com',showIf:'options.get("sendSubmissionsTo") === "email"'},{name:'sendWithJs',type:'boolean',helperText:'Set to false to use basic html form action',defaultValue:true,showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:'name',type:'string',defaultValue:'My form'},{name:'action',type:'string',helperText:'URL to send the form data to',showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:'contentType',type:'string',defaultValue:'application/json',advanced:true,enum:['application/json','multipart/form-data','application/x-www-form-urlencoded'],showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'},{name:'method',type:'string',showIf:'options.get("sendSubmissionsTo") === "custom"',defaultValue:'POST',advanced:true},{name:'previewState',type:'string',enum:['unsubmitted','sending','success','error'],defaultValue:'unsubmitted',helperText:'Choose a state to edit, e.g. choose "success" to show what users see on success and edit the message',showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:'successUrl',type:'url',helperText:'Optional URL to redirect the user to on form submission success',showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:'resetFormOnSubmit',type:'boolean',showIf:"options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",advanced:true},{name:'successMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Thanks!</span>'}}}]},{name:'validate',type:'boolean',defaultValue:true,advanced:true},{name:'errorMessagePath',type:'text',advanced:true,helperText:'Path to where to get the error message from in a JSON response to display to the user, e.g. "error.message" for a response like { "error": { "message": "this username is taken" }}'},{name:'errorMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},bindings:{'component.options.text':'state.formErrorMessage || block.component.options.text'},component:{name:'Text',options:{text:'<span>Form submission error :( Please check your answers and try again</span>'}}}]},{name:'sendingMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Sending...</span>'}}}]},{name:'customHeaders',type:'map',valueType:{type:'string'},advanced:true,showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'}],noWrap:true,canHaveChildren:true,defaultChildren:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Enter your name</span>'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:Input',options:{name:'name',placeholder:'Jane Doe'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Enter your email</span>'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:Input',options:{name:'email',placeholder:'jane@doe.com'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:SubmitButton',options:{text:'Submit'}}}]});
|
|
225
|
+
registerComponent(FormComponent, {name:'Form:Form',builtIn:true,defaults:{responsiveStyles:{large:{marginTop:'15px',paddingBottom:'15px'}}},image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fef36d2a846134910b64b88e6d18c5ca5',inputs:[{name:'sendSubmissionsTo',type:'string',enum:[{label:'Send to email',value:'email',helperText:'Send form submissions to the email address of your choosing'},{label:'Custom',value:'custom',helperText:'Handle where the form requests go manually with a little code, e.g. to your own custom backend'}],defaultValue:'email'},{name:'sendSubmissionsToEmail',type:'string',required:true,defaultValue:'your@email.com',showIf:'options.get("sendSubmissionsTo") === "email"'},{name:'sendWithJs',type:'boolean',helperText:'Set to false to use basic html form action',defaultValue:true,showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:'name',type:'string',defaultValue:'My form'},{name:'action',type:'string',helperText:'URL to send the form data to',showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:'contentType',type:'string',defaultValue:'application/json',advanced:true,enum:['application/json','multipart/form-data','application/x-www-form-urlencoded'],showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'},{name:'method',type:'string',showIf:'options.get("sendSubmissionsTo") === "custom"',defaultValue:'POST',advanced:true},{name:'previewState',type:'string',enum:['unsubmitted','sending','success','error'],defaultValue:'unsubmitted',helperText:'Choose a state to edit, e.g. choose "success" to show what users see on success and edit the message',showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:'successUrl',type:'url',helperText:'Optional URL to redirect the user to on form submission success',showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:'resetFormOnSubmit',type:'boolean',showIf:"options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",advanced:true},{name:'successMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Thanks!</span>'}}}]},{name:'validate',type:'boolean',defaultValue:true,advanced:true},{name:'errorMessagePath',type:'text',advanced:true,helperText:'Path to where to get the error message from in a JSON response to display to the user, e.g. "error.message" for a response like { "error": { "message": "this username is taken" }}'},{name:'errorMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},bindings:{'component.options.text':'state.formErrorMessage || block.component.options.text'},component:{name:'Text',options:{text:'<span>Form submission error :( Please check your answers and try again</span>'}}}]},{name:'sendingMessage',type:'uiBlocks',hideFromUI:true,defaultValue:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Sending...</span>'}}}]},{name:'customHeaders',type:'map',valueType:{type:'string'},advanced:true,showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'}],noWrap:true,canHaveChildren:true,defaultChildren:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Enter your name</span>'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:Input',options:{name:'name',placeholder:'Jane Doe'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Text',options:{text:'<span>Enter your email</span>'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:Input',options:{name:'email',placeholder:'jane@doe.com'}}},{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{marginTop:'10px'}},component:{name:'Form:SubmitButton',options:{text:'Submit'}}}]});
|
package/src/blocks/form.lite.tsx
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
-
import { useState,
|
|
4
|
-
import
|
|
5
|
-
import { Builder, builder } from "@builder.io/sdk";
|
|
6
|
-
import { BuilderBlocks } from "@dummy";
|
|
7
|
-
import { set } from "@dummy";
|
|
8
|
-
import { get } from "@dummy";
|
|
3
|
+
import { useState, useRef } from "react";
|
|
4
|
+
import RenderBlock from "../components/render-block.lite";
|
|
9
5
|
|
|
10
6
|
export default function FormComponent(props) {
|
|
11
7
|
const [state, setState] = useState(() => "unsubmitted");
|
|
@@ -145,7 +141,7 @@ export default function FormComponent(props) {
|
|
|
145
141
|
get(body, props.errorMessagePath);
|
|
146
142
|
if (message) {
|
|
147
143
|
if (typeof message !== "string") {
|
|
148
|
-
/* TODO: ideally convert json to yaml so it woul dbe like
|
|
144
|
+
/* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
|
|
149
145
|
JSON.stringify(message);
|
|
150
146
|
}
|
|
151
147
|
setFormErrorMessage(message);
|
|
@@ -213,45 +209,45 @@ export default function FormComponent(props) {
|
|
|
213
209
|
onSubmit={(event) => onSubmit(event)}
|
|
214
210
|
>
|
|
215
211
|
{" "}
|
|
216
|
-
{props.builderBlock && props.builderBlock.children
|
|
212
|
+
{props.builderBlock && props.builderBlock.children ? (
|
|
217
213
|
<>
|
|
218
|
-
{props.builderBlock?.children
|
|
219
|
-
<
|
|
214
|
+
{props.builderBlock?.children?.map((block, index) => (
|
|
215
|
+
<RenderBlock block={block} />
|
|
220
216
|
))}
|
|
221
217
|
</>
|
|
222
|
-
)}{" "}
|
|
223
|
-
{submissionState() === "error"
|
|
218
|
+
) : null}{" "}
|
|
219
|
+
{submissionState() === "error" ? (
|
|
224
220
|
<>
|
|
225
221
|
<BuilderBlocks dataPath="errorMessage" blocks={props.errorMessage} />
|
|
226
222
|
</>
|
|
227
|
-
)}{" "}
|
|
228
|
-
{submissionState() === "sending"
|
|
223
|
+
) : null}{" "}
|
|
224
|
+
{submissionState() === "sending" ? (
|
|
229
225
|
<>
|
|
230
226
|
<BuilderBlocks
|
|
231
227
|
dataPath="sendingMessage"
|
|
232
228
|
blocks={props.sendingMessage}
|
|
233
229
|
/>
|
|
234
230
|
</>
|
|
235
|
-
)}{" "}
|
|
236
|
-
{submissionState() === "error" && responseData
|
|
231
|
+
) : null}{" "}
|
|
232
|
+
{submissionState() === "error" && responseData ? (
|
|
237
233
|
<>
|
|
238
|
-
<View
|
|
234
|
+
<View style={styles.view1}>
|
|
239
235
|
{" "}
|
|
240
|
-
{JSON.stringify(responseData, null, 2)}{" "}
|
|
236
|
+
<Text>{JSON.stringify(responseData, null, 2)}</Text>{" "}
|
|
241
237
|
</View>
|
|
242
238
|
</>
|
|
243
|
-
)}{" "}
|
|
244
|
-
{submissionState() === "success"
|
|
239
|
+
) : null}{" "}
|
|
240
|
+
{submissionState() === "success" ? (
|
|
245
241
|
<>
|
|
246
242
|
<BuilderBlocks
|
|
247
243
|
dataPath="successMessage"
|
|
248
244
|
blocks={props.successMessage}
|
|
249
245
|
/>
|
|
250
246
|
</>
|
|
251
|
-
)}{" "}
|
|
247
|
+
) : null}{" "}
|
|
252
248
|
</View>
|
|
253
249
|
);
|
|
254
250
|
}
|
|
255
251
|
const styles = StyleSheet.create({
|
|
256
|
-
view1: { padding:
|
|
252
|
+
view1: { padding: 10, color: "red", textAlign: "center" },
|
|
257
253
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { registerComponent } from '../functions/register-component';
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { View, Text } from "react-native";
|
|
5
|
+
function FragmentComponent(props) {
|
|
6
|
+
return /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(Text, null, props.children));
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
FragmentComponent as default
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
registerComponent(FragmentComponent, {name:'Fragment',static:true,hidden:true,builtIn:true,canHaveChildren:true,noWrap:true});
|
package/src/blocks/image.js
CHANGED
|
@@ -1,26 +1,46 @@
|
|
|
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) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __spreadValues = (a, b) => {
|
|
8
|
+
for (var prop in b || (b = {}))
|
|
9
|
+
if (__hasOwnProp.call(b, prop))
|
|
10
|
+
__defNormalProp(a, prop, b[prop]);
|
|
11
|
+
if (__getOwnPropSymbols)
|
|
12
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
13
|
+
if (__propIsEnum.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
}
|
|
16
|
+
return a;
|
|
17
|
+
};
|
|
2
18
|
import { Image as ReactImage, View } from "react-native";
|
|
3
19
|
import { registerComponent } from "../functions/register-component";
|
|
4
20
|
function Image(props) {
|
|
5
|
-
return /* @__PURE__ */ React.createElement(View, {
|
|
21
|
+
return props.aspectRatio ? /* @__PURE__ */ React.createElement(View, {
|
|
6
22
|
style: { position: "relative" }
|
|
7
23
|
}, /* @__PURE__ */ React.createElement(ReactImage, {
|
|
8
24
|
resizeMode: props.backgroundSize || "contain",
|
|
9
25
|
style: { position: "absolute", top: 0, bottom: 0, left: 0, right: 0 },
|
|
10
26
|
source: { uri: props.image }
|
|
11
|
-
}), /* @__PURE__ */ React.createElement(
|
|
12
|
-
className: "builder-image-sizer",
|
|
27
|
+
}), /* @__PURE__ */ React.createElement(View, {
|
|
13
28
|
style: {
|
|
14
29
|
width: "100%",
|
|
15
|
-
paddingTop: props.aspectRatio * 100 + "%"
|
|
16
|
-
pointerEvents: "none",
|
|
17
|
-
fontSize: 0
|
|
30
|
+
paddingTop: props.aspectRatio * 100 + "%"
|
|
18
31
|
}
|
|
19
|
-
},
|
|
32
|
+
})) : /* @__PURE__ */ React.createElement(ReactImage, {
|
|
33
|
+
resizeMode: props.backgroundSize || "contain",
|
|
34
|
+
style: __spreadValues(__spreadValues({
|
|
35
|
+
position: "relative"
|
|
36
|
+
}, props.width ? { width: props.width } : {}), props.height ? { height: props.height } : {}),
|
|
37
|
+
source: { uri: props.image }
|
|
38
|
+
});
|
|
20
39
|
}
|
|
21
40
|
registerComponent(Image, {
|
|
22
41
|
name: "Image",
|
|
23
42
|
static: true,
|
|
43
|
+
builtIn: true,
|
|
24
44
|
image: "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",
|
|
25
45
|
defaultStyles: {
|
|
26
46
|
position: "relative",
|