@tanstack/table-core 8.9.2 → 8.9.7
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/core/row.js +1 -1
- package/build/lib/core/row.js.map +1 -1
- package/build/lib/core/table.js +2 -2
- package/build/lib/core/table.js.map +1 -1
- package/build/lib/features/ColumnSizing.js +1 -1
- package/build/lib/features/ColumnSizing.js.map +1 -1
- package/build/lib/features/Expanding.js +1 -1
- package/build/lib/features/Expanding.js.map +1 -1
- package/build/lib/features/Filters.js +8 -8
- package/build/lib/features/Filters.js.map +1 -1
- package/build/lib/features/Grouping.js +1 -1
- package/build/lib/features/Grouping.js.map +1 -1
- package/build/lib/features/Pagination.js +4 -4
- package/build/lib/features/Pagination.js.map +1 -1
- package/build/lib/features/Pinning.js +2 -2
- package/build/lib/features/Pinning.js.map +1 -1
- package/build/lib/features/Sorting.js +4 -3
- package/build/lib/features/Sorting.js.map +1 -1
- package/build/lib/features/Visibility.js +1 -1
- package/build/lib/features/Visibility.js.map +1 -1
- package/build/lib/filterFns.js +6 -6
- package/build/lib/filterFns.js.map +1 -1
- package/build/lib/index.esm.js +45 -43
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +45 -43
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/utils/filterRowsUtils.js +3 -3
- package/build/lib/utils/filterRowsUtils.js.map +1 -1
- package/build/lib/utils/getSortedRowModel.js +10 -9
- package/build/lib/utils/getSortedRowModel.js.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +45 -43
- 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/Sorting.ts +1 -0
- package/src/utils/filterRowsUtils.ts +3 -3
- package/src/utils/getSortedRowModel.ts +10 -11
package/build/lib/index.esm.js
CHANGED
|
@@ -65,7 +65,7 @@ function memo(getDeps, fn, opts) {
|
|
|
65
65
|
let resultTime;
|
|
66
66
|
if (opts.key && opts.debug) resultTime = Date.now();
|
|
67
67
|
result = fn(...newDeps);
|
|
68
|
-
opts == null
|
|
68
|
+
opts == null || opts.onChange == null || opts.onChange(result);
|
|
69
69
|
if (opts.key && opts.debug) {
|
|
70
70
|
if (opts != null && opts.debug()) {
|
|
71
71
|
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
@@ -609,7 +609,7 @@ const ColumnSizing = {
|
|
|
609
609
|
if (!column || !canResize) {
|
|
610
610
|
return;
|
|
611
611
|
}
|
|
612
|
-
e.persist == null
|
|
612
|
+
e.persist == null || e.persist();
|
|
613
613
|
if (isTouchStartEvent(e)) {
|
|
614
614
|
// lets not respond to multiple touches (e.g. 2 or 3 fingers)
|
|
615
615
|
if (e.touches && e.touches.length > 1) {
|
|
@@ -825,7 +825,7 @@ const Expanding = {
|
|
|
825
825
|
},
|
|
826
826
|
getToggleAllRowsExpandedHandler: () => {
|
|
827
827
|
return e => {
|
|
828
|
-
e.persist == null
|
|
828
|
+
e.persist == null || e.persist();
|
|
829
829
|
table.toggleAllRowsExpanded();
|
|
830
830
|
};
|
|
831
831
|
},
|
|
@@ -925,19 +925,19 @@ const Expanding = {
|
|
|
925
925
|
};
|
|
926
926
|
|
|
927
927
|
const includesString = (row, columnId, filterValue) => {
|
|
928
|
-
var _row$getValue
|
|
928
|
+
var _row$getValue;
|
|
929
929
|
const search = filterValue.toLowerCase();
|
|
930
|
-
return Boolean((_row$getValue = row.getValue(columnId)) == null
|
|
930
|
+
return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
|
|
931
931
|
};
|
|
932
932
|
includesString.autoRemove = val => testFalsey(val);
|
|
933
933
|
const includesStringSensitive = (row, columnId, filterValue) => {
|
|
934
|
-
var _row$getValue2
|
|
935
|
-
return Boolean((_row$getValue2 = row.getValue(columnId)) == null
|
|
934
|
+
var _row$getValue2;
|
|
935
|
+
return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
|
|
936
936
|
};
|
|
937
937
|
includesStringSensitive.autoRemove = val => testFalsey(val);
|
|
938
938
|
const equalsString = (row, columnId, filterValue) => {
|
|
939
|
-
var _row$getValue3
|
|
940
|
-
return ((_row$getValue3 = row.getValue(columnId)) == null
|
|
939
|
+
var _row$getValue3;
|
|
940
|
+
return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
|
|
941
941
|
};
|
|
942
942
|
equalsString.autoRemove = val => testFalsey(val);
|
|
943
943
|
const arrIncludes = (row, columnId, filterValue) => {
|
|
@@ -1031,8 +1031,8 @@ const Filters = {
|
|
|
1031
1031
|
maxLeafRowFilterDepth: 100,
|
|
1032
1032
|
globalFilterFn: 'auto',
|
|
1033
1033
|
getColumnCanGlobalFilter: column => {
|
|
1034
|
-
var _table$getCoreRowMode
|
|
1035
|
-
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null
|
|
1034
|
+
var _table$getCoreRowMode;
|
|
1035
|
+
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
|
|
1036
1036
|
return typeof value === 'string' || typeof value === 'number';
|
|
1037
1037
|
}
|
|
1038
1038
|
};
|
|
@@ -1075,12 +1075,12 @@ const Filters = {
|
|
|
1075
1075
|
},
|
|
1076
1076
|
getIsFiltered: () => column.getFilterIndex() > -1,
|
|
1077
1077
|
getFilterValue: () => {
|
|
1078
|
-
var _table$getState$colum
|
|
1079
|
-
return (_table$getState$colum = table.getState().columnFilters) == null
|
|
1078
|
+
var _table$getState$colum;
|
|
1079
|
+
return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
|
|
1080
1080
|
},
|
|
1081
1081
|
getFilterIndex: () => {
|
|
1082
|
-
var _table$getState$
|
|
1083
|
-
return (_table$getState$
|
|
1082
|
+
var _table$getState$colum2, _table$getState$colum3;
|
|
1083
|
+
return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) != null ? _table$getState$colum2 : -1;
|
|
1084
1084
|
},
|
|
1085
1085
|
setFilterValue: value => {
|
|
1086
1086
|
table.setColumnFilters(old => {
|
|
@@ -1173,10 +1173,10 @@ const Filters = {
|
|
|
1173
1173
|
return true;
|
|
1174
1174
|
});
|
|
1175
1175
|
};
|
|
1176
|
-
table.options.onColumnFiltersChange == null
|
|
1176
|
+
table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
|
|
1177
1177
|
},
|
|
1178
1178
|
setGlobalFilter: updater => {
|
|
1179
|
-
table.options.onGlobalFilterChange == null
|
|
1179
|
+
table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
|
|
1180
1180
|
},
|
|
1181
1181
|
resetGlobalFilter: defaultState => {
|
|
1182
1182
|
table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
|
|
@@ -1322,7 +1322,7 @@ const Grouping = {
|
|
|
1322
1322
|
return {
|
|
1323
1323
|
aggregatedCell: props => {
|
|
1324
1324
|
var _toString, _props$getValue;
|
|
1325
|
-
return (_toString = (_props$getValue = props.getValue()) == null
|
|
1325
|
+
return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
|
|
1326
1326
|
},
|
|
1327
1327
|
aggregationFn: 'auto'
|
|
1328
1328
|
};
|
|
@@ -1572,12 +1572,12 @@ const Pagination = {
|
|
|
1572
1572
|
});
|
|
1573
1573
|
},
|
|
1574
1574
|
resetPageIndex: defaultState => {
|
|
1575
|
-
var _table$initialState$p2, _table$initialState
|
|
1576
|
-
table.setPageIndex(defaultState ? defaultPageIndex : (_table$initialState$p2 = (_table$initialState = table.initialState) == null
|
|
1575
|
+
var _table$initialState$p2, _table$initialState;
|
|
1576
|
+
table.setPageIndex(defaultState ? defaultPageIndex : (_table$initialState$p2 = (_table$initialState = table.initialState) == null || (_table$initialState = _table$initialState.pagination) == null ? void 0 : _table$initialState.pageIndex) != null ? _table$initialState$p2 : defaultPageIndex);
|
|
1577
1577
|
},
|
|
1578
1578
|
resetPageSize: defaultState => {
|
|
1579
|
-
var _table$initialState$
|
|
1580
|
-
table.setPageSize(defaultState ? defaultPageSize : (_table$initialState$
|
|
1579
|
+
var _table$initialState$p3, _table$initialState2;
|
|
1580
|
+
table.setPageSize(defaultState ? defaultPageSize : (_table$initialState$p3 = (_table$initialState2 = table.initialState) == null || (_table$initialState2 = _table$initialState2.pagination) == null ? void 0 : _table$initialState2.pageSize) != null ? _table$initialState$p3 : defaultPageSize);
|
|
1581
1581
|
},
|
|
1582
1582
|
setPageSize: updater => {
|
|
1583
1583
|
table.setPagination(old => {
|
|
@@ -1717,9 +1717,9 @@ const Pinning = {
|
|
|
1717
1717
|
return isLeft ? 'left' : isRight ? 'right' : false;
|
|
1718
1718
|
},
|
|
1719
1719
|
getPinnedIndex: () => {
|
|
1720
|
-
var _table$getState$colum, _table$getState$colum2
|
|
1720
|
+
var _table$getState$colum, _table$getState$colum2;
|
|
1721
1721
|
const position = column.getIsPinned();
|
|
1722
|
-
return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null
|
|
1722
|
+
return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
|
|
1723
1723
|
}
|
|
1724
1724
|
};
|
|
1725
1725
|
},
|
|
@@ -2305,7 +2305,8 @@ const Sorting = {
|
|
|
2305
2305
|
},
|
|
2306
2306
|
getDefaultColumnDef: () => {
|
|
2307
2307
|
return {
|
|
2308
|
-
sortingFn: 'auto'
|
|
2308
|
+
sortingFn: 'auto',
|
|
2309
|
+
sortUndefined: 1
|
|
2309
2310
|
};
|
|
2310
2311
|
},
|
|
2311
2312
|
getDefaultOptions: table => {
|
|
@@ -2479,8 +2480,8 @@ const Sorting = {
|
|
|
2479
2480
|
const canSort = column.getCanSort();
|
|
2480
2481
|
return e => {
|
|
2481
2482
|
if (!canSort) return;
|
|
2482
|
-
e.persist == null
|
|
2483
|
-
column.toggleSorting == null
|
|
2483
|
+
e.persist == null || e.persist();
|
|
2484
|
+
column.toggleSorting == null || column.toggleSorting(undefined, column.getCanMultiSort() ? table.options.isMultiSortEvent == null ? void 0 : table.options.isMultiSortEvent(e) : false);
|
|
2484
2485
|
};
|
|
2485
2486
|
}
|
|
2486
2487
|
};
|
|
@@ -2540,7 +2541,7 @@ const Visibility = {
|
|
|
2540
2541
|
},
|
|
2541
2542
|
getToggleVisibilityHandler: () => {
|
|
2542
2543
|
return e => {
|
|
2543
|
-
column.toggleVisibility == null
|
|
2544
|
+
column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
|
|
2544
2545
|
};
|
|
2545
2546
|
}
|
|
2546
2547
|
};
|
|
@@ -2678,7 +2679,7 @@ function createTable(options) {
|
|
|
2678
2679
|
return table.options.state;
|
|
2679
2680
|
},
|
|
2680
2681
|
setState: updater => {
|
|
2681
|
-
table.options.onStateChange == null
|
|
2682
|
+
table.options.onStateChange == null || table.options.onStateChange(updater);
|
|
2682
2683
|
},
|
|
2683
2684
|
_getRowId: (row, index, parent) => {
|
|
2684
2685
|
var _table$options$getRow;
|
|
@@ -2723,7 +2724,7 @@ function createTable(options) {
|
|
|
2723
2724
|
// footer: props => props.header.column.id,
|
|
2724
2725
|
cell: props => {
|
|
2725
2726
|
var _props$renderValue$to, _props$renderValue;
|
|
2726
|
-
return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null
|
|
2727
|
+
return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
|
|
2727
2728
|
},
|
|
2728
2729
|
...table._features.reduce((obj, feature) => {
|
|
2729
2730
|
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
@@ -2914,7 +2915,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
2914
2915
|
};
|
|
2915
2916
|
for (let i = 0; i < table._features.length; i++) {
|
|
2916
2917
|
const feature = table._features[i];
|
|
2917
|
-
Object.assign(row, feature == null
|
|
2918
|
+
Object.assign(row, feature == null || feature.createRow == null ? void 0 : feature.createRow(row, table));
|
|
2918
2919
|
}
|
|
2919
2920
|
return row;
|
|
2920
2921
|
};
|
|
@@ -3061,13 +3062,13 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
|
3061
3062
|
if (filterRow(row) && !newRow.subRows.length) {
|
|
3062
3063
|
rows.push(row);
|
|
3063
3064
|
newFilteredRowsById[row.id] = row;
|
|
3064
|
-
|
|
3065
|
+
newFilteredFlatRows.push(row);
|
|
3065
3066
|
continue;
|
|
3066
3067
|
}
|
|
3067
3068
|
if (filterRow(row) || newRow.subRows.length) {
|
|
3068
3069
|
rows.push(row);
|
|
3069
3070
|
newFilteredRowsById[row.id] = row;
|
|
3070
|
-
|
|
3071
|
+
newFilteredFlatRows.push(row);
|
|
3071
3072
|
continue;
|
|
3072
3073
|
}
|
|
3073
3074
|
} else {
|
|
@@ -3075,7 +3076,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
|
3075
3076
|
if (filterRow(row)) {
|
|
3076
3077
|
rows.push(row);
|
|
3077
3078
|
newFilteredRowsById[row.id] = row;
|
|
3078
|
-
|
|
3079
|
+
newFilteredFlatRows.push(row);
|
|
3079
3080
|
}
|
|
3080
3081
|
}
|
|
3081
3082
|
}
|
|
@@ -3353,22 +3354,23 @@ function getSortedRowModel() {
|
|
|
3353
3354
|
const sortEntry = availableSorting[i];
|
|
3354
3355
|
const columnInfo = columnInfoById[sortEntry.id];
|
|
3355
3356
|
const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
|
|
3357
|
+
let sortInt = 0;
|
|
3358
|
+
|
|
3359
|
+
// All sorting ints should always return in ascending order
|
|
3356
3360
|
if (columnInfo.sortUndefined) {
|
|
3357
3361
|
const aValue = rowA.getValue(sortEntry.id);
|
|
3358
3362
|
const bValue = rowB.getValue(sortEntry.id);
|
|
3359
|
-
const aUndefined =
|
|
3360
|
-
const bUndefined =
|
|
3363
|
+
const aUndefined = aValue === undefined;
|
|
3364
|
+
const bUndefined = bValue === undefined;
|
|
3361
3365
|
if (aUndefined || bUndefined) {
|
|
3362
|
-
|
|
3363
|
-
if (isDesc && undefinedSort !== 0) {
|
|
3364
|
-
undefinedSort *= -1;
|
|
3365
|
-
}
|
|
3366
|
-
return undefinedSort;
|
|
3366
|
+
sortInt = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
|
|
3367
3367
|
}
|
|
3368
3368
|
}
|
|
3369
|
+
if (sortInt === 0) {
|
|
3370
|
+
sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
|
|
3371
|
+
}
|
|
3369
3372
|
|
|
3370
|
-
//
|
|
3371
|
-
let sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
|
|
3373
|
+
// If sorting is non-zero, take care of desc and inversion
|
|
3372
3374
|
if (sortInt !== 0) {
|
|
3373
3375
|
if (isDesc) {
|
|
3374
3376
|
sortInt *= -1;
|