material-react-table 0.26.1 → 0.26.4
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/dist/MaterialReactTable.d.ts +3 -1
- package/dist/material-react-table.cjs.development.js +17 -10
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +17 -10
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +4 -0
- package/src/column.utils.ts +9 -3
- package/src/head/MRT_TableHeadCell.tsx +11 -1
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +2 -2
- package/src/inputs/MRT_FilterTextField.tsx +4 -4
- package/src/table/MRT_TableRoot.tsx +2 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.26.
|
|
2
|
+
"version": "0.26.4",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -710,7 +710,9 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
710
710
|
onShowAlertBannerChange?: OnChangeFn<boolean>;
|
|
711
711
|
onShowFiltersChange?: OnChangeFn<boolean>;
|
|
712
712
|
onShowGlobalFilterChange?: OnChangeFn<boolean>;
|
|
713
|
+
onTableInstanceChange?: (table: MRT_TableInstance<TData>) => void;
|
|
713
714
|
positionActionsColumn?: 'first' | 'last';
|
|
715
|
+
positionExpandColumn?: 'first' | 'last';
|
|
714
716
|
positionGlobalFilter?: 'left' | 'right';
|
|
715
717
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
716
718
|
positionToolbarAlertBanner?: 'bottom' | 'top';
|
|
@@ -815,6 +817,7 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
815
817
|
icons,
|
|
816
818
|
localization,
|
|
817
819
|
positionActionsColumn = 'first',
|
|
820
|
+
positionExpandColumn = 'first',
|
|
818
821
|
positionGlobalFilter = 'right',
|
|
819
822
|
positionPagination = 'bottom',
|
|
820
823
|
positionToolbarAlertBanner = 'top',
|
|
@@ -857,6 +860,7 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
857
860
|
icons={{ ...MRT_Default_Icons, ...icons }}
|
|
858
861
|
localization={{ ...MRT_DefaultLocalization_EN, ...localization }}
|
|
859
862
|
positionActionsColumn={positionActionsColumn}
|
|
863
|
+
positionExpandColumn={positionExpandColumn}
|
|
860
864
|
positionGlobalFilter={positionGlobalFilter}
|
|
861
865
|
positionPagination={positionPagination}
|
|
862
866
|
positionToolbarAlertBanner={positionToolbarAlertBanner}
|
package/src/column.utils.ts
CHANGED
|
@@ -87,9 +87,10 @@ export const getLeadingDisplayColumnIds = <
|
|
|
87
87
|
((props.positionActionsColumn === 'first' && props.enableRowActions) ||
|
|
88
88
|
(props.enableEditing && props.editingMode === 'row')) &&
|
|
89
89
|
'mrt-row-actions',
|
|
90
|
-
|
|
91
|
-
props.
|
|
92
|
-
|
|
90
|
+
props.positionExpandColumn === 'first' &&
|
|
91
|
+
(props.enableExpanding ||
|
|
92
|
+
props.enableGrouping ||
|
|
93
|
+
props.renderDetailPanel) &&
|
|
93
94
|
'mrt-row-expand',
|
|
94
95
|
props.enableRowSelection && 'mrt-row-select',
|
|
95
96
|
props.enableRowNumbers && 'mrt-row-numbers',
|
|
@@ -103,6 +104,11 @@ export const getTrailingDisplayColumnIds = <
|
|
|
103
104
|
((props.positionActionsColumn === 'last' && props.enableRowActions) ||
|
|
104
105
|
(props.enableEditing && props.editingMode === 'row')) &&
|
|
105
106
|
'mrt-row-actions',
|
|
107
|
+
props.positionExpandColumn === 'last' &&
|
|
108
|
+
(props.enableExpanding ||
|
|
109
|
+
props.enableGrouping ||
|
|
110
|
+
props.renderDetailPanel) &&
|
|
111
|
+
'mrt-row-expand',
|
|
106
112
|
];
|
|
107
113
|
|
|
108
114
|
export const getDefaultColumnOrderIds = <
|
|
@@ -177,7 +177,12 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
177
177
|
alignItems: 'flex-start',
|
|
178
178
|
display: 'flex',
|
|
179
179
|
justifyContent:
|
|
180
|
-
|
|
180
|
+
tableCellProps?.align === 'right'
|
|
181
|
+
? 'flex-end'
|
|
182
|
+
: columnDefType === 'group' ||
|
|
183
|
+
tableCellProps?.align === 'center'
|
|
184
|
+
? 'center'
|
|
185
|
+
: 'space-between',
|
|
181
186
|
position: 'relative',
|
|
182
187
|
width: '100%',
|
|
183
188
|
}}
|
|
@@ -192,6 +197,11 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
192
197
|
: undefined,
|
|
193
198
|
display: 'flex',
|
|
194
199
|
flexWrap: 'nowrap',
|
|
200
|
+
m: tableCellProps?.align === 'center' ? 'auto' : undefined,
|
|
201
|
+
pl:
|
|
202
|
+
tableCellProps?.align === 'center' && column.getCanSort()
|
|
203
|
+
? '1rem'
|
|
204
|
+
: undefined,
|
|
195
205
|
whiteSpace:
|
|
196
206
|
(columnDef.header?.length ?? 0) < 24 ? 'nowrap' : 'normal',
|
|
197
207
|
}}
|
|
@@ -27,8 +27,8 @@ export const MRT_TableHeadCellFilterLabel: FC<Props> = ({ header, table }) => {
|
|
|
27
27
|
// @ts-ignore
|
|
28
28
|
localization[
|
|
29
29
|
`filter${
|
|
30
|
-
currentFilterOption
|
|
31
|
-
currentFilterOption
|
|
30
|
+
currentFilterOption?.charAt(0)?.toUpperCase() +
|
|
31
|
+
currentFilterOption?.slice(1)
|
|
32
32
|
}`
|
|
33
33
|
],
|
|
34
34
|
)
|
|
@@ -134,8 +134,8 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
134
134
|
? //@ts-ignore
|
|
135
135
|
localization[
|
|
136
136
|
`filter${
|
|
137
|
-
currentFilterOption
|
|
138
|
-
currentFilterOption
|
|
137
|
+
currentFilterOption?.charAt(0)?.toUpperCase() +
|
|
138
|
+
currentFilterOption?.slice(1)
|
|
139
139
|
}`
|
|
140
140
|
]
|
|
141
141
|
: '';
|
|
@@ -183,8 +183,8 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
183
183
|
// @ts-ignore
|
|
184
184
|
localization[
|
|
185
185
|
`filter${
|
|
186
|
-
currentFilterOption
|
|
187
|
-
currentFilterOption
|
|
186
|
+
currentFilterOption?.charAt(0)?.toUpperCase() +
|
|
187
|
+
currentFilterOption?.slice(1)
|
|
188
188
|
}`
|
|
189
189
|
],
|
|
190
190
|
)}
|
|
@@ -252,7 +252,6 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
252
252
|
columns: columnDefs,
|
|
253
253
|
data,
|
|
254
254
|
getSubRows: (row) => row?.subRows,
|
|
255
|
-
//@ts-ignore
|
|
256
255
|
globalFilterFn:
|
|
257
256
|
MRT_FilterFns[currentGlobalFilterFn] ?? MRT_FilterFns.fuzzy,
|
|
258
257
|
initialState,
|
|
@@ -297,6 +296,8 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
297
296
|
setShowGlobalFilter: props.onShowGlobalFilterChange ?? setShowGlobalFilter,
|
|
298
297
|
} as MRT_TableInstance;
|
|
299
298
|
|
|
299
|
+
useEffect(() => props?.onTableInstanceChange?.(table as any), [table]);
|
|
300
|
+
|
|
300
301
|
return (
|
|
301
302
|
<>
|
|
302
303
|
<Dialog
|