@dev-crew-berlin/enter-js-utils 0.5.3 → 0.5.6
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/dist/api-client/api-base.js +160 -287
- package/dist/api-client/index.js +73 -190
- package/dist/lib/api-result.js +9 -13
- package/dist/lib/class-names.js +2 -12
- package/dist/lib/index.js +1 -2
- package/dist/lib/not-undefined.js +2 -3
- package/dist/lib/result.js +27 -23
- package/dist/lib/theme.js +17 -18
- package/dist/models/_helpers.js +64 -65
- package/dist/models/access-token.js +9 -6
- package/dist/models/attendee.js +109 -100
- package/dist/models/checkin-counts.js +7 -3
- package/dist/models/checkins.js +61 -69
- package/dist/models/event.js +1 -2
- package/dist/models/field-group.js +43 -43
- package/dist/models/field-value.js +1 -2
- package/dist/models/field.js +86 -41
- package/dist/models/index.js +1 -2
- package/dist/models/instance.js +109 -99
- package/dist/models/invite.js +18 -15
- package/dist/models/meta-field.js +8 -7
- package/dist/models/user.js +10 -9
- package/dist/models/variable.js +15 -14
- package/dist/ui/button.js +15 -29
- package/dist/ui/button.stories.js +17 -27
- package/dist/ui/checkin-count-indicator.js +67 -46
- package/dist/ui/checkin-count-indicator.stories.js +45 -47
- package/dist/ui/companion-info.js +14 -14
- package/dist/ui/companion-info.stories.js +59 -50
- package/dist/ui/fonts.js +6 -4
- package/dist/ui/guest-card.js +39 -30
- package/dist/ui/guest-card.stories.js +115 -104
- package/dist/ui/index.js +1 -2
- package/dist/ui/tag.js +9 -6
- package/package.json +7 -34
- package/dist/api-client/api-base.js.map +0 -1
- package/dist/api-client/index.js.map +0 -1
- package/dist/lib/api-result.js.map +0 -1
- package/dist/lib/class-names.js.map +0 -1
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/not-undefined.js.map +0 -1
- package/dist/lib/result.js.map +0 -1
- package/dist/lib/theme.js.map +0 -1
- package/dist/models/_helpers.js.map +0 -1
- package/dist/models/access-token.js.map +0 -1
- package/dist/models/attendee.js.map +0 -1
- package/dist/models/checkin-counts.js.map +0 -1
- package/dist/models/checkins.js.map +0 -1
- package/dist/models/event.js.map +0 -1
- package/dist/models/field-group.js.map +0 -1
- package/dist/models/field-value.js.map +0 -1
- package/dist/models/field.js.map +0 -1
- package/dist/models/index.js.map +0 -1
- package/dist/models/instance.js.map +0 -1
- package/dist/models/invite.js.map +0 -1
- package/dist/models/meta-field.js.map +0 -1
- package/dist/models/user.js.map +0 -1
- package/dist/models/variable.js.map +0 -1
- package/dist/ui/button.js.map +0 -1
- package/dist/ui/button.stories.js.map +0 -1
- package/dist/ui/checkin-count-indicator.js.map +0 -1
- package/dist/ui/checkin-count-indicator.stories.js.map +0 -1
- package/dist/ui/companion-info.js.map +0 -1
- package/dist/ui/companion-info.stories.js.map +0 -1
- package/dist/ui/fonts.js.map +0 -1
- package/dist/ui/guest-card.js.map +0 -1
- package/dist/ui/guest-card.stories.js.map +0 -1
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/tag.js.map +0 -1
package/dist/models/attendee.js
CHANGED
|
@@ -1,105 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { array, boolean, defaultTo, enumerate, number, object, parseDate, pipe, string, union, } from 'fefe';
|
|
1
|
+
import { array, boolean, defaultTo, enumerate, number, object, parseDate, pipe, string, union } from 'fefe';
|
|
13
2
|
import { apiValidator, success } from '../lib';
|
|
14
3
|
import { Checkins, checkins } from './checkins';
|
|
15
4
|
import { rawFieldValue } from './field-value';
|
|
16
5
|
import { toString, maybe, dictionary, constant } from './_helpers';
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
6
|
+
export class Attendee {
|
|
7
|
+
constructor(rawAttendee) {
|
|
8
|
+
this.id = rawAttendee.id;
|
|
9
|
+
this.auth = rawAttendee.auth;
|
|
10
|
+
this.userdata = rawAttendee.userdata;
|
|
11
|
+
this.metadata = rawAttendee.metadata;
|
|
12
|
+
this.tags = rawAttendee.tags;
|
|
13
|
+
this.language = rawAttendee.language;
|
|
14
|
+
this.time = rawAttendee.time;
|
|
15
|
+
this.rsvp = rawAttendee.rsvp;
|
|
16
|
+
this.checkin = rawAttendee.checkin;
|
|
17
|
+
this.companions = rawAttendee.companions;
|
|
18
|
+
this.payment = rawAttendee.payment;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getRsvpCountForTag(checkinTag) {
|
|
22
|
+
const rsvp = this.rsvp[checkinTag];
|
|
23
|
+
if (!rsvp) return 0;
|
|
24
|
+
return rsvp;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getResponseForTag(checkinTag) {
|
|
28
|
+
const rsvp = this.rsvp[checkinTag] ?? null;
|
|
29
|
+
if (rsvp === null) return 'no-response';
|
|
30
|
+
return rsvp > 0 ? 'positive-response' : 'negative-repsone';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getCheckinsForTag(checkinTag) {
|
|
34
|
+
return this.checkin[checkinTag] ?? new Checkins({
|
|
35
|
+
checkins: [],
|
|
36
|
+
deleted: []
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getCheckinCountForTag(checkinTag) {
|
|
41
|
+
const checkins = this.checkin[checkinTag];
|
|
42
|
+
if (!checkins) return 0;
|
|
43
|
+
return checkins.getAllCheckins().length;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
addCheckinForTag(args) {
|
|
47
|
+
const exsitingCheckins = this.getCheckinsForTag(args.checkinTag);
|
|
48
|
+
const newCheckins = new Checkins({
|
|
49
|
+
checkins: [args.checkin],
|
|
50
|
+
deleted: []
|
|
51
|
+
});
|
|
52
|
+
const mergedCheckins = exsitingCheckins.merge(newCheckins);
|
|
53
|
+
return new Attendee({ ...this,
|
|
54
|
+
checkin: { ...this.checkin,
|
|
55
|
+
[args.checkinTag]: mergedCheckins
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
deleteCheckinForTag(args) {
|
|
61
|
+
const exsitingCheckins = this.getCheckinsForTag(args.checkinTag);
|
|
62
|
+
const deletedCheckins = new Checkins({
|
|
63
|
+
checkins: [],
|
|
64
|
+
deleted: [args.checkinId]
|
|
65
|
+
});
|
|
66
|
+
const mergedCheckins = exsitingCheckins.merge(deletedCheckins);
|
|
67
|
+
return new Attendee({ ...this,
|
|
68
|
+
checkin: { ...this.checkin,
|
|
69
|
+
[args.checkinTag]: mergedCheckins
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
export const rawAttendee = object({
|
|
76
|
+
id: string(),
|
|
77
|
+
auth: maybe(string()),
|
|
78
|
+
userdata: dictionary(rawFieldValue),
|
|
79
|
+
metadata: dictionary(toString),
|
|
80
|
+
tags: maybe(array(string())),
|
|
81
|
+
language: maybe(string()),
|
|
82
|
+
time: pipe(string()).pipe(parseDate({
|
|
83
|
+
iso: true
|
|
84
|
+
})),
|
|
85
|
+
rsvp: dictionary(maybe(number())),
|
|
86
|
+
checkin: dictionary(checkins),
|
|
87
|
+
companions: union(object({
|
|
88
|
+
isCompanion: constant(false)
|
|
89
|
+
}), object({
|
|
90
|
+
isCompanion: constant(true),
|
|
91
|
+
mainGuestId: string()
|
|
92
|
+
})),
|
|
93
|
+
payment: defaultTo(maybe(object({
|
|
94
|
+
paid: boolean(),
|
|
95
|
+
provider: enumerate('credit', 'paypal'),
|
|
96
|
+
amount: number({
|
|
97
|
+
integer: true
|
|
98
|
+
}),
|
|
99
|
+
testmode: boolean()
|
|
100
|
+
})), null)
|
|
101
|
+
}, {
|
|
102
|
+
allowExcessProperties: true
|
|
103
|
+
});
|
|
104
|
+
const rawAttendeeList = array(rawAttendee);
|
|
105
|
+
export const parseAttendee = value => {
|
|
106
|
+
const result = apiValidator(rawAttendee)(value);
|
|
107
|
+
if (!result.success) return result;
|
|
108
|
+
return success(new Attendee(result.data));
|
|
104
109
|
};
|
|
105
|
-
|
|
110
|
+
export const parseAttendeeList = value => {
|
|
111
|
+
const result = apiValidator(rawAttendeeList)(value);
|
|
112
|
+
if (!result.success) return result;
|
|
113
|
+
return success(result.data.map(rawAttendee => new Attendee(rawAttendee)));
|
|
114
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { number, object } from 'fefe';
|
|
2
2
|
import { apiValidator } from '../lib';
|
|
3
3
|
import { dictionary } from './_helpers';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export const checkinCounts = dictionary(object({
|
|
5
|
+
checkins: number(),
|
|
6
|
+
rsvp: number()
|
|
7
|
+
}, {
|
|
8
|
+
allowExcessProperties: true
|
|
9
|
+
}));
|
|
10
|
+
export const parseCheckinCounts = apiValidator(checkinCounts);
|
package/dist/models/checkins.js
CHANGED
|
@@ -1,71 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
|
-
import { array, boolean, isFailure, object, parseDate, pipe, string, success as fefeSuccess, } from 'fefe';
|
|
1
|
+
import { array, boolean, isFailure, object, parseDate, pipe, string, success as fefeSuccess } from 'fefe';
|
|
11
2
|
import { notUndefined } from '../lib';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
3
|
+
export class Checkins {
|
|
4
|
+
constructor(rawCheckins) {
|
|
5
|
+
this.checkins = rawCheckins.checkins;
|
|
6
|
+
this.deleted = rawCheckins.deleted;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
toJSON() {
|
|
10
|
+
return {
|
|
11
|
+
checkins: this.checkins.map(checkin => ({
|
|
12
|
+
id: checkin.id,
|
|
13
|
+
time: checkin.time.toISOString(),
|
|
14
|
+
main: checkin.main
|
|
15
|
+
})),
|
|
16
|
+
deleted: this.deleted
|
|
26
17
|
};
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getAllCheckins() {
|
|
21
|
+
const mainAndOthers = [this.getMainCheckin(), ...this.getOtherCheckins()];
|
|
22
|
+
return mainAndOthers.filter(notUndefined);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getOtherCheckins() {
|
|
26
|
+
return this.checkins.filter(c => c.main === false && !this.deleted.includes(c.id));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getMainCheckin() {
|
|
30
|
+
const nonDeletedCheckins = this.checkins.filter(checkin => checkin.main === true && !this.deleted.includes(checkin.id)).sort((a, b) => a.time.getTime() - b.time.getTime());
|
|
31
|
+
return nonDeletedCheckins[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
merge(otherCheckin) {
|
|
35
|
+
const checkins = new Map([...this.checkins, ...otherCheckin.checkins].map(checkin => [checkin.id, checkin])).values();
|
|
36
|
+
const deleted = new Set([...this.deleted, ...otherCheckin.deleted]);
|
|
37
|
+
return new Checkins({
|
|
38
|
+
checkins: Array.from(checkins),
|
|
39
|
+
deleted: Array.from(deleted)
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
export const checkin = object({
|
|
45
|
+
id: string(),
|
|
46
|
+
time: pipe(string()).pipe(parseDate({
|
|
47
|
+
iso: true
|
|
48
|
+
})),
|
|
49
|
+
main: boolean()
|
|
50
|
+
}, {
|
|
51
|
+
allowExcessProperties: true
|
|
52
|
+
});
|
|
53
|
+
const rawCheckins = object({
|
|
54
|
+
checkins: array(checkin),
|
|
55
|
+
deleted: array(string())
|
|
56
|
+
}, {
|
|
57
|
+
allowExcessProperties: true
|
|
58
|
+
});
|
|
59
|
+
export const checkins = value => {
|
|
60
|
+
const result = rawCheckins(value);
|
|
61
|
+
if (isFailure(result)) return result;
|
|
62
|
+
return fefeSuccess(new Checkins(result.right));
|
|
63
|
+
};
|
package/dist/models/event.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=event.js.map
|
|
1
|
+
export {};
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { array, object, string, optional, union
|
|
1
|
+
import { array, object, string, optional, union } from 'fefe';
|
|
2
2
|
import { apiValidator, success } from '../lib';
|
|
3
3
|
import { field } from './field';
|
|
4
4
|
import { dictionary } from './_helpers';
|
|
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
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
5
|
+
export class FieldGroups {
|
|
6
|
+
constructor(rawFieldGroupList) {
|
|
7
|
+
this.groups = rawFieldGroupList;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
toJSON() {
|
|
11
|
+
return this.groups;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getFieldLabels() {
|
|
15
|
+
return this.groups.reduce((labels, group) => {
|
|
16
|
+
return group.questions.reduce((labels, question) => {
|
|
17
|
+
labels[question.name] = question.title;
|
|
18
|
+
return labels;
|
|
19
|
+
}, labels);
|
|
20
|
+
}, {});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getLabelForField(fieldKey, language) {
|
|
24
|
+
const fieldLabel = this.getFieldLabels()[fieldKey];
|
|
25
|
+
const translatedLabel = fieldLabel === null || typeof fieldLabel === 'string' ? fieldLabel : fieldLabel[language];
|
|
26
|
+
return translatedLabel ?? fieldKey;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
export const fieldGroup = object({
|
|
31
|
+
title: optional(union(string(), dictionary(string()))),
|
|
32
|
+
class: optional(string()),
|
|
33
|
+
questions: array(field),
|
|
34
|
+
info: optional(union(string(), dictionary(string()))),
|
|
35
|
+
if: optional(string())
|
|
36
|
+
}, {
|
|
37
|
+
allowExcessProperties: true
|
|
38
|
+
});
|
|
39
|
+
const rawFieldGroupList = array(fieldGroup);
|
|
40
|
+
export const parseFieldGroup = apiValidator(fieldGroup);
|
|
41
|
+
export const parseRawFieldGroupList = apiValidator(rawFieldGroupList);
|
|
40
42
|
// export const fieldGroups = (value: unknown): FefeResult<FieldGroups> => {
|
|
41
43
|
// const result = rawFieldGroupList(value)
|
|
42
44
|
// if (isFailure(result)) return result
|
|
43
45
|
// return fefeSuccess(new FieldGroups(result.right))
|
|
44
46
|
// }
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=field-group.js.map
|
|
47
|
+
export const parseFieldGroups = value => {
|
|
48
|
+
const result = apiValidator(rawFieldGroupList)(value);
|
|
49
|
+
if (!result.success) return result;
|
|
50
|
+
return success(new FieldGroups(result.data));
|
|
51
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { array, number, string, union } from 'fefe';
|
|
2
2
|
import { maybe } from './_helpers';
|
|
3
|
-
export
|
|
4
|
-
//# sourceMappingURL=field-value.js.map
|
|
3
|
+
export const rawFieldValue = maybe(union(string(), number(), array(string())));
|
package/dist/models/field.js
CHANGED
|
@@ -1,44 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { array, object, string, optional, enumerate, boolean, defaultTo, union, number, } from 'fefe';
|
|
1
|
+
import { array, object, string, optional, enumerate, boolean, defaultTo, union, number } from 'fefe';
|
|
13
2
|
import { apiValidator } from '../lib';
|
|
14
3
|
import { dictionary, maybe } from './_helpers';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
const basicFieldProps = {
|
|
5
|
+
name: string({
|
|
6
|
+
minLength: 1
|
|
7
|
+
}),
|
|
8
|
+
title: maybe(union(string(), dictionary(string()))),
|
|
9
|
+
info: maybe(union(string(), dictionary(string()))),
|
|
10
|
+
required: defaultTo(boolean(), false),
|
|
11
|
+
if: maybe(string()),
|
|
12
|
+
class: maybe(string())
|
|
22
13
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
14
|
+
const staticField = object({
|
|
15
|
+
type: enumerate('static'),
|
|
16
|
+
...basicFieldProps
|
|
17
|
+
}, {
|
|
18
|
+
allowExcessProperties: true
|
|
19
|
+
});
|
|
20
|
+
const textField = object({
|
|
21
|
+
type: enumerate('text'),
|
|
22
|
+
...basicFieldProps
|
|
23
|
+
}, {
|
|
24
|
+
allowExcessProperties: true
|
|
25
|
+
});
|
|
26
|
+
const longtextField = object({
|
|
27
|
+
type: enumerate('longtext'),
|
|
28
|
+
...basicFieldProps
|
|
29
|
+
}, {
|
|
30
|
+
allowExcessProperties: true
|
|
31
|
+
});
|
|
32
|
+
const emailField = object({
|
|
33
|
+
type: enumerate('email'),
|
|
34
|
+
...basicFieldProps
|
|
35
|
+
}, {
|
|
36
|
+
allowExcessProperties: true
|
|
37
|
+
});
|
|
38
|
+
const numberField = object({
|
|
39
|
+
type: enumerate('number'),
|
|
40
|
+
...basicFieldProps
|
|
41
|
+
}, {
|
|
42
|
+
allowExcessProperties: true
|
|
43
|
+
});
|
|
44
|
+
const checkboxField = object({
|
|
45
|
+
type: enumerate('check'),
|
|
46
|
+
...basicFieldProps,
|
|
47
|
+
items: array(object({
|
|
48
|
+
name: union(string(), dictionary(string())),
|
|
49
|
+
value: optional(string())
|
|
50
|
+
}))
|
|
51
|
+
}, {
|
|
52
|
+
allowExcessProperties: true
|
|
53
|
+
});
|
|
54
|
+
const singleCheckboxField = object({
|
|
55
|
+
type: enumerate('checkbox'),
|
|
56
|
+
...basicFieldProps,
|
|
57
|
+
value: defaultTo(number(), 0)
|
|
58
|
+
}, {
|
|
59
|
+
allowExcessProperties: true
|
|
60
|
+
});
|
|
61
|
+
const radioField = object({
|
|
62
|
+
type: enumerate('radio'),
|
|
63
|
+
...basicFieldProps,
|
|
64
|
+
items: array(object({
|
|
65
|
+
name: union(string(), dictionary(string())),
|
|
66
|
+
value: optional(string())
|
|
67
|
+
}))
|
|
68
|
+
}, {
|
|
69
|
+
allowExcessProperties: true
|
|
70
|
+
});
|
|
71
|
+
const singleRadioField = object({
|
|
72
|
+
type: enumerate('radiobutton'),
|
|
73
|
+
...basicFieldProps,
|
|
74
|
+
itemval: optional(string())
|
|
75
|
+
}, {
|
|
76
|
+
allowExcessProperties: true
|
|
77
|
+
});
|
|
78
|
+
const selectField = object({
|
|
79
|
+
type: enumerate('dropdown'),
|
|
80
|
+
...basicFieldProps,
|
|
81
|
+
items: array(object({
|
|
82
|
+
name: union(string(), dictionary(string())),
|
|
83
|
+
value: optional(string())
|
|
84
|
+
}))
|
|
85
|
+
}, {
|
|
86
|
+
allowExcessProperties: true
|
|
87
|
+
});
|
|
88
|
+
export const field = union(staticField, textField, longtextField, emailField, numberField, checkboxField, singleCheckboxField, radioField, singleRadioField, selectField);
|
|
89
|
+
export const parseField = apiValidator(field);
|
package/dist/models/index.js
CHANGED