@lminii/material-react-table 4.0.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 +22 -0
- package/README.md +234 -0
- package/dist/index.d.mts +2408 -0
- package/dist/index.d.ts +2408 -0
- package/dist/index.js +4825 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4631 -0
- package/dist/index.mjs.map +1 -0
- package/locales/ar/index.d.mts +3 -0
- package/locales/ar/index.d.ts +3 -0
- package/locales/ar/index.js +100 -0
- package/locales/ar/index.mjs +96 -0
- package/locales/ar/package.json +6 -0
- package/locales/az/index.d.mts +3 -0
- package/locales/az/index.d.ts +3 -0
- package/locales/az/index.js +100 -0
- package/locales/az/index.mjs +96 -0
- package/locales/az/package.json +6 -0
- package/locales/bg/index.d.mts +3 -0
- package/locales/bg/index.d.ts +3 -0
- package/locales/bg/index.js +100 -0
- package/locales/bg/index.mjs +96 -0
- package/locales/bg/package.json +6 -0
- package/locales/cs/index.d.mts +3 -0
- package/locales/cs/index.d.ts +3 -0
- package/locales/cs/index.js +100 -0
- package/locales/cs/index.mjs +96 -0
- package/locales/cs/package.json +6 -0
- package/locales/da/index.d.mts +3 -0
- package/locales/da/index.d.ts +3 -0
- package/locales/da/index.js +100 -0
- package/locales/da/index.mjs +96 -0
- package/locales/da/package.json +6 -0
- package/locales/de/index.d.mts +3 -0
- package/locales/de/index.d.ts +3 -0
- package/locales/de/index.js +100 -0
- package/locales/de/index.mjs +96 -0
- package/locales/de/package.json +6 -0
- package/locales/el/index.d.mts +3 -0
- package/locales/el/index.d.ts +3 -0
- package/locales/el/index.js +100 -0
- package/locales/el/index.mjs +96 -0
- package/locales/el/package.json +6 -0
- package/locales/en/index.d.mts +3 -0
- package/locales/en/index.d.ts +3 -0
- package/locales/en/index.js +100 -0
- package/locales/en/index.mjs +96 -0
- package/locales/en/package.json +6 -0
- package/locales/es/index.d.mts +3 -0
- package/locales/es/index.d.ts +3 -0
- package/locales/es/index.js +100 -0
- package/locales/es/index.mjs +96 -0
- package/locales/es/package.json +6 -0
- package/locales/et/index.d.mts +3 -0
- package/locales/et/index.d.ts +3 -0
- package/locales/et/index.js +100 -0
- package/locales/et/index.mjs +96 -0
- package/locales/et/package.json +6 -0
- package/locales/fa/index.d.mts +3 -0
- package/locales/fa/index.d.ts +3 -0
- package/locales/fa/index.js +100 -0
- package/locales/fa/index.mjs +96 -0
- package/locales/fa/package.json +6 -0
- package/locales/fi/index.d.mts +3 -0
- package/locales/fi/index.d.ts +3 -0
- package/locales/fi/index.js +100 -0
- package/locales/fi/index.mjs +96 -0
- package/locales/fi/package.json +6 -0
- package/locales/fr/index.d.mts +3 -0
- package/locales/fr/index.d.ts +3 -0
- package/locales/fr/index.js +100 -0
- package/locales/fr/index.mjs +96 -0
- package/locales/fr/package.json +6 -0
- package/locales/he/index.d.mts +3 -0
- package/locales/he/index.d.ts +3 -0
- package/locales/he/index.js +100 -0
- package/locales/he/index.mjs +96 -0
- package/locales/he/package.json +6 -0
- package/locales/hr/index.d.mts +3 -0
- package/locales/hr/index.d.ts +3 -0
- package/locales/hr/index.js +100 -0
- package/locales/hr/index.mjs +96 -0
- package/locales/hr/package.json +6 -0
- package/locales/hu/index.d.mts +3 -0
- package/locales/hu/index.d.ts +3 -0
- package/locales/hu/index.js +100 -0
- package/locales/hu/index.mjs +96 -0
- package/locales/hu/package.json +6 -0
- package/locales/hy/index.d.mts +3 -0
- package/locales/hy/index.d.ts +3 -0
- package/locales/hy/index.js +100 -0
- package/locales/hy/index.mjs +96 -0
- package/locales/hy/package.json +6 -0
- package/locales/id/index.d.mts +3 -0
- package/locales/id/index.d.ts +3 -0
- package/locales/id/index.js +100 -0
- package/locales/id/index.mjs +96 -0
- package/locales/id/package.json +6 -0
- package/locales/it/index.d.mts +3 -0
- package/locales/it/index.d.ts +3 -0
- package/locales/it/index.js +100 -0
- package/locales/it/index.mjs +96 -0
- package/locales/it/package.json +6 -0
- package/locales/ja/index.d.mts +3 -0
- package/locales/ja/index.d.ts +3 -0
- package/locales/ja/index.js +100 -0
- package/locales/ja/index.mjs +96 -0
- package/locales/ja/package.json +6 -0
- package/locales/ko/index.d.mts +3 -0
- package/locales/ko/index.d.ts +3 -0
- package/locales/ko/index.js +100 -0
- package/locales/ko/index.mjs +96 -0
- package/locales/ko/package.json +6 -0
- package/locales/nl/index.d.mts +3 -0
- package/locales/nl/index.d.ts +3 -0
- package/locales/nl/index.js +100 -0
- package/locales/nl/index.mjs +96 -0
- package/locales/nl/package.json +6 -0
- package/locales/no/index.d.mts +3 -0
- package/locales/no/index.d.ts +3 -0
- package/locales/no/index.js +100 -0
- package/locales/no/index.mjs +96 -0
- package/locales/no/package.json +6 -0
- package/locales/np/index.d.mts +3 -0
- package/locales/np/index.d.ts +3 -0
- package/locales/np/index.js +100 -0
- package/locales/np/index.mjs +96 -0
- package/locales/np/package.json +6 -0
- package/locales/pl/index.d.mts +3 -0
- package/locales/pl/index.d.ts +3 -0
- package/locales/pl/index.js +100 -0
- package/locales/pl/index.mjs +96 -0
- package/locales/pl/package.json +6 -0
- package/locales/pt/index.d.mts +3 -0
- package/locales/pt/index.d.ts +3 -0
- package/locales/pt/index.js +100 -0
- package/locales/pt/index.mjs +96 -0
- package/locales/pt/package.json +6 -0
- package/locales/pt-BR/index.d.mts +3 -0
- package/locales/pt-BR/index.d.ts +3 -0
- package/locales/pt-BR/index.js +100 -0
- package/locales/pt-BR/index.mjs +96 -0
- package/locales/pt-BR/package.json +6 -0
- package/locales/ro/index.d.mts +3 -0
- package/locales/ro/index.d.ts +3 -0
- package/locales/ro/index.js +100 -0
- package/locales/ro/index.mjs +96 -0
- package/locales/ro/package.json +6 -0
- package/locales/ru/index.d.mts +3 -0
- package/locales/ru/index.d.ts +3 -0
- package/locales/ru/index.js +100 -0
- package/locales/ru/index.mjs +96 -0
- package/locales/ru/package.json +6 -0
- package/locales/sk/index.d.mts +3 -0
- package/locales/sk/index.d.ts +3 -0
- package/locales/sk/index.js +100 -0
- package/locales/sk/index.mjs +96 -0
- package/locales/sk/package.json +6 -0
- package/locales/sr-Cyrl-RS/index.d.mts +3 -0
- package/locales/sr-Cyrl-RS/index.d.ts +3 -0
- package/locales/sr-Cyrl-RS/index.js +100 -0
- package/locales/sr-Cyrl-RS/index.mjs +96 -0
- package/locales/sr-Cyrl-RS/package.json +6 -0
- package/locales/sr-Latn-RS/index.d.mts +3 -0
- package/locales/sr-Latn-RS/index.d.ts +3 -0
- package/locales/sr-Latn-RS/index.js +100 -0
- package/locales/sr-Latn-RS/index.mjs +96 -0
- package/locales/sr-Latn-RS/package.json +6 -0
- package/locales/sv/index.d.mts +3 -0
- package/locales/sv/index.d.ts +3 -0
- package/locales/sv/index.js +100 -0
- package/locales/sv/index.mjs +96 -0
- package/locales/sv/package.json +6 -0
- package/locales/tr/index.d.mts +3 -0
- package/locales/tr/index.d.ts +3 -0
- package/locales/tr/index.js +100 -0
- package/locales/tr/index.mjs +96 -0
- package/locales/tr/package.json +6 -0
- package/locales/uk/index.d.mts +3 -0
- package/locales/uk/index.d.ts +3 -0
- package/locales/uk/index.js +100 -0
- package/locales/uk/index.mjs +96 -0
- package/locales/uk/package.json +6 -0
- package/locales/vi/index.d.mts +3 -0
- package/locales/vi/index.d.ts +3 -0
- package/locales/vi/index.js +100 -0
- package/locales/vi/index.mjs +96 -0
- package/locales/vi/package.json +6 -0
- package/locales/zh-Hans/index.d.mts +3 -0
- package/locales/zh-Hans/index.d.ts +3 -0
- package/locales/zh-Hans/index.js +100 -0
- package/locales/zh-Hans/index.mjs +96 -0
- package/locales/zh-Hans/package.json +6 -0
- package/locales/zh-Hant/index.d.mts +3 -0
- package/locales/zh-Hant/index.d.ts +3 -0
- package/locales/zh-Hant/index.js +100 -0
- package/locales/zh-Hant/index.mjs +96 -0
- package/locales/zh-Hant/package.json +6 -0
- package/package.json +147 -0
- package/skills/README.md +81 -0
- package/skills/composable-components/SKILL.md +189 -0
- package/skills/customization/SKILL.md +190 -0
- package/skills/drag-and-drop-ordering/SKILL.md +227 -0
- package/skills/editing/SKILL.md +243 -0
- package/skills/filtering/SKILL.md +213 -0
- package/skills/getting-started/SKILL.md +213 -0
- package/skills/localization/SKILL.md +182 -0
- package/skills/migrate-v3-to-v4/SKILL.md +161 -0
- package/skills/state-and-server-data/SKILL.md +200 -0
- package/skills/virtualization/SKILL.md +203 -0
- package/src/components/MaterialReactTable.tsx +36 -0
- package/src/components/body/MRT_TableBody.tsx +221 -0
- package/src/components/body/MRT_TableBodyCell.tsx +351 -0
- package/src/components/body/MRT_TableBodyCellValue.tsx +130 -0
- package/src/components/body/MRT_TableBodyRow.tsx +288 -0
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +61 -0
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +58 -0
- package/src/components/body/MRT_TableDetailPanel.tsx +110 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +72 -0
- package/src/components/buttons/MRT_CopyButton.tsx +87 -0
- package/src/components/buttons/MRT_EditActionButtons.tsx +134 -0
- package/src/components/buttons/MRT_ExpandAllButton.tsx +78 -0
- package/src/components/buttons/MRT_ExpandButton.tsx +102 -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 +50 -0
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +52 -0
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +40 -0
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +51 -0
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +46 -0
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +126 -0
- package/src/components/footer/MRT_TableFooter.tsx +88 -0
- package/src/components/footer/MRT_TableFooterCell.tsx +107 -0
- package/src/components/footer/MRT_TableFooterRow.tsx +95 -0
- package/src/components/head/MRT_TableHead.tsx +91 -0
- package/src/components/head/MRT_TableHeadCell.tsx +351 -0
- package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +96 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +52 -0
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +178 -0
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +91 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +96 -0
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +101 -0
- package/src/components/head/MRT_TableHeadRow.tsx +90 -0
- package/src/components/inputs/MRT_EditCellTextField.tsx +202 -0
- package/src/components/inputs/MRT_FilterCheckbox.tsx +90 -0
- package/src/components/inputs/MRT_FilterRangeFields.tsx +41 -0
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +143 -0
- package/src/components/inputs/MRT_FilterTextField.tsx +592 -0
- package/src/components/inputs/MRT_GlobalFilterTextField.tsx +167 -0
- package/src/components/inputs/MRT_SelectCheckbox.tsx +135 -0
- package/src/components/menus/MRT_ActionMenuItem.tsx +62 -0
- package/src/components/menus/MRT_CellActionMenu.tsx +107 -0
- package/src/components/menus/MRT_ColumnActionMenu.tsx +352 -0
- package/src/components/menus/MRT_FilterOptionMenu.tsx +292 -0
- package/src/components/menus/MRT_RowActionMenu.tsx +88 -0
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +181 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +203 -0
- package/src/components/modals/MRT_EditRowModal.tsx +114 -0
- package/src/components/table/MRT_Table.tsx +84 -0
- package/src/components/table/MRT_TableContainer.tsx +111 -0
- package/src/components/table/MRT_TableLoadingOverlay.tsx +58 -0
- package/src/components/table/MRT_TablePaper.tsx +89 -0
- package/src/components/toolbar/MRT_BottomToolbar.tsx +111 -0
- package/src/components/toolbar/MRT_LinearProgressBar.tsx +53 -0
- package/src/components/toolbar/MRT_TablePagination.tsx +241 -0
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +184 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +83 -0
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +72 -0
- package/src/components/toolbar/MRT_TopToolbar.tsx +130 -0
- package/src/features/mrtCellActionsFeature.ts +67 -0
- package/src/features/mrtColumnDraggingFeature.ts +83 -0
- package/src/features/mrtDensityFeature.ts +64 -0
- package/src/features/mrtEditingFeature.ts +102 -0
- package/src/features/mrtFeatures.ts +103 -0
- package/src/features/mrtFilterModesFeature.ts +99 -0
- package/src/features/mrtFnsFeature.ts +46 -0
- package/src/features/mrtFullScreenFeature.ts +63 -0
- package/src/features/mrtLoadingFeature.ts +35 -0
- package/src/features/mrtRefsFeature.ts +60 -0
- package/src/features/mrtRowDraggingFeature.ts +81 -0
- package/src/features/mrtStateCompatFeature.ts +43 -0
- package/src/features/mrtToolbarsFeature.ts +76 -0
- package/src/fns/aggregationFns.ts +3 -0
- package/src/fns/filterFns.ts +196 -0
- package/src/fns/sortingFns.ts +31 -0
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +28 -0
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +29 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +97 -0
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +30 -0
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +24 -0
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +34 -0
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +33 -0
- package/src/hooks/useMRT_ColumnVirtualizer.ts +124 -0
- package/src/hooks/useMRT_Effects.ts +108 -0
- package/src/hooks/useMRT_RowVirtualizer.ts +88 -0
- package/src/hooks/useMRT_Rows.ts +44 -0
- package/src/hooks/useMRT_TableInstance.ts +181 -0
- package/src/hooks/useMRT_TableOptions.ts +241 -0
- package/src/hooks/useMaterialReactTable.ts +12 -0
- package/src/icons.ts +73 -0
- package/src/index.ts +91 -0
- package/src/locales/ar.ts +97 -0
- package/src/locales/az.ts +97 -0
- package/src/locales/bg.ts +97 -0
- package/src/locales/cs.ts +98 -0
- package/src/locales/da.ts +97 -0
- package/src/locales/de.ts +97 -0
- package/src/locales/el.ts +97 -0
- package/src/locales/en.ts +97 -0
- package/src/locales/es.ts +97 -0
- package/src/locales/et.ts +98 -0
- package/src/locales/fa.ts +97 -0
- package/src/locales/fi.ts +98 -0
- package/src/locales/fr.ts +97 -0
- package/src/locales/he.ts +97 -0
- package/src/locales/hr.ts +97 -0
- package/src/locales/hu.ts +97 -0
- package/src/locales/hy.ts +97 -0
- package/src/locales/id.ts +98 -0
- package/src/locales/it.ts +97 -0
- package/src/locales/ja.ts +97 -0
- package/src/locales/ko.ts +97 -0
- package/src/locales/mk.ts +96 -0
- package/src/locales/nl.ts +97 -0
- package/src/locales/no.ts +99 -0
- package/src/locales/np.ts +98 -0
- package/src/locales/pl.ts +97 -0
- package/src/locales/pt-BR.ts +97 -0
- package/src/locales/pt.ts +97 -0
- package/src/locales/ro.ts +97 -0
- package/src/locales/ru.ts +97 -0
- package/src/locales/sk.ts +98 -0
- package/src/locales/sr-Cyrl-RS.ts +97 -0
- package/src/locales/sr-Latn-RS.ts +97 -0
- package/src/locales/sv.ts +97 -0
- package/src/locales/tr.ts +97 -0
- package/src/locales/uk.ts +97 -0
- package/src/locales/vi.ts +97 -0
- package/src/locales/zh-Hans.ts +96 -0
- package/src/locales/zh-Hant.ts +96 -0
- package/src/types.ts +1314 -0
- package/src/utils/cell.utils.ts +234 -0
- package/src/utils/column.utils.ts +204 -0
- package/src/utils/displayColumn.utils.ts +152 -0
- package/src/utils/row.utils.ts +258 -0
- package/src/utils/style.utils.ts +211 -0
- package/src/utils/tanstack.helpers.ts +64 -0
- package/src/utils/utils.ts +34 -0
- package/src/utils/virtualization.utils.ts +24 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assignTableAPIs,
|
|
3
|
+
functionalUpdate,
|
|
4
|
+
makeStateUpdater,
|
|
5
|
+
type OnChangeFn,
|
|
6
|
+
type RowData,
|
|
7
|
+
type TableFeature,
|
|
8
|
+
type TableFeatures,
|
|
9
|
+
type Updater,
|
|
10
|
+
} from '@tanstack/react-table';
|
|
11
|
+
|
|
12
|
+
export interface MRT_Table_Toolbars {
|
|
13
|
+
setShowAlertBanner: (updater: Updater<boolean>) => void;
|
|
14
|
+
setShowToolbarDropZone: (updater: Updater<boolean>) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface MRT_TableOptions_Toolbars {
|
|
18
|
+
onShowAlertBannerChange?: OnChangeFn<boolean>;
|
|
19
|
+
onShowToolbarDropZoneChange?: OnChangeFn<boolean>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MRT_TableState_Toolbars {
|
|
23
|
+
showAlertBanner: boolean;
|
|
24
|
+
showToolbarDropZone: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare module '@tanstack/react-table' {
|
|
28
|
+
interface Plugins {
|
|
29
|
+
mrtToolbarsFeature: TableFeature;
|
|
30
|
+
}
|
|
31
|
+
interface Table_FeatureMap<
|
|
32
|
+
TFeatures extends TableFeatures,
|
|
33
|
+
TData extends RowData,
|
|
34
|
+
> {
|
|
35
|
+
mrtToolbarsFeature: MRT_Table_Toolbars;
|
|
36
|
+
}
|
|
37
|
+
interface TableOptions_FeatureMap<
|
|
38
|
+
TFeatures extends TableFeatures,
|
|
39
|
+
TData extends RowData,
|
|
40
|
+
> {
|
|
41
|
+
mrtToolbarsFeature: MRT_TableOptions_Toolbars;
|
|
42
|
+
}
|
|
43
|
+
interface TableState_FeatureMap {
|
|
44
|
+
mrtToolbarsFeature: MRT_TableState_Toolbars;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const mrtToolbarsFeature: TableFeature = {
|
|
49
|
+
constructTableAPIs: (table) => {
|
|
50
|
+
assignTableAPIs('mrtToolbarsFeature', table, {
|
|
51
|
+
table_setShowAlertBanner: {
|
|
52
|
+
fn: (updater: Updater<boolean>) =>
|
|
53
|
+
(
|
|
54
|
+
table.options as MRT_TableOptions_Toolbars
|
|
55
|
+
).onShowAlertBannerChange?.((old) => functionalUpdate(updater, old)),
|
|
56
|
+
},
|
|
57
|
+
table_setShowToolbarDropZone: {
|
|
58
|
+
fn: (updater: Updater<boolean>) =>
|
|
59
|
+
(
|
|
60
|
+
table.options as MRT_TableOptions_Toolbars
|
|
61
|
+
).onShowToolbarDropZoneChange?.((old) =>
|
|
62
|
+
functionalUpdate(updater, old),
|
|
63
|
+
),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
getDefaultTableOptions: (table) => ({
|
|
68
|
+
onShowAlertBannerChange: makeStateUpdater('showAlertBanner', table),
|
|
69
|
+
onShowToolbarDropZoneChange: makeStateUpdater('showToolbarDropZone', table),
|
|
70
|
+
}),
|
|
71
|
+
getInitialState: (initialState) => ({
|
|
72
|
+
showAlertBanner: false,
|
|
73
|
+
showToolbarDropZone: false,
|
|
74
|
+
...initialState,
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
@@ -0,0 +1,196 @@
|
|
|
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
|
+
import { type MRT_RowData } from '../types';
|
|
8
|
+
|
|
9
|
+
const fuzzy = <TData extends MRT_RowData>(
|
|
10
|
+
row: Row<any, TData>,
|
|
11
|
+
columnId: string,
|
|
12
|
+
filterValue: number | string,
|
|
13
|
+
addMeta?: (item: RankingInfo) => void,
|
|
14
|
+
): boolean => {
|
|
15
|
+
const itemRank = rankItem(
|
|
16
|
+
row.getValue<null | number | string>(columnId),
|
|
17
|
+
filterValue as string,
|
|
18
|
+
{
|
|
19
|
+
threshold: rankings.MATCHES,
|
|
20
|
+
},
|
|
21
|
+
);
|
|
22
|
+
addMeta?.(itemRank);
|
|
23
|
+
return itemRank.passed;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
fuzzy.autoRemove = (val: any) => !val;
|
|
27
|
+
|
|
28
|
+
const contains = <TData extends MRT_RowData>(
|
|
29
|
+
row: Row<any, TData>,
|
|
30
|
+
id: string,
|
|
31
|
+
filterValue: number | string,
|
|
32
|
+
): boolean =>
|
|
33
|
+
!!row
|
|
34
|
+
.getValue<null | number | string>(id)
|
|
35
|
+
?.toString()
|
|
36
|
+
.toLowerCase()
|
|
37
|
+
.trim()
|
|
38
|
+
.includes(filterValue.toString().toLowerCase().trim());
|
|
39
|
+
|
|
40
|
+
contains.autoRemove = (val: any) => !val;
|
|
41
|
+
|
|
42
|
+
const startsWith = <TData extends MRT_RowData>(
|
|
43
|
+
row: Row<any, TData>,
|
|
44
|
+
id: string,
|
|
45
|
+
filterValue: number | string,
|
|
46
|
+
): boolean =>
|
|
47
|
+
!!row
|
|
48
|
+
.getValue<null | number | string>(id)
|
|
49
|
+
?.toString()
|
|
50
|
+
.toLowerCase()
|
|
51
|
+
.trim()
|
|
52
|
+
.startsWith(filterValue.toString().toLowerCase().trim());
|
|
53
|
+
|
|
54
|
+
startsWith.autoRemove = (val: any) => !val;
|
|
55
|
+
|
|
56
|
+
const endsWith = <TData extends MRT_RowData>(
|
|
57
|
+
row: Row<any, TData>,
|
|
58
|
+
id: string,
|
|
59
|
+
filterValue: number | string,
|
|
60
|
+
): boolean =>
|
|
61
|
+
!!row
|
|
62
|
+
.getValue<null | number | string>(id)
|
|
63
|
+
?.toString()
|
|
64
|
+
.toLowerCase()
|
|
65
|
+
.trim()
|
|
66
|
+
.endsWith(filterValue.toString().toLowerCase().trim());
|
|
67
|
+
|
|
68
|
+
endsWith.autoRemove = (val: any) => !val;
|
|
69
|
+
|
|
70
|
+
const equals = <TData extends MRT_RowData>(
|
|
71
|
+
row: Row<any, TData>,
|
|
72
|
+
id: string,
|
|
73
|
+
filterValue: number | string,
|
|
74
|
+
): boolean =>
|
|
75
|
+
row.getValue<null | number | string>(id)?.toString().toLowerCase().trim() ===
|
|
76
|
+
filterValue.toString().toLowerCase().trim();
|
|
77
|
+
|
|
78
|
+
equals.autoRemove = (val: any) => !val;
|
|
79
|
+
|
|
80
|
+
const notEquals = <TData extends MRT_RowData>(
|
|
81
|
+
row: Row<any, TData>,
|
|
82
|
+
id: string,
|
|
83
|
+
filterValue: number | string,
|
|
84
|
+
): boolean =>
|
|
85
|
+
row.getValue<null | number | string>(id)?.toString().toLowerCase().trim() !==
|
|
86
|
+
filterValue.toString().toLowerCase().trim();
|
|
87
|
+
|
|
88
|
+
notEquals.autoRemove = (val: any) => !val;
|
|
89
|
+
|
|
90
|
+
const greaterThan = <TData extends MRT_RowData>(
|
|
91
|
+
row: Row<any, TData>,
|
|
92
|
+
id: string,
|
|
93
|
+
filterValue: number | string,
|
|
94
|
+
): boolean =>
|
|
95
|
+
!isNaN(+filterValue) && !isNaN(+row.getValue<number | string>(id))
|
|
96
|
+
? +(row.getValue<null | number | string>(id) ?? 0) > +filterValue
|
|
97
|
+
: (row.getValue<null | number | string>(id) ?? '')
|
|
98
|
+
?.toString()
|
|
99
|
+
.toLowerCase()
|
|
100
|
+
.trim() > filterValue.toString().toLowerCase().trim();
|
|
101
|
+
|
|
102
|
+
greaterThan.autoRemove = (val: any) => !val;
|
|
103
|
+
|
|
104
|
+
const greaterThanOrEqualTo = <TData extends MRT_RowData>(
|
|
105
|
+
row: Row<any, TData>,
|
|
106
|
+
id: string,
|
|
107
|
+
filterValue: number | string,
|
|
108
|
+
): boolean => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
|
109
|
+
|
|
110
|
+
greaterThanOrEqualTo.autoRemove = (val: any) => !val;
|
|
111
|
+
|
|
112
|
+
const lessThan = <TData extends MRT_RowData>(
|
|
113
|
+
row: Row<any, TData>,
|
|
114
|
+
id: string,
|
|
115
|
+
filterValue: number | string,
|
|
116
|
+
): boolean =>
|
|
117
|
+
!isNaN(+filterValue) && !isNaN(+row.getValue<number | string>(id))
|
|
118
|
+
? +(row.getValue<null | number | string>(id) ?? 0) < +filterValue
|
|
119
|
+
: (row.getValue<null | number | string>(id) ?? '')
|
|
120
|
+
?.toString()
|
|
121
|
+
.toLowerCase()
|
|
122
|
+
.trim() < filterValue.toString().toLowerCase().trim();
|
|
123
|
+
|
|
124
|
+
lessThan.autoRemove = (val: any) => !val;
|
|
125
|
+
|
|
126
|
+
const lessThanOrEqualTo = <TData extends MRT_RowData>(
|
|
127
|
+
row: Row<any, TData>,
|
|
128
|
+
id: string,
|
|
129
|
+
filterValue: number | string,
|
|
130
|
+
): boolean => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
|
131
|
+
|
|
132
|
+
lessThanOrEqualTo.autoRemove = (val: any) => !val;
|
|
133
|
+
|
|
134
|
+
const between = <TData extends MRT_RowData>(
|
|
135
|
+
row: Row<any, TData>,
|
|
136
|
+
id: string,
|
|
137
|
+
filterValues: [number | string, number | string],
|
|
138
|
+
): boolean =>
|
|
139
|
+
((['', undefined] as any[]).includes(filterValues[0]) ||
|
|
140
|
+
greaterThan(row, id, filterValues[0])) &&
|
|
141
|
+
((!isNaN(+filterValues[0]) &&
|
|
142
|
+
!isNaN(+filterValues[1]) &&
|
|
143
|
+
+filterValues[0] > +filterValues[1]) ||
|
|
144
|
+
(['', undefined] as any[]).includes(filterValues[1]) ||
|
|
145
|
+
lessThan(row, id, filterValues[1]));
|
|
146
|
+
|
|
147
|
+
between.autoRemove = (val: any) => !val;
|
|
148
|
+
|
|
149
|
+
const betweenInclusive = <TData extends MRT_RowData>(
|
|
150
|
+
row: Row<any, TData>,
|
|
151
|
+
id: string,
|
|
152
|
+
filterValues: [number | string, number | string],
|
|
153
|
+
): boolean =>
|
|
154
|
+
((['', undefined] as any[]).includes(filterValues[0]) ||
|
|
155
|
+
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
|
156
|
+
((!isNaN(+filterValues[0]) &&
|
|
157
|
+
!isNaN(+filterValues[1]) &&
|
|
158
|
+
+filterValues[0] > +filterValues[1]) ||
|
|
159
|
+
(['', undefined] as any[]).includes(filterValues[1]) ||
|
|
160
|
+
lessThanOrEqualTo(row, id, filterValues[1]));
|
|
161
|
+
|
|
162
|
+
betweenInclusive.autoRemove = (val: any) => !val;
|
|
163
|
+
|
|
164
|
+
const empty = <TData extends MRT_RowData>(
|
|
165
|
+
row: Row<any, TData>,
|
|
166
|
+
id: string,
|
|
167
|
+
_filterValue: number | string,
|
|
168
|
+
): boolean => !row.getValue<null | number | string>(id)?.toString().trim();
|
|
169
|
+
|
|
170
|
+
empty.autoRemove = (val: any) => !val;
|
|
171
|
+
|
|
172
|
+
const notEmpty = <TData extends MRT_RowData>(
|
|
173
|
+
row: Row<any, TData>,
|
|
174
|
+
id: string,
|
|
175
|
+
_filterValue: number | string,
|
|
176
|
+
): boolean => !!row.getValue<null | number | string>(id)?.toString().trim();
|
|
177
|
+
|
|
178
|
+
notEmpty.autoRemove = (val: any) => !val;
|
|
179
|
+
|
|
180
|
+
export const MRT_FilterFns = {
|
|
181
|
+
...filterFns,
|
|
182
|
+
between,
|
|
183
|
+
betweenInclusive,
|
|
184
|
+
contains,
|
|
185
|
+
empty,
|
|
186
|
+
endsWith,
|
|
187
|
+
equals,
|
|
188
|
+
fuzzy,
|
|
189
|
+
greaterThan,
|
|
190
|
+
greaterThanOrEqualTo,
|
|
191
|
+
lessThan,
|
|
192
|
+
lessThanOrEqualTo,
|
|
193
|
+
notEmpty,
|
|
194
|
+
notEquals,
|
|
195
|
+
startsWith,
|
|
196
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { compareItems, type RankingInfo } from '@tanstack/match-sorter-utils';
|
|
2
|
+
import { type Row, sortFns } from '@tanstack/react-table';
|
|
3
|
+
import { type MRT_Row, type MRT_RowData } from '../types';
|
|
4
|
+
|
|
5
|
+
const fuzzy = <TData extends MRT_RowData>(
|
|
6
|
+
rowA: Row<any, TData>,
|
|
7
|
+
rowB: Row<any, TData>,
|
|
8
|
+
columnId: string,
|
|
9
|
+
) => {
|
|
10
|
+
let dir = 0;
|
|
11
|
+
if (rowA.columnFiltersMeta[columnId]) {
|
|
12
|
+
dir = compareItems(
|
|
13
|
+
rowA.columnFiltersMeta[columnId] as RankingInfo,
|
|
14
|
+
rowB.columnFiltersMeta[columnId] as RankingInfo,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
// Provide a fallback for when the item ranks are equal
|
|
18
|
+
return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const MRT_SortingFns = {
|
|
22
|
+
...sortFns,
|
|
23
|
+
fuzzy,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const rankGlobalFuzzy = <TData extends MRT_RowData>(
|
|
27
|
+
rowA: MRT_Row<TData>,
|
|
28
|
+
rowB: MRT_Row<TData>,
|
|
29
|
+
) =>
|
|
30
|
+
Math.max(...Object.values(rowB.columnFiltersMeta).map((v: any) => v.rank)) -
|
|
31
|
+
Math.max(...Object.values(rowA.columnFiltersMeta).map((v: any) => v.rank));
|
|
@@ -0,0 +1,28 @@
|
|
|
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> => {
|
|
12
|
+
return {
|
|
13
|
+
Cell: ({ cell, row, staticRowIndex, table }) => (
|
|
14
|
+
<MRT_ToggleRowActionMenuButton
|
|
15
|
+
cell={cell}
|
|
16
|
+
row={row}
|
|
17
|
+
staticRowIndex={staticRowIndex}
|
|
18
|
+
table={table}
|
|
19
|
+
/>
|
|
20
|
+
),
|
|
21
|
+
...defaultDisplayColumnProps({
|
|
22
|
+
header: 'actions',
|
|
23
|
+
id: 'mrt-row-actions',
|
|
24
|
+
size: 70,
|
|
25
|
+
tableOptions,
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { MRT_TableBodyRowGrabHandle } from '../../components/body/MRT_TableBodyRowGrabHandle';
|
|
3
|
+
import {
|
|
4
|
+
type MRT_ColumnDef,
|
|
5
|
+
type MRT_RowData,
|
|
6
|
+
type MRT_StatefulTableOptions,
|
|
7
|
+
} from '../../types';
|
|
8
|
+
import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
|
|
9
|
+
|
|
10
|
+
export const getMRT_RowDragColumnDef = <TData extends MRT_RowData>(
|
|
11
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
12
|
+
): MRT_ColumnDef<TData> => {
|
|
13
|
+
return {
|
|
14
|
+
Cell: ({ row, rowRef, table }) => (
|
|
15
|
+
<MRT_TableBodyRowGrabHandle
|
|
16
|
+
row={row}
|
|
17
|
+
rowRef={rowRef as RefObject<HTMLTableRowElement | null>}
|
|
18
|
+
table={table}
|
|
19
|
+
/>
|
|
20
|
+
),
|
|
21
|
+
grow: false,
|
|
22
|
+
...defaultDisplayColumnProps({
|
|
23
|
+
header: 'move',
|
|
24
|
+
id: 'mrt-row-drag',
|
|
25
|
+
size: 60,
|
|
26
|
+
tableOptions,
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import Stack from '@mui/material/Stack';
|
|
3
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
4
|
+
import { MRT_ExpandAllButton } from '../../components/buttons/MRT_ExpandAllButton';
|
|
5
|
+
import { MRT_ExpandButton } from '../../components/buttons/MRT_ExpandButton';
|
|
6
|
+
import {
|
|
7
|
+
type MRT_ColumnDef,
|
|
8
|
+
type MRT_RowData,
|
|
9
|
+
type MRT_StatefulTableOptions,
|
|
10
|
+
} from '../../types';
|
|
11
|
+
import { defaultDisplayColumnProps } from '../../utils/displayColumn.utils';
|
|
12
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
|
13
|
+
|
|
14
|
+
export const getMRT_RowExpandColumnDef = <TData extends MRT_RowData>(
|
|
15
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
16
|
+
): MRT_ColumnDef<TData> => {
|
|
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, staticRowIndex, table }) => {
|
|
35
|
+
const expandButtonProps = { row, staticRowIndex, table };
|
|
36
|
+
const subRowsLength = row.subRows?.length;
|
|
37
|
+
if (groupedColumnMode === 'remove' && row.groupingColumnId) {
|
|
38
|
+
return (
|
|
39
|
+
<Stack
|
|
40
|
+
sx={{
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
gap: '0.25rem',
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<MRT_ExpandButton {...expandButtonProps} />
|
|
47
|
+
<Tooltip
|
|
48
|
+
{...getCommonTooltipProps('right')}
|
|
49
|
+
title={table.getColumn(row.groupingColumnId).columnDef.header}
|
|
50
|
+
>
|
|
51
|
+
<span>{row.groupingValue as ReactNode}</span>
|
|
52
|
+
</Tooltip>
|
|
53
|
+
{!!subRowsLength && <span>({subRowsLength})</span>}
|
|
54
|
+
</Stack>
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<MRT_ExpandButton {...expandButtonProps} />
|
|
60
|
+
{column.columnDef.GroupedCell?.({ cell, column, row, table })}
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
Header: enableExpandAll
|
|
66
|
+
? ({ table }) => {
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<MRT_ExpandAllButton table={table} />
|
|
70
|
+
{groupedColumnMode === 'remove' &&
|
|
71
|
+
grouping
|
|
72
|
+
?.map(
|
|
73
|
+
(groupedColumnId) =>
|
|
74
|
+
table.getColumn(groupedColumnId).columnDef.header,
|
|
75
|
+
)
|
|
76
|
+
?.join(', ')}
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
: undefined,
|
|
81
|
+
muiTableBodyCellProps: alignProps,
|
|
82
|
+
muiTableHeadCellProps: alignProps,
|
|
83
|
+
...defaultDisplayColumnProps({
|
|
84
|
+
header: 'expand',
|
|
85
|
+
id: 'mrt-row-expand',
|
|
86
|
+
size:
|
|
87
|
+
groupedColumnMode === 'remove'
|
|
88
|
+
? (defaultColumn?.size ?? 180)
|
|
89
|
+
: renderDetailPanel
|
|
90
|
+
? enableExpandAll
|
|
91
|
+
? 60
|
|
92
|
+
: 70
|
|
93
|
+
: 100,
|
|
94
|
+
tableOptions,
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
97
|
+
};
|
|
@@ -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> => {
|
|
11
|
+
const { localization, rowNumberDisplayMode } = tableOptions;
|
|
12
|
+
const {
|
|
13
|
+
pagination: { pageIndex, pageSize },
|
|
14
|
+
} = tableOptions.state;
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
Cell: ({ row, staticRowIndex }) =>
|
|
18
|
+
((rowNumberDisplayMode === 'static'
|
|
19
|
+
? (staticRowIndex || 0) + (pageSize || 0) * (pageIndex || 0)
|
|
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> => {
|
|
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> => {
|
|
12
|
+
const { enableMultiRowSelection, enableSelectAll } = tableOptions;
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
Cell: ({ row, staticRowIndex, table }) => (
|
|
16
|
+
<MRT_SelectCheckbox
|
|
17
|
+
row={row}
|
|
18
|
+
staticRowIndex={staticRowIndex}
|
|
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
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MRT_DefaultDisplayColumn } from '../useMRT_TableOptions';
|
|
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
|
+
const blankColProps = {
|
|
10
|
+
children: null,
|
|
11
|
+
sx: {
|
|
12
|
+
minWidth: 0,
|
|
13
|
+
p: 0,
|
|
14
|
+
width: 0,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getMRT_RowSpacerColumnDef = <TData extends MRT_RowData>(
|
|
19
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
20
|
+
): MRT_ColumnDef<TData> => {
|
|
21
|
+
return {
|
|
22
|
+
...defaultDisplayColumnProps({
|
|
23
|
+
id: 'mrt-row-spacer',
|
|
24
|
+
size: 0,
|
|
25
|
+
tableOptions,
|
|
26
|
+
}),
|
|
27
|
+
grow: true,
|
|
28
|
+
...MRT_DefaultDisplayColumn,
|
|
29
|
+
muiTableBodyCellProps: blankColProps,
|
|
30
|
+
muiTableFooterCellProps: blankColProps,
|
|
31
|
+
muiTableHeadCellProps: blankColProps,
|
|
32
|
+
};
|
|
33
|
+
};
|