Skip to content

Commit 8fc6739

Browse files
committed
Some more improvements
1 parent b3f2893 commit 8fc6739

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

packages/angular-table/tsconfig.build.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"allowJs": true,
55
"module": "ESNext",
66
"moduleDetection": "force",
7-
"moduleResolution": "Bundler"
7+
"moduleResolution": "Bundler",
8+
// Use a more recent lib to support ES2022 features, because we now use the index.ts as entrypoint for table-core
9+
"lib": ["dom", "es2022"]
810
},
911
"angularCompilerOptions": {
1012
"enableI18nLegacyMessageIdFormat": false,

packages/table-core/src/core/row.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,30 @@ export function getRowProto<TData extends RowData>(table: Table<TData>) {
114114
proto.subRows = [] as const
115115

116116
proto.getValue = function (columnId: string) {
117+
/*
117118
if (this._valuesCache.hasOwnProperty(columnId)) {
118119
return this._valuesCache[columnId]
119120
}
121+
*/
120122

121123
const column = table.getColumn(columnId)
122124

123125
if (!column?.accessorFn) {
124126
return undefined
125127
}
126128

129+
return column.accessorFn(
130+
this.original as TData,
131+
this.index
132+
) as any
133+
/*
127134
this._valuesCache[columnId] = column.accessorFn(
128135
this.original as TData,
129136
this.index
130137
)
131138
132139
return this._valuesCache[columnId] as any
140+
*/
133141
}
134142

135143
proto.getUniqueValues = function (columnId: string) {
@@ -149,8 +157,10 @@ export function getRowProto<TData extends RowData>(table: Table<TData>) {
149157
}
150158

151159
if (!column.columnDef.getUniqueValues) {
152-
this._uniqueValuesCache[columnId] = [this.getValue(columnId)]
153-
return this._uniqueValuesCache[columnId]
160+
// Avoid unnecessary caching for unique values
161+
return [this.getValue(columnId)];
162+
// this._uniqueValuesCache[columnId] = [this.getValue(columnId)]
163+
// return this._uniqueValuesCache[columnId]
154164
}
155165

156166
this._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(
@@ -199,16 +209,20 @@ export function getRowProto<TData extends RowData>(table: Table<TData>) {
199209

200210
proto._getAllCellsByColumnId = memo(
201211
function (this: Row<TData>) {
202-
return [this.getAllCells()]
212+
// return [this.getAllCells()]
213+
return []
203214
},
204-
allCells => {
215+
() => {
216+
throw new Error('Row._getAllCellsByColumnId not implemented because it is a memory leak')
217+
/*
205218
return allCells.reduce(
206219
(acc, cell) => {
207220
acc[cell.column.id] = cell
208221
return acc
209222
},
210223
{} as Record<string, Cell<TData, unknown>>
211224
)
225+
*/
212226
},
213227
getMemoOptions(table.options, 'debugRows', 'getAllCellsByColumnId')
214228
)
@@ -236,7 +250,7 @@ export const createRow = <TData extends RowData>(
236250
original,
237251
depth,
238252
parentId,
239-
_valuesCache: {},
253+
// _valuesCache: {},
240254
})
241255

242256
if (subRows) {

packages/table-core/src/utils/getFilteredRowModel.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ export function getFilteredRowModel<TData extends RowData>(): (
1818
!rowModel.rows.length ||
1919
(!columnFilters?.length && !globalFilter)
2020
) {
21+
// TODO: Does this have any consequences? Would avoid iterating the rows again
22+
return rowModel;
23+
/*
2124
for (let i = 0; i < rowModel.flatRows.length; i++) {
2225
rowModel.flatRows[i]!.columnFilters = {}
2326
rowModel.flatRows[i]!.columnFiltersMeta = {}
2427
}
2528
return rowModel
29+
*/
2630
}
2731

2832
const resolvedColumnFilters: ResolvedColumnFilter<TData>[] = []

packages/table-core/src/utils/getGroupedRowModel.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ export function getGroupedRowModel<TData extends RowData>(): (
1111
() => [table.getState().grouping, table.getPreGroupedRowModel()],
1212
(grouping, rowModel) => {
1313
if (!rowModel.rows.length || !grouping.length) {
14+
// TODO: Does this have any consequences? Would avoid iterating the rows again
15+
return rowModel;
16+
/*
1417
rowModel.rows.forEach(row => {
1518
row.depth = 0
1619
row.parentId = undefined
1720
})
1821
return rowModel
22+
*/
1923
}
2024

2125
// Filter the grouping list down to columns that exist

0 commit comments

Comments
 (0)