2023-04-06 17:16:27 +08:00
|
|
|
import { EXPAND_COLUMN, Summary } from 'rc-table';
|
2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2023-07-05 16:54:04 +08:00
|
|
|
import type { AnyObject } from '../_util/type';
|
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 type { TableProps } from './InternalTable';
|
2023-04-06 17:16:27 +08:00
|
|
|
import InternalTable from './InternalTable';
|
2023-01-07 21:21:52 +08:00
|
|
|
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';
|
2023-04-06 17:16:27 +08:00
|
|
|
import type { RefTable } from './interface';
|
2016-06-19 10:56:42 +08:00
|
|
|
|
2023-07-05 16:54:04 +08:00
|
|
|
const Table = <RecordType extends AnyObject = AnyObject>(
|
2021-09-17 11:17:29 +08:00
|
|
|
props: TableProps<RecordType>,
|
2023-01-07 21:21:52 +08:00
|
|
|
ref: React.Ref<HTMLDivElement>,
|
2023-04-06 17:16:27 +08:00
|
|
|
) => {
|
2023-07-05 16:54:04 +08:00
|
|
|
const renderTimesRef = React.useRef<number>(0);
|
2023-01-07 21:21:52 +08:00
|
|
|
renderTimesRef.current += 1;
|
|
|
|
return <InternalTable<RecordType> {...props} ref={ref} _renderTimes={renderTimesRef.current} />;
|
2023-04-06 17:16:27 +08:00
|
|
|
};
|
2019-08-28 02:35:39 +08:00
|
|
|
|
2023-04-06 17:16:27 +08:00
|
|
|
const ForwardTable = React.forwardRef(Table) as unknown as RefTable & {
|
2023-07-17 23:43:32 +08:00
|
|
|
displayName?: string;
|
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;
|
2023-03-25 13:59:21 +08:00
|
|
|
SELECTION_ALL: typeof SELECTION_ALL;
|
|
|
|
SELECTION_INVERT: typeof SELECTION_INVERT;
|
|
|
|
SELECTION_NONE: typeof SELECTION_NONE;
|
2021-09-17 11:17:29 +08:00
|
|
|
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-07-17 23:43:32 +08:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
ForwardTable.displayName = 'Table';
|
|
|
|
}
|
|
|
|
|
2023-01-07 21:21:52 +08:00
|
|
|
export default ForwardTable;
|