@tap-payments/os-micro-frontend-shared 0.0.97 → 0.0.99-amount-fix
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/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/build/components/DropdownMenu/DropdownMenu.js +3 -3
- package/build/components/DropdownMenu/type.d.ts +1 -0
- package/build/components/MultiSelectStatusButton/MultiSelectStatusButton.d.ts +5 -0
- package/build/components/MultiSelectStatusButton/MultiSelectStatusButton.js +97 -0
- package/build/components/MultiSelectStatusButton/index.d.ts +3 -0
- package/build/components/MultiSelectStatusButton/index.js +2 -0
- package/build/components/MultiSelectStatusButton/style.d.ts +41 -0
- package/build/components/MultiSelectStatusButton/style.js +71 -0
- package/build/components/MultiSelectStatusButton/type.d.ts +14 -0
- package/build/components/MultiSelectStatusButton/type.js +1 -0
- package/build/components/SearchButton/styles.d.ts +1 -1
- package/build/components/StatusBar/StatusBar.d.ts +6 -1
- package/build/components/StatusBar/StatusBar.js +62 -26
- package/build/components/TableCells/CustomCells/ActionCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/SourceMergedCell/style.d.ts +1 -1
- package/build/components/TableCells/CustomCells/StatusCell/style.d.ts +1 -1
- package/build/components/TableHeader_V2/components/StatusButtons/ChevronIcon.d.ts +1 -1
- package/build/components/TableHeader_V2/components/StatusButtons/ChevronIcon.js +4 -2
- package/build/components/TableHeader_V2/components/StatusButtons/style.js +1 -0
- package/build/components/TableHeader_V2/components/StatusButtons/type.d.ts +3 -0
- package/build/components/VirtualTable/components/ColumnFilter/Inputs/Inputs.js +18 -31
- package/build/components/VirtualTable/style.d.ts +1 -1
- package/build/components/index.d.ts +1 -0
- package/build/components/index.js +1 -0
- package/build/types/table.d.ts +1 -1
- package/build/utils/currency.d.ts +1 -9
- package/build/utils/currency.js +17 -26
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IProps } from './type';
|
|
2
|
-
declare function Dropdown({ open, menuItems, anchorEl, onClose, selected, ...props }: IProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare function Dropdown({ open, menuItems, anchorEl, onClose, selected, allowShadows, ...props }: IProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default Dropdown;
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Divider, Box, useTheme } from '@mui/material';
|
|
14
14
|
import { StyledListItemText, StyledMenu, StyledListItemIcon, StyledMenuItem } from './styles';
|
|
15
15
|
function Dropdown(_a) {
|
|
16
|
-
var { open, menuItems, anchorEl, onClose, selected } = _a, props = __rest(_a, ["open", "menuItems", "anchorEl", "onClose", "selected"]);
|
|
16
|
+
var { open, menuItems, anchorEl, onClose, selected, allowShadows = true } = _a, props = __rest(_a, ["open", "menuItems", "anchorEl", "onClose", "selected", "allowShadows"]);
|
|
17
17
|
const theme = useTheme();
|
|
18
18
|
return (_jsx(StyledMenu, Object.assign({ open: open, anchorEl: anchorEl, onClose: onClose, onContextMenu: (e) => {
|
|
19
19
|
e.preventDefault();
|
|
@@ -27,7 +27,7 @@ function Dropdown(_a) {
|
|
|
27
27
|
item.onClick(e);
|
|
28
28
|
}, onContextMenu: item.onRightClick, selected: item.selected, sx: Object.assign({ '&:hover': {
|
|
29
29
|
backgroundColor: 'transparent',
|
|
30
|
-
boxShadow: theme.shadows[10],
|
|
30
|
+
boxShadow: allowShadows ? theme.shadows[10] : 'none',
|
|
31
31
|
'& .sandbox-Icon': {
|
|
32
32
|
display: 'none',
|
|
33
33
|
},
|
|
@@ -36,7 +36,7 @@ function Dropdown(_a) {
|
|
|
36
36
|
},
|
|
37
37
|
} }, (idx === selected && {
|
|
38
38
|
backgroundColor: 'transparent',
|
|
39
|
-
boxShadow: theme.shadows[10],
|
|
39
|
+
boxShadow: allowShadows ? theme.shadows[10] : 'none',
|
|
40
40
|
})) }, { children: [item.icon && _jsx(StyledListItemIcon, { children: item.icon }), _jsx(StyledListItemText, { children: item.label }), _jsx(Box, Object.assign({ className: item.alwaysShowRightAction ? '' : 'menu-right-action' }, { children: item.rightAction && item.rightAction }))] }))) }, `${item.label}-${idx}`));
|
|
41
41
|
}) })));
|
|
42
42
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MultiSelectStatusButtonProps } from './type';
|
|
3
|
+
declare function MultiSelectStatusButton({ options, selectedValues, onSelectionChange, label, variant }: MultiSelectStatusButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const _default: import("react").MemoExoticComponent<typeof MultiSelectStatusButton>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useState, useRef, useEffect } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { Typography, Checkbox } from '@mui/material';
|
|
5
|
+
import { ChevronIcon } from '../TableHeader_V2/components/StatusButtons/ChevronIcon';
|
|
6
|
+
import StyledBadge, { BadgeVariants } from '../CountBadge';
|
|
7
|
+
import CountryFlag from '../CountryFlag';
|
|
8
|
+
import { formatNumber } from '../../utils/index.js';
|
|
9
|
+
import { closeXIcon } from '../../constants/index.js';
|
|
10
|
+
import { ChevronContainer, Label, LabelWrapper, StyledDropdown, MenuItemContainer, CheckboxStyles, StyledStatusButton, ClearIcon, ChevronIconWrapper, } from './style';
|
|
11
|
+
function MultiSelectStatusButton({ options, selectedValues, onSelectionChange, label, variant = 'inActive' }) {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
14
|
+
const buttonRef = useRef(null);
|
|
15
|
+
const [internalSelectedValues, setInternalSelectedValues] = useState(selectedValues);
|
|
16
|
+
const [dropdownWidth, setDropdownWidth] = useState(0);
|
|
17
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
18
|
+
const isOpen = Boolean(anchorEl);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!isOpen) {
|
|
21
|
+
setInternalSelectedValues(selectedValues);
|
|
22
|
+
}
|
|
23
|
+
}, [selectedValues, isOpen]);
|
|
24
|
+
const handleDropdownClick = (event) => {
|
|
25
|
+
var _a;
|
|
26
|
+
event.stopPropagation();
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
if (isOpen) {
|
|
29
|
+
handleClose();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
setAnchorEl(buttonRef.current);
|
|
33
|
+
const buttonWidth = ((_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) || 200;
|
|
34
|
+
setDropdownWidth(Math.max(buttonWidth, 200));
|
|
35
|
+
};
|
|
36
|
+
const handleClose = () => {
|
|
37
|
+
const hasChanged = JSON.stringify([...internalSelectedValues].sort()) !== JSON.stringify([...selectedValues].sort());
|
|
38
|
+
if (hasChanged) {
|
|
39
|
+
onSelectionChange(internalSelectedValues);
|
|
40
|
+
}
|
|
41
|
+
setAnchorEl(null);
|
|
42
|
+
setDropdownWidth(0);
|
|
43
|
+
};
|
|
44
|
+
const handleClearAll = (event) => {
|
|
45
|
+
event.stopPropagation();
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
setInternalSelectedValues([]);
|
|
48
|
+
onSelectionChange([]);
|
|
49
|
+
};
|
|
50
|
+
const handleOptionToggle = (optionStatus, event) => {
|
|
51
|
+
if (event) {
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
}
|
|
55
|
+
const newSelection = internalSelectedValues.includes(optionStatus)
|
|
56
|
+
? internalSelectedValues.filter((status) => status !== optionStatus)
|
|
57
|
+
: [...internalSelectedValues, optionStatus];
|
|
58
|
+
setInternalSelectedValues(newSelection);
|
|
59
|
+
};
|
|
60
|
+
const getDisplayLabel = () => {
|
|
61
|
+
return (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: "11px", variant: "inherit" }, { children: t('Currencies') })));
|
|
62
|
+
};
|
|
63
|
+
const countBadge = (_jsx(StyledBadge, Object.assign({ pointer: true, variant: variant === 'active' ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE }, { children: formatNumber(selectedValues.length > 0 ? selectedValues.length : options.length) })));
|
|
64
|
+
return (_jsxs(_Fragment, { children: [_jsx(StyledStatusButton, Object.assign({ buttonVariant: variant, ref: buttonRef, sx: {
|
|
65
|
+
paddingInlineEnd: '27px',
|
|
66
|
+
}, "data-testid": "MultiSelectStatusButton", onClick: handleDropdownClick, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false) }, { children: _jsxs(LabelWrapper, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [getDisplayLabel(), countBadge] })), _jsxs(ChevronContainer, Object.assign({ onClick: isHovered && internalSelectedValues.length > 0 ? handleClearAll : undefined, sx: {
|
|
67
|
+
'&:hover': {
|
|
68
|
+
backgroundColor: 'transparent',
|
|
69
|
+
},
|
|
70
|
+
} }, { children: [_jsx(ClearIcon, { variant: variant, src: closeXIcon, alt: "clear all", sx: {
|
|
71
|
+
opacity: isHovered && internalSelectedValues.length > 0 ? 1 : 0,
|
|
72
|
+
pointerEvents: isHovered && internalSelectedValues.length > 0 ? 'auto' : 'none',
|
|
73
|
+
} }), _jsx(ChevronIconWrapper, Object.assign({ isVisible: !(isHovered && internalSelectedValues.length > 0) }, { children: _jsx(ChevronIcon, { disableHover: true, isActive: variant === 'active' }) }))] }))] }) })), isOpen && anchorEl && (_jsx(StyledDropdown, { open: isOpen, onClose: handleClose, anchorEl: anchorEl, allowShadows: false, style: {
|
|
74
|
+
minWidth: dropdownWidth || 200,
|
|
75
|
+
width: dropdownWidth || 'auto',
|
|
76
|
+
marginTop: '6px',
|
|
77
|
+
maxWidth: 300,
|
|
78
|
+
}, sx: {
|
|
79
|
+
boxShadow: 'none !important',
|
|
80
|
+
'&:hover': {
|
|
81
|
+
boxShadow: 'none !important',
|
|
82
|
+
},
|
|
83
|
+
}, menuItems: options.map((option) => ({
|
|
84
|
+
label: (_jsxs(MenuItemContainer, { children: [_jsx(Checkbox, { checked: internalSelectedValues.includes(option.status), size: "small", sx: CheckboxStyles, onClick: (e) => {
|
|
85
|
+
var _a;
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
|
|
88
|
+
} }), _jsx(CountryFlag, { code: option.flagCode || option.code, sx: { border: '1px solid white', borderRadius: '3px' } }), _jsx(Typography, Object.assign({ variant: "body2" }, { children: option.name }))] })),
|
|
89
|
+
onClick: (e) => {
|
|
90
|
+
var _a;
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
|
|
94
|
+
},
|
|
95
|
+
})) }))] }));
|
|
96
|
+
}
|
|
97
|
+
export default memo(MultiSelectStatusButton);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type Theme } from '@mui/material';
|
|
3
|
+
export { statusButtonVariants, ChevronContainer, Label, LabelWrapper, StyledDropdown, } from '../TableHeader_V2/components/StatusButtons/style';
|
|
4
|
+
export declare const StyledStatusButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
5
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
|
|
6
|
+
}, "disabled" | "className" | "style" | "classes" | "color" | "children" | "sx" | "tabIndex" | "size" | "variant" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "href" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "startIcon"> & import("@mui/system").MUIStyledCommonProps<Theme> & {
|
|
7
|
+
buttonVariant: 'active' | 'inActive';
|
|
8
|
+
}, {}, {}>;
|
|
9
|
+
export declare const FlagContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
10
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
11
|
+
}, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
12
|
+
export declare const MenuItemContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
13
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
14
|
+
}, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
15
|
+
export declare const CheckboxStyles: {
|
|
16
|
+
padding: number;
|
|
17
|
+
color: string;
|
|
18
|
+
'&.Mui-checked': {
|
|
19
|
+
color: string;
|
|
20
|
+
};
|
|
21
|
+
'&.MuiCheckbox-root': {
|
|
22
|
+
color: string;
|
|
23
|
+
};
|
|
24
|
+
'& .MuiSvgIcon-root': {
|
|
25
|
+
color: string;
|
|
26
|
+
};
|
|
27
|
+
'&.Mui-checked .MuiSvgIcon-root': {
|
|
28
|
+
color: string;
|
|
29
|
+
'& path': {
|
|
30
|
+
fill: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const ClearIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme> & {
|
|
35
|
+
variant: 'active' | 'inActive';
|
|
36
|
+
}, React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
37
|
+
export declare const ChevronIconWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
38
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
39
|
+
}, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme> & {
|
|
40
|
+
isVisible: boolean;
|
|
41
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Box, Button } from '@mui/material';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
export { statusButtonVariants, ChevronContainer, Label, LabelWrapper, StyledDropdown, } from '../TableHeader_V2/components/StatusButtons/style';
|
|
4
|
+
const baseButtonStyle = (theme) => (Object.assign(Object.assign({}, theme.typography.subtitle1), { borderRadius: '50px', borderWidth: '1px', borderStyle: 'solid', minWidth: '135.11px', height: '32px', display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '8px', textTransform: 'none', transition: 'background-color 0.5s ease, color 0.3s ease', paddingInline: theme.spacing(2) }));
|
|
5
|
+
export const StyledStatusButton = styled(Button, {
|
|
6
|
+
shouldForwardProp: (prop) => prop !== 'buttonVariant',
|
|
7
|
+
})(({ theme, buttonVariant }) => (Object.assign(Object.assign({}, baseButtonStyle(theme)), (buttonVariant === 'active'
|
|
8
|
+
? {
|
|
9
|
+
background: theme.palette.background.gradient.shadedBlue,
|
|
10
|
+
color: theme.palette.common.white,
|
|
11
|
+
}
|
|
12
|
+
: {
|
|
13
|
+
backgroundColor: theme.palette.common.white,
|
|
14
|
+
borderColor: theme.palette.grey[100],
|
|
15
|
+
color: theme.palette.text.primary,
|
|
16
|
+
'&:hover': {
|
|
17
|
+
backgroundColor: 'white',
|
|
18
|
+
},
|
|
19
|
+
}))));
|
|
20
|
+
export const FlagContainer = styled(Box)(({ theme }) => ({
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
gap: theme.spacing(0.5),
|
|
24
|
+
}));
|
|
25
|
+
export const MenuItemContainer = styled(Box)(({ theme }) => ({
|
|
26
|
+
display: 'flex',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
gap: theme.spacing(0.3),
|
|
29
|
+
width: '100%',
|
|
30
|
+
}));
|
|
31
|
+
export const CheckboxStyles = {
|
|
32
|
+
padding: 0.3,
|
|
33
|
+
color: '#8C9196',
|
|
34
|
+
'&.Mui-checked': {
|
|
35
|
+
color: '#1F88D0',
|
|
36
|
+
},
|
|
37
|
+
'&.MuiCheckbox-root': {
|
|
38
|
+
color: '#8C9196',
|
|
39
|
+
},
|
|
40
|
+
'& .MuiSvgIcon-root': {
|
|
41
|
+
color: 'inherit',
|
|
42
|
+
},
|
|
43
|
+
'&.Mui-checked .MuiSvgIcon-root': {
|
|
44
|
+
color: '#1F88D0',
|
|
45
|
+
'& path': {
|
|
46
|
+
fill: '#1F88D0',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export const ClearIcon = styled('img')(({ variant }) => ({
|
|
51
|
+
width: '10px',
|
|
52
|
+
height: '10px',
|
|
53
|
+
filter: variant === 'active' ? 'brightness(0) invert(1)' : 'brightness(0) invert(0)',
|
|
54
|
+
cursor: 'pointer',
|
|
55
|
+
position: 'absolute',
|
|
56
|
+
top: '50%',
|
|
57
|
+
left: '47%',
|
|
58
|
+
transform: 'translate(-50%, -50%)',
|
|
59
|
+
transition: 'opacity 0.2s ease-in-out',
|
|
60
|
+
}));
|
|
61
|
+
export const ChevronIconWrapper = styled(Box, {
|
|
62
|
+
shouldForwardProp: (prop) => prop !== 'isVisible',
|
|
63
|
+
})(({ isVisible }) => ({
|
|
64
|
+
opacity: isVisible ? 1 : 0,
|
|
65
|
+
transition: 'opacity 0.2s ease-in-out',
|
|
66
|
+
display: 'flex',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
width: '100%',
|
|
70
|
+
height: '100%',
|
|
71
|
+
}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TableHeaderStatus } from '../../types/index.js';
|
|
2
|
+
export interface CurrencyOption {
|
|
3
|
+
code: string;
|
|
4
|
+
name: string;
|
|
5
|
+
flagCode?: string;
|
|
6
|
+
status: TableHeaderStatus;
|
|
7
|
+
}
|
|
8
|
+
export interface MultiSelectStatusButtonProps {
|
|
9
|
+
options: CurrencyOption[];
|
|
10
|
+
selectedValues: TableHeaderStatus[];
|
|
11
|
+
onSelectionChange: (selected: TableHeaderStatus[]) => void;
|
|
12
|
+
label?: string;
|
|
13
|
+
variant?: 'active' | 'inActive';
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -554,9 +554,9 @@ export declare const Icon: import("@emotion/styled").StyledComponent<{
|
|
|
554
554
|
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLImageElement> | undefined;
|
|
555
555
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
556
556
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
557
|
+
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
557
558
|
src?: string | undefined;
|
|
558
559
|
alt?: string | undefined;
|
|
559
|
-
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
560
560
|
crossOrigin?: "" | "anonymous" | "use-credentials" | undefined;
|
|
561
561
|
useMap?: string | undefined;
|
|
562
562
|
loading?: "eager" | "lazy" | undefined;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { AvailableStatus } from '../TableHeader_V2';
|
|
3
|
+
import { CurrencyOption } from '../MultiSelectStatusButton';
|
|
3
4
|
import { TableHeaderStatus } from '../../types/index.js';
|
|
4
5
|
interface StatusBarProps {
|
|
5
6
|
status?: TableHeaderStatus;
|
|
6
7
|
availableStatuses?: AvailableStatus[];
|
|
7
8
|
isFilteredIdsShown?: boolean;
|
|
8
9
|
onStatusChange?: (status: TableHeaderStatus) => void;
|
|
10
|
+
onMultiSelectChange?: (status: TableHeaderStatus[]) => void;
|
|
11
|
+
currencyOptions?: CurrencyOption[];
|
|
12
|
+
selectedCurrencies?: TableHeaderStatus[];
|
|
13
|
+
enableMultiSelectCurrency?: boolean;
|
|
9
14
|
}
|
|
10
|
-
declare function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, status }: StatusBarProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, status, onMultiSelectChange, currencyOptions, selectedCurrencies, enableMultiSelectCurrency, }: StatusBarProps): import("react/jsx-runtime").JSX.Element;
|
|
11
16
|
declare const _default: import("react").MemoExoticComponent<typeof StatusBar>;
|
|
12
17
|
export default _default;
|
|
@@ -1,32 +1,68 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
1
|
import { createElement as _createElement } from "react";
|
|
3
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useCallback, useState, useEffect } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { StatusButton } from '../TableHeader_V2';
|
|
6
|
-
|
|
6
|
+
import MultiSelectStatusButton from '../MultiSelectStatusButton';
|
|
7
|
+
function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, status, onMultiSelectChange, currencyOptions, selectedCurrencies = [], enableMultiSelectCurrency = false, }) {
|
|
7
8
|
const { t } = useTranslation();
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
9
|
+
const [multiSelectValues, setMultiSelectValues] = useState(selectedCurrencies);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (status && multiSelectValues.length > 0) {
|
|
12
|
+
setMultiSelectValues([]);
|
|
13
|
+
}
|
|
14
|
+
}, [status, multiSelectValues.length]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!status) {
|
|
17
|
+
setMultiSelectValues(selectedCurrencies);
|
|
18
|
+
}
|
|
19
|
+
}, [selectedCurrencies, status]);
|
|
20
|
+
const getButtonStatus = useCallback((buttonStatus) => {
|
|
21
|
+
if (multiSelectValues.length > 0) {
|
|
22
|
+
return 'inActive';
|
|
23
|
+
}
|
|
24
|
+
return buttonStatus === status && !isFilteredIdsShown ? 'active' : 'inActive';
|
|
25
|
+
}, [status, isFilteredIdsShown, multiSelectValues.length]);
|
|
26
|
+
const handleMultiSelectChange = useCallback((selected) => {
|
|
27
|
+
setMultiSelectValues(selected);
|
|
28
|
+
onMultiSelectChange === null || onMultiSelectChange === void 0 ? void 0 : onMultiSelectChange(selected);
|
|
29
|
+
if (selected.length > 0) {
|
|
30
|
+
onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange('');
|
|
31
|
+
}
|
|
32
|
+
}, [onMultiSelectChange, onStatusChange]);
|
|
33
|
+
const handleStatusChange = useCallback((newStatus) => {
|
|
34
|
+
if (multiSelectValues.length > 0) {
|
|
35
|
+
setMultiSelectValues([]);
|
|
36
|
+
onMultiSelectChange === null || onMultiSelectChange === void 0 ? void 0 : onMultiSelectChange([]);
|
|
37
|
+
}
|
|
38
|
+
onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(newStatus);
|
|
39
|
+
}, [multiSelectValues.length, onMultiSelectChange, onStatusChange]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (enableMultiSelectCurrency && multiSelectValues.length === 0 && selectedCurrencies.length === 0 && !status) {
|
|
42
|
+
handleStatusChange('all');
|
|
43
|
+
}
|
|
44
|
+
}, [enableMultiSelectCurrency, multiSelectValues.length, selectedCurrencies.length, status, handleStatusChange]);
|
|
45
|
+
return (_jsxs(_Fragment, { children: [enableMultiSelectCurrency && currencyOptions && (_jsx(MultiSelectStatusButton, { options: currencyOptions, selectedValues: multiSelectValues, onSelectionChange: handleMultiSelectChange, label: t('Currencies') || 'Currencies', variant: multiSelectValues.length > 0 && !status ? 'active' : 'inActive' })), availableStatuses === null || availableStatuses === void 0 ? void 0 : availableStatuses.map((s) => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
if (!Array.isArray(s.status)) {
|
|
48
|
+
return (_createElement(StatusButton, Object.assign({}, s, { key: `status-button-array-${s.status}`, variant: getButtonStatus(s.status), onClick: () => {
|
|
49
|
+
if (!Array.isArray(s.status)) {
|
|
50
|
+
handleStatusChange(s.status);
|
|
51
|
+
}
|
|
52
|
+
} })));
|
|
53
|
+
}
|
|
54
|
+
const isCurrentStatusDropdown = (_a = s.status) === null || _a === void 0 ? void 0 : _a.includes(status || '');
|
|
55
|
+
const variant = multiSelectValues.length > 0 ? 'inActive' : isCurrentStatusDropdown ? 'active' : 'inActive';
|
|
56
|
+
const statusLabel = isCurrentStatusDropdown ? status : s.status[0];
|
|
57
|
+
return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, s, { label: t(statusLabel || ''), variant: variant, onButtonBodyClick: (buttonStatus) => {
|
|
58
|
+
handleStatusChange(buttonStatus);
|
|
59
|
+
}, dropdownOptions: s.status.map((stat) => ({
|
|
60
|
+
label: t(stat || ''),
|
|
61
|
+
onClick: () => {
|
|
62
|
+
handleStatusChange(stat);
|
|
63
|
+
},
|
|
64
|
+
status: stat,
|
|
65
|
+
})) })) }, (_b = s === null || s === void 0 ? void 0 : s.status) === null || _b === void 0 ? void 0 : _b[0]));
|
|
66
|
+
})] }));
|
|
31
67
|
}
|
|
32
68
|
export default memo(StatusBar);
|
|
@@ -269,9 +269,9 @@ export declare const ActionIcon: import("@emotion/styled").StyledComponent<{
|
|
|
269
269
|
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLImageElement> | undefined;
|
|
270
270
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
271
271
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
272
|
+
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
272
273
|
src?: string | undefined;
|
|
273
274
|
alt?: string | undefined;
|
|
274
|
-
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
275
275
|
crossOrigin?: "" | "anonymous" | "use-credentials" | undefined;
|
|
276
276
|
useMap?: string | undefined;
|
|
277
277
|
loading?: "eager" | "lazy" | undefined;
|
|
@@ -273,9 +273,9 @@ export declare const MultiRefundIcon: import("@emotion/styled").StyledComponent<
|
|
|
273
273
|
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLImageElement> | undefined;
|
|
274
274
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
275
275
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
276
|
+
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
276
277
|
src?: string | undefined;
|
|
277
278
|
alt?: string | undefined;
|
|
278
|
-
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
279
279
|
crossOrigin?: "" | "anonymous" | "use-credentials" | undefined;
|
|
280
280
|
useMap?: string | undefined;
|
|
281
281
|
loading?: "eager" | "lazy" | undefined;
|
|
@@ -262,9 +262,9 @@ export declare const MultiRefundIcon: import("@emotion/styled").StyledComponent<
|
|
|
262
262
|
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLImageElement> | undefined;
|
|
263
263
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
264
264
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
265
|
+
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
265
266
|
src?: string | undefined;
|
|
266
267
|
alt?: string | undefined;
|
|
267
|
-
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
268
268
|
crossOrigin?: "" | "anonymous" | "use-credentials" | undefined;
|
|
269
269
|
useMap?: string | undefined;
|
|
270
270
|
loading?: "eager" | "lazy" | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ChevronIconProps } from './type';
|
|
2
|
-
export declare function ChevronIcon({ isActive }: ChevronIconProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function ChevronIcon({ isActive, disableHover }: ChevronIconProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useTheme } from '@mui/material';
|
|
4
|
-
export function ChevronIcon({ isActive }) {
|
|
4
|
+
export function ChevronIcon({ isActive, disableHover }) {
|
|
5
5
|
const [isHovered, setIsHovered] = useState(false);
|
|
6
6
|
const theme = useTheme();
|
|
7
7
|
const handleMouseEnter = () => {
|
|
8
|
-
|
|
8
|
+
if (!disableHover) {
|
|
9
|
+
setIsHovered(true);
|
|
10
|
+
}
|
|
9
11
|
};
|
|
10
12
|
const handleMouseLeave = () => {
|
|
11
13
|
setIsHovered(false);
|
|
@@ -15,8 +15,11 @@ export interface StatusButtonProps extends Omit<ButtonProps, 'variant' | 'childr
|
|
|
15
15
|
dropdownOptions?: Array<MenuItemI & {
|
|
16
16
|
status: TableHeaderStatus;
|
|
17
17
|
}>;
|
|
18
|
+
render?: (status: TableHeaderStatus) => ReactNode;
|
|
19
|
+
onMultiSelectChange?: (status: TableHeaderStatus[]) => void;
|
|
18
20
|
}
|
|
19
21
|
export interface ChevronIconProps {
|
|
20
22
|
isActive?: boolean;
|
|
23
|
+
disableHover?: boolean;
|
|
21
24
|
}
|
|
22
25
|
export type StatusButtonIcon = keyof typeof statusButtonIcons;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import Box from '@mui/material/Box';
|
|
4
4
|
import Collapse from '@mui/material/Collapse';
|
|
5
5
|
import lodashValues from 'lodash/values';
|
|
@@ -23,38 +23,25 @@ function Inputs({ onCloseDropdown, filter: { options = [], onConfirm, data, isOn
|
|
|
23
23
|
const onClickClear = () => {
|
|
24
24
|
setValues(options.reduce((acc, { apiKey }) => (Object.assign(Object.assign({}, acc), { [apiKey]: '' })), {}));
|
|
25
25
|
};
|
|
26
|
+
const isInputHasValue = (key) => values[key] !== undefined && values[key].length > 0;
|
|
26
27
|
const getInputValue = (key) => (values[key] !== undefined && values[key].length ? values[key] : '');
|
|
27
|
-
const showClearButton = useMemo(() => lodashValues(values).some((x) => Boolean(x)), [values]);
|
|
28
|
-
const getFilterByApiKey = useCallback((key) => {
|
|
29
|
-
return options === null || options === void 0 ? void 0 : options.find((option) => option.apiKey === key);
|
|
30
|
-
}, [options]);
|
|
31
|
-
const isAnyInputWithValue = (group) => Object.entries(values).some(([inputKey, val]) => { var _a; return Boolean(val) && (((_a = getFilterByApiKey(inputKey)) === null || _a === void 0 ? void 0 : _a.filterGroup) !== group || !group); });
|
|
32
|
-
return (_jsxs(Wrapper, Object.assign({ component: "article", "data-testid": "ColumnFilterInputs" }, { children: [_jsx(Text, Object.assign({ component: "header", "data-testid": "ColumnFilterInputs_title" }, { children: t('filterBy') })), _jsx(InputsWrapper, Object.assign({ "data-testid": "ColumnFilterInputs_inputs", component: "main" }, { children: options.map(({ placeholder, apiKey, isDisabled, filterGroup, render }) => {
|
|
33
|
-
const inputValue = getInputValue(apiKey);
|
|
34
|
-
return (_jsx(ColumnFilterInput, { apiKey: apiKey, isOnlyOneFilter: isOnlyOneFilter, setValues: setValues, options: options, value: inputValue, render: render, placeholder: placeholder, isDisabled: isDisabled, filterGroup: filterGroup, isAnyInputWithValue: isAnyInputWithValue(filterGroup) }, apiKey));
|
|
35
|
-
}) })), _jsx(Collapse, Object.assign({ in: showClearButton, component: "section", "data-testid": "ColumnFilterInputs_Collapse" }, { children: _jsx(ClearWrapper, Object.assign({ "data-testid": "ColumnFilterInputs_ClearWrapper" }, { children: _jsx(ClearButton, Object.assign({ type: "button", onClick: onClickClear, "data-testid": "ColumnFilterInputs_ClearButton" }, { children: t('clear') })) })) })), _jsxs(Footer, Object.assign({ component: "footer", "data-testid": "ColumnFilterInputs_footer" }, { children: [_jsx(CancelButton, Object.assign({ type: "button", onClick: onClickCancel, "data-testid": "ColumnFilterInputs_CancelButton" }, { children: t('cancel') })), _jsx(OkayButton, Object.assign({ type: "button", onClick: onClickOkay, "data-testid": "ColumnFilterInputs_OkayButton" }, { children: t('okay') }))] }))] })));
|
|
36
|
-
}
|
|
37
|
-
function ColumnFilterInput({ apiKey, isOnlyOneFilter, setValues, value, render, placeholder, isDisabled, isAnyInputWithValue, }) {
|
|
38
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
39
|
-
const isInputHasValue = useMemo(() => value !== undefined && value.length > 0, [value]);
|
|
40
28
|
const onClickResetInput = (key) => {
|
|
41
|
-
if (isInputHasValue)
|
|
42
|
-
setValues(
|
|
29
|
+
if (isInputHasValue(key))
|
|
30
|
+
setValues(Object.assign(Object.assign({}, values), { [key]: '' }));
|
|
43
31
|
};
|
|
44
|
-
const
|
|
45
|
-
|
|
32
|
+
const showClearButton = useMemo(() => lodashValues(values).some((x) => Boolean(x)), [values]);
|
|
33
|
+
const getFilterByApiKey = useCallback((apiKey) => {
|
|
34
|
+
return options.find((option) => option.apiKey === apiKey);
|
|
35
|
+
}, [options]);
|
|
36
|
+
const isInputDisabled = useCallback((key, filterGroup) => {
|
|
37
|
+
const inputWithValue = (values === null || values === void 0 ? void 0 : values[key]) !== undefined && (values === null || values === void 0 ? void 0 : values[key]) !== '' && (values === null || values === void 0 ? void 0 : values[key]) !== null;
|
|
38
|
+
const isAnyInputWithValue = Object.entries(values).some(([inputKey, val]) => { var _a; return Boolean(val) && (((_a = getFilterByApiKey(inputKey)) === null || _a === void 0 ? void 0 : _a.filterGroup) !== filterGroup || !filterGroup); });
|
|
46
39
|
return isOnlyOneFilter && !inputWithValue && isAnyInputWithValue;
|
|
47
|
-
}, [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
return (_jsx(InputStyled, { className: "input", "data-testid": "ColumnFilterInputs_InputStyled", name: apiKey, placeholder: placeholder, onChange: (e) => {
|
|
55
|
-
setValues((prev) => (Object.assign(Object.assign({}, prev), { [apiKey]: e.target.value })));
|
|
56
|
-
}, disabled: isDisabled || isInputDisabled, value: value, inputProps: { autoComplete: 'off', 'data-testid': 'ColumnFilterInputs_input' }, endAdornment: _jsx(Box, { component: "img", "data-testid": "ColumnFilterInputs_icon", "data-icon": isInputHasValue ? 'close' : 'search', src: isInputHasValue ? grayCloseIcon : searchIcon, alt: "search", className: "icon", sx: { cursor: isInputHasValue ? 'pointer' : 'default' }, onClick: () => {
|
|
57
|
-
onClickResetInput(apiKey);
|
|
58
|
-
} }) }));
|
|
40
|
+
}, [options, values, isOnlyOneFilter]);
|
|
41
|
+
return (_jsxs(Wrapper, Object.assign({ component: "article", "data-testid": "ColumnFilterInputs" }, { children: [_jsx(Text, Object.assign({ component: "header", "data-testid": "ColumnFilterInputs_title" }, { children: t('filterBy') })), _jsx(InputsWrapper, Object.assign({ "data-testid": "ColumnFilterInputs_inputs", component: "main" }, { children: options.map(({ placeholder, apiKey, isDisabled, filterGroup, render }) => (_jsx(Fragment, { children: render ? (render()) : (_jsx(InputStyled, { className: "input", "data-testid": "ColumnFilterInputs_InputStyled", name: apiKey, placeholder: placeholder, onChange: (e) => {
|
|
42
|
+
setValues(Object.assign(Object.assign({}, values), { [apiKey]: e.target.value }));
|
|
43
|
+
}, disabled: isDisabled || isInputDisabled(apiKey, filterGroup), value: getInputValue(apiKey), inputProps: { autoComplete: 'off', 'data-testid': 'ColumnFilterInputs_input' }, endAdornment: _jsx(Box, { component: "img", "data-testid": "ColumnFilterInputs_icon", "data-icon": isInputHasValue(apiKey) ? 'close' : 'search', src: isInputHasValue(apiKey) ? grayCloseIcon : searchIcon, alt: "search", className: "icon", sx: { cursor: isInputHasValue(apiKey) ? 'pointer' : 'default' }, onClick: () => {
|
|
44
|
+
onClickResetInput(apiKey);
|
|
45
|
+
} }) })) }, apiKey))) })), _jsx(Collapse, Object.assign({ in: showClearButton, component: "section", "data-testid": "ColumnFilterInputs_Collapse" }, { children: _jsx(ClearWrapper, Object.assign({ "data-testid": "ColumnFilterInputs_ClearWrapper" }, { children: _jsx(ClearButton, Object.assign({ type: "button", onClick: onClickClear, "data-testid": "ColumnFilterInputs_ClearButton" }, { children: t('clear') })) })) })), _jsxs(Footer, Object.assign({ component: "footer", "data-testid": "ColumnFilterInputs_footer" }, { children: [_jsx(CancelButton, Object.assign({ type: "button", onClick: onClickCancel, "data-testid": "ColumnFilterInputs_CancelButton" }, { children: t('cancel') })), _jsx(OkayButton, Object.assign({ type: "button", onClick: onClickOkay, "data-testid": "ColumnFilterInputs_OkayButton" }, { children: t('okay') }))] }))] })));
|
|
59
46
|
}
|
|
60
47
|
export default Inputs;
|
|
@@ -306,9 +306,9 @@ export declare const ActionIcon: import("@emotion/styled").StyledComponent<{
|
|
|
306
306
|
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLImageElement> | undefined;
|
|
307
307
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
308
308
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLImageElement> | undefined;
|
|
309
|
+
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
309
310
|
src?: string | undefined;
|
|
310
311
|
alt?: string | undefined;
|
|
311
|
-
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
312
312
|
crossOrigin?: "" | "anonymous" | "use-credentials" | undefined;
|
|
313
313
|
useMap?: string | undefined;
|
|
314
314
|
loading?: "eager" | "lazy" | undefined;
|
|
@@ -86,6 +86,7 @@ export { default as FlagDetails } from './FlagDetails';
|
|
|
86
86
|
export { default as TapLoader } from './Loaders';
|
|
87
87
|
export { default as Error } from './Error';
|
|
88
88
|
export { default as StatusBar } from './StatusBar';
|
|
89
|
+
export { default as MultiSelectStatusButton, type CurrencyOption, type MultiSelectStatusButtonProps } from './MultiSelectStatusButton';
|
|
89
90
|
export * from './Chip';
|
|
90
91
|
export * from './TableHeader_V2';
|
|
91
92
|
export { default as RangeCalender } from './RangeCalender';
|
|
@@ -86,6 +86,7 @@ export { default as FlagDetails } from './FlagDetails';
|
|
|
86
86
|
export { default as TapLoader } from './Loaders';
|
|
87
87
|
export { default as Error } from './Error';
|
|
88
88
|
export { default as StatusBar } from './StatusBar';
|
|
89
|
+
export { default as MultiSelectStatusButton } from './MultiSelectStatusButton';
|
|
89
90
|
export * from './Chip';
|
|
90
91
|
export * from './TableHeader_V2';
|
|
91
92
|
export { default as RangeCalender } from './RangeCalender';
|
package/build/types/table.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export interface IColumnFilterOption {
|
|
|
70
70
|
options?: IColumnFilterOption[];
|
|
71
71
|
isDisabled?: boolean;
|
|
72
72
|
filterGroup?: string;
|
|
73
|
-
render?: (
|
|
73
|
+
render?: () => React.ReactNode;
|
|
74
74
|
}
|
|
75
75
|
export type IColumnListFilterOption = Omit<IColumnFilterOption, 'apiKey' | 'options'> & {
|
|
76
76
|
value: string;
|
|
@@ -10,22 +10,14 @@ export declare const isIntegerAmount: (charge: number) => boolean;
|
|
|
10
10
|
export declare const isDecimalWithOneDigit: (charge: number) => boolean;
|
|
11
11
|
export declare const hasOnlyOneDigitAfterDecimal: (charge: number) => boolean;
|
|
12
12
|
export declare const formatCurrencyWithInput: (charge: number, selectedCurrency: CurrencyCodes) => string;
|
|
13
|
-
export declare function formatAmount(amount: number,
|
|
13
|
+
export declare function formatAmount(amount: number, decimal?: number): {
|
|
14
14
|
integerAmount: string;
|
|
15
15
|
decimalAmount: string;
|
|
16
16
|
fullAmount: string;
|
|
17
|
-
raw: {
|
|
18
|
-
integer: number;
|
|
19
|
-
decimal: number;
|
|
20
|
-
};
|
|
21
17
|
};
|
|
22
18
|
export declare function formatAmountWithCurrency(amount?: number, currency?: string): {
|
|
23
19
|
integerAmount: string;
|
|
24
20
|
decimalAmount: string;
|
|
25
21
|
fullAmount: string;
|
|
26
|
-
raw: {
|
|
27
|
-
integer: number;
|
|
28
|
-
decimal: number;
|
|
29
|
-
};
|
|
30
22
|
};
|
|
31
23
|
export declare const getSupportedCurrencies: (currencies: Currency[]) => Currency[];
|
package/build/utils/currency.js
CHANGED
|
@@ -55,33 +55,24 @@ export const formatCurrencyWithInput = (charge, selectedCurrency) => {
|
|
|
55
55
|
}
|
|
56
56
|
return chargeString;
|
|
57
57
|
};
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
amount = Math.abs(amount);
|
|
73
|
-
const integerAmount = Math.floor(amount);
|
|
74
|
-
let decimalStr = (amount - integerAmount).toString().split('.')[1] || '0';
|
|
75
|
-
decimalStr = decimalStr.padEnd(decimalPlaces, '0').slice(0, decimalPlaces);
|
|
76
|
-
const formattedIntegerAmount = Intl.NumberFormat('en-US').format(integerAmount);
|
|
77
|
-
const decimalStrWithoutRounding = (_a = amount.toString().split('.')[1]) === null || _a === void 0 ? void 0 : _a.slice(0, decimalPlaces);
|
|
78
|
-
const fullAmount = buildFormattedAmount(formattedIntegerAmount, decimalStrWithoutRounding);
|
|
79
|
-
const raw = getRawAmount(integerAmount, decimalStr, isNegative);
|
|
58
|
+
export function formatAmount(amount, decimal = 2) {
|
|
59
|
+
const num = parseFloat(amount.toString());
|
|
60
|
+
if (isNaN(num)) {
|
|
61
|
+
const [integerAmount, decimalAmount] = (0).toFixed(decimal).split('.');
|
|
62
|
+
const fullAmount = `${integerAmount}.${decimalAmount}`;
|
|
63
|
+
return {
|
|
64
|
+
integerAmount,
|
|
65
|
+
decimalAmount,
|
|
66
|
+
fullAmount,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const fixedNumber = num.toFixed(decimal);
|
|
70
|
+
const [integerPart, decimalPart] = fixedNumber.split('.');
|
|
71
|
+
const formattedInteger = parseInt(integerPart).toLocaleString();
|
|
80
72
|
return {
|
|
81
|
-
integerAmount:
|
|
82
|
-
decimalAmount:
|
|
83
|
-
fullAmount
|
|
84
|
-
raw,
|
|
73
|
+
integerAmount: formattedInteger,
|
|
74
|
+
decimalAmount: decimalPart,
|
|
75
|
+
fullAmount: `${formattedInteger}.${decimalPart}`,
|
|
85
76
|
};
|
|
86
77
|
}
|
|
87
78
|
export function formatAmountWithCurrency(amount = 0, currency = '') {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/os-micro-frontend-shared",
|
|
3
3
|
"description": "Shared components and utilities for Tap Payments micro frontends",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.99-amount-fix",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"module": "build/index.js",
|