@builder.io/sdk-solid 0.0.8-5 → 0.0.8-8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/package.json +6 -9
  2. package/src/blocks/button/button.jsx +13 -0
  3. package/src/blocks/button/button.lite.tsx +23 -0
  4. package/src/blocks/button/component-info.js +41 -0
  5. package/src/blocks/columns/columns.jsx +91 -0
  6. package/src/blocks/columns/columns.lite.tsx +109 -0
  7. package/src/blocks/columns/component-info.js +217 -0
  8. package/src/blocks/custom-code/component-info.js +31 -0
  9. package/src/blocks/custom-code/custom-code.jsx +52 -0
  10. package/src/blocks/custom-code/custom-code.lite.tsx +69 -0
  11. package/src/blocks/embed/component-info.js +24 -0
  12. package/src/blocks/embed/embed.jsx +52 -0
  13. package/src/blocks/embed/embed.lite.tsx +61 -0
  14. package/src/blocks/form/component-info.js +262 -0
  15. package/src/blocks/form/form.jsx +253 -0
  16. package/src/blocks/form/form.lite.tsx +296 -0
  17. package/src/blocks/fragment/component-info.js +11 -0
  18. package/src/blocks/fragment/fragment.jsx +5 -0
  19. package/src/blocks/fragment/fragment.lite.tsx +5 -0
  20. package/src/blocks/image/component-info.js +104 -0
  21. package/src/blocks/image/image.jsx +54 -0
  22. package/src/blocks/image/image.lite.tsx +86 -0
  23. package/src/blocks/img/component-info.js +20 -0
  24. package/src/blocks/img/img.jsx +10 -0
  25. package/src/blocks/img/img.lite.tsx +18 -0
  26. package/src/blocks/input/component-info.js +74 -0
  27. package/src/blocks/input/input.jsx +7 -0
  28. package/src/blocks/input/input.lite.tsx +20 -0
  29. package/src/blocks/raw-text/component-info.js +16 -0
  30. package/src/blocks/raw-text/raw-text.jsx +5 -0
  31. package/src/blocks/raw-text/raw-text.lite.tsx +10 -0
  32. package/src/blocks/section/component-info.js +49 -0
  33. package/src/blocks/section/section.jsx +9 -0
  34. package/src/blocks/section/section.lite.tsx +18 -0
  35. package/src/blocks/select/component-info.js +59 -0
  36. package/src/blocks/select/select.jsx +16 -0
  37. package/src/blocks/select/select.lite.tsx +28 -0
  38. package/src/blocks/submit-button/component-info.js +28 -0
  39. package/src/blocks/submit-button/submit-button.jsx +7 -0
  40. package/src/blocks/submit-button/submit-button.lite.tsx +9 -0
  41. package/src/blocks/symbol/component-info.js +42 -0
  42. package/src/blocks/symbol/symbol.jsx +25 -0
  43. package/src/blocks/symbol/symbol.lite.tsx +41 -0
  44. package/src/blocks/text/component-info.js +24 -0
  45. package/src/blocks/text/text.jsx +5 -0
  46. package/src/blocks/text/text.lite.tsx +5 -0
  47. package/src/blocks/textarea/component-info.js +47 -0
  48. package/src/blocks/textarea/textarea.jsx +5 -0
  49. package/src/blocks/textarea/textarea.lite.tsx +13 -0
  50. package/src/blocks/video/component-info.js +106 -0
  51. package/src/blocks/video/video.jsx +14 -0
  52. package/src/blocks/video/video.lite.tsx +26 -0
  53. package/src/components/error-boundary.jsx +5 -0
  54. package/src/components/error-boundary.lite.tsx +5 -0
  55. package/src/components/render-block/block-styles.jsx +36 -0
  56. package/src/components/render-block/block-styles.lite.tsx +38 -0
  57. package/src/components/render-block/render-block.helpers.js +23 -0
  58. package/src/components/render-block/render-block.jsx +126 -0
  59. package/src/components/render-block/render-block.lite.tsx +149 -0
  60. package/src/components/render-blocks.jsx +57 -0
  61. package/src/components/render-blocks.lite.tsx +75 -0
  62. package/src/components/render-content/components/render-styles.jsx +74 -0
  63. package/src/components/render-content/components/render-styles.lite.tsx +76 -0
  64. package/src/components/render-content/index.js +4 -0
  65. package/src/components/render-content/render-content.jsx +236 -0
  66. package/src/components/render-content/render-content.lite.tsx +262 -0
  67. package/src/components/render-inlined-styles.jsx +24 -0
  68. package/src/components/render-inlined-styles.lite.tsx +29 -0
  69. package/src/constants/builder-registered-components.js +45 -0
  70. package/src/constants/device-sizes.js +39 -0
  71. package/src/constants/target.js +4 -0
  72. package/src/context/builder.context.js +11 -0
  73. package/src/functions/evaluate.js +28 -0
  74. package/src/functions/event-handler-name.js +7 -0
  75. package/src/functions/fast-clone.js +4 -0
  76. package/src/functions/get-block-actions.js +23 -0
  77. package/src/functions/get-block-component-options.js +23 -0
  78. package/src/functions/get-block-properties.js +29 -0
  79. package/src/functions/get-block-styles.js +42 -0
  80. package/src/functions/get-block-tag.js +6 -0
  81. package/src/functions/get-builder-search-params/fn.test.js +13 -0
  82. package/src/functions/get-builder-search-params/index.js +22 -0
  83. package/src/functions/get-content/fn.test.js +31 -0
  84. package/src/functions/get-content/index.js +138 -0
  85. package/src/functions/get-fetch.js +34 -0
  86. package/src/functions/get-global-this.js +18 -0
  87. package/src/functions/get-processed-block.js +46 -0
  88. package/src/functions/get-processed-block.test.js +31 -0
  89. package/src/functions/if-target.js +15 -0
  90. package/src/functions/is-browser.js +6 -0
  91. package/src/functions/is-editing.js +7 -0
  92. package/src/functions/is-iframe.js +7 -0
  93. package/src/functions/is-previewing.js +14 -0
  94. package/src/functions/macro-eval.js +5 -0
  95. package/src/functions/on-change.js +27 -0
  96. package/src/functions/on-change.test.js +19 -0
  97. package/src/functions/previewing-model-name.js +11 -0
  98. package/src/functions/register-component.js +70 -0
  99. package/src/functions/register.js +29 -0
  100. package/src/functions/set-editor-settings.js +15 -0
  101. package/src/functions/set.js +11 -0
  102. package/src/functions/set.test.js +16 -0
  103. package/src/functions/track.js +22 -0
  104. package/src/functions/transform-block.js +6 -0
  105. package/src/index-helpers/blocks-exports.js +20 -0
  106. package/src/index-helpers/top-of-file.js +4 -0
  107. package/src/index.js +10 -0
  108. package/src/scripts/init-editing.js +80 -0
  109. package/src/solid-index.jsx +5 -0
  110. package/src/types/builder-block.js +0 -0
  111. package/src/types/builder-content.js +0 -0
  112. package/src/types/components.js +0 -0
  113. package/src/types/deep-partial.js +0 -0
  114. package/src/types/element.js +0 -0
  115. package/src/types/targets.js +0 -0
  116. package/src/types/typescript.js +0 -0
