@dtdot/lego 2.0.0-3 → 2.0.0-32
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 +4 -4
- package/build/components/ActionMenu/ActionMenu.component.js +3 -3
- 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 +1 -1
- package/build/components/Button/Button.component.js +19 -11
- 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/InlineCard/_InlineCardContent.component.js +2 -0
- package/build/components/InlineCard/_InlineCardMeta.component.js +1 -0
- package/build/components/Input/Input.component.d.ts +5 -1
- package/build/components/Input/Input.component.js +38 -8
- 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 +9 -1
- package/build/components/Loader/Loader.component.js +38 -6
- 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 +3 -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/_MobileMenu.constants.js +1 -1
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuContainer.component.js +5 -25
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.d.ts +3 -2
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.js +18 -24
- package/build/components/Modal/Modal.component.d.ts +6 -5
- package/build/components/Modal/Modal.component.js +2 -2
- 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 +3 -2
- package/build/components/Table/_TableRow.component.js +10 -4
- package/build/components/Text/Text.component.d.ts +5 -3
- package/build/components/Text/Text.component.js +21 -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 +50 -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 +4 -2
- package/package.json +5 -12
- package/build/components/MinimalMenu/mobile/_MobileMenuBump.component.d.ts +0 -3
- package/build/components/MinimalMenu/mobile/_MobileMenuBump.component.js +0 -4
- package/build/components/MinimalMenu/mobile/_MobileMenuBump.context.d.ts +0 -6
- package/build/components/MinimalMenu/mobile/_MobileMenuBump.context.js +0 -6
|
@@ -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;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
2
|
-
import React, { useState } from 'react';
|
|
2
|
+
import React, { Fragment, useState } from 'react';
|
|
3
3
|
import { faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
-
import
|
|
5
|
-
import styled, { useTheme } from 'styled-components';
|
|
4
|
+
import styled from 'styled-components';
|
|
6
5
|
import ControlDescription from '../../shared/ControlDescription';
|
|
7
6
|
import ControlLabel from '../../shared/ControlLabel';
|
|
8
7
|
import { ControlStyles } from '../../shared/ControlStyles';
|
|
9
8
|
import getThemeControlColours from '../../theme/helpers/getThemeControlColours';
|
|
10
9
|
import useFormNode, { getValue } from '../Form/useFormNode.hook';
|
|
10
|
+
import { OptionsPopper } from '../common/Options.component';
|
|
11
11
|
const ControlOuter = styled.div `
|
|
12
12
|
position: relative;
|
|
13
13
|
`;
|
|
@@ -35,51 +35,34 @@ const PlaceholderText = styled.div `
|
|
|
35
35
|
const ValueText = styled.div `
|
|
36
36
|
color: ${(props) => getThemeControlColours(props.theme).font};
|
|
37
37
|
`;
|
|
38
|
-
const OptionsContainer = styled.div `
|
|
39
|
-
width: 100%;
|
|
40
|
-
position: absolute;
|
|
41
|
-
background-color: ${(props) => props.theme.colours.controlBackground};
|
|
42
|
-
z-index: 10000;
|
|
43
|
-
|
|
44
|
-
box-shadow: ${(props) => props.theme.shadows.small};
|
|
45
|
-
`;
|
|
46
|
-
const Option = styled(motion.div) `
|
|
47
|
-
color: ${(props) => getThemeControlColours(props.theme).font};
|
|
48
|
-
background-color: ${(props) => props.theme.colours.controlBackgroundDisabled};
|
|
49
|
-
height: 36px;
|
|
50
|
-
display: flex;
|
|
51
|
-
align-items: center;
|
|
52
|
-
padding: 0 12px;
|
|
53
|
-
cursor: pointer;
|
|
54
|
-
`;
|
|
55
38
|
const Select = (props) => {
|
|
56
|
-
const theme = useTheme();
|
|
57
39
|
const [isOpen, setIsOpen] = useState(false);
|
|
58
|
-
const
|
|
40
|
+
const [referenceElement, setReferenceElement] = useState();
|
|
41
|
+
const { label, name, description, placeholder, 'value': propsValue, 'data-testid': dataTestId, options } = props;
|
|
59
42
|
const { value: contextValue, onChange: contextOnChange } = useFormNode(name);
|
|
60
43
|
const value = getValue(propsValue, contextValue);
|
|
61
44
|
const splitDescription = description ? description.split('\\n').map((str) => str.trim()) : undefined;
|
|
62
|
-
const
|
|
45
|
+
const handleSelect = (value) => {
|
|
63
46
|
setIsOpen(false);
|
|
64
47
|
if (contextOnChange) {
|
|
65
|
-
contextOnChange(
|
|
48
|
+
contextOnChange(value);
|
|
66
49
|
}
|
|
67
50
|
if (props.onChange) {
|
|
68
|
-
props.onChange(
|
|
51
|
+
props.onChange(value);
|
|
69
52
|
}
|
|
70
53
|
};
|
|
71
54
|
const valueLabel = value && options.find((o) => o.value === value)?.label;
|
|
72
55
|
return (React.createElement("div", null,
|
|
73
56
|
label && React.createElement(ControlLabel, { htmlFor: name }, label),
|
|
74
|
-
React.createElement(ControlOuter,
|
|
75
|
-
React.createElement(SelectControl, { "data-
|
|
57
|
+
React.createElement(ControlOuter, { ref: setReferenceElement },
|
|
58
|
+
React.createElement(SelectControl, { "data-testid": dataTestId, onClick: () => setIsOpen(!isOpen) },
|
|
76
59
|
React.createElement(TextContainer, null,
|
|
77
60
|
!value && placeholder && React.createElement(PlaceholderText, null, placeholder),
|
|
78
61
|
value && React.createElement(ValueText, null, valueLabel)),
|
|
79
62
|
React.createElement(IconContainer, null,
|
|
80
63
|
React.createElement(FontAwesomeIcon, { icon: isOpen ? faChevronUp : faChevronDown }))),
|
|
81
|
-
isOpen && (React.createElement(
|
|
82
|
-
splitDescription && (React.createElement(ControlDescription, null, splitDescription.map((line, index) => (React.createElement(
|
|
64
|
+
isOpen && (React.createElement(OptionsPopper, { referenceElement: referenceElement, options: options, onSelect: handleSelect, onClose: () => setIsOpen(false) }))),
|
|
65
|
+
splitDescription && (React.createElement(ControlDescription, null, splitDescription.map((line, index) => (React.createElement(Fragment, { key: index },
|
|
83
66
|
index !== 0 && React.createElement("br", null),
|
|
84
67
|
line)))))));
|
|
85
68
|
};
|
|
@@ -4,7 +4,7 @@ export interface SquareButtonProps {
|
|
|
4
4
|
'children': React.ReactChild;
|
|
5
5
|
'variant'?: ColourVariant;
|
|
6
6
|
'onClick'?: () => void;
|
|
7
|
-
'data-
|
|
7
|
+
'data-testid'?: string;
|
|
8
8
|
}
|
|
9
|
-
declare const SquareButton: ({ children, variant, onClick, "data-
|
|
9
|
+
declare const SquareButton: ({ children, variant, onClick, "data-testid": dataTestId }: SquareButtonProps) => JSX.Element;
|
|
10
10
|
export default SquareButton;
|
|
@@ -25,7 +25,7 @@ const StyledButton = styled.button `
|
|
|
25
25
|
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).hover};
|
|
26
26
|
}
|
|
27
27
|
`;
|
|
28
|
-
const SquareButton = ({ children, variant = 'primary', onClick, 'data-
|
|
29
|
-
return (React.createElement(StyledButton, { variant: variant, onClick: onClick, "data-
|
|
28
|
+
const SquareButton = ({ children, variant = 'primary', onClick, 'data-testid': dataTestId }) => {
|
|
29
|
+
return (React.createElement(StyledButton, { variant: variant, onClick: onClick, "data-testid": dataTestId || 'button' }, children));
|
|
30
30
|
};
|
|
31
31
|
export default SquareButton;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TableVariant } from './_Table.context';
|
|
3
|
+
import { TableActionProps } from './_TableAction';
|
|
3
4
|
export type TableCellVariant = 'tight';
|
|
4
5
|
export interface TableProps {
|
|
5
6
|
children: React.ReactNode;
|
|
@@ -10,10 +11,11 @@ export interface TableCellProps {
|
|
|
10
11
|
}
|
|
11
12
|
declare const Table: {
|
|
12
13
|
({ children, variant }: TableProps): JSX.Element;
|
|
13
|
-
Row: ({ children, "data-
|
|
14
|
+
Row: ({ children, "data-testid": dataTestId, border }: import("./_TableRow.component").TableRowProps) => JSX.Element;
|
|
14
15
|
Cell: import("styled-components").StyledComponent<"td", import("styled-components").DefaultTheme, TableCellProps, never>;
|
|
15
16
|
ActionContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
16
|
-
Action: ({ text, onClick, "data-
|
|
17
|
-
ActionMenu: ({ items, "data-
|
|
17
|
+
Action: ({ text, variant, icon, onClick, "data-testid": dataTestId }: TableActionProps) => JSX.Element;
|
|
18
|
+
ActionMenu: ({ items, "data-testid": dataTestId }: import("./_TableActionMenu").TableActionMenuProps) => JSX.Element;
|
|
19
|
+
HiddenAction: (props: TableActionProps) => JSX.Element;
|
|
18
20
|
};
|
|
19
21
|
export default Table;
|
|
@@ -8,6 +8,11 @@ import TableActionMenu from './_TableActionMenu';
|
|
|
8
8
|
import TableRow from './_TableRow.component';
|
|
9
9
|
const StyledTable = styled.table `
|
|
10
10
|
width: 100%;
|
|
11
|
+
border-spacing: 0;
|
|
12
|
+
`;
|
|
13
|
+
const TableHiddenActionSpan = styled.span `
|
|
14
|
+
visibility: none;
|
|
15
|
+
opacity: 0;
|
|
11
16
|
`;
|
|
12
17
|
const TableCell = styled.td `
|
|
13
18
|
font-family: ${(props) => props.theme.fonts.default.family};
|
|
@@ -18,7 +23,16 @@ const TableCell = styled.td `
|
|
|
18
23
|
|
|
19
24
|
padding: ${(props) => (props.variant === 'tight' ? '0' : '0 16px')};
|
|
20
25
|
height: 36px;
|
|
26
|
+
|
|
27
|
+
&:hover {
|
|
28
|
+
${TableHiddenActionSpan} {
|
|
29
|
+
visibility: visible;
|
|
30
|
+
opacity: 1;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
21
33
|
`;
|
|
34
|
+
const TableHiddenAction = (props) => (React.createElement(TableHiddenActionSpan, null,
|
|
35
|
+
React.createElement(TableAction, { ...props })));
|
|
22
36
|
const Table = ({ children, variant = 'regular' }) => {
|
|
23
37
|
return (React.createElement(TableContext.Provider, { value: { variant } },
|
|
24
38
|
React.createElement(ButtonContext.Provider, { value: { height: '24px' } },
|
|
@@ -30,4 +44,5 @@ Table.Cell = TableCell;
|
|
|
30
44
|
Table.ActionContainer = TableActionContainer;
|
|
31
45
|
Table.Action = TableAction;
|
|
32
46
|
Table.ActionMenu = TableActionMenu;
|
|
47
|
+
Table.HiddenAction = TableHiddenAction;
|
|
33
48
|
export default Table;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import { ColourVariant } from '../../theme/theme.types';
|
|
2
4
|
export interface TableActionProps {
|
|
3
|
-
'text'
|
|
5
|
+
'text'?: string;
|
|
6
|
+
'variant'?: ColourVariant;
|
|
7
|
+
'icon'?: IconProp;
|
|
4
8
|
'onClick': () => void;
|
|
5
|
-
'data-
|
|
9
|
+
'data-testid'?: string;
|
|
6
10
|
}
|
|
7
|
-
declare const TableAction: ({ text, onClick, "data-
|
|
11
|
+
declare const TableAction: ({ text, variant, icon, onClick, "data-testid": dataTestId }: TableActionProps) => JSX.Element;
|
|
8
12
|
export default TableAction;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import Button from '../Button/Button.component';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import ButtonContext from '../Button/Button.context';
|
|
4
|
+
const TableAction = ({ text, variant, icon, onClick, 'data-testid': dataTestId }) => {
|
|
5
|
+
const buttonContextVal = useContext(ButtonContext);
|
|
6
|
+
return (React.createElement(ButtonContext.Provider, { value: { ...buttonContextVal, ...(!text && icon && { width: '32px' }) } },
|
|
7
|
+
React.createElement(Button, { variant: variant || 'tertiary', icon: icon, onClick: onClick, "data-testid": dataTestId || 'button-table-action' }, text)));
|
|
5
8
|
};
|
|
6
9
|
export default TableAction;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { IActionMenuItem } from '../ActionMenu/_ActionMenu.types';
|
|
3
3
|
export interface TableActionMenuProps {
|
|
4
4
|
'items': IActionMenuItem[];
|
|
5
|
-
'data-
|
|
5
|
+
'data-testid'?: string;
|
|
6
6
|
}
|
|
7
|
-
declare const TableActionMenu: ({ items, "data-
|
|
7
|
+
declare const TableActionMenu: ({ items, "data-testid": dataTestId }: TableActionMenuProps) => JSX.Element;
|
|
8
8
|
export default TableActionMenu;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ActionMenu from '../ActionMenu/ActionMenu.component';
|
|
3
|
-
const TableActionMenu = ({ items, 'data-
|
|
4
|
-
return (React.createElement(ActionMenu, { variant: 'tertiary', "data-
|
|
3
|
+
const TableActionMenu = ({ items, 'data-testid': dataTestId }) => {
|
|
4
|
+
return (React.createElement(ActionMenu, { variant: 'tertiary', "data-testid": dataTestId }, items.map((item) => (React.createElement(ActionMenu.Item, { key: item.label, onClick: item.onClick }, item.label)))));
|
|
5
5
|
};
|
|
6
6
|
export default TableActionMenu;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface TableRowProps {
|
|
3
3
|
'children': React.ReactNode;
|
|
4
|
-
'
|
|
4
|
+
'border'?: boolean;
|
|
5
|
+
'data-testid'?: string;
|
|
5
6
|
}
|
|
6
|
-
declare const TableRow: ({ children, "data-
|
|
7
|
+
declare const TableRow: ({ children, "data-testid": dataTestId, border }: TableRowProps) => JSX.Element;
|
|
7
8
|
export default TableRow;
|
|
@@ -3,15 +3,21 @@ import { useContext } from 'react';
|
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import TableContext from './_Table.context';
|
|
5
5
|
const StyledRow = styled.tr `
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
${(props) => props.border &&
|
|
7
|
+
`
|
|
8
|
+
box-shadow: 0px 1px 0px 0px ${props.variant === 'regular' ? props.theme.colours.defaultBorder : props.theme.colours.faintBorder}
|
|
9
|
+
`}
|
|
8
10
|
|
|
9
11
|
&:last-child {
|
|
10
12
|
box-shadow: none;
|
|
11
13
|
}
|
|
14
|
+
|
|
15
|
+
&:hover {
|
|
16
|
+
background-color: ${(props) => props.theme.colours.cardBackground};
|
|
17
|
+
}
|
|
12
18
|
`;
|
|
13
|
-
const TableRow = ({ children, 'data-
|
|
19
|
+
const TableRow = ({ children, 'data-testid': dataTestId, border = false }) => {
|
|
14
20
|
const { variant } = useContext(TableContext);
|
|
15
|
-
return (React.createElement(StyledRow, { variant: variant, "data-
|
|
21
|
+
return (React.createElement(StyledRow, { variant: variant, "data-testid": dataTestId, border: border }, children));
|
|
16
22
|
};
|
|
17
23
|
export default TableRow;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export type TextVariant = 'primary' | 'secondary';
|
|
3
3
|
export interface TextProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
variant?: TextVariant;
|
|
4
|
+
'children': React.ReactNode;
|
|
5
|
+
'variant'?: TextVariant;
|
|
6
|
+
'noWrap'?: boolean;
|
|
7
|
+
'data-testid'?: string;
|
|
6
8
|
}
|
|
7
|
-
declare const Text: ({ children, variant }: TextProps) => JSX.Element;
|
|
9
|
+
declare const Text: ({ children, variant, noWrap, "data-testid": dataTestId }: TextProps) => JSX.Element;
|
|
8
10
|
export default Text;
|
|
@@ -6,6 +6,15 @@ const TextContainer = styled.span `
|
|
|
6
6
|
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
7
7
|
|
|
8
8
|
color: ${(props) => props.theme.colours.defaultFont};
|
|
9
|
+
|
|
10
|
+
${(props) => props.noWrap &&
|
|
11
|
+
`
|
|
12
|
+
white-space: nowrap;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
text-overflow: ellipsis;
|
|
15
|
+
display: inline-block;
|
|
16
|
+
max-width: 100%;
|
|
17
|
+
`}
|
|
9
18
|
`;
|
|
10
19
|
const TextContainerSecondary = styled.span `
|
|
11
20
|
font-family: ${(props) => props.theme.fonts.default.family};
|
|
@@ -13,14 +22,23 @@ const TextContainerSecondary = styled.span `
|
|
|
13
22
|
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
14
23
|
|
|
15
24
|
color: ${(props) => props.theme.colours.secondaryFont};
|
|
25
|
+
|
|
26
|
+
${(props) => props.noWrap &&
|
|
27
|
+
`
|
|
28
|
+
white-space: nowrap;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
text-overflow: ellipsis;
|
|
31
|
+
display: inline-block;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
`}
|
|
16
34
|
`;
|
|
17
|
-
const Text = ({ children, variant = 'primary' }) => {
|
|
35
|
+
const Text = ({ children, variant = 'primary', noWrap, 'data-testid': dataTestId }) => {
|
|
18
36
|
switch (variant) {
|
|
19
37
|
case 'secondary':
|
|
20
|
-
return React.createElement(TextContainerSecondary,
|
|
38
|
+
return (React.createElement(TextContainerSecondary, { noWrap: noWrap, "data-testid": dataTestId }, children));
|
|
21
39
|
case 'primary':
|
|
22
40
|
default:
|
|
23
|
-
return React.createElement(TextContainer,
|
|
41
|
+
return (React.createElement(TextContainer, { noWrap: noWrap, "data-testid": dataTestId }, children));
|
|
24
42
|
}
|
|
25
43
|
};
|
|
26
44
|
export default Text;
|
|
@@ -9,7 +9,7 @@ export interface ITextAreaProps {
|
|
|
9
9
|
'onChange'?: (value: any) => void;
|
|
10
10
|
'onFocus'?: () => void;
|
|
11
11
|
'onBlur'?: () => void;
|
|
12
|
-
'data-
|
|
12
|
+
'data-testid'?: string;
|
|
13
13
|
}
|
|
14
14
|
declare const TextArea: React.ForwardRefExoticComponent<ITextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
15
15
|
export default TextArea;
|
|
@@ -70,7 +70,7 @@ const messageVariants = {
|
|
|
70
70
|
errorFocus: { opacity: 1, y: -4 },
|
|
71
71
|
};
|
|
72
72
|
const TextArea = React.forwardRef(function ForwardRefTextArea(props, ref) {
|
|
73
|
-
const { label, name, placeholder, autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-
|
|
73
|
+
const { label, name, placeholder, autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-testid': dataTestId, } = props;
|
|
74
74
|
const [isFocused, setIsFocused] = useState(false);
|
|
75
75
|
const { value: contextValue, error: contextError, onChange: contextOnChange } = useFormNode(name);
|
|
76
76
|
const error = contextError || propsError;
|
|
@@ -97,11 +97,11 @@ const TextArea = React.forwardRef(function ForwardRefTextArea(props, ref) {
|
|
|
97
97
|
const animationVariant = error ? (isFocused ? 'errorFocus' : 'error') : undefined;
|
|
98
98
|
return (React.createElement("div", null,
|
|
99
99
|
label && React.createElement(TextAreaLabel, { htmlFor: name }, label),
|
|
100
|
-
React.createElement(TextAreaContainer, { "data-
|
|
101
|
-
React.createElement(StyledTextArea, { ref: ref, animate: animationVariant, variants: textAreaVariants, transition: { type: 'spring', duration: 0.3 }, name: name, placeholder: placeholder, value: getValue(value, contextValue), onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, autoFocus: autoFocus, "data-
|
|
102
|
-
React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-
|
|
100
|
+
React.createElement(TextAreaContainer, { "data-testid": dataTestId },
|
|
101
|
+
React.createElement(StyledTextArea, { ref: ref, animate: animationVariant, variants: textAreaVariants, transition: { type: 'spring', duration: 0.3 }, name: name, placeholder: placeholder, value: getValue(value, contextValue), onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, autoFocus: autoFocus, "data-testid": 'text-area' }),
|
|
102
|
+
React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-testid": 'error-indicator' },
|
|
103
103
|
React.createElement(ErrorInner, null,
|
|
104
104
|
React.createElement(FontAwesomeIcon, { icon: faExclamationCircle }))),
|
|
105
|
-
error && (React.createElement(ErrorMessage, { style: { opacity: 0, y: 0 }, animate: animationVariant, variants: messageVariants, transition: { type: 'spring', duration: 0.3 }, "data-
|
|
105
|
+
error && (React.createElement(ErrorMessage, { style: { opacity: 0, y: 0 }, animate: animationVariant, variants: messageVariants, transition: { type: 'spring', duration: 0.3 }, "data-testid": 'error-message' }, error)))));
|
|
106
106
|
});
|
|
107
107
|
export default TextArea;
|
|
@@ -30,7 +30,7 @@ const toggleDotVariants = {
|
|
|
30
30
|
on: { transform: 'translateX(22px)' },
|
|
31
31
|
};
|
|
32
32
|
const Toggle = ({ value, onChange }) => {
|
|
33
|
-
return (React.createElement(ToggleOuter, { animate: value ? 'on' : 'off', variants: toggleOuterVariants, transition: { type: 'spring', duration: 0.3 }, onClick: () => onChange(!value) },
|
|
33
|
+
return (React.createElement(ToggleOuter, { animate: value ? 'on' : 'off', variants: toggleOuterVariants, transition: { type: 'spring', duration: 0.3 }, onClick: () => onChange(!value), "data-testid": 'toggle' },
|
|
34
34
|
React.createElement(ToggleDot, { animate: value ? 'on' : 'off', variants: toggleDotVariants, transition: { type: 'spring', duration: 0.3 } })));
|
|
35
35
|
};
|
|
36
36
|
export default Toggle;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const OptionsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const Option: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
export type SelectOption = {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
};
|
|
8
|
+
export interface SelectOptionsProps {
|
|
9
|
+
options: SelectOption[];
|
|
10
|
+
onSelect: (value: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const SelectOptions: ({ options, onSelect }: SelectOptionsProps) => JSX.Element;
|
|
13
|
+
export interface SelectOptionsPopperProps {
|
|
14
|
+
referenceElement: any;
|
|
15
|
+
options: SelectOption[];
|
|
16
|
+
onSelect: (value: string) => void;
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const OptionsPopper: ({ referenceElement, options, onSelect, onClose }: SelectOptionsPopperProps) => React.ReactPortal;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { usePopper } from 'react-popper';
|
|
4
|
+
import { motion } from 'framer-motion';
|
|
5
|
+
import styled, { useTheme } from 'styled-components';
|
|
6
|
+
import getThemeControlColours from '../../theme/helpers/getThemeControlColours';
|
|
7
|
+
export const OptionsContainer = styled.div `
|
|
8
|
+
width: 100%;
|
|
9
|
+
background-color: ${(props) => props.theme.colours.controlBackground};
|
|
10
|
+
z-index: 10000;
|
|
11
|
+
|
|
12
|
+
box-shadow: ${(props) => props.theme.shadows.small};
|
|
13
|
+
`;
|
|
14
|
+
export const Option = styled(motion.div) `
|
|
15
|
+
color: ${(props) => getThemeControlColours(props.theme).font};
|
|
16
|
+
background-color: ${(props) => props.theme.colours.controlBackgroundDisabled};
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
|
|
21
|
+
min-height: 36px;
|
|
22
|
+
padding: 6px 12px;
|
|
23
|
+
`;
|
|
24
|
+
export const SelectOptions = ({ options, onSelect }) => {
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
return (React.createElement(OptionsContainer, null, options.map((option) => (React.createElement(Option, { "data-testid": `option-${option.value}`, whileHover: { backgroundColor: theme.colours.controlBorder }, transition: { type: 'spring', duration: 0.2 }, key: option.value, onClick: () => onSelect(option.value) }, option.label)))));
|
|
27
|
+
};
|
|
28
|
+
export const OptionsPopper = ({ referenceElement, options, onSelect, onClose }) => {
|
|
29
|
+
const [popperElement, setPopperElement] = useState();
|
|
30
|
+
const { styles, attributes } = usePopper(referenceElement, popperElement, { placement: 'bottom-start' });
|
|
31
|
+
const handleGlobalClick = useCallback((event) => {
|
|
32
|
+
if (!popperElement?.contains(event.target)) {
|
|
33
|
+
onClose();
|
|
34
|
+
}
|
|
35
|
+
}, [onClose, popperElement]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
document.addEventListener('mouseup', handleGlobalClick);
|
|
38
|
+
return () => {
|
|
39
|
+
document.removeEventListener('mouseup', handleGlobalClick);
|
|
40
|
+
};
|
|
41
|
+
}, [handleGlobalClick, popperElement]);
|
|
42
|
+
return ReactDOM.createPortal(React.createElement("div", { "data-testid": 'options-popper', ref: setPopperElement, style: {
|
|
43
|
+
...styles.popper,
|
|
44
|
+
zIndex: 999,
|
|
45
|
+
width: referenceElement?.offsetWidth,
|
|
46
|
+
maxHeight: '270px',
|
|
47
|
+
overflowY: 'auto',
|
|
48
|
+
}, ...attributes.popper },
|
|
49
|
+
React.createElement(SelectOptions, { options: options, onSelect: onSelect })), document.querySelector('body'));
|
|
50
|
+
};
|
package/build/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { default as Card } from './components/Card/Card.component';
|
|
|
12
12
|
export { default as CardGroup } from './components/Card/CardGroup.component';
|
|
13
13
|
export { default as Checklist } from './components/Checklist/Checklist.component';
|
|
14
14
|
export { default as ControlGroup } from './components/ControlGroup/ControlGroup.component';
|
|
15
|
+
export { default as ControlLine } from './components/ControlLine/ControlLine.component';
|
|
15
16
|
export { default as FancyCheckbox } from './components/FancyCheckbox/FancyCheckbox.component';
|
|
16
17
|
export { default as Form } from './components/Form/Form.component';
|
|
17
18
|
export { default as Notification } from './components/Notification/Notification.component';
|
package/build/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { default as Card } from './components/Card/Card.component';
|
|
|
12
12
|
export { default as CardGroup } from './components/Card/CardGroup.component';
|
|
13
13
|
export { default as Checklist } from './components/Checklist/Checklist.component';
|
|
14
14
|
export { default as ControlGroup } from './components/ControlGroup/ControlGroup.component';
|
|
15
|
+
export { default as ControlLine } from './components/ControlLine/ControlLine.component';
|
|
15
16
|
export { default as FancyCheckbox } from './components/FancyCheckbox/FancyCheckbox.component';
|
|
16
17
|
export { default as Form } from './components/Form/Form.component';
|
|
17
18
|
export { default as Notification } from './components/Notification/Notification.component';
|
|
@@ -47,14 +47,14 @@ const LoginScreen = ({ loading, error, handleLogin, onRegisterClicked }) => {
|
|
|
47
47
|
React.createElement(Form, { value: value, onChange: setValue, onSubmit: () => handleLogin(value) },
|
|
48
48
|
React.createElement(ControlGroup, null,
|
|
49
49
|
React.createElement(ErrorText, null, error),
|
|
50
|
-
React.createElement(Input, { name: 'email', placeholder: 'Email', type: 'text', "data-
|
|
51
|
-
React.createElement(Input, { name: 'password', placeholder: 'Password', type: 'password', "data-
|
|
50
|
+
React.createElement(Input, { name: 'email', placeholder: 'Email', type: 'text', "data-testid": 'input-email' }),
|
|
51
|
+
React.createElement(Input, { name: 'password', placeholder: 'Password', type: 'password', "data-testid": 'input-password' }),
|
|
52
52
|
React.createElement(ControlGroup.Spacer, null),
|
|
53
|
-
React.createElement(Button, { type: 'submit', loading: loading, "data-
|
|
53
|
+
React.createElement(Button, { type: 'submit', loading: loading, "data-testid": 'button-login' }, "Login"))),
|
|
54
54
|
React.createElement(Spacer, { size: '6x' }),
|
|
55
55
|
React.createElement(CreateAccountMessage, null,
|
|
56
56
|
`Don't have an account?`,
|
|
57
57
|
' ',
|
|
58
|
-
React.createElement(CreateAccountButton, { onClick: onRegisterClicked, "data-
|
|
58
|
+
React.createElement(CreateAccountButton, { onClick: onRegisterClicked, "data-testid": 'button-register' }, "sign up now"))));
|
|
59
59
|
};
|
|
60
60
|
export default LoginScreen;
|
|
@@ -24,9 +24,9 @@ const RegisterScreen = ({ loading, error, handleRegister }) => {
|
|
|
24
24
|
React.createElement(Form, { value: value, onChange: setValue, onSubmit: () => handleRegister(value) },
|
|
25
25
|
React.createElement(ControlGroup, null,
|
|
26
26
|
React.createElement(ErrorText, null, error),
|
|
27
|
-
React.createElement(Input, { name: 'email', placeholder: 'Email', type: 'text', "data-
|
|
28
|
-
React.createElement(Input, { name: 'password', placeholder: 'Password', type: 'password', "data-
|
|
27
|
+
React.createElement(Input, { name: 'email', placeholder: 'Email', type: 'text', "data-testid": 'input-email' }),
|
|
28
|
+
React.createElement(Input, { name: 'password', placeholder: 'Password', type: 'password', "data-testid": 'input-password' }),
|
|
29
29
|
React.createElement(ControlGroup.Spacer, null),
|
|
30
|
-
React.createElement(Button, { type: 'submit', loading: loading, "data-
|
|
30
|
+
React.createElement(Button, { type: 'submit', loading: loading, "data-testid": 'button-register' }, "Create Account")))));
|
|
31
31
|
};
|
|
32
32
|
export default RegisterScreen;
|
|
@@ -32,8 +32,8 @@ const VerificationScreen = ({ message, loading, error, handleVerification }) =>
|
|
|
32
32
|
React.createElement(Form, { value: value, onChange: setValue, onSubmit: () => handleVerification(value) },
|
|
33
33
|
React.createElement(ControlGroup, null,
|
|
34
34
|
React.createElement(ErrorText, null, error),
|
|
35
|
-
React.createElement(Input, { name: 'code', placeholder: 'code', type: 'text', "data-
|
|
35
|
+
React.createElement(Input, { name: 'code', placeholder: 'code', type: 'text', "data-testid": 'input-verification-code' }),
|
|
36
36
|
React.createElement(ControlGroup.Spacer, null),
|
|
37
|
-
React.createElement(Button, { type: 'submit', loading: loading, "data-
|
|
37
|
+
React.createElement(Button, { type: 'submit', loading: loading, "data-testid": 'button-verify' }, "Verify")))));
|
|
38
38
|
};
|
|
39
39
|
export default VerificationScreen;
|
|
@@ -16,7 +16,7 @@ export const ControlStyles = css `
|
|
|
16
16
|
color: ${(props) => getThemeControlColours(props.theme).font};
|
|
17
17
|
background-color: ${(props) => getThemeControlColours(props.theme).background};
|
|
18
18
|
|
|
19
|
-
border: 1px solid ${(props) => getThemeControlColours(props.theme).
|
|
19
|
+
border: 1px solid ${(props) => getThemeControlColours(props.theme).background};
|
|
20
20
|
border-radius: 2px;
|
|
21
21
|
|
|
22
22
|
&:hover {
|
|
@@ -35,9 +35,11 @@ const darkTheme = {
|
|
|
35
35
|
faintBorder: '#cccccc1f',
|
|
36
36
|
controlBackground: '#5e6167',
|
|
37
37
|
controlBackgroundDisabled: '#47494d',
|
|
38
|
-
controlBorder: '#
|
|
38
|
+
controlBorder: '#595b5e',
|
|
39
|
+
// controlBorder: '#565656',
|
|
39
40
|
controlBorderFocus: '#4289de',
|
|
40
|
-
controlBorderHover: '#
|
|
41
|
+
controlBorderHover: '#686c74',
|
|
42
|
+
// controlBorderHover: '#4a4949',
|
|
41
43
|
controlPlaceholder: '#949494',
|
|
42
44
|
controlDescriptionColour: '#cbcbcb',
|
|
43
45
|
uploadBackground: '#5e6167',
|