material-react-table 0.3.3 → 0.4.1

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 (67) hide show
  1. package/dist/MaterialReactTable.d.ts +15 -7
  2. package/dist/body/MRT_TableBodyCell.d.ts +3 -0
  3. package/dist/buttons/MRT_FullScreenToggleButton.d.ts +4 -0
  4. package/dist/buttons/MRT_ToggleSearchButton.d.ts +4 -0
  5. package/dist/head/MRT_TableHeadCell.d.ts +1 -1
  6. package/dist/head/MRT_TableHeadCellActions.d.ts +5 -0
  7. package/dist/inputs/{MRT_EditCellTextfield.d.ts → MRT_EditCellTextField.d.ts} +1 -1
  8. package/dist/inputs/MRT_FilterTextField.d.ts +1 -1
  9. package/dist/material-react-table.cjs.development.js +604 -372
  10. package/dist/material-react-table.cjs.development.js.map +1 -1
  11. package/dist/material-react-table.cjs.production.min.js +1 -1
  12. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  13. package/dist/material-react-table.esm.js +607 -375
  14. package/dist/material-react-table.esm.js.map +1 -1
  15. package/dist/menus/MRT_ColumnActionMenu.d.ts +2 -2
  16. package/dist/menus/MRT_RowActionMenu.d.ts +1 -0
  17. package/dist/table/MRT_TableButtonCell.d.ts +3 -0
  18. package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +5 -0
  19. package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +5 -0
  20. package/dist/{useMaterialReactTable.d.ts → useMRT.d.ts} +8 -3
  21. package/dist/utils/localization.d.ts +8 -0
  22. package/package.json +21 -19
  23. package/src/@types/react-table-config.d.ts +37 -34
  24. package/src/MaterialReactTable.tsx +22 -6
  25. package/src/body/MRT_TableBody.tsx +2 -3
  26. package/src/body/MRT_TableBodyCell.tsx +8 -8
  27. package/src/body/MRT_TableBodyRow.tsx +13 -15
  28. package/src/body/MRT_TableDetailPanel.tsx +2 -2
  29. package/src/buttons/MRT_EditActionButtons.tsx +3 -2
  30. package/src/buttons/MRT_ExpandAllButton.tsx +8 -16
  31. package/src/buttons/MRT_ExpandButton.tsx +8 -9
  32. package/src/buttons/MRT_FullScreenToggleButton.tsx +23 -0
  33. package/src/buttons/MRT_ShowHideColumnsButton.tsx +34 -3
  34. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +5 -5
  35. package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
  36. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +48 -26
  37. package/src/buttons/MRT_ToggleSearchButton.tsx +33 -0
  38. package/src/footer/MRT_TableFooter.tsx +2 -2
  39. package/src/footer/MRT_TableFooterCell.tsx +2 -2
  40. package/src/footer/MRT_TableFooterRow.tsx +9 -4
  41. package/src/head/MRT_TableHead.tsx +2 -2
  42. package/src/head/MRT_TableHeadCell.tsx +20 -16
  43. package/src/head/MRT_TableHeadCellActions.tsx +18 -0
  44. package/src/head/MRT_TableHeadRow.tsx +16 -11
  45. package/src/inputs/MRT_DensePaddingSwitch.tsx +5 -3
  46. package/src/inputs/{MRT_EditCellTextfield.tsx → MRT_EditCellTextField.tsx} +23 -16
  47. package/src/inputs/MRT_FilterTextField.tsx +43 -17
  48. package/src/inputs/MRT_SearchTextField.tsx +39 -34
  49. package/src/inputs/MRT_SelectAllCheckbox.tsx +9 -13
  50. package/src/inputs/MRT_SelectCheckbox.tsx +11 -14
  51. package/src/menus/MRT_ColumnActionMenu.tsx +66 -23
  52. package/src/menus/MRT_RowActionMenu.tsx +4 -8
  53. package/src/menus/MRT_ShowHideColumnsMenu.tsx +24 -15
  54. package/src/table/MRT_Table.tsx +2 -2
  55. package/src/table/MRT_TableButtonCell.tsx +9 -0
  56. package/src/table/MRT_TableContainer.tsx +34 -8
  57. package/src/table/MRT_TableSpacerCell.tsx +2 -2
  58. package/src/toolbar/MRT_TablePagination.tsx +3 -2
  59. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +102 -0
  60. package/src/toolbar/MRT_ToolbarBottom.tsx +9 -5
  61. package/src/toolbar/{MRT_ToolbarButtons.tsx → MRT_ToolbarInternalButtons.tsx} +13 -4
  62. package/src/toolbar/MRT_ToolbarTop.tsx +14 -15
  63. package/src/{useMaterialReactTable.tsx → useMRT.tsx} +40 -23
  64. package/src/utils/localization.ts +22 -6
  65. package/dist/toolbar/MRT_ToolbarButtons.d.ts +0 -5
  66. package/dist/utils/useMRTCalcs.d.ts +0 -11
  67. package/src/utils/useMRTCalcs.tsx +0 -42
