@tap-payments/os-micro-frontend-shared 0.1.212 → 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.
Files changed (50) hide show
  1. package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.d.ts +1 -1
  2. package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +40 -9
  3. package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.d.ts +1 -1
  4. package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.js +2 -2
  5. package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.d.ts +1 -1
  6. package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.js +2 -2
  7. package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.d.ts +1 -1
  8. package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.js +2 -2
  9. package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.d.ts +4 -1
  10. package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js +12 -8
  11. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/ColumnResize.d.ts +5 -0
  12. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/ColumnResize.js +41 -0
  13. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/ResizeOverlay.d.ts +5 -0
  14. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/ResizeOverlay.js +10 -0
  15. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/index.d.ts +2 -0
  16. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/components/index.js +2 -0
  17. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/constants.d.ts +5 -0
  18. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/constants.js +5 -0
  19. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/index.d.ts +2 -0
  20. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/index.js +2 -0
  21. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/useColumnResize.d.ts +16 -0
  22. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/useColumnResize.js +148 -0
  23. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/useColumnResizeWithPinned.d.ts +64 -0
  24. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/hooks/useColumnResizeWithPinned.js +29 -0
  25. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/index.d.ts +4 -0
  26. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/index.js +4 -0
  27. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/styles.d.ts +17 -0
  28. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/styles.js +55 -0
  29. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/types/index.d.ts +45 -0
  30. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/types/index.js +1 -0
  31. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/utils/index.d.ts +1 -0
  32. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/utils/index.js +1 -0
  33. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/utils/resize.d.ts +18 -0
  34. package/build/components/VirtualTables/SheetViewVirtualTable/features/resize/utils/resize.js +114 -0
  35. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.d.ts +1 -0
  36. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.js +1 -0
  37. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableDimensions.d.ts +12 -0
  38. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableDimensions.js +26 -0
  39. package/build/components/VirtualTables/SheetViewVirtualTable/style.js +1 -0
  40. package/build/components/VirtualTables/SheetViewVirtualTable/types.d.ts +8 -0
  41. package/build/components/VirtualTables/components/style.js +1 -0
  42. package/build/constants/assets.d.ts +1 -0
  43. package/build/constants/assets.js +1 -0
  44. package/build/utils/columnResizeStorage.d.ts +16 -0
  45. package/build/utils/columnResizeStorage.js +96 -0
  46. package/build/utils/index.d.ts +1 -0
  47. package/build/utils/index.js +1 -0
  48. package/build/utils/localStorage.d.ts +3 -0
  49. package/build/utils/localStorage.js +3 -0
  50. package/package.json +1 -1
