@dev-crew-berlin/enter-js-utils 0.5.0 → 0.5.4
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 +8 -0
- package/dist/ui/guest-card.js +40 -31
- package/dist/ui/guest-card.stories.js +115 -104
- package/dist/ui/index.js +5 -1
- package/dist/ui/tag.js +9 -7
- package/package.json +7 -34
- package/dist/api-client/api-base.d.ts +0 -30
- package/dist/api-client/api-base.js.map +0 -1
- package/dist/api-client/index.d.ts +0 -75
- package/dist/api-client/index.js.map +0 -1
- package/dist/lib/api-result.d.ts +0 -25
- package/dist/lib/api-result.js.map +0 -1
- package/dist/lib/class-names.d.ts +0 -1
- package/dist/lib/class-names.js.map +0 -1
- package/dist/lib/index.d.ts +0 -5
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/not-undefined.d.ts +0 -1
- package/dist/lib/not-undefined.js.map +0 -1
- package/dist/lib/result.d.ts +0 -33
- package/dist/lib/result.js.map +0 -1
- package/dist/lib/theme.d.ts +0 -18
- package/dist/lib/theme.js.map +0 -1
- package/dist/models/_helpers.d.ts +0 -23
- package/dist/models/_helpers.js.map +0 -1
- package/dist/models/access-token.d.ts +0 -11
- package/dist/models/access-token.js.map +0 -1
- package/dist/models/attendee.d.ts +0 -90
- package/dist/models/attendee.js.map +0 -1
- package/dist/models/checkin-counts.d.ts +0 -10
- package/dist/models/checkin-counts.js.map +0 -1
- package/dist/models/checkins.d.ts +0 -40
- package/dist/models/checkins.js.map +0 -1
- package/dist/models/event.d.ts +0 -40
- package/dist/models/event.js.map +0 -1
- package/dist/models/field-group.d.ts +0 -484
- package/dist/models/field-group.js.map +0 -1
- package/dist/models/field-value.d.ts +0 -2
- package/dist/models/field-value.js.map +0 -1
- package/dist/models/field.d.ts +0 -321
- package/dist/models/field.js.map +0 -1
- package/dist/models/index.d.ts +0 -14
- package/dist/models/index.js.map +0 -1
- package/dist/models/instance.d.ts +0 -78
- package/dist/models/instance.js.map +0 -1
- package/dist/models/invite.d.ts +0 -33
- package/dist/models/invite.js.map +0 -1
- package/dist/models/meta-field.d.ts +0 -7
- package/dist/models/meta-field.js.map +0 -1
- package/dist/models/user.d.ts +0 -18
- package/dist/models/user.js.map +0 -1
- package/dist/models/variable.d.ts +0 -27
- package/dist/models/variable.js.map +0 -1
- package/dist/ui/button.d.ts +0 -7
- package/dist/ui/button.js.map +0 -1
- package/dist/ui/button.stories.d.ts +0 -18
- package/dist/ui/button.stories.js.map +0 -1
- package/dist/ui/checkin-count-indicator.d.ts +0 -15
- package/dist/ui/checkin-count-indicator.js.map +0 -1
- package/dist/ui/checkin-count-indicator.stories.d.ts +0 -84
- package/dist/ui/checkin-count-indicator.stories.js.map +0 -1
- package/dist/ui/companion-info.d.ts +0 -15
- package/dist/ui/companion-info.js.map +0 -1
- package/dist/ui/companion-info.stories.d.ts +0 -44
- package/dist/ui/companion-info.stories.js.map +0 -1
- package/dist/ui/guest-card.d.ts +0 -16
- package/dist/ui/guest-card.js.map +0 -1
- package/dist/ui/guest-card.stories.d.ts +0 -92
- package/dist/ui/guest-card.stories.js.map +0 -1
- package/dist/ui/index.d.ts +0 -1
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/tag.d.ts +0 -7
- package/dist/ui/tag.js.map +0 -1
package/dist/models/instance.js
CHANGED
|
@@ -1,104 +1,114 @@
|
|
|
1
|
-
import { array, boolean, object, parseDate, pipe, string, defaultTo
|
|
1
|
+
import { array, boolean, object, parseDate, pipe, string, defaultTo } from 'fefe';
|
|
2
2
|
import { apiValidator, success } from '../lib';
|
|
3
3
|
import { metaField } from './meta-field';
|
|
4
4
|
import { dictionary, maybe } 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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
Instance.prototype.isRegistrationClosed = function () {
|
|
38
|
-
var _a = this.registration, closed = _a.closed, start = _a.start, end = _a.end;
|
|
39
|
-
if (closed)
|
|
40
|
-
return true;
|
|
41
|
-
var now = new Date();
|
|
42
|
-
if (start !== null && now < start)
|
|
43
|
-
return true;
|
|
44
|
-
if (end !== null && now >= end)
|
|
45
|
-
return true;
|
|
46
|
-
return false;
|
|
47
|
-
};
|
|
48
|
-
Instance.prototype.canEditRegistration = function () {
|
|
49
|
-
var _a = this.registration, canEdit = _a.canEdit, editEnd = _a.editEnd;
|
|
50
|
-
if (!canEdit)
|
|
51
|
-
return false;
|
|
52
|
-
if (editEnd === null)
|
|
53
|
-
return true;
|
|
54
|
-
var now = new Date();
|
|
55
|
-
return editEnd < now;
|
|
5
|
+
export class Instance {
|
|
6
|
+
constructor(rawInstance) {
|
|
7
|
+
this.name = rawInstance.name;
|
|
8
|
+
this.title = rawInstance.title;
|
|
9
|
+
this.description = rawInstance.description;
|
|
10
|
+
this.checkinTags = rawInstance.checkins;
|
|
11
|
+
this.hasTumbnail = rawInstance.thumbnail;
|
|
12
|
+
this.url = rawInstance.url;
|
|
13
|
+
this.registration = rawInstance.registration;
|
|
14
|
+
this.guestNameFields = rawInstance.guestNameFields;
|
|
15
|
+
this.metaFields = rawInstance.metaFields;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
toJSON() {
|
|
19
|
+
return {
|
|
20
|
+
name: this.name,
|
|
21
|
+
title: this.title,
|
|
22
|
+
description: this.description,
|
|
23
|
+
checkins: this.checkinTags,
|
|
24
|
+
thumbnail: this.hasTumbnail,
|
|
25
|
+
url: this.url,
|
|
26
|
+
registration: {
|
|
27
|
+
start: this.registration.start?.toISOString() ?? null,
|
|
28
|
+
end: this.registration.end?.toISOString() ?? null,
|
|
29
|
+
closed: this.registration.closed,
|
|
30
|
+
canEdit: this.registration.canEdit,
|
|
31
|
+
editEnd: this.registration.editEnd?.toISOString() ?? null
|
|
32
|
+
},
|
|
33
|
+
guestNameFields: this.guestNameFields,
|
|
34
|
+
metaFields: this.metaFields
|
|
56
35
|
};
|
|
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
|
-
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
isRegistrationClosed() {
|
|
39
|
+
const {
|
|
40
|
+
closed,
|
|
41
|
+
start,
|
|
42
|
+
end
|
|
43
|
+
} = this.registration;
|
|
44
|
+
if (closed) return true;
|
|
45
|
+
const now = new Date();
|
|
46
|
+
if (start !== null && now < start) return true;
|
|
47
|
+
if (end !== null && now >= end) return true;
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
canEditRegistration() {
|
|
52
|
+
const {
|
|
53
|
+
canEdit,
|
|
54
|
+
editEnd
|
|
55
|
+
} = this.registration;
|
|
56
|
+
if (!canEdit) return false;
|
|
57
|
+
if (editEnd === null) return true;
|
|
58
|
+
const now = new Date();
|
|
59
|
+
return editEnd < now;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
formatName(guest) {
|
|
63
|
+
if (this.guestNameFields.length === 0) {
|
|
64
|
+
// just use the first value we can find
|
|
65
|
+
return Object.values(guest.userdata).slice(0, 1).join('');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return this.guestNameFields.map(fieldKey => guest.userdata[fieldKey] ?? '').join(' ');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
const rawInstance = object({
|
|
73
|
+
name: string(),
|
|
74
|
+
title: string(),
|
|
75
|
+
description: string(),
|
|
76
|
+
checkins: array(string()),
|
|
77
|
+
thumbnail: boolean(),
|
|
78
|
+
url: object({
|
|
79
|
+
domain: string(),
|
|
80
|
+
rootPath: string()
|
|
81
|
+
}),
|
|
82
|
+
registration: object({
|
|
83
|
+
start: maybe(pipe(string()).pipe(parseDate({
|
|
84
|
+
iso: true
|
|
85
|
+
}))),
|
|
86
|
+
end: maybe(pipe(string()).pipe(parseDate({
|
|
87
|
+
iso: true
|
|
88
|
+
}))),
|
|
89
|
+
closed: boolean(),
|
|
90
|
+
canEdit: defaultTo(boolean(), false),
|
|
91
|
+
editEnd: defaultTo(maybe(pipe(string()).pipe(parseDate({
|
|
92
|
+
iso: true
|
|
93
|
+
}))), null)
|
|
94
|
+
}),
|
|
95
|
+
guestNameFields: array(string()),
|
|
96
|
+
metaFields: dictionary(metaField)
|
|
97
|
+
}, {
|
|
98
|
+
allowExcessProperties: true
|
|
99
|
+
});
|
|
100
|
+
const rawInstanceList = object({
|
|
101
|
+
instances: array(rawInstance)
|
|
102
|
+
});
|
|
103
|
+
const parseRawInstance = apiValidator(rawInstance);
|
|
104
|
+
const parseRawInstanceList = apiValidator(rawInstanceList);
|
|
105
|
+
export const parseInstance = value => {
|
|
106
|
+
const result = parseRawInstance(value);
|
|
107
|
+
if (!result.success) return result;
|
|
108
|
+
return success(new Instance(result.data));
|
|
103
109
|
};
|
|
104
|
-
|
|
110
|
+
export const parseInstanceList = value => {
|
|
111
|
+
const result = parseRawInstanceList(value);
|
|
112
|
+
if (!result.success) return result;
|
|
113
|
+
return success(result.data.instances.map(rawInstance => new Instance(rawInstance)));
|
|
114
|
+
};
|
package/dist/models/invite.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { array, number, object, parseDate, pipe, string
|
|
1
|
+
import { array, number, object, parseDate, pipe, string } from 'fefe';
|
|
2
2
|
import { apiValidator } from '../lib';
|
|
3
3
|
import { rawFieldValue } from './field-value';
|
|
4
4
|
import { dictionary, maybe, toString } from './_helpers';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const invite = object({
|
|
6
|
+
auth: string(),
|
|
7
|
+
count: number(),
|
|
8
|
+
limit: number(),
|
|
9
|
+
tags: array(string()),
|
|
10
|
+
userdata: dictionary(rawFieldValue),
|
|
11
|
+
metadata: dictionary(toString),
|
|
12
|
+
expires: maybe(pipe(string()).pipe(parseDate({
|
|
13
|
+
iso: true
|
|
14
|
+
}))),
|
|
15
|
+
language: maybe(string())
|
|
16
|
+
}, {
|
|
17
|
+
allowExcessProperties: true
|
|
18
|
+
});
|
|
19
|
+
const inviteList = array(invite);
|
|
20
|
+
export const parseInvite = apiValidator(invite);
|
|
21
|
+
export const parseInviteList = apiValidator(inviteList);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { array, enumerate, object, optional, string
|
|
1
|
+
import { array, enumerate, object, optional, string } from 'fefe';
|
|
2
2
|
import { maybe } from './_helpers';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}, {
|
|
8
|
-
|
|
3
|
+
export const metaField = object({
|
|
4
|
+
type: enumerate('checkbox', 'list', 'text', 'textfield'),
|
|
5
|
+
values: maybe(optional(array(string()))),
|
|
6
|
+
default: maybe(optional(string()))
|
|
7
|
+
}, {
|
|
8
|
+
allowExcessProperties: true
|
|
9
|
+
});
|
package/dist/models/user.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { array, number, object, string, optional
|
|
1
|
+
import { array, number, object, string, optional } from 'fefe';
|
|
2
2
|
import { apiValidator } from '../lib';
|
|
3
3
|
import { unknown, dictionary } from './_helpers';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, {
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export const user = object({
|
|
5
|
+
name: string(),
|
|
6
|
+
timeout: number(),
|
|
7
|
+
userdata: dictionary(unknown()),
|
|
8
|
+
permissions: optional(dictionary(array(string())))
|
|
9
|
+
}, {
|
|
10
|
+
allowExcessProperties: true
|
|
11
|
+
});
|
|
12
|
+
export const parseUser = apiValidator(user);
|
package/dist/models/variable.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { array, boolean, discriminatedUnion, string
|
|
1
|
+
import { array, boolean, discriminatedUnion, string } from 'fefe';
|
|
2
2
|
import { apiValidator } from '../lib';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
const variable = discriminatedUnion('variableType', {
|
|
4
|
+
text: {
|
|
5
|
+
name: string(),
|
|
6
|
+
title: string(),
|
|
7
|
+
value: string(),
|
|
8
|
+
isPrivate: boolean()
|
|
9
|
+
} // number: { name: string(), title: string(), value: number() },
|
|
10
|
+
|
|
11
|
+
}, {
|
|
12
|
+
allowExcessProperties: true
|
|
13
|
+
});
|
|
14
|
+
const variableList = array(variable);
|
|
15
|
+
export const parseVariable = apiValidator(variable);
|
|
16
|
+
export const parseVariableList = apiValidator(variableList);
|
package/dist/ui/button.js
CHANGED
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
23
5
|
import React from 'react';
|
|
24
6
|
import 'styled-jsx';
|
|
25
7
|
import { theme } from '../lib';
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
8
|
+
export const Button = ({
|
|
9
|
+
appearance = 'default',
|
|
10
|
+
...props
|
|
11
|
+
}) => {
|
|
12
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, props, {
|
|
13
|
+
className: _JSXStyle.dynamic([["1344288011", [theme.fonts.secondary, theme.colors.enterBackground, theme.colors.enterDarkGrey, theme.colors.enterGrey, theme.colors.enterBackground, theme.colors.enterError, theme.colors.enterGrey, theme.colors.enterDarkGrey, theme.colors.enterDarkGrey, theme.colors.enterGreen, theme.colors.enterGreen]]]) + " " + `button ${appearance}`
|
|
14
|
+
}), props.children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
15
|
+
id: "1344288011",
|
|
16
|
+
dynamic: [theme.fonts.secondary, theme.colors.enterBackground, theme.colors.enterDarkGrey, theme.colors.enterGrey, theme.colors.enterBackground, theme.colors.enterError, theme.colors.enterGrey, theme.colors.enterDarkGrey, theme.colors.enterDarkGrey, theme.colors.enterGreen, theme.colors.enterGreen]
|
|
17
|
+
}, `.button.__jsx-style-dynamic-selector{font-family:${theme.fonts.secondary};margin:1em 0;padding:0.8em 1.5em;min-width:150px;font-size:1em;font-weight:500;white-space:nowrap;text-align:center;-webkit-text-decoration:none;text-decoration:none;text-transform:uppercase;-webkit-letter-spacing:0.06em;-moz-letter-spacing:0.06em;-ms-letter-spacing:0.06em;letter-spacing:0.06em;line-height:1;cursor:pointer;border-radius:2px;background-color:${theme.colors.enterBackground};color:${theme.colors.enterDarkGrey};border:1px solid ${theme.colors.enterGrey};box-shadow:0px 0px 2px 0px rgba(0,0,0,0.12), 0px 1px 2px 0px rgba(0,0,0,0.24);}.danger.__jsx-style-dynamic-selector{background-color:${theme.colors.enterBackground};color:${theme.colors.enterError};border:1px solid ${theme.colors.enterGrey};}.primary.__jsx-style-dynamic-selector{background-color:${theme.colors.enterDarkGrey};color:white;border:1px solid ${theme.colors.enterDarkGrey};}.green.__jsx-style-dynamic-selector{background-color:${theme.colors.enterGreen};color:white;border:1px solid ${theme.colors.enterGreen};}`));
|
|
18
|
+
};
|
|
@@ -1,38 +1,28 @@
|
|
|
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
1
|
import React from 'react';
|
|
13
2
|
import { Button } from './button';
|
|
14
3
|
export default {
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
title: 'Button',
|
|
5
|
+
component: Button
|
|
17
6
|
};
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
|
|
8
|
+
const Template = args => /*#__PURE__*/React.createElement(Button, args);
|
|
9
|
+
|
|
10
|
+
export const Basic = Template.bind({});
|
|
20
11
|
Basic.args = {
|
|
21
|
-
|
|
12
|
+
children: 'default'
|
|
22
13
|
};
|
|
23
|
-
export
|
|
14
|
+
export const Primary = Template.bind({});
|
|
24
15
|
Primary.args = {
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
children: 'primary',
|
|
17
|
+
appearance: 'primary'
|
|
27
18
|
};
|
|
28
|
-
export
|
|
19
|
+
export const Danger = Template.bind({});
|
|
29
20
|
Danger.args = {
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
children: 'danger',
|
|
22
|
+
appearance: 'danger'
|
|
32
23
|
};
|
|
33
|
-
export
|
|
24
|
+
export const Green = Template.bind({});
|
|
34
25
|
Green.args = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=button.stories.js.map
|
|
26
|
+
children: 'green',
|
|
27
|
+
appearance: 'green'
|
|
28
|
+
};
|
|
@@ -1,51 +1,72 @@
|
|
|
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
|
-
};
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
10
2
|
import React from 'react';
|
|
11
3
|
import { colors, fonts } from '../lib/theme';
|
|
12
4
|
import 'styled-jsx';
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
5
|
+
const CHUNK_SIZE = 5;
|
|
6
|
+
export const CheckinCountIndicator = props => {
|
|
7
|
+
const checkinCount = props.checkins.length;
|
|
8
|
+
const hasCheckins = checkinCount > 0;
|
|
9
|
+
const rsvpCount = props.response === 'positive-response' ? props.rsvpCount : 0;
|
|
10
|
+
const rsvpsWithoutCheckin = rsvpCount > checkinCount ? rsvpCount - checkinCount : 0;
|
|
11
|
+
const checkinsAndRsvp = [...props.checkins, ...Array.from({
|
|
12
|
+
length: rsvpsWithoutCheckin
|
|
13
|
+
}, () => 'rsvp')];
|
|
14
|
+
const chunked = [];
|
|
15
|
+
|
|
16
|
+
for (let i = 0; i < checkinsAndRsvp.length; i += CHUNK_SIZE) {
|
|
17
|
+
const chunk = checkinsAndRsvp.slice(i, i + CHUNK_SIZE);
|
|
18
|
+
chunked.push(chunk);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const text = getText({
|
|
22
|
+
checkinCount,
|
|
23
|
+
rsvpCount
|
|
24
|
+
});
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: _JSXStyle.dynamic([["3032748268", [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]]]) + " " + 'checkin-count-indicator'
|
|
27
|
+
}, props.response === 'negative-repsone' && !hasCheckins ? /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: _JSXStyle.dynamic([["3032748268", [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]]]) + " " + 'box-wrapper'
|
|
29
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
30
|
+
className: _JSXStyle.dynamic([["3032748268", [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]]]) + " " + 'decline-box'
|
|
31
|
+
}, "\xD7"), /*#__PURE__*/React.createElement("span", {
|
|
32
|
+
className: _JSXStyle.dynamic([["3032748268", [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]]]) + " " + 'text'
|
|
33
|
+
}, "Declined")) : /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: _JSXStyle.dynamic([["3032748268", [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]]]) + " " + `box-wrapper ${chunked.length > 1 ? 'multiple-chunks' : ''} `
|
|
35
|
+
}, chunked.map((chunk, idx) => /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
key: idx,
|
|
37
|
+
className: _JSXStyle.dynamic([["3032748268", [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]]]) + " " + 'chunk'
|
|
38
|
+
}, chunk.map((checkinOrRsvp, idx) => typeof checkinOrRsvp === 'string' ? /*#__PURE__*/React.createElement("span", {
|
|
39
|
+
key: idx,
|
|
40
|
+
className: _JSXStyle.dynamic([["3032748268", [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]]]) + " " + 'rsvp'
|
|
41
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
42
|
+
key: idx,
|
|
43
|
+
"data-toggle": "tooltip",
|
|
44
|
+
title: checkinOrRsvp.time.toLocaleString(),
|
|
45
|
+
className: _JSXStyle.dynamic([["3032748268", [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]]]) + " " + 'checkin'
|
|
46
|
+
})))), text && /*#__PURE__*/React.createElement("span", {
|
|
47
|
+
className: _JSXStyle.dynamic([["3032748268", [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]]]) + " " + 'text'
|
|
48
|
+
}, text)), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
49
|
+
id: "3032748268",
|
|
50
|
+
dynamic: [fonts.primary, colors.enterDarkGrey, colors.enterGreen, colors.enterGreen, colors.enterError, colors.enterError]
|
|
51
|
+
}, `.checkin-count-indicator.__jsx-style-dynamic-selector{font-family:${fonts.primary};}.text.__jsx-style-dynamic-selector{color:${colors.enterDarkGrey};text-transform:uppercase;font-size:10px;line-height:15px;font-weight:bold;white-space:nowrap;width:100%;margin-top:0.2em;}.text.__jsx-style-dynamic-selector:nth-child(2){width:auto;margin-top:0;}.box-wrapper.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;min-width:100px;}.box-wrapper.multiple-chunks.__jsx-style-dynamic-selector{-webkit-flex-flow:wrap;-ms-flex-flow:wrap;flex-flow:wrap;}.chunk.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin-right:5px;margin-bottom:4px;width:95px;white-space:nowrap;}.chunk.__jsx-style-dynamic-selector:first-of-type.chunk.__jsx-style-dynamic-selector:last-of-type{width:auto;margin-right:2px;}.checkin.__jsx-style-dynamic-selector,.rsvp.__jsx-style-dynamic-selector,.decline-box.__jsx-style-dynamic-selector{box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-size:120%;width:15px;height:15px;border-radius:2px;border:3px solid ${colors.enterGreen};margin:0 4px 0 0;vertical-align:middle;color:white;}.checkin.__jsx-style-dynamic-selector{background-color:${colors.enterGreen};}.decline-box.__jsx-style-dynamic-selector{background-color:${colors.enterError};border-color:${colors.enterError};}`));
|
|
35
52
|
};
|
|
53
|
+
|
|
36
54
|
function getText(args) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
55
|
+
if (args.checkinCount === 1 && args.rsvpCount === 1) {
|
|
56
|
+
return 'checked in';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (args.checkinCount > 0) {
|
|
60
|
+
return `${args.checkinCount} / ${args.rsvpCount} Checkins`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (args.rsvpCount == 1) {
|
|
64
|
+
return 'Confirmed';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (args.rsvpCount > 0) {
|
|
68
|
+
return `${args.rsvpCount} Confirmations`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return 'no response';
|
|
72
|
+
}
|