@tap-payments/os-micro-frontend-shared 0.1.134 → 0.1.135-test.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +12 -12
- package/build/components/BackgroundAnimation/BackgroundAnimation.js +28 -0
- package/build/components/BackgroundAnimation/Blob/Blob.js +2 -0
- package/build/components/Chip/style.js +1 -0
- package/build/components/ColorPicker/HexaFields.js +4 -0
- package/build/components/ColorPicker/style.js +1 -1
- package/build/components/Dialog/style.js +1 -0
- package/build/components/Dropdown2/style.js +2 -0
- package/build/components/HeatMap/constant.js +1 -1
- package/build/components/InputBase/AmountInputBase/CurrencyList/style.js +3 -0
- package/build/components/InputBase/PhoneInputBase/CountriesList/CountriesList.js +1 -1
- package/build/components/InputBase/PhoneInputBase/CountriesList/style.js +3 -0
- package/build/components/InputBase/SelectBase/SelectBase.js +1 -0
- package/build/components/InputBase/SelectBase/SelectBaseMultiple.js +3 -0
- package/build/components/InputBase/SelectBase/style.js +3 -2
- package/build/components/InputNumber/InputNumber.js +2 -0
- package/build/components/Inputs/Input/style.js +6 -2
- package/build/components/Inputs/Select/Select.js +1 -0
- package/build/components/Inputs/Select/style.js +3 -2
- package/build/components/JSONViewer/JSONViewer.js +10 -2
- package/build/components/JSONViewer/context/Provider.js +2 -0
- package/build/components/LeftPeekRightExpandingChip/LeftPeekRightExpandingChip.d.ts +10 -0
- package/build/components/LeftPeekRightExpandingChip/LeftPeekRightExpandingChip.js +14 -1
- package/build/components/LeftPeekRightExpandingChip/style.js +1 -0
- package/build/components/LeftPeekRightExpandingChip/useLeftPeekRightExpandingChip.js +30 -2
- package/build/components/MultiSelectStatusButton/MultiSelectStatusButton.js +3 -0
- package/build/components/NestedDropdown/Dropdown.js +3 -0
- package/build/components/RFH/Inputs/FormInput/FormInput.js +1 -0
- package/build/components/RFH/Inputs/MultiSelect/MultiSelect.js +1 -0
- package/build/components/RangeCalender/RangeCalender.js +1 -0
- package/build/components/RangeCalender/components/RangeDatepicker/RangeDatepicker.js +3 -1
- package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.d.ts +32 -0
- package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.js +36 -2
- package/build/components/RightLeftExpandingCenterChip/style.js +25 -4
- package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.d.ts +5 -0
- package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.js +53 -1
- package/build/components/ScrollLoader/ScrollLoader.js +2 -1
- package/build/components/StatusButton/StatusButton.js +11 -3
- package/build/components/StatusButton/constant.js +3 -1
- package/build/components/StatusButton/style.d.ts +2 -1
- package/build/components/StatusButton/type.d.ts +13 -1
- package/build/components/StatusIcons/AuthIcons/constants.js +5 -0
- package/build/components/StatusIcons/AuthorizationAutoIcons/CaptureAutoIcon.js +11 -0
- package/build/components/StatusIcons/AuthorizationAutoIcons/VoidAutoIcon.js +11 -0
- package/build/components/TableCells/CustomCells/ApplicationStatusCell/ApplicationStatusCell.js +3 -1
- package/build/components/TableCells/CustomCells/BrandCell/BrandCell.js +1 -0
- package/build/components/TableCells/CustomCells/ReferenceCell/ReferenceCell.js +3 -1
- package/build/components/TableCells/CustomCells/RefundStatusCell/components/RefundStateIcon.js +1 -0
- package/build/components/TableCells/CustomCells/SegmentsCell/SegmentsCell.js +3 -1
- package/build/components/TableCells/CustomCells/SourceMergedCell/SourceMergedCell.js +7 -1
- package/build/components/TableCells/CustomCells/StatusCell/StatusCell.js +1 -0
- package/build/components/TableView/CustomViews.js +2 -0
- package/build/components/TableView/TableView.js +1 -0
- package/build/components/Timepicker/Timepicker.js +1 -0
- package/build/components/Timepicker/utils.js +9 -5
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +46 -18
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableLoading.js +5 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/components/VirtualTable.js +6 -2
- 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/usePerformanceOptimizations.d.ts +19 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js +89 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePinnedColumns.js +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableData.js +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.js +3 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts +1 -23
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js +25 -21
- package/build/components/VirtualTables/SheetViewVirtualTable/style.js +1 -1
- package/build/components/VirtualTables/VirtualTable/VirtualTable.js +12 -2
- package/build/components/VirtualTables/VirtualTableWithCard/VirtualTableWithCard.js +6 -1
- package/build/components/VirtualTables/components/ColumnFilter/Inputs/Inputs.js +1 -0
- package/build/components/VirtualTables/components/TableFooter/TableFooter.js +9 -0
- package/build/components/VirtualTables/components/TableRow.js +25 -18
- package/build/components/VirtualTables/components/virtualScroll/ListItemWrapper.js +3 -1
- package/build/components/VirtualTables/components/virtualScroll/ListItemWrapperWithCard.js +2 -0
- package/build/components/VirtualTables/components/virtualScroll/VirtualScrollList.js +16 -1
- package/build/components/Widget/style.js +1 -0
- package/build/components/Window/style.js +1 -0
- package/build/components/index.d.ts +2 -1
- package/build/components/index.js +2 -1
- package/build/constants/assets.js +4 -0
- package/build/constants/server.js +1 -0
- package/build/constants/table.d.ts +1 -1
- package/build/constants/table.js +1 -1
- package/build/hooks/useCountdown.js +4 -0
- package/build/hooks/useStickyHeaderShadow.js +6 -0
- package/build/utils/api.js +3 -0
- package/build/utils/array.js +5 -1
- package/build/utils/billing.js +1 -0
- package/build/utils/country.js +1 -0
- package/build/utils/currency.js +6 -0
- package/build/utils/date.d.ts +5 -0
- package/build/utils/date.js +31 -3
- package/build/utils/encrypt.js +3 -1
- package/build/utils/error.js +2 -0
- package/build/utils/freshdesk.js +2 -0
- package/build/utils/geography.js +1 -1
- package/build/utils/localStorage.js +7 -0
- package/build/utils/merchant.js +3 -0
- package/build/utils/number.js +1 -0
- package/build/utils/segment.js +1 -0
- package/build/utils/string.d.ts +7 -0
- package/build/utils/string.js +10 -0
- package/build/utils/style.d.ts +13 -2
- package/build/utils/style.js +30 -2
- package/build/utils/table.js +1 -1
- package/build/utils/url.js +2 -0
- package/package.json +3 -3
|
@@ -38,7 +38,9 @@ function SegmentsCell(_a) {
|
|
|
38
38
|
}, borderColor: "transparent" })) })) }), `${segment.name}-${index}`));
|
|
39
39
|
}), [segments, isTextShown, theme]);
|
|
40
40
|
const referenceSourcesCount = (ReferenceSources === null || ReferenceSources === void 0 ? void 0 : ReferenceSources.length) || 0;
|
|
41
|
-
return (_jsx(TableCell, Object.assign({}, props, { children: _jsx(StyledSourceCell, { children: referenceSourcesCount > 0 ? (_jsx(ReferenceSourcesContainer, Object.assign({ layout: true, className: "reference-sources-container", whileHover: "animate",
|
|
41
|
+
return (_jsx(TableCell, Object.assign({}, props, { children: _jsx(StyledSourceCell, { children: referenceSourcesCount > 0 ? (_jsx(ReferenceSourcesContainer, Object.assign({ layout: true, className: "reference-sources-container", whileHover: "animate",
|
|
42
|
+
// animate when state changes
|
|
43
|
+
animate: isTooltipOpen ? 'animate' : 'start', sourcesCount: referenceSourcesCount, variants: { animate: { width: referenceSourcesCount * (6 + 32) } }, style: {
|
|
42
44
|
zIndex: 29,
|
|
43
45
|
} }, { children: ReferenceSources }))) : null }) })));
|
|
44
46
|
}
|
|
@@ -20,19 +20,24 @@ function SourceMergedCell(_a) {
|
|
|
20
20
|
const iconsList = useMemo(() => icons.filter((icon) => Boolean(icon.icon)), [icons]);
|
|
21
21
|
const [isHovering, setIsHovering] = useState(false);
|
|
22
22
|
const centerIconIndex = Math.max(centerIconKey ? iconsList.findIndex((icon) => icon.key === centerIconKey) : 0, 0);
|
|
23
|
+
// Create refs for each icon to measure their actual widths
|
|
23
24
|
const iconRefs = useRef([]);
|
|
24
25
|
const [iconMeasurements, setIconMeasurements] = useState(new Map());
|
|
26
|
+
// For sheet mode, always show all icons inline
|
|
25
27
|
const isSheetMode = tableMode === 'sheet';
|
|
28
|
+
// Measure icons after render and on table mode change
|
|
26
29
|
useEffect(() => {
|
|
27
30
|
if (isSheetMode)
|
|
28
|
-
return;
|
|
31
|
+
return; // Skip measurements for sheet mode as we don't need hover animations
|
|
29
32
|
setTimeout(() => {
|
|
30
33
|
const tableMode = isTextShown ? 'text' : 'default';
|
|
31
34
|
const newMeasurements = new Map();
|
|
32
35
|
iconRefs.current.forEach((ref, index) => {
|
|
33
36
|
if (ref) {
|
|
34
37
|
const width = ref.getBoundingClientRect().width;
|
|
38
|
+
// Get existing measurements or create new
|
|
35
39
|
const existingMeasurement = iconMeasurements.get(index) || { default: 0, text: 0 };
|
|
40
|
+
// Update only the current table mode's measurement
|
|
36
41
|
newMeasurements.set(index, Object.assign(Object.assign({}, existingMeasurement), { [tableMode]: width }));
|
|
37
42
|
}
|
|
38
43
|
});
|
|
@@ -59,6 +64,7 @@ function SourceMergedCell(_a) {
|
|
|
59
64
|
if (!icon)
|
|
60
65
|
return;
|
|
61
66
|
const tableMode = isTextShown ? 'text' : 'default';
|
|
67
|
+
// To keep x position of each icon while hovering consistent
|
|
62
68
|
const xHoverPosition = getIconXTranslation({
|
|
63
69
|
iconsList: iconsList.map((iconObj, i) => {
|
|
64
70
|
const measurements = iconMeasurements.get(i);
|
|
@@ -28,6 +28,7 @@ function StatusCell(_a) {
|
|
|
28
28
|
} }, { children: _jsx(StatusContainer, Object.assign({ initial: "initial", whileHover: "hover", animate: "start" }, { children: statusesList.map((status, index) => {
|
|
29
29
|
if (!status)
|
|
30
30
|
return;
|
|
31
|
+
// To keep x position of each icon while hovering consistent
|
|
31
32
|
const xHoverPosition = (index - centerIconIndex) * xGapValue;
|
|
32
33
|
const isIconAfterCenterIcon = index > centerIconIndex;
|
|
33
34
|
const isIconBeforeCenterIcon = index < centerIconIndex;
|
|
@@ -6,6 +6,7 @@ import { Reorder } from 'framer-motion';
|
|
|
6
6
|
import Box from '@mui/material/Box';
|
|
7
7
|
import Menu from '@mui/material/Menu';
|
|
8
8
|
import { useTheme } from '@mui/material/styles';
|
|
9
|
+
// import MenuItem from '@components/NestedDropdown/MenuItem'
|
|
9
10
|
import { downArrowIcon } from '../../constants/index.js';
|
|
10
11
|
import { ButtonStyled, ListStyled, DropdownStyled } from './style';
|
|
11
12
|
import { NestedMenuItem as MenuItem } from '../NestedDropdown';
|
|
@@ -52,6 +53,7 @@ function CustomViews({ open, onSelect, setTableViews: setColumns, tableViews, an
|
|
|
52
53
|
setColumns === null || setColumns === void 0 ? void 0 : setColumns(newMenuItems || []);
|
|
53
54
|
}, onSelect: (selectedChild, parentName) => {
|
|
54
55
|
handleUnSelectColumn(selectedChild[0]);
|
|
56
|
+
// modifySelectedColumns(selectedChild)
|
|
55
57
|
const newMenuItems = columns === null || columns === void 0 ? void 0 : columns.map((menuItem) => {
|
|
56
58
|
var _a;
|
|
57
59
|
if (menuItem.name === parentName) {
|
|
@@ -29,6 +29,7 @@ function TableView({ onViewChange, setIsViewVisible, setTableViews, tableViews,
|
|
|
29
29
|
const onClose = () => {
|
|
30
30
|
setAnchorViewEl(null);
|
|
31
31
|
setIsViewVisible(false);
|
|
32
|
+
// to be removed
|
|
32
33
|
setSelectedViewInfo({ label: 'Default', id: 'default' });
|
|
33
34
|
};
|
|
34
35
|
const handleSelectedViewInfo = (selected) => {
|
|
@@ -25,6 +25,7 @@ export function TimePicker({ onChange, defaultTime, enableRealTimeChange }) {
|
|
|
25
25
|
};
|
|
26
26
|
const onClose = () => {
|
|
27
27
|
setAnchorEl(null);
|
|
28
|
+
// Return the 12-hour format with period to match the Time type
|
|
28
29
|
onChange === null || onChange === void 0 ? void 0 : onChange({ hour: hours, minute: minutes, period: period });
|
|
29
30
|
};
|
|
30
31
|
const onClickPeriod = (selectedPeriod) => {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
// Convert 24-hour format to 12-hour format properly
|
|
1
2
|
export const convertTo12Hour = (hour24) => {
|
|
2
3
|
if (hour24 === 0)
|
|
3
|
-
return 12;
|
|
4
|
+
return 12; // Midnight (0) becomes 12 AM
|
|
4
5
|
if (hour24 <= 12)
|
|
5
|
-
return hour24;
|
|
6
|
-
return hour24 - 12;
|
|
6
|
+
return hour24; // 1-12 stays the same
|
|
7
|
+
return hour24 - 12; // 13-23 becomes 1-11
|
|
7
8
|
};
|
|
9
|
+
// Get the period (AM/PM) from 24-hour format
|
|
8
10
|
export const getPeriodFrom24Hour = (hour24) => {
|
|
9
11
|
return hour24 >= 12 ? 'PM' : 'AM';
|
|
10
12
|
};
|
|
@@ -13,12 +15,14 @@ export const getDefaultHour = () => {
|
|
|
13
15
|
const currentHour = new Date().getHours();
|
|
14
16
|
return convertTo12Hour(currentHour);
|
|
15
17
|
};
|
|
18
|
+
// Convert 12-hour format back to 24-hour format correctly
|
|
16
19
|
export const convertTo24Hour = (hour12, period) => {
|
|
17
20
|
if (period === 'AM' && hour12 === 12) {
|
|
18
|
-
return 0;
|
|
21
|
+
return 0; // 12 AM = 0 hours
|
|
19
22
|
}
|
|
20
23
|
else if (period === 'PM' && hour12 !== 12) {
|
|
21
|
-
return hour12 + 12;
|
|
24
|
+
return hour12 + 12; // 1-11 PM = 13-23 hours
|
|
22
25
|
}
|
|
26
|
+
// 12 PM stays as 12 hours, 1-11 AM stays the same
|
|
23
27
|
return hour12;
|
|
24
28
|
};
|
|
@@ -1,13 +1,17 @@
|
|
|
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 } 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, usePinnedColumnsWidths } from './hooks';
|
|
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
|
+
// Performance optimizations
|
|
11
|
+
const { stableColumns, stableFilters } = usePerformanceOptimizations(columns);
|
|
12
|
+
// Custom hooks for state management
|
|
10
13
|
const { selectedCell, selectedColumn, selectedRow, showBackDrop, setShowBackdrop, handleCellClick, handleColumnClick, handleChipClick, selectedChip, } = useTableState();
|
|
14
|
+
// Table data processing
|
|
11
15
|
const { isError, tableLoading, tableError, tableEmpty, hasTimeoutError, showNoDataView, lastItemIndex, areTotalRowsNotFillingHeight, itemsCount, isDelayedFetchingNextPage, } = useTableData({
|
|
12
16
|
rows,
|
|
13
17
|
isLoading,
|
|
@@ -15,9 +19,13 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
15
19
|
isFetchingNextPage,
|
|
16
20
|
areAllRowsLoaded,
|
|
17
21
|
});
|
|
18
|
-
|
|
22
|
+
// Column management
|
|
23
|
+
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(stableColumns, isPinnable, onColumnPin);
|
|
24
|
+
// Scroll synchronization
|
|
19
25
|
const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
|
|
26
|
+
// Column width calculations
|
|
20
27
|
const { pinnedStartColumnsWidth, pinnedEndColumnsWidth } = usePinnedColumnsWidths(pinnedStartColumnsData, pinnedEndColumnsData);
|
|
28
|
+
// Virtual table container logic
|
|
21
29
|
const { getItemSize, getItemDataForContainer } = useVirtualTableContainer({
|
|
22
30
|
rowHeight,
|
|
23
31
|
areAllRowsLoaded,
|
|
@@ -34,6 +42,33 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
34
42
|
handleCellClick,
|
|
35
43
|
handleChipClick,
|
|
36
44
|
});
|
|
45
|
+
// Memoized header props to prevent unnecessary re-renders when filters change
|
|
46
|
+
const memoizedHeaderProps = useMemo(() => ({
|
|
47
|
+
showHeader,
|
|
48
|
+
columnsSorting,
|
|
49
|
+
onColumnSort,
|
|
50
|
+
headerProps,
|
|
51
|
+
showBackDrop,
|
|
52
|
+
onColumnPin: handleColumnPin,
|
|
53
|
+
isPinnable,
|
|
54
|
+
lastColumnId,
|
|
55
|
+
selectedColumn,
|
|
56
|
+
onColumnClick: handleColumnClick,
|
|
57
|
+
// Force re-render only when filters actually change
|
|
58
|
+
filtersKey: Object.keys(stableFilters).length > 0 ? JSON.stringify(stableFilters) : null,
|
|
59
|
+
}), [
|
|
60
|
+
showHeader,
|
|
61
|
+
columnsSorting,
|
|
62
|
+
onColumnSort,
|
|
63
|
+
headerProps,
|
|
64
|
+
showBackDrop,
|
|
65
|
+
handleColumnPin,
|
|
66
|
+
isPinnable,
|
|
67
|
+
lastColumnId,
|
|
68
|
+
selectedColumn,
|
|
69
|
+
handleColumnClick,
|
|
70
|
+
stableFilters,
|
|
71
|
+
]);
|
|
37
72
|
const onPointerDown = (e) => {
|
|
38
73
|
dragControls === null || dragControls === void 0 ? void 0 : dragControls.start(e);
|
|
39
74
|
};
|
|
@@ -57,22 +92,12 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
57
92
|
clearBackdropVisibilityTimeout,
|
|
58
93
|
handleScroll,
|
|
59
94
|
setShowBackdrop,
|
|
95
|
+
overscanCount,
|
|
60
96
|
pinnedStartVirtualListRef,
|
|
61
97
|
pinnedEndVirtualListRef,
|
|
62
98
|
scrollableVirtualListRef,
|
|
63
99
|
]);
|
|
64
|
-
const baseCommonProps = {
|
|
65
|
-
showHeader,
|
|
66
|
-
columnsSorting,
|
|
67
|
-
onColumnSort,
|
|
68
|
-
headerProps,
|
|
69
|
-
showBackDrop,
|
|
70
|
-
onColumnPin: handleColumnPin,
|
|
71
|
-
isPinnable,
|
|
72
|
-
lastColumnId,
|
|
73
|
-
selectedColumn,
|
|
74
|
-
onColumnClick: handleColumnClick,
|
|
75
|
-
tableTitle,
|
|
100
|
+
const baseCommonProps = Object.assign(Object.assign({}, memoizedHeaderProps), { tableTitle,
|
|
76
101
|
areAllRowsLoaded,
|
|
77
102
|
isFetchingNextPage,
|
|
78
103
|
scrollToIndex,
|
|
@@ -80,10 +105,13 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
80
105
|
isError,
|
|
81
106
|
tableMode,
|
|
82
107
|
showNoDataView,
|
|
83
|
-
tableBodyStyles
|
|
84
|
-
};
|
|
108
|
+
tableBodyStyles });
|
|
85
109
|
const commonPropsWithTableStates = Object.assign(Object.assign({}, baseCommonProps), { hasTimeoutError,
|
|
86
110
|
tableLoading });
|
|
87
|
-
return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (
|
|
111
|
+
return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (
|
|
112
|
+
// Show same table structure with pinned columns during loading, but with skeleton rows
|
|
113
|
+
_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsData.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "start", columnsData: pinnedStartColumnsData, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates))), _jsx(LoadingMainTable, Object.assign({ hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, unpinnedColumnsData: unpinnedColumnsData, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns }, commonPropsWithTableStates)), pinnedEndColumnsData.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "end", columnsData: pinnedEndColumnsData, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates)))] })) : (
|
|
114
|
+
// Non-loading error states
|
|
115
|
+
_jsx(NoDataView, Object.assign({ tableLoading: tableLoading, tableError: tableError, tableEmpty: tableEmpty, hasTimeoutError: hasTimeoutError, orderedColumns: orderedColumns, error: error, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps }, baseCommonProps)))) : (_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsData.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "start", columnsData: pinnedStartColumnsData, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates))), _jsx(MainTable, Object.assign({ hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, unpinnedColumnsData: unpinnedColumnsData, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates)), pinnedEndColumnsData.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "end", columnsData: pinnedEndColumnsData, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates)))] })) }), _jsx(TableFooter, Object.assign({ "data-testid": "SheetViewVirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps))] }));
|
|
88
116
|
}
|
|
89
117
|
export default memo(SheetViewVirtualTable);
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js
CHANGED
|
@@ -28,11 +28,13 @@ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, so
|
|
|
28
28
|
setColumnFilterEl(cellRef.current);
|
|
29
29
|
};
|
|
30
30
|
const handleCellClick = (event) => {
|
|
31
|
+
// Only fire column click when clicking on the cell itself, not on child elements
|
|
31
32
|
if (event.target === event.currentTarget) {
|
|
32
33
|
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, event, pinned);
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
const handleHeaderInnerClick = (event) => {
|
|
37
|
+
// Prevent event bubbling to parent cell
|
|
36
38
|
event.stopPropagation();
|
|
37
39
|
onOpenFilterDropdown();
|
|
38
40
|
};
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableLoading.js
CHANGED
|
@@ -16,6 +16,7 @@ const Wrapper = styled('section')(({ isLoaded = false, isPinned = false }) => ({
|
|
|
16
16
|
}));
|
|
17
17
|
function SheetViewTableLoading({ columns, isLoaded = false, animationType, isLoading = false, rowsCount = 13, isPinned = false, }) {
|
|
18
18
|
const [maxAllowedRows, setMaxAllowedRows] = useState(() => {
|
|
19
|
+
// Use provided rowsCount or calculate initial value
|
|
19
20
|
return rowsCount || Math.min(calculateMaxAllowedRows(isLoaded, isLoading), 15);
|
|
20
21
|
});
|
|
21
22
|
useEffect(() => {
|
|
@@ -23,6 +24,7 @@ function SheetViewTableLoading({ columns, isLoaded = false, animationType, isLoa
|
|
|
23
24
|
setMaxAllowedRows(rowsCount);
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
27
|
+
// Calculate rows that fit in the available container height
|
|
26
28
|
const calculateRowsForContainer = () => {
|
|
27
29
|
var _a;
|
|
28
30
|
const wrapperElement = document.querySelector('[data-testid="SheetViewTableLoading"]');
|
|
@@ -30,13 +32,14 @@ function SheetViewTableLoading({ columns, isLoaded = false, animationType, isLoa
|
|
|
30
32
|
return Math.min(calculateMaxAllowedRows(isLoaded, isLoading), 25);
|
|
31
33
|
}
|
|
32
34
|
const containerHeight = ((_a = wrapperElement.parentElement) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0;
|
|
33
|
-
const rowHeight = SHEET_VIEW_TABLE_ROW_HEIGHT;
|
|
34
|
-
const headerHeight = 40;
|
|
35
|
+
const rowHeight = SHEET_VIEW_TABLE_ROW_HEIGHT; // Standard row height for SheetView
|
|
36
|
+
const headerHeight = 40; // Approximate header height
|
|
35
37
|
const availableHeight = containerHeight - headerHeight;
|
|
36
38
|
if (availableHeight <= 0) {
|
|
37
39
|
return Math.min(calculateMaxAllowedRows(isLoaded, isLoading), 25);
|
|
38
40
|
}
|
|
39
41
|
const calculatedRows = Math.floor(availableHeight / rowHeight);
|
|
42
|
+
// Ensure we have at least 3 rows for loading state, but cap at a reasonable maximum
|
|
40
43
|
return Math.max(3, Math.min(calculatedRows + 2, 25));
|
|
41
44
|
};
|
|
42
45
|
const rows = calculateRowsForContainer();
|
|
@@ -20,10 +20,14 @@ function VirtualTable({ columnsData, itemCount, lastItemIndex, areAllRowsLoaded,
|
|
|
20
20
|
return;
|
|
21
21
|
yield (loadMoreItems === null || loadMoreItems === void 0 ? void 0 : loadMoreItems());
|
|
22
22
|
});
|
|
23
|
-
return (
|
|
23
|
+
return (
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
_jsx(InfiniteLoader, Object.assign({ isItemLoaded: (index) => index !== lastItemIndex, itemCount: itemCount, loadMoreItems: handleOnLoadMoreItems, threshold: threshold }, { children: ({ onItemsRendered, ref }) => (_jsx(AutoSizer, Object.assign({ ref: ref }, { children: ({ height, width }) => {
|
|
24
26
|
const itemSize = (index) => getItemSize(index, height);
|
|
25
27
|
const itemData = getItemData(columnsData, isPinned, height);
|
|
26
|
-
return (
|
|
28
|
+
return (
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
_jsx(StyledVirtualList, Object.assign({ listRef: listRef, height: height, width: fixedWidth || width, itemCount: itemCount, itemSize: itemSize, itemData: itemData, onItemsRendered: onItemsRendered, overscanCount: overscanCount, setBackdropVisibility: setBackdropVisibility, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, useIsScrolling: true, onScroll: onScroll, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, style: {
|
|
27
31
|
overflowX: isPinned ? 'hidden' : 'auto',
|
|
28
32
|
paddingBottom: isPinned ? '25px' : '13px',
|
|
29
33
|
backgroundColor: isPinned ? 'transparent' : '#F6F8FACC',
|
|
@@ -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 { usePerformanceOptimizations } from './usePerformanceOptimizations';
|
|
@@ -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 { usePerformanceOptimizations } from './usePerformanceOptimizations';
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IColumnProps } from '../../../../types/index.js';
|
|
2
|
+
interface StableFilterData {
|
|
3
|
+
type: string;
|
|
4
|
+
data?: unknown;
|
|
5
|
+
options?: unknown;
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const usePerformanceOptimizations: (columns: readonly IColumnProps[]) => {
|
|
9
|
+
stableColumns: IColumnProps<any>[];
|
|
10
|
+
stableFilters: Record<string, StableFilterData>;
|
|
11
|
+
columnMetrics: {
|
|
12
|
+
visibleColumns: IColumnProps<any>[];
|
|
13
|
+
totalWidth: number;
|
|
14
|
+
columnCount: number;
|
|
15
|
+
firstColumnId: string | number | symbol;
|
|
16
|
+
lastColumnId: string | number | symbol;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export {};
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useMemo, useRef } from 'react';
|
|
2
|
+
export const usePerformanceOptimizations = (columns) => {
|
|
3
|
+
// Create stable column references to prevent unnecessary re-renders
|
|
4
|
+
const stableColumnsRef = useRef([]);
|
|
5
|
+
// Create stable filter references to prevent unnecessary header re-renders
|
|
6
|
+
const stableFiltersRef = useRef({});
|
|
7
|
+
const stableColumns = useMemo(() => {
|
|
8
|
+
// Only update if columns have actually changed (deep comparison of essential properties)
|
|
9
|
+
const hasChanged = columns.length !== stableColumnsRef.current.length ||
|
|
10
|
+
columns.some((col, index) => {
|
|
11
|
+
const prevCol = stableColumnsRef.current[index];
|
|
12
|
+
return (!prevCol ||
|
|
13
|
+
col.id !== prevCol.id ||
|
|
14
|
+
col.width !== prevCol.width ||
|
|
15
|
+
col.pinned !== prevCol.pinned ||
|
|
16
|
+
col.hidden !== prevCol.hidden ||
|
|
17
|
+
col.order !== prevCol.order);
|
|
18
|
+
});
|
|
19
|
+
if (hasChanged) {
|
|
20
|
+
stableColumnsRef.current = [...columns];
|
|
21
|
+
}
|
|
22
|
+
return stableColumnsRef.current;
|
|
23
|
+
}, [columns]);
|
|
24
|
+
const stableFilters = useMemo(() => {
|
|
25
|
+
// Extract filter-related data from columns for header rendering optimization
|
|
26
|
+
const currentFilters = {};
|
|
27
|
+
columns.forEach((col) => {
|
|
28
|
+
if (col.filter && col.id) {
|
|
29
|
+
const columnId = col.id;
|
|
30
|
+
const filterData = {
|
|
31
|
+
type: col.filter.type,
|
|
32
|
+
data: col.filter.data,
|
|
33
|
+
options: col.filter.options,
|
|
34
|
+
};
|
|
35
|
+
// Only add apiKey if it exists (for 'list' type filters)
|
|
36
|
+
if (col.filter.type === 'list') {
|
|
37
|
+
filterData.apiKey = col.filter.apiKey;
|
|
38
|
+
}
|
|
39
|
+
currentFilters[columnId] = filterData;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
// Deep comparison of filter state
|
|
43
|
+
const hasFilterChanged = () => {
|
|
44
|
+
const currentKeys = Object.keys(currentFilters);
|
|
45
|
+
const prevKeys = Object.keys(stableFiltersRef.current);
|
|
46
|
+
if (currentKeys.length !== prevKeys.length)
|
|
47
|
+
return true;
|
|
48
|
+
return currentKeys.some((key) => {
|
|
49
|
+
const current = currentFilters[key];
|
|
50
|
+
const prev = stableFiltersRef.current[key];
|
|
51
|
+
if (!prev)
|
|
52
|
+
return true;
|
|
53
|
+
// Compare filter properties that affect rendering
|
|
54
|
+
if (current.type !== prev.type || current.apiKey !== prev.apiKey)
|
|
55
|
+
return true;
|
|
56
|
+
// Deep compare options array
|
|
57
|
+
if (JSON.stringify(current.options) !== JSON.stringify(prev.options))
|
|
58
|
+
return true;
|
|
59
|
+
// Deep compare filter data
|
|
60
|
+
if (JSON.stringify(current.data) !== JSON.stringify(prev.data))
|
|
61
|
+
return true;
|
|
62
|
+
return false;
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
if (hasFilterChanged()) {
|
|
66
|
+
stableFiltersRef.current = Object.assign({}, currentFilters);
|
|
67
|
+
}
|
|
68
|
+
return stableFiltersRef.current;
|
|
69
|
+
}, [columns]);
|
|
70
|
+
// Memoize frequently used column calculations
|
|
71
|
+
const columnMetrics = useMemo(() => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
const visibleColumns = stableColumns.filter((col) => !col.hidden);
|
|
74
|
+
const totalWidth = visibleColumns.reduce((sum, col) => sum + +((col === null || col === void 0 ? void 0 : col.width) || 100), 0);
|
|
75
|
+
const columnCount = visibleColumns.length;
|
|
76
|
+
return {
|
|
77
|
+
visibleColumns,
|
|
78
|
+
totalWidth,
|
|
79
|
+
columnCount,
|
|
80
|
+
firstColumnId: (_a = visibleColumns[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
81
|
+
lastColumnId: (_b = visibleColumns[columnCount - 1]) === null || _b === void 0 ? void 0 : _b.id,
|
|
82
|
+
};
|
|
83
|
+
}, [stableColumns]);
|
|
84
|
+
return {
|
|
85
|
+
stableColumns,
|
|
86
|
+
stableFilters,
|
|
87
|
+
columnMetrics,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
@@ -9,6 +9,7 @@ export const usePinnedColumns = (columns, isPinnable, onColumnPin) => {
|
|
|
9
9
|
if (!isPinnable)
|
|
10
10
|
return [];
|
|
11
11
|
const userPinned = columns.filter((c) => c.pinned === 'end').map((c) => c.id);
|
|
12
|
+
// Automatically pin the last column to the end if no end-pinned columns exist
|
|
12
13
|
const visibleColumns = columns.filter((column) => !column.hidden);
|
|
13
14
|
const lastColumn = visibleColumns[visibleColumns.length - 1];
|
|
14
15
|
if (userPinned.length === 0 && lastColumn && !lastColumn.pinned && !lastColumn.isDefaultPinned) {
|
|
@@ -43,6 +44,7 @@ export const usePinnedColumns = (columns, isPinnable, onColumnPin) => {
|
|
|
43
44
|
const start = shownColumns.filter((column) => pinnedStartColumns.includes(column.id));
|
|
44
45
|
const end = shownColumns.filter((column) => pinnedEndColumns.includes(column.id));
|
|
45
46
|
const unpinned = shownColumns.filter((column) => !pinnedStartColumns.includes(column.id) && !pinnedEndColumns.includes(column.id));
|
|
47
|
+
// Sort arrays by order and preserve original column properties including width
|
|
46
48
|
const sortedStart = start.sort((a, b) => { var _a, _b; return ((_a = a === null || a === void 0 ? void 0 : a.order) !== null && _a !== void 0 ? _a : 1000000) - ((_b = b === null || b === void 0 ? void 0 : b.order) !== null && _b !== void 0 ? _b : 1000000); });
|
|
47
49
|
const sortedEnd = end.sort((a, b) => { var _a, _b; return ((_a = a === null || a === void 0 ? void 0 : a.order) !== null && _a !== void 0 ? _a : 1000000) - ((_b = b === null || b === void 0 ? void 0 : b.order) !== null && _b !== void 0 ? _b : 1000000); });
|
|
48
50
|
const sortedUnpinned = unpinned.sort((a, b) => { var _a, _b; return ((_a = a === null || a === void 0 ? void 0 : a.order) !== null && _a !== void 0 ? _a : 1000000) - ((_b = b === null || b === void 0 ? void 0 : b.order) !== null && _b !== void 0 ? _b : 1000000); });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useDelayToSetValue } from '../../../../hooks/index.js';
|
|
3
3
|
import { isHeightNotFullyFilledByRows, isNotFoundError, isTimeoutError, hasError } from '../../../../utils/index.js';
|
|
4
|
+
// Type guard to check if error is AxiosError
|
|
4
5
|
const isAxiosError = (error) => {
|
|
5
6
|
return error !== null && 'isAxiosError' in error && error.isAxiosError === true;
|
|
6
7
|
};
|
|
@@ -17,10 +17,12 @@ export const useTableState = () => {
|
|
|
17
17
|
}
|
|
18
18
|
setSelectedChip(chipKey);
|
|
19
19
|
setSelectedCell(cellKey);
|
|
20
|
+
setSelectedColumn(null);
|
|
20
21
|
setSelectedRow(null);
|
|
21
22
|
}, [selectedChip, setSelectedChip, setSelectedCell, setSelectedRow]);
|
|
22
23
|
const handleCellClick = useCallback((rowIndex, columnIndex, event, pinnedType) => {
|
|
23
24
|
event.stopPropagation();
|
|
25
|
+
// If clicking on any cell in the pinned start section, select the entire row
|
|
24
26
|
if (pinnedType === 'start' && columnIndex === 0) {
|
|
25
27
|
setSelectedRow((prev) => (prev === rowIndex ? null : rowIndex));
|
|
26
28
|
setSelectedCell(null);
|
|
@@ -28,6 +30,7 @@ export const useTableState = () => {
|
|
|
28
30
|
setSelectedChip(null);
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
33
|
+
// Otherwise, handle normal cell selection
|
|
31
34
|
const cellKey = `${pinnedType !== null && pinnedType !== void 0 ? pinnedType : 'default'}-${rowIndex}-${columnIndex}`;
|
|
32
35
|
setSelectedCell((prev) => (prev === cellKey ? null : cellKey));
|
|
33
36
|
setSelectedColumn(null);
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts
CHANGED
|
@@ -23,28 +23,6 @@ interface UseVirtualTableContainerProps<T = unknown> extends TableChipProps {
|
|
|
23
23
|
}
|
|
24
24
|
export declare const useVirtualTableContainer: <T = unknown>({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick, }: UseVirtualTableContainerProps<T>) => {
|
|
25
25
|
getItemSize: (index: number, height: number) => number;
|
|
26
|
-
getItemDataForContainer: (columnsData: IColumnProps[], isPinnedColumn: boolean, height: number) =>
|
|
27
|
-
columns: any;
|
|
28
|
-
isLoading: any;
|
|
29
|
-
rows: any;
|
|
30
|
-
rowProps: any;
|
|
31
|
-
scrollToIndex: any;
|
|
32
|
-
totalCount: any;
|
|
33
|
-
lastItemIndex: any;
|
|
34
|
-
isError: any;
|
|
35
|
-
areAllRowsLoaded: any;
|
|
36
|
-
limit: any;
|
|
37
|
-
newLoadedRowsEndIndex: any;
|
|
38
|
-
isSheetView: boolean;
|
|
39
|
-
isPinned: any;
|
|
40
|
-
selectedCell: any;
|
|
41
|
-
selectedColumn: any;
|
|
42
|
-
selectedRow: any;
|
|
43
|
-
selectedChip: any;
|
|
44
|
-
onCellClick: any;
|
|
45
|
-
onChipClick: any;
|
|
46
|
-
containerHeight: any;
|
|
47
|
-
rowHeight: any;
|
|
48
|
-
};
|
|
26
|
+
getItemDataForContainer: (columnsData: IColumnProps[], isPinnedColumn: boolean, height: number) => any;
|
|
49
27
|
};
|
|
50
28
|
export {};
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
|
2
2
|
import memoize from 'memoize-one';
|
|
3
|
-
const
|
|
3
|
+
const createCoreItemData = memoize((columns, rows, rowProps, totalCount, lastItemIndex, isError, areAllRowsLoaded, isPinned, containerHeight, rowHeight) => ({
|
|
4
4
|
columns,
|
|
5
|
-
isLoading,
|
|
6
5
|
rows,
|
|
7
6
|
rowProps,
|
|
8
|
-
scrollToIndex,
|
|
9
7
|
totalCount,
|
|
10
8
|
lastItemIndex,
|
|
11
9
|
isError,
|
|
@@ -14,41 +12,47 @@ const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToInde
|
|
|
14
12
|
newLoadedRowsEndIndex: lastItemIndex,
|
|
15
13
|
isSheetView: true,
|
|
16
14
|
isPinned,
|
|
15
|
+
containerHeight,
|
|
16
|
+
rowHeight,
|
|
17
|
+
}));
|
|
18
|
+
const createInteractionData = memoize((selectedCell, selectedColumn, selectedRow, selectedChip, onCellClick, onChipClick) => ({
|
|
17
19
|
selectedCell,
|
|
18
20
|
selectedColumn,
|
|
19
21
|
selectedRow,
|
|
20
22
|
selectedChip,
|
|
21
23
|
onCellClick,
|
|
22
24
|
onChipClick,
|
|
23
|
-
containerHeight,
|
|
24
|
-
rowHeight,
|
|
25
25
|
}));
|
|
26
|
+
// eslint-disable-next-line
|
|
27
|
+
const createItemData = (coreData, interactionData, scrollToIndex, isLoading) => (Object.assign(Object.assign(Object.assign({}, coreData), interactionData), { scrollToIndex,
|
|
28
|
+
isLoading }));
|
|
26
29
|
export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick, }) => {
|
|
27
30
|
const getItemSize = useCallback((index, height) => {
|
|
28
31
|
const isLastRow = areAllRowsLoaded && index === rows.length;
|
|
29
32
|
if (isLastRow) {
|
|
33
|
+
// Calculate remaining height: total height - (number of data rows * row height)
|
|
30
34
|
const usedHeight = rows.length * rowHeight;
|
|
31
35
|
const remainingHeight = height - usedHeight;
|
|
32
|
-
const minimumLastRowHeight = rowHeight * 2;
|
|
33
|
-
return Math.max(remainingHeight, minimumLastRowHeight);
|
|
36
|
+
const minimumLastRowHeight = rowHeight * 2; // Minimum height is 2x rowHeight
|
|
37
|
+
return Math.max(remainingHeight, minimumLastRowHeight); // Ensure minimum 2x row height
|
|
34
38
|
}
|
|
35
39
|
return rowHeight;
|
|
36
40
|
}, [areAllRowsLoaded, rows.length, rowHeight]);
|
|
37
|
-
|
|
41
|
+
// Memoize core data that changes less frequently
|
|
42
|
+
const coreItemData = useMemo(() => {
|
|
38
43
|
var _a;
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => createItemData(columnsData, ...commonItemDataParams, isPinnedColumn, ...commonItemDataSuffix, height, rowHeight), [commonItemDataParams, commonItemDataSuffix, rowHeight]);
|
|
44
|
+
return createCoreItemData(null, // columns will be passed per container
|
|
45
|
+
rows, rowProps, (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0, rows.length - 1, // lastItemIndex
|
|
46
|
+
isError, areAllRowsLoaded, false, // isPinned will be passed per container
|
|
47
|
+
0, // height will be passed per container
|
|
48
|
+
rowHeight);
|
|
49
|
+
}, [rows, rowProps, footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount, isError, areAllRowsLoaded, rowHeight]);
|
|
50
|
+
// Memoize interaction data separately
|
|
51
|
+
const interactionData = useMemo(() => createInteractionData(selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick), [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick]);
|
|
52
|
+
const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => {
|
|
53
|
+
const coreWithOverrides = Object.assign(Object.assign({}, coreItemData), { columns: columnsData, isPinned: isPinnedColumn, containerHeight: height });
|
|
54
|
+
return createItemData(coreWithOverrides, interactionData, scrollToIndex, isDelayedFetchingNextPage);
|
|
55
|
+
}, [coreItemData, interactionData, scrollToIndex, isDelayedFetchingNextPage]);
|
|
52
56
|
return {
|
|
53
57
|
getItemSize,
|
|
54
58
|
getItemDataForContainer,
|
|
@@ -67,7 +67,7 @@ const PinnedColumnBase = styled('div')(({ theme }) => ({
|
|
|
67
67
|
backgroundColor: theme.palette.primary.light,
|
|
68
68
|
borderTop: '1px solid #F2F2F2',
|
|
69
69
|
borderBottom: '1px solid #F2F2F2',
|
|
70
|
-
overflow: 'hidden',
|
|
70
|
+
overflow: 'hidden', // Ensure border radius is applied properly
|
|
71
71
|
}));
|
|
72
72
|
export const PinnedStartColumnWrapper = styled(PinnedColumnBase)({
|
|
73
73
|
boxShadow: '4px 0px 24px 0px #00000014',
|