@@ -0,0 +1,296 @@
1
+ import { Show, For } from "solid-js";
2
+
3
+ import { createMutable } from "solid-js/store";
4
+ import { css } from "solid-styled-components";
5
+
6
+ import RenderBlock from "../../components/render-block/render-block.lite";
7
+ import { isEditing } from "../../functions/is-editing.js";
8
+
9
+ function FormComponent(props) {
10
+ const state = createMutable({
11
+ formState: "unsubmitted",
12
+ responseData: null,
13
+ formErrorMessage: "",
14
+ get submissionState() {
15
+ return (isEditing() && props.previewState) || state.formState;
16
+ },
17
+ onSubmit(
18
+ event: Event & {
19
+ currentTarget: HTMLFormElement;
20
+ }
21
+ ) {
22
+ const sendWithJs =
23
+ props.sendWithJs || props.sendSubmissionsTo === "email";
24
+
25
+ if (props.sendSubmissionsTo === "zapier") {
26
+ event.preventDefault();
27
+ } else if (sendWithJs) {
28
+ if (!(props.action || props.sendSubmissionsTo === "email")) {
29
+ event.preventDefault();
30
+ return;
31
+ }
32
+
33
+ event.preventDefault();
34
+ const el = event.currentTarget;
35
+ const headers = props.customHeaders || {};
36
+ let body: any;
37
+ const formData = new FormData(el); // TODO: maybe support null
38
+
39
+ const formPairs: {
40
+ key: string;
41
+ value: File | boolean | number | string | FileList;
42
+ }[] = Array.from(
43
+ event.currentTarget.querySelectorAll("input,select,textarea")
44
+ )
45
+ .filter((el) => !!(el as HTMLInputElement).name)
46
+ .map((el) => {
47
+ let value: any;
48
+ const key = (el as HTMLImageElement).name;
49
+
50
+ if (el instanceof HTMLInputElement) {
51
+ if (el.type === "radio") {
52
+ if (el.checked) {
53
+ value = el.name;
54
+ return {
55
+ key,
56
+ value,
57
+ };
58
+ }
59
+ } else if (el.type === "checkbox") {
60
+ value = el.checked;
61
+ } else if (el.type === "number" || el.type === "range") {
62
+ const num = el.valueAsNumber;
63
+
64
+ if (!isNaN(num)) {
65
+ value = num;
66
+ }
67
+ } else if (el.type === "file") {
68
+ // TODO: one vs multiple files
69
+ value = el.files;
70
+ } else {
71
+ value = el.value;
72
+ }
73
+ } else {
74
+ value = (el as HTMLInputElement).value;
75
+ }
76
+
77
+ return {
78
+ key,
79
+ value,
80
+ };
81
+ });
82
+ let contentType = props.contentType;
83
+
84
+ if (props.sendSubmissionsTo === "email") {
85
+ contentType = "multipart/form-data";
86
+ }
87
+
88
+ Array.from(formPairs).forEach(({ value }) => {
89
+ if (
90
+ value instanceof File ||
91
+ (Array.isArray(value) && value[0] instanceof File) ||
92
+ value instanceof FileList
93
+ ) {
94
+ contentType = "multipart/form-data";
95
+ }
96
+ }); // TODO: send as urlEncoded or multipart by default
97
+ // because of ease of use and reliability in browser API
98
+ // for encoding the form?
99
+
100
+ if (contentType !== "application/json") {
101
+ body = formData;
102
+ } else {
103
+ // Json
104
+ const json = {};
105
+ Array.from(formPairs).forEach(({ value, key }) => {
106
+ set(json, key, value);
107
+ });
108
+ body = JSON.stringify(json);
109
+ }
110
+
111
+ if (contentType && contentType !== "multipart/form-data") {
112
+ if (
113
+ /* Zapier doesn't allow content-type header to be sent from browsers */
114
+ !(sendWithJs && props.action?.includes("zapier.com"))
115
+ ) {
116
+ headers["content-type"] = contentType;
117
+ }
118
+ }
119
+
120
+ const presubmitEvent = new CustomEvent("presubmit", {
121
+ detail: {
122
+ body,
123
+ },
124
+ });
125
+
126
+ if (formRef) {
127
+ formRef.dispatchEvent(presubmitEvent);
128
+
129
+ if (presubmitEvent.defaultPrevented) {
130
+ return;
131
+ }
132
+ }
133
+
134
+ state.formState = "sending";
135
+ const formUrl = `${
136
+ builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"
137
+ }/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(
138
+ props.sendSubmissionsToEmail || ""
139
+ )}&name=${encodeURIComponent(props.name || "")}`;
140
+ fetch(
141
+ props.sendSubmissionsTo === "email" ? formUrl : props.action!,
142
+ /* TODO: throw error if no action URL */
143
+ {
144
+ body,
145
+ headers,
146
+ method: props.method || "post",
147
+ }
148
+ ).then(
149
+ async (res) => {
150
+ let body;
151
+ const contentType = res.headers.get("content-type");
152
+
153
+ if (contentType && contentType.indexOf("application/json") !== -1) {
154
+ body = await res.json();
155
+ } else {
156
+ body = await res.text();
157
+ }
158
+
159
+ if (!res.ok && props.errorMessagePath) {
160
+ /* TODO: allow supplying an error formatter function */
161
+ let message = get(body, props.errorMessagePath);
162
+
163
+ if (message) {
164
+ if (typeof message !== "string") {
165
+ /* TODO: ideally convert json to yaml so it woul dbe like
166
+ error: - email has been taken */
167
+ message = JSON.stringify(message);
168
+ }
169
+
170
+ state.formErrorMessage = message;
171
+ }
172
+ }
173
+
174
+ state.responseData = body;
175
+ state.formState = res.ok ? "success" : "error";
176
+
177
+ if (res.ok) {
178
+ const submitSuccessEvent = new CustomEvent("submit:success", {
179
+ detail: {
180
+ res,
181
+ body,
182
+ },
183
+ });
184
+
185
+ if (formRef) {
186
+ formRef.dispatchEvent(submitSuccessEvent);
187
+
188
+ if (submitSuccessEvent.defaultPrevented) {
189
+ return;
190
+ }
191
+ /* TODO: option to turn this on/off? */
192
+
193
+ if (props.resetFormOnSubmit !== false) {
194
+ formRef.reset();
195
+ }
196
+ }
197
+ /* TODO: client side route event first that can be preventDefaulted */
198
+
199
+ if (props.successUrl) {
200
+ if (formRef) {
201
+ const event = new CustomEvent("route", {
202
+ detail: {
203
+ url: props.successUrl,
204
+ },
205
+ });
206
+ formRef.dispatchEvent(event);
207
+
208
+ if (!event.defaultPrevented) {
209
+ location.href = props.successUrl;
210
+ }
211
+ } else {
212
+ location.href = props.successUrl;
213
+ }
214
+ }
215
+ }
216
+ },
217
+ (err) => {
218
+ const submitErrorEvent = new CustomEvent("submit:error", {
219
+ detail: {
220
+ error: err,
221
+ },
222
+ });
223
+
224
+ if (formRef) {
225
+ formRef.dispatchEvent(submitErrorEvent);
226
+
227
+ if (submitErrorEvent.defaultPrevented) {
228
+ return;
229
+ }
230
+ }
231
+
232
+ state.responseData = err;
233
+ state.formState = "error";
234
+ }
235
+ );
236
+ }
237
+ },
238
+ });
239
+
240
+ const formRef = useRef();
241
+
242
+ return (
243
+ <form
244
+ {...props.attributes}
245
+ validate={props.validate}
246
+ ref={formRef}
247
+ action={!props.sendWithJs && props.action}
248
+ method={props.method}
249
+ name={props.name}
250
+ onSubmit={(event) => state.onSubmit(event)}
251
+ >
252
+ <Show when={props.builderBlock && props.builderBlock.children}>
253
+ <For each={props.builderBlock?.children}>
254
+ {(block, _index) => {
255
+ const index = _index();
256
+ return <RenderBlock block={block}></RenderBlock>;
257
+ }}
258
+ </For>
259
+ </Show>
260
+ <Show when={state.submissionState === "error"}>
261
+ <BuilderBlocks
262
+ dataPath="errorMessage"
263
+ blocks={props.errorMessage}
264
+ ></BuilderBlocks>
265
+ </Show>
266
+ <Show when={state.submissionState === "sending"}>
267
+ <BuilderBlocks
268
+ dataPath="sendingMessage"
269
+ blocks={props.sendingMessage}
270
+ ></BuilderBlocks>
271
+ </Show>
272
+ <Show when={state.submissionState === "error" && state.responseData}>
273
+ <pre
274
+ class={
275
+ "builder-form-error-text " +
276
+ css({
277
+ padding: "10px",
278
+ color: "red",
279
+ textAlign: "center",
280
+ })
281
+ }
282
+ >
283
+ {JSON.stringify(state.responseData, null, 2)}
284
+ </pre>
285
+ </Show>
286
+ <Show when={state.submissionState === "success"}>
287
+ <BuilderBlocks
288
+ dataPath="successMessage"
289
+ blocks={props.successMessage}
290
+ ></BuilderBlocks>
291
+ </Show>
292
+ </form>
293
+ );
294
+ }
295
+
296
+ export default FormComponent;
@@ -0,0 +1,11 @@
1
+ const componentInfo = {
2
+ name: "Fragment",
3
+ static: true,
4
+ hidden: true,
5
+ builtIn: true,
6
+ canHaveChildren: true,
7
+ noWrap: true
8
+ };
9
+ export {
10
+ componentInfo
11
+ };
@@ -0,0 +1,5 @@
1
+ function FragmentComponent(props) {
2
+ return <span>{props.children}</span>;
3
+ }
4
+
5
+ export default FragmentComponent;
@@ -0,0 +1,5 @@
1
+ function FragmentComponent(props) {
2
+ return <span>{props.children}</span>;
3
+ }
4
+
5
+ export default FragmentComponent;
@@ -0,0 +1,104 @@
1
+ const componentInfo = {
2
+ name: "Image",
3
+ static: true,
4
+ builtIn: true,
5
+ 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",
6
+ defaultStyles: {
7
+ position: "relative",
8
+ minHeight: "20px",
9
+ minWidth: "20px",
10
+ overflow: "hidden"
11
+ },
12
+ canHaveChildren: true,
13
+ inputs: [
14
+ {
15
+ name: "image",
16
+ type: "file",
17
+ bubble: true,
18
+ allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
19
+ required: true,
20
+ defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
21
+ 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); } } }); }"
22
+ },
23
+ {
24
+ name: "backgroundSize",
25
+ type: "text",
26
+ defaultValue: "cover",
27
+ enum: [
28
+ {
29
+ label: "contain",
30
+ value: "contain",
31
+ helperText: "The image should never get cropped"
32
+ },
33
+ {
34
+ label: "cover",
35
+ value: "cover",
36
+ helperText: "The image should fill it's box, cropping when needed"
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ name: "backgroundPosition",
42
+ type: "text",
43
+ defaultValue: "center",
44
+ enum: [
45
+ "center",
46
+ "top",
47
+ "left",
48
+ "right",
49
+ "bottom",
50
+ "top left",
51
+ "top right",
52
+ "bottom left",
53
+ "bottom right"
54
+ ]
55
+ },
56
+ {
57
+ name: "altText",
58
+ type: "string",
59
+ helperText: "Text to display when the user has images off"
60
+ },
61
+ {
62
+ name: "height",
63
+ type: "number",
64
+ hideFromUI: true
65
+ },
66
+ {
67
+ name: "width",
68
+ type: "number",
69
+ hideFromUI: true
70
+ },
71
+ {
72
+ name: "sizes",
73
+ type: "string",
74
+ hideFromUI: true
75
+ },
76
+ {
77
+ name: "srcset",
78
+ type: "string",
79
+ hideFromUI: true
80
+ },
81
+ {
82
+ name: "lazy",
83
+ type: "boolean",
84
+ defaultValue: true,
85
+ hideFromUI: true
86
+ },
87
+ {
88
+ name: "fitContent",
89
+ type: "boolean",
90
+ helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
91
+ defaultValue: true
92
+ },
93
+ {
94
+ name: "aspectRatio",
95
+ type: "number",
96
+ 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",
97
+ advanced: true,
98
+ defaultValue: 0.7041
99
+ }
100
+ ]
101
+ };
102
+ export {
103
+ componentInfo
104
+ };
@@ -0,0 +1,54 @@
1
+ import { Show } from "solid-js";
2
+ import { css } from "solid-styled-components";
3
+
4
+ function Image(props) {
5
+ return <div class={css({
6
+ position: "relative"
7
+ })}>
8
+ <picture>
9
+ <img class={"builder-image" + (props.className ? " " + props.className : "") + " " + css({
10
+ opacity: "1",
11
+ transition: "opacity 0.2s ease-in-out",
12
+ position: "absolute",
13
+ height: "100%",
14
+ width: "100%",
15
+ top: "0px",
16
+ left: "0px"
17
+ })} loading="lazy" alt={props.altText} role={props.altText ? "presentation" : undefined} style={{
18
+ "object-position": props.backgroundSize || "center",
19
+ "object-fit": props.backgroundSize || "cover"
20
+ }} src={props.image} srcset={props.srcset} sizes={props.sizes} />
21
+ <source srcSet={props.srcset} />
22
+ </picture>
23
+ <Show when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}>
24
+ <div class={"builder-image-sizer " + css({
25
+ width: "100%",
26
+ pointerEvents: "none",
27
+ fontSize: "0"
28
+ })} style={{
29
+ "padding-top": props.aspectRatio * 100 + "%"
30
+ }}>
31
+ {" "}
32
+ </div>
33
+ </Show>
34
+ <Show when={props.builderBlock?.children?.length && props.fitContent}>
35
+ {props.children}
36
+ </Show>
37
+ <Show when={!props.fitContent}>
38
+ <div class={css({
39
+ display: "flex",
40
+ flexDirection: "column",
41
+ alignItems: "stretch",
42
+ position: "absolute",
43
+ top: "0",
44
+ left: "0",
45
+ width: "100%",
46
+ height: "100%"
47
+ })}>
48
+ {props.children}
49
+ </div>
50
+ </Show>
51
+ </div>;
52
+ }
53
+
54
+ export default Image;
@@ -0,0 +1,86 @@
1
+ import { Show } from "solid-js";
2
+
3
+ import { css } from "solid-styled-components";
4
+
5
+ function Image(props) {
6
+ return (
7
+ <div
8
+ class={css({
9
+ position: "relative",
10
+ })}
11
+ >
12
+ <picture>
13
+ <img
14
+ class={
15
+ "builder-image" +
16
+ (props.className ? " " + props.className : "") +
17
+ " " +
18
+ css({
19
+ opacity: "1",
20
+ transition: "opacity 0.2s ease-in-out",
21
+ position: "absolute",
22
+ height: "100%",
23
+ width: "100%",
24
+ top: "0px",
25
+ left: "0px",
26
+ })
27
+ }
28
+ loading="lazy"
29
+ alt={props.altText}
30
+ role={props.altText ? "presentation" : undefined}
31
+ style={{
32
+ "object-position": props.backgroundSize || "center",
33
+ "object-fit": props.backgroundSize || "cover",
34
+ }}
35
+ src={props.image}
36
+ srcset={props.srcset}
37
+ sizes={props.sizes}
38
+ />
39
+ <source srcSet={props.srcset} />
40
+ </picture>
41
+ <Show
42
+ when={
43
+ props.aspectRatio &&
44
+ !(props.fitContent && props.builderBlock?.children?.length)
45
+ }
46
+ >
47
+ <div
48
+ class={
49
+ "builder-image-sizer " +
50
+ css({
51
+ width: "100%",
52
+ pointerEvents: "none",
53
+ fontSize: "0",
54
+ })
55
+ }
56
+ style={{
57
+ "padding-top": props.aspectRatio * 100 + "%",
58
+ }}
59
+ >
60
+ {" "}
61
+ </div>
62
+ </Show>
63
+ <Show when={props.builderBlock?.children?.length && props.fitContent}>
64
+ {props.children}
65
+ </Show>
66
+ <Show when={!props.fitContent}>
67
+ <div
68
+ class={css({
69
+ display: "flex",
70
+ flexDirection: "column",
71
+ alignItems: "stretch",
72
+ position: "absolute",
73
+ top: "0",
74
+ left: "0",
75
+ width: "100%",
76
+ height: "100%",
77
+ })}
78
+ >
79
+ {props.children}
80
+ </div>
81
+ </Show>
82
+ </div>
83
+ );
84
+ }
85
+
86
+ export default Image;
@@ -0,0 +1,20 @@
1
+ const componentInfo = {
2
+ name: "Raw:Img",
3
+ hideFromInsertMenu: true,
4
+ builtIn: true,
5
+ 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",
6
+ inputs: [
7
+ {
8
+ name: "image",
9
+ bubble: true,
10
+ type: "file",
11
+ allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
12
+ required: true
13
+ }
14
+ ],
15
+ noWrap: true,
16
+ static: true
17
+ };
18
+ export {
19
+ componentInfo
20
+ };
@@ -0,0 +1,10 @@
1
+ import { isEditing } from "../../functions/is-editing.js";
2
+
3
+ function ImgComponent(props) {
4
+ return <img {...props.attributes} style={{
5
+ "object-fit": props.backgroundSize || "cover",
6
+ "object-position": props.backgroundPosition || "center"
7
+ }} key={isEditing() && props.imgSrc || "default-key"} alt={props.altText} src={props.imgSrc} />;
8
+ }
9
+
10
+ export default ImgComponent;
@@ -0,0 +1,18 @@
1
+ import { isEditing } from "../../functions/is-editing.js";
2
+
3
+ function ImgComponent(props) {
4
+ return (
5
+ <img
6
+ {...props.attributes}
7
+ style={{
8
+ "object-fit": props.backgroundSize || "cover",
9
+ "object-position": props.backgroundPosition || "center",
10
+ }}
11
+ key={(isEditing() && props.imgSrc) || "default-key"}
12
+ alt={props.altText}
13
+ src={props.imgSrc}
14
+ />
15
+ );
16
+ }
17
+
18
+ export default ImgComponent;
@@ -0,0 +1,74 @@
1
+ const componentInfo = {
2
+ name: "Form:Input",
3
+ builtIn: true,
4
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca",
5
+ inputs: [
6
+ {
7
+ name: "type",
8
+ type: "text",
9
+ enum: [
10
+ "text",
11
+ "number",
12
+ "email",
13
+ "url",
14
+ "checkbox",
15
+ "radio",
16
+ "range",
17
+ "date",
18
+ "datetime-local",
19
+ "search",
20
+ "tel",
21
+ "time",
22
+ "file",
23
+ "month",
24
+ "week",
25
+ "password",
26
+ "color",
27
+ "hidden"
28
+ ],
29
+ defaultValue: "text"
30
+ },
31
+ {
32
+ name: "name",
33
+ type: "string",
34
+ required: true,
35
+ helperText: 'Every input in a form needs a unique name describing what it takes, e.g. "email"'
36
+ },
37
+ {
38
+ name: "placeholder",
39
+ type: "string",
40
+ defaultValue: "Hello there",
41
+ helperText: "Text to display when there is no value"
42
+ },
43
+ {
44
+ name: "defaultValue",
45
+ type: "string"
46
+ },
47
+ {
48
+ name: "value",
49
+ type: "string",
50
+ advanced: true
51
+ },
52
+ {
53
+ name: "required",
54
+ type: "boolean",
55
+ helperText: "Is this input required to be filled out to submit a form",
56
+ defaultValue: false
57
+ }
58
+ ],
59
+ noWrap: true,
60
+ static: true,
61
+ defaultStyles: {
62
+ paddingTop: "10px",
63
+ paddingBottom: "10px",
64
+ paddingLeft: "10px",
65
+ paddingRight: "10px",
66
+ borderRadius: "3px",
67
+ borderWidth: "1px",
68
+ borderStyle: "solid",
69
+ borderColor: "#ccc"
70
+ }
71
+ };
72
+ export {
73
+ componentInfo
74
+ };