material-react-table 0.26.0 → 0.26.3

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/README.md CHANGED
@@ -55,8 +55,8 @@ _All features can easily be enabled/disabled_
55
55
  - [x] < 35kb gzipped - [Bundlephobia](https://bundlephobia.com/package/material-react-table)
56
56
  - [x] Advanced TypeScript Generics Support (TypeScript Optional)
57
57
  - [x] Click To Copy Cell Values
58
- - [x] Column Actions
59
- - [x] Column Grouping (Group By and Aggregates)
58
+ - [x] Column Action Dropdown Menu
59
+ - [x] Column/Row Grouping (Group By and Aggregates)
60
60
  - [x] Column Hiding
61
61
  - [x] Column Ordering via Drag'n'Drop
62
62
  - [x] Column Pinning (Freeze Columns)
@@ -415,6 +415,7 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
415
415
  onShowAlertBannerChange?: OnChangeFn<boolean>;
416
416
  onShowFiltersChange?: OnChangeFn<boolean>;
417
417
  onShowGlobalFilterChange?: OnChangeFn<boolean>;
418
+ onTableInstanceChange?: (table: MRT_TableInstance<TData>) => void;
418
419
  positionActionsColumn?: 'first' | 'last';
419
420
  positionGlobalFilter?: 'left' | 'right';
420
421
  positionPagination?: 'bottom' | 'top' | 'both';
@@ -224,10 +224,12 @@ var MRT_ExpandButton = function MRT_ExpandButton(_ref) {
224
224
  disabled: !row.getCanExpand() && !renderDetailPanel,
225
225
  onClick: handleToggleExpand
226
226
  }, iconButtonProps, {
227
- sx: _extends({
228
- height: density === 'compact' ? '1.75rem' : '2.25rem',
229
- width: density === 'compact' ? '1.75rem' : '2.25rem'
230
- }, iconButtonProps == null ? void 0 : iconButtonProps.sx)
227
+ sx: function sx(theme) {
228
+ return _extends({
229
+ height: density === 'compact' ? '1.75rem' : '2.25rem',
230
+ width: density === 'compact' ? '1.75rem' : '2.25rem'
231
+ }, (iconButtonProps == null ? void 0 : iconButtonProps.sx) instanceof Function ? iconButtonProps.sx(theme) : iconButtonProps == null ? void 0 : iconButtonProps.sx);
232
+ }
231
233
  }), React__default.createElement(ExpandMoreIcon, {
232
234
  style: {
233
235
  transform: "rotate(" + (!row.getCanExpand() && !renderDetailPanel ? -90 : row.getIsExpanded() ? -180 : 0) + "deg)",
@@ -272,7 +274,7 @@ var MRT_FilterOptionMenu = function MRT_FilterOptionMenu(_ref) {
272
274
  divider: false
273
275
  }, {
274
276
  option: 'contains',
275
- symbol: '[]',
277
+ symbol: '*',
276
278
  label: localization.filterContains,
277
279
  divider: false
278
280
  }, {
@@ -1448,11 +1450,13 @@ var MRT_SelectCheckbox = function MRT_SelectCheckbox(_ref) {
1448
1450
  onChange: !row ? selectAllMode === 'all' ? table.getToggleAllRowsSelectedHandler() : table.getToggleAllPageRowsSelectedHandler() : row.getToggleSelectedHandler(),
1449
1451
  size: density === 'compact' ? 'small' : 'medium'
1450
1452
  }, checkboxProps, {
1451
- sx: _extends({
1452
- height: density === 'compact' ? '1.5rem' : '2rem',
1453
- width: density === 'compact' ? '1.5rem' : '2rem',
1454
- m: '-1re.m'
1455
- }, checkboxProps == null ? void 0 : checkboxProps.sx)
1453
+ sx: function sx(theme) {
1454
+ return _extends({
1455
+ height: density === 'compact' ? '1.5rem' : '2rem',
1456
+ width: density === 'compact' ? '1.5rem' : '2rem',
1457
+ m: '-1re.m'
1458
+ }, (checkboxProps == null ? void 0 : checkboxProps.sx) instanceof Function ? checkboxProps.sx(theme) : checkboxProps == null ? void 0 : checkboxProps.sx);
1459
+ }
1456
1460
  })));
1457
1461
  };
1458
1462
 
