@dtdot/lego 2.0.0-2 → 2.0.0-20

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 (96) hide show
  1. package/build/components/ActionMenu/ActionMenu.component.d.ts +7 -4
  2. package/build/components/ActionMenu/ActionMenu.component.js +3 -17
  3. package/build/components/ActionMenu/_ActionMenuCheckbox.component.d.ts +2 -2
  4. package/build/components/ActionMenu/_ActionMenuCheckbox.component.js +2 -2
  5. package/build/components/ActionMenu/_ActionMenuItem.component.d.ts +2 -2
  6. package/build/components/ActionMenu/_ActionMenuItem.component.js +2 -2
  7. package/build/components/ActionMenu/_ActionMenuPanel.component.js +1 -1
  8. package/build/components/ActionMessage/ActionMessage.component.js +1 -1
  9. package/build/components/Alert/Alert.component.js +3 -3
  10. package/build/components/Badge/Badge.component.js +1 -1
  11. package/build/components/BadgeSelector/BadgeSelector.component.js +1 -1
  12. package/build/components/Button/Button.component.d.ts +6 -2
  13. package/build/components/Button/Button.component.js +74 -14
  14. package/build/components/Button/Button.context.d.ts +1 -0
  15. package/build/components/Button/Button.context.js +1 -0
  16. package/build/components/Card/Card.component.d.ts +7 -6
  17. package/build/components/Card/Card.component.js +2 -2
  18. package/build/components/Card/_CardHeader.component.js +4 -2
  19. package/build/components/Card/_CardToggleSection.component.d.ts +6 -5
  20. package/build/components/Card/_CardToggleSection.component.js +2 -2
  21. package/build/components/Checklist/Checklist.component.js +1 -1
  22. package/build/components/Checklist/_ChecklistItem.component.js +1 -1
  23. package/build/components/ControlLine/ControlLine.component.d.ts +7 -0
  24. package/build/components/ControlLine/ControlLine.component.js +33 -0
  25. package/build/components/FancyCheckbox/FancyCheckbox.component.js +1 -1
  26. package/build/components/Form/Form.component.d.ts +4 -1
  27. package/build/components/Form/Form.component.js +2 -0
  28. package/build/components/Form/_NestedFormArray.d.ts +8 -0
  29. package/build/components/Form/_NestedFormArray.js +23 -0
  30. package/build/components/Heading/Heading.component.d.ts +1 -0
  31. package/build/components/Heading/Heading.component.js +2 -0
  32. package/build/components/Heading/_DividerHeading.component.d.ts +2 -0
  33. package/build/components/Heading/_DividerHeading.component.js +15 -0
  34. package/build/components/ImageUpload/ImageUpload.component.d.ts +2 -2
  35. package/build/components/ImageUpload/ImageUpload.component.js +10 -10
  36. package/build/components/InlineCard/InlineCard.component.d.ts +8 -7
  37. package/build/components/InlineCard/InlineCard.component.js +2 -2
  38. package/build/components/Input/Input.component.d.ts +3 -1
  39. package/build/components/Input/Input.component.js +24 -7
  40. package/build/components/LiveInput/LiveInput.component.d.ts +2 -2
  41. package/build/components/LiveInput/LiveInput.component.js +2 -2
  42. package/build/components/LiveList/LiveList.component.js +2 -2
  43. package/build/components/LiveList/_LiveListRow.js +3 -3
  44. package/build/components/Loader/Loader.component.d.ts +4 -1
  45. package/build/components/Loader/Loader.component.js +17 -5
  46. package/build/components/Menu/_MenuHeading.component.js +2 -2
  47. package/build/components/Menu/_MenuItem.component.js +1 -1
  48. package/build/components/Menu/_MenuPanel.component.js +1 -1
  49. package/build/components/MinimalMenu/MinimalMenu.component.d.ts +2 -1
  50. package/build/components/MinimalMenu/MinimalMenu.component.js +2 -0
  51. package/build/components/MinimalMenu/_MinimalMenuHeader.component.d.ts +15 -0
  52. package/build/components/MinimalMenu/_MinimalMenuHeader.component.js +31 -0
  53. package/build/components/MinimalMenu/_MinimalMenuItem.component.d.ts +2 -2
  54. package/build/components/MinimalMenu/_MinimalMenuItem.component.js +3 -3
  55. package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.d.ts +2 -2
  56. package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.js +2 -2
  57. package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.d.ts +2 -2
  58. package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.js +2 -2
  59. package/build/components/Modal/Modal.component.js +1 -1
  60. package/build/components/Modal/_ModalHeader.component.js +2 -2
  61. package/build/components/Notification/Notification.component.js +1 -1
  62. package/build/components/ProfileImage/ProfileImage.component.js +2 -2
  63. package/build/components/QrCode/QrCode.component.js +2 -2
  64. package/build/components/Select/Select.component.d.ts +2 -5
  65. package/build/components/Select/Select.component.js +12 -29
  66. package/build/components/Spacer/Spacer.component.d.ts +1 -1
  67. package/build/components/Spacer/Spacer.component.js +2 -0
  68. package/build/components/SquareButton/SquareButton.component.d.ts +2 -2
  69. package/build/components/SquareButton/SquareButton.component.js +2 -2
  70. package/build/components/Table/Table.component.d.ts +5 -3
  71. package/build/components/Table/Table.component.js +14 -0
  72. package/build/components/Table/_TableAction.d.ts +7 -3
  73. package/build/components/Table/_TableAction.js +6 -3
  74. package/build/components/Table/_TableActionMenu.d.ts +2 -2
  75. package/build/components/Table/_TableActionMenu.js +2 -2
  76. package/build/components/Table/_TableRow.component.d.ts +2 -2
  77. package/build/components/Table/_TableRow.component.js +2 -2
  78. package/build/components/Text/Text.component.d.ts +4 -3
  79. package/build/components/Text/Text.component.js +3 -3
  80. package/build/components/TextArea/TextArea.component.d.ts +1 -1
  81. package/build/components/TextArea/TextArea.component.js +5 -5
  82. package/build/components/Toggle/Toggle.component.js +1 -1
  83. package/build/components/common/Options.component.d.ts +19 -0
  84. package/build/components/common/Options.component.js +44 -0
  85. package/build/index.d.ts +1 -0
  86. package/build/index.js +1 -0
  87. package/build/screens/Login/Login.screen.js +4 -4
  88. package/build/screens/Register/Register.screen.js +3 -3
  89. package/build/screens/Verification/Verification.screen.js +2 -2
  90. package/build/shared/ControlStyles.js +1 -1
  91. package/build/theme/dark.theme.js +20 -8
  92. package/build/theme/default.theme.js +6 -0
  93. package/build/theme/helpers/getThemeVariantColours.d.ts +1 -5
  94. package/build/theme/helpers/getThemeVariantColours.js +3 -15
  95. package/build/theme/theme.types.d.ts +2 -0
  96. 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-cy': dataCy, }) => {
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-cy": dataCy },
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-cy": dataCy },
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-cy": 'button-image-upload' },
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-cy": 'button-image-search' },
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-cy": 'input-image-hidden' }),
142
- error && (React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-cy": 'error-indicator' },
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-cy": 'error-message' }, error)))));
145
+ React.createElement(ErrorMessage, { "data-testid": 'error-message' }, error)))));
146
146
  }
