import React from 'react'; import { Pagination } from 'antd'; import classNames from 'classnames'; import styles from './index.less'; import { CommonProps, CommonState } from './interface'; import Table from './Table'; import OperateConfig from './operate'; import TableOperateConfig from './tableOperate'; import { defaultLocale } from '../locale'; import { Provider } from './context'; class AirTable extends React.Component { static getDerivedStateFromProps(nextProps: CommonProps, prevState: CommonState) { const { columns, dataSource } = prevState; const nextState: CommonState = { ...prevState, }; if (JSON.stringify(dataSource) !== JSON.stringify(nextProps.dataSource)) { nextState.dataSource = nextProps.dataSource; } if (JSON.stringify(columns) !== JSON.stringify(nextProps.columns)) { nextState.columns = nextProps.columns; } return nextState; } constructor(props: CommonProps) { super(props); const { columns, dataSource } = props; this.state = { columns, dataSource, }; } onScroll = () => { const { onScroll } = this.props; if (typeof onScroll === 'function') { onScroll(); } }; getContext = () => { const { locale } = this.props; if (locale) { if (locale.context) { if (locale.lang && defaultLocale[locale.lang]) { return { ...defaultLocale[locale.lang], ...locale.context }; } return locale.context; } } return defaultLocale.cn; }; render() { const { columns, dataSource } = this.state; const { className, tableClassName, rowStyle, rowClassName, distanceToLoad, emitChangeCell, bordered, width, height, operateConfig, paginationConfig, showIndex, showExpand, emptyPlaceholder, cellEditable, rowHeight, loading, rowSelection, tableOperateConfig, noDataPlaceholder, columnWidth, headerHeight, contentMenu, onScroll, loadComp, canResized, onDragResized, canFixed, onDragFixed, canSorted, onDragSorted, onEmitMsg, tableId, cachedFeAttr, renderFirstLeft, leftMargin, } = this.props; const sortConfig = operateConfig && operateConfig.menusGroup && operateConfig.menusGroup.find((item: any) => { return item.type === 'sort'; }); return (
{operateConfig && }
{tableOperateConfig && (
)}
{paginationConfig && } ); } } export default AirTable;