@builder.io/sdk-react-native 0.0.1-50 → 0.0.1-53

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 (113) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +1 -1
  3. package/src/blocks/button/button.js +31 -0
  4. package/src/blocks/{button.lite.tsx → button/button.lite.tsx} +0 -0
  5. package/src/blocks/button/component-info.js +42 -0
  6. package/src/blocks/columns/columns.js +59 -0
  7. package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +5 -4
  8. package/src/blocks/columns/component-info.js +218 -0
  9. package/src/blocks/custom-code/component-info.js +32 -0
  10. package/src/blocks/custom-code/custom-code.js +50 -0
  11. package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +1 -1
  12. package/src/blocks/embed/component-info.js +25 -0
  13. package/src/blocks/embed/embed.js +50 -0
  14. package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +1 -1
  15. package/src/blocks/form/component-info.js +263 -0
  16. package/src/blocks/form/form.js +221 -0
  17. package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +8 -7
  18. package/src/blocks/fragment/component-info.js +12 -0
  19. package/src/blocks/fragment/fragment.js +8 -0
  20. package/src/blocks/{fragment.lite.tsx → fragment/fragment.lite.tsx} +0 -0
  21. package/src/blocks/{image.js → image/component-info.js} +4 -42
  22. package/src/blocks/image/image.js +41 -0
  23. package/src/blocks/{image.lite.tsx → image/image.lite.tsx} +1 -1
  24. package/src/blocks/img/component-info.js +21 -0
  25. package/src/blocks/img/img.js +36 -0
  26. package/src/blocks/{img.lite.tsx → img/img.lite.tsx} +1 -1
  27. package/src/blocks/input/component-info.js +75 -0
  28. package/src/blocks/input/input.js +36 -0
  29. package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +1 -1
  30. package/src/blocks/raw-text/component-info.js +17 -0
  31. package/src/blocks/raw-text/raw-text.js +10 -0
  32. package/src/blocks/{raw-text.lite.tsx → raw-text/raw-text.lite.tsx} +1 -1
  33. package/src/blocks/section/component-info.js +50 -0
  34. package/src/blocks/section/section.js +31 -0
  35. package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +0 -0
  36. package/src/blocks/select/component-info.js +60 -0
  37. package/src/blocks/select/select.js +36 -0
  38. package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +2 -2
  39. package/src/blocks/submit-button/component-info.js +29 -0
  40. package/src/blocks/submit-button/submit-button.js +29 -0
  41. package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +0 -0
  42. package/src/blocks/symbol/component-info.js +43 -0
  43. package/src/blocks/symbol/symbol.js +68 -0
  44. package/src/blocks/{symbol.lite.tsx → symbol/symbol.lite.tsx} +7 -7
  45. package/src/blocks/text/component-info.js +25 -0
  46. package/src/blocks/{text.js → text/text.js} +0 -22
  47. package/src/blocks/{text.lite.tsx → text/text.lite.tsx} +1 -1
  48. package/src/blocks/textarea/component-info.js +48 -0
  49. package/src/blocks/textarea/textarea.js +32 -0
  50. package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +0 -0
  51. package/src/blocks/{video.js → video/component-info.js} +52 -40
  52. package/src/blocks/video/video.js +33 -0
  53. package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +0 -0
  54. package/src/components/render-block/block-styles.js +29 -0
  55. package/src/components/render-block/block-styles.lite.tsx +35 -0
  56. package/src/components/render-block/render-block.helpers.js +24 -0
  57. package/src/components/{render-block.js → render-block/render-block.js} +28 -20
  58. package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +43 -31
  59. package/src/components/render-blocks.js +3 -3
  60. package/src/components/render-blocks.lite.tsx +3 -3
  61. package/src/components/render-content/components/render-styles.js +58 -0
  62. package/src/components/render-content/components/render-styles.lite.tsx +70 -0
  63. package/src/components/render-content/index.js +5 -0
  64. package/src/components/{render-content.js → render-content/render-content.js} +57 -69
  65. package/src/components/{render-content.lite.tsx → render-content/render-content.lite.tsx} +67 -92
  66. package/src/components/render-inlined-styles.js +18 -0
  67. package/src/components/render-inlined-styles.lite.tsx +31 -0
  68. package/src/constants/builder-registered-components.js +27 -0
  69. package/src/constants/target.js +5 -0
  70. package/src/context/builder.context.js +2 -1
  71. package/src/functions/evaluate.js +2 -2
  72. package/src/functions/fast-clone.js +5 -0
  73. package/src/functions/get-block-actions.js +2 -2
  74. package/src/functions/get-block-properties.js +1 -1
  75. package/src/functions/get-builder-search-params/fn.test.js +1 -1
  76. package/src/functions/get-content/index.js +3 -2
  77. package/src/functions/get-fetch.js +29 -7
  78. package/src/functions/get-processed-block.js +3 -3
  79. package/src/functions/get-processed-block.test.js +1 -1
  80. package/src/functions/if-target.js +11 -2
  81. package/src/functions/is-editing.js +1 -1
  82. package/src/functions/is-iframe.js +1 -1
  83. package/src/functions/is-previewing.js +2 -2
  84. package/src/functions/on-change.test.js +1 -1
  85. package/src/functions/previewing-model-name.js +1 -1
  86. package/src/functions/register-component.js +30 -13
  87. package/src/functions/register.js +1 -1
  88. package/src/functions/set-editor-settings.js +1 -1
  89. package/src/functions/set.test.js +1 -1
  90. package/src/functions/track.js +4 -4
  91. package/src/index-helpers/blocks-exports.js +8 -8
  92. package/src/index.js +10 -13
  93. package/src/scripts/init-editing.js +72 -62
  94. package/src/types/components.js +1 -0
  95. package/src/types/element.js +1 -0
  96. package/src/types/targets.js +1 -0
  97. package/src/blocks/button.js +0 -36
  98. package/src/blocks/columns.js +0 -63
  99. package/src/blocks/custom-code.js +0 -55
  100. package/src/blocks/embed.js +0 -55
  101. package/src/blocks/form.js +0 -225
  102. package/src/blocks/fragment.js +0 -13
  103. package/src/blocks/img.js +0 -41
  104. package/src/blocks/input.js +0 -41
  105. package/src/blocks/raw-text.js +0 -15
  106. package/src/blocks/section.js +0 -36
  107. package/src/blocks/select.js +0 -41
  108. package/src/blocks/submit-button.js +0 -34
  109. package/src/blocks/symbol.js +0 -73
  110. package/src/blocks/textarea.js +0 -37
  111. package/src/components/block-styles.js +0 -7
  112. package/src/components/block-styles.lite.tsx +0 -6
  113. package/src/functions/get-target.js +0 -7
