@dev-crew-berlin/enter-js-utils 0.80.3 → 0.81.0
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/models/attendee.js +4 -10
- package/dist/ui/form-elements/input.js +3 -2
- package/dist/ui/form-elements/select.d.ts +11 -0
- package/dist/ui/form-elements/select.js +37 -0
- package/dist/ui/form-elements/select.stories.d.ts +8 -0
- package/dist/ui/form-elements/select.stories.js +30 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +1 -0
- package/package.json +1 -1
package/dist/models/attendee.js
CHANGED
|
@@ -57,10 +57,10 @@ export class Attendee {
|
|
|
57
57
|
// so we implement it here again by hand
|
|
58
58
|
|
|
59
59
|
// convert each checkin to its json representation
|
|
60
|
-
const checkin = Object.fromEntries(
|
|
60
|
+
const checkin = Object.fromEntries(this.checkin.entries().map(([checkinTag, checkin]) => [checkinTag, checkin.toJSON()]));
|
|
61
61
|
|
|
62
62
|
// convert each rsvp to its json representation
|
|
63
|
-
const rsvp = Object.fromEntries(
|
|
63
|
+
const rsvp = Object.fromEntries(this.rsvp.entries().map(([checkinTag, rsvp]) => [checkinTag, rsvp ? rsvp.toJSON() : null]));
|
|
64
64
|
return {
|
|
65
65
|
...this,
|
|
66
66
|
time: this.time?.toISOString(),
|
|
@@ -110,10 +110,7 @@ export class Attendee {
|
|
|
110
110
|
newCheckins.checkins = [args.checkin];
|
|
111
111
|
const mergedCheckins = exsitingCheckins.merge(newCheckins);
|
|
112
112
|
const newAttendee = new Attendee(this.toJSON());
|
|
113
|
-
newAttendee.checkin
|
|
114
|
-
...this.checkin,
|
|
115
|
-
[args.branchName]: mergedCheckins
|
|
116
|
-
};
|
|
113
|
+
newAttendee.checkin.set(args.branchName, mergedCheckins);
|
|
117
114
|
return newAttendee;
|
|
118
115
|
}
|
|
119
116
|
deleteCheckinForBranch(args) {
|
|
@@ -124,10 +121,7 @@ export class Attendee {
|
|
|
124
121
|
});
|
|
125
122
|
const mergedCheckins = exsitingCheckins.merge(deletedCheckins);
|
|
126
123
|
const newAttendee = new Attendee(this.toJSON());
|
|
127
|
-
newAttendee.checkin
|
|
128
|
-
...this.checkin,
|
|
129
|
-
[args.branchName]: mergedCheckins
|
|
130
|
-
};
|
|
124
|
+
newAttendee.checkin.set(args.branchName, mergedCheckins);
|
|
131
125
|
return newAttendee;
|
|
132
126
|
}
|
|
133
127
|
getFieldValueString(fieldKey) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useId } from 'react';
|
|
4
4
|
import { colors, fonts } from '../../lib/theme';
|
|
5
5
|
import { Label } from './label';
|
|
6
6
|
export const Input = ({
|
|
7
7
|
label,
|
|
8
8
|
...props
|
|
9
9
|
}) => {
|
|
10
|
-
const
|
|
10
|
+
const _id = useId();
|
|
11
|
+
const id = props.id ?? _id;
|
|
11
12
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Label, {
|
|
12
13
|
htmlFor: id
|
|
13
14
|
}, label), /*#__PURE__*/React.createElement("input", _extends({}, props, {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { SelectHTMLAttributes } from 'react';
|
|
2
|
+
type Props<Option> = Omit<SelectHTMLAttributes<HTMLSelectElement>, 'onChange' | 'value'> & {
|
|
3
|
+
label: string;
|
|
4
|
+
value?: Option;
|
|
5
|
+
options: Option[];
|
|
6
|
+
onChange: (option: Option) => void;
|
|
7
|
+
optionFormat?: (option: Option) => string;
|
|
8
|
+
optionDisabled?: (option: Option) => boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function Select<Option extends string>({ optionFormat, optionDisabled, ...props }: Props<Option>): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
import React, { useId } from 'react';
|
|
4
|
+
import { colors, fonts } from '../../lib/theme';
|
|
5
|
+
import { Label } from './label';
|
|
6
|
+
export function Select({
|
|
7
|
+
optionFormat = option => option,
|
|
8
|
+
optionDisabled = () => false,
|
|
9
|
+
...props
|
|
10
|
+
}) {
|
|
11
|
+
const {
|
|
12
|
+
options,
|
|
13
|
+
value,
|
|
14
|
+
onChange,
|
|
15
|
+
...inputProps
|
|
16
|
+
} = props;
|
|
17
|
+
const _id = useId();
|
|
18
|
+
const id = props.id ?? _id;
|
|
19
|
+
const uriEncodedChevronSVG = encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 50' ><polygon fill='${colors.enterBackground}' points='0,0 100,0 50,50'/></svg>`);
|
|
20
|
+
const chevronSVGImageURL = `data:image/svg+xml,${uriEncodedChevronSVG}`;
|
|
21
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Label, {
|
|
22
|
+
htmlFor: id
|
|
23
|
+
}, props.label), /*#__PURE__*/React.createElement("select", _extends({}, inputProps, {
|
|
24
|
+
id: id,
|
|
25
|
+
value: value,
|
|
26
|
+
onChange: e => onChange(e.target.value),
|
|
27
|
+
className: _JSXStyle.dynamic([["2093301006", [fonts.primary, colors.enterDarkGrey, colors.enterMediumGrey, chevronSVGImageURL, colors.enterRed]]]) + " " + (inputProps && inputProps.className != null && inputProps.className || "")
|
|
28
|
+
}), options.map(option => /*#__PURE__*/React.createElement("option", {
|
|
29
|
+
key: option,
|
|
30
|
+
value: option,
|
|
31
|
+
disabled: optionDisabled(option),
|
|
32
|
+
className: _JSXStyle.dynamic([["2093301006", [fonts.primary, colors.enterDarkGrey, colors.enterMediumGrey, chevronSVGImageURL, colors.enterRed]]])
|
|
33
|
+
}, optionFormat(option)))), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
34
|
+
id: "2093301006",
|
|
35
|
+
dynamic: [fonts.primary, colors.enterDarkGrey, colors.enterMediumGrey, chevronSVGImageURL, colors.enterRed]
|
|
36
|
+
}, `select.__jsx-style-dynamic-selector{font-family:${fonts.primary};font-size:1.1em;display:block;width:100%;padding:0.2em 0;margin-bottom:1.1em;border:none;outline:none;background-color:transparent;color:${colors.enterDarkGrey};border-bottom:1px solid ${colors.enterMediumGrey};border-radius:0;-webkit-transition:border-color 0.2s;transition:border-color 0.2s;background:url('${chevronSVGImageURL}');background-repeat:no-repeat;background-position:right 0.5em center;background-size:12px;}select.__jsx-style-dynamic-selector:focus{border-color:1px solid ${colors.enterRed};}`));
|
|
37
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Select } from './select';
|
|
3
|
+
declare const meta: Meta<typeof Select>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Select>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const WithPleaseSelect: Story;
|
|
8
|
+
export declare const WithCustomFormat: Story;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Select } from './select';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Form Elements/Select',
|
|
4
|
+
component: Select
|
|
5
|
+
};
|
|
6
|
+
export default meta;
|
|
7
|
+
export const Basic = {
|
|
8
|
+
args: {
|
|
9
|
+
label: 'Select',
|
|
10
|
+
options: ['One', 'Two'],
|
|
11
|
+
onClick: () => undefined
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const WithPleaseSelect = {
|
|
15
|
+
args: {
|
|
16
|
+
label: 'Select',
|
|
17
|
+
options: ['Please Select', 'One', 'Two'],
|
|
18
|
+
value: 'Please Select',
|
|
19
|
+
optionDisabled: option => option === 'Please Select',
|
|
20
|
+
onClick: () => undefined
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export const WithCustomFormat = {
|
|
24
|
+
args: {
|
|
25
|
+
label: 'Select',
|
|
26
|
+
options: ['one', 'two'],
|
|
27
|
+
optionFormat: option => option.toUpperCase(),
|
|
28
|
+
onClick: () => undefined
|
|
29
|
+
}
|
|
30
|
+
};
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { Input } from './form-elements/input';
|
|
|
2
2
|
export { Label } from './form-elements/label';
|
|
3
3
|
export { SearchInput } from './form-elements/search-input';
|
|
4
4
|
export { SegmentedControl } from './form-elements/segmented-control';
|
|
5
|
+
export { Select } from './form-elements/select';
|
|
5
6
|
export { AddGuestIcon } from './icons/add-guest-icon';
|
|
6
7
|
export { CaretIcon } from './icons/caret-icon';
|
|
7
8
|
export { FilterIcon } from './icons/filter-icon';
|
package/dist/ui/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { Input } from './form-elements/input';
|
|
|
2
2
|
export { Label } from './form-elements/label';
|
|
3
3
|
export { SearchInput } from './form-elements/search-input';
|
|
4
4
|
export { SegmentedControl } from './form-elements/segmented-control';
|
|
5
|
+
export { Select } from './form-elements/select';
|
|
5
6
|
export { AddGuestIcon } from './icons/add-guest-icon';
|
|
6
7
|
export { CaretIcon } from './icons/caret-icon';
|
|
7
8
|
export { FilterIcon } from './icons/filter-icon';
|