147
- return (React.createElement("div", { "data-cy": dataCy },
148
- React.createElement(Image, { "data-cy": 'uploaded-image', src: getUrl(internalValue) })));
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-cy": 'inline-card' }, children),
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-cy'?: string;
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
- margin: 2px 0;
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-cy': dataCy, } = props;
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-cy": dataCy },
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-cy": 'input' }),
95
- React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-cy": 'error-indicator' },
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-cy": 'error-message' }, error))),
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-cy'?: string;
8
+ 'data-testid'?: string;
9
9
  }
10
- declare const LiveInput: ({ name, type, placeholder, value, onChange, "data-cy": dataCy }: LiveInputProps) => JSX.Element;
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-cy': dataCy }) => {
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-cy": dataCy || 'live-input' })));
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-cy": 'live-list' },
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-cy": 'button-add-list-item' },
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-cy": 'live-list-row' },
63
- React.createElement(Input, { onFocus: handleFocus, onBlur: handleBlur, ref: inputRef, value: value || '', error: error, onChange: handleChange, "data-cy": 'live-list-input' }),
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-cy": 'live-list-remove' },
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,3 +1,6 @@
1
1
  /// <reference types="react" />
2
- declare const Loader: () => JSX.Element;
2
+ export interface LoaderProps {
3
+ variant?: 'page-loader' | 'default';
4
+ }
5
+ declare const Loader: ({ variant }: LoaderProps) => JSX.Element;
3
6
  export default Loader;
