package.build.lib.utils.getFacetedMinMaxValues.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of table-core Show documentation
Show all versions of table-core Show documentation
Headless UI for building powerful tables & datagrids for TS/JS.
The newest version!
/**
* table-core
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var utils = require('../utils.js');
function getFacetedMinMaxValues() {
return (table, columnId) => utils.memo(() => {
var _table$getColumn;
return [(_table$getColumn = table.getColumn(columnId)) == null ? void 0 : _table$getColumn.getFacetedRowModel()];
}, facetedRowModel => {
var _facetedRowModel$flat;
if (!facetedRowModel) return undefined;
const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getUniqueValues(columnId);
if (typeof firstValue === 'undefined') {
return undefined;
}
let facetedMinMaxValues = [firstValue, firstValue];
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
for (let j = 0; j < values.length; j++) {
const value = values[j];
if (value < facetedMinMaxValues[0]) {
facetedMinMaxValues[0] = value;
} else if (value > facetedMinMaxValues[1]) {
facetedMinMaxValues[1] = value;
}
}
}
return facetedMinMaxValues;
}, {
key: process.env.NODE_ENV === 'development' && 'getFacetedMinMaxValues_' + columnId,
debug: () => {
var _table$options$debugA;
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
},
onChange: () => {}
});
}
exports.getFacetedMinMaxValues = getFacetedMinMaxValues;
//# sourceMappingURL=getFacetedMinMaxValues.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy