@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,104 +1,114 @@
1
- import { array, boolean, object, parseDate, pipe, string, defaultTo, } from 'fefe';
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
- var Instance = /** @class */ (function () {
6
- function Instance(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
- Instance.prototype.toJSON = function () {
18
- var _a, _b, _c, _d, _e, _f;
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: (_b = (_a = this.registration.start) === null || _a === void 0 ? void 0 : _a.toISOString()) !== null && _b !== void 0 ? _b : null,
28
- end: (_d = (_c = this.registration.end) === null || _c === void 0 ? void 0 : _c.toISOString()) !== null && _d !== void 0 ? _d : null,
29
- closed: this.registration.closed,
30
- canEdit: this.registration.canEdit,
31
- editEnd: (_f = (_e = this.registration.editEnd) === null || _e === void 0 ? void 0 : _e.toISOString()) !== null && _f !== void 0 ? _f : null,
32
- },
33
- guestNameFields: this.guestNameFields,
34
- metaFields: this.metaFields,
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
- Instance.prototype.formatName = function (guest) {
58
- if (this.guestNameFields.length === 0) {
59
- // just use the first value we can find
60
- return Object.values(guest.userdata).slice(0, 1).join('');
61
- }
62
- return this.guestNameFields
63
- .map(function (fieldKey) { var _a; return (_a = guest.userdata[fieldKey]) !== null && _a !== void 0 ? _a : ''; })
64
- .join(' ');
65
- };
66
- return Instance;
67
- }());
68
- export { Instance };
69
- var rawInstance = object({
70
- name: string(),
71
- title: string(),
72
- description: string(),
73
- checkins: array(string()),
74
- thumbnail: boolean(),
75
- url: object({
76
- domain: string(),
77
- rootPath: string(),
78
- }),
79
- registration: object({
80
- start: maybe(pipe(string()).pipe(parseDate({ iso: true }))),
81
- end: maybe(pipe(string()).pipe(parseDate({ iso: true }))),
82
- closed: boolean(),
83
- canEdit: defaultTo(boolean(), false),
84
- editEnd: defaultTo(maybe(pipe(string()).pipe(parseDate({ iso: true }))), null),
85
- }),
86
- guestNameFields: array(string()),
87
- metaFields: dictionary(metaField),
88
- }, { allowExcessProperties: true });
89
- var rawInstanceList = object({ instances: array(rawInstance) });
90
- var parseRawInstance = apiValidator(rawInstance);
91
- var parseRawInstanceList = apiValidator(rawInstanceList);
92
- export var parseInstance = function (value) {
93
- var result = parseRawInstance(value);
94
- if (!result.success)
95
- return result;
96
- return success(new Instance(result.data));
97
- };
98
- export var parseInstanceList = function (value) {
99
- var result = parseRawInstanceList(value);
100
- if (!result.success)
101
- return result;
102
- return success(result.data.instances.map(function (rawInstance) { return new Instance(rawInstance); }));
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
- //# sourceMappingURL=instance.js.map
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
+ };
@@ -1,18 +1,21 @@
1
- import { array, number, object, parseDate, pipe, string, } from 'fefe';
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
- var 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({ iso: true }))),
13
- language: maybe(string()),
14
- }, { allowExcessProperties: true });
15
- var inviteList = array(invite);
16
- export var parseInvite = apiValidator(invite);
17
- export var parseInviteList = apiValidator(inviteList);
18
- //# sourceMappingURL=invite.js.map
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, } from 'fefe';
1
+ import { array, enumerate, object, optional, string } from 'fefe';
2
2
  import { maybe } from './_helpers';
3
- export var metaField = object({
4
- type: enumerate('checkbox', 'list', 'text', 'textfield'),
5
- values: maybe(optional(array(string()))),
6
- default: maybe(optional(string())),
7
- }, { allowExcessProperties: true });
8
- //# sourceMappingURL=meta-field.js.map
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
+ });
@@ -1,11 +1,12 @@
1
- import { array, number, object, string, optional, } from 'fefe';
1
+ import { array, number, object, string, optional } from 'fefe';
2
2
  import { apiValidator } from '../lib';
3
3
  import { unknown, dictionary } from './_helpers';
