@tanstack/react-table 8.0.0-beta.3 → 8.0.0-beta.6

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.
@@ -66,6 +66,7 @@ function useTableInstance(table, options) {
66
66
  onStateChange: () => {},
67
67
  // noop
68
68
  render,
69
+ renderFallbackValue: null,
69
70
  ...options
70
71
  }; // Create a new table instance and store it in state
71
72
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nexport * from '@tanstack/table-core'\n\nimport {\n createTableInstance,\n TableOptions,\n TableInstance,\n Table,\n TableGenerics,\n createTableFactory,\n Overwrite,\n PartialKeys,\n TableOptionsResolved,\n} from '@tanstack/table-core'\n\nexport type Renderable<TProps> =\n | React.ReactNode\n | React.FunctionComponent<TProps>\n | React.Component<TProps>\n\nexport type Render = <TProps extends {}>(\n Comp: Renderable<TProps>,\n props: TProps\n) => React.ReactNode | JSX.Element\n\nexport type ReactTableGenerics = Overwrite<\n TableGenerics,\n { Renderer: Render; Rendered: ReturnType<Render> }\n>\n\n//\n\nexport const render: Render = (Comp, props) =>\n !Comp ? null : isReactComponent(Comp) ? <Comp {...props} /> : Comp\n\nfunction isReactComponent(component: unknown): component is React.FC {\n return (\n isClassComponent(component) ||\n typeof component === 'function' ||\n isExoticComponent(component)\n )\n}\n\nfunction isClassComponent(component: any) {\n return (\n typeof component === 'function' &&\n (() => {\n const proto = Object.getPrototypeOf(component)\n return proto.prototype && proto.prototype.isReactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)\n )\n}\n\nexport const createTable = createTableFactory({ render })\n\n// const useIsomorphicLayoutEffect =\n// typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\nexport type UseTableInstanceOptions<TGenerics extends ReactTableGenerics> =\n TableOptions<TGenerics>\n\nexport function useTableInstance<TGenerics extends ReactTableGenerics>(\n table: Table<TGenerics>,\n options: UseTableInstanceOptions<TGenerics>\n): TableInstance<TGenerics> {\n // Compose in the generic options to the user options\n const resolvedOptions: TableOptionsResolved<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n ...options,\n }\n\n // Create a new table instance and store it in state\n const [instanceRef] = React.useState(() => ({\n current: createTableInstance<TGenerics>(resolvedOptions),\n }))\n\n // By default, manage table state here using the instance's initial state\n const [state, setState] = React.useState(\n () => instanceRef.current.initialState\n )\n\n // Compose the default state above with any user state. This will allow the user\n // to only control a subset of the state if desired.\n instanceRef.current.setOptions(prev => ({\n ...prev,\n ...options,\n state: {\n ...state,\n ...options.state,\n },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n setState(updater)\n options.onStateChange?.(updater)\n },\n }))\n\n return instanceRef.current\n}\n"],"names":["render","Comp","props","isReactComponent","React","component","isClassComponent","isExoticComponent","proto","Object","getPrototypeOf","prototype","$$typeof","includes","description","createTable","createTableFactory","useTableInstance","table","options","resolvedOptions","state","onStateChange","instanceRef","useState","current","createTableInstance","setState","initialState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA;AAEO,MAAMA,MAAc,GAAG,CAACC,IAAD,EAAOC,KAAP,KAC5B,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAACF,IAAD,CAAhB,gBAAyBG,gBAAA,CAAA,aAAA,CAAC,IAAD,EAAUF,KAAV,CAAzB,GAA+CD,KADzD;;AAGP,SAASE,gBAAT,CAA0BE,SAA1B,EAAqE;AACnE,EAAA,OACEC,gBAAgB,CAACD,SAAD,CAAhB,IACA,OAAOA,SAAP,KAAqB,UADrB,IAEAE,iBAAiB,CAACF,SAAD,CAHnB,CAAA;AAKD,CAAA;;AAED,SAASC,gBAAT,CAA0BD,SAA1B,EAA0C;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,CAAoBI,UAApB,CAA+BC,IAAI,KAAK,EACtC,GAAGA,IADmC;AAEtC,IAAA,GAAGX,OAFmC;AAGtCE,IAAAA,KAAK,EAAE,EACL,GAAGA,KADE;AAEL,MAAA,GAAGF,OAAO,CAACE,KAAAA;AAFN,KAH+B;AAOtC;AACA;AACAC,IAAAA,aAAa,EAAES,OAAO,IAAI;AACxBJ,MAAAA,QAAQ,CAACI,OAAD,CAAR,CAAA;AACAZ,MAAAA,OAAO,CAACG,aAAR,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAH,OAAO,CAACG,aAAR,CAAwBS,OAAxB,CAAA,CAAA;AACD,KAAA;AAZqC,GAAL,CAAnC,CAAA,CAAA;AAeA,EAAOR,OAAAA,WAAW,CAACE,OAAnB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nexport * from '@tanstack/table-core'\n\nimport {\n createTableInstance,\n TableOptions,\n TableInstance,\n Table,\n TableGenerics,\n createTableFactory,\n Overwrite,\n PartialKeys,\n TableOptionsResolved,\n} from '@tanstack/table-core'\n\nexport type Renderable<TProps> =\n | React.ReactNode\n | React.FunctionComponent<TProps>\n | React.Component<TProps>\n\nexport type Render = <TProps extends {}>(\n Comp: Renderable<TProps>,\n props: TProps\n) => React.ReactNode | JSX.Element\n\nexport type ReactTableGenerics = Overwrite<\n TableGenerics,\n { Renderer: Render; Rendered: ReturnType<Render> }\n>\n\n//\n\nexport const render: Render = (Comp, props) =>\n !Comp ? null : isReactComponent(Comp) ? <Comp {...props} /> : Comp\n\nfunction isReactComponent(component: unknown): component is React.FC {\n return (\n isClassComponent(component) ||\n typeof component === 'function' ||\n isExoticComponent(component)\n )\n}\n\nfunction isClassComponent(component: any) {\n return (\n typeof component === 'function' &&\n (() => {\n const proto = Object.getPrototypeOf(component)\n return proto.prototype && proto.prototype.isReactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)\n )\n}\n\nexport const createTable = createTableFactory({ render })\n\n// const useIsomorphicLayoutEffect =\n// typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\nexport type UseTableInstanceOptions<TGenerics extends ReactTableGenerics> =\n TableOptions<TGenerics>\n\nexport function useTableInstance<TGenerics extends ReactTableGenerics>(\n table: Table<TGenerics>,\n options: UseTableInstanceOptions<TGenerics>\n): TableInstance<TGenerics> {\n // Compose in the generic options to the user options\n const resolvedOptions: TableOptionsResolved<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n renderFallbackValue: null,\n ...options,\n }\n\n // Create a new table instance and store it in state\n const [instanceRef] = React.useState(() => ({\n current: createTableInstance<TGenerics>(resolvedOptions),\n }))\n\n // By default, manage table state here using the instance's initial state\n const [state, setState] = React.useState(\n () => instanceRef.current.initialState\n )\n\n // Compose the default state above with any user state. This will allow the user\n // to only control a subset of the state if desired.\n instanceRef.current.setOptions(prev => ({\n ...prev,\n ...options,\n state: {\n ...state,\n ...options.state,\n },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n setState(updater)\n options.onStateChange?.(updater)\n },\n }))\n\n return instanceRef.current\n}\n"],"names":["render","Comp","props","isReactComponent","React","component","isClassComponent","isExoticComponent","proto","Object","getPrototypeOf","prototype","$$typeof","includes","description","createTable","createTableFactory","useTableInstance","table","options","resolvedOptions","state","onStateChange","renderFallbackValue","instanceRef","useState","current","createTableInstance","setState","initialState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA;AAEO,MAAMA,MAAc,GAAG,CAACC,IAAD,EAAOC,KAAP,KAC5B,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAACF,IAAD,CA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AACK,WAAD,CAAA,GAAgBpB,gBAAK,CAACqB,QAAN,CAAe,OAAO;AAC1CC,IAAAA,OAAO,EAAEC,yBAAmB,CAAYP,eAAZ,CAAA;AADc,GAAP,CAAf,CAAtB,CAZ0B;;AAiB1B,EAAA,MAAM,CAACC,KAAD,EAAQO,QAAR,CAAA,GAAoBxB,gBAAK,CAACqB,QAAN,CACxB,MAAMD,WAAW,CAACE,OAAZ,CAAoBG,YADF,CAA1B,CAjB0B;AAsB1B;;AACAL,EAAAA,WAAW,CAACE,OAAZ,CAAoBI,UAApB,CAA+BC,IAAI,KAAK,EACtC,GAAGA,IADmC;AAEtC,IAAA,GAAGZ,OAFmC;AAGtCE,IAAAA,KAAK,EAAE,EACL,GAAGA,KADE;AAEL,MAAA,GAAGF,OAAO,CAACE,KAAAA;AAFN,KAH+B;AAOtC;AACA;AACAC,IAAAA,aAAa,EAAEU,OAAO,IAAI;AACxBJ,MAAAA,QAAQ,CAACI,OAAD,CAAR,CAAA;AACAb,MAAAA,OAAO,CAACG,aAAR,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAH,OAAO,CAACG,aAAR,CAAwBU,OAAxB,CAAA,CAAA;AACD,KAAA;AAZqC,GAAL,CAAnC,CAAA,CAAA;AAeA,EAAOR,OAAAA,WAAW,CAACE,OAAnB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -828,7 +828,6 @@ const Expanding = {
828
828
  getDefaultOptions: instance => {
829
829
  return {
830
830
  onExpandedChange: makeStateUpdater('expanded', instance),
831
- autoResetExpanded: true,
832
831
  paginateExpandedRows: true
833
832
  };
834
833
  },
