@tap-payments/os-micro-frontend-shared 0.1.249-test.2 → 0.1.249-test.3

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.
Files changed (117) hide show
  1. package/build/components/Amount/TotalAmount/Loading.d.ts +1 -0
  2. package/build/components/Amount/TotalAmount/Loading.js +9 -0
  3. package/build/components/Amount/TotalAmount/TotalAmount.d.ts +15 -0
  4. package/build/components/Amount/TotalAmount/TotalAmount.js +60 -0
  5. package/build/components/Amount/TotalAmount/index.d.ts +1 -0
  6. package/build/components/Amount/TotalAmount/index.js +1 -0
  7. package/build/components/Amount/TotalAmount/style.d.ts +11 -0
  8. package/build/components/Amount/TotalAmount/style.js +26 -0
  9. package/build/components/Amount/index.d.ts +1 -0
  10. package/build/components/Amount/index.js +1 -0
  11. package/build/components/Discount/DiscountDropdown/DiscountDropdown.d.ts +13 -0
  12. package/build/components/Discount/DiscountDropdown/DiscountDropdown.js +67 -0
  13. package/build/components/Discount/DiscountDropdown/index.d.ts +2 -0
  14. package/build/components/Discount/DiscountDropdown/index.js +2 -0
  15. package/build/components/Discount/DiscountDropdown/style.d.ts +12 -0
  16. package/build/components/Discount/DiscountDropdown/style.js +40 -0
  17. package/build/components/Discount/DiscountRateDropdown/DiscountRateDropdown.d.ts +12 -0
  18. package/build/components/Discount/DiscountRateDropdown/DiscountRateDropdown.js +53 -0
  19. package/build/components/Discount/DiscountRateDropdown/index.d.ts +2 -0
  20. package/build/components/Discount/DiscountRateDropdown/index.js +2 -0
  21. package/build/components/Discount/DiscountRateDropdown/style.d.ts +7 -0
  22. package/build/components/Discount/DiscountRateDropdown/style.js +33 -0
  23. package/build/components/Discount/TotalDiscount/TotalDiscount.d.ts +12 -0
  24. package/build/components/Discount/TotalDiscount/TotalDiscount.js +29 -0
  25. package/build/components/Discount/TotalDiscount/index.d.ts +1 -0
  26. package/build/components/Discount/TotalDiscount/index.js +1 -0
  27. package/build/components/Discount/TotalDiscount/style.d.ts +12 -0
  28. package/build/components/Discount/TotalDiscount/style.js +5 -0
  29. package/build/components/Discount/index.d.ts +4 -0
  30. package/build/components/Discount/index.js +4 -0
  31. package/build/components/Discount/utils.d.ts +8 -0
  32. package/build/components/Discount/utils.js +12 -0
  33. package/build/components/FilterDropdown/FilterDropdown.d.ts +10 -0
  34. package/build/components/FilterDropdown/FilterDropdown.js +54 -0
  35. package/build/components/FilterDropdown/components/BrandItem/BrandItem.d.ts +12 -0
  36. package/build/components/FilterDropdown/components/BrandItem/BrandItem.js +39 -0
  37. package/build/components/FilterDropdown/components/BrandItem/index.d.ts +2 -0
  38. package/build/components/FilterDropdown/components/BrandItem/index.js +2 -0
  39. package/build/components/FilterDropdown/components/BrandItem/style.d.ts +4 -0
  40. package/build/components/FilterDropdown/components/BrandItem/style.js +9 -0
  41. package/build/components/FilterDropdown/components/CountriesItem/CountriesItem.d.ts +12 -0
  42. package/build/components/FilterDropdown/components/CountriesItem/CountriesItem.js +54 -0
  43. package/build/components/FilterDropdown/components/CountriesItem/index.d.ts +1 -0
  44. package/build/components/FilterDropdown/components/CountriesItem/index.js +1 -0
  45. package/build/components/FilterDropdown/components/CurrenciesItem/CurrenciesItem.d.ts +12 -0
  46. package/build/components/FilterDropdown/components/CurrenciesItem/CurrenciesItem.js +59 -0
  47. package/build/components/FilterDropdown/components/CurrenciesItem/index.d.ts +1 -0
  48. package/build/components/FilterDropdown/components/CurrenciesItem/index.js +1 -0
  49. package/build/components/FilterDropdown/components/FlatMerchantsListMenu/FlatMerchantsListMenu.d.ts +11 -0
  50. package/build/components/FilterDropdown/components/FlatMerchantsListMenu/FlatMerchantsListMenu.js +39 -0
  51. package/build/components/FilterDropdown/components/FlatMerchantsListMenu/index.d.ts +2 -0
  52. package/build/components/FilterDropdown/components/FlatMerchantsListMenu/index.js +2 -0
  53. package/build/components/FilterDropdown/components/FlatMerchantsListMenu/style.d.ts +12 -0
  54. package/build/components/FilterDropdown/components/FlatMerchantsListMenu/style.js +23 -0
  55. package/build/components/FilterDropdown/components/MerchantItem/MerchantItem.d.ts +13 -0
  56. package/build/components/FilterDropdown/components/MerchantItem/MerchantItem.js +43 -0
  57. package/build/components/FilterDropdown/components/MerchantItem/index.d.ts +2 -0
  58. package/build/components/FilterDropdown/components/MerchantItem/index.js +2 -0
  59. package/build/components/FilterDropdown/components/RetailersItem/RetailersItem.d.ts +14 -0
  60. package/build/components/FilterDropdown/components/RetailersItem/RetailersItem.js +70 -0
  61. package/build/components/FilterDropdown/components/RetailersItem/index.d.ts +1 -0
  62. package/build/components/FilterDropdown/components/RetailersItem/index.js +1 -0
  63. package/build/components/FilterDropdown/components/RetailersItem/style.d.ts +4 -0
  64. package/build/components/FilterDropdown/components/RetailersItem/style.js +8 -0
  65. package/build/components/FilterDropdown/components/index.d.ts +4 -0
  66. package/build/components/FilterDropdown/components/index.js +4 -0
  67. package/build/components/FilterDropdown/index.d.ts +3 -0
  68. package/build/components/FilterDropdown/index.js +3 -0
  69. package/build/components/FilterDropdown/style.d.ts +20 -0
  70. package/build/components/FilterDropdown/style.js +60 -0
  71. package/build/components/FilterDropdown/type.d.ts +4 -0
  72. package/build/components/FilterDropdown/type.js +1 -0
  73. package/build/components/MenuItem/MenuItem.d.ts +1 -1
  74. package/build/components/MerchantLogo/MerchantLogo.d.ts +10 -0
  75. package/build/components/MerchantLogo/MerchantLogo.js +17 -0
  76. package/build/components/MerchantLogo/index.d.ts +1 -0
  77. package/build/components/MerchantLogo/index.js +1 -0
  78. package/build/components/MerchantLogo/style.d.ts +5 -0
  79. package/build/components/MerchantLogo/style.js +13 -0
  80. package/build/components/VAT/TotalVAT/TotalVAT.d.ts +12 -0
  81. package/build/components/VAT/TotalVAT/TotalVAT.js +31 -0
  82. package/build/components/VAT/TotalVAT/index.d.ts +1 -0
  83. package/build/components/VAT/TotalVAT/index.js +1 -0
  84. package/build/components/VAT/TotalVAT/style.d.ts +12 -0
  85. package/build/components/VAT/TotalVAT/style.js +5 -0
  86. package/build/components/VAT/VATDropdown/VATDropdown.d.ts +11 -0
  87. package/build/components/VAT/VATDropdown/VATDropdown.js +34 -0
  88. package/build/components/VAT/VATDropdown/index.d.ts +1 -0
  89. package/build/components/VAT/VATDropdown/index.js +1 -0
  90. package/build/components/VAT/VATDropdown/style.d.ts +7 -0
  91. package/build/components/VAT/VATDropdown/style.js +32 -0
  92. package/build/components/VAT/VATRateDropdown/VATRateDropdown.d.ts +10 -0
  93. package/build/components/VAT/VATRateDropdown/VATRateDropdown.js +38 -0
  94. package/build/components/VAT/VATRateDropdown/index.d.ts +1 -0
  95. package/build/components/VAT/VATRateDropdown/index.js +1 -0
  96. package/build/components/VAT/VATRateDropdown/style.d.ts +7 -0
  97. package/build/components/VAT/VATRateDropdown/style.js +30 -0
  98. package/build/components/VAT/index.d.ts +4 -0
  99. package/build/components/VAT/index.js +4 -0
  100. package/build/components/VAT/utils.d.ts +7 -0
  101. package/build/components/VAT/utils.js +8 -0
  102. package/build/components/Window/Window.d.ts +3 -4
  103. package/build/components/Window/Window.js +2 -2
  104. package/build/components/index.d.ts +5 -0
  105. package/build/components/index.js +5 -0
  106. package/build/constants/index.d.ts +1 -0
  107. package/build/constants/index.js +1 -0
  108. package/build/constants/rate.d.ts +6 -0
  109. package/build/constants/rate.js +6 -0
  110. package/build/types/destination.d.ts +14 -0
  111. package/build/types/discount.d.ts +5 -0
  112. package/build/types/discount.js +6 -0
  113. package/build/types/index.d.ts +2 -0
  114. package/build/types/index.js +2 -0
  115. package/build/types/invoice.d.ts +1 -6
  116. package/build/types/invoice.js +0 -6
  117. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ export declare const Loading: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Skeleton from '@mui/material/Skeleton';
