@builder.io/sdk-react-native 0.4.5 → 0.5.0
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/dist/blocks/button/button.js +6 -2
- package/dist/blocks/button/component-info.js +4 -8
- package/dist/blocks/columns/columns.js +17 -21
- package/dist/blocks/columns/component-info.js +27 -48
- package/dist/blocks/custom-code/component-info.js +4 -8
- package/dist/blocks/custom-code/custom-code.js +1 -1
- package/dist/blocks/embed/component-info.js +7 -11
- package/dist/blocks/embed/embed.js +1 -1
- package/dist/blocks/embed/helpers.js +2 -6
- package/dist/blocks/form/component-info.js +33 -69
- package/dist/blocks/form/form.js +2 -203
- package/dist/blocks/fragment/fragment.js +1 -1
- package/dist/blocks/helpers.js +33 -0
- package/dist/blocks/image/component-info.js +21 -47
- package/dist/blocks/image/image.helpers.js +2 -2
- package/dist/blocks/img/component-info.js +2 -4
- package/dist/blocks/img/img.js +2 -1
- package/dist/blocks/input/component-info.js +8 -34
- package/dist/blocks/input/input.js +2 -1
- package/dist/blocks/raw-text/component-info.js +2 -4
- package/dist/blocks/raw-text/raw-text.js +3 -2
- package/dist/blocks/section/component-info.js +5 -10
- package/dist/blocks/section/section.js +2 -1
- package/dist/blocks/select/component-info.js +12 -24
- package/dist/blocks/select/select.js +2 -1
- package/dist/blocks/submit-button/component-info.js +2 -4
- package/dist/blocks/submit-button/submit-button.js +2 -1
- package/dist/blocks/symbol/component-info.js +7 -12
- package/dist/blocks/symbol/symbol.helpers.js +66 -0
- package/dist/blocks/symbol/symbol.js +23 -52
- package/dist/blocks/text/component-info.js +3 -4
- package/dist/blocks/textarea/component-info.js +6 -12
- package/dist/blocks/textarea/textarea.js +2 -1
- package/dist/blocks/video/component-info.js +21 -41
- package/dist/components/block/block.helpers.js +12 -23
- package/dist/components/block/block.js +40 -70
- package/dist/components/block/components/block-styles.js +1 -1
- package/dist/components/block/components/block-wrapper/block-wrapper.js +41 -0
- package/dist/components/block/components/block-wrapper.js +56 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.js +40 -0
- package/dist/components/block/components/component-ref/component-ref.js +63 -0
- package/dist/components/block/components/component-ref.js +81 -0
- package/dist/components/block/components/interactive-element/interactive-element.helpers.js +35 -0
- package/dist/components/block/components/interactive-element/interactive-element.js +36 -0
- package/dist/components/block/components/interactive-element.js +46 -0
- package/dist/components/block/components/repeated-block.js +4 -4
- package/dist/components/blocks/blocks-wrapper.js +5 -2
- package/dist/components/blocks/blocks.js +2 -2
- package/dist/components/content/builder-editing.js +32 -0
- package/dist/components/content/components/enable-editor.js +30 -33
- package/dist/components/content/components/styles.helpers.js +55 -0
- package/dist/components/content/components/styles.js +61 -0
- package/dist/components/content/content.helpers.js +10 -3
- package/dist/components/content/content.js +25 -42
- package/dist/components/content/wrap-component-ref.js +1 -1
- package/dist/components/content-variants/content-variants.js +38 -34
- package/dist/components/content-variants/content-variants.types.js +1 -0
- package/dist/components/content-variants/helpers.js +61 -25
- package/dist/components/inlined-script.js +1 -1
- package/dist/components/inlined-styles.js +1 -1
- package/dist/constants/device-sizes.js +2 -2
- package/dist/constants/sdk-version.js +1 -1
- package/dist/context/builder.context.js +1 -1
- package/dist/functions/apply-patch-with-mutation.js +75 -0
- package/dist/functions/apply-patch-with-mutation.test.js +55 -0
- package/dist/functions/camel-to-kebab-case.js +1 -1
- package/dist/functions/evaluate/acorn.js +1691 -0
- package/dist/functions/evaluate/evaluate.js +72 -0
- package/dist/functions/evaluate/index.js +5 -0
- package/dist/functions/evaluate/interpreter.js +2903 -0
- package/dist/functions/evaluate/non-node-runtime.js +97 -0
- package/dist/functions/evaluate/types.js +1 -0
- package/dist/functions/evaluate.test.js +12 -6
- package/dist/functions/event-handler-name.js +1 -1
- package/dist/functions/extract-text-styles.js +3 -9
- package/dist/functions/fast-clone.js +1 -1
- package/dist/functions/get-block-actions-handler.js +2 -2
- package/dist/functions/get-block-actions.js +14 -1
- package/dist/functions/get-block-component-options.js +6 -1
- package/dist/functions/get-block-properties.js +21 -8
- package/dist/functions/get-builder-search-params/fn.test.js +3 -3
- package/dist/functions/get-builder-search-params/index.js +4 -4
- package/dist/functions/get-content/generate-content-url.js +12 -5
- package/dist/functions/get-content/generate-content-url.test.js +31 -17
- package/dist/functions/get-content/index.js +36 -12
- package/dist/functions/get-content/processCookies.js +7 -0
- package/dist/functions/get-processed-block.js +8 -3
- package/dist/functions/get-processed-block.test.js +3 -1
- package/dist/functions/get-react-native-block-styles.js +6 -1
- package/dist/functions/is-non-node-server.js +12 -0
- package/dist/functions/on-change.test.js +13 -3
- package/dist/functions/register-component.js +24 -19
- package/dist/functions/sanitize-react-native-block-styles.js +17 -6
- package/dist/functions/set.test.js +9 -3
- package/dist/functions/track/helpers.js +5 -5
- package/dist/functions/track/index.js +29 -18
- package/dist/functions/track/interaction.js +10 -4
- package/dist/functions/transform-block-properties.js +2 -0
- package/dist/helpers/ab-tests.js +35 -14
- package/dist/helpers/canTrack.js +2 -2
- package/dist/helpers/css.js +2 -2
- package/dist/helpers/flatten.js +10 -7
- package/dist/helpers/nullable.js +1 -1
- package/dist/helpers/preview-lru-cache/get.js +11 -0
- package/dist/helpers/preview-lru-cache/helpers.js +13 -0
- package/dist/helpers/preview-lru-cache/init.js +13 -0
- package/dist/helpers/preview-lru-cache/set.js +37 -0
- package/dist/helpers/preview-lru-cache/types.js +1 -0
- package/dist/helpers/sessionId.js +13 -6
- package/dist/helpers/url.js +1 -1
- package/dist/helpers/visitorId.js +4 -1
- package/dist/index-helpers/blocks-exports.js +2 -2
- package/dist/scripts/init-editing.js +61 -46
- package/package.json +2 -2
- package/src/blocks/button/button.jsx +11 -2
- package/src/blocks/button/component-info.js +16 -22
- package/src/blocks/columns/columns.jsx +27 -26
- package/src/blocks/columns/component-info.js +203 -226
- package/src/blocks/custom-code/component-info.js +19 -25
- package/src/blocks/custom-code/custom-code.jsx +1 -1
- package/src/blocks/embed/component-info.js +31 -37
- package/src/blocks/embed/embed.jsx +1 -1
- package/src/blocks/embed/helpers.js +3 -9
- package/src/blocks/form/component-info.js +174 -212
- package/src/blocks/form/form.jsx +3 -247
- package/src/blocks/fragment/component-info.js +1 -3
- package/src/blocks/fragment/fragment.jsx +1 -1
- package/src/blocks/helpers.js +27 -0
- package/src/blocks/image/component-info.js +105 -133
- package/src/blocks/image/image.helpers.js +3 -5
- package/src/blocks/img/component-info.js +8 -12
- package/src/blocks/img/img.jsx +3 -1
- package/src/blocks/input/component-info.js +29 -57
- package/src/blocks/input/input.jsx +3 -1
- package/src/blocks/raw-text/component-info.js +7 -11
- package/src/blocks/raw-text/raw-text.jsx +4 -2
- package/src/blocks/section/component-info.js +24 -31
- package/src/blocks/section/section.jsx +3 -1
- package/src/blocks/select/component-info.js +34 -48
- package/src/blocks/select/select.jsx +3 -1
- package/src/blocks/submit-button/component-info.js +6 -10
- package/src/blocks/submit-button/submit-button.jsx +3 -2
- package/src/blocks/symbol/component-info.js +30 -37
- package/src/blocks/symbol/symbol.helpers.js +60 -0
- package/src/blocks/symbol/symbol.jsx +33 -61
- package/src/blocks/text/component-info.js +10 -13
- package/src/blocks/textarea/component-info.js +22 -30
- package/src/blocks/textarea/textarea.jsx +3 -1
- package/src/blocks/video/component-info.js +74 -96
- package/src/components/{render-block/render-block.helpers.js → block/block.helpers.js} +26 -44
- package/src/components/{render-block/render-block.jsx → block/block.jsx} +68 -81
- package/src/components/{render-block → block/components}/block-styles.jsx +18 -17
- package/src/components/block/components/block-wrapper.jsx +58 -0
- package/src/components/block/components/component-ref/component-ref.helpers.js +41 -0
- package/src/components/block/components/component-ref/component-ref.jsx +72 -0
- package/src/components/block/components/interactive-element.jsx +37 -0
- package/src/components/{render-block/render-repeated-block.jsx → block/components/repeated-block.jsx} +10 -6
- package/src/components/blocks/blocks-wrapper.jsx +74 -0
- package/src/components/blocks/blocks.jsx +51 -0
- package/src/components/{render-content/render-content.jsx → content/components/enable-editor.jsx} +77 -163
- package/src/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +6 -7
- package/src/components/{render-content/components/render-styles.jsx → content/components/styles.jsx} +5 -5
- package/src/components/{render-content/render-content.helpers.js → content/content.helpers.js} +15 -15
- package/src/components/content/content.jsx +141 -0
- package/src/components/content/index.js +2 -0
- package/src/components/content/wrap-component-ref.js +2 -0
- package/src/components/{render-content-variants/render-content-variants.jsx → content-variants/content-variants.jsx} +20 -23
- package/src/components/{render-content-variants → content-variants}/helpers.js +28 -40
- package/src/components/inlined-script.jsx +1 -1
- package/src/components/inlined-styles.jsx +1 -1
- package/src/constants/device-sizes.js +6 -6
- package/src/constants/sdk-version.js +1 -1
- package/src/context/builder.context.js +1 -1
- package/src/functions/apply-patch-with-mutation.js +66 -0
- package/src/functions/camel-to-kebab-case.js +2 -4
- package/src/functions/evaluate/acorn.js +1595 -0
- package/src/functions/{evaluate.js → evaluate/evaluate.js} +36 -10
- package/src/functions/evaluate/index.js +2 -0
- package/src/functions/evaluate/interpreter.js +2801 -0
- package/src/functions/evaluate/non-node-runtime.js +92 -0
- package/src/functions/evaluate/types.js +0 -0
- package/src/functions/event-handler-name.js +2 -4
- package/src/functions/extract-text-styles.js +4 -12
- package/src/functions/fast-clone.js +2 -4
- package/src/functions/get-block-actions-handler.js +3 -5
- package/src/functions/get-block-actions.js +15 -4
- package/src/functions/get-block-component-options.js +11 -12
- package/src/functions/get-block-properties.js +29 -19
- package/src/functions/get-builder-search-params/index.js +5 -10
- package/src/functions/get-content/generate-content-url.js +17 -19
- package/src/functions/get-content/index.js +43 -29
- package/src/functions/get-fetch.js +1 -3
- package/src/functions/get-global-this.js +1 -3
- package/src/functions/get-processed-block.js +12 -13
- package/src/functions/get-react-native-block-styles.js +11 -12
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +1 -3
- package/src/functions/is-editing.js +1 -3
- package/src/functions/is-iframe.js +1 -3
- package/src/functions/is-non-node-server.js +9 -0
- package/src/functions/is-previewing.js +1 -3
- package/src/functions/on-change.js +1 -4
- package/src/functions/register-component.js +34 -42
- package/src/functions/register.js +1 -3
- package/src/functions/sanitize-react-native-block-styles.js +22 -17
- package/src/functions/set-editor-settings.js +1 -3
- package/src/functions/set.js +1 -3
- package/src/functions/track/helpers.js +3 -5
- package/src/functions/track/index.js +45 -43
- package/src/functions/track/interaction.js +11 -7
- package/src/functions/transform-block-properties.js +2 -0
- package/src/helpers/ab-tests.js +45 -28
- package/src/helpers/canTrack.js +3 -5
- package/src/helpers/css.js +3 -7
- package/src/helpers/flatten.js +15 -18
- package/src/helpers/localStorage.js +1 -4
- package/src/helpers/logger.js +1 -3
- package/src/helpers/nullable.js +2 -4
- package/src/helpers/preview-lru-cache/get.js +8 -0
- package/src/helpers/preview-lru-cache/helpers.js +10 -0
- package/src/helpers/preview-lru-cache/init.js +10 -0
- package/src/helpers/preview-lru-cache/set.js +35 -0
- package/src/helpers/preview-lru-cache/types.js +0 -0
- package/src/helpers/sessionId.js +14 -11
- package/src/helpers/time.js +1 -3
- package/src/helpers/url.js +2 -4
- package/src/helpers/uuid.js +4 -6
- package/src/helpers/visitorId.js +8 -7
- package/src/index-helpers/blocks-exports.js +1 -1
- package/src/index.js +2 -17
- package/src/scripts/init-editing.js +62 -48
- package/src/types/api-version.js +1 -3
- package/src/types/builder-props.js +0 -0
- package/src/blocks/util.js +0 -8
- package/src/components/render-block/render-component.jsx +0 -55
- package/src/components/render-blocks.jsx +0 -101
- package/src/components/render-content/builder-editing.jsx +0 -16
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/wrap-component-ref.js +0 -4
- package/src/functions/evaluate.test.js +0 -17
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-content/generate-content-url.test.js +0 -97
- package/src/functions/get-processed-block.test.js +0 -34
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/set.test.js +0 -16
- package/src/helpers/url.test.js +0 -21
- /package/src/components/{render-block → block}/types.js +0 -0
- /package/src/components/{render-content/render-content.types.js → content/content.types.js} +0 -0
- /package/src/components/{render-content-variants/render-content-variants.types.js → content-variants/content-variants.types.js} +0 -0
package/dist/blocks/form/form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
"use client";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -23,211 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
__setModuleDefault(result, mod);
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
const BaseText_1 = __importDefault(require("../BaseText"));
|
|
31
27
|
const React = __importStar(require("react"));
|
|
32
28
|
const react_native_1 = require("react-native");
|
|
33
|
-
const react_1 = require("react");
|
|
34
|
-
const render_block_1 = __importDefault(require("../../components/render-block/render-block"));
|
|
35
|
-
const render_blocks_1 = __importDefault(require("../../components/render-blocks"));
|
|
36
|
-
const is_editing_js_1 = require("../../functions/is-editing.js");
|
|
37
29
|
function FormComponent(props) {
|
|
38
|
-
|
|
39
|
-
const formRef = (0, react_1.useRef)(null);
|
|
40
|
-
const [formState, setFormState] = (0, react_1.useState)(() => "unsubmitted");
|
|
41
|
-
const [responseData, setResponseData] = (0, react_1.useState)(() => null);
|
|
42
|
-
const [formErrorMessage, setFormErrorMessage] = (0, react_1.useState)(() => "");
|
|
43
|
-
function submissionState() {
|
|
44
|
-
return ((0, is_editing_js_1.isEditing)() && props.previewState) || formState;
|
|
45
|
-
}
|
|
46
|
-
function onSubmit(event) {
|
|
47
|
-
var _a;
|
|
48
|
-
const sendWithJs = props.sendWithJs || props.sendSubmissionsTo === "email";
|
|
49
|
-
if (props.sendSubmissionsTo === "zapier") {
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
}
|
|
52
|
-
else if (sendWithJs) {
|
|
53
|
-
if (!(props.action || props.sendSubmissionsTo === "email")) {
|
|
54
|
-
event.preventDefault();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
event.preventDefault();
|
|
58
|
-
const el = event.currentTarget;
|
|
59
|
-
const headers = props.customHeaders || {};
|
|
60
|
-
let body;
|
|
61
|
-
const formData = new FormData(el);
|
|
62
|
-
// TODO: maybe support null
|
|
63
|
-
const formPairs = Array.from(event.currentTarget.querySelectorAll("input,select,textarea"))
|
|
64
|
-
.filter((el) => !!el.name)
|
|
65
|
-
.map((el) => {
|
|
66
|
-
let value;
|
|
67
|
-
const key = el.name;
|
|
68
|
-
if (el instanceof HTMLInputElement) {
|
|
69
|
-
if (el.type === "radio") {
|
|
70
|
-
if (el.checked) {
|
|
71
|
-
value = el.name;
|
|
72
|
-
return {
|
|
73
|
-
key,
|
|
74
|
-
value,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (el.type === "checkbox") {
|
|
79
|
-
value = el.checked;
|
|
80
|
-
}
|
|
81
|
-
else if (el.type === "number" || el.type === "range") {
|
|
82
|
-
const num = el.valueAsNumber;
|
|
83
|
-
if (!isNaN(num)) {
|
|
84
|
-
value = num;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else if (el.type === "file") {
|
|
88
|
-
// TODO: one vs multiple files
|
|
89
|
-
value = el.files;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
value = el.value;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
value = el.value;
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
key,
|
|
100
|
-
value,
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
let contentType = props.contentType;
|
|
104
|
-
if (props.sendSubmissionsTo === "email") {
|
|
105
|
-
contentType = "multipart/form-data";
|
|
106
|
-
}
|
|
107
|
-
Array.from(formPairs).forEach(({ value }) => {
|
|
108
|
-
if (value instanceof File ||
|
|
109
|
-
(Array.isArray(value) && value[0] instanceof File) ||
|
|
110
|
-
value instanceof FileList) {
|
|
111
|
-
contentType = "multipart/form-data";
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
// TODO: send as urlEncoded or multipart by default
|
|
115
|
-
// because of ease of use and reliability in browser API
|
|
116
|
-
// for encoding the form?
|
|
117
|
-
if (contentType !== "application/json") {
|
|
118
|
-
body = formData;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
// Json
|
|
122
|
-
const json = {};
|
|
123
|
-
Array.from(formPairs).forEach(({ value, key }) => {
|
|
124
|
-
set(json, key, value);
|
|
125
|
-
});
|
|
126
|
-
body = JSON.stringify(json);
|
|
127
|
-
}
|
|
128
|
-
if (contentType && contentType !== "multipart/form-data") {
|
|
129
|
-
if (
|
|
130
|
-
/* Zapier doesn't allow content-type header to be sent from browsers */ !(sendWithJs && ((_a = props.action) === null || _a === void 0 ? void 0 : _a.includes("zapier.com")))) {
|
|
131
|
-
headers["content-type"] = contentType;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const presubmitEvent = new CustomEvent("presubmit", { detail: { body } });
|
|
135
|
-
if (formRef.current) {
|
|
136
|
-
formRef.current.dispatchEvent(presubmitEvent);
|
|
137
|
-
if (presubmitEvent.defaultPrevented) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
setFormState("sending");
|
|
142
|
-
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 || "")}`;
|
|
143
|
-
fetch(props.sendSubmissionsTo === "email"
|
|
144
|
-
? formUrl
|
|
145
|
-
: props.action /* TODO: throw error if no action URL */, { body, headers, method: props.method || "post" }).then(async (res) => {
|
|
146
|
-
let body;
|
|
147
|
-
const contentType = res.headers.get("content-type");
|
|
148
|
-
if (contentType && contentType.indexOf("application/json") !== -1) {
|
|
149
|
-
body = await res.json();
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
body = await res.text();
|
|
153
|
-
}
|
|
154
|
-
if (!res.ok && props.errorMessagePath) {
|
|
155
|
-
/* TODO: allow supplying an error formatter function */ let message = get(body, props.errorMessagePath);
|
|
156
|
-
if (message) {
|
|
157
|
-
if (typeof message !== "string") {
|
|
158
|
-
/* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
|
|
159
|
-
JSON.stringify(message);
|
|
160
|
-
}
|
|
161
|
-
setFormErrorMessage(message);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
setResponseData(body);
|
|
165
|
-
setFormState(res.ok ? "success" : "error");
|
|
166
|
-
if (res.ok) {
|
|
167
|
-
const submitSuccessEvent = new CustomEvent("submit:success", {
|
|
168
|
-
detail: { res, body },
|
|
169
|
-
});
|
|
170
|
-
if (formRef.current) {
|
|
171
|
-
formRef.current.dispatchEvent(submitSuccessEvent);
|
|
172
|
-
if (submitSuccessEvent.defaultPrevented) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
/* TODO: option to turn this on/off? */ if (props.resetFormOnSubmit !== false) {
|
|
176
|
-
formRef.current.reset();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/* TODO: client side route event first that can be preventDefaulted */ if (props.successUrl) {
|
|
180
|
-
if (formRef.current) {
|
|
181
|
-
const event = new CustomEvent("route", {
|
|
182
|
-
detail: { url: props.successUrl },
|
|
183
|
-
});
|
|
184
|
-
formRef.current.dispatchEvent(event);
|
|
185
|
-
if (!event.defaultPrevented) {
|
|
186
|
-
location.href = props.successUrl;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
location.href = props.successUrl;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}, (err) => {
|
|
195
|
-
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
196
|
-
detail: { error: err },
|
|
197
|
-
});
|
|
198
|
-
if (formRef.current) {
|
|
199
|
-
formRef.current.dispatchEvent(submitErrorEvent);
|
|
200
|
-
if (submitErrorEvent.defaultPrevented) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
setResponseData(err);
|
|
205
|
-
setFormState("error");
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
const builderContext = (0, react_1.useContext)(BuilderContext);
|
|
210
|
-
return (React.createElement(react_native_1.View, { validate: props.validate, ref: formRef, action: !props.sendWithJs && props.action, method: props.method, name: props.name, onSubmit: (event) => onSubmit(event), ...props.attributes },
|
|
211
|
-
" ",
|
|
212
|
-
props.builderBlock && props.builderBlock.children ? (React.createElement(React.Fragment, null, (_b = (_a = props.builderBlock) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.map((block) => (React.createElement(render_block_1.default, { block: block, context: builderContext }))))) : null,
|
|
213
|
-
" ",
|
|
214
|
-
submissionState() === "error" ? (React.createElement(React.Fragment, null,
|
|
215
|
-
React.createElement(render_blocks_1.default, { dataPath: "errorMessage", blocks: props.errorMessage }))) : null,
|
|
216
|
-
" ",
|
|
217
|
-
submissionState() === "sending" ? (React.createElement(React.Fragment, null,
|
|
218
|
-
React.createElement(render_blocks_1.default, { dataPath: "sendingMessage", blocks: props.sendingMessage }))) : null,
|
|
219
|
-
" ",
|
|
220
|
-
submissionState() === "error" && responseData ? (React.createElement(React.Fragment, null,
|
|
221
|
-
React.createElement(react_native_1.View, { style: styles.view1 },
|
|
222
|
-
" ",
|
|
223
|
-
React.createElement(BaseText_1.default, null, JSON.stringify(responseData, null, 2)),
|
|
224
|
-
" "))) : null,
|
|
225
|
-
" ",
|
|
226
|
-
submissionState() === "success" ? (React.createElement(React.Fragment, null,
|
|
227
|
-
React.createElement(render_blocks_1.default, { dataPath: "successMessage", blocks: props.successMessage }))) : null,
|
|
228
|
-
" "));
|
|
30
|
+
return React.createElement(React.Fragment, null);
|
|
229
31
|
}
|
|
230
|
-
const styles = react_native_1.StyleSheet.create({
|
|
231
|
-
view1: { padding: 10, color: "red", textAlign: "center" },
|
|
232
|
-
});
|
|
233
32
|
exports.default = FormComponent;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setAttrs = exports.filterAttrs = void 0;
|
|
4
|
+
function filterAttrs(attrs = {}, prefix, isEvent) {
|
|
5
|
+
const result = {};
|
|
6
|
+
for (const attr in attrs) {
|
|
7
|
+
if (!attrs[attr])
|
|
8
|
+
continue;
|
|
9
|
+
if (isEvent && !attr.startsWith(prefix))
|
|
10
|
+
continue;
|
|
11
|
+
const eventName = isEvent ? attr.replace(prefix, "") : attr;
|
|
12
|
+
result[eventName] = attrs[attr];
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
exports.filterAttrs = filterAttrs;
|
|
17
|
+
function setAttrs(node, attrs = {}) {
|
|
18
|
+
const attrKeys = Object.keys(attrs);
|
|
19
|
+
const setup = attr => node.addEventListener(attr, attrs[attr]);
|
|
20
|
+
const teardown = attr => node.removeEventListener(attr, attrs[attr]);
|
|
21
|
+
attrKeys.forEach(setup);
|
|
22
|
+
return {
|
|
23
|
+
update(attrs2 = {}) {
|
|
24
|
+
const attrKeys2 = Object.keys(attrs2);
|
|
25
|
+
attrKeys2.forEach(teardown);
|
|
26
|
+
attrKeys2.forEach(setup);
|
|
27
|
+
},
|
|
28
|
+
destroy() {
|
|
29
|
+
attrKeys.forEach(teardown);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.setAttrs = setAttrs;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.componentInfo = void 0;
|
|
4
|
-
const util_js_1 = require("../util.js");
|
|
5
4
|
const componentInfo = {
|
|
6
5
|
name: "Image",
|
|
7
6
|
static: true,
|
|
@@ -13,15 +12,14 @@ const componentInfo = {
|
|
|
13
12
|
overflow: "hidden"
|
|
14
13
|
},
|
|
15
14
|
canHaveChildren: true,
|
|
16
|
-
inputs: [
|
|
17
|
-
{
|
|
15
|
+
inputs: [{
|
|
18
16
|
name: "image",
|
|
19
17
|
type: "file",
|
|
20
18
|
bubble: true,
|
|
21
19
|
allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
|
|
22
20
|
required: true,
|
|
23
21
|
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
|
|
24
|
-
onChange:
|
|
22
|
+
onChange: options => {
|
|
25
23
|
const DEFAULT_ASPECT_RATIO = 0.7041;
|
|
26
24
|
options.delete("srcset");
|
|
27
25
|
options.delete("noWebp");
|
|
@@ -33,7 +31,7 @@ const componentInfo = {
|
|
|
33
31
|
loaded = true;
|
|
34
32
|
resolve(img);
|
|
35
33
|
};
|
|
36
|
-
img.addEventListener("error",
|
|
34
|
+
img.addEventListener("error", event => {
|
|
37
35
|
console.warn("Image load failed", event.error);
|
|
38
36
|
reject(event.error);
|
|
39
37
|
});
|
|
@@ -50,13 +48,13 @@ const componentInfo = {
|
|
|
50
48
|
}
|
|
51
49
|
const value = options.get("image");
|
|
52
50
|
const aspectRatio = options.get("aspectRatio");
|
|
53
|
-
fetch(value).then(
|
|
51
|
+
fetch(value).then(res => res.blob()).then(blob => {
|
|
54
52
|
if (blob.type.includes("svg")) {
|
|
55
53
|
options.set("noWebp", true);
|
|
56
54
|
}
|
|
57
55
|
});
|
|
58
56
|
if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) {
|
|
59
|
-
return loadImage(value).then(
|
|
57
|
+
return loadImage(value).then(img => {
|
|
60
58
|
const possiblyUpdatedAspectRatio = options.get("aspectRatio");
|
|
61
59
|
if (options.get("image") === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
|
|
62
60
|
if (img.width && img.height) {
|
|
@@ -67,85 +65,61 @@ const componentInfo = {
|
|
|
67
65
|
}
|
|
68
66
|
});
|
|
69
67
|
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
{
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
73
70
|
name: "backgroundSize",
|
|
74
71
|
type: "text",
|
|
75
72
|
defaultValue: "cover",
|
|
76
|
-
enum: [
|
|
77
|
-
{
|
|
73
|
+
enum: [{
|
|
78
74
|
label: "contain",
|
|
79
75
|
value: "contain",
|
|
80
76
|
helperText: "The image should never get cropped"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
77
|
+
}, {
|
|
83
78
|
label: "cover",
|
|
84
79
|
value: "cover",
|
|
85
80
|
helperText: "The image should fill it's box, cropping when needed"
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
{
|
|
81
|
+
}]
|
|
82
|
+
}, {
|
|
90
83
|
name: "backgroundPosition",
|
|
91
84
|
type: "text",
|
|
92
85
|
defaultValue: "center",
|
|
93
|
-
enum: [
|
|
94
|
-
|
|
95
|
-
"top",
|
|
96
|
-
"left",
|
|
97
|
-
"right",
|
|
98
|
-
"bottom",
|
|
99
|
-
"top left",
|
|
100
|
-
"top right",
|
|
101
|
-
"bottom left",
|
|
102
|
-
"bottom right"
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
{
|
|
86
|
+
enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
|
|
87
|
+
}, {
|
|
106
88
|
name: "altText",
|
|
107
89
|
type: "string",
|
|
108
90
|
helperText: "Text to display when the user has images off"
|
|
109
|
-
},
|
|
110
|
-
{
|
|
91
|
+
}, {
|
|
111
92
|
name: "height",
|
|
112
93
|
type: "number",
|
|
113
94
|
hideFromUI: true
|
|
114
|
-
},
|
|
115
|
-
{
|
|
95
|
+
}, {
|
|
116
96
|
name: "width",
|
|
117
97
|
type: "number",
|
|
118
98
|
hideFromUI: true
|
|
119
|
-
},
|
|
120
|
-
{
|
|
99
|
+
}, {
|
|
121
100
|
name: "sizes",
|
|
122
101
|
type: "string",
|
|
123
102
|
hideFromUI: true
|
|
124
|
-
},
|
|
125
|
-
{
|
|
103
|
+
}, {
|
|
126
104
|
name: "srcset",
|
|
127
105
|
type: "string",
|
|
128
106
|
hideFromUI: true
|
|
129
|
-
},
|
|
130
|
-
{
|
|
107
|
+
}, {
|
|
131
108
|
name: "lazy",
|
|
132
109
|
type: "boolean",
|
|
133
110
|
defaultValue: true,
|
|
134
111
|
hideFromUI: true
|
|
135
|
-
},
|
|
136
|
-
{
|
|
112
|
+
}, {
|
|
137
113
|
name: "fitContent",
|
|
138
114
|
type: "boolean",
|
|
139
115
|
helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
|
|
140
116
|
defaultValue: true
|
|
141
|
-
},
|
|
142
|
-
{
|
|
117
|
+
}, {
|
|
143
118
|
name: "aspectRatio",
|
|
144
119
|
type: "number",
|
|
145
120
|
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",
|
|
146
121
|
advanced: true,
|
|
147
122
|
defaultValue: 0.7041
|
|
148
|
-
}
|
|
149
|
-
]
|
|
123
|
+
}]
|
|
150
124
|
};
|
|
151
125
|
exports.componentInfo = componentInfo;
|
|
@@ -39,10 +39,10 @@ function getSrcSet(url) {
|
|
|
39
39
|
if (!isNaN(widthInSrc)) {
|
|
40
40
|
srcUrl = `${srcUrl} ${widthInSrc}w`;
|
|
41
41
|
}
|
|
42
|
-
return sizes.filter(
|
|
42
|
+
return sizes.filter(size => size !== widthInSrc).map(size => `${updateQueryParam(url, "width", size)} ${size}w`).concat([srcUrl]).join(", ");
|
|
43
43
|
}
|
|
44
44
|
if (url.match(/cdn\.shopify\.com/)) {
|
|
45
|
-
return sizes.map(
|
|
45
|
+
return sizes.map(size => [getShopifyImageUrl(url, `${size}x${size}`), size]).filter(([sizeUrl]) => !!sizeUrl).map(([sizeUrl, size]) => `${sizeUrl} ${size}w`).concat([url]).join(", ");
|
|
46
46
|
}
|
|
47
47
|
return url;
|
|
48
48
|
}
|
|
@@ -5,15 +5,13 @@ const componentInfo = {
|
|
|
5
5
|
name: "Raw:Img",
|
|
6
6
|
hideFromInsertMenu: true,
|
|
7
7
|
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",
|
|
8
|
-
inputs: [
|
|
9
|
-
{
|
|
8
|
+
inputs: [{
|
|
10
9
|
name: "image",
|
|
11
10
|
bubble: true,
|
|
12
11
|
type: "file",
|
|
13
12
|
allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
|
|
14
13
|
required: true
|
|
15
|
-
}
|
|
16
|
-
],
|
|
14
|
+
}],
|
|
17
15
|
noWrap: true,
|
|
18
16
|
static: true
|
|
19
17
|
};
|
package/dist/blocks/img/img.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
"use client";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
const React = __importStar(require("react"));
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
29
|
const is_editing_js_1 = require("../../functions/is-editing.js");
|
|
30
|
+
const helpers_js_1 = require("../helpers.js");
|
|
30
31
|
function ImgComponent(props) {
|
|
31
32
|
return (React.createElement(react_native_1.View, { style: {
|
|
32
33
|
objectFit: props.backgroundSize || "cover",
|
|
@@ -4,60 +4,34 @@ exports.componentInfo = void 0;
|
|
|
4
4
|
const componentInfo = {
|
|
5
5
|
name: "Form:Input",
|
|
6
6
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca",
|
|
7
|
-
inputs: [
|
|
8
|
-
{
|
|
7
|
+
inputs: [{
|
|
9
8
|
name: "type",
|
|
10
9
|
type: "text",
|
|
11
|
-
enum: [
|
|
12
|
-
"text",
|
|
13
|
-
"number",
|
|
14
|
-
"email",
|
|
15
|
-
"url",
|
|
16
|
-
"checkbox",
|
|
17
|
-
"radio",
|
|
18
|
-
"range",
|
|
19
|
-
"date",
|
|
20
|
-
"datetime-local",
|
|
21
|
-
"search",
|
|
22
|
-
"tel",
|
|
23
|
-
"time",
|
|
24
|
-
"file",
|
|
25
|
-
"month",
|
|
26
|
-
"week",
|
|
27
|
-
"password",
|
|
28
|
-
"color",
|
|
29
|
-
"hidden"
|
|
30
|
-
],
|
|
10
|
+
enum: ["text", "number", "email", "url", "checkbox", "radio", "range", "date", "datetime-local", "search", "tel", "time", "file", "month", "week", "password", "color", "hidden"],
|
|
31
11
|
defaultValue: "text"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
12
|
+
}, {
|
|
34
13
|
name: "name",
|
|
35
14
|
type: "string",
|
|
36
15
|
required: true,
|
|
37
16
|
helperText: 'Every input in a form needs a unique name describing what it takes, e.g. "email"'
|
|
38
|
-
},
|
|
39
|
-
{
|
|
17
|
+
}, {
|
|
40
18
|
name: "placeholder",
|
|
41
19
|
type: "string",
|
|
42
20
|
defaultValue: "Hello there",
|
|
43
21
|
helperText: "Text to display when there is no value"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
22
|
+
}, {
|
|
46
23
|
name: "defaultValue",
|
|
47
24
|
type: "string"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
25
|
+
}, {
|
|
50
26
|
name: "value",
|
|
51
27
|
type: "string",
|
|
52
28
|
advanced: true
|
|
53
|
-
},
|
|
54
|
-
{
|
|
29
|
+
}, {
|
|
55
30
|
name: "required",
|
|
56
31
|
type: "boolean",
|
|
57
32
|
helperText: "Is this input required to be filled out to submit a form",
|
|
58
33
|
defaultValue: false
|
|
59
|
-
}
|
|
60
|
-
],
|
|
34
|
+
}],
|
|
61
35
|
noWrap: true,
|
|
62
36
|
static: true,
|
|
63
37
|
defaultStyles: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
"use client";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
const React = __importStar(require("react"));
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
29
|
const is_editing_js_1 = require("../../functions/is-editing.js");
|
|
30
|
+
const helpers_js_1 = require("../helpers.js");
|
|
30
31
|
function FormInputComponent(props) {
|
|
31
32
|
return (React.createElement(react_native_1.View, { ...props.attributes, key: (0, is_editing_js_1.isEditing)() && props.defaultValue ? props.defaultValue : "default-key", placeholder: props.placeholder, type: props.type, name: props.name, value: props.value, defaultValue: props.defaultValue, required: props.required }));
|
|
32
33
|
}
|
|
@@ -4,13 +4,11 @@ exports.componentInfo = void 0;
|
|
|
4
4
|
const componentInfo = {
|
|
5
5
|
name: "Builder:RawText",
|
|
6
6
|
hideFromInsertMenu: true,
|
|
7
|
-
inputs: [
|
|
8
|
-
{
|
|
7
|
+
inputs: [{
|
|
9
8
|
name: "text",
|
|
10
9
|
bubble: true,
|
|
11
10
|
type: "longText",
|
|
12
11
|
required: true
|
|
13
|
-
}
|
|
14
|
-
]
|
|
12
|
+
}]
|
|
15
13
|
};
|
|
16
14
|
exports.componentInfo = componentInfo;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
"use client";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
const React = __importStar(require("react"));
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
29
|
function RawText(props) {
|
|
30
|
-
|
|
30
|
+
var _a;
|
|
31
|
+
return (React.createElement(react_native_1.View, { dangerouslySetInnerHTML: { __html: ((_a = props.text) === null || _a === void 0 ? void 0 : _a.toString()) || "" } }));
|
|
31
32
|
}
|
|
32
33
|
exports.default = RawText;
|
|
@@ -5,20 +5,17 @@ const componentInfo = {
|
|
|
5
5
|
name: "Core:Section",
|
|
6
6
|
static: true,
|
|
7
7
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
|
|
8
|
-
inputs: [
|
|
9
|
-
{
|
|
8
|
+
inputs: [{
|
|
10
9
|
name: "maxWidth",
|
|
11
10
|
type: "number",
|
|
12
11
|
defaultValue: 1200
|
|
13
|
-
},
|
|
14
|
-
{
|
|
12
|
+
}, {
|
|
15
13
|
name: "lazyLoad",
|
|
16
14
|
type: "boolean",
|
|
17
15
|
defaultValue: false,
|
|
18
16
|
advanced: true,
|
|
19
17
|
description: "Only render this section when in view"
|
|
20
|
-
}
|
|
21
|
-
],
|
|
18
|
+
}],
|
|
22
19
|
defaultStyles: {
|
|
23
20
|
paddingLeft: "20px",
|
|
24
21
|
paddingRight: "20px",
|
|
@@ -29,8 +26,7 @@ const componentInfo = {
|
|
|
29
26
|
marginLeft: "calc(50% - 50vw)"
|
|
30
27
|
},
|
|
31
28
|
canHaveChildren: true,
|
|
32
|
-
defaultChildren: [
|
|
33
|
-
{
|
|
29
|
+
defaultChildren: [{
|
|
34
30
|
"@type": "@builder.io/sdk:Element",
|
|
35
31
|
responsiveStyles: {
|
|
36
32
|
large: {
|
|
@@ -43,7 +39,6 @@ const componentInfo = {
|
|
|
43
39
|
text: "<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
|
-
}
|
|
47
|
-
]
|
|
42
|
+
}]
|
|
48
43
|
};
|
|
49
44
|
exports.componentInfo = componentInfo;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
"use client";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -26,6 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
const React = __importStar(require("react"));
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
|
+
const helpers_js_1 = require("../helpers.js");
|
|
29
30
|
function SectionComponent(props) {
|
|
30
31
|
return (React.createElement(react_native_1.View, { ...props.attributes, style: {
|
|
31
32
|
width: "100%",
|