@builder.io/sdk-svelte 0.1.3 → 0.1.5
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 +5 -1
- package/package/CHANGELOG.md +15 -2
- package/package/blocks/button/button.svelte +2 -2
- package/package/blocks/form/form.svelte +2 -2
- package/package/blocks/img/img.svelte +2 -2
- package/package/blocks/input/input.svelte +2 -2
- package/package/blocks/section/section.svelte +2 -2
- package/package/blocks/select/select.svelte +2 -2
- package/package/blocks/submit-button/submit-button.svelte +2 -2
- package/package/blocks/symbol/symbol.svelte +2 -2
- package/package/blocks/textarea/textarea.svelte +2 -2
- package/package/blocks/video/video.svelte +2 -2
- package/package/components/render-block/render-block.helpers.js +1 -1
- package/package/components/render-block/render-block.svelte +20 -3
- package/package/components/render-block/render-component.svelte.d.ts +8 -1
- package/package/components/render-block/render-repeated-block.svelte +1 -0
- package/package/components/render-content/components/render-styles.helpers.d.ts +15 -0
- package/package/components/render-content/components/render-styles.helpers.js +59 -0
- package/package/components/render-content/components/render-styles.svelte +12 -54
- package/package/components/render-content/components/render-styles.svelte.d.ts +3 -8
- package/package/components/render-content/render-content.helpers.d.ts +7 -0
- package/package/components/render-content/render-content.helpers.js +30 -0
- package/package/components/render-content/render-content.svelte +90 -87
- package/package/components/render-content/render-content.svelte.d.ts +2 -17
- package/package/components/render-content/render-content.types.d.ts +27 -0
- package/package/components/render-content/render-content.types.js +1 -0
- package/package/components/render-inlined-styles.svelte +1 -1
- package/package/constants/builder-registered-components.js +6 -6
- package/package/context/builder.context.d.ts +1 -0
- package/package/context/builder.context.js +1 -0
- package/package/context/types.d.ts +1 -0
- package/package/index-helpers/blocks-exports.d.ts +6 -6
- package/package/index-helpers/blocks-exports.js +6 -6
- package/package/types/builder-content.d.ts +1 -2
- package/package/types/input.d.ts +117 -0
- package/package/types/input.js +1 -0
- package/package.json +1 -1
- package/src/blocks/button/button.svelte +2 -2
- package/src/blocks/form/form.svelte +2 -2
- package/src/blocks/img/img.svelte +2 -2
- package/src/blocks/input/input.svelte +2 -2
- package/src/blocks/section/section.svelte +2 -2
- package/src/blocks/select/select.svelte +2 -2
- package/src/blocks/submit-button/submit-button.svelte +2 -2
- package/src/blocks/symbol/symbol.svelte +2 -2
- package/src/blocks/textarea/textarea.svelte +2 -2
- package/src/blocks/video/video.svelte +2 -2
- package/src/components/render-block/render-block.helpers.ts +1 -1
- package/src/components/render-block/render-block.svelte +27 -4
- package/src/components/render-block/render-component.svelte +9 -1
- package/src/components/render-block/render-repeated-block.svelte +1 -0
- package/src/components/render-content/components/render-styles.helpers.ts +79 -0
- package/src/components/render-content/components/render-styles.svelte +13 -64
- package/src/components/render-content/render-content.helpers.ts +48 -0
- package/src/components/render-content/render-content.svelte +99 -115
- package/src/components/render-content/render-content.types.ts +31 -0
- package/src/components/render-inlined-styles.svelte +1 -1
- package/src/constants/builder-registered-components.ts +6 -6
- package/src/context/builder.context.ts +1 -0
- package/src/context/types.ts +1 -0
- package/src/index-helpers/blocks-exports.ts +6 -6
- package/src/types/builder-content.ts +1 -3
- package/src/types/input.ts +120 -0
|
@@ -17,32 +17,43 @@ import builderContext from "../../context/builder.context.js";
|
|
|
17
17
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../scripts/init-editing.js";
|
|
18
18
|
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
19
19
|
import { getInteractionPropertiesForEvent } from "../../functions/track/interaction.js";
|
|
20
|
+
import { getContentInitialValue, getContextStateInitialValue, } from "./render-content.helpers.js";
|
|
20
21
|
export let content;
|
|
21
22
|
export let data;
|
|
22
23
|
export let canTrack;
|
|
23
24
|
export let locale;
|
|
24
|
-
export let context;
|
|
25
25
|
export let customComponents;
|
|
26
26
|
export let model;
|
|
27
|
+
export let context;
|
|
27
28
|
export let apiKey;
|
|
28
29
|
export let includeRefs;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
function mergeNewContent(newContent) {
|
|
31
|
+
useContent = {
|
|
32
|
+
...useContent,
|
|
33
|
+
...newContent,
|
|
34
|
+
data: {
|
|
35
|
+
...useContent?.data,
|
|
36
|
+
...newContent?.data,
|
|
37
|
+
},
|
|
38
|
+
meta: {
|
|
39
|
+
...useContent?.meta,
|
|
40
|
+
...newContent?.meta,
|
|
41
|
+
breakpoints: newContent?.meta?.breakpoints || useContent?.meta?.breakpoints,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function setBreakpoints(breakpoints) {
|
|
46
|
+
useContent = {
|
|
47
|
+
...useContent,
|
|
48
|
+
meta: {
|
|
49
|
+
...useContent?.meta,
|
|
50
|
+
breakpoints,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function setContextState(newState) {
|
|
55
|
+
contentState = newState;
|
|
56
|
+
}
|
|
46
57
|
function processMessage(event) {
|
|
47
58
|
const { data } = event;
|
|
48
59
|
if (data) {
|
|
@@ -50,10 +61,12 @@ function processMessage(event) {
|
|
|
50
61
|
case "builder.configureSdk": {
|
|
51
62
|
const messageContent = data.data;
|
|
52
63
|
const { breakpoints, contentId } = messageContent;
|
|
53
|
-
if (!contentId || contentId !== useContent?.
|
|
64
|
+
if (!contentId || contentId !== useContent?.id) {
|
|
54
65
|
return;
|
|
55
66
|
}
|
|
56
|
-
|
|
67
|
+
if (breakpoints) {
|
|
68
|
+
setBreakpoints(breakpoints);
|
|
69
|
+
}
|
|
57
70
|
forceReRenderCount = forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
|
|
58
71
|
break;
|
|
59
72
|
}
|
|
@@ -65,7 +78,7 @@ function processMessage(event) {
|
|
|
65
78
|
messageContent.modelName;
|
|
66
79
|
const contentData = messageContent.data;
|
|
67
80
|
if (key === model) {
|
|
68
|
-
|
|
81
|
+
mergeNewContent(contentData);
|
|
69
82
|
forceReRenderCount = forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
|
|
70
83
|
}
|
|
71
84
|
break;
|
|
@@ -79,19 +92,19 @@ function processMessage(event) {
|
|
|
79
92
|
}
|
|
80
93
|
function evaluateJsCode() {
|
|
81
94
|
// run any dynamic JS code attached to content
|
|
82
|
-
const jsCode = useContent?.
|
|
95
|
+
const jsCode = useContent?.data?.jsCode;
|
|
83
96
|
if (jsCode) {
|
|
84
97
|
evaluate({
|
|
85
98
|
code: jsCode,
|
|
86
|
-
context:
|
|
87
|
-
state: contentState
|
|
99
|
+
context: context || {},
|
|
100
|
+
state: contentState,
|
|
88
101
|
});
|
|
89
102
|
}
|
|
90
103
|
}
|
|
91
104
|
function onClick(event) {
|
|
92
|
-
if (useContent
|
|
93
|
-
const variationId = useContent?.
|
|
94
|
-
const contentId = useContent?.
|
|
105
|
+
if (useContent) {
|
|
106
|
+
const variationId = useContent?.testVariationId;
|
|
107
|
+
const contentId = useContent?.id;
|
|
95
108
|
_track({
|
|
96
109
|
type: "click",
|
|
97
110
|
canTrack: canTrackToUse,
|
|
@@ -109,26 +122,26 @@ function onClick(event) {
|
|
|
109
122
|
function evalExpression(expression) {
|
|
110
123
|
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
111
124
|
code: group,
|
|
112
|
-
context:
|
|
113
|
-
state: contentState
|
|
125
|
+
context: context || {},
|
|
126
|
+
state: contentState,
|
|
114
127
|
}));
|
|
115
128
|
}
|
|
116
129
|
function handleRequest({ url, key }) {
|
|
117
130
|
fetch(url)
|
|
118
131
|
.then((response) => response.json())
|
|
119
132
|
.then((json) => {
|
|
120
|
-
const
|
|
121
|
-
...
|
|
133
|
+
const newState = {
|
|
134
|
+
...contentState,
|
|
122
135
|
[key]: json,
|
|
123
136
|
};
|
|
124
|
-
|
|
137
|
+
setContextState(newState);
|
|
125
138
|
})
|
|
126
139
|
.catch((err) => {
|
|
127
140
|
console.log("error fetching dynamic data", url, err);
|
|
128
141
|
});
|
|
129
142
|
}
|
|
130
143
|
function runHttpRequests() {
|
|
131
|
-
const requests = useContent?.
|
|
144
|
+
const requests = useContent?.data?.httpRequests ?? {};
|
|
132
145
|
Object.entries(requests).forEach(([key, url]) => {
|
|
133
146
|
if (url && (!httpReqsData[key] || isEditing())) {
|
|
134
147
|
const evaluatedUrl = evalExpression(url);
|
|
@@ -143,7 +156,7 @@ function emitStateUpdate() {
|
|
|
143
156
|
if (isEditing()) {
|
|
144
157
|
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
145
158
|
detail: {
|
|
146
|
-
state: contentState
|
|
159
|
+
state: contentState,
|
|
147
160
|
ref: {
|
|
148
161
|
name: model,
|
|
149
162
|
},
|
|
@@ -151,52 +164,24 @@ function emitStateUpdate() {
|
|
|
151
164
|
}));
|
|
152
165
|
}
|
|
153
166
|
}
|
|
154
|
-
$: useContent = () => {
|
|
155
|
-
if (!content && !overrideContent) {
|
|
156
|
-
return undefined;
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
...content,
|
|
160
|
-
...overrideContent,
|
|
161
|
-
data: {
|
|
162
|
-
...content?.data,
|
|
163
|
-
...data,
|
|
164
|
-
...overrideContent?.data,
|
|
165
|
-
},
|
|
166
|
-
meta: {
|
|
167
|
-
...content?.meta,
|
|
168
|
-
...overrideContent?.meta,
|
|
169
|
-
breakpoints: useBreakpoints ||
|
|
170
|
-
overrideContent?.meta?.breakpoints ||
|
|
171
|
-
content?.meta?.breakpoints,
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
$: contentState = () => {
|
|
176
|
-
return {
|
|
177
|
-
...content?.data?.state,
|
|
178
|
-
...data,
|
|
179
|
-
...(locale
|
|
180
|
-
? {
|
|
181
|
-
locale: locale,
|
|
182
|
-
}
|
|
183
|
-
: {}),
|
|
184
|
-
...overrideState,
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
167
|
$: shouldRenderContentStyles = () => {
|
|
188
|
-
return Boolean((useContent?.
|
|
189
|
-
useContent?.()?.data?.customFonts?.length) &&
|
|
168
|
+
return Boolean((useContent?.data?.cssCode || useContent?.data?.customFonts?.length) &&
|
|
190
169
|
TARGET !== "reactNative");
|
|
191
170
|
};
|
|
192
171
|
let elementRef;
|
|
193
172
|
let forceReRenderCount = 0;
|
|
194
173
|
let overrideContent = null;
|
|
174
|
+
let useContent = getContentInitialValue({
|
|
175
|
+
content: content,
|
|
176
|
+
data: data,
|
|
177
|
+
});
|
|
195
178
|
let update = 0;
|
|
196
|
-
let useBreakpoints = null;
|
|
197
179
|
let canTrackToUse = checkIsDefined(canTrack) ? canTrack : true;
|
|
198
|
-
let
|
|
199
|
-
|
|
180
|
+
let contentState = getContextStateInitialValue({
|
|
181
|
+
content: content,
|
|
182
|
+
data: data,
|
|
183
|
+
locale: locale,
|
|
184
|
+
});
|
|
200
185
|
let allRegisteredComponents = [
|
|
201
186
|
...getDefaultRegisteredComponents(),
|
|
202
187
|
// While this `components` object is deprecated, we must maintain support for it.
|
|
@@ -239,9 +224,9 @@ onMount(() => {
|
|
|
239
224
|
window.addEventListener("message", processMessage);
|
|
240
225
|
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
241
226
|
}
|
|
242
|
-
if (useContent
|
|
243
|
-
const variationId = useContent?.
|
|
244
|
-
const contentId = useContent?.
|
|
227
|
+
if (useContent) {
|
|
228
|
+
const variationId = useContent?.testVariationId;
|
|
229
|
+
const contentId = useContent?.id;
|
|
245
230
|
_track({
|
|
246
231
|
type: "impression",
|
|
247
232
|
canTrack: canTrackToUse,
|
|
@@ -272,7 +257,7 @@ onMount(() => {
|
|
|
272
257
|
apiKey: apiKey,
|
|
273
258
|
}).then((content) => {
|
|
274
259
|
if (content) {
|
|
275
|
-
|
|
260
|
+
mergeNewContent(content);
|
|
276
261
|
}
|
|
277
262
|
});
|
|
278
263
|
}
|
|
@@ -285,15 +270,35 @@ onMount(() => {
|
|
|
285
270
|
function onUpdateFn_0() {
|
|
286
271
|
evaluateJsCode();
|
|
287
272
|
}
|
|
288
|
-
$: onUpdateFn_0(...[useContent?.
|
|
273
|
+
$: onUpdateFn_0(...[useContent?.data?.jsCode, contentState]);
|
|
289
274
|
function onUpdateFn_1() {
|
|
290
275
|
runHttpRequests();
|
|
291
276
|
}
|
|
292
|
-
$: onUpdateFn_1(...[useContent?.
|
|
277
|
+
$: onUpdateFn_1(...[useContent?.data?.httpRequests]);
|
|
293
278
|
function onUpdateFn_2() {
|
|
294
279
|
emitStateUpdate();
|
|
295
280
|
}
|
|
296
|
-
$: onUpdateFn_2(...[contentState
|
|
281
|
+
$: onUpdateFn_2(...[contentState]);
|
|
282
|
+
setContext(builderContext.key, {
|
|
283
|
+
get content() {
|
|
284
|
+
return useContent;
|
|
285
|
+
},
|
|
286
|
+
get state() {
|
|
287
|
+
return contentState;
|
|
288
|
+
},
|
|
289
|
+
get setState() {
|
|
290
|
+
return setContextState;
|
|
291
|
+
},
|
|
292
|
+
get context() {
|
|
293
|
+
return context || {};
|
|
294
|
+
},
|
|
295
|
+
get apiKey() {
|
|
296
|
+
return apiKey;
|
|
297
|
+
},
|
|
298
|
+
get registeredComponents() {
|
|
299
|
+
return allRegisteredComponents;
|
|
300
|
+
},
|
|
301
|
+
});
|
|
297
302
|
onDestroy(() => {
|
|
298
303
|
if (isBrowser()) {
|
|
299
304
|
window.removeEventListener("message", processMessage);
|
|
@@ -302,24 +307,22 @@ onDestroy(() => {
|
|
|
302
307
|
});
|
|
303
308
|
</script>
|
|
304
309
|
|
|
305
|
-
{#if useContent
|
|
310
|
+
{#if useContent}
|
|
306
311
|
<div
|
|
307
312
|
bind:this={elementRef}
|
|
308
313
|
on:click={(event) => {
|
|
309
314
|
onClick(event);
|
|
310
315
|
}}
|
|
311
|
-
builder-content-id={useContent?.
|
|
316
|
+
builder-content-id={useContent?.id}
|
|
312
317
|
builder-model={model}
|
|
313
318
|
>
|
|
314
319
|
{#if shouldRenderContentStyles()}
|
|
315
320
|
<RenderContentStyles
|
|
316
|
-
|
|
317
|
-
|
|
321
|
+
contentId={useContent?.id}
|
|
322
|
+
cssCode={useContent?.data?.cssCode}
|
|
323
|
+
customFonts={useContent?.data?.customFonts}
|
|
318
324
|
/>
|
|
319
325
|
{/if}
|
|
320
|
-
<RenderBlocks
|
|
321
|
-
blocks={useContent?.()?.data?.blocks}
|
|
322
|
-
key={forceReRenderCount}
|
|
323
|
-
/>
|
|
326
|
+
<RenderBlocks blocks={useContent?.data?.blocks} key={forceReRenderCount} />
|
|
324
327
|
</div>
|
|
325
328
|
{/if}
|
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type {
|
|
3
|
-
import type { BuilderContent } from "../../types/builder-content.js";
|
|
4
|
-
import type { Nullable } from "../../types/typescript.js";
|
|
5
|
-
export declare type RenderContentProps = {
|
|
6
|
-
content?: Nullable<BuilderContent>;
|
|
7
|
-
model?: string;
|
|
8
|
-
data?: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
11
|
-
context?: BuilderRenderContext;
|
|
12
|
-
apiKey: string;
|
|
13
|
-
customComponents?: RegisteredComponent[];
|
|
14
|
-
canTrack?: boolean;
|
|
15
|
-
locale?: string;
|
|
16
|
-
includeRefs?: boolean;
|
|
17
|
-
};
|
|
2
|
+
import type { RenderContentProps } from "./render-content.types.js";
|
|
18
3
|
declare const __propDef: {
|
|
19
4
|
props: {
|
|
20
5
|
content: RenderContentProps["content"];
|
|
21
6
|
data: RenderContentProps["data"];
|
|
22
7
|
canTrack: RenderContentProps["canTrack"];
|
|
23
8
|
locale: RenderContentProps["locale"];
|
|
24
|
-
context: RenderContentProps["context"];
|
|
25
9
|
customComponents: RenderContentProps["customComponents"];
|
|
26
10
|
model: RenderContentProps["model"];
|
|
11
|
+
context: RenderContentProps["context"];
|
|
27
12
|
apiKey: RenderContentProps["apiKey"];
|
|
28
13
|
includeRefs: RenderContentProps["includeRefs"];
|
|
29
14
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BuilderRenderContext, RegisteredComponent, BuilderRenderState } from '../../context/types';
|
|
2
|
+
import type { BuilderContent } from '../../types/builder-content';
|
|
3
|
+
import type { Nullable } from '../../types/typescript';
|
|
4
|
+
export declare type RenderContentProps = {
|
|
5
|
+
content?: Nullable<BuilderContent>;
|
|
6
|
+
model?: string;
|
|
7
|
+
data?: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
context?: BuilderRenderContext;
|
|
11
|
+
apiKey: string;
|
|
12
|
+
customComponents?: RegisteredComponent[];
|
|
13
|
+
canTrack?: boolean;
|
|
14
|
+
locale?: string;
|
|
15
|
+
includeRefs?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export interface BuilderComponentStateChange {
|
|
18
|
+
state: BuilderRenderState;
|
|
19
|
+
ref: {
|
|
20
|
+
name?: string;
|
|
21
|
+
props?: {
|
|
22
|
+
builderBlock?: {
|
|
23
|
+
id?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -25,15 +25,15 @@ import { componentInfo as customCodeInfo } from '../blocks/custom-code/component
|
|
|
25
25
|
* NOTE: This needs to be a function to work around ESM circular dependencies.
|
|
26
26
|
*/
|
|
27
27
|
export const getDefaultRegisteredComponents = () => [
|
|
28
|
+
{ component: Button, ...buttonComponentInfo },
|
|
28
29
|
{ component: Columns, ...columnsComponentInfo },
|
|
30
|
+
{ component: customCode, ...customCodeInfo },
|
|
31
|
+
{ component: embed, ...embedComponentInfo },
|
|
32
|
+
{ component: Fragment, ...fragmentComponentInfo },
|
|
29
33
|
{ component: Image, ...imageComponentInfo },
|
|
30
34
|
{ component: Img, ...imgComponentInfo },
|
|
35
|
+
{ component: Section, ...sectionComponentInfo },
|
|
36
|
+
{ component: Symbol, ...symbolComponentInfo },
|
|
31
37
|
{ component: Text, ...textComponentInfo },
|
|
32
38
|
{ component: Video, ...videoComponentInfo },
|
|
33
|
-
{ component: Symbol, ...symbolComponentInfo },
|
|
34
|
-
{ component: Button, ...buttonComponentInfo },
|
|
35
|
-
{ component: Section, ...sectionComponentInfo },
|
|
36
|
-
{ component: Fragment, ...fragmentComponentInfo },
|
|
37
|
-
{ component: embed, ...embedComponentInfo },
|
|
38
|
-
{ component: customCode, ...customCodeInfo },
|
|
39
39
|
];
|
|
@@ -11,6 +11,7 @@ export interface BuilderContextInterface {
|
|
|
11
11
|
content: Nullable<BuilderContent>;
|
|
12
12
|
context: BuilderRenderContext;
|
|
13
13
|
state: BuilderRenderState;
|
|
14
|
+
setState?: (state: BuilderRenderState) => void;
|
|
14
15
|
apiKey: string | null;
|
|
15
16
|
registeredComponents: RegisteredComponents;
|
|
16
17
|
inheritedStyles: Record<string, unknown>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
export { default as Button } from '../blocks/button/button.svelte';
|
|
1
2
|
export { default as Columns } from '../blocks/columns/columns.svelte';
|
|
3
|
+
export { default as Fragment } from '../blocks/fragment/fragment.svelte';
|
|
2
4
|
export { default as Image } from '../blocks/image/image.svelte';
|
|
5
|
+
export { default as RenderBlocks } from '../components/render-blocks.svelte';
|
|
6
|
+
export { default as RenderContent } from '../components/render-content/render-content.svelte';
|
|
7
|
+
export { default as Section } from '../blocks/section/section.svelte';
|
|
8
|
+
export { default as Symbol } from '../blocks/symbol/symbol.svelte';
|
|
3
9
|
export { default as Text } from '../blocks/text/text.svelte';
|
|
4
10
|
export { default as Video } from '../blocks/video/video.svelte';
|
|
5
|
-
export { default as Symbol } from '../blocks/symbol/symbol.svelte';
|
|
6
|
-
export { default as Button } from '../blocks/button/button.svelte';
|
|
7
|
-
export { default as Section } from '../blocks/section/section.svelte';
|
|
8
|
-
export { default as Fragment } from '../blocks/fragment/fragment.svelte';
|
|
9
|
-
export { default as RenderContent } from '../components/render-content/render-content.svelte';
|
|
10
|
-
export { default as RenderBlocks } from '../components/render-blocks.svelte';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
export { default as Button } from '../blocks/button/button.svelte';
|
|
1
2
|
export { default as Columns } from '../blocks/columns/columns.svelte';
|
|
3
|
+
export { default as Fragment } from '../blocks/fragment/fragment.svelte';
|
|
2
4
|
export { default as Image } from '../blocks/image/image.svelte';
|
|
5
|
+
export { default as RenderBlocks } from '../components/render-blocks.svelte';
|
|
6
|
+
export { default as RenderContent } from '../components/render-content/render-content.svelte';
|
|
7
|
+
export { default as Section } from '../blocks/section/section.svelte';
|
|
8
|
+
export { default as Symbol } from '../blocks/symbol/symbol.svelte';
|
|
3
9
|
export { default as Text } from '../blocks/text/text.svelte';
|
|
4
10
|
export { default as Video } from '../blocks/video/video.svelte';
|
|
5
|
-
export { default as Symbol } from '../blocks/symbol/symbol.svelte';
|
|
6
|
-
export { default as Button } from '../blocks/button/button.svelte';
|
|
7
|
-
export { default as Section } from '../blocks/section/section.svelte';
|
|
8
|
-
export { default as Fragment } from '../blocks/fragment/fragment.svelte';
|
|
9
|
-
export { default as RenderContent } from '../components/render-content/render-content.svelte';
|
|
10
|
-
export { default as RenderBlocks } from '../components/render-blocks.svelte';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BuilderBlock } from './builder-block.js';
|
|
2
|
+
import type { Input } from './components.js';
|
|
2
3
|
import type { Nullable } from './typescript.js';
|
|
3
|
-
declare type Input = any;
|
|
4
4
|
export interface Breakpoints {
|
|
5
5
|
small: number;
|
|
6
6
|
medium: number;
|
|
@@ -44,4 +44,3 @@ export interface BuilderContent extends BuilderContentVariation {
|
|
|
44
44
|
testVariationId?: string;
|
|
45
45
|
testVariationName?: string;
|
|
46
46
|
}
|
|
47
|
-
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export interface Input {
|
|
2
|
+
/** This is the name of the component prop this input represents */
|
|
3
|
+
name: string;
|
|
4
|
+
/** A friendlier name to show in the UI if the component prop name is not ideal for end users */
|
|
5
|
+
friendlyName?: string;
|
|
6
|
+
/** @hidden @deprecated */
|
|
7
|
+
description?: string;
|
|
8
|
+
/** A default value to use */
|
|
9
|
+
defaultValue?: any;
|
|
10
|
+
/**
|
|
11
|
+
* The type of input to use, such as 'text'
|
|
12
|
+
*
|
|
13
|
+
* See all available inputs [here](https://www.builder.io/c/docs/custom-react-components#input-types)
|
|
14
|
+
* and you can create your own custom input types and associated editor UIs with [plugins](https://www.builder.io/c/docs/extending/plugins)
|
|
15
|
+
*/
|
|
16
|
+
type: string;
|
|
17
|
+
/** Is this input mandatory or not */
|
|
18
|
+
required?: boolean;
|
|
19
|
+
/** @hidden */
|
|
20
|
+
autoFocus?: boolean;
|
|
21
|
+
subFields?: Input[];
|
|
22
|
+
/**
|
|
23
|
+
* Additional text to render in the UI to give guidance on how to use this
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* helperText: 'Be sure to use a proper URL, starting with "https://"'
|
|
28
|
+
* 111
|
|
29
|
+
*/
|
|
30
|
+
helperText?: string;
|
|
31
|
+
/** @hidden */
|
|
32
|
+
allowedFileTypes?: string[];
|
|
33
|
+
/** @hidden */
|
|
34
|
+
imageHeight?: number;
|
|
35
|
+
/** @hidden */
|
|
36
|
+
imageWidth?: number;
|
|
37
|
+
/** @hidden */
|
|
38
|
+
mediaHeight?: number;
|
|
39
|
+
/** @hidden */
|
|
40
|
+
mediaWidth?: number;
|
|
41
|
+
/** @hidden */
|
|
42
|
+
hideFromUI?: boolean;
|
|
43
|
+
/** @hidden */
|
|
44
|
+
modelId?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Number field type validation maximum accepted input
|
|
47
|
+
*/
|
|
48
|
+
max?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Number field type validation minimum accepted input
|
|
51
|
+
*/
|
|
52
|
+
min?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Number field type step size when using arrows
|
|
55
|
+
*/
|
|
56
|
+
step?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Set this to `true` to show the editor for this input when
|
|
59
|
+
* children of this component are selected. This is useful for things
|
|
60
|
+
* like Tabs, such that users may not always select the Tabs component
|
|
61
|
+
* directly but will still be looking for how to add additional tabs
|
|
62
|
+
*/
|
|
63
|
+
broadcast?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Set this to `true` to show the editor for this input when
|
|
66
|
+
* group locked parents of this component are selected. This is useful
|
|
67
|
+
* to bubble up important inputs for locked groups, like text and images
|
|
68
|
+
*/
|
|
69
|
+
bubble?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Set this to `true` if you want this component to be translatable
|
|
72
|
+
*/
|
|
73
|
+
localized?: boolean;
|
|
74
|
+
/** @hidden */
|
|
75
|
+
options?: {
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* For "text" input type, specifying an enum will show a dropdown of options instead
|
|
80
|
+
*/
|
|
81
|
+
enum?: string[] | {
|
|
82
|
+
label: string;
|
|
83
|
+
value: any;
|
|
84
|
+
helperText?: string;
|
|
85
|
+
}[];
|
|
86
|
+
/** Regex field validation for all string types (text, longText, html, url, etc) */
|
|
87
|
+
regex?: {
|
|
88
|
+
/** pattern to test, like "^\/[a-z]$" */
|
|
89
|
+
pattern: string;
|
|
90
|
+
/** flags for the RegExp constructor, e.g. "gi" */
|
|
91
|
+
options?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Friendly message to display to end-users if the regex fails, e.g.
|
|
94
|
+
* "You must use a relative url starting with '/...' "
|
|
95
|
+
*/
|
|
96
|
+
message: string;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Set this to `true` to put this under the "show more" section of
|
|
100
|
+
* the options editor. Useful for things that are more advanced
|
|
101
|
+
* or more rarely used and don't need to be too prominent
|
|
102
|
+
*/
|
|
103
|
+
advanced?: boolean;
|
|
104
|
+
/** @hidden */
|
|
105
|
+
/** @hidden */
|
|
106
|
+
code?: boolean;
|
|
107
|
+
/** @hidden */
|
|
108
|
+
richText?: boolean;
|
|
109
|
+
/** @hidden */
|
|
110
|
+
showIf?: ((options: Map<string, any>) => boolean) | string;
|
|
111
|
+
/** @hidden */
|
|
112
|
+
copyOnAdd?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Use optionally with inputs of type `reference`. Restricts the content entry picker to a specific model by name.
|
|
115
|
+
*/
|
|
116
|
+
model?: string;
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
});
|
|
20
20
|
return validAttr;
|
|
21
21
|
};
|
|
22
|
-
const setAttrs = (node, attrs) => {
|
|
22
|
+
const setAttrs = (node, attrs = {}) => {
|
|
23
23
|
const attrKeys = Object.keys(attrs);
|
|
24
24
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
25
25
|
const teardown = (attr) =>
|
|
26
26
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
27
27
|
attrKeys.map(setup);
|
|
28
28
|
return {
|
|
29
|
-
update(attrs) {
|
|
29
|
+
update(attrs = {}) {
|
|
30
30
|
const attrKeys = Object.keys(attrs);
|
|
31
31
|
attrKeys.map(teardown);
|
|
32
32
|
attrKeys.map(setup);
|
|
@@ -75,14 +75,14 @@
|
|
|
75
75
|
});
|
|
76
76
|
return validAttr;
|
|
77
77
|
};
|
|
78
|
-
const setAttrs = (node, attrs) => {
|
|
78
|
+
const setAttrs = (node, attrs = {}) => {
|
|
79
79
|
const attrKeys = Object.keys(attrs);
|
|
80
80
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
81
81
|
const teardown = (attr) =>
|
|
82
82
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
83
83
|
attrKeys.map(setup);
|
|
84
84
|
return {
|
|
85
|
-
update(attrs) {
|
|
85
|
+
update(attrs = {}) {
|
|
86
86
|
const attrKeys = Object.keys(attrs);
|
|
87
87
|
attrKeys.map(teardown);
|
|
88
88
|
attrKeys.map(setup);
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
});
|
|
33
33
|
return validAttr;
|
|
34
34
|
};
|
|
35
|
-
const setAttrs = (node, attrs) => {
|
|
35
|
+
const setAttrs = (node, attrs = {}) => {
|
|
36
36
|
const attrKeys = Object.keys(attrs);
|
|
37
37
|
const setup = (attr) => node.addEventListener(attr.substr(3), attrs[attr]);
|
|
38
38
|
const teardown = (attr) =>
|
|
39
39
|
node.removeEventListener(attr.substr(3), attrs[attr]);
|
|
40
40
|
attrKeys.map(setup);
|
|
41
41
|
return {
|
|
42
|
-
update(attrs) {
|
|
42
|
+
update(attrs = {}) {
|
|
43
43
|
const attrKeys = Object.keys(attrs);
|
|
44
44
|
attrKeys.map(teardown);
|
|
45
45
|
attrKeys.map(setup);
|