3
+ export const Loading = () => {
4
+ return (_jsx(Skeleton, { sx: {
5
+ height: 32,
6
+ width: 80,
7
+ borderRadius: '4px',
8
+ }, variant: "rectangular" }));
9
+ };
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { Currency, Item } from '../../../types/index.js';
3
+ export interface TotalAmountProps {
4
+ totalGrossAmount: number;
5
+ items: Item[];
6
+ selectedCurrency: Currency;
7
+ isAmountIsMissing: boolean;
8
+ isDisabled?: boolean;
9
+ isLoading?: boolean;
10
+ onResetAllItems: () => void;
11
+ onAddFirstItem: (amount: number) => void;
12
+ }
13
+ declare function TotalAmount({ totalGrossAmount, items, selectedCurrency, isAmountIsMissing, isDisabled, isLoading, onResetAllItems, onAddFirstItem, }: Readonly<TotalAmountProps>): import("react/jsx-runtime").JSX.Element;
14
+ declare const _default: import("react").MemoExoticComponent<typeof TotalAmount>;
15
+ export default _default;
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useState, useMemo, useEffect } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import Box from '@mui/material/Box';
5
+ import { removeAllItem, unknownIcon } from '../../../constants/index.js';
6
+ import { useConfirmDialog, DisplayAmount } from '../../index.js';
7
+ import { isSafariBrowser, numberToString, getAmountPlaceholder } from '../../../utils/index.js';
8
+ import { InputStyled, TotalAmountWrapper, Error } from './style';
9
+ import { Loading } from './Loading';
10
+ const isSafari = isSafariBrowser();
11
+ function TotalAmount({ totalGrossAmount, items, selectedCurrency, isAmountIsMissing, isDisabled, isLoading, onResetAllItems, onAddFirstItem, }) {
12
+ const [editMode, setEditMode] = useState(false);
13
+ const [amount, setAmount] = useState();
14
+ const { isConfirmed } = useConfirmDialog();
15
+ const { t } = useTranslation();
16
+ const currencyPlaceholder = useMemo(() => getAmountPlaceholder(selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.decimals), [selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.decimals]);
17
+ useEffect(() => {
18
+ if (!totalGrossAmount) {
19
+ setAmount(undefined);
20
+ }
21
+ }, [totalGrossAmount]);
22
+ const removeAllItems = () => {
23
+ isConfirmed({
24
+ message: t('removeTotalAmount'),
25
+ confirmText: _jsx(Box, Object.assign({ sx: (theme) => ({ color: theme.palette.error.light }) }, { children: t('remove') })),
26
+ cancelText: t('cancel') || 'Cancel',
27
+ }).then((confirmed) => {
28
+ if (confirmed) {
29
+ onResetAllItems();
30
+ setAmount(undefined);
31
+ }
32
+ });
33
+ };
34
+ const handleChangeInput = (e) => {
35
+ if (!e.target.value) {
36
+ setAmount(undefined);
37
+ return false;
38
+ }
39
+ setAmount(Number(numberToString(Number(e.target.value), selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.decimals)));
40
+ };
41
+ const handleBlurInput = (e) => {
42
+ setEditMode(false);
43
+ onAddFirstItem(Number(numberToString(Number(e.target.value), selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.decimals)));
44
+ };
45
+ const isEditable = totalGrossAmount === 0 || (items.length === 1 && totalGrossAmount === items[0].total);
46
+ if (isLoading) {
47
+ return _jsx(Loading, {});
48
+ }
49
+ return (_jsxs(Box, Object.assign({ sx: Object.assign({}, (isDisabled && { pointerEvents: 'none', opacity: 0.7 })) }, { children: [editMode ? (_jsx(_Fragment, { children: isEditable ? (_jsx(InputStyled, { value: amount, placeholder: currencyPlaceholder, hideArrows: true, inputProps: { step: '0.01' }, onChange: handleChangeInput, onBlur: handleBlurInput, onKeyDown: (evt) => {
50
+ if (isSafari && isNaN(Number(evt.key)) && evt.key !== 'Backspace' && evt.key !== '.') {
51
+ evt.preventDefault();
52
+ }
53
+ }, autoFocus: true })) : (_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' }, amount: totalGrossAmount || 0, selectedCurrency: selectedCurrency, onClick: () => {
54
+ setEditMode(true);
55
+ } })) })) : (_jsxs(TotalAmountWrapper, { children: [_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' }, selectedCurrency: selectedCurrency, amount: totalGrossAmount || 0, onClick: () => {
56
+ if (isEditable)
57
+ setEditMode(true);
58
+ } }), 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') })] }))] })));
59
+ }
60
+ export default memo(TotalAmount);
@@ -0,0 +1 @@
1
+ export { default } from './TotalAmount';
@@ -0,0 +1 @@
1
+ export { default } from './TotalAmount';
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export declare const InputStyled: import("@emotion/styled").StyledComponent<Omit<Readonly<import("@mui/material").InputProps & {
3
+ isError?: boolean | undefined;
4
+ hideArrows?: boolean | undefined;
5
+ }>, "ref"> & import("react").RefAttributes<HTMLInputElement> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
6
+ export declare const TotalAmountWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
7
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
8
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
9
+ export declare const Error: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
10
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
11
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
@@ -0,0 +1,26 @@
1
+ import Box from '@mui/material/Box';
2
+ import { styled } from '@mui/material/styles';
3
+ import { InputNumber } from '../../index.js';
4
+ export const InputStyled = styled(InputNumber)(() => ({
5
+ fontSize: '36px !important',
6
+ textAlign: 'center',
7
+ border: 'none',
8
+ height: 49.5,
9
+ input: {
10
+ textAlign: 'center',
11
+ },
12
+ }));
13
+ export const TotalAmountWrapper = styled(Box)(() => ({
14
+ display: 'flex',
15
+ gap: '5px',
16
+ alignItems: 'center',
17
+ height: 49.5,
18
+ maxWidth: '-webkit-fill-available',
19
+ paddingInline: '24px',
20
+ }));
21
+ export const Error = styled(Box)(({ theme }) => ({
22
+ fontSize: '10px',
23
+ color: theme.palette.error.dark,
24
+ display: 'flex',
25
+ gap: '4px',
26
+ }));
@@ -0,0 +1 @@
1
+ export { default as TotalAmount } from './TotalAmount';
@@ -0,0 +1 @@
1
+ export { default as TotalAmount } from './TotalAmount';
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { BoxProps } from '@mui/material/Box';
3
+ import { Currency, Discount } from '../../../types/index.js';
4
+ interface DiscountDropdownProps extends BoxProps {
5
+ discount: Discount;
6
+ maxDiscount?: number;
7
+ selectedCurrency: Currency;
8
+ setDiscount: (value: Discount) => void;
9
+ setIsOpen: (value: boolean) => void;
10
+ }
11
+ declare function DiscountDropdown({ discount, maxDiscount, setDiscount, setIsOpen, selectedCurrency, ...props }: Readonly<DiscountDropdownProps>): import("react/jsx-runtime").JSX.Element;
12
+ declare const _default: import("react").MemoExoticComponent<typeof DiscountDropdown>;
13
+ export default _default;
@@ -0,0 +1,67 @@
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, useState } from 'react';
14
+ import { useTranslation } from 'react-i18next';
15
+ import Box from '@mui/material/Box';
16
+ import { DISCOUNT_TYPE } from '../../../types/index.js';
17
+ import { checkIcon, rightArrow } from '../../../constants/index.js';
18
+ import { AmountInput } from '../../index.js';
19
+ import { Wrapper, Option, Dropdown } from './style';
20
+ import DiscountRateDropdown from '../DiscountRateDropdown';
21
+ function DiscountDropdown(_a) {
22
+ var { discount, maxDiscount, setDiscount, setIsOpen, selectedCurrency } = _a, props = __rest(_a, ["discount", "maxDiscount", "setDiscount", "setIsOpen", "selectedCurrency"]);
23
+ const [isRatDropdownOpen, setIsRatDropdownOpen] = useState(false);
24
+ const [isFlatDropdownOpen, setIsFlatDropdownOpen] = useState(false);
25
+ const { t } = useTranslation();
26
+ const isNoDiscount = discount.type === DISCOUNT_TYPE.NO_DISCOUNT;
27
+ const isPercent = discount.type === DISCOUNT_TYPE.PERCENT;
28
+ const handleSelectDiscount = (newDiscount) => {
29
+ setDiscount(newDiscount);
30
+ };
31
+ const onClickNoneDiscount = (e) => {
32
+ e.stopPropagation();
33
+ setIsOpen(false);
34
+ handleSelectDiscount({
35
+ type: DISCOUNT_TYPE.NO_DISCOUNT,
36
+ value: 0,
37
+ percentage: 0,
38
+ flat: 0,
39
+ });
40
+ if (isRatDropdownOpen)
41
+ setIsRatDropdownOpen(false);
42
+ if (isFlatDropdownOpen)
43
+ setIsFlatDropdownOpen(false);
44
+ };
45
+ const openRatDropdown = (e) => {
46
+ e.stopPropagation();
47
+ setIsRatDropdownOpen(true);
48
+ if (isFlatDropdownOpen)
49
+ setIsFlatDropdownOpen(false);
50
+ };
51
+ const openFLatDropdown = (e) => {
52
+ e.stopPropagation();
53
+ setIsFlatDropdownOpen(true);
54
+ if (isRatDropdownOpen)
55
+ setIsRatDropdownOpen(false);
56
+ };
57
+ return (_jsxs(Wrapper, Object.assign({ sx: Object.assign(Object.assign({}, props.sx), (isFlatDropdownOpen && { borderBottomRightRadius: 0 })) }, { children: [_jsxs(Option, Object.assign({ className: "option", onClick: onClickNoneDiscount, sx: { justifyContent: 'flex-start' } }, { children: [isNoDiscount ? _jsx("img", { src: checkIcon, alt: "c" }) : _jsx(Box, { width: "12px" }), _jsx("span", { children: t('none') })] })), _jsxs(Option, Object.assign({ className: "option", onClick: openRatDropdown, sx: (theme) => (Object.assign({ justifyContent: 'space-between', position: 'relative' }, (isRatDropdownOpen && { boxShadow: theme.shadows[3] }))) }, { children: [_jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center', gap: '6px' } }, { children: [isPercent ? _jsx("img", { src: checkIcon, alt: "check" }) : _jsx(Box, { width: "12px" }), _jsx("span", { children: "%" })] })), _jsx("img", { src: rightArrow, alt: "r" }), _jsx(DiscountRateDropdown, { sx: {
58
+ position: 'absolute',
59
+ left: '100%',
60
+ top: 0,
61
+ display: isRatDropdownOpen ? 'block' : 'none',
62
+ borderTopLeftRadius: 0,
63
+ }, setIsOpen: setIsOpen, discount: discount, setDiscount: setDiscount })] })), _jsxs(Option, Object.assign({ className: "option", onClick: openFLatDropdown, sx: (theme) => (Object.assign({ justifyContent: 'space-between', position: 'relative' }, (isFlatDropdownOpen && { boxShadow: theme.shadows[3] }))) }, { children: [_jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center', gap: '6px' } }, { children: [discount.type === DISCOUNT_TYPE.FLAT ? _jsx("img", { src: checkIcon, alt: "c" }) : _jsx(Box, { width: "12px" }), _jsx("span", { children: t('flat') })] })), _jsx("img", { src: rightArrow, alt: "r" }), _jsx(Dropdown, Object.assign({ isOpen: isFlatDropdownOpen }, { children: _jsx(AmountInput, { selectedCurrency: selectedCurrency, sx: { height: 24, width: '100%', input: { height: 20, width: '100%', textAlign: 'right', flexGrow: 1 } }, amount: discount.type === DISCOUNT_TYPE.FLAT ? Number(discount.flat) : '', setAmount: (value) => {
64
+ handleSelectDiscount(Object.assign(Object.assign({}, discount), { type: DISCOUNT_TYPE.FLAT, flat: Number(value) }));
65
+ }, maxAmount: maxDiscount }) }))] }))] })));
66
+ }
67
+ export default memo(DiscountDropdown);
@@ -0,0 +1,2 @@
1
+ export { default } from './DiscountDropdown';
2
+ export * from './DiscountDropdown';
@@ -0,0 +1,2 @@
1
+ export { default } from './DiscountDropdown';
2
+ export * from './DiscountDropdown';
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
4
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
5
+ export declare const Option: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
6
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
7
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
8
+ export declare const Dropdown: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
9
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
10
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
11
+ isOpen: boolean;
12
+ }, {}, {}>;
@@ -0,0 +1,40 @@
1
+ import Box from '@mui/material/Box';
2
+ import { styled } from '@mui/material/styles';
3
+ export const Wrapper = styled(Box)(({ theme }) => ({
4
+ width: 106,
5
+ boxShadow: theme.shadows[16],
6
+ borderRadius: 4,
7
+ backgroundColor: theme.palette.common.white,
8
+ '.option + .option': {
9
+ borderTop: `1px solid ${theme.palette.divider}`,
10
+ },
11
+ zIndex: 3,
12
+ }));
13
+ export const Option = styled(Box)(({ theme }) => ({
14
+ fontSize: '11px',
15
+ padding: theme.spacing(1),
16
+ display: 'flex',
17
+ justifyContent: 'flex-end',
18
+ alignItems: 'center',
19
+ gap: theme.spacing(1),
20
+ cursor: 'pointer',
21
+ height: 40,
22
+ input: {
23
+ height: 24,
24
+ width: 47,
25
+ textAlign: 'right',
26
+ },
27
+ }));
28
+ export const Dropdown = styled(Box, { shouldForwardProp: (props) => props !== 'isOpen' })(({ isOpen, theme }) => ({
29
+ display: isOpen ? 'block' : 'none',
30
+ position: 'absolute',
31
+ left: '100%',
32
+ top: 0,
33
+ background: theme.palette.common.white,
34
+ padding: '8px',
35
+ borderTopRightRadius: '4px',
36
+ borderBottomRightRadius: '4px',
37
+ overflow: 'hidden',
38
+ minWidth: 112,
39
+ height: 39,
40
+ }));
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { BoxProps } from '@mui/material/Box';
3
+ import { Discount } from '../../../types/index.js';
4
+ interface DiscountRateDropdownProps extends BoxProps {
5
+ discount: Discount;
6
+ setDiscount: (value: Discount) => void;
7
+ setIsDropdownOpen?: (value: boolean) => void;
8
+ setIsOpen: (value: boolean) => void;
9
+ }
10
+ declare function DiscountRateDropdown({ discount, setDiscount, setIsDropdownOpen, setIsOpen, ...props }: Readonly<DiscountRateDropdownProps>): import("react/jsx-runtime").JSX.Element;
11
+ declare const _default: import("react").MemoExoticComponent<typeof DiscountRateDropdown>;
12
+ export default _default;
@@ -0,0 +1,53 @@
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 { DISCOUNT_TYPE } from '../../../types/index.js';
15
+ import { Input } from '../../index.js';
16
+ import { checkIcon, RATES } from '../../../constants/index.js';
17
+ import { removeAllCharsFromNumber } from '../../../utils/index.js';
18
+ import { Wrapper, Option } from './style';
19
+ function DiscountRateDropdown(_a) {
20
+ var { discount, setDiscount, setIsDropdownOpen, setIsOpen } = _a, props = __rest(_a, ["discount", "setDiscount", "setIsDropdownOpen", "setIsOpen"]);
21
+ const { percentage, value } = discount;
22
+ const isFivePercent = percentage === RATES.FIVE;
23
+ const isTenPercent = percentage === RATES.TEN;
24
+ const isFifteenPercent = percentage === RATES.FIFTEEN;
25
+ const isCustomPercent = percentage !== RATES.FIVE && percentage !== RATES.TEN && percentage !== RATES.FIFTEEN && percentage !== RATES.ZERO && value !== RATES.ZERO;
26
+ const discountRATES = [
27
+ { label: '5%', value: RATES.FIVE, selected: isFivePercent },
28
+ { label: '10%', value: RATES.TEN, selected: isTenPercent },
29
+ { label: '15%', value: RATES.FIFTEEN, selected: isFifteenPercent },
30
+ ];
31
+ const selectRate = (percentageValue) => {
32
+ setDiscount({ value, percentage: percentageValue, type: DISCOUNT_TYPE.PERCENT });
33
+ setIsOpen(false);
34
+ };
35
+ const handleCustomRate = (e) => {
36
+ if (Number(e.target.value || !Number(e.target.value)) > 100)
37
+ return false;
38
+ setDiscount({
39
+ value: Number(e.target.value),
40
+ percentage: Number(removeAllCharsFromNumber(e.target.value)),
41
+ type: DISCOUNT_TYPE.PERCENT,
42
+ });
43
+ };
44
+ const renderSelectedIcon = (selected) => {
45
+ return selected ? _jsx("img", { src: checkIcon, alt: "c" }) : _jsx("span", {});
46
+ };
47
+ return (_jsxs(Wrapper, Object.assign({ sx: props.sx }, { children: [discountRATES.map((discountI) => (_jsxs(Option, Object.assign({ className: "option", onClick: () => {
48
+ selectRate(discountI.value);
49
+ if (setIsDropdownOpen)
50
+ setIsDropdownOpen(false);
51
+ } }, { children: [renderSelectedIcon(discountI.selected), _jsx("span", { children: discountI.label })] }), discountI.value))), _jsxs(Option, Object.assign({ className: "option" }, { children: [renderSelectedIcon(isCustomPercent), _jsx(Input, { placeholder: "%", sx: { input: { width: '100% !important' } }, value: isCustomPercent ? percentage : '', onChange: handleCustomRate })] }))] })));
52
+ }
53
+ export default memo(DiscountRateDropdown);
@@ -0,0 +1,2 @@
1
+ export { default } from './DiscountRateDropdown';
2
+ export * from './DiscountRateDropdown';
@@ -0,0 +1,2 @@
1
+ export { default } from './DiscountRateDropdown';
2
+ export * from './DiscountRateDropdown';
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
4
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
5
+ export declare const Option: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
6
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
7
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
@@ -0,0 +1,33 @@
1
+ import Box from '@mui/material/Box';
2
+ import { styled } from '@mui/material/styles';
3
+ export const Wrapper = styled(Box)(({ theme }) => ({
4
+ width: 112,
5
+ boxShadow: theme.shadows[16],
6
+ borderRadius: 4,
7
+ backgroundColor: theme.palette.common.white,
8
+ '.option + .option': {
9
+ borderTop: `1px solid ${theme.palette.divider}`,
10
+ },
11
+ zIndex: 3,
12
+ }));
13
+ export const Option = styled(Box)(({ theme }) => ({
14
+ fontSize: '11px',
15
+ paddingInlineStart: theme.spacing(2),
16
+ paddingInlineEnd: theme.spacing(1),
17
+ paddingTop: theme.spacing(1.5),
18
+ paddingBottom: theme.spacing(1.5),
19
+ display: 'flex',
20
+ justifyContent: 'space-between',
21
+ alignItems: 'center',
22
+ gap: theme.spacing(1),
23
+ cursor: 'pointer',
24
+ height: 40,
25
+ input: {
26
+ height: 24,
27
+ width: 47,
28
+ textAlign: 'right',
29
+ },
30
+ '&:hover': {
31
+ boxShadow: theme.shadows[3],
32
+ },
33
+ }));
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { Currency, Discount } from '../../../types/index.js';
3
+ interface TotalDiscountProps {
4
+ selectedCurrency: Currency;
5
+ totalGrossAmount: number;
6
+ totalDiscount: Discount;
7
+ isDisabled: boolean;
8
+ onChangeTotalDiscount: (newDiscount: Discount) => void;
9
+ }
10
+ declare function TotalDiscount({ selectedCurrency, totalGrossAmount, totalDiscount, onChangeTotalDiscount, isDisabled }: Readonly<TotalDiscountProps>): import("react/jsx-runtime").JSX.Element;
11
+ declare const _default: import("react").MemoExoticComponent<typeof TotalDiscount>;
12
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useRef, useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import Box from '@mui/material/Box';
5
+ import Popper from '@mui/material/Popper';
6
+ import { CustomBackdrop, DisplayAmount } from '../../index.js';
7
+ import { actionsIcon, activeActionIcon, discountIcon } from '../../../constants/index.js';
8
+ import { LabelWrapper, Label } from './style';
9
+ import DiscountDropdown from '../DiscountDropdown';
10
+ import { getDiscountValue } from '../utils';
11
+ function TotalDiscount({ selectedCurrency, totalGrossAmount, totalDiscount, onChangeTotalDiscount, isDisabled }) {
12
+ const [isOpen, setIsOpen] = useState(false);
13
+ const discountButtonRef = useRef();
14
+ const { t } = useTranslation();
15
+ const toggleDropdown = () => {
16
+ if (!isDisabled)
17
+ setIsOpen(!isOpen);
18
+ };
19
+ const handleDiscount = (newDiscount) => {
20
+ onChangeTotalDiscount(Object.assign(Object.assign({}, newDiscount), { value: getDiscountValue(totalGrossAmount, newDiscount) }));
21
+ };
22
+ const getLabel = () => {
23
+ if (totalDiscount.value === 0)
24
+ 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
+ };
27
+ 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
+ export default memo(TotalDiscount);
@@ -0,0 +1 @@
1
+ export { default } from './TotalDiscount';
@@ -0,0 +1 @@
1
+ export { default } from './TotalDiscount';
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ export declare const LabelWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
4
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
5
+ isDisabled?: boolean | undefined;
6
+ isOpen?: boolean | undefined;
7
+ }, {}, {}>;
8
+ export declare const Label: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
9
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
10
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
11
+ isDisabled: boolean;
12
+ }, {}, {}>;
@@ -0,0 +1,5 @@
1
+ import { Box, styled } from '@mui/material';
2
+ export const LabelWrapper = styled(Box, {
3
+ shouldForwardProp: (props) => props !== 'isDisabled' && props !== 'isOpen',
4
+ })(({ theme, isOpen, isDisabled }) => (Object.assign(Object.assign({ display: 'flex', gap: theme.spacing(1), alignItems: 'center', justifyContent: 'space-between', fontSize: '11px', border: `1px solid ${theme.palette.divider}`, height: 32, padding: theme.spacing(1), borderRadius: '4px' }, (isOpen && { borderColor: theme.palette.info.dark, position: 'relative' })), (isDisabled ? { color: theme.palette.grey[700], cursor: 'not-allowed' } : { cursor: 'pointer' }))));
5
+ export const Label = styled(Box, { shouldForwardProp: (props) => props !== 'isDisabled' })(({ theme, isDisabled }) => (Object.assign({ fontSize: '11px', fontWeight: 600, color: theme.palette.text.primary }, (isDisabled && { color: theme.palette.grey[700] }))));
@@ -0,0 +1,4 @@
1
+ export * from './utils';
2
+ export { default as DiscountDropdown } from './DiscountDropdown';
3
+ export { default as DiscountRateDropdown } from './DiscountRateDropdown';
4
+ export { default as TotalDiscount } from './TotalDiscount';
@@ -0,0 +1,4 @@
1
+ export * from './utils';
2
+ export { default as DiscountDropdown } from './DiscountDropdown';
3
+ export { default as DiscountRateDropdown } from './DiscountRateDropdown';
4
+ export { default as TotalDiscount } from './TotalDiscount';
@@ -0,0 +1,8 @@
1
+ import { Discount, DISCOUNT_TYPE } from '../../types/index.js';
2
+ export declare const getDiscountValue: (amount: number, totalDiscount: Discount) => number;
3
+ export declare const getItemDiscount: (discount: Discount, itemPrice: number, quantity: number) => {
4
+ value: number;
5
+ type: DISCOUNT_TYPE;
6
+ percentage?: number | undefined;
7
+ flat?: number | undefined;
8
+ };
@@ -0,0 +1,12 @@
1
+ import { DISCOUNT_TYPE } from '../../types/index.js';
2
+ export const getDiscountValue = (amount, totalDiscount) => {
3
+ let newDiscountValue = 0;
4
+ if (totalDiscount.type === DISCOUNT_TYPE.FLAT && !!totalDiscount.flat && totalDiscount.flat > 0) {
5
+ newDiscountValue = totalDiscount.flat;
6
+ }
7
+ if (totalDiscount.type === DISCOUNT_TYPE.PERCENT && !!totalDiscount.percentage && totalDiscount.percentage > 0) {
8
+ newDiscountValue = amount * (totalDiscount.percentage / 100);
9
+ }
10
+ return newDiscountValue;
11
+ };
12
+ export const getItemDiscount = (discount, itemPrice, quantity) => (Object.assign(Object.assign({}, discount), { value: getDiscountValue(itemPrice, discount) * quantity }));
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ interface FilterDropdownProps {
3
+ children?: React.ReactNode;
4
+ onConfirm: () => void;
5
+ onCancel: () => void;
6
+ isOkayButDisabled?: boolean;
7
+ isDisabled?: boolean;
8
+ }
9
+ export default function FilterDropdown({ onConfirm, onCancel, isOkayButDisabled, children, isDisabled }: Readonly<FilterDropdownProps>): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Box from '@mui/material/Box';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { useState, useEffect } from 'react';
5
+ import { ClickAwayListener } from '@mui/material';
6
+ import { darkFilterIcon } from '../../constants/index.js';
7
+ import { Menu, CustomBackdrop } from '../index.js';
8
+ import { CancelButton, FilterButton, Footer, OkayButton, TitleStyled } from './style';
9
+ export default function FilterDropdown({ onConfirm, onCancel, isOkayButDisabled, children, isDisabled }) {
10
+ const [anchorEl, setAnchorEl] = useState(null);
11
+ const open = Boolean(anchorEl);
12
+ const { t } = useTranslation();
13
+ // Lock body scroll when filter dropdown is open (Safari fix)
14
+ useEffect(() => {
15
+ if (open) {
16
+ const scrollY = window.scrollY;
17
+ document.body.style.position = 'fixed';
18
+ document.body.style.top = `-${scrollY}px`;
19
+ document.body.style.width = '100%';
20
+ document.body.style.overflow = 'hidden';
21
+ return () => {
22
+ document.body.style.position = '';
23
+ document.body.style.top = '';
24
+ document.body.style.width = '';
25
+ document.body.style.overflow = '';
26
+ window.scrollTo(0, scrollY);
27
+ };
28
+ }
29
+ }, [open]);
30
+ const onOpen = (e) => {
31
+ if (isDisabled)
32
+ return;
33
+ if (!open) {
34
+ setAnchorEl(e.currentTarget);
35
+ return;
36
+ }
37
+ onClose();
38
+ };
39
+ const onClose = () => {
40
+ setAnchorEl(null);
41
+ onCancel();
42
+ };
43
+ const handleCancel = () => {
44
+ if (!open)
45
+ return;
46
+ onCancel();
47
+ onClose();
48
+ };
49
+ const handleConfirm = () => {
50
+ onConfirm();
51
+ onClose();
52
+ };
53
+ return (_jsx(ClickAwayListener, Object.assign({ onClickAway: handleCancel }, { children: _jsxs(Box, { children: [_jsx(FilterButton, Object.assign({ isActive: open, onClick: onOpen, sx: Object.assign({}, (isDisabled && { pointerEvents: 'none', opacity: 0.5 })) }, { children: _jsx(Box, { component: "img", src: darkFilterIcon, alt: "filter" }) })), _jsxs(Menu, Object.assign({ anchorEl: anchorEl, open: open, sx: { marginTop: '8px', marginBottom: '8px', width: 193 }, placement: "bottom-end" }, { children: [_jsx(TitleStyled, Object.assign({ component: "span" }, { children: t('filterBy') })), children, _jsxs(Footer, { children: [_jsx(CancelButton, Object.assign({ onClick: handleCancel }, { children: t('cancel') })), _jsx(OkayButton, Object.assign({ disabled: isOkayButDisabled, onClick: handleConfirm }, { children: t('okay') }))] })] })), open && _jsx(CustomBackdrop, { onClick: onClose })] }) })));
54
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { MerchantItemProps } from '../MerchantItem';
3
+ import { BrandProps } from '../../type';
4
+ interface BrandItemProps extends Pick<MerchantItemProps, 'atLeastOneMerchantSelected' | 'merchantsIds'> {
5
+ brand: BrandProps;
6
+ isDisabled?: boolean;
7
+ showSearchInput?: boolean;
8
+ renderBrandLogo: (logo: string) => React.ReactNode;
9
+ onChangeMerchant?: (value: string[]) => void;
10
+ }
11
+ export default function BrandItem({ brand, merchantsIds, isDisabled, atLeastOneMerchantSelected, showSearchInput, renderBrandLogo, onChangeMerchant, }: Readonly<BrandItemProps>): import("react/jsx-runtime").JSX.Element;
12
+ export {};