@@ -0,0 +1,263 @@
1
+ import * as React from 'react';
2
+ const componentInfo = {
3
+ name: "Form:Form",
4
+ builtIn: true,
5
+ defaults: {
6
+ responsiveStyles: {
7
+ large: {
8
+ marginTop: "15px",
9
+ paddingBottom: "15px"
10
+ }
11
+ }
12
+ },
13
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fef36d2a846134910b64b88e6d18c5ca5",
14
+ inputs: [
15
+ {
16
+ name: "sendSubmissionsTo",
17
+ type: "string",
18
+ enum: [
19
+ {
20
+ label: "Send to email",
21
+ value: "email",
22
+ helperText: "Send form submissions to the email address of your choosing"
23
+ },
24
+ {
25
+ label: "Custom",
26
+ value: "custom",
27
+ helperText: "Handle where the form requests go manually with a little code, e.g. to your own custom backend"
28
+ }
29
+ ],
30
+ defaultValue: "email"
31
+ },
32
+ {
33
+ name: "sendSubmissionsToEmail",
34
+ type: "string",
35
+ required: true,
36
+ defaultValue: "your@email.com",
37
+ showIf: 'options.get("sendSubmissionsTo") === "email"'
38
+ },
39
+ {
40
+ name: "sendWithJs",
41
+ type: "boolean",
42
+ helperText: "Set to false to use basic html form action",
43
+ defaultValue: true,
44
+ showIf: 'options.get("sendSubmissionsTo") === "custom"'
45
+ },
46
+ {
47
+ name: "name",
48
+ type: "string",
49
+ defaultValue: "My form"
50
+ },
51
+ {
52
+ name: "action",
53
+ type: "string",
54
+ helperText: "URL to send the form data to",
55
+ showIf: 'options.get("sendSubmissionsTo") === "custom"'
56
+ },
57
+ {
58
+ name: "contentType",
59
+ type: "string",
60
+ defaultValue: "application/json",
61
+ advanced: true,
62
+ enum: [
63
+ "application/json",
64
+ "multipart/form-data",
65
+ "application/x-www-form-urlencoded"
66
+ ],
67
+ showIf: 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'
68
+ },
69
+ {
70
+ name: "method",
71
+ type: "string",
72
+ showIf: 'options.get("sendSubmissionsTo") === "custom"',
73
+ defaultValue: "POST",
74
+ advanced: true
75
+ },
76
+ {
77
+ name: "previewState",
78
+ type: "string",
79
+ enum: ["unsubmitted", "sending", "success", "error"],
80
+ defaultValue: "unsubmitted",
81
+ helperText: 'Choose a state to edit, e.g. choose "success" to show what users see on success and edit the message',
82
+ showIf: 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'
83
+ },
84
+ {
85
+ name: "successUrl",
86
+ type: "url",
87
+ helperText: "Optional URL to redirect the user to on form submission success",
88
+ showIf: 'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'
89
+ },
90
+ {
91
+ name: "resetFormOnSubmit",
92
+ type: "boolean",
93
+ showIf: "options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",
94
+ advanced: true
95
+ },
96
+ {
97
+ name: "successMessage",
98
+ type: "uiBlocks",
99
+ hideFromUI: true,
100
+ defaultValue: [
101
+ {
102
+ "@type": "@builder.io/sdk:Element",
103
+ responsiveStyles: {
104
+ large: {
105
+ marginTop: "10px"
106
+ }
107
+ },
108
+ component: {
109
+ name: "Text",
110
+ options: {
111
+ text: "<span>Thanks!</span>"
112
+ }
113
+ }
114
+ }
115
+ ]
116
+ },
117
+ {
118
+ name: "validate",
119
+ type: "boolean",
120
+ defaultValue: true,
121
+ advanced: true
122
+ },
123
+ {
124
+ name: "errorMessagePath",
125
+ type: "text",
126
+ advanced: true,
127
+ 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" }}'
128
+ },
129
+ {
130
+ name: "errorMessage",
131
+ type: "uiBlocks",
132
+ hideFromUI: true,
133
+ defaultValue: [
134
+ {
135
+ "@type": "@builder.io/sdk:Element",
136
+ responsiveStyles: {
137
+ large: {
138
+ marginTop: "10px"
139
+ }
140
+ },
141
+ bindings: {
142
+ "component.options.text": "state.formErrorMessage || block.component.options.text"
143
+ },
144
+ component: {
145
+ name: "Text",
146
+ options: {
147
+ text: "<span>Form submission error :( Please check your answers and try again</span>"
148
+ }
149
+ }
150
+ }
151
+ ]
152
+ },
153
+ {
154
+ name: "sendingMessage",
155
+ type: "uiBlocks",
156
+ hideFromUI: true,
157
+ defaultValue: [
158
+ {
159
+ "@type": "@builder.io/sdk:Element",
160
+ responsiveStyles: {
161
+ large: {
162
+ marginTop: "10px"
163
+ }
164
+ },
165
+ component: {
166
+ name: "Text",
167
+ options: {
168
+ text: "<span>Sending...</span>"
169
+ }
170
+ }
171
+ }
172
+ ]
173
+ },
174
+ {
175
+ name: "customHeaders",
176
+ type: "map",
177
+ valueType: {
178
+ type: "string"
179
+ },
180
+ advanced: true,
181
+ showIf: 'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'
182
+ }
183
+ ],
184
+ noWrap: true,
185
+ canHaveChildren: true,
186
+ defaultChildren: [
187
+ {
188
+ "@type": "@builder.io/sdk:Element",
189
+ responsiveStyles: {
190
+ large: {
191
+ marginTop: "10px"
192
+ }
193
+ },
194
+ component: {
195
+ name: "Text",
196
+ options: {
197
+ text: "<span>Enter your name</span>"
198
+ }
199
+ }
200
+ },
201
+ {
202
+ "@type": "@builder.io/sdk:Element",
203
+ responsiveStyles: {
204
+ large: {
205
+ marginTop: "10px"
206
+ }
207
+ },
208
+ component: {
209
+ name: "Form:Input",
210
+ options: {
211
+ name: "name",
212
+ placeholder: "Jane Doe"
213
+ }
214
+ }
215
+ },
216
+ {
217
+ "@type": "@builder.io/sdk:Element",
218
+ responsiveStyles: {
219
+ large: {
220
+ marginTop: "10px"
221
+ }
222
+ },
223
+ component: {
224
+ name: "Text",
225
+ options: {
226
+ text: "<span>Enter your email</span>"
227
+ }
228
+ }
229
+ },
230
+ {
231
+ "@type": "@builder.io/sdk:Element",
232
+ responsiveStyles: {
233
+ large: {
234
+ marginTop: "10px"
235
+ }
236
+ },
237
+ component: {
238
+ name: "Form:Input",
239
+ options: {
240
+ name: "email",
241
+ placeholder: "jane@doe.com"
242
+ }
243
+ }
244
+ },
245
+ {
246
+ "@type": "@builder.io/sdk:Element",
247
+ responsiveStyles: {
248
+ large: {
249
+ marginTop: "10px"
250
+ }
251
+ },
252
+ component: {
253
+ name: "Form:SubmitButton",
254
+ options: {
255
+ text: "Submit"
256
+ }
257
+ }
258
+ }
259
+ ]
260
+ };
261
+ export {
262
+ componentInfo
263
+ };
@@ -0,0 +1,221 @@
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
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ import * as React from "react";
41
+ import { View, StyleSheet, Text } from "react-native";
42
+ import { useState, useRef } from "react";
43
+ import RenderBlock from "../../components/render-block/render-block.js";
44
+ import { isEditing } from "../../functions/is-editing.js";
45
+ function FormComponent(props) {
46
+ var _a, _b;
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 formRef = useRef();
194
+ return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
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.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
+ }))) : null, " ", submissionState() === "error" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
204
+ dataPath: "errorMessage",
205
+ blocks: props.errorMessage
206
+ })) : null, " ", submissionState() === "sending" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
207
+ dataPath: "sendingMessage",
208
+ blocks: props.sendingMessage
209
+ })) : null, " ", submissionState() === "error" && responseData ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
210
+ style: styles.view1
211
+ }, " ", /* @__PURE__ */ React.createElement(Text, null, JSON.stringify(responseData, null, 2)), " ")) : null, " ", submissionState() === "success" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
212
+ dataPath: "successMessage",
213
+ blocks: props.successMessage
214
+ })) : null, " ");
215
+ }
216
+ const styles = StyleSheet.create({
217
+ view1: { padding: 10, color: "red", textAlign: "center" }
218
+ });
219
+ export {
220
+ FormComponent as default
221
+ };
@@ -1,17 +1,18 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet, Image, Text } from "react-native";
3
3
  import { useState, useRef } from "react";