@@ -1803,12 +1807,14 @@ var MRT_TablePagination = function MRT_TablePagination(_ref) {
1803
1807
  showFirstButton: showFirstLastPageButtons,
1804
1808
  showLastButton: showFirstLastPageButtons
1805
1809
  }, tablePaginationProps, {
1806
- sx: _extends({
1807
- m: '0 0.5rem',
1808
- mt: position === 'top' && enableToolbarInternalActions && !showGlobalFilter ? '3.5rem' : undefined,
1809
- position: 'relative',
1810
- zIndex: 2
1811
- }, tablePaginationProps == null ? void 0 : tablePaginationProps.sx)
1810
+ sx: function sx(theme) {
1811
+ return _extends({
1812
+ m: '0 0.5rem',
1813
+ mt: position === 'top' && enableToolbarInternalActions && !showGlobalFilter ? '3.5rem' : undefined,
1814
+ position: 'relative',
1815
+ zIndex: 2
1816
+ }, (tablePaginationProps == null ? void 0 : tablePaginationProps.sx) instanceof Function ? tablePaginationProps.sx(theme) : tablePaginationProps == null ? void 0 : tablePaginationProps.sx);
1817
+ }
1812
1818
  }));
1813
1819
  };
1814
1820
 
@@ -1850,17 +1856,19 @@ var MRT_ToolbarAlertBanner = function MRT_ToolbarAlertBanner(_ref) {
1850
1856
  color: "info",
1851
1857
  icon: false
1852
1858
  }, alertProps, {
1853
- sx: _extends({
1854
- borderRadius: 0,
1855
- fontSize: '1rem',
1856
- left: 0,
1857
- p: 0,
1858
- position: 'relative',
1859
- right: 0,
1860
- top: 0,
1861
- width: '100%',
1862
- zIndex: 2
1863
- }, alertProps == null ? void 0 : alertProps.sx)
1859
+ sx: function sx(theme) {
1860
+ return _extends({
1861
+ borderRadius: 0,
1862
+ fontSize: '1rem',
1863
+ left: 0,
1864
+ p: 0,
1865
+ position: 'relative',
1866
+ right: 0,
1867
+ top: 0,
1868
+ width: '100%',
1869
+ zIndex: 2
1870
+ }, (alertProps == null ? void 0 : alertProps.sx) instanceof Function ? alertProps.sx(theme) : alertProps == null ? void 0 : alertProps.sx);
1871
+ }
1864
1872
  }), (alertProps == null ? void 0 : alertProps.title) && React__default.createElement(material.AlertTitle, null, alertProps.title), React__default.createElement(material.Box, {
1865
1873
  sx: {
1866
1874
  p: '0.5rem 1rem'
@@ -1949,7 +1957,7 @@ var MRT_ToolbarTop = function MRT_ToolbarTop(_ref2) {
1949
1957
  top: isFullScreen ? '0' : undefined
1950
1958
  }, commonToolbarStyles({
1951
1959
  theme: theme
1952
- }), toolbarProps == null ? void 0 : toolbarProps.sx);
1960
+ }), (toolbarProps == null ? void 0 : toolbarProps.sx) instanceof Function ? toolbarProps.sx(theme) : toolbarProps == null ? void 0 : toolbarProps.sx);
1953
1961
  }
1954
1962
  }), positionToolbarAlertBanner === 'top' && React__default.createElement(MRT_ToolbarAlertBanner, {
1955
1963
  stackAlertBanner: stackAlertBanner,
@@ -2015,7 +2023,7 @@ var MRT_ToolbarBottom = function MRT_ToolbarBottom(_ref) {
2015
2023
  left: 0,
2016
2024
  position: isFullScreen ? 'fixed' : 'relative',
2017
2025
  right: 0
2018
- }, toolbarProps == null ? void 0 : toolbarProps.sx);
2026
+ }, (toolbarProps == null ? void 0 : toolbarProps.sx) instanceof Function ? toolbarProps.sx(theme) : toolbarProps == null ? void 0 : toolbarProps.sx);
2019
2027
  }
2020
2028
  }), React__default.createElement(MRT_LinearProgressBar, {
2021
2029
  isTopToolbar: false,
@@ -2090,16 +2098,18 @@ var MRT_TableHeadCellColumnActionsButton = function MRT_TableHeadCellColumnActio
2090
2098
  onClick: handleClick,
2091
2099
  size: "small"
2092
2100
  }, iconButtonProps, {
2093
- sx: _extends({
2094
- height: '2rem',
2095
- mt: '-0.2rem',
2096
- opacity: 0.5,
2097
- transition: 'opacity 0.2s',
2098
- width: '2rem',
2099
- '&:hover': {
2100
- opacity: 1
2101
- }
2102
- }, iconButtonProps.sx)
2101
+ sx: function sx(theme) {
2102
+ return _extends({
2103
+ height: '2rem',
2104
+ mt: '-0.2rem',
2105
+ opacity: 0.5,
2106
+ transition: 'opacity 0.2s',
2107
+ width: '2rem',
2108
+ '&:hover': {
2109
+ opacity: 1
2110
+ }
2111
+ }, (iconButtonProps == null ? void 0 : iconButtonProps.sx) instanceof Function ? iconButtonProps.sx(theme) : iconButtonProps == null ? void 0 : iconButtonProps.sx);
2112
+ }
2103
2113
  }), React__default.createElement(MoreVertIcon, null))), React__default.createElement(MRT_ColumnActionMenu, {
2104
2114
  anchorEl: anchorEl,
2105
2115
  header: header,
@@ -2284,15 +2294,17 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
2284
2294
  }, React__default.createElement(CloseIcon, null)))))