4
- export var user = object({
5
- name: string(),
6
- timeout: number(),
7
- userdata: dictionary(unknown()),
8
- permissions: optional(dictionary(array(string()))),
9
- }, { allowExcessProperties: true });
10
- export var parseUser = apiValidator(user);
11
- //# sourceMappingURL=user.js.map
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);
@@ -1,15 +1,16 @@
1
- import { array, boolean, discriminatedUnion, string, } from 'fefe';
1
+ import { array, boolean, discriminatedUnion, string } from 'fefe';
2
2
  import { apiValidator } from '../lib';
3
- var variable = discriminatedUnion('variableType', {
4
- text: {
5
- name: string(),
6
- title: string(),
7
- value: string(),
8
- isPrivate: boolean(),
9
- },
10
- // number: { name: string(), title: string(), value: number() },
11
- }, { allowExcessProperties: true });
12
- var variableList = array(variable);
13
- export var parseVariable = apiValidator(variable);
14
- export var parseVariableList = apiValidator(variableList);
15
- //# sourceMappingURL=variable.js.map
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
- 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
- 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 var Button = function (_a) {
27
- var _b = _a.appearance, appearance = _b === void 0 ? 'default' : _b, props = __rest(_a, ["appearance"]);
28
- return (React.createElement("button", __assign({}, props, { className: "button ".concat(appearance) }),
29
- props.children,
30
- React.createElement("style", { jsx: true }, "\n .button {\n font-family: ".concat(theme.fonts.secondary, ";\n margin: 1em 0;\n padding: 0.8em 1.5em;\n min-width: 150px;\n font-size: 1em;\n font-weight: 500;\n white-space: nowrap;\n text-align: center;\n text-decoration: none;\n text-transform: uppercase;\n letter-spacing: 0.06em;\n line-height: 1;\n cursor: pointer;\n border-radius: 2px;\n background-color: ").concat(theme.colors.enterBackground, ";\n color: ").concat(theme.colors.enterDarkGrey, ";\n border: 1px solid ").concat(theme.colors.enterGrey, ";\n box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.12),\n 0px 1px 2px 0px rgba(0, 0, 0, 0.24);\n }\n\n .danger {\n background-color: ").concat(theme.colors.enterBackground, ";\n color: ").concat(theme.colors.enterError, ";\n border: 1px solid ").concat(theme.colors.enterGrey, ";\n }\n\n .primary {\n background-color: ").concat(theme.colors.enterDarkGrey, ";\n color: white;\n border: 1px solid ").concat(theme.colors.enterDarkGrey, ";\n }\n\n .green {\n background-color: ").concat(theme.colors.enterGreen, ";\n color: white;\n border: 1px solid ").concat(theme.colors.enterGreen, ";\n }\n "))));
31
- };
32
- //# sourceMappingURL=button.js.map
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
- title: 'Button',
16
- component: Button,
4
+ title: 'Button',
5
+ component: Button
17
6
  };
18
- var Template = function (args) { return React.createElement(Button, __assign({}, args)); };
19
- export var Basic = Template.bind({});
7
+
8
+ const Template = args => /*#__PURE__*/React.createElement(Button, args);
9
+
10
+ export const Basic = Template.bind({});
20
11
  Basic.args = {
21
- children: 'default',
12
+ children: 'default'
22
13
  };
23
- export var Primary = Template.bind({});
14
+ export const Primary = Template.bind({});
24
15
  Primary.args = {
25
- children: 'primary',
26
- appearance: 'primary',
16
+ children: 'primary',
17
+ appearance: 'primary'
27
18
  };
28
- export var Danger = Template.bind({});
19
+ export const Danger = Template.bind({});
29
20
  Danger.args = {
30
- children: 'danger',
31
- appearance: 'danger',
21
+ children: 'danger',
22
+ appearance: 'danger'
32
23
  };
