@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,84 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
import classes from './MRT_CopyButton.module.css';
|
|
6
|
+
|
|
7
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
CopyButton,
|
|
11
|
+
Tooltip,
|
|
12
|
+
UnstyledButton,
|
|
13
|
+
type UnstyledButtonProps,
|
|
14
|
+
} from '@mantine/core';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
type MRT_Cell,
|
|
18
|
+
type MRT_CellValue,
|
|
19
|
+
type MRT_RowData,
|
|
20
|
+
type MRT_TableInstance,
|
|
21
|
+
} from '../../types';
|
|
22
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
23
|
+
|
|
24
|
+
interface Props<TData extends MRT_RowData, TValue = MRT_CellValue>
|
|
25
|
+
extends UnstyledButtonProps {
|
|
26
|
+
cell: MRT_Cell<TData, TValue>;
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
table: MRT_TableInstance<TData>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const MRT_CopyButton = <TData extends MRT_RowData>({
|
|
32
|
+
cell,
|
|
33
|
+
children,
|
|
34
|
+
table,
|
|
35
|
+
...rest
|
|
36
|
+
}: Props<TData>) => {
|
|
37
|
+
const {
|
|
38
|
+
options: {
|
|
39
|
+
localization: { clickToCopy, copiedToClipboard },
|
|
40
|
+
mantineCopyButtonProps,
|
|
41
|
+
},
|
|
42
|
+
} = table;
|
|
43
|
+
const { column, row } = cell;
|
|
44
|
+
const { columnDef } = column;
|
|
45
|
+
|
|
46
|
+
const arg = { cell, column, row, table };
|
|
47
|
+
const buttonProps = {
|
|
48
|
+
...parseFromValuesOrFunc(mantineCopyButtonProps, arg),
|
|
49
|
+
...parseFromValuesOrFunc(columnDef.mantineCopyButtonProps, arg),
|
|
50
|
+
...rest,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<CopyButton value={cell.getValue<string>()}>
|
|
55
|
+
{({ copied, copy }) => (
|
|
56
|
+
<Tooltip
|
|
57
|
+
color={copied ? 'green' : undefined}
|
|
58
|
+
label={
|
|
59
|
+
buttonProps?.title ?? (copied ? copiedToClipboard : clickToCopy)
|
|
60
|
+
}
|
|
61
|
+
openDelay={1000}
|
|
62
|
+
withinPortal
|
|
63
|
+
>
|
|
64
|
+
<UnstyledButton
|
|
65
|
+
{...buttonProps}
|
|
66
|
+
className={clsx(
|
|
67
|
+
'mrt-copy-button',
|
|
68
|
+
classes.root,
|
|
69
|
+
buttonProps?.className,
|
|
70
|
+
)}
|
|
71
|
+
onClick={(e) => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
copy();
|
|
74
|
+
}}
|
|
75
|
+
role="presentation"
|
|
76
|
+
title={undefined}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</UnstyledButton>
|
|
80
|
+
</Tooltip>
|
|
81
|
+
)}
|
|
82
|
+
</CopyButton>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
import classes from './MRT_EditActionButtons.module.css';
|
|
6
|
+
|
|
7
|
+
import { ActionIcon, Box, type BoxProps, Button, Tooltip } from '@mantine/core';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
type MRT_Row,
|
|
11
|
+
type MRT_RowData,
|
|
12
|
+
type MRT_TableInstance,
|
|
13
|
+
} from '../../types';
|
|
14
|
+
|
|
15
|
+
interface Props<TData extends MRT_RowData> extends BoxProps {
|
|
16
|
+
row: MRT_Row<TData>;
|
|
17
|
+
table: MRT_TableInstance<TData>;
|
|
18
|
+
variant?: 'icon' | 'text';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const MRT_EditActionButtons = <TData extends MRT_RowData>({
|
|
22
|
+
row,
|
|
23
|
+
table,
|
|
24
|
+
variant = 'icon',
|
|
25
|
+
...rest
|
|
26
|
+
}: Props<TData>) => {
|
|
27
|
+
const {
|
|
28
|
+
getState,
|
|
29
|
+
options: {
|
|
30
|
+
icons: { IconCircleX, IconDeviceFloppy },
|
|
31
|
+
localization,
|
|
32
|
+
onCreatingRowCancel,
|
|
33
|
+
onCreatingRowSave,
|
|
34
|
+
onEditingRowCancel,
|
|
35
|
+
onEditingRowSave,
|
|
36
|
+
},
|
|
37
|
+
refs: { editInputRefs },
|
|
38
|
+
setCreatingRow,
|
|
39
|
+
setEditingRow,
|
|
40
|
+
} = table;
|
|
41
|
+
const { creatingRow, editingRow, isSaving } = getState();
|
|
42
|
+
|
|
43
|
+
const isCreating = creatingRow?.id === row.id;
|
|
44
|
+
const isEditing = editingRow?.id === row.id;
|
|
45
|
+
|
|
46
|
+
const handleCancel = () => {
|
|
47
|
+
if (isCreating) {
|
|
48
|
+
onCreatingRowCancel?.({ row, table });
|
|
49
|
+
setCreatingRow(null);
|
|
50
|
+
} else if (isEditing) {
|
|
51
|
+
onEditingRowCancel?.({ row, table });
|
|
52
|
+
setEditingRow(null);
|
|
53
|
+
}
|
|
54
|
+
row._valuesCache = {} as any; //reset values cache
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const handleSubmitRow = () => {
|
|
58
|
+
//look for auto-filled input values. A browser can fill an input without
|
|
59
|
+
//firing the change event that saves the value to the row cache.
|
|
60
|
+
const inputNamePrefix = `${row.id}_`; //input names are cell ids: rowId_columnId
|
|
61
|
+
const valuesCache = row._valuesCache as Record<string, unknown>;
|
|
62
|
+
Object.values(editInputRefs?.current ?? {})
|
|
63
|
+
.filter((input) => input?.name?.startsWith(inputNamePrefix))
|
|
64
|
+
.forEach((input) => {
|
|
65
|
+
const columnId = input.name.slice(inputNamePrefix.length);
|
|
66
|
+
const editVariant = table.getColumn(columnId)?.columnDef.editVariant;
|
|
67
|
+
//select inputs show the option label, not the value, so only text inputs are read
|
|
68
|
+
const isTextInput = !editVariant || editVariant === 'text';
|
|
69
|
+
if (
|
|
70
|
+
isTextInput &&
|
|
71
|
+
Object.hasOwn(valuesCache, columnId) &&
|
|
72
|
+
//a number or other parsed value is the consumer's, and its text form can differ
|
|
73
|
+
(typeof valuesCache[columnId] === 'string' ||
|
|
74
|
+
valuesCache[columnId] == null) &&
|
|
75
|
+
input.value !== String(valuesCache[columnId] ?? '')
|
|
76
|
+
) {
|
|
77
|
+
valuesCache[columnId] = input.value;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
if (isCreating)
|
|
81
|
+
onCreatingRowSave?.({
|
|
82
|
+
exitCreatingMode: () => setCreatingRow(null),
|
|
83
|
+
row,
|
|
84
|
+
table,
|
|
85
|
+
values: row._valuesCache,
|
|
86
|
+
});
|
|
87
|
+
else if (isEditing) {
|
|
88
|
+
onEditingRowSave?.({
|
|
89
|
+
exitEditingMode: () => setEditingRow(null),
|
|
90
|
+
row,
|
|
91
|
+
table,
|
|
92
|
+
values: row?._valuesCache,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Box
|
|
99
|
+
className={clsx('mrt-edit-action-buttons', classes.root)}
|
|
100
|
+
onClick={(e) => e.stopPropagation()}
|
|
101
|
+
{...rest}
|
|
102
|
+
>
|
|
103
|
+
{variant === 'icon' ? (
|
|
104
|
+
<>
|
|
105
|
+
<Tooltip label={localization.cancel} withinPortal>
|
|
106
|
+
<ActionIcon
|
|
107
|
+
aria-label={localization.cancel}
|
|
108
|
+
color="red"
|
|
109
|
+
onClick={handleCancel}
|
|
110
|
+
variant="subtle"
|
|
111
|
+
>
|
|
112
|
+
<IconCircleX />
|
|
113
|
+
</ActionIcon>
|
|
114
|
+
</Tooltip>
|
|
115
|
+
<Tooltip label={localization.save} withinPortal>
|
|
116
|
+
<ActionIcon
|
|
117
|
+
aria-label={localization.save}
|
|
118
|
+
color="blue"
|
|
119
|
+
loading={isSaving}
|
|
120
|
+
onClick={handleSubmitRow}
|
|
121
|
+
variant="subtle"
|
|
122
|
+
>
|
|
123
|
+
<IconDeviceFloppy />
|
|
124
|
+
</ActionIcon>
|
|
125
|
+
</Tooltip>
|
|
126
|
+
</>
|
|
127
|
+
) : (
|
|
128
|
+
<>
|
|
129
|
+
<Button onClick={handleCancel} variant="subtle">
|
|
130
|
+
{localization.cancel}
|
|
131
|
+
</Button>
|
|
132
|
+
<Button loading={isSaving} onClick={handleSubmitRow} variant="filled">
|
|
133
|
+
{localization.save}
|
|
134
|
+
</Button>
|
|
135
|
+
</>
|
|
136
|
+
)}
|
|
137
|
+
</Box>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
margin-left: 6px;
|
|
3
|
+
opacity: 0.8;
|
|
4
|
+
&:disabled {
|
|
5
|
+
background-color: transparent;
|
|
6
|
+
border: none;
|
|
7
|
+
}
|
|
8
|
+
&:hover {
|
|
9
|
+
opacity: 1;
|
|
10
|
+
}
|
|
11
|
+
&:global(.xl) {
|
|
12
|
+
margin-left: -6px;
|
|
13
|
+
}
|
|
14
|
+
&:global(.md) {
|
|
15
|
+
margin-left: 0;
|
|
16
|
+
}
|
|
17
|
+
.chevron {
|
|
18
|
+
transition: transform 150ms;
|
|
19
|
+
&.up {
|
|
20
|
+
transform: rotate(-180deg);
|
|
21
|
+
}
|
|
22
|
+
&.right {
|
|
23
|
+
transform: rotate(-90deg);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
import classes from './MRT_ExpandAllButton.module.css';
|
|
6
|
+
|
|
7
|
+
import { ActionIcon, type ActionIconProps, Tooltip } from '@mantine/core';
|
|
8
|
+
|
|
9
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
10
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
11
|
+
|
|
12
|
+
interface Props<TData extends MRT_RowData> extends ActionIconProps {
|
|
13
|
+
table: MRT_TableInstance<TData>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const MRT_ExpandAllButton = <TData extends MRT_RowData>({
|
|
17
|
+
table,
|
|
18
|
+
...rest
|
|
19
|
+
}: Props<TData>) => {
|
|
20
|
+
const {
|
|
21
|
+
getCanSomeRowsExpand,
|
|
22
|
+
getIsAllRowsExpanded,
|
|
23
|
+
getIsSomeRowsExpanded,
|
|
24
|
+
getState,
|
|
25
|
+
options: {
|
|
26
|
+
icons: { IconChevronsDown },
|
|
27
|
+
localization,
|
|
28
|
+
mantineExpandAllButtonProps,
|
|
29
|
+
renderDetailPanel,
|
|
30
|
+
},
|
|
31
|
+
toggleAllRowsExpanded,
|
|
32
|
+
} = table;
|
|
33
|
+
const { density, isLoading } = getState();
|
|
34
|
+
|
|
35
|
+
const actionIconProps = {
|
|
36
|
+
...parseFromValuesOrFunc(mantineExpandAllButtonProps, {
|
|
37
|
+
table,
|
|
38
|
+
}),
|
|
39
|
+
...rest,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const isAllRowsExpanded = getIsAllRowsExpanded();
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Tooltip
|
|
46
|
+
label={
|
|
47
|
+
(actionIconProps?.title ?? isAllRowsExpanded)
|
|
48
|
+
? localization.collapseAll
|
|
49
|
+
: localization.expandAll
|
|
50
|
+
}
|
|
51
|
+
openDelay={1000}
|
|
52
|
+
withinPortal
|
|
53
|
+
>
|
|
54
|
+
<ActionIcon
|
|
55
|
+
aria-label={localization.expandAll}
|
|
56
|
+
color="gray"
|
|
57
|
+
variant="subtle"
|
|
58
|
+
{...actionIconProps}
|
|
59
|
+
className={clsx(
|
|
60
|
+
'mrt-expand-all-button',
|
|
61
|
+
classes.root,
|
|
62
|
+
actionIconProps?.className,
|
|
63
|
+
density,
|
|
64
|
+
)}
|
|
65
|
+
disabled={isLoading || (!renderDetailPanel && !getCanSomeRowsExpand())}
|
|
66
|
+
onClick={() => toggleAllRowsExpanded(!isAllRowsExpanded)}
|
|
67
|
+
title={undefined}
|
|
68
|
+
>
|
|
69
|
+
{actionIconProps?.children ?? (
|
|
70
|
+
<IconChevronsDown
|
|
71
|
+
className={clsx(
|
|
72
|
+
classes.chevron,
|
|
73
|
+
isAllRowsExpanded
|
|
74
|
+
? classes.up
|
|
75
|
+
: getIsSomeRowsExpanded()
|
|
76
|
+
? classes.right
|
|
77
|
+
: undefined,
|
|
78
|
+
)}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
</ActionIcon>
|
|
82
|
+
</Tooltip>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
opacity: 0.8;
|
|
3
|
+
&:disabled {
|
|
4
|
+
background-color: transparent;
|
|
5
|
+
border: none;
|
|
6
|
+
opacity: 0.3;
|
|
7
|
+
}
|
|
8
|
+
&:hover {
|
|
9
|
+
opacity: 1;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.root-ltr {
|
|
14
|
+
margin-left: calc(calc(var(--mrt-row-depth, 0)) * 16px);
|
|
15
|
+
.chevron {
|
|
16
|
+
transition: transform 200ms;
|
|
17
|
+
&.right {
|
|
18
|
+
transform: rotate(270deg);
|
|
19
|
+
}
|
|
20
|
+
&.up {
|
|
21
|
+
transform: rotate(-180deg);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.root-rtl {
|
|
27
|
+
margin-right: calc(calc(var(--mrt-row-depth, 0)) * 16px);
|
|
28
|
+
.chevron {
|
|
29
|
+
transition: transform 200ms;
|
|
30
|
+
&.right {
|
|
31
|
+
transform: rotate(-270deg);
|
|
32
|
+
}
|
|
33
|
+
&.up {
|
|
34
|
+
transform: rotate(180deg);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
import classes from './MRT_ExpandButton.module.css';
|
|
6
|
+
|
|
7
|
+
import { type MouseEvent } from 'react';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
ActionIcon,
|
|
11
|
+
type ActionIconProps,
|
|
12
|
+
Tooltip,
|
|
13
|
+
useDirection,
|
|
14
|
+
} from '@mantine/core';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
type MRT_Row,
|
|
18
|
+
type MRT_RowData,
|
|
19
|
+
type MRT_TableInstance,
|
|
20
|
+
} from '../../types';
|
|
21
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
22
|
+
import { MRT_EditCellTextInput } from '../inputs/MRT_EditCellTextInput';
|
|
23
|
+
|
|
24
|
+
interface Props<TData extends MRT_RowData> extends ActionIconProps {
|
|
25
|
+
row: MRT_Row<TData>;
|
|
26
|
+
table: MRT_TableInstance<TData>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const MRT_ExpandButton = <TData extends MRT_RowData>({
|
|
30
|
+
row,
|
|
31
|
+
table,
|
|
32
|
+
...rest
|
|
33
|
+
}: Props<TData>) => {
|
|
34
|
+
const direction = useDirection();
|
|
35
|
+
const {
|
|
36
|
+
options: {
|
|
37
|
+
icons: { IconChevronDown },
|
|
38
|
+
localization,
|
|
39
|
+
mantineExpandButtonProps,
|
|
40
|
+
positionExpandColumn,
|
|
41
|
+
renderDetailPanel,
|
|
42
|
+
},
|
|
43
|
+
} = table;
|
|
44
|
+
|
|
45
|
+
const actionIconProps = {
|
|
46
|
+
...parseFromValuesOrFunc(mantineExpandButtonProps, {
|
|
47
|
+
row,
|
|
48
|
+
table,
|
|
49
|
+
}),
|
|
50
|
+
...rest,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const internalEditComponents = row
|
|
54
|
+
.getAllCells()
|
|
55
|
+
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
|
56
|
+
.map((cell) => (
|
|
57
|
+
<MRT_EditCellTextInput cell={cell} key={cell.id} table={table} />
|
|
58
|
+
));
|
|
59
|
+
|
|
60
|
+
const canExpand = row.getCanExpand();
|
|
61
|
+
const isExpanded = row.getIsExpanded();
|
|
62
|
+
|
|
63
|
+
const DetailPanel = !!renderDetailPanel?.({
|
|
64
|
+
internalEditComponents,
|
|
65
|
+
row,
|
|
66
|
+
table,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
|
|
70
|
+
event.stopPropagation();
|
|
71
|
+
row.toggleExpanded();
|
|
72
|
+
actionIconProps?.onClick?.(event);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const rtl = direction.dir === 'rtl' || positionExpandColumn === 'last';
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Tooltip
|
|
79
|
+
disabled={!canExpand && !DetailPanel}
|
|
80
|
+
label={
|
|
81
|
+
actionIconProps?.title ??
|
|
82
|
+
(isExpanded ? localization.collapse : localization.expand)
|
|
83
|
+
}
|
|
84
|
+
openDelay={1000}
|
|
85
|
+
withinPortal
|
|
86
|
+
>
|
|
87
|
+
<ActionIcon
|
|
88
|
+
aria-label={localization.expand}
|
|
89
|
+
color="gray"
|
|
90
|
+
disabled={!canExpand && !DetailPanel}
|
|
91
|
+
variant="subtle"
|
|
92
|
+
{...actionIconProps}
|
|
93
|
+
__vars={{
|
|
94
|
+
'--mrt-row-depth': `${row.depth}`,
|
|
95
|
+
}}
|
|
96
|
+
className={clsx(
|
|
97
|
+
'mrt-expand-button',
|
|
98
|
+
classes.root,
|
|
99
|
+
classes[`root-${rtl ? 'rtl' : 'ltr'}`],
|
|
100
|
+
actionIconProps?.className,
|
|
101
|
+
)}
|
|
102
|
+
onClick={handleToggleExpand}
|
|
103
|
+
title={undefined}
|
|
104
|
+
>
|
|
105
|
+
{actionIconProps?.children ?? (
|
|
106
|
+
<IconChevronDown
|
|
107
|
+
className={clsx(
|
|
108
|
+
'mrt-expand-button-chevron',
|
|
109
|
+
classes.chevron,
|
|
110
|
+
!canExpand && !renderDetailPanel
|
|
111
|
+
? classes.right
|
|
112
|
+
: isExpanded
|
|
113
|
+
? classes.up
|
|
114
|
+
: undefined,
|
|
115
|
+
)}
|
|
116
|
+
/>
|
|
117
|
+
)}
|
|
118
|
+
</ActionIcon>
|
|
119
|
+
</Tooltip>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
import classes from './MRT_GrabHandleButton.module.css';
|
|
6
|
+
|
|
7
|
+
import { type DragEventHandler } from 'react';
|
|
8
|
+
|
|
9
|
+
import { ActionIcon, type ActionIconProps, Tooltip } from '@mantine/core';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
type HTMLPropsRef,
|
|
13
|
+
type MRT_RowData,
|
|
14
|
+
type MRT_TableInstance,
|
|
15
|
+
} from '../../types';
|
|
16
|
+
|
|
17
|
+
interface Props<TData extends MRT_RowData> {
|
|
18
|
+
actionIconProps?: ActionIconProps & HTMLPropsRef<HTMLButtonElement>;
|
|
19
|
+
onDragEnd: DragEventHandler<HTMLButtonElement>;
|
|
20
|
+
onDragStart: DragEventHandler<HTMLButtonElement>;
|
|
21
|
+
table: MRT_TableInstance<TData>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const MRT_GrabHandleButton = <TData extends MRT_RowData>({
|
|
25
|
+
actionIconProps,
|
|
26
|
+
onDragEnd,
|
|
27
|
+
onDragStart,
|
|
28
|
+
table: {
|
|
29
|
+
options: {
|
|
30
|
+
icons: { IconGripHorizontal },
|
|
31
|
+
localization: { move },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
}: Props<TData>) => {
|
|
35
|
+
return (
|
|
36
|
+
<Tooltip
|
|
37
|
+
label={actionIconProps?.title ?? move}
|
|
38
|
+
openDelay={1000}
|
|
39
|
+
withinPortal
|
|
40
|
+
>
|
|
41
|
+
<ActionIcon
|
|
42
|
+
aria-label={actionIconProps?.title ?? move}
|
|
43
|
+
draggable
|
|
44
|
+
{...actionIconProps}
|
|
45
|
+
className={clsx(
|
|
46
|
+
'mrt-grab-handle-button',
|
|
47
|
+
classes['grab-icon'],
|
|
48
|
+
actionIconProps?.className,
|
|
49
|
+
)}
|
|
50
|
+
color="gray"
|
|
51
|
+
onClick={(e) => {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
actionIconProps?.onClick?.(e);
|
|
54
|
+
}}
|
|
55
|
+
onDragEnd={onDragEnd}
|
|
56
|
+
onDragStart={onDragStart}
|
|
57
|
+
size="sm"
|
|
58
|
+
title={undefined}
|
|
59
|
+
variant="transparent"
|
|
60
|
+
>
|
|
61
|
+
<IconGripHorizontal size="100%" />
|
|
62
|
+
</ActionIcon>
|
|
63
|
+
</Tooltip>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import { type MouseEvent, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import { type RowPinningPosition } from '@tanstack/react-table';
|
|
6
|
+
|
|
7
|
+
import { ActionIcon, type ActionIconProps, Tooltip } from '@mantine/core';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
type MRT_Row,
|
|
11
|
+
type MRT_RowData,
|
|
12
|
+
type MRT_TableInstance,
|
|
13
|
+
} from '../../types';
|
|
14
|
+
|
|
15
|
+
interface Props<TData extends MRT_RowData> extends ActionIconProps {
|
|
16
|
+
pinningPosition: RowPinningPosition;
|
|
17
|
+
row: MRT_Row<TData>;
|
|
18
|
+
table: MRT_TableInstance<TData>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const MRT_RowPinButton = <TData extends MRT_RowData>({
|
|
22
|
+
pinningPosition,
|
|
23
|
+
row,
|
|
24
|
+
table,
|
|
25
|
+
...rest
|
|
26
|
+
}: Props<TData>) => {
|
|
27
|
+
const {
|
|
28
|
+
options: {
|
|
29
|
+
icons: { IconPinned, IconX },
|
|
30
|
+
localization,
|
|
31
|
+
rowPinningDisplayMode,
|
|
32
|
+
},
|
|
33
|
+
} = table;
|
|
34
|
+
|
|
35
|
+
const isPinned = row.getIsPinned();
|
|
36
|
+
|
|
37
|
+
const [tooltipOpened, setTooltipOpened] = useState(false);
|
|
38
|
+
|
|
39
|
+
const handleTogglePin = (event: MouseEvent<HTMLButtonElement>) => {
|
|
40
|
+
setTooltipOpened(false);
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
row.pin(isPinned ? false : pinningPosition);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Tooltip
|
|
47
|
+
label={isPinned ? localization.unpin : localization.pin}
|
|
48
|
+
openDelay={1000}
|
|
49
|
+
opened={tooltipOpened}
|
|
50
|
+
>
|
|
51
|
+
<ActionIcon
|
|
52
|
+
aria-label={localization.pin}
|
|
53
|
+
color="gray"
|
|
54
|
+
onClick={handleTogglePin}
|
|
55
|
+
onMouseEnter={() => setTooltipOpened(true)}
|
|
56
|
+
onMouseLeave={() => setTooltipOpened(false)}
|
|
57
|
+
size="xs"
|
|
58
|
+
style={{
|
|
59
|
+
height: '24px',
|
|
60
|
+
width: '24px',
|
|
61
|
+
}}
|
|
62
|
+
variant="subtle"
|
|
63
|
+
{...rest}
|
|
64
|
+
>
|
|
65
|
+
{isPinned ? (
|
|
66
|
+
<IconX />
|
|
67
|
+
) : (
|
|
68
|
+
<IconPinned
|
|
69
|
+
fontSize="small"
|
|
70
|
+
style={{
|
|
71
|
+
transform: `rotate(${
|
|
72
|
+
rowPinningDisplayMode === 'sticky'
|
|
73
|
+
? 135
|
|
74
|
+
: pinningPosition === 'top'
|
|
75
|
+
? 180
|
|
76
|
+
: 0
|
|
77
|
+
}deg)`,
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
</ActionIcon>
|
|
82
|
+
</Tooltip>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use no memo';
|
|
2
|
+
|
|
3
|
+
import { ActionIcon, type ActionIconProps, Menu, Tooltip } from '@mantine/core';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type HTMLPropsRef,
|
|
7
|
+
type MRT_RowData,
|
|
8
|
+
type MRT_TableInstance,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
11
|
+
|
|
12
|
+
interface Props<TData extends MRT_RowData>
|
|
13
|
+
extends ActionIconProps,
|
|
14
|
+
HTMLPropsRef<HTMLButtonElement> {
|
|
15
|
+
table: MRT_TableInstance<TData>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const MRT_ShowHideColumnsButton = <TData extends MRT_RowData>({
|
|
19
|
+
table,
|
|
20
|
+
title,
|
|
21
|
+
...rest
|
|
22
|
+
}: Props<TData>) => {
|
|
23
|
+
const {
|
|
24
|
+
icons: { IconColumns },
|
|
25
|
+
localization: { showHideColumns },
|
|
26
|
+
} = table.options;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Menu closeOnItemClick={false} withinPortal>
|
|
30
|
+
<Tooltip label={title ?? showHideColumns} withinPortal>
|
|
31
|
+
<Menu.Target>
|
|
32
|
+
<ActionIcon
|
|
33
|
+
aria-label={title ?? showHideColumns}
|
|
34
|
+
color="gray"
|
|
35
|
+
size="lg"
|
|
36
|
+
variant="subtle"
|
|
37
|
+
{...rest}
|
|
38
|
+
>
|
|
39
|
+
<IconColumns />
|
|
40
|
+
</ActionIcon>
|
|
41
|
+
</Menu.Target>
|
|
42
|
+
</Tooltip>
|
|
43
|
+
<MRT_ShowHideColumnsMenu table={table} />
|
|
44
|
+
</Menu>
|
|
45
|
+
);
|
|
46
|
+
};
|