@@ -0,0 +1,102 @@
1
+ import React, { FC, Fragment } from 'react';
2
+ import {
3
+ Alert as MuiAlert,
4
+ Chip,
5
+ Collapse,
6
+ styled,
7
+ useMediaQuery,
8
+ } from '@mui/material';
9
+ import { useMRT } from '../useMRT';
10
+
11
+ const Alert = styled(MuiAlert, {
12
+ shouldForwardProp: (prop) =>
13
+ prop !== 'displayAbsolute' && prop !== 'toolbarPosition',
14
+ })<{ displayAbsolute?: boolean; toolbarPosition?: 'top' | 'bottom' }>(
15
+ ({ displayAbsolute, toolbarPosition }) => ({
16
+ borderRadius: 0,
17
+ fontSize: '1rem',
18
+ left: 0,
19
+ marginLeft: !displayAbsolute ? '-0.5rem' : undefined,
20
+ padding: toolbarPosition === 'bottom' ? '0 1rem' : '0.5rem 1.25rem',
21
+ position: displayAbsolute ? 'absolute' : 'relative',
22
+ right: 0,
23
+ top: 0,
24
+ width: `calc(100% - ${displayAbsolute ? '2.5rem' : '1.5rem'})`,
25
+ zIndex: 2,
26
+ }),
27
+ );
28
+
29
+ interface Props {}
30
+
31
+ export const MRT_ToolbarAlertBanner: FC<Props> = () => {
32
+ const {
33
+ muiTableToolbarAlertBannerProps,
34
+ tableInstance,
35
+ positionToolbarAlertBanner,
36
+ positionToolbarActions,
37
+ localization,
38
+ renderToolbarCustomActions,
39
+ } = useMRT();
40
+
41
+ const isMobile = useMediaQuery('(max-width:720px)');
42
+
43
+ const alertProps =
44
+ muiTableToolbarAlertBannerProps instanceof Function
45
+ ? muiTableToolbarAlertBannerProps(tableInstance)
46
+ : muiTableToolbarAlertBannerProps;
47
+
48
+ const selectMessage =
49
+ tableInstance.selectedFlatRows.length > 0
50
+ ? localization?.toolbarAlertSelectionMessage
51
+ ?.replace(
52
+ '{selectedCount}',
53
+ tableInstance.selectedFlatRows.length.toString(),
54
+ )
55
+ ?.replace('{rowCount}', tableInstance.flatRows.length.toString())
56
+ : null;
57
+
58
+ const groupedByMessage =
59
+ tableInstance.state.groupBy.length > 0 ? (
60
+ <span>
61
+ {localization?.toolbarAlertGroupedByMessage}{' '}
62
+ {tableInstance.state.groupBy.map((columnId, index) => (
63
+ <Fragment key={`${index}-${columnId}`}>
64
+ {index > 0 ? localization?.toolbarAlertGroupedThenByMessage : ''}
65
+ <Chip
66
+ color="secondary"
67
+ label={
68
+ tableInstance.allColumns.find(
69
+ (column) => column.id === columnId,
70
+ )?.Header
71
+ }
72
+ onDelete={() => tableInstance.toggleGroupBy(columnId, false)}
73
+ />
74
+ </Fragment>
75
+ ))}
76
+ </span>
77
+ ) : null;
78
+
79
+ const displayAbsolute = !(
80
+ isMobile ||
81
+ (positionToolbarAlertBanner === 'bottom' &&
82
+ positionToolbarActions === 'bottom') ||
83
+ (positionToolbarAlertBanner === 'top' && !!renderToolbarCustomActions)
84
+ );
85
+
86
+ return (
87
+ <Collapse
88
+ in={!!selectMessage || !!groupedByMessage}
89
+ timeout={displayAbsolute ? 0 : 200}
90
+ >
91
+ <Alert
92
+ displayAbsolute={displayAbsolute}
93
+ icon={false}
94
+ color="info"
95
+ {...alertProps}
96
+ >
97
+ {selectMessage}
98
+ {groupedByMessage}
99
+ </Alert>
100
+ </Collapse>
101
+ );
102
+ };
@@ -1,13 +1,15 @@
1
1
  import React, { FC } from 'react';
