@tap-payments/os-micro-frontend-shared 0.1.135-test.4 → 0.1.136

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
+ ```
@@ -51,7 +51,7 @@ function CountriesList({ isLoading, countries, value: countryValue, onCountryCha
51
51
  border: 'none',
52
52
  height: 34,
53
53
  paddingInlineStart: '8px',
54
- } }, { children: isLoading ? (_jsx(Skeleton, { variant: "rectangular", width: 56.5, height: 20, sx: { borderRadius: '4px' } })) : (_jsxs(_Fragment, { children: [selectedCountry && (_jsxs(_Fragment, { children: [_jsx("img", { src: selectedCountry.logo, alt: "c", className: "logo" }), _jsx("span", { children: `+${selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.idd_prefix}` })] })), required && _jsx(Required, Object.assign({ component: "span" }, { children: "*" })), _jsx(Box, { component: "img", src: downArrowIcon, alt: "d", className: "arrow", sx: Object.assign({}, (open && { transform: 'rotate(180deg)' })) })] })) })), open && _jsx(CustomBackdrop, { onClick: closeDropdown, sx: { zIndex: 9999 } }), open && (_jsx(ClickAwayListener, Object.assign({ onClickAway: closeDropdown }, { children: _jsxs(CountriesWrapper, Object.assign({ id: "CountriesList_CountriesWrapper", open: open, anchorEl: anchorEl, "data-testid": "CountriesList_CountriesWrapper", placement: "bottom-start" }, { children: [_jsx(InputStyled, { endAdornment: _jsx("img", { src: searchIcon, alt: "arrow" }), onChange: handleSearch, hideArrows: true, "data-testid": "CountriesList_InputStyled", value: searchValue }), _jsx(CountriesListStyled, Object.assign({ "data-testid": "CountriesList_CountriesListStyled" }, { children: filteredCountries.map((country) => {
54
+ } }, { children: isLoading ? (_jsx(Skeleton, { variant: "rectangular", width: 56.5, height: 20, sx: { borderRadius: '4px' } })) : (_jsxs(_Fragment, { children: [selectedCountry && (_jsxs(_Fragment, { children: [_jsx("img", { src: selectedCountry.logo, alt: "c", className: "logo" }), _jsx("span", { children: `+${selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.idd_prefix}` })] })), required && _jsx(Required, Object.assign({ component: "span" }, { children: "*" })), _jsx(Box, { component: "img", src: downArrowIcon, alt: "d", className: "arrow", sx: Object.assign({}, (open && { transform: 'rotate(180deg)' })) })] })) })), open && _jsx(CustomBackdrop, { onClick: closeDropdown }), open && (_jsx(ClickAwayListener, Object.assign({ onClickAway: closeDropdown }, { children: _jsxs(CountriesWrapper, Object.assign({ id: "CountriesList_CountriesWrapper", open: open, anchorEl: anchorEl, "data-testid": "CountriesList_CountriesWrapper", placement: "bottom-start" }, { children: [_jsx(InputStyled, { endAdornment: _jsx("img", { src: searchIcon, alt: "arrow" }), onChange: handleSearch, hideArrows: true, "data-testid": "CountriesList_InputStyled", value: searchValue }), _jsx(CountriesListStyled, Object.assign({ "data-testid": "CountriesList_CountriesListStyled" }, { children: filteredCountries.map((country) => {
55
55
  const isSelected = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.countryId) === country.countryId;
56
56
  return (_jsxs(CountryStyled, Object.assign({ onClick: () => {
57
57
  handleOnCountryChange(country);
@@ -1,14 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { memo, useCallback, useMemo } from 'react';
2
+ import { memo, useCallback } from 'react';
3
3
  import { SHEET_VIEW_TABLE_THRESHOLD } from '../../../constants/index.js';
4
4
  import TableFooter from '../components/TableFooter/TableFooter';
5
5
  import { SheetViewTableContainer } from '../components/style';
6
6
  import { SheetViewVirtualTableWrapper } from './style';
7
- import { usePinnedColumns, useSynchronizedScroll, useTableState, useTableData, useVirtualTableContainer, usePinnedColumnsWidths, usePerformanceOptimizations, } from './hooks';
7
+ import { usePinnedColumns, useSynchronizedScroll, useTableState, useTableData, useVirtualTableContainer, usePinnedColumnsWidths } from './hooks';
8
8
  import { PinnedColumn, MainTable, LoadingMainTable, NoDataView, VirtualTable } from './components';
9
9
  function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, rowHeight = 28, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableTitle, dragControls, onColumnPin, clearBackdropVisibilityTimeout = 100, isPinnable = false, tableMode, overscanCount, }) {
10
- // Performance optimizations
11
- const { stableColumns, stableFilters } = usePerformanceOptimizations(columns);
12
10
  // Custom hooks for state management
13
11
  const { selectedCell, selectedColumn, selectedRow, showBackDrop, setShowBackdrop, handleCellClick, handleColumnClick, handleChipClick, selectedChip, } = useTableState();
14
12
  // Table data processing
@@ -20,7 +18,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
20
18
  areAllRowsLoaded,
21
19
  });
22
20
  // Column management
23
- const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(stableColumns, isPinnable, onColumnPin);
21
+ const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(columns, isPinnable, onColumnPin);
24
22
  // Scroll synchronization
25
23
  const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
26
24
  // Column width calculations
@@ -42,31 +40,6 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
42
40
  handleCellClick,
43
41
  handleChipClick,
44
42
  });
45
- // Memoized header props to prevent unnecessary re-renders when filters change
46
- const memoizedHeaderProps = useMemo(() => ({
47
- showHeader,
48
- columnsSorting,
49
- onColumnSort,
50
- headerProps,
51
- showBackDrop,
52
- onColumnPin: handleColumnPin,
53
- isPinnable,
54
- lastColumnId,
55
- selectedColumn,
56
- onColumnClick: handleColumnClick,
57
- }), [
58
- showHeader,
59
- columnsSorting,
60
- onColumnSort,
61
- headerProps,
62
- showBackDrop,
63
- handleColumnPin,
64
- isPinnable,
65
- lastColumnId,
66
- selectedColumn,
67
- handleColumnClick,
68
- stableFilters, // This dependency ensures re-render when filters change
69
- ]);
70
43
  const onPointerDown = (e) => {
71
44
  dragControls === null || dragControls === void 0 ? void 0 : dragControls.start(e);
72
45
  };
@@ -90,12 +63,22 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
90
63
  clearBackdropVisibilityTimeout,
91
64
  handleScroll,
92
65
  setShowBackdrop,
93
- overscanCount,
94
66
  pinnedStartVirtualListRef,
95
67
  pinnedEndVirtualListRef,
96
68
  scrollableVirtualListRef,
97
69
  ]);
98
- const baseCommonProps = Object.assign(Object.assign({}, memoizedHeaderProps), { tableTitle,
70
+ const baseCommonProps = {
71
+ showHeader,
72
+ columnsSorting,
73
+ onColumnSort,
74
+ headerProps,
75
+ showBackDrop,
76
+ onColumnPin: handleColumnPin,
77
+ isPinnable,
78
+ lastColumnId,
79
+ selectedColumn,
80
+ onColumnClick: handleColumnClick,
81
+ tableTitle,
99
82
  areAllRowsLoaded,
100
83
  isFetchingNextPage,
101
84
  scrollToIndex,
@@ -103,7 +86,8 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
103
86
  isError,
104
87
  tableMode,
105
88
  showNoDataView,
106
- tableBodyStyles });
89
+ tableBodyStyles,
90
+ };
107
91
  const commonPropsWithTableStates = Object.assign(Object.assign({}, baseCommonProps), { hasTimeoutError,
108
92
  tableLoading });
109
93
  return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (
@@ -4,4 +4,3 @@ 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,4 +4,3 @@ 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';
@@ -17,7 +17,6 @@ export const useTableState = () => {
17
17
  }
18
18
  setSelectedChip(chipKey);
19
19
  setSelectedCell(cellKey);
20
- setSelectedColumn(null);
21
20
  setSelectedRow(null);
22
21
  }, [selectedChip, setSelectedChip, setSelectedCell, setSelectedRow]);
23
22
  const handleCellClick = useCallback((rowIndex, columnIndex, event, pinnedType) => {
@@ -23,6 +23,28 @@ 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) => any;
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
+ };
27
49
  };
28
50
  export {};
@@ -1,9 +1,11 @@
1
1
  import { useCallback, useMemo } from 'react';
2
2
  import memoize from 'memoize-one';
3
- const createCoreItemData = memoize((columns, rows, rowProps, totalCount, lastItemIndex, isError, areAllRowsLoaded, isPinned, containerHeight, rowHeight) => ({
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,
5
+ isLoading,
5
6
  rows,
6
7
  rowProps,
8
+ scrollToIndex,
7
9
  totalCount,
8
10
  lastItemIndex,
9
11
  isError,
@@ -12,20 +14,15 @@ const createCoreItemData = memoize((columns, rows, rowProps, totalCount, lastIte
12
14
  newLoadedRowsEndIndex: lastItemIndex,
13
15
  isSheetView: true,
14
16
  isPinned,
15
- containerHeight,
16
- rowHeight,
17
- }));
18
- const createInteractionData = memoize((selectedCell, selectedColumn, selectedRow, selectedChip, onCellClick, onChipClick) => ({
19
17
  selectedCell,
20
18
  selectedColumn,
21
19
  selectedRow,
22
20
  selectedChip,
23
21
  onCellClick,
24
22
  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 }));
29
26
  export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick, }) => {
30
27
  const getItemSize = useCallback((index, height) => {
31
28
  const isLastRow = areAllRowsLoaded && index === rows.length;
@@ -38,21 +35,21 @@ export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, is
38
35
  }
39
36
  return rowHeight;
40
37
  }, [areAllRowsLoaded, rows.length, rowHeight]);
41
- // Memoize core data that changes less frequently
42
- const coreItemData = useMemo(() => {
38
+ const commonItemDataParams = useMemo(() => {
43
39
  var _a;
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]);
40
+ return [
41
+ isDelayedFetchingNextPage,
42
+ rows,
43
+ rowProps,
44
+ scrollToIndex,
45
+ rows.length - 1,
46
+ (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0,
47
+ isError,
48
+ areAllRowsLoaded,
49
+ ];
50
+ }, [isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount, isError, areAllRowsLoaded]);
51
+ const commonItemDataSuffix = useMemo(() => [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick], [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick]);
52
+ const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => createItemData(columnsData, ...commonItemDataParams, isPinnedColumn, ...commonItemDataSuffix, height, rowHeight), [commonItemDataParams, commonItemDataSuffix, rowHeight]);
56
53
  return {
57
54
  getItemSize,
58
55
  getItemDataForContainer,
@@ -6,25 +6,23 @@ 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 = 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 }));
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);
26
13
  };
27
- }, [row, index, selectedChip, onChipClick]);
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
+ };
28
26
  const content = useMemo(() => (_jsx(_Fragment, { children: columns.map((column, colIndex) => {
29
27
  var _a, _b;
30
28
  const cellKey = `${(_a = column.pinned) !== null && _a !== void 0 ? _a : 'default'}-${index}-${colIndex}`;
@@ -55,7 +53,7 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
55
53
  // Handle border styling for row selection
56
54
  const rowSelectionBorderStyles = isRowSelected
57
55
  ? getRowSelectionBorderStyles({
58
- isFirstColumn,
56
+ effectiveFirst,
59
57
  isPinnedStart: column.pinned === 'start',
60
58
  isPinnedEnd: column.pinned === 'end',
61
59
  })
@@ -64,7 +62,7 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
64
62
  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) => {
65
63
  onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(index, colIndex, event, column.pinned);
66
64
  }, 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}`));
