@tap-payments/os-micro-frontend-shared 0.1.129 → 0.1.130-test.6

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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Tap Payments
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tap Payments
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # os-micro-frontend-shared
2
-
3
- ## Publishing Workflow
4
-
5
- 1. Update version in package.json
6
- 2. Commit changes
7
- 3. Create and push a tag:
8
-
9
- ```bash
10
- npm version patch # or minor, major
11
- git push origin main --tags
12
- ```
1
+ # os-micro-frontend-shared
2
+
3
+ ## Publishing Workflow
4
+
5
+ 1. Update version in package.json
6
+ 2. Commit changes
7
+ 3. Create and push a tag:
8
+
9
+ ```bash
10
+ npm version patch # or minor, major
11
+ git push origin main --tags
12
+ ```
@@ -4,9 +4,10 @@ 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
+ const { stableColumnsWithFilters } = usePerformanceOptimizations(columns);
10
11
  const { selectedCell, selectedColumn, selectedRow, showBackDrop, setShowBackdrop, handleCellClick, handleColumnClick, handleChipClick, selectedChip, } = useTableState();
11
12
  const { isError, tableLoading, tableError, tableEmpty, hasTimeoutError, showNoDataView, lastItemIndex, areTotalRowsNotFillingHeight, itemsCount, isDelayedFetchingNextPage, } = useTableData({
12
13
  rows,
@@ -15,7 +16,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
15
16
  isFetchingNextPage,
16
17
  areAllRowsLoaded,
17
18
  });
18
- const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(columns, isPinnable, onColumnPin);
19
+ const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(stableColumnsWithFilters, isPinnable, onColumnPin);
19
20
  const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
20
21
  const { pinnedStartColumnsWidth, pinnedEndColumnsWidth } = usePinnedColumnsWidths(pinnedStartColumnsData, pinnedEndColumnsData);
21
22
  const { getItemSize, getItemDataForContainer } = useVirtualTableContainer({
@@ -57,6 +58,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
57
58
  clearBackdropVisibilityTimeout,
58
59
  handleScroll,
59
60
  setShowBackdrop,
61
+ overscanCount,
60
62
  pinnedStartVirtualListRef,
61
63
  pinnedEndVirtualListRef,
62
64
  scrollableVirtualListRef,
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { memo, useCallback, useMemo, useRef, useState } from 'react';
3
3
  import Box from '@mui/material/Box';
4
4
  import { pinIcon, unpinIcon } from '../../../../constants/index.js';
5
+ import { areTableHeaderCellPropsEqual } from '../../../../utils/index.js';
5
6
  import ColumnFilter from '../../components/ColumnFilter';
6
7
  import { StyledCell, TableHeaderInner } from '../../components/style';
7
8
  import { PinIconContainer, HeaderText } from '../style';
@@ -44,11 +45,9 @@ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, so
44
45
  right: 0,
45
46
  left: 0,
46
47
  bottom: 0,
47
- } }, headerStyle)) }, { children: _jsxs(TableHeaderInner, Object.assign({ onClick: handleHeaderInnerClick }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "SheetViewTableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && _jsx(HeaderText, Object.assign({ "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell_header_text" }, { children: header })) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter, { anchorEl: columnFilterEl, setAnchorEl: setColumnFilterEl })), sortable && (_jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, onClick: (e) => {
48
- onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, e, pinned);
49
- } })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
48
+ } }, headerStyle)) }, { children: _jsxs(TableHeaderInner, Object.assign({ onClick: handleHeaderInnerClick }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "SheetViewTableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && _jsx(HeaderText, Object.assign({ "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell_header_text" }, { children: header })) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter, { anchorEl: columnFilterEl, setAnchorEl: setColumnFilterEl })), sortable && _jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting }), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
50
49
  event.stopPropagation();
51
50
  handlePinClick(id);
52
51
  }, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] })) })));
53
52
  }
54
- export default memo(SheetViewTableHeaderCell);
53
+ export default memo(SheetViewTableHeaderCell, areTableHeaderCellPropsEqual);
@@ -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';
@@ -0,0 +1,38 @@
1
+ /// <reference types="react" />
2
+ import type { IColumnProps } from '../../../../types/index.js';
3
+ export declare const usePerformanceOptimizations: (columns: readonly IColumnProps[]) => {
4
+ stableColumns: IColumnProps<any>[];
5
+ stableColumnsWithFilters: {
6
+ filter: ({
7
+ onConfirm?: ((filterValues: import("../../../../types/index.js").ColumnFilterValues) => void) | undefined;
8
+ onClear: (apiKeys: string[]) => void;
9
+ onClearFilterFields?: (() => void) | undefined;
10
+ data?: import("../../../../types/index.js").ColumnFilterValues | undefined;
11
+ isOnlyOneFilter?: boolean | undefined;
12
+ wrapperSx?: import("@mui/system").SxProps | undefined;
13
+ } & (import("../../../../types/index.js").IColumnFilterList | import("../../../../types/index.js").IColumnFilterInputs | import("../../../../types/index.js").IColumnFilterCustom)) | undefined;
14
+ header?: string | (() => import("react").ReactNode) | undefined;
15
+ render?: ((props: import("../../../../types/index.js").IRenderAttr<any, IColumnProps<any>>) => import("react").ReactNode) | undefined;
16
+ id: string | number | symbol;
17
+ tableViewId?: string | undefined;
18
+ width?: import("csstype").Property.Width<string | number> | undefined;
19
+ format?: ((props: import("../../../../types/index.js").IFormatAttr<any>) => string) | undefined;
20
+ selector?: ((props: import("../../../../types/index.js").ISelectorAttr<any>) => string | number | Record<string, any>) | undefined;
21
+ align?: import("csstype").Property.TextAlign | undefined;
22
+ sortable?: boolean | undefined;
23
+ hidden?: boolean | undefined;
24
+ order?: number | undefined;
25
+ pinned?: "start" | "end" | undefined;
26
+ pinnable?: boolean | undefined;
27
+ cellStyle?: import("react").CSSProperties | undefined;
28
+ headerStyle?: import("react").CSSProperties | undefined;
29
+ isDefaultPinned?: boolean | undefined;
30
+ }[];
31
+ columnMetrics: {
32
+ visibleColumns: IColumnProps<any>[];
33
+ totalWidth: number;
34
+ columnCount: number;
35
+ firstColumnId: string | number | symbol;
36
+ lastColumnId: string | number | symbol;
37
+ };
38
+ };
@@ -0,0 +1,44 @@
1
+ import { useMemo, useRef } from 'react';
2
+ export const usePerformanceOptimizations = (columns) => {
3
+ const stableColumnsRef = useRef([]);
4
+ const stableColumns = useMemo(() => {
5
+ const hasChanged = columns.length !== stableColumnsRef.current.length ||
6
+ columns.some((col, index) => {
7
+ const prevCol = stableColumnsRef.current[index];
8
+ return (!prevCol ||
9
+ col.id !== prevCol.id ||
10
+ col.width !== prevCol.width ||
11
+ col.pinned !== prevCol.pinned ||
12
+ col.hidden !== prevCol.hidden ||
13
+ col.order !== prevCol.order);
14
+ });
15
+ if (hasChanged) {
16
+ stableColumnsRef.current = [...columns];
17
+ }
18
+ return stableColumnsRef.current;
19
+ }, [columns]);
20
+ const stableColumnsWithFilters = useMemo(() => {
21
+ return stableColumns.map((stableCol, index) => {
22
+ const currentCol = columns[index];
23
+ return Object.assign(Object.assign({}, stableCol), { filter: currentCol === null || currentCol === void 0 ? void 0 : currentCol.filter });
24
+ });
25
+ }, [stableColumns, columns]);
26
+ const columnMetrics = useMemo(() => {
27
+ var _a, _b;
28
+ const visibleColumns = stableColumns.filter((col) => !col.hidden);
29
+ const totalWidth = visibleColumns.reduce((sum, col) => sum + +((col === null || col === void 0 ? void 0 : col.width) || 100), 0);
30
+ const columnCount = visibleColumns.length;
31
+ return {
32
+ visibleColumns,
33
+ totalWidth,
34
+ columnCount,
35
+ firstColumnId: (_a = visibleColumns[0]) === null || _a === void 0 ? void 0 : _a.id,
36
+ lastColumnId: (_b = visibleColumns[columnCount - 1]) === null || _b === void 0 ? void 0 : _b.id,
37
+ };
38
+ }, [stableColumns]);
39
+ return {
40
+ stableColumns,
41
+ stableColumnsWithFilters,
42
+ columnMetrics,
43
+ };
44
+ };
@@ -17,6 +17,7 @@ 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,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 {};
@@ -1,11 +1,9 @@
1
1
  import { useCallback, useMemo } from 'react';
