@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.
Files changed (83) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +15 -0
  3. package/package.json +6 -4
  4. package/src/blocks/button.js +5 -6
  5. package/src/blocks/button.lite.tsx +7 -11
  6. package/src/blocks/columns.js +32 -16
  7. package/src/blocks/columns.lite.tsx +39 -16
  8. package/src/blocks/custom-code.js +1 -2
  9. package/src/blocks/custom-code.lite.tsx +2 -10
  10. package/src/blocks/embed.js +1 -2
  11. package/src/blocks/embed.lite.tsx +2 -6
  12. package/src/blocks/form.js +11 -15
  13. package/src/blocks/form.lite.tsx +18 -22
  14. package/src/blocks/fragment.js +13 -0
  15. package/src/blocks/fragment.lite.tsx +10 -0
  16. package/src/blocks/image.js +27 -7
  17. package/src/blocks/image.lite.tsx +42 -10
  18. package/src/blocks/img.js +3 -3
  19. package/src/blocks/img.lite.tsx +2 -3
  20. package/src/blocks/input.js +3 -3
  21. package/src/blocks/input.lite.tsx +2 -5
  22. package/src/blocks/raw-text.js +1 -3
  23. package/src/blocks/raw-text.lite.tsx +1 -7
  24. package/src/blocks/section.js +3 -3
  25. package/src/blocks/section.lite.tsx +1 -2
  26. package/src/blocks/select.js +7 -6
  27. package/src/blocks/select.lite.tsx +6 -7
  28. package/src/blocks/submit-button.js +3 -3
  29. package/src/blocks/submit-button.lite.tsx +1 -2
  30. package/src/blocks/symbol.js +65 -12
  31. package/src/blocks/symbol.lite.tsx +44 -4
  32. package/src/blocks/text.js +57 -1
  33. package/src/blocks/text.lite.tsx +1 -7
  34. package/src/blocks/textarea.js +1 -1
  35. package/src/blocks/textarea.lite.tsx +0 -1
  36. package/src/blocks/video.js +90 -44
  37. package/src/blocks/video.lite.tsx +0 -1
  38. package/src/components/block-styles.js +7 -0
  39. package/src/components/block-styles.lite.tsx +6 -0
  40. package/src/components/error-boundary.js +25 -0
  41. package/src/components/error-boundary.lite.tsx +6 -0
  42. package/src/components/render-block.js +43 -19
  43. package/src/components/render-block.lite.tsx +69 -34
  44. package/src/components/render-blocks.js +12 -5
  45. package/src/components/render-blocks.lite.tsx +16 -7
  46. package/src/components/render-content.js +224 -24
  47. package/src/components/render-content.lite.tsx +247 -34
  48. package/src/context/builder.context.js +6 -1
  49. package/src/functions/evaluate.js +15 -6
  50. package/src/functions/event-handler-name.js +8 -0
  51. package/src/functions/get-block-actions.js +13 -12
  52. package/src/functions/get-block-component-options.js +17 -1
  53. package/src/functions/get-block-properties.js +7 -4
  54. package/src/functions/get-block-styles.js +31 -1
  55. package/src/functions/get-builder-search-params/fn.test.js +14 -0
  56. package/src/functions/get-builder-search-params/index.js +23 -0
  57. package/src/functions/get-content/fn.test.js +32 -0
  58. package/src/functions/get-content/index.js +138 -0
  59. package/src/functions/get-fetch.js +13 -0
  60. package/src/functions/get-global-this.js +19 -0
  61. package/src/functions/get-processed-block.js +3 -1
  62. package/src/functions/get-processed-block.test.js +12 -7
  63. package/src/functions/get-target.js +1 -1
  64. package/src/functions/is-browser.js +1 -2
  65. package/src/functions/is-previewing.js +15 -0
  66. package/src/functions/is-react-native.js +1 -1
  67. package/src/functions/on-change.test.js +0 -1
  68. package/src/functions/previewing-model-name.js +12 -0
  69. package/src/functions/register-component.js +1 -0
  70. package/src/functions/register.js +30 -0
  71. package/src/functions/set-editor-settings.js +16 -0
  72. package/src/functions/set.test.js +0 -1
  73. package/src/functions/track.js +5 -1
  74. package/src/functions/transform-block.js +38 -0
  75. package/src/index-helpers/blocks-exports.js +19 -0
  76. package/src/index-helpers/top-of-file.js +2 -0
  77. package/src/index.js +8 -18
  78. package/src/scripts/init-editing.js +18 -2
  79. package/src/types/deep-partial.js +1 -0
  80. package/src/types/typescript.js +1 -0
  81. package/index.js +0 -11
  82. package/src/functions/get-content.js +0 -103
  83. package/src/package.json +0 -18
@@ -1,35 +1,67 @@
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 Image(props) {
6
5
  return (
7
- <>
6
+ <View style={styles.view1}>
8
7
  <View>
9
8
  <View
10
9
  loading="lazy"
11
10
  alt={props.altText}
12
11
  aria-role={props.altText ? "presentation" : undefined}
13
- className={"builder-image" + (props.class ? " " + props.class : "")}
12
+ style={styles.view2}
14
13
  src={props.image}
15
14
  srcset={props.srcset}
16
15
  sizes={props.sizes}
17
- style={styles.view1}
18
16
  />
19
17
 
20
18
  <View srcSet={props.srcset} />
21
19
  </View>
22
20
 
23
- {props.children}
24
- </>
21
+ {props.aspectRatio &&
22
+ !(props.fitContent && props.builderBlock?.children?.length) ? (
23
+ <View style={styles.view3}>
24
+ <Text> </Text>
25
+ </View>
26
+ ) : null}
27
+
28
+ {props.builderBlock?.children?.length && props.fitContent ? (
29
+ <>
30
+ <Text>{props.children}</Text>
31
+ </>
32
+ ) : null}
33
+
34
+ {!props.fitContent ? (
35
+ <>
36
+ <View style={styles.view4}>
37
+ <Text>{props.children}</Text>
38
+ </View>
39
+ </>
40
+ ) : null}
41
+ </View>
25
42
  );
26
43
  }
27
44
 
28
45
  const styles = StyleSheet.create({
29
- view1: {
30
- opacity: "1",
46
+ view1: { position: "relative" },
47
+ view2: {
48
+ opacity: 1,
31
49
  transition: "opacity 0.2s ease-in-out",
32
- objectFit: "cover",
33
- objectPosition: "center",
50
+ position: "absolute",
51
+ height: 100,
52
+ width: 100,
53
+ top: 0,
54
+ left: 0,
55
+ },
56
+ view3: { width: 100, pointerEvents: "none", fontSize: 0 },
57
+ view4: {
58
+ display: "flex",
59
+ flexDirection: "column",
60
+ alignItems: "stretch",
61
+ position: "absolute",
62
+ top: 0,
63
+ left: 0,
64
+ width: 100,
65
+ height: 100,
34
66
  },
35
67
  });
package/src/blocks/img.js CHANGED
@@ -21,14 +21,14 @@ return a;
21
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
22
  import * as React from "react";
23
23
  import { View } from "react-native";
24
- import { Builder } from "@builder.io/sdk";
24
+ import { isEditing } from "../functions/is-editing";
25
25
  function ImgComponent(props) {
26
26
  return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
27
27
  style: {
28
28
  objectFit: props.backgroundSize || "cover",
29
29
  objectPosition: props.backgroundPosition || "center"
30
30
  },
31
- key: Builder.isEditing && props.imgSrc || "default-key",
31
+ key: isEditing() && props.imgSrc || "default-key",
32
32
  alt: props.altText,
33
33
  src: props.imgSrc
34
34
  }));
@@ -38,4 +38,4 @@ ImgComponent as default
38
38
  };
39
39
 
40
40
 
