@builder.io/sdk-svelte 0.1.4 → 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 +8 -0
- package/package/components/render-block/render-block.helpers.js +1 -1
- package/package/components/render-block/render-block.svelte +18 -1
- 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/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/components/render-block/render-block.helpers.ts +1 -1
- package/src/components/render-block/render-block.svelte +25 -2
- 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/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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script context="module" lang="ts">
|
|
2
2
|
import type {
|
|
3
|
-
BuilderRenderContext,
|
|
4
3
|
BuilderRenderState,
|
|
5
4
|
RegisteredComponent,
|
|
6
5
|
RegisteredComponents,
|
|
@@ -13,31 +12,10 @@
|
|
|
13
12
|
|
|
14
13
|
import type { Nullable } from "../../types/typescript.js";
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
};
|
|
22
|
-
context?: BuilderRenderContext;
|
|
23
|
-
apiKey: string;
|
|
24
|
-
customComponents?: RegisteredComponent[];
|
|
25
|
-
canTrack?: boolean;
|
|
26
|
-
locale?: string;
|
|
27
|
-
includeRefs?: boolean;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
interface BuilderComponentStateChange {
|
|
31
|
-
state: BuilderRenderState;
|
|
32
|
-
ref: {
|
|
33
|
-
name?: string;
|
|
34
|
-
props?: {
|
|
35
|
-
builderBlock?: {
|
|
36
|
-
id?: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
}
|
|
15
|
+
import type {
|
|
16
|
+
RenderContentProps,
|
|
17
|
+
BuilderComponentStateChange,
|
|
18
|
+
} from "./render-content.types.js";
|
|
41
19
|
</script>
|
|
42
20
|
|
|
43
21
|
<script lang="ts">
|
|
@@ -65,35 +43,49 @@
|
|
|
65
43
|
} from "../../scripts/init-editing.js";
|
|
66
44
|
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
67
45
|
import { getInteractionPropertiesForEvent } from "../../functions/track/interaction.js";
|
|
46
|
+
import {
|
|
47
|
+
getContentInitialValue,
|
|
48
|
+
getContextStateInitialValue,
|
|
49
|
+
} from "./render-content.helpers.js";
|
|
68
50
|
|
|
69
51
|
export let content: RenderContentProps["content"];
|
|
70
52
|
export let data: RenderContentProps["data"];
|
|
71
53
|
export let canTrack: RenderContentProps["canTrack"];
|
|
72
54
|
export let locale: RenderContentProps["locale"];
|
|
73
|
-
export let context: RenderContentProps["context"];
|
|
74
55
|
export let customComponents: RenderContentProps["customComponents"];
|
|
75
56
|
export let model: RenderContentProps["model"];
|
|
57
|
+
export let context: RenderContentProps["context"];
|
|
76
58
|
export let apiKey: RenderContentProps["apiKey"];
|
|
77
59
|
export let includeRefs: RenderContentProps["includeRefs"];
|
|
78
60
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
61
|
+
function mergeNewContent(newContent) {
|
|
62
|
+
useContent = {
|
|
63
|
+
...useContent,
|
|
64
|
+
...newContent,
|
|
65
|
+
data: {
|
|
66
|
+
...useContent?.data,
|
|
67
|
+
...newContent?.data,
|
|
68
|
+
},
|
|
69
|
+
meta: {
|
|
70
|
+
...useContent?.meta,
|
|
71
|
+
...newContent?.meta,
|
|
72
|
+
breakpoints:
|
|
73
|
+
newContent?.meta?.breakpoints || useContent?.meta?.breakpoints,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function setBreakpoints(breakpoints) {
|
|
78
|
+
useContent = {
|
|
79
|
+
...useContent,
|
|
80
|
+
meta: {
|
|
81
|
+
...useContent?.meta,
|
|
82
|
+
breakpoints,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function setContextState(newState) {
|
|
87
|
+
contentState = newState;
|
|
88
|
+
}
|
|
97
89
|
function processMessage(event) {
|
|
98
90
|
const { data } = event;
|
|
99
91
|
if (data) {
|
|
@@ -101,10 +93,12 @@
|
|
|
101
93
|
case "builder.configureSdk": {
|
|
102
94
|
const messageContent = data.data;
|
|
103
95
|
const { breakpoints, contentId } = messageContent;
|
|
104
|
-
if (!contentId || contentId !== useContent?.
|
|
96
|
+
if (!contentId || contentId !== useContent?.id) {
|
|
105
97
|
return;
|
|
106
98
|
}
|
|
107
|
-
|
|
99
|
+
if (breakpoints) {
|
|
100
|
+
setBreakpoints(breakpoints);
|
|
101
|
+
}
|
|
108
102
|
forceReRenderCount = forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
|
|
109
103
|
break;
|
|
110
104
|
}
|
|
@@ -117,7 +111,7 @@
|
|
|
117
111
|
messageContent.modelName;
|
|
118
112
|
const contentData = messageContent.data;
|
|
119
113
|
if (key === model) {
|
|
120
|
-
|
|
114
|
+
mergeNewContent(contentData);
|
|
121
115
|
forceReRenderCount = forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
|
|
122
116
|
}
|
|
123
117
|
|
|
@@ -132,19 +126,19 @@
|
|
|
132
126
|
}
|
|
133
127
|
function evaluateJsCode() {
|
|
134
128
|
// run any dynamic JS code attached to content
|
|
135
|
-
const jsCode = useContent?.
|
|
129
|
+
const jsCode = useContent?.data?.jsCode;
|
|
136
130
|
if (jsCode) {
|
|
137
131
|
evaluate({
|
|
138
132
|
code: jsCode,
|
|
139
|
-
context:
|
|
140
|
-
state: contentState
|
|
133
|
+
context: context || {},
|
|
134
|
+
state: contentState,
|
|
141
135
|
});
|
|
142
136
|
}
|
|
143
137
|
}
|
|
144
138
|
function onClick(event) {
|
|
145
|
-
if (useContent
|
|
146
|
-
const variationId = useContent?.
|
|
147
|
-
const contentId = useContent?.
|
|
139
|
+
if (useContent) {
|
|
140
|
+
const variationId = useContent?.testVariationId;
|
|
141
|
+
const contentId = useContent?.id;
|
|
148
142
|
_track({
|
|
149
143
|
type: "click",
|
|
150
144
|
canTrack: canTrackToUse,
|
|
@@ -163,8 +157,8 @@
|
|
|
163
157
|
return expression.replace(/{{([^}]+)}}/g, (_match, group) =>
|
|
164
158
|
evaluate({
|
|
165
159
|
code: group,
|
|
166
|
-
context:
|
|
167
|
-
state: contentState
|
|
160
|
+
context: context || {},
|
|
161
|
+
state: contentState,
|
|
168
162
|
})
|
|
169
163
|
);
|
|
170
164
|
}
|
|
@@ -172,18 +166,18 @@
|
|
|
172
166
|
fetch(url)
|
|
173
167
|
.then((response) => response.json())
|
|
174
168
|
.then((json) => {
|
|
175
|
-
const
|
|
176
|
-
...
|
|
169
|
+
const newState = {
|
|
170
|
+
...contentState,
|
|
177
171
|
[key]: json,
|
|
178
172
|
};
|
|
179
|
-
|
|
173
|
+
setContextState(newState);
|
|
180
174
|
})
|
|
181
175
|
.catch((err) => {
|
|
182
176
|
console.log("error fetching dynamic data", url, err);
|
|
183
177
|
});
|
|
184
178
|
}
|
|
185
179
|
function runHttpRequests() {
|
|
186
|
-
const requests = useContent?.
|
|
180
|
+
const requests = useContent?.data?.httpRequests ?? {};
|
|
187
181
|
Object.entries(requests).forEach(([key, url]) => {
|
|
188
182
|
if (url && (!httpReqsData[key] || isEditing())) {
|
|
189
183
|
const evaluatedUrl = evalExpression(url);
|
|
@@ -199,7 +193,7 @@
|
|
|
199
193
|
window.dispatchEvent(
|
|
200
194
|
new CustomEvent("builder:component:stateChange", {
|
|
201
195
|
detail: {
|
|
202
|
-
state: contentState
|
|
196
|
+
state: contentState,
|
|
203
197
|
ref: {
|
|
204
198
|
name: model,
|
|
205
199
|
},
|
|
@@ -208,44 +202,9 @@
|
|
|
208
202
|
);
|
|
209
203
|
}
|
|
210
204
|
}
|
|
211
|
-
$: useContent = () => {
|
|
212
|
-
if (!content && !overrideContent) {
|
|
213
|
-
return undefined;
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
...content,
|
|
217
|
-
...overrideContent,
|
|
218
|
-
data: {
|
|
219
|
-
...content?.data,
|
|
220
|
-
...data,
|
|
221
|
-
...overrideContent?.data,
|
|
222
|
-
},
|
|
223
|
-
meta: {
|
|
224
|
-
...content?.meta,
|
|
225
|
-
...overrideContent?.meta,
|
|
226
|
-
breakpoints:
|
|
227
|
-
useBreakpoints ||
|
|
228
|
-
overrideContent?.meta?.breakpoints ||
|
|
229
|
-
content?.meta?.breakpoints,
|
|
230
|
-
},
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
|
-
$: contentState = () => {
|
|
234
|
-
return {
|
|
235
|
-
...content?.data?.state,
|
|
236
|
-
...data,
|
|
237
|
-
...(locale
|
|
238
|
-
? {
|
|
239
|
-
locale: locale,
|
|
240
|
-
}
|
|
241
|
-
: {}),
|
|
242
|
-
...overrideState,
|
|
243
|
-
};
|
|
244
|
-
};
|
|
245
205
|
$: shouldRenderContentStyles = () => {
|
|
246
206
|
return Boolean(
|
|
247
|
-
(useContent?.
|
|
248
|
-
useContent?.()?.data?.customFonts?.length) &&
|
|
207
|
+
(useContent?.data?.cssCode || useContent?.data?.customFonts?.length) &&
|
|
249
208
|
TARGET !== "reactNative"
|
|
250
209
|
);
|
|
251
210
|
};
|
|
@@ -254,11 +213,17 @@
|
|
|
254
213
|
|
|
255
214
|
let forceReRenderCount = 0;
|
|
256
215
|
let overrideContent = null;
|
|
216
|
+
let useContent = getContentInitialValue({
|
|
217
|
+
content: content,
|
|
218
|
+
data: data,
|
|
219
|
+
});
|
|
257
220
|
let update = 0;
|
|
258
|
-
let useBreakpoints = null;
|
|
259
221
|
let canTrackToUse = checkIsDefined(canTrack) ? canTrack : true;
|
|
260
|
-
let
|
|
261
|
-
|
|
222
|
+
let contentState = getContextStateInitialValue({
|
|
223
|
+
content: content,
|
|
224
|
+
data: data,
|
|
225
|
+
locale: locale,
|
|
226
|
+
});
|
|
262
227
|
let allRegisteredComponents = [
|
|
263
228
|
...getDefaultRegisteredComponents(),
|
|
264
229
|
// While this `components` object is deprecated, we must maintain support for it.
|
|
@@ -312,9 +277,9 @@
|
|
|
312
277
|
emitStateUpdate
|
|
313
278
|
);
|
|
314
279
|
}
|
|
315
|
-
if (useContent
|
|
316
|
-
const variationId = useContent?.
|
|
317
|
-
const contentId = useContent?.
|
|
280
|
+
if (useContent) {
|
|
281
|
+
const variationId = useContent?.testVariationId;
|
|
282
|
+
const contentId = useContent?.id;
|
|
318
283
|
_track({
|
|
319
284
|
type: "impression",
|
|
320
285
|
canTrack: canTrackToUse,
|
|
@@ -348,7 +313,7 @@
|
|
|
348
313
|
apiKey: apiKey,
|
|
349
314
|
}).then((content) => {
|
|
350
315
|
if (content) {
|
|
351
|
-
|
|
316
|
+
mergeNewContent(content);
|
|
352
317
|
}
|
|
353
318
|
});
|
|
354
319
|
}
|
|
@@ -362,15 +327,36 @@
|
|
|
362
327
|
function onUpdateFn_0() {
|
|
363
328
|
evaluateJsCode();
|
|
364
329
|
}
|
|
365
|
-
$: onUpdateFn_0(...[useContent?.
|
|
330
|
+
$: onUpdateFn_0(...[useContent?.data?.jsCode, contentState]);
|
|
366
331
|
function onUpdateFn_1() {
|
|
367
332
|
runHttpRequests();
|
|
368
333
|
}
|
|
369
|
-
$: onUpdateFn_1(...[useContent?.
|
|
334
|
+
$: onUpdateFn_1(...[useContent?.data?.httpRequests]);
|
|
370
335
|
function onUpdateFn_2() {
|
|
371
336
|
emitStateUpdate();
|
|
372
337
|
}
|
|
373
|
-
$: onUpdateFn_2(...[contentState
|
|
338
|
+
$: onUpdateFn_2(...[contentState]);
|
|
339
|
+
|
|
340
|
+
setContext(builderContext.key, {
|
|
341
|
+
get content() {
|
|
342
|
+
return useContent;
|
|
343
|
+
},
|
|
344
|
+
get state() {
|
|
345
|
+
return contentState;
|
|
346
|
+
},
|
|
347
|
+
get setState() {
|
|
348
|
+
return setContextState;
|
|
349
|
+
},
|
|
350
|
+
get context() {
|
|
351
|
+
return context || {};
|
|
352
|
+
},
|
|
353
|
+
get apiKey() {
|
|
354
|
+
return apiKey;
|
|
355
|
+
},
|
|
356
|
+
get registeredComponents() {
|
|
357
|
+
return allRegisteredComponents;
|
|
358
|
+
},
|
|
359
|
+
});
|
|
374
360
|
|
|
375
361
|
onDestroy(() => {
|
|
376
362
|
if (isBrowser()) {
|
|
@@ -383,24 +369,22 @@
|
|
|
383
369
|
});
|
|
384
370
|
</script>
|
|
385
371
|
|
|
386
|
-
{#if useContent
|
|
372
|
+
{#if useContent}
|
|
387
373
|
<div
|
|
388
374
|
bind:this={elementRef}
|
|
389
375
|
on:click={(event) => {
|
|
390
376
|
onClick(event);
|
|
391
377
|
}}
|
|
392
|
-
builder-content-id={useContent?.
|
|
378
|
+
builder-content-id={useContent?.id}
|
|
393
379
|
builder-model={model}
|
|
394
380
|
>
|
|
395
381
|
{#if shouldRenderContentStyles()}
|
|
396
382
|
<RenderContentStyles
|
|
397
|
-
|
|
398
|
-
|
|
383
|
+
contentId={useContent?.id}
|
|
384
|
+
cssCode={useContent?.data?.cssCode}
|
|
385
|
+
customFonts={useContent?.data?.customFonts}
|
|
399
386
|
/>
|
|
400
387
|
{/if}
|
|
401
|
-
<RenderBlocks
|
|
402
|
-
blocks={useContent?.()?.data?.blocks}
|
|
403
|
-
key={forceReRenderCount}
|
|
404
|
-
/>
|
|
388
|
+
<RenderBlocks blocks={useContent?.data?.blocks} key={forceReRenderCount} />
|
|
405
389
|
</div>
|
|
406
390
|
{/if}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BuilderRenderContext,
|
|
3
|
+
RegisteredComponent,
|
|
4
|
+
BuilderRenderState,
|
|
5
|
+
} from '../../context/types';
|
|
6
|
+
import type { BuilderContent } from '../../types/builder-content';
|
|
7
|
+
import type { Nullable } from '../../types/typescript';
|
|
8
|
+
|
|
9
|
+
export type RenderContentProps = {
|
|
10
|
+
content?: Nullable<BuilderContent>;
|
|
11
|
+
model?: string;
|
|
12
|
+
data?: { [key: string]: any };
|
|
13
|
+
context?: BuilderRenderContext;
|
|
14
|
+
apiKey: string;
|
|
15
|
+
customComponents?: RegisteredComponent[];
|
|
16
|
+
canTrack?: boolean;
|
|
17
|
+
locale?: string;
|
|
18
|
+
includeRefs?: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export interface BuilderComponentStateChange {
|
|
22
|
+
state: BuilderRenderState;
|
|
23
|
+
ref: {
|
|
24
|
+
name?: string;
|
|
25
|
+
props?: {
|
|
26
|
+
builderBlock?: {
|
|
27
|
+
id?: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -28,15 +28,15 @@ import { componentInfo as customCodeInfo } from '../blocks/custom-code/component
|
|
|
28
28
|
*/
|
|
29
29
|
export const getDefaultRegisteredComponents: () => RegisteredComponent[] =
|
|
30
30
|
() => [
|
|
31
|
+
{ component: Button, ...buttonComponentInfo },
|
|
31
32
|
{ component: Columns, ...columnsComponentInfo },
|
|
33
|
+
{ component: customCode, ...customCodeInfo },
|
|
34
|
+
{ component: embed, ...embedComponentInfo },
|
|
35
|
+
{ component: Fragment, ...fragmentComponentInfo },
|
|
32
36
|
{ component: Image, ...imageComponentInfo },
|
|
33
37
|
{ component: Img, ...imgComponentInfo },
|
|
38
|
+
{ component: Section, ...sectionComponentInfo },
|
|
39
|
+
{ component: Symbol, ...symbolComponentInfo },
|
|
34
40
|
{ component: Text, ...textComponentInfo },
|
|
35
41
|
{ component: Video, ...videoComponentInfo },
|
|
36
|
-
{ component: Symbol, ...symbolComponentInfo },
|
|
37
|
-
{ component: Button, ...buttonComponentInfo },
|
|
38
|
-
{ component: Section, ...sectionComponentInfo },
|
|
39
|
-
{ component: Fragment, ...fragmentComponentInfo },
|
|
40
|
-
{ component: embed, ...embedComponentInfo },
|
|
41
|
-
{ component: customCode, ...customCodeInfo },
|
|
42
42
|
];
|
package/src/context/types.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface BuilderContextInterface {
|
|
|
16
16
|
content: Nullable<BuilderContent>;
|
|
17
17
|
context: BuilderRenderContext;
|
|
18
18
|
state: BuilderRenderState;
|
|
19
|
+
setState?: (state: BuilderRenderState) => void;
|
|
19
20
|
apiKey: string | null;
|
|
20
21
|
registeredComponents: RegisteredComponents;
|
|
21
22
|
// Used to recursively store all CSS coming from a parent that would apply to a Text block
|
|
@@ -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';
|
|
@@ -0,0 +1,120 @@
|
|
|
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?:
|
|
82
|
+
| string[]
|
|
83
|
+
| {
|
|
84
|
+
label: string;
|
|
85
|
+
value: any;
|
|
86
|
+
helperText?: string;
|
|
87
|
+
}[];
|
|
88
|
+
/** Regex field validation for all string types (text, longText, html, url, etc) */
|
|
89
|
+
regex?: {
|
|
90
|
+
/** pattern to test, like "^\/[a-z]$" */
|
|
91
|
+
pattern: string;
|
|
92
|
+
/** flags for the RegExp constructor, e.g. "gi" */
|
|
93
|
+
options?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Friendly message to display to end-users if the regex fails, e.g.
|
|
96
|
+
* "You must use a relative url starting with '/...' "
|
|
97
|
+
*/
|
|
98
|
+
message: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Set this to `true` to put this under the "show more" section of
|
|
102
|
+
* the options editor. Useful for things that are more advanced
|
|
103
|
+
* or more rarely used and don't need to be too prominent
|
|
104
|
+
*/
|
|
105
|
+
advanced?: boolean;
|
|
106
|
+
/** @hidden */
|
|
107
|
+
// onChange?: Function | string;
|
|
108
|
+
/** @hidden */
|
|
109
|
+
code?: boolean;
|
|
110
|
+
/** @hidden */
|
|
111
|
+
richText?: boolean;
|
|
112
|
+
/** @hidden */
|
|
113
|
+
showIf?: ((options: Map<string, any>) => boolean) | string;
|
|
114
|
+
/** @hidden */
|
|
115
|
+
copyOnAdd?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Use optionally with inputs of type `reference`. Restricts the content entry picker to a specific model by name.
|
|
118
|
+
*/
|
|
119
|
+
model?: string;
|
|
120
|
+
}
|