@tap-payments/os-micro-frontend-shared 0.1.101 → 0.1.103-test.107
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/build/components/AmountStatusChip/AmountStatusChip.d.ts +9 -0
- package/build/components/AmountStatusChip/AmountStatusChip.js +20 -0
- package/build/components/AmountStatusChip/index.d.ts +3 -0
- package/build/components/AmountStatusChip/index.js +2 -0
- package/build/components/AmountStatusChip/style.d.ts +4 -0
- package/build/components/AmountStatusChip/style.js +27 -0
- package/build/components/ColorPicker/ColorPicker.d.ts +4 -1
- package/build/components/ColorPicker/ColorPicker.js +3 -12
- package/build/components/StatusChip/StatusChip.d.ts +1 -1
- package/build/components/StatusChip/StatusChip.js +11 -8
- package/build/components/StatusChip/style.d.ts +1 -0
- package/build/components/StatusChip/type.d.ts +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +38 -17
- package/build/components/VirtualTables/SheetViewVirtualTable/components/LoadingMainTable.js +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.js +30 -4
- package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.js +32 -5
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableLoading.js +37 -3
- package/build/components/VirtualTables/SheetViewVirtualTable/components/VirtualTable.js +18 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.js +15 -3
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js +8 -4
- package/build/components/VirtualTables/components/style.js +1 -1
- package/build/components/VirtualTables/optimization/AnimationOptimizations.d.ts +25 -0
- package/build/components/VirtualTables/optimization/AnimationOptimizations.js +86 -0
- package/build/components/index.d.ts +1 -0
- package/build/components/index.js +1 -0
- package/build/constants/table/cell/authorizationTableCellWidth.d.ts +2 -2
- package/build/constants/table/cell/authorizationTableCellWidth.js +2 -2
- package/build/constants/table/cell/chargeTableCellWidth.d.ts +2 -2
- package/build/constants/table/cell/chargeTableCellWidth.js +2 -2
- package/build/constants/table/cell/destinationsTableCellWidth.d.ts +2 -2
- package/build/constants/table/cell/destinationsTableCellWidth.js +2 -2
- package/build/constants/table/cell/refundTableCellWidth.d.ts +2 -2
- package/build/constants/table/cell/refundTableCellWidth.js +2 -2
- package/build/utils/color.d.ts +11 -0
- package/build/utils/color.js +10 -0
- package/build/utils/style.js +0 -4
- package/package.json +10 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StatusChipWithCopyProps } from '../StatusChipWithCopy';
|
|
3
|
+
export interface AmountStatusChipProps extends StatusChipWithCopyProps {
|
|
4
|
+
amount?: string;
|
|
5
|
+
currency?: string;
|
|
6
|
+
}
|
|
7
|
+
declare function AmountStatusChip({ amount, currency, ...rest }: AmountStatusChipProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare const _default: import("react").MemoExoticComponent<typeof AmountStatusChip>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { memo } from 'react';
|
|
14
|
+
import CurrencyIcon from '../CurrencyIcon';
|
|
15
|
+
import { AmountLabel, CurrencyIconContainer, StyledAmountStatusChip } from './style';
|
|
16
|
+
function AmountStatusChip(_a) {
|
|
17
|
+
var { amount, currency } = _a, rest = __rest(_a, ["amount", "currency"]);
|
|
18
|
+
return (_jsxs(StyledAmountStatusChip, Object.assign({ expandDirection: "left" }, rest, { children: [currency && (_jsx(AmountLabel, { children: _jsx(CurrencyIconContainer, { children: _jsx(CurrencyIcon, { currency: currency, fontSize: 10 }) }) })), amount] })));
|
|
19
|
+
}
|
|
20
|
+
export default memo(AmountStatusChip);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledAmountStatusChip: import("@emotion/styled").StyledComponent<import("../StatusChipWithCopy").StatusChipWithCopyProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
3
|
+
export declare const AmountLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
4
|
+
export declare const CurrencyIconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { styled } from '@mui/material/styles';
|
|
2
|
+
import StatusChipWithCopy from '../StatusChipWithCopy';
|
|
3
|
+
export const StyledAmountStatusChip = styled(StatusChipWithCopy)(() => ({
|
|
4
|
+
backgroundColor: '#EFF1F2',
|
|
5
|
+
border: 'none',
|
|
6
|
+
display: 'flex',
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
transition: 'none !important',
|
|
10
|
+
animation: 'none !important',
|
|
11
|
+
transform: 'none !important',
|
|
12
|
+
'& *': {
|
|
13
|
+
transition: 'none !important',
|
|
14
|
+
animation: 'none !important',
|
|
15
|
+
transform: 'none !important',
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
export const AmountLabel = styled('span')(() => ({
|
|
19
|
+
marginRight: '2px',
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
}));
|
|
23
|
+
export const CurrencyIconContainer = styled('span')(() => ({
|
|
24
|
+
marginInline: '1.5px',
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
}));
|
|
@@ -5,6 +5,9 @@ type ColorPickerProps = {
|
|
|
5
5
|
onChange: (value: string) => void;
|
|
6
6
|
onReset?: () => void;
|
|
7
7
|
sx?: SxProps;
|
|
8
|
+
options?: {
|
|
9
|
+
hideReset?: boolean;
|
|
10
|
+
};
|
|
8
11
|
};
|
|
9
|
-
declare const ColorPicker: ({ id, value, onChange, onReset, sx }: ColorPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare const ColorPicker: ({ id, value, onChange, onReset, sx, options }: ColorPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
13
|
export default ColorPicker;
|
|
@@ -13,7 +13,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { useCallback, useRef, useState } from 'react';
|
|
14
14
|
import { RgbaColorPicker } from 'react-colorful';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
import Color from 'color';
|
|
17
16
|
import Box from '@mui/material/Box';
|
|
18
17
|
import ClickAwayListener from '@mui/material/ClickAwayListener';
|
|
19
18
|
import Divider from '@mui/material/Divider';
|
|
@@ -22,16 +21,8 @@ import Stack from '@mui/material/Stack';
|
|
|
22
21
|
import Typography from '@mui/material/Typography';
|
|
23
22
|
import { CancelButton, ConfirmButton, Footer, StyledCloseButtonWrapper, StyledColorWidgetWrapper } from './style';
|
|
24
23
|
import { closeXIcon } from '../../constants/index.js';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const { r, g, b, alpha = 1 } = colorInstance.object();
|
|
28
|
-
return {
|
|
29
|
-
value: { r, g, b, alpha },
|
|
30
|
-
stringified: `rgba(${r},${g},${b},${alpha})`,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
const rgba2Hexa = (value) => Color(value).hexa();
|
|
34
|
-
const ColorPicker = ({ id, value = '#ffffff', onChange, onReset, sx }) => {
|
|
24
|
+
import { hexa2Rgba, rgba2Hexa } from '../../utils/index.js';
|
|
25
|
+
const ColorPicker = ({ id, value = '#ffffff', onChange, onReset, sx, options }) => {
|
|
35
26
|
const { t } = useTranslation();
|
|
36
27
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
37
28
|
const rootRef = useRef(null);
|
|
@@ -54,6 +45,6 @@ const ColorPicker = ({ id, value = '#ffffff', onChange, onReset, sx }) => {
|
|
|
54
45
|
onChange(rgba2Hexa(Object.assign(Object.assign({}, rest), { alpha })));
|
|
55
46
|
setAnchorEl(null);
|
|
56
47
|
}, [onChange, color]);
|
|
57
|
-
return (_jsx(ClickAwayListener, Object.assign({ onClickAway: () => setAnchorEl(null) }, { children: _jsxs(Stack, Object.assign({ ref: rootRef, bgcolor: "grey.400", borderRadius: "4px", p: "4px", pr: "12px", direction: "row", justifyContent: "space-between", spacing: 1, alignItems: "center", className: "color-picker" }, { children: [_jsxs(Stack, Object.assign({
|
|
48
|
+
return (_jsx(ClickAwayListener, Object.assign({ onClickAway: () => setAnchorEl(null) }, { children: _jsxs(Stack, Object.assign({ ref: rootRef, bgcolor: "grey.400", borderRadius: "4px", p: "4px", pr: "12px", direction: "row", justifyContent: "space-between", spacing: 1, alignItems: "center", className: "color-picker", sx: sx }, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", className: "color-picker__controls-wrapper" }, { children: [_jsx(Box, { borderRadius: "5px", width: 32, height: 32, sx: { backgroundColor: value }, className: "color-picker__viewer" }), _jsxs(Box, Object.assign({ className: "color-picker__actions-wrapper" }, { children: [_jsx(Typography, Object.assign({ className: "color-picker__label", fontWeight: 500, fontSize: 9, color: "text.primary", textTransform: "uppercase" }, { children: value })), _jsx(Typography, Object.assign({ className: "color-picker__edit-btn", role: "button", onClick: handleOpen, htmlFor: id, fontWeight: 500, fontSize: 9, color: "info.dark", component: "label", sx: { textDecoration: 'underline', cursor: 'pointer' } }, { children: "Edit" }))] }))] })), !(options === null || options === void 0 ? void 0 : options.hideReset) ? (_jsx(StyledCloseButtonWrapper, Object.assign({ className: "color-picker__close-btn", type: "button", onClick: onReset }, { children: _jsx(Box, { component: "img", src: closeXIcon, width: 10, height: 10 }) }))) : (_jsx("div", {})), _jsx(Popper, Object.assign({ anchorEl: anchorEl, open: !!anchorEl, placement: "top" }, { children: _jsxs(StyledColorWidgetWrapper, Object.assign({ className: "color-picker__widget" }, { children: [_jsx(RgbaColorPicker, { color: color, onChange: setColor }), _jsx(Divider, { sx: { my: '12px' } }), _jsxs(Footer, Object.assign({ className: "color-picker__widget-actions" }, { children: [_jsx(CancelButton, Object.assign({ className: "color-picker__widget-actions__cancel", onClick: handleCancel }, { children: t('cancel') })), _jsx(ConfirmButton, Object.assign({ className: "color-picker__widget-actions__confirm", onClick: handleConfirm }, { children: t('okay') }))] }))] })) }))] })) })));
|
|
58
49
|
};
|
|
59
50
|
export default ColorPicker;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ChipProps } from './type';
|
|
2
|
-
declare const StatusChip: ({ children, unknownText, copyText, ...props }: ChipProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const StatusChip: ({ children, unknownText, copyText, expandDirection, ...props }: ChipProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default StatusChip;
|
|
@@ -18,7 +18,7 @@ import { copyIcon, greenCheckIcon } from '../../constants/index.js';
|
|
|
18
18
|
import { unknownGeographyColors } from './constants';
|
|
19
19
|
import { ChipStyled, Wrapper, CopyWrapper } from './style';
|
|
20
20
|
const StatusChip = (_a) => {
|
|
21
|
-
var { children, unknownText, copyText } = _a, props = __rest(_a, ["children", "unknownText", "copyText"]);
|
|
21
|
+
var { children, unknownText, copyText, expandDirection = 'right' } = _a, props = __rest(_a, ["children", "unknownText", "copyText", "expandDirection"]);
|
|
22
22
|
const [showCopy, setShowCopy] = useState(false);
|
|
23
23
|
const { t } = useTranslation();
|
|
24
24
|
const isSelected = props.isSelected;
|
|
@@ -38,12 +38,15 @@ const StatusChip = (_a) => {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
const isCopyActive = isSelected && copyText;
|
|
42
|
+
return (_jsxs(motion.div, Object.assign({ style: { position: 'relative' }, animate: { zIndex: isSelected ? 3 : 0 } }, { children: [_jsx(ChipStyled, Object.assign({}, props, { sx: { visibility: 'hidden', pointerEvents: 'none' } }, { children: _jsx(Wrapper, { children: children }) })), _jsx(motion.div, Object.assign({ style: { position: 'absolute', top: 0, zIndex: isSelected ? 3 : 0 }, animate: {
|
|
43
|
+
left: isCopyActive && expandDirection === 'left' ? -12 : 0,
|
|
44
|
+
}, transition: { delay: isSelected ? 0 : 0.2, duration: 0.2 } }, { children: _jsx(ChipStyled, Object.assign({}, props, { isSelected: isSelected }, { children: _jsxs(motion.div, Object.assign({ layout: "size", style: { display: 'flex', gap: '4px' }, animate: {
|
|
45
|
+
paddingRight: isCopyActive ? 12 : 0,
|
|
46
|
+
}, transition: { delay: isSelected ? 0 : 0.2, duration: 0.2 } }, { children: [_jsx(Wrapper, { children: children }), _jsx(AnimatePresence, { children: isCopyActive && (_jsx(CopyWrapper, { children: _jsx(motion.img, { initial: { opacity: 0, x: -5 }, animate: { opacity: 1, x: 0 }, exit: { opacity: 0, x: -2 }, transition: { delay: 0.2, duration: 0.1 }, onClick: handleCopy, src: showCopy ? greenCheckIcon : copyIcon, style: {
|
|
47
|
+
height: 12,
|
|
48
|
+
width: 12,
|
|
49
|
+
objectFit: 'contain',
|
|
50
|
+
} }) })) })] })) })) }))] })));
|
|
48
51
|
};
|
|
49
52
|
export default StatusChip;
|
|
@@ -11,6 +11,7 @@ export declare const ChipStyled: import("@emotion/styled").StyledComponent<impor
|
|
|
11
11
|
maxWidth?: string | undefined;
|
|
12
12
|
isSelected?: boolean | undefined;
|
|
13
13
|
copyText?: string | undefined;
|
|
14
|
+
expandDirection?: "left" | "right" | undefined;
|
|
14
15
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
15
16
|
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
16
17
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & {
|
|
@@ -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,51 @@ 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
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
+
console.log({ selectedCell, selectedColumn, selectedRow, selectedChip });
|
|
74
|
+
const createVirtualTableContainer = useCallback((columnsData, containerKey, isPinned = false, fixedWidth) => {
|
|
75
|
+
switch (containerKey) {
|
|
76
|
+
case 'pinnedStart':
|
|
77
|
+
return createPinnedStartTable(columnsData, fixedWidth);
|
|
78
|
+
case 'pinnedEnd':
|
|
79
|
+
return createPinnedEndTable(columnsData, fixedWidth);
|
|
80
|
+
case 'scrollable':
|
|
81
|
+
default:
|
|
82
|
+
return createScrollableTable(columnsData);
|
|
83
|
+
}
|
|
84
|
+
}, [createPinnedStartTable, createPinnedEndTable, createScrollableTable]);
|
|
64
85
|
const baseCommonProps = {
|
|
65
86
|
showHeader,
|
|
66
87
|
columnsSorting,
|
|
@@ -12,8 +12,10 @@ function LoadingMainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, s
|
|
|
12
12
|
minWidth: 'fit-content',
|
|
13
13
|
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_LoadingStyledBox", hidePadding: true, className: "list-wrapper", sx: {
|
|
14
14
|
height: '100%',
|
|
15
|
+
maxHeight: '100%',
|
|
15
16
|
display: 'flex',
|
|
16
17
|
flexDirection: 'column',
|
|
18
|
+
overflow: 'hidden',
|
|
17
19
|
} }, { children: _jsx(SheetViewTableLoading, { "data-testid": "SheetViewVirtualTable_TableLoading", columns: unpinnedColumnsData, isLoading: true, isPinned: false }) })) }))] })) })) })));
|
|
18
20
|
}
|
|
19
21
|
export default memo(LoadingMainTable);
|
|
@@ -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,35 @@ 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
|
-
|
|
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
|
-
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_ScrollableStyledBox", hidePadding: true, className: "list-wrapper"
|
|
15
|
+
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_ScrollableStyledBox", hidePadding: true, className: "list-wrapper", sx: {
|
|
16
|
+
height: '100%',
|
|
17
|
+
maxHeight: '100%',
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
} }, { children: tableLoading ? (_jsx(SheetViewTableLoading, { "data-testid": "SheetViewVirtualTable_TableLoading", columns: unpinnedColumnsData, isLoading: true, isPinned: false })) : (createVirtualTableContainer(unpinnedColumnsData, 'scrollable', false)) })) }))] })) })) })));
|
|
14
20
|
}
|
|
15
|
-
export default memo(MainTable)
|
|
21
|
+
export default memo(MainTable, (prevProps, nextProps) => {
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
23
|
+
const criticalProps = [
|
|
24
|
+
'hasPinnedStart',
|
|
25
|
+
'hasPinnedEnd',
|
|
26
|
+
'showHeader',
|
|
27
|
+
'showBackDrop',
|
|
28
|
+
'tableLoading',
|
|
29
|
+
'showNoDataView',
|
|
30
|
+
'isLoading',
|
|
31
|
+
'isError',
|
|
32
|
+
'hasTimeoutError',
|
|
33
|
+
'tableMode',
|
|
34
|
+
];
|
|
35
|
+
const areCriticalPropsSame = criticalProps.every((prop) => prevProps[prop] === nextProps[prop]);
|
|
36
|
+
const areColumnsDataSame = ((_a = prevProps.unpinnedColumnsData) === null || _a === void 0 ? void 0 : _a.length) === ((_b = nextProps.unpinnedColumnsData) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
37
|
+
((_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); }));
|
|
38
|
+
const arePinnedColumnsSame = ((_d = prevProps.pinnedStartColumns) === null || _d === void 0 ? void 0 : _d.length) === ((_e = nextProps.pinnedStartColumns) === null || _e === void 0 ? void 0 : _e.length) &&
|
|
39
|
+
((_f = prevProps.pinnedEndColumns) === null || _f === void 0 ? void 0 : _f.length) === ((_g = nextProps.pinnedEndColumns) === null || _g === void 0 ? void 0 : _g.length);
|
|
40
|
+
return areCriticalPropsSame && areColumnsDataSame && arePinnedColumnsSame;
|
|
41
|
+
});
|
|
@@ -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';
|
|
@@ -7,14 +7,41 @@ import SheetViewTableHeader from './SheetViewTableHeader';
|
|
|
7
7
|
import SheetViewTableLoading from './SheetViewTableLoading';
|
|
8
8
|
function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, hasPinnedStart, hasPinnedEnd, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableLoading, createVirtualTableContainer, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
|
+
const { Wrapper, containerKey } = useMemo(() => {
|
|
11
|
+
const key = position === 'start' ? 'pinnedStart' : 'pinnedEnd';
|
|
12
|
+
return {
|
|
13
|
+
Wrapper: position === 'start' ? PinnedStartColumnWrapper : PinnedEndColumnWrapper,
|
|
14
|
+
containerKey: key,
|
|
15
|
+
};
|
|
16
|
+
}, [position]);
|
|
10
17
|
if (columnsData.length === 0)
|
|
11
18
|
return null;
|
|
12
|
-
const Wrapper = position === 'start' ? PinnedStartColumnWrapper : PinnedEndColumnWrapper;
|
|
13
|
-
const containerKey = position === 'start' ? 'pinnedStart' : 'pinnedEnd';
|
|
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
|
-
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_PinnedStyledBox", hidePadding: true, className: "list-wrapper"
|
|
23
|
+
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_PinnedStyledBox", hidePadding: true, className: "list-wrapper", sx: {
|
|
24
|
+
height: '100%',
|
|
25
|
+
maxHeight: '100%',
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
} }, { children: tableLoading ? (_jsx(SheetViewTableLoading, { "data-testid": `SheetViewVirtualTable_PinnedTableLoading_${position}`, columns: columnsData, isLoading: true, isPinned: true })) : (createVirtualTableContainer(columnsData, containerKey, true, columnsWidth)) })) }))] })) }));
|
|
19
28
|
}
|
|
20
|
-
export default memo(PinnedColumn)
|
|
29
|
+
export default memo(PinnedColumn, (prevProps, nextProps) => {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f;
|
|
31
|
+
const criticalProps = [
|
|
32
|
+
'position',
|
|
33
|
+
'columnsWidth',
|
|
34
|
+
'showHeader',
|
|
35
|
+
'showBackDrop',
|
|
36
|
+
'tableLoading',
|
|
37
|
+
'showNoDataView',
|
|
38
|
+
'hasPinnedStart',
|
|
39
|
+
'hasPinnedEnd',
|
|
40
|
+
];
|
|
41
|
+
const areCriticalPropsSame = criticalProps.every((prop) => prevProps[prop] === nextProps[prop]);
|
|
42
|
+
const areColumnsDataSame = ((_a = prevProps.columnsData) === null || _a === void 0 ? void 0 : _a.length) === ((_b = nextProps.columnsData) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
43
|
+
((_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); }));
|
|
44
|
+
const arePinnedColumnsSame = ((_d = prevProps.pinnedColumnsList) === null || _d === void 0 ? void 0 : _d.length) === ((_e = nextProps.pinnedColumnsList) === null || _e === void 0 ? void 0 : _e.length) &&
|
|
45
|
+
((_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]); }));
|
|
46
|
+
return areCriticalPropsSame && areColumnsDataSame && arePinnedColumnsSame;
|
|
47
|
+
});
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableLoading.js
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from 'react';
|
|
2
|
+
import { memo, useEffect, useState } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import uniqueId from 'lodash/uniqueId';
|
|
5
5
|
import { calculateMaxAllowedRows } from '../../../../utils/index.js';
|
|
6
6
|
import SheetViewTableRowLoading from './SheetViewTableRowLoading';
|
|
7
|
+
import { SHEET_VIEW_TABLE_ROW_HEIGHT } from '../../../../constants/index.js';
|
|
7
8
|
const Wrapper = styled('section')(({ isLoaded = false, isPinned = false }) => ({
|
|
8
9
|
overflow: 'hidden',
|
|
9
10
|
paddingInline: isLoaded && !isPinned ? '32px' : '0px',
|
|
10
11
|
backgroundColor: isLoaded && !isPinned ? 'rgba(255, 255, 255, 0.60)' : 'none',
|
|
11
12
|
filter: isLoaded && !isPinned ? 'blur(8px)' : 'none',
|
|
12
13
|
marginTop: isLoaded && !isPinned ? '1rem' : '0',
|
|
14
|
+
height: '100%',
|
|
15
|
+
maxHeight: '100%',
|
|
13
16
|
}));
|
|
14
17
|
function SheetViewTableLoading({ columns, isLoaded = false, animationType, isLoading = false, rowsCount, isPinned = false, }) {
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const [maxAllowedRows, setMaxAllowedRows] = useState(() => {
|
|
19
|
+
return rowsCount || Math.min(calculateMaxAllowedRows(isLoaded, isLoading), 15);
|
|
20
|
+
});
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (rowsCount) {
|
|
23
|
+
setMaxAllowedRows(rowsCount);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const calculateRowsForContainer = () => {
|
|
27
|
+
var _a;
|
|
28
|
+
const wrapperElement = document.querySelector('[data-testid="SheetViewTableLoading"]');
|
|
29
|
+
if (!wrapperElement) {
|
|
30
|
+
return Math.min(calculateMaxAllowedRows(isLoaded, isLoading), 25);
|
|
31
|
+
}
|
|
32
|
+
const containerHeight = ((_a = wrapperElement.parentElement) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0;
|
|
33
|
+
const rowHeight = SHEET_VIEW_TABLE_ROW_HEIGHT;
|
|
34
|
+
const headerHeight = 40;
|
|
35
|
+
const availableHeight = containerHeight - headerHeight;
|
|
36
|
+
if (availableHeight <= 0) {
|
|
37
|
+
return Math.min(calculateMaxAllowedRows(isLoaded, isLoading), 25);
|
|
38
|
+
}
|
|
39
|
+
const calculatedRows = Math.floor(availableHeight / rowHeight);
|
|
40
|
+
return Math.max(3, Math.min(calculatedRows + 2, 25));
|
|
41
|
+
};
|
|
42
|
+
const rows = calculateRowsForContainer();
|
|
43
|
+
setMaxAllowedRows(rows);
|
|
44
|
+
const handleResize = () => {
|
|
45
|
+
const calculatedRows = calculateRowsForContainer();
|
|
46
|
+
setMaxAllowedRows(calculatedRows);
|
|
47
|
+
};
|
|
48
|
+
window.addEventListener('resize', handleResize);
|
|
49
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
50
|
+
}, [isLoaded, isLoading, rowsCount]);
|
|
17
51
|
return (_jsx(Wrapper, Object.assign({ isLoaded: isLoaded, isPinned: isPinned, "data-testid": "SheetViewTableLoading" }, { children: [...Array(maxAllowedRows)].map((_, index) => (_jsx(SheetViewTableRowLoading, { columns: columns, animationType: animationType, rowIndex: index, useTableBackground: !isPinned }, `i-${uniqueId('SheetViewTableLoadingRow_')}`))) })));
|
|
18
52
|
}
|
|
19
53
|
export default memo(SheetViewTableLoading);
|
|
@@ -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
|
-
|
|
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
|
};
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js
CHANGED
|
@@ -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 ===
|
|
32
|
+
const isLastRow = areAllRowsLoaded && index === stableRowsLength.current;
|
|
29
33
|
if (isLastRow) {
|
|
30
|
-
const usedHeight =
|
|
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,
|
|
40
|
+
}, [areAllRowsLoaded, rowHeight]);
|
|
37
41
|
const commonItemDataParams = useMemo(() => {
|
|
38
42
|
var _a;
|
|
39
43
|
return [
|
|
@@ -146,7 +146,7 @@ export const SheetViewTableContainer = styled(Box)(() => ({
|
|
|
146
146
|
position: 'relative',
|
|
147
147
|
display: 'flex',
|
|
148
148
|
flexDirection: 'column',
|
|
149
|
-
height: '
|
|
149
|
+
height: '100%',
|
|
150
150
|
paddingInline: '28px',
|
|
151
151
|
borderRadius: '8px',
|
|
152
152
|
marginBottom: '16px !important',
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const useAnimationOptimization: (isAnimating: boolean) => ((callback: () => void) => void) | null;
|
|
3
|
+
export declare const OptimizedAnimatedCell: import("react").MemoExoticComponent<({ children, ...props }: {
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element>;
|
|
7
|
+
export declare const animationStyles: {
|
|
8
|
+
slideIn: {
|
|
9
|
+
transform: string;
|
|
10
|
+
transition: string;
|
|
11
|
+
};
|
|
12
|
+
slideOut: {
|
|
13
|
+
transform: string;
|
|
14
|
+
transition: string;
|
|
15
|
+
};
|
|
16
|
+
fadeIn: {
|
|
17
|
+
opacity: number;
|
|
18
|
+
transition: string;
|
|
19
|
+
};
|
|
20
|
+
fadeOut: {
|
|
21
|
+
opacity: number;
|
|
22
|
+
transition: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
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 } = _a, props = __rest(_a, ["children"]);
|
|
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
|
+
};
|
|
@@ -105,4 +105,5 @@ export * from './LeftPeekRightExpandingChip';
|
|
|
105
105
|
export { default as ColorPicker } from './ColorPicker';
|
|
106
106
|
export { default as WindowBackdrop } from './WindowBackdrop';
|
|
107
107
|
export { default as LazyImage } from './LazyImage';
|
|
108
|
+
export { default as AmountStatusChip, type AmountStatusChipProps } from './AmountStatusChip';
|
|
108
109
|
export * from './LazyImage';
|
|
@@ -105,4 +105,5 @@ export * from './LeftPeekRightExpandingChip';
|
|
|
105
105
|
export { default as ColorPicker } from './ColorPicker';
|
|
106
106
|
export { default as WindowBackdrop } from './WindowBackdrop';
|
|
107
107
|
export { default as LazyImage } from './LazyImage';
|
|
108
|
+
export { default as AmountStatusChip } from './AmountStatusChip';
|
|
108
109
|
export * from './LazyImage';
|
|
@@ -57,12 +57,12 @@ export declare const authorizationTableCellWidth: {
|
|
|
57
57
|
readonly payment_agreement: {
|
|
58
58
|
readonly default: "50px";
|
|
59
59
|
readonly text: "150px";
|
|
60
|
-
readonly sheet: "
|
|
60
|
+
readonly sheet: "230px";
|
|
61
61
|
};
|
|
62
62
|
readonly amount: {
|
|
63
63
|
readonly default: "170px";
|
|
64
64
|
readonly text: "195px";
|
|
65
|
-
readonly sheet: "
|
|
65
|
+
readonly sheet: "150px";
|
|
66
66
|
};
|
|
67
67
|
readonly destinations: {
|
|
68
68
|
readonly default: "70px";
|
|
@@ -57,12 +57,12 @@ export const authorizationTableCellWidth = {
|
|
|
57
57
|
payment_agreement: {
|
|
58
58
|
default: '50px',
|
|
59
59
|
text: '150px',
|
|
60
|
-
sheet: '
|
|
60
|
+
sheet: '230px',
|
|
61
61
|
},
|
|
62
62
|
amount: {
|
|
63
63
|
default: '170px',
|
|
64
64
|
text: '195px',
|
|
65
|
-
sheet: '
|
|
65
|
+
sheet: '150px',
|
|
66
66
|
},
|
|
67
67
|
destinations: {
|
|
68
68
|
default: '70px',
|
|
@@ -52,7 +52,7 @@ export declare const chargeTableCellWidth: {
|
|
|
52
52
|
readonly payment_agreement: {
|
|
53
53
|
readonly default: "50px";
|
|
54
54
|
readonly text: "150px";
|
|
55
|
-
readonly sheet: "
|
|
55
|
+
readonly sheet: "230px";
|
|
56
56
|
};
|
|
57
57
|
readonly payment_initiated: {
|
|
58
58
|
readonly default: "150px";
|
|
@@ -222,7 +222,7 @@ export declare const chargeTableCellWidth: {
|
|
|
222
222
|
readonly consolidated_amount: {
|
|
223
223
|
readonly default: "180px";
|
|
224
224
|
readonly text: "180px";
|
|
225
|
-
readonly sheet: "
|
|
225
|
+
readonly sheet: "150px";
|
|
226
226
|
};
|
|
227
227
|
readonly customer_amount: {
|
|
228
228
|
readonly default: "150px";
|
|
@@ -52,7 +52,7 @@ export const chargeTableCellWidth = {
|
|
|
52
52
|
payment_agreement: {
|
|
53
53
|
default: '50px',
|
|
54
54
|
text: '150px',
|
|
55
|
-
sheet: '
|
|
55
|
+
sheet: '230px',
|
|
56
56
|
},
|
|
57
57
|
payment_initiated: {
|
|
58
58
|
default: '150px',
|
|
@@ -222,7 +222,7 @@ export const chargeTableCellWidth = {
|
|
|
222
222
|
consolidated_amount: {
|
|
223
223
|
default: '180px',
|
|
224
224
|
text: '180px',
|
|
225
|
-
sheet: '
|
|
225
|
+
sheet: '150px',
|
|
226
226
|
},
|
|
227
227
|
customer_amount: {
|
|
228
228
|
default: '150px',
|
|
@@ -62,12 +62,12 @@ export declare const destinationsTableCellWidth: {
|
|
|
62
62
|
readonly payment_agreement: {
|
|
63
63
|
readonly default: "50px";
|
|
64
64
|
readonly text: "250px";
|
|
65
|
-
readonly sheet: "
|
|
65
|
+
readonly sheet: "230px";
|
|
66
66
|
};
|
|
67
67
|
readonly amount: {
|
|
68
68
|
readonly default: "195px";
|
|
69
69
|
readonly text: "195px";
|
|
70
|
-
readonly sheet: "
|
|
70
|
+
readonly sheet: "150px";
|
|
71
71
|
};
|
|
72
72
|
readonly status: {
|
|
73
73
|
readonly default: "50px";
|
|
@@ -62,12 +62,12 @@ export const destinationsTableCellWidth = {
|
|
|
62
62
|
payment_agreement: {
|
|
63
63
|
default: '50px',
|
|
64
64
|
text: '250px',
|
|
65
|
-
sheet: '
|
|
65
|
+
sheet: '230px',
|
|
66
66
|
},
|
|
67
67
|
amount: {
|
|
68
68
|
default: '195px',
|
|
69
69
|
text: '195px',
|
|
70
|
-
sheet: '
|
|
70
|
+
sheet: '150px',
|
|
71
71
|
},
|
|
72
72
|
status: {
|
|
73
73
|
default: '50px',
|
|
@@ -47,7 +47,7 @@ export declare const refundTableCellWidth: {
|
|
|
47
47
|
readonly payment_agreement: {
|
|
48
48
|
readonly default: "50px";
|
|
49
49
|
readonly text: "200px";
|
|
50
|
-
readonly sheet: "
|
|
50
|
+
readonly sheet: "230px";
|
|
51
51
|
};
|
|
52
52
|
readonly payment_initiated: {
|
|
53
53
|
readonly default: "150px";
|
|
@@ -92,7 +92,7 @@ export declare const refundTableCellWidth: {
|
|
|
92
92
|
readonly amount: {
|
|
93
93
|
readonly default: "195px";
|
|
94
94
|
readonly text: "195px";
|
|
95
|
-
readonly sheet: "
|
|
95
|
+
readonly sheet: "150px";
|
|
96
96
|
};
|
|
97
97
|
readonly payouts: {
|
|
98
98
|
readonly default: "195px";
|
|
@@ -47,7 +47,7 @@ export const refundTableCellWidth = {
|
|
|
47
47
|
payment_agreement: {
|
|
48
48
|
default: '50px',
|
|
49
49
|
text: '200px',
|
|
50
|
-
sheet: '
|
|
50
|
+
sheet: '230px',
|
|
51
51
|
},
|
|
52
52
|
payment_initiated: {
|
|
53
53
|
default: '150px',
|
|
@@ -92,7 +92,7 @@ export const refundTableCellWidth = {
|
|
|
92
92
|
amount: {
|
|
93
93
|
default: '195px',
|
|
94
94
|
text: '195px',
|
|
95
|
-
sheet: '
|
|
95
|
+
sheet: '150px',
|
|
96
96
|
},
|
|
97
97
|
payouts: {
|
|
98
98
|
default: '195px',
|
package/build/utils/color.d.ts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
import { ColorObject } from 'color';
|
|
1
2
|
export declare function getRandomColor(): string;
|
|
2
3
|
export declare function getRandomGradientColor(): string;
|
|
4
|
+
export declare const hexa2Rgba: (value: string) => {
|
|
5
|
+
value: {
|
|
6
|
+
r: number;
|
|
7
|
+
g: number;
|
|
8
|
+
b: number;
|
|
9
|
+
alpha: number;
|
|
10
|
+
};
|
|
11
|
+
stringified: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const rgba2Hexa: (value: ColorObject) => string;
|
package/build/utils/color.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Color from 'color';
|
|
1
2
|
export function getRandomColor() {
|
|
2
3
|
const colors = [
|
|
3
4
|
'#D6D6D6',
|
|
@@ -36,3 +37,12 @@ export function getRandomGradientColor() {
|
|
|
36
37
|
];
|
|
37
38
|
return colors[Math.trunc(Math.random() * colors.length)];
|
|
38
39
|
}
|
|
40
|
+
export const hexa2Rgba = (value) => {
|
|
41
|
+
const colorInstance = Color(value).rgb();
|
|
42
|
+
const { r, g, b, alpha = 1 } = colorInstance.object();
|
|
43
|
+
return {
|
|
44
|
+
value: { r, g, b, alpha },
|
|
45
|
+
stringified: `rgba(${r},${g},${b},${alpha})`,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export const rgba2Hexa = (value) => Color(value).hexa();
|
package/build/utils/style.js
CHANGED
|
@@ -31,10 +31,6 @@ export const getSelectionStyles = ({ isSelected, isCellSelected, isColumnSelecte
|
|
|
31
31
|
const getRowSelectionStyles = () => ({
|
|
32
32
|
backgroundColor: SELECTION_COLORS.background,
|
|
33
33
|
color: SELECTION_COLORS.primary,
|
|
34
|
-
border: 'none',
|
|
35
|
-
'&:before': {
|
|
36
|
-
border: 'none',
|
|
37
|
-
},
|
|
38
34
|
});
|
|
39
35
|
const getSingleCellSelectionStyles = () => ({
|
|
40
36
|
border: `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.primary}`,
|
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.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.103-test.107",
|
|
5
|
+
"testVersion": 107,
|
|
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": "^
|
|
122
|
-
"lint-staged": "^
|
|
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": "
|
|
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
|
+
}
|