@builder.io/sdk-react-native 0.4.5 → 0.5.1
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 +9 -3
- 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 +27 -40
- 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/context/components.context.js +6 -0
- 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 +61 -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 +148 -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/context/components.context.js +5 -0
- 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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function filterAttrs(attrs = {}, prefix, isEvent) {
|
|
2
|
+
const result = {};
|
|
3
|
+
for (const attr in attrs) {
|
|
4
|
+
if (!attrs[attr]) continue;
|
|
5
|
+
if (isEvent && !attr.startsWith(prefix)) continue;
|
|
6
|
+
const eventName = isEvent ? attr.replace(prefix, "") : attr;
|
|
7
|
+
result[eventName] = attrs[attr];
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
function setAttrs(node, attrs = {}) {
|
|
12
|
+
const attrKeys = Object.keys(attrs);
|
|
13
|
+
const setup = attr => node.addEventListener(attr, attrs[attr]);
|
|
14
|
+
const teardown = attr => node.removeEventListener(attr, attrs[attr]);
|
|
15
|
+
attrKeys.forEach(setup);
|
|
16
|
+
return {
|
|
17
|
+
update(attrs2 = {}) {
|
|
18
|
+
const attrKeys2 = Object.keys(attrs2);
|
|
19
|
+
attrKeys2.forEach(teardown);
|
|
20
|
+
attrKeys2.forEach(setup);
|
|
21
|
+
},
|
|
22
|
+
destroy() {
|
|
23
|
+
attrKeys.forEach(teardown);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export { filterAttrs, setAttrs }
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { serializeFn } from "../util.js";
|
|
2
1
|
const componentInfo = {
|
|
3
2
|
name: "Image",
|
|
4
3
|
static: true,
|
|
@@ -10,141 +9,114 @@ const componentInfo = {
|
|
|
10
9
|
overflow: "hidden"
|
|
11
10
|
},
|
|
12
11
|
canHaveChildren: true,
|
|
13
|
-
inputs: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
reject(event.error);
|
|
36
|
-
});
|
|
37
|
-
img.src = url;
|
|
38
|
-
setTimeout(() => {
|
|
39
|
-
if (!loaded) {
|
|
40
|
-
reject(new Error("Image load timed out"));
|
|
41
|
-
}
|
|
42
|
-
}, timeout);
|
|
12
|
+
inputs: [{
|
|
13
|
+
name: "image",
|
|
14
|
+
type: "file",
|
|
15
|
+
bubble: true,
|
|
16
|
+
allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
|
|
17
|
+
required: true,
|
|
18
|
+
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
|
|
19
|
+
onChange: options => {
|
|
20
|
+
const DEFAULT_ASPECT_RATIO = 0.7041;
|
|
21
|
+
options.delete("srcset");
|
|
22
|
+
options.delete("noWebp");
|
|
23
|
+
function loadImage(url, timeout = 6e4) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const img = document.createElement("img");
|
|
26
|
+
let loaded = false;
|
|
27
|
+
img.onload = () => {
|
|
28
|
+
loaded = true;
|
|
29
|
+
resolve(img);
|
|
30
|
+
};
|
|
31
|
+
img.addEventListener("error", event => {
|
|
32
|
+
console.warn("Image load failed", event.error);
|
|
33
|
+
reject(event.error);
|
|
43
34
|
});
|
|
35
|
+
img.src = url;
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
if (!loaded) {
|
|
38
|
+
reject(new Error("Image load timed out"));
|
|
39
|
+
}
|
|
40
|
+
}, timeout);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function round(num) {
|
|
44
|
+
return Math.round(num * 1e3) / 1e3;
|
|
45
|
+
}
|
|
46
|
+
const value = options.get("image");
|
|
47
|
+
const aspectRatio = options.get("aspectRatio");
|
|
48
|
+
fetch(value).then(res => res.blob()).then(blob => {
|
|
49
|
+
if (blob.type.includes("svg")) {
|
|
50
|
+
options.set("noWebp", true);
|
|
44
51
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
});
|
|
53
|
+
if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) {
|
|
54
|
+
return loadImage(value).then(img => {
|
|
55
|
+
const possiblyUpdatedAspectRatio = options.get("aspectRatio");
|
|
56
|
+
if (options.get("image") === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
|
|
57
|
+
if (img.width && img.height) {
|
|
58
|
+
options.set("aspectRatio", round(img.height / img.width));
|
|
59
|
+
options.set("height", img.height);
|
|
60
|
+
options.set("width", img.width);
|
|
61
|
+
}
|
|
53
62
|
}
|
|
54
63
|
});
|
|
55
|
-
|
|
56
|
-
return loadImage(value).then((img) => {
|
|
57
|
-
const possiblyUpdatedAspectRatio = options.get("aspectRatio");
|
|
58
|
-
if (options.get("image") === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
|
|
59
|
-
if (img.width && img.height) {
|
|
60
|
-
options.set("aspectRatio", round(img.height / img.width));
|
|
61
|
-
options.set("height", img.height);
|
|
62
|
-
options.set("width", img.width);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "backgroundSize",
|
|
71
|
-
type: "text",
|
|
72
|
-
defaultValue: "cover",
|
|
73
|
-
enum: [
|
|
74
|
-
{
|
|
75
|
-
label: "contain",
|
|
76
|
-
value: "contain",
|
|
77
|
-
helperText: "The image should never get cropped"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
label: "cover",
|
|
81
|
-
value: "cover",
|
|
82
|
-
helperText: "The image should fill it's box, cropping when needed"
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: "backgroundPosition",
|
|
88
|
-
type: "text",
|
|
89
|
-
defaultValue: "center",
|
|
90
|
-
enum: [
|
|
91
|
-
"center",
|
|
92
|
-
"top",
|
|
93
|
-
"left",
|
|
94
|
-
"right",
|
|
95
|
-
"bottom",
|
|
96
|
-
"top left",
|
|
97
|
-
"top right",
|
|
98
|
-
"bottom left",
|
|
99
|
-
"bottom right"
|
|
100
|
-
]
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: "altText",
|
|
104
|
-
type: "string",
|
|
105
|
-
helperText: "Text to display when the user has images off"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: "height",
|
|
109
|
-
type: "number",
|
|
110
|
-
hideFromUI: true
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: "width",
|
|
114
|
-
type: "number",
|
|
115
|
-
hideFromUI: true
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
name: "sizes",
|
|
119
|
-
type: "string",
|
|
120
|
-
hideFromUI: true
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
name: "srcset",
|
|
124
|
-
type: "string",
|
|
125
|
-
hideFromUI: true
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: "lazy",
|
|
129
|
-
type: "boolean",
|
|
130
|
-
defaultValue: true,
|
|
131
|
-
hideFromUI: true
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
name: "fitContent",
|
|
135
|
-
type: "boolean",
|
|
136
|
-
helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
|
|
137
|
-
defaultValue: true
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: "aspectRatio",
|
|
141
|
-
type: "number",
|
|
142
|
-
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",
|
|
143
|
-
advanced: true,
|
|
144
|
-
defaultValue: 0.7041
|
|
64
|
+
}
|
|
145
65
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
66
|
+
}, {
|
|
67
|
+
name: "backgroundSize",
|
|
68
|
+
type: "text",
|
|
69
|
+
defaultValue: "cover",
|
|
70
|
+
enum: [{
|
|
71
|
+
label: "contain",
|
|
72
|
+
value: "contain",
|
|
73
|
+
helperText: "The image should never get cropped"
|
|
74
|
+
}, {
|
|
75
|
+
label: "cover",
|
|
76
|
+
value: "cover",
|
|
77
|
+
helperText: "The image should fill it's box, cropping when needed"
|
|
78
|
+
}]
|
|
79
|
+
}, {
|
|
80
|
+
name: "backgroundPosition",
|
|
81
|
+
type: "text",
|
|
82
|
+
defaultValue: "center",
|
|
83
|
+
enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
|
|
84
|
+
}, {
|
|
85
|
+
name: "altText",
|
|
86
|
+
type: "string",
|
|
87
|
+
helperText: "Text to display when the user has images off"
|
|
88
|
+
}, {
|
|
89
|
+
name: "height",
|
|
90
|
+
type: "number",
|
|
91
|
+
hideFromUI: true
|
|
92
|
+
}, {
|
|
93
|
+
name: "width",
|
|
94
|
+
type: "number",
|
|
95
|
+
hideFromUI: true
|
|
96
|
+
}, {
|
|
97
|
+
name: "sizes",
|
|
98
|
+
type: "string",
|
|
99
|
+
hideFromUI: true
|
|
100
|
+
}, {
|
|
101
|
+
name: "srcset",
|
|
102
|
+
type: "string",
|
|
103
|
+
hideFromUI: true
|
|
104
|
+
}, {
|
|
105
|
+
name: "lazy",
|
|
106
|
+
type: "boolean",
|
|
107
|
+
defaultValue: true,
|
|
108
|
+
hideFromUI: true
|
|
109
|
+
}, {
|
|
110
|
+
name: "fitContent",
|
|
111
|
+
type: "boolean",
|
|
112
|
+
helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
|
|
113
|
+
defaultValue: true
|
|
114
|
+
}, {
|
|
115
|
+
name: "aspectRatio",
|
|
116
|
+
type: "number",
|
|
117
|
+
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",
|
|
118
|
+
advanced: true,
|
|
119
|
+
defaultValue: 0.7041
|
|
120
|
+
}]
|
|
150
121
|
};
|
|
122
|
+
export { componentInfo }
|
|
@@ -36,13 +36,11 @@ function getSrcSet(url) {
|
|
|
36
36
|
if (!isNaN(widthInSrc)) {
|
|
37
37
|
srcUrl = `${srcUrl} ${widthInSrc}w`;
|
|
38
38
|
}
|
|
39
|
-
return sizes.filter(
|
|
39
|
+
return sizes.filter(size => size !== widthInSrc).map(size => `${updateQueryParam(url, "width", size)} ${size}w`).concat([srcUrl]).join(", ");
|
|
40
40
|
}
|
|
41
41
|
if (url.match(/cdn\.shopify\.com/)) {
|
|
42
|
-
return sizes.map(
|
|
42
|
+
return sizes.map(size => [getShopifyImageUrl(url, `${size}x${size}`), size]).filter(([sizeUrl]) => !!sizeUrl).map(([sizeUrl, size]) => `${sizeUrl} ${size}w`).concat([url]).join(", ");
|
|
43
43
|
}
|
|
44
44
|
return url;
|
|
45
45
|
}
|
|
46
|
-
export {
|
|
47
|
-
getSrcSet
|
|
48
|
-
};
|
|
46
|
+
export { getSrcSet }
|
|
@@ -2,18 +2,14 @@ const componentInfo = {
|
|
|
2
2
|
name: "Raw:Img",
|
|
3
3
|
hideFromInsertMenu: true,
|
|
4
4
|
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",
|
|
5
|
-
inputs: [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
],
|
|
5
|
+
inputs: [{
|
|
6
|
+
name: "image",
|
|
7
|
+
bubble: true,
|
|
8
|
+
type: "file",
|
|
9
|
+
allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
|
|
10
|
+
required: true
|
|
11
|
+
}],
|
|
14
12
|
noWrap: true,
|
|
15
13
|
static: true
|
|
16
14
|
};
|
|
17
|
-
export {
|
|
18
|
-
componentInfo
|
|
19
|
-
};
|
|
15
|
+
export { componentInfo }
|
package/src/blocks/img/img.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {
|
|
4
4
|
FlatList,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Text,
|
|
10
10
|
} from "react-native";
|
|
11
11
|
import { isEditing } from "../../functions/is-editing.js";
|
|
12
|
+
import { filterAttrs } from "../helpers.js";
|
|
12
13
|
|
|
13
14
|
function ImgComponent(props) {
|
|
14
15
|
return (
|
|
@@ -20,6 +21,7 @@ function ImgComponent(props) {
|
|
|
20
21
|
key={(isEditing() && props.imgSrc) || "default-key"}
|
|
21
22
|
alt={props.altText}
|
|
22
23
|
src={props.imgSrc || props.image}
|
|
24
|
+
{...{}}
|
|
23
25
|
{...props.attributes}
|
|
24
26
|
/>
|
|
25
27
|
);
|
|
@@ -1,60 +1,34 @@
|
|
|
1
1
|
const componentInfo = {
|
|
2
2
|
name: "Form:Input",
|
|
3
3
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca",
|
|
4
|
-
inputs: [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type: "string",
|
|
33
|
-
required: true,
|
|
34
|
-
helperText: 'Every input in a form needs a unique name describing what it takes, e.g. "email"'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: "placeholder",
|
|
38
|
-
type: "string",
|
|
39
|
-
defaultValue: "Hello there",
|
|
40
|
-
helperText: "Text to display when there is no value"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "defaultValue",
|
|
44
|
-
type: "string"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: "value",
|
|
48
|
-
type: "string",
|
|
49
|
-
advanced: true
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "required",
|
|
53
|
-
type: "boolean",
|
|
54
|
-
helperText: "Is this input required to be filled out to submit a form",
|
|
55
|
-
defaultValue: false
|
|
56
|
-
}
|
|
57
|
-
],
|
|
4
|
+
inputs: [{
|
|
5
|
+
name: "type",
|
|
6
|
+
type: "text",
|
|
7
|
+
enum: ["text", "number", "email", "url", "checkbox", "radio", "range", "date", "datetime-local", "search", "tel", "time", "file", "month", "week", "password", "color", "hidden"],
|
|
8
|
+
defaultValue: "text"
|
|
9
|
+
}, {
|
|
10
|
+
name: "name",
|
|
11
|
+
type: "string",
|
|
12
|
+
required: true,
|
|
13
|
+
helperText: 'Every input in a form needs a unique name describing what it takes, e.g. "email"'
|
|
14
|
+
}, {
|
|
15
|
+
name: "placeholder",
|
|
16
|
+
type: "string",
|
|
17
|
+
defaultValue: "Hello there",
|
|
18
|
+
helperText: "Text to display when there is no value"
|
|
19
|
+
}, {
|
|
20
|
+
name: "defaultValue",
|
|
21
|
+
type: "string"
|
|
22
|
+
}, {
|
|
23
|
+
name: "value",
|
|
24
|
+
type: "string",
|
|
25
|
+
advanced: true
|
|
26
|
+
}, {
|
|
27
|
+
name: "required",
|
|
28
|
+
type: "boolean",
|
|
29
|
+
helperText: "Is this input required to be filled out to submit a form",
|
|
30
|
+
defaultValue: false
|
|
31
|
+
}],
|
|
58
32
|
noWrap: true,
|
|
59
33
|
static: true,
|
|
60
34
|
defaultStyles: {
|
|
@@ -68,6 +42,4 @@ const componentInfo = {
|
|
|
68
42
|
borderColor: "#ccc"
|
|
69
43
|
}
|
|
70
44
|
};
|
|
71
|
-
export {
|
|
72
|
-
componentInfo
|
|
73
|
-
};
|
|
45
|
+
export { componentInfo }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {
|
|
4
4
|
FlatList,
|
|
@@ -9,10 +9,12 @@ import {
|
|
|
9
9
|
Text,
|
|
10
10
|
} from "react-native";
|
|
11
11
|
import { isEditing } from "../../functions/is-editing.js";
|
|
12
|
+
import { filterAttrs } from "../helpers.js";
|
|
12
13
|
|
|
13
14
|
function FormInputComponent(props) {
|
|
14
15
|
return (
|
|
15
16
|
<View
|
|
17
|
+
{...{}}
|
|
16
18
|
{...props.attributes}
|
|
17
19
|
key={
|
|
18
20
|
isEditing() && props.defaultValue ? props.defaultValue : "default-key"
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
const componentInfo = {
|
|
2
2
|
name: "Builder:RawText",
|
|
3
3
|
hideFromInsertMenu: true,
|
|
4
|
-
inputs: [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
]
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
componentInfo
|
|
4
|
+
inputs: [{
|
|
5
|
+
name: "text",
|
|
6
|
+
bubble: true,
|
|
7
|
+
type: "longText",
|
|
8
|
+
required: true
|
|
9
|
+
}]
|
|
15
10
|
};
|
|
11
|
+
export { componentInfo }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {
|
|
4
4
|
FlatList,
|
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
} from "react-native";
|
|
11
11
|
|
|
12
12
|
function RawText(props) {
|
|
13
|
-
return
|
|
13
|
+
return (
|
|
14
|
+
<View dangerouslySetInnerHTML={{ __html: props.text?.toString() || "" }} />
|
|
15
|
+
);
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export default RawText;
|
|
@@ -2,20 +2,17 @@ const componentInfo = {
|
|
|
2
2
|
name: "Core:Section",
|
|
3
3
|
static: true,
|
|
4
4
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
|
|
5
|
-
inputs: [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
description: "Only render this section when in view"
|
|
17
|
-
}
|
|
18
|
-
],
|
|
5
|
+
inputs: [{
|
|
6
|
+
name: "maxWidth",
|
|
7
|
+
type: "number",
|
|
8
|
+
defaultValue: 1200
|
|
9
|
+
}, {
|
|
10
|
+
name: "lazyLoad",
|
|
11
|
+
type: "boolean",
|
|
12
|
+
defaultValue: false,
|
|
13
|
+
advanced: true,
|
|
14
|
+
description: "Only render this section when in view"
|
|
15
|
+
}],
|
|
19
16
|
defaultStyles: {
|
|
20
17
|
paddingLeft: "20px",
|
|
21
18
|
paddingRight: "20px",
|
|
@@ -26,23 +23,19 @@ const componentInfo = {
|
|
|
26
23
|
marginLeft: "calc(50% - 50vw)"
|
|
27
24
|
},
|
|
28
25
|
canHaveChildren: true,
|
|
29
|
-
defaultChildren: [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
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>"
|
|
41
|
-
}
|
|
26
|
+
defaultChildren: [{
|
|
27
|
+
"@type": "@builder.io/sdk:Element",
|
|
28
|
+
responsiveStyles: {
|
|
29
|
+
large: {
|
|
30
|
+
textAlign: "center"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
component: {
|
|
34
|
+
name: "Text",
|
|
35
|
+
options: {
|
|
36
|
+
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>"
|
|
42
37
|
}
|
|
43
38
|
}
|
|
44
|
-
]
|
|
45
|
-
};
|
|
46
|
-
export {
|
|
47
|
-
componentInfo
|
|
39
|
+
}]
|
|
48
40
|
};
|
|
41
|
+
export { componentInfo }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {
|
|
4
4
|
FlatList,
|
|
@@ -8,10 +8,12 @@ import {
|
|
|
8
8
|
Image,
|
|
9
9
|
Text,
|
|
10
10
|
} from "react-native";
|
|
11
|
+
import { filterAttrs } from "../helpers.js";
|
|
11
12
|
|
|
12
13
|
function SectionComponent(props) {
|
|
13
14
|
return (
|
|
14
15
|
<View
|
|
16
|
+
{...{}}
|
|
15
17
|
{...props.attributes}
|
|
16
18
|
style={{
|
|
17
19
|
width: "100%",
|