@tap-payments/os-micro-frontend-shared 0.1.136-test.1 → 0.1.136-test.3

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.
@@ -5,7 +5,7 @@ export declare const usePerformanceOptimizations: (columns: readonly IColumnProp
5
5
  visibleColumns: IColumnProps<any>[];
6
6
  totalWidth: number;
7
7
  columnCount: number;
8
- firstColumnId: string | number | symbol | undefined;
9
- lastColumnId: string | number | symbol | undefined;
8
+ firstColumnId: string | number | symbol;
9
+ lastColumnId: string | number | symbol;
10
10
  };
11
11
  };
@@ -1,108 +1,37 @@
1
1
  import { useMemo, useRef } from 'react';
2
- import { isEqual, pick, has, sumBy, first, last, forEach } from 'lodash';
3
- // Deep comparison helper for filter data
4
- const areFilterDataEqual = (filter1, filter2) => {
5
- if (filter1 === filter2)
6
- return true;
7
- if (!filter1 || !filter2 || filter1.type === 'custom' || filter2.type === 'custom')
8
- return false;
9
- console.log({ filter1, filter2 });
10
- // Extract comparable properties (excluding functions) using lodash
11
- const getComparableProps = (filter) => {
12
- if (!filter)
13
- return null;
14
- // Pick only the data properties we want to compare, excluding functions
15
- const baseProps = pick(filter, ['type', 'data', 'options', 'isOnlyOneFilter']);
16
- // Conditionally add properties that might not exist
17
- const conditionalProps = {};
18
- if (has(filter, 'apiKey'))
19
- conditionalProps.apiKey = filter.apiKey;
20
- if (has(filter, 'countries'))
21
- conditionalProps.countries = filter.countries;
22
- if (has(filter, 'isCountriesLoading'))
23
- conditionalProps.isCountriesLoading = filter.isCountriesLoading;
24
- return Object.assign(Object.assign({}, baseProps), conditionalProps);
25
- };
26
- const props1 = getComparableProps(filter1);
27
- const props2 = getComparableProps(filter2);
28
- // Use lodash's deep equality check instead of manual comparison
29
- return isEqual(props1, props2);
30
- };
31
2
  export const usePerformanceOptimizations = (columns) => {
32
3
  // Create stable column references to prevent unnecessary re-renders
33
4
  const stableColumnsRef = useRef([]);
34
- const isFirstRenderRef = useRef(true);
35
- const filterChangeTrackingRef = useRef(new Map());
36
5
  const stableColumns = useMemo(() => {
37
- // On first render, just initialize and return columns
38
- if (isFirstRenderRef.current) {
39
- isFirstRenderRef.current = false;
40
- stableColumnsRef.current = [...columns];
41
- // Initialize filter tracking using lodash forEach
42
- forEach(columns, (col) => {
43
- filterChangeTrackingRef.current.set(col.id, col === null || col === void 0 ? void 0 : col.filter);
44
- });
45
- return stableColumnsRef.current;
46
- }
47
- // After first render, only update if structural changes or filter changes occurred
48
- const structurallyChanged = columns.length !== stableColumnsRef.current.length ||
6
+ // Only update if columns have actually changed (deep comparison of essential properties)
7
+ const hasChanged = columns.length !== stableColumnsRef.current.length ||
49
8
  columns.some((col, index) => {
50
9
  const prevCol = stableColumnsRef.current[index];
51
- if (!prevCol)
52
- return true;
53
- // Extract structural properties and compare using lodash
54
- const currentStructure = pick(col, ['id', 'width', 'pinned', 'hidden', 'order']);
55
- const prevStructure = pick(prevCol, ['id', 'width', 'pinned', 'hidden', 'order']);
56
- return !isEqual(currentStructure, prevStructure);
10
+ return (!prevCol ||
11
+ col.id !== prevCol.id ||
12
+ col.width !== prevCol.width ||
13
+ col.pinned !== prevCol.pinned ||
14
+ col.hidden !== prevCol.hidden ||
15
+ col.order !== prevCol.order ||
16
+ col.filter !== prevCol.filter);
57
17
  });
58
- // Check for filter-only changes using lodash forEach
59
- const columnsWithFilterChanges = new Set();
60
- forEach(columns, (col) => {
61
- const colId = col.id;
62
- const prevFilter = filterChangeTrackingRef.current.get(colId);
63
- const currentFilter = col === null || col === void 0 ? void 0 : col.filter;
64
- console.log({ col });
65
- if (!areFilterDataEqual(prevFilter, currentFilter)) {
66
- columnsWithFilterChanges.add(colId);
67
- filterChangeTrackingRef.current.set(colId, currentFilter);
68
- }
69
- });
70
- // Only update if there are structural changes or filter changes
71
- if (structurallyChanged || columnsWithFilterChanges.size > 0) {
72
- // For filter-only changes, update only the affected columns
73
- if (!structurallyChanged && columnsWithFilterChanges.size > 0) {
74
- // Create a new array but preserve references for unchanged columns
75
- const updatedColumns = stableColumnsRef.current.map((stableCol, index) => {
76
- const newCol = columns[index];
77
- const colId = newCol === null || newCol === void 0 ? void 0 : newCol.id;
78
- // Only replace if this column's filter changed
79
- if (columnsWithFilterChanges.has(colId)) {
80
- return newCol;
81
- }
82
- // Keep the stable reference for unchanged columns
83
- return stableCol;
84
- });
85
- stableColumnsRef.current = updatedColumns;
86
- }
87
- else {
88
- // Full update for structural changes
89
- stableColumnsRef.current = [...columns];
90
- }
18
+ if (hasChanged) {
19
+ stableColumnsRef.current = [...columns];
91
20
  }
92
21
  return stableColumnsRef.current;
93
22
  }, [columns]);
94
- // Memoize frequently used column calculations using lodash utilities
23
+ // Memoize frequently used column calculations
95
24
  const columnMetrics = useMemo(() => {
96
25
  var _a, _b;
97
26
  const visibleColumns = stableColumns.filter((col) => !col.hidden);
98
- const totalWidth = sumBy(visibleColumns, (col) => +((col === null || col === void 0 ? void 0 : col.width) || 100));
27
+ const totalWidth = visibleColumns.reduce((sum, col) => sum + +((col === null || col === void 0 ? void 0 : col.width) || 100), 0);
99
28
  const columnCount = visibleColumns.length;
100
29
  return {
101
30
  visibleColumns,
102
31
  totalWidth,
103
32
  columnCount,
104
- firstColumnId: (_a = first(visibleColumns)) === null || _a === void 0 ? void 0 : _a.id,
105
- lastColumnId: (_b = last(visibleColumns)) === null || _b === void 0 ? void 0 : _b.id,
33
+ firstColumnId: (_a = visibleColumns[0]) === null || _a === void 0 ? void 0 : _a.id,
34
+ lastColumnId: (_b = visibleColumns[columnCount - 1]) === null || _b === void 0 ? void 0 : _b.id,
106
35
  };
107
36
  }, [stableColumns]);
108
37
  return {
@@ -1,7 +1,10 @@
1
1
  export { default as AccordionAdapter } from './AccordionAdapter';
2
2
  export { default as ActionMenu, ActionMenuDropDown, ActionMenuItem, type ActionMenuProps } from './ActionMenu';
3
3
  export { default as ActivityAreaChart, type ActivityAreaChartProps, type ChartDataPoint, ChartTooltip, type ChartTooltipProps, LoadingChart, type PayloadItem, } from './ActivityAreaChart';
4
- export { default as AppWindowWrapper, type AccountHeaderProps, AccountHeaderTitle, AppWindowHeader, type AppWindowHeaderProps, type AppWindowHeaderBaseProps, AppWindow, type AccountHeaderTitleProps, type AppWindowProps, type WindowProps, AppWindowContext, AppWindowContextProvider, LEFT_SIDEBAR, RIGHT_SIDEBAR, VIEWER_HEIGHT, VIEWER_WIDTH, animationDuration, StyledFooter, StyledHideButton, StyledMenuLink, StyledSubmitButton, SubmitButtonWrapper, } from './AppWindowWrapper';
4
+ export { default as AppWindowWrapper, type AccountHeaderProps, AccountHeaderTitle, AppWindowHeader, type AppWindowHeaderProps, type AppWindowHeaderBaseProps, AppWindow, type AccountHeaderTitleProps, type AppWindowProps, type WindowProps, AppWindowContext, AppWindowContextProvider, LEFT_SIDEBAR, RIGHT_SIDEBAR, VIEWER_HEIGHT, VIEWER_WIDTH, animationDuration, StyledFooter, // used account , leads
5
+ StyledHideButton, StyledMenuLink, // used account only
6
+ StyledSubmitButton, // used account , leads
7
+ SubmitButtonWrapper, } from './AppWindowWrapper';
5
8
  export { default as BackgroundAnimation, type BlobGradient, type Blob } from './BackgroundAnimation';
6
9
  export { default as Button, PlusButton, StyledButton } from './Button';
7
10
  export { default as Calender, type CalenderProps, type DateObject } from './Calender';
@@ -13,7 +16,9 @@ export { default as Dialog, DialogToolbar } from './Dialog';
13
16
  export { default as Tooltip } from './Tooltip';
14
17
  export * from './RFH';
15
18
  export { VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, // To not to be confused/conflicted with the other seperated `components/TableHeader`
16
- TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, TableFooter, TableError, } from './VirtualTables';
19
+ TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, // used src\features\shared\MerchantsDropdown\MerchantsDropdown.tsx only
20
+ ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, // used src\features\shared\Account\UserDetailsContent\components\TableCell\TableCell.tsx only
21
+ TableFooter, TableError, } from './VirtualTables';
17
22
  export { default as SheetViewVirtualTable } from './VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable';
18
23
  export { default as Widget, ListItem, WidgetHeader, WidgetList } from './Widget';
19
24
  export { default as TapLogo } from './TapLogo';
@@ -1,7 +1,11 @@
1
1
  export { default as AccordionAdapter } from './AccordionAdapter';
2
2
  export { default as ActionMenu, ActionMenuDropDown, ActionMenuItem } from './ActionMenu';
3
3
  export { default as ActivityAreaChart, ChartTooltip, LoadingChart, } from './ActivityAreaChart';
4
- export { default as AppWindowWrapper, AccountHeaderTitle, AppWindowHeader, AppWindow, AppWindowContext, AppWindowContextProvider, LEFT_SIDEBAR, RIGHT_SIDEBAR, VIEWER_HEIGHT, VIEWER_WIDTH, animationDuration, StyledFooter, StyledHideButton, StyledMenuLink, StyledSubmitButton, SubmitButtonWrapper, } from './AppWindowWrapper';
4
+ export { default as AppWindowWrapper, AccountHeaderTitle, AppWindowHeader, AppWindow, AppWindowContext, AppWindowContextProvider, LEFT_SIDEBAR, RIGHT_SIDEBAR, VIEWER_HEIGHT, VIEWER_WIDTH, animationDuration, StyledFooter, // used account , leads
5
+ StyledHideButton, StyledMenuLink, // used account only
6
+ StyledSubmitButton, // used account , leads
7
+ SubmitButtonWrapper, // used account , leads
8
+ } from './AppWindowWrapper';
5
9
  export { default as BackgroundAnimation } from './BackgroundAnimation';
6
10
  export { default as Button, PlusButton, StyledButton } from './Button';
7
11
  export { default as Calender } from './Calender';
@@ -13,7 +17,9 @@ export { default as Dialog, DialogToolbar } from './Dialog';
13
17
  export { default as Tooltip } from './Tooltip';
14
18
  export * from './RFH';
15
19
  export { VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, // To not to be confused/conflicted with the other seperated `components/TableHeader`
16
- TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, TableFooter, TableError, } from './VirtualTables';
20
+ TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, // used src\features\shared\MerchantsDropdown\MerchantsDropdown.tsx only
21
+ ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, // used src\features\shared\Account\UserDetailsContent\components\TableCell\TableCell.tsx only
22
+ TableFooter, TableError, } from './VirtualTables';
17
23
  export { default as SheetViewVirtualTable } from './VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable';
18
24
  export { default as Widget, ListItem, WidgetHeader, WidgetList } from './Widget';
19
25
  export { default as TapLogo } from './TapLogo';
@@ -29,6 +35,7 @@ export { default as WindowSideBar, TITLE_BAR_HEIGHT } from './WindowSideBar';
29
35
  export { default as WindowAppIcon } from './WindowAppIcon';
30
36
  export { default as Window } from './Window';
31
37
  export * from './ToolbarIcon';
38
+ // StyledHeaderWrapper used src\features\AppWindow\components\AppWindowHeader\AppWindowHeader.tsx only
32
39
  export { default as Toolbar, StyledHeaderWrapper, StyledHeaderWrapperStyled } from './Toolbar';
33
40
  export { default as ToggleButtons } from './ToggleButtons';
34
41
  export { default as Text } from './Text';
@@ -59,6 +66,7 @@ export * from './Inputs';
59
66
  export { default as JSONViewer, FooterButton, JSONTitleBar, JsonViewerDialogContext, JSONViewerList, useJsonViewerContext, JsonViewerDialogContextProvider, } from './JSONViewer';
60
67
  export { default as Loader } from './Loader';
61
68
  export { default as MUIThemeProvider } from './MUIThemeProvider';
69
+ // ImageWrapper used src\features\shared\Account\BrandDetails\components\AppsIcons\AppsIcons.tsx only
62
70
  export { default as ImageWrapper } from './ImageWrapper';
63
71
  export { default as Input } from './Input';
64
72
  export { default as IconGallery } from './IconGallery';
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.136-test.1",
5
- "testVersion": 1,
4
+ "version": "0.1.136-test.3",
5
+ "testVersion": 3,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",