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