@dtdot/lego 2.0.0-2 → 2.0.0-21
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/build/components/ActionMenu/ActionMenu.component.d.ts +7 -4
- package/build/components/ActionMenu/ActionMenu.component.js +3 -17
- package/build/components/ActionMenu/_ActionMenuCheckbox.component.d.ts +2 -2
- package/build/components/ActionMenu/_ActionMenuCheckbox.component.js +2 -2
- package/build/components/ActionMenu/_ActionMenuItem.component.d.ts +2 -2
- package/build/components/ActionMenu/_ActionMenuItem.component.js +2 -2
- package/build/components/ActionMenu/_ActionMenuPanel.component.js +1 -1
- package/build/components/ActionMessage/ActionMessage.component.js +1 -1
- package/build/components/Alert/Alert.component.js +3 -3
- package/build/components/Badge/Badge.component.js +1 -1
- package/build/components/BadgeSelector/BadgeSelector.component.js +1 -1
- package/build/components/Button/Button.component.d.ts +6 -2
- package/build/components/Button/Button.component.js +74 -14
- package/build/components/Button/Button.context.d.ts +1 -0
- package/build/components/Button/Button.context.js +1 -0
- package/build/components/Card/Card.component.d.ts +7 -6
- package/build/components/Card/Card.component.js +2 -2
- package/build/components/Card/_CardHeader.component.js +4 -2
- package/build/components/Card/_CardToggleSection.component.d.ts +6 -5
- package/build/components/Card/_CardToggleSection.component.js +2 -2
- package/build/components/Checklist/Checklist.component.js +1 -1
- package/build/components/Checklist/_ChecklistItem.component.js +1 -1
- package/build/components/ControlLine/ControlLine.component.d.ts +7 -0
- package/build/components/ControlLine/ControlLine.component.js +33 -0
- package/build/components/FancyCheckbox/FancyCheckbox.component.js +1 -1
- package/build/components/Form/Form.component.d.ts +4 -1
- package/build/components/Form/Form.component.js +2 -0
- package/build/components/Form/_NestedFormArray.d.ts +8 -0
- package/build/components/Form/_NestedFormArray.js +23 -0
- package/build/components/Heading/Heading.component.d.ts +1 -0
- package/build/components/Heading/Heading.component.js +2 -0
- package/build/components/Heading/_DividerHeading.component.d.ts +2 -0
- package/build/components/Heading/_DividerHeading.component.js +15 -0
- package/build/components/ImageUpload/ImageUpload.component.d.ts +2 -2
- package/build/components/ImageUpload/ImageUpload.component.js +10 -10
- package/build/components/InlineCard/InlineCard.component.d.ts +8 -7
- package/build/components/InlineCard/InlineCard.component.js +2 -2
- package/build/components/Input/Input.component.d.ts +3 -1
- package/build/components/Input/Input.component.js +24 -7
- package/build/components/LiveInput/LiveInput.component.d.ts +2 -2
- package/build/components/LiveInput/LiveInput.component.js +2 -2
- package/build/components/LiveList/LiveList.component.js +2 -2
- package/build/components/LiveList/_LiveListRow.js +3 -3
- package/build/components/Loader/Loader.component.d.ts +4 -1
- package/build/components/Loader/Loader.component.js +17 -5
- package/build/components/Menu/_MenuHeading.component.js +2 -2
- package/build/components/Menu/_MenuItem.component.js +1 -1
- package/build/components/Menu/_MenuPanel.component.js +1 -1
- package/build/components/MinimalMenu/MinimalMenu.component.d.ts +2 -1
- package/build/components/MinimalMenu/MinimalMenu.component.js +2 -0
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.d.ts +15 -0
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.js +31 -0
- package/build/components/MinimalMenu/_MinimalMenuItem.component.d.ts +2 -2
- package/build/components/MinimalMenu/_MinimalMenuItem.component.js +3 -3
- package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.d.ts +2 -2
- package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.js +2 -2
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.d.ts +2 -2
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.js +2 -2
- package/build/components/Modal/Modal.component.js +1 -1
- package/build/components/Modal/_ModalHeader.component.js +2 -2
- package/build/components/Notification/Notification.component.js +1 -1
- package/build/components/ProfileImage/ProfileImage.component.js +2 -2
- package/build/components/QrCode/QrCode.component.js +2 -2
- package/build/components/Select/Select.component.d.ts +2 -5
- package/build/components/Select/Select.component.js +12 -29
- package/build/components/Spacer/Spacer.component.d.ts +1 -1
- package/build/components/Spacer/Spacer.component.js +2 -0
- package/build/components/SquareButton/SquareButton.component.d.ts +2 -2
- package/build/components/SquareButton/SquareButton.component.js +2 -2
- package/build/components/Table/Table.component.d.ts +5 -3
- package/build/components/Table/Table.component.js +15 -0
- package/build/components/Table/_TableAction.d.ts +7 -3
- package/build/components/Table/_TableAction.js +6 -3
- package/build/components/Table/_TableActionMenu.d.ts +2 -2
- package/build/components/Table/_TableActionMenu.js +2 -2
- package/build/components/Table/_TableRow.component.d.ts +2 -2
- package/build/components/Table/_TableRow.component.js +6 -2
- package/build/components/Text/Text.component.d.ts +4 -3
- package/build/components/Text/Text.component.js +3 -3
- package/build/components/TextArea/TextArea.component.d.ts +1 -1
- package/build/components/TextArea/TextArea.component.js +5 -5
- package/build/components/Toggle/Toggle.component.js +1 -1
- package/build/components/common/Options.component.d.ts +19 -0
- package/build/components/common/Options.component.js +44 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/screens/Login/Login.screen.js +4 -4
- package/build/screens/Register/Register.screen.js +3 -3
- package/build/screens/Verification/Verification.screen.js +2 -2
- package/build/shared/ControlStyles.js +1 -1
- package/build/theme/dark.theme.js +20 -8
- package/build/theme/default.theme.js +6 -0
- package/build/theme/helpers/getThemeVariantColours.d.ts +1 -5
- package/build/theme/helpers/getThemeVariantColours.js +3 -15
- package/build/theme/theme.types.d.ts +2 -0
- package/package.json +3 -1
|
@@ -94,7 +94,7 @@ const ErrorInner = styled.div `
|
|
|
94
94
|
const errorVariants = {
|
|
95
95
|
show: { opacity: 1 },
|
|
96
96
|
};
|
|
97
|
-
const ImageUpload = ({ name, value, 'error': propsError, 'uploading': uploadingProp, onChange, onSearch, 'data-
|
|
97
|
+
const ImageUpload = ({ name, value, 'error': propsError, 'uploading': uploadingProp, onChange, onSearch, 'data-testid': dataTestId, }) => {
|
|
98
98
|
const { upload, getUrl } = useContext(FileContext);
|
|
99
99
|
const [uploading, setUploading] = useState(false);
|
|
100
100
|
const { value: contextValue, error: contextError, onChange: contextOnChange } = useFormNode(name);
|
|
@@ -125,26 +125,26 @@ const ImageUpload = ({ name, value, 'error': propsError, 'uploading': uploadingP
|
|
|
125
125
|
};
|
|
126
126
|
const internalValue = value ? value : contextValue;
|
|
127
127
|
if (uploading || uploadingProp) {
|
|
128
|
-
return (React.createElement(UploadContainer, { "data-
|
|
128
|
+
return (React.createElement(UploadContainer, { "data-testid": dataTestId },
|
|
129
129
|
React.createElement(LoaderContainer, null,
|
|
130
130
|
React.createElement(Loader, null))));
|
|
131
131
|
}
|
|
132
132
|
if (!internalValue) {
|
|
133
|
-
return (React.createElement(UploadContainer, { "data-
|
|
133
|
+
return (React.createElement(UploadContainer, { "data-testid": dataTestId },
|
|
134
134
|
React.createElement(UploadInnerContainer, null,
|
|
135
|
-
React.createElement(IconContainer, { whileHover: { scale: 1.05 }, onClick: handleUploadClicked, "data-
|
|
135
|
+
React.createElement(IconContainer, { whileHover: { scale: 1.05 }, onClick: handleUploadClicked, "data-testid": 'button-image-upload' },
|
|
136
136
|
React.createElement(FontAwesomeIcon, { icon: faCloudUploadAlt })),
|
|
137
137
|
onSearch && (React.createElement(React.Fragment, null,
|
|
138
138
|
React.createElement(UploadVerticalDivider, null),
|
|
139
|
-
React.createElement(IconContainer, { whileHover: { scale: 1.05 }, onClick: onSearch, "data-
|
|
139
|
+
React.createElement(IconContainer, { whileHover: { scale: 1.05 }, onClick: onSearch, "data-testid": 'button-image-search' },
|
|
140
140
|
React.createElement(FontAwesomeIcon, { icon: faSearch }))))),
|
|
141
|
-
React.createElement(HiddenInput, { value: '', ref: inputRef, type: 'file', onChange: handleUpload, "data-
|
|
142
|
-
error && (React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-
|
|
141
|
+
React.createElement(HiddenInput, { value: '', ref: inputRef, type: 'file', onChange: handleUpload, "data-testid": 'input-image-hidden' }),
|
|
142
|
+
error && (React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-testid": 'error-indicator' },
|
|
143
143
|
React.createElement(ErrorInner, null,
|
|
144
144
|
React.createElement(FontAwesomeIcon, { icon: faExclamationCircle })),
|
|
145
|
-
React.createElement(ErrorMessage, { "data-
|
|
145
|
+
React.createElement(ErrorMessage, { "data-testid": 'error-message' }, error)))));
|
|
146
146
|
}
|
|
147
|
-
return (React.createElement("div", { "data-
|
|
148
|
-
React.createElement(Image, { "data-
|
|
147
|
+
return (React.createElement("div", { "data-testid": dataTestId },
|
|
148
|
+
React.createElement(Image, { "data-testid": 'uploaded-image', src: getUrl(internalValue) })));
|
|
149
149
|
};
|
|
150
150
|
export default ImageUpload;
|
|
@@ -4,15 +4,16 @@ import { Status } from '../../theme/theme.types';
|
|
|
4
4
|
export type InlineCardSize = 'fill' | 'xs' | 'sm' | 'md' | 'lg';
|
|
5
5
|
export type DragVariant = Status;
|
|
6
6
|
export interface InlineCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
size?: InlineCardSize;
|
|
9
|
-
value?: string;
|
|
10
|
-
gestureLeftIcon?: IconProp;
|
|
11
|
-
gestureLeftVariant?: DragVariant;
|
|
12
|
-
onGestureLeft?: () => void;
|
|
7
|
+
'children': React.ReactNode;
|
|
8
|
+
'size'?: InlineCardSize;
|
|
9
|
+
'value'?: string;
|
|
10
|
+
'gestureLeftIcon'?: IconProp;
|
|
11
|
+
'gestureLeftVariant'?: DragVariant;
|
|
12
|
+
'onGestureLeft'?: () => void;
|
|
13
|
+
'data-testid'?: string;
|
|
13
14
|
}
|
|
14
15
|
declare const InlineCard: {
|
|
15
|
-
({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, }: InlineCardProps): JSX.Element;
|
|
16
|
+
({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, "data-testid": dataTestId, }: InlineCardProps): JSX.Element;
|
|
16
17
|
Media: ({ children, variant }: import("./_InlineCardMedia.component").InlineCardMediaProps) => JSX.Element;
|
|
17
18
|
Content: ({ children, center }: import("./_InlineCardContent.component").InlineCardContentProps) => JSX.Element;
|
|
18
19
|
Meta: ({ children }: import("./_InlineCardMeta.component").InlineCardMetaProps) => JSX.Element;
|
|
@@ -105,7 +105,7 @@ const SelectIconContainer = styled.div `
|
|
|
105
105
|
|
|
106
106
|
color: ${(props) => props.theme.colours.statusInfo.contrast};
|
|
107
107
|
`;
|
|
108
|
-
const InlineCard = ({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, }) => {
|
|
108
|
+
const InlineCard = ({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, 'data-testid': dataTestId, }) => {
|
|
109
109
|
const { value: selectedValues, onToggle } = useContext(InlineCardSelectionContext);
|
|
110
110
|
const isSelectable = !!onToggle;
|
|
111
111
|
const isSelected = selectedValues?.length && value && selectedValues.includes(value);
|
|
@@ -136,7 +136,7 @@ const InlineCard = ({ children, size, value, onClick, gestureLeftIcon, gestureLe
|
|
|
136
136
|
};
|
|
137
137
|
return (React.createElement(CardWrapper, { size: size },
|
|
138
138
|
React.createElement(CardActionBackground, { style: { opacity, backgroundColor: gestureLeftTheme.main } }, gestureLeftIcon && (React.createElement(FontAwesomeIcon, { style: { fontSize: '20px', color: gestureLeftTheme.contrast }, icon: gestureLeftIcon }))),
|
|
139
|
-
React.createElement(CardOuter, { drag: onGestureLeft ? 'x' : undefined, onDragEnd: handleDragEnd, ref: ref, style: { x }, animate: { x: gestureLeftActivated ? -bounds.width : undefined, opacity: gestureLeftActivated ? 0 : undefined }, dragConstraints: { left: 0, right: 0 }, usePointer: !!onClick || isSelectable, onClick: handleClick, "data-
|
|
139
|
+
React.createElement(CardOuter, { drag: onGestureLeft ? 'x' : undefined, onDragEnd: handleDragEnd, ref: ref, style: { x }, animate: { x: gestureLeftActivated ? -bounds.width : undefined, opacity: gestureLeftActivated ? 0 : undefined }, dragConstraints: { left: 0, right: 0 }, usePointer: !!onClick || isSelectable, onClick: handleClick, "data-testid": dataTestId || 'inline-card' }, children),
|
|
140
140
|
isSelectable && isSelected ? (React.createElement(SelectChecked, null,
|
|
141
141
|
React.createElement(SelectIconContainer, null,
|
|
142
142
|
React.createElement(FontAwesomeIcon, { icon: faCheck })))) : null));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { SelectOption } from '../common/Options.component';
|
|
2
3
|
export interface IInputProps {
|
|
3
4
|
'name'?: string;
|
|
4
5
|
'label'?: string;
|
|
@@ -12,7 +13,8 @@ export interface IInputProps {
|
|
|
12
13
|
'onChange'?: (value: any) => void;
|
|
13
14
|
'onFocus'?: () => void;
|
|
14
15
|
'onBlur'?: () => void;
|
|
15
|
-
'data-
|
|
16
|
+
'data-testid'?: string;
|
|
17
|
+
'suggestions'?: SelectOption[];
|
|
16
18
|
}
|
|
17
19
|
declare const Input: React.ForwardRefExoticComponent<IInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
18
20
|
export default Input;
|
|
@@ -8,9 +8,10 @@ import ControlDescription from '../../shared/ControlDescription';
|
|
|
8
8
|
import ControlLabel from '../../shared/ControlLabel';
|
|
9
9
|
import { ControlStyles } from '../../shared/ControlStyles';
|
|
10
10
|
import useFormNode, { getValue } from '../Form/useFormNode.hook';
|
|
11
|
+
import { OptionsPopper } from '../common/Options.component';
|
|
11
12
|
const InputContainer = styled.div `
|
|
12
13
|
position: relative;
|
|
13
|
-
|
|
14
|
+
border-radius: 2px;
|
|
14
15
|
|
|
15
16
|
background-color: ${(props) => props.theme.colours.controlBackground};
|
|
16
17
|
`;
|
|
@@ -62,11 +63,22 @@ const messageVariants = {
|
|
|
62
63
|
errorFocus: { opacity: 1, y: -4 },
|
|
63
64
|
};
|
|
64
65
|
const Input = React.forwardRef(function ForwardRefInput(props, ref) {
|
|
65
|
-
const { label, name, description, placeholder, disabled, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-
|
|
66
|
+
const { label, name, description, placeholder, disabled, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-testid': dataTestId, suggestions, } = props;
|
|
67
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
66
68
|
const [isFocused, setIsFocused] = useState(false);
|
|
69
|
+
const [referenceElement, setReferenceElement] = useState();
|
|
67
70
|
const { value: contextValue, error: contextError, onChange: contextOnChange } = useFormNode(name);
|
|
68
71
|
const error = contextError || propsError;
|
|
69
72
|
const splitDescription = description ? description.split('\\n').map((str) => str.trim()) : undefined;
|
|
73
|
+
const handleSetSuggestion = (value) => {
|
|
74
|
+
setIsOpen(false);
|
|
75
|
+
if (onChange) {
|
|
76
|
+
onChange(value);
|
|
77
|
+
}
|
|
78
|
+
if (contextOnChange) {
|
|
79
|
+
contextOnChange(value);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
70
82
|
const handleChange = (e) => {
|
|
71
83
|
if (onChange) {
|
|
72
84
|
onChange(e.target.value);
|
|
@@ -87,17 +99,22 @@ const Input = React.forwardRef(function ForwardRefInput(props, ref) {
|
|
|
87
99
|
onBlur();
|
|
88
100
|
}
|
|
89
101
|
};
|
|
102
|
+
const handleClick = () => {
|
|
103
|
+
setIsOpen(true);
|
|
104
|
+
};
|
|
90
105
|
const animationVariant = error ? (isFocused ? 'errorFocus' : 'error') : undefined;
|
|
106
|
+
const filteredOptions = suggestions?.filter((option) => !value || option.label.toLowerCase().includes(value.toLowerCase()));
|
|
91
107
|
return (React.createElement("div", null,
|
|
92
108
|
label && React.createElement(ControlLabel, { htmlFor: name }, label),
|
|
93
|
-
React.createElement(InputContainer, { "data-
|
|
94
|
-
React.createElement(StyledInput, { ref: ref, animate: animationVariant, variants: inputVariants, transition: { type: 'spring', duration: 0.3 }, type: type, name: name, placeholder: placeholder, disabled: disabled, value: getValue(value, contextValue), onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, autoFocus: autoFocus, "data-
|
|
95
|
-
React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-
|
|
109
|
+
React.createElement(InputContainer, { "data-testid": dataTestId, ref: setReferenceElement },
|
|
110
|
+
React.createElement(StyledInput, { ref: ref, animate: animationVariant, variants: inputVariants, transition: { type: 'spring', duration: 0.3 }, type: type, name: name, placeholder: placeholder, disabled: disabled, value: getValue(value, contextValue), onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onClick: handleClick, autoFocus: autoFocus, "data-testid": 'input' }),
|
|
111
|
+
React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-testid": 'error-indicator' },
|
|
96
112
|
React.createElement(ErrorInner, null,
|
|
97
113
|
React.createElement(FontAwesomeIcon, { icon: faExclamationCircle }))),
|
|
98
|
-
error && (React.createElement(ErrorMessage, { style: { opacity: 0, y: 0 }, animate: animationVariant, variants: messageVariants, transition: { type: 'spring', duration: 0.3 }, "data-
|
|
114
|
+
error && (React.createElement(ErrorMessage, { style: { opacity: 0, y: 0 }, animate: animationVariant, variants: messageVariants, transition: { type: 'spring', duration: 0.3 }, "data-testid": 'error-message' }, error))),
|
|
99
115
|
splitDescription && (React.createElement(ControlDescription, null, splitDescription.map((line, index) => (React.createElement(React.Fragment, null,
|
|
100
116
|
index !== 0 && React.createElement("br", null),
|
|
101
|
-
line)))))
|
|
117
|
+
line))))),
|
|
118
|
+
filteredOptions && isOpen && (React.createElement(OptionsPopper, { referenceElement: referenceElement, options: filteredOptions, onSelect: handleSetSuggestion, onClose: () => setIsOpen(false) }))));
|
|
102
119
|
});
|
|
103
120
|
export default Input;
|
|
@@ -5,7 +5,7 @@ interface LiveInputProps {
|
|
|
5
5
|
'type'?: string;
|
|
6
6
|
'value'?: string;
|
|
7
7
|
'onChange'?: (value: string) => void;
|
|
8
|
-
'data-
|
|
8
|
+
'data-testid'?: string;
|
|
9
9
|
}
|
|
10
|
-
declare const LiveInput: ({ name, type, placeholder, value, onChange, "data-
|
|
10
|
+
declare const LiveInput: ({ name, type, placeholder, value, onChange, "data-testid": dataTestId, }: LiveInputProps) => JSX.Element;
|
|
11
11
|
export default LiveInput;
|
|
@@ -14,7 +14,7 @@ const StyledInput = styled.input `
|
|
|
14
14
|
color: ${(props) => props.theme.colours.controlPlaceholder};
|
|
15
15
|
}
|
|
16
16
|
`;
|
|
17
|
-
const LiveInput = ({ name, type = 'text', placeholder, value, onChange, 'data-
|
|
17
|
+
const LiveInput = ({ name, type = 'text', placeholder, value, onChange, 'data-testid': dataTestId, }) => {
|
|
18
18
|
const { value: contextValue, onChange: contextOnChange } = useFormNode(name);
|
|
19
19
|
const handleChange = (e) => {
|
|
20
20
|
if (onChange) {
|
|
@@ -25,6 +25,6 @@ const LiveInput = ({ name, type = 'text', placeholder, value, onChange, 'data-cy
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
return (React.createElement("div", null,
|
|
28
|
-
React.createElement(StyledInput, { name: name, type: type, value: value || contextValue, placeholder: placeholder, onChange: handleChange, "data-
|
|
28
|
+
React.createElement(StyledInput, { name: name, type: type, value: value || contextValue, placeholder: placeholder, onChange: handleChange, "data-testid": dataTestId || 'live-input' })));
|
|
29
29
|
};
|
|
30
30
|
export default LiveInput;
|
|
@@ -100,10 +100,10 @@ const LiveList = ({ value: inputValue, name, onChange: propsOnChange }) => {
|
|
|
100
100
|
if (!value?.length) {
|
|
101
101
|
return null;
|
|
102
102
|
}
|
|
103
|
-
return (React.createElement("div", { "data-
|
|
103
|
+
return (React.createElement("div", { "data-testid": 'live-list' },
|
|
104
104
|
value.map((val) => (React.createElement(LiveListRow, { key: val.id, id: val.id, value: val.value, error: contextError ? contextError[val.id] : undefined, onChange: (newVal) => handleRowChange(val.id, newVal), onRemove: () => handleRowRemove(val.id) }))),
|
|
105
105
|
React.createElement(AddRow, null,
|
|
106
|
-
React.createElement(AddRowInner, { style: { scale: 1 }, whileHover: 'hover', variants: addVariants, onClick: handleRowAdd, "data-
|
|
106
|
+
React.createElement(AddRowInner, { style: { scale: 1 }, whileHover: 'hover', variants: addVariants, onClick: handleRowAdd, "data-testid": 'button-add-list-item' },
|
|
107
107
|
React.createElement(IconContainer, null,
|
|
108
108
|
React.createElement(FontAwesomeIcon, { icon: faPlusCircle })),
|
|
109
109
|
"add"))));
|
|
@@ -59,10 +59,10 @@ const LiveListRow = ({ id, value, error, onChange, onRemove }) => {
|
|
|
59
59
|
setIsFocused(false);
|
|
60
60
|
onBlur(id);
|
|
61
61
|
};
|
|
62
|
-
return (React.createElement(InputContainer, { whileHover: 'hover', "data-
|
|
63
|
-
React.createElement(Input, { onFocus: handleFocus, onBlur: handleBlur, ref: inputRef, value: value || '', error: error, onChange: handleChange, "data-
|
|
62
|
+
return (React.createElement(InputContainer, { whileHover: 'hover', "data-testid": 'live-list-row' },
|
|
63
|
+
React.createElement(Input, { onFocus: handleFocus, onBlur: handleBlur, ref: inputRef, value: value || '', error: error, onChange: handleChange, "data-testid": 'live-list-input' }),
|
|
64
64
|
React.createElement(RemoveContainer, { animate: isFocused ? 'focus' : undefined, style: { opacity: 0 }, variants: removeVariants, transition: { type: 'spring', duration: 0.3 } },
|
|
65
|
-
React.createElement(RemoveInner, { onClick: onRemove, "data-
|
|
65
|
+
React.createElement(RemoveInner, { onClick: onRemove, "data-testid": 'live-list-remove' },
|
|
66
66
|
React.createElement(FontAwesomeIcon, { icon: faTimes })))));
|
|
67
67
|
};
|
|
68
68
|
export default LiveListRow;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { motion } from 'framer-motion';
|
|
3
|
+
import styled from 'styled-components';
|
|
3
4
|
import colours from '../../colours/colours';
|
|
5
|
+
const PageLoaderContainer = styled.div `
|
|
6
|
+
display: flex;
|
|
7
|
+
height: 300px;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
align-items: center;
|
|
10
|
+
`;
|
|
4
11
|
const loadingContainer = {
|
|
5
12
|
width: '40px',
|
|
6
13
|
height: '26px',
|
|
@@ -40,10 +47,15 @@ const loadingCircleTransition = {
|
|
|
40
47
|
repeatType: 'reverse',
|
|
41
48
|
ease: 'easeInOut',
|
|
42
49
|
}; // Framer motion isn't accepting 'repeatType' but animation breaks without it
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
const BaseLoader = () => (React.createElement(motion.div, { style: loadingContainer, variants: loadingContainerVariants, initial: 'start', animate: 'end', "data-testid": 'loader' },
|
|
51
|
+
React.createElement(motion.span, { style: loadingCircle, variants: loadingCircleVariants, transition: loadingCircleTransition }),
|
|
52
|
+
React.createElement(motion.span, { style: loadingCircle, variants: loadingCircleVariants, transition: loadingCircleTransition }),
|
|
53
|
+
React.createElement(motion.span, { style: loadingCircle, variants: loadingCircleVariants, transition: loadingCircleTransition })));
|
|
54
|
+
const Loader = ({ variant = 'default' }) => {
|
|
55
|
+
if (variant === 'page-loader') {
|
|
56
|
+
return (React.createElement(PageLoaderContainer, null,
|
|
57
|
+
React.createElement(BaseLoader, null)));
|
|
58
|
+
}
|
|
59
|
+
return React.createElement(BaseLoader, null);
|
|
48
60
|
};
|
|
49
61
|
export default Loader;
|
|
@@ -38,8 +38,8 @@ const MenuToggle = styled.div `
|
|
|
38
38
|
`;
|
|
39
39
|
const MenuHeading = ({ children, onOpen, onClose, isOpen }) => (React.createElement(MenuHeadingDiv, null,
|
|
40
40
|
React.createElement(MenuHeadingInner, null,
|
|
41
|
-
isOpen ? (React.createElement(MenuToggle, { onClick: onClose, "data-
|
|
42
|
-
React.createElement(FontAwesomeIcon, { icon: faBars }))) : (React.createElement(MenuToggle, { onClick: onOpen, "data-
|
|
41
|
+
isOpen ? (React.createElement(MenuToggle, { onClick: onClose, "data-testid": 'button-menu-close' },
|
|
42
|
+
React.createElement(FontAwesomeIcon, { icon: faBars }))) : (React.createElement(MenuToggle, { onClick: onOpen, "data-testid": 'button-menu-open' },
|
|
43
43
|
React.createElement(FontAwesomeIcon, { icon: faBars }))),
|
|
44
44
|
children)));
|
|
45
45
|
export default MenuHeading;
|
|
@@ -41,7 +41,7 @@ const MenuActivePlaceholder = styled.div `
|
|
|
41
41
|
height: 100%;
|
|
42
42
|
width: 4px;
|
|
43
43
|
`;
|
|
44
|
-
const MenuItem = ({ children, icon, active, onClick }) => (React.createElement(MenuItemOuter, { onClick: onClick, "data-
|
|
44
|
+
const MenuItem = ({ children, icon, active, onClick }) => (React.createElement(MenuItemOuter, { onClick: onClick, "data-testid": 'menu-item' },
|
|
45
45
|
active ? React.createElement(MenuActiveBar, null) : React.createElement(MenuActivePlaceholder, null),
|
|
46
46
|
React.createElement(MenuItemDiv, { active: active },
|
|
47
47
|
icon && (React.createElement(MenuIconContainer, null,
|
|
@@ -55,6 +55,6 @@ ${(props) => responsive.useStylesFor('desktop').andLarger(props.scrollable
|
|
|
55
55
|
: ``)}
|
|
56
56
|
`;
|
|
57
57
|
const MenuPanel = ({ children, scrollable, panelSize = 'sm' }) => {
|
|
58
|
-
return (React.createElement(MenuPanelDiv, { panelSize: panelSize, scrollable: scrollable, "data-
|
|
58
|
+
return (React.createElement(MenuPanelDiv, { panelSize: panelSize, scrollable: scrollable, "data-testid": 'menu-panel' }, children));
|
|
59
59
|
};
|
|
60
60
|
export default MenuPanel;
|
|
@@ -4,7 +4,8 @@ export interface MinimalMenuProps {
|
|
|
4
4
|
}
|
|
5
5
|
declare const MinimalMenu: {
|
|
6
6
|
({ children }: MinimalMenuProps): JSX.Element;
|
|
7
|
-
|
|
7
|
+
Header: ({ hiddenMenu, text, rightContent }: import("./_MinimalMenuHeader.component").MinimalMenuHeaderProps) => JSX.Element;
|
|
8
|
+
Item: ({ icon, active, onClick, "data-testid": dataTestId }: import("./_MinimalMenuItem.component").MinimalMenuItemProps) => JSX.Element;
|
|
8
9
|
Page: ({ children, hiddenMenu }: import("./_MinimalMenuPage.component").MinimalMenuPageProps) => JSX.Element;
|
|
9
10
|
};
|
|
10
11
|
export default MinimalMenu;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIsScreenSize } from '../../responsive/responsive';
|
|
3
|
+
import MinimalMenuHeader from './_MinimalMenuHeader.component';
|
|
3
4
|
import MinimalMenuItem from './_MinimalMenuItem.component';
|
|
4
5
|
import MinimalMenuPage from './_MinimalMenuPage.component';
|
|
5
6
|
import DesktopMinimalMenuContainer from './desktop/_DesktopMinimalMenuContainer.component';
|
|
@@ -11,6 +12,7 @@ const MinimalMenu = ({ children }) => {
|
|
|
11
12
|
}
|
|
12
13
|
return React.createElement(DesktopMinimalMenuContainer, null, children);
|
|
13
14
|
};
|
|
15
|
+
MinimalMenu.Header = MinimalMenuHeader;
|
|
14
16
|
MinimalMenu.Item = MinimalMenuItem;
|
|
15
17
|
MinimalMenu.Page = MinimalMenuPage;
|
|
16
18
|
export default MinimalMenu;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MinimalMenuHeaderProps {
|
|
3
|
+
/** Set the page to be in hidden menu mode.
|
|
4
|
+
* This is useful for rendering your app and preventing re-renders between a un-authenticated no-menu mode and the regular authenticated mode
|
|
5
|
+
**/
|
|
6
|
+
hiddenMenu?: boolean;
|
|
7
|
+
text?: string;
|
|
8
|
+
rightContent?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A header that is designed to be nested within the page content.
|
|
12
|
+
* You can use a header per page or simply use a single header for your entire application.
|
|
13
|
+
*/
|
|
14
|
+
declare const MinimalMenuHeader: ({ hiddenMenu, text, rightContent }: MinimalMenuHeaderProps) => JSX.Element;
|
|
15
|
+
export default MinimalMenuHeader;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
const MinimalMenuHeaderContainer = styled.div ``;
|
|
4
|
+
const Header = styled.div `
|
|
5
|
+
height: 48px;
|
|
6
|
+
background-color: ${(props) => props.theme.colours.cardBackground};
|
|
7
|
+
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
`;
|
|
12
|
+
const HeaderItem = styled.div `
|
|
13
|
+
padding: 0 16px;
|
|
14
|
+
`;
|
|
15
|
+
const TitleText = styled.div `
|
|
16
|
+
font-family: ${(props) => props.theme.fonts.subHeading.family};
|
|
17
|
+
font-size: ${(props) => props.theme.fonts.subHeading.size};
|
|
18
|
+
font-weight: ${(props) => props.theme.fonts.subHeading.weight};
|
|
19
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
20
|
+
`;
|
|
21
|
+
/**
|
|
22
|
+
* A header that is designed to be nested within the page content.
|
|
23
|
+
* You can use a header per page or simply use a single header for your entire application.
|
|
24
|
+
*/
|
|
25
|
+
const MinimalMenuHeader = ({ hiddenMenu, text, rightContent }) => {
|
|
26
|
+
return (React.createElement(MinimalMenuHeaderContainer, { hiddenMenu: !!hiddenMenu },
|
|
27
|
+
React.createElement(Header, null,
|
|
28
|
+
React.createElement(HeaderItem, null, text && React.createElement(TitleText, null, text)),
|
|
29
|
+
React.createElement(HeaderItem, null, rightContent))));
|
|
30
|
+
};
|
|
31
|
+
export default MinimalMenuHeader;
|
|
@@ -4,7 +4,7 @@ export interface MinimalMenuItemProps {
|
|
|
4
4
|
'icon'?: IconProp;
|
|
5
5
|
'active'?: boolean;
|
|
6
6
|
'onClick'?: () => void;
|
|
7
|
-
'data-
|
|
7
|
+
'data-testid'?: string;
|
|
8
8
|
}
|
|
9
|
-
declare const MinimalMenuItem: ({ icon, active, onClick, "data-
|
|
9
|
+
declare const MinimalMenuItem: ({ icon, active, onClick, "data-testid": dataTestId }: MinimalMenuItemProps) => JSX.Element;
|
|
10
10
|
export default MinimalMenuItem;
|
|
@@ -2,11 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { useIsScreenSize } from '../../responsive/responsive';
|
|
3
3
|
import DesktopMinimalMenuItem from './desktop/_DesktopMinimalMenuItem.component';
|
|
4
4
|
import MobileMinimalMenuItem from './mobile/_MobileMinimalMenuItem.component';
|
|
5
|
-
const MinimalMenuItem = ({ icon, active, onClick, 'data-
|
|
5
|
+
const MinimalMenuItem = ({ icon, active, onClick, 'data-testid': dataTestId }) => {
|
|
6
6
|
const isMobile = useIsScreenSize('mobile');
|
|
7
7
|
if (isMobile) {
|
|
8
|
-
return React.createElement(MobileMinimalMenuItem, { icon: icon, active: active, onClick: onClick, "data-
|
|
8
|
+
return React.createElement(MobileMinimalMenuItem, { icon: icon, active: active, onClick: onClick, "data-testid": dataTestId });
|
|
9
9
|
}
|
|
10
|
-
return React.createElement(DesktopMinimalMenuItem, { icon: icon, active: active, onClick: onClick, "data-
|
|
10
|
+
return React.createElement(DesktopMinimalMenuItem, { icon: icon, active: active, onClick: onClick, "data-testid": dataTestId });
|
|
11
11
|
};
|
|
12
12
|
export default MinimalMenuItem;
|
|
@@ -4,7 +4,7 @@ export interface DesktopMinimalMenuItemProps {
|
|
|
4
4
|
'icon'?: IconProp;
|
|
5
5
|
'active'?: boolean;
|
|
6
6
|
'onClick'?: () => void;
|
|
7
|
-
'data-
|
|
7
|
+
'data-testid'?: string;
|
|
8
8
|
}
|
|
9
|
-
declare const DesktopMinimalMenuItem: ({ icon, active, onClick, "data-
|
|
9
|
+
declare const DesktopMinimalMenuItem: ({ icon, active, onClick, "data-testid": dataTestId }: DesktopMinimalMenuItemProps) => JSX.Element;
|
|
10
10
|
export default DesktopMinimalMenuItem;
|
|
@@ -27,14 +27,14 @@ const iconContainerVariants = {
|
|
|
27
27
|
active: { x: 2 },
|
|
28
28
|
hoverActive: { x: 2 },
|
|
29
29
|
};
|
|
30
|
-
const DesktopMinimalMenuItem = ({ icon, active, onClick, 'data-
|
|
30
|
+
const DesktopMinimalMenuItem = ({ icon, active, onClick, 'data-testid': dataTestId }) => {
|
|
31
31
|
const theme = useTheme();
|
|
32
32
|
const barVariants = useMemo(() => ({
|
|
33
33
|
hover: { opacity: 1, backgroundColor: theme.colours.defaultBorder, width: 4 },
|
|
34
34
|
active: { opacity: 1, backgroundColor: theme.colours.primary.main, width: 4 },
|
|
35
35
|
hoverActive: { opacity: 1, backgroundColor: theme.colours.primary.main, width: 4 },
|
|
36
36
|
}), [theme]);
|
|
37
|
-
return (React.createElement(ItemContainer, { whileHover: active ? 'hoverActive' : 'hover', animate: active ? 'active' : undefined, onClick: onClick, "data-
|
|
37
|
+
return (React.createElement(ItemContainer, { whileHover: active ? 'hoverActive' : 'hover', animate: active ? 'active' : undefined, onClick: onClick, "data-testid": dataTestId || 'menu-item' },
|
|
38
38
|
React.createElement(MenuIconBar, { style: { backgroundColor: theme.colours.cardBackground, opacity: 0 }, variants: barVariants, transition: { type: 'spring', duration: 0.3 } }),
|
|
39
39
|
icon && (React.createElement(motion.div, { variants: iconContainerVariants },
|
|
40
40
|
React.createElement(FontAwesomeIcon, { icon: icon })))));
|
|
@@ -4,7 +4,7 @@ export interface MobileMinimalMenuItemProps {
|
|
|
4
4
|
'icon'?: IconProp;
|
|
5
5
|
'active'?: boolean;
|
|
6
6
|
'onClick'?: () => void;
|
|
7
|
-
'data-
|
|
7
|
+
'data-testid'?: string;
|
|
8
8
|
}
|
|
9
|
-
declare const MobileMinimalMenuItem: ({ icon, active, onClick, "data-
|
|
9
|
+
declare const MobileMinimalMenuItem: ({ icon, active, onClick, "data-testid": dataTestId }: MobileMinimalMenuItemProps) => JSX.Element;
|
|
10
10
|
export default MobileMinimalMenuItem;
|
|
@@ -20,7 +20,7 @@ const ItemContainer = styled.div `
|
|
|
20
20
|
const iconContainerVariants = {
|
|
21
21
|
active: { fontSize: '28px', y: -8 },
|
|
22
22
|
};
|
|
23
|
-
const MobileMinimalMenuItem = ({ icon, active, onClick, 'data-
|
|
23
|
+
const MobileMinimalMenuItem = ({ icon, active, onClick, 'data-testid': dataTestId }) => {
|
|
24
24
|
const { width } = useWindowDimensions();
|
|
25
25
|
const { setBumpX } = useContext(MobileMenuBumpContext);
|
|
26
26
|
const itemRef = useRef(null);
|
|
@@ -36,7 +36,7 @@ const MobileMinimalMenuItem = ({ icon, active, onClick, 'data-cy': dataCy }) =>
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
}, [active, setBumpX, width]);
|
|
39
|
-
return (React.createElement(ItemContainer, { onClick: onClick, ref: itemRef, "data-
|
|
39
|
+
return (React.createElement(ItemContainer, { onClick: onClick, ref: itemRef, "data-testid": dataTestId || 'menu-item' }, icon && (React.createElement(motion.div, { animate: active ? 'active' : undefined, style: { fontSize: '20px' }, variants: iconContainerVariants, transition: mobileMenuDefaultTransition },
|
|
40
40
|
React.createElement(FontAwesomeIcon, { icon: icon })))));
|
|
41
41
|
};
|
|
42
42
|
export default MobileMinimalMenuItem;
|
|
@@ -90,7 +90,7 @@ const Modal = ({ children, size, loading, onClose }) => {
|
|
|
90
90
|
React.createElement(ScrollContainer, null,
|
|
91
91
|
React.createElement(ModalContext.Provider, { value: { onClose } },
|
|
92
92
|
React.createElement(ModalWrapper, { size: size || 'md' },
|
|
93
|
-
React.createElement(ModalOuter, { transition: { type: 'spring', bounce: 0, duration: 0.6 }, initial: { height: loading ? loadingHeight : 'auto' }, animate: { height: loading ? loadingHeight : 'auto' }, size: size || 'md', onClick: handleModalClick, "data-
|
|
93
|
+
React.createElement(ModalOuter, { transition: { type: 'spring', bounce: 0, duration: 0.6 }, initial: { height: loading ? loadingHeight : 'auto' }, animate: { height: loading ? loadingHeight : 'auto' }, size: size || 'md', onClick: handleModalClick, "data-testid": 'modal' },
|
|
94
94
|
!loading && children,
|
|
95
95
|
loading && (React.createElement(SpinnerContainer, null,
|
|
96
96
|
React.createElement(Loader, null))))))))), document.body);
|
|
@@ -43,12 +43,12 @@ const IconClickableArea = styled.div `
|
|
|
43
43
|
`;
|
|
44
44
|
const ModalHeader = ({ header, subHeader }) => {
|
|
45
45
|
const { onClose } = useContext(ModalContext);
|
|
46
|
-
return (React.createElement(HeaderContainer, { "data-
|
|
46
|
+
return (React.createElement(HeaderContainer, { "data-testid": 'modal-header' },
|
|
47
47
|
React.createElement(TextContainer, null,
|
|
48
48
|
React.createElement(HeaderText, null, header),
|
|
49
49
|
SubHeaderText && React.createElement(SubHeaderText, null, subHeader)),
|
|
50
50
|
React.createElement(IconContainer, null,
|
|
51
|
-
React.createElement(IconClickableArea, { onClick: onClose, "data-
|
|
51
|
+
React.createElement(IconClickableArea, { onClick: onClose, "data-testid": 'button-modal-close' },
|
|
52
52
|
React.createElement(FontAwesomeIcon, { icon: faTimes })))));
|
|
53
53
|
};
|
|
54
54
|
export default ModalHeader;
|
|
@@ -10,6 +10,6 @@ const NotificationContainer = styled.div `
|
|
|
10
10
|
`)}
|
|
11
11
|
}
|
|
12
12
|
`;
|
|
13
|
-
const Notification = (props) => (React.createElement(NotificationContainer, { "data-
|
|
13
|
+
const Notification = (props) => (React.createElement(NotificationContainer, { "data-testid": 'notification' },
|
|
14
14
|
React.createElement(Alert, { ...props })));
|
|
15
15
|
export default Notification;
|
|
@@ -44,10 +44,10 @@ const Identicon = ({ value }) => {
|
|
|
44
44
|
};
|
|
45
45
|
const ProfileImage = ({ name, image }) => {
|
|
46
46
|
if (image) {
|
|
47
|
-
return (React.createElement(ImageContainer, { "data-
|
|
47
|
+
return (React.createElement(ImageContainer, { "data-testid": 'profile-image' },
|
|
48
48
|
React.createElement(Image, { src: image })));
|
|
49
49
|
}
|
|
50
|
-
return (React.createElement(ImageContainer, { "data-
|
|
50
|
+
return (React.createElement(ImageContainer, { "data-testid": 'profile-image' },
|
|
51
51
|
React.createElement(Identicon, { value: name })));
|
|
52
52
|
};
|
|
53
53
|
export default ProfileImage;
|
|
@@ -61,11 +61,11 @@ const QrCode = ({ value }) => {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
}, [value]);
|
|
64
|
-
return (React.createElement(Container, { onClick: () => showHint(), "data-
|
|
64
|
+
return (React.createElement(Container, { onClick: () => showHint(), "data-testid": 'qrcode' },
|
|
65
65
|
copiedHint && (React.createElement(ToastContainer, null,
|
|
66
66
|
React.createElement(Toast, null,
|
|
67
67
|
React.createElement(StyledText, null, "Copied!")))),
|
|
68
|
-
React.createElement(CopyInput, { readOnly: true, ref: inputRef, value: value, "data-
|
|
68
|
+
React.createElement(CopyInput, { readOnly: true, ref: inputRef, value: value, "data-testid": 'input-qrcode-hidden' }),
|
|
69
69
|
React.createElement(StyledCanvas, { ref: ref })));
|
|
70
70
|
};
|
|
71
71
|
export default QrCode;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
value: string;
|
|
4
|
-
label: string;
|
|
5
|
-
};
|
|
2
|
+
import { SelectOption } from '../common/Options.component';
|
|
6
3
|
export interface ISelectProps {
|
|
7
4
|
'name'?: string;
|
|
8
5
|
'label'?: string;
|
|
@@ -10,7 +7,7 @@ export interface ISelectProps {
|
|
|
10
7
|
'placeholder'?: string;
|
|
11
8
|
'value'?: string;
|
|
12
9
|
'onChange'?: (value: any) => void;
|
|
13
|
-
'data-
|
|
10
|
+
'data-testid'?: string;
|
|
14
11
|
'options': SelectOption[];
|
|
15
12
|
}
|
|
16
13
|
declare const Select: (props: ISelectProps) => JSX.Element;
|