@cutting/material-react-table 5.0.0-beta.2 → 5.1.0

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.
Files changed (190) hide show
  1. package/README.md +1 -4
  2. package/dist/index.d.ts +189 -524
  3. package/dist/index.js +329 -345
  4. package/dist/index.js.map +1 -1
  5. package/locales/ar/index.mjs +1 -2
  6. package/locales/az/index.mjs +1 -2
  7. package/locales/bg/index.mjs +1 -2
  8. package/locales/cs/index.mjs +1 -2
  9. package/locales/da/index.mjs +1 -2
  10. package/locales/de/index.mjs +1 -2
  11. package/locales/el/index.mjs +1 -2
  12. package/locales/en/index.mjs +1 -2
  13. package/locales/es/index.mjs +1 -2
  14. package/locales/et/index.mjs +1 -2
  15. package/locales/fa/index.mjs +1 -2
  16. package/locales/fi/index.mjs +1 -2
  17. package/locales/fr/index.mjs +1 -2
  18. package/locales/he/index.mjs +1 -2
  19. package/locales/hr/index.mjs +1 -2
  20. package/locales/hu/index.mjs +1 -2
  21. package/locales/hy/index.mjs +1 -2
  22. package/locales/id/index.mjs +1 -2
  23. package/locales/it/index.mjs +1 -2
  24. package/locales/ja/index.mjs +1 -2
  25. package/locales/ko/index.mjs +1 -2
  26. package/locales/nl/index.mjs +1 -2
  27. package/locales/no/index.mjs +1 -2
  28. package/locales/np/index.mjs +1 -2
  29. package/locales/pl/index.mjs +1 -2
  30. package/locales/pt/index.mjs +1 -2
  31. package/locales/pt-BR/index.mjs +1 -2
  32. package/locales/ro/index.mjs +1 -2
  33. package/locales/ru/index.mjs +1 -2
  34. package/locales/sk/index.mjs +1 -2
  35. package/locales/sr-Cyrl-RS/index.mjs +1 -2
  36. package/locales/sr-Latn-RS/index.mjs +1 -2
  37. package/locales/sv/index.mjs +1 -2
  38. package/locales/tr/index.mjs +1 -2
  39. package/locales/uk/index.mjs +1 -2
  40. package/locales/vi/index.mjs +1 -2
  41. package/locales/zh-Hans/index.mjs +1 -2
  42. package/locales/zh-Hant/index.mjs +1 -2
  43. package/package.json +32 -40
  44. package/src/MaterialReactTable.smoke.test.tsx +3 -9
  45. package/src/components/MaterialReactTable.tsx +13 -21
  46. package/src/components/body/MRT_TableBody.tsx +67 -82
  47. package/src/components/body/MRT_TableBodyCell.tsx +38 -80
  48. package/src/components/body/MRT_TableBodyCellValue.tsx +5 -14
  49. package/src/components/body/MRT_TableBodyRow.tsx +55 -102
  50. package/src/components/body/MRT_TableBodyRowGrabHandle.test.tsx +2 -6
  51. package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +4 -9
  52. package/src/components/body/MRT_TableBodyRowPinButton.tsx +8 -14
  53. package/src/components/body/MRT_TableDetailPanel.test.tsx +3 -9
  54. package/src/components/body/MRT_TableDetailPanel.tsx +8 -14
  55. package/src/components/buttons/MRT_ColumnPinningButtons.test.tsx +6 -16
  56. package/src/components/buttons/MRT_ColumnPinningButtons.tsx +6 -12
  57. package/src/components/buttons/MRT_CopyButton.tsx +7 -15
  58. package/src/components/buttons/MRT_EditActionButtons.test.tsx +2 -6
  59. package/src/components/buttons/MRT_EditActionButtons.tsx +15 -37
  60. package/src/components/buttons/MRT_ExpandAllButton.tsx +8 -16
  61. package/src/components/buttons/MRT_ExpandButton.tsx +9 -21
  62. package/src/components/buttons/MRT_GrabHandleButton.tsx +6 -10
  63. package/src/components/buttons/MRT_RowPinButton.tsx +8 -23
  64. package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +5 -18
  65. package/src/components/buttons/MRT_ToggleDensePaddingButton.test.tsx +4 -12
  66. package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +4 -11
  67. package/src/components/buttons/MRT_ToggleFiltersButton.test.tsx +4 -13
  68. package/src/components/buttons/MRT_ToggleFiltersButton.tsx +3 -5
  69. package/src/components/buttons/MRT_ToggleFullScreenButton.test.tsx +3 -11
  70. package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +4 -9
  71. package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -5
  72. package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +7 -15
  73. package/src/components/footer/MRT_TableFooter.tsx +9 -16
  74. package/src/components/footer/MRT_TableFooterCell.tsx +9 -32
  75. package/src/components/footer/MRT_TableFooterRow.tsx +18 -32
  76. package/src/components/head/MRT_TableHead.tsx +8 -18
  77. package/src/components/head/MRT_TableHeadCell.tsx +46 -100
  78. package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +10 -30
  79. package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +4 -15
  80. package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +20 -54
  81. package/src/components/head/MRT_TableHeadCellGrabHandle.test.tsx +5 -19
  82. package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +9 -38
  83. package/src/components/head/MRT_TableHeadCellResizeHandle.test.tsx +3 -13
  84. package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +10 -24
  85. package/src/components/head/MRT_TableHeadCellSortLabel.tsx +10 -26
  86. package/src/components/head/MRT_TableHeadRow.tsx +24 -36
  87. package/src/components/inputs/MRT_EditCellTextField.test.tsx +2 -9
  88. package/src/components/inputs/MRT_EditCellTextField.tsx +9 -28
  89. package/src/components/inputs/MRT_FilterCheckbox.tsx +9 -23
  90. package/src/components/inputs/MRT_FilterRangeFields.tsx +6 -15
  91. package/src/components/inputs/MRT_FilterRangeSlider.tsx +24 -32
  92. package/src/components/inputs/MRT_FilterTextField.test.tsx +72 -14
  93. package/src/components/inputs/MRT_FilterTextField.tsx +77 -138
  94. package/src/components/inputs/MRT_GlobalFilterTextField.tsx +10 -32
  95. package/src/components/inputs/MRT_SelectCheckbox.test.tsx +4 -11
  96. package/src/components/inputs/MRT_SelectCheckbox.tsx +17 -36
  97. package/src/components/menus/MRT_ActionMenuItem.tsx +6 -15
  98. package/src/components/menus/MRT_CellActionMenu.tsx +6 -9
  99. package/src/components/menus/MRT_ColumnActionMenu.tsx +22 -57
  100. package/src/components/menus/MRT_FilterOptionMenu.tsx +38 -65
  101. package/src/components/menus/MRT_RowActionMenu.tsx +33 -22
  102. package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +29 -65
  103. package/src/components/menus/MRT_ShowHideColumnsMenuItems.test.tsx +43 -0
  104. package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +14 -50
  105. package/src/components/modals/MRT_EditRowModal.test.tsx +5 -21
  106. package/src/components/modals/MRT_EditRowModal.tsx +8 -26
  107. package/src/components/table/MRT_Table.tsx +12 -20
  108. package/src/components/table/MRT_TableContainer.test.tsx +147 -0
  109. package/src/components/table/MRT_TableContainer.tsx +33 -37
  110. package/src/components/table/MRT_TableLoadingOverlay.tsx +3 -5
  111. package/src/components/table/MRT_TablePaper.tsx +7 -14
  112. package/src/components/toolbar/MRT_BottomToolbar.tsx +11 -23
  113. package/src/components/toolbar/MRT_LinearProgressBar.tsx +4 -11
  114. package/src/components/toolbar/MRT_TablePagination.tsx +33 -40
  115. package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +21 -50
  116. package/src/components/toolbar/MRT_ToolbarDropZone.test.tsx +26 -10
  117. package/src/components/toolbar/MRT_ToolbarDropZone.tsx +23 -21
  118. package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +11 -21
  119. package/src/components/toolbar/MRT_TopToolbar.tsx +12 -28
  120. package/src/fns/aggregationFns.test.tsx +1 -3
  121. package/src/fns/filterFns.test.tsx +9 -37
  122. package/src/fns/filterFns.ts +73 -96
  123. package/src/fns/sortingFns.test.tsx +39 -0
  124. package/src/fns/sortingFns.ts +15 -15
  125. package/src/fns/tableFeatures.test.tsx +6 -29
  126. package/src/fns/tableFeatures.ts +5 -4
  127. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +2 -11
  128. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +2 -10
  129. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +8 -17
  130. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +3 -8
  131. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +2 -8
  132. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +3 -13
  133. package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +1 -5
  134. package/src/hooks/useMRT_ColumnVirtualizer.ts +28 -49
  135. package/src/hooks/useMRT_Effects.test.tsx +114 -0
  136. package/src/hooks/useMRT_Effects.ts +26 -27
  137. package/src/hooks/useMRT_RowVirtualizer.ts +18 -33
  138. package/src/hooks/useMRT_Rows.ts +3 -42
  139. package/src/hooks/useMRT_TableInstance.ts +63 -129
  140. package/src/hooks/useMRT_TableOptions.ts +15 -29
  141. package/src/hooks/useMaterialReactTable.ts +2 -7
  142. package/src/icons.ts +38 -1
  143. package/src/index.ts +0 -4
  144. package/src/locales/ar.ts +1 -2
  145. package/src/locales/az.ts +1 -2
  146. package/src/locales/bg.ts +1 -2
  147. package/src/locales/cs.ts +2 -4
  148. package/src/locales/da.ts +1 -2
  149. package/src/locales/de.ts +1 -2
  150. package/src/locales/el.ts +1 -2
  151. package/src/locales/en.ts +1 -2
  152. package/src/locales/es.ts +1 -2
  153. package/src/locales/et.ts +2 -4
  154. package/src/locales/fa.ts +1 -2
  155. package/src/locales/fi.ts +2 -4
  156. package/src/locales/fr.ts +1 -2
  157. package/src/locales/he.ts +1 -2
  158. package/src/locales/hr.ts +1 -2
  159. package/src/locales/hu.ts +1 -2
  160. package/src/locales/hy.ts +1 -2
  161. package/src/locales/id.ts +2 -4
  162. package/src/locales/it.ts +1 -2
  163. package/src/locales/ja.ts +1 -2
  164. package/src/locales/ko.ts +1 -2
  165. package/src/locales/nl.ts +1 -2
  166. package/src/locales/no.ts +2 -4
  167. package/src/locales/np.ts +2 -4
  168. package/src/locales/pl.ts +1 -2
  169. package/src/locales/pt-BR.ts +1 -2
  170. package/src/locales/pt.ts +1 -2
  171. package/src/locales/ro.ts +1 -2
  172. package/src/locales/ru.ts +1 -2
  173. package/src/locales/sk.ts +2 -4
  174. package/src/locales/sr-Cyrl-RS.ts +1 -2
  175. package/src/locales/sr-Latn-RS.ts +1 -2
  176. package/src/locales/sv.ts +1 -2
  177. package/src/locales/tr.ts +1 -2
  178. package/src/locales/uk.ts +1 -2
  179. package/src/locales/vi.ts +1 -2
  180. package/src/types.ts +156 -349
  181. package/src/utils/cell.utils.ts +30 -68
  182. package/src/utils/column.utils.ts +61 -49
  183. package/src/utils/displayColumn.utils.ts +16 -38
  184. package/src/utils/highlight.utils.ts +7 -11
  185. package/src/utils/row.utils.ts +40 -65
  186. package/src/utils/slotProps.utils.ts +1 -4
  187. package/src/utils/style.utils.ts +18 -46
  188. package/src/utils/tanstack.helpers.ts +10 -17
  189. package/src/utils/utils.ts +6 -10
  190. package/src/utils/virtualization.utils.ts +5 -9
