material-react-table 1.0.4 → 1.0.5

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.4",
2
+ "version": "1.0.5",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -21,19 +21,18 @@ export const getColumnId = <TData extends Record<string, any> = {}>(
21
21
  export const getAllLeafColumnDefs = <TData extends Record<string, any> = {}>(
22
22
  columns: MRT_ColumnDef<TData>[],
23
23
  ): MRT_ColumnDef<TData>[] => {
24
- let lowestLevelColumns: MRT_ColumnDef<TData>[] = columns;
25
- let currentCols: MRT_ColumnDef<TData>[] | undefined = columns;
26
- while (!!currentCols?.length && currentCols.some((col) => col.columns)) {
27
- const nextCols: MRT_ColumnDef<TData>[] = currentCols
28
- .filter((col) => !!col.columns)
29
- .map((col) => col.columns)
30
- .flat() as MRT_ColumnDef<TData>[];
31
- if (nextCols.every((col) => !col?.columns)) {
32
- lowestLevelColumns = [...lowestLevelColumns, ...nextCols];
33
- }
34
- currentCols = nextCols;
35
- }
36
- return lowestLevelColumns.filter((col) => !col.columns);
24
+ const allLeafColumnDefs: MRT_ColumnDef<TData>[] = [];
25
+ const getLeafColumns = (cols: MRT_ColumnDef<TData>[]) => {
26
+ cols.forEach((col) => {
27
+ if (col.columns) {
28
+ getLeafColumns(col.columns);
29
+ } else {
30
+ allLeafColumnDefs.push(col);
31
+ }
32
+ });
33
+ };
34
+ getLeafColumns(columns);
35
+ return allLeafColumnDefs;
37
36
  };
38
37
 
39
38
  export const prepareColumns = <TData extends Record<string, any> = {}>({