@dtdot/lego 2.0.0-3 → 2.0.0-30
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 +2 -2
- package/build/components/MinimalMenu/_MinimalMenuItem.component.js +3 -3
- package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.d.ts +2 -2
- package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.js +2 -2
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.d.ts +2 -2
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.js +2 -2
- package/build/components/Modal/Modal.component.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
|
@@ -8,11 +8,11 @@ export interface ActionMenuProps {
|
|
|
8
8
|
'size'?: ButtonSize;
|
|
9
9
|
'icon'?: IconProp;
|
|
10
10
|
'text'?: string;
|
|
11
|
-
'data-
|
|
11
|
+
'data-testid'?: string;
|
|
12
12
|
}
|
|
13
13
|
declare const ActionMenu: {
|
|
14
|
-
({ children, variant, size, icon, text, "data-
|
|
15
|
-
Item: ({ children, onClick, "data-
|
|
16
|
-
Checkbox: ({ children, checked, onClick, "data-
|
|
14
|
+
({ children, variant, size, icon, text, "data-testid": dataTestId }: ActionMenuProps): JSX.Element;
|
|
15
|
+
Item: ({ children, onClick, "data-testid": dataTestId }: import("./_ActionMenuItem.component").ActionMenuItemProps) => JSX.Element;
|
|
16
|
+
Checkbox: ({ children, checked, onClick, "data-testid": dataTestId }: import("./_ActionMenuCheckbox.component").ActionMenuCheckboxProps) => JSX.Element;
|
|
17
17
|
};
|
|
18
18
|
export default ActionMenu;
|
|
@@ -8,7 +8,7 @@ import ActionMenuCheckbox from './_ActionMenuCheckbox.component';
|
|
|
8
8
|
import ActionMenuItem from './_ActionMenuItem.component';
|
|
9
9
|
import ActionMenuPanel from './_ActionMenuPanel.component';
|
|
10
10
|
const offsetFn = () => [70, 4];
|
|
11
|
-
const ActionMenu = ({ children, variant, size, icon, text, 'data-
|
|
11
|
+
const ActionMenu = ({ children, variant, size, icon, text, 'data-testid': dataTestId }) => {
|
|
12
12
|
const [shown, setShown] = useState(false);
|
|
13
13
|
const [referenceElement, setReferenceElement] = useState();
|
|
14
14
|
const [popperElement, setPopperElement] = useState();
|
|
@@ -34,9 +34,9 @@ const ActionMenu = ({ children, variant, size, icon, text, 'data-cy': dataCy })
|
|
|
34
34
|
};
|
|
35
35
|
}, [handleGlobalClick, popperElement]);
|
|
36
36
|
return (React.createElement(React.Fragment, null,
|
|
37
|
-
React.createElement(Button, { variant: variant, size: size, icon: icon || faEllipsisV, "data-
|
|
37
|
+
React.createElement(Button, { variant: variant, size: size, icon: icon || faEllipsisV, "data-testid": dataTestId || 'action-menu-button', ref: setReferenceElement, onClick: () => setShown(true) }, text),
|
|
38
38
|
shown &&
|
|
39
|
-
ReactDOM.createPortal(React.createElement("div", { ref: setPopperElement, style: styles.popper, ...attributes.popper },
|
|
39
|
+
ReactDOM.createPortal(React.createElement("div", { ref: setPopperElement, style: { ...styles.popper, zIndex: 999 }, ...attributes.popper },
|
|
40
40
|
React.createElement(ActionMenuContext.Provider, { value: { closeActionMenu: () => setShown(false) } },
|
|
41
41
|
React.createElement(ActionMenuPanel, null, children))), document.querySelector('body'))));
|
|
42
42
|
};
|
|
@@ -3,7 +3,7 @@ export interface ActionMenuCheckboxProps {
|
|
|
3
3
|
'children': React.ReactNode;
|
|
4
4
|
'checked': boolean;
|
|
5
5
|
'onClick': () => void;
|
|
6
|
-
'data-
|
|
6
|
+
'data-testid'?: string;
|
|
7
7
|
}
|
|
8
|
-
declare const ActionMenuCheckbox: ({ children, checked, onClick, "data-
|
|
8
|
+
declare const ActionMenuCheckbox: ({ children, checked, onClick, "data-testid": dataTestId }: ActionMenuCheckboxProps) => JSX.Element;
|
|
9
9
|
export default ActionMenuCheckbox;
|
|
@@ -19,10 +19,10 @@ const ActionMenuCheckboxOuter = styled(motion.div) `
|
|
|
19
19
|
const Spacer = styled.div `
|
|
20
20
|
width: 16px;
|
|
21
21
|
`;
|
|
22
|
-
const ActionMenuCheckbox = ({ children, checked, onClick, 'data-
|
|
22
|
+
const ActionMenuCheckbox = ({ children, checked, onClick, 'data-testid': dataTestId }) => {
|
|
23
23
|
const theme = useTheme();
|
|
24
24
|
return (React.createElement(React.Fragment, null,
|
|
25
|
-
React.createElement(ActionMenuCheckboxOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: onClick, "data-
|
|
25
|
+
React.createElement(ActionMenuCheckboxOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: onClick, "data-testid": dataTestId || 'action-menu-checkbox' },
|
|
26
26
|
children,
|
|
27
27
|
React.createElement(Spacer, null),
|
|
28
28
|
React.createElement(Checkmark, { checked: checked, large: false }))));
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
export interface ActionMenuItemProps {
|
|
3
3
|
'children': React.ReactNode;
|
|
4
4
|
'onClick': () => void;
|
|
5
|
-
'data-
|
|
5
|
+
'data-testid'?: string;
|
|
6
6
|
}
|
|
7
|
-
declare const ActionMenuItem: ({ children, onClick, "data-
|
|
7
|
+
declare const ActionMenuItem: ({ children, onClick, "data-testid": dataTestId }: ActionMenuItemProps) => JSX.Element;
|
|
8
8
|
export default ActionMenuItem;
|
|
@@ -15,7 +15,7 @@ const ActionMenuItemOuter = styled(motion.div) `
|
|
|
15
15
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
16
16
|
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
17
17
|
`;
|
|
18
|
-
const ActionMenuItem = ({ children, onClick, 'data-
|
|
18
|
+
const ActionMenuItem = ({ children, onClick, 'data-testid': dataTestId }) => {
|
|
19
19
|
const theme = useTheme();
|
|
20
20
|
const { closeActionMenu } = useContext(ActionMenuContext);
|
|
21
21
|
const handleClick = () => {
|
|
@@ -23,6 +23,6 @@ const ActionMenuItem = ({ children, onClick, 'data-cy': dataCy }) => {
|
|
|
23
23
|
closeActionMenu();
|
|
24
24
|
};
|
|
25
25
|
return (React.createElement(React.Fragment, null,
|
|
26
|
-
React.createElement(ActionMenuItemOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: handleClick, "data-
|
|
26
|
+
React.createElement(ActionMenuItemOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: handleClick, "data-testid": dataTestId || 'action-menu-item' }, children)));
|
|
27
27
|
};
|
|
28
28
|
export default ActionMenuItem;
|
|
@@ -4,5 +4,5 @@ const ActionMenuPanelOuter = styled.div `
|
|
|
4
4
|
background-color: ${(props) => props.theme.colours.tertiary.main};
|
|
5
5
|
min-width: 160px;
|
|
6
6
|
`;
|
|
7
|
-
const ActionMenuPanel = ({ children }) => (React.createElement(ActionMenuPanelOuter, { "data-
|
|
7
|
+
const ActionMenuPanel = ({ children }) => (React.createElement(ActionMenuPanelOuter, { "data-testid": 'action-menu-popover' }, children));
|
|
8
8
|
export default ActionMenuPanel;
|
|
@@ -14,7 +14,7 @@ const ActionMessageContainer = styled.div `
|
|
|
14
14
|
}
|
|
15
15
|
`;
|
|
16
16
|
const ActionMessage = ({ header, info, action, onAction }) => {
|
|
17
|
-
return (React.createElement(ActionMessageContainer, { "data-
|
|
17
|
+
return (React.createElement(ActionMessageContainer, { "data-testid": 'action-message' },
|
|
18
18
|
React.createElement("div", null,
|
|
19
19
|
React.createElement(Heading.SubHeading, null, header)),
|
|
20
20
|
info && (React.createElement(React.Fragment, null,
|
|
@@ -46,9 +46,9 @@ const CountContainer = styled.div `
|
|
|
46
46
|
const Alert = ({ variant, message, count, action, onAction }) => {
|
|
47
47
|
const theme = useTheme();
|
|
48
48
|
const colour = getThemeStatusColour(variant, theme).main;
|
|
49
|
-
return (React.createElement(AlertContainer, { colour: colour, "data-
|
|
50
|
-
React.createElement(MessageContainer, { "data-
|
|
51
|
-
action && (React.createElement(ActionContainer, { onClick: onAction, "data-
|
|
49
|
+
return (React.createElement(AlertContainer, { colour: colour, "data-testid": 'alert' },
|
|
50
|
+
React.createElement(MessageContainer, { "data-testid": 'alert-message' }, message),
|
|
51
|
+
action && (React.createElement(ActionContainer, { onClick: onAction, "data-testid": 'alert-action' }, action)),
|
|
52
52
|
count && count > 1 && React.createElement(CountContainer, { colour: colour }, count)));
|
|
53
53
|
};
|
|
54
54
|
export default Alert;
|
|
@@ -30,7 +30,7 @@ const ActionSpan = styled.span `
|
|
|
30
30
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
31
31
|
`;
|
|
32
32
|
const Badge = ({ children, variant, actionIcon, onAction }) => {
|
|
33
|
-
return (React.createElement(BadgeSpan, { variant: variant, useHover: !!actionIcon, "data-
|
|
33
|
+
return (React.createElement(BadgeSpan, { variant: variant, useHover: !!actionIcon, "data-testid": 'badge' },
|
|
34
34
|
children,
|
|
35
35
|
actionIcon && (React.createElement(ActionSpan, { onClick: onAction },
|
|
36
36
|
React.createElement(FontAwesomeIcon, { icon: actionIcon })))));
|
|
@@ -24,6 +24,6 @@ const BadgeSelector = ({ options, value, onChange }) => {
|
|
|
24
24
|
const handleClick = (_value) => {
|
|
25
25
|
onChange([_value]);
|
|
26
26
|
};
|
|
27
|
-
return (React.createElement(BadgeSelectorOuter, { "data-
|
|
27
|
+
return (React.createElement(BadgeSelectorOuter, { "data-testid": 'badge-selector' }, options.map((option) => (React.createElement(InteractiveBadge, { useHover: false, key: option.value, variant: option.variant, inactive: !value.includes(option.value), onClick: () => handleClick(option.value), "data-testid": value.includes(option.value) ? 'badge-selected' : 'badge' }, option.name)))));
|
|
28
28
|
};
|
|
29
29
|
export default BadgeSelector;
|
|
@@ -10,7 +10,7 @@ export interface ButtonProps {
|
|
|
10
10
|
'type'?: 'submit' | 'button';
|
|
11
11
|
'icon'?: IconProp;
|
|
12
12
|
'onClick'?: () => void;
|
|
13
|
-
'data-
|
|
13
|
+
'data-testid'?: string;
|
|
14
14
|
}
|
|
15
15
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<unknown>>;
|
|
16
16
|
export default Button;
|
|
@@ -33,9 +33,13 @@ const IconOuter = styled.span `
|
|
|
33
33
|
justify-content: center;
|
|
34
34
|
|
|
35
35
|
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
36
|
-
background-color: ${(props) =>
|
|
36
|
+
background-color: ${(props) => props.noBackground
|
|
37
|
+
? 'transparent'
|
|
38
|
+
: props.iconOnly
|
|
39
|
+
? getThemeVariantColours(props.variant, props.theme).main
|
|
40
|
+
: getThemeVariantColours(props.variant, props.theme).darker};
|
|
37
41
|
|
|
38
|
-
height: ${(props) => getIconContainerSizePx(props.size).height};
|
|
42
|
+
height: ${(props) => props.height || getIconContainerSizePx(props.size).height};
|
|
39
43
|
width: ${(props) => getIconContainerSizePx(props.size).width};
|
|
40
44
|
`;
|
|
41
45
|
const StyledButton = styled.button `
|
|
@@ -45,12 +49,13 @@ const StyledButton = styled.button `
|
|
|
45
49
|
|
|
46
50
|
cursor: pointer;
|
|
47
51
|
padding: 0;
|
|
52
|
+
margin: 0;
|
|
48
53
|
|
|
49
54
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
50
55
|
font-family: ${(props) => props.theme.fonts.default.family};
|
|
51
56
|
|
|
52
|
-
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
53
|
-
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).main};
|
|
57
|
+
color: ${(props) => getThemeVariantColours(props.noBackground ? 'secondary' : props.variant, props.theme).contrastText};
|
|
58
|
+
background-color: ${(props) => props.noBackground ? 'transparent' : getThemeVariantColours(props.variant, props.theme).main};
|
|
54
59
|
|
|
55
60
|
border-radius: 2px;
|
|
56
61
|
|
|
@@ -61,16 +66,19 @@ const StyledButton = styled.button `
|
|
|
61
66
|
margin-top: ${(props) => props.marginTop};
|
|
62
67
|
|
|
63
68
|
&:hover {
|
|
64
|
-
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).hover};
|
|
69
|
+
background-color: ${(props) => props.noBackground ? 'transparent' : getThemeVariantColours(props.variant, props.theme).hover};
|
|
65
70
|
|
|
66
71
|
${IconOuter} {
|
|
67
|
-
background-color: ${(props) =>
|
|
72
|
+
background-color: ${(props) => props.iconOnly
|
|
73
|
+
? getThemeVariantColours(props.variant, props.theme).hover
|
|
74
|
+
: getThemeVariantColours(props.variant, props.theme).darkerHover};
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
77
|
`;
|
|
71
78
|
const ButtonInner = styled.div `
|
|
72
79
|
display: flex;
|
|
73
80
|
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
74
82
|
`;
|
|
75
83
|
const ButtonTextContainer = styled.span `
|
|
76
84
|
padding: ${(props) => getButtonPaddingPx(props.size)};
|
|
@@ -103,12 +111,12 @@ const ButtonSpinner = styled.div `
|
|
|
103
111
|
}
|
|
104
112
|
`;
|
|
105
113
|
const Button = React.forwardRef(function Button(props, ref) {
|
|
106
|
-
const { children, loading, variant = 'primary', size = 'md', type = 'button', icon, onClick, 'data-
|
|
107
|
-
const { width, height, alignSelf, marginTop } = useContext(ButtonContext);
|
|
108
|
-
return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, variant: variant, size: size, type: type, onClick: onClick, "data-
|
|
109
|
-
React.createElement(ButtonSpinner, { "data-
|
|
114
|
+
const { children, loading, variant = 'primary', size = 'md', type = 'button', icon, onClick, 'data-testid': dataTestId, } = props;
|
|
115
|
+
const { width, height, alignSelf, marginTop, noBackground } = useContext(ButtonContext);
|
|
116
|
+
return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, noBackground: noBackground, variant: variant, size: size, type: type, onClick: onClick, "data-testid": dataTestId || 'button', iconOnly: !children }, loading ? (React.createElement(SpinnerContainer, null,
|
|
117
|
+
React.createElement(ButtonSpinner, { "data-testid": 'button-loading-spinner', variant: variant, size: size, iconOnly: !children }))) : (React.createElement(ButtonInner, null,
|
|
110
118
|
children && React.createElement(ButtonTextContainer, { size: size }, children),
|
|
111
|
-
icon && (React.createElement(IconOuter, { variant: variant, size: size },
|
|
119
|
+
icon && (React.createElement(IconOuter, { noBackground: noBackground, variant: variant, size: size, height: height, iconOnly: !children },
|
|
112
120
|
React.createElement(FontAwesomeIcon, { icon: icon })))))));
|
|
113
121
|
});
|
|
114
122
|
export default Button;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CardSize } from './Card.context';
|
|
3
3
|
export interface CardProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
size?: CardSize;
|
|
6
|
-
padded?: boolean;
|
|
7
|
-
onClick?: () => void;
|
|
4
|
+
'children': React.ReactNode;
|
|
5
|
+
'size'?: CardSize;
|
|
6
|
+
'padded'?: boolean;
|
|
7
|
+
'onClick'?: () => void;
|
|
8
|
+
'data-testid'?: string;
|
|
8
9
|
}
|
|
9
10
|
declare const Card: {
|
|
10
|
-
({ children, padded, size, onClick }: CardProps): JSX.Element;
|
|
11
|
-
ToggleSection: ({ heading, enabled, setEnabled, children }: import("./_CardToggleSection.component").CardToggleSectionProps) => JSX.Element;
|
|
11
|
+
({ children, padded, size, onClick, "data-testid": dataTestId }: CardProps): JSX.Element;
|
|
12
|
+
ToggleSection: ({ heading, enabled, setEnabled, children, "data-testid": dataTestId, }: import("./_CardToggleSection.component").CardToggleSectionProps) => JSX.Element;
|
|
12
13
|
Actions: ({ children }: import("./_CardActions.component").CardActionsProps) => React.ReactPortal | null;
|
|
13
14
|
Action: ({ children, onClick }: import("./_CardActions.component").CardActionProps) => JSX.Element;
|
|
14
15
|
Content: ({ children }: import("./_CardContent.component").CardContentProps) => JSX.Element;
|
|
@@ -69,7 +69,7 @@ const CardOuter = styled(motion.div) `
|
|
|
69
69
|
cursor: ${(props) => (props.usePointer ? 'pointer' : 'default')};
|
|
70
70
|
padding: ${(props) => (props.padded ? '16px' : 0)};
|
|
71
71
|
`;
|
|
72
|
-
const Card = ({ children, padded, size = 'sm', onClick }) => {
|
|
72
|
+
const Card = ({ children, padded, size = 'sm', onClick, 'data-testid': dataTestId }) => {
|
|
73
73
|
const actionsRef = useRef(null);
|
|
74
74
|
const [htmlActionsRef, setHtmlActionsRef] = useState();
|
|
75
75
|
const [showActions, setShowActions] = useState(false);
|
|
@@ -94,7 +94,7 @@ const Card = ({ children, padded, size = 'sm', onClick }) => {
|
|
|
94
94
|
scale: 1.005,
|
|
95
95
|
boxShadow: theme.shadows.xlarge,
|
|
96
96
|
}
|
|
97
|
-
: {}, size: size, padded: padded, onClick: handleClick, usePointer: !!onClick, "data-
|
|
97
|
+
: {}, size: size, padded: padded, onClick: handleClick, usePointer: !!onClick, "data-testid": dataTestId || 'card' },
|
|
98
98
|
React.createElement(CardActionsContainer, { ref: actionsRef }),
|
|
99
99
|
React.createElement(CardInner, null, children))));
|
|
100
100
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { Text } from '../..';
|
|
4
|
+
import ButtonContext from '../Button/Button.context';
|
|
4
5
|
const HeaderRow = styled.div `
|
|
5
6
|
display: flex;
|
|
6
7
|
justify-content: space-between;
|
|
7
8
|
padding: 8px 16px;
|
|
8
9
|
margin-bottom: 8px;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
background-color: ${(props) => props.theme.colours.cardBackgroundSecondary};
|
|
11
12
|
`;
|
|
12
13
|
const LeftContainer = styled.div `
|
|
13
14
|
display: flex;
|
|
@@ -43,6 +44,7 @@ const CardHeader = ({ image, heading, subHeading, meta }) => {
|
|
|
43
44
|
React.createElement(Text, null, heading)),
|
|
44
45
|
React.createElement("div", null,
|
|
45
46
|
React.createElement(Text, { variant: 'secondary' }, subHeading)))),
|
|
46
|
-
meta && React.createElement(MetaContainer, null,
|
|
47
|
+
meta && (React.createElement(MetaContainer, null,
|
|
48
|
+
React.createElement(ButtonContext.Provider, { value: { height: '24px', width: '24px', noBackground: true } }, meta)))));
|
|
47
49
|
};
|
|
48
50
|
export default CardHeader;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface CardToggleSectionProps {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
heading: string;
|
|
5
|
-
enabled: boolean;
|
|
6
|
-
setEnabled: (enabled: boolean) => void;
|
|
3
|
+
'children': React.ReactNode;
|
|
4
|
+
'heading': string;
|
|
5
|
+
'enabled': boolean;
|
|
6
|
+
'setEnabled': (enabled: boolean) => void;
|
|
7
|
+
'data-testid'?: string;
|
|
7
8
|
}
|
|
8
|
-
declare const CardToggleSection: ({ heading, enabled, setEnabled, children }: CardToggleSectionProps) => JSX.Element;
|
|
9
|
+
declare const CardToggleSection: ({ heading, enabled, setEnabled, children, "data-testid": dataTestId, }: CardToggleSectionProps) => JSX.Element;
|
|
9
10
|
export default CardToggleSection;
|
|
@@ -14,9 +14,9 @@ const ToggleHeaderContainer = styled.div `
|
|
|
14
14
|
|
|
15
15
|
background-color: ${(props) => props.theme.colours.cardBackgroundSecondary};
|
|
16
16
|
`;
|
|
17
|
-
const CardToggleSection = ({ heading, enabled, setEnabled, children }) => {
|
|
17
|
+
const CardToggleSection = ({ heading, enabled, setEnabled, children, 'data-testid': dataTestId, }) => {
|
|
18
18
|
return (React.createElement(React.Fragment, null,
|
|
19
|
-
React.createElement(ToggleHeaderContainer, { onClick: () => setEnabled(!enabled) },
|
|
19
|
+
React.createElement(ToggleHeaderContainer, { onClick: () => setEnabled(!enabled), "data-testid": dataTestId || 'card-toggle-header' },
|
|
20
20
|
React.createElement(Text, null, heading),
|
|
21
21
|
React.createElement(Toggle, { value: enabled, onChange: setEnabled })),
|
|
22
22
|
enabled && React.createElement("div", null, children)));
|
|
@@ -35,7 +35,7 @@ const Checklist = ({ items, value, onChange, noSplitGap, large }) => {
|
|
|
35
35
|
.filter((item) => value.includes(item.id))
|
|
36
36
|
.sort((a, b) => checkedOrder.indexOf(a.id) - checkedOrder.indexOf(b.id));
|
|
37
37
|
const unCheckedItems = items.filter((item) => !value.includes(item.id));
|
|
38
|
-
return (React.createElement(LayoutGroup, { "data-
|
|
38
|
+
return (React.createElement(LayoutGroup, { "data-testid": 'checklist' },
|
|
39
39
|
unCheckedItems.map((item) => (React.createElement(motion.div, { layoutId: item.id, key: item.id },
|
|
40
40
|
React.createElement(ChecklistItem, { label: item.label, value: value.includes(item.id), onChange: (checked) => handleChange(item.id, checked), large: !!large })))),
|
|
41
41
|
checkedItems.length && !noSplitGap ? React.createElement(ListDivider, null) : null,
|
|
@@ -50,7 +50,7 @@ const ChecklistItem = ({ label, value, onChange, large }) => {
|
|
|
50
50
|
onChange(false);
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
return (React.createElement(Outerlabel, { checked: value, whileHover: { backgroundColor: theme.colours.cardBackground }, "data-
|
|
53
|
+
return (React.createElement(Outerlabel, { checked: value, whileHover: { backgroundColor: theme.colours.cardBackground }, "data-testid": value ? 'checklist-item-checked' : 'checklist-item' },
|
|
54
54
|
React.createElement(Checkmark, { checked: value, large: large }),
|
|
55
55
|
React.createElement(Spacer, null),
|
|
56
56
|
label,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
const ActionContainer = styled.div `
|
|
4
|
+
display: flex;
|
|
5
|
+
width: 100%;
|
|
6
|
+
|
|
7
|
+
> :first-child {
|
|
8
|
+
flex-grow: 1;
|
|
9
|
+
margin-right: 3px;
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
const SpacedContainer = styled.div `
|
|
13
|
+
display: flex;
|
|
14
|
+
|
|
15
|
+
> * {
|
|
16
|
+
flex-grow: 1;
|
|
17
|
+
margin-right: 3px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
> *:last-child {
|
|
21
|
+
margin-right: 0;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
const ControlLine = ({ children, variant = 'action' }) => {
|
|
25
|
+
if (variant === 'action') {
|
|
26
|
+
return React.createElement(ActionContainer, null, children);
|
|
27
|
+
}
|
|
28
|
+
if (variant === 'spaced') {
|
|
29
|
+
return React.createElement(SpacedContainer, null, children);
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
export default ControlLine;
|
|
@@ -48,6 +48,6 @@ const FancyCheckbox = ({ name, label, options, value, onChange }) => {
|
|
|
48
48
|
const selectedValue = value || contextValue;
|
|
49
49
|
return (React.createElement("div", null,
|
|
50
50
|
label && React.createElement(FancyCheckboxLabel, { htmlFor: name }, label),
|
|
51
|
-
React.createElement(ButtonGroup, { "data-
|
|
51
|
+
React.createElement(ButtonGroup, { "data-testid": 'checkbox-group' }, options.map((option) => (React.createElement(StyledButton, { selected: option.value === selectedValue, key: option.value, onClick: () => handleChange(option.value), "data-testid": option.value === selectedValue ? 'checkbox-selected' : 'checkbox' }, option.label))))));
|
|
52
52
|
};
|
|
53
53
|
export default FancyCheckbox;
|
|
@@ -6,5 +6,8 @@ interface FormProps {
|
|
|
6
6
|
onSubmit?: () => void;
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
}
|
|
9
|
-
declare const Form:
|
|
9
|
+
declare const Form: {
|
|
10
|
+
({ value, errors, onChange, onSubmit, children }: FormProps): JSX.Element;
|
|
11
|
+
NestedFormArray: ({ name, index, children }: import("./_NestedFormArray").NestedFormArrayProps) => JSX.Element;
|
|
12
|
+
};
|
|
10
13
|
export default Form;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import FormStateContext from './FormState.context';
|
|
4
|
+
import NestedFormArray from './_NestedFormArray';
|
|
4
5
|
const Form = ({ value, errors = {}, onChange, onSubmit, children }) => {
|
|
5
6
|
const onChangeFn = (key, fieldValue) => {
|
|
6
7
|
onChange({
|
|
@@ -22,4 +23,5 @@ const Form = ({ value, errors = {}, onChange, onSubmit, children }) => {
|
|
|
22
23
|
return (React.createElement(FormStateContext.Provider, { value: contextValue },
|
|
23
24
|
React.createElement("form", { onSubmit: onSubmitFn }, children)));
|
|
24
25
|
};
|
|
26
|
+
Form.NestedFormArray = NestedFormArray;
|
|
25
27
|
export default Form;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface NestedFormArrayProps {
|
|
3
|
+
name: string;
|
|
4
|
+
index: number;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare const NestedFormArray: ({ name, index, children }: NestedFormArrayProps) => JSX.Element;
|
|
8
|
+
export default NestedFormArray;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FormStateContext from './FormState.context';
|
|
3
|
+
import useFormNode from './useFormNode.hook';
|
|
4
|
+
const NestedFormArray = ({ name, index, children }) => {
|
|
5
|
+
const { value, error, onChange } = useFormNode(name);
|
|
6
|
+
const safeValue = Array.from(Array(Math.max(index + 1, value?.length || 0))).map((_, i) => value?.[i] || {});
|
|
7
|
+
const safeError = Array.from(Array(Math.max(index + 1, value?.length || 0))).map((_, i) => error?.[i] || {});
|
|
8
|
+
const nestedValue = safeValue[index];
|
|
9
|
+
const nestedErrors = safeError[index];
|
|
10
|
+
const onChangeFn = (key, fieldValue) => {
|
|
11
|
+
const newValue = [
|
|
12
|
+
...safeValue.map((item, i) => (i === index ? { ...item, [key]: fieldValue } : item)),
|
|
13
|
+
];
|
|
14
|
+
onChange && onChange(newValue);
|
|
15
|
+
};
|
|
16
|
+
const contextValue = {
|
|
17
|
+
value: nestedValue,
|
|
18
|
+
errors: nestedErrors,
|
|
19
|
+
onChange: onChangeFn,
|
|
20
|
+
};
|
|
21
|
+
return React.createElement(FormStateContext.Provider, { value: contextValue }, children);
|
|
22
|
+
};
|
|
23
|
+
export default NestedFormArray;
|
|
@@ -6,5 +6,6 @@ declare const Heading: {
|
|
|
6
6
|
({ children }: HeadingProps): JSX.Element;
|
|
7
7
|
SubHeading: import("styled-components").StyledComponent<"h3", import("styled-components").DefaultTheme, {}, never>;
|
|
8
8
|
FormHeading: import("styled-components").StyledComponent<"h3", import("styled-components").DefaultTheme, {}, never>;
|
|
9
|
+
DividerHeading: import("styled-components").StyledComponent<"h3", import("styled-components").DefaultTheme, {}, never>;
|
|
9
10
|
};
|
|
10
11
|
export default Heading;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import DividerHeading from './_DividerHeading.component';
|
|
3
4
|
import FormHeading from './_FormHeading.component';
|
|
4
5
|
import SubHeading from './_SubHeading.component';
|
|
5
6
|
const HeadingContainer = styled.h2 `
|
|
@@ -14,4 +15,5 @@ const HeadingContainer = styled.h2 `
|
|
|
14
15
|
const Heading = ({ children }) => React.createElement(HeadingContainer, null, children);
|
|
15
16
|
Heading.SubHeading = SubHeading;
|
|
16
17
|
Heading.FormHeading = FormHeading;
|
|
18
|
+
Heading.DividerHeading = DividerHeading;
|
|
17
19
|
export default Heading;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
const DividerHeading = styled.h3 `
|
|
3
|
+
font-family: ${(props) => props.theme.fonts.default.family};
|
|
4
|
+
font-size: ${(props) => props.theme.fonts.default.size};
|
|
5
|
+
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
6
|
+
|
|
7
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
8
|
+
|
|
9
|
+
width: 100%;
|
|
10
|
+
padding: 8px;
|
|
11
|
+
|
|
12
|
+
background-color: ${(props) => props.theme.colours.cardBackground};
|
|
13
|
+
box-shadow: ${(props) => props.theme.shadows.small};
|
|
14
|
+
`;
|
|
15
|
+
export default DividerHeading;
|
|
@@ -8,7 +8,7 @@ interface ImageUploadProps {
|
|
|
8
8
|
'onChange'?: (value: string) => void;
|
|
9
9
|
'onSearch'?: () => void;
|
|
10
10
|
'uploadFn'?: (file: File) => Promise<string>;
|
|
11
|
-
'data-
|
|
11
|
+
'data-testid'?: string;
|
|
12
12
|
}
|
|
13
|
-
declare const ImageUpload: ({ name, value, "error": propsError, "uploading": uploadingProp, onChange, onSearch, "data-
|
|
13
|
+
declare const ImageUpload: ({ name, value, "error": propsError, "uploading": uploadingProp, onChange, onSearch, "data-testid": dataTestId, }: ImageUploadProps) => JSX.Element;
|
|
14
14
|
export default ImageUpload;
|
|
@@ -94,7 +94,7 @@ const ErrorInner = styled.div `
|
|
|
94
94
|
const errorVariants = {
|
|
95
95
|
show: { opacity: 1 },
|
|
96
96
|
};
|
|
97
|
-
const ImageUpload = ({ name, value, 'error': propsError, 'uploading': uploadingProp, onChange, onSearch, 'data-
|
|
97
|
+
const ImageUpload = ({ name, value, 'error': propsError, 'uploading': uploadingProp, onChange, onSearch, 'data-testid': dataTestId, }) => {
|
|
98
98
|
const { upload, getUrl } = useContext(FileContext);
|
|
99
99
|
const [uploading, setUploading] = useState(false);
|
|
100
100
|
const { value: contextValue, error: contextError, onChange: contextOnChange } = useFormNode(name);
|
|
@@ -125,26 +125,26 @@ const ImageUpload = ({ name, value, 'error': propsError, 'uploading': uploadingP
|
|
|
125
125
|
};
|
|
126
126
|
const internalValue = value ? value : contextValue;
|
|
127
127
|
if (uploading || uploadingProp) {
|
|
128
|
-
return (React.createElement(UploadContainer, { "data-
|
|
128
|
+
return (React.createElement(UploadContainer, { "data-testid": dataTestId },
|
|
129
129
|
React.createElement(LoaderContainer, null,
|
|
130
130
|
React.createElement(Loader, null))));
|
|
131
131
|
}
|
|
132
132
|
if (!internalValue) {
|
|
133
|
-
return (React.createElement(UploadContainer, { "data-
|
|
133
|
+
return (React.createElement(UploadContainer, { "data-testid": dataTestId },
|
|
134
134
|
React.createElement(UploadInnerContainer, null,
|
|
135
|
-
React.createElement(IconContainer, { whileHover: { scale: 1.05 }, onClick: handleUploadClicked, "data-
|
|
135
|
+
React.createElement(IconContainer, { whileHover: { scale: 1.05 }, onClick: handleUploadClicked, "data-testid": 'button-image-upload' },
|
|
136
136
|
React.createElement(FontAwesomeIcon, { icon: faCloudUploadAlt })),
|
|
137
137
|
onSearch && (React.createElement(React.Fragment, null,
|
|
138
138
|
React.createElement(UploadVerticalDivider, null),
|
|
139
|
-
React.createElement(IconContainer, { whileHover: { scale: 1.05 }, onClick: onSearch, "data-
|
|
139
|
+
React.createElement(IconContainer, { whileHover: { scale: 1.05 }, onClick: onSearch, "data-testid": 'button-image-search' },
|
|
140
140
|
React.createElement(FontAwesomeIcon, { icon: faSearch }))))),
|
|
141
|
-
React.createElement(HiddenInput, { value: '', ref: inputRef, type: 'file', onChange: handleUpload, "data-
|
|
142
|
-
error && (React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-
|
|
141
|
+
React.createElement(HiddenInput, { value: '', ref: inputRef, type: 'file', onChange: handleUpload, "data-testid": 'input-image-hidden' }),
|
|
142
|
+
error && (React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-testid": 'error-indicator' },
|
|
143
143
|
React.createElement(ErrorInner, null,
|
|
144
144
|
React.createElement(FontAwesomeIcon, { icon: faExclamationCircle })),
|
|
145
|
-
React.createElement(ErrorMessage, { "data-
|
|
145
|
+
React.createElement(ErrorMessage, { "data-testid": 'error-message' }, error)))));
|
|
146
146
|
}
|
|
147
|
-
return (React.createElement("div", { "data-
|
|
148
|
-
React.createElement(Image, { "data-
|
|
147
|
+
return (React.createElement("div", { "data-testid": dataTestId },
|
|
148
|
+
React.createElement(Image, { "data-testid": 'uploaded-image', src: getUrl(internalValue) })));
|
|
149
149
|
};
|
|
150
150
|
export default ImageUpload;
|
|
@@ -4,15 +4,16 @@ import { Status } from '../../theme/theme.types';
|
|
|
4
4
|
export type InlineCardSize = 'fill' | 'xs' | 'sm' | 'md' | 'lg';
|
|
5
5
|
export type DragVariant = Status;
|
|
6
6
|
export interface InlineCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
size?: InlineCardSize;
|
|
9
|
-
value?: string;
|
|
10
|
-
gestureLeftIcon?: IconProp;
|
|
11
|
-
gestureLeftVariant?: DragVariant;
|
|
12
|
-
onGestureLeft?: () => void;
|
|
7
|
+
'children': React.ReactNode;
|
|
8
|
+
'size'?: InlineCardSize;
|
|
9
|
+
'value'?: string;
|
|
10
|
+
'gestureLeftIcon'?: IconProp;
|
|
11
|
+
'gestureLeftVariant'?: DragVariant;
|
|
12
|
+
'onGestureLeft'?: () => void;
|
|
13
|
+
'data-testid'?: string;
|
|
13
14
|
}
|
|
14
15
|
declare const InlineCard: {
|
|
15
|
-
({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, }: InlineCardProps): JSX.Element;
|
|
16
|
+
({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, "data-testid": dataTestId, }: InlineCardProps): JSX.Element;
|
|
16
17
|
Media: ({ children, variant }: import("./_InlineCardMedia.component").InlineCardMediaProps) => JSX.Element;
|
|
17
18
|
Content: ({ children, center }: import("./_InlineCardContent.component").InlineCardContentProps) => JSX.Element;
|
|
18
19
|
Meta: ({ children }: import("./_InlineCardMeta.component").InlineCardMetaProps) => JSX.Element;
|