-
Notifications
You must be signed in to change notification settings - Fork 1
/
data.ts
66 lines (52 loc) · 1.69 KB
/
data.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
export type ChoicesLayoutTypes = 'vertical' | 'horizontal' | 'two_column' | 'three_column'
export interface SerializedOption {
id: string
value: string
}
export interface SerializedElement {
type: string
id: string
control: string
className?: string
attributes?: Array<SerializedOption>
}
export interface SerializedInputElement extends SerializedElement {
type: string
label: string
name: string
classNames: {
wrapper: string
label: string
input: string
}
choicesLayout?: ChoicesLayoutTypes,
options: Array<SerializedOption>
}
export interface SerializedTextElement extends SerializedElement {
tag: string
text: string
}
export type ElementSerialization =
| SerializedForm
| SerializedElement
| SerializedContainer
| SerializedTextElement
| SerializedInputElement
export interface SerializedContainer extends SerializedElement {
direction: string // 'row' | 'column'
children: Array<ElementSerialization>
}
export interface SerializedForm extends SerializedContainer {
}
export function isSerializedInput(
toBeDetermined: SerializedElement
): toBeDetermined is SerializedInputElement { return (toBeDetermined.type === 'INPUT') }
export function isSerializedContainer(
toBeDetermined: SerializedElement
): toBeDetermined is SerializedContainer { return (toBeDetermined.type === 'CONTAINER') }
export function isSerializedText(
toBeDetermined: SerializedElement
): toBeDetermined is SerializedTextElement { return (toBeDetermined.type === 'TEXT') }
export function isSerializedForm(
toBeDetermined: any
): toBeDetermined is SerializedForm { return (toBeDetermined.type === 'FORM') }