This commit is contained in:
Jan Prochazka
2021-01-23 07:22:09 +01:00
parent 37cc86f8d2
commit 451af5d09f
141 changed files with 763 additions and 787 deletions

View File

@@ -7,7 +7,7 @@ import useTheme from '../theme/useTheme';
const Table = styled.table`
border-collapse: collapse;
width: 100%;
user-select: ${(props) =>
user-select: ${props =>
// @ts-ignore
props.focusable ? 'none' : ''};
// outline: none;
@@ -16,17 +16,17 @@ const TableHead = styled.thead``;
const TableBody = styled.tbody``;
const TableHeaderRow = styled.tr``;
const TableBodyRow = styled.tr`
background-color: ${(props) =>
background-color: ${props =>
// @ts-ignore
props.isSelected ? props.theme.gridbody_background_blue[1] : props.theme.gridbody_background};
`;
const TableHeaderCell = styled.td`
border: 1px solid ${(props) => props.theme.gridheader_background};
background-color: ${(props) => props.theme.gridheader_background};
border: 1px solid ${props => props.theme.gridheader_background};
background-color: ${props => props.theme.gridheader_background};
padding: 5px;
`;
const TableBodyCell = styled.td`
border: 1px solid ${(props) => props.theme.gridbody_background2};
border: 1px solid ${props => props.theme.gridbody_background2};
padding: 5px;
`;
@@ -51,8 +51,8 @@ export default function TableControl({
tableRef = undefined,
}) {
const columns = (children instanceof Array ? _.flatten(children) : [children])
.filter((child) => child && child.props && child.props.fieldName)
.map((child) => child.props);
.filter(child => child && child.props && child.props.fieldName)
.map(child => child.props);
const myTableRef = React.useRef(null);
const currentTableRef = tableRef || myTableRef;
@@ -65,12 +65,12 @@ export default function TableControl({
}, []);
const handleKeyDown = React.useCallback(
(event) => {
event => {
if (event.keyCode == keycodes.downArrow) {
setSelectedIndex((i) => Math.min(i + 1, rows.length - 1));
setSelectedIndex(i => Math.min(i + 1, rows.length - 1));
}
if (event.keyCode == keycodes.upArrow) {
setSelectedIndex((i) => Math.max(0, i - 1));
setSelectedIndex(i => Math.max(0, i - 1));
}
if (onKeyDown) onKeyDown(event);
},
@@ -87,7 +87,7 @@ export default function TableControl({
>
<TableHead>
<TableHeaderRow>
{columns.map((x) => (
{columns.map(x => (
<TableHeaderCell key={x.fieldName} theme={theme}>
{x.header}
</TableHeaderCell>
@@ -110,8 +110,10 @@ export default function TableControl({
: undefined
}
>
{columns.map((col) => (
<TableBodyCell key={col.fieldName} theme={theme}>{format(row, col)}</TableBodyCell>
{columns.map(col => (
<TableBodyCell key={col.fieldName} theme={theme}>
{format(row, col)}
</TableBodyCell>
))}
</TableBodyRow>
))}