@builder.io/sdk-react-native 0.1.2 → 0.1.3

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 (178) hide show
  1. package/dist/blocks/BaseText.js +40 -0
  2. package/dist/blocks/button/button.js +39 -0
  3. package/dist/blocks/button/component-info.js +42 -0
  4. package/dist/blocks/columns/columns.js +149 -0
  5. package/dist/blocks/columns/component-info.js +244 -0
  6. package/dist/blocks/custom-code/component-info.js +32 -0
  7. package/dist/blocks/custom-code/custom-code.js +76 -0
  8. package/dist/blocks/embed/component-info.js +47 -0
  9. package/dist/blocks/embed/embed.js +67 -0
  10. package/dist/blocks/embed/helpers.js +10 -0
  11. package/dist/blocks/form/component-info.js +263 -0
  12. package/dist/blocks/form/form.js +232 -0
  13. package/dist/blocks/fragment/component-info.js +12 -0
  14. package/dist/blocks/fragment/fragment.js +36 -0
  15. package/dist/blocks/image/component-info.js +152 -0
  16. package/dist/blocks/image/image.helpers.js +49 -0
  17. package/dist/blocks/image/image.js +81 -0
  18. package/dist/blocks/img/component-info.js +21 -0
  19. package/dist/blocks/img/img.js +35 -0
  20. package/dist/blocks/input/component-info.js +75 -0
  21. package/dist/blocks/input/input.js +32 -0
  22. package/dist/blocks/raw-text/component-info.js +17 -0
  23. package/dist/blocks/raw-text/raw-text.js +31 -0
  24. package/dist/blocks/section/component-info.js +50 -0
  25. package/dist/blocks/section/section.js +49 -0
  26. package/dist/blocks/select/component-info.js +60 -0
  27. package/dist/blocks/select/select.js +38 -0
  28. package/dist/blocks/submit-button/component-info.js +29 -0
  29. package/dist/blocks/submit-button/submit-button.js +36 -0
  30. package/dist/blocks/symbol/component-info.js +44 -0
  31. package/dist/blocks/symbol/symbol.js +97 -0
  32. package/dist/blocks/text/component-info.js +25 -0
  33. package/dist/blocks/text/text.js +112 -0
  34. package/dist/blocks/textarea/component-info.js +48 -0
  35. package/dist/blocks/textarea/textarea.js +31 -0
  36. package/dist/blocks/util.js +9 -0
  37. package/dist/blocks/video/component-info.js +107 -0
  38. package/dist/blocks/video/video.js +81 -0
  39. package/dist/components/render-block/block-styles.js +79 -0
  40. package/dist/components/render-block/render-block.helpers.js +109 -0
  41. package/dist/components/render-block/render-block.js +154 -0
  42. package/dist/components/render-block/render-component-with-context.js +45 -0
  43. package/dist/components/render-block/render-component.js +50 -0
  44. package/dist/components/render-block/render-repeated-block.js +45 -0
  45. package/dist/components/render-block/types.js +1 -0
  46. package/dist/components/render-blocks.js +76 -0
  47. package/dist/components/render-content/builder-editing.js +31 -0
  48. package/dist/components/render-content/components/render-styles.js +91 -0
  49. package/dist/components/render-content/index.js +8 -0
  50. package/dist/components/render-content/render-content.js +325 -0
  51. package/dist/components/render-inlined-styles.js +42 -0
  52. package/dist/constants/builder-registered-components.js +46 -0
  53. package/dist/constants/device-sizes.js +49 -0
  54. package/dist/constants/target.js +5 -0
  55. package/dist/context/builder.context.js +13 -0
  56. package/dist/context/types.js +1 -0
  57. package/dist/functions/camel-to-kebab-case.js +5 -0
  58. package/dist/functions/evaluate.js +25 -0
  59. package/dist/functions/event-handler-name.js +8 -0
  60. package/dist/functions/extract-text-styles.js +23 -0
  61. package/dist/functions/fast-clone.js +5 -0
  62. package/dist/functions/get-block-actions-handler.js +12 -0
  63. package/dist/functions/get-block-actions.js +19 -0
  64. package/dist/functions/get-block-component-options.js +29 -0
  65. package/dist/functions/get-block-properties.js +51 -0
  66. package/dist/functions/get-block-tag.js +8 -0
  67. package/dist/functions/get-builder-search-params/fn.test.js +15 -0
  68. package/dist/functions/get-builder-search-params/index.js +39 -0
  69. package/dist/functions/get-content/ab-testing.js +89 -0
  70. package/dist/functions/get-content/generate-content-url.js +44 -0
  71. package/dist/functions/get-content/generate-content-url.test.js +33 -0
  72. package/dist/functions/get-content/index.js +68 -0
  73. package/dist/functions/get-content/types.js +1 -0
  74. package/dist/functions/get-fetch.js +15 -0
  75. package/dist/functions/get-global-this.js +19 -0
  76. package/dist/functions/get-processed-block.js +52 -0
  77. package/dist/functions/get-processed-block.test.js +34 -0
  78. package/dist/functions/get-react-native-block-styles.js +30 -0
  79. package/dist/functions/if-target.js +13 -0
  80. package/dist/functions/is-browser.js +7 -0
  81. package/dist/functions/is-editing.js +8 -0
  82. package/dist/functions/is-iframe.js +8 -0
  83. package/dist/functions/is-previewing.js +15 -0
  84. package/dist/functions/on-change.js +28 -0
  85. package/dist/functions/on-change.test.js +21 -0
  86. package/dist/functions/register-component.js +65 -0
  87. package/dist/functions/register.js +31 -0
  88. package/dist/functions/sanitize-react-native-block-styles.js +71 -0
  89. package/dist/functions/set-editor-settings.js +16 -0
  90. package/dist/functions/set.js +12 -0
  91. package/dist/functions/set.test.js +18 -0
  92. package/dist/functions/track/helpers.js +53 -0
  93. package/dist/functions/track/index.js +124 -0
  94. package/dist/functions/track/interaction.js +51 -0
  95. package/dist/functions/track.js +120 -0
  96. package/dist/functions/transform-block-properties.js +18 -0
  97. package/dist/functions/transform-block.js +38 -0
  98. package/dist/helpers/ab-tests.js +10 -0
  99. package/dist/helpers/cookie.js +70 -0
  100. package/dist/helpers/css.js +33 -0
  101. package/dist/helpers/flatten.js +35 -0
  102. package/dist/helpers/localStorage.js +31 -0
  103. package/dist/helpers/nullable.js +5 -0
  104. package/dist/helpers/sessionId.js +51 -0
  105. package/dist/helpers/time.js +6 -0
  106. package/dist/helpers/url.js +14 -0
  107. package/dist/helpers/url.test.js +23 -0
  108. package/dist/helpers/uuid.js +14 -0
  109. package/dist/helpers/visitorId.js +33 -0
  110. package/dist/index-helpers/blocks-exports.js +22 -0
  111. package/dist/index-helpers/top-of-file.js +3 -0
  112. package/dist/index.js +29 -0
  113. package/dist/scripts/init-editing.js +97 -0
  114. package/dist/types/builder-block.js +1 -0
  115. package/dist/types/builder-content.js +1 -0
  116. package/dist/types/can-track.js +1 -0
  117. package/dist/types/components.js +1 -0
  118. package/dist/types/deep-partial.js +1 -0
  119. package/dist/types/element.js +1 -0
  120. package/dist/types/targets.js +1 -0
  121. package/dist/types/typescript.js +1 -0
  122. package/package.json +13 -5
  123. package/src/blocks/BaseText.jsx +17 -0
  124. package/src/blocks/button/button.jsx +28 -0
  125. package/src/blocks/columns/{columns.js → columns.jsx} +59 -36
  126. package/src/blocks/custom-code/{custom-code.js → custom-code.jsx} +22 -15
  127. package/src/blocks/embed/{embed.js → embed.jsx} +12 -11
  128. package/src/blocks/form/form.jsx +251 -0
  129. package/src/blocks/fragment/fragment.jsx +11 -0
  130. package/src/blocks/image/image.jsx +78 -0
  131. package/src/blocks/img/img.jsx +18 -0
  132. package/src/blocks/input/input.jsx +20 -0
  133. package/src/blocks/raw-text/raw-text.jsx +6 -0
  134. package/src/blocks/section/section.jsx +29 -0
  135. package/src/blocks/select/select.jsx +24 -0
  136. package/src/blocks/submit-button/submit-button.jsx +11 -0
  137. package/src/blocks/symbol/symbol.jsx +86 -0
  138. package/src/blocks/text/text.jsx +100 -0
  139. package/src/blocks/textarea/textarea.jsx +14 -0
  140. package/src/blocks/video/video.jsx +70 -0
  141. package/src/components/render-block/block-styles.jsx +70 -0
  142. package/src/components/render-block/render-block.helpers.js +90 -0
  143. package/src/components/render-block/render-block.jsx +183 -0
  144. package/src/components/render-block/render-component.jsx +45 -0
  145. package/src/components/render-block/render-repeated-block.jsx +22 -0
  146. package/src/components/render-blocks.jsx +86 -0
  147. package/src/components/render-content/builder-editing.jsx +6 -0
  148. package/src/components/render-content/components/{render-styles.js → render-styles.jsx} +21 -14
  149. package/src/components/render-content/render-content.jsx +373 -0
  150. package/src/components/render-inlined-styles.jsx +29 -0
  151. package/src/functions/track/helpers.js +50 -0
  152. package/src/functions/{track.js → track/index.js} +10 -6
  153. package/src/functions/track/interaction.js +53 -0
  154. package/src/index.js +1 -1
  155. package/src/blocks/BaseText.js +0 -31
  156. package/src/blocks/button/button.js +0 -36
  157. package/src/blocks/form/form.js +0 -222
  158. package/src/blocks/fragment/fragment.js +0 -9
  159. package/src/blocks/image/image.js +0 -55
  160. package/src/blocks/img/img.js +0 -33
  161. package/src/blocks/input/input.js +0 -36
  162. package/src/blocks/raw-text/raw-text.js +0 -10
  163. package/src/blocks/section/section.js +0 -41
  164. package/src/blocks/select/select.js +0 -37
  165. package/src/blocks/submit-button/submit-button.js +0 -27
  166. package/src/blocks/symbol/symbol.js +0 -73
  167. package/src/blocks/text/text.js +0 -67
  168. package/src/blocks/textarea/textarea.js +0 -32
  169. package/src/blocks/video/video.js +0 -55
  170. package/src/components/render-block/block-styles.js +0 -50
  171. package/src/components/render-block/render-block.js +0 -202
  172. package/src/components/render-block/render-component-with-context.js +0 -35
  173. package/src/components/render-block/render-component.js +0 -35
  174. package/src/components/render-block/render-repeated-block.js +0 -33
  175. package/src/components/render-blocks.js +0 -63
  176. package/src/components/render-content/builder-editing.js +0 -8
  177. package/src/components/render-content/render-content.js +0 -297
  178. package/src/components/render-inlined-styles.js +0 -17
