@tanstack/table-core 8.15.2 → 8.16.0
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/build/lib/features/ColumnGrouping.js +2 -2
- package/build/lib/features/ColumnGrouping.js.map +1 -1
- package/build/lib/features/RowSorting.d.ts +1 -1
- package/build/lib/features/RowSorting.js.map +1 -1
- package/build/lib/index.esm.js +7 -4
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +7 -4
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/utils/getSortedRowModel.js +5 -2
- package/build/lib/utils/getSortedRowModel.js.map +1 -1
- package/build/umd/index.development.js +7 -4
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/features/ColumnGrouping.ts +3 -5
- package/src/features/RowSorting.ts +1 -1
- package/src/utils/getSortedRowModel.ts +7 -4
package/package.json
CHANGED
|
@@ -283,11 +283,9 @@ export const ColumnGrouping: TableFeature = {
|
|
|
283
283
|
|
|
284
284
|
column.getCanGroup = () => {
|
|
285
285
|
return (
|
|
286
|
-
column.columnDef.enableGrouping ??
|
|
287
|
-
true
|
|
288
|
-
|
|
289
|
-
true ??
|
|
290
|
-
!!column.accessorFn
|
|
286
|
+
(column.columnDef.enableGrouping ?? true) &&
|
|
287
|
+
(table.options.enableGrouping ?? true) &&
|
|
288
|
+
(!!column.accessorFn || !!column.columnDef.getGroupingValue)
|
|
291
289
|
)
|
|
292
290
|
}
|
|
293
291
|
|
|
@@ -90,7 +90,7 @@ export interface SortingColumnDef<TData extends RowData> {
|
|
|
90
90
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortundefined)
|
|
91
91
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)
|
|
92
92
|
*/
|
|
93
|
-
sortUndefined?: false | -1 | 1
|
|
93
|
+
sortUndefined?: false | -1 | 1 | 'first' | 'last'
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export interface SortingColumn<TData extends RowData> {
|
|
@@ -25,7 +25,7 @@ export function getSortedRowModel<TData extends RowData>(): (
|
|
|
25
25
|
const columnInfoById: Record<
|
|
26
26
|
string,
|
|
27
27
|
{
|
|
28
|
-
sortUndefined?: false | -1 | 1
|
|
28
|
+
sortUndefined?: false | -1 | 1 | 'first' | 'last'
|
|
29
29
|
invertSorting?: boolean
|
|
30
30
|
sortingFn: SortingFn<TData>
|
|
31
31
|
}
|
|
@@ -51,12 +51,13 @@ export function getSortedRowModel<TData extends RowData>(): (
|
|
|
51
51
|
for (let i = 0; i < availableSorting.length; i += 1) {
|
|
52
52
|
const sortEntry = availableSorting[i]!
|
|
53
53
|
const columnInfo = columnInfoById[sortEntry.id]!
|
|
54
|
+
const sortUndefined = columnInfo.sortUndefined
|
|
54
55
|
const isDesc = sortEntry?.desc ?? false
|
|
55
56
|
|
|
56
57
|
let sortInt = 0
|
|
57
58
|
|
|
58
59
|
// All sorting ints should always return in ascending order
|
|
59
|
-
if (
|
|
60
|
+
if (sortUndefined) {
|
|
60
61
|
const aValue = rowA.getValue(sortEntry.id)
|
|
61
62
|
const bValue = rowB.getValue(sortEntry.id)
|
|
62
63
|
|
|
@@ -64,12 +65,14 @@ export function getSortedRowModel<TData extends RowData>(): (
|
|
|
64
65
|
const bUndefined = bValue === undefined
|
|
65
66
|
|
|
66
67
|
if (aUndefined || bUndefined) {
|
|
68
|
+
if (sortUndefined === 'first') return aUndefined ? -1 : 1
|
|
69
|
+
if (sortUndefined === 'last') return aUndefined ? 1 : -1
|
|
67
70
|
sortInt =
|
|
68
71
|
aUndefined && bUndefined
|
|
69
72
|
? 0
|
|
70
73
|
: aUndefined
|
|
71
|
-
?
|
|
72
|
-
: -
|
|
74
|
+
? sortUndefined
|
|
75
|
+
: -sortUndefined
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
|