2
2
  import memoize from 'memoize-one';
3
- const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToIndex, lastItemIndex, totalCount, isError, areAllRowsLoaded, isPinned, selectedCell, selectedColumn, selectedRow, selectedChip, onCellClick, onChipClick, containerHeight, rowHeight) => ({
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,15 +12,19 @@ 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
+ const createItemData = (coreData, interactionData, scrollToIndex, isLoading) => (Object.assign(Object.assign(Object.assign({}, coreData), interactionData), { scrollToIndex,
27
+ isLoading }));
26
28
  export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick, }) => {
27
29
  const getItemSize = useCallback((index, height) => {
28
30
  const isLastRow = areAllRowsLoaded && index === rows.length;
@@ -34,21 +36,15 @@ export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, is
34
36
  }
35
37
  return rowHeight;
36
38
  }, [areAllRowsLoaded, rows.length, rowHeight]);
37
- const commonItemDataParams = useMemo(() => {
39
+ const coreItemData = useMemo(() => {
38
40
  var _a;
39
- return [
40
- isDelayedFetchingNextPage,
41
- rows,
42
- rowProps,
43
- scrollToIndex,
44
- rows.length - 1,
45
- (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0,
46
- isError,
47
- areAllRowsLoaded,
48
- ];
49
- }, [isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount, isError, areAllRowsLoaded]);
50
- const commonItemDataSuffix = useMemo(() => [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick], [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick]);
51
- const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => createItemData(columnsData, ...commonItemDataParams, isPinnedColumn, ...commonItemDataSuffix, height, rowHeight), [commonItemDataParams, commonItemDataSuffix, rowHeight]);
41
+ return createCoreItemData(null, rows, rowProps, (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0, rows.length - 1, isError, areAllRowsLoaded, false, 0, rowHeight);
42
+ }, [rows, rowProps, footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount, isError, areAllRowsLoaded, rowHeight]);
43
+ const interactionData = useMemo(() => createInteractionData(selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick), [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick]);
44
+ const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => {
45
+ const coreWithOverrides = Object.assign(Object.assign({}, coreItemData), { columns: columnsData, isPinned: isPinnedColumn, containerHeight: height });
46
+ return createItemData(coreWithOverrides, interactionData, scrollToIndex, isDelayedFetchingNextPage);
47
+ }, [coreItemData, interactionData, scrollToIndex, isDelayedFetchingNextPage]);
52
48
  return {
53
49
  getItemSize,
54
50
  getItemDataForContainer,
@@ -6,23 +6,25 @@ import { areEqual } from 'react-window';
6
6
  import { StyledCell, StyledTableRow } from './style';
7
7
  import { getSelectionStyles, getRowSelectionBorderStyles } from '../../../utils/index.js';
8
8
  function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = null, selectedColumn = null, selectedRow = null, selectedChip = null, onCellClick, isLastRow = false, onChipClick, }) {
9
- const renderCell = (column, rowIndex, colIndex) => {
10
- const { render, format, selector } = column;
11
- const handleChipClick = (event, chipIndex) => {
12
- onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(rowIndex, colIndex, event, chipIndex, column.pinned);
9
+ const renderCell = useMemo(() => {
10
+ return (column, rowIndex, colIndex) => {
11
+ const { render, format, selector } = column;
12
+ const handleChipClick = (event, chipIndex) => {
13
+ onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(rowIndex, colIndex, event, chipIndex, column.pinned);
14
+ };
15
+ if (!(column === null || column === void 0 ? void 0 : column.id) || !row)
16
+ return null;
17
+ const value = selector ? selector({ row, index, value: row[column === null || column === void 0 ? void 0 : column.id] }) : row[column === null || column === void 0 ? void 0 : column.id];
18
+ const formattedValue = format ? format({ value, row, index }) : value;
19
+ return render ? (render({
20
+ row,
21
+ column,
22
+ index,
23
+ value: row[column === null || column === void 0 ? void 0 : column.id],
24
+ selectionProps: { onClick: handleChipClick, rowIndex, colIndex, selectedId: selectedChip },
25
+ })) : (_jsx(_Fragment, { children: formattedValue }));
13
26
  };
14
- if (!(column === null || column === void 0 ? void 0 : column.id) || !row)
15
- return null;
16
- const value = selector ? selector({ row, index, value: row[column === null || column === void 0 ? void 0 : column.id] }) : row[column === null || column === void 0 ? void 0 : column.id];
17
- const formattedValue = format ? format({ value, row, index }) : value;
18
- return render ? (render({
19
- row,
20
- column,
21
- index,
22
- value: row[column === null || column === void 0 ? void 0 : column.id],
23
- selectionProps: { onClick: handleChipClick, rowIndex, colIndex, selectedId: selectedChip },
24
- })) : (_jsx(_Fragment, { children: formattedValue }));
25
- };
27
+ }, [row, index, selectedChip, onChipClick]);
26
28
  const content = useMemo(() => (_jsx(_Fragment, { children: columns.map((column, colIndex) => {
27
29
  var _a, _b;
28
30
  const cellKey = `${(_a = column.pinned) !== null && _a !== void 0 ? _a : 'default'}-${index}-${colIndex}`;
@@ -48,7 +50,7 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
48
50
  }
49
51
  const rowSelectionBorderStyles = isRowSelected
50
52
  ? getRowSelectionBorderStyles({
51
- effectiveFirst,
53
+ isFirstColumn,
52
54
  isPinnedStart: column.pinned === 'start',
53
55
  isPinnedEnd: column.pinned === 'end',
54
56
  })
@@ -57,7 +59,7 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
57
59
  return (_jsx(StyledCell, Object.assign({ component: "div", "data-testid": "TableRow_TableCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, isFirst: effectiveFirst, isLast: effectiveLast, onClick: (event) => {
58
60
  onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(index, colIndex, event, column.pinned);
59
61
  }, sx: Object.assign(Object.assign(Object.assign({ width: column.width, minWidth: column.width, textAlign: column.align, justifyContent: isIndexColumn ? 'center' : column.align === 'right' ? 'flex-end' : 'flex-start', cursor: onCellClick ? 'pointer' : 'default' }, selectionStyles), rowSelectionBorderStyles), column.cellStyle), isSheetView: isSheetView, isSelected: isCellSelected }, { children: isSheetView ? (_jsx(Box, Object.assign({ sx: { position: 'relative', zIndex: 1 } }, { children: renderCell(column, index, colIndex) }))) : (_jsx(_Fragment, { children: renderCell(column, index, colIndex) })) }), `${column.id}-${colIndex}`));
60
- }) })), [columns, row, index, selectedCell, selectedColumn, selectedRow, onCellClick, isLastRow, selectedChip, isSheetView]);
62
+ }) })), [columns, index, selectedCell, selectedColumn, selectedRow, onCellClick, isLastRow, isSheetView, renderCell]);
61
63
  return (_createElement(StyledTableRow, Object.assign({ "data-testid": "TableRow", onClick: rowProps === null || rowProps === void 0 ? void 0 : rowProps.onRowClick, showShadowHighlight: rowProps === null || rowProps === void 0 ? void 0 : rowProps.showShadowHighlight, showLoadedStyle: rowProps === null || rowProps === void 0 ? void 0 : rowProps.showLoadedStyle, component: "article" }, rowProps, { key: index, isSheetView: isSheetView }), content));
