@tanstack/react-table 8.5.16 → 8.5.18
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/table-core/build/esm/index.js +36 -12
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +36 -12
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +17 -17
- package/build/umd/index.development.js +36 -12
- 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 +2 -2
|
@@ -117,6 +117,9 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
117
117
|
let result = originalRow;
|
|
118
118
|
for (const key of accessorKey.split('.')) {
|
|
119
119
|
result = result[key];
|
|
120
|
+
if (process.env.NODE_ENV !== 'production' && result === undefined) {
|
|
121
|
+
throw new Error(`"${key}" in deeply nested key "${accessorKey}" returned undefined.`);
|
|
122
|
+
}
|
|
120
123
|
}
|
|
121
124
|
return result;
|
|
122
125
|
};
|
|
@@ -2671,6 +2674,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows) => {
|
|
|
2671
2674
|
original,
|
|
2672
2675
|
depth,
|
|
2673
2676
|
_valuesCache: {},
|
|
2677
|
+
_uniqueValuesCache: {},
|
|
2674
2678
|
getValue: columnId => {
|
|
2675
2679
|
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
2676
2680
|
return row._valuesCache[columnId];
|
|
@@ -2682,6 +2686,21 @@ const createRow = (table, id, original, rowIndex, depth, subRows) => {
|
|
|
2682
2686
|
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
2683
2687
|
return row._valuesCache[columnId];
|
|
2684
2688
|
},
|
|
2689
|
+
getUniqueValues: columnId => {
|
|
2690
|
+
if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
|
|
2691
|
+
return row._uniqueValuesCache[columnId];
|
|
2692
|
+
}
|
|
2693
|
+
const column = table.getColumn(columnId);
|
|
2694
|
+
if (!column.accessorFn) {
|
|
2695
|
+
return undefined;
|
|
2696
|
+
}
|
|
2697
|
+
if (!column.columnDef.getUniqueValues) {
|
|
2698
|
+
row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
|
|
2699
|
+
return row._uniqueValuesCache[columnId];
|
|
2700
|
+
}
|
|
2701
|
+
row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
|
|
2702
|
+
return row._uniqueValuesCache[columnId];
|
|
2703
|
+
},
|
|
2685
2704
|
renderValue: columnId => row.getValue(columnId) ?? table.options.renderFallbackValue,
|
|
2686
2705
|
subRows: subRows ?? [],
|
|
2687
2706
|
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
@@ -3022,12 +3041,14 @@ function getFacetedUniqueValues() {
|
|
|
3022
3041
|
return (table, columnId) => memo(() => [table.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
|
|
3023
3042
|
let facetedUniqueValues = new Map();
|
|
3024
3043
|
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3044
|
+
const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
|
|
3045
|
+
for (let j = 0; j < values.length; j++) {
|
|
3046
|
+
const value = values[j];
|
|
3047
|
+
if (facetedUniqueValues.has(value)) {
|
|
3048
|
+
facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
|
|
3049
|
+
} else {
|
|
3050
|
+
facetedUniqueValues.set(value, 1);
|
|
3051
|
+
}
|
|
3031
3052
|
}
|
|
3032
3053
|
}
|
|
3033
3054
|
return facetedUniqueValues;
|
|
@@ -3041,17 +3062,20 @@ function getFacetedUniqueValues() {
|
|
|
3041
3062
|
function getFacetedMinMaxValues() {
|
|
3042
3063
|
return (table, columnId) => memo(() => [table.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
|
|
3043
3064
|
var _facetedRowModel$flat;
|
|
3044
|
-
const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.
|
|
3065
|
+
const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getUniqueValues(columnId);
|
|
3045
3066
|
if (typeof firstValue === 'undefined') {
|
|
3046
3067
|
return undefined;
|
|
3047
3068
|
}
|
|
3048
3069
|
let facetedMinMaxValues = [firstValue, firstValue];
|
|
3049
3070
|
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
3050
|
-
const
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3071
|
+
const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
|
|
3072
|
+
for (let j = 0; j < values.length; j++) {
|
|
3073
|
+
const value = values[j];
|
|
3074
|
+
if (value < facetedMinMaxValues[0]) {
|
|
3075
|
+
facetedMinMaxValues[0] = value;
|
|
3076
|
+
} else if (value > facetedMinMaxValues[1]) {
|
|
3077
|
+
facetedMinMaxValues[1] = value;
|
|
3078
|
+
}
|
|
3055
3079
|
}
|
|
3056
3080
|
}
|
|
3057
3081
|
return facetedMinMaxValues;
|