This repository has been archived on 2025-05-09. You can view files and clone it, but cannot push or open issues or pull requests.
2021-05-18 10:32:52 +03:00

40 lines
1.0 KiB
TypeScript

import { Table as AntTable, TableProps } from 'antd';
import { Box } from 'client/UIKit/grid';
import { toJS } from 'mobx';
import { observer } from 'mobx-react-lite';
import React from 'react';
import styled from 'styled-components';
const TableWrapper = styled(Box)`
.ant-table-row-level-1 .ant-table-selection-column {
visibility: hidden;
}
`;
interface ITableProps {
selectKey: (key: string) => void;
selectedKey: string;
tableConfig: TableProps<any>;
dataSource: any[];
}
export default observer(
({ selectKey, selectedKey, tableConfig, dataSource, ...props }) => {
return (
<TableWrapper my="5px">
<AntTable
{...tableConfig}
rowSelection={Object.assign(tableConfig.rowSelection, {
selectedRowKeys: selectedKey ? [selectedKey] : [],
onSelect: record => {
selectKey(record.key);
},
})}
dataSource={toJS(dataSource)}
{...props}
></AntTable>
</TableWrapper>
);
},
) as React.FC<ITableProps>;