@tap-payments/os-micro-frontend-shared 0.1.96 → 0.1.97-test.102

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.
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { memo, useCallback } from 'react';
2
+ import { memo, useCallback, useMemo } 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';
@@ -37,30 +37,50 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
37
37
  const onPointerDown = (e) => {
38
38
  dragControls === null || dragControls === void 0 ? void 0 : dragControls.start(e);
39
39
  };
40
- const createVirtualTableContainer = useCallback((columnsData, containerKey, isPinned = false, fixedWidth) => {
41
- const listRef = containerKey === 'pinnedStart' ? pinnedStartVirtualListRef : containerKey === 'pinnedEnd' ? pinnedEndVirtualListRef : scrollableVirtualListRef;
42
- const handleScrollCallback = (scrollProps) => {
43
- const source = containerKey === 'pinnedStart' ? 'start' : containerKey === 'pinnedEnd' ? 'end' : 'scrollable';
44
- handleScroll(scrollProps, source);
45
- };
46
- return (_jsx(VirtualTable, { columnsData: columnsData, itemCount: itemsCount, lastItemIndex: lastItemIndex, areAllRowsLoaded: areAllRowsLoaded, loadMoreItems: loadMoreItems, threshold: threshold, getItemSize: getItemSize, getItemData: getItemDataForContainer, isPinned: isPinned, fixedWidth: fixedWidth, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, onScroll: handleScrollCallback, setBackdropVisibility: setShowBackdrop, listRef: listRef, overscanCount: overscanCount }));
47
- }, [
40
+ const scrollHandlers = useMemo(() => ({
41
+ start: (scrollProps) => handleScroll(scrollProps, 'start'),
42
+ end: (scrollProps) => handleScroll(scrollProps, 'end'),
43
+ scrollable: (scrollProps) => handleScroll(scrollProps, 'scrollable'),
44
+ }), [handleScroll]);
45
+ const stableTableProps = useMemo(() => ({
46
+ itemCount: itemsCount,
47
+ lastItemIndex,
48
+ areAllRowsLoaded,
49
+ loadMoreItems,
50
+ threshold,
51
+ areTotalRowsNotFillingHeight,
52
+ clearBackdropVisibilityTimeout,
53
+ overscanCount,
54
+ }), [
48
55
  itemsCount,
49
56
  lastItemIndex,
50
57
  areAllRowsLoaded,
51
58
  loadMoreItems,
52
59
  threshold,
53
- getItemSize,
54
- getItemDataForContainer,
55
- scrollToIndex,
56
60
  areTotalRowsNotFillingHeight,
57
61
  clearBackdropVisibilityTimeout,
58
- handleScroll,
59
- setShowBackdrop,
60
- pinnedStartVirtualListRef,
61
- pinnedEndVirtualListRef,
62
- scrollableVirtualListRef,
62
+ overscanCount,
63
63
  ]);
64
+ const dynamicTableProps = useMemo(() => ({
65
+ getItemSize,
66
+ getItemData: getItemDataForContainer,
67
+ scrollToIndex,
68
+ setBackdropVisibility: setShowBackdrop,
69
+ }), [getItemSize, getItemDataForContainer, scrollToIndex, setShowBackdrop]);
70
+ const createPinnedStartTable = useCallback((columnsData, fixedWidth) => (_jsx(VirtualTable, Object.assign({ columnsData: columnsData }, stableTableProps, dynamicTableProps, { isPinned: true, fixedWidth: fixedWidth, onScroll: scrollHandlers.start, listRef: pinnedStartVirtualListRef }), "pinned-start")), [stableTableProps, dynamicTableProps, scrollHandlers.start, pinnedStartVirtualListRef]);
71
+ const createPinnedEndTable = useCallback((columnsData, fixedWidth) => (_jsx(VirtualTable, Object.assign({ columnsData: columnsData }, stableTableProps, dynamicTableProps, { isPinned: true, fixedWidth: fixedWidth, onScroll: scrollHandlers.end, listRef: pinnedEndVirtualListRef }), "pinned-end")), [stableTableProps, dynamicTableProps, scrollHandlers.end, pinnedEndVirtualListRef]);
72
+ const createScrollableTable = useCallback((columnsData) => (_jsx(VirtualTable, Object.assign({ columnsData: columnsData }, stableTableProps, dynamicTableProps, { isPinned: false, onScroll: scrollHandlers.scrollable, listRef: scrollableVirtualListRef }), "scrollable")), [stableTableProps, dynamicTableProps, scrollHandlers.scrollable, scrollableVirtualListRef]);
73
+ const createVirtualTableContainer = useCallback((columnsData, containerKey, isPinned = false, fixedWidth) => {
74
+ switch (containerKey) {
75
+ case 'pinnedStart':
76
+ return createPinnedStartTable(columnsData, fixedWidth);
77
+ case 'pinnedEnd':
78
+ return createPinnedEndTable(columnsData, fixedWidth);
79
+ case 'scrollable':
80
+ default:
81
+ return createScrollableTable(columnsData);
82
+ }
83
+ }, [createPinnedStartTable, createPinnedEndTable, createScrollableTable]);
64
84
  const baseCommonProps = {
65
85
  showHeader,
66
86
  columnsSorting,
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { memo } from 'react';
2
+ import { memo, useMemo } from 'react';
3
3
  import { useTheme } from '@mui/material/styles';
4
4
  import { StyledTableBox, TableWrapper, StyledBox } from '../../components/style';
5
5
  import { MainTableWrapper, UnpinnedTableHeaderWrapper } from '../style';
@@ -7,9 +7,31 @@ import SheetViewTableHeader from './SheetViewTableHeader';
7
7
  import SheetViewTableLoading from './SheetViewTableLoading';
8
8
  function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, pinnedStartColumns, pinnedEndColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, tableLoading, createVirtualTableContainer, }) {
9
9
  const theme = useTheme();
10
- return (_jsx(MainTableWrapper, Object.assign({ hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_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, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' }) }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_UnpinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [...pinnedStartColumns, ...pinnedEndColumns], onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: "scrollable", hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
10
+ const allPinnedColumns = useMemo(() => [...pinnedStartColumns, ...pinnedEndColumns], [pinnedStartColumns, pinnedEndColumns]);
11
+ const memoizedTableBodyStyles = useMemo(() => (Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' })), [tableBodyStyles]);
12
+ return (_jsx(MainTableWrapper, Object.assign({ hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_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, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: memoizedTableBodyStyles }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_UnpinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: allPinnedColumns, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: "scrollable", hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
11
13
  width: '100%',
12
14
  minWidth: 'fit-content',
13
15
  } }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_ScrollableStyledBox", hidePadding: true, className: "list-wrapper" }, { children: tableLoading ? (_jsx(SheetViewTableLoading, { "data-testid": "SheetViewVirtualTable_TableLoading", columns: unpinnedColumnsData, isLoading: true, isPinned: false })) : (createVirtualTableContainer(unpinnedColumnsData, 'scrollable', false)) })) }))] })) })) })));
14
16
  }
15
- export default memo(MainTable);
17
+ export default memo(MainTable, (prevProps, nextProps) => {
18
+ var _a, _b, _c, _d, _e, _f, _g;
19
+ const criticalProps = [
20
+ 'hasPinnedStart',
21
+ 'hasPinnedEnd',
22
+ 'showHeader',
23
+ 'showBackDrop',
24
+ 'tableLoading',
25
+ 'showNoDataView',
26
+ 'isLoading',
27
+ 'isError',
28
+ 'hasTimeoutError',
29
+ 'tableMode',
30
+ ];
31
+ const areCriticalPropsSame = criticalProps.every((prop) => prevProps[prop] === nextProps[prop]);
32
+ const areColumnsDataSame = ((_a = prevProps.unpinnedColumnsData) === null || _a === void 0 ? void 0 : _a.length) === ((_b = nextProps.unpinnedColumnsData) === null || _b === void 0 ? void 0 : _b.length) &&
33
+ ((_c = prevProps.unpinnedColumnsData) === null || _c === void 0 ? void 0 : _c.every((col, index) => { var _a, _b; return col.id === ((_b = (_a = nextProps.unpinnedColumnsData) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.id); }));
34
+ const arePinnedColumnsSame = ((_d = prevProps.pinnedStartColumns) === null || _d === void 0 ? void 0 : _d.length) === ((_e = nextProps.pinnedStartColumns) === null || _e === void 0 ? void 0 : _e.length) &&
35
+ ((_f = prevProps.pinnedEndColumns) === null || _f === void 0 ? void 0 : _f.length) === ((_g = nextProps.pinnedEndColumns) === null || _g === void 0 ? void 0 : _g.length);
36
+ return areCriticalPropsSame && areColumnsDataSame && arePinnedColumnsSame;
37
+ });
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { memo } from 'react';
2
+ import { memo, useMemo } from 'react';
3
3
  import { useTheme } from '@mui/material/styles';
4
4
  import { StyledTableBox, TableWrapper, StyledBox } from '../../components/style';
5
5
  import { PinnedStartColumnWrapper, PinnedEndColumnWrapper } from '../style';
@@ -9,12 +9,35 @@ function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList,
9
9
  const theme = useTheme();
10
10
  if (columnsData.length === 0)
11
11
  return null;
12
- const Wrapper = position === 'start' ? PinnedStartColumnWrapper : PinnedEndColumnWrapper;
13
- const containerKey = position === 'start' ? 'pinnedStart' : 'pinnedEnd';
12
+ const { Wrapper, containerKey } = useMemo(() => {
13
+ const key = position === 'start' ? 'pinnedStart' : 'pinnedEnd';
14
+ return {
15
+ Wrapper: position === 'start' ? PinnedStartColumnWrapper : PinnedEndColumnWrapper,
16
+ containerKey: key,
17
+ };
18
+ }, [position]);
14
19
  return (_jsx(Wrapper, { children: _jsxs(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_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: [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, tablePosition: position === 'start' ? 'pinnedStart' : 'pinnedEnd', hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
15
20
  width: '100%',
16
21
  minWidth: 'fit-content',
17
22
  overflowX: 'hidden',
18
23
  } }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_PinnedStyledBox", hidePadding: true, className: "list-wrapper" }, { children: tableLoading ? (_jsx(SheetViewTableLoading, { "data-testid": `SheetViewVirtualTable_PinnedTableLoading_${position}`, columns: columnsData, isLoading: true, isPinned: true })) : (createVirtualTableContainer(columnsData, containerKey, true, columnsWidth)) })) }))] })) }));
19
24
  }
20
- export default memo(PinnedColumn);
25
+ export default memo(PinnedColumn, (prevProps, nextProps) => {
26
+ var _a, _b, _c, _d, _e, _f;
27
+ const criticalProps = [
28
+ 'position',
29
+ 'columnsWidth',
30
+ 'showHeader',
31
+ 'showBackDrop',
32
+ 'tableLoading',
33
+ 'showNoDataView',
34
+ 'hasPinnedStart',
35
+ 'hasPinnedEnd',
36
+ ];
37
+ const areCriticalPropsSame = criticalProps.every((prop) => prevProps[prop] === nextProps[prop]);
38
+ const areColumnsDataSame = ((_a = prevProps.columnsData) === null || _a === void 0 ? void 0 : _a.length) === ((_b = nextProps.columnsData) === null || _b === void 0 ? void 0 : _b.length) &&
39
+ ((_c = prevProps.columnsData) === null || _c === void 0 ? void 0 : _c.every((col, index) => { var _a, _b, _c, _d; return col.id === ((_b = (_a = nextProps.columnsData) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.id) && col.width === ((_d = (_c = nextProps.columnsData) === null || _c === void 0 ? void 0 : _c[index]) === null || _d === void 0 ? void 0 : _d.width); }));
40
+ const arePinnedColumnsSame = ((_d = prevProps.pinnedColumnsList) === null || _d === void 0 ? void 0 : _d.length) === ((_e = nextProps.pinnedColumnsList) === null || _e === void 0 ? void 0 : _e.length) &&
41
+ ((_f = prevProps.pinnedColumnsList) === null || _f === void 0 ? void 0 : _f.every((col, index) => { var _a; return col === ((_a = nextProps.pinnedColumnsList) === null || _a === void 0 ? void 0 : _a[index]); }));
42
+ return areCriticalPropsSame && areColumnsDataSame && arePinnedColumnsSame;
43
+ });
@@ -30,4 +30,21 @@ function VirtualTable({ columnsData, itemCount, lastItemIndex, areAllRowsLoaded,
30
30
  } }, { children: ListItemWrapper })));
31
31
  } }))) })));
