@novastera-oss/material-react-table 4.0.0-beta.7
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/LICENSE +21 -0
- package/README.md +233 -0
- package/dist/index.cjs +5190 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1871 -0
- package/dist/index.js +5084 -0
- package/dist/index.js.map +1 -0
- package/locales/ar/index.d.ts +3 -0
- package/locales/ar/index.esm.d.ts +3 -0
- package/locales/ar/index.esm.js +96 -0
- package/locales/ar/index.js +98 -0
- package/locales/ar/package.json +6 -0
- package/locales/az/index.d.ts +3 -0
- package/locales/az/index.esm.d.ts +3 -0
- package/locales/az/index.esm.js +96 -0
- package/locales/az/index.js +98 -0
- package/locales/az/package.json +6 -0
- package/locales/bg/index.d.ts +3 -0
- package/locales/bg/index.esm.d.ts +3 -0
- package/locales/bg/index.esm.js +96 -0
- package/locales/bg/index.js +98 -0
- package/locales/bg/package.json +6 -0
- package/locales/cs/index.d.ts +3 -0
- package/locales/cs/index.esm.d.ts +3 -0
- package/locales/cs/index.esm.js +96 -0
- package/locales/cs/index.js +98 -0
- package/locales/cs/package.json +6 -0
- package/locales/da/index.d.ts +3 -0
- package/locales/da/index.esm.d.ts +3 -0
- package/locales/da/index.esm.js +96 -0
- package/locales/da/index.js +98 -0
- package/locales/da/package.json +6 -0
- package/locales/de/index.d.ts +3 -0
- package/locales/de/index.esm.d.ts +3 -0
- package/locales/de/index.esm.js +96 -0
- package/locales/de/index.js +98 -0
- package/locales/de/package.json +6 -0
- package/locales/el/index.d.ts +3 -0
- package/locales/el/index.esm.d.ts +3 -0
- package/locales/el/index.esm.js +96 -0
- package/locales/el/index.js +98 -0
- package/locales/el/package.json +6 -0
- package/locales/en/index.d.ts +3 -0
- package/locales/en/index.esm.d.ts +3 -0
- package/locales/en/index.esm.js +96 -0
- package/locales/en/index.js +98 -0
- package/locales/en/package.json +6 -0
- package/locales/es/index.d.ts +3 -0
- package/locales/es/index.esm.d.ts +3 -0
- package/locales/es/index.esm.js +96 -0
- package/locales/es/index.js +98 -0
- package/locales/es/package.json +6 -0
- package/locales/et/index.d.ts +3 -0
- package/locales/et/index.esm.d.ts +3 -0
- package/locales/et/index.esm.js +96 -0
- package/locales/et/index.js +98 -0
- package/locales/et/package.json +6 -0
- package/locales/fa/index.d.ts +3 -0
- package/locales/fa/index.esm.d.ts +3 -0
- package/locales/fa/index.esm.js +96 -0
- package/locales/fa/index.js +98 -0
- package/locales/fa/package.json +6 -0
- package/locales/fi/index.d.ts +3 -0
- package/locales/fi/index.esm.d.ts +3 -0
- package/locales/fi/index.esm.js +96 -0
- package/locales/fi/index.js +98 -0
- package/locales/fi/package.json +6 -0
- package/locales/fr/index.d.ts +3 -0
- package/locales/fr/index.esm.d.ts +3 -0
- package/locales/fr/index.esm.js +96 -0
- package/locales/fr/index.js +98 -0
- package/locales/fr/package.json +6 -0
- package/locales/he/index.d.ts +3 -0
- package/locales/he/index.esm.d.ts +3 -0
- package/locales/he/index.esm.js +96 -0
- package/locales/he/index.js +98 -0
- package/locales/he/package.json +6 -0
- package/locales/hr/index.d.ts +3 -0
- package/locales/hr/index.esm.d.ts +3 -0
- package/locales/hr/index.esm.js +96 -0
- package/locales/hr/index.js +98 -0
- package/locales/hr/package.json +6 -0
- package/locales/hu/index.d.ts +3 -0
- package/locales/hu/index.esm.d.ts +3 -0
- package/locales/hu/index.esm.js +96 -0
- package/locales/hu/index.js +98 -0
- package/locales/hu/package.json +6 -0
- package/locales/hy/index.d.ts +3 -0
- package/locales/hy/index.esm.d.ts +3 -0
- package/locales/hy/index.esm.js +96 -0
- package/locales/hy/index.js +98 -0
- package/locales/hy/package.json +6 -0
- package/locales/id/index.d.ts +3 -0
- package/locales/id/index.esm.d.ts +3 -0
- package/locales/id/index.esm.js +96 -0
- package/locales/id/index.js +98 -0
- package/locales/id/package.json +6 -0
- package/locales/it/index.d.ts +3 -0
- package/locales/it/index.esm.d.ts +3 -0
- package/locales/it/index.esm.js +96 -0
- package/locales/it/index.js +98 -0
- package/locales/it/package.json +6 -0
- package/locales/ja/index.d.ts +3 -0
- package/locales/ja/index.esm.d.ts +3 -0
- package/locales/ja/index.esm.js +96 -0
- package/locales/ja/index.js +98 -0
- package/locales/ja/package.json +6 -0
- package/locales/ko/index.d.ts +3 -0
- package/locales/ko/index.esm.d.ts +3 -0
- package/locales/ko/index.esm.js +96 -0
- package/locales/ko/index.js +98 -0
- package/locales/ko/package.json +6 -0
- package/locales/nl/index.d.ts +3 -0
- package/locales/nl/index.esm.d.ts +3 -0
- package/locales/nl/index.esm.js +96 -0
- package/locales/nl/index.js +98 -0
- package/locales/nl/package.json +6 -0
- package/locales/no/index.d.ts +3 -0
- package/locales/no/index.esm.d.ts +3 -0
- package/locales/no/index.esm.js +96 -0
- package/locales/no/index.js +98 -0
- package/locales/no/package.json +6 -0
- package/locales/np/index.d.ts +3 -0
- package/locales/np/index.esm.d.ts +3 -0
- package/locales/np/index.esm.js +96 -0
- package/locales/np/index.js +98 -0
- package/locales/np/package.json +6 -0
- package/locales/pl/index.d.ts +3 -0
- package/locales/pl/index.esm.d.ts +3 -0
- package/locales/pl/index.esm.js +96 -0
- package/locales/pl/index.js +98 -0
- package/locales/pl/package.json +6 -0
- package/locales/pt/index.d.ts +3 -0
- package/locales/pt/index.esm.d.ts +3 -0
- package/locales/pt/index.esm.js +96 -0
- package/locales/pt/index.js +98 -0
- package/locales/pt/package.json +6 -0
- package/locales/pt-BR/index.d.ts +3 -0
- package/locales/pt-BR/index.esm.d.ts +3 -0
- package/locales/pt-BR/index.esm.js +96 -0
- package/locales/pt-BR/index.js +98 -0
- package/locales/pt-BR/package.json +6 -0
- package/locales/ro/index.d.ts +3 -0
- package/locales/ro/index.esm.d.ts +3 -0
- package/locales/ro/index.esm.js +96 -0
- package/locales/ro/index.js +98 -0
- package/locales/ro/package.json +6 -0
- package/locales/ru/index.d.ts +3 -0
- package/locales/ru/index.esm.d.ts +3 -0
- package/locales/ru/index.esm.js +96 -0
- package/locales/ru/index.js +98 -0
- package/locales/ru/package.json +6 -0
- package/locales/sk/index.d.ts +3 -0
- package/locales/sk/index.esm.d.ts +3 -0
- package/locales/sk/index.esm.js +96 -0
- package/locales/sk/index.js +98 -0
- package/locales/sk/package.json +6 -0
- package/locales/sr-Cyrl-RS/index.d.ts +3 -0
- package/locales/sr-Cyrl-RS/index.esm.d.ts +3 -0
- package/locales/sr-Cyrl-RS/index.esm.js +96 -0
- package/locales/sr-Cyrl-RS/index.js +98 -0
- package/locales/sr-Cyrl-RS/package.json +6 -0
- package/locales/sr-Latn-RS/index.d.ts +3 -0
- package/locales/sr-Latn-RS/index.esm.d.ts +3 -0
- package/locales/sr-Latn-RS/index.esm.js +96 -0
- package/locales/sr-Latn-RS/index.js +98 -0
- package/locales/sr-Latn-RS/package.json +6 -0
- package/locales/sv/index.d.ts +3 -0
- package/locales/sv/index.esm.d.ts +3 -0
- package/locales/sv/index.esm.js +96 -0
- package/locales/sv/index.js +98 -0
- package/locales/sv/package.json +6 -0
- package/locales/tr/index.d.ts +3 -0
- package/locales/tr/index.esm.d.ts +3 -0
- package/locales/tr/index.esm.js +96 -0
- package/locales/tr/index.js +98 -0
- package/locales/tr/package.json +6 -0
- package/locales/uk/index.d.ts +3 -0
- package/locales/uk/index.esm.d.ts +3 -0
- package/locales/uk/index.esm.js +96 -0
- package/locales/uk/index.js +98 -0
- package/locales/uk/package.json +6 -0
- package/locales/vi/index.d.ts +3 -0
- package/locales/vi/index.esm.d.ts +3 -0
- package/locales/vi/index.esm.js +96 -0
- package/locales/vi/index.js +98 -0
- package/locales/vi/package.json +6 -0
- package/locales/zh-Hans/index.d.ts +3 -0
- package/locales/zh-Hans/index.esm.d.ts +3 -0
- package/locales/zh-Hans/index.esm.js +96 -0
- package/locales/zh-Hans/index.js +98 -0
- package/locales/zh-Hans/package.json +6 -0
- package/locales/zh-Hant/index.d.ts +3 -0
- package/locales/zh-Hant/index.esm.d.ts +3 -0
- package/locales/zh-Hant/index.esm.js +96 -0
- package/locales/zh-Hant/index.js +98 -0
- package/locales/zh-Hant/package.json +6 -0
- package/package.json +103 -0
- package/src/components/MaterialReactTable.tsx +36 -0
- package/src/components/body/MRT_TableBody.tsx +233 -0
- package/src/components/body/MRT_TableBodyCell.tsx +356 -0
- package/src/components/body/MRT_TableBodyCellValue.tsx +130 -0
- package/src/components/body/MRT_TableBodyRow.tsx +306 -0
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +61 -0
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +58 -0
- package/src/components/body/MRT_TableDetailPanel.tsx +118 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +73 -0
- package/src/components/buttons/MRT_CopyButton.tsx +91 -0
- package/src/components/buttons/MRT_EditActionButtons.tsx +135 -0
- package/src/components/buttons/MRT_ExpandAllButton.tsx +82 -0
- package/src/components/buttons/MRT_ExpandButton.tsx +106 -0
- package/src/components/buttons/MRT_GrabHandleButton.tsx +66 -0
- package/src/components/buttons/MRT_RowPinButton.tsx +84 -0
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +50 -0
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +52 -0
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +40 -0
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +51 -0
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +46 -0
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +126 -0
- package/src/components/footer/MRT_TableFooter.tsx +92 -0
- package/src/components/footer/MRT_TableFooterCell.tsx +111 -0
- package/src/components/footer/MRT_TableFooterRow.tsx +99 -0
- package/src/components/head/MRT_TableHead.tsx +95 -0
- package/src/components/head/MRT_TableHeadCell.tsx +357 -0
- package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +100 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +52 -0
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +180 -0
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +91 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +96 -0
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +102 -0
- package/src/components/head/MRT_TableHeadRow.tsx +94 -0
- package/src/components/inputs/MRT_EditCellTextField.tsx +195 -0
- package/src/components/inputs/MRT_FilterCheckbox.tsx +94 -0
- package/src/components/inputs/MRT_FilterRangeFields.tsx +42 -0
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +145 -0
- package/src/components/inputs/MRT_FilterTextField.tsx +610 -0
- package/src/components/inputs/MRT_GlobalFilterTextField.tsx +166 -0
- package/src/components/inputs/MRT_SelectCheckbox.tsx +133 -0
- package/src/components/menus/MRT_ActionMenuItem.tsx +62 -0
- package/src/components/menus/MRT_CellActionMenu.tsx +109 -0
- package/src/components/menus/MRT_ColumnActionMenu.tsx +354 -0
- package/src/components/menus/MRT_FilterOptionMenu.tsx +294 -0
- package/src/components/menus/MRT_RowActionMenu.tsx +90 -0
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +181 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +204 -0
- package/src/components/modals/MRT_EditRowModal.tsx +114 -0
- package/src/components/table/MRT_Table.tsx +86 -0
- package/src/components/table/MRT_TableContainer.tsx +115 -0
- package/src/components/table/MRT_TableLoadingOverlay.tsx +58 -0
- package/src/components/table/MRT_TablePaper.tsx +91 -0
- package/src/components/toolbar/MRT_BottomToolbar.tsx +112 -0
- package/src/components/toolbar/MRT_LinearProgressBar.tsx +53 -0
- package/src/components/toolbar/MRT_TablePagination.tsx +241 -0
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +182 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +82 -0
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +73 -0
- package/src/components/toolbar/MRT_TopToolbar.tsx +134 -0
- package/src/fns/aggregationFns.ts +3 -0
- package/src/fns/filterFns.ts +196 -0
- package/src/fns/sortingFns.ts +33 -0
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +28 -0
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +29 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +91 -0
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +30 -0
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +24 -0
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +34 -0
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +33 -0
- package/src/hooks/useMRT_ColumnVirtualizer.ts +124 -0
- package/src/hooks/useMRT_Effects.ts +106 -0
- package/src/hooks/useMRT_RowVirtualizer.ts +88 -0
- package/src/hooks/useMRT_Rows.ts +44 -0
- package/src/hooks/useMRT_TableInstance.ts +317 -0
- package/src/hooks/useMRT_TableOptions.ts +270 -0
- package/src/hooks/useMaterialReactTable.ts +12 -0
- package/src/icons.ts +73 -0
- package/src/index.ts +91 -0
- package/src/locales/ar.ts +97 -0
- package/src/locales/az.ts +97 -0
- package/src/locales/bg.ts +97 -0
- package/src/locales/cs.ts +98 -0
- package/src/locales/da.ts +97 -0
- package/src/locales/de.ts +97 -0
- package/src/locales/el.ts +97 -0
- package/src/locales/en.ts +97 -0
- package/src/locales/es.ts +97 -0
- package/src/locales/et.ts +98 -0
- package/src/locales/fa.ts +97 -0
- package/src/locales/fi.ts +98 -0
- package/src/locales/fr.ts +97 -0
- package/src/locales/he.ts +97 -0
- package/src/locales/hr.ts +97 -0
- package/src/locales/hu.ts +97 -0
- package/src/locales/hy.ts +97 -0
- package/src/locales/id.ts +98 -0
- package/src/locales/it.ts +97 -0
- package/src/locales/ja.ts +97 -0
- package/src/locales/ko.ts +97 -0
- package/src/locales/mk.ts +96 -0
- package/src/locales/nl.ts +97 -0
- package/src/locales/no.ts +99 -0
- package/src/locales/np.ts +98 -0
- package/src/locales/pl.ts +97 -0
- package/src/locales/pt-BR.ts +97 -0
- package/src/locales/pt.ts +97 -0
- package/src/locales/ro.ts +97 -0
- package/src/locales/ru.ts +97 -0
- package/src/locales/sk.ts +98 -0
- package/src/locales/sr-Cyrl-RS.ts +97 -0
- package/src/locales/sr-Latn-RS.ts +97 -0
- package/src/locales/sv.ts +97 -0
- package/src/locales/tr.ts +97 -0
- package/src/locales/uk.ts +97 -0
- package/src/locales/vi.ts +97 -0
- package/src/locales/zh-Hans.ts +96 -0
- package/src/locales/zh-Hant.ts +96 -0
- package/src/types.ts +1298 -0
- package/src/utils/cell.utils.ts +234 -0
- package/src/utils/column.utils.ts +209 -0
- package/src/utils/displayColumn.utils.ts +152 -0
- package/src/utils/row.utils.ts +260 -0
- package/src/utils/style.utils.ts +221 -0
- package/src/utils/tanstack.helpers.ts +64 -0
- package/src/utils/utils.ts +56 -0
- package/src/utils/virtualization.utils.ts +24 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import Box, { type BoxProps } from '@mui/material/Box';
|
|
2
|
+
import Button from '@mui/material/Button';
|
|
3
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
4
|
+
import IconButton from '@mui/material/IconButton';
|
|
5
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
6
|
+
import {
|
|
7
|
+
type MRT_Row,
|
|
8
|
+
type MRT_RowData,
|
|
9
|
+
type MRT_TableInstance,
|
|
10
|
+
} from '../../types';
|
|
11
|
+
|
|
12
|
+
export interface MRT_EditActionButtonsProps<TData extends MRT_RowData>
|
|
13
|
+
extends BoxProps {
|
|
14
|
+
row: MRT_Row<TData>;
|
|
15
|
+
table: MRT_TableInstance<TData>;
|
|
16
|
+
variant?: 'icon' | 'text';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const MRT_EditActionButtons = <TData extends MRT_RowData>({
|
|
20
|
+
row,
|
|
21
|
+
table,
|
|
22
|
+
variant = 'icon',
|
|
23
|
+
...rest
|
|
24
|
+
}: MRT_EditActionButtonsProps<TData>) => {
|
|
25
|
+
const {
|
|
26
|
+
getState,
|
|
27
|
+
options: {
|
|
28
|
+
icons: { CancelIcon, SaveIcon },
|
|
29
|
+
localization,
|
|
30
|
+
onCreatingRowCancel,
|
|
31
|
+
onCreatingRowSave,
|
|
32
|
+
onEditingRowCancel,
|
|
33
|
+
onEditingRowSave,
|
|
34
|
+
},
|
|
35
|
+
refs: { editInputRefs },
|
|
36
|
+
setCreatingRow,
|
|
37
|
+
setEditingRow,
|
|
38
|
+
} = table;
|
|
39
|
+
const { creatingRow, editingRow, isSaving } = getState();
|
|
40
|
+
|
|
41
|
+
const isCreating = creatingRow?.id === row.id;
|
|
42
|
+
const isEditing = editingRow?.id === row.id;
|
|
43
|
+
|
|
44
|
+
const handleCancel = () => {
|
|
45
|
+
if (isCreating) {
|
|
46
|
+
onCreatingRowCancel?.({ row, table });
|
|
47
|
+
setCreatingRow(null);
|
|
48
|
+
} else if (isEditing) {
|
|
49
|
+
onEditingRowCancel?.({ row, table });
|
|
50
|
+
setEditingRow(null);
|
|
51
|
+
}
|
|
52
|
+
row._valuesCache = {} as any; //reset values cache
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const handleSubmitRow = () => {
|
|
56
|
+
//look for auto-filled input values
|
|
57
|
+
Object.values(editInputRefs.current ?? {})
|
|
58
|
+
.filter((inputRef) => row.id === inputRef?.name?.split('_')?.[0])
|
|
59
|
+
?.forEach((input) => {
|
|
60
|
+
if (
|
|
61
|
+
input.value !== undefined &&
|
|
62
|
+
Object.hasOwn(row?._valuesCache as object, input.name)
|
|
63
|
+
) {
|
|
64
|
+
// @ts-expect-error
|
|
65
|
+
row._valuesCache[input.name] = input.value;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (isCreating)
|
|
69
|
+
onCreatingRowSave?.({
|
|
70
|
+
exitCreatingMode: () => setCreatingRow(null),
|
|
71
|
+
row,
|
|
72
|
+
table,
|
|
73
|
+
values: row._valuesCache,
|
|
74
|
+
});
|
|
75
|
+
else if (isEditing) {
|
|
76
|
+
onEditingRowSave?.({
|
|
77
|
+
exitEditingMode: () => setEditingRow(null),
|
|
78
|
+
row,
|
|
79
|
+
table,
|
|
80
|
+
values: row?._valuesCache,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Box
|
|
87
|
+
onClick={(e) => e.stopPropagation()}
|
|
88
|
+
sx={[
|
|
89
|
+
{
|
|
90
|
+
display: 'flex',
|
|
91
|
+
gap: '0.75rem',
|
|
92
|
+
},
|
|
93
|
+
...(Array.isArray(rest?.sx) ? rest.sx : [rest?.sx]),
|
|
94
|
+
]}
|
|
95
|
+
>
|
|
96
|
+
{variant === 'icon' ? (
|
|
97
|
+
<>
|
|
98
|
+
<Tooltip title={localization.cancel}>
|
|
99
|
+
<IconButton aria-label={localization.cancel} onClick={handleCancel}>
|
|
100
|
+
<CancelIcon />
|
|
101
|
+
</IconButton>
|
|
102
|
+
</Tooltip>
|
|
103
|
+
{((isCreating && onCreatingRowSave) ||
|
|
104
|
+
(isEditing && onEditingRowSave)) && (
|
|
105
|
+
<Tooltip title={localization.save}>
|
|
106
|
+
<IconButton
|
|
107
|
+
aria-label={localization.save}
|
|
108
|
+
color="info"
|
|
109
|
+
disabled={isSaving}
|
|
110
|
+
onClick={handleSubmitRow}
|
|
111
|
+
>
|
|
112
|
+
{isSaving ? <CircularProgress size={18} /> : <SaveIcon />}
|
|
113
|
+
</IconButton>
|
|
114
|
+
</Tooltip>
|
|
115
|
+
)}
|
|
116
|
+
</>
|
|
117
|
+
) : (
|
|
118
|
+
<>
|
|
119
|
+
<Button onClick={handleCancel} sx={{ minWidth: '100px' }}>
|
|
120
|
+
{localization.cancel}
|
|
121
|
+
</Button>
|
|
122
|
+
<Button
|
|
123
|
+
disabled={isSaving}
|
|
124
|
+
onClick={handleSubmitRow}
|
|
125
|
+
sx={{ minWidth: '100px' }}
|
|
126
|
+
variant="contained"
|
|
127
|
+
>
|
|
128
|
+
{isSaving && <CircularProgress color="inherit" size={18} />}
|
|
129
|
+
{localization.save}
|
|
130
|
+
</Button>
|
|
131
|
+
</>
|
|
132
|
+
)}
|
|
133
|
+
</Box>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
|
2
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
3
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
4
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
|
5
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
6
|
+
|
|
7
|
+
export interface MRT_ExpandAllButtonProps<TData extends MRT_RowData>
|
|
8
|
+
extends IconButtonProps {
|
|
9
|
+
table: MRT_TableInstance<TData>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const MRT_ExpandAllButton = <TData extends MRT_RowData>({
|
|
13
|
+
table,
|
|
14
|
+
...rest
|
|
15
|
+
}: MRT_ExpandAllButtonProps<TData>) => {
|
|
16
|
+
const {
|
|
17
|
+
getCanSomeRowsExpand,
|
|
18
|
+
getIsAllRowsExpanded,
|
|
19
|
+
getIsSomeRowsExpanded,
|
|
20
|
+
getState,
|
|
21
|
+
options: {
|
|
22
|
+
icons: { KeyboardDoubleArrowDownIcon },
|
|
23
|
+
localization,
|
|
24
|
+
muiExpandAllButtonProps,
|
|
25
|
+
renderDetailPanel,
|
|
26
|
+
},
|
|
27
|
+
toggleAllRowsExpanded,
|
|
28
|
+
} = table;
|
|
29
|
+
const { density, isLoading } = getState();
|
|
30
|
+
|
|
31
|
+
const iconButtonProps = {
|
|
32
|
+
...parseFromValuesOrFunc(muiExpandAllButtonProps, {
|
|
33
|
+
table,
|
|
34
|
+
}),
|
|
35
|
+
...rest,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const isAllRowsExpanded = getIsAllRowsExpanded();
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Tooltip
|
|
42
|
+
{...getCommonTooltipProps()}
|
|
43
|
+
title={
|
|
44
|
+
iconButtonProps?.title ??
|
|
45
|
+
(isAllRowsExpanded ? localization.collapseAll : localization.expandAll)
|
|
46
|
+
}
|
|
47
|
+
>
|
|
48
|
+
<span>
|
|
49
|
+
<IconButton
|
|
50
|
+
aria-label={localization.expandAll}
|
|
51
|
+
disabled={
|
|
52
|
+
isLoading || (!renderDetailPanel && !getCanSomeRowsExpand())
|
|
53
|
+
}
|
|
54
|
+
onClick={() => toggleAllRowsExpanded(!isAllRowsExpanded)}
|
|
55
|
+
{...iconButtonProps}
|
|
56
|
+
sx={[
|
|
57
|
+
{
|
|
58
|
+
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
59
|
+
mt: density !== 'compact' ? '-0.25rem' : undefined,
|
|
60
|
+
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
61
|
+
},
|
|
62
|
+
...(Array.isArray(iconButtonProps?.sx)
|
|
63
|
+
? iconButtonProps.sx
|
|
64
|
+
: [iconButtonProps?.sx]),
|
|
65
|
+
]}
|
|
66
|
+
title={undefined}
|
|
67
|
+
>
|
|
68
|
+
{iconButtonProps?.children ?? (
|
|
69
|
+
<KeyboardDoubleArrowDownIcon
|
|
70
|
+
style={{
|
|
71
|
+
transform: `rotate(${
|
|
72
|
+
isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0
|
|
73
|
+
}deg)`,
|
|
74
|
+
transition: 'transform 150ms',
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
)}
|
|
78
|
+
</IconButton>
|
|
79
|
+
</span>
|
|
80
|
+
</Tooltip>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type MouseEvent } from 'react';
|
|
2
|
+
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
|
3
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
4
|
+
import { useTheme } from '@mui/material/styles';
|
|
5
|
+
import {
|
|
6
|
+
type MRT_Row,
|
|
7
|
+
type MRT_RowData,
|
|
8
|
+
type MRT_TableInstance,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
|
11
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
12
|
+
|
|
13
|
+
export interface MRT_ExpandButtonProps<TData extends MRT_RowData>
|
|
14
|
+
extends IconButtonProps {
|
|
15
|
+
row: MRT_Row<TData>;
|
|
16
|
+
staticRowIndex?: number;
|
|
17
|
+
table: MRT_TableInstance<TData>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const MRT_ExpandButton = <TData extends MRT_RowData>({
|
|
21
|
+
row,
|
|
22
|
+
staticRowIndex,
|
|
23
|
+
table,
|
|
24
|
+
}: MRT_ExpandButtonProps<TData>) => {
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
const {
|
|
27
|
+
getState,
|
|
28
|
+
options: {
|
|
29
|
+
icons: { ExpandMoreIcon },
|
|
30
|
+
localization,
|
|
31
|
+
muiExpandButtonProps,
|
|
32
|
+
positionExpandColumn,
|
|
33
|
+
renderDetailPanel,
|
|
34
|
+
},
|
|
35
|
+
} = table;
|
|
36
|
+
const { density } = getState();
|
|
37
|
+
|
|
38
|
+
const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
|
|
39
|
+
row,
|
|
40
|
+
staticRowIndex,
|
|
41
|
+
table,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const canExpand = row.getCanExpand();
|
|
45
|
+
const isExpanded = row.getIsExpanded();
|
|
46
|
+
|
|
47
|
+
const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
row.toggleExpanded();
|
|
50
|
+
iconButtonProps?.onClick?.(event);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const detailPanel = !!renderDetailPanel?.({ row, table });
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Tooltip
|
|
57
|
+
disableHoverListener={!canExpand && !detailPanel}
|
|
58
|
+
{...getCommonTooltipProps()}
|
|
59
|
+
title={
|
|
60
|
+
iconButtonProps?.title ??
|
|
61
|
+
(isExpanded ? localization.collapse : localization.expand)
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
<span>
|
|
65
|
+
<IconButton
|
|
66
|
+
aria-label={localization.expand}
|
|
67
|
+
disabled={!canExpand && !detailPanel}
|
|
68
|
+
{...iconButtonProps}
|
|
69
|
+
onClick={handleToggleExpand}
|
|
70
|
+
sx={[
|
|
71
|
+
(theme) => ({
|
|
72
|
+
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
73
|
+
opacity: !canExpand && !detailPanel ? 0.3 : 1,
|
|
74
|
+
[theme.direction === 'rtl' || positionExpandColumn === 'last'
|
|
75
|
+
? 'mr'
|
|
76
|
+
: 'ml']: `${row.depth * 16}px`,
|
|
77
|
+
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
78
|
+
}),
|
|
79
|
+
...(Array.isArray(iconButtonProps?.sx)
|
|
80
|
+
? iconButtonProps.sx
|
|
81
|
+
: [iconButtonProps?.sx]),
|
|
82
|
+
]}
|
|
83
|
+
title={undefined}
|
|
84
|
+
>
|
|
85
|
+
{iconButtonProps?.children ?? (
|
|
86
|
+
<ExpandMoreIcon
|
|
87
|
+
style={{
|
|
88
|
+
transform: `rotate(${
|
|
89
|
+
!canExpand && !renderDetailPanel
|
|
90
|
+
? positionExpandColumn === 'last' ||
|
|
91
|
+
theme.direction === 'rtl'
|
|
92
|
+
? 90
|
|
93
|
+
: -90
|
|
94
|
+
: isExpanded
|
|
95
|
+
? -180
|
|
96
|
+
: 0
|
|
97
|
+
}deg)`,
|
|
98
|
+
transition: 'transform 150ms',
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
)}
|
|
102
|
+
</IconButton>
|
|
103
|
+
</span>
|
|
104
|
+
</Tooltip>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type DragEventHandler } from 'react';
|
|
2
|
+
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
|
3
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
4
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
5
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
|
6
|
+
|
|
7
|
+
export interface MRT_GrabHandleButtonProps<TData extends MRT_RowData>
|
|
8
|
+
extends IconButtonProps {
|
|
9
|
+
iconButtonProps?: IconButtonProps;
|
|
10
|
+
location?: 'column' | 'row';
|
|
11
|
+
onDragEnd: DragEventHandler<HTMLButtonElement>;
|
|
12
|
+
onDragStart: DragEventHandler<HTMLButtonElement>;
|
|
13
|
+
table: MRT_TableInstance<TData>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const MRT_GrabHandleButton = <TData extends MRT_RowData>({
|
|
17
|
+
location,
|
|
18
|
+
table,
|
|
19
|
+
...rest
|
|
20
|
+
}: MRT_GrabHandleButtonProps<TData>) => {
|
|
21
|
+
const {
|
|
22
|
+
options: {
|
|
23
|
+
icons: { DragHandleIcon },
|
|
24
|
+
localization,
|
|
25
|
+
},
|
|
26
|
+
} = table;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Tooltip
|
|
30
|
+
{...getCommonTooltipProps('top')}
|
|
31
|
+
title={rest?.title ?? localization.move}
|
|
32
|
+
>
|
|
33
|
+
<IconButton
|
|
34
|
+
aria-label={rest.title ?? localization.move}
|
|
35
|
+
disableRipple
|
|
36
|
+
draggable="true"
|
|
37
|
+
size="small"
|
|
38
|
+
{...rest}
|
|
39
|
+
onClick={(e) => {
|
|
40
|
+
e.stopPropagation();
|
|
41
|
+
rest?.onClick?.(e);
|
|
42
|
+
}}
|
|
43
|
+
sx={[
|
|
44
|
+
{
|
|
45
|
+
'&:active': {
|
|
46
|
+
cursor: 'grabbing',
|
|
47
|
+
},
|
|
48
|
+
'&:hover': {
|
|
49
|
+
backgroundColor: 'transparent',
|
|
50
|
+
opacity: 1,
|
|
51
|
+
},
|
|
52
|
+
cursor: 'grab',
|
|
53
|
+
m: '0 -0.1rem',
|
|
54
|
+
opacity: location === 'row' ? 1 : 0.5,
|
|
55
|
+
p: '2px',
|
|
56
|
+
transition: 'all 150ms ease-in-out',
|
|
57
|
+
},
|
|
58
|
+
...(Array.isArray(rest?.sx) ? rest.sx : [rest?.sx]),
|
|
59
|
+
]}
|
|
60
|
+
title={undefined}
|
|
61
|
+
>
|
|
62
|
+
<DragHandleIcon />
|
|
63
|
+
</IconButton>
|
|
64
|
+
</Tooltip>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type MouseEvent, useState } from 'react';
|
|
2
|
+
import { type RowPinningPosition } from '@tanstack/react-table';
|
|
3
|
+
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
|
4
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
5
|
+
import {
|
|
6
|
+
type MRT_Row,
|
|
7
|
+
type MRT_RowData,
|
|
8
|
+
type MRT_TableInstance,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
|
11
|
+
|
|
12
|
+
export interface MRT_RowPinButtonProps<TData extends MRT_RowData>
|
|
13
|
+
extends IconButtonProps {
|
|
14
|
+
pinningPosition: RowPinningPosition;
|
|
15
|
+
row: MRT_Row<TData>;
|
|
16
|
+
table: MRT_TableInstance<TData>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const MRT_RowPinButton = <TData extends MRT_RowData>({
|
|
20
|
+
pinningPosition,
|
|
21
|
+
row,
|
|
22
|
+
table,
|
|
23
|
+
...rest
|
|
24
|
+
}: MRT_RowPinButtonProps<TData>) => {
|
|
25
|
+
const {
|
|
26
|
+
options: {
|
|
27
|
+
icons: { CloseIcon, PushPinIcon },
|
|
28
|
+
localization,
|
|
29
|
+
rowPinningDisplayMode,
|
|
30
|
+
},
|
|
31
|
+
} = table;
|
|
32
|
+
|
|
33
|
+
const isPinned = row.getIsPinned();
|
|
34
|
+
|
|
35
|
+
const [tooltipOpened, setTooltipOpened] = useState(false);
|
|
36
|
+
|
|
37
|
+
const handleTogglePin = (event: MouseEvent<HTMLButtonElement>) => {
|
|
38
|
+
setTooltipOpened(false);
|
|
39
|
+
event.stopPropagation();
|
|
40
|
+
row.pin(isPinned ? false : pinningPosition);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Tooltip
|
|
45
|
+
{...getCommonTooltipProps()}
|
|
46
|
+
open={tooltipOpened}
|
|
47
|
+
title={isPinned ? localization.unpin : localization.pin}
|
|
48
|
+
>
|
|
49
|
+
<IconButton
|
|
50
|
+
aria-label={localization.pin}
|
|
51
|
+
onBlur={() => setTooltipOpened(false)}
|
|
52
|
+
onClick={handleTogglePin}
|
|
53
|
+
onFocus={() => setTooltipOpened(true)}
|
|
54
|
+
onMouseEnter={() => setTooltipOpened(true)}
|
|
55
|
+
onMouseLeave={() => setTooltipOpened(false)}
|
|
56
|
+
size="small"
|
|
57
|
+
{...rest}
|
|
58
|
+
sx={[
|
|
59
|
+
{
|
|
60
|
+
height: '24px',
|
|
61
|
+
width: '24px',
|
|
62
|
+
},
|
|
63
|
+
...(Array.isArray(rest?.sx) ? rest.sx : [rest?.sx]),
|
|
64
|
+
]}
|
|
65
|
+
>
|
|
66
|
+
{isPinned ? (
|
|
67
|
+
<CloseIcon />
|
|
68
|
+
) : (
|
|
69
|
+
<PushPinIcon
|
|
70
|
+
fontSize="small"
|
|
71
|
+
style={{
|
|
72
|
+
transform: `rotate(${rowPinningDisplayMode === 'sticky'
|
|
73
|
+
? 135
|
|
74
|
+
: pinningPosition === 'top'
|
|
75
|
+
? 180
|
|
76
|
+
: 0
|
|
77
|
+
}deg)`,
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
</IconButton>
|
|
82
|
+
</Tooltip>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type MouseEvent, useState } from 'react';
|
|
2
|
+
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
|
3
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
4
|
+
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
5
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
6
|
+
|
|
7
|
+
export interface MRT_ShowHideColumnsButtonProps<TData extends MRT_RowData>
|
|
8
|
+
extends IconButtonProps {
|
|
9
|
+
table: MRT_TableInstance<TData>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const MRT_ShowHideColumnsButton = <TData extends MRT_RowData>({
|
|
13
|
+
table,
|
|
14
|
+
...rest
|
|
15
|
+
}: MRT_ShowHideColumnsButtonProps<TData>) => {
|
|
16
|
+
const {
|
|
17
|
+
options: {
|
|
18
|
+
icons: { ViewColumnIcon },
|
|
19
|
+
localization,
|
|
20
|
+
},
|
|
21
|
+
} = table;
|
|
22
|
+
|
|
23
|
+
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
|
24
|
+
|
|
25
|
+
const handleClick = (event: MouseEvent<HTMLElement>) => {
|
|
26
|
+
setAnchorEl(event.currentTarget);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<Tooltip title={rest?.title ?? localization.showHideColumns}>
|
|
32
|
+
<IconButton
|
|
33
|
+
aria-label={localization.showHideColumns}
|
|
34
|
+
onClick={handleClick}
|
|
35
|
+
{...rest}
|
|
36
|
+
title={undefined}
|
|
37
|
+
>
|
|
38
|
+
<ViewColumnIcon />
|
|
39
|
+
</IconButton>
|
|
40
|
+
</Tooltip>
|
|
41
|
+
{anchorEl && (
|
|
42
|
+
<MRT_ShowHideColumnsMenu
|
|
43
|
+
anchorEl={anchorEl}
|
|
44
|
+
setAnchorEl={setAnchorEl}
|
|
45
|
+
table={table}
|
|
46
|
+
/>
|
|
47
|
+
)}
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
|
2
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
3
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
4
|
+
|
|
5
|
+
export interface MRT_ToggleDensePaddingButtonProps<TData extends MRT_RowData>
|
|
6
|
+
extends IconButtonProps {
|
|
7
|
+
table: MRT_TableInstance<TData>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const MRT_ToggleDensePaddingButton = <TData extends MRT_RowData>({
|
|
11
|
+
table,
|
|
12
|
+
...rest
|
|
13
|
+
}: MRT_ToggleDensePaddingButtonProps<TData>) => {
|
|
14
|
+
const {
|
|
15
|
+
getState,
|
|
16
|
+
options: {
|
|
17
|
+
icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon },
|
|
18
|
+
localization,
|
|
19
|
+
},
|
|
20
|
+
setDensity,
|
|
21
|
+
} = table;
|
|
22
|
+
const { density } = getState();
|
|
23
|
+
|
|
24
|
+
const handleToggleDensePadding = () => {
|
|
25
|
+
const nextDensity =
|
|
26
|
+
density === 'comfortable'
|
|
27
|
+
? 'compact'
|
|
28
|
+
: density === 'compact'
|
|
29
|
+
? 'spacious'
|
|
30
|
+
: 'comfortable';
|
|
31
|
+
setDensity(nextDensity);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Tooltip title={rest?.title ?? localization.toggleDensity}>
|
|
36
|
+
<IconButton
|
|
37
|
+
aria-label={localization.toggleDensity}
|
|
38
|
+
onClick={handleToggleDensePadding}
|
|
39
|
+
{...rest}
|
|
40
|
+
title={undefined}
|
|
41
|
+
>
|
|
42
|
+
{density === 'compact' ? (
|
|
43
|
+
<DensitySmallIcon />
|
|
44
|
+
) : density === 'comfortable' ? (
|
|
45
|
+
<DensityMediumIcon />
|
|
46
|
+
) : (
|
|
47
|
+
<DensityLargeIcon />
|
|
48
|
+
)}
|
|
49
|
+
</IconButton>
|
|
50
|
+
</Tooltip>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
|
2
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
3
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
4
|
+
|
|
5
|
+
export interface MRT_ToggleFiltersButtonProps<TData extends MRT_RowData>
|
|
6
|
+
extends IconButtonProps {
|
|
7
|
+
table: MRT_TableInstance<TData>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const MRT_ToggleFiltersButton = <TData extends MRT_RowData>({
|
|
11
|
+
table,
|
|
12
|
+
...rest
|
|
13
|
+
}: MRT_ToggleFiltersButtonProps<TData>) => {
|
|
14
|
+
const {
|
|
15
|
+
getState,
|
|
16
|
+
options: {
|
|
17
|
+
icons: { FilterListIcon, FilterListOffIcon },
|
|
18
|
+
localization,
|
|
19
|
+
},
|
|
20
|
+
setShowColumnFilters,
|
|
21
|
+
} = table;
|
|
22
|
+
const { showColumnFilters } = getState();
|
|
23
|
+
|
|
24
|
+
const handleToggleShowFilters = () => {
|
|
25
|
+
setShowColumnFilters(!showColumnFilters);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Tooltip title={rest?.title ?? localization.showHideFilters}>
|
|
30
|
+
<IconButton
|
|
31
|
+
aria-label={localization.showHideFilters}
|
|
32
|
+
onClick={handleToggleShowFilters}
|
|
33
|
+
{...rest}
|
|
34
|
+
title={undefined}
|
|
35
|
+
>
|
|
36
|
+
{showColumnFilters ? <FilterListOffIcon /> : <FilterListIcon />}
|
|
37
|
+
</IconButton>
|
|
38
|
+
</Tooltip>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
|
3
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
4
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
5
|
+
|
|
6
|
+
export interface MRT_ToggleFullScreenButtonProps<TData extends MRT_RowData>
|
|
7
|
+
extends IconButtonProps {
|
|
8
|
+
table: MRT_TableInstance<TData>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const MRT_ToggleFullScreenButton = <TData extends MRT_RowData>({
|
|
12
|
+
table,
|
|
13
|
+
...rest
|
|
14
|
+
}: MRT_ToggleFullScreenButtonProps<TData>) => {
|
|
15
|
+
const {
|
|
16
|
+
getState,
|
|
17
|
+
options: {
|
|
18
|
+
icons: { FullscreenExitIcon, FullscreenIcon },
|
|
19
|
+
localization,
|
|
20
|
+
},
|
|
21
|
+
setIsFullScreen,
|
|
22
|
+
} = table;
|
|
23
|
+
const { isFullScreen } = getState();
|
|
24
|
+
|
|
25
|
+
const [tooltipOpened, setTooltipOpened] = useState(false);
|
|
26
|
+
|
|
27
|
+
const handleToggleFullScreen = () => {
|
|
28
|
+
setTooltipOpened(false);
|
|
29
|
+
setIsFullScreen(!isFullScreen);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Tooltip
|
|
34
|
+
open={tooltipOpened}
|
|
35
|
+
title={rest?.title ?? localization.toggleFullScreen}
|
|
36
|
+
>
|
|
37
|
+
<IconButton
|
|
38
|
+
aria-label={localization.toggleFullScreen}
|
|
39
|
+
onBlur={() => setTooltipOpened(false)}
|
|
40
|
+
onClick={handleToggleFullScreen}
|
|
41
|
+
onFocus={() => setTooltipOpened(true)}
|
|
42
|
+
onMouseEnter={() => setTooltipOpened(true)}
|
|
43
|
+
onMouseLeave={() => setTooltipOpened(false)}
|
|
44
|
+
{...rest}
|
|
45
|
+
title={undefined}
|
|
46
|
+
>
|
|
47
|
+
{isFullScreen ? <FullscreenExitIcon /> : <FullscreenIcon />}
|
|
48
|
+
</IconButton>
|
|
49
|
+
</Tooltip>
|
|
50
|
+
);
|
|
51
|
+
};
|