4
- import RenderBlock from "../components/render-block.lite";
4
+ import RenderBlock from "../../components/render-block/render-block.lite";
5
+ import { isEditing } from "../../functions/is-editing.js";
5
6
 
6
7
  export default function FormComponent(props) {
7
- const [state, setState] = useState(() => "unsubmitted");
8
+ const [formState, setFormState] = useState(() => "unsubmitted");
8
9
 
9
10
  const [responseData, setResponseData] = useState(() => null);
10
11
 
11
12
  const [formErrorMessage, setFormErrorMessage] = useState(() => "");
12
13
 
13
14
  function submissionState() {
14
- return (Builder.isEditing && props.previewState) || state;
15
+ return (isEditing() && props.previewState) || formState;
15
16
  }
16
17
 
17
18
  function onSubmit(event) {
@@ -116,7 +117,7 @@ export default function FormComponent(props) {
116
117
  return;
117
118
  }
118
119
  }
119
- setState("sending");
120
+ setFormState("sending");
120
121
  const formUrl = `${
121
122
  builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"
122
123
  }/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(
@@ -148,7 +149,7 @@ export default function FormComponent(props) {
148
149
  }
149
150
  }
150
151
  setResponseData(body);
151
- setState(res.ok ? "success" : "error");
152
+ setFormState(res.ok ? "success" : "error");
152
153
  if (res.ok) {
153
154
  const submitSuccessEvent = new CustomEvent("submit:success", {
154
155
  detail: { res, body },
@@ -192,7 +193,7 @@ export default function FormComponent(props) {
192
193
  }
193
194
  }
194
195
  setResponseData(err);
195
- setState("error");
196
+ setFormState("error");
196
197
  }
197
198
  );
198
199
  }
@@ -211,7 +212,7 @@ export default function FormComponent(props) {
211
212
  {" "}
212
213
  {props.builderBlock && props.builderBlock.children ? (
213
214
  <>
214
- {props.builderBlock?.children?.map((block, index) => (
215
+ {props.builderBlock?.children?.map((block) => (
215
216
  <RenderBlock block={block} />
216
217
  ))}
217
218
  </>
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ const componentInfo = {
3
+ name: "Fragment",
4
+ static: true,
5
+ hidden: true,
6
+ builtIn: true,
7
+ canHaveChildren: true,
8
+ noWrap: true
9
+ };
10
+ export {
11
+ componentInfo
12
+ };
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import { View, Text } from "react-native";
3
+ function FragmentComponent(props) {
4
+ return /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(Text, null, props.children));
5
+ }
6
+ export {
7
+ FragmentComponent as default
8
+ };
@@ -1,43 +1,5 @@
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
- };
18
- import { Image as ReactImage, View } from "react-native";
19
- import { registerComponent } from "../functions/register-component";
20
- function Image(props) {
21
- return props.aspectRatio ? /* @__PURE__ */ React.createElement(View, {
22
- style: { position: "relative" }
23
- }, /* @__PURE__ */ React.createElement(ReactImage, {
24
- resizeMode: props.backgroundSize || "contain",
25
- style: { position: "absolute", top: 0, bottom: 0, left: 0, right: 0 },
26
- source: { uri: props.image }
27
- }), /* @__PURE__ */ React.createElement(View, {
28
- style: {
29
- width: "100%",
30
- paddingTop: props.aspectRatio * 100 + "%"
31
- }
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
- });
39
- }
40
- registerComponent(Image, {
2
+ const componentInfo = {
41
3
  name: "Image",
42
4
  static: true,
43
5
  builtIn: true,
@@ -72,7 +34,7 @@ registerComponent(Image, {
72
34
  {
73
35
  label: "cover",
74
36
  value: "cover",
75
- helperText: `The image should fill it's box, cropping when needed`
37
+ helperText: "The image should fill it's box, cropping when needed"
76
38
  }
