@tanstack/react-table 8.5.30 → 8.6.0

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.
@@ -968,6 +968,7 @@ const Filters = {
968
968
  onColumnFiltersChange: makeStateUpdater('columnFilters', table),
969
969
  onGlobalFilterChange: makeStateUpdater('globalFilter', table),
970
970
  filterFromLeafRows: false,
971
+ maxLeafRowFilterDepth: 100,
971
972
  globalFilterFn: 'auto',
972
973
  getColumnCanGlobalFilter: column => {
973
974
  var _table$getCoreRowMode, _table$getCoreRowMode2;
@@ -2849,7 +2850,11 @@ function filterRows(rows, filterRowImpl, table) {
2849
2850
  function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
2850
2851
  const newFilteredFlatRows = [];
2851
2852
  const newFilteredRowsById = {};
2853
+ const maxDepth = table.options.maxLeafRowFilterDepth ?? 100;
2852
2854
  const recurseFilterRows = function (rowsToFilter, depth) {
2855
+ if (depth === void 0) {
2856
+ depth = 0;
2857
+ }
2853
2858
  const rows = [];
2854
2859
 
2855
2860
  // Filter from children up first
@@ -2858,8 +2863,8 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
2858
2863
  let row = rowsToFilter[i];
2859
2864
  const newRow = createRow(table, row.id, row.original, row.index, row.depth);
2860
2865
  newRow.columnFilters = row.columnFilters;
2861
- if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
2862
- newRow.subRows = recurseFilterRows(row.subRows);
2866
+ if ((_row$subRows = row.subRows) != null && _row$subRows.length && depth < maxDepth) {
2867
+ newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
2863
2868
  row = newRow;
2864
2869
  if (filterRow(row) && !newRow.subRows.length) {
2865
2870
  rows.push(row);
@@ -2893,9 +2898,13 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
2893
2898
  function filterRowModelFromRoot(rowsToFilter, filterRow, table) {
2894
2899
  const newFilteredFlatRows = [];
2895
2900
  const newFilteredRowsById = {};
2901
+ const maxDepth = table.options.maxLeafRowFilterDepth ?? 100;
2896
2902
 
2897
2903
  // Filters top level and nested rows
2898
2904
  const recurseFilterRows = function (rowsToFilter, depth) {
2905
+ if (depth === void 0) {
2906
+ depth = 0;
2907
+ }
2899
2908
  // Filter from parents downward first
2900
2909
 
2901
2910
  const rows = [];
@@ -2906,9 +2915,9 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, table) {
2906
2915
  const pass = filterRow(row);
2907
2916
  if (pass) {
2908
2917
  var _row$subRows2;
2909
- if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2918
+ if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length && depth < maxDepth) {
2910
2919
  const newRow = createRow(table, row.id, row.original, row.index, row.depth);
2911
- newRow.subRows = recurseFilterRows(row.subRows);
2920
+ newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
2912
2921
  row = newRow;
2913
2922
  }
2914
2923
  rows.push(row);