/** * 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'; var filterFns = require('../filterFns.js'); var utils = require('../utils.js'); // const GlobalFiltering = { getInitialState: state => { return { globalFilter: undefined, ...state }; }, getDefaultOptions: table => { return { onGlobalFilterChange: utils.makeStateUpdater('globalFilter', table), globalFilterFn: 'auto', getColumnCanGlobalFilter: column => { var _table$getCoreRowMode; const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue(); return typeof value === 'string' || typeof value === 'number'; } }; }, createColumn: (column, table) => { column.getCanGlobalFilter = () => { var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol; return ((_column$columnDef$ena = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGlobalFilter) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn; }; }, createTable: table => { table.getGlobalAutoFilterFn = () => { return filterFns.filterFns.includesString; }; table.getGlobalFilterFn = () => { var _table$options$filter, _table$options$filter2; const { globalFilterFn: globalFilterFn } = table.options; return utils.isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns.filterFns[globalFilterFn]; }; table.setGlobalFilter = updater => { table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater); }; table.resetGlobalFilter = defaultState => { table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter); }; } }; exports.GlobalFiltering = GlobalFiltering; //# sourceMappingURL=GlobalFiltering.js.map