@kissesses/mantine-react-table-open 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +196 -0
- package/dist/index.cjs +3769 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1488 -0
- package/dist/index.esm.d.mts +1488 -0
- package/dist/index.esm.mjs +3664 -0
- package/dist/index.esm.mjs.map +1 -0
- package/locales/ar/index.cjs +97 -0
- package/locales/ar/index.d.cts +3 -0
- package/locales/ar/index.esm.d.mts +3 -0
- package/locales/ar/index.esm.mjs +95 -0
- package/locales/ar/package.json +19 -0
- package/locales/az/index.cjs +97 -0
- package/locales/az/index.d.cts +3 -0
- package/locales/az/index.esm.d.mts +3 -0
- package/locales/az/index.esm.mjs +95 -0
- package/locales/az/package.json +19 -0
- package/locales/bg/index.cjs +97 -0
- package/locales/bg/index.d.cts +3 -0
- package/locales/bg/index.esm.d.mts +3 -0
- package/locales/bg/index.esm.mjs +95 -0
- package/locales/bg/package.json +19 -0
- package/locales/cs/index.cjs +97 -0
- package/locales/cs/index.d.cts +3 -0
- package/locales/cs/index.esm.d.mts +3 -0
- package/locales/cs/index.esm.mjs +95 -0
- package/locales/cs/package.json +19 -0
- package/locales/da/index.cjs +97 -0
- package/locales/da/index.d.cts +3 -0
- package/locales/da/index.esm.d.mts +3 -0
- package/locales/da/index.esm.mjs +95 -0
- package/locales/da/package.json +19 -0
- package/locales/de/index.cjs +97 -0
- package/locales/de/index.d.cts +3 -0
- package/locales/de/index.esm.d.mts +3 -0
- package/locales/de/index.esm.mjs +95 -0
- package/locales/de/package.json +19 -0
- package/locales/el/index.cjs +97 -0
- package/locales/el/index.d.cts +3 -0
- package/locales/el/index.esm.d.mts +3 -0
- package/locales/el/index.esm.mjs +95 -0
- package/locales/el/package.json +19 -0
- package/locales/en/index.cjs +97 -0
- package/locales/en/index.d.cts +3 -0
- package/locales/en/index.esm.d.mts +3 -0
- package/locales/en/index.esm.mjs +95 -0
- package/locales/en/package.json +19 -0
- package/locales/es/index.cjs +97 -0
- package/locales/es/index.d.cts +3 -0
- package/locales/es/index.esm.d.mts +3 -0
- package/locales/es/index.esm.mjs +95 -0
- package/locales/es/package.json +19 -0
- package/locales/et/index.cjs +97 -0
- package/locales/et/index.d.cts +3 -0
- package/locales/et/index.esm.d.mts +3 -0
- package/locales/et/index.esm.mjs +95 -0
- package/locales/et/package.json +19 -0
- package/locales/fa/index.cjs +97 -0
- package/locales/fa/index.d.cts +3 -0
- package/locales/fa/index.esm.d.mts +3 -0
- package/locales/fa/index.esm.mjs +95 -0
- package/locales/fa/package.json +19 -0
- package/locales/fi/index.cjs +97 -0
- package/locales/fi/index.d.cts +3 -0
- package/locales/fi/index.esm.d.mts +3 -0
- package/locales/fi/index.esm.mjs +95 -0
- package/locales/fi/package.json +19 -0
- package/locales/fr/index.cjs +97 -0
- package/locales/fr/index.d.cts +3 -0
- package/locales/fr/index.esm.d.mts +3 -0
- package/locales/fr/index.esm.mjs +95 -0
- package/locales/fr/package.json +19 -0
- package/locales/he/index.cjs +97 -0
- package/locales/he/index.d.cts +3 -0
- package/locales/he/index.esm.d.mts +3 -0
- package/locales/he/index.esm.mjs +95 -0
- package/locales/he/package.json +19 -0
- package/locales/hr/index.cjs +97 -0
- package/locales/hr/index.d.cts +3 -0
- package/locales/hr/index.esm.d.mts +3 -0
- package/locales/hr/index.esm.mjs +95 -0
- package/locales/hr/package.json +19 -0
- package/locales/hu/index.cjs +97 -0
- package/locales/hu/index.d.cts +3 -0
- package/locales/hu/index.esm.d.mts +3 -0
- package/locales/hu/index.esm.mjs +95 -0
- package/locales/hu/package.json +19 -0
- package/locales/hy/index.cjs +97 -0
- package/locales/hy/index.d.cts +3 -0
- package/locales/hy/index.esm.d.mts +3 -0
- package/locales/hy/index.esm.mjs +95 -0
- package/locales/hy/package.json +19 -0
- package/locales/id/index.cjs +97 -0
- package/locales/id/index.d.cts +3 -0
- package/locales/id/index.esm.d.mts +3 -0
- package/locales/id/index.esm.mjs +95 -0
- package/locales/id/package.json +19 -0
- package/locales/it/index.cjs +97 -0
- package/locales/it/index.d.cts +3 -0
- package/locales/it/index.esm.d.mts +3 -0
- package/locales/it/index.esm.mjs +95 -0
- package/locales/it/package.json +19 -0
- package/locales/ja/index.cjs +97 -0
- package/locales/ja/index.d.cts +3 -0
- package/locales/ja/index.esm.d.mts +3 -0
- package/locales/ja/index.esm.mjs +95 -0
- package/locales/ja/package.json +19 -0
- package/locales/ko/index.cjs +97 -0
- package/locales/ko/index.d.cts +3 -0
- package/locales/ko/index.esm.d.mts +3 -0
- package/locales/ko/index.esm.mjs +95 -0
- package/locales/ko/package.json +19 -0
- package/locales/nl/index.cjs +97 -0
- package/locales/nl/index.d.cts +3 -0
- package/locales/nl/index.esm.d.mts +3 -0
- package/locales/nl/index.esm.mjs +95 -0
- package/locales/nl/package.json +19 -0
- package/locales/no/index.cjs +97 -0
- package/locales/no/index.d.cts +3 -0
- package/locales/no/index.esm.d.mts +3 -0
- package/locales/no/index.esm.mjs +95 -0
- package/locales/no/package.json +19 -0
- package/locales/np/index.cjs +97 -0
- package/locales/np/index.d.cts +3 -0
- package/locales/np/index.esm.d.mts +3 -0
- package/locales/np/index.esm.mjs +95 -0
- package/locales/np/package.json +19 -0
- package/locales/pl/index.cjs +97 -0
- package/locales/pl/index.d.cts +3 -0
- package/locales/pl/index.esm.d.mts +3 -0
- package/locales/pl/index.esm.mjs +95 -0
- package/locales/pl/package.json +19 -0
- package/locales/pt/index.cjs +97 -0
- package/locales/pt/index.d.cts +3 -0
- package/locales/pt/index.esm.d.mts +3 -0
- package/locales/pt/index.esm.mjs +95 -0
- package/locales/pt/package.json +19 -0
- package/locales/pt-BR/index.cjs +97 -0
- package/locales/pt-BR/index.d.cts +3 -0
- package/locales/pt-BR/index.esm.d.mts +3 -0
- package/locales/pt-BR/index.esm.mjs +95 -0
- package/locales/pt-BR/package.json +19 -0
- package/locales/ro/index.cjs +97 -0
- package/locales/ro/index.d.cts +3 -0
- package/locales/ro/index.esm.d.mts +3 -0
- package/locales/ro/index.esm.mjs +95 -0
- package/locales/ro/package.json +19 -0
- package/locales/ru/index.cjs +97 -0
- package/locales/ru/index.d.cts +3 -0
- package/locales/ru/index.esm.d.mts +3 -0
- package/locales/ru/index.esm.mjs +95 -0
- package/locales/ru/package.json +19 -0
- package/locales/sk/index.cjs +97 -0
- package/locales/sk/index.d.cts +3 -0
- package/locales/sk/index.esm.d.mts +3 -0
- package/locales/sk/index.esm.mjs +95 -0
- package/locales/sk/package.json +19 -0
- package/locales/sr-Cyrl-RS/index.cjs +97 -0
- package/locales/sr-Cyrl-RS/index.d.cts +3 -0
- package/locales/sr-Cyrl-RS/index.esm.d.mts +3 -0
- package/locales/sr-Cyrl-RS/index.esm.mjs +95 -0
- package/locales/sr-Cyrl-RS/package.json +19 -0
- package/locales/sr-Latn-RS/index.cjs +97 -0
- package/locales/sr-Latn-RS/index.d.cts +3 -0
- package/locales/sr-Latn-RS/index.esm.d.mts +3 -0
- package/locales/sr-Latn-RS/index.esm.mjs +95 -0
- package/locales/sr-Latn-RS/package.json +19 -0
- package/locales/sv/index.cjs +97 -0
- package/locales/sv/index.d.cts +3 -0
- package/locales/sv/index.esm.d.mts +3 -0
- package/locales/sv/index.esm.mjs +95 -0
- package/locales/sv/package.json +19 -0
- package/locales/tr/index.cjs +97 -0
- package/locales/tr/index.d.cts +3 -0
- package/locales/tr/index.esm.d.mts +3 -0
- package/locales/tr/index.esm.mjs +95 -0
- package/locales/tr/package.json +19 -0
- package/locales/uk/index.cjs +97 -0
- package/locales/uk/index.d.cts +3 -0
- package/locales/uk/index.esm.d.mts +3 -0
- package/locales/uk/index.esm.mjs +95 -0
- package/locales/uk/package.json +19 -0
- package/locales/vi/index.cjs +97 -0
- package/locales/vi/index.d.cts +3 -0
- package/locales/vi/index.esm.d.mts +3 -0
- package/locales/vi/index.esm.mjs +95 -0
- package/locales/vi/package.json +19 -0
- package/locales/zh-Hans/index.cjs +97 -0
- package/locales/zh-Hans/index.d.cts +3 -0
- package/locales/zh-Hans/index.esm.d.mts +3 -0
- package/locales/zh-Hans/index.esm.mjs +95 -0
- package/locales/zh-Hans/package.json +19 -0
- package/locales/zh-Hant/index.cjs +97 -0
- package/locales/zh-Hant/index.d.cts +3 -0
- package/locales/zh-Hant/index.esm.d.mts +3 -0
- package/locales/zh-Hant/index.esm.mjs +95 -0
- package/locales/zh-Hant/package.json +19 -0
- package/package.json +154 -0
- package/src/components/MantineReactTable.tsx +37 -0
- package/src/components/body/MRT_TableBody.module.css +42 -0
- package/src/components/body/MRT_TableBody.tsx +215 -0
- package/src/components/body/MRT_TableBodyCell.module.css +107 -0
- package/src/components/body/MRT_TableBodyCell.tsx +351 -0
- package/src/components/body/MRT_TableBodyCellValue.tsx +113 -0
- package/src/components/body/MRT_TableBodyEmptyRow.tsx +110 -0
- package/src/components/body/MRT_TableBodyRow.module.css +252 -0
- package/src/components/body/MRT_TableBodyRow.tsx +263 -0
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +58 -0
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +58 -0
- package/src/components/body/MRT_TableDetailPanel.module.css +35 -0
- package/src/components/body/MRT_TableDetailPanel.tsx +131 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.module.css +11 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +68 -0
- package/src/components/buttons/MRT_CopyButton.module.css +27 -0
- package/src/components/buttons/MRT_CopyButton.tsx +83 -0
- package/src/components/buttons/MRT_EditActionButtons.module.css +4 -0
- package/src/components/buttons/MRT_EditActionButtons.tsx +128 -0
- package/src/components/buttons/MRT_ExpandAllButton.module.css +26 -0
- package/src/components/buttons/MRT_ExpandAllButton.tsx +83 -0
- package/src/components/buttons/MRT_ExpandButton.module.css +37 -0
- package/src/components/buttons/MRT_ExpandButton.tsx +120 -0
- package/src/components/buttons/MRT_GrabHandleButton.module.css +6 -0
- package/src/components/buttons/MRT_GrabHandleButton.tsx +64 -0
- package/src/components/buttons/MRT_RowPinButton.tsx +83 -0
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +45 -0
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +65 -0
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +44 -0
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +58 -0
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +51 -0
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +86 -0
- package/src/components/footer/MRT_TableFooter.module.css +17 -0
- package/src/components/footer/MRT_TableFooter.tsx +72 -0
- package/src/components/footer/MRT_TableFooterCell.module.css +50 -0
- package/src/components/footer/MRT_TableFooterCell.tsx +122 -0
- package/src/components/footer/MRT_TableFooterRow.module.css +10 -0
- package/src/components/footer/MRT_TableFooterRow.tsx +94 -0
- package/src/components/head/MRT_TableHead.module.css +32 -0
- package/src/components/head/MRT_TableHead.tsx +108 -0
- package/src/components/head/MRT_TableHeadCell.module.css +163 -0
- package/src/components/head/MRT_TableHeadCell.tsx +322 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.module.css +5 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +147 -0
- package/src/components/head/MRT_TableHeadCellFilterLabel.module.css +14 -0
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +171 -0
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +81 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.module.css +44 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +67 -0
- package/src/components/head/MRT_TableHeadCellSortLabel.module.css +22 -0
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +89 -0
- package/src/components/head/MRT_TableHeadRow.module.css +12 -0
- package/src/components/head/MRT_TableHeadRow.tsx +87 -0
- package/src/components/inputs/MRT_EditCellTextInput.tsx +218 -0
- package/src/components/inputs/MRT_FilterCheckBox.module.css +4 -0
- package/src/components/inputs/MRT_FilterCheckbox.tsx +79 -0
- package/src/components/inputs/MRT_FilterRangeFields.module.css +5 -0
- package/src/components/inputs/MRT_FilterRangeFields.tsx +35 -0
- package/src/components/inputs/MRT_FilterRangeSlider.module.css +6 -0
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +106 -0
- package/src/components/inputs/MRT_FilterTextInput.module.css +27 -0
- package/src/components/inputs/MRT_FilterTextInput.tsx +417 -0
- package/src/components/inputs/MRT_GlobalFilterTextInput.module.css +11 -0
- package/src/components/inputs/MRT_GlobalFilterTextInput.tsx +141 -0
- package/src/components/inputs/MRT_SelectCheckbox.tsx +137 -0
- package/src/components/menus/MRT_ColumnActionMenu.module.css +7 -0
- package/src/components/menus/MRT_ColumnActionMenu.tsx +287 -0
- package/src/components/menus/MRT_FilterOptionMenu.module.css +6 -0
- package/src/components/menus/MRT_FilterOptionMenu.tsx +274 -0
- package/src/components/menus/MRT_RowActionMenu.tsx +74 -0
- package/src/components/menus/MRT_ShowHideColumnsMenu.module.css +10 -0
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +135 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.module.css +35 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +170 -0
- package/src/components/modals/MRT_EditRowModal.tsx +97 -0
- package/src/components/table/MRT_Table.module.css +7 -0
- package/src/components/table/MRT_Table.tsx +110 -0
- package/src/components/table/MRT_TableContainer.module.css +20 -0
- package/src/components/table/MRT_TableContainer.tsx +109 -0
- package/src/components/table/MRT_TablePaper.module.css +88 -0
- package/src/components/table/MRT_TablePaper.tsx +92 -0
- package/src/components/toolbar/MRT_BottomToolbar.module.css +40 -0
- package/src/components/toolbar/MRT_BottomToolbar.tsx +100 -0
- package/src/components/toolbar/MRT_ProgressBar.module.css +10 -0
- package/src/components/toolbar/MRT_ProgressBar.tsx +53 -0
- package/src/components/toolbar/MRT_TablePagination.module.css +20 -0
- package/src/components/toolbar/MRT_TablePagination.tsx +166 -0
- package/src/components/toolbar/MRT_ToolbarAlertBanner.module.css +37 -0
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +168 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.module.css +23 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +67 -0
- package/src/components/toolbar/MRT_ToolbarInternalButtons.module.css +6 -0
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +73 -0
- package/src/components/toolbar/MRT_TopToolbar.module.css +24 -0
- package/src/components/toolbar/MRT_TopToolbar.tsx +128 -0
- package/src/components/toolbar/common.styles.module.css +10 -0
- package/src/fns/aggregationFns.ts +3 -0
- package/src/fns/filterFns.ts +272 -0
- package/src/fns/sortingFns.ts +34 -0
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +23 -0
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +30 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +92 -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 +34 -0
- package/src/hooks/useMRT_ColumnVirtualizer.ts +129 -0
- package/src/hooks/useMRT_Effects.ts +105 -0
- package/src/hooks/useMRT_RowVirtualizer.ts +95 -0
- package/src/hooks/useMRT_Rows.ts +46 -0
- package/src/hooks/useMRT_TableInstance.ts +314 -0
- package/src/hooks/useMRT_TableOptions.ts +264 -0
- package/src/hooks/useMantineReactTable.ts +14 -0
- package/src/icons.ts +73 -0
- package/src/index.ts +90 -0
- package/src/locales/ar.ts +96 -0
- package/src/locales/az.ts +96 -0
- package/src/locales/bg.ts +96 -0
- package/src/locales/cs.ts +97 -0
- package/src/locales/da.ts +96 -0
- package/src/locales/de.ts +96 -0
- package/src/locales/el.ts +96 -0
- package/src/locales/en.ts +96 -0
- package/src/locales/es.ts +96 -0
- package/src/locales/et.ts +97 -0
- package/src/locales/fa.ts +96 -0
- package/src/locales/fi.ts +97 -0
- package/src/locales/fr.ts +96 -0
- package/src/locales/he.ts +96 -0
- package/src/locales/hr.ts +96 -0
- package/src/locales/hu.ts +96 -0
- package/src/locales/hy.ts +96 -0
- package/src/locales/id.ts +97 -0
- package/src/locales/it.ts +96 -0
- package/src/locales/ja.ts +96 -0
- package/src/locales/ko.ts +96 -0
- package/src/locales/nl.ts +96 -0
- package/src/locales/no.ts +97 -0
- package/src/locales/np.ts +97 -0
- package/src/locales/pl.ts +96 -0
- package/src/locales/pt-BR.ts +96 -0
- package/src/locales/pt.ts +96 -0
- package/src/locales/ro.ts +96 -0
- package/src/locales/ru.ts +96 -0
- package/src/locales/sk.ts +97 -0
- package/src/locales/sr-Cyrl-RS.ts +96 -0
- package/src/locales/sr-Latn-RS.ts +96 -0
- package/src/locales/sv.ts +96 -0
- package/src/locales/tr.ts +96 -0
- package/src/locales/uk.ts +96 -0
- package/src/locales/vi.ts +96 -0
- package/src/locales/zh-Hans.ts +95 -0
- package/src/locales/zh-Hant.ts +95 -0
- package/src/types.ts +1276 -0
- package/src/typings.d.ts +1 -0
- package/src/utils/column.utils.ts +124 -0
- package/src/utils/displayColumn.utils.ts +153 -0
- package/src/utils/row.utils.ts +263 -0
- package/src/utils/style.utils.ts +32 -0
- package/src/utils/tanstack.helpers.ts +66 -0
- package/src/utils/utils.ts +4 -0
- package/src/utils/virtualization.utils.ts +19 -0
- package/styles.css +1320 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
|
|
3
|
+
import commonClasses from './common.styles.module.css';
|
|
4
|
+
import classes from './MRT_TopToolbar.module.css';
|
|
5
|
+
|
|
6
|
+
import { Box, type BoxProps, Flex } from '@mantine/core';
|
|
7
|
+
import { useMediaQuery } from '@mantine/hooks';
|
|
8
|
+
|
|
9
|
+
import { MRT_ProgressBar } from './MRT_ProgressBar';
|
|
10
|
+
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
11
|
+
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
12
|
+
import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone';
|
|
13
|
+
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
14
|
+
|
|
15
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
16
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
17
|
+
import { MRT_GlobalFilterTextInput } from '../inputs/MRT_GlobalFilterTextInput';
|
|
18
|
+
|
|
19
|
+
interface Props<TData extends MRT_RowData> extends BoxProps {
|
|
20
|
+
table: MRT_TableInstance<TData>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const MRT_TopToolbar = <TData extends MRT_RowData>({
|
|
24
|
+
table,
|
|
25
|
+
...rest
|
|
26
|
+
}: Props<TData>) => {
|
|
27
|
+
'use no memo';
|
|
28
|
+
const {
|
|
29
|
+
getState,
|
|
30
|
+
options: {
|
|
31
|
+
enableGlobalFilter,
|
|
32
|
+
enablePagination,
|
|
33
|
+
enableToolbarInternalActions,
|
|
34
|
+
mantineTopToolbarProps,
|
|
35
|
+
positionGlobalFilter,
|
|
36
|
+
positionPagination,
|
|
37
|
+
positionToolbarAlertBanner,
|
|
38
|
+
positionToolbarDropZone,
|
|
39
|
+
renderTopToolbarCustomActions,
|
|
40
|
+
},
|
|
41
|
+
refs: { topToolbarRef },
|
|
42
|
+
} = table;
|
|
43
|
+
|
|
44
|
+
const { isFullScreen, showGlobalFilter } = getState();
|
|
45
|
+
|
|
46
|
+
const isMobile = useMediaQuery('(max-width:720px)');
|
|
47
|
+
const isTablet = useMediaQuery('(max-width:1024px)');
|
|
48
|
+
|
|
49
|
+
const toolbarProps = {
|
|
50
|
+
...parseFromValuesOrFunc(mantineTopToolbarProps, { table }),
|
|
51
|
+
...rest,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const stackAlertBanner =
|
|
55
|
+
isMobile ||
|
|
56
|
+
!!renderTopToolbarCustomActions ||
|
|
57
|
+
(showGlobalFilter && isTablet);
|
|
58
|
+
|
|
59
|
+
const globalFilterProps = {
|
|
60
|
+
style: !isTablet
|
|
61
|
+
? {
|
|
62
|
+
zIndex: 3,
|
|
63
|
+
}
|
|
64
|
+
: undefined,
|
|
65
|
+
table,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Box
|
|
70
|
+
{...toolbarProps}
|
|
71
|
+
className={clsx(
|
|
72
|
+
commonClasses['common-toolbar-styles'],
|
|
73
|
+
classes['root'],
|
|
74
|
+
isFullScreen && classes['root-fullscreen'],
|
|
75
|
+
toolbarProps?.className,
|
|
76
|
+
)}
|
|
77
|
+
ref={(node: HTMLDivElement) => {
|
|
78
|
+
if (node) {
|
|
79
|
+
topToolbarRef.current = node;
|
|
80
|
+
if (toolbarProps?.ref) {
|
|
81
|
+
toolbarProps.ref.current = node;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{positionToolbarAlertBanner === 'top' && (
|
|
87
|
+
<MRT_ToolbarAlertBanner
|
|
88
|
+
stackAlertBanner={stackAlertBanner}
|
|
89
|
+
table={table}
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
92
|
+
{['both', 'top'].includes(positionToolbarDropZone ?? '') && (
|
|
93
|
+
<MRT_ToolbarDropZone table={table} />
|
|
94
|
+
)}
|
|
95
|
+
<Flex
|
|
96
|
+
className={clsx(
|
|
97
|
+
classes['actions-container'],
|
|
98
|
+
stackAlertBanner && classes['actions-container-stack-alert'],
|
|
99
|
+
)}
|
|
100
|
+
>
|
|
101
|
+
{enableGlobalFilter && positionGlobalFilter === 'left' && (
|
|
102
|
+
<MRT_GlobalFilterTextInput {...globalFilterProps} />
|
|
103
|
+
)}
|
|
104
|
+
{renderTopToolbarCustomActions?.({ table }) ?? <span />}
|
|
105
|
+
{enableToolbarInternalActions ? (
|
|
106
|
+
<Flex justify={'end'} wrap={'wrap-reverse'}>
|
|
107
|
+
{enableGlobalFilter && positionGlobalFilter === 'right' && (
|
|
108
|
+
<MRT_GlobalFilterTextInput {...globalFilterProps} />
|
|
109
|
+
)}
|
|
110
|
+
<MRT_ToolbarInternalButtons table={table} />
|
|
111
|
+
</Flex>
|
|
112
|
+
) : (
|
|
113
|
+
enableGlobalFilter &&
|
|
114
|
+
positionGlobalFilter === 'right' && (
|
|
115
|
+
<MRT_GlobalFilterTextInput {...globalFilterProps} />
|
|
116
|
+
)
|
|
117
|
+
)}
|
|
118
|
+
</Flex>
|
|
119
|
+
{enablePagination &&
|
|
120
|
+
['both', 'top'].includes(positionPagination ?? '') && (
|
|
121
|
+
<Flex justify="end">
|
|
122
|
+
<MRT_TablePagination position="top" table={table} />
|
|
123
|
+
</Flex>
|
|
124
|
+
)}
|
|
125
|
+
<MRT_ProgressBar isTopToolbar table={table} />
|
|
126
|
+
</Box>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type RankingInfo,
|
|
3
|
+
rankings,
|
|
4
|
+
rankItem,
|
|
5
|
+
} from '@tanstack/match-sorter-utils';
|
|
6
|
+
import { filterFns, type Row } from '@tanstack/react-table';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
type MRT_FilterOption,
|
|
10
|
+
type MRT_Localization,
|
|
11
|
+
type MRT_RowData,
|
|
12
|
+
} from '../types';
|
|
13
|
+
|
|
14
|
+
const parseComparableNumber = (value: unknown): null | number => {
|
|
15
|
+
if (value === null || value === undefined || value === '') {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (typeof value === 'number') {
|
|
20
|
+
return Number.isNaN(value) ? null : value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (value instanceof Date) {
|
|
24
|
+
const timestamp = value.getTime();
|
|
25
|
+
return Number.isNaN(timestamp) ? null : timestamp;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof value === 'string') {
|
|
29
|
+
const trimmed = value.trim();
|
|
30
|
+
if (!trimmed) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const asNumber = Number(trimmed);
|
|
35
|
+
if (!Number.isNaN(asNumber)) {
|
|
36
|
+
return asNumber;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const timestamp = Date.parse(trimmed);
|
|
40
|
+
if (!Number.isNaN(timestamp)) {
|
|
41
|
+
return timestamp;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (typeof value === 'object') {
|
|
48
|
+
const primitive = (value as { valueOf?: () => unknown }).valueOf?.();
|
|
49
|
+
if (primitive !== undefined && primitive !== value) {
|
|
50
|
+
return parseComparableNumber(primitive);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const normalizeStringValue = (value: unknown): string =>
|
|
58
|
+
value?.toString?.().toLowerCase().trim() ?? '';
|
|
59
|
+
|
|
60
|
+
const compareValues = (a: unknown, b: unknown): number => {
|
|
61
|
+
const aNumber = parseComparableNumber(a);
|
|
62
|
+
const bNumber = parseComparableNumber(b);
|
|
63
|
+
|
|
64
|
+
if (aNumber !== null && bNumber !== null) {
|
|
65
|
+
if (aNumber === bNumber) return 0;
|
|
66
|
+
return aNumber > bNumber ? 1 : -1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const aString = normalizeStringValue(a);
|
|
70
|
+
const bString = normalizeStringValue(b);
|
|
71
|
+
|
|
72
|
+
if (aString === bString) return 0;
|
|
73
|
+
return aString > bString ? 1 : -1;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const isNullishFilterValue = (value: unknown) =>
|
|
77
|
+
value === undefined || value === null || value === '';
|
|
78
|
+
|
|
79
|
+
const fuzzy = <TData extends MRT_RowData>(
|
|
80
|
+
row: Row<TData>,
|
|
81
|
+
columnId: string,
|
|
82
|
+
filterValue: number | string,
|
|
83
|
+
addMeta: (item: RankingInfo) => void,
|
|
84
|
+
) => {
|
|
85
|
+
const itemRank = rankItem(row.getValue(columnId), filterValue as string, {
|
|
86
|
+
threshold: rankings.MATCHES,
|
|
87
|
+
});
|
|
88
|
+
addMeta(itemRank);
|
|
89
|
+
return itemRank.passed;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
fuzzy.autoRemove = (val: any) => !val;
|
|
93
|
+
|
|
94
|
+
const contains = <TData extends MRT_RowData>(
|
|
95
|
+
row: Row<TData>,
|
|
96
|
+
id: string,
|
|
97
|
+
filterValue: number | string,
|
|
98
|
+
) =>
|
|
99
|
+
normalizeStringValue(row.getValue(id)).includes(
|
|
100
|
+
normalizeStringValue(filterValue),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
contains.autoRemove = (val: any) => !val;
|
|
104
|
+
|
|
105
|
+
const startsWith = <TData extends MRT_RowData>(
|
|
106
|
+
row: Row<TData>,
|
|
107
|
+
id: string,
|
|
108
|
+
filterValue: number | string,
|
|
109
|
+
) =>
|
|
110
|
+
normalizeStringValue(row.getValue(id)).startsWith(
|
|
111
|
+
normalizeStringValue(filterValue),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
startsWith.autoRemove = (val: any) => !val;
|
|
115
|
+
|
|
116
|
+
const endsWith = <TData extends MRT_RowData>(
|
|
117
|
+
row: Row<TData>,
|
|
118
|
+
id: string,
|
|
119
|
+
filterValue: number | string,
|
|
120
|
+
) =>
|
|
121
|
+
normalizeStringValue(row.getValue(id)).endsWith(
|
|
122
|
+
normalizeStringValue(filterValue),
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
endsWith.autoRemove = (val: any) => !val;
|
|
126
|
+
|
|
127
|
+
const equals = <TData extends MRT_RowData>(
|
|
128
|
+
row: Row<TData>,
|
|
129
|
+
id: string,
|
|
130
|
+
filterValue: number | string,
|
|
131
|
+
) => compareValues(row.getValue(id), filterValue) === 0;
|
|
132
|
+
|
|
133
|
+
equals.autoRemove = (val: any) => !val;
|
|
134
|
+
|
|
135
|
+
const notEquals = <TData extends MRT_RowData>(
|
|
136
|
+
row: Row<TData>,
|
|
137
|
+
id: string,
|
|
138
|
+
filterValue: number | string,
|
|
139
|
+
) => normalizeStringValue(row.getValue(id)) !== normalizeStringValue(filterValue);
|
|
140
|
+
|
|
141
|
+
notEquals.autoRemove = (val: any) => !val;
|
|
142
|
+
|
|
143
|
+
const greaterThan = <TData extends MRT_RowData>(
|
|
144
|
+
row: Row<TData>,
|
|
145
|
+
id: string,
|
|
146
|
+
filterValue: number | string,
|
|
147
|
+
) => compareValues(row.getValue(id), filterValue) > 0;
|
|
148
|
+
|
|
149
|
+
greaterThan.autoRemove = (val: any) => !val;
|
|
150
|
+
|
|
151
|
+
const greaterThanOrEqualTo = <TData extends MRT_RowData>(
|
|
152
|
+
row: Row<TData>,
|
|
153
|
+
id: string,
|
|
154
|
+
filterValue: number | string,
|
|
155
|
+
) => compareValues(row.getValue(id), filterValue) >= 0;
|
|
156
|
+
|
|
157
|
+
greaterThanOrEqualTo.autoRemove = (val: any) => !val;
|
|
158
|
+
|
|
159
|
+
const lessThan = <TData extends MRT_RowData>(
|
|
160
|
+
row: Row<TData>,
|
|
161
|
+
id: string,
|
|
162
|
+
filterValue: number | string,
|
|
163
|
+
) => compareValues(row.getValue(id), filterValue) < 0;
|
|
164
|
+
|
|
165
|
+
lessThan.autoRemove = (val: any) => !val;
|
|
166
|
+
|
|
167
|
+
const lessThanOrEqualTo = <TData extends MRT_RowData>(
|
|
168
|
+
row: Row<TData>,
|
|
169
|
+
id: string,
|
|
170
|
+
filterValue: number | string,
|
|
171
|
+
) => compareValues(row.getValue(id), filterValue) <= 0;
|
|
172
|
+
|
|
173
|
+
lessThanOrEqualTo.autoRemove = (val: any) => !val;
|
|
174
|
+
|
|
175
|
+
const between = <TData extends MRT_RowData>(
|
|
176
|
+
row: Row<TData>,
|
|
177
|
+
id: string,
|
|
178
|
+
filterValues: [number | string, number | string],
|
|
179
|
+
) => {
|
|
180
|
+
const [min, max] = filterValues;
|
|
181
|
+
|
|
182
|
+
if (isNullishFilterValue(min) && isNullishFilterValue(max)) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (!isNullishFilterValue(min) && compareValues(row.getValue(id), min) <= 0) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (!isNullishFilterValue(max) && compareValues(row.getValue(id), max) >= 0) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return true;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
between.autoRemove = (val: any) => !val;
|
|
198
|
+
|
|
199
|
+
const betweenInclusive = <TData extends MRT_RowData>(
|
|
200
|
+
row: Row<TData>,
|
|
201
|
+
id: string,
|
|
202
|
+
filterValues: [number | string, number | string],
|
|
203
|
+
) => {
|
|
204
|
+
const [min, max] = filterValues;
|
|
205
|
+
|
|
206
|
+
if (isNullishFilterValue(min) && isNullishFilterValue(max)) {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (
|
|
211
|
+
!isNullishFilterValue(min) &&
|
|
212
|
+
compareValues(row.getValue(id), min) < 0
|
|
213
|
+
) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (
|
|
218
|
+
!isNullishFilterValue(max) &&
|
|
219
|
+
compareValues(row.getValue(id), max) > 0
|
|
220
|
+
) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return true;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
betweenInclusive.autoRemove = (val: any) => !val;
|
|
228
|
+
|
|
229
|
+
const empty = <TData extends MRT_RowData>(
|
|
230
|
+
row: Row<TData>,
|
|
231
|
+
id: string,
|
|
232
|
+
_filterValue: number | string,
|
|
233
|
+
) => !row.getValue<number | string>(id)?.toString().trim();
|
|
234
|
+
|
|
235
|
+
empty.autoRemove = (val: any) => !val;
|
|
236
|
+
|
|
237
|
+
const notEmpty = <TData extends MRT_RowData>(
|
|
238
|
+
row: Row<TData>,
|
|
239
|
+
id: string,
|
|
240
|
+
_filterValue: number | string,
|
|
241
|
+
) => !!row.getValue<number | string>(id)?.toString().trim();
|
|
242
|
+
|
|
243
|
+
notEmpty.autoRemove = (val: any) => !val;
|
|
244
|
+
|
|
245
|
+
export const MRT_FilterFns = {
|
|
246
|
+
...filterFns,
|
|
247
|
+
between,
|
|
248
|
+
betweenInclusive,
|
|
249
|
+
contains,
|
|
250
|
+
empty,
|
|
251
|
+
endsWith,
|
|
252
|
+
equals,
|
|
253
|
+
fuzzy,
|
|
254
|
+
greaterThan,
|
|
255
|
+
greaterThanOrEqualTo,
|
|
256
|
+
lessThan,
|
|
257
|
+
lessThanOrEqualTo,
|
|
258
|
+
notEmpty,
|
|
259
|
+
notEquals,
|
|
260
|
+
startsWith,
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
export function localizedFilterOption(
|
|
264
|
+
localization: MRT_Localization,
|
|
265
|
+
option: MRT_FilterOption,
|
|
266
|
+
) {
|
|
267
|
+
if (!option) {
|
|
268
|
+
return '';
|
|
269
|
+
}
|
|
270
|
+
const key = `filter${option[0].toUpperCase()}${option.slice(1)}`;
|
|
271
|
+
return localization[key as keyof MRT_Localization] ?? '';
|
|
272
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { compareItems, type RankingInfo } from '@tanstack/match-sorter-utils';
|
|
2
|
+
import { type Row, sortingFns } from '@tanstack/react-table';
|
|
3
|
+
|
|
4
|
+
import { type MRT_Row, type MRT_RowData } from '../types';
|
|
5
|
+
|
|
6
|
+
const fuzzy = <TData extends MRT_RowData>(
|
|
7
|
+
rowA: Row<TData>,
|
|
8
|
+
rowB: Row<TData>,
|
|
9
|
+
columnId: string,
|
|
10
|
+
) => {
|
|
11
|
+
let dir = 0;
|
|
12
|
+
if (rowA.columnFiltersMeta[columnId]) {
|
|
13
|
+
dir = compareItems(
|
|
14
|
+
rowA.columnFiltersMeta[columnId] as RankingInfo,
|
|
15
|
+
rowB.columnFiltersMeta[columnId] as RankingInfo,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
// Provide a fallback for when the item ranks are equal
|
|
19
|
+
return dir === 0
|
|
20
|
+
? sortingFns.alphanumeric(rowA as Row<any>, rowB as Row<any>, columnId)
|
|
21
|
+
: dir;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const MRT_SortingFns = {
|
|
25
|
+
...sortingFns,
|
|
26
|
+
fuzzy,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const rankGlobalFuzzy = <TData extends MRT_RowData>(
|
|
30
|
+
rowA: MRT_Row<TData>,
|
|
31
|
+
rowB: MRT_Row<TData>,
|
|
32
|
+
) =>
|
|
33
|
+
Math.max(...Object.values(rowB.columnFiltersMeta).map((v: any) => v.rank)) -
|
|
34
|
+
Math.max(...Object.values(rowA.columnFiltersMeta).map((v: any) => v.rank));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MRT_ToggleRowActionMenuButton } from '../../components/buttons/MRT_ToggleRowActionMenuButton';
|
|
2
|
+
import {
|
|
3
|
+
type MRT_ColumnDef,
|
|
4
|
+
type MRT_RowData,
|
|
5
|
+
type MRT_StatefulTableOptions,
|
|
6
|
+
} from '../../types';
|
|
7
|
+
import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
|
|
8
|
+
|
|
9
|
+
export const getMRT_RowActionsColumnDef = <TData extends MRT_RowData>(
|
|
10
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
11
|
+
): MRT_ColumnDef<TData> | null => {
|
|
12
|
+
return {
|
|
13
|
+
Cell: ({ cell, row, table }) => (
|
|
14
|
+
<MRT_ToggleRowActionMenuButton cell={cell} row={row} table={table} />
|
|
15
|
+
),
|
|
16
|
+
...defaultDisplayColumnProps({
|
|
17
|
+
header: 'actions',
|
|
18
|
+
id: 'mrt-row-actions',
|
|
19
|
+
size: 70,
|
|
20
|
+
tableOptions,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
import { MRT_TableBodyRowGrabHandle } from '../../components/body/MRT_TableBodyRowGrabHandle';
|
|
4
|
+
import {
|
|
5
|
+
type MRT_ColumnDef,
|
|
6
|
+
type MRT_RowData,
|
|
7
|
+
type MRT_StatefulTableOptions,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
|
|
10
|
+
|
|
11
|
+
export const getMRT_RowDragColumnDef = <TData extends MRT_RowData>(
|
|
12
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
13
|
+
): MRT_ColumnDef<TData> | null => {
|
|
14
|
+
return {
|
|
15
|
+
Cell: ({ row, rowRef, table }) => (
|
|
16
|
+
<MRT_TableBodyRowGrabHandle
|
|
17
|
+
row={row}
|
|
18
|
+
rowRef={rowRef as RefObject<HTMLTableRowElement | null>}
|
|
19
|
+
table={table}
|
|
20
|
+
/>
|
|
21
|
+
),
|
|
22
|
+
grow: false,
|
|
23
|
+
...defaultDisplayColumnProps({
|
|
24
|
+
header: 'move',
|
|
25
|
+
id: 'mrt-row-drag',
|
|
26
|
+
size: 60,
|
|
27
|
+
tableOptions,
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Flex, Tooltip } from '@mantine/core';
|
|
4
|
+
|
|
5
|
+
import { MRT_ExpandAllButton } from '../../components/buttons/MRT_ExpandAllButton';
|
|
6
|
+
import { MRT_ExpandButton } from '../../components/buttons/MRT_ExpandButton';
|
|
7
|
+
import {
|
|
8
|
+
type MRT_ColumnDef,
|
|
9
|
+
type MRT_RowData,
|
|
10
|
+
type MRT_StatefulTableOptions,
|
|
11
|
+
} from '../../types';
|
|
12
|
+
import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
|
|
13
|
+
|
|
14
|
+
export const getMRT_RowExpandColumnDef = <TData extends MRT_RowData>(
|
|
15
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
16
|
+
): MRT_ColumnDef<TData> | null => {
|
|
17
|
+
const {
|
|
18
|
+
defaultColumn,
|
|
19
|
+
enableExpandAll,
|
|
20
|
+
groupedColumnMode,
|
|
21
|
+
positionExpandColumn,
|
|
22
|
+
renderDetailPanel,
|
|
23
|
+
state: { grouping },
|
|
24
|
+
} = tableOptions;
|
|
25
|
+
|
|
26
|
+
const alignProps =
|
|
27
|
+
positionExpandColumn === 'last'
|
|
28
|
+
? ({
|
|
29
|
+
align: 'right',
|
|
30
|
+
} as const)
|
|
31
|
+
: undefined;
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
Cell: ({ cell, column, row, table }) => {
|
|
35
|
+
const expandButtonProps = { row, table };
|
|
36
|
+
const subRowsLength = row.subRows?.length;
|
|
37
|
+
if (tableOptions.groupedColumnMode === 'remove' && row.groupingColumnId) {
|
|
38
|
+
return (
|
|
39
|
+
<Flex align="center" gap="0.25rem">
|
|
40
|
+
<MRT_ExpandButton {...expandButtonProps} />
|
|
41
|
+
<Tooltip
|
|
42
|
+
label={table.getColumn(row.groupingColumnId).columnDef.header}
|
|
43
|
+
openDelay={1000}
|
|
44
|
+
position="right"
|
|
45
|
+
>
|
|
46
|
+
<span>{row.groupingValue as ReactNode}</span>
|
|
47
|
+
</Tooltip>
|
|
48
|
+
{!!subRowsLength && <span>({subRowsLength})</span>}
|
|
49
|
+
</Flex>
|
|
50
|
+
);
|
|
51
|
+
} else {
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<MRT_ExpandButton {...expandButtonProps} />
|
|
55
|
+
{column.columnDef.GroupedCell?.({ cell, column, row, table })}
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
Header: enableExpandAll
|
|
61
|
+
? ({ table }) => {
|
|
62
|
+
return (
|
|
63
|
+
<Flex align="center">
|
|
64
|
+
<MRT_ExpandAllButton table={table} />
|
|
65
|
+
{groupedColumnMode === 'remove' &&
|
|
66
|
+
grouping
|
|
67
|
+
?.map(
|
|
68
|
+
(groupedColumnId) =>
|
|
69
|
+
table.getColumn(groupedColumnId).columnDef.header,
|
|
70
|
+
)
|
|
71
|
+
?.join(', ')}
|
|
72
|
+
</Flex>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
: undefined,
|
|
76
|
+
mantineTableBodyCellProps: alignProps,
|
|
77
|
+
mantineTableHeadCellProps: alignProps,
|
|
78
|
+
...defaultDisplayColumnProps({
|
|
79
|
+
header: 'expand',
|
|
80
|
+
id: 'mrt-row-expand',
|
|
81
|
+
size:
|
|
82
|
+
groupedColumnMode === 'remove'
|
|
83
|
+
? (defaultColumn?.size ?? 180)
|
|
84
|
+
: renderDetailPanel
|
|
85
|
+
? enableExpandAll
|
|
86
|
+
? 60
|
|
87
|
+
: 70
|
|
88
|
+
: 100,
|
|
89
|
+
tableOptions,
|
|
90
|
+
}),
|
|
91
|
+
};
|
|
92
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type MRT_ColumnDef,
|
|
3
|
+
type MRT_RowData,
|
|
4
|
+
type MRT_StatefulTableOptions,
|
|
5
|
+
} from '../../types';
|
|
6
|
+
import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
|
|
7
|
+
|
|
8
|
+
export const getMRT_RowNumbersColumnDef = <TData extends MRT_RowData>(
|
|
9
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
10
|
+
): MRT_ColumnDef<TData> | null => {
|
|
11
|
+
const { localization, rowNumberDisplayMode } = tableOptions;
|
|
12
|
+
const {
|
|
13
|
+
pagination: { pageIndex, pageSize },
|
|
14
|
+
} = tableOptions.state;
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
Cell: ({ renderedRowIndex = 0, row }) =>
|
|
18
|
+
((rowNumberDisplayMode === 'static'
|
|
19
|
+
? renderedRowIndex + pageSize * pageIndex
|
|
20
|
+
: row.index) ?? 0) + 1,
|
|
21
|
+
grow: false,
|
|
22
|
+
Header: () => localization.rowNumber,
|
|
23
|
+
...defaultDisplayColumnProps({
|
|
24
|
+
header: 'rowNumbers',
|
|
25
|
+
id: 'mrt-row-numbers',
|
|
26
|
+
size: 50,
|
|
27
|
+
tableOptions,
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MRT_TableBodyRowPinButton } from '../../components/body/MRT_TableBodyRowPinButton';
|
|
2
|
+
import {
|
|
3
|
+
type MRT_ColumnDef,
|
|
4
|
+
type MRT_RowData,
|
|
5
|
+
type MRT_StatefulTableOptions,
|
|
6
|
+
} from '../../types';
|
|
7
|
+
import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
|
|
8
|
+
|
|
9
|
+
export const getMRT_RowPinningColumnDef = <TData extends MRT_RowData>(
|
|
10
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
11
|
+
): MRT_ColumnDef<TData> | null => {
|
|
12
|
+
return {
|
|
13
|
+
Cell: ({ row, table }) => (
|
|
14
|
+
<MRT_TableBodyRowPinButton row={row} table={table} />
|
|
15
|
+
),
|
|
16
|
+
grow: false,
|
|
17
|
+
...defaultDisplayColumnProps({
|
|
18
|
+
header: 'pin',
|
|
19
|
+
id: 'mrt-row-pin',
|
|
20
|
+
size: 60,
|
|
21
|
+
tableOptions,
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { MRT_SelectCheckbox } from '../../components/inputs/MRT_SelectCheckbox';
|
|
2
|
+
import {
|
|
3
|
+
type MRT_ColumnDef,
|
|
4
|
+
type MRT_RowData,
|
|
5
|
+
type MRT_StatefulTableOptions,
|
|
6
|
+
} from '../../types';
|
|
7
|
+
import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
|
|
8
|
+
|
|
9
|
+
export const getMRT_RowSelectColumnDef = <TData extends MRT_RowData>(
|
|
10
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
11
|
+
): MRT_ColumnDef<TData> | null => {
|
|
12
|
+
const { enableMultiRowSelection, enableSelectAll } = tableOptions;
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
Cell: ({ renderedRowIndex, row, table }) => (
|
|
16
|
+
<MRT_SelectCheckbox
|
|
17
|
+
renderedRowIndex={renderedRowIndex}
|
|
18
|
+
row={row}
|
|
19
|
+
table={table}
|
|
20
|
+
/>
|
|
21
|
+
),
|
|
22
|
+
grow: false,
|
|
23
|
+
Header:
|
|
24
|
+
enableSelectAll && enableMultiRowSelection
|
|
25
|
+
? ({ table }) => <MRT_SelectCheckbox table={table} />
|
|
26
|
+
: undefined,
|
|
27
|
+
...defaultDisplayColumnProps({
|
|
28
|
+
header: 'select',
|
|
29
|
+
id: 'mrt-row-select',
|
|
30
|
+
size: enableSelectAll ? 60 : 70,
|
|
31
|
+
tableOptions,
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
};
|