@tap-payments/os-micro-frontend-shared 0.1.130-test.5 → 0.1.130-test.6
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/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +2 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js +3 -4
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.d.ts +27 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js +8 -2
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/build/utils/memoComparison.d.ts +19 -0
- package/build/utils/memoComparison.js +24 -0
- package/package.json +2 -2
|
@@ -7,7 +7,7 @@ import { SheetViewVirtualTableWrapper } from './style';
|
|
|
7
7
|
import { usePinnedColumns, useSynchronizedScroll, useTableState, useTableData, useVirtualTableContainer, usePinnedColumnsWidths, usePerformanceOptimizations, } from './hooks';
|
|
8
8
|
import { PinnedColumn, MainTable, LoadingMainTable, NoDataView, VirtualTable } from './components';
|
|
9
9
|
function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, rowHeight = 28, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableTitle, dragControls, onColumnPin, clearBackdropVisibilityTimeout = 100, isPinnable = false, tableMode, overscanCount, }) {
|
|
10
|
-
const {
|
|
10
|
+
const { stableColumnsWithFilters } = usePerformanceOptimizations(columns);
|
|
11
11
|
const { selectedCell, selectedColumn, selectedRow, showBackDrop, setShowBackdrop, handleCellClick, handleColumnClick, handleChipClick, selectedChip, } = useTableState();
|
|
12
12
|
const { isError, tableLoading, tableError, tableEmpty, hasTimeoutError, showNoDataView, lastItemIndex, areTotalRowsNotFillingHeight, itemsCount, isDelayedFetchingNextPage, } = useTableData({
|
|
13
13
|
rows,
|
|
@@ -16,7 +16,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
16
16
|
isFetchingNextPage,
|
|
17
17
|
areAllRowsLoaded,
|
|
18
18
|
});
|
|
19
|
-
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(
|
|
19
|
+
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(stableColumnsWithFilters, isPinnable, onColumnPin);
|
|
20
20
|
const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
|
|
21
21
|
const { pinnedStartColumnsWidth, pinnedEndColumnsWidth } = usePinnedColumnsWidths(pinnedStartColumnsData, pinnedEndColumnsData);
|
|
22
22
|
const { getItemSize, getItemDataForContainer } = useVirtualTableContainer({
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { memo, useCallback, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import Box from '@mui/material/Box';
|
|
4
4
|
import { pinIcon, unpinIcon } from '../../../../constants/index.js';
|
|
5
|
+
import { areTableHeaderCellPropsEqual } from '../../../../utils/index.js';
|
|
5
6
|
import ColumnFilter from '../../components/ColumnFilter';
|
|
6
7
|
import { StyledCell, TableHeaderInner } from '../../components/style';
|
|
7
8
|
import { PinIconContainer, HeaderText } from '../style';
|
|
@@ -44,11 +45,9 @@ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, so
|
|
|
44
45
|
right: 0,
|
|
45
46
|
left: 0,
|
|
46
47
|
bottom: 0,
|
|
47
|
-
} }, 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 &&
|
|
48
|
-
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, e, pinned);
|
|
49
|
-
} })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
|
|
48
|
+
} }, 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 }), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
|
|
50
49
|
event.stopPropagation();
|
|
51
50
|
handlePinClick(id);
|
|
52
51
|
}, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] })) })));
|
|
53
52
|
}
|
|
54
|
-
export default memo(SheetViewTableHeaderCell);
|
|
53
|
+
export default memo(SheetViewTableHeaderCell, areTableHeaderCellPropsEqual);
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.d.ts
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { IColumnProps } from '../../../../types/index.js';
|
|
2
3
|
export declare const usePerformanceOptimizations: (columns: readonly IColumnProps[]) => {
|
|
3
4
|
stableColumns: IColumnProps<any>[];
|
|
5
|
+
stableColumnsWithFilters: {
|
|
6
|
+
filter: ({
|
|
7
|
+
onConfirm?: ((filterValues: import("../../../../types/index.js").ColumnFilterValues) => void) | undefined;
|
|
8
|
+
onClear: (apiKeys: string[]) => void;
|
|
9
|
+
onClearFilterFields?: (() => void) | undefined;
|
|
10
|
+
data?: import("../../../../types/index.js").ColumnFilterValues | undefined;
|
|
11
|
+
isOnlyOneFilter?: boolean | undefined;
|
|
12
|
+
wrapperSx?: import("@mui/system").SxProps | undefined;
|
|
13
|
+
} & (import("../../../../types/index.js").IColumnFilterList | import("../../../../types/index.js").IColumnFilterInputs | import("../../../../types/index.js").IColumnFilterCustom)) | undefined;
|
|
14
|
+
header?: string | (() => import("react").ReactNode) | undefined;
|
|
15
|
+
render?: ((props: import("../../../../types/index.js").IRenderAttr<any, IColumnProps<any>>) => import("react").ReactNode) | undefined;
|
|
16
|
+
id: string | number | symbol;
|
|
17
|
+
tableViewId?: string | undefined;
|
|
18
|
+
width?: import("csstype").Property.Width<string | number> | undefined;
|
|
19
|
+
format?: ((props: import("../../../../types/index.js").IFormatAttr<any>) => string) | undefined;
|
|
20
|
+
selector?: ((props: import("../../../../types/index.js").ISelectorAttr<any>) => string | number | Record<string, any>) | undefined;
|
|
21
|
+
align?: import("csstype").Property.TextAlign | undefined;
|
|
22
|
+
sortable?: boolean | undefined;
|
|
23
|
+
hidden?: boolean | undefined;
|
|
24
|
+
order?: number | undefined;
|
|
25
|
+
pinned?: "start" | "end" | undefined;
|
|
26
|
+
pinnable?: boolean | undefined;
|
|
27
|
+
cellStyle?: import("react").CSSProperties | undefined;
|
|
28
|
+
headerStyle?: import("react").CSSProperties | undefined;
|
|
29
|
+
isDefaultPinned?: boolean | undefined;
|
|
30
|
+
}[];
|
|
4
31
|
columnMetrics: {
|
|
5
32
|
visibleColumns: IColumnProps<any>[];
|
|
6
33
|
totalWidth: number;
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js
CHANGED
|
@@ -10,14 +10,19 @@ export const usePerformanceOptimizations = (columns) => {
|
|
|
10
10
|
col.width !== prevCol.width ||
|
|
11
11
|
col.pinned !== prevCol.pinned ||
|
|
12
12
|
col.hidden !== prevCol.hidden ||
|
|
13
|
-
col.order !== prevCol.order
|
|
14
|
-
col.filter !== prevCol.filter);
|
|
13
|
+
col.order !== prevCol.order);
|
|
15
14
|
});
|
|
16
15
|
if (hasChanged) {
|
|
17
16
|
stableColumnsRef.current = [...columns];
|
|
18
17
|
}
|
|
19
18
|
return stableColumnsRef.current;
|
|
20
19
|
}, [columns]);
|
|
20
|
+
const stableColumnsWithFilters = useMemo(() => {
|
|
21
|
+
return stableColumns.map((stableCol, index) => {
|
|
22
|
+
const currentCol = columns[index];
|
|
23
|
+
return Object.assign(Object.assign({}, stableCol), { filter: currentCol === null || currentCol === void 0 ? void 0 : currentCol.filter });
|
|
24
|
+
});
|
|
25
|
+
}, [stableColumns, columns]);
|
|
21
26
|
const columnMetrics = useMemo(() => {
|
|
22
27
|
var _a, _b;
|
|
23
28
|
const visibleColumns = stableColumns.filter((col) => !col.hidden);
|
|
@@ -33,6 +38,7 @@ export const usePerformanceOptimizations = (columns) => {
|
|
|
33
38
|
}, [stableColumns]);
|
|
34
39
|
return {
|
|
35
40
|
stableColumns,
|
|
41
|
+
stableColumnsWithFilters,
|
|
36
42
|
columnMetrics,
|
|
37
43
|
};
|
|
38
44
|
};
|
package/build/utils/index.d.ts
CHANGED
package/build/utils/index.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { IColumnProps } from '../types/index.js';
|
|
3
|
+
interface SheetViewTableHeaderCellProps {
|
|
4
|
+
column: IColumnProps;
|
|
5
|
+
colIndex: number;
|
|
6
|
+
isFirst: boolean;
|
|
7
|
+
isLast: boolean;
|
|
8
|
+
isSelected: boolean;
|
|
9
|
+
isDefaultPinned: boolean;
|
|
10
|
+
isPinnable?: boolean;
|
|
11
|
+
lastColumnId?: string | null;
|
|
12
|
+
columnsSorting?: Record<string, 'asc' | 'desc'>;
|
|
13
|
+
pinnedColumns?: string[];
|
|
14
|
+
onColumnSort?: (columnsSorting: Record<string, 'asc' | 'desc'>) => void;
|
|
15
|
+
onColumnPin?: (columnId: string, position: 'start' | 'end' | 'unpin') => void;
|
|
16
|
+
onColumnClick?: (columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const areTableHeaderCellPropsEqual: (prevProps: SheetViewTableHeaderCellProps, nextProps: SheetViewTableHeaderCellProps) => boolean;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const areTableHeaderCellPropsEqual = (prevProps, nextProps) => {
|
|
2
|
+
const prevCol = prevProps.column;
|
|
3
|
+
const nextCol = nextProps.column;
|
|
4
|
+
const filterChanged = prevCol.filter !== nextCol.filter;
|
|
5
|
+
const essentialPropsChanged = prevCol.id !== nextCol.id ||
|
|
6
|
+
prevCol.header !== nextCol.header ||
|
|
7
|
+
prevCol.width !== nextCol.width ||
|
|
8
|
+
prevCol.align !== nextCol.align ||
|
|
9
|
+
prevCol.pinned !== nextCol.pinned ||
|
|
10
|
+
prevCol.sortable !== nextCol.sortable ||
|
|
11
|
+
prevCol.pinnable !== nextCol.pinnable ||
|
|
12
|
+
prevCol.order !== nextCol.order ||
|
|
13
|
+
JSON.stringify(prevCol.headerStyle) !== JSON.stringify(nextCol.headerStyle);
|
|
14
|
+
const otherPropsChanged = prevProps.colIndex !== nextProps.colIndex ||
|
|
15
|
+
prevProps.isFirst !== nextProps.isFirst ||
|
|
16
|
+
prevProps.isLast !== nextProps.isLast ||
|
|
17
|
+
prevProps.isSelected !== nextProps.isSelected ||
|
|
18
|
+
prevProps.isDefaultPinned !== nextProps.isDefaultPinned ||
|
|
19
|
+
prevProps.isPinnable !== nextProps.isPinnable ||
|
|
20
|
+
prevProps.lastColumnId !== nextProps.lastColumnId ||
|
|
21
|
+
JSON.stringify(prevProps.columnsSorting) !== JSON.stringify(nextProps.columnsSorting) ||
|
|
22
|
+
JSON.stringify(prevProps.pinnedColumns) !== JSON.stringify(nextProps.pinnedColumns);
|
|
23
|
+
return !filterChanged && !essentialPropsChanged && !otherPropsChanged;
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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.130-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.130-test.6",
|
|
5
|
+
"testVersion": 6,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|