67
- }) })), [columns, index, selectedCell, selectedColumn, selectedRow, onCellClick, isLastRow, isSheetView, renderCell]);
65
+ }) })), [columns, row, index, selectedCell, selectedColumn, selectedRow, onCellClick, isLastRow, selectedChip, isSheetView]);
68
66
  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));
69
67
  }
70
68
  export default memo(TableRow, areEqual);
@@ -68,9 +68,9 @@ function ListItemWrapper(_a) {
68
68
  width: '100%',
69
69
  } }, { children: isError ? _jsx(RowErrorState, {}) : lastRowContent })));
70
70
  }, [isError]);
71
- const isLastRow = React.useMemo(() => isLoadingRow || (areAllRowsLoaded && index === lastItemIndex + 1), [isLoadingRow, areAllRowsLoaded, index, lastItemIndex]);
72
71
  const memoizedListItemComponent = React.useMemo(() => {
73
72
  const lastRowContent = _jsx(LastRowContent, { isSheetView: isSheetView, isLoadingRow: isLoadingRow, columns: columns, currentRowCount: rows.length });
73
+ const isLastRow = isLoadingRow || (areAllRowsLoaded && index === lastItemIndex + 1);
74
74
  if (isPinned && isLastRow) {
75
75
  if (isSheetView && isLoadingRow && columns && columns.length > 0) {
76
76
  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 = 20;
6
+ export declare const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 50;
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 = 20;
6
+ export const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 50;
7
7
  export const SHEET_VIEW_TABLE_THRESHOLD = 20;
8
8
  export const SHEET_VIEW_TABLE_ROW_HEIGHT = 28;
@@ -25,9 +25,9 @@ type SelectionStyles = Record<string, string | Record<string, string>>;
25
25
  */
26
26
  export declare const getSelectionStyles: ({ isSelected, isCellSelected, isColumnSelected, isRowSelected, isLastRow, }: GetSelectionStylesParams) => SelectionStyles;
27
27
  interface GetRowSelectionBorderStylesParams {
28
- isFirstColumn: boolean;
28
+ effectiveFirst: boolean;
29
29
  isPinnedStart: boolean;
30
30
  isPinnedEnd: boolean;
31
31
  }
32
- export declare const getRowSelectionBorderStyles: ({ isFirstColumn, isPinnedStart, isPinnedEnd }: GetRowSelectionBorderStylesParams) => SelectionStyles;
32
+ export declare const getRowSelectionBorderStyles: ({ effectiveFirst, isPinnedStart, isPinnedEnd }: GetRowSelectionBorderStylesParams) => SelectionStyles;
33
33
  export {};
@@ -87,9 +87,9 @@ const getBorderWidthForColumn = () => {
87
87
  const getBorderBottomForColumn = (isLastRow) => {
88
88
  return isLastRow ? `${BORDER_STYLES.thick} solid ${SELECTION_COLORS.primary}` : `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.border}`;
89
89
  };
90
- export const getRowSelectionBorderStyles = ({ isFirstColumn, isPinnedStart, isPinnedEnd }) => ({
90
+ export const getRowSelectionBorderStyles = ({ effectiveFirst, isPinnedStart, isPinnedEnd }) => ({
91
91
  borderTop: `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.primary}`,
92
92
  borderBottom: `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.primary}`,
93
93
  borderRight: `${BORDER_STYLES.thin} solid ${isPinnedEnd ? SELECTION_COLORS.primary : 'none'}`,
94
- borderLeft: `${BORDER_STYLES.thin} solid ${isPinnedStart && isFirstColumn ? SELECTION_COLORS.primary : 'transparent'}`,
94
+ borderLeft: `${BORDER_STYLES.thin} solid ${isPinnedStart && effectiveFirst ? SELECTION_COLORS.primary : 'transparent'}`,
95
95
  });
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.135-test.4",
5
- "testVersion": 4,
4
+ "version": "0.1.136",
5
+ "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",
@@ -136,4 +136,4 @@
136
136
  "publishConfig": {
137
137
  "registry": "https://registry.npmjs.org/"
138
138
  }
139
- }
139
+ }
@@ -1,19 +0,0 @@
1
- import type { IColumnProps } from '../../../../types/index.js';
2
- interface StableFilterData {
3
- type: string;
4
- data?: unknown;
5
- options?: unknown;
6
- apiKey?: string;
7
- }
8
- export declare const usePerformanceOptimizations: (columns: readonly IColumnProps[]) => {
9
- stableColumns: IColumnProps<any>[];
10
- stableFilters: Record<string, StableFilterData>;
11
- columnMetrics: {
12
- visibleColumns: IColumnProps<any>[];
13
- totalWidth: number;
14
- columnCount: number;
15
- firstColumnId: string | number | symbol;
16
- lastColumnId: string | number | symbol;
17
- };
18
- };
19
- export {};
@@ -1,121 +0,0 @@
1
- import { useMemo, useRef } from 'react';
2
- export const usePerformanceOptimizations = (columns) => {
3
- // Create stable column references to prevent unnecessary re-renders
4
- const stableColumnsRef = useRef([]);
5
- // Create stable filter references to prevent unnecessary header re-renders
6
- const stableFiltersRef = useRef({});
7
- const stableColumns = useMemo(() => {
8
- // Only update if columns have actually changed (deep comparison of essential properties)
9
- const hasChanged = columns.length !== stableColumnsRef.current.length ||
10
- columns.some((col, index) => {
11
- const prevCol = stableColumnsRef.current[index];
12
- return (!prevCol ||
13
- col.id !== prevCol.id ||
14
- col.width !== prevCol.width ||
15
- col.pinned !== prevCol.pinned ||
16
- col.hidden !== prevCol.hidden ||
17
- col.order !== prevCol.order);
18
- });
19
- if (hasChanged) {
20
- stableColumnsRef.current = [...columns];
21
- }
22
- return stableColumnsRef.current;
23
- }, [columns]);
24
- const stableFilters = useMemo(() => {
25
- // Extract filter-related data from columns for header rendering optimization
26
- const currentFilters = {};
27
- columns.forEach((col) => {
28
- if (col.filter && col.id) {
29
- const columnId = col.id;
30
- const filterData = {
31
- type: col.filter.type,
32
- data: col.filter.data,
33
- options: col.filter.options,
34
- };
35
- // Only add apiKey if it exists (for 'list' type filters)
36
- if (col.filter.type === 'list') {
37
- filterData.apiKey = col.filter.apiKey;
38
- }
39
- currentFilters[columnId] = filterData;
40
- }
41
- });
42
- // Safe comparison helper that avoids circular references
43
- const safeCompare = (obj1, obj2) => {
44
- // Handle primitive types
45
- if (obj1 === obj2)
46
- return true;
47
- if (obj1 == null || obj2 == null)
48
- return obj1 === obj2;
49
- if (typeof obj1 !== 'object' || typeof obj2 !== 'object')
50
- return obj1 === obj2;
51
- // Handle arrays
52
- if (Array.isArray(obj1) && Array.isArray(obj2)) {
53
- if (obj1.length !== obj2.length)
54
- return false;
55
- return obj1.every((item, index) => safeCompare(item, obj2[index]));
56
- }
57
- if (Array.isArray(obj1) || Array.isArray(obj2))
58
- return false;
59
- // Handle objects - only compare basic properties, avoid complex nested objects
60
- const keys1 = Object.keys(obj1);
61
- const keys2 = Object.keys(obj2);
62
- if (keys1.length !== keys2.length)
63
- return false;
64
- return keys1.every((key) => {
65
- const val1 = obj1[key];
66
- const val2 = obj2[key];
67
- // Skip complex objects that might have circular references
68
- if (typeof val1 === 'object' && val1 != null && (val1.constructor === Object || Array.isArray(val1))) {
69
- return safeCompare(val1, val2);
70
- }
71
- // For other object types (like React contexts), just compare references
72
- return val1 === val2;
73
- });
74
- };
75
- // Deep comparison of filter state
76
- const hasFilterChanged = () => {
77
- const currentKeys = Object.keys(currentFilters);
78
- const prevKeys = Object.keys(stableFiltersRef.current);
79
- if (currentKeys.length !== prevKeys.length)
80
- return true;
81
- return currentKeys.some((key) => {
82
- const current = currentFilters[key];
83
- const prev = stableFiltersRef.current[key];
84
- if (!prev)
85
- return true;
86
- // Compare filter properties that affect rendering
87
- if (current.type !== prev.type || current.apiKey !== prev.apiKey)
88
- return true;
89
- // Safe comparison for options and data
90
- if (!safeCompare(current.options, prev.options))
91
- return true;
92
- if (!safeCompare(current.data, prev.data))
93
- return true;
94
- return false;
95
- });
96
- };
97
- if (hasFilterChanged()) {
98
- stableFiltersRef.current = Object.assign({}, currentFilters);
99
- }
100
- return stableFiltersRef.current;
101
- }, [columns]);
102
- // Memoize frequently used column calculations
103
- const columnMetrics = useMemo(() => {
104
- var _a, _b;
105
- const visibleColumns = stableColumns.filter((col) => !col.hidden);
106
- const totalWidth = visibleColumns.reduce((sum, col) => sum + +((col === null || col === void 0 ? void 0 : col.width) || 100), 0);
107
- const columnCount = visibleColumns.length;
108
- return {
109
- visibleColumns,
110
- totalWidth,
111
- columnCount,
112
- firstColumnId: (_a = visibleColumns[0]) === null || _a === void 0 ? void 0 : _a.id,
113
- lastColumnId: (_b = visibleColumns[columnCount - 1]) === null || _b === void 0 ? void 0 : _b.id,
114
- };
115
- }, [stableColumns]);
116
- return {
117
- stableColumns,
118
- stableFilters,
119
- columnMetrics,
120
- };
121
- };