@tanstack/table-core 8.0.0-beta.8 → 8.0.0-beta.9
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/cjs/features/Pagination.js +1 -1
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/filterFns.js +22 -6
- package/build/cjs/filterFns.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js +6 -11
- package/build/cjs/utils/filterRowsUtils.js.map +1 -1
- package/build/esm/index.js +29 -18
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +312 -312
- package/build/umd/index.development.js +29 -18
- 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/Pagination.ts +4 -4
- package/src/filterFns.ts +6 -6
- package/src/utils/filterRowsUtils.ts +5 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.0.0-beta.
|
|
4
|
+
"version": "8.0.0-beta.9",
|
|
5
5
|
"description": "Headless UI for building powerful tables & datagrids for TS/JS.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/table#readme",
|
|
@@ -131,9 +131,9 @@ export const Pagination: TableFeature = {
|
|
|
131
131
|
let pageIndex = functionalUpdate(updater, old.pageIndex)
|
|
132
132
|
|
|
133
133
|
const maxPageIndex =
|
|
134
|
-
typeof instance.options.pageCount
|
|
135
|
-
|
|
136
|
-
:
|
|
134
|
+
(typeof instance.options.pageCount === 'undefined' || instance.options.pageCount === -1) ?
|
|
135
|
+
Number.MAX_SAFE_INTEGER
|
|
136
|
+
: instance.options.pageCount - 1
|
|
137
137
|
|
|
138
138
|
pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex)
|
|
139
139
|
|
|
@@ -255,7 +255,7 @@ export const Pagination: TableFeature = {
|
|
|
255
255
|
instance.options.pageCount ??
|
|
256
256
|
Math.ceil(
|
|
257
257
|
instance.getPrePaginationRowModel().rows.length /
|
|
258
|
-
|
|
258
|
+
instance.getState().pagination.pageSize
|
|
259
259
|
)
|
|
260
260
|
)
|
|
261
261
|
},
|
package/src/filterFns.ts
CHANGED
|
@@ -6,7 +6,7 @@ const includesString: FilterFn<any> = (
|
|
|
6
6
|
filterValue: string
|
|
7
7
|
) => {
|
|
8
8
|
const search = filterValue.toLowerCase()
|
|
9
|
-
return row.getValue(columnId)
|
|
9
|
+
return row.getValue(columnId)?.toLowerCase().includes(search)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
includesString.autoRemove = (val: any) => testFalsey(val)
|
|
@@ -16,7 +16,7 @@ const includesStringSensitive: FilterFn<any> = (
|
|
|
16
16
|
columnId: string,
|
|
17
17
|
filterValue: string
|
|
18
18
|
) => {
|
|
19
|
-
return row.getValue(columnId)
|
|
19
|
+
return row.getValue(columnId)?.includes(filterValue)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
includesStringSensitive.autoRemove = (val: any) => testFalsey(val)
|
|
@@ -26,7 +26,7 @@ const equalsString: FilterFn<any> = (
|
|
|
26
26
|
columnId: string,
|
|
27
27
|
filterValue: string
|
|
28
28
|
) => {
|
|
29
|
-
return row.getValue(columnId)
|
|
29
|
+
return row.getValue(columnId)?.toLowerCase() === filterValue.toLowerCase()
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
equalsString.autoRemove = (val: any) => testFalsey(val)
|
|
@@ -36,7 +36,7 @@ const arrIncludes: FilterFn<any> = (
|
|
|
36
36
|
columnId: string,
|
|
37
37
|
filterValue: unknown
|
|
38
38
|
) => {
|
|
39
|
-
return row.getValue(columnId)
|
|
39
|
+
return row.getValue(columnId)?.includes(filterValue)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
arrIncludes.autoRemove = (val: any) => testFalsey(val) || !val?.length
|
|
@@ -46,7 +46,7 @@ const arrIncludesAll: FilterFn<any> = (
|
|
|
46
46
|
columnId: string,
|
|
47
47
|
filterValue: unknown[]
|
|
48
48
|
) => {
|
|
49
|
-
return !filterValue.some(val => !row.getValue(columnId)
|
|
49
|
+
return !filterValue.some(val => !row.getValue(columnId)?.includes(val))
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
arrIncludesAll.autoRemove = (val: any) => testFalsey(val) || !val?.length
|
|
@@ -56,7 +56,7 @@ const arrIncludesSome: FilterFn<any> = (
|
|
|
56
56
|
columnId: string,
|
|
57
57
|
filterValue: unknown[]
|
|
58
58
|
) => {
|
|
59
|
-
return filterValue.some(val => row.getValue(columnId)
|
|
59
|
+
return filterValue.some(val => row.getValue(columnId)?.includes(val))
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
arrIncludesSome.autoRemove = (val: any) => testFalsey(val) || !val?.length
|
|
@@ -21,18 +21,16 @@ export function filterRowModelFromLeafs<TGenerics extends TableGenerics>(
|
|
|
21
21
|
const newFilteredFlatRows: Row<TGenerics>[] = []
|
|
22
22
|
const newFilteredRowsById: Record<string, Row<TGenerics>> = {}
|
|
23
23
|
|
|
24
|
-
let row
|
|
25
|
-
let newRow
|
|
26
24
|
|
|
27
25
|
const recurseFilterRows = (rowsToFilter: Row<TGenerics>[], depth = 0) => {
|
|
28
26
|
const rows: Row<TGenerics>[] = []
|
|
29
27
|
|
|
30
28
|
// Filter from children up first
|
|
31
29
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
32
|
-
row = rowsToFilter[i]!
|
|
30
|
+
let row = rowsToFilter[i]!
|
|
33
31
|
|
|
34
32
|
if (row.subRows?.length) {
|
|
35
|
-
newRow = createRow(instance, row.id, row.original, row.index, row.depth)
|
|
33
|
+
const newRow = createRow(instance, row.id, row.original, row.index, row.depth)
|
|
36
34
|
newRow.columnFilters = row.columnFilters
|
|
37
35
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1)
|
|
38
36
|
if (!newRow.subRows.length) {
|
|
@@ -66,25 +64,21 @@ export function filterRowModelFromRoot<TGenerics extends TableGenerics>(
|
|
|
66
64
|
const newFilteredFlatRows: Row<TGenerics>[] = []
|
|
67
65
|
const newFilteredRowsById: Record<string, Row<TGenerics>> = {}
|
|
68
66
|
|
|
69
|
-
let rows
|
|
70
|
-
let row
|
|
71
|
-
let newRow
|
|
72
|
-
|
|
73
67
|
// Filters top level and nested rows
|
|
74
68
|
const recurseFilterRows = (rowsToFilter: Row<TGenerics>[], depth = 0) => {
|
|
75
69
|
// Filter from parents downward first
|
|
76
70
|
|
|
77
|
-
rows = []
|
|
71
|
+
const rows = []
|
|
78
72
|
|
|
79
73
|
// Apply the filter to any subRows
|
|
80
74
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
81
|
-
row = rowsToFilter[i]!
|
|
75
|
+
let row = rowsToFilter[i]!
|
|
82
76
|
|
|
83
77
|
const pass = filterRow(row)
|
|
84
78
|
|
|
85
79
|
if (pass) {
|
|
86
80
|
if (row.subRows?.length) {
|
|
87
|
-
newRow = createRow(
|
|
81
|
+
const newRow = createRow(
|
|
88
82
|
instance,
|
|
89
83
|
row.id,
|
|
90
84
|
row.original,
|