@tap-payments/os-micro-frontend-shared 0.1.103-test.113 → 0.1.103-test.115

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.
@@ -22,7 +22,7 @@ interface UseVirtualTableContainerProps<T = unknown> extends TableChipProps {
22
22
  handleChipClick: (rowIndex: number, columnIndex: number, event: React.MouseEvent, chipIndex: number, pinnedType?: 'start' | 'end') => void;
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
- getItemSize: (index: number, containerHeight: number) => number;
25
+ getItemSize: (index: number, height: number) => number;
26
26
  getItemDataForContainer: (columnsData: IColumnProps[], isPinnedColumn: boolean, height: number) => {
27
27
  columns: any;
28
28
  isLoading: any;
@@ -1,4 +1,4 @@
1
- import { useCallback, useRef } from 'react';
1
+ import { useCallback, useMemo, useRef } from 'react';
2
2
  import memoize from 'memoize-one';
3
3
  const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToIndex, lastItemIndex, totalCount, isError, areAllRowsLoaded, isPinned, selectedCell, selectedColumn, selectedRow, selectedChip, onCellClick, onChipClick, containerHeight, rowHeight) => ({
4
4
  columns,
@@ -28,33 +28,34 @@ export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, is
28
28
  if (stableRowsLength.current !== rows.length) {
29
29
  stableRowsLength.current = rows.length;
30
30
  }
31
- const getItemSize = useCallback((index, containerHeight) => {
32
- if (!areAllRowsLoaded && index === rows.length - 1) {
33
- const remainingHeight = containerHeight - index * rowHeight;
31
+ const getItemSize = useCallback((index, height) => {
32
+ const isLastRow = areAllRowsLoaded && index === stableRowsLength.current;
33
+ if (isLastRow) {
34
+ const usedHeight = stableRowsLength.current * rowHeight;
35
+ const remainingHeight = height - usedHeight;
34
36
  const minimumLastRowHeight = rowHeight * 2;
35
37
  return Math.max(remainingHeight, minimumLastRowHeight);
36
38
  }
37
39
  return rowHeight;
38
40
  }, [areAllRowsLoaded, rowHeight]);
39
- const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => {
41
+ const commonItemDataParams = useMemo(() => {
40
42
  var _a;
41
- return createItemData(columnsData, isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, rows.length - 1, (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0, isError, areAllRowsLoaded, isPinnedColumn, selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick, height, rowHeight);
42
- }, [
43
- isDelayedFetchingNextPage,
44
- rows,
45
- rowProps,
46
- scrollToIndex,
47
- footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount,
48
- isError,
49
- areAllRowsLoaded,
50
- selectedCell,
51
- selectedColumn,
52
- selectedRow,
53
- selectedChip,
54
- handleCellClick,
55
- handleChipClick,
56
- rowHeight,
57
- ]);
43
+ return [
44
+ isDelayedFetchingNextPage,
45
+ rows,
46
+ rowProps,
47
+ scrollToIndex,
48
+ rows.length - 1,
49
+ (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0,
50
+ isError,
51
+ areAllRowsLoaded,
52
+ ];
53
+ }, [isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount, isError, areAllRowsLoaded]);
54
+ const commonItemDataSuffix = useMemo(() => [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick], [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick]);
55
+ const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => {
56
+ console.log('createItemData(columnsData, ...commonItemDataParams, isPinnedColumn, ...commonItemDataSuffix, height, rowHeight)', columnsData, commonItemDataParams, isPinnedColumn, commonItemDataSuffix, height, rowHeight);
57
+ return createItemData(columnsData, ...commonItemDataParams, isPinnedColumn, ...commonItemDataSuffix, height, rowHeight);
58
+ }, [commonItemDataParams, commonItemDataSuffix, rowHeight]);
58
59
  return {
59
60
  getItemSize,
60
61
  getItemDataForContainer,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.103-test.113",
5
- "testVersion": 113,
4
+ "version": "0.1.103-test.115",
5
+ "testVersion": 115,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",