2022-06-22 14:57:09 +08:00
|
|
|
import * as React from 'react';
|
2023-01-07 21:21:52 +08:00
|
|
|
import { Summary, EXPAND_COLUMN } from 'rc-table';
|
2022-06-22 14:57:09 +08:00
|
|
|
import Column from './Column';
|
|
|
|
import ColumnGroup from './ColumnGroup';
|
2023-01-07 21:21:52 +08:00
|
|
|
import InternalTable from './InternalTable';
|
|
|
|
import type { TableProps } from './InternalTable';
|
|
|
|
import type { RefTable } from './interface';
|
|
|
|
import {
|
2020-12-29 10:38:43 +08:00
|
|
|
SELECTION_ALL,
|
2021-11-26 17:50:41 +08:00
|
|
|
SELECTION_COLUMN,
|
2020-12-29 10:38:43 +08:00
|
|
|
SELECTION_INVERT,
|
|
|
|
SELECTION_NONE,
|
|
|
|
} from './hooks/useSelection';
|
2016-06-19 10:56:42 +08:00
|
|
|
|
2023-01-07 21:21:52 +08:00
|
|
|
function Table<RecordType extends object = any>(
|
2021-09-17 11:17:29 +08:00
|
|
|
props: TableProps<RecordType>,
|
2023-01-07 21:21:52 +08:00
|
|
|
ref: React.Ref<HTMLDivElement>,
|
2021-09-17 11:17:29 +08:00
|
|
|
) {
|
2023-01-07 21:21:52 +08:00
|
|
|
const renderTimesRef = React.useRef(0);
|
|
|
|
renderTimesRef.current += 1;
|
2018-11-01 13:42:53 +08:00
|
|
|
|
2023-01-07 21:21:52 +08:00
|
|
|
return <InternalTable<RecordType> {...props} ref={ref} _renderTimes={renderTimesRef.current} />;
|
2016-06-19 10:56:42 +08:00
|
|
|
}
|
2019-08-28 02:35:39 +08:00
|
|
|
|
2023-01-07 21:21:52 +08:00
|
|
|
const ForwardTable = React.forwardRef(Table) as any as RefTable & {
|
2021-11-26 17:50:41 +08:00
|
|
|
SELECTION_COLUMN: typeof SELECTION_COLUMN;
|
2023-01-07 21:21:52 +08:00
|
|
|
EXPAND_COLUMN: typeof EXPAND_COLUMN;
|
2021-09-17 11:17:29 +08:00
|
|
|
SELECTION_ALL: 'SELECT_ALL';
|
|
|
|
SELECTION_INVERT: 'SELECT_INVERT';
|
|
|
|
SELECTION_NONE: 'SELECT_NONE';
|
|
|
|
Column: typeof Column;
|
|
|
|
ColumnGroup: typeof ColumnGroup;
|
|
|
|
Summary: typeof Summary;
|
2022-11-19 16:56:23 +08:00
|
|
|
};
|
2021-09-17 11:17:29 +08:00
|
|
|
|
2023-01-07 21:21:52 +08:00
|
|
|
ForwardTable.SELECTION_COLUMN = SELECTION_COLUMN;
|
|
|
|
ForwardTable.EXPAND_COLUMN = EXPAND_COLUMN;
|
|
|
|
ForwardTable.SELECTION_ALL = SELECTION_ALL;
|
|
|
|
ForwardTable.SELECTION_INVERT = SELECTION_INVERT;
|
|
|
|
ForwardTable.SELECTION_NONE = SELECTION_NONE;
|
|
|
|
ForwardTable.Column = Column;
|
|
|
|
ForwardTable.ColumnGroup = ColumnGroup;
|
|
|
|
ForwardTable.Summary = Summary;
|
2019-08-28 02:35:39 +08:00
|
|
|
|
2023-01-07 21:21:52 +08:00
|
|
|
export default ForwardTable;
|