@careharmony/mantine-react-table-ng 0.0.0-stage → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +217 -3
- package/dist/index.cjs +4023 -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 +3909 -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/th/index.cjs +97 -0
- package/locales/th/index.d.cts +3 -0
- package/locales/th/index.esm.d.mts +3 -0
- package/locales/th/index.esm.mjs +95 -0
- package/locales/th/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 +184 -4
- package/src/components/MantineReactTable.tsx +38 -0
- package/src/components/body/MRT_TableBody.module.css +42 -0
- package/src/components/body/MRT_TableBody.tsx +214 -0
- package/src/components/body/MRT_TableBodyCell.module.css +107 -0
- package/src/components/body/MRT_TableBodyCell.tsx +355 -0
- package/src/components/body/MRT_TableBodyCellValue.tsx +114 -0
- package/src/components/body/MRT_TableBodyEmptyRow.tsx +89 -0
- package/src/components/body/MRT_TableBodyRow.module.css +261 -0
- package/src/components/body/MRT_TableBodyRow.tsx +278 -0
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +59 -0
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +59 -0
- package/src/components/body/MRT_TableDetailPanel.module.css +35 -0
- package/src/components/body/MRT_TableDetailPanel.tsx +132 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.module.css +11 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +69 -0
- package/src/components/buttons/MRT_CopyButton.module.css +27 -0
- package/src/components/buttons/MRT_CopyButton.tsx +84 -0
- package/src/components/buttons/MRT_EditActionButtons.module.css +4 -0
- package/src/components/buttons/MRT_EditActionButtons.tsx +139 -0
- package/src/components/buttons/MRT_ExpandAllButton.module.css +26 -0
- package/src/components/buttons/MRT_ExpandAllButton.tsx +84 -0
- package/src/components/buttons/MRT_ExpandButton.module.css +37 -0
- package/src/components/buttons/MRT_ExpandButton.tsx +121 -0
- package/src/components/buttons/MRT_GrabHandleButton.module.css +6 -0
- package/src/components/buttons/MRT_GrabHandleButton.tsx +65 -0
- package/src/components/buttons/MRT_RowPinButton.tsx +84 -0
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +46 -0
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +66 -0
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +45 -0
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +59 -0
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +52 -0
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +87 -0
- package/src/components/footer/MRT_TableFooter.module.css +17 -0
- package/src/components/footer/MRT_TableFooter.tsx +70 -0
- package/src/components/footer/MRT_TableFooterCell.module.css +59 -0
- package/src/components/footer/MRT_TableFooterCell.tsx +126 -0
- package/src/components/footer/MRT_TableFooterRow.module.css +10 -0
- package/src/components/footer/MRT_TableFooterRow.tsx +111 -0
- package/src/components/head/MRT_TableHead.module.css +32 -0
- package/src/components/head/MRT_TableHead.tsx +106 -0
- package/src/components/head/MRT_TableHeadCell.module.css +172 -0
- package/src/components/head/MRT_TableHeadCell.tsx +317 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.module.css +5 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +123 -0
- package/src/components/head/MRT_TableHeadCellFilterLabel.module.css +14 -0
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +176 -0
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +82 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.module.css +44 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +68 -0
- package/src/components/head/MRT_TableHeadCellSortLabel.module.css +22 -0
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +90 -0
- package/src/components/head/MRT_TableHeadRow.module.css +12 -0
- package/src/components/head/MRT_TableHeadRow.tsx +105 -0
- package/src/components/inputs/MRT_EditCellTextInput.tsx +214 -0
- package/src/components/inputs/MRT_FilterCheckBox.module.css +4 -0
- package/src/components/inputs/MRT_FilterCheckbox.tsx +80 -0
- package/src/components/inputs/MRT_FilterRangeFields.module.css +5 -0
- package/src/components/inputs/MRT_FilterRangeFields.tsx +36 -0
- package/src/components/inputs/MRT_FilterRangeSlider.module.css +6 -0
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +107 -0
- package/src/components/inputs/MRT_FilterTextInput.module.css +27 -0
- package/src/components/inputs/MRT_FilterTextInput.tsx +418 -0
- package/src/components/inputs/MRT_GlobalFilterTextInput.module.css +11 -0
- package/src/components/inputs/MRT_GlobalFilterTextInput.tsx +142 -0
- package/src/components/inputs/MRT_SelectCheckbox.tsx +138 -0
- package/src/components/menus/MRT_ColumnActionMenu.module.css +7 -0
- package/src/components/menus/MRT_ColumnActionMenu.tsx +288 -0
- package/src/components/menus/MRT_FilterOptionMenu.module.css +6 -0
- package/src/components/menus/MRT_FilterOptionMenu.tsx +279 -0
- package/src/components/menus/MRT_RowActionMenu.tsx +75 -0
- package/src/components/menus/MRT_ShowHideColumnsMenu.module.css +10 -0
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +136 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.module.css +35 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +171 -0
- package/src/components/modals/MRT_EditRowModal.tsx +98 -0
- package/src/components/table/MRT_Table.module.css +7 -0
- package/src/components/table/MRT_Table.tsx +155 -0
- package/src/components/table/MRT_TableContainer.module.css +32 -0
- package/src/components/table/MRT_TableContainer.tsx +124 -0
- package/src/components/table/MRT_TablePaper.module.css +88 -0
- package/src/components/table/MRT_TablePaper.tsx +91 -0
- package/src/components/toolbar/MRT_BottomToolbar.module.css +40 -0
- package/src/components/toolbar/MRT_BottomToolbar.tsx +99 -0
- package/src/components/toolbar/MRT_ProgressBar.module.css +10 -0
- package/src/components/toolbar/MRT_ProgressBar.tsx +54 -0
- package/src/components/toolbar/MRT_TablePagination.module.css +20 -0
- package/src/components/toolbar/MRT_TablePagination.tsx +175 -0
- package/src/components/toolbar/MRT_ToolbarAlertBanner.module.css +37 -0
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +169 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.module.css +23 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +68 -0
- package/src/components/toolbar/MRT_ToolbarInternalButtons.module.css +6 -0
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +74 -0
- package/src/components/toolbar/MRT_TopToolbar.module.css +24 -0
- package/src/components/toolbar/MRT_TopToolbar.tsx +127 -0
- package/src/components/toolbar/common.styles.module.css +10 -0
- package/src/fns/aggregationFns.ts +3 -0
- package/src/fns/filterFns.ts +243 -0
- package/src/fns/sortingFns.ts +34 -0
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +25 -0
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +32 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +94 -0
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +32 -0
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +26 -0
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +36 -0
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +36 -0
- package/src/hooks/useMRT_ColumnVirtualizer.ts +135 -0
- package/src/hooks/useMRT_Effects.ts +109 -0
- package/src/hooks/useMRT_RowVirtualizer.ts +101 -0
- package/src/hooks/useMRT_Rows.ts +47 -0
- package/src/hooks/useMRT_TableInstance.ts +320 -0
- package/src/hooks/useMRT_TableOptions.ts +300 -0
- package/src/hooks/useMRT_TableSnapshot.ts +134 -0
- package/src/hooks/useMRT_VirtualizerScrollElement.ts +31 -0
- package/src/hooks/useMantineReactTable.ts +23 -0
- package/src/icons.ts +108 -0
- package/src/index.ts +91 -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/th.ts +97 -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 +1299 -0
- package/src/typings.d.ts +1 -0
- package/src/utils/column.utils.ts +157 -0
- package/src/utils/displayColumn.utils.ts +153 -0
- package/src/utils/row.utils.ts +263 -0
- package/src/utils/snapshot.utils.ts +97 -0
- package/src/utils/style.utils.ts +32 -0
- package/src/utils/tanstack.helpers.ts +66 -0
- package/src/utils/utils.ts +15 -0
- package/src/utils/virtualization.utils.ts +85 -0
- package/styles.css +1381 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
import classes from './MRT_ShowHideColumnsMenu.module.css';
|
|
6
|
+
|
|
7
|
+
import { useMemo, useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Button, Flex, Menu } from '@mantine/core';
|
|
10
|
+
|
|
11
|
+
import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
type MRT_Column,
|
|
15
|
+
type MRT_RowData,
|
|
16
|
+
type MRT_TableInstance,
|
|
17
|
+
} from '../../types';
|
|
18
|
+
import { getDefaultColumnOrderIds } from '../../utils/displayColumn.utils';
|
|
19
|
+
|
|
20
|
+
interface Props<TData extends MRT_RowData> {
|
|
21
|
+
table: MRT_TableInstance<TData>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
25
|
+
table,
|
|
26
|
+
}: Props<TData>) => {
|
|
27
|
+
const {
|
|
28
|
+
getAllColumns,
|
|
29
|
+
getAllLeafColumns,
|
|
30
|
+
getCenterLeafColumns,
|
|
31
|
+
getIsAllColumnsVisible,
|
|
32
|
+
getIsSomeColumnsPinned,
|
|
33
|
+
getIsSomeColumnsVisible,
|
|
34
|
+
getLeftLeafColumns,
|
|
35
|
+
getRightLeafColumns,
|
|
36
|
+
getState,
|
|
37
|
+
options: {
|
|
38
|
+
enableColumnOrdering,
|
|
39
|
+
enableColumnPinning,
|
|
40
|
+
enableHiding,
|
|
41
|
+
localization,
|
|
42
|
+
},
|
|
43
|
+
} = table;
|
|
44
|
+
const { columnOrder, columnPinning } = getState();
|
|
45
|
+
|
|
46
|
+
const handleToggleAllColumns = (value?: boolean) => {
|
|
47
|
+
getAllLeafColumns()
|
|
48
|
+
.filter((col) => col.columnDef.enableHiding !== false)
|
|
49
|
+
.forEach((col) => col.toggleVisibility(value));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const allColumns = useMemo(() => {
|
|
53
|
+
const columns = getAllColumns();
|
|
54
|
+
if (
|
|
55
|
+
columnOrder.length > 0 &&
|
|
56
|
+
!columns.some((col) => col.columnDef.columnDefType === 'group')
|
|
57
|
+
) {
|
|
58
|
+
return [
|
|
59
|
+
...getLeftLeafColumns(),
|
|
60
|
+
...Array.from(new Set(columnOrder)).map((colId) =>
|
|
61
|
+
getCenterLeafColumns().find((col) => col?.id === colId),
|
|
62
|
+
),
|
|
63
|
+
...getRightLeafColumns(),
|
|
64
|
+
].filter(Boolean);
|
|
65
|
+
}
|
|
66
|
+
return columns;
|
|
67
|
+
}, [
|
|
68
|
+
columnOrder,
|
|
69
|
+
columnPinning,
|
|
70
|
+
getAllColumns(),
|
|
71
|
+
getCenterLeafColumns(),
|
|
72
|
+
getLeftLeafColumns(),
|
|
73
|
+
getRightLeafColumns(),
|
|
74
|
+
]) as MRT_Column<TData>[];
|
|
75
|
+
|
|
76
|
+
const [hoveredColumn, setHoveredColumn] = useState<MRT_Column<TData> | null>(
|
|
77
|
+
null,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Menu.Dropdown className={clsx('mrt-show-hide-columns-menu', classes.root)}>
|
|
82
|
+
<Flex className={classes.content}>
|
|
83
|
+
{enableHiding && (
|
|
84
|
+
<Button
|
|
85
|
+
disabled={!getIsSomeColumnsVisible()}
|
|
86
|
+
onClick={() => handleToggleAllColumns(false)}
|
|
87
|
+
variant="subtle"
|
|
88
|
+
>
|
|
89
|
+
{localization.hideAll}
|
|
90
|
+
</Button>
|
|
91
|
+
)}
|
|
92
|
+
{enableColumnOrdering && (
|
|
93
|
+
<Button
|
|
94
|
+
onClick={() =>
|
|
95
|
+
table.setColumnOrder(
|
|
96
|
+
getDefaultColumnOrderIds(table.options as any, true),
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
variant="subtle"
|
|
100
|
+
>
|
|
101
|
+
{localization.resetOrder}
|
|
102
|
+
</Button>
|
|
103
|
+
)}
|
|
104
|
+
{enableColumnPinning && (
|
|
105
|
+
<Button
|
|
106
|
+
disabled={!getIsSomeColumnsPinned()}
|
|
107
|
+
onClick={() => table.resetColumnPinning(true)}
|
|
108
|
+
variant="subtle"
|
|
109
|
+
>
|
|
110
|
+
{localization.unpinAll}
|
|
111
|
+
</Button>
|
|
112
|
+
)}
|
|
113
|
+
{enableHiding && (
|
|
114
|
+
<Button
|
|
115
|
+
disabled={getIsAllColumnsVisible()}
|
|
116
|
+
onClick={() => handleToggleAllColumns(true)}
|
|
117
|
+
variant="subtle"
|
|
118
|
+
>
|
|
119
|
+
{localization.showAll}
|
|
120
|
+
</Button>
|
|
121
|
+
)}
|
|
122
|
+
</Flex>
|
|
123
|
+
<Menu.Divider />
|
|
124
|
+
{allColumns.map((column, index) => (
|
|
125
|
+
<MRT_ShowHideColumnsMenuItems
|
|
126
|
+
allColumns={allColumns}
|
|
127
|
+
column={column}
|
|
128
|
+
hoveredColumn={hoveredColumn}
|
|
129
|
+
key={`${index}-${column.id}`}
|
|
130
|
+
setHoveredColumn={setHoveredColumn}
|
|
131
|
+
table={table}
|
|
132
|
+
/>
|
|
133
|
+
))}
|
|
134
|
+
</Menu.Dropdown>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
align-items: center;
|
|
3
|
+
cursor: default;
|
|
4
|
+
justify-content: flex-start;
|
|
5
|
+
opacity: 1;
|
|
6
|
+
outline: none;
|
|
7
|
+
padding-left: var(--_column-depth);
|
|
8
|
+
padding-top: rem(6px);
|
|
9
|
+
padding-bottom: rem(6);
|
|
10
|
+
&[data-dragging] {
|
|
11
|
+
opacity: 0.5;
|
|
12
|
+
outline: 1px dashed var(--mantine-color-gray-7);
|
|
13
|
+
}
|
|
14
|
+
&[data-order-hovered]:not(&[data-dragging]) {
|
|
15
|
+
outline: 2px dashed var(--_hover-color);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
.menu {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
flex-wrap: nowrap;
|
|
22
|
+
gap: rem(8px);
|
|
23
|
+
}
|
|
24
|
+
.grab {
|
|
25
|
+
width: rem(28px);
|
|
26
|
+
}
|
|
27
|
+
.pin {
|
|
28
|
+
width: rem(70px);
|
|
29
|
+
}
|
|
30
|
+
.switch {
|
|
31
|
+
cursor: pointer !important;
|
|
32
|
+
}
|
|
33
|
+
.header {
|
|
34
|
+
align-self: center;
|
|
35
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import classes from './MRT_ShowHideColumnsMenuItems.module.css';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type Dispatch,
|
|
7
|
+
type DragEvent,
|
|
8
|
+
type SetStateAction,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
Box,
|
|
15
|
+
Menu,
|
|
16
|
+
Switch,
|
|
17
|
+
Text,
|
|
18
|
+
Tooltip,
|
|
19
|
+
useMantineTheme,
|
|
20
|
+
} from '@mantine/core';
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
type MRT_CellValue,
|
|
24
|
+
type MRT_Column,
|
|
25
|
+
type MRT_RowData,
|
|
26
|
+
type MRT_TableInstance,
|
|
27
|
+
} from '../../types';
|
|
28
|
+
import { reorderColumn } from '../../utils/column.utils';
|
|
29
|
+
import { dataVariable, getPrimaryColor } from '../../utils/style.utils';
|
|
30
|
+
import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
|
|
31
|
+
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
|
32
|
+
|
|
33
|
+
interface Props<TData extends MRT_RowData, TValue = MRT_CellValue> {
|
|
34
|
+
allColumns: MRT_Column<TData>[];
|
|
35
|
+
column: MRT_Column<TData, TValue>;
|
|
36
|
+
hoveredColumn: MRT_Column<TData> | null;
|
|
37
|
+
setHoveredColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
|
|
38
|
+
table: MRT_TableInstance<TData>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const MRT_ShowHideColumnsMenuItems = <TData extends MRT_RowData>({
|
|
42
|
+
allColumns,
|
|
43
|
+
column,
|
|
44
|
+
hoveredColumn,
|
|
45
|
+
setHoveredColumn,
|
|
46
|
+
table,
|
|
47
|
+
}: Props<TData>) => {
|
|
48
|
+
const theme = useMantineTheme();
|
|
49
|
+
const {
|
|
50
|
+
getState,
|
|
51
|
+
options: {
|
|
52
|
+
enableColumnOrdering,
|
|
53
|
+
enableColumnPinning,
|
|
54
|
+
enableHiding,
|
|
55
|
+
localization,
|
|
56
|
+
},
|
|
57
|
+
setColumnOrder,
|
|
58
|
+
} = table;
|
|
59
|
+
const { columnOrder } = getState();
|
|
60
|
+
const { columnDef } = column;
|
|
61
|
+
const { columnDefType } = columnDef;
|
|
62
|
+
|
|
63
|
+
const switchChecked =
|
|
64
|
+
(columnDefType !== 'group' && column.getIsVisible()) ||
|
|
65
|
+
(columnDefType === 'group' &&
|
|
66
|
+
column.getLeafColumns().some((col) => col.getIsVisible()));
|
|
67
|
+
|
|
68
|
+
const handleToggleColumnHidden = (column: MRT_Column<TData>) => {
|
|
69
|
+
if (columnDefType === 'group') {
|
|
70
|
+
column?.columns?.forEach?.((childColumn: MRT_Column<TData>) => {
|
|
71
|
+
childColumn.toggleVisibility(!switchChecked);
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
column.toggleVisibility();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const menuItemRef = useRef<HTMLElement>(null);
|
|
79
|
+
|
|
80
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
81
|
+
|
|
82
|
+
const handleDragStart = (e: DragEvent<HTMLButtonElement>) => {
|
|
83
|
+
setIsDragging(true);
|
|
84
|
+
e.dataTransfer.setDragImage(menuItemRef.current as HTMLElement, 0, 0);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleDragEnd = (_e: DragEvent<HTMLButtonElement>) => {
|
|
88
|
+
setIsDragging(false);
|
|
89
|
+
setHoveredColumn(null);
|
|
90
|
+
if (hoveredColumn) {
|
|
91
|
+
setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const handleDragEnter = (_e: DragEvent) => {
|
|
96
|
+
if (!isDragging && columnDef.enableColumnOrdering !== false) {
|
|
97
|
+
setHoveredColumn(column);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<>
|
|
107
|
+
<Menu.Item
|
|
108
|
+
className={classes.root}
|
|
109
|
+
component="span"
|
|
110
|
+
onDragEnter={handleDragEnter}
|
|
111
|
+
ref={menuItemRef as any}
|
|
112
|
+
style={{
|
|
113
|
+
'--_column-depth': `${(column.depth + 0.5) * 2}rem`,
|
|
114
|
+
'--_hover-color': getPrimaryColor(theme),
|
|
115
|
+
}}
|
|
116
|
+
{...dataVariable('dragging', isDragging)}
|
|
117
|
+
{...dataVariable('order-hovered', hoveredColumn?.id === column.id)}
|
|
118
|
+
>
|
|
119
|
+
<Box className={classes.menu}>
|
|
120
|
+
{columnDefType !== 'group' &&
|
|
121
|
+
enableColumnOrdering &&
|
|
122
|
+
!allColumns.some(
|
|
123
|
+
(col) => col.columnDef.columnDefType === 'group',
|
|
124
|
+
) &&
|
|
125
|
+
(columnDef.enableColumnOrdering !== false ? (
|
|
126
|
+
<MRT_GrabHandleButton
|
|
127
|
+
onDragEnd={handleDragEnd}
|
|
128
|
+
onDragStart={handleDragStart}
|
|
129
|
+
table={table}
|
|
130
|
+
/>
|
|
131
|
+
) : (
|
|
132
|
+
<Box className={classes.grab} />
|
|
133
|
+
))}
|
|
134
|
+
{enableColumnPinning &&
|
|
135
|
+
(column.getCanPin() ? (
|
|
136
|
+
<MRT_ColumnPinningButtons column={column} table={table} />
|
|
137
|
+
) : (
|
|
138
|
+
<Box className={classes.pin} />
|
|
139
|
+
))}
|
|
140
|
+
{enableHiding ? (
|
|
141
|
+
<Tooltip
|
|
142
|
+
label={localization.toggleVisibility}
|
|
143
|
+
openDelay={1000}
|
|
144
|
+
withinPortal
|
|
145
|
+
>
|
|
146
|
+
<Switch
|
|
147
|
+
checked={switchChecked}
|
|
148
|
+
className={classes.switch}
|
|
149
|
+
disabled={!column.getCanHide()}
|
|
150
|
+
label={columnDef.header}
|
|
151
|
+
onChange={() => handleToggleColumnHidden(column)}
|
|
152
|
+
/>
|
|
153
|
+
</Tooltip>
|
|
154
|
+
) : (
|
|
155
|
+
<Text className={classes.header}>{columnDef.header}</Text>
|
|
156
|
+
)}
|
|
157
|
+
</Box>
|
|
158
|
+
</Menu.Item>
|
|
159
|
+
{column.columns?.map((c: MRT_Column<TData>, i) => (
|
|
160
|
+
<MRT_ShowHideColumnsMenuItems
|
|
161
|
+
allColumns={allColumns}
|
|
162
|
+
column={c}
|
|
163
|
+
hoveredColumn={hoveredColumn}
|
|
164
|
+
key={`${i}-${c.id}`}
|
|
165
|
+
setHoveredColumn={setHoveredColumn}
|
|
166
|
+
table={table}
|
|
167
|
+
/>
|
|
168
|
+
))}
|
|
169
|
+
</>
|
|
170
|
+
);
|
|
171
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import { Flex, Modal, type ModalProps, Stack } from '@mantine/core';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type MRT_Row,
|
|
7
|
+
type MRT_RowData,
|
|
8
|
+
type MRT_TableInstance,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
11
|
+
import { MRT_EditActionButtons } from '../buttons/MRT_EditActionButtons';
|
|
12
|
+
import { MRT_EditCellTextInput } from '../inputs/MRT_EditCellTextInput';
|
|
13
|
+
|
|
14
|
+
interface Props<TData extends MRT_RowData> extends Partial<ModalProps> {
|
|
15
|
+
open: boolean;
|
|
16
|
+
table: MRT_TableInstance<TData>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const MRT_EditRowModal = <TData extends MRT_RowData>({
|
|
20
|
+
open,
|
|
21
|
+
table,
|
|
22
|
+
...rest
|
|
23
|
+
}: Props<TData>) => {
|
|
24
|
+
const {
|
|
25
|
+
getState,
|
|
26
|
+
options: {
|
|
27
|
+
mantineCreateRowModalProps,
|
|
28
|
+
mantineEditRowModalProps,
|
|
29
|
+
onCreatingRowCancel,
|
|
30
|
+
onEditingRowCancel,
|
|
31
|
+
renderCreateRowModalContent,
|
|
32
|
+
renderEditRowModalContent,
|
|
33
|
+
},
|
|
34
|
+
setCreatingRow,
|
|
35
|
+
setEditingRow,
|
|
36
|
+
} = table;
|
|
37
|
+
const { creatingRow, editingRow } = getState();
|
|
38
|
+
const row = (creatingRow ?? editingRow) as MRT_Row<TData>;
|
|
39
|
+
|
|
40
|
+
const arg = { row, table };
|
|
41
|
+
const modalProps = {
|
|
42
|
+
...parseFromValuesOrFunc(mantineEditRowModalProps, arg),
|
|
43
|
+
...(creatingRow && parseFromValuesOrFunc(mantineCreateRowModalProps, arg)),
|
|
44
|
+
...rest,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const internalEditComponents = row
|
|
48
|
+
.getAllCells()
|
|
49
|
+
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
|
50
|
+
.map((cell) => (
|
|
51
|
+
<MRT_EditCellTextInput cell={cell} key={cell.id} table={table} />
|
|
52
|
+
));
|
|
53
|
+
|
|
54
|
+
const handleCancel = () => {
|
|
55
|
+
if (creatingRow) {
|
|
56
|
+
onCreatingRowCancel?.({ row, table });
|
|
57
|
+
setCreatingRow(null);
|
|
58
|
+
} else {
|
|
59
|
+
onEditingRowCancel?.({ row, table });
|
|
60
|
+
setEditingRow(null);
|
|
61
|
+
}
|
|
62
|
+
row._valuesCache = {} as any; //reset values cache
|
|
63
|
+
modalProps.onClose?.();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Modal
|
|
68
|
+
opened={open}
|
|
69
|
+
withCloseButton={false}
|
|
70
|
+
{...modalProps}
|
|
71
|
+
key={row.id}
|
|
72
|
+
onClose={handleCancel}
|
|
73
|
+
>
|
|
74
|
+
{((creatingRow &&
|
|
75
|
+
renderCreateRowModalContent?.({
|
|
76
|
+
internalEditComponents,
|
|
77
|
+
row,
|
|
78
|
+
table,
|
|
79
|
+
})) ||
|
|
80
|
+
renderEditRowModalContent?.({
|
|
81
|
+
internalEditComponents,
|
|
82
|
+
row,
|
|
83
|
+
table,
|
|
84
|
+
})) ?? (
|
|
85
|
+
<>
|
|
86
|
+
<form onSubmit={(e) => e.preventDefault()}>
|
|
87
|
+
<Stack gap="lg" pb={24} pt={16}>
|
|
88
|
+
{internalEditComponents}
|
|
89
|
+
</Stack>
|
|
90
|
+
</form>
|
|
91
|
+
<Flex justify="flex-end">
|
|
92
|
+
<MRT_EditActionButtons row={row} table={table} variant="text" />
|
|
93
|
+
</Flex>
|
|
94
|
+
</>
|
|
95
|
+
)}
|
|
96
|
+
</Modal>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
import classes from './MRT_Table.module.css';
|
|
6
|
+
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
darken,
|
|
11
|
+
lighten,
|
|
12
|
+
Table,
|
|
13
|
+
type TableProps,
|
|
14
|
+
type TableScrollContainerProps,
|
|
15
|
+
useMantineColorScheme,
|
|
16
|
+
} from '@mantine/core';
|
|
17
|
+
|
|
18
|
+
import { useMRT_ColumnVirtualizer } from '../../hooks/useMRT_ColumnVirtualizer';
|
|
19
|
+
import {
|
|
20
|
+
type MRT_RowData,
|
|
21
|
+
type MRT_ScrollAreaProps,
|
|
22
|
+
type MRT_TableInstance,
|
|
23
|
+
} from '../../types';
|
|
24
|
+
import { parseCSSVarId } from '../../utils/style.utils';
|
|
25
|
+
import { assignRef, parseFromValuesOrFunc } from '../../utils/utils';
|
|
26
|
+
import { Memo_MRT_TableBody, MRT_TableBody } from '../body/MRT_TableBody';
|
|
27
|
+
import { MRT_TableFooter } from '../footer/MRT_TableFooter';
|
|
28
|
+
import { MRT_TableHead } from '../head/MRT_TableHead';
|
|
29
|
+
|
|
30
|
+
interface Props<TData extends MRT_RowData> extends TableProps {
|
|
31
|
+
table: MRT_TableInstance<TData>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const MRT_Table = <TData extends MRT_RowData>({
|
|
35
|
+
table,
|
|
36
|
+
...rest
|
|
37
|
+
}: Props<TData>) => {
|
|
38
|
+
const {
|
|
39
|
+
getFlatHeaders,
|
|
40
|
+
getState,
|
|
41
|
+
options: {
|
|
42
|
+
columns,
|
|
43
|
+
enableTableFooter,
|
|
44
|
+
enableTableHead,
|
|
45
|
+
layoutMode,
|
|
46
|
+
mantineScrollAreaProps,
|
|
47
|
+
mantineTableProps,
|
|
48
|
+
memoMode,
|
|
49
|
+
withScrollArea,
|
|
50
|
+
},
|
|
51
|
+
} = table;
|
|
52
|
+
const { columnSizing, columnSizingInfo, columnVisibility, density } =
|
|
53
|
+
getState();
|
|
54
|
+
|
|
55
|
+
const tableProps = {
|
|
56
|
+
highlightOnHover: true,
|
|
57
|
+
horizontalSpacing: density,
|
|
58
|
+
verticalSpacing: density,
|
|
59
|
+
...parseFromValuesOrFunc(mantineTableProps, { table }),
|
|
60
|
+
...rest,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const columnSizeVars = useMemo(() => {
|
|
64
|
+
const headers = getFlatHeaders();
|
|
65
|
+
const colSizes: { [key: string]: number } = {};
|
|
66
|
+
for (let i = 0; i < headers.length; i++) {
|
|
67
|
+
const header = headers[i];
|
|
68
|
+
const colSize = header.getSize();
|
|
69
|
+
colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
|
|
70
|
+
colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
|
71
|
+
}
|
|
72
|
+
return colSizes;
|
|
73
|
+
}, [columns, columnSizing, columnSizingInfo, columnVisibility]);
|
|
74
|
+
|
|
75
|
+
const columnVirtualizer = useMRT_ColumnVirtualizer(table);
|
|
76
|
+
|
|
77
|
+
const commonTableGroupProps = {
|
|
78
|
+
columnVirtualizer,
|
|
79
|
+
table,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const { colorScheme } = useMantineColorScheme();
|
|
83
|
+
|
|
84
|
+
const { stripedColor } = tableProps;
|
|
85
|
+
|
|
86
|
+
const tableNode = (
|
|
87
|
+
<Table
|
|
88
|
+
className={clsx(
|
|
89
|
+
'mrt-table',
|
|
90
|
+
classes.root,
|
|
91
|
+
layoutMode?.startsWith('grid') && classes['root-grid'],
|
|
92
|
+
tableProps.className,
|
|
93
|
+
)}
|
|
94
|
+
{...tableProps}
|
|
95
|
+
__vars={{
|
|
96
|
+
...columnSizeVars,
|
|
97
|
+
'--mrt-striped-row-background-color': stripedColor,
|
|
98
|
+
'--mrt-striped-row-hover-background-color': stripedColor
|
|
99
|
+
? colorScheme === 'dark'
|
|
100
|
+
? lighten(stripedColor, 0.08)
|
|
101
|
+
: darken(stripedColor, 0.12)
|
|
102
|
+
: undefined,
|
|
103
|
+
...tableProps.__vars,
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
{enableTableHead && <MRT_TableHead {...commonTableGroupProps} />}
|
|
107
|
+
{memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (
|
|
108
|
+
<Memo_MRT_TableBody
|
|
109
|
+
{...commonTableGroupProps}
|
|
110
|
+
tableProps={tableProps}
|
|
111
|
+
/>
|
|
112
|
+
) : (
|
|
113
|
+
<MRT_TableBody {...commonTableGroupProps} tableProps={tableProps} />
|
|
114
|
+
)}
|
|
115
|
+
{enableTableFooter && <MRT_TableFooter {...commonTableGroupProps} />}
|
|
116
|
+
</Table>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
if (!withScrollArea) return tableNode;
|
|
120
|
+
|
|
121
|
+
const {
|
|
122
|
+
ref: scrollAreaRef,
|
|
123
|
+
viewportRef,
|
|
124
|
+
...scrollContainerProps
|
|
125
|
+
} = {
|
|
126
|
+
h: '100%',
|
|
127
|
+
minWidth: '100%',
|
|
128
|
+
offsetScrollbars: 'present',
|
|
129
|
+
w: '100%',
|
|
130
|
+
...parseFromValuesOrFunc(mantineScrollAreaProps, { table }),
|
|
131
|
+
} as MRT_ScrollAreaProps & TableScrollContainerProps;
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<Table.ScrollContainer
|
|
135
|
+
{...scrollContainerProps}
|
|
136
|
+
className={clsx(
|
|
137
|
+
'mrt-table-scroll-area',
|
|
138
|
+
scrollContainerProps.className,
|
|
139
|
+
)}
|
|
140
|
+
//Mantine hands over the viewport itself, and null when it unmounts, so
|
|
141
|
+
//the ref does not depend on a class name and never keeps a removed node
|
|
142
|
+
scrollAreaProps={{
|
|
143
|
+
...scrollContainerProps.scrollAreaProps,
|
|
144
|
+
viewportRef: (node: HTMLDivElement | null) => {
|
|
145
|
+
table.refs.scrollAreaViewportRef.current = node;
|
|
146
|
+
assignRef(scrollAreaRef, node);
|
|
147
|
+
assignRef(viewportRef, node);
|
|
148
|
+
assignRef(scrollContainerProps.scrollAreaProps?.viewportRef, node);
|
|
149
|
+
},
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
{tableNode}
|
|
153
|
+
</Table.ScrollContainer>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
--max-height-calc: calc(100vh - calc(var(--mrt-top-toolbar-height) * 1px));
|
|
3
|
+
--max-height: 100%;
|
|
4
|
+
|
|
5
|
+
background-color: var(--mrt-base-background-color);
|
|
6
|
+
max-width: 100%;
|
|
7
|
+
position: relative;
|
|
8
|
+
overflow: auto;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* set by the `withScrollArea` option, so a ScrollArea in a cell or detail panel does not match */
|
|
12
|
+
.root-scroll-area {
|
|
13
|
+
overflow: unset;
|
|
14
|
+
height: var(--max-height-calc);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.root-sticky {
|
|
18
|
+
--max-height: clamp(350px, var(--max-height-calc), 9999px);
|
|
19
|
+
max-height: var(--max-height);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.root-fullscreen {
|
|
23
|
+
--max-height: var(--max-height-calc) !important;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.root > :global(.mrt-table-scroll-area) {
|
|
27
|
+
max-height: var(--max-height);
|
|
28
|
+
|
|
29
|
+
> [data-orientation='vertical'] {
|
|
30
|
+
top: var(--mrt-scroll-offset);
|
|
31
|
+
}
|
|
32
|
+
}
|