77
39
  ]
78
40
  },
@@ -137,7 +99,7 @@ registerComponent(Image, {
137
99
  defaultValue: 0.7041
138
100
  }
139
101
  ]
140
- });
102
+ };
141
103
  export {
142
- Image as default
104
+ componentInfo
143
105
  };
@@ -0,0 +1,41 @@
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
+ };
18
+ import { Image as ReactImage, View } from "react-native";
19
+ function Image(props) {
20
+ return props.aspectRatio ? /* @__PURE__ */ React.createElement(View, {
21
+ style: { position: "relative" }
22
+ }, /* @__PURE__ */ React.createElement(ReactImage, {
23
+ resizeMode: props.backgroundSize || "contain",
24
+ style: { position: "absolute", top: 0, bottom: 0, left: 0, right: 0 },
25
+ source: { uri: props.image }
26
+ }), /* @__PURE__ */ React.createElement(View, {
27
+ style: {
28
+ width: "100%",
29
+ paddingTop: props.aspectRatio * 100 + "%"
30
+ }
31
+ })) : /* @__PURE__ */ React.createElement(ReactImage, {
32
+ resizeMode: props.backgroundSize || "contain",
33
+ style: __spreadValues(__spreadValues({
34
+ position: "relative"
35
+ }, props.width ? { width: props.width } : {}), props.height ? { height: props.height } : {}),
36
+ source: { uri: props.image }
37
+ });
38
+ }
39
+ export {
40
+ Image as default
41
+ };
@@ -8,7 +8,7 @@ export default function Image(props) {
8
8
  <View
9
9
  loading="lazy"
10
10
  alt={props.altText}
11
- aria-role={props.altText ? "presentation" : undefined}
11
+ role={props.altText ? "presentation" : undefined}
12
12
  style={styles.view2}
13
13
  src={props.image}
14
14
  srcset={props.srcset}