@tap-payments/os-micro-frontend-shared 0.1.287 → 0.1.288
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/Amount/TotalAmount/TotalAmount.js +4 -2
- package/build/components/AmountInput/AmountInput.d.ts +1 -1
- package/build/components/AmountInput/AmountInput.js +3 -2
- package/build/components/Discount/TotalDiscount/TotalDiscount.js +2 -1
- package/build/components/DisplayAmount/DisplayAmount.d.ts +2 -3
- package/build/components/DisplayAmount/DisplayAmount.js +2 -3
- package/build/components/VAT/TotalVAT/TotalVAT.js +4 -2
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import { InputStyled, TotalAmountWrapper, Error } from './style';
|
|
|
9
9
|
import { Loading } from './Loading';
|
|
10
10
|
const isSafari = isSafariBrowser();
|
|
11
11
|
function TotalAmount({ totalGrossAmount, items, selectedCurrency, isAmountIsMissing, isDisabled, isLoading, onResetAllItems, onAddFirstItem, }) {
|
|
12
|
+
var _a;
|
|
12
13
|
const [editMode, setEditMode] = useState(false);
|
|
13
14
|
const [amount, setAmount] = useState();
|
|
14
15
|
const { isConfirmed } = useConfirmDialog();
|
|
@@ -43,6 +44,7 @@ function TotalAmount({ totalGrossAmount, items, selectedCurrency, isAmountIsMiss
|
|
|
43
44
|
onAddFirstItem(Number(numberToString(Number(e.target.value), selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.decimals)));
|
|
44
45
|
};
|
|
45
46
|
const isEditable = totalGrossAmount === 0 || (items.length === 1 && totalGrossAmount === items[0].total);
|
|
47
|
+
const currencyCode = ((_a = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _a === void 0 ? void 0 : _a.english) || '';
|
|
46
48
|
if (isLoading) {
|
|
47
49
|
return _jsx(Loading, {});
|
|
48
50
|
}
|
|
@@ -50,9 +52,9 @@ function TotalAmount({ totalGrossAmount, items, selectedCurrency, isAmountIsMiss
|
|
|
50
52
|
if (isSafari && isNaN(Number(evt.key)) && evt.key !== 'Backspace' && evt.key !== '.') {
|
|
51
53
|
evt.preventDefault();
|
|
52
54
|
}
|
|
53
|
-
}, autoFocus: true })) : (_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' }, amount: totalGrossAmount || 0,
|
|
55
|
+
}, autoFocus: true })) : (_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' }, amount: totalGrossAmount || 0, currencyCode: currencyCode, onClick: () => {
|
|
54
56
|
setEditMode(true);
|
|
55
|
-
} })) })) : (_jsxs(TotalAmountWrapper, { children: [_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' },
|
|
57
|
+
} })) })) : (_jsxs(TotalAmountWrapper, { children: [_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' }, currencyCode: currencyCode, amount: totalGrossAmount || 0, onClick: () => {
|
|
56
58
|
if (isEditable)
|
|
57
59
|
setEditMode(true);
|
|
58
60
|
} }), totalGrossAmount > 0 && _jsx(Box, { component: "img", src: removeAllItem, alt: "r", onClick: removeAllItems })] })), isAmountIsMissing && (_jsxs(Error, { children: [_jsx(Box, { component: "img", src: unknownIcon }), _jsx(Box, { children: t('enterAmount') })] }))] })));
|
|
@@ -9,6 +9,6 @@ interface AmountInputI extends BoxProps {
|
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
selectedCurrency: Currency;
|
|
11
11
|
}
|
|
12
|
-
declare function AmountInput({ amount, setAmount,
|
|
12
|
+
declare function AmountInput({ amount, setAmount, maxAmount, isError, selectedCurrency, ...props }: AmountInputI): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
declare const _default: import("react").MemoExoticComponent<typeof AmountInput>;
|
|
14
14
|
export default _default;
|
|
@@ -16,7 +16,8 @@ import { DisplayAmount } from '../index.js';
|
|
|
16
16
|
import { Wrapper, InputStyled } from './style';
|
|
17
17
|
const isSafari = isSafariBrowser();
|
|
18
18
|
function AmountInput(_a) {
|
|
19
|
-
var
|
|
19
|
+
var _b;
|
|
20
|
+
var { amount, setAmount, maxAmount, isError, selectedCurrency } = _a, props = __rest(_a, ["amount", "setAmount", "maxAmount", "isError", "selectedCurrency"]);
|
|
20
21
|
const [editMode, setEditMode] = useState(false);
|
|
21
22
|
const [value, setValue] = useState(amount || '');
|
|
22
23
|
const currencyPlaceholder = useMemo(() => getAmountPlaceholder(selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.decimals), [selectedCurrency]);
|
|
@@ -36,7 +37,7 @@ function AmountInput(_a) {
|
|
|
36
37
|
evt.preventDefault();
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
|
-
return (_jsx(Wrapper, Object.assign({ sx: props.sx }, { children: editMode ? (_jsx(InputStyled, { placeholder: currencyPlaceholder, value: value, onChange: onChange, onBlur: onBlur, onKeyDown: onKeyDown, isError: isError, inputProps: { step: '0.01' }, hideArrows: true, autoFocus: true })) : (_jsx(DisplayAmount, { selectedCurrency: selectedCurrency, amount: amount, onClick: () => {
|
|
40
|
+
return (_jsx(Wrapper, Object.assign({ sx: props.sx }, { children: editMode ? (_jsx(InputStyled, { placeholder: currencyPlaceholder, value: value, onChange: onChange, onBlur: onBlur, onKeyDown: onKeyDown, isError: isError, inputProps: { step: '0.01' }, hideArrows: true, autoFocus: true })) : (_jsx(DisplayAmount, { currencyCode: (_b = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _b === void 0 ? void 0 : _b.english, amount: amount, onClick: () => {
|
|
40
41
|
setEditMode(true);
|
|
41
42
|
} })) })));
|
|
42
43
|
}
|
|
@@ -20,9 +20,10 @@ function TotalDiscount({ selectedCurrency, totalGrossAmount, totalDiscount, onCh
|
|
|
20
20
|
onChangeTotalDiscount(Object.assign(Object.assign({}, newDiscount), { value: getDiscountValue(totalGrossAmount, newDiscount) }));
|
|
21
21
|
};
|
|
22
22
|
const getLabel = () => {
|
|
23
|
+
var _a;
|
|
23
24
|
if (totalDiscount.value === 0)
|
|
24
25
|
return t('noDiscount');
|
|
25
|
-
return (_jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '2px' } }, { children: [_jsx("span", { children: "-" }), _jsx(DisplayAmount, { amount: totalDiscount.value, selectedCurrency: selectedCurrency })] })));
|
|
26
|
+
return (_jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '2px' } }, { children: [_jsx("span", { children: "-" }), _jsx(DisplayAmount, { amount: totalDiscount.value, currencyCode: (_a = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _a === void 0 ? void 0 : _a.english })] })));
|
|
26
27
|
};
|
|
27
28
|
return (_jsxs(LabelWrapper, Object.assign({ isOpen: isOpen, isDisabled: isDisabled, onClick: toggleDropdown, ref: discountButtonRef, sx: Object.assign({}, (isDisabled && { pointerEvents: 'none', opacity: 0.7 })) }, { children: [_jsx("img", { src: discountIcon, alt: "p" }), _jsx(Label, Object.assign({ isDisabled: isDisabled }, { children: getLabel() })), _jsx(Box, { component: "img", src: isOpen ? activeActionIcon : actionsIcon, alt: "a" }), isOpen && _jsx(CustomBackdrop, { onClick: toggleDropdown }), _jsx(Popper, Object.assign({ open: Boolean(isOpen), anchorEl: discountButtonRef.current, placement: "bottom-start" }, { children: _jsx(DiscountDropdown, { sx: { position: 'absolute', top: 8, left: 0, display: isOpen ? 'block' : 'none' }, selectedCurrency: selectedCurrency, discount: totalDiscount, setDiscount: handleDiscount, setIsOpen: setIsOpen, maxDiscount: Number(totalGrossAmount) }) }))] })));
|
|
28
29
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BoxProps } from '@mui/material/Box';
|
|
3
|
-
import { Currency } from '../../types/index.js';
|
|
4
3
|
interface DisplayAmountI extends BoxProps {
|
|
5
4
|
amount: number;
|
|
6
|
-
|
|
5
|
+
currencyCode: string;
|
|
7
6
|
}
|
|
8
|
-
declare function DisplayAmount({ amount,
|
|
7
|
+
declare function DisplayAmount({ amount, currencyCode, ...props }: DisplayAmountI): import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
declare const _default: import("react").MemoExoticComponent<typeof DisplayAmount>;
|
|
10
9
|
export default _default;
|
|
@@ -14,9 +14,8 @@ import { memo } from 'react';
|
|
|
14
14
|
import { formatAmountWithCurrency } from '../../utils/index.js';
|
|
15
15
|
import { DecimalSpan, CurrencySpan } from './style';
|
|
16
16
|
function DisplayAmount(_a) {
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
const { integerAmount, decimalAmount } = formatAmountWithCurrency(amount, (_b = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _b === void 0 ? void 0 : _b.english);
|
|
17
|
+
var { amount, currencyCode } = _a, props = __rest(_a, ["amount", "currencyCode"]);
|
|
18
|
+
const { integerAmount, decimalAmount } = formatAmountWithCurrency(amount, currencyCode);
|
|
20
19
|
return (_jsxs(CurrencySpan, Object.assign({}, props, { children: [_jsx("span", { children: integerAmount }), _jsx("span", { children: "." }), _jsx(DecimalSpan, { children: decimalAmount })] })));
|
|
21
20
|
}
|
|
22
21
|
export default memo(DisplayAmount);
|
|
@@ -9,6 +9,7 @@ import { Label, LabelWrapper } from './style';
|
|
|
9
9
|
import { getVatValue } from '../utils';
|
|
10
10
|
import VATDropdown from '../VATDropdown';
|
|
11
11
|
function TotalVAT({ totalGrossAmount, totalVat, selectedCurrency, onChangeTotalVat, isDisabled }) {
|
|
12
|
+
var _a;
|
|
12
13
|
const [isOpen, setIsOpen] = useState(false);
|
|
13
14
|
const vatButtonRef = useRef();
|
|
14
15
|
const { t } = useTranslation();
|
|
@@ -19,12 +20,13 @@ function TotalVAT({ totalGrossAmount, totalVat, selectedCurrency, onChangeTotalV
|
|
|
19
20
|
const modifyTotalVAT = (newVat) => {
|
|
20
21
|
onChangeTotalVat(Object.assign(Object.assign({}, newVat), { value: getVatValue(totalGrossAmount, newVat) }));
|
|
21
22
|
};
|
|
23
|
+
const currencyCode = ((_a = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _a === void 0 ? void 0 : _a.english) || '';
|
|
22
24
|
const getLabel = () => {
|
|
23
25
|
if (totalVat.percentage === 0)
|
|
24
26
|
return t('noVat');
|
|
25
27
|
if (!totalVat.isInclusive)
|
|
26
|
-
return _jsx(DisplayAmount, {
|
|
27
|
-
return (_jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '4px' } }, { children: [_jsxs("span", { children: [t('inclusive'), " "] }), _jsx(DisplayAmount, { amount: totalVat.value,
|
|
28
|
+
return _jsx(DisplayAmount, { currencyCode: currencyCode, amount: totalVat.value });
|
|
29
|
+
return (_jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '4px' } }, { children: [_jsxs("span", { children: [t('inclusive'), " "] }), _jsx(DisplayAmount, { amount: totalVat.value, currencyCode: currencyCode })] })));
|
|
28
30
|
};
|
|
29
31
|
return (_jsxs(LabelWrapper, Object.assign({ isDisabled: isDisabled, isOpen: isOpen, onClick: toggleDropdown, ref: vatButtonRef, sx: Object.assign({}, (isDisabled && { pointerEvents: 'none', opacity: 0.7 })) }, { children: [_jsx("img", { src: taxIcon, alt: "p" }), _jsx(Label, Object.assign({ isDisabled: isDisabled }, { children: getLabel() })), _jsx(Box, { component: "img", src: isOpen ? activeActionIcon : actionsIcon, alt: "a" }), isOpen && _jsx(CustomBackdrop, { onClick: toggleDropdown }), _jsx(Popper, Object.assign({ open: Boolean(isOpen), anchorEl: vatButtonRef.current, placement: "bottom-start" }, { children: _jsx(VATDropdown, { setIsOpen: setIsOpen, vat: totalVat, setVat: modifyTotalVAT, sx: { position: 'absolute', top: 8, left: 0, display: isOpen ? 'block' : 'none' } }) }))] })));
|
|
30
32
|
}
|
package/package.json
CHANGED