1- import { getMemoOptions , memo } from '../../utils'
1+ import { assignAPIs , getMemoOptions , memo } from '../../utils'
22import { _table_getState } from '../table/Tables.utils'
33import { _createColumn } from './createColumn'
44import {
@@ -25,62 +25,55 @@ export const Columns: TableFeature = {
2525 column : Column < TFeatures , TData , TValue > ,
2626 table : Table < TFeatures , TData > ,
2727 ) => {
28- column . getFlatColumns = memo (
29- ( ) => [ table . options . columns ] ,
30- ( ) => column_getFlatColumns ( column ) ,
31- getMemoOptions ( table . options , 'debugColumns' , 'column.getFlatColumns' ) ,
32- )
33-
34- column . getLeafColumns = memo (
35- ( ) => [
36- _table_getState ( table ) . columnOrder ,
37- _table_getState ( table ) . grouping ,
38- table . options . columns ,
39- table . options . groupedColumnMode ,
40- ] ,
41- ( ) => column_getLeafColumns ( column , table ) ,
42- getMemoOptions ( table . options , 'debugColumns' , 'column.getLeafColumns' ) ,
43- )
28+ assignAPIs ( column , table , [
29+ {
30+ fn : ( ) => column_getFlatColumns ( column ) ,
31+ memoDeps : ( ) => [ table . options . columns ] ,
32+ } ,
33+ {
34+ fn : ( ) => column_getLeafColumns ( column , table ) ,
35+ memoDeps : ( ) => [
36+ _table_getState ( table ) . columnOrder ,
37+ _table_getState ( table ) . grouping ,
38+ table . options . columns ,
39+ table . options . groupedColumnMode ,
40+ ] ,
41+ } ,
42+ ] )
4443 } ,
4544
4645 _createTable : < TFeatures extends TableFeatures , TData extends RowData > (
4746 table : Table < TFeatures , TData > ,
4847 ) => {
49- table . _getDefaultColumnDef = memo (
50- ( ) => [ table . options . defaultColumn ] ,
51- ( ) => table_getDefaultColumnDef ( table ) ,
52- getMemoOptions ( table . options , 'debugColumns' , '_getDefaultColumnDef' ) ,
53- )
54-
55- table . getAllColumns = memo (
56- ( ) => [ table . options . columns ] ,
57- ( ) => table_getAllColumns ( table ) ,
58- getMemoOptions ( table . options , 'debugColumns' , 'getAllColumns' ) ,
59- )
60-
61- table . getAllFlatColumns = memo (
62- ( ) => [ table . options . columns ] ,
63- ( ) => table_getAllFlatColumns ( table ) ,
64- getMemoOptions ( table . options , 'debugColumns' , 'getAllFlatColumns' ) ,
65- )
66-
67- table . _getAllFlatColumnsById = memo (
68- ( ) => [ table . options . columns ] ,
69- ( ) => table_getAllFlatColumnsById ( table ) ,
70- getMemoOptions ( table . options , 'debugColumns' , 'getAllFlatColumnsById' ) ,
71- )
72-
73- table . getAllLeafColumns = memo (
74- ( ) => [
75- _table_getState ( table ) . columnOrder ,
76- _table_getState ( table ) . grouping ,
77- table . options . columns ,
78- table . options . groupedColumnMode ,
79- ] ,
80- ( ) => table_getAllLeafColumns ( table ) ,
81- getMemoOptions ( table . options , 'debugColumns' , 'getAllLeafColumns' ) ,
82- )
83-
84- table . getColumn = ( columnId ) => table_getColumn ( table , columnId )
48+ assignAPIs ( table , table , [
49+ {
50+ fn : ( ) => table_getDefaultColumnDef ( table ) ,
51+ memoDeps : ( ) => [ table . options . defaultColumn ] ,
52+ } ,
53+ {
54+ fn : ( ) => table_getAllColumns ( table ) ,
55+ memoDeps : ( ) => [ table . options . columns ] ,
56+ } ,
57+ {
58+ fn : ( ) => table_getAllFlatColumns ( table ) ,
59+ memoDeps : ( ) => [ table . options . columns ] ,
60+ } ,
61+ {
62+ fn : ( ) => table_getAllFlatColumnsById ( table ) ,
63+ memoDeps : ( ) => [ table . options . columns ] ,
64+ } ,
65+ {
66+ fn : ( ) => table_getAllLeafColumns ( table ) ,
67+ memoDeps : ( ) => [
68+ _table_getState ( table ) . columnOrder ,
69+ _table_getState ( table ) . grouping ,
70+ table . options . columns ,
71+ table . options . groupedColumnMode ,
72+ ] ,
73+ } ,
74+ {
75+ fn : ( columnId ) => table_getColumn ( table , columnId ) ,
76+ } ,
77+ ] )
8578 } ,
8679}
0 commit comments