@@ -0,0 +1,29 @@
1
+ import { useMemo } from 'react';
2
+ import { getColumnId } from '../utils/resize';
3
+ export const useColumnResizeWithPinned = ({ pinnedStartColumnsData, pinnedEndColumnsData, columnWidths }) => {
4
+ const pinnedStartColumnsWidth = useMemo(() => pinnedStartColumnsData.reduce((acc, col) => {
5
+ const columnId = getColumnId(col);
6
+ const width = columnWidths[columnId] || parseInt(String(col.width)) || 150;
7
+ return acc + width;
8
+ }, 0.2), [pinnedStartColumnsData, columnWidths]);
9
+ const pinnedEndColumnsWidth = useMemo(() => pinnedEndColumnsData.reduce((acc, col) => {
10
+ const columnId = getColumnId(col);
11
+ const width = columnWidths[columnId] || parseInt(String(col.width)) || 150;
12
+ return acc + width;
13
+ }, 0.2), [pinnedEndColumnsData, columnWidths]);
14
+ // Create updated column data with dynamic widths
15
+ const pinnedStartColumnsDataWithWidths = useMemo(() => pinnedStartColumnsData.map((col) => {
16
+ const columnId = getColumnId(col);
17
+ return Object.assign(Object.assign({}, col), { width: columnWidths[columnId] || col.width });
18
+ }), [pinnedStartColumnsData, columnWidths]);
19
+ const pinnedEndColumnsDataWithWidths = useMemo(() => pinnedEndColumnsData.map((col) => {
20
+ const columnId = getColumnId(col);
21
+ return Object.assign(Object.assign({}, col), { width: columnWidths[columnId] || col.width });
22
+ }), [pinnedEndColumnsData, columnWidths]);
23
+ return {
24
+ pinnedStartColumnsWidth,
25
+ pinnedEndColumnsWidth,
26
+ pinnedStartColumnsDataWithWidths,
27
+ pinnedEndColumnsDataWithWidths,
28
+ };
29
+ };
@@ -0,0 +1,4 @@
1
+ export * from './components';
2
+ export * from './utils';
3
+ export * from './hooks';
4
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ export * from './components';
2
+ export * from './utils';
3
+ export * from './hooks';
4
+ export * from './types';
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledResizeIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
3
+ isResizing: boolean;
4
+ isLast: boolean;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
+ export declare const IndicatorLine: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
7
+ isVisible: boolean;
8
+ x: number;
9
+ height: number;
10
+ top: number;
11
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
12
+ export declare const ResizeIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
13
+ isVisible: boolean;
14
+ x: number;
15
+ y: number;
16
+ offsetX?: number | undefined;
17
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,55 @@
1
+ import { styled } from '@mui/material/styles';
2
+ import { columnResizeIndicatorIcon } from '../../../../../constants/index.js';
3
+ export const StyledResizeIcon = styled('div', {
4
+ shouldForwardProp: (prop) => prop !== 'isResizing' && prop !== 'isLast',
5
+ })(({ isLast }) => ({
6
+ position: 'absolute',
7
+ top: 0,
8
+ right: isLast ? -10 : -11,
9
+ width: 20,
10
+ height: '100%',
11
+ backgroundColor: 'transparent',
12
+ zIndex: 100000,
13
+ display: 'flex',
14
+ alignItems: 'center',
15
+ justifyContent: 'center',
16
+ }));
17
+ export const IndicatorLine = styled('div', {
18
+ shouldForwardProp: (prop) => prop !== 'isVisible' && prop !== 'x' && prop !== 'height' && prop !== 'top',
19
+ })(({ isVisible, x, height, top }) => ({
20
+ position: 'fixed',
21
+ left: x,
22
+ top: top,
23
+ width: 1,
24
+ height: `calc(${height}px - 14px)`,
25
+ backgroundColor: '#1F88D0',
26
+ zIndex: 9999,
27
+ pointerEvents: 'none',
28
+ opacity: isVisible ? 1 : 0,
29
+ transition: 'opacity 0.1s ease',
30
+ '&::before': {
31
+ content: '""',
32
+ position: 'absolute',
33
+ left: -1,
34
+ top: 0,
35
+ width: 1,
36
+ height: '100%',
37
+ },
38
+ }));
39
+ export const ResizeIcon = styled('div', {
40
+ shouldForwardProp: (prop) => prop !== 'isVisible' && prop !== 'x' && prop !== 'y' && prop !== 'offsetX',
41
+ })(({ isVisible, x, y, offsetX = 0 }) => ({
42
+ position: 'fixed',
43
+ left: x + offsetX - 8,
44
+ top: y,
45
+ width: 20,
46
+ height: 16,
47
+ backgroundImage: `url(${columnResizeIndicatorIcon})`,
48
+ backgroundSize: 'contain',
49
+ backgroundRepeat: 'no-repeat',
50
+ backgroundPosition: 'center',
51
+ zIndex: 100000,
52
+ pointerEvents: 'none',
53
+ display: isVisible ? 'block' : 'none',
54
+ transform: 'translate(-50%, -50%)',
55
+ }));
@@ -0,0 +1,45 @@
1
+ /// <reference types="react" />
2
+ import type { IColumnProps } from '../../../../../../types/index.js';
3
+ export interface ColumnResizeState {
4
+ columnWidths: Record<string, number>;
5
+ isResizing: boolean;
6
+ resizingColumn: string | null;
7
+ startX: number;
8
+ startWidth: number;
9
+ resizeIndicatorX: number;
10
+ resizingColumnIndex?: number;
11
+ resizingColumnPinned?: 'start' | 'end';
12
+ }
13
+ export interface UseColumnResizeProps {
14
+ columns: IColumnProps[];
15
+ onColumnResize?: (columnId: string, newWidth: number) => void;
16
+ handleColumnClick: (columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
17
+ windowId?: string;
18
+ serviceCode?: string;
19
+ tableContainerRef?: React.RefObject<HTMLDivElement>;
20
+ }
21
+ export interface ColumnResizeProps {
22
+ columnId: string;
23
+ onStartResize: (e: React.MouseEvent, columnId: string) => void;
24
+ isResizing: boolean;
25
+ isLast?: boolean;
26
+ }
27
+ export interface ResizeIndicatorProps {
28
+ isVisible: boolean;
29
+ x: number;
30
+ height: number;
31
+ top?: number;
32
+ }
33
+ export interface FloatingResizeIconProps {
34
+ isVisible: boolean;
35
+ x: number;
36
+ y: number;
37
+ }
38
+ export interface ResizeOverlayProps {
39
+ isVisible: boolean;
40
+ indicatorX: number;
41
+ indicatorHeight: number;
42
+ indicatorTop: number;
43
+ iconX: number;
44
+ iconY: number;
45
+ }
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import { IColumnProps } from '../../../../../../types/index.js';
3
+ import { ColumnResizeState } from '../types';
4
+ export declare const parseColumnWidth: (width: React.CSSProperties['width']) => number;
5
+ export declare const clampWidth: (width: number) => number;
6
+ export declare const getColumnId: (column: {
7
+ id: string | number | symbol;
8
+ tableViewId?: string;
9
+ }) => string;
10
+ export declare const applyColumnWidths: (columns: IColumnProps[], columnWidths: Record<string, number>) => IColumnProps[];
11
+ export declare const cleanupEventListeners: (mouseMoveRef: import("react").MutableRefObject<((e: MouseEvent) => void) | undefined>, mouseUpRef: import("react").MutableRefObject<((e: MouseEvent) => void) | undefined>) => void;
12
+ export declare const createMouseUpHandler: (columnId: string, currentWidth: number, startX: number, windowId: string | undefined, serviceCode: string | undefined, onColumnResize: ((columnId: string, width: number) => void) | undefined, setResizeState: React.Dispatch<React.SetStateAction<ColumnResizeState>>, cleanupFn: () => void, clampedXRef: React.MutableRefObject<number>) => (mouseEvent: MouseEvent) => void;
13
+ export declare const createMouseMoveHandler: (setResizeState: React.Dispatch<React.SetStateAction<ColumnResizeState>>, setCursorPosition: React.Dispatch<React.SetStateAction<{
14
+ x: number;
15
+ y: number;
16
+ }>>, initialCursorYRef: React.MutableRefObject<number>, tableContainerRef?: React.RefObject<HTMLDivElement>, resizingColumnIndex?: number, resizingColumnPinned?: 'start' | 'end', clampedXRef?: React.MutableRefObject<number>) => (mouseEvent: MouseEvent) => void;
17
+ export declare const getColumnWidthFromState: (columnWidths: Record<string, number>, columnId: string) => number;
18
+ export declare const createResizeEndHandler: (windowId: string | undefined, serviceCode: string | undefined, onColumnResize: ((columnId: string, width: number) => void) | undefined, setResizeState: React.Dispatch<React.SetStateAction<ColumnResizeState>>, cleanupFn: () => void, isResizingRef: React.MutableRefObject<boolean>, clampedXRef: React.MutableRefObject<number>) => (columnId: string, currentWidth: number, startX: number) => (event: MouseEvent) => void;
@@ -0,0 +1,114 @@
1
+ import { setColumnWidth } from '../../../../../../utils/index.js';
2
+ import { COLUMN_WIDTH_CONSTRAINTS } from '../constants';
3
+ export const parseColumnWidth = (width) => {
4
+ if (typeof width === 'string') {
5
+ const parsed = parseInt(width, 10);
6
+ return isNaN(parsed) ? COLUMN_WIDTH_CONSTRAINTS.DEFAULT_WIDTH : parsed;
7
+ }
8
+ return width || COLUMN_WIDTH_CONSTRAINTS.DEFAULT_WIDTH;
9
+ };
10
+ export const clampWidth = (width) => {
11
+ return Math.max(COLUMN_WIDTH_CONSTRAINTS.MIN_WIDTH, Math.min(COLUMN_WIDTH_CONSTRAINTS.MAX_WIDTH, width));
12
+ };
13
+ export const getColumnId = (column) => {
14
+ // Create a unique identifier by combining id and tableViewId
15
+ // This prevents conflicts when the same tableViewId is used in different columns
16
+ const baseId = String(column.id);
17
+ if (column.tableViewId) {
18
+ // Combine both id and tableViewId with a separator to ensure uniqueness
19
+ return `${baseId}_${column.tableViewId}`;
20
+ }
21
+ return baseId;
22
+ };
23
+ export const applyColumnWidths = (columns, columnWidths) => {
24
+ return columns.map((col) => {
25
+ const columnId = getColumnId(col);
26
+ return Object.assign(Object.assign({}, col), { width: columnWidths[columnId] || col.width });
27
+ });
28
+ };
29
+ // Event handler utilities
30
+ export const cleanupEventListeners = (mouseMoveRef, mouseUpRef) => {
31
+ if (mouseMoveRef.current) {
32
+ document.removeEventListener('mousemove', mouseMoveRef.current);
33
+ mouseMoveRef.current = undefined;
34
+ }
35
+ if (mouseUpRef.current) {
36
+ document.removeEventListener('mouseup', mouseUpRef.current);
37
+ mouseUpRef.current = undefined;
38
+ }
39
+ document.body.style.cursor = '';
40
+ document.body.style.userSelect = '';
41
+ };
42
+ // Mouse event handler
43
+ export const createMouseUpHandler = (columnId, currentWidth, startX, windowId, serviceCode, onColumnResize, setResizeState, cleanupFn, clampedXRef) => {
44
+ return (mouseEvent) => {
45
+ try {
46
+ // Use the clamped X position from the ref instead of raw mouse position
47
+ const deltaX = clampedXRef.current - startX;
48
+ const newWidth = clampWidth(currentWidth + deltaX);
49
+ setResizeState((prev) => (Object.assign(Object.assign({}, prev), { columnWidths: Object.assign(Object.assign({}, prev.columnWidths), { [columnId]: newWidth }), isResizing: false, resizingColumn: null, resizeIndicatorX: 0 })));
50
+ // Save to localStorage if windowId and serviceCode are provided
51
+ if (windowId && serviceCode) {
52
+ const success = setColumnWidth(windowId, serviceCode, String(columnId), newWidth);
53
+ if (!success) {
54
+ console.warn(`Failed to persist column width for ${columnId}`);
55
+ }
56
+ }
57
+ onColumnResize === null || onColumnResize === void 0 ? void 0 : onColumnResize(columnId, newWidth);
58
+ // Prevent event bubbling
59
+ mouseEvent.stopPropagation();
60
+ mouseEvent.preventDefault();
61
+ cleanupFn();
62
+ }
63
+ catch (error) {
64
+ console.error('Error in mouse up handler:', error);
65
+ cleanupFn();
66
+ }
67
+ };
68
+ };
69
+ export const createMouseMoveHandler = (setResizeState, setCursorPosition, initialCursorYRef, tableContainerRef, resizingColumnIndex, resizingColumnPinned, clampedXRef) => {
70
+ return (mouseEvent) => {
71
+ try {
72
+ let clampedX = mouseEvent.clientX;
73
+ // Clamp the x position to stay within the table boundaries
74
+ if (tableContainerRef === null || tableContainerRef === void 0 ? void 0 : tableContainerRef.current) {
75
+ const tableRect = tableContainerRef.current.getBoundingClientRect();
76
+ const minX = tableRect.left;
77
+ let maxX = tableRect.right;
78
+ // Adjust maxX for second pinned start column (index 1)
79
+ if (resizingColumnPinned === 'start' && resizingColumnIndex === 1) {
80
+ maxX = maxX - 44;
81
+ }
82
+ clampedX = Math.max(minX, Math.min(maxX, mouseEvent.clientX));
83
+ }
84
+ // Store the clamped X position in the ref for use in mouse up handler
85
+ if (clampedXRef) {
86
+ clampedXRef.current = clampedX;
87
+ }
88
+ setResizeState((prev) => (Object.assign(Object.assign({}, prev), { resizeIndicatorX: clampedX })));
89
+ setCursorPosition({
90
+ x: clampedX,
91
+ y: initialCursorYRef.current,
92
+ });
93
+ }
94
+ catch (error) {
95
+ console.error('Error in mouse move handler:', error);
96
+ }
97
+ };
98
+ };
99
+ // Column width utility
100
+ export const getColumnWidthFromState = (columnWidths, columnId) => {
101
+ return columnWidths[columnId] || COLUMN_WIDTH_CONSTRAINTS.DEFAULT_WIDTH;
102
+ };
103
+ // Creates a mouse up handler that clears the resize flag after completion
104
+ export const createResizeEndHandler = (windowId, serviceCode, onColumnResize, setResizeState, cleanupFn, isResizingRef, clampedXRef) => {
105
+ return (columnId, currentWidth, startX) => {
106
+ return (event) => {
107
+ createMouseUpHandler(columnId, currentWidth, startX, windowId, serviceCode, onColumnResize, setResizeState, cleanupFn, clampedXRef)(event);
108
+ // Clear resize flag to allow column selection after resize
109
+ setTimeout(() => {
110
+ isResizingRef.current = false;
111
+ }, 0);
112
+ };
113
+ };
114
+ };
@@ -4,3 +4,4 @@ export { useTableState } from './useTableState';
4
4
  export { useTableData } from './useTableData';
5
5
  export { useVirtualTableContainer } from './useVirtualTableContainer';
6
6
  export { usePinnedColumnsWidths } from './usePinnedColumnsWidths';
7
+ export { useTableDimensions } from './useTableDimensions';
@@ -4,3 +4,4 @@ export { useTableState } from './useTableState';
4
4
  export { useTableData } from './useTableData';
5
5
  export { useVirtualTableContainer } from './useVirtualTableContainer';
6
6
  export { usePinnedColumnsWidths } from './usePinnedColumnsWidths';
7
+ export { useTableDimensions } from './useTableDimensions';
@@ -0,0 +1,12 @@
1
+ import { RefObject } from 'react';
2
+ interface TableDimensions {
3
+ top: number;
4
+ height: number;
5
+ }
6
+ interface UseTableDimensionsProps {
7
+ tableContainerRef: RefObject<HTMLDivElement>;
8
+ showHeader: boolean;
9
+ isResizing: boolean;
10
+ }
11
+ export declare const useTableDimensions: ({ tableContainerRef, showHeader, isResizing }: UseTableDimensionsProps) => TableDimensions;
12
+ export {};
@@ -0,0 +1,26 @@
1
+ import { SHEET_VIEW_TABLE_ROW_HEIGHT } from '../../../../constants/index.js';
2
+ import { useEffect, useState } from 'react';
3
+ export const useTableDimensions = ({ tableContainerRef, showHeader, isResizing }) => {
4
+ const [tableDimensions, setTableDimensions] = useState({ top: 0, height: 0 });
5
+ useEffect(() => {
6
+ const updateTableDimensions = () => {
7
+ if (tableContainerRef.current) {
8
+ const rect = tableContainerRef.current.getBoundingClientRect();
9
+ const headerHeight = showHeader ? SHEET_VIEW_TABLE_ROW_HEIGHT : 0; // Header height is 28px
10
+ setTableDimensions({
11
+ top: rect.top + headerHeight,
12
+ height: rect.height - headerHeight,
13
+ });
14
+ }
15
+ };
16
+ // Update dimensions on mount and when resizing starts
17
+ updateTableDimensions();
18
+ if (isResizing) {
19
+ // Update dimensions during resize to handle window resizing
20
+ const handleResize = () => updateTableDimensions();
21
+ window.addEventListener('resize', handleResize);
22
+ return () => window.removeEventListener('resize', handleResize);
23
+ }
24
+ }, [isResizing, showHeader, tableContainerRef]);
25
+ return tableDimensions;
26
+ };
@@ -55,6 +55,7 @@ export const SheetViewVirtualTableWrapper = styled('div')({
55
55
  width: '100%',
56
56
  height: '100%',
57
57
  overflow: 'hidden',
58
+ borderRadius: '12px',
58
59
  });
59
60
  const PinnedColumnBase = styled('div')(({ theme }) => ({
60
61
  width: 'auto',
@@ -6,6 +6,8 @@ export interface ISheetViewVirtualTable extends Omit<IVirtualTable, 'isSheetView
6
6
  isPinnable?: boolean;
7
7
  clearBackdropVisibilityTimeout?: number;
8
8
  overscanCount?: number;
9
+ windowId?: string;
10
+ serviceCode?: string;
9
11
  }
10
12
  export interface SheetViewTableHeaderProps {
11
13
  columns: IColumnProps[];
@@ -22,6 +24,9 @@ export interface SheetViewTableHeaderProps {
22
24
  tablePosition?: TablePosition;
23
25
  hasPinnedStart?: boolean;
24
26
  hasPinnedEnd?: boolean;
27
+ onStartResize?: (e: React.MouseEvent, columnId: string) => void;
28
+ isResizing?: boolean;
29
+ resizingColumn?: string | null;
25
30
  }
26
31
  export interface VirtualTableContainerProps {
27
32
  columnsData: IColumnProps[];
@@ -50,6 +55,9 @@ export interface CommonTableProps {
50
55
  tableMode?: string;
51
56
  showNoDataView: boolean;
52
57
  tableBodyStyles?: CSSProperties;
58
+ onStartResize?: (e: React.MouseEvent, columnId: string) => void;
59
+ isResizing?: boolean;
60
+ resizingColumn?: string | null;
53
61
  }
54
62
  export interface PinnedColumnProps extends CommonTableProps {
55
63
  position: 'start' | 'end';
@@ -56,6 +56,7 @@ export const TableHeaderInner = styled(Box)(({ theme }) => ({
56
56
  display: 'flex',
57
57
  gap: theme.spacing(0.5),
58
58
  alignItems: 'center',
59
+ overflow: 'hidden !important',
59
60
  }));
60
61
  export const StyledVirtualList = styled(VirtualScrollList, {
61
62
  shouldForwardProp: (prop) => !['areTotalRowsNotFillingHeight', 'isSheetView'].includes(prop),
@@ -456,6 +456,7 @@ export declare const fileDownloadBlueIcon: string;
456
456
  export declare const fileDownloadGreyIcon: string;
457
457
  export declare const metaIcon: string;
458
458
  export declare const darkFilterIcon: string;
459
+ export declare const columnResizeIndicatorIcon: string;
459
460
  export declare const homeIcon: string;
460
461
  export declare const lockIcon: string;
461
462
  export declare const calenderIcon: string;
@@ -463,6 +463,7 @@ export const fileDownloadBlueIcon = `${appBaseUrl}/fileDownloadBlue.svg`;
463
463
  export const fileDownloadGreyIcon = `${appBaseUrl}/fileDownloadGrey.svg`;
464
464
  export const metaIcon = `${lightUrl}/meta.svg`;
465
465
  export const darkFilterIcon = `${lightUrl}/darkFilterIcon.svg`;
466
+ export const columnResizeIndicatorIcon = `${lightUrl}/resize-icon.svg`;
466
467
  export const homeIcon = `${lightUrl}/home.svg`;
467
468
  export const lockIcon = `${lightUrl}/lockIcon.svg`;
468
469
  export const calenderIcon = `${lightUrl}/Calendar.svg`;
@@ -0,0 +1,16 @@
1
+ export interface ColumnSettings {
2
+ width: number;
3
+ }
4
+ export interface ColumnSettingsMap {
5
+ [columnId: string]: ColumnSettings;
6
+ }
7
+ export interface ServiceColumnsMap {
8
+ [serviceCode: string]: ColumnSettingsMap;
9
+ }
10
+ export interface SheetViewColumnsData {
11
+ [windowId: string]: ServiceColumnsMap;
12
+ }
13
+ export declare const getSheetViewColumns: () => SheetViewColumnsData;
14
+ export declare const setSheetViewColumns: (data: SheetViewColumnsData) => boolean;
15
+ export declare const getColumnWidth: (windowId: string, serviceCode: string, columnId: string, defaultWidth?: number) => number | undefined;
16
+ export declare const setColumnWidth: (windowId: string, serviceCode: string, columnId: string, width: number) => boolean;
@@ -0,0 +1,96 @@
1
+ import { getSheetViewColumnsStorage, setSheetViewColumnsStorage } from './localStorage';
2
+ const isValidString = (value) => typeof value === 'string' && value.trim().length > 0;
3
+ const isValidNumber = (value) => typeof value === 'number' && !isNaN(value) && isFinite(value) && value > 0;
4
+ const isValidColumnSettings = (data) => {
5
+ if (!data || typeof data !== 'object')
6
+ return false;
7
+ const settings = data;
8
+ return 'width' in settings && isValidNumber(settings.width);
9
+ };
10
+ const isValidColumnSettingsMap = (data) => {
11
+ if (!data || typeof data !== 'object')
12
+ return false;
13
+ return Object.values(data).every(isValidColumnSettings);
14
+ };
15
+ const isValidServiceColumnsMap = (data) => {
16
+ if (!data || typeof data !== 'object')
17
+ return false;
18
+ return Object.values(data).every(isValidColumnSettingsMap);
19
+ };
20
+ const isValidSheetViewColumnsData = (data) => {
21
+ if (!data || typeof data !== 'object')
22
+ return false;
23
+ return Object.values(data).every(isValidServiceColumnsMap);
24
+ };
25
+ export const getSheetViewColumns = () => {
26
+ try {
27
+ const data = getSheetViewColumnsStorage();
28
+ if (!data)
29
+ return {};
30
+ const parsedData = data;
31
+ if (!isValidSheetViewColumnsData(parsedData)) {
32
+ console.warn('Invalid column settings in localStorage');
33
+ return {};
34
+ }
35
+ return parsedData;
36
+ }
37
+ catch (error) {
38
+ console.warn('Failed to get sheetview columns:', error);
39
+ return {};
40
+ }
41
+ };
42
+ export const setSheetViewColumns = (data) => {
43
+ if (!isValidSheetViewColumnsData(data)) {
44
+ console.warn('Invalid data structure for sheetview columns');
45
+ return false;
46
+ }
47
+ try {
48
+ setSheetViewColumnsStorage(data);
49
+ return true;
50
+ }
51
+ catch (error) {
52
+ console.warn('Failed to save sheetview columns:', error);
53
+ return false;
54
+ }
55
+ };
56
+ export const getColumnWidth = (windowId, serviceCode, columnId, defaultWidth) => {
57
+ var _a, _b, _c;
58
+ if (!isValidString(windowId) || !isValidString(serviceCode) || !isValidString(columnId)) {
59
+ return defaultWidth;
60
+ }
61
+ try {
62
+ const columnsData = getSheetViewColumns();
63
+ const width = (_c = (_b = (_a = columnsData[windowId]) === null || _a === void 0 ? void 0 : _a[serviceCode]) === null || _b === void 0 ? void 0 : _b[columnId]) === null || _c === void 0 ? void 0 : _c.width;
64
+ return width !== null && width !== void 0 ? width : defaultWidth;
65
+ }
66
+ catch (error) {
67
+ console.warn('Failed to get column width:', error);
68
+ return defaultWidth;
69
+ }
70
+ };
71
+ export const setColumnWidth = (windowId, serviceCode, columnId, width) => {
72
+ if (!isValidString(windowId) || !isValidString(serviceCode) || !isValidString(columnId) || !isValidNumber(width)) {
73
+ console.warn('Invalid parameters for setColumnWidth');
74
+ return false;
75
+ }
76
+ try {
77
+ const columnsData = getSheetViewColumns();
78
+ if (!columnsData[windowId]) {
79
+ columnsData[windowId] = {};
80
+ }
81
+ if (!columnsData[windowId][serviceCode]) {
82
+ columnsData[windowId][serviceCode] = {};
83
+ }
84
+ if (!columnsData[windowId][serviceCode][columnId]) {
85
+ columnsData[windowId][serviceCode][columnId] = { width };
86
+ }
87
+ else {
88
+ columnsData[windowId][serviceCode][columnId].width = width;
89
+ }
90
+ return setSheetViewColumns(columnsData);
91
+ }
92
+ catch (error) {
93
+ console.warn('Failed to set column width:', error);
94
+ return false;
95
+ }
96
+ };
@@ -42,3 +42,4 @@ export * from './encrypt';
42
42
  export * from './day';
43
43
  export * from './style';
44
44
  export * from './boolean';
45
+ export * from './columnResizeStorage';
@@ -42,3 +42,4 @@ export * from './encrypt';
42
42
  export * from './day';
43
43
  export * from './style';
44
44
  export * from './boolean';
45
+ export * from './columnResizeStorage';
@@ -1,4 +1,5 @@
1
1
  import { AppDetails, Segment, TableMode, Timezone } from '../types/index.js';
2
+ import { SheetViewColumnsData } from './columnResizeStorage';
2
3
  export declare function setSecretKey(): void;
3
4
  export declare function getSecretKey(): string | null;
4
5
  export declare function removeSecretKey(): void;
@@ -29,4 +30,6 @@ export declare const removeCalenderTimezoneHistory: () => void;
29
30
  export declare const setGlobalTableModeStorage: (mode: TableMode) => void;
30
31
  export declare const getGlobalTableModeStorage: () => TableMode;
31
32
  export declare const removeGlobalTableModeStorage: () => void;
33
+ export declare const setSheetViewColumnsStorage: (data: SheetViewColumnsData) => void;
34
+ export declare const getSheetViewColumnsStorage: () => SheetViewColumnsData;
32
35
  export declare const clearTapOsLocalStorage: () => void;
@@ -11,6 +11,7 @@ const APP_VERSION = 'tap-dashboard-app-version';
11
11
  const CALENDER_TIMEZONE = 'tap-dashboard-calender-timezone';
12
12
  const CALENDER_TIMEZONE_HISTORY = 'tap-dashboard-calender-timezone-history';
13
13
  const GLOBAL_TABLE_MODE_KEY = 'tap-dashboard-global-table-mode';
14
+ const SHEETVIEW_COLUMNS_KEY = 'sheetview_columns';
14
15
  export function setSecretKey() {
15
16
  localStorage.setItem(SECRET_KEY_LOCAL_STORAGE, TEST_SECRET_KEY);
16
17
  }
@@ -166,6 +167,8 @@ export const getGlobalTableModeStorage = () => {
166
167
  export const removeGlobalTableModeStorage = () => {
167
168
  localStorage.removeItem(GLOBAL_TABLE_MODE_KEY);
168
169
  };
170
+ export const setSheetViewColumnsStorage = (data) => localStorage.setItem(SHEETVIEW_COLUMNS_KEY, JSON.stringify(data));
171
+ export const getSheetViewColumnsStorage = () => JSON.parse(localStorage.getItem(SHEETVIEW_COLUMNS_KEY) || '{}');
169
172
  export const clearTapOsLocalStorage = () => {
170
173
  removeSecretKey();
171
174
  removeConnectMetaData();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.212",
4
+ "version": "0.1.213",
5
5
  "testVersion": 11,
6
6
  "type": "module",
7
7
  "main": "build/index.js",