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