@tanstack/table-core 9.0.0-beta.49 → 9.0.0-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/rows/coreRowsFeature.cjs +5 -1
- package/dist/core/rows/coreRowsFeature.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.js +6 -2
- package/dist/core/rows/coreRowsFeature.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +8 -0
- package/dist/core/rows/coreRowsFeature.types.d.ts +8 -0
- package/dist/core/rows/coreRowsFeature.utils.cjs +11 -0
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +6 -1
- package/dist/core/rows/coreRowsFeature.utils.d.ts +6 -1
- package/dist/core/rows/coreRowsFeature.utils.js +11 -1
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/features/aggregation/aggregationFeature.cjs +3 -2
- package/dist/features/aggregation/aggregationFeature.cjs.map +1 -1
- package/dist/features/aggregation/aggregationFeature.js +3 -2
- package/dist/features/aggregation/aggregationFeature.js.map +1 -1
- package/dist/features/aggregation/aggregationFeature.types.cjs.map +1 -1
- package/dist/features/aggregation/aggregationFeature.types.d.cts +36 -13
- package/dist/features/aggregation/aggregationFeature.types.d.ts +36 -13
- package/dist/features/aggregation/aggregationFeature.types.js.map +1 -1
- package/dist/features/aggregation/aggregationFeature.utils.cjs +36 -22
- package/dist/features/aggregation/aggregationFeature.utils.cjs.map +1 -1
- package/dist/features/aggregation/aggregationFeature.utils.d.cts +9 -8
- package/dist/features/aggregation/aggregationFeature.utils.d.ts +9 -8
- package/dist/features/aggregation/aggregationFeature.utils.js +36 -22
- package/dist/features/aggregation/aggregationFeature.utils.js.map +1 -1
- package/dist/features/aggregation/aggregationFns.cjs +35 -29
- package/dist/features/aggregation/aggregationFns.cjs.map +1 -1
- package/dist/features/aggregation/aggregationFns.d.cts +8 -7
- package/dist/features/aggregation/aggregationFns.d.ts +8 -7
- package/dist/features/aggregation/aggregationFns.js +35 -29
- package/dist/features/aggregation/aggregationFns.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +3 -3
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.js +3 -3
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/static-functions.cjs +1 -0
- package/dist/static-functions.d.cts +2 -2
- package/dist/static-functions.d.ts +2 -2
- package/dist/static-functions.js +2 -2
- package/package.json +1 -1
- package/skills/aggregation/SKILL.md +25 -15
- package/skills/api-not-found/SKILL.md +1 -1
- package/skills/client-vs-server/SKILL.md +1 -1
- package/skills/column-faceting/SKILL.md +1 -1
- package/skills/column-filtering/SKILL.md +1 -1
- package/skills/column-ordering/SKILL.md +1 -1
- package/skills/column-pinning/SKILL.md +1 -1
- package/skills/column-resizing/SKILL.md +1 -1
- package/skills/column-sizing/SKILL.md +1 -1
- package/skills/column-visibility/SKILL.md +1 -1
- package/skills/core/SKILL.md +1 -1
- package/skills/custom-features/SKILL.md +1 -1
- package/skills/expanding/SKILL.md +1 -1
- package/skills/global-filtering/SKILL.md +1 -1
- package/skills/grouping/SKILL.md +1 -1
- package/skills/migrate-v8-to-v9/SKILL.md +11 -3
- package/skills/pagination/SKILL.md +1 -1
- package/skills/row-pinning/SKILL.md +1 -1
- package/skills/row-selection/SKILL.md +1 -1
- package/skills/sorting/SKILL.md +1 -1
- package/skills/table-features/SKILL.md +1 -1
- package/skills/typescript/SKILL.md +1 -1
- package/src/core/rows/coreRowsFeature.ts +5 -0
- package/src/core/rows/coreRowsFeature.types.ts +8 -0
- package/src/core/rows/coreRowsFeature.utils.ts +18 -0
- package/src/features/aggregation/aggregationFeature.ts +2 -1
- package/src/features/aggregation/aggregationFeature.types.ts +39 -12
- package/src/features/aggregation/aggregationFeature.utils.ts +56 -27
- package/src/features/aggregation/aggregationFns.ts +42 -33
- package/src/features/column-grouping/createGroupedRowModel.ts +3 -3
|
@@ -39,8 +39,8 @@ function collectRangeValues(context: AggregationContext<any, any, unknown>) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Sums numeric row values. Non-number values contribute zero. As in
|
|
43
|
-
* previous API, `NaN` is a number and therefore propagates through the sum.
|
|
42
|
+
* Sums numeric selected-row values. Non-number values contribute zero. As in
|
|
43
|
+
* the previous API, `NaN` is a number and therefore propagates through the sum.
|
|
44
44
|
*/
|
|
45
45
|
export const aggregationFn_sum = constructAggregationFn<
|
|
46
46
|
any,
|
|
@@ -56,10 +56,10 @@ export const aggregationFn_sum = constructAggregationFn<
|
|
|
56
56
|
}
|
|
57
57
|
return sum
|
|
58
58
|
},
|
|
59
|
-
merge: ({
|
|
59
|
+
merge: ({ subRowResults }) => {
|
|
60
60
|
let sum = 0
|
|
61
|
-
for (let i = 0; i <
|
|
62
|
-
const value =
|
|
61
|
+
for (let i = 0; i < subRowResults.length; i++) {
|
|
62
|
+
const value = subRowResults[i]
|
|
63
63
|
if (isNumber(value)) sum += value
|
|
64
64
|
}
|
|
65
65
|
return sum
|
|
@@ -67,8 +67,8 @@ export const aggregationFn_sum = constructAggregationFn<
|
|
|
67
67
|
})
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* Finds the minimum numeric or Date value. Invalid value
|
|
71
|
-
* `NaN` preserves the legacy numeric seeding behavior.
|
|
70
|
+
* Finds the minimum numeric or Date value from the selected rows. Invalid value
|
|
71
|
+
* types are ignored; `NaN` preserves the legacy numeric seeding behavior.
|
|
72
72
|
*/
|
|
73
73
|
export const aggregationFn_min = constructAggregationFn<
|
|
74
74
|
any,
|
|
@@ -84,16 +84,17 @@ export const aggregationFn_min = constructAggregationFn<
|
|
|
84
84
|
}
|
|
85
85
|
return result
|
|
86
86
|
},
|
|
87
|
-
merge: ({
|
|
87
|
+
merge: ({ subRowResults }) => {
|
|
88
88
|
let result: RangeValue | undefined
|
|
89
89
|
let kind: 'date' | 'number' | undefined
|
|
90
|
-
for (let i = 0; i <
|
|
91
|
-
const value =
|
|
90
|
+
for (let i = 0; i < subRowResults.length; i++) {
|
|
91
|
+
const value = subRowResults[i]
|
|
92
92
|
const valueKind = getRangeKind(value)
|
|
93
93
|
if (!valueKind) continue
|
|
94
|
+
if (value === undefined) continue
|
|
94
95
|
kind ??= valueKind
|
|
95
96
|
if (kind !== valueKind) continue
|
|
96
|
-
if (result === undefined || compareRangeValues(value
|
|
97
|
+
if (result === undefined || compareRangeValues(value, result) < 0) {
|
|
97
98
|
result = value
|
|
98
99
|
}
|
|
99
100
|
}
|
|
@@ -102,8 +103,8 @@ export const aggregationFn_min = constructAggregationFn<
|
|
|
102
103
|
})
|
|
103
104
|
|
|
104
105
|
/**
|
|
105
|
-
* Finds the maximum numeric or Date value. Invalid value
|
|
106
|
-
* `NaN` preserves the legacy numeric seeding behavior.
|
|
106
|
+
* Finds the maximum numeric or Date value from the selected rows. Invalid value
|
|
107
|
+
* types are ignored; `NaN` preserves the legacy numeric seeding behavior.
|
|
107
108
|
*/
|
|
108
109
|
export const aggregationFn_max = constructAggregationFn<
|
|
109
110
|
any,
|
|
@@ -119,16 +120,17 @@ export const aggregationFn_max = constructAggregationFn<
|
|
|
119
120
|
}
|
|
120
121
|
return result
|
|
121
122
|
},
|
|
122
|
-
merge: ({
|
|
123
|
+
merge: ({ subRowResults }) => {
|
|
123
124
|
let result: RangeValue | undefined
|
|
124
125
|
let kind: 'date' | 'number' | undefined
|
|
125
|
-
for (let i = 0; i <
|
|
126
|
-
const value =
|
|
126
|
+
for (let i = 0; i < subRowResults.length; i++) {
|
|
127
|
+
const value = subRowResults[i]
|
|
127
128
|
const valueKind = getRangeKind(value)
|
|
128
129
|
if (!valueKind) continue
|
|
130
|
+
if (value === undefined) continue
|
|
129
131
|
kind ??= valueKind
|
|
130
132
|
if (kind !== valueKind) continue
|
|
131
|
-
if (result === undefined || compareRangeValues(value
|
|
133
|
+
if (result === undefined || compareRangeValues(value, result) > 0) {
|
|
132
134
|
result = value
|
|
133
135
|
}
|
|
134
136
|
}
|
|
@@ -137,7 +139,8 @@ export const aggregationFn_max = constructAggregationFn<
|
|
|
137
139
|
})
|
|
138
140
|
|
|
139
141
|
/**
|
|
140
|
-
* Finds the minimum and maximum numeric or Date values
|
|
142
|
+
* Finds the minimum and maximum numeric or Date values from the selected rows.
|
|
143
|
+
* Empty inputs return
|
|
141
144
|
* `[undefined, undefined]`, preserving the previous built-in result shape.
|
|
142
145
|
*/
|
|
143
146
|
export const aggregationFn_extent = constructAggregationFn<
|
|
@@ -158,26 +161,32 @@ export const aggregationFn_extent = constructAggregationFn<
|
|
|
158
161
|
}
|
|
159
162
|
return [min, max]
|
|
160
163
|
},
|
|
161
|
-
merge: ({
|
|
164
|
+
merge: ({ subRowResults }) => {
|
|
162
165
|
let result: [RangeValue | undefined, RangeValue | undefined] = [
|
|
163
166
|
undefined,
|
|
164
167
|
undefined,
|
|
165
168
|
]
|
|
166
169
|
let kind: 'date' | 'number' | undefined
|
|
167
|
-
for (let i = 0; i <
|
|
168
|
-
const extent =
|
|
169
|
-
const
|
|
170
|
-
|
|
170
|
+
for (let i = 0; i < subRowResults.length; i++) {
|
|
171
|
+
const extent = subRowResults[i]!
|
|
172
|
+
const min = extent[0]
|
|
173
|
+
const max = extent[1]
|
|
174
|
+
const valueKind = getRangeKind(min)
|
|
175
|
+
if (!valueKind || min === undefined || max === undefined) continue
|
|
171
176
|
kind ??= valueKind
|
|
172
177
|
if (kind !== valueKind) continue
|
|
173
178
|
if (result[0] === undefined) {
|
|
174
|
-
result = [
|
|
179
|
+
result = [min, max]
|
|
175
180
|
} else {
|
|
176
|
-
if (compareRangeValues(
|
|
177
|
-
result[0] =
|
|
181
|
+
if (compareRangeValues(min, result[0]) < 0) {
|
|
182
|
+
result[0] = min
|
|
178
183
|
}
|
|
179
|
-
|
|
180
|
-
|
|
184
|
+
const currentMax = result[1]
|
|
185
|
+
if (
|
|
186
|
+
currentMax === undefined ||
|
|
187
|
+
compareRangeValues(max, currentMax) > 0
|
|
188
|
+
) {
|
|
189
|
+
result[1] = max
|
|
181
190
|
}
|
|
182
191
|
}
|
|
183
192
|
}
|
|
@@ -277,10 +286,10 @@ export const aggregationFn_count = constructAggregationFn<
|
|
|
277
286
|
number
|
|
278
287
|
>({
|
|
279
288
|
aggregate: ({ rows }) => rows.length,
|
|
280
|
-
merge: ({
|
|
289
|
+
merge: ({ subRowResults }) => {
|
|
281
290
|
let count = 0
|
|
282
|
-
for (let i = 0; i <
|
|
283
|
-
const value =
|
|
291
|
+
for (let i = 0; i < subRowResults.length; i++) {
|
|
292
|
+
const value = subRowResults[i]
|
|
284
293
|
if (isNumber(value)) count += value
|
|
285
294
|
}
|
|
286
295
|
return count
|
|
@@ -296,7 +305,7 @@ export const aggregationFn_first = constructAggregationFn<
|
|
|
296
305
|
>({
|
|
297
306
|
aggregate: (context) =>
|
|
298
307
|
context.rows[0] ? context.getValue(context.rows[0]) : undefined,
|
|
299
|
-
merge: ({
|
|
308
|
+
merge: ({ subRowResults }) => subRowResults[0],
|
|
300
309
|
})
|
|
301
310
|
|
|
302
311
|
/** Returns the last row's value, including a nullish value. */
|
|
@@ -310,7 +319,7 @@ export const aggregationFn_last = constructAggregationFn<
|
|
|
310
319
|
const row = context.rows[context.rows.length - 1]
|
|
311
320
|
return row ? context.getValue(row) : undefined
|
|
312
321
|
},
|
|
313
|
-
merge: ({
|
|
322
|
+
merge: ({ subRowResults }) => subRowResults[subRowResults.length - 1],
|
|
314
323
|
})
|
|
315
324
|
|
|
316
325
|
/**
|
|
@@ -118,7 +118,7 @@ function _createGroupedRowModel<
|
|
|
118
118
|
subRow.parentId = id
|
|
119
119
|
})
|
|
120
120
|
|
|
121
|
-
const leafRows = normalizeAggregationRows(groupedRows)
|
|
121
|
+
const leafRows = normalizeAggregationRows(groupedRows, Infinity)
|
|
122
122
|
|
|
123
123
|
const row = constructRow(
|
|
124
124
|
table,
|
|
@@ -167,10 +167,10 @@ function _createGroupedRowModel<
|
|
|
167
167
|
const cache = ((row as any)._aggregationValuesCache ??=
|
|
168
168
|
makeObjectMap())
|
|
169
169
|
cache[colId] = aggregateColumnValue({
|
|
170
|
-
|
|
170
|
+
subRows,
|
|
171
171
|
column,
|
|
172
172
|
groupingRow: row,
|
|
173
|
-
rows:
|
|
173
|
+
rows: groupedRows,
|
|
174
174
|
})
|
|
175
175
|
return cache[colId]
|
|
176
176
|
},
|