@@ -49,11 +49,12 @@ var __async = (__this, __arguments, generator) => {
49
49
  step((generator = generator.apply(__this, __arguments)).next());
50
50
  });
51
51
  };
52
- import { TARGET } from "../constants/target.js";
53
- import { getSessionId } from "../helpers/sessionId.js";
54
- import { getVisitorId } from "../helpers/visitorId.js";
55
- import { isBrowser } from "./is-browser.js";
56
- import { isEditing } from "./is-editing.js";
52
+ import { TARGET } from "../../constants/target.js";
53
+ import { getSessionId } from "../../helpers/sessionId.js";
54
+ import { getVisitorId } from "../../helpers/visitorId.js";
55
+ import { isBrowser } from "../is-browser.js";
56
+ import { isEditing } from "../is-editing.js";
57
+ import { getUserAttributes } from "./helpers.js";
57
58
  const getTrackingEventData = (_0) => __async(void 0, [_0], function* ({
58
59
  canTrack
59
60
  }) {
@@ -82,8 +83,11 @@ const createEvent = (_a) => __async(void 0, null, function* () {
82
83
  return {
83
84
  type: eventType,
84
85
  data: __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, properties), {
85
- metadata: JSON.stringify(metadata)
86
+ metadata: __spreadValues({
87
+ url: location.href
88
+ }, metadata)
86
89
  }), yield getTrackingEventData({ canTrack })), {
90
+ userAttributes: getUserAttributes(),
87
91
  ownerId: apiKey
88
92
  })
89
93
  };
