/** * 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'; const includesString = (row, columnId, filterValue) => { var _filterValue$toString, _row$getValue; const search = filterValue == null || (_filterValue$toString = filterValue.toString()) == null ? void 0 : _filterValue$toString.toLowerCase(); 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)); }; includesString.autoRemove = val => testFalsey(val); const includesStringSensitive = (row, columnId, filterValue) => { var _row$getValue2; return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue)); }; includesStringSensitive.autoRemove = val => testFalsey(val); const equalsString = (row, columnId, filterValue) => { var _row$getValue3; return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase()); }; equalsString.autoRemove = val => testFalsey(val); const arrIncludes = (row, columnId, filterValue) => { var _row$getValue4; return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue); }; arrIncludes.autoRemove = val => testFalsey(val); const arrIncludesAll = (row, columnId, filterValue) => { return !filterValue.some(val => { var _row$getValue5; return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val)); }); }; arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length); const arrIncludesSome = (row, columnId, filterValue) => { return filterValue.some(val => { var _row$getValue6; return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val); }); }; arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length); const equals = (row, columnId, filterValue) => { return row.getValue(columnId) === filterValue; }; equals.autoRemove = val => testFalsey(val); const weakEquals = (row, columnId, filterValue) => { return row.getValue(columnId) == filterValue; }; weakEquals.autoRemove = val => testFalsey(val); const inNumberRange = (row, columnId, filterValue) => { let [min, max] = filterValue; const rowValue = row.getValue(columnId); return rowValue >= min && rowValue <= max; }; inNumberRange.resolveFilterValue = val => { let [unsafeMin, unsafeMax] = val; let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin; let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax; let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin; let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax; if (min > max) { const temp = min; min = max; max = temp; } return [min, max]; }; inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]); // Export const filterFns = { includesString, includesStringSensitive, equalsString, arrIncludes, arrIncludesAll, arrIncludesSome, equals, weakEquals, inNumberRange }; // Utils function testFalsey(val) { return val === undefined || val === null || val === ''; } exports.filterFns = filterFns; //# sourceMappingURL=filterFns.js.map