2285
2295
  }
2286
2296
  }, textFieldProps, {
2287
- sx: _extends({
2288
- m: '-0.25rem',
2289
- p: 0,
2290
- minWidth: !filterChipLabel ? '8rem' : 'auto',
2291
- width: 'calc(100% + 0.5rem)',
2292
- '& .MuiSelect-icon': {
2293
- mr: '1.5rem'
2294
- }
2295
- }, textFieldProps == null ? void 0 : textFieldProps.sx)
2297
+ sx: function sx(theme) {
2298
+ return _extends({
2299
+ m: '-0.25rem',
2300
+ p: 0,
2301
+ minWidth: !filterChipLabel ? '8rem' : 'auto',
2302
+ width: 'calc(100% + 0.5rem)',
2303
+ '& .MuiSelect-icon': {
2304
+ mr: '1.5rem'
2305
+ }
2306
+ }, (textFieldProps == null ? void 0 : textFieldProps.sx) instanceof Function ? textFieldProps.sx(theme) : textFieldProps == null ? void 0 : textFieldProps.sx);
2307
+ }
2296
2308
  }), isSelectFilter && React__default.createElement(material.MenuItem, {
2297
2309
  divider: true,
2298
2310
  disabled: !filterValue,
@@ -2626,7 +2638,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
2626
2638
  userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined,
2627
2639
  verticalAlign: 'top',
2628
2640
  zIndex: column.getIsResizing() || (currentDraggingColumn == null ? void 0 : currentDraggingColumn.id) === column.id ? 3 : column.getIsPinned() && columnDefType !== 'group' ? 2 : 1
2629
- }, tableCellProps == null ? void 0 : tableCellProps.sx, draggingBorders, {
2641
+ }, (tableCellProps == null ? void 0 : tableCellProps.sx) instanceof Function ? tableCellProps.sx(theme) : tableCellProps == null ? void 0 : tableCellProps.sx, draggingBorders, {
2630
2642
  maxWidth: "min(" + column.getSize() + "px, fit-content)",
2631
2643
  minWidth: "max(" + column.getSize() + "px, " + ((_columnDef$minSize = columnDef.minSize) != null ? _columnDef$minSize : 30) + "px)",
2632
2644
  width: header.getSize()
@@ -2647,6 +2659,8 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
2647
2659
  cursor: column.getCanSort() && columnDefType !== 'group' ? 'pointer' : undefined,
2648
2660
  display: 'flex',
2649
2661
  flexWrap: 'nowrap',
2662
+ m: (tableCellProps == null ? void 0 : tableCellProps.align) === 'center' ? 'auto' : undefined,
2663
+ pl: (tableCellProps == null ? void 0 : tableCellProps.align) === 'center' ? '1rem' : undefined,
2650
2664
  whiteSpace: ((_columnDef$header$len = (_columnDef$header = columnDef.header) == null ? void 0 : _columnDef$header.length) != null ? _columnDef$header$len : 0) < 24 ? 'nowrap' : 'normal'
2651
2665
  }
2652
2666
  }, headerElement, column.getCanSort() && React__default.createElement(MRT_TableHeadCellSortLabel, {
@@ -2848,19 +2862,21 @@ var MRT_CopyButton = function MRT_CopyButton(_ref) {
2848
2862
  type: "button",
2849
2863
  variant: "text"
2850
2864
  }, buttonProps, {
2851
- sx: _extends({
2852
- backgroundColor: 'transparent',
2853
- border: 'none',
2854
- color: 'inherit',
2855
- cursor: 'copy',
2856
- fontFamily: 'inherit',
2857
- fontSize: 'inherit',
2858
- letterSpacing: 'inherit',
2859
- m: '-0.25rem',
2860
- minWidth: 'unset',
2861
- textAlign: 'inherit',
2862
- textTransform: 'inherit'
2863
- }, buttonProps == null ? void 0 : buttonProps.sx)
2865
+ sx: function sx(theme) {
2866
+ return _extends({
2867
+ backgroundColor: 'transparent',
2868
+ border: 'none',
2869
+ color: 'inherit',
2870
+ cursor: 'copy',
2871
+ fontFamily: 'inherit',
2872
+ fontSize: 'inherit',
2873
+ letterSpacing: 'inherit',
2874
+ m: '-0.25rem',
2875
+ minWidth: 'unset',
2876
+ textAlign: 'inherit',
2877
+ textTransform: 'inherit'
2878
+ }, (buttonProps == null ? void 0 : buttonProps.sx) instanceof Function ? buttonProps.sx(theme) : buttonProps == null ? void 0 : buttonProps.sx);
2879
+ }
2864
2880
  }), children));