@@ -0,0 +1,53 @@
1
+ function round(num) {
2
+ return Math.round(num * 1e3) / 1e3;
3
+ }
4
+ const findParentElement = (target, callback, checkElement = true) => {
5
+ if (!(target instanceof HTMLElement)) {
6
+ return null;
7
+ }
8
+ let parent = checkElement ? target : target.parentElement;
9
+ do {
10
+ if (!parent) {
11
+ return null;
12
+ }
13
+ const matches = callback(parent);
14
+ if (matches) {
15
+ return parent;
16
+ }
17
+ } while (parent = parent.parentElement);
18
+ return null;
19
+ };
20
+ const findBuilderParent = (target) => findParentElement(target, (el) => {
21
+ const id = el.getAttribute("builder-id") || el.id;
22
+ return Boolean((id == null ? void 0 : id.indexOf("builder-")) === 0);
23
+ });
24
+ const computeOffset = ({
25
+ event,
26
+ target
27
+ }) => {
28
+ const targetRect = target.getBoundingClientRect();
29
+ const xOffset = event.clientX - targetRect.left;
30
+ const yOffset = event.clientY - targetRect.top;
31
+ const xRatio = round(xOffset / targetRect.width);
32
+ const yRatio = round(yOffset / targetRect.height);
33
+ return {
34
+ x: xRatio,
35
+ y: yRatio
36
+ };
37
+ };
38
+ const getInteractionPropertiesForEvent = (event) => {
39
+ const target = event.target;
40
+ const targetBuilderElement = target && findBuilderParent(target);
41
+ const builderId = (targetBuilderElement == null ? void 0 : targetBuilderElement.getAttribute("builder-id")) || (targetBuilderElement == null ? void 0 : targetBuilderElement.id);
42
+ return {
43
+ targetBuilderElement: builderId || void 0,
44
+ metadata: {
45
+ targetOffset: target ? computeOffset({ event, target }) : void 0,
46
+ builderTargetOffset: targetBuilderElement ? computeOffset({ event, target: targetBuilderElement }) : void 0,
47
+ builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
48
+ }
49
+ };
50
+ };
51
+ export {
52
+ getInteractionPropertiesForEvent
53
+ };
package/src/index.js CHANGED
@@ -8,7 +8,7 @@ export * from "./functions/register.js";
8
8
  export * from "./functions/set-editor-settings.js";