32
32
  }
33
- export default memo(VirtualTable);
33
+ export default memo(VirtualTable, (prevProps, nextProps) => {
34
+ var _a, _b, _c;
35
+ const propsToCompare = [
36
+ 'columnsData',
37
+ 'itemCount',
38
+ 'lastItemIndex',
39
+ 'areAllRowsLoaded',
40
+ 'isPinned',
41
+ 'fixedWidth',
42
+ 'scrollToIndex',
43
+ 'areTotalRowsNotFillingHeight',
44
+ 'overscanCount',
45
+ ];
46
+ const areCriticalPropsSame = propsToCompare.every((key) => prevProps[key] === nextProps[key]);
47
+ const areColumnsDataSame = ((_a = prevProps.columnsData) === null || _a === void 0 ? void 0 : _a.length) === ((_b = nextProps.columnsData) === null || _b === void 0 ? void 0 : _b.length) &&
48
+ ((_c = prevProps.columnsData) === null || _c === void 0 ? void 0 : _c.every((col, index) => { var _a, _b, _c, _d; return col.id === ((_b = (_a = nextProps.columnsData) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.id) && col.width === ((_d = (_c = nextProps.columnsData) === null || _c === void 0 ? void 0 : _c[index]) === null || _d === void 0 ? void 0 : _d.width); }));
49
+ return areCriticalPropsSame && areColumnsDataSame;
50
+ });
@@ -1,4 +1,4 @@
1
- import { useState, useCallback } from 'react';
1
+ import { useState, useCallback, useMemo } from 'react';
2
2
  export const useTableState = () => {
3
3
  const [selectedCell, setSelectedCell] = useState(null);
4
4
  const [selectedColumn, setSelectedColumn] = useState(null);
@@ -48,7 +48,7 @@ export const useTableState = () => {
48
48
  setSelectedChip(null);
49
49
  setSelectedRow(null);
50
50
  }, []);
51
- return {
51
+ const tableStateAPI = useMemo(() => ({
52
52
  selectedCell,
53
53
  selectedColumn,
54
54
  selectedRow,
@@ -59,5 +59,17 @@ export const useTableState = () => {
59
59
  handleCellClick,
60
60
  handleColumnClick,
61
61
  resetSelection,
62
- };
62
+ }), [
63
+ selectedCell,
64
+ selectedColumn,
65
+ selectedRow,
66
+ showBackDrop,
67
+ selectedChip,
68
+ setShowBackdrop,
69
+ handleChipClick,
70
+ handleCellClick,
71
+ handleColumnClick,
72
+ resetSelection,
73
+ ]);
74
+ return tableStateAPI;
63
75
  };
@@ -1,4 +1,4 @@
1
- import { useCallback, useMemo } 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,
@@ -24,16 +24,20 @@ const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToInde
24
24
  rowHeight,
25
25
  }));