@@ -1,18 +1,10 @@
1
- import { Box, type BoxProps } from '@mui/material';
2
- import { Button } from '@mui/material';
3
- import { CircularProgress } from '@mui/material';
4
- import { IconButton } from '@mui/material';
5
- import { Tooltip } from '@mui/material';
1
+ import { Box, type BoxProps, Button, CircularProgress, IconButton, Tooltip } from '@mui/material';
2
+ import { type CSSObject } from '@mui/material/styles';
6
3
 
7
- import {
8
- type MRT_Row,
9
- type MRT_RowData,
10
- type MRT_TableInstance,
11
- } from '../../types';
4
+ import { type MRT_EditValues, type MRT_Row, type MRT_RowData, type MRT_TableInstance } from '../../types';
12
5
  import { parseFromValuesOrFunc } from '../../utils/utils';
13
6
 
14
- export interface MRT_EditActionButtonsProps<TData extends MRT_RowData>
15
- extends BoxProps {
7
+ export interface MRT_EditActionButtonsProps<TData extends MRT_RowData> extends BoxProps {
16
8
  row: MRT_Row<TData>;
17
9
  table: MRT_TableInstance<TData>;
18
10
  variant?: 'icon' | 'text';
@@ -23,7 +15,7 @@ export const MRT_EditActionButtons = <TData extends MRT_RowData>({
23
15
  table,
24
16
  variant = 'icon',
25
17
  ...rest
26
- }: MRT_EditActionButtonsProps<TData>) => {
18
+ }: MRT_EditActionButtonsProps<TData>): JSX.Element => {
27
19
  const {
28
20
  options: {
29
21
  icons: { CancelIcon, SaveIcon },
@@ -50,7 +42,7 @@ export const MRT_EditActionButtons = <TData extends MRT_RowData>({
50
42
  onEditingRowCancel?.({ row, table });
51
43
  setEditingRow(null);
52
44
  }
53
- row._valuesCache = {} as any; //reset values cache
45
+ row._valuesCache = {}; //reset values cache
54
46
  };
55
47
 
56
48
  const handleSubmitRow = () => {
@@ -58,26 +50,23 @@ export const MRT_EditActionButtons = <TData extends MRT_RowData>({
58
50
  Object.values(editInputRefs.current ?? {})
59
51
  .filter((inputRef) => row.id === inputRef?.name?.split('_')?.[0])
60
52
  ?.forEach((input) => {
61
- if (
62
- input.value !== undefined &&
63
- Object.hasOwn(row?._valuesCache as object, input.name)
64
- ) {
53
+ if (input.value !== undefined && Object.hasOwn(row?._valuesCache as object, input.name)) {
65
54
  row._valuesCache[input.name] = input.value;
66
55
  }
67
56
  });
68
- if (isCreating)
57
+ if (isCreating) {
69
58
  onCreatingRowSave?.({
70
59
  exitCreatingMode: () => setCreatingRow(null),
71
60
  row,
72
61
  table,
73
- values: row._valuesCache,
62
+ values: row._valuesCache as MRT_EditValues<TData>,
74
63
  });
75
- else if (isEditing) {
64
+ } else if (isEditing) {
76
65
  onEditingRowSave?.({
77
66
  exitEditingMode: () => setEditingRow(null),
78
67
  row,
79
68
  table,
80
- values: row?._valuesCache,
69
+ values: row._valuesCache as MRT_EditValues<TData>,
81
70
  });
82
71
  }
83
72
  };
@@ -88,7 +77,7 @@ export const MRT_EditActionButtons = <TData extends MRT_RowData>({
88
77
  sx={(theme) => ({
89
78
  display: 'flex',
90
79
  gap: '0.75rem',
91
- ...(parseFromValuesOrFunc(rest?.sx, theme) as any),
80
+ ...(parseFromValuesOrFunc(rest?.sx, theme) as CSSObject),
92
81
  })}
93
82
  >
94
83
  {variant === 'icon' ? (
@@ -98,15 +87,9 @@ export const MRT_EditActionButtons = <TData extends MRT_RowData>({
98
87
  <CancelIcon />
99
88
  </IconButton>
100
89
  </Tooltip>
101
- {((isCreating && onCreatingRowSave) ||
102
- (isEditing && onEditingRowSave)) && (
90
+ {((isCreating && onCreatingRowSave) || (isEditing && onEditingRowSave)) && (
103
91
  <Tooltip title={localization.save}>
104
- <IconButton
105
- aria-label={localization.save}
106
- color="info"
107
- disabled={isSaving}
108
- onClick={handleSubmitRow}
109
- >
92
+ <IconButton aria-label={localization.save} color="info" disabled={isSaving} onClick={handleSubmitRow}>
110
93
  {isSaving ? <CircularProgress size={18} /> : <SaveIcon />}
111
94
  </IconButton>
112
95
  </Tooltip>
@@ -117,12 +100,7 @@ export const MRT_EditActionButtons = <TData extends MRT_RowData>({
117
100
  <Button onClick={handleCancel} sx={{ minWidth: '100px' }}>
118
101
  {localization.cancel}
119
102
  </Button>
120
- <Button
121
- disabled={isSaving}
122
- onClick={handleSubmitRow}
123
- sx={{ minWidth: '100px' }}
124
- variant="contained"
125
- >
103
+ <Button disabled={isSaving} onClick={handleSubmitRow} sx={{ minWidth: '100px' }} variant="contained">
126
104
  {isSaving && <CircularProgress color="inherit" size={18} />}
127
105
  {localization.save}
128
106
  </Button>
@@ -1,19 +1,18 @@
1
- import { IconButton, type IconButtonProps } from '@mui/material';
2
- import { Tooltip } from '@mui/material';
1
+ import { IconButton, type IconButtonProps, Tooltip } from '@mui/material';
2
+ import { type CSSObject } from '@mui/material/styles';
3
3
 
4
4
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
5
5
  import { getCommonTooltipProps } from '../../utils/style.utils';
6
6
  import { parseFromValuesOrFunc } from '../../utils/utils';
7
7
 
8
- export interface MRT_ExpandAllButtonProps<TData extends MRT_RowData>
9
- extends IconButtonProps {
8
+ export interface MRT_ExpandAllButtonProps<TData extends MRT_RowData> extends IconButtonProps {
10
9
  table: MRT_TableInstance<TData>;
11
10
  }
12
11
 
13
12
  export const MRT_ExpandAllButton = <TData extends MRT_RowData>({
14
13
  table,
15
14
  ...rest
16
- }: MRT_ExpandAllButtonProps<TData>) => {
15
+ }: MRT_ExpandAllButtonProps<TData>): JSX.Element => {
17
16
  const {
18
17
  getCanSomeRowsExpand,
19
18
  getIsAllRowsExpanded,
@@ -40,33 +39,26 @@ export const MRT_ExpandAllButton = <TData extends MRT_RowData>({
40
39
  return (
41
40
  <Tooltip
42
41
  {...getCommonTooltipProps()}
43
- title={
44
- iconButtonProps?.title ??
45
- (isAllRowsExpanded ? localization.collapseAll : localization.expandAll)
46
- }
42
+ title={iconButtonProps?.title ?? (isAllRowsExpanded ? localization.collapseAll : localization.expandAll)}
47
43
  >
48
44
  <span>
49
45
  <IconButton
50
46
  aria-label={localization.expandAll}
51
- disabled={
52
- isLoading || (!renderDetailPanel && !getCanSomeRowsExpand())
53
- }
47
+ disabled={isLoading || (!renderDetailPanel && !getCanSomeRowsExpand())}
54
48
  onClick={() => toggleAllRowsExpanded(!isAllRowsExpanded)}
55
49
  {...iconButtonProps}
56
50
  sx={(theme) => ({
57
51
  height: density === 'compact' ? '1.75rem' : '2.25rem',
58
52
  mt: density !== 'compact' ? '-0.25rem' : undefined,
59
53
  width: density === 'compact' ? '1.75rem' : '2.25rem',
60
- ...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any),
54
+ ...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as CSSObject),
61
55
  })}
62
56
  title={undefined}
63
57
  >
64
58
  {iconButtonProps?.children ?? (
65
59
  <KeyboardDoubleArrowDownIcon
66
60
  style={{
67
- transform: `rotate(${
68
- isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0
69
- }deg)`,
61
+ transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
70
62
  transition: 'transform 150ms',
71
63
  }}
72
64
  />
@@ -1,18 +1,12 @@
1
- import { IconButton, type IconButtonProps } from '@mui/material';
2
- import { Tooltip } from '@mui/material';
3
- import { useTheme } from '@mui/material/styles';
1
+ import { IconButton, type IconButtonProps, Tooltip } from '@mui/material';
2
+ import { type CSSObject, useTheme } from '@mui/material/styles';
4
3
  import { type MouseEvent } from 'react';
5
4
 
6
- import {
7
- type MRT_Row,
8
- type MRT_RowData,
9
- type MRT_TableInstance,
10
- } from '../../types';
5
+ import { type MRT_Row, type MRT_RowData, type MRT_TableInstance } from '../../types';
11
6
  import { getCommonTooltipProps } from '../../utils/style.utils';
12
7
  import { parseFromValuesOrFunc } from '../../utils/utils';
13
8
 
14
- export interface MRT_ExpandButtonProps<TData extends MRT_RowData>
15
- extends IconButtonProps {
9
+ export interface MRT_ExpandButtonProps<TData extends MRT_RowData> extends IconButtonProps {
16
10
  row: MRT_Row<TData>;
17
11
  staticRowIndex?: number;
18
12
  table: MRT_TableInstance<TData>;
@@ -22,7 +16,7 @@ export const MRT_ExpandButton = <TData extends MRT_RowData>({
22
16
  row,
23
17
  staticRowIndex,
24
18
  table,
25
- }: MRT_ExpandButtonProps<TData>) => {
19
+ }: MRT_ExpandButtonProps<TData>): JSX.Element => {
26
20
  const theme = useTheme();
27
21
  const {
28
22
  options: {
@@ -56,10 +50,7 @@ export const MRT_ExpandButton = <TData extends MRT_RowData>({
56
50
  <Tooltip
57
51
  disableHoverListener={!canExpand && !detailPanel}
58
52
  {...getCommonTooltipProps()}
59
- title={
60
- iconButtonProps?.title ??
61
- (isExpanded ? localization.collapse : localization.expand)
62
- }
53
+ title={iconButtonProps?.title ?? (isExpanded ? localization.collapse : localization.expand)}
63
54
  >
64
55
  <span>
65
56
  <IconButton
@@ -70,11 +61,9 @@ export const MRT_ExpandButton = <TData extends MRT_RowData>({
70
61
  sx={(theme) => ({
71
62
  height: density === 'compact' ? '1.75rem' : '2.25rem',
72
63
  opacity: !canExpand && !detailPanel ? 0.3 : 1,
73
- [theme.direction === 'rtl' || positionExpandColumn === 'last'
74
- ? 'mr'
75
- : 'ml']: `${row.depth * 16}px`,
64
+ [theme.direction === 'rtl' || positionExpandColumn === 'last' ? 'mr' : 'ml']: `${row.depth * 16}px`,
76
65
  width: density === 'compact' ? '1.75rem' : '2.25rem',
77
- ...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any),
66
+ ...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as CSSObject),
78
67
  })}
79
68
  title={undefined}
80
69
  >
@@ -83,8 +72,7 @@ export const MRT_ExpandButton = <TData extends MRT_RowData>({
83
72
  style={{
84
73
  transform: `rotate(${
85
74
  !canExpand && !renderDetailPanel
86
- ? positionExpandColumn === 'last' ||
87
- theme.direction === 'rtl'
75
+ ? positionExpandColumn === 'last' || theme.direction === 'rtl'
88
76
  ? 90
89
77
  : -90
90
78
  : isExpanded
@@ -1,13 +1,12 @@
1
- import { IconButton, type IconButtonProps } from '@mui/material';
2
- import { Tooltip } from '@mui/material';
1
+ import { IconButton, type IconButtonProps, Tooltip } from '@mui/material';
2
+ import { type CSSObject } from '@mui/material/styles';
3
3
  import { type DragEventHandler } from 'react';
4
4
 
5
5
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
6
6
  import { getCommonTooltipProps } from '../../utils/style.utils';
7
7
  import { parseFromValuesOrFunc } from '../../utils/utils';
8
8
 
9
- export interface MRT_GrabHandleButtonProps<TData extends MRT_RowData>
10
- extends IconButtonProps {
9
+ export interface MRT_GrabHandleButtonProps<TData extends MRT_RowData> extends IconButtonProps {
11
10
  iconButtonProps?: IconButtonProps;
12
11
  location?: 'column' | 'row';
13
12
  onDragEnd: DragEventHandler<HTMLButtonElement>;
@@ -19,7 +18,7 @@ export const MRT_GrabHandleButton = <TData extends MRT_RowData>({
19
18
  location,
20
19
  table,
21
20
  ...rest
22
- }: MRT_GrabHandleButtonProps<TData>) => {
21
+ }: MRT_GrabHandleButtonProps<TData>): JSX.Element => {
23
22
  const {
24
23
  options: {
25
24
  icons: { DragHandleIcon },
@@ -28,10 +27,7 @@ export const MRT_GrabHandleButton = <TData extends MRT_RowData>({
28
27
  } = table;
29
28
 
30
29
  return (
31
- <Tooltip
32
- {...getCommonTooltipProps('top')}
33
- title={rest?.title ?? localization.move}
34
- >
30
+ <Tooltip {...getCommonTooltipProps('top')} title={rest?.title ?? localization.move}>
35
31
  <IconButton
36
32
  aria-label={rest.title ?? localization.move}
37
33
  disableRipple
@@ -55,7 +51,7 @@ export const MRT_GrabHandleButton = <TData extends MRT_RowData>({
55
51
  opacity: location === 'row' ? 1 : 0.5,
56
52
  p: '2px',
57
53
  transition: 'all 150ms ease-in-out',
58
- ...(parseFromValuesOrFunc(rest?.sx, theme) as any),
54
+ ...(parseFromValuesOrFunc(rest?.sx, theme) as CSSObject),
59
55
  })}
60
56
  title={undefined}
61
57
  >
@@ -1,18 +1,13 @@
1
- import { IconButton, type IconButtonProps } from '@mui/material';
2
- import { Tooltip } from '@mui/material';
1
+ import { IconButton, type IconButtonProps, Tooltip } from '@mui/material';
2
+ import { type CSSObject } from '@mui/material/styles';
3
3
  import { type RowPinningPosition } from '@tanstack/react-table';
4
4
  import { type MouseEvent, useState } from 'react';
5
5
 
6
- import {
7
- type MRT_Row,
8
- type MRT_RowData,
9
- type MRT_TableInstance,
10
- } from '../../types';
6
+ import { type MRT_Row, type MRT_RowData, type MRT_TableInstance } from '../../types';
11
7
  import { getCommonTooltipProps } from '../../utils/style.utils';
12
8
  import { parseFromValuesOrFunc } from '../../utils/utils';
13
9
 
14
- export interface MRT_RowPinButtonProps<TData extends MRT_RowData>
15
- extends IconButtonProps {
10
+ export interface MRT_RowPinButtonProps<TData extends MRT_RowData> extends IconButtonProps {
16
11
  pinningPosition: RowPinningPosition;
17
12
  row: MRT_Row<TData>;
18
13
  table: MRT_TableInstance<TData>;
@@ -23,7 +18,7 @@ export const MRT_RowPinButton = <TData extends MRT_RowData>({
23
18
  row,
24
19
  table,
25
20
  ...rest
26
- }: MRT_RowPinButtonProps<TData>) => {
21
+ }: MRT_RowPinButtonProps<TData>): JSX.Element => {
27
22
  const {
28
23
  options: {
29
24
  icons: { CloseIcon, PushPinIcon },
@@ -43,11 +38,7 @@ export const MRT_RowPinButton = <TData extends MRT_RowData>({
43
38
  };
44
39
 
45
40
  return (
46
- <Tooltip
47
- {...getCommonTooltipProps()}
48
- open={tooltipOpened}
49
- title={isPinned ? localization.unpin : localization.pin}
50
- >
41
+ <Tooltip {...getCommonTooltipProps()} open={tooltipOpened} title={isPinned ? localization.unpin : localization.pin}>
51
42
  <IconButton
52
43
  aria-label={localization.pin}
53
44
  onBlur={() => setTooltipOpened(false)}
@@ -60,7 +51,7 @@ export const MRT_RowPinButton = <TData extends MRT_RowData>({
60
51
  sx={(theme) => ({
61
52
  height: '24px',
62
53
  width: '24px',
63
- ...(parseFromValuesOrFunc(rest?.sx, theme) as any),
54
+ ...(parseFromValuesOrFunc(rest?.sx, theme) as CSSObject),
64
55
  })}
65
56
  >
66
57
  {isPinned ? (
@@ -69,13 +60,7 @@ export const MRT_RowPinButton = <TData extends MRT_RowData>({
69
60
  <PushPinIcon
70
61
  fontSize="small"
71
62
  style={{
72
- transform: `rotate(${
73
- rowPinningDisplayMode === 'sticky'
74
- ? 135
75
- : pinningPosition === 'top'
76
- ? 180
77
- : 0
78
- }deg)`,
63
+ transform: `rotate(${rowPinningDisplayMode === 'sticky' ? 135 : pinningPosition === 'top' ? 180 : 0}deg)`,
79
64
  }}
80
65
  />
81
66
  )}
@@ -1,19 +1,17 @@
1
- import { IconButton, type IconButtonProps } from '@mui/material';
2
- import { Tooltip } from '@mui/material';
1
+ import { IconButton, type IconButtonProps, Tooltip } from '@mui/material';
3
2
  import { type MouseEvent, useState } from 'react';
4
3
 
5
4
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
6
5
  import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
7
6
 
8
- export interface MRT_ShowHideColumnsButtonProps<TData extends MRT_RowData>
9
- extends IconButtonProps {
7
+ export interface MRT_ShowHideColumnsButtonProps<TData extends MRT_RowData> extends IconButtonProps {
10
8
  table: MRT_TableInstance<TData>;
11
9
  }
12
10
 
13
11
  export const MRT_ShowHideColumnsButton = <TData extends MRT_RowData>({
14
12
  table,
15
13
  ...rest
16
- }: MRT_ShowHideColumnsButtonProps<TData>) => {
14
+ }: MRT_ShowHideColumnsButtonProps<TData>): JSX.Element => {
17
15
  const {
18
16
  options: {
19
17
  icons: { ViewColumnIcon },
@@ -30,22 +28,11 @@ export const MRT_ShowHideColumnsButton = <TData extends MRT_RowData>({
30
28
  return (
31
29
  <>
32
30
  <Tooltip title={rest?.title ?? localization.showHideColumns}>
33
- <IconButton
34
- aria-label={localization.showHideColumns}
35
- onClick={handleClick}
36
- {...rest}
37
- title={undefined}
38
- >
31
+ <IconButton aria-label={localization.showHideColumns} onClick={handleClick} {...rest} title={undefined}>
39
32
  <ViewColumnIcon />
40
33
  </IconButton>
41
34
  </Tooltip>
42
- {anchorEl && (
43
- <MRT_ShowHideColumnsMenu
44
- anchorEl={anchorEl}
45
- setAnchorEl={setAnchorEl}
46
- table={table}
47
- />
48
- )}
35
+ {anchorEl && <MRT_ShowHideColumnsMenu anchorEl={anchorEl} setAnchorEl={setAnchorEl} table={table} />}
49
36
  </>
50
37
  );
51
38
  };
@@ -11,27 +11,19 @@ interface Person {
11
11
 
12
12
  const data: Person[] = [{ name: 'Alice' }];
13
13
 
14
- const columns = (): MRT_ColumnDef<Person>[] => [
15
- { accessorKey: 'name', header: 'Name' },
16
- ];
14
+ const columns = (): MRT_ColumnDef<Person>[] => [{ accessorKey: 'name', header: 'Name' }];
17
15
 
18
16
  const bodyCellPadding = (container: HTMLElement) =>
19
- getComputedStyle(
20
- container.querySelector('tbody td') as HTMLElement,
21
- ).getPropertyValue('padding');
17
+ getComputedStyle(container.querySelector('tbody td') as HTMLElement).getPropertyValue('padding');
22
18
 
23
19
  describe('density toggle', () => {
24
20
  test('changes body cell padding when clicked', async () => {
25
21
  const user = userEvent.setup();
26
- const { container } = render(
27
- <MaterialReactTable columns={columns()} data={data} />,
28
- );
22
+ const { container } = render(<MaterialReactTable columns={columns()} data={data} />);
29
23
 
30
24
  const before = bodyCellPadding(container);
31
25
 
32
- await user.click(
33
- container.querySelector('[aria-label="Toggle density"]') as HTMLElement,
34
- );
26
+ await user.click(container.querySelector('[aria-label="Toggle density"]') as HTMLElement);
35
27
 
36
28
  expect(bodyCellPadding(container)).not.toBe(before);
37
29
  });
@@ -1,17 +1,15 @@
1
- import { IconButton, type IconButtonProps } from '@mui/material';
2
- import { Tooltip } from '@mui/material';
1
+ import { IconButton, type IconButtonProps, Tooltip } from '@mui/material';
3
2
 
4
3
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
5
4
 
6
- export interface MRT_ToggleDensePaddingButtonProps<TData extends MRT_RowData>
7
- extends IconButtonProps {
5
+ export interface MRT_ToggleDensePaddingButtonProps<TData extends MRT_RowData> extends IconButtonProps {
8
6
  table: MRT_TableInstance<TData>;
9
7
  }
10
8
 
11
9
  export const MRT_ToggleDensePaddingButton = <TData extends MRT_RowData>({
12
10
  table,
13
11
  ...rest
14
- }: MRT_ToggleDensePaddingButtonProps<TData>) => {
12
+ }: MRT_ToggleDensePaddingButtonProps<TData>): JSX.Element => {
15
13
  const {
16
14
  options: {
17
15
  icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon },
@@ -22,12 +20,7 @@ export const MRT_ToggleDensePaddingButton = <TData extends MRT_RowData>({
22
20
  const { density } = table.state;
23
21
 
24
22
  const handleToggleDensePadding = () => {
25
- const nextDensity =
26
- density === 'comfortable'
27
- ? 'compact'
28
- : density === 'compact'
29
- ? 'spacious'
30
- : 'comfortable';
23
+ const nextDensity = density === 'comfortable' ? 'compact' : density === 'compact' ? 'spacious' : 'comfortable';
31
24
  setDensity(nextDensity);
32
25
  };
33
26
 
@@ -11,27 +11,18 @@ interface Person {
11
11
 
12
12
  const data: Person[] = [{ name: 'Alice' }];
13
13
 
14
- const columns = (): MRT_ColumnDef<Person>[] => [
15
- { accessorKey: 'name', header: 'Name' },
16
- ];
14
+ const columns = (): MRT_ColumnDef<Person>[] => [{ accessorKey: 'name', header: 'Name' }];
17
15
 
18
- const filterInputCount = (container: HTMLElement) =>
19
- container.querySelectorAll('thead input').length;
16
+ const filterInputCount = (container: HTMLElement) => container.querySelectorAll('thead input').length;
20
17
 
21
18
  describe('filters toggle', () => {
22
19
  test('reveals the column filter inputs when clicked', async () => {
23
20
  const user = userEvent.setup();
24
- const { container } = render(
25
- <MaterialReactTable columns={columns()} data={data} />,
26
- );
21
+ const { container } = render(<MaterialReactTable columns={columns()} data={data} />);
27
22
 
28
23
  expect(filterInputCount(container)).toBe(0);
29
24
 
30
- await user.click(
31
- container.querySelector(
32
- '[aria-label="Show/Hide filters"]',
33
- ) as HTMLElement,
34
- );
25
+ await user.click(container.querySelector('[aria-label="Show/Hide filters"]') as HTMLElement);
35
26
 
36
27
  expect(filterInputCount(container)).toBeGreaterThan(0);
37
28
  });
@@ -1,17 +1,15 @@
1
- import { IconButton, type IconButtonProps } from '@mui/material';
2
- import { Tooltip } from '@mui/material';
1
+ import { IconButton, type IconButtonProps, Tooltip } from '@mui/material';
3
2
 
4
3
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
5
4
 
6
- export interface MRT_ToggleFiltersButtonProps<TData extends MRT_RowData>
7
- extends IconButtonProps {
5
+ export interface MRT_ToggleFiltersButtonProps<TData extends MRT_RowData> extends IconButtonProps {
8
6
  table: MRT_TableInstance<TData>;
9
7
  }
10
8
 
11
9
  export const MRT_ToggleFiltersButton = <TData extends MRT_RowData>({
12
10
  table,
13
11
  ...rest
14
- }: MRT_ToggleFiltersButtonProps<TData>) => {
12
+ }: MRT_ToggleFiltersButtonProps<TData>): JSX.Element => {
15
13
  const {
16
14
  options: {
17
15
  icons: { FilterListIcon, FilterListOffIcon },
@@ -11,25 +11,17 @@ interface Person {
11
11
 
12
12
  const data: Person[] = [{ name: 'Alice' }];
13
13
 
14
- const columns = (): MRT_ColumnDef<Person>[] => [
15
- { accessorKey: 'name', header: 'Name' },
16
- ];
14
+ const columns = (): MRT_ColumnDef<Person>[] => [{ accessorKey: 'name', header: 'Name' }];
17
15
 
18
16
  describe('full screen toggle', () => {
19
17
  test('fixes the table paper to the viewport when clicked', async () => {
20
18
  const user = userEvent.setup();
21
- const { container } = render(
22
- <MaterialReactTable columns={columns()} data={data} />,
23
- );
19
+ const { container } = render(<MaterialReactTable columns={columns()} data={data} />);
24
20
 
25
21
  const paper = container.firstElementChild as HTMLElement;
26
22
  expect(getComputedStyle(paper).position).not.toBe('fixed');
27
23
 
28
- await user.click(
29
- container.querySelector(
30
- '[aria-label="Toggle full screen"]',
31
- ) as HTMLElement,
32
- );
24
+ await user.click(container.querySelector('[aria-label="Toggle full screen"]') as HTMLElement);
33
25
 
34
26
  expect(getComputedStyle(paper).position).toBe('fixed');
35
27
  });
@@ -1,18 +1,16 @@
1
- import { IconButton, type IconButtonProps } from '@mui/material';
2
- import { Tooltip } from '@mui/material';
1
+ import { IconButton, type IconButtonProps, Tooltip } from '@mui/material';
3
2
  import { useState } from 'react';
4
3
 
5
4
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
6
5
 
7
- export interface MRT_ToggleFullScreenButtonProps<TData extends MRT_RowData>
8
- extends IconButtonProps {
6
+ export interface MRT_ToggleFullScreenButtonProps<TData extends MRT_RowData> extends IconButtonProps {
9
7
  table: MRT_TableInstance<TData>;
10
8
  }
11
9
 
12
10
  export const MRT_ToggleFullScreenButton = <TData extends MRT_RowData>({
13
11
  table,
14
12
  ...rest
15
- }: MRT_ToggleFullScreenButtonProps<TData>) => {
13
+ }: MRT_ToggleFullScreenButtonProps<TData>): JSX.Element => {
16
14
  const {
17
15
  options: {
18
16
  icons: { FullscreenExitIcon, FullscreenIcon },
@@ -30,10 +28,7 @@ export const MRT_ToggleFullScreenButton = <TData extends MRT_RowData>({
30
28
  };
31
29
 
32
30
  return (
33
- <Tooltip
34
- open={tooltipOpened}
35
- title={rest?.title ?? localization.toggleFullScreen}
36
- >
31
+ <Tooltip open={tooltipOpened} title={rest?.title ?? localization.toggleFullScreen}>
37
32
  <IconButton
38
33
  aria-label={localization.toggleFullScreen}
39
34
  onBlur={() => setTooltipOpened(false)}
@@ -1,17 +1,15 @@
1
- import { IconButton, type IconButtonProps } from '@mui/material';
2
- import { Tooltip } from '@mui/material';
1
+ import { IconButton, type IconButtonProps, Tooltip } from '@mui/material';
3
2
 
4
3
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
5
4
 
6
- export interface MRT_ToggleGlobalFilterButtonProps<TData extends MRT_RowData>
7
- extends IconButtonProps {
5
+ export interface MRT_ToggleGlobalFilterButtonProps<TData extends MRT_RowData> extends IconButtonProps {
8
6
  table: MRT_TableInstance<TData>;
9
7
  }
10
8
 
11
9
  export const MRT_ToggleGlobalFilterButton = <TData extends MRT_RowData>({
12
10
  table,
13
11
  ...rest
14
- }: MRT_ToggleGlobalFilterButtonProps<TData>) => {
12
+ }: MRT_ToggleGlobalFilterButtonProps<TData>): JSX.Element => {
15
13
  const {
16
14
  options: {
17
15
  icons: { SearchIcon, SearchOffIcon },