@builder.io/sdk-svelte 0.13.1 → 0.13.2
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/lib/browser/blocks/form/form/component-info.d.ts +2 -0
- package/lib/browser/blocks/form/form/form.svelte +302 -0
- package/lib/browser/blocks/form/input/component-info.d.ts +2 -0
- package/lib/browser/blocks/{input → form/input}/input.svelte +3 -3
- package/lib/browser/blocks/form/select/component-info.d.ts +2 -0
- package/lib/{node/blocks → browser/blocks/form}/select/select.svelte +3 -3
- package/lib/browser/blocks/form/submit-button/component-info.d.ts +2 -0
- package/lib/{node/blocks → browser/blocks/form}/submit-button/submit-button.svelte +2 -2
- package/lib/browser/blocks/slot/slot.svelte +1 -0
- package/lib/browser/blocks/slot/slot.svelte.d.ts +4 -7
- package/lib/browser/components/block/block.svelte +4 -2
- package/lib/browser/constants/builder-registered-components.js +5 -24
- package/lib/browser/constants/extra-components.d.ts +7 -0
- package/lib/browser/constants/extra-components.js +47 -0
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/get-env.d.ts +2 -0
- package/lib/browser/functions/get-env.js +5 -0
- package/lib/browser/functions/get.d.ts +1 -0
- package/lib/browser/functions/get.js +4 -0
- package/lib/edge/blocks/form/form/component-info.d.ts +2 -0
- package/lib/edge/blocks/form/form/form.svelte +302 -0
- package/lib/edge/blocks/form/input/component-info.d.ts +2 -0
- package/lib/{node/blocks → edge/blocks/form}/input/input.svelte +3 -3
- package/lib/edge/blocks/form/select/component-info.d.ts +2 -0
- package/lib/{browser/blocks → edge/blocks/form}/select/select.svelte +3 -3
- package/lib/edge/blocks/form/submit-button/component-info.d.ts +2 -0
- package/lib/edge/blocks/{submit-button → form/submit-button}/submit-button.svelte +2 -2
- package/lib/edge/blocks/slot/slot.svelte +1 -0
- package/lib/edge/blocks/slot/slot.svelte.d.ts +4 -7
- package/lib/edge/components/block/block.svelte +4 -2
- package/lib/edge/constants/builder-registered-components.js +5 -24
- package/lib/edge/constants/extra-components.d.ts +7 -0
- package/lib/edge/constants/extra-components.js +47 -0
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/get-env.d.ts +2 -0
- package/lib/edge/functions/get-env.js +5 -0
- package/lib/edge/functions/get.d.ts +1 -0
- package/lib/edge/functions/get.js +4 -0
- package/lib/node/blocks/form/form/component-info.d.ts +2 -0
- package/lib/node/blocks/form/form/form.svelte +302 -0
- package/lib/node/blocks/form/input/component-info.d.ts +2 -0
- package/lib/{edge/blocks → node/blocks/form}/input/input.svelte +3 -3
- package/lib/node/blocks/form/select/component-info.d.ts +2 -0
- package/lib/{edge/blocks → node/blocks/form}/select/select.svelte +3 -3
- package/lib/node/blocks/form/submit-button/component-info.d.ts +2 -0
- package/lib/{browser/blocks → node/blocks/form}/submit-button/submit-button.svelte +2 -2
- package/lib/node/blocks/slot/slot.svelte +1 -0
- package/lib/node/blocks/slot/slot.svelte.d.ts +4 -7
- package/lib/node/components/block/block.svelte +4 -2
- package/lib/node/constants/builder-registered-components.js +5 -24
- package/lib/node/constants/extra-components.d.ts +7 -0
- package/lib/node/constants/extra-components.js +47 -0
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/get-env.d.ts +2 -0
- package/lib/node/functions/get-env.js +5 -0
- package/lib/node/functions/get.d.ts +1 -0
- package/lib/node/functions/get.js +4 -0
- package/package.json +1 -1
- package/src/blocks/form/{component-info.ts → form/component-info.ts} +1 -1
- package/src/blocks/form/form/form.svelte +359 -0
- package/src/blocks/{input → form/input}/component-info.ts +1 -1
- package/src/blocks/{input → form/input}/input.svelte +3 -3
- package/src/blocks/{select → form/select}/component-info.ts +1 -1
- package/src/blocks/{select → form/select}/select.svelte +3 -3
- package/src/blocks/{submit-button → form/submit-button}/component-info.ts +1 -1
- package/src/blocks/{submit-button → form/submit-button}/submit-button.svelte +2 -2
- package/src/blocks/slot/slot.svelte +4 -6
- package/src/components/block/block.svelte +4 -2
- package/src/constants/builder-registered-components.ts +5 -24
- package/src/constants/extra-components.ts +49 -0
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/get-env.ts +5 -0
- package/src/functions/get.ts +4 -0
- package/lib/browser/blocks/form/component-info.d.ts +0 -2
- package/lib/browser/blocks/form/form.svelte +0 -2
- package/lib/browser/blocks/form/form.svelte.d.ts +0 -14
- package/lib/browser/blocks/input/component-info.d.ts +0 -2
- package/lib/browser/blocks/select/component-info.d.ts +0 -2
- package/lib/browser/blocks/submit-button/component-info.d.ts +0 -2
- package/lib/edge/blocks/form/component-info.d.ts +0 -2
- package/lib/edge/blocks/form/form.svelte +0 -2
- package/lib/edge/blocks/form/form.svelte.d.ts +0 -14
- package/lib/edge/blocks/input/component-info.d.ts +0 -2
- package/lib/edge/blocks/select/component-info.d.ts +0 -2
- package/lib/edge/blocks/submit-button/component-info.d.ts +0 -2
- package/lib/node/blocks/form/component-info.d.ts +0 -2
- package/lib/node/blocks/form/form.svelte +0 -2
- package/lib/node/blocks/form/form.svelte.d.ts +0 -14
- package/lib/node/blocks/input/component-info.d.ts +0 -2
- package/lib/node/blocks/select/component-info.d.ts +0 -2
- package/lib/node/blocks/submit-button/component-info.d.ts +0 -2
- package/src/blocks/form/form.svelte +0 -2
- /package/lib/browser/blocks/form/{component-info.js → form/component-info.js} +0 -0
- /package/lib/browser/blocks/{input → form/input}/component-info.js +0 -0
- /package/lib/browser/blocks/{select → form/select}/component-info.js +0 -0
- /package/lib/browser/blocks/{submit-button → form/submit-button}/component-info.js +0 -0
- /package/lib/browser/blocks/{submit-button → form/submit-button}/submit-button.svelte.d.ts +0 -0
- /package/lib/edge/blocks/form/{component-info.js → form/component-info.js} +0 -0
- /package/lib/edge/blocks/{input → form/input}/component-info.js +0 -0
- /package/lib/edge/blocks/{select → form/select}/component-info.js +0 -0
- /package/lib/edge/blocks/{submit-button → form/submit-button}/component-info.js +0 -0
- /package/lib/edge/blocks/{submit-button → form/submit-button}/submit-button.svelte.d.ts +0 -0
- /package/lib/node/blocks/form/{component-info.js → form/component-info.js} +0 -0
- /package/lib/node/blocks/{input → form/input}/component-info.js +0 -0
- /package/lib/node/blocks/{select → form/select}/component-info.js +0 -0
- /package/lib/node/blocks/{submit-button → form/submit-button}/component-info.js +0 -0
- /package/lib/node/blocks/{submit-button → form/submit-button}/submit-button.svelte.d.ts +0 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
<script context="module">/**
|
|
2
|
+
* This import is used by the Svelte SDK. Do not remove.
|
|
3
|
+
*/
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<script>import Block from "../../../components/block/block.svelte";
|
|
7
|
+
import Blocks from "../../../components/blocks/blocks.svelte";
|
|
8
|
+
import { getEnv } from "../../../functions/get-env.js";
|
|
9
|
+
import { get } from "../../../functions/get.js";
|
|
10
|
+
import { isEditing } from "../../../functions/is-editing.js";
|
|
11
|
+
import { set } from "../../../functions/set.js";
|
|
12
|
+
import { filterAttrs } from "../../helpers.js";
|
|
13
|
+
import { setAttrs } from "../../helpers.js";
|
|
14
|
+
export let js;
|
|
15
|
+
export let builderContext;
|
|
16
|
+
export let previewState = undefined;
|
|
17
|
+
export let sendWithJs = undefined;
|
|
18
|
+
export let sendSubmissionsTo = undefined;
|
|
19
|
+
export let action = undefined;
|
|
20
|
+
export let customHeaders = undefined;
|
|
21
|
+
export let contentType = undefined;
|
|
22
|
+
export let sendSubmissionsToEmail = undefined;
|
|
23
|
+
export let name = undefined;
|
|
24
|
+
export let method = undefined;
|
|
25
|
+
export let errorMessagePath = undefined;
|
|
26
|
+
export let resetFormOnSubmit = undefined;
|
|
27
|
+
export let successUrl = undefined;
|
|
28
|
+
export let validate = undefined;
|
|
29
|
+
export let attributes = undefined;
|
|
30
|
+
export let builderBlock;
|
|
31
|
+
export let builderComponents;
|
|
32
|
+
export let builderLinkComponent = undefined;
|
|
33
|
+
export let errorMessage = undefined;
|
|
34
|
+
export let sendingMessage = undefined;
|
|
35
|
+
export let successMessage = undefined;
|
|
36
|
+
function mergeNewRootState(newData) {
|
|
37
|
+
const combinedState = {
|
|
38
|
+
...$builderContext.rootState,
|
|
39
|
+
...newData,
|
|
40
|
+
};
|
|
41
|
+
if ($builderContext.rootSetState) {
|
|
42
|
+
$builderContext.rootSetState?.(combinedState);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
$builderContext.rootState = combinedState;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function submissionState() {
|
|
49
|
+
return (isEditing() && previewState) || formState;
|
|
50
|
+
}
|
|
51
|
+
function onSubmit(event) {
|
|
52
|
+
const sendWithJsProp = sendWithJs || sendSubmissionsTo === "email";
|
|
53
|
+
if (sendSubmissionsTo === "zapier") {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
}
|
|
56
|
+
else if (sendWithJsProp) {
|
|
57
|
+
if (!(action || sendSubmissionsTo === "email")) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
const el = event.currentTarget;
|
|
63
|
+
const headers = customHeaders || {};
|
|
64
|
+
let body;
|
|
65
|
+
const formData = new FormData(el);
|
|
66
|
+
// TODO: maybe support null
|
|
67
|
+
const formPairs = Array.from(event.currentTarget.querySelectorAll("input,select,textarea"))
|
|
68
|
+
.filter((el) => !!el.name)
|
|
69
|
+
.map((el) => {
|
|
70
|
+
let value;
|
|
71
|
+
const key = el.name;
|
|
72
|
+
if (el instanceof HTMLInputElement) {
|
|
73
|
+
if (el.type === "radio") {
|
|
74
|
+
if (el.checked) {
|
|
75
|
+
value = el.name;
|
|
76
|
+
return {
|
|
77
|
+
key,
|
|
78
|
+
value,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (el.type === "checkbox") {
|
|
83
|
+
value = el.checked;
|
|
84
|
+
}
|
|
85
|
+
else if (el.type === "number" || el.type === "range") {
|
|
86
|
+
const num = el.valueAsNumber;
|
|
87
|
+
if (!isNaN(num)) {
|
|
88
|
+
value = num;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (el.type === "file") {
|
|
92
|
+
// TODO: one vs multiple files
|
|
93
|
+
value = el.files;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
value = el.value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
value = el.value;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
key,
|
|
104
|
+
value,
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
let formContentType = contentType;
|
|
108
|
+
if (sendSubmissionsTo === "email") {
|
|
109
|
+
formContentType = "multipart/form-data";
|
|
110
|
+
}
|
|
111
|
+
Array.from(formPairs).forEach(({ value }) => {
|
|
112
|
+
if (value instanceof File ||
|
|
113
|
+
(Array.isArray(value) && value[0] instanceof File) ||
|
|
114
|
+
value instanceof FileList) {
|
|
115
|
+
formContentType = "multipart/form-data";
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
// TODO: send as urlEncoded or multipart by default
|
|
119
|
+
// because of ease of use and reliability in browser API
|
|
120
|
+
// for encoding the form?
|
|
121
|
+
if (formContentType !== "application/json") {
|
|
122
|
+
body = formData;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// Json
|
|
126
|
+
const json = {};
|
|
127
|
+
Array.from(formPairs).forEach(({ value, key }) => {
|
|
128
|
+
set(json, key, value);
|
|
129
|
+
});
|
|
130
|
+
body = JSON.stringify(json);
|
|
131
|
+
}
|
|
132
|
+
if (formContentType && formContentType !== "multipart/form-data") {
|
|
133
|
+
if (
|
|
134
|
+
/* Zapier doesn't allow content-type header to be sent from browsers */
|
|
135
|
+
!(sendWithJsProp && action?.includes("zapier.com"))) {
|
|
136
|
+
headers["content-type"] = formContentType;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const presubmitEvent = new CustomEvent("presubmit", {
|
|
140
|
+
detail: {
|
|
141
|
+
body,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
if (formRef) {
|
|
145
|
+
formRef.dispatchEvent(presubmitEvent);
|
|
146
|
+
if (presubmitEvent.defaultPrevented) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
formState = "sending";
|
|
151
|
+
const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${$builderContext.apiKey}&to=${btoa(sendSubmissionsToEmail || "")}&name=${encodeURIComponent(name || "")}`;
|
|
152
|
+
fetch(sendSubmissionsTo === "email"
|
|
153
|
+
? formUrl
|
|
154
|
+
: action /* TODO: throw error if no action URL */, {
|
|
155
|
+
body,
|
|
156
|
+
headers,
|
|
157
|
+
method: method || "post",
|
|
158
|
+
}).then(async (res) => {
|
|
159
|
+
let body;
|
|
160
|
+
const contentType = res.headers.get("content-type");
|
|
161
|
+
if (contentType && contentType.indexOf("application/json") !== -1) {
|
|
162
|
+
body = await res.json();
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
body = await res.text();
|
|
166
|
+
}
|
|
167
|
+
if (!res.ok && errorMessagePath) {
|
|
168
|
+
/* TODO: allow supplying an error formatter function */
|
|
169
|
+
let message = get(body, errorMessagePath);
|
|
170
|
+
if (message) {
|
|
171
|
+
if (typeof message !== "string") {
|
|
172
|
+
/* TODO: ideally convert json to yaml so it woul dbe like
|
|
173
|
+
error: - email has been taken */
|
|
174
|
+
message = JSON.stringify(message);
|
|
175
|
+
}
|
|
176
|
+
formErrorMessage = message;
|
|
177
|
+
mergeNewRootState({
|
|
178
|
+
formErrorMessage: message,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
responseData = body;
|
|
183
|
+
formState = res.ok ? "success" : "error";
|
|
184
|
+
if (res.ok) {
|
|
185
|
+
const submitSuccessEvent = new CustomEvent("submit:success", {
|
|
186
|
+
detail: {
|
|
187
|
+
res,
|
|
188
|
+
body,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
if (formRef) {
|
|
192
|
+
formRef.dispatchEvent(submitSuccessEvent);
|
|
193
|
+
if (submitSuccessEvent.defaultPrevented) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
/* TODO: option to turn this on/off? */
|
|
197
|
+
if (resetFormOnSubmit !== false) {
|
|
198
|
+
formRef.reset();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/* TODO: client side route event first that can be preventDefaulted */
|
|
202
|
+
if (successUrl) {
|
|
203
|
+
if (formRef) {
|
|
204
|
+
const event = new CustomEvent("route", {
|
|
205
|
+
detail: {
|
|
206
|
+
url: successUrl,
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
formRef.dispatchEvent(event);
|
|
210
|
+
if (!event.defaultPrevented) {
|
|
211
|
+
location.href = successUrl;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
location.href = successUrl;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}, (err) => {
|
|
220
|
+
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
221
|
+
detail: {
|
|
222
|
+
error: err,
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
if (formRef) {
|
|
226
|
+
formRef.dispatchEvent(submitErrorEvent);
|
|
227
|
+
if (submitErrorEvent.defaultPrevented) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
responseData = err;
|
|
232
|
+
formState = "error";
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
let formRef;
|
|
237
|
+
let formState = "unsubmitted";
|
|
238
|
+
let responseData = null;
|
|
239
|
+
let formErrorMessage = "";
|
|
240
|
+
</script>
|
|
241
|
+
|
|
242
|
+
<form
|
|
243
|
+
{validate}
|
|
244
|
+
bind:this={formRef}
|
|
245
|
+
action={!sendWithJs && action}
|
|
246
|
+
{method}
|
|
247
|
+
{name}
|
|
248
|
+
on:submit={(event) => {
|
|
249
|
+
onSubmit(event);
|
|
250
|
+
}}
|
|
251
|
+
{...filterAttrs(attributes, "on:", false)}
|
|
252
|
+
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
253
|
+
>
|
|
254
|
+
{#if builderBlock && builderBlock.children}
|
|
255
|
+
{#each builderBlock?.children as block, idx (`form-block-${idx}`)}
|
|
256
|
+
<Block
|
|
257
|
+
{block}
|
|
258
|
+
context={builderContext}
|
|
259
|
+
registeredComponents={builderComponents}
|
|
260
|
+
linkComponent={builderLinkComponent}
|
|
261
|
+
/>
|
|
262
|
+
{/each}
|
|
263
|
+
{/if}
|
|
264
|
+
|
|
265
|
+
{#if submissionState() === "error"}
|
|
266
|
+
<Blocks
|
|
267
|
+
path="errorMessage"
|
|
268
|
+
blocks={errorMessage}
|
|
269
|
+
context={builderContext}
|
|
270
|
+
/>
|
|
271
|
+
{/if}
|
|
272
|
+
|
|
273
|
+
{#if submissionState() === "sending"}
|
|
274
|
+
<Blocks
|
|
275
|
+
path="sendingMessage"
|
|
276
|
+
blocks={sendingMessage}
|
|
277
|
+
context={builderContext}
|
|
278
|
+
/>
|
|
279
|
+
{/if}
|
|
280
|
+
|
|
281
|
+
{#if submissionState() === "error" && responseData}
|
|
282
|
+
<pre class="builder-form-error-text pre">
|
|
283
|
+
{JSON.stringify(responseData, null, 2)}
|
|
284
|
+
</pre>
|
|
285
|
+
{/if}
|
|
286
|
+
|
|
287
|
+
{#if submissionState() === "success"}
|
|
288
|
+
<Blocks
|
|
289
|
+
path="successMessage"
|
|
290
|
+
blocks={successMessage}
|
|
291
|
+
context={builderContext}
|
|
292
|
+
/>
|
|
293
|
+
{/if}
|
|
294
|
+
</form>
|
|
295
|
+
|
|
296
|
+
<style>
|
|
297
|
+
.pre {
|
|
298
|
+
padding: 10px;
|
|
299
|
+
color: red;
|
|
300
|
+
text-align: center;
|
|
301
|
+
}
|
|
302
|
+
</style>
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
|
-
<script>import { isEditing } from "
|
|
7
|
-
import { filterAttrs } from "
|
|
8
|
-
import { setAttrs } from "
|
|
6
|
+
<script>import { isEditing } from "../../../functions/is-editing.js";
|
|
7
|
+
import { filterAttrs } from "../../helpers.js";
|
|
8
|
+
import { setAttrs } from "../../helpers.js";
|
|
9
9
|
export let attributes = undefined;
|
|
10
10
|
export let defaultValue = undefined;
|
|
11
11
|
export let placeholder = undefined;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
|
-
<script>import { isEditing } from "
|
|
7
|
-
import { filterAttrs } from "
|
|
8
|
-
import { setAttrs } from "
|
|
6
|
+
<script>import { isEditing } from "../../../functions/is-editing.js";
|
|
7
|
+
import { filterAttrs } from "../../helpers.js";
|
|
8
|
+
import { setAttrs } from "../../helpers.js";
|
|
9
9
|
export let attributes = undefined;
|
|
10
10
|
export let value = undefined;
|
|
11
11
|
export let defaultValue = undefined;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
|
-
<script>import { filterAttrs } from "
|
|
7
|
-
import { setAttrs } from "
|
|
6
|
+
<script>import { filterAttrs } from "../../helpers.js";
|
|
7
|
+
import { setAttrs } from "../../helpers.js";
|
|
8
8
|
export let attributes = undefined;
|
|
9
9
|
export let text = undefined;
|
|
10
10
|
</script>
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
export
|
|
2
|
+
export type DropzoneProps = PropsWithBuilderData<{
|
|
3
3
|
name: string;
|
|
4
|
-
builderBlock: BuilderBlock;
|
|
5
|
-
builderContext: Writable<BuilderContextInterface>;
|
|
6
4
|
attributes: any;
|
|
7
|
-
}
|
|
8
|
-
import type {
|
|
9
|
-
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
10
|
-
import type { Writable } from "svelte/store";
|
|
5
|
+
}>;
|
|
6
|
+
import type { PropsWithBuilderData } from "../../types/builder-props.js";
|
|
11
7
|
declare const __propDef: {
|
|
12
8
|
props: {
|
|
9
|
+
js: any;
|
|
13
10
|
builderContext: DropzoneProps["builderContext"];
|
|
14
11
|
name: DropzoneProps["name"];
|
|
15
12
|
};
|
|
@@ -81,13 +81,15 @@ $: componentRefProps = () => {
|
|
|
81
81
|
builderContext: context,
|
|
82
82
|
...(blockComponent?.()?.name === "Core:Button" ||
|
|
83
83
|
blockComponent?.()?.name === "Symbol" ||
|
|
84
|
-
blockComponent?.()?.name === "Columns"
|
|
84
|
+
blockComponent?.()?.name === "Columns" ||
|
|
85
|
+
blockComponent?.()?.name === "Form:Form"
|
|
85
86
|
? {
|
|
86
87
|
builderLinkComponent: linkComponent,
|
|
87
88
|
}
|
|
88
89
|
: {}),
|
|
89
90
|
...(blockComponent?.()?.name === "Symbol" ||
|
|
90
|
-
blockComponent?.()?.name === "Columns"
|
|
91
|
+
blockComponent?.()?.name === "Columns" ||
|
|
92
|
+
blockComponent?.()?.name === "Form:Form"
|
|
91
93
|
? {
|
|
92
94
|
builderComponents: registeredComponents,
|
|
93
95
|
}
|
|
@@ -2,16 +2,10 @@ import { default as Button } from '../blocks/button/button.svelte';
|
|
|
2
2
|
import { componentInfo as buttonComponentInfo } from '../blocks/button/component-info.js';
|
|
3
3
|
import { default as Columns } from '../blocks/columns/columns.svelte';
|
|
4
4
|
import { componentInfo as columnsComponentInfo } from '../blocks/columns/component-info.js';
|
|
5
|
-
import { componentInfo as customCodeInfo } from '../blocks/custom-code/component-info.js';
|
|
6
|
-
import { default as customCode } from '../blocks/custom-code/custom-code.svelte';
|
|
7
|
-
import { componentInfo as embedComponentInfo } from '../blocks/embed/component-info.js';
|
|
8
|
-
import { default as embed } from '../blocks/embed/embed.svelte';
|
|
9
5
|
import { componentInfo as fragmentComponentInfo } from '../blocks/fragment/component-info.js';
|
|
10
6
|
import { default as Fragment } from '../blocks/fragment/fragment.svelte';
|
|
11
7
|
import { componentInfo as imageComponentInfo } from '../blocks/image/component-info.js';
|
|
12
8
|
import { default as Image } from '../blocks/image/image.svelte';
|
|
13
|
-
import { componentInfo as imgComponentInfo } from '../blocks/img/component-info.js';
|
|
14
|
-
import { default as Img } from '../blocks/img/img.svelte';
|
|
15
9
|
import { componentInfo as sectionComponentInfo } from '../blocks/section/component-info.js';
|
|
16
10
|
import { default as Section } from '../blocks/section/section.svelte';
|
|
17
11
|
import { componentInfo as slotComponentInfo } from '../blocks/slot/component-info.js';
|
|
@@ -20,8 +14,7 @@ import { componentInfo as symbolComponentInfo } from '../blocks/symbol/component
|
|
|
20
14
|
import { default as Symbol } from '../blocks/symbol/symbol.svelte';
|
|
21
15
|
import { componentInfo as textComponentInfo } from '../blocks/text/component-info.js';
|
|
22
16
|
import { default as Text } from '../blocks/text/text.svelte';
|
|
23
|
-
import {
|
|
24
|
-
import { default as Video } from '../blocks/video/video.svelte';
|
|
17
|
+
import { getExtraComponents } from './extra-components.js';
|
|
25
18
|
/**
|
|
26
19
|
* Returns a list of all registered components.
|
|
27
20
|
* NOTE: This needs to be a function to work around ESM circular dependencies.
|
|
@@ -32,34 +25,22 @@ export const getDefaultRegisteredComponents = () => [{
|
|
|
32
25
|
}, {
|
|
33
26
|
component: Columns,
|
|
34
27
|
...columnsComponentInfo
|
|
35
|
-
}, {
|
|
36
|
-
component: customCode,
|
|
37
|
-
...customCodeInfo
|
|
38
|
-
}, {
|
|
39
|
-
component: embed,
|
|
40
|
-
...embedComponentInfo
|
|
41
28
|
}, {
|
|
42
29
|
component: Fragment,
|
|
43
30
|
...fragmentComponentInfo
|
|
44
31
|
}, {
|
|
45
32
|
component: Image,
|
|
46
33
|
...imageComponentInfo
|
|
47
|
-
}, {
|
|
48
|
-
component: Img,
|
|
49
|
-
...imgComponentInfo
|
|
50
34
|
}, {
|
|
51
35
|
component: Section,
|
|
52
36
|
...sectionComponentInfo
|
|
37
|
+
}, {
|
|
38
|
+
component: Slot,
|
|
39
|
+
...slotComponentInfo
|
|
53
40
|
}, {
|
|
54
41
|
component: Symbol,
|
|
55
42
|
...symbolComponentInfo
|
|
56
43
|
}, {
|
|
57
44
|
component: Text,
|
|
58
45
|
...textComponentInfo
|
|
59
|
-
},
|
|
60
|
-
component: Video,
|
|
61
|
-
...videoComponentInfo
|
|
62
|
-
}, {
|
|
63
|
-
component: Slot,
|
|
64
|
-
...slotComponentInfo
|
|
65
|
-
}];
|
|
46
|
+
}, ...getExtraComponents()];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These are in a separate file because React Native does not support them (yet).
|
|
3
|
+
* Having them in a separate file allows us to override it to be empty in the
|
|
4
|
+
* React Native SDK.
|
|
5
|
+
*/
|
|
6
|
+
import type { RegisteredComponent } from '../context/types.js';
|
|
7
|
+
export declare const getExtraComponents: () => RegisteredComponent[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These are in a separate file because React Native does not support them (yet).
|
|
3
|
+
* Having them in a separate file allows us to override it to be empty in the
|
|
4
|
+
* React Native SDK.
|
|
5
|
+
*/
|
|
6
|
+
import { componentInfo as customCodeInfo } from '../blocks/custom-code/component-info.js';
|
|
7
|
+
import { default as customCode } from '../blocks/custom-code/custom-code.svelte';
|
|
8
|
+
import { componentInfo as embedComponentInfo } from '../blocks/embed/component-info.js';
|
|
9
|
+
import { default as embed } from '../blocks/embed/embed.svelte';
|
|
10
|
+
import { componentInfo as formComponentInfo } from '../blocks/form/form/component-info.js';
|
|
11
|
+
import { default as Form } from '../blocks/form/form/form.svelte';
|
|
12
|
+
import { componentInfo as formInputComponentInfo } from '../blocks/form/input/component-info.js';
|
|
13
|
+
import { default as FormInput } from '../blocks/form/input/input.svelte';
|
|
14
|
+
import { componentInfo as formSelectComponentInfo } from '../blocks/form/select/component-info.js';
|
|
15
|
+
import { default as FormSelect } from '../blocks/form/select/select.svelte';
|
|
16
|
+
import { componentInfo as formSubmitButtonComponentInfo } from '../blocks/form/submit-button/component-info.js';
|
|
17
|
+
import { default as FormSubmitButton } from '../blocks/form/submit-button/submit-button.svelte';
|
|
18
|
+
import { componentInfo as imgComponentInfo } from '../blocks/img/component-info.js';
|
|
19
|
+
import { default as Img } from '../blocks/img/img.svelte';
|
|
20
|
+
import { componentInfo as videoComponentInfo } from '../blocks/video/component-info.js';
|
|
21
|
+
import { default as Video } from '../blocks/video/video.svelte';
|
|
22
|
+
import { TARGET } from './target.js';
|
|
23
|
+
export const getExtraComponents = () => [{
|
|
24
|
+
component: customCode,
|
|
25
|
+
...customCodeInfo
|
|
26
|
+
}, {
|
|
27
|
+
component: embed,
|
|
28
|
+
...embedComponentInfo
|
|
29
|
+
}, ...(TARGET === 'rsc' ? [] : [{
|
|
30
|
+
component: Form,
|
|
31
|
+
...formComponentInfo
|
|
32
|
+
}, {
|
|
33
|
+
component: FormInput,
|
|
34
|
+
...formInputComponentInfo
|
|
35
|
+
}, {
|
|
36
|
+
component: FormSubmitButton,
|
|
37
|
+
...formSubmitButtonComponentInfo
|
|
38
|
+
}, {
|
|
39
|
+
component: FormSelect,
|
|
40
|
+
...formSelectComponentInfo
|
|
41
|
+
}]), {
|
|
42
|
+
component: Img,
|
|
43
|
+
...imgComponentInfo
|
|
44
|
+
}, {
|
|
45
|
+
component: Video,
|
|
46
|
+
...videoComponentInfo
|
|
47
|
+
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.13.
|
|
1
|
+
export declare const SDK_VERSION = "0.13.2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.13.
|
|
1
|
+
export const SDK_VERSION = "0.13.2";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const validEnvList = ['production', 'qa', 'test', 'development', 'dev', 'cdn-qa', 'cloud', 'fast', 'cdn2', 'cdn-prod'];
|
|
2
|
+
export const getEnv = () => {
|
|
3
|
+
const env = process.env.NODE_ENV || 'production';
|
|
4
|
+
return validEnvList.includes(env) ? env : 'production';
|
|
5
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const get: (obj: any, path: string, defaultValue?: any) => any;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const get = (obj, path, defaultValue) => {
|
|
2
|
+
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== undefined ? res[key] : res, obj);
|
|
3
|
+
return result === undefined || result === obj ? defaultValue : result;
|
|
4
|
+
};
|