@tap-payments/os-micro-frontend-shared 0.1.211 → 0.1.213
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/build/components/TableCells/CustomCells/SalesChannelCell/SalesChannelCellSheet.js +2 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +40 -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 +12 -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 +148 -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 +45 -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 +114 -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/components/VirtualTables/components/style.js +1 -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 +1 -1
|
@@ -47,8 +47,8 @@ function SalesChannelCellSheet({ channels, selectionProps = {} }) {
|
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
} }, { children: _jsx(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', gap: '4px', padding: '4px' } }, { children: filteredChannels.map((channel, index) => {
|
|
50
|
-
var _a
|
|
51
|
-
return (_jsxs(StatusChipWithCopy, Object.assign({ copyText:
|
|
50
|
+
var _a;
|
|
51
|
+
return (_jsxs(StatusChipWithCopy, Object.assign({ copyText: channel.address, chipIndex: index + 1, selectionProps: selectionProps }, { children: [(_a = channel.name) === null || _a === void 0 ? void 0 : _a.en, ": ", channel.address] }), channel.id));
|
|
52
52
|
}) })) }))] }));
|
|
53
53
|
}
|
|
54
54
|
export default SalesChannelCellSheet;
|
|
@@ -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,19 @@
|
|
|
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);
|
|
16
|
+
const tableWrapperRef = useRef(null);
|
|
12
17
|
// Table data processing
|
|
13
18
|
const { isError, tableLoading, tableError, tableEmpty, hasTimeoutError, showNoDataView, lastItemIndex, areTotalRowsNotFillingHeight, itemsCount, isDelayedFetchingNextPage, } = useTableData({
|
|
14
19
|
rows,
|
|
@@ -21,8 +26,30 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
21
26
|
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(columns, isPinnable, onColumnPin);
|
|
22
27
|
// Scroll synchronization
|
|
23
28
|
const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
|
|
24
|
-
// Column
|
|
25
|
-
const {
|
|
29
|
+
// Column resize functionality
|
|
30
|
+
const { columnWidths, isResizing, resizingColumn, resizeIndicatorX, cursorPosition, startResize, handleColumnClick: handleColumnClickWithResize, } = useColumnResize({
|
|
31
|
+
columns,
|
|
32
|
+
handleColumnClick,
|
|
33
|
+
windowId,
|
|
34
|
+
serviceCode,
|
|
35
|
+
tableContainerRef: tableWrapperRef,
|
|
36
|
+
});
|
|
37
|
+
// Table dimensions for resize indicator positioning
|
|
38
|
+
const tableDimensions = useTableDimensions({
|
|
39
|
+
tableContainerRef,
|
|
40
|
+
showHeader: showHeader !== null && showHeader !== void 0 ? showHeader : false,
|
|
41
|
+
isResizing,
|
|
42
|
+
});
|
|
43
|
+
// Column width calculations with dynamic resize support
|
|
44
|
+
const { pinnedStartColumnsWidth, pinnedEndColumnsWidth, pinnedStartColumnsDataWithWidths, pinnedEndColumnsDataWithWidths } = useColumnResizeWithPinned({
|
|
45
|
+
pinnedStartColumnsData,
|
|
46
|
+
pinnedEndColumnsData,
|
|
47
|
+
columnWidths,
|
|
48
|
+
});
|
|
49
|
+
// Apply dynamic widths to unpinned columns
|
|
50
|
+
const unpinnedColumnsDataWithWidths = useMemo(() => applyColumnWidths(unpinnedColumnsData, columnWidths), [unpinnedColumnsData, columnWidths]);
|
|
51
|
+
// Apply dynamic widths to ordered columns (for no-data view)
|
|
52
|
+
const orderedColumnsWithWidths = useMemo(() => applyColumnWidths(orderedColumns, columnWidths), [orderedColumns, columnWidths]);
|
|
26
53
|
// Virtual table container logic
|
|
27
54
|
const { getItemSize, getItemDataForContainer } = useVirtualTableContainer({
|
|
28
55
|
rowHeight,
|
|
@@ -66,6 +93,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
66
93
|
pinnedStartVirtualListRef,
|
|
67
94
|
pinnedEndVirtualListRef,
|
|
68
95
|
scrollableVirtualListRef,
|
|
96
|
+
overscanCount,
|
|
69
97
|
]);
|
|
70
98
|
const baseCommonProps = {
|
|
71
99
|
showHeader,
|
|
@@ -77,7 +105,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
77
105
|
isPinnable,
|
|
78
106
|
lastColumnId,
|
|
79
107
|
selectedColumn,
|
|
80
|
-
onColumnClick:
|
|
108
|
+
onColumnClick: handleColumnClickWithResize,
|
|
81
109
|
tableTitle,
|
|
82
110
|
areAllRowsLoaded,
|
|
83
111
|
isFetchingNextPage,
|
|
@@ -87,13 +115,16 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
87
115
|
tableMode,
|
|
88
116
|
showNoDataView,
|
|
89
117
|
tableBodyStyles,
|
|
118
|
+
onStartResize: startResize,
|
|
119
|
+
isResizing,
|
|
120
|
+
resizingColumn,
|
|
90
121
|
};
|
|
91
122
|
const commonPropsWithTableStates = Object.assign(Object.assign({}, baseCommonProps), { hasTimeoutError,
|
|
92
123
|
tableLoading });
|
|
93
|
-
return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (
|
|
124
|
+
return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, Object.assign({ ref: tableContainerRef }, { children: showNoDataView ? (tableLoading ? (
|
|
94
125
|
// Show same table structure with pinned columns during loading, but with skeleton rows
|
|
95
|
-
_jsxs(SheetViewVirtualTableWrapper, { children: [
|
|
126
|
+
_jsxs(SheetViewVirtualTableWrapper, Object.assign({ ref: tableWrapperRef }, { 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
127
|
// Non-loading error states
|
|
97
|
-
_jsx(NoDataView, Object.assign({ tableLoading: tableLoading, tableError: tableError, tableEmpty: tableEmpty, hasTimeoutError: hasTimeoutError, orderedColumns:
|
|
128
|
+
_jsx(NoDataView, Object.assign({ tableLoading: tableLoading, tableError: tableError, tableEmpty: tableEmpty, hasTimeoutError: hasTimeoutError, orderedColumns: orderedColumnsWithWidths, error: error, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps }, baseCommonProps)))) : (_jsxs(SheetViewVirtualTableWrapper, Object.assign({ ref: tableWrapperRef }, { 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
129
|
}
|
|
99
130
|
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,11 @@ 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
|
+
import { getColumnId } from '../features/resize/utils/resize';
|
|
11
|
+
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, }) {
|
|
12
|
+
// Use the same unique column ID logic as resize to ensure consistency
|
|
13
|
+
const columnId = getColumnId({ id, tableViewId });
|
|
10
14
|
const [columnFilterEl, setColumnFilterEl] = useState(null);
|
|
11
15
|
const cellRef = useRef(null);
|
|
12
16
|
const checkIsPanned = useCallback((columnId) => pinnedColumns === null || pinnedColumns === void 0 ? void 0 : pinnedColumns.includes(columnId), [pinnedColumns]);
|
|
@@ -38,7 +42,7 @@ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, so
|
|
|
38
42
|
event.stopPropagation();
|
|
39
43
|
onOpenFilterDropdown();
|
|
40
44
|
};
|
|
41
|
-
return (
|
|
45
|
+
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: 'visible !important', 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
46
|
content: '""',
|
|
43
47
|
borderBottom: 'none',
|
|
44
48
|
position: 'absolute',
|
|
@@ -46,11 +50,11 @@ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, so
|
|
|
46
50
|
right: 0,
|
|
47
51
|
left: 0,
|
|
48
52
|
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
|
-
|
|
53
|
+
} }, 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) => {
|
|
54
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, e, pinned);
|
|
55
|
+
} })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
handlePinClick(id);
|
|
58
|
+
}, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] })), onStartResize && pinned !== 'end' && (_jsx(ColumnResize, { columnId: columnId, onStartResize: onStartResize, isResizing: isResizing, isLast: isLast }))] })));
|
|
55
59
|
}
|
|
56
60
|
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: 8, "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, tableContainerRef }: 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,148 @@
|
|
|
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, tableContainerRef }) => {
|
|
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
|
+
}, [windowId, serviceCode]);
|
|
26
|
+
const [{ columnWidths, isResizing, resizingColumn, resizeIndicatorX }, 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 clampedXRef = useRef(0);
|
|
39
|
+
const mouseMoveRef = useRef();
|
|
40
|
+
const mouseUpRef = useRef();
|
|
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
|
+
}, []);
|
|
55
|
+
const getColumnWidth = useCallback((columnId) => {
|
|
56
|
+
return getColumnWidthFromState(columnWidths, columnId);
|
|
57
|
+
}, [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, clampedXRef)(columnId, currentWidth, startX);
|
|
65
|
+
}, [windowId, serviceCode, onColumnResize, cleanupEventListeners]);
|
|
66
|
+
const createMouseMoveHandlerCallback = useCallback((columnIndex, columnPinned) => {
|
|
67
|
+
return createMouseMoveHandler(setResizeState, setCursorPosition, initialCursorYRef, tableContainerRef, columnIndex, columnPinned, clampedXRef);
|
|
68
|
+
}, [tableContainerRef]);
|
|
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
|
+
// Find the column being resized to get its index and pinned status
|
|
76
|
+
const columnBeingResized = columns.find((col) => getColumnId(col) === columnId);
|
|
77
|
+
const columnIndex = columnBeingResized
|
|
78
|
+
? columns.filter((col) => col.pinned === columnBeingResized.pinned).findIndex((col) => getColumnId(col) === columnId)
|
|
79
|
+
: undefined;
|
|
80
|
+
const columnPinned = columnBeingResized === null || columnBeingResized === void 0 ? void 0 : columnBeingResized.pinned;
|
|
81
|
+
// Calculate the icon's Y position (center of the header cell)
|
|
82
|
+
const target = e.currentTarget;
|
|
83
|
+
const headerCell = target.closest('[data-testid="SheetViewVirtualTable_TableHeader_StyledCell"]');
|
|
84
|
+
let iconY = e.clientY; // fallback to mouse Y
|
|
85
|
+
if (headerCell) {
|
|
86
|
+
const rect = headerCell.getBoundingClientRect();
|
|
87
|
+
iconY = rect.top + rect.height / 2; // Center of the header cell (same as icon position)
|
|
88
|
+
}
|
|
89
|
+
setResizeState((prev) => (Object.assign(Object.assign({}, prev), { isResizing: true, resizingColumn: columnId, startX, startWidth: currentWidth, resizeIndicatorX: startX, resizingColumnIndex: columnIndex, resizingColumnPinned: columnPinned })));
|
|
90
|
+
initialCursorYRef.current = iconY;
|
|
91
|
+
clampedXRef.current = startX;
|
|
92
|
+
setCursorPosition({ x: startX, y: iconY });
|
|
93
|
+
isResizingRef.current = true;
|
|
94
|
+
// Create and store event handlers
|
|
95
|
+
const handleMouseMove = createMouseMoveHandlerCallback(columnIndex, columnPinned);
|
|
96
|
+
const handleMouseUp = createResizeEndHandlerMemo(columnId, currentWidth, startX);
|
|
97
|
+
mouseMoveRef.current = handleMouseMove;
|
|
98
|
+
mouseUpRef.current = handleMouseUp;
|
|
99
|
+
// Add global event listeners
|
|
100
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
101
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
102
|
+
// Hide cursor and disable text selection during resize
|
|
103
|
+
document.body.style.cursor = 'none';
|
|
104
|
+
document.body.style.userSelect = 'none';
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.error('Error starting resize:', error);
|
|
108
|
+
cleanupEventListeners();
|
|
109
|
+
}
|
|
110
|
+
}, [getColumnWidth, createMouseMoveHandlerCallback, createResizeEndHandlerMemo, cleanupEventListeners, columns]);
|
|
111
|
+
const stopResize = useCallback(() => {
|
|
112
|
+
try {
|
|
113
|
+
setResizeState((prev) => (Object.assign(Object.assign({}, prev), { isResizing: false, resizingColumn: null, resizeIndicatorX: 0 })));
|
|
114
|
+
isResizingRef.current = false;
|
|
115
|
+
cleanupEventListeners();
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
console.error('Error stopping resize:', error);
|
|
119
|
+
cleanupEventListeners();
|
|
120
|
+
}
|
|
121
|
+
}, [cleanupEventListeners]);
|
|
122
|
+
const isCurrentlyResizing = useCallback(() => {
|
|
123
|
+
return isResizingRef.current;
|
|
124
|
+
}, []);
|
|
125
|
+
// Wrapper for column click that prevents clicks during resize
|
|
126
|
+
const handleColumnClickWithResizeCheck = useCallback((columnIndex, event, pinnedType) => {
|
|
127
|
+
if (isCurrentlyResizing()) {
|
|
128
|
+
return; // Don't handle column click if we're currently resizing
|
|
129
|
+
}
|
|
130
|
+
handleColumnClick(columnIndex, event, pinnedType);
|
|
131
|
+
}, [handleColumnClick, isCurrentlyResizing]);
|
|
132
|
+
// Cleanup on unmount
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
return cleanupEventListeners;
|
|
135
|
+
}, [cleanupEventListeners]);
|
|
136
|
+
return {
|
|
137
|
+
columnWidths,
|
|
138
|
+
isResizing,
|
|
139
|
+
resizingColumn,
|
|
140
|
+
resizeIndicatorX,
|
|
141
|
+
cursorPosition,
|
|
142
|
+
getColumnWidth,
|
|
143
|
+
startResize,
|
|
144
|
+
stopResize,
|
|
145
|
+
isCurrentlyResizing,
|
|
146
|
+
handleColumnClick: handleColumnClickWithResizeCheck,
|
|
147
|
+
};
|
|
148
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { IColumnProps } from '../../../../../../types/index.js';
|
|
3
|
+
interface UseColumnResizeWithPinnedProps {
|
|
4
|
+
pinnedStartColumnsData: IColumnProps[];
|
|
5
|
+
pinnedEndColumnsData: IColumnProps[];
|
|
6
|
+
columnWidths: Record<string, number>;
|
|
7
|
+
}
|
|
8
|
+
export declare const useColumnResizeWithPinned: ({ pinnedStartColumnsData, pinnedEndColumnsData, columnWidths }: UseColumnResizeWithPinnedProps) => {
|
|
9
|
+
pinnedStartColumnsWidth: number;
|
|
10
|
+
pinnedEndColumnsWidth: number;
|
|
11
|
+
pinnedStartColumnsDataWithWidths: {
|
|
12
|
+
width: string | number | undefined;
|
|
13
|
+
header?: string | (() => import("react").ReactNode) | undefined;
|
|
14
|
+
render?: ((props: import("../../../../../../types/index.js").IRenderAttr<any, IColumnProps<any>>) => import("react").ReactNode) | undefined;
|
|
15
|
+
id: string | number | symbol;
|
|
16
|
+
tableViewId?: string | undefined;
|
|
17
|
+
format?: ((props: import("../../../../../../types/index.js").IFormatAttr<any>) => string) | undefined;
|
|
18
|
+
selector?: ((props: import("../../../../../../types/index.js").ISelectorAttr<any>) => string | number | Record<string, any>) | undefined;
|
|
19
|
+
align?: import("csstype").Property.TextAlign | undefined;
|
|
20
|
+
sortable?: boolean | undefined;
|
|
21
|
+
hidden?: boolean | undefined;
|
|
22
|
+
order?: number | undefined;
|
|
23
|
+
pinned?: "start" | "end" | undefined;
|
|
24
|
+
pinnable?: boolean | undefined;
|
|
25
|
+
cellStyle?: import("react").CSSProperties | undefined;
|
|
26
|
+
headerStyle?: import("react").CSSProperties | undefined;
|
|
27
|
+
filter?: ({
|
|
28
|
+
onConfirm?: ((filterValues: import("../../../../../../types/index.js").ColumnFilterValues) => void) | undefined;
|
|
29
|
+
onClear: (apiKeys: string[]) => void;
|
|
30
|
+
onClearFilterFields?: (() => void) | undefined;
|
|
31
|
+
data?: import("../../../../../../types/index.js").ColumnFilterValues | undefined;
|
|
32
|
+
isOnlyOneFilter?: boolean | undefined;
|
|
33
|
+
wrapperSx?: import("@mui/system").SxProps | undefined;
|
|
34
|
+
} & (import("../../../../../../types/index.js").IColumnFilterList | import("../../../../../../types/index.js").IColumnFilterInputs | import("../../../../../../types/index.js").IColumnFilterCustom)) | undefined;
|
|
35
|
+
isDefaultPinned?: boolean | undefined;
|
|
36
|
+
}[];
|
|
37
|
+
pinnedEndColumnsDataWithWidths: {
|
|
38
|
+
width: string | number | undefined;
|
|
39
|
+
header?: string | (() => import("react").ReactNode) | undefined;
|
|
40
|
+
render?: ((props: import("../../../../../../types/index.js").IRenderAttr<any, IColumnProps<any>>) => import("react").ReactNode) | undefined;
|
|
41
|
+
id: string | number | symbol;
|
|
42
|
+
tableViewId?: string | undefined;
|
|
43
|
+
format?: ((props: import("../../../../../../types/index.js").IFormatAttr<any>) => string) | undefined;
|
|
44
|
+
selector?: ((props: import("../../../../../../types/index.js").ISelectorAttr<any>) => string | number | Record<string, any>) | undefined;
|
|
45
|
+
align?: import("csstype").Property.TextAlign | undefined;
|
|
46
|
+
sortable?: boolean | undefined;
|
|
47
|
+
hidden?: boolean | undefined;
|
|
48
|
+
order?: number | undefined;
|
|
49
|
+
pinned?: "start" | "end" | undefined;
|
|
50
|
+
pinnable?: boolean | undefined;
|
|
51
|
+
cellStyle?: import("react").CSSProperties | undefined;
|
|
52
|
+
headerStyle?: import("react").CSSProperties | undefined;
|
|
53
|
+
filter?: ({
|
|
54
|
+
onConfirm?: ((filterValues: import("../../../../../../types/index.js").ColumnFilterValues) => void) | undefined;
|
|
55
|
+
onClear: (apiKeys: string[]) => void;
|
|
56
|
+
onClearFilterFields?: (() => void) | undefined;
|
|
57
|
+
data?: import("../../../../../../types/index.js").ColumnFilterValues | undefined;
|
|
58
|
+
isOnlyOneFilter?: boolean | undefined;
|
|
59
|
+
wrapperSx?: import("@mui/system").SxProps | undefined;
|
|
60
|
+
} & (import("../../../../../../types/index.js").IColumnFilterList | import("../../../../../../types/index.js").IColumnFilterInputs | import("../../../../../../types/index.js").IColumnFilterCustom)) | undefined;
|
|
61
|
+
isDefaultPinned?: boolean | undefined;
|
|
62
|
+
}[];
|
|
63
|
+
};
|
|
64
|
+
export {};
|