@tap-payments/os-micro-frontend-shared 0.1.8 → 0.1.9-test.1-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/build/components/ActionMenu/style.d.ts +1 -1
- package/build/components/Chip/style.d.ts +1 -1
- package/build/components/CountBadge/style.d.ts +1 -1
- package/build/components/Dialog/style.d.ts +1 -1
- package/build/components/FlippingCard/style.d.ts +1 -1
- package/build/components/ImageWrapper/ImageWrapper.d.ts +1 -1
- package/build/components/JSONViewer/style.d.ts +2 -2
- package/build/components/SearchButton/styles.d.ts +3 -3
- package/build/components/StatusIcons/AuthIcons/style.d.ts +2 -2
- package/build/components/StatusIcons/AuthorizationAutoIcons/style.d.ts +1 -1
- package/build/components/StatusIcons/ChargeStatusIcon/style.d.ts +6 -6
- package/build/components/StatusIcons/SourceIcons/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/ActionCell/hooks/useActionCell.d.ts +1 -1
- package/build/components/TableCells/CustomCells/ActionCell/style.d.ts +2 -2
- package/build/components/TableCells/CustomCells/ApplicationStatusCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/AuthenticationCell/style.d.ts +2 -2
- package/build/components/TableCells/CustomCells/AuthenticationStatusCell/style.d.ts +5 -5
- package/build/components/TableCells/CustomCells/AuthenticationTypeCell/style.d.ts +5 -5
- package/build/components/TableCells/CustomCells/BalanceCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/ChannelsCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/CheckoutStatusCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/DestinationStatusCell/style.d.ts +5 -5
- package/build/components/TableCells/CustomCells/DueDateCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/IDButton/style.d.ts +2 -2
- package/build/components/TableCells/CustomCells/IntentsStatusCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/InvoiceStatusCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/PayoutStatusCell/style.d.ts +5 -5
- package/build/components/TableCells/CustomCells/ProductsCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/ReferenceCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/RefundChargeCell/style.d.ts +2 -2
- package/build/components/TableCells/CustomCells/RefundStatusCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/SalesChannelCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/SegmentsCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/SourceCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/SourceMergedCell/style.d.ts +6 -6
- package/build/components/TableCells/CustomCells/StatusCell/style.d.ts +6 -6
- package/build/components/TableCells/CustomCells/TokenStatusCell/style.d.ts +5 -5
- package/build/components/TableCells/CustomCells/style.d.ts +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +34 -174
- package/build/components/VirtualTables/SheetViewVirtualTable/components/NoDataSection.d.ts +32 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/NoDataSection.js +30 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumnSection.d.ts +51 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumnSection.js +20 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader/SheetViewTableHeader.js +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader/TableCell.js +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableLoading.js +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableNoData.js +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/VirtualListSection.d.ts +34 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/VirtualListSection.js +76 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/index.d.ts +3 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/index.js +3 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePinnedWidths.d.ts +5 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePinnedWidths.js +12 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useSelection.d.ts +6 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useSelection.js +17 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useSharedItemSize.d.ts +10 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useSharedItemSize.js +21 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useSheetViewStates.d.ts +14 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useSheetViewStates.js +20 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/style.d.ts +0 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/style.js +0 -10
- package/build/components/VirtualTables/VirtualTable/VirtualTable.d.ts +1 -1
- package/build/components/VirtualTables/VirtualTable/VirtualTable.js +19 -79
- package/build/components/VirtualTables/VirtualTable/VirtualTableList.d.ts +19 -0
- package/build/components/VirtualTables/VirtualTable/VirtualTableList.js +27 -0
- package/build/components/VirtualTables/VirtualTable/useVirtualTable.d.ts +31 -0
- package/build/components/VirtualTables/VirtualTable/useVirtualTable.js +70 -0
- package/build/components/VirtualTables/components/TableRow.js +1 -1
- package/build/components/VirtualTables/components/style.d.ts +1 -1
- package/build/components/Window/style.d.ts +2 -2
- package/build/constants/assets.d.ts +1 -0
- package/build/constants/assets.js +1 -0
- package/build/types/table.d.ts +0 -1
- package/package.json +134 -134
- /package/build/components/VirtualTables/{utils/getSelectionStyles.d.ts → components/utils.d.ts} +0 -0
- /package/build/components/VirtualTables/{utils/getSelectionStyles.js → components/utils.js} +0 -0
package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumnSection.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { useTheme } from '@mui/material/styles';
|
|
4
|
+
import { StyledBox, StyledTableBox, TableWrapper } from '../../components/style';
|
|
5
|
+
import { PinnedStartColumnWrapper, PinnedEndColumnWrapper } from '../style';
|
|
6
|
+
import SheetViewTableHeader from './SheetViewTableHeader';
|
|
7
|
+
import VirtualListSection from './VirtualListSection';
|
|
8
|
+
function PinnedColumnSection({ position, columnsData, columnsWidth, pinnedColumnsList, showHeader, headerProps, columnsSorting, onColumnSort, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, listRef, itemsCount, rows, rowProps, rowsLength, loadMoreItems, threshold, areAllRowsLoaded, rowHeight, scrollToIndex, totalCount, isError, isDelayedFetchingNextPage, selectedCell, selectedColumnValue, handleCellClick, areTotalRowsNotFillingHeight, setShowBackdrop, handleScroll, clearBackdropVisibilityTimeout, getItemSize, updateReferenceHeight, tableTitle, areAllRowsLoadedDataAttr, isFetchingNextPageDataAttr, isLoadingDataAttr, hasTimeoutErrorDataAttr, tableMode, showNoDataView, }) {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
const Wrapper = position === 'start' ? PinnedStartColumnWrapper : PinnedEndColumnWrapper;
|
|
11
|
+
const containerKey = position === 'start' ? 'pinnedStart' : 'pinnedEnd';
|
|
12
|
+
if (columnsData.length === 0)
|
|
13
|
+
return null;
|
|
14
|
+
return (_jsx(Wrapper, Object.assign({ "data-testid": `SheetViewVirtualTable_PinnedColumnWrapper_${position}` }, { children: _jsxs(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_PinnedStyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": areAllRowsLoadedDataAttr, "data-is-fetching-next-page": !!isFetchingNextPageDataAttr, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoadingDataAttr, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutErrorDataAttr, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView }, { children: [showHeader && (_jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_PinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: columnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: pinnedColumnsList, onColumnPin: onColumnPin, isPinnable: !!isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
15
|
+
width: '100%',
|
|
16
|
+
minWidth: 'fit-content',
|
|
17
|
+
overflowX: 'hidden',
|
|
18
|
+
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": `SheetViewVirtualTable_PinnedStyledBox_${position}`, hidePadding: true, className: "list-wrapper" }, { children: _jsx(VirtualListSection, { "data-testid": `SheetViewVirtualTable_VirtualListSection_${position}`, containerKey: containerKey, isPinned: true, fixedWidth: columnsWidth, listRef: listRef, columnsData: columnsData, itemsCount: itemsCount, rows: rows, rowProps: rowProps, rowsLength: rowsLength, loadMoreItems: loadMoreItems, threshold: threshold, areAllRowsLoaded: areAllRowsLoaded, rowHeight: rowHeight, scrollToIndex: scrollToIndex, totalCount: totalCount, isError: isError, isDelayedFetchingNextPage: isDelayedFetchingNextPage, selectedCell: selectedCell, selectedColumn: selectedColumnValue, handleCellClick: handleCellClick, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, setShowBackdrop: setShowBackdrop, handleScroll: handleScroll, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, getItemSize: getItemSize, updateReferenceHeight: updateReferenceHeight }) })) }))] })) })));
|
|
19
|
+
}
|
|
20
|
+
export default memo(PinnedColumnSection);
|
|
@@ -4,7 +4,7 @@ import { StyledHeader, StyledMUITableRow } from '../../style';
|
|
|
4
4
|
import TableCell from './TableCell';
|
|
5
5
|
function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, }) {
|
|
6
6
|
return (_jsx(StyledHeader, Object.assign({ component: "nav", "data-testid": "SheetViewVirtualTable_TableHeader_StyledHeader", showBackDrop: showBackDrop }, headerProps, { children: _jsx(StyledMUITableRow, Object.assign({ component: "section", "data-testid": "SheetViewVirtualTable_TableHeader_StyledMUITableRow" }, { children: columns.map((column, colIndex) => {
|
|
7
|
-
return (_jsx(TableCell, { column: column, isFirst: column.id === columns[0].id, isLast: column.id === columns[columns.length - 1].id, isDefaultPinned: !!column.isDefaultPinned, isSelected: selectedColumn === column.id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, pinnedColumns: pinnedColumns, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, onColumnClick: onColumnClick }, `${column.id}-${colIndex}`));
|
|
7
|
+
return (_jsx(TableCell, { "data-testid": "SheetViewVirtualTable_TableHeader_TableCell", column: column, isFirst: column.id === columns[0].id, isLast: column.id === columns[columns.length - 1].id, isDefaultPinned: !!column.isDefaultPinned, isSelected: selectedColumn === column.id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, pinnedColumns: pinnedColumns, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, onColumnClick: onColumnClick }, `${column.id}-${colIndex}`));
|
|
8
8
|
}) })) })));
|
|
9
9
|
}
|
|
10
10
|
export default memo(SheetViewTableHeader);
|
|
@@ -38,7 +38,7 @@ function TableCell({ column: { header, id, align, headerStyle, sortable, filter,
|
|
|
38
38
|
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, event);
|
|
39
39
|
} }))), sortable && (_jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, onClick: (e) => {
|
|
40
40
|
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, e);
|
|
41
|
-
} })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
|
|
41
|
+
} })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ "data-testid": "SheetViewVirtualTable_TableHeader_PinIconContainer", onClick: (event) => {
|
|
42
42
|
event.stopPropagation();
|
|
43
43
|
handlePinClick(id);
|
|
44
44
|
}, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] })));
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableLoading.js
CHANGED
|
@@ -15,6 +15,6 @@ const Wrapper = styled('section')(({ isLoaded = false }) => ({
|
|
|
15
15
|
function SheetViewTableLoading({ columns, isLoaded = false, animationType, isLoading = false, rowsCount }) {
|
|
16
16
|
let maxAllowedRows = rowsCount || calculateMaxAllowedRows(isLoaded, isLoading);
|
|
17
17
|
maxAllowedRows = rowsCount || Math.max(maxAllowedRows, 25);
|
|
18
|
-
return (_jsx(Wrapper, Object.assign({ isLoaded: isLoaded, "data-testid": "
|
|
18
|
+
return (_jsx(Wrapper, Object.assign({ isLoaded: isLoaded, "data-testid": "SheetViewVirtualTable_Loading_Wrapper" }, { children: [...Array(maxAllowedRows)].map((_, index) => (_jsx(SheetViewTableRowLoading, { columns: columns, animationType: animationType, rowIndex: index }, `i-${uniqueId('SheetViewTableLoadingRow_')}`))) })));
|
|
19
19
|
}
|
|
20
20
|
export default memo(SheetViewTableLoading);
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableNoData.js
CHANGED
|
@@ -21,7 +21,7 @@ function SheetViewTableNoData({ error, tableEmpty, isTimeoutError, tableError, t
|
|
|
21
21
|
else if (tableEmpty) {
|
|
22
22
|
const axiosErr = error;
|
|
23
23
|
const { formatted } = backendErrorHandler({ error: axiosErr, fallbackMessage: 'tryAdjustingTheDateOrFilters' });
|
|
24
|
-
content = _jsx(EmptyList, { sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode, heading: "nothingFound", message: formatted });
|
|
24
|
+
content = (_jsx(EmptyList, { "data-testid": "SheetViewVirtualTable_EmptyList", sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode, heading: "nothingFound", message: formatted }));
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
content = (_jsx(ErrorList, { "data-testid": "SheetViewVirtualTable_ErrorList_tableError", heading: "somethingWentWrong", message: "connectionErrorMsg", triggerDataRefetch: triggerDataRefetch, sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode }));
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/VirtualListSection.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { VariableSizeList, ListOnScrollProps } from 'react-window';
|
|
3
|
+
import type { IColumnProps } from '../../../../types/index.js';
|
|
4
|
+
interface VirtualListSectionProps {
|
|
5
|
+
containerKey: 'pinnedStart' | 'pinnedEnd' | 'scrollable';
|
|
6
|
+
isPinned: boolean;
|
|
7
|
+
fixedWidth?: number;
|
|
8
|
+
listRef: React.RefObject<VariableSizeList>;
|
|
9
|
+
columnsData: IColumnProps[];
|
|
10
|
+
itemsCount: number;
|
|
11
|
+
rows: unknown[];
|
|
12
|
+
rowProps: unknown;
|
|
13
|
+
rowsLength: number;
|
|
14
|
+
loadMoreItems?: () => Promise<unknown>;
|
|
15
|
+
threshold: number;
|
|
16
|
+
areAllRowsLoaded: boolean;
|
|
17
|
+
rowHeight: number;
|
|
18
|
+
scrollToIndex?: number;
|
|
19
|
+
totalCount: number;
|
|
20
|
+
isError: boolean;
|
|
21
|
+
isDelayedFetchingNextPage: boolean;
|
|
22
|
+
selectedCell: string | null;
|
|
23
|
+
selectedColumn: string | null;
|
|
24
|
+
handleCellClick: (rowIndex: number, columnId: string, event: React.MouseEvent) => void;
|
|
25
|
+
areTotalRowsNotFillingHeight: boolean;
|
|
26
|
+
setShowBackdrop: (v: boolean) => void;
|
|
27
|
+
handleScroll: (scrollProps: ListOnScrollProps, source: 'start' | 'end' | 'scrollable') => void;
|
|
28
|
+
clearBackdropVisibilityTimeout: number;
|
|
29
|
+
getItemSize?: (index: number) => number;
|
|
30
|
+
updateReferenceHeight?: (height: number) => void;
|
|
31
|
+
}
|
|
32
|
+
declare function VirtualListSection({ containerKey, isPinned, fixedWidth, listRef, columnsData, itemsCount, rows, rowProps, rowsLength, loadMoreItems, threshold, areAllRowsLoaded, rowHeight, scrollToIndex, totalCount, isError, isDelayedFetchingNextPage, selectedCell, selectedColumn, handleCellClick, areTotalRowsNotFillingHeight, setShowBackdrop, handleScroll, clearBackdropVisibilityTimeout, getItemSize: externalGetItemSize, updateReferenceHeight, }: Readonly<VirtualListSectionProps>): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
declare const _default: import("react").MemoExoticComponent<typeof VirtualListSection>;
|
|
34
|
+
export default _default;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
12
|
+
import memoize from 'memoize-one';
|
|
13
|
+
import InfiniteLoader from 'react-window-infinite-loader';
|
|
14
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
15
|
+
import { StyledVirtualList } from '../../components/style';
|
|
16
|
+
import ListItemWrapper from '../../components/virtualScroll/ListItemWrapper';
|
|
17
|
+
import { TABLE_LIST_OVER_SCAN } from '../../../../constants/index.js';
|
|
18
|
+
const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToIndex, totalCount, isError, areAllRowsLoaded, isPinned, selectedCell, selectedColumn, onCellClick, containerHeight, rowHeight) => ({
|
|
19
|
+
columns,
|
|
20
|
+
isLoading,
|
|
21
|
+
rows,
|
|
22
|
+
rowProps,
|
|
23
|
+
scrollToIndex,
|
|
24
|
+
totalCount,
|
|
25
|
+
isError,
|
|
26
|
+
areAllRowsLoaded,
|
|
27
|
+
limit: totalCount,
|
|
28
|
+
newLoadedRowsEndIndex: rows.length - 1,
|
|
29
|
+
isSheetView: true,
|
|
30
|
+
isPinned,
|
|
31
|
+
selectedCell,
|
|
32
|
+
selectedColumn,
|
|
33
|
+
onCellClick,
|
|
34
|
+
containerHeight,
|
|
35
|
+
rowHeight,
|
|
36
|
+
}));
|
|
37
|
+
function VirtualListSection({ containerKey, isPinned, fixedWidth, listRef, columnsData, itemsCount, rows, rowProps, rowsLength, loadMoreItems, threshold, areAllRowsLoaded, rowHeight, scrollToIndex, totalCount, isError, isDelayedFetchingNextPage, selectedCell, selectedColumn, handleCellClick, areTotalRowsNotFillingHeight, setShowBackdrop, handleScroll, clearBackdropVisibilityTimeout, getItemSize: externalGetItemSize, updateReferenceHeight, }) {
|
|
38
|
+
const onItemsRenderedSource = useMemo(() => (containerKey === 'pinnedStart' ? 'start' : containerKey === 'pinnedEnd' ? 'end' : 'scrollable'), [containerKey]);
|
|
39
|
+
const listStyle = useMemo(() => ({
|
|
40
|
+
overflowX: (isPinned ? 'hidden' : 'auto'),
|
|
41
|
+
paddingBottom: isPinned ? '25px' : '13px',
|
|
42
|
+
backgroundColor: isPinned ? 'transparent' : '#F6F8FACC',
|
|
43
|
+
}), [isPinned]);
|
|
44
|
+
const isItemLoaded = useCallback((index) => {
|
|
45
|
+
if (areAllRowsLoaded)
|
|
46
|
+
return true;
|
|
47
|
+
return index < rowsLength;
|
|
48
|
+
}, [areAllRowsLoaded, rowsLength]);
|
|
49
|
+
const onLoadMore = useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (areAllRowsLoaded)
|
|
51
|
+
return;
|
|
52
|
+
yield (loadMoreItems === null || loadMoreItems === void 0 ? void 0 : loadMoreItems());
|
|
53
|
+
}), [areAllRowsLoaded, loadMoreItems]);
|
|
54
|
+
const onScrollSync = useCallback((scrollProps) => {
|
|
55
|
+
handleScroll(scrollProps, onItemsRenderedSource);
|
|
56
|
+
}, [handleScroll, onItemsRenderedSource]);
|
|
57
|
+
return (_jsx(InfiniteLoader, Object.assign({ "data-testid": `SheetViewVirtualTable_VirtualListSection_InfiniteLoader_${containerKey}`, isItemLoaded: isItemLoaded, itemCount: itemsCount, loadMoreItems: onLoadMore, threshold: threshold }, { children: ({ onItemsRendered, ref }) => (_jsx(AutoSizer, Object.assign({ ref: ref, "data-testid": "VirtualListSection_AutoSizer" }, { children: ({ height, width }) => {
|
|
58
|
+
if (!isPinned && updateReferenceHeight) {
|
|
59
|
+
updateReferenceHeight(height);
|
|
60
|
+
}
|
|
61
|
+
const getItemSize = externalGetItemSize ||
|
|
62
|
+
((index) => {
|
|
63
|
+
const isLastRow = areAllRowsLoaded && index === rowsLength;
|
|
64
|
+
if (isLastRow) {
|
|
65
|
+
const usedHeight = rowsLength * rowHeight;
|
|
66
|
+
const remainingHeight = height - usedHeight;
|
|
67
|
+
const minimumLastRowHeight = rowHeight * 2;
|
|
68
|
+
return Math.max(remainingHeight, minimumLastRowHeight);
|
|
69
|
+
}
|
|
70
|
+
return rowHeight;
|
|
71
|
+
});
|
|
72
|
+
const itemData = createItemData(columnsData, isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, totalCount, isError, areAllRowsLoaded, isPinned, selectedCell, selectedColumn, handleCellClick, height, rowHeight);
|
|
73
|
+
return (_jsx(StyledVirtualList, Object.assign({ "data-testid": `SheetViewVirtualTable_VirtualListSection_StyledVirtualList_${containerKey}`, listRef: listRef, height: height, width: fixedWidth || width, itemCount: itemsCount, itemSize: getItemSize, itemData: itemData, onItemsRendered: onItemsRendered, overscanCount: TABLE_LIST_OVER_SCAN, setBackdropVisibility: setShowBackdrop, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, useIsScrolling: true, onScroll: onScrollSync, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, style: listStyle }, { children: ListItemWrapper })));
|
|
74
|
+
} }))) })));
|
|
75
|
+
}
|
|
76
|
+
export default memo(VirtualListSection);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { default as SheetViewTableLoading } from './SheetViewTableLoading';
|
|
2
2
|
export { default as SheetViewTableRowLoading } from './SheetViewTableRowLoading';
|
|
3
3
|
export { default as SheetViewTableNoData } from './SheetViewTableNoData';
|
|
4
|
+
export { default as VirtualListSection } from './VirtualListSection';
|
|
5
|
+
export { default as PinnedColumnSection } from './PinnedColumnSection';
|
|
6
|
+
export { default as NoDataSection } from './NoDataSection';
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { default as SheetViewTableLoading } from './SheetViewTableLoading';
|
|
2
2
|
export { default as SheetViewTableRowLoading } from './SheetViewTableRowLoading';
|
|
3
3
|
export { default as SheetViewTableNoData } from './SheetViewTableNoData';
|
|
4
|
+
export { default as VirtualListSection } from './VirtualListSection';
|
|
5
|
+
export { default as PinnedColumnSection } from './PinnedColumnSection';
|
|
6
|
+
export { default as NoDataSection } from './NoDataSection';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
export function usePinnedWidths(pinnedStart, pinnedEnd) {
|
|
3
|
+
const pinnedStartColumnsWidth = useMemo(() => pinnedStart.reduce((acc, col) => {
|
|
4
|
+
const width = typeof col.width === 'string' ? parseInt(col.width) : col.width || 100;
|
|
5
|
+
return acc + width;
|
|
6
|
+
}, 0), [pinnedStart]);
|
|
7
|
+
const pinnedEndColumnsWidth = useMemo(() => pinnedEnd.reduce((acc, col) => {
|
|
8
|
+
const width = typeof col.width === 'string' ? parseInt(col.width) : col.width || 100;
|
|
9
|
+
return acc + width;
|
|
10
|
+
}, 0), [pinnedEnd]);
|
|
11
|
+
return { pinnedStartColumnsWidth, pinnedEndColumnsWidth };
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function useSelection(): {
|
|
2
|
+
selectedCell: string | null;
|
|
3
|
+
selectedColumn: string | null;
|
|
4
|
+
handleCellClick: (rowIndex: number, columnId: string, event: React.MouseEvent) => void;
|
|
5
|
+
handleColumnClick: (columnId: string, event: React.MouseEvent) => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
export function useSelection() {
|
|
3
|
+
const [selectedCell, setSelectedCell] = useState(null);
|
|
4
|
+
const [selectedColumn, setSelectedColumn] = useState(null);
|
|
5
|
+
const handleCellClick = useCallback((rowIndex, columnId, event) => {
|
|
6
|
+
event.stopPropagation();
|
|
7
|
+
const cellKey = `${rowIndex}-${columnId}`;
|
|
8
|
+
setSelectedCell((prev) => (prev === cellKey ? null : cellKey));
|
|
9
|
+
setSelectedColumn(null);
|
|
10
|
+
}, []);
|
|
11
|
+
const handleColumnClick = useCallback((columnId, event) => {
|
|
12
|
+
event.stopPropagation();
|
|
13
|
+
setSelectedColumn((prev) => (prev === columnId ? null : columnId));
|
|
14
|
+
setSelectedCell(null);
|
|
15
|
+
}, []);
|
|
16
|
+
return { selectedCell, selectedColumn, handleCellClick, handleColumnClick };
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface UseSharedItemSizeProps {
|
|
2
|
+
rowsLength: number;
|
|
3
|
+
areAllRowsLoaded: boolean;
|
|
4
|
+
rowHeight: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const useSharedItemSize: ({ rowsLength, areAllRowsLoaded, rowHeight }: UseSharedItemSizeProps) => {
|
|
7
|
+
getItemSize: (index: number) => number;
|
|
8
|
+
updateReferenceHeight: (height: number) => void;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
export const useSharedItemSize = ({ rowsLength, areAllRowsLoaded, rowHeight }) => {
|
|
3
|
+
const referenceHeightRef = useRef(0);
|
|
4
|
+
const updateReferenceHeight = useCallback((height) => {
|
|
5
|
+
referenceHeightRef.current = height;
|
|
6
|
+
}, []);
|
|
7
|
+
const getItemSize = useCallback((index) => {
|
|
8
|
+
const isLastRow = areAllRowsLoaded && index === rowsLength;
|
|
9
|
+
if (isLastRow) {
|
|
10
|
+
const usedHeight = rowsLength * rowHeight;
|
|
11
|
+
const remainingHeight = referenceHeightRef.current - usedHeight;
|
|
12
|
+
const minimumLastRowHeight = rowHeight * 2;
|
|
13
|
+
return Math.max(remainingHeight, minimumLastRowHeight);
|
|
14
|
+
}
|
|
15
|
+
return rowHeight;
|
|
16
|
+
}, [areAllRowsLoaded, rowsLength, rowHeight]);
|
|
17
|
+
return {
|
|
18
|
+
getItemSize,
|
|
19
|
+
updateReferenceHeight,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface UseSheetViewStatesParams {
|
|
2
|
+
rowsLength: number;
|
|
3
|
+
isLoading?: boolean;
|
|
4
|
+
error?: Error | null;
|
|
5
|
+
}
|
|
6
|
+
export declare function useSheetViewStates({ rowsLength, isLoading, error }: UseSheetViewStatesParams): {
|
|
7
|
+
isError: boolean;
|
|
8
|
+
tableLoading: boolean;
|
|
9
|
+
tableError: boolean;
|
|
10
|
+
tableEmpty: boolean;
|
|
11
|
+
hasTimeoutError: boolean;
|
|
12
|
+
showNoDataView: boolean;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { hasError, isNotFoundError, isTimeoutError } from '../../../../utils/index.js';
|
|
3
|
+
export function useSheetViewStates({ rowsLength, isLoading, error }) {
|
|
4
|
+
const normalizedError = error !== null && error !== void 0 ? error : null;
|
|
5
|
+
const isError = hasError(normalizedError);
|
|
6
|
+
const tableLoading = isLoading !== null && isLoading !== void 0 ? isLoading : true;
|
|
7
|
+
const tableEmpty = !isLoading && rowsLength === 0;
|
|
8
|
+
const tableError = useMemo(() => {
|
|
9
|
+
if (isLoading)
|
|
10
|
+
return false;
|
|
11
|
+
if (rowsLength !== 0)
|
|
12
|
+
return false;
|
|
13
|
+
if (!isError)
|
|
14
|
+
return false;
|
|
15
|
+
return !isNotFoundError(normalizedError);
|
|
16
|
+
}, [isLoading, rowsLength, isError, normalizedError]);
|
|
17
|
+
const hasTimeoutError = isTimeoutError(normalizedError);
|
|
18
|
+
const showNoDataView = tableLoading || tableError || tableEmpty || hasTimeoutError;
|
|
19
|
+
return { isError, tableLoading, tableError, tableEmpty, hasTimeoutError, showNoDataView };
|
|
20
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const ActionIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
3
|
-
export declare const ColumnIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
4
2
|
export declare const HeaderText: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
5
3
|
export declare const PinIconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
4
|
export declare const StyledHeader: import("@emotion/styled").StyledComponent<import("@mui/material/TableHead").TableHeadOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & {
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { styled } from '@mui/material/styles';
|
|
2
2
|
import TableHead from '@mui/material/TableHead';
|
|
3
3
|
import MUITableRow from '@mui/material/TableRow';
|
|
4
|
-
export const ActionIcon = styled('img')(() => ({
|
|
5
|
-
width: '13.3px',
|
|
6
|
-
height: '13.3px',
|
|
7
|
-
}));
|
|
8
|
-
export const ColumnIcon = styled('img')(() => ({
|
|
9
|
-
width: '8px',
|
|
10
|
-
height: '6.4px',
|
|
11
|
-
cursor: 'pointer',
|
|
12
|
-
marginTop: '2px',
|
|
13
|
-
}));
|
|
14
4
|
export const HeaderText = styled('span')(({ theme }) => ({
|
|
15
5
|
color: theme.palette.text.primary,
|
|
16
6
|
textOverflow: 'ellipsis',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IVirtualTable } from '../../../types/index.js';
|
|
3
|
-
declare function VirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableMode, tableTitle, dragControls,
|
|
3
|
+
declare function VirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableMode, tableTitle, dragControls, }: Readonly<IVirtualTable>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof VirtualTable>;
|
|
5
5
|
export default _default;
|
|
@@ -1,94 +1,34 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
-
import {
|
|
2
|
+
import { memo } from 'react';
|
|
12
3
|
import { useTheme } from '@mui/material/styles';
|
|
13
|
-
import
|
|
14
|
-
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
15
|
-
import InfiniteLoader from 'react-window-infinite-loader';
|
|
16
|
-
import { TABLE_ROW_HEIGHT, TABLE_THRESHOLD, TABLE_LIST_OVER_SCAN, SHEET_VIEW_TABLE_ROW_HEIGHT } from '../../../constants/index.js';
|
|
17
|
-
import { useDelayToSetValue } from '../../../hooks/index.js';
|
|
18
|
-
import { isHeightNotFullyFilledByRows, isNotFoundError, isTimeoutError, hasError } from '../../../utils/index.js';
|
|
4
|
+
import { TABLE_ROW_HEIGHT, TABLE_THRESHOLD } from '../../../constants/index.js';
|
|
19
5
|
import TableFooter from '../components/TableFooter/TableFooter';
|
|
20
6
|
import TableHeader from '../components/TableHeader';
|
|
21
7
|
import TableLastItem from '../components/TableLastItem';
|
|
22
8
|
import TableNoData from '../components/TableNoData';
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
isLoading,
|
|
28
|
-
rows,
|
|
29
|
-
rowProps,
|
|
30
|
-
scrollToIndex,
|
|
31
|
-
totalCount,
|
|
32
|
-
lastItemIndex,
|
|
33
|
-
isError,
|
|
34
|
-
areAllRowsLoaded,
|
|
35
|
-
isSheetView,
|
|
36
|
-
}));
|
|
37
|
-
function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableMode, tableTitle, dragControls, isSheetView = false, }) {
|
|
38
|
-
var _a;
|
|
9
|
+
import { StyledBox, StyledTableBox, TableContainer, TableWrapper } from '../components/style';
|
|
10
|
+
import VirtualTableList from './VirtualTableList';
|
|
11
|
+
import { useVirtualTable } from './useVirtualTable';
|
|
12
|
+
function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableMode, tableTitle, dragControls, }) {
|
|
39
13
|
const theme = useTheme();
|
|
40
14
|
const onPointerDown = (e) => {
|
|
41
15
|
dragControls === null || dragControls === void 0 ? void 0 : dragControls.start(e);
|
|
42
16
|
};
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const tableEmpty = !isLoading && rows.length === 0;
|
|
52
|
-
const hasTimeoutError = isTimeoutError(error);
|
|
53
|
-
const lastItemIndex = rows.length - 1;
|
|
54
|
-
const shownColumns = useMemo(() => columns.filter((column) => !column.hidden), [columns]);
|
|
55
|
-
const orderedColumns = useMemo(() => shownColumns.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); }), [shownColumns]);
|
|
56
|
-
const areTotalRowsNotFillingHeight = isHeightNotFullyFilledByRows(rows.length) && !tableLoading;
|
|
57
|
-
const itemsCount = isDelayedFetchingNextPage || (areAllRowsLoaded && !areTotalRowsNotFillingHeight) ? rows.length + 1 : rows.length;
|
|
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
|
-
const tableRowHeight = isSheetView ? SHEET_VIEW_TABLE_ROW_HEIGHT : TABLE_ROW_HEIGHT;
|
|
60
|
-
const listRef = useRef(null);
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (listRef.current && typeof listRef.current.resetAfterIndex === 'function') {
|
|
63
|
-
listRef.current.resetAfterIndex(0, true);
|
|
64
|
-
}
|
|
65
|
-
}, [isSheetView, tableRowHeight]);
|
|
66
|
-
const renderTableContainer = useMemo(() => {
|
|
67
|
-
const setBackdropVisibility = (isVisible) => {
|
|
68
|
-
setShowBackdrop(isVisible);
|
|
69
|
-
};
|
|
70
|
-
const handleOnLoadMoreItems = () => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
if (areAllRowsLoaded)
|
|
72
|
-
return;
|
|
73
|
-
yield (loadMoreItems === null || loadMoreItems === void 0 ? void 0 : loadMoreItems());
|
|
74
|
-
});
|
|
75
|
-
return (_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 }))) }))) })));
|
|
76
|
-
}, [
|
|
77
|
-
lastItemIndex,
|
|
78
|
-
loadMoreItems,
|
|
79
|
-
threshold,
|
|
80
|
-
areAllRowsLoaded,
|
|
81
|
-
areTotalRowsNotFillingHeight,
|
|
82
|
-
itemsCount,
|
|
83
|
-
tableRowHeight,
|
|
84
|
-
isSheetView,
|
|
85
|
-
itemData,
|
|
17
|
+
const { isError, tableLoading, tableError, tableEmpty, hasTimeoutError, showNoDataView, orderedColumns, areTotalRowsNotFillingHeight, itemsCount, itemData, listRef, showBackDrop, setBackdropVisibility, loadMoreItemsSafe, } = useVirtualTable({
|
|
18
|
+
columns,
|
|
19
|
+
rows,
|
|
20
|
+
rowProps,
|
|
21
|
+
footerProps,
|
|
22
|
+
isLoading,
|
|
23
|
+
error,
|
|
24
|
+
isFetchingNextPage,
|
|
86
25
|
scrollToIndex,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
26
|
+
areAllRowsLoaded,
|
|
27
|
+
loadMoreItems,
|
|
28
|
+
});
|
|
29
|
+
return (_jsxs(_Fragment, { children: [_jsxs(TableContainer, Object.assign({ "data-testid": "VirtualTable_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({ isSheetView: false, "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: false })), showNoDataView ? (_jsx(TableNoData, { "data-testid": "VirtualTable_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: {
|
|
90
30
|
width: '100%',
|
|
91
31
|
minWidth: 'fit-content',
|
|
92
|
-
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "VirtualTable_StyledBox", hidePadding: true, className: "list-wrapper" }, { children:
|
|
32
|
+
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "VirtualTable_StyledBox", hidePadding: true, className: "list-wrapper" }, { children: _jsx(VirtualTableList, { rowsLength: rows.length, itemsCount: itemsCount, threshold: threshold, tableRowHeight: TABLE_ROW_HEIGHT, areAllRowsLoaded: areTotalRowsNotFillingHeight ? false : areAllRowsLoaded, isFetchingNextPage: isFetchingNextPage, loadMoreItems: loadMoreItemsSafe, itemData: itemData, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, scrollToIndex: scrollToIndex, setBackdropVisibility: setBackdropVisibility, listRef: listRef }) })) })))] })) })), !showNoDataView && areTotalRowsNotFillingHeight && !isFetchingNextPage && (_jsx(TableLastItem, { height: (itemsCount + 1) * TABLE_ROW_HEIGHT, 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))] }));
|
|
93
33
|
}
|
|
94
34
|
export default memo(VirtualTable);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { VariableSizeList } from 'react-window';
|
|
3
|
+
interface VirtualTableListProps {
|
|
4
|
+
rowsLength: number;
|
|
5
|
+
itemsCount: number;
|
|
6
|
+
threshold: number;
|
|
7
|
+
tableRowHeight: number;
|
|
8
|
+
areAllRowsLoaded: boolean;
|
|
9
|
+
isFetchingNextPage?: boolean;
|
|
10
|
+
loadMoreItems?: () => Promise<void> | void;
|
|
11
|
+
itemData: any;
|
|
12
|
+
areTotalRowsNotFillingHeight: boolean;
|
|
13
|
+
scrollToIndex?: number;
|
|
14
|
+
setBackdropVisibility: (isVisible: boolean) => void;
|
|
15
|
+
listRef: React.RefObject<VariableSizeList>;
|
|
16
|
+
}
|
|
17
|
+
declare function VirtualTableList({ rowsLength, itemsCount, threshold, tableRowHeight, areAllRowsLoaded, isFetchingNextPage, loadMoreItems, itemData, areTotalRowsNotFillingHeight, scrollToIndex, setBackdropVisibility, listRef, }: Readonly<VirtualTableListProps>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare const _default: import("react").MemoExoticComponent<typeof VirtualTableList>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { memo, useCallback } from 'react';
|
|
12
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
13
|
+
import InfiniteLoader from 'react-window-infinite-loader';
|
|
14
|
+
import { TABLE_LIST_OVER_SCAN } from '../../../constants/index.js';
|
|
15
|
+
import ListItemWrapper from '../components/virtualScroll/ListItemWrapper';
|
|
16
|
+
import { StyledVirtualList } from '../components/style';
|
|
17
|
+
function VirtualTableList({ rowsLength, itemsCount, threshold, tableRowHeight, areAllRowsLoaded, isFetchingNextPage, loadMoreItems, itemData, areTotalRowsNotFillingHeight, scrollToIndex, setBackdropVisibility, listRef, }) {
|
|
18
|
+
const isItemLoaded = useCallback((index) => index < rowsLength, [rowsLength]);
|
|
19
|
+
const handleOnLoadMoreItems = useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (areAllRowsLoaded || isFetchingNextPage)
|
|
21
|
+
return;
|
|
22
|
+
yield (loadMoreItems === null || loadMoreItems === void 0 ? void 0 : loadMoreItems());
|
|
23
|
+
}), [areAllRowsLoaded, isFetchingNextPage, loadMoreItems]);
|
|
24
|
+
const itemSizeForIndex = useCallback(() => tableRowHeight, [tableRowHeight]);
|
|
25
|
+
return (_jsx(InfiniteLoader, Object.assign({ "data-testid": "VirtualTable_InfiniteLoader", isItemLoaded: isItemLoaded, 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: itemSizeForIndex, onItemsRendered: onItemsRendered, setBackdropVisibility: setBackdropVisibility, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, scrollToIndex: scrollToIndex, overscanCount: TABLE_LIST_OVER_SCAN, isSheetView: false, listRef: listRef }, { children: ListItemWrapper }))) }))) })));
|
|
26
|
+
}
|
|
27
|
+
export default memo(VirtualTableList);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { VariableSizeList } from 'react-window';
|
|
3
|
+
import type { IVirtualTable } from '../../../types/index.js';
|
|
4
|
+
export type UseVirtualTableArgs = Pick<IVirtualTable, 'columns' | 'rows' | 'rowProps' | 'footerProps' | 'isLoading' | 'error' | 'isFetchingNextPage' | 'scrollToIndex' | 'areAllRowsLoaded' | 'loadMoreItems'>;
|
|
5
|
+
export declare function useVirtualTable({ columns, rows, rowProps, footerProps, isLoading, error, isFetchingNextPage, scrollToIndex, areAllRowsLoaded, loadMoreItems, }: Readonly<UseVirtualTableArgs>): {
|
|
6
|
+
isDelayedFetchingNextPage: boolean;
|
|
7
|
+
isError: boolean;
|
|
8
|
+
tableLoading: boolean;
|
|
9
|
+
tableError: boolean;
|
|
10
|
+
tableEmpty: boolean;
|
|
11
|
+
hasTimeoutError: boolean;
|
|
12
|
+
showNoDataView: boolean;
|
|
13
|
+
orderedColumns: import("../../../types/index.js").IColumnProps<any>[];
|
|
14
|
+
areTotalRowsNotFillingHeight: boolean;
|
|
15
|
+
itemsCount: number;
|
|
16
|
+
itemData: {
|
|
17
|
+
columns: any;
|
|
18
|
+
isLoading: boolean;
|
|
19
|
+
rows: any[];
|
|
20
|
+
rowProps: any;
|
|
21
|
+
scrollToIndex: number | undefined;
|
|
22
|
+
totalCount: number;
|
|
23
|
+
lastItemIndex: number;
|
|
24
|
+
isError: boolean;
|
|
25
|
+
areAllRowsLoaded: boolean;
|
|
26
|
+
};
|
|
27
|
+
listRef: import("react").RefObject<VariableSizeList<any>>;
|
|
28
|
+
showBackDrop: boolean;
|
|
29
|
+
setBackdropVisibility: (isVisible: boolean) => void;
|
|
30
|
+
loadMoreItemsSafe: () => Promise<void>;
|
|
31
|
+
};
|