33
- export var Green = Template.bind({});
24
+ export const Green = Template.bind({});
34
25
  Green.args = {
35
- children: 'green',
36
- appearance: 'green',
37
- };
38
- //# sourceMappingURL=button.stories.js.map
26
+ children: 'green',
27
+ appearance: 'green'
28
+ };
@@ -1,51 +1,72 @@
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
- };
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
- var CHUNK_SIZE = 5;
14
- export var CheckinCountIndicator = function (props) {
15
- var checkinCount = props.checkins.length;
16
- var hasCheckins = checkinCount > 0;
17
- var rsvpCount = props.response === 'positive-response' ? props.rsvpCount : 0;
18
- var rsvpsWithoutCheckin = rsvpCount > checkinCount ? rsvpCount - checkinCount : 0;
19
- var checkinsAndRsvp = __spreadArray(__spreadArray([], props.checkins, true), Array.from({ length: rsvpsWithoutCheckin }, function () { return 'rsvp'; }), true);
20
- var chunked = [];
21
- for (var i = 0; i < checkinsAndRsvp.length; i += CHUNK_SIZE) {
22
- var chunk = checkinsAndRsvp.slice(i, i + CHUNK_SIZE);
23
- chunked.push(chunk);
24
- }
25
- var text = getText({ checkinCount: checkinCount, rsvpCount: rsvpCount });
26
- return (React.createElement("div", { className: 'checkin-count-indicator' },
27
- props.response === 'negative-repsone' && !hasCheckins ? (React.createElement("div", { className: 'box-wrapper' },
28
- React.createElement("span", { className: 'decline-box' }, "\u00D7"),
29
- React.createElement("span", { className: 'text' }, "Declined"))) : (React.createElement("div", { className: "box-wrapper ".concat(chunked.length > 1 ? 'multiple-chunks' : '', " ") },
30
- chunked.map(function (chunk, idx) { return (React.createElement("div", { key: idx, className: 'chunk' }, chunk.map(function (checkinOrRsvp, idx) {
31
- return typeof checkinOrRsvp === 'string' ? (React.createElement("span", { key: idx, className: 'rsvp' })) : (React.createElement("span", { key: idx, className: 'checkin', "data-toggle": 'tooltip', title: checkinOrRsvp.time.toLocaleString() }));
32
- }))); }),
33
- text && React.createElement("span", { className: 'text' }, text))),
34
- React.createElement("style", { jsx: true }, "\n .checkin-count-indicator {\n font-family: ".concat(fonts.primary, ";\n }\n\n .text {\n color: ").concat(colors.enterDarkGrey, ";\n text-transform: uppercase;\n font-size: 10px;\n line-height: 15px;\n font-weight: bold;\n white-space: nowrap;\n width: 100%;\n margin-top: 0.2em;\n }\n\n .text:nth-child(2) {\n width: auto;\n margin-top: 0;\n }\n\n .box-wrapper {\n display: flex;\n min-width: 100px;\n }\n .box-wrapper.multiple-chunks {\n flex-flow: wrap;\n }\n\n .chunk {\n display: flex;\n margin-right: 5px;\n margin-bottom: 4px;\n width: 95px;\n white-space: nowrap;\n }\n\n .chunk:first-of-type.chunk:last-of-type {\n width: auto;\n margin-right: 2px;\n }\n\n .checkin,\n .rsvp,\n .decline-box {\n box-sizing: border-box;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 120%;\n width: 15px;\n height: 15px;\n border-radius: 2px;\n border: 3px solid ").concat(colors.enterGreen, ";\n margin: 0 4px 0 0;\n vertical-align: middle;\n color: white;\n }\n\n .checkin {\n background-color: ").concat(colors.enterGreen, ";\n }\n\n .decline-box {\n background-color: ").concat(colors.enterError, ";\n border-color: ").concat(colors.enterError, ";\n }\n "))));
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
- if (args.checkinCount === 1 && args.rsvpCount === 1) {
38
- return 'checked in';
39
- }
40
- if (args.checkinCount > 0) {
41
- return "".concat(args.checkinCount, " / ").concat(args.rsvpCount, " Checkins");
42
- }
43
- if (args.rsvpCount == 1) {
44
- return 'Confirmed';
45
- }
46
- if (args.rsvpCount > 0) {
47
- return "".concat(args.rsvpCount, " Confirmations");
48
- }
49
- return 'no response';
50
- }
51
- //# sourceMappingURL=checkin-count-indicator.js.map
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
+ }