24
24
* - All expanded props, move into expandable
25
25
*/
26
26
27
+ import { makeImmutable } from '@rc-component/context' ;
27
28
import classNames from 'classnames' ;
28
29
import ResizeObserver from 'rc-resize-observer' ;
29
30
import isVisible from 'rc-util/lib/Dom/isVisible' ;
30
31
import { isStyleSupport } from 'rc-util/lib/Dom/styleChecker' ;
31
32
import { getTargetScrollBarSize } from 'rc-util/lib/getScrollBarSize' ;
33
+ import isEqual from 'rc-util/lib/isEqual' ;
32
34
import pickAttrs from 'rc-util/lib/pickAttrs' ;
35
+ import getValue from 'rc-util/lib/utils/get' ;
33
36
import warning from 'rc-util/lib/warning' ;
34
37
import * as React from 'react' ;
35
- import isEqual from 'rc-util/lib/isEqual' ;
36
38
import Body from './Body' ;
37
39
import ColGroup from './ColGroup' ;
38
40
import { EXPAND_COLUMN } from './constant' ;
@@ -53,7 +55,6 @@ import useStickyOffsets from './hooks/useStickyOffsets';
53
55
import type {
54
56
ColumnsType ,
55
57
ColumnType ,
56
- CustomizeComponent ,
57
58
CustomizeScrollBody ,
58
59
DefaultRecordType ,
59
60
ExpandableConfig ,
@@ -77,7 +78,7 @@ import ColumnGroup from './sugar/ColumnGroup';
77
78
import { findAllChildrenKeys , renderExpandIcon } from './utils/expandUtil' ;
78
79
import { getCellFixedInfo } from './utils/fixUtil' ;
79
80
import { getExpandableProps } from './utils/legacyUtil' ;
80
- import { getColumnsKey , getPathValue , validateValue } from './utils/valueUtil' ;
81
+ import { getColumnsKey , validateValue } from './utils/valueUtil' ;
81
82
82
83
// Used for conditions cache
83
84
const EMPTY_DATA = [ ] ;
@@ -171,11 +172,15 @@ export interface TableProps<RecordType = unknown>
171
172
sticky ?: boolean | TableSticky ;
172
173
}
173
174
175
+ function defaultEmpty ( ) {
176
+ return 'No Data' ;
177
+ }
178
+
174
179
function Table < RecordType extends DefaultRecordType > ( tableProps : TableProps < RecordType > ) {
175
180
const props = {
176
181
rowKey : 'key' ,
177
182
prefixCls : 'rc-table' ,
178
- emptyText : ( ) => 'No Data' ,
183
+ emptyText : defaultEmpty ,
179
184
...tableProps ,
180
185
} ;
181
186
@@ -235,9 +240,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
235
240
236
241
// ==================== Customize =====================
237
242
const getComponent = React . useCallback < GetComponent > (
238
- ( path , defaultComponent ) =>
239
- getPathValue < CustomizeComponent , TableComponents < RecordType >> ( components || { } , path ) ||
240
- defaultComponent ,
243
+ ( path , defaultComponent ) => getValue ( components , path ) || defaultComponent ,
241
244
[ components ] ,
242
245
) ;
243
246
@@ -893,12 +896,20 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
893
896
) ;
894
897
}
895
898
896
- Table . EXPAND_COLUMN = EXPAND_COLUMN ;
899
+ const ImmutableTable = makeImmutable ( Table ) ;
900
+ type ImmutableTableType = typeof ImmutableTable & {
901
+ EXPAND_COLUMN : typeof EXPAND_COLUMN ;
902
+ Column : typeof Column ;
903
+ ColumnGroup : typeof ColumnGroup ;
904
+ Summary : typeof FooterComponents ;
905
+ } ;
906
+
907
+ ( ImmutableTable as ImmutableTableType ) . EXPAND_COLUMN = EXPAND_COLUMN ;
897
908
898
- Table . Column = Column ;
909
+ ( ImmutableTable as ImmutableTableType ) . Column = Column ;
899
910
900
- Table . ColumnGroup = ColumnGroup ;
911
+ ( ImmutableTable as ImmutableTableType ) . ColumnGroup = ColumnGroup ;
901
912
902
- Table . Summary = FooterComponents ;
913
+ ( ImmutableTable as ImmutableTableType ) . Summary = FooterComponents ;
903
914
904
- export default Table ;
915
+ export default ImmutableTable as ImmutableTableType ;
0 commit comments