41
- registerComponent(ImgComponent, {name:'Raw:Img',hideFromInsertMenu:true,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',inputs:[{name:'image',bubble:true,type:'file',allowedFileTypes:['jpeg','jpg','png','svg'],required:true}],noWrap:true,static:true});
41
+ registerComponent(ImgComponent, {name:'Raw:Img',hideFromInsertMenu:true,builtIn:true,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',inputs:[{name:'image',bubble:true,type:'file',allowedFileTypes:['jpeg','jpg','png','svg'],required:true}],noWrap:true,static:true});
@@ -1,7 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useContext } from "react";
4
- import { Builder } from "@builder.io/sdk";
3
+ import { isEditing } from "../functions/is-editing";
5
4
 
6
5
  export default function ImgComponent(props) {
7
6
  return (
@@ -11,7 +10,7 @@ export default function ImgComponent(props) {
11
10
  objectFit: props.backgroundSize || "cover",
12
11
  objectPosition: props.backgroundPosition || "center",
13
12
  }}
14
- key={(Builder.isEditing && props.imgSrc) || "default-key"}
13
+ key={(isEditing() && props.imgSrc) || "default-key"}
15
14
  alt={props.altText}
16
15
  src={props.imgSrc}
17
16
  />
@@ -21,10 +21,10 @@ return a;
21
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
22
  import * as React from "react";
23
23
  import { View } from "react-native";
24
- import { Builder } from "@builder.io/sdk";
24
+ import { isEditing } from "../functions/is-editing";
25
25
  function FormInputComponent(props) {
26
26
  return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
27
- key: Builder.isEditing && props.defaultValue ? props.defaultValue : "default-key",
27
+ key: isEditing() && props.defaultValue ? props.defaultValue : "default-key",
28
28
  placeholder: props.placeholder,
29
29
  type: props.type,
30
30
  name: props.name,
@@ -38,4 +38,4 @@ FormInputComponent as default
38
38
  };
39
39
 
40
40
 
41
- registerComponent(FormInputComponent, {name:'Form:Input',image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca',inputs:[{name:'type',type:'text',enum:['text','number','email','url','checkbox','radio','range','date','datetime-local','search','tel','time','file','month','week','password','color','hidden'],defaultValue:'text'},{name:'name',type:'string',required:true,helperText:'Every input in a form needs a unique name describing what it takes, e.g. "email"'},{name:'placeholder',type:'string',defaultValue:'Hello there',helperText:'Text to display when there is no value'},{name:'defaultValue',type:'string'},{name:'value',type:'string',advanced:true},{name:'required',type:'boolean',helperText:'Is this input required to be filled out to submit a form',defaultValue:false}],noWrap:true,static:true,defaultStyles:{paddingTop:'10px',paddingBottom:'10px',paddingLeft:'10px',paddingRight:'10px',borderRadius:'3px',borderWidth:'1px',borderStyle:'solid',borderColor:'#ccc'}});
41
+ registerComponent(FormInputComponent, {name:'Form:Input',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca',inputs:[{name:'type',type:'text',enum:['text','number','email','url','checkbox','radio','range','date','datetime-local','search','tel','time','file','month','week','password','color','hidden'],defaultValue:'text'},{name:'name',type:'string',required:true,helperText:'Every input in a form needs a unique name describing what it takes, e.g. "email"'},{name:'placeholder',type:'string',defaultValue:'Hello there',helperText:'Text to display when there is no value'},{name:'defaultValue',type:'string'},{name:'value',type:'string',advanced:true},{name:'required',type:'boolean',helperText:'Is this input required to be filled out to submit a form',defaultValue:false}],noWrap:true,static:true,defaultStyles:{paddingTop:'10px',paddingBottom:'10px',paddingLeft:'10px',paddingRight:'10px',borderRadius:'3px',borderWidth:'1px',borderStyle:'solid',borderColor:'#ccc'}});
@@ -1,16 +1,13 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useContext } from "react";
4
- import { Builder } from "@builder.io/sdk";
3
+ import { isEditing } from "../functions/is-editing";
5
4
 
6
5
  export default function FormInputComponent(props) {
7
6
  return (
8
7
  <View
9
8
  {...props.attributes}
10
9
  key={
11
- Builder.isEditing && props.defaultValue
12
- ? props.defaultValue
13
- : "default-key"
10
+ isEditing() && props.defaultValue ? props.defaultValue : "default-key"
14
11
  }
15
12
  placeholder={props.placeholder}
16
13
  type={props.type}
@@ -3,9 +3,7 @@ import { registerComponent } from '../functions/register-component';
3
3
  import * as React from "react";
4
4
  import { View } from "react-native";
5
5
  function RawText(props) {
6
- var _a, _b;
7
6
  return /* @__PURE__ */ React.createElement(View, {
8
- className: ((_a = props.attributes) == null ? void 0 : _a.class) || ((_b = props.attributes) == null ? void 0 : _b.className),
9
7
  dangerouslySetInnerHTML: { __html: "props.text || ''" }
10
8
  });
11
9
  }
@@ -14,4 +12,4 @@ RawText as default
14
12
  };
15
13
 
16
14
 
17
- registerComponent(RawText, {name:'Builder:RawText',hideFromInsertMenu:true,inputs:[{name:'text',bubble:true,type:'longText',required:true}]});
15
+ registerComponent(RawText, {name:'Builder:RawText',hideFromInsertMenu:true,builtIn:true,inputs:[{name:'text',bubble:true,type:'longText',required:true}]});
@@ -1,12 +1,6 @@
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 RawText(props) {
6
- return (
7
- <View
8
- className={props.attributes?.class || props.attributes?.className}
9
- dangerouslySetInnerHTML={{ __html: "props.text || ''" }}
10
- />
11
- );
5
+ return <View dangerouslySetInnerHTML={{ __html: "props.text || ''" }} />;
12
6
  }
@@ -20,17 +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 SectionComponent(props) {
25
25
  return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
26
26
  style: props.maxWidth && typeof props.maxWidth === "number" ? {
27
27
  maxWidth: props.maxWidth
28
28
  } : void 0
29
- }), props.children);
29
+ }), /* @__PURE__ */ React.createElement(Text, null, props.children));
30
30
  }
31
31
  export {
32
32
  SectionComponent as default
33
33
  };
34
34
 
35
35
 
36
- registerComponent(SectionComponent, {name:'Core:Section',static:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a',inputs:[{name:'maxWidth',type:'number',defaultValue:1200},{name:'lazyLoad',type:'boolean',defaultValue:false,advanced:true,description:'Only render this section when in view'}],defaultStyles:{paddingLeft:'20px',paddingRight:'20px',paddingTop:'50px',paddingBottom:'50px',marginTop:'0px',width:'100vw',marginLeft:'calc(50% - 50vw)'},canHaveChildren:true,defaultChildren:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{textAlign:'center'}},component:{name:'Text',options:{text:"<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"}}}]});
36
+ registerComponent(SectionComponent, {name:'Core:Section',static:true,builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a',inputs:[{name:'maxWidth',type:'number',defaultValue:1200},{name:'lazyLoad',type:'boolean',defaultValue:false,advanced:true,description:'Only render this section when in view'}],defaultStyles:{paddingLeft:'20px',paddingRight:'20px',paddingTop:'50px',paddingBottom:'50px',marginTop:'0px',width:'100vw',marginLeft:'calc(50% - 50vw)'},canHaveChildren:true,defaultChildren:[{'@type':'@builder.io/sdk:Element',responsiveStyles:{large:{textAlign:'center'}},component:{name:'Text',options:{text:"<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"}}}]});
@@ -1,6 +1,5 @@
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 SectionComponent(props) {
6
5
  return (
@@ -14,7 +13,7 @@ export default function SectionComponent(props) {
14
13
  : undefined
15
14
  }
16
15
  >
17
- {props.children}
16
+ <Text>{props.children}</Text>
18
17
  </View>
19
18
  );
20
19
  }
@@ -20,21 +20,22 @@ 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";
24
- import { Builder } from "@builder.io/sdk";
23
+ import { View, Text } from "react-native";
24
+ import { isEditing } from "../functions/is-editing";
25
25
  function SelectComponent(props) {
26
+ var _a;
26
27
  return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
27
28
  value: props.value,
28
- key: Builder.isEditing && props.defaultValue ? props.defaultValue : "default-key",
29
+ key: isEditing() && props.defaultValue ? props.defaultValue : "default-key",
29
30
  defaultValue: props.defaultValue,
30
31
  name: props.name
31
- }), props.options.map((option) => /* @__PURE__ */ React.createElement(View, {
32
+ }), (_a = props.options) == null ? void 0 : _a.map((option, index) => /* @__PURE__ */ React.createElement(View, {
32
33
  value: option.value
33
- }, option.name || option.value)));
34
+ }, /* @__PURE__ */ React.createElement(Text, null, option.name || option.value))));
34
35
  }
