@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
44 lines (39 loc) • 1.26 kB
JavaScript
/**
* MSKCC 2021, 2024
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
/**
* Default implementation of how we filter rows internally. The idea behind this
* implementation is to use the given list of row ids and headers to get the
* individual cell values for a row. Then, we go through each cell value and see
* if any of them includes the given inputValue.
*
* @param {object} config
* @param {Array<string>} config.rowIds array of all the row ids in the table
* @param {Array<object>} config.headers
* @param {object} config.cellsById object containing a map of cell id to cell
* @param {string} config.inputValue the current input value in the Table Search
* @param {Function} config.getCellId
* @returns {Array<string>} rowIds
*/
const defaultFilterRows = _ref => {
let {
rowIds,
headers,
cellsById,
inputValue,
getCellId
} = _ref;
return rowIds.filter(rowId => headers.some(_ref2 => {
let {
key
} = _ref2;
const id = getCellId(rowId, key);
if (typeof cellsById[id].value === 'boolean') {
return false;
}
return ('' + cellsById[id].value).toLowerCase().includes(inputValue.toLowerCase());
}));
};
exports.defaultFilterRows = defaultFilterRows;