9
9
  export * from "./functions/get-content/index.js";
10
10
  export * from "./functions/get-builder-search-params/index.js";
11
- import { track } from "./functions/track";
11
+ import { track } from "./functions/track/index.js";
12
12
  export {
13
13
  track
14
14
  };
@@ -1,31 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import * as React from "react";
21
- import { Text } from "react-native";
22
- import BuilderContext from "../context/builder.context";
23
- function BaseText(props) {
24
- const builderContext = React.useContext(BuilderContext);
25
- return /* @__PURE__ */ React.createElement(Text, __spreadProps(__spreadValues({}, props), {
26
- style: __spreadValues(__spreadValues({}, builderContext.inheritedStyles), props.style)
27
- }));
28
- }
29
- export {
30
- BaseText as default
31
- };
@@ -1,36 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import BaseText from "../BaseText";
21
- import * as React from "react";
22
- import { View, StyleSheet } from "react-native";
23
- function Button(props) {
24
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.link ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({
25
- role: "button"
26
- }, props.attributes), {
27
- href: props.link,
28
- target: props.openLinkInNewTab ? "_blank" : void 0
29
- }), /* @__PURE__ */ React.createElement(BaseText, null, props.text))) : /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
30
- style: styles.view1
31
- }), /* @__PURE__ */ React.createElement(BaseText, null, props.text)));
32
- }
33
- const styles = StyleSheet.create({ view1: { all: "unset" } });
34
- export {
35
- Button as default
36
- };
@@ -1,222 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __async = (__this, __arguments, generator) => {
18
- return new Promise((resolve, reject) => {
19
- var fulfilled = (value) => {
20
- try {
21
- step(generator.next(value));
22
- } catch (e) {
23
- reject(e);
24
- }
25
- };
26
- var rejected = (value) => {
27
- try {
28
- step(generator.throw(value));
29
- } catch (e) {
30
- reject(e);
31
- }
32
- };
33
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
- step((generator = generator.apply(__this, __arguments)).next());
35
- });
36
- };
37
- import BaseText from "../BaseText";
38
- import * as React from "react";
39
- import { View, StyleSheet } from "react-native";
40
- import { useState, useContext, useRef } from "react";
41
- import RenderBlock from "../../components/render-block/render-block.js";
42
- import BuilderBlocks from "../../components/render-blocks.js";
43
- import { isEditing } from "../../functions/is-editing.js";
44
- function FormComponent(props) {
45
- var _a, _b;
46
- const formRef = useRef(null);
47
- const [formState, setFormState] = useState(() => "unsubmitted");
48
- const [responseData, setResponseData] = useState(() => null);
49
- const [formErrorMessage, setFormErrorMessage] = useState(() => "");
50
- function submissionState() {
51
- return isEditing() && props.previewState || formState;
52
- }
53
- function onSubmit(event) {
54
- var _a2;
55
- const sendWithJs = props.sendWithJs || props.sendSubmissionsTo === "email";
56
- if (props.sendSubmissionsTo === "zapier") {
57
- event.preventDefault();
58
- } else if (sendWithJs) {
59
- if (!(props.action || props.sendSubmissionsTo === "email")) {
60
- event.preventDefault();
61
- return;
62
- }
63
- event.preventDefault();
64
- const el = event.currentTarget;
65
- const headers = props.customHeaders || {};
66
- let body;
67
- const formData = new FormData(el);
68
- const formPairs = Array.from(event.currentTarget.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
69
- let value;
70
- const key = el2.name;
71
- if (el2 instanceof HTMLInputElement) {
72
- if (el2.type === "radio") {
73
- if (el2.checked) {
74
- value = el2.name;
75
- return {
76
- key,
77
- value
78
- };
79
- }
80
- } else if (el2.type === "checkbox") {
81
- value = el2.checked;
82
- } else if (el2.type === "number" || el2.type === "range") {
83
- const num = el2.valueAsNumber;
84
- if (!isNaN(num)) {
85
- value = num;
86
- }
87
- } else if (el2.type === "file") {
88
- value = el2.files;
89
- } else {
90
- value = el2.value;
91
- }
92
- } else {
93
- value = el2.value;
94
- }
95
- return {
96
- key,
97
- value
98
- };
99
- });
100
- let contentType = props.contentType;
101
- if (props.sendSubmissionsTo === "email") {
102
- contentType = "multipart/form-data";
103
- }
104
- Array.from(formPairs).forEach(({ value }) => {
105
- if (value instanceof File || Array.isArray(value) && value[0] instanceof File || value instanceof FileList) {
106
- contentType = "multipart/form-data";
107
- }
108
- });
109
- if (contentType !== "application/json") {
110
- body = formData;
111
- } else {
112
- const json = {};
113
- Array.from(formPairs).forEach(({ value, key }) => {
114
- set(json, key, value);
115
- });
116
- body = JSON.stringify(json);
117
- }
118
- if (contentType && contentType !== "multipart/form-data") {
119
- if (!(sendWithJs && ((_a2 = props.action) == null ? void 0 : _a2.includes("zapier.com")))) {
120
- headers["content-type"] = contentType;
121
- }
122
- }
123
- const presubmitEvent = new CustomEvent("presubmit", { detail: { body } });
124
- if (formRef.current) {
125
- formRef.current.dispatchEvent(presubmitEvent);
126
- if (presubmitEvent.defaultPrevented) {
127
- return;
128
- }
129
- }
130
- setFormState("sending");
131
- const formUrl = `${builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(props.sendSubmissionsToEmail || "")}&name=${encodeURIComponent(props.name || "")}`;
132
- fetch(props.sendSubmissionsTo === "email" ? formUrl : props.action, { body, headers, method: props.method || "post" }).then((res) => __async(this, null, function* () {
133
- let body2;
134
- const contentType2 = res.headers.get("content-type");
135
- if (contentType2 && contentType2.indexOf("application/json") !== -1) {
136
- body2 = yield res.json();
137
- } else {
138
- body2 = yield res.text();
139
- }
140
- if (!res.ok && props.errorMessagePath) {
141
- let message = get(body2, props.errorMessagePath);
142
- if (message) {
143
- if (typeof message !== "string") {
144
- message = JSON.stringify(message);
145
- }
146
- setFormErrorMessage(message);
147
- }
148
- }
149
- setResponseData(body2);
150
- setFormState(res.ok ? "success" : "error");
151
- if (res.ok) {
152
- const submitSuccessEvent = new CustomEvent("submit:success", {
153
- detail: { res, body: body2 }
154
- });
155
- if (formRef.current) {
156
- formRef.current.dispatchEvent(submitSuccessEvent);
157
- if (submitSuccessEvent.defaultPrevented) {
158
- return;
159
- }
160
- if (props.resetFormOnSubmit !== false) {
161
- formRef.current.reset();
162
- }
163
- }
164
- if (props.successUrl) {
165
- if (formRef.current) {
166
- const event2 = new CustomEvent("route", {
167
- detail: { url: props.successUrl }
168
- });
169
- formRef.current.dispatchEvent(event2);
170
- if (!event2.defaultPrevented) {
171
- location.href = props.successUrl;
172
- }
173
- } else {
174
- location.href = props.successUrl;
175
- }
176
- }
177
- }
178
- }), (err) => {
179
- const submitErrorEvent = new CustomEvent("submit:error", {
180
- detail: { error: err }
181
- });
182
- if (formRef.current) {
183
- formRef.current.dispatchEvent(submitErrorEvent);
184
- if (submitErrorEvent.defaultPrevented) {
185
- return;
186
- }
187
- }
188
- setResponseData(err);
189
- setFormState("error");
190
- });
191
- }
192
- }
193
- const builderContext = useContext(BuilderContext);
194
- return /* @__PURE__ */ React.createElement(View, __spreadValues({
195
- validate: props.validate,
196
- ref: formRef,
197
- action: !props.sendWithJs && props.action,
198
- method: props.method,
199
- name: props.name,
200
- onSubmit: (event) => onSubmit(event)
201
- }, props.attributes), " ", 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) => /* @__PURE__ */ React.createElement(RenderBlock, {
202
- block,
203
- context: builderContext
204
- }))) : null, " ", submissionState() === "error" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
205
- dataPath: "errorMessage",
206
- blocks: props.errorMessage
207
- })) : null, " ", submissionState() === "sending" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
208
- dataPath: "sendingMessage",
209
- blocks: props.sendingMessage
210
- })) : null, " ", submissionState() === "error" && responseData ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
211
- style: styles.view1
212
- }, " ", /* @__PURE__ */ React.createElement(BaseText, null, JSON.stringify(responseData, null, 2)), " ")) : null, " ", submissionState() === "success" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
213
- dataPath: "successMessage",
214
- blocks: props.successMessage
215
- })) : null, " ");
216
- }
217
- const styles = StyleSheet.create({
218
- view1: { padding: 10, color: "red", textAlign: "center" }
219
- });
220
- export {
221
- FormComponent as default
222
- };
@@ -1,9 +0,0 @@
1
- import BaseText from "../BaseText";
2
- import * as React from "react";
3
- import { View } from "react-native";
4
- function FragmentComponent(props) {
5
- return /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(BaseText, null, props.children));
6
- }
7
- export {
8
- FragmentComponent as default
9
- };
@@ -1,55 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- import * as React from "react";
18
- import { Image as ReactImage, View } from "react-native";
19
- function Image(props) {
20
- var _a, _b;
21
- const shouldRenderUnwrappedChildren = props.fitContent && ((_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.length);
22
- const imageStyle = props.aspectRatio ? {
23
- position: "absolute",
24
- top: 0,
25
- bottom: 0,
26
- left: 0,
27
- right: 0
28
- } : __spreadValues(__spreadValues({
29
- position: "relative"
30
- }, props.width ? { width: props.width } : {}), props.height ? { height: props.height } : {});
31
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ReactImage, {
32
- resizeMode: props.backgroundSize || "contain",
33
- style: imageStyle,
34
- source: { uri: props.image }
35
- }), props.aspectRatio && !shouldRenderUnwrappedChildren ? /* @__PURE__ */ React.createElement(View, {
36
- style: {
37
- width: "100%",
38
- paddingTop: props.aspectRatio * 100 + "%"
39
- }
40
- }) : null), shouldRenderUnwrappedChildren && props.children, !props.fitContent && props.children && /* @__PURE__ */ React.createElement(View, {
41
- css: {
42
- display: "flex",
43
- flexDirection: "column",
44
- alignItems: "stretch",
45
- position: "absolute",
46
- top: "0",
47
- left: "0",
48
- width: "100%",
49
- height: "100%"
50
- }
51
- }, props.children));
52
- }
53
- export {
54
- Image as default
55
- };
@@ -1,33 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- import * as React from "react";
18
- import { View } from "react-native";
19
- import { isEditing } from "../../functions/is-editing.js";
20
- function ImgComponent(props) {
21
- return /* @__PURE__ */ React.createElement(View, __spreadValues({
22
- style: {
23
- objectFit: props.backgroundSize || "cover",
24
- objectPosition: props.backgroundPosition || "center"
25
- },
26
- key: isEditing() && props.imgSrc || "default-key",
27
- alt: props.altText,
28
- src: props.imgSrc || props.image
29
- }, props.attributes));
30
- }
31
- export {
32
- ImgComponent as default
33
- };
@@ -1,36 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import * as React from "react";
21
- import { View } from "react-native";
22
- import { isEditing } from "../../functions/is-editing.js";
23
- function FormInputComponent(props) {
24
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
25
- key: isEditing() && props.defaultValue ? props.defaultValue : "default-key",
26
- placeholder: props.placeholder,
27
- type: props.type,
28
- name: props.name,
29
- value: props.value,
30
- defaultValue: props.defaultValue,
31
- required: props.required
32
- }));
33
- }
34
- export {
35
- FormInputComponent as default
36
- };
@@ -1,10 +0,0 @@
1
- import * as React from "react";
2
- import { View } from "react-native";
3
- function RawText(props) {
4
- return /* @__PURE__ */ React.createElement(View, {
5
- dangerouslySetInnerHTML: { __html: props.text || "" }
6
- });
7
- }
8
- export {
9
- RawText as default
10
- };
@@ -1,41 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import BaseText from "../BaseText";
21
- import * as React from "react";
22
- import { View } from "react-native";
23
- function SectionComponent(props) {
24
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
25
- style: {
26
- width: "100%",
27
- alignSelf: "stretch",
28
- flexGrow: "1",
29
- boxSizing: "border-box",
30
- maxWidth: `${props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : 1200}px`,
31
- display: "flex",
32
- flexDirection: "column",
33
- alignItems: "stretch",
34
- marginLeft: "auto",
35
- marginRight: "auto"
36
- }
37
- }), /* @__PURE__ */ React.createElement(BaseText, null, props.children));
38
- }
39
- export {
40
- SectionComponent as default
41
- };
@@ -1,37 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import BaseText from "../BaseText";
21
- import * as React from "react";
22
- import { View } from "react-native";
23
- import { isEditing } from "../../functions/is-editing.js";
24
- function SelectComponent(props) {
25
- var _a;
26
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
27
- value: props.value,
28
- key: isEditing() && props.defaultValue ? props.defaultValue : "default-key",
29
- defaultValue: props.defaultValue,
30
- name: props.name
31
- }), (_a = props.options) == null ? void 0 : _a.map((option) => /* @__PURE__ */ React.createElement(View, {
32
- value: option.value
33
- }, /* @__PURE__ */ React.createElement(BaseText, null, option.name || option.value))));
34
- }
35
- export {
36
- SelectComponent as default
37
- };
@@ -1,27 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- import BaseText from "../BaseText";
18
- import * as React from "react";
19
- import { View } from "react-native";
20
- function SubmitButton(props) {
21
- return /* @__PURE__ */ React.createElement(View, __spreadValues({
22
- type: "submit"
23
- }, props.attributes), /* @__PURE__ */ React.createElement(BaseText, null, props.text));
24
- }
25
- export {
26
- SubmitButton as default
27
- };