@dtdot/lego 1.2.0 → 1.4.0
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 -3
- package/build/components/ActionMenu/ActionMenu.component.js +2 -2
- package/build/components/Input/Input.component.d.ts +1 -0
- package/build/components/Input/Input.component.js +10 -2
- package/build/components/Table/Table.component.d.ts +2 -0
- package/build/components/Table/Table.component.js +4 -0
- package/build/components/Table/_TableActionContainer.d.ts +2 -0
- package/build/components/Table/_TableActionContainer.js +5 -0
- package/build/components/Table/_TableActionMenu.d.ts +8 -0
- package/build/components/Table/_TableActionMenu.js +6 -0
- package/build/theme/dark.theme.js +1 -0
- package/build/theme/default.theme.js +1 -0
- package/build/theme/theme.types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { ColourVariant } from '../../theme/theme.types';
|
|
3
3
|
import { IActionMenuItem } from './_ActionMenu.types';
|
|
4
4
|
export interface ActionMenuProps {
|
|
5
|
-
items: IActionMenuItem[];
|
|
6
|
-
variant?: ColourVariant;
|
|
5
|
+
'items': IActionMenuItem[];
|
|
6
|
+
'variant'?: ColourVariant;
|
|
7
|
+
'data-cy'?: string;
|
|
7
8
|
}
|
|
8
|
-
declare const ActionMenu: ({ items, variant }: ActionMenuProps) => JSX.Element;
|
|
9
|
+
declare const ActionMenu: ({ items, variant, "data-cy": dataCy }: ActionMenuProps) => JSX.Element;
|
|
9
10
|
export default ActionMenu;
|
|
@@ -10,7 +10,7 @@ const StyledIcon = styled(FontAwesomeIcon) `
|
|
|
10
10
|
font-size: 18px;
|
|
11
11
|
`;
|
|
12
12
|
const offsetFn = () => [70, 4];
|
|
13
|
-
const ActionMenu = ({ items, variant }) => {
|
|
13
|
+
const ActionMenu = ({ items, variant, 'data-cy': dataCy }) => {
|
|
14
14
|
const [shown, setShown] = useState(false);
|
|
15
15
|
const [referenceElement, setReferenceElement] = useState();
|
|
16
16
|
const [popperElement, setPopperElement] = useState();
|
|
@@ -43,7 +43,7 @@ const ActionMenu = ({ items, variant }) => {
|
|
|
43
43
|
},
|
|
44
44
|
}));
|
|
45
45
|
return (React.createElement(React.Fragment, null,
|
|
46
|
-
React.createElement(Button, { variant: variant, "data-cy": 'action-menu-button', ref: setReferenceElement, onClick: () => setShown(true) },
|
|
46
|
+
React.createElement(Button, { variant: variant, "data-cy": dataCy || 'action-menu-button', ref: setReferenceElement, onClick: () => setShown(true) },
|
|
47
47
|
React.createElement(StyledIcon, { icon: faEllipsisV })),
|
|
48
48
|
shown &&
|
|
49
49
|
ReactDOM.createPortal(React.createElement("div", { ref: setPopperElement, style: styles.popper, ...attributes.popper },
|
|
@@ -50,6 +50,14 @@ export const InputStyles = css `
|
|
|
50
50
|
&::placeholder {
|
|
51
51
|
color: ${(props) => getThemeControlColours(props.theme).placeholder};
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
&:disabled {
|
|
55
|
+
color: ${(props) => getThemeControlColours(props.theme).font};
|
|
56
|
+
opacity: 1;
|
|
57
|
+
-webkit-text-fill-color: ${(props) => getThemeControlColours(props.theme).font};
|
|
58
|
+
background-color: ${(props) => props.theme.colours.controlBackgroundDisabled};
|
|
59
|
+
border: none;
|
|
60
|
+
}
|
|
53
61
|
`;
|
|
54
62
|
const StyledInput = styled(motion.input) `
|
|
55
63
|
${InputStyles}
|
|
@@ -99,7 +107,7 @@ const messageVariants = {
|
|
|
99
107
|
errorFocus: { opacity: 1, y: -4 },
|
|
100
108
|
};
|
|
101
109
|
const Input = React.forwardRef(function ForwardRefInput(props, ref) {
|
|
102
|
-
const { label, name, placeholder, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-cy': dataCy, } = props;
|
|
110
|
+
const { label, name, placeholder, disabled, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-cy': dataCy, } = props;
|
|
103
111
|
const [isFocused, setIsFocused] = useState(false);
|
|
104
112
|
const { value: contextValue, error: contextError, onChange: contextOnChange } = useFormNode(name);
|
|
105
113
|
const error = contextError || propsError;
|
|
@@ -127,7 +135,7 @@ const Input = React.forwardRef(function ForwardRefInput(props, ref) {
|
|
|
127
135
|
return (React.createElement("div", null,
|
|
128
136
|
label && React.createElement(InputLabel, { htmlFor: name }, label),
|
|
129
137
|
React.createElement(InputContainer, { "data-cy": dataCy },
|
|
130
|
-
React.createElement(StyledInput, { ref: ref, animate: animationVariant, variants: inputVariants, transition: { type: 'spring', duration: 0.3 }, type: type, name: name, placeholder: placeholder, value: getValue(value, contextValue), onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, autoFocus: autoFocus, "data-cy": 'input' }),
|
|
138
|
+
React.createElement(StyledInput, { ref: ref, animate: animationVariant, variants: inputVariants, transition: { type: 'spring', duration: 0.3 }, type: type, name: name, placeholder: placeholder, disabled: disabled, value: getValue(value, contextValue), onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, autoFocus: autoFocus, "data-cy": 'input' }),
|
|
131
139
|
React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-cy": 'error-indicator' },
|
|
132
140
|
React.createElement(ErrorInner, null,
|
|
133
141
|
React.createElement(FontAwesomeIcon, { icon: faExclamationCircle }))),
|
|
@@ -12,6 +12,8 @@ declare const Table: {
|
|
|
12
12
|
({ children, variant }: TableProps): JSX.Element;
|
|
13
13
|
Row: ({ children, "data-cy": dataCy }: import("./_TableRow.component").TableRowProps) => JSX.Element;
|
|
14
14
|
Cell: import("styled-components").StyledComponent<"td", import("styled-components").DefaultTheme, TableCellProps, never>;
|
|
15
|
+
ActionContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
15
16
|
Action: ({ text, onClick, "data-cy": dataCy }: import("./_TableAction").TableActionProps) => JSX.Element;
|
|
17
|
+
ActionMenu: ({ items, "data-cy": dataCy }: import("./_TableActionMenu").TableActionMenuProps) => JSX.Element;
|
|
16
18
|
};
|
|
17
19
|
export default Table;
|
|
@@ -3,6 +3,8 @@ import styled from 'styled-components';
|
|
|
3
3
|
import ButtonContext from '../Button/Button.context';
|
|
4
4
|
import TableContext from './_Table.context';
|
|
5
5
|
import TableAction from './_TableAction';
|
|
6
|
+
import TableActionContainer from './_TableActionContainer';
|
|
7
|
+
import TableActionMenu from './_TableActionMenu';
|
|
6
8
|
import TableRow from './_TableRow.component';
|
|
7
9
|
const StyledTable = styled.table `
|
|
8
10
|
width: 100%;
|
|
@@ -25,5 +27,7 @@ const Table = ({ children, variant = 'regular' }) => {
|
|
|
25
27
|
};
|
|
26
28
|
Table.Row = TableRow;
|
|
27
29
|
Table.Cell = TableCell;
|
|
30
|
+
Table.ActionContainer = TableActionContainer;
|
|
28
31
|
Table.Action = TableAction;
|
|
32
|
+
Table.ActionMenu = TableActionMenu;
|
|
29
33
|
export default Table;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IActionMenuItem } from '../ActionMenu/_ActionMenu.types';
|
|
3
|
+
export interface TableActionMenuProps {
|
|
4
|
+
'items': IActionMenuItem[];
|
|
5
|
+
'data-cy'?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const TableActionMenu: ({ items, "data-cy": dataCy }: TableActionMenuProps) => JSX.Element;
|
|
8
|
+
export default TableActionMenu;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ActionMenu from '../ActionMenu/ActionMenu.component';
|
|
3
|
+
const TableActionMenu = ({ items, 'data-cy': dataCy }) => {
|
|
4
|
+
return React.createElement(ActionMenu, { variant: 'tertiary', items: items, "data-cy": dataCy });
|
|
5
|
+
};
|
|
6
|
+
export default TableActionMenu;
|
|
@@ -25,6 +25,7 @@ const defaultTheme = {
|
|
|
25
25
|
defaultBorder: colours.grey20,
|
|
26
26
|
faintBorder: colours.grey20,
|
|
27
27
|
controlBackground: colours.white,
|
|
28
|
+
controlBackgroundDisabled: colours.grey20,
|
|
28
29
|
controlBorder: colours.grey20,
|
|
29
30
|
controlBorderFocus: colours.grey50,
|
|
30
31
|
controlBorderHover: colours.grey30,
|