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