@builder.io/sdk-react-native 0.0.1-49 → 0.0.1-51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -2
- package/package.json +1 -1
- package/src/blocks/button/button.js +31 -0
- package/src/blocks/{button.lite.tsx → button/button.lite.tsx} +3 -3
- package/src/blocks/button/component-info.js +42 -0
- package/src/blocks/columns/columns.js +59 -0
- package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +22 -21
- package/src/blocks/columns/component-info.js +218 -0
- package/src/blocks/custom-code/component-info.js +32 -0
- package/src/blocks/custom-code/custom-code.js +50 -0
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +11 -11
- package/src/blocks/embed/component-info.js +25 -0
- package/src/blocks/embed/embed.js +50 -0
- package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +11 -11
- package/src/blocks/form/component-info.js +263 -0
- package/src/blocks/form/form.js +221 -0
- package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +51 -50
- package/src/blocks/fragment/component-info.js +12 -0
- package/src/blocks/fragment/fragment.js +8 -0
- package/src/blocks/{fragment.lite.tsx → fragment/fragment.lite.tsx} +2 -2
- package/src/blocks/image/component-info.js +105 -0
- package/src/blocks/image/image.js +41 -0
- package/src/blocks/{image.lite.tsx → image/image.lite.tsx} +11 -11
- package/src/blocks/img/component-info.js +21 -0
- package/src/blocks/img/img.js +36 -0
- package/src/blocks/img/img.lite.tsx +18 -0
- package/src/blocks/input/component-info.js +75 -0
- package/src/blocks/input/input.js +36 -0
- package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +4 -4
- package/src/blocks/raw-text/component-info.js +17 -0
- package/src/blocks/raw-text/raw-text.js +10 -0
- package/src/blocks/raw-text/raw-text.lite.tsx +6 -0
- package/src/blocks/section/component-info.js +50 -0
- package/src/blocks/section/section.js +31 -0
- package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +3 -3
- package/src/blocks/select/component-info.js +60 -0
- package/src/blocks/select/select.js +36 -0
- package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +4 -4
- package/src/blocks/submit-button/component-info.js +29 -0
- package/src/blocks/submit-button/submit-button.js +29 -0
- package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +2 -2
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.js +68 -0
- package/src/blocks/symbol/symbol.lite.tsx +60 -0
- package/src/blocks/text/component-info.js +25 -0
- package/src/blocks/text/text.js +65 -0
- package/src/blocks/text/text.lite.tsx +6 -0
- package/src/blocks/textarea/component-info.js +48 -0
- package/src/blocks/textarea/textarea.js +32 -0
- package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +2 -2
- package/src/blocks/video/component-info.js +107 -0
- package/src/blocks/video/video.js +33 -0
- package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +5 -5
- package/src/components/error-boundary.js +9 -11
- package/src/components/error-boundary.lite.tsx +2 -2
- package/src/components/render-block/block-styles.js +29 -0
- package/src/components/render-block/block-styles.lite.tsx +35 -0
- package/src/components/render-block/render-block.helpers.js +24 -0
- package/src/components/render-block/render-block.js +116 -0
- package/src/components/render-block/render-block.lite.tsx +139 -0
- package/src/components/render-blocks.js +35 -61
- package/src/components/render-blocks.lite.tsx +11 -11
- package/src/components/render-content/components/render-styles.js +58 -0
- package/src/components/render-content/components/render-styles.lite.tsx +70 -0
- package/src/components/render-content/index.js +5 -0
- package/src/components/render-content/render-content.js +254 -0
- package/src/components/render-content/render-content.lite.tsx +283 -0
- package/src/components/render-inlined-styles.js +18 -0
- package/src/components/render-inlined-styles.lite.tsx +31 -0
- package/src/constants/builder-registered-components.js +27 -0
- package/src/constants/device-sizes.js +11 -8
- package/src/constants/target.js +5 -0
- package/src/context/builder.context.js +11 -3
- package/src/functions/evaluate.js +20 -20
- package/src/functions/event-handler-name.js +3 -1
- package/src/functions/fast-clone.js +5 -0
- package/src/functions/get-block-actions.js +17 -16
- package/src/functions/get-block-component-options.js +9 -16
- package/src/functions/get-block-properties.js +14 -18
- package/src/functions/get-block-styles.js +17 -34
- package/src/functions/get-block-tag.js +4 -2
- package/src/functions/get-builder-search-params/fn.test.js +6 -10
- package/src/functions/get-builder-search-params/index.js +6 -3
- package/src/functions/get-content/fn.test.js +15 -17
- package/src/functions/get-content/index.js +25 -42
- package/src/functions/get-fetch.js +32 -8
- package/src/functions/get-global-this.js +7 -5
- package/src/functions/get-processed-block.js +13 -17
- package/src/functions/get-processed-block.test.js +16 -27
- package/src/functions/if-target.js +14 -3
- package/src/functions/is-browser.js +4 -2
- package/src/functions/is-editing.js +5 -5
- package/src/functions/is-iframe.js +4 -2
- package/src/functions/is-previewing.js +6 -4
- package/src/functions/is-react-native.js +3 -1
- package/src/functions/macro-eval.js +5 -2
- package/src/functions/on-change.js +7 -4
- package/src/functions/on-change.test.js +9 -10
- package/src/functions/previewing-model-name.js +5 -3
- package/src/functions/register-component.js +33 -44
- package/src/functions/register.js +10 -8
- package/src/functions/set-editor-settings.js +7 -5
- package/src/functions/set.js +5 -14
- package/src/functions/set.test.js +13 -14
- package/src/functions/track.js +13 -7
- package/src/functions/transform-block.js +13 -17
- package/src/index-helpers/blocks-exports.js +9 -9
- package/src/index-helpers/top-of-file.js +1 -1
- package/src/index.js +10 -12
- package/src/scripts/init-editing.js +74 -88
- package/src/types/components.js +1 -0
- package/src/types/element.js +1 -0
- package/src/types/targets.js +1 -0
- package/src/types/typescript.js +1 -0
- package/src/blocks/button.js +0 -86
- package/src/blocks/columns.js +0 -293
- package/src/blocks/custom-code.js +0 -83
- package/src/blocks/embed.js +0 -77
- package/src/blocks/form.js +0 -521
- package/src/blocks/fragment.js +0 -21
- package/src/blocks/image.js +0 -165
- package/src/blocks/img.js +0 -64
- package/src/blocks/img.lite.tsx +0 -18
- package/src/blocks/input.js +0 -113
- package/src/blocks/raw-text.js +0 -17
- package/src/blocks/raw-text.lite.tsx +0 -6
- package/src/blocks/section.js +0 -84
- package/src/blocks/select.js +0 -91
- package/src/blocks/submit-button.js +0 -60
- package/src/blocks/symbol.js +0 -20
- package/src/blocks/symbol.lite.tsx +0 -20
- package/src/blocks/text.js +0 -100
- package/src/blocks/text.lite.tsx +0 -6
- package/src/blocks/textarea.js +0 -73
- package/src/blocks/video.js +0 -100
- package/src/components/block-styles.js +0 -5
- package/src/components/block-styles.lite.tsx +0 -6
- package/src/components/render-block.js +0 -164
- package/src/components/render-block.lite.tsx +0 -132
- package/src/components/render-content.js +0 -220
- package/src/components/render-content.lite.tsx +0 -206
- package/src/functions/get-target.js +0 -5
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
3
|
-
import { useState, useRef } from
|
|
4
|
-
import RenderBlock from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
import { useState, useRef } from "react";
|
|
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 [
|
|
8
|
+
const [formState, setFormState] = useState(() => "unsubmitted");
|
|
8
9
|
|
|
9
10
|
const [responseData, setResponseData] = useState(() => null);
|
|
10
11
|
|
|
11
|
-
const [formErrorMessage, setFormErrorMessage] = useState(() =>
|
|
12
|
+
const [formErrorMessage, setFormErrorMessage] = useState(() => "");
|
|
12
13
|
|
|
13
14
|
function submissionState() {
|
|
14
|
-
return (
|
|
15
|
+
return (isEditing() && props.previewState) || formState;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
function onSubmit(event) {
|
|
18
|
-
const sendWithJs = props.sendWithJs || props.sendSubmissionsTo ===
|
|
19
|
+
const sendWithJs = props.sendWithJs || props.sendSubmissionsTo === "email";
|
|
19
20
|
|
|
20
|
-
if (props.sendSubmissionsTo ===
|
|
21
|
+
if (props.sendSubmissionsTo === "zapier") {
|
|
21
22
|
event.preventDefault();
|
|
22
23
|
} else if (sendWithJs) {
|
|
23
|
-
if (!(props.action || props.sendSubmissionsTo ===
|
|
24
|
+
if (!(props.action || props.sendSubmissionsTo === "email")) {
|
|
24
25
|
event.preventDefault();
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
@@ -32,7 +33,7 @@ export default function FormComponent(props) {
|
|
|
32
33
|
const formData = new FormData(el); // TODO: maybe support null
|
|
33
34
|
|
|
34
35
|
const formPairs = Array.from(
|
|
35
|
-
event.currentTarget.querySelectorAll(
|
|
36
|
+
event.currentTarget.querySelectorAll("input,select,textarea")
|
|
36
37
|
)
|
|
37
38
|
.filter((el) => !!el.name)
|
|
38
39
|
.map((el) => {
|
|
@@ -40,7 +41,7 @@ export default function FormComponent(props) {
|
|
|
40
41
|
const key = el.name;
|
|
41
42
|
|
|
42
43
|
if (el instanceof HTMLInputElement) {
|
|
43
|
-
if (el.type ===
|
|
44
|
+
if (el.type === "radio") {
|
|
44
45
|
if (el.checked) {
|
|
45
46
|
value = el.name;
|
|
46
47
|
return {
|
|
@@ -48,15 +49,15 @@ export default function FormComponent(props) {
|
|
|
48
49
|
value,
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
|
-
} else if (el.type ===
|
|
52
|
+
} else if (el.type === "checkbox") {
|
|
52
53
|
value = el.checked;
|
|
53
|
-
} else if (el.type ===
|
|
54
|
+
} else if (el.type === "number" || el.type === "range") {
|
|
54
55
|
const num = el.valueAsNumber;
|
|
55
56
|
|
|
56
57
|
if (!isNaN(num)) {
|
|
57
58
|
value = num;
|
|
58
59
|
}
|
|
59
|
-
} else if (el.type ===
|
|
60
|
+
} else if (el.type === "file") {
|
|
60
61
|
// TODO: one vs multiple files
|
|
61
62
|
value = el.files;
|
|
62
63
|
} else {
|
|
@@ -73,8 +74,8 @@ export default function FormComponent(props) {
|
|
|
73
74
|
});
|
|
74
75
|
let contentType = props.contentType;
|
|
75
76
|
|
|
76
|
-
if (props.sendSubmissionsTo ===
|
|
77
|
-
contentType =
|
|
77
|
+
if (props.sendSubmissionsTo === "email") {
|
|
78
|
+
contentType = "multipart/form-data";
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
Array.from(formPairs).forEach(({ value }) => {
|
|
@@ -83,13 +84,13 @@ export default function FormComponent(props) {
|
|
|
83
84
|
(Array.isArray(value) && value[0] instanceof File) ||
|
|
84
85
|
value instanceof FileList
|
|
85
86
|
) {
|
|
86
|
-
contentType =
|
|
87
|
+
contentType = "multipart/form-data";
|
|
87
88
|
}
|
|
88
89
|
}); // TODO: send as urlEncoded or multipart by default
|
|
89
90
|
// because of ease of use and reliability in browser API
|
|
90
91
|
// for encoding the form?
|
|
91
92
|
|
|
92
|
-
if (contentType !==
|
|
93
|
+
if (contentType !== "application/json") {
|
|
93
94
|
body = formData;
|
|
94
95
|
} else {
|
|
95
96
|
// Json
|
|
@@ -100,38 +101,38 @@ export default function FormComponent(props) {
|
|
|
100
101
|
body = JSON.stringify(json);
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
if (contentType && contentType !==
|
|
104
|
+
if (contentType && contentType !== "multipart/form-data") {
|
|
104
105
|
if (
|
|
105
106
|
/* Zapier doesn't allow content-type header to be sent from browsers */ !(
|
|
106
|
-
sendWithJs && props.action?.includes(
|
|
107
|
+
sendWithJs && props.action?.includes("zapier.com")
|
|
107
108
|
)
|
|
108
109
|
) {
|
|
109
|
-
headers[
|
|
110
|
+
headers["content-type"] = contentType;
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
|
-
const presubmitEvent = new CustomEvent(
|
|
113
|
+
const presubmitEvent = new CustomEvent("presubmit", { detail: { body } });
|
|
113
114
|
if (formRef.current) {
|
|
114
115
|
formRef.current.dispatchEvent(presubmitEvent);
|
|
115
116
|
if (presubmitEvent.defaultPrevented) {
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
setFormState("sending");
|
|
120
121
|
const formUrl = `${
|
|
121
|
-
builder.env ===
|
|
122
|
+
builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"
|
|
122
123
|
}/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(
|
|
123
|
-
props.sendSubmissionsToEmail ||
|
|
124
|
-
)}&name=${encodeURIComponent(props.name ||
|
|
124
|
+
props.sendSubmissionsToEmail || ""
|
|
125
|
+
)}&name=${encodeURIComponent(props.name || "")}`;
|
|
125
126
|
fetch(
|
|
126
|
-
props.sendSubmissionsTo ===
|
|
127
|
+
props.sendSubmissionsTo === "email"
|
|
127
128
|
? formUrl
|
|
128
129
|
: props.action /* TODO: throw error if no action URL */,
|
|
129
|
-
{ body, headers, method: props.method ||
|
|
130
|
+
{ body, headers, method: props.method || "post" }
|
|
130
131
|
).then(
|
|
131
132
|
async (res) => {
|
|
132
133
|
let body;
|
|
133
|
-
const contentType = res.headers.get(
|
|
134
|
-
if (contentType && contentType.indexOf(
|
|
134
|
+
const contentType = res.headers.get("content-type");
|
|
135
|
+
if (contentType && contentType.indexOf("application/json") !== -1) {
|
|
135
136
|
body = await res.json();
|
|
136
137
|
} else {
|
|
137
138
|
body = await res.text();
|
|
@@ -140,7 +141,7 @@ export default function FormComponent(props) {
|
|
|
140
141
|
/* TODO: allow supplying an error formatter function */ let message =
|
|
141
142
|
get(body, props.errorMessagePath);
|
|
142
143
|
if (message) {
|
|
143
|
-
if (typeof message !==
|
|
144
|
+
if (typeof message !== "string") {
|
|
144
145
|
/* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
|
|
145
146
|
JSON.stringify(message);
|
|
146
147
|
}
|
|
@@ -148,9 +149,9 @@ export default function FormComponent(props) {
|
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
setResponseData(body);
|
|
151
|
-
|
|
152
|
+
setFormState(res.ok ? "success" : "error");
|
|
152
153
|
if (res.ok) {
|
|
153
|
-
const submitSuccessEvent = new CustomEvent(
|
|
154
|
+
const submitSuccessEvent = new CustomEvent("submit:success", {
|
|
154
155
|
detail: { res, body },
|
|
155
156
|
});
|
|
156
157
|
if (formRef.current) {
|
|
@@ -168,7 +169,7 @@ export default function FormComponent(props) {
|
|
|
168
169
|
props.successUrl
|
|
169
170
|
) {
|
|
170
171
|
if (formRef.current) {
|
|
171
|
-
const event = new CustomEvent(
|
|
172
|
+
const event = new CustomEvent("route", {
|
|
172
173
|
detail: { url: props.successUrl },
|
|
173
174
|
});
|
|
174
175
|
formRef.current.dispatchEvent(event);
|
|
@@ -182,7 +183,7 @@ export default function FormComponent(props) {
|
|
|
182
183
|
}
|
|
183
184
|
},
|
|
184
185
|
(err) => {
|
|
185
|
-
const submitErrorEvent = new CustomEvent(
|
|
186
|
+
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
186
187
|
detail: { error: err },
|
|
187
188
|
});
|
|
188
189
|
if (formRef.current) {
|
|
@@ -192,7 +193,7 @@ export default function FormComponent(props) {
|
|
|
192
193
|
}
|
|
193
194
|
}
|
|
194
195
|
setResponseData(err);
|
|
195
|
-
|
|
196
|
+
setFormState("error");
|
|
196
197
|
}
|
|
197
198
|
);
|
|
198
199
|
}
|
|
@@ -208,46 +209,46 @@ export default function FormComponent(props) {
|
|
|
208
209
|
name={props.name}
|
|
209
210
|
onSubmit={(event) => onSubmit(event)}
|
|
210
211
|
>
|
|
211
|
-
{
|
|
212
|
+
{" "}
|
|
212
213
|
{props.builderBlock && props.builderBlock.children ? (
|
|
213
214
|
<>
|
|
214
215
|
{props.builderBlock?.children?.map((block) => (
|
|
215
216
|
<RenderBlock block={block} />
|
|
216
217
|
))}
|
|
217
218
|
</>
|
|
218
|
-
) : null}{
|
|
219
|
-
{submissionState() ===
|
|
219
|
+
) : null}{" "}
|
|
220
|
+
{submissionState() === "error" ? (
|
|
220
221
|
<>
|
|
221
222
|
<BuilderBlocks dataPath="errorMessage" blocks={props.errorMessage} />
|
|
222
223
|
</>
|
|
223
|
-
) : null}{
|
|
224
|
-
{submissionState() ===
|
|
224
|
+
) : null}{" "}
|
|
225
|
+
{submissionState() === "sending" ? (
|
|
225
226
|
<>
|
|
226
227
|
<BuilderBlocks
|
|
227
228
|
dataPath="sendingMessage"
|
|
228
229
|
blocks={props.sendingMessage}
|
|
229
230
|
/>
|
|
230
231
|
</>
|
|
231
|
-
) : null}{
|
|
232
|
-
{submissionState() ===
|
|
232
|
+
) : null}{" "}
|
|
233
|
+
{submissionState() === "error" && responseData ? (
|
|
233
234
|
<>
|
|
234
235
|
<View style={styles.view1}>
|
|
235
|
-
{
|
|
236
|
-
<Text>{JSON.stringify(responseData, null, 2)}</Text>{
|
|
236
|
+
{" "}
|
|
237
|
+
<Text>{JSON.stringify(responseData, null, 2)}</Text>{" "}
|
|
237
238
|
</View>
|
|
238
239
|
</>
|
|
239
|
-
) : null}{
|
|
240
|
-
{submissionState() ===
|
|
240
|
+
) : null}{" "}
|
|
241
|
+
{submissionState() === "success" ? (
|
|
241
242
|
<>
|
|
242
243
|
<BuilderBlocks
|
|
243
244
|
dataPath="successMessage"
|
|
244
245
|
blocks={props.successMessage}
|
|
245
246
|
/>
|
|
246
247
|
</>
|
|
247
|
-
) : null}{
|
|
248
|
+
) : null}{" "}
|
|
248
249
|
</View>
|
|
249
250
|
);
|
|
250
251
|
}
|
|
251
252
|
const styles = StyleSheet.create({
|
|
252
|
-
view1: { padding: 10, color:
|
|
253
|
+
view1: { padding: 10, color: "red", textAlign: "center" },
|
|
253
254
|
});
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const componentInfo = {
|
|
3
|
+
name: "Image",
|
|
4
|
+
static: true,
|
|
5
|
+
builtIn: true,
|
|
6
|
+
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",
|
|
7
|
+
defaultStyles: {
|
|
8
|
+
position: "relative",
|
|
9
|
+
minHeight: "20px",
|
|
10
|
+
minWidth: "20px",
|
|
11
|
+
overflow: "hidden"
|
|
12
|
+
},
|
|
13
|
+
canHaveChildren: true,
|
|
14
|
+
inputs: [
|
|
15
|
+
{
|
|
16
|
+
name: "image",
|
|
17
|
+
type: "file",
|
|
18
|
+
bubble: true,
|
|
19
|
+
allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
|
|
20
|
+
required: true,
|
|
21
|
+
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
|
|
22
|
+
onChange: " const DEFAULT_ASPECT_RATIO = 0.7041; options.delete('srcset'); options.delete('noWebp'); function loadImage(url, timeout) { return new Promise((resolve, reject) => { const img = document.createElement('img'); let loaded = false; img.onload = () => { loaded = true; resolve(img); }; img.addEventListener('error', event => { console.warn('Image load failed', event.error); reject(event.error); }); img.src = url; setTimeout(() => { if (!loaded) { reject(new Error('Image load timed out')); } }, timeout); }); } function round(num) { return Math.round(num * 1000) / 1000; } const value = options.get('image'); const aspectRatio = options.get('aspectRatio'); // For SVG images - don't render as webp, keep them as SVG fetch(value) .then(res => res.blob()) .then(blob => { if (blob.type.includes('svg')) { options.set('noWebp', true); } }); if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) { return loadImage(value).then(img => { const possiblyUpdatedAspectRatio = options.get('aspectRatio'); if ( options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO) ) { if (img.width && img.height) { options.set('aspectRatio', round(img.height / img.width)); options.set('height', img.height); options.set('width', img.width); } } }); }"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "backgroundSize",
|
|
26
|
+
type: "text",
|
|
27
|
+
defaultValue: "cover",
|
|
28
|
+
enum: [
|
|
29
|
+
{
|
|
30
|
+
label: "contain",
|
|
31
|
+
value: "contain",
|
|
32
|
+
helperText: "The image should never get cropped"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "cover",
|
|
36
|
+
value: "cover",
|
|
37
|
+
helperText: "The image should fill it's box, cropping when needed"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "backgroundPosition",
|
|
43
|
+
type: "text",
|
|
44
|
+
defaultValue: "center",
|
|
45
|
+
enum: [
|
|
46
|
+
"center",
|
|
47
|
+
"top",
|
|
48
|
+
"left",
|
|
49
|
+
"right",
|
|
50
|
+
"bottom",
|
|
51
|
+
"top left",
|
|
52
|
+
"top right",
|
|
53
|
+
"bottom left",
|
|
54
|
+
"bottom right"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "altText",
|
|
59
|
+
type: "string",
|
|
60
|
+
helperText: "Text to display when the user has images off"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "height",
|
|
64
|
+
type: "number",
|
|
65
|
+
hideFromUI: true
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "width",
|
|
69
|
+
type: "number",
|
|
70
|
+
hideFromUI: true
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "sizes",
|
|
74
|
+
type: "string",
|
|
75
|
+
hideFromUI: true
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "srcset",
|
|
79
|
+
type: "string",
|
|
80
|
+
hideFromUI: true
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "lazy",
|
|
84
|
+
type: "boolean",
|
|
85
|
+
defaultValue: true,
|
|
86
|
+
hideFromUI: true
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "fitContent",
|
|
90
|
+
type: "boolean",
|
|
91
|
+
helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
|
|
92
|
+
defaultValue: true
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "aspectRatio",
|
|
96
|
+
type: "number",
|
|
97
|
+
helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
|
|
98
|
+
advanced: true,
|
|
99
|
+
defaultValue: 0.7041
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
componentInfo
|
|
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
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View, StyleSheet, Image, Text } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
3
|
|
|
4
4
|
export default function Image(props) {
|
|
5
5
|
return (
|
|
@@ -8,7 +8,7 @@ export default function Image(props) {
|
|
|
8
8
|
<View
|
|
9
9
|
loading="lazy"
|
|
10
10
|
alt={props.altText}
|
|
11
|
-
|
|
11
|
+
role={props.altText ? "presentation" : undefined}
|
|
12
12
|
style={styles.view2}
|
|
13
13
|
src={props.image}
|
|
14
14
|
srcset={props.srcset}
|
|
@@ -43,22 +43,22 @@ export default function Image(props) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const styles = StyleSheet.create({
|
|
46
|
-
view1: { position:
|
|
46
|
+
view1: { position: "relative" },
|
|
47
47
|
view2: {
|
|
48
48
|
opacity: 1,
|
|
49
|
-
transition:
|
|
50
|
-
position:
|
|
49
|
+
transition: "opacity 0.2s ease-in-out",
|
|
50
|
+
position: "absolute",
|
|
51
51
|
height: 100,
|
|
52
52
|
width: 100,
|
|
53
53
|
top: 0,
|
|
54
54
|
left: 0,
|
|
55
55
|
},
|
|
56
|
-
view3: { width: 100, pointerEvents:
|
|
56
|
+
view3: { width: 100, pointerEvents: "none", fontSize: 0 },
|
|
57
57
|
view4: {
|
|
58
|
-
display:
|
|
59
|
-
flexDirection:
|
|
60
|
-
alignItems:
|
|
61
|
-
position:
|
|
58
|
+
display: "flex",
|
|
59
|
+
flexDirection: "column",
|
|
60
|
+
alignItems: "stretch",
|
|
61
|
+
position: "absolute",
|
|
62
62
|
top: 0,
|
|
63
63
|
left: 0,
|
|
64
64
|
width: 100,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const componentInfo = {
|
|
3
|
+
name: "Raw:Img",
|
|
4
|
+
hideFromInsertMenu: true,
|
|
5
|
+
builtIn: true,
|
|
6
|
+
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",
|
|
7
|
+
inputs: [
|
|
8
|
+
{
|
|
9
|
+
name: "image",
|
|
10
|
+
bubble: true,
|
|
11
|
+
type: "file",
|
|
12
|
+
allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
|
|
13
|
+
required: true
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
noWrap: true,
|
|
17
|
+
static: true
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
componentInfo
|
|
21
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 ImgComponent(props) {
|
|
24
|
+
return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
|
|
25
|
+
style: {
|
|
26
|
+
objectFit: props.backgroundSize || "cover",
|
|
27
|
+
objectPosition: props.backgroundPosition || "center"
|
|
28
|
+
},
|
|
29
|
+
key: isEditing() && props.imgSrc || "default-key",
|
|
30
|
+
alt: props.altText,
|
|
31
|
+
src: props.imgSrc
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
ImgComponent as default
|
|
36
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Image, Text } from "react-native";
|
|
3
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
4
|
+
|
|
5
|
+
export default function ImgComponent(props) {
|
|
6
|
+
return (
|
|
7
|
+
<View
|
|
8
|
+
{...props.attributes}
|
|
9
|
+
style={{
|
|
10
|
+
objectFit: props.backgroundSize || "cover",
|
|
11
|
+
objectPosition: props.backgroundPosition || "center",
|
|
12
|
+
}}
|
|
13
|
+
key={(isEditing() && props.imgSrc) || "default-key"}
|
|
14
|
+
alt={props.altText}
|
|
15
|
+
src={props.imgSrc}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const componentInfo = {
|
|
3
|
+
name: "Form:Input",
|
|
4
|
+
builtIn: true,
|
|
5
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca",
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "type",
|
|
9
|
+
type: "text",
|
|
10
|
+
enum: [
|
|
11
|
+
"text",
|
|
12
|
+
"number",
|
|
13
|
+
"email",
|
|
14
|
+
"url",
|
|
15
|
+
"checkbox",
|
|
16
|
+
"radio",
|
|
17
|
+
"range",
|
|
18
|
+
"date",
|
|
19
|
+
"datetime-local",
|
|
20
|
+
"search",
|
|
21
|
+
"tel",
|
|
22
|
+
"time",
|
|
23
|
+
"file",
|
|
24
|
+
"month",
|
|
25
|
+
"week",
|
|
26
|
+
"password",
|
|
27
|
+
"color",
|
|
28
|
+
"hidden"
|
|
29
|
+
],
|
|
30
|
+
defaultValue: "text"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "name",
|
|
34
|
+
type: "string",
|
|
35
|
+
required: true,
|
|
36
|
+
helperText: 'Every input in a form needs a unique name describing what it takes, e.g. "email"'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "placeholder",
|
|
40
|
+
type: "string",
|
|
41
|
+
defaultValue: "Hello there",
|
|
42
|
+
helperText: "Text to display when there is no value"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "defaultValue",
|
|
46
|
+
type: "string"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "value",
|
|
50
|
+
type: "string",
|
|
51
|
+
advanced: true
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "required",
|
|
55
|
+
type: "boolean",
|
|
56
|
+
helperText: "Is this input required to be filled out to submit a form",
|
|
57
|
+
defaultValue: false
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
noWrap: true,
|
|
61
|
+
static: true,
|
|
62
|
+
defaultStyles: {
|
|
63
|
+
paddingTop: "10px",
|
|
64
|
+
paddingBottom: "10px",
|
|
65
|
+
paddingLeft: "10px",
|
|
66
|
+
paddingRight: "10px",
|
|
67
|
+
borderRadius: "3px",
|
|
68
|
+
borderWidth: "1px",
|
|
69
|
+
borderStyle: "solid",
|
|
70
|
+
borderColor: "#ccc"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
componentInfo
|
|
75
|
+
};
|