@tap-payments/os-micro-frontend-shared 0.1.135 → 0.1.136-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/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 +16 -3
- 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 +11 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js +107 -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 +8 -2
- package/build/components/index.js +11 -2
- 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
|
};
|
|
@@ -4,10 +4,14 @@ 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 } = 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,
|
|
@@ -57,6 +65,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
57
65
|
clearBackdropVisibilityTimeout,
|
|
58
66
|
handleScroll,
|
|
59
67
|
setShowBackdrop,
|
|
68
|
+
overscanCount,
|
|
60
69
|
pinnedStartVirtualListRef,
|
|
61
70
|
pinnedEndVirtualListRef,
|
|
62
71
|
scrollableVirtualListRef,
|
|
@@ -84,6 +93,10 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
84
93
|
};
|
|
85
94
|
const commonPropsWithTableStates = Object.assign(Object.assign({}, baseCommonProps), { hasTimeoutError,
|
|
86
95
|
tableLoading });
|
|
87
|
-
return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (
|
|
96
|
+
return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (
|
|
97
|
+
// Show same table structure with pinned columns during loading, but with skeleton rows
|
|
98
|
+
_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)))] })) : (
|
|
99
|
+
// Non-loading error states
|
|
100
|
+
_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
101
|
}
|
|
89
102
|
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,11 @@
|
|
|
1
|
+
import type { IColumnProps } from '../../../../types/index.js';
|
|
2
|
+
export declare const usePerformanceOptimizations: (columns: readonly IColumnProps[]) => {
|
|
3
|
+
stableColumns: IColumnProps<any>[];
|
|
4
|
+
columnMetrics: {
|
|
5
|
+
visibleColumns: IColumnProps<any>[];
|
|
6
|
+
totalWidth: number;
|
|
7
|
+
columnCount: number;
|
|
8
|
+
firstColumnId: string | number | symbol;
|
|
9
|
+
lastColumnId: string | number | symbol;
|
|
10
|
+
};
|
|
11
|
+
};
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useMemo, useRef } from 'react';
|
|
2
|
+
// Deep comparison helper for filter data
|
|
3
|
+
const areFilterDataEqual = (data1, data2) => {
|
|
4
|
+
if (data1 === data2)
|
|
5
|
+
return true;
|
|
6
|
+
if (!data1 || !data2)
|
|
7
|
+
return false;
|
|
8
|
+
const keys1 = Object.keys(data1);
|
|
9
|
+
const keys2 = Object.keys(data2);
|
|
10
|
+
if (keys1.length !== keys2.length)
|
|
11
|
+
return false;
|
|
12
|
+
return keys1.every((key) => {
|
|
13
|
+
const val1 = data1[key];
|
|
14
|
+
const val2 = data2[key];
|
|
15
|
+
if (Array.isArray(val1) && Array.isArray(val2)) {
|
|
16
|
+
return val1.length === val2.length && val1.every((v, i) => v === val2[i]);
|
|
17
|
+
}
|
|
18
|
+
if (typeof val1 === 'object' && typeof val2 === 'object' && val1 && val2) {
|
|
19
|
+
return JSON.stringify(val1) === JSON.stringify(val2);
|
|
20
|
+
}
|
|
21
|
+
return val1 === val2;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export const usePerformanceOptimizations = (columns) => {
|
|
25
|
+
// Create stable column references to prevent unnecessary re-renders
|
|
26
|
+
const stableColumnsRef = useRef([]);
|
|
27
|
+
const isFirstRenderRef = useRef(true);
|
|
28
|
+
const filterChangeTrackingRef = useRef(new Map());
|
|
29
|
+
const stableColumns = useMemo(() => {
|
|
30
|
+
// On first render, just initialize and return columns
|
|
31
|
+
if (isFirstRenderRef.current) {
|
|
32
|
+
isFirstRenderRef.current = false;
|
|
33
|
+
stableColumnsRef.current = [...columns];
|
|
34
|
+
// Initialize filter tracking
|
|
35
|
+
columns.forEach((col) => {
|
|
36
|
+
var _a;
|
|
37
|
+
filterChangeTrackingRef.current.set(col.id, (_a = col.filter) === null || _a === void 0 ? void 0 : _a.data);
|
|
38
|
+
});
|
|
39
|
+
return stableColumnsRef.current;
|
|
40
|
+
}
|
|
41
|
+
// After first render, only update if structural changes or filter changes occurred
|
|
42
|
+
const structurallyChanged = columns.length !== stableColumnsRef.current.length ||
|
|
43
|
+
columns.some((col, index) => {
|
|
44
|
+
const prevCol = stableColumnsRef.current[index];
|
|
45
|
+
console.log({ colFilter: col.filter, prevColFilter: prevCol === null || prevCol === void 0 ? void 0 : prevCol.filter });
|
|
46
|
+
return (!prevCol ||
|
|
47
|
+
col.id !== prevCol.id ||
|
|
48
|
+
col.width !== prevCol.width ||
|
|
49
|
+
col.pinned !== prevCol.pinned ||
|
|
50
|
+
col.hidden !== prevCol.hidden ||
|
|
51
|
+
col.order !== prevCol.order);
|
|
52
|
+
});
|
|
53
|
+
// Check for filter-only changes
|
|
54
|
+
const columnsWithFilterChanges = new Set();
|
|
55
|
+
columns.forEach((col) => {
|
|
56
|
+
var _a;
|
|
57
|
+
const colId = col.id;
|
|
58
|
+
const prevFilterData = filterChangeTrackingRef.current.get(colId);
|
|
59
|
+
const currentFilterData = (_a = col.filter) === null || _a === void 0 ? void 0 : _a.data;
|
|
60
|
+
if (!areFilterDataEqual(prevFilterData, currentFilterData)) {
|
|
61
|
+
columnsWithFilterChanges.add(colId);
|
|
62
|
+
filterChangeTrackingRef.current.set(colId, currentFilterData);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
// Only update if there are structural changes or filter changes
|
|
66
|
+
if (structurallyChanged || columnsWithFilterChanges.size > 0) {
|
|
67
|
+
// For filter-only changes, update only the affected columns
|
|
68
|
+
if (!structurallyChanged && columnsWithFilterChanges.size > 0) {
|
|
69
|
+
// Create a new array but preserve references for unchanged columns
|
|
70
|
+
const updatedColumns = stableColumnsRef.current.map((stableCol, index) => {
|
|
71
|
+
const newCol = columns[index];
|
|
72
|
+
const colId = newCol === null || newCol === void 0 ? void 0 : newCol.id;
|
|
73
|
+
// Only replace if this column's filter changed
|
|
74
|
+
if (columnsWithFilterChanges.has(colId)) {
|
|
75
|
+
return newCol;
|
|
76
|
+
}
|
|
77
|
+
// Keep the stable reference for unchanged columns
|
|
78
|
+
return stableCol;
|
|
79
|
+
});
|
|
80
|
+
stableColumnsRef.current = updatedColumns;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Full update for structural changes
|
|
84
|
+
stableColumnsRef.current = [...columns];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return stableColumnsRef.current;
|
|
88
|
+
}, [columns]);
|
|
89
|
+
// Memoize frequently used column calculations
|
|
90
|
+
const columnMetrics = useMemo(() => {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
const visibleColumns = stableColumns.filter((col) => !col.hidden);
|
|
93
|
+
const totalWidth = visibleColumns.reduce((sum, col) => sum + +((col === null || col === void 0 ? void 0 : col.width) || 100), 0);
|
|
94
|
+
const columnCount = visibleColumns.length;
|
|
95
|
+
return {
|
|
96
|
+
visibleColumns,
|
|
97
|
+
totalWidth,
|
|
98
|
+
columnCount,
|
|
99
|
+
firstColumnId: (_a = visibleColumns[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
100
|
+
lastColumnId: (_b = visibleColumns[columnCount - 1]) === null || _b === void 0 ? void 0 : _b.id,
|
|
101
|
+
};
|
|
102
|
+
}, [stableColumns]);
|
|
103
|
+
return {
|
|
104
|
+
stableColumns,
|
|
105
|
+
columnMetrics,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
@@ -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',
|
|
@@ -58,6 +58,7 @@ function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader,
|
|
|
58
58
|
const itemData = createItemData(orderedColumns, isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, lastItemIndex, (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0, isError, areAllRowsLoaded && !areTotalRowsNotFillingHeight, isSheetView);
|
|
59
59
|
const tableRowHeight = isSheetView ? SHEET_VIEW_TABLE_ROW_HEIGHT : TABLE_ROW_HEIGHT;
|
|
60
60
|
const listRef = useRef(null);
|
|
61
|
+
// Reset row heights when isSheetView or tableRowHeight changes
|
|
61
62
|
useEffect(() => {
|
|
62
63
|
if (listRef.current && typeof listRef.current.resetAfterIndex === 'function') {
|
|
63
64
|
listRef.current.resetAfterIndex(0, true);
|
|
@@ -68,11 +69,16 @@ function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader,
|
|
|
68
69
|
setShowBackdrop(isVisible);
|
|
69
70
|
};
|
|
70
71
|
const handleOnLoadMoreItems = () => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
// TODO: start index and stop index are not working as expected
|
|
73
|
+
// console.log('startIndex', startIndex, 'stopIndex', stopIndex,
|
|
74
|
+
// 'rows.length', rows.length)
|
|
71
75
|
if (areAllRowsLoaded)
|
|
72
76
|
return;
|
|
73
77
|
yield (loadMoreItems === null || loadMoreItems === void 0 ? void 0 : loadMoreItems());
|
|
74
78
|
});
|
|
75
|
-
return (
|
|
79
|
+
return (
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
_jsx(InfiniteLoader, Object.assign({ "data-testid": "VirtualTable_InfiniteLoader", isItemLoaded: (index) => index !== lastItemIndex, itemCount: itemsCount, loadMoreItems: handleOnLoadMoreItems, threshold: threshold }, { children: ({ onItemsRendered, ref }) => (_jsx(AutoSizer, Object.assign({ ref: ref, "data-testid": "VirtualTable_AutoSizer" }, { children: ({ height, width }) => (_jsx(StyledVirtualList, Object.assign({ "data-testid": "VirtualTable_VirtualList", useIsScrolling: true, className: "list", itemData: itemData, height: height || 0, width: width || 0, itemCount: itemsCount, itemSize: () => tableRowHeight, onItemsRendered: onItemsRendered, setBackdropVisibility: setBackdropVisibility, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, scrollToIndex: scrollToIndex, overscanCount: TABLE_LIST_OVER_SCAN, isSheetView: isSheetView, listRef: listRef }, { children: ListItemWrapper }))) }), `${footerProps === null || footerProps === void 0 ? void 0 : footerProps.maximized}-${isMinimized}`)) })));
|
|
76
82
|
}, [
|
|
77
83
|
isMinimized,
|
|
78
84
|
footerProps === null || footerProps === void 0 ? void 0 : footerProps.maximized,
|
|
@@ -91,6 +97,10 @@ function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader,
|
|
|
91
97
|
return (_jsxs(_Fragment, { children: [_jsxs(TableContainer, { children: [_jsx(StyledTableBox, Object.assign({ as: "main", id: "table-box-container", "aria-labelledby": "table-box-container", "data-testid": "VirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: Object.assign({}, tableBodyStyles) }, { children: [showHeader && (_jsx(TableHeader, { "data-testid": "VirtualTable_TableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: orderedColumns, headerProps: headerProps, showBackDrop: showBackDrop, isSheetView: isSheetView })), showNoDataView ? (_jsx(TableNoData, { error: error, tableEmpty: tableEmpty, isTimeoutError: hasTimeoutError, tableError: tableError, tableLoading: tableLoading, orderedColumns: orderedColumns, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps })) : (_jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
92
98
|
width: '100%',
|
|
93
99
|
minWidth: 'fit-content',
|
|
94
|
-
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "VirtualTable_StyledBox", hidePadding: true, className: "list-wrapper" }, { children: renderTableContainer })) })))] })) })), !showNoDataView && areTotalRowsNotFillingHeight && !isFetchingNextPage && (_jsx(TableLastItem
|
|
100
|
+
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "VirtualTable_StyledBox", hidePadding: true, className: "list-wrapper" }, { children: renderTableContainer })) })))] })) })), !showNoDataView && areTotalRowsNotFillingHeight && !isFetchingNextPage && (_jsx(TableLastItem
|
|
101
|
+
// rows height + header height
|
|
102
|
+
, {
|
|
103
|
+
// rows height + header height
|
|
104
|
+
height: (itemsCount + 1) * tableRowHeight, sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode, "data-testid": "VirtualTable_TableLastItem" }))] }), _jsx(TableFooter, Object.assign({ "data-testid": "VirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps))] }));
|
|
95
105
|
}
|
|
96
106
|
export default memo(VirtualTable);
|