@@ -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 Loader = () => {
44
- return (React.createElement(motion.div, { style: loadingContainer, variants: loadingContainerVariants, initial: 'start', animate: 'end', "data-cy": 'loader' },
45
- React.createElement(motion.span, { style: loadingCircle, variants: loadingCircleVariants, transition: loadingCircleTransition }),
46
- React.createElement(motion.span, { style: loadingCircle, variants: loadingCircleVariants, transition: loadingCircleTransition }),
47
- React.createElement(motion.span, { style: loadingCircle, variants: loadingCircleVariants, transition: loadingCircleTransition })));
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-cy": 'button-menu-close' },
42
- React.createElement(FontAwesomeIcon, { icon: faBars }))) : (React.createElement(MenuToggle, { onClick: onOpen, "data-cy": 'button-menu-open' },
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-cy": 'menu-item' },
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-cy": 'menu-panel' }, children));
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
- Item: ({ icon, active, onClick, "data-cy": dataCy }: import("./_MinimalMenuItem.component").MinimalMenuItemProps) => JSX.Element;
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-cy'?: string;
7
+ 'data-testid'?: string;
8
8
  }
9
- declare const MinimalMenuItem: ({ icon, active, onClick, "data-cy": dataCy }: MinimalMenuItemProps) => JSX.Element;
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-cy': dataCy }) => {
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-cy": dataCy });
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-cy": dataCy });
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-cy'?: string;
7
+ 'data-testid'?: string;
8
8
  }
9
- declare const DesktopMinimalMenuItem: ({ icon, active, onClick, "data-cy": dataCy }: DesktopMinimalMenuItemProps) => JSX.Element;
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-cy': dataCy }) => {
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-cy": dataCy || 'menu-item' },
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-cy'?: string;
7
+ 'data-testid'?: string;
8
8
  }
9
- declare const MobileMinimalMenuItem: ({ icon, active, onClick, "data-cy": dataCy }: MobileMinimalMenuItemProps) => JSX.Element;
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-cy': dataCy }) => {
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-cy": dataCy || 'menu-item' }, icon && (React.createElement(motion.div, { animate: active ? 'active' : undefined, style: { fontSize: '20px' }, variants: iconContainerVariants, transition: mobileMenuDefaultTransition },
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-cy": 'modal' },
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-cy": 'modal-header' },
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-cy": 'button-modal-close' },
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-cy": 'notification' },
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-cy": 'profile-image' },
47
+ return (React.createElement(ImageContainer, { "data-testid": 'profile-image' },
48
48
  React.createElement(Image, { src: image })));
49
49
  }
50
- return (React.createElement(ImageContainer, { "data-cy": 'profile-image' },
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-cy": 'qrcode' },
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-cy": 'input-qrcode-hidden' }),
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
- export type SelectOption = {
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-cy'?: string;
10
+ 'data-testid'?: string;
14
11
  'options': SelectOption[];
15
12
  }
16
13
  declare const Select: (props: ISelectProps) => JSX.Element;