@tap-payments/os-micro-frontend-shared 0.0.151 → 0.0.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,8 +5,8 @@ import { Typography, Checkbox } from '@mui/material';
|
|
|
5
5
|
import { ChevronIcon } from '../TableHeader_V2/components/StatusButtons/ChevronIcon';
|
|
6
6
|
import StyledBadge, { BadgeVariants } from '../CountBadge';
|
|
7
7
|
import CountryFlag from '../CountryFlag';
|
|
8
|
-
import { formatNumber
|
|
9
|
-
import { closeXIcon } from '../../constants/index.js';
|
|
8
|
+
import { formatNumber } from '../../utils/index.js';
|
|
9
|
+
import { closeXIcon, SUPPORTED_CURRENCY_DETAILS } from '../../constants/index.js';
|
|
10
10
|
import { ChevronContainer, Label, LabelWrapper, StyledDropdown, MenuItemContainer, CheckboxStyles, StyledStatusButton, ClearIcon, ChevronIconWrapper, } from './style';
|
|
11
11
|
function MultiSelectStatusButton({ options = [], selectedValues, onSelectionChange, label, variant = 'inActive' }) {
|
|
12
12
|
const { t } = useTranslation();
|
|
@@ -80,18 +80,21 @@ function MultiSelectStatusButton({ options = [], selectedValues, onSelectionChan
|
|
|
80
80
|
'&:hover': {
|
|
81
81
|
boxShadow: 'none !important',
|
|
82
82
|
},
|
|
83
|
-
}, menuItems: options.map((option) =>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
e
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
}, menuItems: options.map((option) => {
|
|
84
|
+
var _a;
|
|
85
|
+
return ({
|
|
86
|
+
label: (_jsxs(MenuItemContainer, { children: [_jsx(Checkbox, { checked: internalSelectedValues.includes(option.status), size: "small", sx: CheckboxStyles, onClick: (e) => {
|
|
87
|
+
var _a;
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
|
|
90
|
+
} }), _jsx(CountryFlag, { code: ((_a = SUPPORTED_CURRENCY_DETAILS[option.code]) === null || _a === void 0 ? void 0 : _a.country) || '', sx: { border: '1px solid white', borderRadius: '3px' } }), _jsx(Typography, Object.assign({ variant: "body2" }, { children: option.name }))] })),
|
|
91
|
+
onClick: (e) => {
|
|
92
|
+
var _a;
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
e.stopPropagation();
|
|
95
|
+
handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}) }))] }));
|
|
96
99
|
}
|
|
97
100
|
export default memo(MultiSelectStatusButton);
|
|
@@ -20,8 +20,7 @@ import { FlagIcon } from '../style';
|
|
|
20
20
|
function AmountCell(_a) {
|
|
21
21
|
var { conversionType, amount, currency, tooltipLabel, amountTooltipLabel, isTextShown, tableMode } = _a, props = __rest(_a, ["conversionType", "amount", "currency", "tooltipLabel", "amountTooltipLabel", "isTextShown", "tableMode"]);
|
|
22
22
|
const icon = currency && _jsx(FlagIcon, { src: getCurrenciesIcon(currency), alt: "customer icon" });
|
|
23
|
-
const {
|
|
24
|
-
const [integerAmount, decimalAmount] = fullAmount.toString().split('.');
|
|
23
|
+
const { integerAmount, decimalAmount } = formatAmountWithCurrency(amount, currency);
|
|
25
24
|
return (_jsx(TableCell, Object.assign({}, props, { children: _jsxs(AmountCellContainer, { children: [_jsx(Tooltip, Object.assign({ title: tooltipLabel || '' }, { children: conversionType && (_jsx(ConversionBadge, Object.assign({ tableMode: tableMode, className: "conversion-type" }, { children: conversionType }))) })), _jsx(Tooltip, Object.assign({ title: _jsx(CurrencyIcon, { currency: currency }) }, { children: isTextShown ? _jsx("span", {}) : _jsx(FlagContainer, { children: icon }) })), _jsx(Tooltip, Object.assign({ title: amountTooltipLabel }, { children: _jsx(CurrencySpan, Object.assign({ tableMode: tableMode }, { children: amount !== undefined ? (_jsxs(_Fragment, { children: [_jsx("span", { children: _jsx(CurrencyIcon, { currency: currency, fontSize: 10 }) }), ' ', integerAmount, decimalAmount && (_jsxs(_Fragment, { children: [".", _jsx(DecimalSpan, { children: decimalAmount })] }))] })) : (_jsx("span", { children: "-" })) })) }))] }) })));
|
|
26
25
|
}
|
|
27
26
|
export default AmountCell;
|
|
@@ -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