material-react-table 2.9.2 → 2.11.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/README.md +3 -2
- package/dist/index.d.ts +222 -152
- package/dist/index.esm.js +906 -769
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +910 -768
- package/dist/index.js.map +1 -1
- package/locales/ar/index.esm.js +2 -0
- package/locales/ar/index.js +2 -0
- package/locales/az/index.esm.js +2 -0
- package/locales/az/index.js +2 -0
- package/locales/bg/index.esm.js +2 -0
- package/locales/bg/index.js +2 -0
- package/locales/cs/index.esm.js +2 -0
- package/locales/cs/index.js +2 -0
- package/locales/da/index.esm.js +2 -0
- package/locales/da/index.js +2 -0
- package/locales/de/index.esm.js +2 -0
- package/locales/de/index.js +2 -0
- package/locales/en/index.esm.js +2 -0
- package/locales/en/index.js +2 -0
- package/locales/es/index.esm.js +2 -0
- package/locales/es/index.js +2 -0
- package/locales/et/index.esm.js +2 -0
- package/locales/et/index.js +2 -0
- package/locales/fa/index.esm.js +2 -0
- package/locales/fa/index.js +2 -0
- package/locales/fi/index.esm.js +2 -0
- package/locales/fi/index.js +2 -0
- package/locales/fr/index.esm.js +2 -0
- package/locales/fr/index.js +2 -0
- package/locales/he/index.esm.js +2 -0
- package/locales/he/index.js +2 -0
- package/locales/hu/index.esm.js +2 -0
- package/locales/hu/index.js +2 -0
- package/locales/hy/index.esm.js +2 -0
- package/locales/hy/index.js +2 -0
- package/locales/id/index.esm.js +2 -0
- package/locales/id/index.js +2 -0
- package/locales/it/index.esm.js +2 -0
- package/locales/it/index.js +2 -0
- package/locales/ja/index.esm.js +2 -0
- package/locales/ja/index.js +2 -0
- package/locales/ko/index.esm.js +2 -0
- package/locales/ko/index.js +2 -0
- package/locales/nl/index.esm.js +2 -0
- package/locales/nl/index.js +2 -0
- package/locales/no/index.esm.js +2 -0
- package/locales/no/index.js +2 -0
- package/locales/np/index.esm.js +2 -0
- package/locales/np/index.js +2 -0
- package/locales/pl/index.esm.js +2 -0
- package/locales/pl/index.js +2 -0
- package/locales/pt/index.esm.js +2 -0
- package/locales/pt/index.js +2 -0
- package/locales/pt-BR/index.esm.js +2 -0
- package/locales/pt-BR/index.js +2 -0
- package/locales/ro/index.esm.js +2 -0
- package/locales/ro/index.js +2 -0
- package/locales/ru/index.esm.js +2 -0
- package/locales/ru/index.js +2 -0
- package/locales/sk/index.esm.js +2 -0
- package/locales/sk/index.js +2 -0
- package/locales/sr-Cyrl-RS/index.esm.js +2 -0
- package/locales/sr-Cyrl-RS/index.js +2 -0
- package/locales/sr-Latn-RS/index.esm.js +2 -0
- package/locales/sr-Latn-RS/index.js +2 -0
- package/locales/sv/index.esm.js +2 -0
- package/locales/sv/index.js +2 -0
- package/locales/tr/index.esm.js +2 -0
- package/locales/tr/index.js +2 -0
- package/locales/uk/index.esm.js +2 -0
- package/locales/uk/index.js +2 -0
- package/locales/vi/index.esm.js +2 -0
- package/locales/vi/index.js +2 -0
- package/locales/zh-Hans/index.esm.js +2 -0
- package/locales/zh-Hans/index.js +2 -0
- package/locales/zh-Hant/index.esm.js +2 -0
- package/locales/zh-Hant/index.js +2 -0
- package/package.json +20 -20
- package/src/components/MaterialReactTable.tsx +3 -3
- package/src/components/body/MRT_TableBody.tsx +3 -2
- package/src/components/body/MRT_TableBodyCell.tsx +45 -34
- package/src/components/body/MRT_TableBodyCellValue.tsx +5 -2
- package/src/components/body/MRT_TableBodyRow.tsx +13 -12
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +4 -3
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +3 -2
- package/src/components/body/MRT_TableDetailPanel.tsx +3 -2
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +3 -2
- package/src/components/buttons/MRT_CopyButton.tsx +4 -2
- package/src/components/buttons/MRT_EditActionButtons.tsx +3 -2
- package/src/components/buttons/MRT_ExpandAllButton.tsx +3 -2
- package/src/components/buttons/MRT_ExpandButton.tsx +3 -2
- package/src/components/buttons/MRT_GrabHandleButton.tsx +9 -15
- package/src/components/buttons/MRT_RowPinButton.tsx +3 -2
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +3 -2
- package/src/components/footer/MRT_TableFooter.tsx +3 -2
- package/src/components/footer/MRT_TableFooterCell.tsx +3 -2
- package/src/components/footer/MRT_TableFooterRow.tsx +5 -3
- package/src/components/head/MRT_TableHead.tsx +3 -2
- package/src/components/head/MRT_TableHeadCell.tsx +9 -5
- package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +4 -2
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +4 -2
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +4 -2
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +4 -3
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +3 -2
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +3 -2
- package/src/components/head/MRT_TableHeadRow.tsx +4 -2
- package/src/components/inputs/MRT_EditCellTextField.tsx +3 -2
- package/src/components/inputs/MRT_FilterCheckbox.tsx +3 -2
- package/src/components/inputs/MRT_FilterRangeFields.tsx +3 -2
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +3 -2
- package/src/components/inputs/MRT_FilterTextField.tsx +15 -6
- package/src/components/inputs/MRT_GlobalFilterTextField.tsx +3 -2
- package/src/components/inputs/MRT_SelectCheckbox.tsx +26 -33
- package/src/components/menus/MRT_ActionMenuItem.tsx +61 -0
- package/src/components/menus/MRT_CellActionMenu.tsx +109 -0
- package/src/components/menus/MRT_ColumnActionMenu.tsx +92 -172
- package/src/components/menus/MRT_FilterOptionMenu.tsx +9 -16
- package/src/components/menus/MRT_RowActionMenu.tsx +10 -17
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +11 -3
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +7 -5
- package/src/components/modals/MRT_EditRowModal.tsx +3 -2
- package/src/components/table/MRT_Table.tsx +2 -2
- package/src/components/table/MRT_TableContainer.tsx +7 -2
- package/src/components/table/MRT_TableLoadingOverlay.tsx +11 -8
- package/src/components/table/MRT_TablePaper.tsx +3 -2
- package/src/components/toolbar/MRT_BottomToolbar.tsx +3 -2
- package/src/components/toolbar/MRT_LinearProgressBar.tsx +3 -2
- package/src/components/toolbar/MRT_TablePagination.tsx +2 -2
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +30 -13
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +3 -2
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +3 -2
- package/src/components/toolbar/MRT_TopToolbar.tsx +2 -2
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +1 -8
- package/src/hooks/useMRT_Effects.ts +14 -4
- package/src/hooks/useMRT_Rows.ts +11 -79
- package/src/hooks/useMRT_TableInstance.ts +114 -59
- package/src/hooks/useMRT_TableOptions.ts +2 -0
- package/src/icons.ts +2 -0
- package/src/index.ts +2 -0
- package/src/locales/ar.ts +2 -0
- package/src/locales/az.ts +2 -0
- package/src/locales/bg.ts +2 -0
- package/src/locales/cs.ts +2 -0
- package/src/locales/da.ts +2 -0
- package/src/locales/de.ts +2 -0
- package/src/locales/en.ts +2 -0
- package/src/locales/es.ts +2 -0
- package/src/locales/et.ts +2 -0
- package/src/locales/fa.ts +2 -0
- package/src/locales/fi.ts +2 -0
- package/src/locales/fr.ts +2 -0
- package/src/locales/he.ts +2 -0
- package/src/locales/hu.ts +2 -0
- package/src/locales/hy.ts +2 -0
- package/src/locales/id.ts +2 -0
- package/src/locales/it.ts +2 -0
- package/src/locales/ja.ts +2 -0
- package/src/locales/ko.ts +2 -0
- package/src/locales/nl.ts +2 -0
- package/src/locales/no.ts +2 -0
- package/src/locales/np.ts +2 -0
- package/src/locales/pl.ts +2 -0
- package/src/locales/pt-BR.ts +2 -0
- package/src/locales/pt.ts +2 -0
- package/src/locales/ro.ts +2 -0
- package/src/locales/ru.ts +2 -0
- package/src/locales/sk.ts +2 -0
- package/src/locales/sr-Cyrl-RS.ts +2 -0
- package/src/locales/sr-Latn-RS.ts +2 -0
- package/src/locales/sv.ts +2 -0
- package/src/locales/tr.ts +2 -0
- package/src/locales/uk.ts +2 -0
- package/src/locales/vi.ts +2 -0
- package/src/locales/zh-Hans.ts +2 -0
- package/src/locales/zh-Hant.ts +2 -0
- package/src/types.ts +51 -13
- package/src/utils/cell.utils.ts +50 -0
- package/src/utils/column.utils.ts +4 -6
- package/src/utils/displayColumn.utils.ts +39 -21
- package/src/utils/row.utils.ts +179 -21
- package/locales/am/index.d.ts +0 -3
- package/locales/am/index.esm.d.ts +0 -3
- package/locales/am/index.esm.js +0 -93
- package/locales/am/index.js +0 -97
- package/locales/am/package.json +0 -6
- package/src/hooks/display-columns/getMRT_DisplayColumns.tsx +0 -26
- package/src/locales/am.ts +0 -94
package/src/locales/ru.ts
CHANGED
|
@@ -8,8 +8,10 @@ export const MRT_Localization_RU: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: 'Изменить режим поиска',
|
|
9
9
|
clearFilter: 'Очистить фильтр',
|
|
10
10
|
clearSearch: 'Очистить поиск',
|
|
11
|
+
clearSelection: 'Очистить выбор',
|
|
11
12
|
clearSort: 'Очистить сортировку',
|
|
12
13
|
clickToCopy: 'Нажмите, чтобы скопировать',
|
|
14
|
+
copy: 'Копировать',
|
|
13
15
|
columnActions: 'Действие колонки',
|
|
14
16
|
copiedToClipboard: 'Скопировано в буфер обмена',
|
|
15
17
|
collapse: 'Свернуть',
|
package/src/locales/sk.ts
CHANGED
|
@@ -8,8 +8,10 @@ export const MRT_Localization_SK: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: 'Zmeniť režim hľadania',
|
|
9
9
|
clearFilter: 'Vyčistiť filter',
|
|
10
10
|
clearSearch: 'Vyčistiť hľadanie',
|
|
11
|
+
clearSelection: 'Vyčistiť výber',
|
|
11
12
|
clearSort: 'Vyčistiť zoradenie',
|
|
12
13
|
clickToCopy: 'Kliknutím skopírovať',
|
|
14
|
+
copy: 'Kopírovať',
|
|
13
15
|
collapse: 'Zbaliť',
|
|
14
16
|
collapseAll: 'Zbaliť všetko',
|
|
15
17
|
columnActions: 'Akcie stĺpca',
|
|
@@ -8,8 +8,10 @@ export const MRT_Localization_SR_CYRL_RS: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: 'Промени режим претраге',
|
|
9
9
|
clearFilter: 'Поништи филтер',
|
|
10
10
|
clearSearch: 'Поништи претрагу',
|
|
11
|
+
clearSelection: 'Поништи избор',
|
|
11
12
|
clearSort: 'Поништи сортирање',
|
|
12
13
|
clickToCopy: 'Кликни да копираш',
|
|
14
|
+
copy: 'Копирај',
|
|
13
15
|
collapse: 'Рашири',
|
|
14
16
|
collapseAll: 'Рашири све',
|
|
15
17
|
columnActions: 'Акције над колонама',
|
|
@@ -8,8 +8,10 @@ export const MRT_Localization_SR_LATN_RS: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: 'Promeni režim pretrage',
|
|
9
9
|
clearFilter: 'Poništi filter',
|
|
10
10
|
clearSearch: 'Poništi pretragu',
|
|
11
|
+
clearSelection: 'Poništi izbor',
|
|
11
12
|
clearSort: 'Poništi sortiranje',
|
|
12
13
|
clickToCopy: 'Klikni da kopiraš',
|
|
14
|
+
copy: 'Kopiraj',
|
|
13
15
|
collapse: 'Raširi',
|
|
14
16
|
collapseAll: 'Raširi sve',
|
|
15
17
|
columnActions: 'Akcije nad kolonama',
|
package/src/locales/sv.ts
CHANGED
|
@@ -8,8 +8,10 @@ export const MRT_Localization_SV: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: 'Ändra sökläge',
|
|
9
9
|
clearFilter: 'Rensa filter',
|
|
10
10
|
clearSearch: 'Rensa sök',
|
|
11
|
+
clearSelection: 'Rensa val',
|
|
11
12
|
clearSort: 'Rensa sortering',
|
|
12
13
|
clickToCopy: 'Klicka för att kopiera',
|
|
14
|
+
copy: 'Kopiera',
|
|
13
15
|
collapse: 'Stäng',
|
|
14
16
|
collapseAll: 'Stäng alla',
|
|
15
17
|
columnActions: 'Kolumnåtgärd',
|
package/src/locales/tr.ts
CHANGED
|
@@ -8,8 +8,10 @@ export const MRT_Localization_TR: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: 'Arama Modunu Değiştir',
|
|
9
9
|
clearFilter: 'Filtreyi Temizle',
|
|
10
10
|
clearSearch: 'Aramayı Temizle',
|
|
11
|
+
clearSelection: 'Seçimi Temizle',
|
|
11
12
|
clearSort: 'Sıralamayı Sıfırla',
|
|
12
13
|
clickToCopy: 'Kopyala',
|
|
14
|
+
copy: 'Kopyala',
|
|
13
15
|
columnActions: 'Sütun İşlemleri',
|
|
14
16
|
copiedToClipboard: 'Panoya Kopyalandı',
|
|
15
17
|
collapse: 'Daralt',
|
package/src/locales/uk.ts
CHANGED
|
@@ -8,8 +8,10 @@ export const MRT_Localization_UK: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: 'Змінити режим пошуку',
|
|
9
9
|
clearFilter: 'Очистити фільтр',
|
|
10
10
|
clearSearch: 'Очистити пошук',
|
|
11
|
+
clearSelection: 'Скасувати вибір',
|
|
11
12
|
clearSort: 'Очистити сортування',
|
|
12
13
|
clickToCopy: 'Натисніть, щоб скопіювати',
|
|
14
|
+
copy: 'Копіювати',
|
|
13
15
|
collapse: 'Згорнути',
|
|
14
16
|
collapseAll: 'Згорнути все',
|
|
15
17
|
columnActions: 'Дії стовпця',
|
package/src/locales/vi.ts
CHANGED
|
@@ -8,8 +8,10 @@ export const MRT_Localization_VI: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: 'Thay đổi chế độ tìm kiếm',
|
|
9
9
|
clearFilter: 'Xoá bộ lọc',
|
|
10
10
|
clearSearch: 'Xoá ô tìm kiếm',
|
|
11
|
+
clearSelection: 'Xoá lựa chọn',
|
|
11
12
|
clearSort: 'Huỷ sắp xếp',
|
|
12
13
|
clickToCopy: 'Nhấn vào để sao chép',
|
|
14
|
+
copy: 'Sao chép',
|
|
13
15
|
columnActions: 'Lựa chọn',
|
|
14
16
|
copiedToClipboard: 'Sao chép vào bảng tạm',
|
|
15
17
|
collapse: 'Thu gọn',
|
package/src/locales/zh-Hans.ts
CHANGED
|
@@ -8,8 +8,10 @@ export const MRT_Localization_ZH_HANS: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: '更改搜索模式',
|
|
9
9
|
clearFilter: '清除过滤',
|
|
10
10
|
clearSearch: '清除搜索',
|
|
11
|
+
clearSelection: '清除选择',
|
|
11
12
|
clearSort: '清除排序',
|
|
12
13
|
clickToCopy: '点击以复制',
|
|
14
|
+
copy: '复制',
|
|
13
15
|
collapse: '折叠',
|
|
14
16
|
collapseAll: '全部折叠',
|
|
15
17
|
columnActions: '列操作',
|
package/src/locales/zh-Hant.ts
CHANGED
|
@@ -8,8 +8,10 @@ export const MRT_Localization_ZH_HANT: MRT_Localization = {
|
|
|
8
8
|
changeSearchMode: '更改搜尋模式',
|
|
9
9
|
clearFilter: '清除過濾',
|
|
10
10
|
clearSearch: '清除搜尋',
|
|
11
|
+
clearSelection: '清除選擇',
|
|
11
12
|
clearSort: '清除排序',
|
|
12
13
|
clickToCopy: '點擊以複製',
|
|
14
|
+
copy: '複製',
|
|
13
15
|
collapse: '折疊',
|
|
14
16
|
collapseAll: '全部折疊',
|
|
15
17
|
columnActions: '欄位動作',
|
package/src/types.ts
CHANGED
|
@@ -170,12 +170,14 @@ export interface MRT_Localization {
|
|
|
170
170
|
changeSearchMode: string;
|
|
171
171
|
clearFilter: string;
|
|
172
172
|
clearSearch: string;
|
|
173
|
+
clearSelection: string;
|
|
173
174
|
clearSort: string;
|
|
174
175
|
clickToCopy: string;
|
|
175
176
|
collapse: string;
|
|
176
177
|
collapseAll: string;
|
|
177
178
|
columnActions: string;
|
|
178
179
|
copiedToClipboard: string;
|
|
180
|
+
copy: string;
|
|
179
181
|
dropToGroupBy: string;
|
|
180
182
|
edit: string;
|
|
181
183
|
expand: string;
|
|
@@ -315,17 +317,20 @@ export type MRT_TableInstance<TData extends MRT_RowData> = Omit<
|
|
|
315
317
|
getTopRows: () => MRT_Row<TData>[];
|
|
316
318
|
options: MRT_StatefulTableOptions<TData>;
|
|
317
319
|
refs: {
|
|
318
|
-
|
|
320
|
+
actionCellRef: MutableRefObject<HTMLTableCellElement | null>;
|
|
321
|
+
bottomToolbarRef: MutableRefObject<HTMLDivElement | null>;
|
|
319
322
|
editInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
|
|
320
323
|
filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
+
lastSelectedRowId: MutableRefObject<null | string>;
|
|
325
|
+
searchInputRef: MutableRefObject<HTMLInputElement | null>;
|
|
326
|
+
tableContainerRef: MutableRefObject<HTMLDivElement | null>;
|
|
327
|
+
tableFooterRef: MutableRefObject<HTMLTableSectionElement | null>;
|
|
324
328
|
tableHeadCellRefs: MutableRefObject<Record<string, HTMLTableCellElement>>;
|
|
325
|
-
tableHeadRef: MutableRefObject<HTMLTableSectionElement>;
|
|
326
|
-
tablePaperRef: MutableRefObject<HTMLDivElement>;
|
|
327
|
-
topToolbarRef: MutableRefObject<HTMLDivElement>;
|
|
329
|
+
tableHeadRef: MutableRefObject<HTMLTableSectionElement | null>;
|
|
330
|
+
tablePaperRef: MutableRefObject<HTMLDivElement | null>;
|
|
331
|
+
topToolbarRef: MutableRefObject<HTMLDivElement | null>;
|
|
328
332
|
};
|
|
333
|
+
setActionCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
|
|
329
334
|
setColumnFilterFns: Dispatch<SetStateAction<MRT_ColumnFilterFnsState>>;
|
|
330
335
|
setCreatingRow: Dispatch<SetStateAction<MRT_Row<TData> | null | true>>;
|
|
331
336
|
setDensity: Dispatch<SetStateAction<MRT_DensityState>>;
|
|
@@ -375,7 +380,8 @@ export type MRT_StatefulTableOptions<TData extends MRT_RowData> =
|
|
|
375
380
|
>;
|
|
376
381
|
};
|
|
377
382
|
|
|
378
|
-
export
|
|
383
|
+
export interface MRT_TableState<TData extends MRT_RowData> extends TableState {
|
|
384
|
+
actionCell?: MRT_Cell<TData> | null;
|
|
379
385
|
columnFilterFns: MRT_ColumnFilterFnsState;
|
|
380
386
|
creatingRow: MRT_Row<TData> | null;
|
|
381
387
|
density: MRT_DensityState;
|
|
@@ -396,7 +402,7 @@ export type MRT_TableState<TData extends MRT_RowData> = TableState & {
|
|
|
396
402
|
showProgressBars: boolean;
|
|
397
403
|
showSkeletons: boolean;
|
|
398
404
|
showToolbarDropZone: boolean;
|
|
399
|
-
}
|
|
405
|
+
}
|
|
400
406
|
|
|
401
407
|
export type MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> = Omit<
|
|
402
408
|
ColumnDef<TData, TValue>,
|
|
@@ -423,6 +429,7 @@ export type MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> = Omit<
|
|
|
423
429
|
renderedCellValue: ReactNode;
|
|
424
430
|
row: MRT_Row<TData>;
|
|
425
431
|
rowRef?: RefObject<HTMLTableRowElement>;
|
|
432
|
+
staticColumnIndex?: number;
|
|
426
433
|
staticRowIndex?: number;
|
|
427
434
|
table: MRT_TableInstance<TData>;
|
|
428
435
|
}) => ReactNode;
|
|
@@ -503,7 +510,10 @@ export type MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> = Omit<
|
|
|
503
510
|
}) => DropdownOption[])
|
|
504
511
|
| DropdownOption[];
|
|
505
512
|
editVariant?: 'select' | 'text';
|
|
506
|
-
enableClickToCopy?:
|
|
513
|
+
enableClickToCopy?:
|
|
514
|
+
| 'context-menu'
|
|
515
|
+
| ((cell: MRT_Cell<TData>) => 'context-menu' | boolean)
|
|
516
|
+
| boolean;
|
|
507
517
|
enableColumnActions?: boolean;
|
|
508
518
|
enableColumnDragging?: boolean;
|
|
509
519
|
enableColumnFilterModes?: boolean;
|
|
@@ -642,6 +652,16 @@ export type MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> = Omit<
|
|
|
642
652
|
table: MRT_TableInstance<TData>;
|
|
643
653
|
}) => TableCellProps)
|
|
644
654
|
| TableCellProps;
|
|
655
|
+
renderCellActionMenuItems?: (props: {
|
|
656
|
+
cell: MRT_Cell<TData>;
|
|
657
|
+
closeMenu: () => void;
|
|
658
|
+
column: MRT_Column<TData>;
|
|
659
|
+
internalMenuItems: ReactNode[];
|
|
660
|
+
row: MRT_Row<TData>;
|
|
661
|
+
staticColumnIndex?: number;
|
|
662
|
+
staticRowIndex?: number;
|
|
663
|
+
table: MRT_TableInstance<TData>;
|
|
664
|
+
}) => ReactNode[];
|
|
645
665
|
renderColumnActionsMenuItems?: (props: {
|
|
646
666
|
closeMenu: () => void;
|
|
647
667
|
column: MRT_Column<TData>;
|
|
@@ -832,8 +852,13 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
|
832
852
|
[key in MRT_DisplayColumnIds]: Partial<MRT_DisplayColumnDef<TData>>;
|
|
833
853
|
}>;
|
|
834
854
|
editDisplayMode?: 'cell' | 'custom' | 'modal' | 'row' | 'table';
|
|
855
|
+
enableBatchRowSelection?: boolean;
|
|
835
856
|
enableBottomToolbar?: boolean;
|
|
836
|
-
|
|
857
|
+
enableCellActions?: ((cell: MRT_Cell<TData>) => boolean) | boolean;
|
|
858
|
+
enableClickToCopy?:
|
|
859
|
+
| 'context-menu'
|
|
860
|
+
| ((cell: MRT_Cell<TData>) => 'context-menu' | boolean)
|
|
861
|
+
| boolean;
|
|
837
862
|
enableColumnActions?: boolean;
|
|
838
863
|
enableColumnDragging?: boolean;
|
|
839
864
|
enableColumnFilterModes?: boolean;
|
|
@@ -894,8 +919,10 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
|
894
919
|
| ((props: { table: MRT_TableInstance<TData> }) => BoxProps)
|
|
895
920
|
| BoxProps;
|
|
896
921
|
muiCircularProgressProps?:
|
|
897
|
-
| ((props: {
|
|
898
|
-
|
|
922
|
+
| ((props: {
|
|
923
|
+
table: MRT_TableInstance<TData>;
|
|
924
|
+
}) => CircularProgressProps & { Component?: ReactNode })
|
|
925
|
+
| (CircularProgressProps & { Component?: ReactNode });
|
|
899
926
|
muiColumnActionsButtonProps?:
|
|
900
927
|
| ((props: {
|
|
901
928
|
column: MRT_Column<TData>;
|
|
@@ -1115,6 +1142,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
|
1115
1142
|
muiTopToolbarProps?:
|
|
1116
1143
|
| ((props: { table: MRT_TableInstance<TData> }) => BoxProps)
|
|
1117
1144
|
| BoxProps;
|
|
1145
|
+
onActionCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
|
1118
1146
|
onColumnFilterFnsChange?: OnChangeFn<{ [key: string]: MRT_FilterOption }>;
|
|
1119
1147
|
onCreatingRowCancel?: (props: {
|
|
1120
1148
|
row: MRT_Row<TData>;
|
|
@@ -1167,6 +1195,16 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
|
1167
1195
|
renderCaption?:
|
|
1168
1196
|
| ((props: { table: MRT_TableInstance<TData> }) => ReactNode)
|
|
1169
1197
|
| ReactNode;
|
|
1198
|
+
renderCellActionMenuItems?: (props: {
|
|
1199
|
+
cell: MRT_Cell<TData>;
|
|
1200
|
+
closeMenu: () => void;
|
|
1201
|
+
column: MRT_Column<TData>;
|
|
1202
|
+
internalMenuItems: ReactNode[];
|
|
1203
|
+
row: MRT_Row<TData>;
|
|
1204
|
+
staticColumnIndex?: number;
|
|
1205
|
+
staticRowIndex?: number;
|
|
1206
|
+
table: MRT_TableInstance<TData>;
|
|
1207
|
+
}) => ReactNode[];
|
|
1170
1208
|
renderColumnActionsMenuItems?: (props: {
|
|
1171
1209
|
closeMenu: () => void;
|
|
1172
1210
|
column: MRT_Column<TData>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type MRT_Cell,
|
|
3
|
+
type MRT_RowData,
|
|
4
|
+
type MRT_TableInstance,
|
|
5
|
+
} from '../types';
|
|
6
|
+
import { parseFromValuesOrFunc } from './utils';
|
|
7
|
+
|
|
8
|
+
export const isCellEditable = <TData extends MRT_RowData>({
|
|
9
|
+
cell,
|
|
10
|
+
table,
|
|
11
|
+
}: {
|
|
12
|
+
cell: MRT_Cell<TData>;
|
|
13
|
+
table: MRT_TableInstance<TData>;
|
|
14
|
+
}) => {
|
|
15
|
+
const { enableEditing } = table.options;
|
|
16
|
+
const {
|
|
17
|
+
column: { columnDef },
|
|
18
|
+
row,
|
|
19
|
+
} = cell;
|
|
20
|
+
return (
|
|
21
|
+
!cell.getIsPlaceholder() &&
|
|
22
|
+
parseFromValuesOrFunc(enableEditing, row) &&
|
|
23
|
+
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const openEditingCell = <TData extends MRT_RowData>({
|
|
28
|
+
cell,
|
|
29
|
+
table,
|
|
30
|
+
}: {
|
|
31
|
+
cell: MRT_Cell<TData>;
|
|
32
|
+
table: MRT_TableInstance<TData>;
|
|
33
|
+
}) => {
|
|
34
|
+
const {
|
|
35
|
+
options: { editDisplayMode },
|
|
36
|
+
refs: { editInputRefs },
|
|
37
|
+
} = table;
|
|
38
|
+
const { column } = cell;
|
|
39
|
+
|
|
40
|
+
if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
|
|
41
|
+
table.setEditingCell(cell);
|
|
42
|
+
queueMicrotask(() => {
|
|
43
|
+
const textField = editInputRefs.current[column.id];
|
|
44
|
+
if (textField) {
|
|
45
|
+
textField.focus();
|
|
46
|
+
textField.select?.();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -115,12 +115,10 @@ export const reorderColumn = <TData extends MRT_RowData>(
|
|
|
115
115
|
export const getDefaultColumnFilterFn = <TData extends MRT_RowData>(
|
|
116
116
|
columnDef: MRT_ColumnDef<TData>,
|
|
117
117
|
): MRT_FilterOption => {
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
columnDef.filterVariant === 'checkbox'
|
|
123
|
-
)
|
|
118
|
+
const { filterVariant } = columnDef;
|
|
119
|
+
if (filterVariant === 'multi-select') return 'arrIncludesSome';
|
|
120
|
+
if (filterVariant?.includes('range')) return 'betweenInclusive';
|
|
121
|
+
if (filterVariant === 'select' || filterVariant === 'checkbox')
|
|
124
122
|
return 'equals';
|
|
125
123
|
return 'fuzzy';
|
|
126
124
|
};
|
|
@@ -31,21 +31,21 @@ export function defaultDisplayColumnProps<TData extends MRT_RowData>({
|
|
|
31
31
|
|
|
32
32
|
export const showRowPinningColumn = <TData extends MRT_RowData>(
|
|
33
33
|
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
34
|
-
) => {
|
|
34
|
+
): boolean => {
|
|
35
35
|
const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
|
|
36
|
-
return enableRowPinning && !rowPinningDisplayMode?.startsWith('select');
|
|
36
|
+
return !!(enableRowPinning && !rowPinningDisplayMode?.startsWith('select'));
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
export const showRowDragColumn = <TData extends MRT_RowData>(
|
|
40
40
|
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
41
|
-
) => {
|
|
41
|
+
): boolean => {
|
|
42
42
|
const { enableRowDragging, enableRowOrdering } = tableOptions;
|
|
43
|
-
return enableRowDragging || enableRowOrdering;
|
|
43
|
+
return !!(enableRowDragging || enableRowOrdering);
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export const showRowExpandColumn = <TData extends MRT_RowData>(
|
|
47
47
|
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
48
|
-
) => {
|
|
48
|
+
): boolean => {
|
|
49
49
|
const {
|
|
50
50
|
enableExpanding,
|
|
51
51
|
enableGrouping,
|
|
@@ -54,14 +54,14 @@ export const showRowExpandColumn = <TData extends MRT_RowData>(
|
|
|
54
54
|
} = tableOptions;
|
|
55
55
|
return !!(
|
|
56
56
|
enableExpanding ||
|
|
57
|
-
(enableGrouping &&
|
|
57
|
+
(enableGrouping && grouping?.length) ||
|
|
58
58
|
renderDetailPanel
|
|
59
59
|
);
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export const showRowActionsColumn = <TData extends MRT_RowData>(
|
|
63
63
|
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
64
|
-
) => {
|
|
64
|
+
): boolean => {
|
|
65
65
|
const {
|
|
66
66
|
createDisplayMode,
|
|
67
67
|
editDisplayMode,
|
|
@@ -69,7 +69,7 @@ export const showRowActionsColumn = <TData extends MRT_RowData>(
|
|
|
69
69
|
enableRowActions,
|
|
70
70
|
state: { creatingRow },
|
|
71
71
|
} = tableOptions;
|
|
72
|
-
return (
|
|
72
|
+
return !!(
|
|
73
73
|
enableRowActions ||
|
|
74
74
|
(creatingRow && createDisplayMode === 'row') ||
|
|
75
75
|
(enableEditing && ['modal', 'row'].includes(editDisplayMode ?? ''))
|
|
@@ -78,15 +78,15 @@ export const showRowActionsColumn = <TData extends MRT_RowData>(
|
|
|
78
78
|
|
|
79
79
|
export const showRowSelectionColumn = <TData extends MRT_RowData>(
|
|
80
80
|
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
81
|
-
) => tableOptions.enableRowSelection;
|
|
81
|
+
): boolean => !!tableOptions.enableRowSelection;
|
|
82
82
|
|
|
83
83
|
export const showRowNumbersColumn = <TData extends MRT_RowData>(
|
|
84
84
|
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
85
|
-
) => tableOptions.enableRowNumbers;
|
|
85
|
+
): boolean => !!tableOptions.enableRowNumbers;
|
|
86
86
|
|
|
87
87
|
export const showRowSpacerColumn = <TData extends MRT_RowData>(
|
|
88
88
|
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
89
|
-
) => tableOptions.layoutMode === 'grid-no-grow';
|
|
89
|
+
): boolean => tableOptions.layoutMode === 'grid-no-grow';
|
|
90
90
|
|
|
91
91
|
export const getLeadingDisplayColumnIds = <TData extends MRT_RowData>(
|
|
92
92
|
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
@@ -119,16 +119,34 @@ export const getTrailingDisplayColumnIds = <TData extends MRT_RowData>(
|
|
|
119
119
|
|
|
120
120
|
export const getDefaultColumnOrderIds = <TData extends MRT_RowData>(
|
|
121
121
|
tableOptions: MRT_StatefulTableOptions<TData>,
|
|
122
|
+
reset = false,
|
|
122
123
|
) => {
|
|
123
|
-
const
|
|
124
|
-
|
|
124
|
+
const {
|
|
125
|
+
state: { columnOrder: currentColumnOrderIds = [] },
|
|
126
|
+
} = tableOptions;
|
|
127
|
+
|
|
128
|
+
const leadingDisplayColIds: string[] =
|
|
129
|
+
getLeadingDisplayColumnIds(tableOptions);
|
|
130
|
+
const trailingDisplayColIds: string[] =
|
|
125
131
|
getTrailingDisplayColumnIds(tableOptions);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
|
|
133
|
+
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map(
|
|
134
|
+
(columnDef) => getColumnId(columnDef),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
let allLeafColumnDefIds = reset
|
|
138
|
+
? defaultColumnDefIds
|
|
139
|
+
: Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
|
|
140
|
+
|
|
141
|
+
allLeafColumnDefIds = allLeafColumnDefIds.filter(
|
|
142
|
+
(colId) =>
|
|
143
|
+
!leadingDisplayColIds.includes(colId) &&
|
|
144
|
+
!trailingDisplayColIds.includes(colId),
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
return [
|
|
148
|
+
...leadingDisplayColIds,
|
|
149
|
+
...allLeafColumnDefIds,
|
|
150
|
+
...trailingDisplayColIds,
|
|
151
|
+
];
|
|
134
152
|
};
|
package/src/utils/row.utils.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type ChangeEvent, type MouseEvent } from 'react';
|
|
2
|
+
import { rankGlobalFuzzy } from '../fns/sortingFns';
|
|
1
3
|
import {
|
|
2
4
|
type MRT_Row,
|
|
3
5
|
type MRT_RowData,
|
|
@@ -5,36 +7,88 @@ import {
|
|
|
5
7
|
} from '../types';
|
|
6
8
|
import { parseFromValuesOrFunc } from './utils';
|
|
7
9
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
table: MRT_TableInstance<TData>;
|
|
14
|
-
}) => {
|
|
10
|
+
export const getMRT_Rows = <TData extends MRT_RowData>(
|
|
11
|
+
table: MRT_TableInstance<TData>,
|
|
12
|
+
pinnedRowIds: string[] = [],
|
|
13
|
+
all?: boolean,
|
|
14
|
+
): MRT_Row<TData>[] => {
|
|
15
15
|
const {
|
|
16
|
-
|
|
16
|
+
getBottomRows,
|
|
17
|
+
getCenterRows,
|
|
18
|
+
getPrePaginationRowModel,
|
|
19
|
+
getRowModel,
|
|
20
|
+
getState,
|
|
21
|
+
getTopRows,
|
|
22
|
+
options: {
|
|
23
|
+
createDisplayMode,
|
|
24
|
+
enablePagination,
|
|
25
|
+
enableRowPinning,
|
|
26
|
+
manualPagination,
|
|
27
|
+
positionCreatingRow,
|
|
28
|
+
rowPinningDisplayMode,
|
|
29
|
+
},
|
|
17
30
|
} = table;
|
|
31
|
+
const { creatingRow, pagination } = getState();
|
|
18
32
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
const isRankingRows = getIsRankingRows(table);
|
|
34
|
+
|
|
35
|
+
let rows: MRT_Row<TData>[] = [];
|
|
36
|
+
if (!isRankingRows) {
|
|
37
|
+
rows =
|
|
38
|
+
!enableRowPinning || rowPinningDisplayMode?.includes('sticky')
|
|
39
|
+
? all
|
|
40
|
+
? getPrePaginationRowModel().rows
|
|
41
|
+
: getRowModel().rows
|
|
42
|
+
: getCenterRows();
|
|
43
|
+
} else {
|
|
44
|
+
rows = getPrePaginationRowModel().rows.sort((a, b) =>
|
|
45
|
+
rankGlobalFuzzy(a, b),
|
|
46
|
+
);
|
|
47
|
+
if (enablePagination && !manualPagination && !all) {
|
|
48
|
+
const start = pagination.pageIndex * pagination.pageSize;
|
|
49
|
+
rows = rows.slice(start, start + pagination.pageSize);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (enableRowPinning && rowPinningDisplayMode?.includes('sticky')) {
|
|
53
|
+
rows = [
|
|
54
|
+
...getTopRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
|
55
|
+
...rows,
|
|
56
|
+
...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
60
|
+
positionCreatingRow !== undefined &&
|
|
61
|
+
creatingRow &&
|
|
62
|
+
createDisplayMode === 'row'
|
|
63
|
+
) {
|
|
64
|
+
const creatingRowIndex = !isNaN(+positionCreatingRow)
|
|
65
|
+
? +positionCreatingRow
|
|
66
|
+
: positionCreatingRow === 'top'
|
|
67
|
+
? 0
|
|
68
|
+
: rows.length;
|
|
69
|
+
rows = [
|
|
70
|
+
...rows.slice(0, creatingRowIndex),
|
|
71
|
+
creatingRow,
|
|
72
|
+
...rows.slice(creatingRowIndex),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return rows;
|
|
25
77
|
};
|
|
26
78
|
|
|
27
79
|
export const getCanRankRows = <TData extends MRT_RowData>(
|
|
28
80
|
table: MRT_TableInstance<TData>,
|
|
29
81
|
) => {
|
|
30
|
-
const { getState, options } = table;
|
|
31
82
|
const {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
83
|
+
getState,
|
|
84
|
+
options: {
|
|
85
|
+
enableGlobalFilterRankedResults,
|
|
86
|
+
manualExpanding,
|
|
87
|
+
manualFiltering,
|
|
88
|
+
manualGrouping,
|
|
89
|
+
manualSorting,
|
|
90
|
+
},
|
|
91
|
+
} = table;
|
|
38
92
|
const { expanded, globalFilterFn } = getState();
|
|
39
93
|
|
|
40
94
|
return (
|
|
@@ -48,3 +102,107 @@ export const getCanRankRows = <TData extends MRT_RowData>(
|
|
|
48
102
|
!Object.values(expanded).some(Boolean)
|
|
49
103
|
);
|
|
50
104
|
};
|
|
105
|
+
|
|
106
|
+
export const getIsRankingRows = <TData extends MRT_RowData>(
|
|
107
|
+
table: MRT_TableInstance<TData>,
|
|
108
|
+
) => {
|
|
109
|
+
const { globalFilter, sorting } = table.getState();
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
getCanRankRows(table) &&
|
|
113
|
+
globalFilter &&
|
|
114
|
+
!Object.values(sorting).some(Boolean)
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const getIsRowSelected = <TData extends MRT_RowData>({
|
|
119
|
+
row,
|
|
120
|
+
table,
|
|
121
|
+
}: {
|
|
122
|
+
row: MRT_Row<TData>;
|
|
123
|
+
table: MRT_TableInstance<TData>;
|
|
124
|
+
}) => {
|
|
125
|
+
const {
|
|
126
|
+
options: { enableRowSelection },
|
|
127
|
+
} = table;
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
row.getIsSelected() ||
|
|
131
|
+
(parseFromValuesOrFunc(enableRowSelection, row) &&
|
|
132
|
+
row.getCanSelectSubRows() &&
|
|
133
|
+
row.getIsAllSubRowsSelected())
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const getMRT_RowSelectionHandler =
|
|
138
|
+
() =>
|
|
139
|
+
<TData extends MRT_RowData>({
|
|
140
|
+
event,
|
|
141
|
+
row,
|
|
142
|
+
staticRowIndex = 0,
|
|
143
|
+
table,
|
|
144
|
+
}: {
|
|
145
|
+
event: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLTableRowElement>;
|
|
146
|
+
row: MRT_Row<TData>;
|
|
147
|
+
staticRowIndex?: number;
|
|
148
|
+
table: MRT_TableInstance<TData>;
|
|
149
|
+
}) => {
|
|
150
|
+
const {
|
|
151
|
+
getState,
|
|
152
|
+
options: {
|
|
153
|
+
enableBatchRowSelection,
|
|
154
|
+
enableRowPinning,
|
|
155
|
+
rowPinningDisplayMode,
|
|
156
|
+
},
|
|
157
|
+
refs: { lastSelectedRowId: lastSelectedRowId },
|
|
158
|
+
} = table;
|
|
159
|
+
const {
|
|
160
|
+
pagination: { pageIndex, pageSize },
|
|
161
|
+
} = getState();
|
|
162
|
+
|
|
163
|
+
const isChecked = getIsRowSelected({ row, table });
|
|
164
|
+
|
|
165
|
+
const isStickySelection =
|
|
166
|
+
enableRowPinning && rowPinningDisplayMode?.includes('select');
|
|
167
|
+
|
|
168
|
+
// toggle selected of this row
|
|
169
|
+
row.getToggleSelectedHandler()(event);
|
|
170
|
+
|
|
171
|
+
// if shift key is pressed, select all rows between last selected and this one
|
|
172
|
+
if (
|
|
173
|
+
enableBatchRowSelection &&
|
|
174
|
+
(event as any).nativeEvent.shiftKey &&
|
|
175
|
+
lastSelectedRowId.current !== null
|
|
176
|
+
) {
|
|
177
|
+
const rows = getMRT_Rows(table, undefined, true);
|
|
178
|
+
const lastIndex = rows.findIndex(
|
|
179
|
+
(r) => r.id === lastSelectedRowId.current,
|
|
180
|
+
);
|
|
181
|
+
if (lastIndex !== -1) {
|
|
182
|
+
const currentIndex = staticRowIndex + pageSize * pageIndex;
|
|
183
|
+
const [start, end] =
|
|
184
|
+
lastIndex < currentIndex
|
|
185
|
+
? [lastIndex, currentIndex]
|
|
186
|
+
: [currentIndex, lastIndex];
|
|
187
|
+
for (let i = start; i <= end; i++) {
|
|
188
|
+
rows[i].toggleSelected(!isChecked);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
lastSelectedRowId.current = row.id;
|
|
193
|
+
|
|
194
|
+
// if all sub rows were selected, unselect them
|
|
195
|
+
if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
|
|
196
|
+
row.subRows?.forEach((r) => r.toggleSelected(false));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (isStickySelection) {
|
|
200
|
+
row.pin(
|
|
201
|
+
!row.getIsPinned() && isChecked
|
|
202
|
+
? rowPinningDisplayMode?.includes('bottom')
|
|
203
|
+
? 'bottom'
|
|
204
|
+
: 'top'
|
|
205
|
+
: false,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
};
|