@tap-payments/os-micro-frontend-shared 0.1.201 → 0.1.202-test.9
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.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +38 -9
- package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.js +2 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.js +2 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.js +2 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.d.ts +4 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js +11 -8
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/ColumnResize.d.ts +5 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/ColumnResize.js +41 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/ResizeOverlay.d.ts +5 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/ResizeOverlay.js +10 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/index.d.ts +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/index.js +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/constants.d.ts +5 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/constants.js +5 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/index.d.ts +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/index.js +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/useColumnResize.d.ts +16 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/useColumnResize.js +141 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/useColumnResizeWithPinned.d.ts +64 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/useColumnResizeWithPinned.js +29 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/index.d.ts +4 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/index.js +4 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/styles.d.ts +17 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/styles.js +55 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/types/index.d.ts +42 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/types/index.js +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/utils/index.d.ts +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/utils/index.js +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/utils/resize.d.ts +18 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/utils/resize.js +90 -0
- 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/useTableDimensions.d.ts +12 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableDimensions.js +26 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/style.js +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/types.d.ts +8 -0
- package/build/constants/assets.d.ts +1 -0
- package/build/constants/assets.js +1 -0
- package/build/utils/columnResizeStorage.d.ts +16 -0
- package/build/utils/columnResizeStorage.js +96 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/build/utils/localStorage.d.ts +3 -0
- package/build/utils/localStorage.js +3 -0
- package/package.json +3 -3
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,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ISheetViewVirtualTable } from './types';
|
|
3
|
-
declare function SheetViewVirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, rowHeight, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableTitle, onStartDrag, onColumnPin, clearBackdropVisibilityTimeout, isPinnable, tableMode, overscanCount, }: Readonly<ISheetViewVirtualTable>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function SheetViewVirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, rowHeight, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableTitle, onStartDrag, onColumnPin, clearBackdropVisibilityTimeout, isPinnable, tableMode, overscanCount, windowId, serviceCode, }: Readonly<ISheetViewVirtualTable>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof SheetViewVirtualTable>;
|
|
5
5
|
export default _default;
|
|
@@ -1,14 +1,18 @@
|
|
|
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, useRef } 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,
|
|
7
|
+
import { usePinnedColumns, useSynchronizedScroll, useTableState, useTableData, useVirtualTableContainer, useTableDimensions } from './hooks';
|
|
8
|
+
import { useColumnResize, useColumnResizeWithPinned, applyColumnWidths } from './features/resize';
|
|
9
|
+
import { ResizeOverlay } from './features/resize/components';
|
|
8
10
|
import { PinnedColumn, MainTable, LoadingMainTable, NoDataView, VirtualTable } from './components';
|
|
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, onStartDrag, onColumnPin, clearBackdropVisibilityTimeout = 100, isPinnable = false, tableMode, overscanCount, }) {
|
|
11
|
+
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, onStartDrag, onColumnPin, clearBackdropVisibilityTimeout = 100, isPinnable = false, tableMode, overscanCount, windowId, serviceCode, }) {
|
|
10
12
|
// Custom hooks for state management
|
|
11
13
|
const { selectedCell, selectedColumn, selectedRow, showBackDrop, setShowBackdrop, handleCellClick, handleColumnClick, handleChipClick, selectedChip, } = useTableState();
|
|
14
|
+
// Refs and state for resize indicator positioning
|
|
15
|
+
const tableContainerRef = useRef(null);
|
|
12
16
|
// Table data processing
|
|
13
17
|
const { isError, tableLoading, tableError, tableEmpty, hasTimeoutError, showNoDataView, lastItemIndex, areTotalRowsNotFillingHeight, itemsCount, isDelayedFetchingNextPage, } = useTableData({
|
|
14
18
|
rows,
|
|
@@ -21,8 +25,29 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
21
25
|
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(columns, isPinnable, onColumnPin);
|
|
22
26
|
// Scroll synchronization
|
|
23
27
|
const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
|
|
24
|
-
// Column
|
|
25
|
-
const {
|
|
28
|
+
// Column resize functionality
|
|
29
|
+
const { columnWidths, isResizing, resizingColumn, resizeIndicatorX, cursorPosition, startResize, handleColumnClick: handleColumnClickWithResize, } = useColumnResize({
|
|
30
|
+
columns,
|
|
31
|
+
handleColumnClick,
|
|
32
|
+
windowId,
|
|
33
|
+
serviceCode,
|
|
34
|
+
});
|
|
35
|
+
// Table dimensions for resize indicator positioning
|
|
36
|
+
const tableDimensions = useTableDimensions({
|
|
37
|
+
tableContainerRef,
|
|
38
|
+
showHeader: showHeader !== null && showHeader !== void 0 ? showHeader : false,
|
|
39
|
+
isResizing,
|
|
40
|
+
});
|
|
41
|
+
// Column width calculations with dynamic resize support
|
|
42
|
+
const { pinnedStartColumnsWidth, pinnedEndColumnsWidth, pinnedStartColumnsDataWithWidths, pinnedEndColumnsDataWithWidths } = useColumnResizeWithPinned({
|
|
43
|
+
pinnedStartColumnsData,
|
|
44
|
+
pinnedEndColumnsData,
|
|
45
|
+
columnWidths,
|
|
46
|
+
});
|
|
47
|
+
// Apply dynamic widths to unpinned columns
|
|
48
|
+
const unpinnedColumnsDataWithWidths = useMemo(() => applyColumnWidths(unpinnedColumnsData, columnWidths), [unpinnedColumnsData, columnWidths]);
|
|
49
|
+
// Apply dynamic widths to ordered columns (for no-data view)
|
|
50
|
+
const orderedColumnsWithWidths = useMemo(() => applyColumnWidths(orderedColumns, columnWidths), [orderedColumns, columnWidths]);
|
|
26
51
|
// Virtual table container logic
|
|
27
52
|
const { getItemSize, getItemDataForContainer } = useVirtualTableContainer({
|
|
28
53
|
rowHeight,
|
|
@@ -66,6 +91,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
66
91
|
pinnedStartVirtualListRef,
|
|
67
92
|
pinnedEndVirtualListRef,
|
|
68
93
|
scrollableVirtualListRef,
|
|
94
|
+
overscanCount,
|
|
69
95
|
]);
|
|
70
96
|
const baseCommonProps = {
|
|
71
97
|
showHeader,
|
|
@@ -77,7 +103,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
77
103
|
isPinnable,
|
|
78
104
|
lastColumnId,
|
|
79
105
|
selectedColumn,
|
|
80
|
-
onColumnClick:
|
|
106
|
+
onColumnClick: handleColumnClickWithResize,
|
|
81
107
|
tableTitle,
|
|
82
108
|
areAllRowsLoaded,
|
|
83
109
|
isFetchingNextPage,
|
|
@@ -87,13 +113,16 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
87
113
|
tableMode,
|
|
88
114
|
showNoDataView,
|
|
89
115
|
tableBodyStyles,
|
|
116
|
+
onStartResize: startResize,
|
|
117
|
+
isResizing,
|
|
118
|
+
resizingColumn,
|
|
90
119
|
};
|
|
91
120
|
const commonPropsWithTableStates = Object.assign(Object.assign({}, baseCommonProps), { hasTimeoutError,
|
|
92
121
|
tableLoading });
|
|
93
|
-
return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (
|
|
122
|
+
return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, Object.assign({ ref: tableContainerRef }, { children: showNoDataView ? (tableLoading ? (
|
|
94
123
|
// Show same table structure with pinned columns during loading, but with skeleton rows
|
|
95
|
-
_jsxs(SheetViewVirtualTableWrapper, { children: [
|
|
124
|
+
_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsDataWithWidths.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "start", columnsData: pinnedStartColumnsDataWithWidths, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsDataWithWidths.length > 0, hasPinnedEnd: pinnedEndColumnsDataWithWidths.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates))), _jsx(LoadingMainTable, Object.assign({ hasPinnedStart: pinnedStartColumnsDataWithWidths.length > 0, hasPinnedEnd: pinnedEndColumnsDataWithWidths.length > 0, unpinnedColumnsData: unpinnedColumnsDataWithWidths, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns }, commonPropsWithTableStates)), pinnedEndColumnsDataWithWidths.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "end", columnsData: pinnedEndColumnsDataWithWidths, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsDataWithWidths.length > 0, hasPinnedEnd: pinnedEndColumnsDataWithWidths.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates)))] })) : (
|
|
96
125
|
// Non-loading error states
|
|
97
|
-
_jsx(NoDataView, Object.assign({ tableLoading: tableLoading, tableError: tableError, tableEmpty: tableEmpty, hasTimeoutError: hasTimeoutError, orderedColumns:
|
|
126
|
+
_jsx(NoDataView, Object.assign({ tableLoading: tableLoading, tableError: tableError, tableEmpty: tableEmpty, hasTimeoutError: hasTimeoutError, orderedColumns: orderedColumnsWithWidths, error: error, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps }, baseCommonProps)))) : (_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsDataWithWidths.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "start", columnsData: pinnedStartColumnsDataWithWidths, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsDataWithWidths.length > 0, hasPinnedEnd: pinnedEndColumnsDataWithWidths.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates))), _jsx(MainTable, Object.assign({ hasPinnedStart: pinnedStartColumnsDataWithWidths.length > 0, hasPinnedEnd: pinnedEndColumnsDataWithWidths.length > 0, unpinnedColumnsData: unpinnedColumnsDataWithWidths, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates)), pinnedEndColumnsDataWithWidths.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "end", columnsData: pinnedEndColumnsDataWithWidths, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsDataWithWidths.length > 0, hasPinnedEnd: pinnedEndColumnsDataWithWidths.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates)))] })) })), _jsx(TableFooter, Object.assign({ "data-testid": "SheetViewVirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps)), _jsx(ResizeOverlay, { isVisible: isResizing, indicatorX: resizeIndicatorX, indicatorHeight: tableDimensions.height, indicatorTop: tableDimensions.top, iconX: cursorPosition.x, iconY: cursorPosition.y })] }));
|
|
98
127
|
}
|
|
99
128
|
export default memo(SheetViewVirtualTable);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { MainTableProps } from '../types';
|
|
3
|
-
declare function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, pinnedStartColumns, pinnedEndColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, tableLoading, createVirtualTableContainer, }: MainTableProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, pinnedStartColumns, pinnedEndColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, tableLoading, createVirtualTableContainer, onStartResize, isResizing, resizingColumn, }: MainTableProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof MainTable>;
|
|
5
5
|
export default _default;
|
|
@@ -5,9 +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, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, pinnedStartColumns, pinnedEndColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, tableLoading, createVirtualTableContainer, }) {
|
|
8
|
+
function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, pinnedStartColumns, pinnedEndColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, tableLoading, createVirtualTableContainer, onStartResize, isResizing, resizingColumn, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
|
-
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: {
|
|
10
|
+
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, onStartResize: onStartResize, isResizing: isResizing, resizingColumn: resizingColumn }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
11
11
|
width: '100%',
|
|
12
12
|
minWidth: 'fit-content',
|
|
13
13
|
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_ScrollableStyledBox", hidePadding: true, className: "list-wrapper", sx: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { PinnedColumnProps } from '../types';
|
|
3
|
-
declare function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, hasPinnedStart, hasPinnedEnd, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableLoading, createVirtualTableContainer, }: PinnedColumnProps): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
declare function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, hasPinnedStart, hasPinnedEnd, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableLoading, createVirtualTableContainer, onStartResize, isResizing, resizingColumn, }: PinnedColumnProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof PinnedColumn>;
|
|
5
5
|
export default _default;
|
|
@@ -5,13 +5,13 @@ 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, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, hasPinnedStart, hasPinnedEnd, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableLoading, createVirtualTableContainer, }) {
|
|
8
|
+
function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, hasPinnedStart, hasPinnedEnd, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableLoading, createVirtualTableContainer, onStartResize, isResizing, resizingColumn, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
10
|
if (columnsData.length === 0)
|
|
11
11
|
return null;
|
|
12
12
|
const Wrapper = position === 'start' ? PinnedStartColumnWrapper : PinnedEndColumnWrapper;
|
|
13
13
|
const containerKey = position === 'start' ? 'pinnedStart' : 'pinnedEnd';
|
|
14
|
-
return (_jsx(Wrapper, { children: _jsxs(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: [showHeader && (_jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_PinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: columnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: pinnedColumnsList, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: position === 'start' ? 'pinnedStart' : 'pinnedEnd', hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
14
|
+
return (_jsx(Wrapper, { children: _jsxs(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: [showHeader && (_jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_PinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: columnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: pinnedColumnsList, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: position === 'start' ? 'pinnedStart' : 'pinnedEnd', hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd, onStartResize: onStartResize, isResizing: isResizing, resizingColumn: resizingColumn })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
15
15
|
width: '100%',
|
|
16
16
|
minWidth: 'fit-content',
|
|
17
17
|
overflowX: 'hidden',
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SheetViewTableHeaderProps } from '../types';
|
|
3
|
-
declare function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, }: SheetViewTableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, onStartResize, isResizing, resizingColumn, }: SheetViewTableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof SheetViewTableHeader>;
|
|
5
5
|
export default _default;
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.js
CHANGED
|
@@ -2,11 +2,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
import { StyledHeader, StyledMUITableRow } from '../style';
|
|
4
4
|
import SheetViewTableHeaderCell from './SheetViewTableHeaderCell';
|
|
5
|
-
function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, }) {
|
|
5
|
+
function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, onStartResize, isResizing = false, resizingColumn = null, }) {
|
|
6
6
|
return (_jsx(StyledHeader, Object.assign({ component: "nav", "data-testid": "SheetViewVirtualTable_TableHeader_StyledHeader", showBackDrop: showBackDrop }, headerProps, { children: _jsx(StyledMUITableRow, Object.assign({ component: "section", "data-testid": "SheetViewVirtualTable_TableHeader_StyledMUITableRow" }, { children: columns.map((column, colIndex) => {
|
|
7
7
|
var _a;
|
|
8
8
|
const columnKey = `${(_a = column.pinned) !== null && _a !== void 0 ? _a : 'default'}-${colIndex}`;
|
|
9
|
-
return (_jsx(SheetViewTableHeaderCell, { column: column, colIndex: colIndex, isFirst: column.id === columns[0].id, isLast: column.id === columns[columns.length - 1].id, isDefaultPinned: !!column.isDefaultPinned, isSelected: selectedColumn === columnKey, onColumnSort: onColumnSort, columnsSorting: columnsSorting, pinnedColumns: pinnedColumns, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, onColumnClick: onColumnClick }, `${column.id}-${colIndex}`));
|
|
9
|
+
return (_jsx(SheetViewTableHeaderCell, { column: column, colIndex: colIndex, isFirst: column.id === columns[0].id, isLast: column.id === columns[columns.length - 1].id, isDefaultPinned: !!column.isDefaultPinned, isSelected: selectedColumn === columnKey, onColumnSort: onColumnSort, columnsSorting: columnsSorting, pinnedColumns: pinnedColumns, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, onColumnClick: onColumnClick, onStartResize: onStartResize, isResizing: isResizing, resizingColumn: resizingColumn }, `${column.id}-${colIndex}`));
|
|
10
10
|
}) })) })));
|
|
11
11
|
}
|
|
12
12
|
export default memo(SheetViewTableHeader);
|
|
@@ -8,7 +8,10 @@ interface SheetViewTableHeaderCellProps extends Pick<SheetViewTableHeaderProps,
|
|
|
8
8
|
isLast: boolean;
|
|
9
9
|
isSelected: boolean;
|
|
10
10
|
isDefaultPinned: boolean;
|
|
11
|
+
onStartResize?: (e: React.MouseEvent, columnId: string) => void;
|
|
12
|
+
isResizing?: boolean;
|
|
13
|
+
resizingColumn?: string | null;
|
|
11
14
|
}
|
|
12
|
-
declare function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order, pinned }, colIndex, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, }: SheetViewTableHeaderCellProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare function SheetViewTableHeaderCell({ column: { header, id, tableViewId, align, headerStyle, sortable, filter, pinnable, width, order, pinned }, colIndex, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, onStartResize, isResizing, resizingColumn, }: SheetViewTableHeaderCellProps): import("react/jsx-runtime").JSX.Element;
|
|
13
16
|
declare const _default: import("react").MemoExoticComponent<typeof SheetViewTableHeaderCell>;
|
|
14
17
|
export default _default;
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js
CHANGED
|
@@ -6,7 +6,10 @@ import ColumnFilter from '../../components/ColumnFilter';
|
|
|
6
6
|
import { StyledCell, TableHeaderInner } from '../../components/style';
|
|
7
7
|
import { PinIconContainer, HeaderText } from '../style';
|
|
8
8
|
import ColumnSort from '../../components/ColumnSort';
|
|
9
|
-
|
|
9
|
+
import { ColumnResize } from '../features/resize';
|
|
10
|
+
function SheetViewTableHeaderCell({ column: { header, id, tableViewId, align, headerStyle, sortable, filter, pinnable, width, order, pinned }, colIndex, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, onStartResize, isResizing = false, resizingColumn = null, }) {
|
|
11
|
+
// Use tableViewId if it exists, otherwise fall back to id
|
|
12
|
+
const columnId = tableViewId || String(id);
|
|
10
13
|
const [columnFilterEl, setColumnFilterEl] = useState(null);
|
|
11
14
|
const cellRef = useRef(null);
|
|
12
15
|
const checkIsPanned = useCallback((columnId) => pinnedColumns === null || pinnedColumns === void 0 ? void 0 : pinnedColumns.includes(columnId), [pinnedColumns]);
|
|
@@ -38,7 +41,7 @@ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, so
|
|
|
38
41
|
event.stopPropagation();
|
|
39
42
|
onOpenFilterDropdown();
|
|
40
43
|
};
|
|
41
|
-
return (
|
|
44
|
+
return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell", "data-column-id": id, "data-column-width": width, "data-column-width-used": width, "data-column-align": align, "data-column-order": order, "data-column-header": typeof header === 'string' ? header : 'component', "data-column-sortable": !!sortable, "data-column-filterable": !!filter, "data-column-pinned": isPinned, isFirst: isFirst, isLast: isLast, isSheetView: true, ref: cellRef, onClick: handleCellClick, sx: (theme) => (Object.assign({ display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width, textAlign: align, overflow: 'unset', cursor: 'pointer', boxSizing: 'border-box', border: '0.5px solid transparent', borderColor: isSelected ? '#1F88D0' : '#F2F2F2', borderBottom: isSelected ? '0.5px solid transparent' : '0.5px solid #F2F2F2', backgroundColor: isSelected ? '#F2F2F2' : '#FCFCFC', minHeight: '28px', position: 'relative', '&:before': {
|
|
42
45
|
content: '""',
|
|
43
46
|
borderBottom: 'none',
|
|
44
47
|
position: 'absolute',
|
|
@@ -46,11 +49,11 @@ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, so
|
|
|
46
49
|
right: 0,
|
|
47
50
|
left: 0,
|
|
48
51
|
bottom: 0,
|
|
49
|
-
} }, headerStyle)) }, { children: _jsxs(TableHeaderInner, Object.assign({ onClick: handleHeaderInnerClick }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "SheetViewTableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && _jsx(HeaderText, Object.assign({ "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell_header_text" }, { children: header })) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter, { anchorEl: columnFilterEl, setAnchorEl: setColumnFilterEl })), sortable && (_jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, onClick: (e) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
} }, headerStyle)) }, { children: [_jsxs(TableHeaderInner, Object.assign({ onClick: handleHeaderInnerClick }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "SheetViewTableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && _jsx(HeaderText, Object.assign({ "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell_header_text" }, { children: header })) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter, { anchorEl: columnFilterEl, setAnchorEl: setColumnFilterEl })), sortable && (_jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, onClick: (e) => {
|
|
53
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, e, pinned);
|
|
54
|
+
} })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
handlePinClick(id);
|
|
57
|
+
}, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] })), onStartResize && (_jsx(ColumnResize, { columnId: columnId, onStartResize: onStartResize, isResizing: isResizing && resizingColumn === columnId, isLast: isLast }))] })));
|
|
55
58
|
}
|
|
56
59
|
export default memo(SheetViewTableHeaderCell);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ColumnResizeProps } from '../types';
|
|
3
|
+
declare function ColumnResize({ columnId, onStartResize, isResizing, isLast }: ColumnResizeProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const _default: import("react").MemoExoticComponent<typeof ColumnResize>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useState, useCallback, useRef } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { StyledResizeIcon, ResizeIcon } from '../styles';
|
|
5
|
+
function ColumnResize({ columnId, onStartResize, isResizing, isLast = false }) {
|
|
6
|
+
const [isHovering, setIsHovering] = useState(false);
|
|
7
|
+
const [hoverPosition, setHoverPosition] = useState({ x: 0, y: 0 });
|
|
8
|
+
const resizeHandleRef = useRef(null);
|
|
9
|
+
const updateHoverPosition = useCallback(() => {
|
|
10
|
+
var _a;
|
|
11
|
+
const rect = (_a = resizeHandleRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
12
|
+
if (rect) {
|
|
13
|
+
setHoverPosition({
|
|
14
|
+
x: rect.right,
|
|
15
|
+
y: rect.top + rect.height / 2,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
const handleMouseEnter = useCallback(() => {
|
|
20
|
+
if (!isResizing) {
|
|
21
|
+
setIsHovering(true);
|
|
22
|
+
updateHoverPosition();
|
|
23
|
+
}
|
|
24
|
+
}, [isResizing, updateHoverPosition]);
|
|
25
|
+
const handleMouseMove = useCallback(() => {
|
|
26
|
+
if (!isResizing && isHovering) {
|
|
27
|
+
updateHoverPosition();
|
|
28
|
+
}
|
|
29
|
+
}, [isResizing, isHovering, updateHoverPosition]);
|
|
30
|
+
const handleMouseLeave = useCallback(() => {
|
|
31
|
+
setIsHovering(false);
|
|
32
|
+
}, []);
|
|
33
|
+
const handleMouseDown = (e) => {
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
setIsHovering(false);
|
|
37
|
+
onStartResize(e, columnId);
|
|
38
|
+
};
|
|
39
|
+
return (_jsxs(_Fragment, { children: [_jsx(StyledResizeIcon, { ref: resizeHandleRef, isResizing: isResizing, isLast: isLast, onMouseDown: handleMouseDown, onMouseEnter: handleMouseEnter, onMouseMove: handleMouseMove, onMouseLeave: handleMouseLeave, "data-testid": `column-resize-handle-${columnId}` }), createPortal(_jsx(ResizeIcon, { isVisible: isHovering && !isResizing, x: hoverPosition.x, y: hoverPosition.y, offsetX: -2 }), document.body)] }));
|
|
40
|
+
}
|
|
41
|
+
export default memo(ColumnResize);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ResizeOverlayProps } from '../types';
|
|
3
|
+
declare function ResizeOverlay({ isVisible, indicatorX, indicatorHeight, indicatorTop, iconX, iconY }: ResizeOverlayProps): import("react").ReactPortal | null;
|
|
4
|
+
declare const _default: import("react").MemoExoticComponent<typeof ResizeOverlay>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { IndicatorLine, ResizeIcon } from '../styles';
|
|
5
|
+
function ResizeOverlay({ isVisible, indicatorX, indicatorHeight, indicatorTop, iconX, iconY }) {
|
|
6
|
+
if (!isVisible)
|
|
7
|
+
return null;
|
|
8
|
+
return createPortal(_jsxs(_Fragment, { children: [_jsx(IndicatorLine, { isVisible: isVisible, x: indicatorX, height: indicatorHeight, top: indicatorTop, "data-testid": "column-resize-indicator" }), _jsx(ResizeIcon, { isVisible: isVisible, x: iconX, y: iconY, offsetX: 2, "data-testid": "floating-resize-icon" })] }), document.body);
|
|
9
|
+
}
|
|
10
|
+
export default memo(ResizeOverlay);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { UseColumnResizeProps } from '../types';
|
|
2
|
+
export declare const useColumnResize: ({ columns, onColumnResize, handleColumnClick, windowId, serviceCode }: UseColumnResizeProps) => {
|
|
3
|
+
columnWidths: Record<string, number>;
|
|
4
|
+
isResizing: boolean;
|
|
5
|
+
resizingColumn: string | null;
|
|
6
|
+
resizeIndicatorX: number;
|
|
7
|
+
cursorPosition: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
getColumnWidth: (columnId: string) => number;
|
|
12
|
+
startResize: (e: React.MouseEvent, columnId: string) => void;
|
|
13
|
+
stopResize: () => void;
|
|
14
|
+
isCurrentlyResizing: () => boolean;
|
|
15
|
+
handleColumnClick: (columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { useState, useCallback, useRef, useEffect, useMemo } from 'react';
|
|
2
|
+
import { getColumnWidth as getStoredColumnWidth } from '../../../../../../utils/index.js';
|
|
3
|
+
import { getColumnId, parseColumnWidth, clampWidth, cleanupEventListeners as cleanupEventListenersUtil, createMouseMoveHandler, getColumnWidthFromState, createResizeEndHandler, } from '../utils/resize';
|
|
4
|
+
export const useColumnResize = ({ columns, onColumnResize, handleColumnClick, windowId, serviceCode }) => {
|
|
5
|
+
// Memoize initial column widths to prevent unnecessary recalculations
|
|
6
|
+
const initialColumnWidths = useMemo(() => {
|
|
7
|
+
return columns.reduce((acc, col) => {
|
|
8
|
+
const columnId = getColumnId(col);
|
|
9
|
+
const defaultWidth = parseColumnWidth(col.width);
|
|
10
|
+
// Try to get width from localStorage if windowId and serviceCode are provided
|
|
11
|
+
let finalWidth = defaultWidth;
|
|
12
|
+
if (windowId && serviceCode) {
|
|
13
|
+
try {
|
|
14
|
+
const storedWidth = getStoredColumnWidth(windowId, serviceCode, columnId, defaultWidth);
|
|
15
|
+
finalWidth = storedWidth !== null && storedWidth !== void 0 ? storedWidth : defaultWidth;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.warn(`Failed to load stored width for column ${columnId}:`, error);
|
|
19
|
+
finalWidth = defaultWidth;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
acc[columnId] = clampWidth(finalWidth);
|
|
23
|
+
return acc;
|
|
24
|
+
}, {});
|
|
25
|
+
}, [columns, windowId, serviceCode]);
|
|
26
|
+
const [resizeState, setResizeState] = useState(() => ({
|
|
27
|
+
columnWidths: initialColumnWidths,
|
|
28
|
+
isResizing: false,
|
|
29
|
+
resizingColumn: null,
|
|
30
|
+
startX: 0,
|
|
31
|
+
startWidth: 0,
|
|
32
|
+
resizeIndicatorX: 0,
|
|
33
|
+
}));
|
|
34
|
+
const [cursorPosition, setCursorPosition] = useState({ x: 0, y: 0 });
|
|
35
|
+
// Refs for managing resize state and event listeners
|
|
36
|
+
const isResizingRef = useRef(false);
|
|
37
|
+
const initialCursorYRef = useRef(0);
|
|
38
|
+
const mouseMoveRef = useRef();
|
|
39
|
+
const mouseUpRef = useRef();
|
|
40
|
+
// Update column widths when dependencies change (windowId, serviceCode, or columns)
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
setResizeState((prev) => {
|
|
43
|
+
const currentKeys = new Set(Object.keys(prev.columnWidths));
|
|
44
|
+
const newKeys = new Set(Object.keys(initialColumnWidths));
|
|
45
|
+
if (currentKeys.size !== newKeys.size) {
|
|
46
|
+
return Object.assign(Object.assign({}, prev), { columnWidths: initialColumnWidths });
|
|
47
|
+
}
|
|
48
|
+
const hasChanged = Array.from(newKeys).some((key) => !currentKeys.has(key) || prev.columnWidths[key] !== initialColumnWidths[key]);
|
|
49
|
+
if (!hasChanged) {
|
|
50
|
+
return prev;
|
|
51
|
+
}
|
|
52
|
+
return Object.assign(Object.assign({}, prev), { columnWidths: initialColumnWidths });
|
|
53
|
+
});
|
|
54
|
+
}, [initialColumnWidths]);
|
|
55
|
+
const getColumnWidth = useCallback((columnId) => {
|
|
56
|
+
return getColumnWidthFromState(resizeState.columnWidths, columnId);
|
|
57
|
+
}, [resizeState.columnWidths]);
|
|
58
|
+
// Clean up event listeners
|
|
59
|
+
const cleanupEventListeners = useCallback(() => {
|
|
60
|
+
cleanupEventListenersUtil(mouseMoveRef, mouseUpRef);
|
|
61
|
+
}, []);
|
|
62
|
+
// Resize end handler with memoization
|
|
63
|
+
const createResizeEndHandlerMemo = useCallback((columnId, currentWidth, startX) => {
|
|
64
|
+
return createResizeEndHandler(windowId, serviceCode, onColumnResize, setResizeState, cleanupEventListeners, isResizingRef)(columnId, currentWidth, startX);
|
|
65
|
+
}, [windowId, serviceCode, onColumnResize, cleanupEventListeners]);
|
|
66
|
+
const createMouseMoveHandlerCallback = useCallback(() => {
|
|
67
|
+
return createMouseMoveHandler(setResizeState, setCursorPosition, initialCursorYRef);
|
|
68
|
+
}, []);
|
|
69
|
+
const startResize = useCallback((e, columnId) => {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
try {
|
|
73
|
+
const currentWidth = getColumnWidth(columnId);
|
|
74
|
+
const startX = e.clientX;
|
|
75
|
+
// Calculate the icon's Y position (center of the header cell)
|
|
76
|
+
const target = e.currentTarget;
|
|
77
|
+
const headerCell = target.closest('[data-testid="SheetViewVirtualTable_TableHeader_StyledCell"]');
|
|
78
|
+
let iconY = e.clientY; // fallback to mouse Y
|
|
79
|
+
if (headerCell) {
|
|
80
|
+
const rect = headerCell.getBoundingClientRect();
|
|
81
|
+
iconY = rect.top + rect.height / 2; // Center of the header cell (same as icon position)
|
|
82
|
+
}
|
|
83
|
+
setResizeState((prev) => (Object.assign(Object.assign({}, prev), { isResizing: true, resizingColumn: columnId, startX, startWidth: currentWidth, resizeIndicatorX: startX })));
|
|
84
|
+
initialCursorYRef.current = iconY;
|
|
85
|
+
setCursorPosition({ x: startX, y: iconY });
|
|
86
|
+
isResizingRef.current = true;
|
|
87
|
+
// Create and store event handlers
|
|
88
|
+
const handleMouseMove = createMouseMoveHandlerCallback();
|
|
89
|
+
const handleMouseUp = createResizeEndHandlerMemo(columnId, currentWidth, startX);
|
|
90
|
+
mouseMoveRef.current = handleMouseMove;
|
|
91
|
+
mouseUpRef.current = handleMouseUp;
|
|
92
|
+
// Add global event listeners
|
|
93
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
94
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
95
|
+
// Hide cursor and disable text selection during resize
|
|
96
|
+
document.body.style.cursor = 'none';
|
|
97
|
+
document.body.style.userSelect = 'none';
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error('Error starting resize:', error);
|
|
101
|
+
cleanupEventListeners();
|
|
102
|
+
}
|
|
103
|
+
}, [getColumnWidth, createMouseMoveHandlerCallback, createResizeEndHandlerMemo, cleanupEventListeners]);
|
|
104
|
+
const stopResize = useCallback(() => {
|
|
105
|
+
try {
|
|
106
|
+
setResizeState((prev) => (Object.assign(Object.assign({}, prev), { isResizing: false, resizingColumn: null, resizeIndicatorX: 0 })));
|
|
107
|
+
isResizingRef.current = false;
|
|
108
|
+
cleanupEventListeners();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.error('Error stopping resize:', error);
|
|
112
|
+
cleanupEventListeners();
|
|
113
|
+
}
|
|
114
|
+
}, [cleanupEventListeners]);
|
|
115
|
+
const isCurrentlyResizing = useCallback(() => {
|
|
116
|
+
return isResizingRef.current;
|
|
117
|
+
}, []);
|
|
118
|
+
// Wrapper for column click that prevents clicks during resize
|
|
119
|
+
const handleColumnClickWithResizeCheck = useCallback((columnIndex, event, pinnedType) => {
|
|
120
|
+
if (isCurrentlyResizing()) {
|
|
121
|
+
return; // Don't handle column click if we're currently resizing
|
|
122
|
+
}
|
|
123
|
+
handleColumnClick(columnIndex, event, pinnedType);
|
|
124
|
+
}, [handleColumnClick, isCurrentlyResizing]);
|
|
125
|
+
// Cleanup on unmount
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
return cleanupEventListeners;
|
|
128
|
+
}, [cleanupEventListeners]);
|
|
129
|
+
return {
|
|
130
|
+
columnWidths: resizeState.columnWidths,
|
|
131
|
+
isResizing: resizeState.isResizing,
|
|
132
|
+
resizingColumn: resizeState.resizingColumn,
|
|
133
|
+
resizeIndicatorX: resizeState.resizeIndicatorX,
|
|
134
|
+
cursorPosition,
|
|
135
|
+
getColumnWidth,
|
|
136
|
+
startResize,
|
|
137
|
+
stopResize,
|
|
138
|
+
isCurrentlyResizing,
|
|
139
|
+
handleColumnClick: handleColumnClickWithResizeCheck,
|
|
140
|
+
};
|
|
141
|
+
};
|