@builder.io/sdk-svelte 0.0.2 → 0.0.4
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/package/--package.json +159 -0
- package/package/blocks/BaseText.svelte +19 -0
- package/package/blocks/BaseText.svelte.d.ts +19 -0
- package/package/blocks/columns/columns.svelte +13 -4
- package/package/blocks/columns/columns.svelte.d.ts +1 -1
- package/package/blocks/custom-code/custom-code.svelte +1 -1
- package/package/blocks/embed/embed.svelte +2 -0
- package/package/blocks/form/form.svelte +7 -5
- package/package/blocks/image/image.svelte +48 -46
- package/package/blocks/image/image.svelte.d.ts +1 -1
- package/package/blocks/img/img.svelte +7 -2
- package/package/blocks/section/section.svelte +7 -2
- package/package/blocks/symbol/symbol.svelte +13 -13
- package/package/blocks/symbol/symbol.svelte.d.ts +3 -3
- package/package/blocks/video/video.svelte +14 -3
- package/package/components/render-block/block-styles.svelte +24 -19
- package/package/components/render-block/block-styles.svelte.d.ts +2 -2
- package/package/components/render-block/render-block.svelte +81 -58
- package/package/components/render-block/render-block.svelte.d.ts +2 -2
- package/package/components/render-block/render-component-with-context.svelte +32 -0
- package/package/components/render-block/render-component-with-context.svelte.d.ts +19 -0
- package/package/components/render-block/render-component.svelte +1 -3
- package/package/components/render-block/render-component.svelte.d.ts +2 -2
- package/package/components/render-block/render-repeated-block.svelte +3 -0
- package/package/components/render-block/types.d.ts +2 -2
- package/package/components/render-block/types.js +1 -2
- package/package/components/render-blocks.svelte +12 -1
- package/package/components/render-blocks.svelte.d.ts +3 -1
- package/package/components/render-content/components/render-styles.svelte +2 -1
- package/package/components/render-content/render-content.svelte +24 -8
- package/package/components/render-content/render-content.svelte.d.ts +2 -2
- package/package/constants/builder-registered-components.js +3 -0
- package/package/context/builder.context.d.ts +1 -0
- package/package/context/builder.context.js +1 -0
- package/package/context/types.d.ts +4 -3
- package/package/context/types.js +1 -3
- package/package/functions/extract-text-styles.d.ts +4 -0
- package/package/functions/extract-text-styles.js +34 -0
- package/package/functions/fast-clone.d.ts +4 -0
- package/package/functions/fast-clone.js +4 -0
- package/package/functions/get-block-actions-handler.d.ts +5 -0
- package/package/functions/get-block-actions-handler.js +9 -0
- package/package/functions/get-block-actions.d.ts +1 -1
- package/package/functions/get-block-actions.js +2 -8
- package/package/functions/get-block-component-options.d.ts +1 -1
- package/package/functions/get-block-component-options.js +0 -1
- package/package/functions/get-block-properties.d.ts +1 -1
- package/package/functions/get-block-properties.js +0 -1
- package/package/functions/get-block-tag.d.ts +1 -1
- package/package/functions/get-block-tag.js +0 -1
- package/package/functions/get-builder-search-params/index.d.ts +1 -1
- package/package/functions/get-builder-search-params/index.js +6 -2
- package/package/functions/get-content/ab-testing.d.ts +5 -3
- package/package/functions/get-content/ab-testing.js +75 -37
- package/package/functions/get-content/index.d.ts +1 -1
- package/package/functions/get-content/index.js +4 -5
- package/package/functions/get-content/types.d.ts +7 -2
- package/package/functions/get-processed-block.d.ts +1 -1
- package/package/functions/get-processed-block.js +5 -4
- package/package/functions/get-processed-block.test.js +0 -1
- package/package/functions/get-react-native-block-styles.d.ts +6 -0
- package/package/functions/get-react-native-block-styles.js +16 -0
- package/package/functions/register-component.d.ts +2 -2
- package/package/functions/register-component.js +1 -5
- package/package/functions/register.d.ts +2 -2
- package/package/functions/register.js +0 -2
- package/package/functions/sanitize-react-native-block-styles.d.ts +3 -0
- package/package/functions/sanitize-react-native-block-styles.js +53 -0
- package/package/functions/track.d.ts +1 -1
- package/package/functions/track.js +5 -6
- package/package/functions/transform-block.d.ts +1 -1
- package/package/functions/transform-block.js +0 -1
- package/package/helpers/ab-tests.d.ts +8 -0
- package/package/helpers/ab-tests.js +5 -0
- package/package/helpers/cookie.d.ts +9 -3
- package/package/helpers/cookie.js +8 -3
- package/package/helpers/css.d.ts +5 -1
- package/package/helpers/css.js +14 -1
- package/package/helpers/localStorage.d.ts +3 -4
- package/package/helpers/sessionId.d.ts +3 -4
- package/package/helpers/sessionId.js +5 -3
- package/package/helpers/visitorId.d.ts +3 -5
- package/package/scripts/init-editing.js +42 -38
- package/package/types/builder-content.d.ts +1 -1
- package/package/types/builder-content.js +1 -1
- package/package/types/targets.d.ts +1 -1
- package/package/types/typescript.d.ts +1 -0
- package/package.json +8 -3
- package/package/blocks/button/button.lite.d.ts +0 -0
- package/package/blocks/button/button.lite.tsx +0 -36
- package/package/blocks/columns/columns.lite.d.ts +0 -0
- package/package/blocks/columns/columns.lite.tsx +0 -139
- package/package/blocks/custom-code/custom-code.lite.d.ts +0 -0
- package/package/blocks/custom-code/custom-code.lite.tsx +0 -70
- package/package/blocks/embed/embed.lite.d.ts +0 -0
- package/package/blocks/embed/embed.lite.tsx +0 -52
- package/package/blocks/form/form.lite.d.ts +0 -0
- package/package/blocks/form/form.lite.tsx +0 -351
- package/package/blocks/fragment/fragment.lite.d.ts +0 -0
- package/package/blocks/fragment/fragment.lite.tsx +0 -12
- package/package/blocks/image/image.lite.d.ts +0 -0
- package/package/blocks/image/image.lite.tsx +0 -148
- package/package/blocks/img/img.lite.d.ts +0 -0
- package/package/blocks/img/img.lite.tsx +0 -48
- package/package/blocks/input/input.lite.d.ts +0 -0
- package/package/blocks/input/input.lite.tsx +0 -34
- package/package/blocks/raw-text/raw-text.lite.d.ts +0 -0
- package/package/blocks/raw-text/raw-text.lite.tsx +0 -15
- package/package/blocks/section/section.lite.d.ts +0 -0
- package/package/blocks/section/section.lite.tsx +0 -30
- package/package/blocks/select/select.lite.d.ts +0 -0
- package/package/blocks/select/select.lite.tsx +0 -34
- package/package/blocks/submit-button/submit-button.lite.d.ts +0 -0
- package/package/blocks/submit-button/submit-button.lite.tsx +0 -15
- package/package/blocks/symbol/symbol.lite.d.ts +0 -0
- package/package/blocks/symbol/symbol.lite.tsx +0 -92
- package/package/blocks/text/text.lite.d.ts +0 -0
- package/package/blocks/text/text.lite.tsx +0 -11
- package/package/blocks/textarea/textarea.lite.d.ts +0 -0
- package/package/blocks/textarea/textarea.lite.tsx +0 -19
- package/package/blocks/video/video.lite.d.ts +0 -0
- package/package/blocks/video/video.lite.tsx +0 -92
- package/package/components/render-block/block-styles.lite.d.ts +0 -0
- package/package/components/render-block/block-styles.lite.tsx +0 -60
- package/package/components/render-block/render-block.lite.d.ts +0 -0
- package/package/components/render-block/render-block.lite.tsx +0 -216
- package/package/components/render-block/render-component.lite.d.ts +0 -0
- package/package/components/render-block/render-component.lite.tsx +0 -33
- package/package/components/render-block/render-repeated-block.lite.d.ts +0 -0
- package/package/components/render-block/render-repeated-block.lite.tsx +0 -49
- package/package/components/render-blocks.lite.d.ts +0 -0
- package/package/components/render-blocks.lite.tsx +0 -91
- package/package/components/render-content/components/render-styles.lite.d.ts +0 -0
- package/package/components/render-content/components/render-styles.lite.tsx +0 -86
- package/package/components/render-content/render-content.lite.d.ts +0 -0
- package/package/components/render-content/render-content.lite.tsx +0 -356
- package/package/components/render-inlined-styles.lite.d.ts +0 -0
- package/package/components/render-inlined-styles.lite.tsx +0 -27
- package/package/functions/convert-style-object.d.ts +0 -1
- package/package/functions/convert-style-object.js +0 -3
- package/package/functions/get-block-styles.d.ts +0 -2
- package/package/functions/get-block-styles.js +0 -21
- package/package/functions/sanitize-styles.d.ts +0 -4
- package/package/functions/sanitize-styles.js +0 -6
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
|
|
5
|
-
/* eslint-disable */
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This component was copied over from the old SDKs and has a lot of code pointing to invalid functions/env vars. It needs
|
|
9
|
-
* to be cleaned up before the component can actually be usable.
|
|
10
|
-
*/
|
|
11
|
-
interface BuilderElement {}
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14
|
-
// @ts-nocheck
|
|
15
|
-
|
|
16
|
-
/* eslint-disable */
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* This component was copied over from the old SDKs and has a lot of code pointing to invalid functions/env vars. It needs
|
|
20
|
-
* to be cleaned up before the component can actually be usable.
|
|
21
|
-
*/
|
|
22
|
-
export interface FormProps {
|
|
23
|
-
attributes?: any;
|
|
24
|
-
name?: string;
|
|
25
|
-
action?: string;
|
|
26
|
-
validate?: boolean;
|
|
27
|
-
method?: string;
|
|
28
|
-
builderBlock?: BuilderElement;
|
|
29
|
-
sendSubmissionsTo?: string;
|
|
30
|
-
sendSubmissionsToEmail?: string;
|
|
31
|
-
sendWithJs?: boolean;
|
|
32
|
-
contentType?: string;
|
|
33
|
-
customHeaders?: {
|
|
34
|
-
[key: string]: string;
|
|
35
|
-
};
|
|
36
|
-
successUrl?: string;
|
|
37
|
-
previewState?: FormState;
|
|
38
|
-
successMessage?: BuilderElement[];
|
|
39
|
-
errorMessage?: BuilderElement[];
|
|
40
|
-
sendingMessage?: BuilderElement[];
|
|
41
|
-
resetFormOnSubmit?: boolean;
|
|
42
|
-
errorMessagePath?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
46
|
-
// @ts-nocheck
|
|
47
|
-
|
|
48
|
-
/* eslint-disable */
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* This component was copied over from the old SDKs and has a lot of code pointing to invalid functions/env vars. It needs
|
|
52
|
-
* to be cleaned up before the component can actually be usable.
|
|
53
|
-
*/
|
|
54
|
-
export type FormState = "unsubmitted" | "sending" | "success" | "error";
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<script lang="ts">
|
|
58
|
-
import { getContext, setContext } from "svelte";
|
|
59
|
-
|
|
60
|
-
import RenderBlock from "../../components/render-block/render-block.svelte";
|
|
61
|
-
import BuilderBlocks from "../../components/render-blocks.svelte";
|
|
62
|
-
import { isEditing } from "../../functions/is-editing.js";
|
|
63
|
-
|
|
64
|
-
export let previewState: FormProps["previewState"];
|
|
65
|
-
export let sendWithJs: FormProps["sendWithJs"];
|
|
66
|
-
export let sendSubmissionsTo: FormProps["sendSubmissionsTo"];
|
|
67
|
-
export let action: FormProps["action"];
|
|
68
|
-
export let customHeaders: FormProps["customHeaders"];
|
|
69
|
-
export let contentType: FormProps["contentType"];
|
|
70
|
-
export let sendSubmissionsToEmail: FormProps["sendSubmissionsToEmail"];
|
|
71
|
-
export let name: FormProps["name"];
|
|
72
|
-
export let method: FormProps["method"];
|
|
73
|
-
export let errorMessagePath: FormProps["errorMessagePath"];
|
|
74
|
-
export let resetFormOnSubmit: FormProps["resetFormOnSubmit"];
|
|
75
|
-
export let successUrl: FormProps["successUrl"];
|
|
76
|
-
export let validate: FormProps["validate"];
|
|
77
|
-
export let attributes: FormProps["attributes"];
|
|
78
|
-
export let builderBlock: FormProps["builderBlock"];
|
|
79
|
-
export let errorMessage: FormProps["errorMessage"];
|
|
80
|
-
export let sendingMessage: FormProps["sendingMessage"];
|
|
81
|
-
export let successMessage: FormProps["successMessage"];
|
|
82
|
-
|
|
83
|
-
let builderContext = getContext(BuilderContext.key);
|
|
84
|
-
|
|
85
|
-
function onSubmit(event) {
|
|
86
|
-
const sendWithJs = sendWithJs || sendSubmissionsTo === "email";
|
|
87
|
-
|
|
88
|
-
if (sendSubmissionsTo === "zapier") {
|
|
89
|
-
event.preventDefault();
|
|
90
|
-
} else if (sendWithJs) {
|
|
91
|
-
if (!(action || sendSubmissionsTo === "email")) {
|
|
92
|
-
event.preventDefault();
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
event.preventDefault();
|
|
97
|
-
const el = event.currentTarget;
|
|
98
|
-
const headers = customHeaders || {};
|
|
99
|
-
let body;
|
|
100
|
-
const formData = new FormData(el); // TODO: maybe support null
|
|
101
|
-
|
|
102
|
-
const formPairs = Array.from(
|
|
103
|
-
event.currentTarget.querySelectorAll("input,select,textarea")
|
|
104
|
-
)
|
|
105
|
-
.filter((el) => !!el.name)
|
|
106
|
-
.map((el) => {
|
|
107
|
-
let value;
|
|
108
|
-
const key = el.name;
|
|
109
|
-
|
|
110
|
-
if (el instanceof HTMLInputElement) {
|
|
111
|
-
if (el.type === "radio") {
|
|
112
|
-
if (el.checked) {
|
|
113
|
-
value = el.name;
|
|
114
|
-
return {
|
|
115
|
-
key,
|
|
116
|
-
value,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
} else if (el.type === "checkbox") {
|
|
120
|
-
value = el.checked;
|
|
121
|
-
} else if (el.type === "number" || el.type === "range") {
|
|
122
|
-
const num = el.valueAsNumber;
|
|
123
|
-
|
|
124
|
-
if (!isNaN(num)) {
|
|
125
|
-
value = num;
|
|
126
|
-
}
|
|
127
|
-
} else if (el.type === "file") {
|
|
128
|
-
// TODO: one vs multiple files
|
|
129
|
-
value = el.files;
|
|
130
|
-
} else {
|
|
131
|
-
value = el.value;
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
value = el.value;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
key,
|
|
139
|
-
value,
|
|
140
|
-
};
|
|
141
|
-
});
|
|
142
|
-
let contentType = contentType;
|
|
143
|
-
|
|
144
|
-
if (sendSubmissionsTo === "email") {
|
|
145
|
-
contentType = "multipart/form-data";
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
Array.from(formPairs).forEach(({ value }) => {
|
|
149
|
-
if (
|
|
150
|
-
value instanceof File ||
|
|
151
|
-
(Array.isArray(value) && value[0] instanceof File) ||
|
|
152
|
-
value instanceof FileList
|
|
153
|
-
) {
|
|
154
|
-
contentType = "multipart/form-data";
|
|
155
|
-
}
|
|
156
|
-
}); // TODO: send as urlEncoded or multipart by default
|
|
157
|
-
// because of ease of use and reliability in browser API
|
|
158
|
-
// for encoding the form?
|
|
159
|
-
|
|
160
|
-
if (contentType !== "application/json") {
|
|
161
|
-
body = formData;
|
|
162
|
-
} else {
|
|
163
|
-
// Json
|
|
164
|
-
const json = {};
|
|
165
|
-
Array.from(formPairs).forEach(({ value, key }) => {
|
|
166
|
-
set(json, key, value);
|
|
167
|
-
});
|
|
168
|
-
body = JSON.stringify(json);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (contentType && contentType !== "multipart/form-data") {
|
|
172
|
-
if (
|
|
173
|
-
/* Zapier doesn't allow content-type header to be sent from browsers */
|
|
174
|
-
!(sendWithJs && action?.includes("zapier.com"))
|
|
175
|
-
) {
|
|
176
|
-
headers["content-type"] = contentType;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const presubmitEvent = new CustomEvent("presubmit", {
|
|
181
|
-
detail: {
|
|
182
|
-
body,
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
if (formRef) {
|
|
187
|
-
formRef.dispatchEvent(presubmitEvent);
|
|
188
|
-
|
|
189
|
-
if (presubmitEvent.defaultPrevented) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
formState = "sending";
|
|
195
|
-
const formUrl = `${
|
|
196
|
-
builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"
|
|
197
|
-
}/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(
|
|
198
|
-
sendSubmissionsToEmail || ""
|
|
199
|
-
)}&name=${encodeURIComponent(name || "")}`;
|
|
200
|
-
fetch(
|
|
201
|
-
sendSubmissionsTo === "email" ? formUrl : action,
|
|
202
|
-
/* TODO: throw error if no action URL */
|
|
203
|
-
{
|
|
204
|
-
body,
|
|
205
|
-
headers,
|
|
206
|
-
method: method || "post",
|
|
207
|
-
}
|
|
208
|
-
).then(
|
|
209
|
-
async (res) => {
|
|
210
|
-
let body;
|
|
211
|
-
const contentType = res.headers.get("content-type");
|
|
212
|
-
|
|
213
|
-
if (contentType && contentType.indexOf("application/json") !== -1) {
|
|
214
|
-
body = await res.json();
|
|
215
|
-
} else {
|
|
216
|
-
body = await res.text();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (!res.ok && errorMessagePath) {
|
|
220
|
-
/* TODO: allow supplying an error formatter function */
|
|
221
|
-
let message = get(body, errorMessagePath);
|
|
222
|
-
|
|
223
|
-
if (message) {
|
|
224
|
-
if (typeof message !== "string") {
|
|
225
|
-
/* TODO: ideally convert json to yaml so it woul dbe like
|
|
226
|
-
error: - email has been taken */
|
|
227
|
-
message = JSON.stringify(message);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
formErrorMessage = message;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
responseData = body;
|
|
235
|
-
formState = res.ok ? "success" : "error";
|
|
236
|
-
|
|
237
|
-
if (res.ok) {
|
|
238
|
-
const submitSuccessEvent = new CustomEvent("submit:success", {
|
|
239
|
-
detail: {
|
|
240
|
-
res,
|
|
241
|
-
body,
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
if (formRef) {
|
|
246
|
-
formRef.dispatchEvent(submitSuccessEvent);
|
|
247
|
-
|
|
248
|
-
if (submitSuccessEvent.defaultPrevented) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
/* TODO: option to turn this on/off? */
|
|
252
|
-
|
|
253
|
-
if (resetFormOnSubmit !== false) {
|
|
254
|
-
formRef.reset();
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/* TODO: client side route event first that can be preventDefaulted */
|
|
258
|
-
|
|
259
|
-
if (successUrl) {
|
|
260
|
-
if (formRef) {
|
|
261
|
-
const event = new CustomEvent("route", {
|
|
262
|
-
detail: {
|
|
263
|
-
url: successUrl,
|
|
264
|
-
},
|
|
265
|
-
});
|
|
266
|
-
formRef.dispatchEvent(event);
|
|
267
|
-
|
|
268
|
-
if (!event.defaultPrevented) {
|
|
269
|
-
location.href = successUrl;
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
location.href = successUrl;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
(err) => {
|
|
278
|
-
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
279
|
-
detail: {
|
|
280
|
-
error: err,
|
|
281
|
-
},
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
if (formRef) {
|
|
285
|
-
formRef.dispatchEvent(submitErrorEvent);
|
|
286
|
-
|
|
287
|
-
if (submitErrorEvent.defaultPrevented) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
responseData = err;
|
|
293
|
-
formState = "error";
|
|
294
|
-
}
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
$: submissionState = () => {
|
|
299
|
-
return (isEditing() && previewState) || formState;
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
let formRef;
|
|
303
|
-
|
|
304
|
-
let formState = "unsubmitted";
|
|
305
|
-
let responseData = null;
|
|
306
|
-
let formErrorMessage = "";
|
|
307
|
-
</script>
|
|
308
|
-
|
|
309
|
-
<form
|
|
310
|
-
{...attributes}
|
|
311
|
-
{validate}
|
|
312
|
-
bind:this={formRef}
|
|
313
|
-
action={!sendWithJs && action}
|
|
314
|
-
{method}
|
|
315
|
-
{name}
|
|
316
|
-
on:submit={(event) => {
|
|
317
|
-
onSubmit(event);
|
|
318
|
-
}}
|
|
319
|
-
>
|
|
320
|
-
{#if builderBlock && builderBlock.children}
|
|
321
|
-
{#each builderBlock?.children as block}
|
|
322
|
-
<RenderBlock {block} context={builderContext} />
|
|
323
|
-
{/each}
|
|
324
|
-
{/if}
|
|
325
|
-
|
|
326
|
-
{#if submissionState() === "error"}
|
|
327
|
-
<BuilderBlocks dataPath="errorMessage" blocks={errorMessage} />
|
|
328
|
-
{/if}
|
|
329
|
-
|
|
330
|
-
{#if submissionState() === "sending"}
|
|
331
|
-
<BuilderBlocks dataPath="sendingMessage" blocks={sendingMessage} />
|
|
332
|
-
{/if}
|
|
333
|
-
|
|
334
|
-
{#if submissionState() === "error" && responseData}
|
|
335
|
-
<pre class="builder-form-error-text pre">
|
|
336
|
-
{JSON.stringify(responseData, null, 2)}
|
|
337
|
-
</pre>
|
|
338
|
-
{/if}
|
|
339
|
-
|
|
340
|
-
{#if submissionState() === "success"}
|
|
341
|
-
<BuilderBlocks dataPath="successMessage" blocks={successMessage} />
|
|
342
|
-
{/if}
|
|
343
|
-
</form>
|
|
344
|
-
|
|
345
|
-
<style>
|
|
346
|
-
.pre {
|
|
347
|
-
padding: 10px;
|
|
348
|
-
color: red;
|
|
349
|
-
text-align: center;
|
|
350
|
-
}
|
|
351
|
-
</style>
|
|
File without changes
|
|
File without changes
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
3
|
-
|
|
4
|
-
export interface ImageProps {
|
|
5
|
-
className?: string;
|
|
6
|
-
image: string;
|
|
7
|
-
sizes?: string;
|
|
8
|
-
lazy?: boolean;
|
|
9
|
-
height?: number;
|
|
10
|
-
width?: number;
|
|
11
|
-
altText?: string;
|
|
12
|
-
backgroundSize?: string;
|
|
13
|
-
backgroundPosition?: string;
|
|
14
|
-
srcset?: string;
|
|
15
|
-
aspectRatio?: number;
|
|
16
|
-
children?: JSX.Element;
|
|
17
|
-
fitContent?: boolean;
|
|
18
|
-
builderBlock?: BuilderBlock;
|
|
19
|
-
noWebp?: boolean;
|
|
20
|
-
src?: string;
|
|
21
|
-
}
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<script lang="ts">
|
|
25
|
-
import { getSrcSet } from "./image.helpers.js";
|
|
26
|
-
|
|
27
|
-
export let image: ImageProps["image"];
|
|
28
|
-
export let src: ImageProps["src"];
|
|
29
|
-
export let srcset: ImageProps["srcset"];
|
|
30
|
-
export let noWebp: ImageProps["noWebp"];
|
|
31
|
-
export let altText: ImageProps["altText"];
|
|
32
|
-
export let backgroundSize: ImageProps["backgroundSize"];
|
|
33
|
-
export let className: ImageProps["className"];
|
|
34
|
-
export let sizes: ImageProps["sizes"];
|
|
35
|
-
export let aspectRatio: ImageProps["aspectRatio"];
|
|
36
|
-
export let fitContent: ImageProps["fitContent"];
|
|
37
|
-
export let builderBlock: ImageProps["builderBlock"];
|
|
38
|
-
|
|
39
|
-
function mitosis_styling(node, vars) {
|
|
40
|
-
Object.entries(vars).forEach(([p, v]) => {
|
|
41
|
-
node.style[p] = v;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
$: srcSetToUse = () => {
|
|
46
|
-
const imageToUse = image || src;
|
|
47
|
-
const url = imageToUse;
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
!url || // We can auto add srcset for cdn.builder.io and shopify
|
|
51
|
-
// images, otherwise you can supply this prop manually
|
|
52
|
-
!(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/))
|
|
53
|
-
) {
|
|
54
|
-
return srcset;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (srcset && image?.includes("builder.io/api/v1/image")) {
|
|
58
|
-
if (!srcset.includes(image.split("?")[0])) {
|
|
59
|
-
console.debug("Removed given srcset");
|
|
60
|
-
return getSrcSet(url);
|
|
61
|
-
}
|
|
62
|
-
} else if (image && !srcset) {
|
|
63
|
-
return getSrcSet(url);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return getSrcSet(url);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
$: webpSrcSet = () => {
|
|
70
|
-
if (srcSetToUse?.()?.match(/builder\.io/) && !noWebp) {
|
|
71
|
-
return srcSetToUse().replace(/\?/g, "?format=webp&");
|
|
72
|
-
} else {
|
|
73
|
-
return "";
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
</script>
|
|
77
|
-
|
|
78
|
-
<div class="div">
|
|
79
|
-
<picture>
|
|
80
|
-
{#if webpSrcSet()}
|
|
81
|
-
<source type="image/webp" srcset={webpSrcSet()} />
|
|
82
|
-
{/if}
|
|
83
|
-
<img
|
|
84
|
-
use:mitosis_styling={{
|
|
85
|
-
objectPosition: backgroundSize || "center",
|
|
86
|
-
objectFit: backgroundSize || "cover",
|
|
87
|
-
}}
|
|
88
|
-
loading="lazy"
|
|
89
|
-
alt={altText}
|
|
90
|
-
role={altText ? "presentation" : undefined}
|
|
91
|
-
class={"builder-image" + (className ? " " + className : "") + " img"}
|
|
92
|
-
src={image}
|
|
93
|
-
srcset={srcSetToUse()}
|
|
94
|
-
{sizes}
|
|
95
|
-
/>
|
|
96
|
-
<source srcset={srcSetToUse()} />
|
|
97
|
-
</picture>
|
|
98
|
-
|
|
99
|
-
{#if aspectRatio && !(fitContent && builderBlock?.children?.length)}
|
|
100
|
-
<div
|
|
101
|
-
use:mitosis_styling={{
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
103
|
-
paddingTop: aspectRatio * 100 + "%",
|
|
104
|
-
}}
|
|
105
|
-
class="builder-image-sizer div-2"
|
|
106
|
-
/>
|
|
107
|
-
{/if}
|
|
108
|
-
|
|
109
|
-
{#if builderBlock?.children?.length && fitContent}
|
|
110
|
-
<slot />
|
|
111
|
-
{/if}
|
|
112
|
-
|
|
113
|
-
{#if !fitContent}
|
|
114
|
-
<div class="div-3">
|
|
115
|
-
<slot />
|
|
116
|
-
</div>
|
|
117
|
-
{/if}
|
|
118
|
-
</div>
|
|
119
|
-
|
|
120
|
-
<style>
|
|
121
|
-
.div {
|
|
122
|
-
position: relative;
|
|
123
|
-
}
|
|
124
|
-
.img {
|
|
125
|
-
opacity: 1;
|
|
126
|
-
transition: opacity 0.2s ease-in-out;
|
|
127
|
-
position: absolute;
|
|
128
|
-
height: 100%;
|
|
129
|
-
width: 100%;
|
|
130
|
-
top: 0px;
|
|
131
|
-
left: 0px;
|
|
132
|
-
}
|
|
133
|
-
.div-2 {
|
|
134
|
-
width: 100%;
|
|
135
|
-
pointer-events: none;
|
|
136
|
-
font-size: 0;
|
|
137
|
-
}
|
|
138
|
-
.div-3 {
|
|
139
|
-
display: flex;
|
|
140
|
-
flex-direction: column;
|
|
141
|
-
align-items: stretch;
|
|
142
|
-
position: absolute;
|
|
143
|
-
top: 0;
|
|
144
|
-
left: 0;
|
|
145
|
-
width: 100%;
|
|
146
|
-
height: 100%;
|
|
147
|
-
}
|
|
148
|
-
</style>
|
|
File without changes
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
export interface ImgProps {
|
|
3
|
-
attributes?: any;
|
|
4
|
-
imgSrc?: string; // TODO(misko): I think this is unused
|
|
5
|
-
|
|
6
|
-
image?: string;
|
|
7
|
-
altText?: string;
|
|
8
|
-
backgroundSize?: "cover" | "contain";
|
|
9
|
-
backgroundPosition?:
|
|
10
|
-
| "center"
|
|
11
|
-
| "top"
|
|
12
|
-
| "left"
|
|
13
|
-
| "right"
|
|
14
|
-
| "bottom"
|
|
15
|
-
| "top left"
|
|
16
|
-
| "top right"
|
|
17
|
-
| "bottom left"
|
|
18
|
-
| "bottom right";
|
|
19
|
-
}
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<script lang="ts">
|
|
23
|
-
import { isEditing } from "../../functions/is-editing.js";
|
|
24
|
-
|
|
25
|
-
export let backgroundSize: ImgProps["backgroundSize"];
|
|
26
|
-
export let backgroundPosition: ImgProps["backgroundPosition"];
|
|
27
|
-
export let imgSrc: ImgProps["imgSrc"];
|
|
28
|
-
export let altText: ImgProps["altText"];
|
|
29
|
-
export let image: ImgProps["image"];
|
|
30
|
-
export let attributes: ImgProps["attributes"];
|
|
31
|
-
|
|
32
|
-
function mitosis_styling(node, vars) {
|
|
33
|
-
Object.entries(vars).forEach(([p, v]) => {
|
|
34
|
-
node.style[p] = v;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
<img
|
|
40
|
-
{...attributes}
|
|
41
|
-
use:mitosis_styling={{
|
|
42
|
-
objectFit: backgroundSize || "cover",
|
|
43
|
-
objectPosition: backgroundPosition || "center",
|
|
44
|
-
}}
|
|
45
|
-
key={(isEditing() && imgSrc) || "default-key"}
|
|
46
|
-
alt={altText}
|
|
47
|
-
src={imgSrc || image}
|
|
48
|
-
/>
|
|
File without changes
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
export interface FormInputProps {
|
|
3
|
-
type?: string;
|
|
4
|
-
attributes?: any;
|
|
5
|
-
name?: string;
|
|
6
|
-
value?: string;
|
|
7
|
-
placeholder?: string;
|
|
8
|
-
defaultValue?: string;
|
|
9
|
-
required?: boolean;
|
|
10
|
-
}
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<script lang="ts">
|
|
14
|
-
import { isEditing } from "../../functions/is-editing.js";
|
|
15
|
-
|
|
16
|
-
export let attributes: FormInputProps["attributes"];
|
|
17
|
-
export let defaultValue: FormInputProps["defaultValue"];
|
|
18
|
-
export let placeholder: FormInputProps["placeholder"];
|
|
19
|
-
export let type: FormInputProps["type"];
|
|
20
|
-
export let name: FormInputProps["name"];
|
|
21
|
-
export let value: FormInputProps["value"];
|
|
22
|
-
export let required: FormInputProps["required"];
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<input
|
|
26
|
-
{...attributes}
|
|
27
|
-
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
28
|
-
{placeholder}
|
|
29
|
-
{type}
|
|
30
|
-
{name}
|
|
31
|
-
{value}
|
|
32
|
-
{defaultValue}
|
|
33
|
-
{required}
|
|
34
|
-
/>
|
|
File without changes
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
export interface RawTextProps {
|
|
3
|
-
attributes?: any;
|
|
4
|
-
text?: string; // builderBlock?: any;
|
|
5
|
-
}
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<script lang="ts">
|
|
9
|
-
export let attributes: RawTextProps["attributes"];
|
|
10
|
-
export let text: RawTextProps["text"];
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<span class={attributes?.class || attributes?.className}
|
|
14
|
-
>{@html text || ""}</span
|
|
15
|
-
>
|
|
File without changes
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
export interface SectionProps {
|
|
3
|
-
maxWidth?: number;
|
|
4
|
-
attributes?: any;
|
|
5
|
-
children?: any;
|
|
6
|
-
builderBlock?: any;
|
|
7
|
-
}
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<script lang="ts">
|
|
11
|
-
export let attributes: SectionProps["attributes"];
|
|
12
|
-
export let maxWidth: SectionProps["maxWidth"];
|
|
13
|
-
|
|
14
|
-
function mitosis_styling(node, vars) {
|
|
15
|
-
Object.entries(vars).forEach(([p, v]) => {
|
|
16
|
-
node.style[p] = v;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<section
|
|
22
|
-
{...attributes}
|
|
23
|
-
use:mitosis_styling={maxWidth && typeof maxWidth === "number"
|
|
24
|
-
? {
|
|
25
|
-
maxWidth: maxWidth,
|
|
26
|
-
}
|
|
27
|
-
: undefined}
|
|
28
|
-
>
|
|
29
|
-
<slot />
|
|
30
|
-
</section>
|
|
File without changes
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
export interface FormSelectProps {
|
|
3
|
-
options?: {
|
|
4
|
-
name?: string;
|
|
5
|
-
value: string;
|
|
6
|
-
}[];
|
|
7
|
-
attributes?: any;
|
|
8
|
-
name?: string;
|
|
9
|
-
value?: string;
|
|
10
|
-
defaultValue?: string;
|
|
11
|
-
}
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<script lang="ts">
|
|
15
|
-
import { isEditing } from "../../functions/is-editing.js";
|
|
16
|
-
|
|
17
|
-
export let attributes: FormSelectProps["attributes"];
|
|
18
|
-
export let value: FormSelectProps["value"];
|
|
19
|
-
export let defaultValue: FormSelectProps["defaultValue"];
|
|
20
|
-
export let name: FormSelectProps["name"];
|
|
21
|
-
export let options: FormSelectProps["options"];
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<select
|
|
25
|
-
{...attributes}
|
|
26
|
-
{value}
|
|
27
|
-
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
28
|
-
{defaultValue}
|
|
29
|
-
{name}
|
|
30
|
-
>
|
|
31
|
-
{#each options as option}
|
|
32
|
-
<option value={option.value}>{option.name || option.value}</option>
|
|
33
|
-
{/each}
|
|
34
|
-
</select>
|
|
File without changes
|