@tap-payments/os-micro-frontend-shared 0.0.283-test.3 → 0.0.283-test.4
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.
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
-
import { useMemo, memo, useState, useCallback
|
|
11
|
+
import { useMemo, memo, useState, useCallback } from 'react';
|
|
12
12
|
import { useTheme } from '@mui/material/styles';
|
|
13
13
|
import memoize from 'memoize-one';
|
|
14
14
|
import InfiniteLoader from 'react-window-infinite-loader';
|
|
@@ -51,25 +51,6 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
51
51
|
const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
|
|
52
52
|
const [selectedCell, setSelectedCell] = useState(null);
|
|
53
53
|
const [selectedColumn, setSelectedColumn] = useState(null);
|
|
54
|
-
const containerHeightRef = useRef(0);
|
|
55
|
-
const lastKnownRowsLengthRef = useRef(0);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
var _a, _b, _c, _d, _e, _f;
|
|
58
|
-
const hasRowsChanged = lastKnownRowsLengthRef.current !== rows.length;
|
|
59
|
-
const shouldResetCache = hasRowsChanged || areAllRowsLoaded;
|
|
60
|
-
if (shouldResetCache) {
|
|
61
|
-
if (pinnedStartVirtualListRef.current) {
|
|
62
|
-
(_b = (_a = pinnedStartVirtualListRef.current).resetAfterIndex) === null || _b === void 0 ? void 0 : _b.call(_a, 0);
|
|
63
|
-
}
|
|
64
|
-
if (scrollableVirtualListRef.current) {
|
|
65
|
-
(_d = (_c = scrollableVirtualListRef.current).resetAfterIndex) === null || _d === void 0 ? void 0 : _d.call(_c, 0);
|
|
66
|
-
}
|
|
67
|
-
if (pinnedEndVirtualListRef.current) {
|
|
68
|
-
(_f = (_e = pinnedEndVirtualListRef.current).resetAfterIndex) === null || _f === void 0 ? void 0 : _f.call(_e, 0);
|
|
69
|
-
}
|
|
70
|
-
lastKnownRowsLengthRef.current = rows.length;
|
|
71
|
-
}
|
|
72
|
-
}, [rows.length, areAllRowsLoaded, pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef]);
|
|
73
54
|
const handleCellClick = useCallback((rowIndex, columnId, event) => {
|
|
74
55
|
event.stopPropagation();
|
|
75
56
|
const cellKey = `${rowIndex}-${columnId}`;
|
|
@@ -112,17 +93,13 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
112
93
|
};
|
|
113
94
|
return (_jsx(InfiniteLoader, Object.assign({ isItemLoaded: (index) => index !== lastItemIndex, itemCount: tableItemsCount, loadMoreItems: handleOnLoadMoreItems, threshold: threshold }, { children: ({ onItemsRendered }) => (_jsx(AutoSizer, { children: ({ height, width }) => {
|
|
114
95
|
var _a;
|
|
115
|
-
containerHeightRef.current = height;
|
|
116
96
|
const getItemSize = (index) => {
|
|
117
|
-
console.log({ All: areAllRowsLoaded, rows, index
|
|
118
|
-
const currentHeight = height || containerHeightRef.current || 400;
|
|
97
|
+
console.log({ All: areAllRowsLoaded, rows, index });
|
|
119
98
|
const isLastRow = areAllRowsLoaded && index === rows.length;
|
|
120
|
-
if (isLastRow
|
|
99
|
+
if (isLastRow) {
|
|
121
100
|
const usedHeight = rows.length * rowHeight;
|
|
122
|
-
const remainingHeight =
|
|
123
|
-
|
|
124
|
-
console.log({ usedHeight, remainingHeight, calculatedHeight, currentHeight });
|
|
125
|
-
return calculatedHeight;
|
|
101
|
+
const remainingHeight = height - usedHeight;
|
|
102
|
+
return Math.max(remainingHeight, rowHeight);
|
|
126
103
|
}
|
|
127
104
|
return rowHeight;
|
|
128
105
|
};
|
|
@@ -146,8 +123,8 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
146
123
|
return (_jsx(StyledVirtualList, Object.assign({ listRef: listRef, height: height, width: fixedWidth || width, itemCount: tableItemsCount, itemSize: getItemSize, itemData: currentItemData, onItemsRendered: onItemsRendered, overscanCount: TABLE_LIST_OVER_SCAN, setBackdropVisibility: setShowBackdrop, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, useIsScrolling: true, onScroll: handleScrollCallback, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, style: {
|
|
147
124
|
overflowX: isPinned ? 'hidden' : 'auto',
|
|
148
125
|
paddingBottom: isPinned ? '25px' : '13px',
|
|
149
|
-
backgroundColor: isPinned ? 'transparent' :
|
|
150
|
-
} }, { children: ListItemWrapper })
|
|
126
|
+
backgroundColor: isPinned ? 'transparent' : '#F6F8FACC',
|
|
127
|
+
} }, { children: ListItemWrapper })));
|
|
151
128
|
} })) })));
|
|
152
129
|
}, [
|
|
153
130
|
itemsCount,
|
|
@@ -175,7 +152,6 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
175
152
|
pinnedStartVirtualListRef,
|
|
176
153
|
scrollableVirtualListRef,
|
|
177
154
|
theme.palette.background.default,
|
|
178
|
-
containerHeightRef,
|
|
179
155
|
]);
|
|
180
156
|
const showNoDataView = tableLoading || tableError || tableEmpty || hasTimeoutError;
|
|
181
157
|
const pinnedStartColumnsWidth = useMemo(() => pinnedStartColumnsData.reduce((acc, col) => {
|
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.0.283-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.0.283-test.4",
|
|
5
|
+
"testVersion": 4,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|