File tree 2 files changed +27
-18
lines changed
packages/table-core/src/features
2 files changed +27
-18
lines changed Original file line number Diff line number Diff line change 1
- import { RowModel } from '..'
1
+ import { getRowProto , RowModel } from '..'
2
2
import { BuiltInFilterFn , filterFns } from '../filterFns'
3
3
import {
4
4
Column ,
@@ -362,15 +362,6 @@ export const ColumnFiltering: TableFeature = {
362
362
}
363
363
} ,
364
364
365
- createRow : < TData extends RowData > (
366
- row : Row < TData > ,
367
- _table : Table < TData >
368
- ) : void => {
369
- // TODO: move to a lazy-initialized proto getters
370
- row . columnFilters = { }
371
- row . columnFiltersMeta = { }
372
- } ,
373
-
374
365
createTable : < TData extends RowData > ( table : Table < TData > ) : void => {
375
366
table . setColumnFilters = ( updater : Updater < ColumnFiltersState > ) => {
376
367
const leafColumns = table . getAllLeafColumns ( )
@@ -412,6 +403,23 @@ export const ColumnFiltering: TableFeature = {
412
403
413
404
return table . _getFilteredRowModel ( )
414
405
}
406
+
407
+ Object . assign ( getRowProto ( table ) , {
408
+ get columnFilters ( ) {
409
+ // Lazy-init the backing cache on the instance so we don't take up memory for rows that don't need it
410
+ return ( (
411
+ this as { _columnFilters ?: ColumnFiltersRow < any > [ 'columnFilters' ] }
412
+ ) . _columnFilters ??= { } )
413
+ } ,
414
+ get columnFiltersMeta ( ) {
415
+ // Lazy-init the backing cache on the instance so we don't take up memory for rows that don't need it
416
+ return ( (
417
+ this as {
418
+ _columnFiltersMeta ?: ColumnFiltersRow < any > [ 'columnFiltersMeta' ]
419
+ }
420
+ ) . _columnFiltersMeta ??= { } )
421
+ } ,
422
+ } as ColumnFiltersRow < any > & Row < any > )
415
423
} ,
416
424
}
417
425
Original file line number Diff line number Diff line change @@ -355,6 +355,15 @@ export const ColumnGrouping: TableFeature = {
355
355
}
356
356
357
357
Object . assign ( getRowProto ( table ) , {
358
+ get _groupingValuesCache ( ) {
359
+ // Lazy-init the backing cache on the instance so we don't take up memory for rows that don't need it
360
+ return ( (
361
+ this as {
362
+ __groupingValuesCache ?: GroupingRow [ '_groupingValuesCache' ]
363
+ }
364
+ ) . __groupingValuesCache ??= { } )
365
+ } ,
366
+
358
367
getIsGrouped ( ) {
359
368
return ! ! this . groupingColumnId
360
369
} ,
@@ -378,14 +387,6 @@ export const ColumnGrouping: TableFeature = {
378
387
} as GroupingRow & Row < any > )
379
388
} ,
380
389
381
- createRow : < TData extends RowData > (
382
- row : Row < TData > ,
383
- table : Table < TData >
384
- ) : void => {
385
- // TODO: move to a lazy-initialized proto getter
386
- row . _groupingValuesCache = { }
387
- } ,
388
-
389
390
createCell : < TData extends RowData , TValue > (
390
391
cell : Cell < TData , TValue > ,
391
392
column : Column < TData , TValue > ,
You can’t perform that action at this time.
0 commit comments