35
36
  export {
36
37
  SelectComponent as default
37
38
  };
38
39
 
39
40
 
40
- registerComponent(SelectComponent, {name:'Form:Select',image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F83acca093fb24aaf94dee136e9a4b045',defaultStyles:{alignSelf:'flex-start'},inputs:[{name:'options',type:'list',required:true,subFields:[{name:'value',type:'text',required:true},{name:'name',type:'text'}],defaultValue:[{value:'option 1'},{value:'option 2'}]},{name:'name',type:'string',required:true,helperText:'Every select in a form needs a unique name describing what it gets, e.g. "email"'},{name:'defaultValue',type:'string'},{name:'value',type:'string',advanced:true},{name:'required',type:'boolean',defaultValue:false}],static:true,noWrap:true});
41
+ registerComponent(SelectComponent, {name:'Form:Select',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F83acca093fb24aaf94dee136e9a4b045',defaultStyles:{alignSelf:'flex-start'},inputs:[{name:'options',type:'list',required:true,subFields:[{name:'value',type:'text',required:true},{name:'name',type:'text'}],defaultValue:[{value:'option 1'},{value:'option 2'}]},{name:'name',type:'string',required:true,helperText:'Every select in a form needs a unique name describing what it gets, e.g. "email"'},{name:'defaultValue',type:'string'},{name:'value',type:'string',advanced:true},{name:'required',type:'boolean',defaultValue:false}],static:true,noWrap:true});
@@ -1,7 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useContext } from "react";
4
- import { Builder } from "@builder.io/sdk";
3
+ import { isEditing } from "../functions/is-editing";
5
4
 
6
5
  export default function SelectComponent(props) {
7
6
  return (
@@ -9,15 +8,15 @@ export default function SelectComponent(props) {
9
8
  {...props.attributes}
10
9
  value={props.value}
11
10
  key={
12
- Builder.isEditing && props.defaultValue
13
- ? props.defaultValue
14
- : "default-key"
11
+ isEditing() && props.defaultValue ? props.defaultValue : "default-key"
15
12
  }
16
13
  defaultValue={props.defaultValue}
17
14
  name={props.name}
18
15
  >
19
- {props.options.map((option) => (
20
- <View value={option.value}>{option.name || option.value}</View>
16
+ {props.options?.map((option, index) => (
17
+ <View value={option.value}>
18
+ <Text>{option.name || option.value}</Text>
19
+ </View>
21
20
  ))}
22
21
  </View>
23
22
  );
@@ -20,15 +20,15 @@ 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 SubmitButton(props) {
25
25
  return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
26
26
  type: "submit"
27
- }), props.text);
27
+ }), /* @__PURE__ */ React.createElement(Text, null, props.text));
28
28
  }
29
29
  export {
30
30
  SubmitButton as default
31
31
  };
32
32
 
33
33
 
34
- registerComponent(SubmitButton, {name:'Form:SubmitButton',image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fdf2820ffed1f4349a94c40b3221f5b98',defaultStyles:{appearance:'none',paddingTop:'15px',paddingBottom:'15px',paddingLeft:'25px',paddingRight:'25px',backgroundColor:'#3898EC',color:'white',borderRadius:'4px',cursor:'pointer'},inputs:[{name:'text',type:'text',defaultValue:'Click me'}],static:true,noWrap:true});
34
+ registerComponent(SubmitButton, {name:'Form:SubmitButton',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fdf2820ffed1f4349a94c40b3221f5b98',defaultStyles:{appearance:'none',paddingTop:'15px',paddingBottom:'15px',paddingLeft:'25px',paddingRight:'25px',backgroundColor:'#3898EC',color:'white',borderRadius:'4px',cursor:'pointer'},inputs:[{name:'text',type:'text',defaultValue:'Click me'}],static:true,noWrap:true});
@@ -1,11 +1,10 @@
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 SubmitButton(props) {
6
5
  return (
7
6
  <View {...props.attributes} type="submit">
8
- {props.text}
7
+ <Text>{props.text}</Text>
9
8
  </View>
10
9
  );
11
10
  }
@@ -1,20 +1,73 @@
1
+ import { registerComponent } from '../functions/register-component';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
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;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1
22
  import * as React from "react";
2
23
  import { View } from "react-native";
3
- import { useContext } from "react";
24
+ import { useState, useContext, useEffect } from "react";
4
25
  import RenderContent from "../components/render-content";
5
26
  import BuilderContext from "../context/builder.context";
27
+ import { getContent } from "../functions/get-content";
6
28
  function Symbol(props) {
7
- var _a, _b, _c;
8
- const builderContext = useContext(BuilderContext);
9
- return /* @__PURE__ */ React.createElement(View, {
10
- className: "builder-symbol"
11
- }, /* @__PURE__ */ React.createElement(RenderContent, {
12
- context: builderContext.context,
13
- data: (_a = props.symbol) == null ? void 0 : _a.data,
14
- model: (_b = props.symbol) == null ? void 0 : _b.model,
15
- content: (_c = props.symbol) == null ? void 0 : _c.content
16
- }));
29
+ var _a, _b, _c, _d, _e, _f, _g, _h;
30
+ const [className, setClassName] = useState(() => "builder-symbol");
31
+ const [content, setContent] = useState(() => null);
32
+ const builderContext = useContext(BuilderContext);
33
+ useEffect(() => {
34
+ var _a2;
35
+ setContent((_a2 = props.symbol) == null ? void 0 : _a2.content);
36
+ }, []);
37
+ useEffect(() => {
38
+ const symbol = props.symbol;
39
+ if (symbol && !symbol.content && !content && symbol.model) {
40
+ getContent({
41
+ model: symbol.model,
42
+ apiKey: builderContext.apiKey,
43
+ options: {
44
+ entry: symbol.entry
45
+ }
46
+ }).then((response) => {
47
+ setContent(response);
48
+ });
49
+ }
50
+ }, [
51
+ (_a = props.symbol) == null ? void 0 : _a.content,
52
+ (_b = props.symbol) == null ? void 0 : _b.model,
53
+ (_c = props.symbol) == null ? void 0 : _c.entry,
54
+ content
55
+ ]);
56
+ return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
57
+ dataSet: {
58
+ class: className
59
+ }
60
+ }), /* @__PURE__ */ React.createElement(RenderContent, {
61
+ apiKey: builderContext.apiKey,
62
+ context: builderContext.context,
63
+ data: __spreadValues(__spreadValues(__spreadValues({}, (_d = props.symbol) == null ? void 0 : _d.data), builderContext.state), (_g = (_f = (_e = props.symbol) == null ? void 0 : _e.content) == null ? void 0 : _f.data) == null ? void 0 : _g.state),
64
+ model: (_h = props.symbol) == null ? void 0 : _h.model,
65
+ content
66
+ }));
17
67
  }
18
68
  export {
19
- Symbol as default
69
+ Symbol as default
20
70
  };
71
+
72
+
73
+ registerComponent(Symbol, {name:'Symbol',noWrap:true,static:true,inputs:[{name:'symbol',type:'uiSymbol'},{name:'dataOnly',helperText:"Make this a data symbol that doesn't display any UI",type:'boolean',defaultValue:false,advanced:true,hideFromUI:true},{name:'inheritState',helperText:'Inherit the parent component state and data',type:'boolean',defaultValue:false,advanced:true},{name:'renderToLiquid',helperText:'Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting',type:'boolean',defaultValue:false,advanced:true,hideFromUI:true},{name:'useChildren',hideFromUI:true,type:'boolean'}]});
@@ -1,19 +1,59 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet, Image, Text } from "react-native";
3
- import { useContext } from "react";
3
+ import { useState, useContext, useEffect } from "react";
4
4
  import RenderContent from "../components/render-content.lite";
5
5
  import BuilderContext from "../context/builder.context.lite";
6
+ import { getContent } from "../functions/get-content";
6
7
 
7
8
  export default function Symbol(props) {
9
+ const [className, setClassName] = useState(() => "builder-symbol");
10
+
11
+ const [content, setContent] = useState(() => null);
12
+
8
13
  const builderContext = useContext(BuilderContext);
9
14
 
15
+ useEffect(() => {
16
+ setContent(props.symbol?.content);
17
+ }, []);
18
+
19
+ useEffect(() => {
20
+ const symbol = props.symbol;
21
+
22
+ if (symbol && !symbol.content && !content && symbol.model) {
23
+ getContent({
24
+ model: symbol.model,
25
+ apiKey: builderContext.apiKey,
26
+ options: {
27
+ entry: symbol.entry,
28
+ },
29
+ }).then((response) => {
30
+ setContent(response);
31
+ });
32
+ }
33
+ }, [
34
+ props.symbol?.content,
35
+ props.symbol?.model,
36
+ props.symbol?.entry,
37
+ content,
38
+ ]);
39
+
10
40
  return (
11
- <View className="builder-symbol">
41
+ <View
42
+ {...props.attributes}
43
+ dataSet={{
44
+ class: className,
45
+ }}
46
+ >
12
47
  <RenderContent
48
+ apiKey={builderContext.apiKey}
13
49
  context={builderContext.context}
14
- data={props.symbol?.data}
50
+ data={{
51
+ ...props.symbol?.data,
52
+ ...builderContext.state,
53
+ ...props.symbol?.content?.data?.state,
54
+ }}
15
55
  model={props.symbol?.model}
16
- content={props.symbol?.content}
56
+ content={content}
17
57
  />
18
58
  </View>
19
59
  );
@@ -1,14 +1,70 @@
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 HTML from "react-native-render-html";
3
19
  import { registerComponent } from "../functions/register-component";
20
+ function camelToKebabCase(string) {
21
+ return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
22
+ }
23
+ function pick(object, keys) {
24
+ return keys.reduce((obj, key) => {
25
+ if (object && object.hasOwnProperty(key)) {
26
+ obj[key] = object[key];
27
+ }
28
+ return obj;
29
+ }, {});
30
+ }
31
+ const PICK_STYLES = ["textAlign"];
32
+ function getBlockStyles(block) {
33
+ var _a, _b, _c;
34
+ const styles = __spreadValues(__spreadValues({}, (_a = block.responsiveStyles) == null ? void 0 : _a.large), block.styles);
35
+ if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
36
+ Object.assign(styles, block.responsiveStyles.medium);
37
+ }
38
+ if ((_c = block.responsiveStyles) == null ? void 0 : _c.small) {
39
+ Object.assign(styles, block.responsiveStyles.small);
40
+ }
41
+ return styles;
42
+ }
43
+ function getCss(block) {
44
+ const styleObject = pick(getBlockStyles(block), PICK_STYLES);
45
+ if (!styleObject) {
46
+ return "";
47
+ }
48
+ let str = ``;
49
+ for (const key in styleObject) {
50
+ const value = styleObject[key];
51
+ if (typeof value === "string") {
52
+ str += `${camelToKebabCase(key)}: ${value};`;
53
+ }
54
+ }
55
+ return str;
56
+ }
4
57
  function Text(props) {
5
58
  return /* @__PURE__ */ React.createElement(HTML, {
6
- source: { html: props.text }
59
+ source: {
60
+ html: `<div style="${getCss(props.builderBlock)}">${props.text || ""}</div>`
61
+ }
7
62
  });
8
63
  }
9
64
  registerComponent(Text, {
10
65
  name: "Text",
11
66
  static: true,
67
+ builtIn: true,
12
68
  image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
13
69
  inputs: [
14
70
  {
@@ -1,12 +1,6 @@
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 Text(props) {
6
- return (
7
- <View
8
- className="builder-text"
9
- dangerouslySetInnerHTML={{ __html: "props.text" }}
10
- />
11
- );
5
+ return <View dangerouslySetInnerHTML={{ __html: "props.text" }} />;
12
6
  }
@@ -34,4 +34,4 @@ Textarea as default
34
34
  };
35
35
 
36
36
 
37
- registerComponent(Textarea, {name:'Form:TextArea',image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3',inputs:[{advanced:true,name:'value',type:'string'},{name:'name',type:'string',required:true,helperText:'Every input in a form needs a unique name describing what it gets, e.g. "email"'},{name:'defaultValue',type:'string'},{name:'placeholder',type:'string',defaultValue:'Hello there'},{name:'required',type:'boolean',defaultValue:false}],defaultStyles:{paddingTop:'10px',paddingBottom:'10px',paddingLeft:'10px',paddingRight:'10px',borderRadius:'3px',borderWidth:'1px',borderStyle:'solid',borderColor:'#ccc'},static:true,noWrap:true});
37
+ registerComponent(Textarea, {name:'Form:TextArea',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3',inputs:[{advanced:true,name:'value',type:'string'},{name:'name',type:'string',required:true,helperText:'Every input in a form needs a unique name describing what it gets, e.g. "email"'},{name:'defaultValue',type:'string'},{name:'placeholder',type:'string',defaultValue:'Hello there'},{name:'required',type:'boolean',defaultValue:false}],defaultStyles:{paddingTop:'10px',paddingBottom:'10px',paddingLeft:'10px',paddingRight:'10px',borderRadius:'3px',borderWidth:'1px',borderStyle:'solid',borderColor:'#ccc'},static:true,noWrap:true});
@@ -1,6 +1,5 @@
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 Textarea(props) {
6
5
  return (