@@ -837,6 +836,8 @@ const Expanding = {
837
836
  let queued = false;
838
837
  return {
839
838
  _autoResetExpanded: () => {
839
+ var _ref, _instance$options$aut;
840
+
840
841
  if (!registered) {
841
842
  instance._queue(() => {
842
843
  registered = true;
@@ -845,11 +846,7 @@ const Expanding = {
845
846
  return;
846
847
  }
847
848
 
848
- if (instance.options.autoResetAll === false) {
849
- return;
850
- }
851
-
852
- if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
849
+ if ((_ref = (_instance$options$aut = instance.options.autoResetAll) != null ? _instance$options$aut : instance.options.autoResetExpanded) != null ? _ref : !instance.options.manualExpanding) {
853
850
  if (queued) return;
854
851
  queued = true;
855
852
 
@@ -913,7 +910,7 @@ const Expanding = {
913
910
  });
914
911
  return maxDepth;
915
912
  },
916
- getPreExpandedRowModel: () => instance.getGroupedRowModel(),
913
+ getPreExpandedRowModel: () => instance.getSortedRowModel(),
917
914
  getExpandedRowModel: () => {
918
915
  if (!instance._getExpandedRowModel && instance.options.getExpandedRowModel) {
919
916
  instance._getExpandedRowModel = instance.options.getExpandedRowModel(instance);
@@ -1514,7 +1511,7 @@ const Grouping = {
1514
1511
 
1515
1512
  instance.setGrouping(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.grouping) != null ? _instance$initialStat : []);
1516
1513
  },
1517
- getPreGroupedRowModel: () => instance.getSortedRowModel(),
1514
+ getPreGroupedRowModel: () => instance.getFilteredRowModel(),
1518
1515
  getGroupedRowModel: () => {
1519
1516
  if (!instance._getGroupedRowModel && instance.options.getGroupedRowModel) {
1520
1517
  instance._getGroupedRowModel = instance.options.getGroupedRowModel(instance);
@@ -1535,6 +1532,12 @@ const Grouping = {
1535
1532
  };
1536
1533
  },
1537
1534
  createCell: (cell, column, row, instance) => {
1535
+ const getRenderValue = () => {
1536
+ var _cell$getValue;
1537
+
1538
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
1539
+ };
1540
+
1538
1541
  return {
1539
1542
  getIsGrouped: () => column.getIsGrouped() && column.id === row.groupingColumnId,
1540
1543
  getIsPlaceholder: () => !cell.getIsGrouped() && column.getIsGrouped(),
@@ -1544,15 +1547,19 @@ const Grouping = {
1544
1547
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1545
1548
  },
1546
1549
  renderAggregatedCell: () => {
1547
- var _column$columnDef$agg;
1550
+ if (process.env.NODE_ENV === 'development') {
1551
+ if (!column.columnDef.aggregatedCell) {
1552
+ console.warn('A columnDef.aggregatedCell template is recommended for displaying aggregated values.');
1553
+ }
1554
+ }
1548
1555
 
1549
- const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
1556
+ const template = column.columnDef.aggregatedCell || column.columnDef.cell;
1550
1557
  return template ? instance._render(template, {
1551
1558
  instance,
1552
1559
  column,
1553
1560
  row,
1554
1561
  cell,
1555
- getValue: cell.getValue
1562
+ getValue: getRenderValue
1556
1563
  }) : null;
1557
1564
  }
1558
1565
  };
@@ -2022,11 +2029,11 @@ const RowSelection = {
2022
2029
  });
2023
2030
  },
2024
2031
  toggleAllPageRowsSelected: value => instance.setRowSelection(old => {
2025
- typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2032
+ const resolvedValue = typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2026
2033
  const rowSelection = { ...old
2027
2034
  };
2028
2035
  instance.getRowModel().rows.forEach(row => {
2029
- mutateRowIsSelected(rowSelection, row.id, value, instance);
2036
+ mutateRowIsSelected(rowSelection, row.id, resolvedValue, instance);
2030
2037
  });
2031
2038
  return rowSelection;
2032
2039
  }),
@@ -2117,7 +2124,7 @@ const RowSelection = {
2117
2124
  return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
2118
2125
  }
2119
2126
  }),
2120
- getGroupedSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getGroupedRowModel()], (rowSelection, rowModel) => {
2127
+ getGroupedSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getSortedRowModel()], (rowSelection, rowModel) => {
2121
2128
  if (!Object.keys(rowSelection).length) {
2122
2129
  return {
2123
2130
  rows: [],
@@ -2181,7 +2188,7 @@ const RowSelection = {
2181
2188
  },
2182
2189
  getIsSomePageRowsSelected: () => {
2183
2190
  const paginationFlatRows = instance.getPaginationRowModel().flatRows;
2184
- return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
2191
+ return instance.getIsAllPageRowsSelected() ? false : paginationFlatRows.some(d => d.getIsSelected() || d.getIsSomeSelected());
2185
2192
  },
2186
2193
  getToggleAllRowsSelectedHandler: () => {
2187
2194
  return e => {
@@ -2535,8 +2542,10 @@ const Sorting = {
2535
2542
  // })
2536
2543
  // return
2537
2544
  // }
2545
+ // this needs to be outside of instance.setSorting to be in sync with rerender
2546
+ const nextSortingOrder = column.getNextSortingOrder();
2538
2547
  instance.setSorting(old => {
2539
- var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2548
+ var _instance$options$ena, _instance$options$ena2;
2540
2549
 
2541
2550
  // Find any existing sorting for this column
2542
2551
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2561,30 +2570,29 @@ const Sorting = {
2561
2570
  } else {
2562
2571
  sortAction = 'replace';
2563
2572
  }
2564
- }
2573
+ } // Handle toggle states that will remove the sorting
2565
2574
 
2566
- const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
2567
2575
 
2568
2576
  if (sortAction === 'toggle' && ( // Must be toggling
2569
2577
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
2570
2578
  !hasDescDefined && ( // Must not be setting desc
2571
- multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
2572
- existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
2573
- ? !sortDescFirst : sortDescFirst)) {
2579
+ multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && // If multi, don't allow if enableMultiRemove
2580
+ !nextSortingOrder // Finally, detect if it should indeed be removed
2581
+ ) {
2574
2582
  sortAction = 'remove';
2575
2583
  }
2576
2584
 
2577
2585
  if (sortAction === 'replace') {
2578
2586
  newSorting = [{
2579
2587
  id: column.id,
2580
- desc: hasDescDefined ? desc : !!sortDescFirst
2588
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2581
2589
  }];
2582
2590
  } else if (sortAction === 'add' && old != null && old.length) {
2583
2591
  var _instance$options$max;
2584
2592
 
2585
2593
  newSorting = [...old, {
2586
2594
  id: column.id,
2587
- desc: hasDescDefined ? desc : !!sortDescFirst
2595
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2588
2596
  }]; // Take latest n columns
2589
2597
 
2590
2598
  newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
@@ -2593,7 +2601,7 @@ const Sorting = {
2593
2601
  newSorting = old.map(d => {
2594
2602
  if (d.id === column.id) {
2595
2603
  return { ...d,
2596
- desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
2604
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2597
2605
  };
2598
2606
  }
2599
2607
 
@@ -2606,6 +2614,23 @@ const Sorting = {
2606
2614
  return newSorting;
2607
2615
  });
2608
2616
  },
2617
+ getNextSortingOrder: () => {
2618
+ var _ref2, _column$columnDef$sor;
2619
+
2620
+ const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc';
2621
+ const firstSortDirection = sortDescFirst ? 'desc' : 'asc';
2622
+ const isSorted = column.getIsSorted();
2623
+
2624
+ if (!isSorted) {
2625
+ return firstSortDirection;
2626
+ }
2627
+
2628
+ if (isSorted === firstSortDirection) {
2629
+ return isSorted === 'desc' ? 'asc' : 'desc';
2630
+ } else {
2631
+ return false;
2632
+ }
2633
+ },
2609
2634
  getCanSort: () => {
2610
2635
  var _column$columnDef$ena, _instance$options$ena3;
2611
2636
 
@@ -2649,7 +2674,7 @@ const Sorting = {
2649
2674
 
2650
2675
  instance.setSorting(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.sorting) != null ? _instance$initialStat : []);
2651
2676
  },
2652
- getPreSortedRowModel: () => instance.getFilteredRowModel(),
2677
+ getPreSortedRowModel: () => instance.getGroupedRowModel(),
2653
2678
  getSortedRowModel: () => {
2654
2679
  if (!instance._getSortedRowModel && instance.options.getSortedRowModel) {
2655
2680
  instance._getSortedRowModel = instance.options.getSortedRowModel(instance);
@@ -3055,6 +3080,12 @@ function createTable(_, __, options) {
3055
3080
  }
3056
3081
 
3057
3082
  function createCell(instance, row, column, columnId) {
3083
+ const getRenderValue = () => {
3084
+ var _cell$getValue;
3085
+
3086
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
3087
+ };
3088
+
3058
3089
  const cell = {
3059
3090
  id: row.id + "_" + column.id,
3060
3091
  row,
@@ -3066,7 +3097,7 @@ function createCell(instance, row, column, columnId) {
3066
3097
  column,
3067
3098
  row,
3068
3099
  cell: cell,
3069
- getValue: cell.getValue
3100
+ getValue: getRenderValue
3070
3101
  }) : null;
3071
3102
  }
3072
3103
  };
@@ -3795,20 +3826,34 @@ function getPaginationRowModel(opts) {
3795
3826
  const pageStart = pageSize * pageIndex;
3796
3827
  const pageEnd = pageStart + pageSize;
3797
3828
  rows = rows.slice(pageStart, pageEnd);
3829
+ let paginatedRowModel;
3798
3830
 
3799
3831
  if (!instance.options.paginateExpandedRows) {
3800
- return expandRows({
3832
+ paginatedRowModel = expandRows({
3801
3833
  rows,
3802
3834
  flatRows,
3803
3835
  rowsById
3804
3836
  });
3837
+ } else {
3838
+ paginatedRowModel = {
3839
+ rows,
3840
+ flatRows,
3841
+ rowsById
3842
+ };
3805
3843
  }
3806
3844
 
3807
- return {
3808
- rows,
3809
- flatRows,
3810
- rowsById
3845
+ paginatedRowModel.flatRows = [];
3846
+
3847
+ const handleRow = row => {
3848
+ paginatedRowModel.flatRows.push(row);
3849
+
3850
+ if (row.subRows.length) {
3851
+ row.subRows.forEach(handleRow);
3852
+ }
3811
3853
  };
3854
+
3855
+ paginatedRowModel.rows.forEach(handleRow);
3856
+ return paginatedRowModel;
3812
3857
  }, {
3813
3858
  key: process.env.NODE_ENV === 'development' && 'getPaginationRowModel',
3814
3859
  debug: () => {