@tap-payments/os-micro-frontend-shared 0.1.132 → 0.1.133-test.2
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 -21
- package/README.md +12 -12
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +64 -32
- package/build/components/VirtualTables/SheetViewVirtualTable/components/LoadingMainTable.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/LoadingMainTable.js +2 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.js +2 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/NoDataView.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/NoDataView.js +2 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.js +2 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/VirtualTable.js +15 -12
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.d.ts +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.js +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.d.ts +11 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js +37 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePinnedColumns.js +73 -35
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.js +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts +1 -23
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js +32 -28
- package/build/components/VirtualTables/SheetViewVirtualTable/types.d.ts +14 -7
- package/build/components/VirtualTables/components/ColumnFilter/ColumnFilter.js +1 -1
- package/build/components/VirtualTables/components/TableRow.js +20 -18
- package/build/components/VirtualTables/components/virtualScroll/ListItemWrapper.js +1 -1
- package/build/components/index.d.ts +0 -2
- package/build/components/index.js +0 -2
- package/build/constants/table/cell/terminalsTableCellWidth.d.ts +3 -3
- package/build/constants/table/cell/terminalsTableCellWidth.js +3 -3
- package/build/constants/table.d.ts +1 -1
- package/build/constants/table.js +1 -1
- package/build/types/entity.d.ts +0 -5
- package/build/utils/style.d.ts +2 -2
- package/build/utils/style.js +2 -2
- package/package.json +3 -3
- package/build/components/ErrorToast/ErrorToast.d.ts +0 -3
- package/build/components/ErrorToast/ErrorToast.js +0 -7
- package/build/components/ErrorToast/index.d.ts +0 -2
- package/build/components/ErrorToast/index.js +0 -2
- package/build/components/ErrorToast/style.d.ts +0 -9
- package/build/components/ErrorToast/style.js +0 -33
- package/build/components/ErrorToast/type.d.ts +0 -10
- package/build/components/ErrorToast/type.js +0 -1
- package/build/components/ToggleView/ToggleView.d.ts +0 -16
- package/build/components/ToggleView/ToggleView.js +0 -32
- package/build/components/ToggleView/ToggleWrapper.d.ts +0 -4
- package/build/components/ToggleView/ToggleWrapper.js +0 -8
- package/build/components/ToggleView/index.d.ts +0 -3
- package/build/components/ToggleView/index.js +0 -3
- package/build/components/ToggleView/style.d.ts +0 -14
- package/build/components/ToggleView/style.js +0 -31
- package/build/components/ToggleView/types.d.ts +0 -6
- package/build/components/ToggleView/types.js +0 -6
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Tap Payments
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tap Payments
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# os-micro-frontend-shared
|
|
2
|
-
|
|
3
|
-
## Publishing Workflow
|
|
4
|
-
|
|
5
|
-
1. Update version in package.json
|
|
6
|
-
2. Commit changes
|
|
7
|
-
3. Create and push a tag:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm version patch # or minor, major
|
|
11
|
-
git push origin main --tags
|
|
12
|
-
```
|
|
1
|
+
# os-micro-frontend-shared
|
|
2
|
+
|
|
3
|
+
## Publishing Workflow
|
|
4
|
+
|
|
5
|
+
1. Update version in package.json
|
|
6
|
+
2. Commit changes
|
|
7
|
+
3. Create and push a tag:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm version patch # or minor, major
|
|
11
|
+
git push origin main --tags
|
|
12
|
+
```
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useCallback } from 'react';
|
|
2
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
3
3
|
import { SHEET_VIEW_TABLE_THRESHOLD } from '../../../constants/index.js';
|
|
4
4
|
import TableFooter from '../components/TableFooter/TableFooter';
|
|
5
5
|
import { SheetViewTableContainer } from '../components/style';
|
|
6
6
|
import { SheetViewVirtualTableWrapper } from './style';
|
|
7
|
-
import { usePinnedColumns, useSynchronizedScroll, useTableState, useTableData, useVirtualTableContainer, usePinnedColumnsWidths } from './hooks';
|
|
7
|
+
import { usePinnedColumns, useSynchronizedScroll, useTableState, useTableData, useVirtualTableContainer, usePinnedColumnsWidths, usePerformanceOptimizations, } from './hooks';
|
|
8
8
|
import { PinnedColumn, MainTable, LoadingMainTable, NoDataView, VirtualTable } from './components';
|
|
9
9
|
function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, rowHeight = 28, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableTitle, dragControls, onColumnPin, clearBackdropVisibilityTimeout = 100, isPinnable = false, tableMode, overscanCount, }) {
|
|
10
|
+
const { stableColumns } = usePerformanceOptimizations(columns);
|
|
10
11
|
const { selectedCell, selectedColumn, selectedRow, showBackDrop, setShowBackdrop, handleCellClick, handleColumnClick, handleChipClick, selectedChip, } = useTableState();
|
|
11
12
|
const { isError, tableLoading, tableError, tableEmpty, hasTimeoutError, showNoDataView, lastItemIndex, areTotalRowsNotFillingHeight, itemsCount, isDelayedFetchingNextPage, } = useTableData({
|
|
12
13
|
rows,
|
|
@@ -15,7 +16,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
15
16
|
isFetchingNextPage,
|
|
16
17
|
areAllRowsLoaded,
|
|
17
18
|
});
|
|
18
|
-
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(
|
|
19
|
+
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(stableColumns, isPinnable, onColumnPin);
|
|
19
20
|
const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
|
|
20
21
|
const { pinnedStartColumnsWidth, pinnedEndColumnsWidth } = usePinnedColumnsWidths(pinnedStartColumnsData, pinnedEndColumnsData);
|
|
21
22
|
const { getItemSize, getItemDataForContainer } = useVirtualTableContainer({
|
|
@@ -37,31 +38,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
37
38
|
const onPointerDown = (e) => {
|
|
38
39
|
dragControls === null || dragControls === void 0 ? void 0 : dragControls.start(e);
|
|
39
40
|
};
|
|
40
|
-
const
|
|
41
|
-
const listRef = containerKey === 'pinnedStart' ? pinnedStartVirtualListRef : containerKey === 'pinnedEnd' ? pinnedEndVirtualListRef : scrollableVirtualListRef;
|
|
42
|
-
const handleScrollCallback = (scrollProps) => {
|
|
43
|
-
const source = containerKey === 'pinnedStart' ? 'start' : containerKey === 'pinnedEnd' ? 'end' : 'scrollable';
|
|
44
|
-
handleScroll(scrollProps, source);
|
|
45
|
-
};
|
|
46
|
-
return (_jsx(VirtualTable, { columnsData: columnsData, itemCount: itemsCount, lastItemIndex: lastItemIndex, areAllRowsLoaded: areAllRowsLoaded, loadMoreItems: loadMoreItems, threshold: threshold, getItemSize: getItemSize, getItemData: getItemDataForContainer, isPinned: isPinned, fixedWidth: fixedWidth, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, onScroll: handleScrollCallback, setBackdropVisibility: setShowBackdrop, listRef: listRef, overscanCount: overscanCount }));
|
|
47
|
-
}, [
|
|
48
|
-
itemsCount,
|
|
49
|
-
lastItemIndex,
|
|
50
|
-
areAllRowsLoaded,
|
|
51
|
-
loadMoreItems,
|
|
52
|
-
threshold,
|
|
53
|
-
getItemSize,
|
|
54
|
-
getItemDataForContainer,
|
|
55
|
-
scrollToIndex,
|
|
56
|
-
areTotalRowsNotFillingHeight,
|
|
57
|
-
clearBackdropVisibilityTimeout,
|
|
58
|
-
handleScroll,
|
|
59
|
-
setShowBackdrop,
|
|
60
|
-
pinnedStartVirtualListRef,
|
|
61
|
-
pinnedEndVirtualListRef,
|
|
62
|
-
scrollableVirtualListRef,
|
|
63
|
-
]);
|
|
64
|
-
const baseCommonProps = {
|
|
41
|
+
const baseCommonProps = useMemo(() => ({
|
|
65
42
|
showHeader,
|
|
66
43
|
columnsSorting,
|
|
67
44
|
onColumnSort,
|
|
@@ -81,9 +58,64 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
81
58
|
tableMode,
|
|
82
59
|
showNoDataView,
|
|
83
60
|
tableBodyStyles,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
61
|
+
}), [
|
|
62
|
+
showHeader,
|
|
63
|
+
columnsSorting,
|
|
64
|
+
onColumnSort,
|
|
65
|
+
headerProps,
|
|
66
|
+
showBackDrop,
|
|
67
|
+
handleColumnPin,
|
|
68
|
+
isPinnable,
|
|
69
|
+
lastColumnId,
|
|
70
|
+
selectedColumn,
|
|
71
|
+
handleColumnClick,
|
|
72
|
+
tableTitle,
|
|
73
|
+
areAllRowsLoaded,
|
|
74
|
+
isFetchingNextPage,
|
|
75
|
+
scrollToIndex,
|
|
76
|
+
isLoading,
|
|
77
|
+
isError,
|
|
78
|
+
tableMode,
|
|
79
|
+
showNoDataView,
|
|
80
|
+
tableBodyStyles,
|
|
81
|
+
]);
|
|
82
|
+
const commonPropsWithTableStates = useMemo(() => (Object.assign(Object.assign({}, baseCommonProps), { hasTimeoutError,
|
|
83
|
+
tableLoading })), [baseCommonProps, hasTimeoutError, tableLoading]);
|
|
84
|
+
const virtualTableBaseProps = useMemo(() => ({
|
|
85
|
+
itemCount: itemsCount,
|
|
86
|
+
lastItemIndex,
|
|
87
|
+
areAllRowsLoaded,
|
|
88
|
+
loadMoreItems,
|
|
89
|
+
threshold,
|
|
90
|
+
getItemSize,
|
|
91
|
+
getItemData: getItemDataForContainer,
|
|
92
|
+
scrollToIndex,
|
|
93
|
+
areTotalRowsNotFillingHeight,
|
|
94
|
+
clearBackdropVisibilityTimeout,
|
|
95
|
+
setBackdropVisibility: setShowBackdrop,
|
|
96
|
+
overscanCount,
|
|
97
|
+
}), [
|
|
98
|
+
itemsCount,
|
|
99
|
+
lastItemIndex,
|
|
100
|
+
areAllRowsLoaded,
|
|
101
|
+
loadMoreItems,
|
|
102
|
+
threshold,
|
|
103
|
+
getItemSize,
|
|
104
|
+
getItemDataForContainer,
|
|
105
|
+
scrollToIndex,
|
|
106
|
+
areTotalRowsNotFillingHeight,
|
|
107
|
+
clearBackdropVisibilityTimeout,
|
|
108
|
+
setShowBackdrop,
|
|
109
|
+
overscanCount,
|
|
110
|
+
]);
|
|
111
|
+
const createVirtualTableContainer = useCallback((columnsData, containerKey, isPinned = false, fixedWidth) => {
|
|
112
|
+
const listRef = containerKey === 'pinnedStart' ? pinnedStartVirtualListRef : containerKey === 'pinnedEnd' ? pinnedEndVirtualListRef : scrollableVirtualListRef;
|
|
113
|
+
const handleScrollCallback = (scrollProps) => {
|
|
114
|
+
const source = containerKey === 'pinnedStart' ? 'start' : containerKey === 'pinnedEnd' ? 'end' : 'scrollable';
|
|
115
|
+
handleScroll(scrollProps, source);
|
|
116
|
+
};
|
|
117
|
+
return (_jsx(VirtualTable, Object.assign({}, virtualTableBaseProps, { columnsData: columnsData, isPinned: isPinned, fixedWidth: fixedWidth, onScroll: handleScrollCallback, listRef: listRef })));
|
|
118
|
+
}, [virtualTableBaseProps, handleScroll, pinnedStartVirtualListRef, pinnedEndVirtualListRef, scrollableVirtualListRef]);
|
|
119
|
+
return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsData.length > 0 && (_jsx(PinnedColumn, { position: "start", columnsData: pinnedStartColumnsData, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates })), _jsx(LoadingMainTable, { hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, unpinnedColumnsData: unpinnedColumnsData, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns, commonProps: commonPropsWithTableStates }), pinnedEndColumnsData.length > 0 && (_jsx(PinnedColumn, { position: "end", columnsData: pinnedEndColumnsData, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates }))] })) : (_jsx(NoDataView, { tableLoading: tableLoading, tableError: tableError, tableEmpty: tableEmpty, hasTimeoutError: hasTimeoutError, orderedColumns: orderedColumns, error: error, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps, commonProps: baseCommonProps }))) : (_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsData.length > 0 && (_jsx(PinnedColumn, { position: "start", columnsData: pinnedStartColumnsData, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates })), _jsx(MainTable, { hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, unpinnedColumnsData: unpinnedColumnsData, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates }), pinnedEndColumnsData.length > 0 && (_jsx(PinnedColumn, { position: "end", columnsData: pinnedEndColumnsData, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates }))] })) }), _jsx(TableFooter, Object.assign({ "data-testid": "SheetViewVirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps))] }));
|
|
88
120
|
}
|
|
89
121
|
export default memo(SheetViewVirtualTable);
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/LoadingMainTable.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { LoadingMainTableProps } from '../types';
|
|
3
|
-
declare function LoadingMainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData,
|
|
3
|
+
declare function LoadingMainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, pinnedStartColumns, pinnedEndColumns, commonProps, }: LoadingMainTableProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof LoadingMainTable>;
|
|
5
5
|
export default _default;
|
|
@@ -5,8 +5,9 @@ import { StyledTableBox, TableWrapper, StyledBox } from '../../components/style'
|
|
|
5
5
|
import { MainTableWrapper, UnpinnedTableHeaderWrapper } from '../style';
|
|
6
6
|
import SheetViewTableHeader from './SheetViewTableHeader';
|
|
7
7
|
import SheetViewTableLoading from './SheetViewTableLoading';
|
|
8
|
-
function LoadingMainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData,
|
|
8
|
+
function LoadingMainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, pinnedStartColumns, pinnedEndColumns, commonProps, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
|
+
const { showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, } = commonProps;
|
|
10
11
|
return (_jsx(MainTableWrapper, Object.assign({ hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox_Loading", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_LoadingTableWrapper", showNoDataView: showNoDataView, sx: Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' }) }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_LoadingTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [...pinnedStartColumns, ...pinnedEndColumns], onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: "scrollable", hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_LoadingTableWrapper", sx: {
|
|
11
12
|
width: '100%',
|
|
12
13
|
minWidth: 'fit-content',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { MainTableProps } from '../types';
|
|
3
|
-
declare function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData,
|
|
3
|
+
declare function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, pinnedStartColumns, pinnedEndColumns, createVirtualTableContainer, commonProps, }: MainTableProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof MainTable>;
|
|
5
5
|
export default _default;
|
|
@@ -5,8 +5,9 @@ import { StyledTableBox, TableWrapper, StyledBox } from '../../components/style'
|
|
|
5
5
|
import { MainTableWrapper, UnpinnedTableHeaderWrapper } from '../style';
|
|
6
6
|
import SheetViewTableHeader from './SheetViewTableHeader';
|
|
7
7
|
import SheetViewTableLoading from './SheetViewTableLoading';
|
|
8
|
-
function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData,
|
|
8
|
+
function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, pinnedStartColumns, pinnedEndColumns, createVirtualTableContainer, commonProps, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
|
+
const { showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, tableLoading, } = commonProps;
|
|
10
11
|
return (_jsx(MainTableWrapper, Object.assign({ hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' }) }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_UnpinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [...pinnedStartColumns, ...pinnedEndColumns], onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: "scrollable", hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
11
12
|
width: '100%',
|
|
12
13
|
minWidth: 'fit-content',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { NoDataViewProps } from '../types';
|
|
3
|
-
declare function NoDataView({ tableLoading, tableError, tableEmpty, hasTimeoutError, orderedColumns,
|
|
3
|
+
declare function NoDataView({ tableLoading, tableError, tableEmpty, hasTimeoutError, orderedColumns, error, triggerDataRefetch, footerProps, commonProps, }: NoDataViewProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof NoDataView>;
|
|
5
5
|
export default _default;
|
|
@@ -5,8 +5,9 @@ import { StyledTableBox, TableWrapper } from '../../components/style';
|
|
|
5
5
|
import { UnpinnedTableHeaderWrapper } from '../style';
|
|
6
6
|
import TableNoData from '../../components/TableNoData';
|
|
7
7
|
import SheetViewTableHeader from './SheetViewTableHeader';
|
|
8
|
-
function NoDataView({ tableLoading, tableError, tableEmpty, hasTimeoutError, orderedColumns,
|
|
8
|
+
function NoDataView({ tableLoading, tableError, tableEmpty, hasTimeoutError, orderedColumns, error, triggerDataRefetch, footerProps, commonProps, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
|
+
const { showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, tableMode, tableBodyStyles, } = commonProps;
|
|
10
11
|
const showNoDataView = tableLoading || tableError || tableEmpty || hasTimeoutError;
|
|
11
12
|
return (_jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: tableBodyStyles }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_LoadingTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: orderedColumns, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [], onColumnPin: onColumnPin, isPinnable: false, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick }) })), _jsx(TableNoData, { error: error || null, tableEmpty: tableEmpty, isTimeoutError: hasTimeoutError, tableError: tableError, tableLoading: tableLoading, orderedColumns: orderedColumns, triggerDataRefetch: triggerDataRefetch || (() => Promise.resolve()), footerProps: footerProps })] })) })));
|
|
12
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { PinnedColumnProps } from '../types';
|
|
3
|
-
declare function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList,
|
|
3
|
+
declare function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, hasPinnedStart, hasPinnedEnd, createVirtualTableContainer, commonProps, }: PinnedColumnProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof PinnedColumn>;
|
|
5
5
|
export default _default;
|
|
@@ -5,8 +5,9 @@ import { StyledTableBox, TableWrapper, StyledBox } from '../../components/style'
|
|
|
5
5
|
import { PinnedStartColumnWrapper, PinnedEndColumnWrapper } from '../style';
|
|
6
6
|
import SheetViewTableHeader from './SheetViewTableHeader';
|
|
7
7
|
import SheetViewTableLoading from './SheetViewTableLoading';
|
|
8
|
-
function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList,
|
|
8
|
+
function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, hasPinnedStart, hasPinnedEnd, createVirtualTableContainer, commonProps, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
|
+
const { showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableLoading, } = commonProps;
|
|
10
11
|
if (columnsData.length === 0)
|
|
11
12
|
return null;
|
|
12
13
|
const Wrapper = position === 'start' ? PinnedStartColumnWrapper : PinnedEndColumnWrapper;
|
|
@@ -8,26 +8,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { memo } from 'react';
|
|
11
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
12
12
|
import InfiniteLoader from 'react-window-infinite-loader';
|
|
13
13
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
14
14
|
import { SHEET_VIEW_TABLE_LIST_OVER_SCAN } from '../../../../constants/index.js';
|
|
15
15
|
import ListItemWrapper from '../../components/virtualScroll/ListItemWrapper';
|
|
16
16
|
import { StyledVirtualList } from '../../components/style';
|
|
17
17
|
function VirtualTable({ columnsData, itemCount, lastItemIndex, areAllRowsLoaded, loadMoreItems, threshold, getItemSize, getItemData, isPinned, fixedWidth, scrollToIndex, areTotalRowsNotFillingHeight, clearBackdropVisibilityTimeout, onScroll, setBackdropVisibility, listRef, overscanCount = SHEET_VIEW_TABLE_LIST_OVER_SCAN, }) {
|
|
18
|
-
const handleOnLoadMoreItems = () => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const handleOnLoadMoreItems = useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
if (areAllRowsLoaded)
|
|
20
20
|
return;
|
|
21
21
|
yield (loadMoreItems === null || loadMoreItems === void 0 ? void 0 : loadMoreItems());
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} }, { children: ListItemWrapper })));
|
|
31
|
-
} }))) })));
|
|
22
|
+
}), [areAllRowsLoaded, loadMoreItems]);
|
|
23
|
+
const isItemLoaded = useCallback((index) => index !== lastItemIndex, [lastItemIndex]);
|
|
24
|
+
const listStyle = useMemo(() => ({
|
|
25
|
+
overflowX: isPinned ? 'hidden' : 'auto',
|
|
26
|
+
paddingBottom: isPinned ? '25px' : '13px',
|
|
27
|
+
backgroundColor: isPinned ? 'transparent' : '#F6F8FACC',
|
|
28
|
+
}), [isPinned]);
|
|
29
|
+
return (_jsx(InfiniteLoader, Object.assign({ isItemLoaded: isItemLoaded, itemCount: itemCount, loadMoreItems: handleOnLoadMoreItems, threshold: threshold }, { children: ({ onItemsRendered, ref }) => (_jsx(AutoSizer, Object.assign({ ref: ref }, { children: ({ height, width }) => (_jsx(MemoizedVirtualList, { listRef: listRef, height: height, width: fixedWidth || width, itemCount: itemCount, getItemSize: getItemSize, getItemData: getItemData, columnsData: columnsData, isPinned: isPinned, onItemsRendered: onItemsRendered, overscanCount: overscanCount, setBackdropVisibility: setBackdropVisibility, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, onScroll: onScroll, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, listStyle: listStyle })) }))) })));
|
|
32
30
|
}
|
|
31
|
+
const MemoizedVirtualList = memo(function MemoizedVirtualList({ listRef, height, width, itemCount, getItemSize, getItemData, columnsData, isPinned, onItemsRendered, overscanCount, setBackdropVisibility, scrollToIndex, areTotalRowsNotFillingHeight, onScroll, clearBackdropVisibilityTimeout, listStyle, }) {
|
|
32
|
+
const itemSize = useCallback((index) => getItemSize(index, height), [getItemSize, height]);
|
|
33
|
+
const itemData = useMemo(() => getItemData(columnsData, isPinned, height), [getItemData, columnsData, isPinned, height]);
|
|
34
|
+
return (_jsx(StyledVirtualList, Object.assign({ listRef: listRef, height: height, width: width, itemCount: itemCount, itemSize: itemSize, itemData: itemData, onItemsRendered: onItemsRendered, overscanCount: overscanCount, setBackdropVisibility: setBackdropVisibility, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, useIsScrolling: true, onScroll: onScroll, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, style: listStyle }, { children: ListItemWrapper })));
|
|
35
|
+
});
|
|
33
36
|
export default memo(VirtualTable);
|
|
@@ -4,3 +4,4 @@ export { useTableState } from './useTableState';
|
|
|
4
4
|
export { useTableData } from './useTableData';
|
|
5
5
|
export { useVirtualTableContainer } from './useVirtualTableContainer';
|
|
6
6
|
export { usePinnedColumnsWidths } from './usePinnedColumnsWidths';
|
|
7
|
+
export { usePerformanceOptimizations } from './usePerformanceOptimizations';
|
|
@@ -4,3 +4,4 @@ export { useTableState } from './useTableState';
|
|
|
4
4
|
export { useTableData } from './useTableData';
|
|
5
5
|
export { useVirtualTableContainer } from './useVirtualTableContainer';
|
|
6
6
|
export { usePinnedColumnsWidths } from './usePinnedColumnsWidths';
|
|
7
|
+
export { usePerformanceOptimizations } from './usePerformanceOptimizations';
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IColumnProps } from '../../../../types/index.js';
|
|
2
|
+
export declare const usePerformanceOptimizations: (columns: readonly IColumnProps[]) => {
|
|
3
|
+
stableColumns: IColumnProps<any>[];
|
|
4
|
+
columnMetrics: {
|
|
5
|
+
visibleColumns: IColumnProps<any>[];
|
|
6
|
+
totalWidth: number;
|
|
7
|
+
columnCount: number;
|
|
8
|
+
firstColumnId: string | number | symbol;
|
|
9
|
+
lastColumnId: string | number | symbol;
|
|
10
|
+
};
|
|
11
|
+
};
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useMemo, useRef } from 'react';
|
|
2
|
+
export const usePerformanceOptimizations = (columns) => {
|
|
3
|
+
const stableColumnsRef = useRef([]);
|
|
4
|
+
const stableColumns = useMemo(() => {
|
|
5
|
+
const hasChanged = columns.length !== stableColumnsRef.current.length ||
|
|
6
|
+
columns.some((col, index) => {
|
|
7
|
+
const prevCol = stableColumnsRef.current[index];
|
|
8
|
+
return (!prevCol ||
|
|
9
|
+
col.id !== prevCol.id ||
|
|
10
|
+
col.width !== prevCol.width ||
|
|
11
|
+
col.pinned !== prevCol.pinned ||
|
|
12
|
+
col.hidden !== prevCol.hidden ||
|
|
13
|
+
col.order !== prevCol.order);
|
|
14
|
+
});
|
|
15
|
+
if (hasChanged) {
|
|
16
|
+
stableColumnsRef.current = [...columns];
|
|
17
|
+
}
|
|
18
|
+
return stableColumnsRef.current;
|
|
19
|
+
}, [columns]);
|
|
20
|
+
const columnMetrics = useMemo(() => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const visibleColumns = stableColumns.filter((col) => !col.hidden);
|
|
23
|
+
const totalWidth = visibleColumns.reduce((sum, col) => sum + +((col === null || col === void 0 ? void 0 : col.width) || 100), 0);
|
|
24
|
+
const columnCount = visibleColumns.length;
|
|
25
|
+
return {
|
|
26
|
+
visibleColumns,
|
|
27
|
+
totalWidth,
|
|
28
|
+
columnCount,
|
|
29
|
+
firstColumnId: (_a = visibleColumns[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
30
|
+
lastColumnId: (_b = visibleColumns[columnCount - 1]) === null || _b === void 0 ? void 0 : _b.id,
|
|
31
|
+
};
|
|
32
|
+
}, [stableColumns]);
|
|
33
|
+
return {
|
|
34
|
+
stableColumns,
|
|
35
|
+
columnMetrics,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
import { useState, useCallback, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
const getInitialPinnedStartColumns = (columns, isPinnable) => {
|
|
3
|
+
if (!isPinnable && columns.length === 0)
|
|
4
|
+
return [];
|
|
5
|
+
const defaultPinned = [];
|
|
6
|
+
const userPinned = [];
|
|
7
|
+
for (const column of columns) {
|
|
8
|
+
const columnId = column.id;
|
|
9
|
+
if (column.isDefaultPinned) {
|
|
10
|
+
defaultPinned.push(columnId);
|
|
11
|
+
}
|
|
12
|
+
else if (isPinnable && column.pinned === 'start') {
|
|
13
|
+
userPinned.push(columnId);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return Array.from(new Set([...defaultPinned, ...userPinned]));
|
|
17
|
+
};
|
|
18
|
+
const getInitialPinnedEndColumns = (columns, isPinnable) => {
|
|
19
|
+
if (!isPinnable)
|
|
20
|
+
return [];
|
|
21
|
+
const userPinned = [];
|
|
22
|
+
let lastVisibleColumn = null;
|
|
23
|
+
for (const column of columns) {
|
|
24
|
+
if (column.pinned === 'end') {
|
|
25
|
+
userPinned.push(column.id);
|
|
16
26
|
}
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
if (!column.hidden) {
|
|
28
|
+
lastVisibleColumn = column;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (userPinned.length === 0 && lastVisibleColumn && !lastVisibleColumn.pinned && !lastVisibleColumn.isDefaultPinned) {
|
|
32
|
+
return [lastVisibleColumn.id];
|
|
33
|
+
}
|
|
34
|
+
return userPinned;
|
|
35
|
+
};
|
|
36
|
+
export const usePinnedColumns = (columns, isPinnable, onColumnPin) => {
|
|
37
|
+
const [pinnedStartColumns, setPinnedStartColumns] = useState(() => getInitialPinnedStartColumns(columns, isPinnable));
|
|
38
|
+
const [pinnedEndColumns, setPinnedEndColumns] = useState(() => getInitialPinnedEndColumns(columns, isPinnable));
|
|
19
39
|
const handleColumnPin = useCallback((columnId, position = 'start') => {
|
|
20
40
|
if (!isPinnable)
|
|
21
41
|
return;
|
|
@@ -38,33 +58,51 @@ export const usePinnedColumns = (columns, isPinnable, onColumnPin) => {
|
|
|
38
58
|
const isPinned = newPinnedStart.includes(columnId) || newPinnedEnd.includes(columnId);
|
|
39
59
|
onColumnPin === null || onColumnPin === void 0 ? void 0 : onColumnPin(columnId, isPinned);
|
|
40
60
|
}, [pinnedStartColumns, pinnedEndColumns, onColumnPin, isPinnable]);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
61
|
+
const columnData = useMemo(() => {
|
|
62
|
+
const pinnedStartSet = new Set(pinnedStartColumns);
|
|
63
|
+
const pinnedEndSet = new Set(pinnedEndColumns);
|
|
64
|
+
const visibleColumns = [];
|
|
65
|
+
const startColumns = [];
|
|
66
|
+
const endColumns = [];
|
|
67
|
+
const unpinnedColumns = [];
|
|
68
|
+
for (const column of columns) {
|
|
69
|
+
if (column.hidden)
|
|
70
|
+
continue;
|
|
71
|
+
visibleColumns.push(column);
|
|
72
|
+
const columnId = column.id;
|
|
73
|
+
if (pinnedStartSet.has(columnId)) {
|
|
74
|
+
startColumns.push(column);
|
|
75
|
+
}
|
|
76
|
+
else if (pinnedEndSet.has(columnId)) {
|
|
77
|
+
endColumns.push(column);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
unpinnedColumns.push(column);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const sortByOrder = (a, b) => { var _a, _b; return ((_a = a === null || a === void 0 ? void 0 : a.order) !== null && _a !== void 0 ? _a : 1000000) - ((_b = b === null || b === void 0 ? void 0 : b.order) !== null && _b !== void 0 ? _b : 1000000); };
|
|
84
|
+
const sortedStart = startColumns.sort(sortByOrder);
|
|
85
|
+
const sortedEnd = endColumns.sort(sortByOrder);
|
|
86
|
+
const sortedUnpinned = unpinnedColumns.sort(sortByOrder);
|
|
87
|
+
const orderedColumns = [...sortedStart, ...sortedUnpinned, ...sortedEnd];
|
|
88
|
+
const lastColumnId = orderedColumns.length > 0 ? orderedColumns[orderedColumns.length - 1].id : null;
|
|
49
89
|
return {
|
|
90
|
+
visibleColumns,
|
|
50
91
|
pinnedStartColumnsData: sortedStart,
|
|
51
92
|
pinnedEndColumnsData: sortedEnd,
|
|
52
93
|
unpinnedColumnsData: sortedUnpinned,
|
|
94
|
+
orderedColumns,
|
|
95
|
+
lastColumnId,
|
|
53
96
|
};
|
|
54
|
-
}, [
|
|
55
|
-
const orderedColumns = useMemo(() => [...pinnedStartColumnsData, ...unpinnedColumnsData, ...pinnedEndColumnsData], [pinnedStartColumnsData, unpinnedColumnsData, pinnedEndColumnsData]);
|
|
56
|
-
const lastColumnId = useMemo(() => {
|
|
57
|
-
const lastCol = orderedColumns[orderedColumns.length - 1];
|
|
58
|
-
return lastCol ? lastCol.id : null;
|
|
59
|
-
}, [orderedColumns]);
|
|
97
|
+
}, [columns, pinnedStartColumns, pinnedEndColumns]);
|
|
60
98
|
return {
|
|
61
99
|
pinnedStartColumns,
|
|
62
100
|
pinnedEndColumns,
|
|
63
101
|
handleColumnPin,
|
|
64
|
-
pinnedStartColumnsData,
|
|
65
|
-
pinnedEndColumnsData,
|
|
66
|
-
unpinnedColumnsData,
|
|
67
|
-
orderedColumns,
|
|
68
|
-
lastColumnId,
|
|
102
|
+
pinnedStartColumnsData: columnData.pinnedStartColumnsData,
|
|
103
|
+
pinnedEndColumnsData: columnData.pinnedEndColumnsData,
|
|
104
|
+
unpinnedColumnsData: columnData.unpinnedColumnsData,
|
|
105
|
+
orderedColumns: columnData.orderedColumns,
|
|
106
|
+
lastColumnId: columnData.lastColumnId,
|
|
69
107
|
};
|
|
70
108
|
};
|
|
@@ -17,6 +17,7 @@ export const useTableState = () => {
|
|
|
17
17
|
}
|
|
18
18
|
setSelectedChip(chipKey);
|
|
19
19
|
setSelectedCell(cellKey);
|
|
20
|
+
setSelectedColumn(null);
|
|
20
21
|
setSelectedRow(null);
|
|
21
22
|
}, [selectedChip, setSelectedChip, setSelectedCell, setSelectedRow]);
|
|
22
23
|
const handleCellClick = useCallback((rowIndex, columnIndex, event, pinnedType) => {
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts
CHANGED
|
@@ -23,28 +23,6 @@ interface UseVirtualTableContainerProps<T = unknown> extends TableChipProps {
|
|
|
23
23
|
}
|
|
24
24
|
export declare const useVirtualTableContainer: <T = unknown>({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick, }: UseVirtualTableContainerProps<T>) => {
|
|
25
25
|
getItemSize: (index: number, height: number) => number;
|
|
26
|
-
getItemDataForContainer: (columnsData: IColumnProps[], isPinnedColumn: boolean, height: number) =>
|
|
27
|
-
columns: any;
|
|
28
|
-
isLoading: any;
|
|
29
|
-
rows: any;
|
|
30
|
-
rowProps: any;
|
|
31
|
-
scrollToIndex: any;
|
|
32
|
-
totalCount: any;
|
|
33
|
-
lastItemIndex: any;
|
|
34
|
-
isError: any;
|
|
35
|
-
areAllRowsLoaded: any;
|
|
36
|
-
limit: any;
|
|
37
|
-
newLoadedRowsEndIndex: any;
|
|
38
|
-
isSheetView: boolean;
|
|
39
|
-
isPinned: any;
|
|
40
|
-
selectedCell: any;
|
|
41
|
-
selectedColumn: any;
|
|
42
|
-
selectedRow: any;
|
|
43
|
-
selectedChip: any;
|
|
44
|
-
onCellClick: any;
|
|
45
|
-
onChipClick: any;
|
|
46
|
-
containerHeight: any;
|
|
47
|
-
rowHeight: any;
|
|
48
|
-
};
|
|
26
|
+
getItemDataForContainer: (columnsData: IColumnProps[], isPinnedColumn: boolean, height: number) => any;
|
|
49
27
|
};
|
|
50
28
|
export {};
|