@dtdot/lego 2.0.0-2 → 2.0.0-21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/ActionMenu/ActionMenu.component.d.ts +7 -4
- package/build/components/ActionMenu/ActionMenu.component.js +3 -17
- package/build/components/ActionMenu/_ActionMenuCheckbox.component.d.ts +2 -2
- package/build/components/ActionMenu/_ActionMenuCheckbox.component.js +2 -2
- package/build/components/ActionMenu/_ActionMenuItem.component.d.ts +2 -2
- package/build/components/ActionMenu/_ActionMenuItem.component.js +2 -2
- package/build/components/ActionMenu/_ActionMenuPanel.component.js +1 -1
- package/build/components/ActionMessage/ActionMessage.component.js +1 -1
- package/build/components/Alert/Alert.component.js +3 -3
- package/build/components/Badge/Badge.component.js +1 -1
- package/build/components/BadgeSelector/BadgeSelector.component.js +1 -1
- package/build/components/Button/Button.component.d.ts +6 -2
- package/build/components/Button/Button.component.js +74 -14
- package/build/components/Button/Button.context.d.ts +1 -0
- package/build/components/Button/Button.context.js +1 -0
- package/build/components/Card/Card.component.d.ts +7 -6
- package/build/components/Card/Card.component.js +2 -2
- package/build/components/Card/_CardHeader.component.js +4 -2
- package/build/components/Card/_CardToggleSection.component.d.ts +6 -5
- package/build/components/Card/_CardToggleSection.component.js +2 -2
- package/build/components/Checklist/Checklist.component.js +1 -1
- package/build/components/Checklist/_ChecklistItem.component.js +1 -1
- package/build/components/ControlLine/ControlLine.component.d.ts +7 -0
- package/build/components/ControlLine/ControlLine.component.js +33 -0
- package/build/components/FancyCheckbox/FancyCheckbox.component.js +1 -1
- package/build/components/Form/Form.component.d.ts +4 -1
- package/build/components/Form/Form.component.js +2 -0
- package/build/components/Form/_NestedFormArray.d.ts +8 -0
- package/build/components/Form/_NestedFormArray.js +23 -0
- package/build/components/Heading/Heading.component.d.ts +1 -0
- package/build/components/Heading/Heading.component.js +2 -0
- package/build/components/Heading/_DividerHeading.component.d.ts +2 -0
- package/build/components/Heading/_DividerHeading.component.js +15 -0
- package/build/components/ImageUpload/ImageUpload.component.d.ts +2 -2
- package/build/components/ImageUpload/ImageUpload.component.js +10 -10
- package/build/components/InlineCard/InlineCard.component.d.ts +8 -7
- package/build/components/InlineCard/InlineCard.component.js +2 -2
- package/build/components/Input/Input.component.d.ts +3 -1
- package/build/components/Input/Input.component.js +24 -7
- package/build/components/LiveInput/LiveInput.component.d.ts +2 -2
- package/build/components/LiveInput/LiveInput.component.js +2 -2
- package/build/components/LiveList/LiveList.component.js +2 -2
- package/build/components/LiveList/_LiveListRow.js +3 -3
- package/build/components/Loader/Loader.component.d.ts +4 -1
- package/build/components/Loader/Loader.component.js +17 -5
- package/build/components/Menu/_MenuHeading.component.js +2 -2
- package/build/components/Menu/_MenuItem.component.js +1 -1
- package/build/components/Menu/_MenuPanel.component.js +1 -1
- package/build/components/MinimalMenu/MinimalMenu.component.d.ts +2 -1
- package/build/components/MinimalMenu/MinimalMenu.component.js +2 -0
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.d.ts +15 -0
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.js +31 -0
- package/build/components/MinimalMenu/_MinimalMenuItem.component.d.ts +2 -2
- package/build/components/MinimalMenu/_MinimalMenuItem.component.js +3 -3
- package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.d.ts +2 -2
- package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.js +2 -2
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.d.ts +2 -2
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.js +2 -2
- package/build/components/Modal/Modal.component.js +1 -1
- package/build/components/Modal/_ModalHeader.component.js +2 -2
- package/build/components/Notification/Notification.component.js +1 -1
- package/build/components/ProfileImage/ProfileImage.component.js +2 -2
- package/build/components/QrCode/QrCode.component.js +2 -2
- package/build/components/Select/Select.component.d.ts +2 -5
- package/build/components/Select/Select.component.js +12 -29
- package/build/components/Spacer/Spacer.component.d.ts +1 -1
- package/build/components/Spacer/Spacer.component.js +2 -0
- package/build/components/SquareButton/SquareButton.component.d.ts +2 -2
- package/build/components/SquareButton/SquareButton.component.js +2 -2
- package/build/components/Table/Table.component.d.ts +5 -3
- package/build/components/Table/Table.component.js +15 -0
- package/build/components/Table/_TableAction.d.ts +7 -3
- package/build/components/Table/_TableAction.js +6 -3
- package/build/components/Table/_TableActionMenu.d.ts +2 -2
- package/build/components/Table/_TableActionMenu.js +2 -2
- package/build/components/Table/_TableRow.component.d.ts +2 -2
- package/build/components/Table/_TableRow.component.js +6 -2
- package/build/components/Text/Text.component.d.ts +4 -3
- package/build/components/Text/Text.component.js +3 -3
- package/build/components/TextArea/TextArea.component.d.ts +1 -1
- package/build/components/TextArea/TextArea.component.js +5 -5
- package/build/components/Toggle/Toggle.component.js +1 -1
- package/build/components/common/Options.component.d.ts +19 -0
- package/build/components/common/Options.component.js +44 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/screens/Login/Login.screen.js +4 -4
- package/build/screens/Register/Register.screen.js +3 -3
- package/build/screens/Verification/Verification.screen.js +2 -2
- package/build/shared/ControlStyles.js +1 -1
- package/build/theme/dark.theme.js +20 -8
- package/build/theme/default.theme.js +6 -0
- package/build/theme/helpers/getThemeVariantColours.d.ts +1 -5
- package/build/theme/helpers/getThemeVariantColours.js +3 -15
- package/build/theme/theme.types.d.ts +2 -0
- package/package.json +3 -1
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
3
3
|
import { ColourVariant } from '../../theme/theme.types';
|
|
4
|
+
import { ButtonSize } from '../Button/Button.component';
|
|
4
5
|
export interface ActionMenuProps {
|
|
5
6
|
'children': React.ReactNode;
|
|
6
7
|
'variant'?: ColourVariant;
|
|
8
|
+
'size'?: ButtonSize;
|
|
7
9
|
'icon'?: IconProp;
|
|
8
|
-
'
|
|
10
|
+
'text'?: string;
|
|
11
|
+
'data-testid'?: string;
|
|
9
12
|
}
|
|
10
13
|
declare const ActionMenu: {
|
|
11
|
-
({ children, variant, icon, "data-
|
|
12
|
-
Item: ({ children, onClick, "data-
|
|
13
|
-
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;
|
|
14
17
|
};
|
|
15
18
|
export default ActionMenu;
|
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
2
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
2
|
import ReactDOM from 'react-dom';
|
|
4
3
|
import { usePopper } from 'react-popper';
|
|
5
4
|
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons';
|
|
6
|
-
import styled from 'styled-components';
|
|
7
5
|
import Button from '../Button/Button.component';
|
|
8
6
|
import ActionMenuContext from './ActionMenu.context';
|
|
9
7
|
import ActionMenuCheckbox from './_ActionMenuCheckbox.component';
|
|
10
8
|
import ActionMenuItem from './_ActionMenuItem.component';
|
|
11
9
|
import ActionMenuPanel from './_ActionMenuPanel.component';
|
|
12
|
-
const IconWrapper = styled.div `
|
|
13
|
-
width: 0;
|
|
14
|
-
height: 100%;
|
|
15
|
-
display: flex;
|
|
16
|
-
align-items: center;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
`;
|
|
19
|
-
const StyledIcon = styled(FontAwesomeIcon) `
|
|
20
|
-
font-size: 18px;
|
|
21
|
-
`;
|
|
22
10
|
const offsetFn = () => [70, 4];
|
|
23
|
-
const ActionMenu = ({ children, variant, icon, 'data-
|
|
11
|
+
const ActionMenu = ({ children, variant, size, icon, text, 'data-testid': dataTestId }) => {
|
|
24
12
|
const [shown, setShown] = useState(false);
|
|
25
13
|
const [referenceElement, setReferenceElement] = useState();
|
|
26
14
|
const [popperElement, setPopperElement] = useState();
|
|
@@ -46,11 +34,9 @@ const ActionMenu = ({ children, variant, icon, 'data-cy': dataCy }) => {
|
|
|
46
34
|
};
|
|
47
35
|
}, [handleGlobalClick, popperElement]);
|
|
48
36
|
return (React.createElement(React.Fragment, null,
|
|
49
|
-
React.createElement(Button, { variant: variant, "data-
|
|
50
|
-
React.createElement(IconWrapper, null,
|
|
51
|
-
React.createElement(StyledIcon, { icon: icon || faEllipsisV }))),
|
|
37
|
+
React.createElement(Button, { variant: variant, size: size, icon: icon || faEllipsisV, "data-testid": dataTestId || 'action-menu-button', ref: setReferenceElement, onClick: () => setShown(true) }, text),
|
|
52
38
|
shown &&
|
|
53
|
-
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 },
|
|
54
40
|
React.createElement(ActionMenuContext.Provider, { value: { closeActionMenu: () => setShown(false) } },
|
|
55
41
|
React.createElement(ActionMenuPanel, null, children))), document.querySelector('body'))));
|
|
56
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;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
2
3
|
import { ColourVariant } from '../../theme/theme.types';
|
|
4
|
+
export type ButtonSize = 'sm' | 'md';
|
|
3
5
|
export interface ButtonProps {
|
|
4
|
-
'children'
|
|
6
|
+
'children'?: React.ReactNode;
|
|
5
7
|
'loading'?: boolean;
|
|
6
8
|
'variant'?: ColourVariant;
|
|
9
|
+
'size'?: ButtonSize;
|
|
7
10
|
'type'?: 'submit' | 'button';
|
|
11
|
+
'icon'?: IconProp;
|
|
8
12
|
'onClick'?: () => void;
|
|
9
|
-
'data-
|
|
13
|
+
'data-testid'?: string;
|
|
10
14
|
}
|
|
11
15
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<unknown>>;
|
|
12
16
|
export default Button;
|
|
@@ -1,49 +1,105 @@
|
|
|
1
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
1
2
|
import React, { useContext } from 'react';
|
|
2
3
|
import styled, { keyframes } from 'styled-components';
|
|
3
4
|
import getThemeVariantColours from '../../theme/helpers/getThemeVariantColours';
|
|
4
5
|
import ButtonContext from './Button.context';
|
|
6
|
+
const getButtonHeightPx = (size) => {
|
|
7
|
+
switch (size) {
|
|
8
|
+
case 'sm':
|
|
9
|
+
return '32px';
|
|
10
|
+
case 'md':
|
|
11
|
+
return '48px';
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const getButtonPaddingPx = (size) => {
|
|
15
|
+
switch (size) {
|
|
16
|
+
case 'sm':
|
|
17
|
+
return '0 12px';
|
|
18
|
+
case 'md':
|
|
19
|
+
return '0 24px';
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const getIconContainerSizePx = (size) => {
|
|
23
|
+
switch (size) {
|
|
24
|
+
case 'sm':
|
|
25
|
+
return { width: '32px', height: '32px' };
|
|
26
|
+
case 'md':
|
|
27
|
+
return { width: '48px', height: '48px' };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const IconOuter = styled.span `
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
|
|
35
|
+
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
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};
|
|
41
|
+
|
|
42
|
+
height: ${(props) => props.height || getIconContainerSizePx(props.size).height};
|
|
43
|
+
width: ${(props) => getIconContainerSizePx(props.size).width};
|
|
44
|
+
`;
|
|
5
45
|
const StyledButton = styled.button `
|
|
6
46
|
outline: none;
|
|
7
47
|
box-shadow: none;
|
|
8
48
|
border: none;
|
|
9
49
|
|
|
10
50
|
cursor: pointer;
|
|
11
|
-
|
|
12
|
-
padding: 0 24px;
|
|
51
|
+
padding: 0;
|
|
13
52
|
|
|
14
53
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
15
54
|
font-family: ${(props) => props.theme.fonts.default.family};
|
|
16
55
|
|
|
17
|
-
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
18
|
-
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).main};
|
|
56
|
+
color: ${(props) => getThemeVariantColours(props.noBackground ? 'secondary' : props.variant, props.theme).contrastText};
|
|
57
|
+
background-color: ${(props) => props.noBackground ? 'transparent' : getThemeVariantColours(props.variant, props.theme).main};
|
|
19
58
|
|
|
20
59
|
border-radius: 2px;
|
|
21
60
|
|
|
22
61
|
// Props defined by the context
|
|
23
|
-
height: ${(props) => props.height ||
|
|
62
|
+
height: ${(props) => props.height || getButtonHeightPx(props.size)};
|
|
24
63
|
width: ${(props) => props.width};
|
|
25
64
|
align-self: ${(props) => props.alignSelf};
|
|
26
65
|
margin-top: ${(props) => props.marginTop};
|
|
27
66
|
|
|
28
67
|
&:hover {
|
|
29
|
-
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).hover};
|
|
68
|
+
background-color: ${(props) => props.noBackground ? 'transparent' : getThemeVariantColours(props.variant, props.theme).hover};
|
|
69
|
+
|
|
70
|
+
${IconOuter} {
|
|
71
|
+
background-color: ${(props) => props.iconOnly
|
|
72
|
+
? getThemeVariantColours(props.variant, props.theme).hover
|
|
73
|
+
: getThemeVariantColours(props.variant, props.theme).darkerHover};
|
|
74
|
+
}
|
|
30
75
|
}
|
|
31
76
|
`;
|
|
77
|
+
const ButtonInner = styled.div `
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
`;
|
|
82
|
+
const ButtonTextContainer = styled.span `
|
|
83
|
+
padding: ${(props) => getButtonPaddingPx(props.size)};
|
|
84
|
+
`;
|
|
32
85
|
const spinAnimation = keyframes `
|
|
33
86
|
0% { transform: rotate(0deg); }
|
|
34
87
|
100% { transform: rotate(360deg); }
|
|
35
88
|
`;
|
|
89
|
+
const SpinnerContainer = styled.span `
|
|
90
|
+
padding: 0 24px;
|
|
91
|
+
`;
|
|
36
92
|
const ButtonSpinner = styled.div `
|
|
37
93
|
display: inline-block;
|
|
38
|
-
width:
|
|
39
|
-
height:
|
|
94
|
+
width: ${(props) => getButtonHeightPx(props.size)};
|
|
95
|
+
height: ${(props) => getButtonHeightPx(props.size)};
|
|
40
96
|
|
|
41
97
|
&:after {
|
|
42
98
|
content: ' ';
|
|
43
99
|
display: block;
|
|
44
|
-
width: 24px;
|
|
45
|
-
height: 24px;
|
|
46
|
-
margin: 10px;
|
|
100
|
+
width: ${(props) => (props.size === 'md' ? '24px' : '16px')};
|
|
101
|
+
height: ${(props) => (props.size === 'md' ? '24px' : '16px')};
|
|
102
|
+
margin: ${(props) => (props.size === 'md' ? '10px' : '6px')};
|
|
47
103
|
border-radius: 50%;
|
|
48
104
|
border: 2px solid ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
49
105
|
border-color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText} transparent
|
|
@@ -54,8 +110,12 @@ const ButtonSpinner = styled.div `
|
|
|
54
110
|
}
|
|
55
111
|
`;
|
|
56
112
|
const Button = React.forwardRef(function Button(props, ref) {
|
|
57
|
-
const { children, loading, variant = 'primary', type = 'button', onClick, 'data-
|
|
58
|
-
const { width, height, alignSelf, marginTop } = useContext(ButtonContext);
|
|
59
|
-
return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, variant: variant, type: type, onClick: onClick, "data-
|
|
113
|
+
const { children, loading, variant = 'primary', size = 'md', type = 'button', icon, onClick, 'data-testid': dataTestId, } = props;
|
|
114
|
+
const { width, height, alignSelf, marginTop, noBackground } = useContext(ButtonContext);
|
|
115
|
+
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,
|
|
116
|
+
React.createElement(ButtonSpinner, { "data-testid": 'button-loading-spinner', variant: variant, size: size, iconOnly: !children }))) : (React.createElement(ButtonInner, null,
|
|
117
|
+
children && React.createElement(ButtonTextContainer, { size: size }, children),
|
|
118
|
+
icon && (React.createElement(IconOuter, { noBackground: noBackground, variant: variant, size: size, height: height, iconOnly: !children },
|
|
119
|
+
React.createElement(FontAwesomeIcon, { icon: icon })))))));
|
|
60
120
|
});
|
|
61
121
|
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
|
+
padding-right: 3px;
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
const SpacedContainer = styled.div `
|
|
13
|
+
display: flex;
|
|
14
|
+
|
|
15
|
+
> * {
|
|
16
|
+
flex-grow: 1;
|
|
17
|
+
padding-right: 3px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
> *:last-child {
|
|
21
|
+
padding-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;
|