26
26
  export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick, }) => {
27
+ const stableRowsLength = useRef(rows.length);
28
+ if (stableRowsLength.current !== rows.length) {
29
+ stableRowsLength.current = rows.length;
30
+ }
27
31
  const getItemSize = useCallback((index, height) => {
28
- const isLastRow = areAllRowsLoaded && index === rows.length;
32
+ const isLastRow = areAllRowsLoaded && index === stableRowsLength.current;
29
33
  if (isLastRow) {
30
- const usedHeight = rows.length * rowHeight;
34
+ const usedHeight = stableRowsLength.current * rowHeight;
31
35
  const remainingHeight = height - usedHeight;
32
36
  const minimumLastRowHeight = rowHeight * 2;
33
37
  return Math.max(remainingHeight, minimumLastRowHeight);
34
38
  }
35
39
  return rowHeight;
36
- }, [areAllRowsLoaded, rows.length, rowHeight]);
40
+ }, [areAllRowsLoaded, rowHeight]);
37
41
  const commonItemDataParams = useMemo(() => {
38
42
  var _a;
39
43
  return [
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ export declare const useAnimationOptimization: (isAnimating: boolean) => ((callback: () => void) => void) | null;
3
+ export declare const OptimizedAnimatedCell: import("react").MemoExoticComponent<({ children, isAnimating, ...props }: {
4
+ [key: string]: any;
5
+ children: React.ReactNode;
6
+ isAnimating: boolean;
7
+ }) => import("react/jsx-runtime").JSX.Element>;
8
+ export declare const animationStyles: {
9
+ slideIn: {
10
+ transform: string;
11
+ transition: string;
12
+ };
13
+ slideOut: {
14
+ transform: string;
15
+ transition: string;
16
+ };
17
+ fadeIn: {
18
+ opacity: number;
19
+ transition: string;
20
+ };
21
+ fadeOut: {
22
+ opacity: number;
23
+ transition: string;
24
+ };
25
+ };
26
+ export declare const useScrollOptimization: () => boolean;
@@ -0,0 +1,86 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { memo, useMemo, useRef, useEffect } from 'react';
14
+ const optimizedCellStyles = {
15
+ willChange: 'transform, opacity',
16
+ transform: 'translateZ(0)',
17
+ contain: 'layout style paint',
18
+ };
19
+ export const useAnimationOptimization = (isAnimating) => {
20
+ const animationFrameRef = useRef();
21
+ const throttledUpdate = useMemo(() => {
22
+ if (!isAnimating)
23
+ return null;
24
+ return (callback) => {
25
+ if (animationFrameRef.current) {
26
+ cancelAnimationFrame(animationFrameRef.current);
27
+ }
28
+ animationFrameRef.current = requestAnimationFrame(callback);
29
+ };
30
+ }, [isAnimating]);
31
+ useEffect(() => {
32
+ return () => {
33
+ if (animationFrameRef.current) {
34
+ cancelAnimationFrame(animationFrameRef.current);
35
+ }
36
+ };
37
+ }, []);
38
+ return throttledUpdate;
39
+ };
40
+ export const OptimizedAnimatedCell = memo((_a) => {
41
+ var { children, isAnimating } = _a, props = __rest(_a, ["children", "isAnimating"]);
42
+ return (_jsx("div", Object.assign({ style: optimizedCellStyles }, props, { children: children })));
43
+ }, (prevProps, nextProps) => {
44
+ return prevProps.isAnimating === nextProps.isAnimating && prevProps.children === nextProps.children;
45
+ });
46
+ export const animationStyles = {
47
+ slideIn: {
48
+ transform: 'translateX(0)',
49
+ transition: 'transform 0.2s ease-out',
50
+ },
51
+ slideOut: {
52
+ transform: 'translateX(-100%)',
53
+ transition: 'transform 0.2s ease-out',
54
+ },
55
+ fadeIn: {
56
+ opacity: 1,
57
+ transition: 'opacity 0.15s ease-out',
58
+ },
59
+ fadeOut: {
60
+ opacity: 0,
61
+ transition: 'opacity 0.15s ease-out',
62
+ },
63
+ };
64
+ export const useScrollOptimization = () => {
65
+ const isScrolling = useRef(false);
66
+ const scrollTimeoutRef = useRef();
67
+ useEffect(() => {
68
+ const handleScroll = () => {
69
+ isScrolling.current = true;
70
+ if (scrollTimeoutRef.current) {
71
+ clearTimeout(scrollTimeoutRef.current);
72
+ }
73
+ scrollTimeoutRef.current = setTimeout(() => {
74
+ isScrolling.current = false;
75
+ }, 150);
76
+ };
77
+ window.addEventListener('scroll', handleScroll, { passive: true });
78
+ return () => {
79
+ window.removeEventListener('scroll', handleScroll);
80
+ if (scrollTimeoutRef.current) {
81
+ clearTimeout(scrollTimeoutRef.current);
82
+ }
83
+ };
84
+ }, []);
85
+ return isScrolling.current;
86
+ };
@@ -12,6 +12,20 @@ export declare const SERVICE_COMMON_FUNCTIONS: {
12
12
  code: string;
13
13
  };
14
14
  };
15
+ export declare const BUSINESS_FUNCTIONS: {
16
+ updateEntity: {
17
+ code: string;
18
+ };
19
+ updateBrand: {
20
+ code: string;
21
+ };
22
+ updateUsers: {
23
+ code: string;
24
+ };
25
+ createUsers: {
26
+ code: string;
27
+ };
28
+ };
15
29
  export declare const APP_CODES: {
16
30
  tokens: {
17
31
  code: string;
@@ -84,6 +98,18 @@ export declare const APP_CODES: {
84
98
  merchant: {
85
99
  code: string;
86
100
  functions: {
101
+ updateEntity: {
102
+ code: string;
103
+ };
104
+ updateBrand: {
105
+ code: string;
106
+ };
107
+ updateUsers: {
108
+ code: string;
109
+ };
110
+ createUsers: {
111
+ code: string;
112
+ };
87
113
  view: {
88
114
  code: string;
89
115
  };
@@ -101,6 +127,18 @@ export declare const APP_CODES: {
101
127
  retailer: {
102
128
  code: string;
103
129
  functions: {
130
+ updateEntity: {
131
+ code: string;
132
+ };
133
+ updateBrand: {
134
+ code: string;
135
+ };
136
+ updateUsers: {
137
+ code: string;
138
+ };
139
+ createUsers: {
140
+ code: string;
141
+ };
104
142
  view: {
105
143
  code: string;
106
144
  };
@@ -14,6 +14,20 @@ export const SERVICE_COMMON_FUNCTIONS = {
14
14
  code: 'REPORTS',
15
15
  },
16
16
  };
17
+ export const BUSINESS_FUNCTIONS = {
18
+ updateEntity: {
19
+ code: 'UPDATE ENTITY',
20
+ },
21
+ updateBrand: {
22
+ code: 'UPDATE BRAND',
23
+ },
24
+ updateUsers: {
25
+ code: 'UPDATE USERS',
26
+ },
27
+ createUsers: {
28
+ code: 'CREATE USERS',
29
+ },
30
+ };
17
31
  export const APP_CODES = {
18
32
  tokens: {
19
33
  code: 'TOKEN',
@@ -40,11 +54,11 @@ export const APP_CODES = {
40
54
  services: {
41
55
  merchant: {
42
56
  code: 'MERCHANT',
43
- functions: Object.assign({}, SERVICE_COMMON_FUNCTIONS),
57
+ functions: Object.assign(Object.assign({}, SERVICE_COMMON_FUNCTIONS), BUSINESS_FUNCTIONS),
44
58
  },
45
59
  retailer: {
46
60
  code: 'RETAILER',
47
- functions: Object.assign({}, SERVICE_COMMON_FUNCTIONS),
61
+ functions: Object.assign(Object.assign({}, SERVICE_COMMON_FUNCTIONS), BUSINESS_FUNCTIONS),
48
62
  },
49
63
  },
50
64
  },
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.96",
5
- "testVersion": 0,
4
+ "version": "0.1.97-test.102",
5
+ "testVersion": 102,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",
@@ -118,15 +118,19 @@
118
118
  "eslint-plugin-react-hooks": "^5.0.0",
119
119
  "eslint-plugin-react-refresh": "^0.4.16",
120
120
  "globals": "^15.14.0",
121
- "husky": "^8.0.3",
122
- "lint-staged": "^13.2.2",
121
+ "husky": "^9.1.7",
122
+ "lint-staged": "^16.1.6",
123
123
  "prettier": "^2.8.8",
124
124
  "tsc-alias": "^1.8.16",
125
125
  "typescript": "5.0.2",
126
126
  "typescript-eslint": "^8.18.2",
127
- "vite": "6.0.5",
127
+ "vite": "^7.1.4",
128
128
  "vite-tsconfig-paths": "^4.2.0"
129
129
  },
130
+ "peerDependencies": {
131
+ "react": ">=18.0.0",
132
+ "react-dom": ">=18.0.0"
133
+ },
130
134
  "lint-staged": {
131
135
  "src/**/*.{ts,tsx,json,js,jsx}": [
132
136
  "yarn run prettier:fix",
@@ -136,4 +140,4 @@
136
140
  "publishConfig": {
137
141
  "registry": "https://registry.npmjs.org/"
138
142
  }
139
- }
143
+ }