62
64
  }
63
65
  export default memo(TableRow, areEqual);
@@ -66,9 +66,9 @@ function ListItemWrapper(_a) {
66
66
  width: '100%',
67
67
  } }, { children: isError ? _jsx(RowErrorState, {}) : lastRowContent })));
68
68
  }, [isError]);
69
+ const isLastRow = React.useMemo(() => isLoadingRow || (areAllRowsLoaded && index === lastItemIndex + 1), [isLoadingRow, areAllRowsLoaded, index, lastItemIndex]);
69
70
  const memoizedListItemComponent = React.useMemo(() => {
70
71
  const lastRowContent = _jsx(LastRowContent, { isSheetView: isSheetView, isLoadingRow: isLoadingRow, columns: columns, currentRowCount: rows.length });
71
- const isLastRow = isLoadingRow || (areAllRowsLoaded && index === lastItemIndex + 1);
72
72
  if (isPinned && isLastRow) {
73
73
  if (isSheetView && isLoadingRow && columns && columns.length > 0) {
74
74
  return renderSheetViewLoadingRow(lastRowContent);
@@ -3,6 +3,6 @@ export declare const TABLE_CONTENT_ROW_HEIGHT = 70;
3
3
  export declare const TABLE_ROW_HEIGHT = 57;
4
4
  export declare const TABLE_THRESHOLD = 200;
5
5
  export declare const TABLE_LIST_OVER_SCAN = 5;
6
- export declare const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 50;
6
+ export declare const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 20;
7
7
  export declare const SHEET_VIEW_TABLE_THRESHOLD = 20;
8
8
  export declare const SHEET_VIEW_TABLE_ROW_HEIGHT = 28;
@@ -3,6 +3,6 @@ export const TABLE_CONTENT_ROW_HEIGHT = 70;
3
3
  export const TABLE_ROW_HEIGHT = 57;
4
4
  export const TABLE_THRESHOLD = 200;
5
5
  export const TABLE_LIST_OVER_SCAN = 5;
6
- export const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 50;
6
+ export const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 20;
7
7
  export const SHEET_VIEW_TABLE_THRESHOLD = 20;
8
8
  export const SHEET_VIEW_TABLE_ROW_HEIGHT = 28;
@@ -41,3 +41,4 @@ export * from './flag';
41
41
  export * from './encrypt';
42
42
  export * from './day';
43
43
  export * from './style';
44
+ export * from './memoComparison';
@@ -41,3 +41,4 @@ export * from './flag';
41
41
  export * from './encrypt';
42
42
  export * from './day';
43
43
  export * from './style';
44
+ export * from './memoComparison';
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import type { IColumnProps } from '../types/index.js';
3
+ interface SheetViewTableHeaderCellProps {
4
+ column: IColumnProps;
5
+ colIndex: number;
6
+ isFirst: boolean;
7
+ isLast: boolean;
8
+ isSelected: boolean;
9
+ isDefaultPinned: boolean;
10
+ isPinnable?: boolean;
11
+ lastColumnId?: string | null;
12
+ columnsSorting?: Record<string, 'asc' | 'desc'>;
13
+ pinnedColumns?: string[];
14
+ onColumnSort?: (columnsSorting: Record<string, 'asc' | 'desc'>) => void;
15
+ onColumnPin?: (columnId: string, position: 'start' | 'end' | 'unpin') => void;
16
+ onColumnClick?: (columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
17
+ }
18
+ export declare const areTableHeaderCellPropsEqual: (prevProps: SheetViewTableHeaderCellProps, nextProps: SheetViewTableHeaderCellProps) => boolean;
19
+ export {};
@@ -0,0 +1,24 @@
1
+ export const areTableHeaderCellPropsEqual = (prevProps, nextProps) => {
2
+ const prevCol = prevProps.column;
3
+ const nextCol = nextProps.column;
4
+ const filterChanged = prevCol.filter !== nextCol.filter;
5
+ const essentialPropsChanged = prevCol.id !== nextCol.id ||
6
+ prevCol.header !== nextCol.header ||
7
+ prevCol.width !== nextCol.width ||
8
+ prevCol.align !== nextCol.align ||
9
+ prevCol.pinned !== nextCol.pinned ||
10
+ prevCol.sortable !== nextCol.sortable ||
11
+ prevCol.pinnable !== nextCol.pinnable ||
12
+ prevCol.order !== nextCol.order ||
13
+ JSON.stringify(prevCol.headerStyle) !== JSON.stringify(nextCol.headerStyle);
14
+ const otherPropsChanged = prevProps.colIndex !== nextProps.colIndex ||
15
+ prevProps.isFirst !== nextProps.isFirst ||
16
+ prevProps.isLast !== nextProps.isLast ||
17
+ prevProps.isSelected !== nextProps.isSelected ||
18
+ prevProps.isDefaultPinned !== nextProps.isDefaultPinned ||
19
+ prevProps.isPinnable !== nextProps.isPinnable ||
20
+ prevProps.lastColumnId !== nextProps.lastColumnId ||
21
+ JSON.stringify(prevProps.columnsSorting) !== JSON.stringify(nextProps.columnsSorting) ||
22
+ JSON.stringify(prevProps.pinnedColumns) !== JSON.stringify(nextProps.pinnedColumns);
23
+ return !filterChanged && !essentialPropsChanged && !otherPropsChanged;
24
+ };
@@ -14,9 +14,9 @@ interface GetSelectionStylesParams {
14
14
  type SelectionStyles = Record<string, string | Record<string, string>>;
15
15
  export declare const getSelectionStyles: ({ isSelected, isCellSelected, isColumnSelected, isRowSelected, isLastRow, }: GetSelectionStylesParams) => SelectionStyles;
16
16
  interface GetRowSelectionBorderStylesParams {
17
- effectiveFirst: boolean;
17
+ isFirstColumn: boolean;
18
18
  isPinnedStart: boolean;
19
19
  isPinnedEnd: boolean;
20
20
  }
21
- export declare const getRowSelectionBorderStyles: ({ effectiveFirst, isPinnedStart, isPinnedEnd }: GetRowSelectionBorderStylesParams) => SelectionStyles;
21
+ export declare const getRowSelectionBorderStyles: ({ isFirstColumn, isPinnedStart, isPinnedEnd }: GetRowSelectionBorderStylesParams) => SelectionStyles;
22
22
  export {};
@@ -59,9 +59,9 @@ const getBorderWidthForColumn = () => {
59
59
  const getBorderBottomForColumn = (isLastRow) => {
60
60
  return isLastRow ? `${BORDER_STYLES.thick} solid ${SELECTION_COLORS.primary}` : `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.border}`;
61
61
  };
62
- export const getRowSelectionBorderStyles = ({ effectiveFirst, isPinnedStart, isPinnedEnd }) => ({
62
+ export const getRowSelectionBorderStyles = ({ isFirstColumn, isPinnedStart, isPinnedEnd }) => ({
63
63
  borderTop: `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.primary}`,
64
64
  borderBottom: `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.primary}`,
65
65
  borderRight: `${BORDER_STYLES.thin} solid ${isPinnedEnd ? SELECTION_COLORS.primary : 'none'}`,
66
- borderLeft: `${BORDER_STYLES.thin} solid ${isPinnedStart && effectiveFirst ? SELECTION_COLORS.primary : 'transparent'}`,
66
+ borderLeft: `${BORDER_STYLES.thin} solid ${isPinnedStart && isFirstColumn ? SELECTION_COLORS.primary : 'transparent'}`,
67
67
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
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.129",
4
+ "version": "0.1.130-test.6",
5
5
  "testVersion": 6,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
@@ -136,4 +136,4 @@
136
136
  "publishConfig": {
137
137
  "registry": "https://registry.npmjs.org/"
138
138
  }
139
- }
139
+ }