2
2
  import { styled, Toolbar as MuiToolbar } from '@mui/material';
3
- import { useMaterialReactTable } from '../useMaterialReactTable';
3
+ import { useMRT } from '../useMRT';
4
4
  import { MRT_TablePagination } from './MRT_TablePagination';
5
- import { MRT_ToolbarButtons } from './MRT_ToolbarButtons';
5
+ import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
6
+ import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
6
7
 
7
8
  const Toolbar = styled(MuiToolbar)({
8
- padding: 0,
9
9
  display: 'flex',
10
10
  justifyContent: 'space-between',
11
+ padding: '0 0.5rem !important',
12
+ overflowY: 'hidden',
11
13
  });
12
14
 
13
15
  interface Props {}
@@ -19,8 +21,9 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
19
21
  muiTableToolbarBottomProps,
20
22
  positionPagination,
21
23
  positionToolbarActions,
24
+ positionToolbarAlertBanner,
22
25
  tableInstance,
23
- } = useMaterialReactTable();
26
+ } = useMRT();
24
27
 
25
28
  const toolbarProps =
26
29
  muiTableToolbarBottomProps instanceof Function
@@ -30,10 +33,11 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
30
33
  return (
31
34
  <Toolbar variant="dense" {...toolbarProps}>
32
35
  {!hideToolbarActions && positionToolbarActions === 'bottom' ? (
33
- <MRT_ToolbarButtons />
36
+ <MRT_ToolbarInternalButtons />
34
37
  ) : (
35
38
  <span />
36
39
  )}
40
+ {positionToolbarAlertBanner === 'bottom' && <MRT_ToolbarAlertBanner />}
37
41
  {!manualPagination &&
38
42
  ['bottom', 'both'].includes(positionPagination ?? '') && (
39
43
  <MRT_TablePagination />
@@ -2,8 +2,10 @@ import React, { FC } from 'react';
2
2
  import { styled } from '@mui/material';
3
3
  import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
4
4
  import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
5
- import { useMaterialReactTable } from '../useMaterialReactTable';
5
+ import { useMRT } from '../useMRT';
6
6
  import { MRT_DensePaddingSwitch } from '../inputs/MRT_DensePaddingSwitch';
7
+ import { MRT_ToggleSearchButton } from '../buttons/MRT_ToggleSearchButton';
8
+ import { MRT_FullScreenToggleButton } from '../buttons/MRT_FullScreenToggleButton';
7
9
 
8
10
  const ToolbarButtonsContainer = styled('div')({
9
11
  display: 'flex',
@@ -13,15 +15,22 @@ const ToolbarButtonsContainer = styled('div')({
13
15
 
14
16
  interface Props {}
15
17
 
16
- export const MRT_ToolbarButtons: FC<Props> = () => {
17
- const { disableFilters, disableColumnHiding, disableDensePaddingToggle } =
18
- useMaterialReactTable();
18
+ export const MRT_ToolbarInternalButtons: FC<Props> = () => {
19
+ const {
20
+ disableFilters,
21
+ disableColumnHiding,
22
+ disableDensePaddingToggle,
23
+ disableGlobalFilter,
24
+ disableFullScreenToggle,
25
+ } = useMRT();
19
26
 
20
27
  return (
21
28
  <ToolbarButtonsContainer>
29
+ {!disableGlobalFilter && <MRT_ToggleSearchButton />}
22
30
  {!disableFilters && <MRT_ToggleFiltersButton />}
23
31
  {!disableColumnHiding && <MRT_ShowHideColumnsButton />}
24
32
  {!disableDensePaddingToggle && <MRT_DensePaddingSwitch />}
33
+ {!disableFullScreenToggle && <MRT_FullScreenToggleButton />}
25
34
  </ToolbarButtonsContainer>
26
35
  );
27
36
  };
@@ -1,16 +1,18 @@
1
1
  import React, { FC } from 'react';
2
- import { styled, Toolbar as MuiToolbar, Typography } from '@mui/material';
2
+ import { styled, Toolbar as MuiToolbar } from '@mui/material';
3
3
  import { MRT_SearchTextField } from '../inputs/MRT_SearchTextField';
4
- import { useMaterialReactTable } from '../useMaterialReactTable';
5
- import { MRT_ToolbarButtons } from './MRT_ToolbarButtons';
4
+ import { useMRT } from '../useMRT';
5
+ import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
6
6
  import { MRT_TablePagination } from './MRT_TablePagination';
7
+ import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
7
8
 
8
9
  const Toolbar = styled(MuiToolbar)({
9
10
  display: 'grid',
11
+ padding: '0 0.5rem !important',
10
12
  });
11
13
 
12
14
  const ToolbarTopRow = styled('div')({
13
- padding: '0.5rem',
15
+ padding: '1rem 0.5rem',
14
16
  display: 'flex',
15
17
  justifyContent: 'space-between',
16
18
  });
@@ -18,6 +20,8 @@ const ToolbarTopRow = styled('div')({
18
20
  const ToolbarActionsContainer = styled('div')({
19
21
  display: 'flex',
20
22
  gap: '0.5rem',
23
+ position: 'relative',
24
+ zIndex: 3,
21
25
  });
22
26
 
23
27
  interface Props {}
@@ -27,13 +31,13 @@ export const MRT_ToolbarTop: FC<Props> = () => {
27
31
  disableGlobalFilter,
28
32
  hideToolbarActions,
29
33
  manualPagination,
30
- muiTableTitleProps,
31
34
  muiTableToolbarTopProps,
32
35
  positionPagination,
33
36
  positionToolbarActions,
37
+ positionToolbarAlertBanner,
38
+ renderToolbarCustomActions,
34
39
  tableInstance,
35
- title,
36
- } = useMaterialReactTable();
40
+ } = useMRT();
37
41
 
38
42
  const toolbarProps =
39
43
  muiTableToolbarTopProps instanceof Function
@@ -42,18 +46,13 @@ export const MRT_ToolbarTop: FC<Props> = () => {
42
46
 
43
47
  return (
44
48
  <Toolbar variant="dense" {...toolbarProps}>
49
+ {positionToolbarAlertBanner === 'top' && <MRT_ToolbarAlertBanner />}
45
50
  <ToolbarTopRow>
46
- {title ? (
47
- <Typography variant="h5" {...muiTableTitleProps}>
48
- {title}
49
- </Typography>
50
- ) : (
51
- <span />
52
- )}
51
+ {renderToolbarCustomActions?.(tableInstance) ?? <span />}
53
52
  <ToolbarActionsContainer>
54
53
  {!disableGlobalFilter && <MRT_SearchTextField />}
55
54
  {!hideToolbarActions && positionToolbarActions === 'top' && (
56
- <MRT_ToolbarButtons />
55
+ <MRT_ToolbarInternalButtons />
57
56
  )}
58
57
  </ToolbarActionsContainer>
59
58
  </ToolbarTopRow>
@@ -3,6 +3,7 @@ import React, {
3
3
  createContext,
4
4
  PropsWithChildren,
5
5
  useContext,
6
+ useMemo,
6
7
  useState,
7
8
  } from 'react';
8
9
  import {
@@ -21,30 +22,30 @@ import {
21
22
  useTable,
22
23
  } from 'react-table';
23
24
  import { MaterialReactTableProps } from './MaterialReactTable';
24
- import { UseMRTCalcs, useMRTCalcs } from './utils/useMRTCalcs';
25
25
 
26
- export interface UseMaterialReactTable<D extends {}>
27
- extends MaterialReactTableProps<D>,
28
- UseMRTCalcs {
26
+ export interface UseMRT<D extends {} = {}> extends MaterialReactTableProps<D> {
27
+ anyRowsCanExpand: boolean;
28
+ anyRowsExpanded: boolean;
29
29
  currentEditingRow: Row<D> | null;
30
30
  densePadding: boolean;
31
+ fullScreen: boolean;
31
32
  setCurrentEditingRow: (currentRowEditingId: Row<D> | null) => void;
32
33
  setDensePadding: (densePadding: boolean) => void;
34
+ setFullScreen: (fullScreen: boolean) => void;
33
35
  setShowFilters: (showFilters: boolean) => void;
36
+ setShowSearch: (showSearch: boolean) => void;
34
37
  showFilters: boolean;
38
+ showSearch: boolean;
35
39
  tableInstance: TableInstance<D>;
36
40
  }
37
41
 
38
42
  const MaterialReactTableContext = (<D extends {}>() =>
39
- createContext<UseMaterialReactTable<D>>(
40
- {} as UseMaterialReactTable<D>,
41
- ) as Context<UseMaterialReactTable<D>>)();
43
+ createContext<UseMRT<D>>({} as UseMRT<D>) as Context<UseMRT<D>>)();
42
44
 
43
45
  export const MaterialReactTableProvider = <D extends {}>(
44
46
  props: PropsWithChildren<MaterialReactTableProps<D>>,
45
47
  ) => {
46
48
  const hooks: PluginHook<D>[] = [
47
- useResizeColumns,
48
49
  useFilters,
49
50
  useGlobalFilter,
50
51
  useGroupBy,
@@ -54,32 +55,50 @@ export const MaterialReactTableProvider = <D extends {}>(
54
55
  useRowSelect,
55
56
  ];
56
57
 
57
- if (props.enableColumnResizing) hooks.unshift(useFlexLayout);
58
+ if (props.enableColumnResizing)
59
+ hooks.unshift(useResizeColumns, useFlexLayout);
58
60
 
59
61
  const tableInstance = useTable<D>(props, ...hooks);
60
62
 
61
- const mrtCalcs = useMRTCalcs({ tableInstance });
62
-
63
- const [showFilters, setShowFilters] = useState<boolean>(
64
- props.defaultShowFilters ?? false,
63
+ const anyRowsCanExpand = useMemo(
64
+ () => tableInstance.rows.some((row) => row.canExpand),
65
+ [tableInstance.rows],
65
66
  );
66
- const [densePadding, setDensePadding] = useState<boolean>(
67
- props.defaultDensePadding ?? false,
67
+ const anyRowsExpanded = useMemo(
68
+ () => tableInstance.rows.some((row) => row.isExpanded),
69
+ [tableInstance.rows],
68
70
  );
69
71
  const [currentEditingRow, setCurrentEditingRow] = useState<Row | null>(null);
72
+ const [densePadding, setDensePadding] = useState(
73
+ props.defaultDensePadding ?? false,
74
+ );
75
+ const [fullScreen, setFullScreen] = useState(
76
+ props.defaultFullScreen ?? false,
77
+ );
78
+ const [showFilters, setShowFilters] = useState(
79
+ props.defaultShowFilters ?? false,
80
+ );
81
+ const [showSearch, setShowSearch] = useState(
82
+ props.defaultShowSearchTextField ?? false,
83
+ );
70
84
 
71
85
  return (
72
86
  <MaterialReactTableContext.Provider
73
87
  value={{
74
- ...mrtCalcs,
75
88
  ...props,
89
+ anyRowsCanExpand,
90
+ anyRowsExpanded,
91
+ currentEditingRow,
76
92
  densePadding,
93
+ setCurrentEditingRow,
77
94
  setDensePadding,
95
+ fullScreen,
96
+ setFullScreen,
78
97
  setShowFilters,
79
- currentEditingRow,
80
- setCurrentEditingRow,
98
+ setShowSearch,
81
99
  showFilters,
82
- // @ts-ignore
100
+ showSearch,
101
+ //@ts-ignore
83
102
  tableInstance,
84
103
  }}
85
104
  >
@@ -88,8 +107,6 @@ export const MaterialReactTableProvider = <D extends {}>(
88
107
  );
89
108
  };
90
109
 
91
- export const useMaterialReactTable = <
92
- D extends {},
93
- >(): UseMaterialReactTable<D> =>
110
+ export const useMRT = <D extends {}>(): UseMRT<D> =>
94
111
  //@ts-ignore
95
- useContext<UseMaterialReactTable<D>>(MaterialReactTableContext);
112
+ useContext<UseMRT<D>>(MaterialReactTableContext);
@@ -7,6 +7,8 @@ export interface MRT_Localization {
7
7
  columnActionMenuItemSortAsc: string;
8
8
  columnActionMenuItemSortDesc: string;
9
9
  columnActionMenuItemUnGroupBy: string;
10
+ columnShowHideMenuHideAll: string;
11
+ columnShowHideMenuShowAll: string;
10
12
  expandAllButtonTitle: string;
11
13
  expandButtonTitle: string;
12
14
  filterTextFieldClearButtonTitle: string;
@@ -19,24 +21,32 @@ export interface MRT_Localization {
19
21
  searchTextFieldClearButtonTitle: string;
20
22
  searchTextFieldPlaceholder: string;
21
23
  selectAllCheckboxTitle: string;
24
+ selectCheckboxTitle: string;
22
25
  showHideColumnsButtonTitle: string;
23
26
  toggleDensePaddingSwitchTitle: string;
24
27
  toggleFilterButtonTitle: string;
28
+ toggleFullScreenButtonTitle: string;
29
+ toggleSearchButtonTitle: string;
30
+ toolbarAlertSelectionMessage: string;
31
+ toolbarAlertGroupedByMessage: string;
32
+ toolbarAlertGroupedThenByMessage: string;
25
33
  }
26
34
 
27
35
  export const defaultLocalization: MRT_Localization = {
28
36
  actionsHeadColumnTitle: 'Actions',
29
37
  columnActionMenuButtonTitle: 'Column Actions',
30
38
  columnActionMenuItemClearSort: 'Clear sorting',
31
- columnActionMenuItemGroupBy: 'Group by column',
32
- columnActionMenuItemHideColumn: 'Hide column',
33
- columnActionMenuItemSortAsc: 'Sort ascending',
34
- columnActionMenuItemSortDesc: 'Sort descending',
35
- columnActionMenuItemUnGroupBy: 'Ungroup column',
39
+ columnActionMenuItemGroupBy: 'Group by {column}',
40
+ columnActionMenuItemHideColumn: 'Hide {column} column',
41
+ columnActionMenuItemSortAsc: 'Sort by {column} ascending',
42
+ columnActionMenuItemSortDesc: 'Sort by {column} descending',
43
+ columnActionMenuItemUnGroupBy: 'Ungroup by {column}',
44
+ columnShowHideMenuHideAll: 'Hide all',
45
+ columnShowHideMenuShowAll: 'Show all',
36
46
  expandAllButtonTitle: 'Expand all',
37
47
  expandButtonTitle: 'Expand',
38
48
  filterTextFieldClearButtonTitle: 'Clear filter',
39
- filterTextFieldPlaceholder: 'Filter',
49
+ filterTextFieldPlaceholder: 'Filter by {column}',
40
50
  rowActionButtonCancel: 'Cancel',
41
51
  rowActionButtonSave: 'Save',
42
52
  rowActionMenuButtonTitle: 'Row Actions',
@@ -45,7 +55,13 @@ export const defaultLocalization: MRT_Localization = {
45
55
  searchTextFieldClearButtonTitle: 'Clear search',
46
56
  searchTextFieldPlaceholder: 'Search',
47
57
  selectAllCheckboxTitle: 'Select all',
58
+ selectCheckboxTitle: 'Select row',
48
59
  showHideColumnsButtonTitle: 'Show/Hide columns',
49
60
  toggleDensePaddingSwitchTitle: 'Toggle dense padding',
50
61
  toggleFilterButtonTitle: 'Toggle filters',
62
+ toggleFullScreenButtonTitle: 'Toggle full screen',
63
+ toggleSearchButtonTitle: 'Toggle search',
64
+ toolbarAlertSelectionMessage: '{selectedCount} of {rowCount} row(s) selected',
65
+ toolbarAlertGroupedByMessage: 'Grouped by ',
66
+ toolbarAlertGroupedThenByMessage: ', then by ',
51
67
  };
@@ -1,5 +0,0 @@
1
- import { FC } from 'react';
2
- interface Props {
3
- }
4
- export declare const MRT_ToolbarButtons: FC<Props>;
5
- export {};
@@ -1,11 +0,0 @@
1
- import { TableInstance } from 'react-table';
2
- export interface UseMRTCalcs {
3
- anyRowsCanExpand: boolean;
4
- anyRowsExpanded: boolean;
5
- maxColumnDepth: number;
6
- }
7
- interface Props<D extends {}> {
8
- tableInstance: TableInstance<D>;
9
- }
10
- export declare const useMRTCalcs: <D extends {}>({ tableInstance, }: Props<D>) => UseMRTCalcs;
11
- export {};
@@ -1,42 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { TableInstance } from 'react-table';
3
-
4
- export interface UseMRTCalcs {
5
- anyRowsCanExpand: boolean;
6
- anyRowsExpanded: boolean;
7
- maxColumnDepth: number;
8
- }
9
-
10
- interface Props<D extends {}> {
11
- tableInstance: TableInstance<D>;
12
- }
13
-
14
- export const useMRTCalcs = <D extends {}>({
15
- tableInstance,
16
- }: Props<D>): UseMRTCalcs => {
17
- const anyRowsCanExpand = useMemo(
18
- () => tableInstance.rows.some((row) => row.canExpand),
19
- [tableInstance.rows],
20
- );
21
-
22
- const anyRowsExpanded = useMemo(
23
- () => tableInstance.rows.some((row) => row.isExpanded),
24
- [tableInstance.rows],
25
- );
26
-
27
- const maxColumnDepth = useMemo(() => {
28
- let maxDepth = 1;
29
- tableInstance.columns.forEach((column) => {
30
- if (column.columns?.length) {
31
- maxDepth = Math.max(maxDepth, column.columns.length);
32
- }
33
- });
34
- return maxDepth - 1;
35
- }, [tableInstance.columns]);
36
-
37
- return {
38
- anyRowsCanExpand,
39
- anyRowsExpanded,
40
- maxColumnDepth,
41
- };
42
- };