@dtdot/lego 2.0.0-9 → 2.0.1
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/LICENSE +21 -0
- package/README.md +51 -0
- 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 +15 -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/FloatingActionButton/FloatingActionButton.component.d.ts +13 -0
- package/build/components/FloatingActionButton/FloatingActionButton.component.js +21 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.context.d.ts +15 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.context.js +6 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.internal.d.ts +10 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.internal.js +45 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.provider.d.ts +6 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.provider.js +15 -0
- package/build/components/Form/_NestedFormArray.js +0 -2
- 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 +7 -2
- package/build/components/Loader/Loader.component.js +28 -8
- 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 -2
- package/build/components/MinimalMenu/MinimalMenu.context.d.ts +7 -0
- package/build/components/MinimalMenu/MinimalMenu.context.js +6 -0
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.d.ts +2 -1
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.js +3 -3
- package/build/components/MinimalMenu/_MinimalMenuItem.component.d.ts +3 -2
- package/build/components/MinimalMenu/_MinimalMenuItem.component.js +3 -3
- package/build/components/MinimalMenu/_MinimalMenuPage.component.js +10 -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 +4 -24
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.d.ts +3 -2
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.js +22 -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 +3 -5
- package/build/components/Select/Select.component.js +13 -30
- 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 +3 -3
- package/build/components/Table/Table.component.js +1 -0
- package/build/components/Table/_TableAction.d.ts +2 -2
- package/build/components/Table/_TableAction.js +2 -2
- 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/constants/zIndex.constants.d.ts +1 -0
- package/build/constants/zIndex.constants.js +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -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 +14 -14
- 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
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
3
3
|
export interface MobileMinimalMenuItemProps {
|
|
4
4
|
'icon'?: IconProp;
|
|
5
|
+
'label': string;
|
|
5
6
|
'active'?: boolean;
|
|
6
7
|
'onClick'?: () => void;
|
|
7
|
-
'data-
|
|
8
|
+
'data-testid'?: string;
|
|
8
9
|
}
|
|
9
|
-
declare const MobileMinimalMenuItem: ({ icon, active, onClick, "data-
|
|
10
|
+
declare const MobileMinimalMenuItem: ({ icon, label, active, onClick, "data-testid": dataTestId, }: MobileMinimalMenuItemProps) => JSX.Element;
|
|
10
11
|
export default MobileMinimalMenuItem;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { motion } from 'framer-motion';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
|
-
import useWindowDimensions from '../../../hooks/useWindowDimensions';
|
|
6
5
|
import { mobileMenuDefaultTransition } from './_MobileMenu.constants';
|
|
7
|
-
import
|
|
6
|
+
import darkTheme from '../../../theme/dark.theme';
|
|
8
7
|
const ItemContainer = styled.div `
|
|
9
8
|
position: relative;
|
|
10
9
|
|
|
11
|
-
color: ${(props) => props.theme.colours.defaultFont};
|
|
12
10
|
cursor: pointer;
|
|
13
11
|
|
|
14
12
|
width: 48px;
|
|
@@ -17,26 +15,26 @@ const ItemContainer = styled.div `
|
|
|
17
15
|
justify-content: center;
|
|
18
16
|
align-items: center;
|
|
19
17
|
`;
|
|
18
|
+
const MotionDivContainer = styled(motion.div) `
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
align-items: center;
|
|
23
|
+
|
|
24
|
+
padding-top: 3px;
|
|
25
|
+
`;
|
|
26
|
+
const TextDiv = styled.div `
|
|
27
|
+
font-size: 12px;
|
|
28
|
+
padding-top: 6px;
|
|
29
|
+
`;
|
|
30
|
+
const StyledIcon = styled(FontAwesomeIcon) `
|
|
31
|
+
font-size: 22px;
|
|
32
|
+
`;
|
|
20
33
|
const iconContainerVariants = {
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
const MobileMinimalMenuItem = ({ icon, active, onClick, 'data-cy': dataCy }) => {
|
|
24
|
-
const { width } = useWindowDimensions();
|
|
25
|
-
const { setBumpX } = useContext(MobileMenuBumpContext);
|
|
26
|
-
const itemRef = useRef(null);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (active && width > 0) {
|
|
29
|
-
const left = itemRef.current?.offsetLeft;
|
|
30
|
-
const center = left ? left + 48 / 2 : undefined;
|
|
31
|
-
setBumpX(center);
|
|
32
|
-
}
|
|
33
|
-
return () => {
|
|
34
|
-
if (active) {
|
|
35
|
-
setBumpX(undefined);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
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 },
|
|
40
|
-
React.createElement(FontAwesomeIcon, { icon: icon })))));
|
|
34
|
+
base: { color: darkTheme.colours.defaultFont },
|
|
35
|
+
active: { color: darkTheme.colours.primary.hover },
|
|
41
36
|
};
|
|
37
|
+
const MobileMinimalMenuItem = ({ icon, label, active, onClick, 'data-testid': dataTestId, }) => (React.createElement(ItemContainer, { onClick: onClick, "data-testid": dataTestId || 'menu-item' }, icon && (React.createElement(MotionDivContainer, { animate: active ? 'active' : 'base', variants: iconContainerVariants, transition: mobileMenuDefaultTransition },
|
|
38
|
+
React.createElement(StyledIcon, { icon: icon }),
|
|
39
|
+
React.createElement(TextDiv, null, label)))));
|
|
42
40
|
export default MobileMinimalMenuItem;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export type ModalSize = 'sm' | 'md' | 'lg';
|
|
3
3
|
export interface ModalProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
size?: ModalSize;
|
|
6
|
-
loading?: boolean;
|
|
7
|
-
onClose: () => void;
|
|
4
|
+
'children': React.ReactNode;
|
|
5
|
+
'size'?: ModalSize;
|
|
6
|
+
'loading'?: boolean;
|
|
7
|
+
'onClose': () => void;
|
|
8
|
+
'data-testid'?: string;
|
|
8
9
|
}
|
|
9
10
|
declare const Modal: {
|
|
10
|
-
({ children, size, loading, onClose }: ModalProps): React.ReactPortal;
|
|
11
|
+
({ children, size, loading, onClose, "data-testid": dataTestId }: ModalProps): React.ReactPortal;
|
|
11
12
|
Body: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
12
13
|
Header: ({ header, subHeader }: import("./_ModalHeader.component").ModalHeaderProps) => JSX.Element;
|
|
13
14
|
};
|
|
@@ -76,7 +76,7 @@ const SpinnerContainer = styled.div `
|
|
|
76
76
|
justify-content: center;
|
|
77
77
|
align-items: center;
|
|
78
78
|
`;
|
|
79
|
-
const Modal = ({ children, size, loading, onClose }) => {
|
|
79
|
+
const Modal = ({ children, size, loading, onClose, 'data-testid': dataTestId }) => {
|
|
80
80
|
const handleModalClick = (event) => {
|
|
81
81
|
event.modalClicked = true;
|
|
82
82
|
};
|
|
@@ -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": dataTestId || '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,8 +7,9 @@ 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[];
|
|
12
|
+
'className'?: string;
|
|
15
13
|
}
|
|
16
14
|
declare const Select: (props: ISelectProps) => JSX.Element;
|
|
17
15
|
export default Select;
|
|
@@ -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, className, } = 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
|
-
return (React.createElement("div",
|
|
55
|
+
return (React.createElement("div", { className: className },
|
|
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;
|
|
@@ -11,11 +11,11 @@ export interface TableCellProps {
|
|
|
11
11
|
}
|
|
12
12
|
declare const Table: {
|
|
13
13
|
({ children, variant }: TableProps): JSX.Element;
|
|
14
|
-
Row: ({ children, "data-
|
|
14
|
+
Row: ({ children, "data-testid": dataTestId, border }: import("./_TableRow.component").TableRowProps) => JSX.Element;
|
|
15
15
|
Cell: import("styled-components").StyledComponent<"td", import("styled-components").DefaultTheme, TableCellProps, never>;
|
|
16
16
|
ActionContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
17
|
-
Action: ({ text, variant, icon, onClick, "data-
|
|
18
|
-
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
19
|
HiddenAction: (props: TableActionProps) => JSX.Element;
|
|
20
20
|
};
|
|
21
21
|
export default Table;
|
|
@@ -6,7 +6,7 @@ export interface TableActionProps {
|
|
|
6
6
|
'variant'?: ColourVariant;
|
|
7
7
|
'icon'?: IconProp;
|
|
8
8
|
'onClick': () => void;
|
|
9
|
-
'data-
|
|
9
|
+
'data-testid'?: string;
|
|
10
10
|
}
|
|
11
|
-
declare const TableAction: ({ text, variant, icon, onClick, "data-
|
|
11
|
+
declare const TableAction: ({ text, variant, icon, onClick, "data-testid": dataTestId }: TableActionProps) => JSX.Element;
|
|
12
12
|
export default TableAction;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
import Button from '../Button/Button.component';
|
|
3
3
|
import ButtonContext from '../Button/Button.context';
|
|
4
|
-
const TableAction = ({ text, variant, icon, onClick, 'data-
|
|
4
|
+
const TableAction = ({ text, variant, icon, onClick, 'data-testid': dataTestId }) => {
|
|
5
5
|
const buttonContextVal = useContext(ButtonContext);
|
|
6
6
|
return (React.createElement(ButtonContext.Provider, { value: { ...buttonContextVal, ...(!text && icon && { width: '32px' }) } },
|
|
7
|
-
React.createElement(Button, { variant: variant || 'tertiary', icon: icon, onClick: onClick, "data-
|
|
7
|
+
React.createElement(Button, { variant: variant || 'tertiary', icon: icon, onClick: onClick, "data-testid": dataTestId || 'button-table-action' }, text)));
|
|
8
8
|
};
|
|
9
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,7 +12,9 @@ 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';
|
|
17
|
+
export { default as FloatingActionButton } from './components/FloatingActionButton/FloatingActionButton.component';
|
|
16
18
|
export { default as Form } from './components/Form/Form.component';
|
|
17
19
|
export { default as Notification } from './components/Notification/Notification.component';
|
|
18
20
|
export { default as Notifications } from './components/Notifications/Notifications.component';
|
package/build/index.js
CHANGED
|
@@ -12,7 +12,9 @@ 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';
|
|
17
|
+
export { default as FloatingActionButton } from './components/FloatingActionButton/FloatingActionButton.component';
|
|
16
18
|
export { default as Form } from './components/Form/Form.component';
|
|
17
19
|
export { default as Notification } from './components/Notification/Notification.component';
|
|
18
20
|
export { default as Notifications } from './components/Notifications/Notifications.component';
|