2865
2881
  };
2866
2882
 
@@ -3015,7 +3031,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
3015
3031
  '&:hover': {
3016
3032
  backgroundColor: enableHover && enableEditing && editingMode !== 'row' ? theme.palette.mode === 'dark' ? material.lighten(theme.palette.background["default"], 0.13) + " !important" : material.darken(theme.palette.background["default"], 0.07) + " !important" : undefined
3017
3033
  }
3018
- }, tableCellProps == null ? void 0 : tableCellProps.sx, draggingBorders, {
3034
+ }, (tableCellProps == null ? void 0 : tableCellProps.sx) instanceof Function ? tableCellProps.sx(theme) : tableCellProps == null ? void 0 : tableCellProps.sx, draggingBorders, {
3019
3035
  maxWidth: "min(" + column.getSize() + "px, fit-content)",
3020
3036
  minWidth: "max(" + column.getSize() + "px, " + ((_columnDef$minSize = columnDef.minSize) != null ? _columnDef$minSize : 30) + "px)",
3021
3037
  width: column.getSize()
@@ -3066,13 +3082,15 @@ var MRT_TableDetailPanel = function MRT_TableDetailPanel(_ref) {
3066
3082
  return React__default.createElement(material.TableRow, Object.assign({}, tableRowProps), React__default.createElement(material.TableCell, Object.assign({
3067
3083
  colSpan: getVisibleLeafColumns().length
3068
3084
  }, tableCellProps, {
3069
- sx: _extends({
3070
- borderBottom: !row.getIsExpanded() ? 'none' : undefined,
3071
- pb: row.getIsExpanded() ? '1rem' : 0,
3072
- pt: row.getIsExpanded() ? '1rem' : 0,
3073
- transition: 'all 0.2s ease-in-out',
3074
- width: table.getTotalSize() + "px"
3075
- }, tableCellProps == null ? void 0 : tableCellProps.sx)
3085
+ sx: function sx(theme) {
3086
+ return _extends({
3087
+ borderBottom: !row.getIsExpanded() ? 'none' : undefined,
3088
+ pb: row.getIsExpanded() ? '1rem' : 0,
3089
+ pt: row.getIsExpanded() ? '1rem' : 0,
3090
+ transition: 'all 0.2s ease-in-out',
3091
+ width: table.getTotalSize() + "px"
3092
+ }, (tableCellProps == null ? void 0 : tableCellProps.sx) instanceof Function ? tableCellProps.sx(theme) : tableCellProps == null ? void 0 : tableCellProps.sx);
3093
+ }
3076
3094
  }), renderDetailPanel && React__default.createElement(material.Collapse, {
3077
3095
  "in": row.getIsExpanded()
3078
3096
  }, renderDetailPanel({
@@ -3130,7 +3148,7 @@ var MRT_TableBodyRow = function MRT_TableBodyRow(_ref) {
3130
3148
  '&:hover td': {
3131
3149
  backgroundColor: (tableRowProps == null ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned() ? theme.palette.mode === 'dark' ? "" + material.lighten(theme.palette.background["default"], 0.12) : "" + material.darken(theme.palette.background["default"], 0.05) : undefined
3132
3150
  }
3133
- }, tableRowProps == null ? void 0 : tableRowProps.sx, draggingBorders);
3151
+ }, (tableRowProps == null ? void 0 : tableRowProps.sx) instanceof Function ? tableRowProps.sx(theme) : tableRowProps == null ? void 0 : tableRowProps.sx, draggingBorders);
3134
3152
  }
3135
3153
  }), row == null ? void 0 : (_row$getVisibleCells = row.getVisibleCells()) == null ? void 0 : _row$getVisibleCells.map == null ? void 0 : _row$getVisibleCells.map(function (cell) {
3136
3154
  return React__default.createElement(MRT_TableBodyCell, {
@@ -3266,7 +3284,7 @@ var MRT_TableFooterCell = function MRT_TableFooterCell(_ref) {
3266
3284
  transition: "all " + (enableColumnResizing ? '10ms' : '0.2s') + " ease-in-out",
3267
3285
  width: column.getSize(),
3268
3286
  verticalAlign: 'text-top'
3269
- }, tableCellProps == null ? void 0 : tableCellProps.sx);
3287
+ }, (tableCellProps == null ? void 0 : tableCellProps.sx) instanceof Function ? tableCellProps.sx(theme) : tableCellProps == null ? void 0 : tableCellProps.sx);
3270
3288
  }
3271
3289
  }), React__default.createElement(React__default.Fragment, null, footer.isPlaceholder ? null : (_ref2 = (_ref3 = columnDef.Footer instanceof Function ? columnDef.Footer == null ? void 0 : columnDef.Footer({
3272
3290
  footer: footer,
@@ -3334,9 +3352,11 @@ var MRT_Table = function MRT_Table(_ref) {
3334
3352
  return React__default.createElement(material.Table, Object.assign({
3335
3353
  stickyHeader: enableStickyHeader || enableRowVirtualization || isFullScreen
3336
3354
  }, tableProps, {
3337
- sx: _extends({
3338
- tableLayout: enableColumnResizing || enableRowVirtualization ? 'fixed' : 'auto'
3339
- }, tableProps == null ? void 0 : tableProps.sx)
3355
+ sx: function sx(theme) {
3356
+ return _extends({
3357
+ tableLayout: enableColumnResizing || enableRowVirtualization ? 'fixed' : 'auto'
3358
+ }, (tableProps == null ? void 0 : tableProps.sx) instanceof Function ? tableProps.sx(theme) : tableProps == null ? void 0 : tableProps.sx);
3359
+ }
3340
3360
  }), enableTableHead && React__default.createElement(MRT_TableHead, {
3341
3361
  table: table
3342
3362
  }), React__default.createElement(MRT_TableBody, {
@@ -3378,11 +3398,13 @@ var MRT_TableContainer = function MRT_TableContainer(_ref) {
3378
3398
  return React__default.createElement(material.TableContainer, Object.assign({
3379
3399
  ref: tableContainerRef
3380
3400
  }, tableContainerProps, {
3381
- sx: _extends({
3382
- maxWidth: '100%',
3383
- maxHeight: enableStickyHeader || enableRowVirtualization ? "clamp(350px, calc(100vh - " + totalToolbarHeight + "px), 9999px)" : undefined,
3384
- overflow: 'auto'
3385
- }, tableContainerProps == null ? void 0 : tableContainerProps.sx),
3401
+ sx: function sx(theme) {
3402
+ return _extends({
3403
+ maxWidth: '100%',
3404
+ maxHeight: enableStickyHeader || enableRowVirtualization ? "clamp(350px, calc(100vh - " + totalToolbarHeight + "px), 9999px)" : undefined,
3405
+ overflow: 'auto'
3406
+ }, (tableContainerProps == null ? void 0 : tableContainerProps.sx) instanceof Function ? tableContainerProps.sx(theme) : tableContainerProps == null ? void 0 : tableContainerProps.sx);
3407
+ },
3386
3408
  style: _extends({
3387
3409
  maxHeight: isFullScreen ? "calc(100vh - " + totalToolbarHeight + "px)" : undefined
3388
3410
  }, tableContainerProps == null ? void 0 : tableContainerProps.style)
@@ -3637,7 +3659,6 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
3637
3659
  getSubRows: function getSubRows(row) {
3638
3660
  return row == null ? void 0 : row.subRows;
3639
3661
  },
3640
- //@ts-ignore
3641
3662
  globalFilterFn: (_MRT_FilterFns$curren = MRT_FilterFns[currentGlobalFilterFn]) != null ? _MRT_FilterFns$curren : MRT_FilterFns.fuzzy,
3642
3663
  initialState: initialState,
3643
3664
  state: _extends({
@@ -3673,6 +3694,9 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
3673
3694
  setShowGlobalFilter: (_props$onShowGlobalFi = props.onShowGlobalFilterChange) != null ? _props$onShowGlobalFi : setShowGlobalFilter
3674
3695
  });
3675
3696
 
3697
+ React.useEffect(function () {
3698
+ return props == null ? void 0 : props.onTableInstanceChange == null ? void 0 : props.onTableInstanceChange(table);
3699
+ }, [table]);
3676
3700
  return React__default.createElement(React__default.Fragment, null, React__default.createElement(material.Dialog, {
3677
3701
  PaperComponent: material.Box,
3678
3702
  TransitionComponent: material.Grow,