material-react-table 1.0.4 → 1.0.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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.4",
2
+ "version": "1.0.6",
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> = {}>({
@@ -120,9 +119,10 @@ export const getLeadingDisplayColumnIds = <
120
119
  ) =>
121
120
  [
122
121
  (props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
123
- ((props.positionActionsColumn === 'first' && props.enableRowActions) ||
124
- (props.enableEditing &&
125
- ['row', 'modal'].includes(props.editingMode ?? ''))) &&
122
+ props.positionActionsColumn === 'first' &&
123
+ (props.enableRowActions ||
124
+ (props.enableEditing &&
125
+ ['row', 'modal'].includes(props.editingMode ?? ''))) &&
126
126
  'mrt-row-actions',
127
127
  props.positionExpandColumn === 'first' &&
128
128
  showExpandColumn(props) &&
@@ -136,9 +136,10 @@ export const getTrailingDisplayColumnIds = <
136
136
  >(
137
137
  props: MaterialReactTableProps<TData>,
138
138
  ) => [
139
- ((props.positionActionsColumn === 'last' && props.enableRowActions) ||
140
- (props.enableEditing &&
141
- ['row', 'modal'].includes(props.editingMode ?? ''))) &&
139
+ props.positionActionsColumn === 'last' &&
140
+ (props.enableRowActions ||
141
+ (props.enableEditing &&
142
+ ['row', 'modal'].includes(props.editingMode ?? ''))) &&
142
143
  'mrt-row-actions',
143
144
  props.positionExpandColumn === 'last' &&
144
145
  showExpandColumn(props) &&