@tap-payments/os-micro-frontend-shared 0.1.262 → 0.1.263
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/MerchantCurrencyDropdown/MerchantCurrencyDropdown.d.ts +12 -0
- package/build/components/MerchantCurrencyDropdown/MerchantCurrencyDropdown.js +38 -0
- package/build/components/MerchantCurrencyDropdown/SelectedCurrency.d.ts +5 -0
- package/build/components/MerchantCurrencyDropdown/SelectedCurrency.js +6 -0
- package/build/components/MerchantCurrencyDropdown/index.d.ts +1 -0
- package/build/components/MerchantCurrencyDropdown/index.js +1 -0
- package/build/components/MerchantCurrencyDropdown/style.d.ts +13 -0
- package/build/components/MerchantCurrencyDropdown/style.js +64 -0
- package/build/components/index.d.ts +1 -0
- package/build/components/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Currency } from '../../types/index.js';
|
|
3
|
+
interface MerchantCurrencyDropdownProps {
|
|
4
|
+
merchantCurrencies: Currency[];
|
|
5
|
+
selectedCurrency?: Currency;
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
onChangeCurrency?: (currency: Currency) => void;
|
|
9
|
+
}
|
|
10
|
+
declare function MerchantCurrencyDropdown({ merchantCurrencies, isLoading, onChangeCurrency, isDisabled, selectedCurrency, }: Readonly<MerchantCurrencyDropdownProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare const _default: import("react").MemoExoticComponent<typeof MerchantCurrencyDropdown>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useState } from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Popper from '@mui/material/Popper';
|
|
5
|
+
import { downArrowIcon3 } from '../../constants/index.js';
|
|
6
|
+
import { Text, Loader, CustomBackdrop } from '../index.js';
|
|
7
|
+
import { CurrencyDropdownContainer, BrandsDropdown, CurrencyBox } from './style';
|
|
8
|
+
import CurrencyItem from './SelectedCurrency';
|
|
9
|
+
function MerchantCurrencyDropdown({ merchantCurrencies, isLoading, onChangeCurrency, isDisabled, selectedCurrency, }) {
|
|
10
|
+
var _a, _b, _c, _d, _e;
|
|
11
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
12
|
+
const open = Boolean(anchorEl);
|
|
13
|
+
const onOpenDropdown = (event) => {
|
|
14
|
+
if (!open)
|
|
15
|
+
setAnchorEl(event.currentTarget);
|
|
16
|
+
};
|
|
17
|
+
const onCloseDropdown = () => {
|
|
18
|
+
if (open)
|
|
19
|
+
setAnchorEl(null);
|
|
20
|
+
};
|
|
21
|
+
const selectCurrency = (currency) => {
|
|
22
|
+
onChangeCurrency === null || onChangeCurrency === void 0 ? void 0 : onChangeCurrency(currency);
|
|
23
|
+
onCloseDropdown();
|
|
24
|
+
};
|
|
25
|
+
if (isLoading || !merchantCurrencies) {
|
|
26
|
+
return (_jsxs(CurrencyDropdownContainer, Object.assign({ sx: { pointerEvents: 'none' } }, { children: [_jsx(Text, Object.assign({ sx: { fontSize: '11px' } }, { children: "Select" })), isLoading ? _jsx(Loader, {}) : _jsx(Box, { component: "img", src: downArrowIcon3, alt: "c", sx: { marginTop: '2px' } })] })));
|
|
27
|
+
}
|
|
28
|
+
if (merchantCurrencies.length === 0) {
|
|
29
|
+
return (_jsxs(CurrencyDropdownContainer, Object.assign({ sx: { pointerEvents: 'none', opacity: 0.5 } }, { children: [_jsx(Text, Object.assign({ sx: { fontSize: '11px' } }, { children: "Select" })), _jsx(Box, Object.assign({ sx: { width: 25, textAlign: 'center' } }, { children: _jsx(Box, { component: "img", src: downArrowIcon3, alt: "c", sx: { marginTop: '2px' } }) }))] })));
|
|
30
|
+
}
|
|
31
|
+
if (merchantCurrencies.length === 1) {
|
|
32
|
+
return (_jsx(CurrencyDropdownContainer, Object.assign({ sx: { border: 'none', pointerEvents: 'none' } }, { children: _jsx(CurrencyItem, { selectedCurrencyCode: (_c = (_b = (_a = merchantCurrencies === null || merchantCurrencies === void 0 ? void 0 : merchantCurrencies[0]) === null || _a === void 0 ? void 0 : _a.code) === null || _b === void 0 ? void 0 : _b.english) !== null && _c !== void 0 ? _c : '' }) })));
|
|
33
|
+
}
|
|
34
|
+
return (_jsxs(CurrencyDropdownContainer, Object.assign({ onClick: onOpenDropdown, sx: Object.assign({}, (isDisabled && { pointerEvents: 'none', opacity: 0.7 })) }, { children: [_jsx(CurrencyItem, { selectedCurrencyCode: (_e = (_d = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _d === void 0 ? void 0 : _d.english) !== null && _e !== void 0 ? _e : '' }), _jsx(Box, { component: "img", src: downArrowIcon3, alt: "c", sx: Object.assign({ marginTop: '2px' }, (open && { transform: 'rotate(180deg)' })) }), open && _jsx(CustomBackdrop, { onClick: onCloseDropdown }), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-start" }, { children: _jsx(BrandsDropdown, { children: merchantCurrencies.map((currency, index) => (_jsx(CurrencyBox, Object.assign({ className: "currency", onClick: () => {
|
|
35
|
+
selectCurrency(currency);
|
|
36
|
+
} }, { children: _jsx(CurrencyItem, { selectedCurrencyCode: currency.code.english }) }), `${currency.symbol}-${index}`))) }) }))] })));
|
|
37
|
+
}
|
|
38
|
+
export default memo(MerchantCurrencyDropdown);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CountryFlag } from '../index.js';
|
|
3
|
+
import { Label } from './style';
|
|
4
|
+
export default function SelectedCurrency({ selectedCurrencyCode }) {
|
|
5
|
+
return (_jsxs(Label, Object.assign({ sx: { padding: 0 } }, { children: [_jsx(CountryFlag, { currencyCode: selectedCurrencyCode }), _jsxs("span", { children: [" ", selectedCurrencyCode] })] })));
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MerchantCurrencyDropdown } from './MerchantCurrencyDropdown';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MerchantCurrencyDropdown } from './MerchantCurrencyDropdown';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const CurrencyDropdownContainer: 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 BrandsDropdown: 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 CurrencyBox: 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
|
+
export declare const Label: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
12
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
13
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Box from '@mui/material/Box';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
export const CurrencyDropdownContainer = styled(Box)(({ theme }) => ({
|
|
4
|
+
display: 'flex',
|
|
5
|
+
alignItems: 'center',
|
|
6
|
+
justifyContent: 'center',
|
|
7
|
+
gap: '4px',
|
|
8
|
+
cursor: 'pointer',
|
|
9
|
+
padding: '8px',
|
|
10
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
11
|
+
background: theme.palette.common.white,
|
|
12
|
+
borderRadius: '4px',
|
|
13
|
+
fontSize: '14px',
|
|
14
|
+
fontWeight: 500,
|
|
15
|
+
'.logo': { width: 17 },
|
|
16
|
+
color: theme.palette.text.primary,
|
|
17
|
+
height: 32,
|
|
18
|
+
}));
|
|
19
|
+
export const BrandsDropdown = styled(Box)(({ theme }) => ({
|
|
20
|
+
width: 109,
|
|
21
|
+
boxShadow: theme.shadows[9],
|
|
22
|
+
backgroundColor: theme.palette.common.white,
|
|
23
|
+
borderRadius: '4px',
|
|
24
|
+
fontSize: '14px',
|
|
25
|
+
fontWeight: 500,
|
|
26
|
+
color: theme.palette.text.primary,
|
|
27
|
+
maxHeight: 210,
|
|
28
|
+
overflow: 'auto',
|
|
29
|
+
marginTop: '8px',
|
|
30
|
+
'.currecy+.currency': {
|
|
31
|
+
marginTop: '4px',
|
|
32
|
+
},
|
|
33
|
+
}));
|
|
34
|
+
export const CurrencyBox = styled(Box)(({ theme }) => ({
|
|
35
|
+
display: 'flex',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
paddingInlineStart: theme.spacing(1),
|
|
38
|
+
paddingInlineEnd: theme.spacing(2),
|
|
39
|
+
paddingTop: theme.spacing(1),
|
|
40
|
+
paddingBottom: theme.spacing(1),
|
|
41
|
+
gap: '4px',
|
|
42
|
+
cursor: 'pointer',
|
|
43
|
+
height: 42,
|
|
44
|
+
'.logo': {
|
|
45
|
+
width: 20,
|
|
46
|
+
borderRadius: '2px',
|
|
47
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
48
|
+
},
|
|
49
|
+
'&:hover': {
|
|
50
|
+
boxShadow: theme.shadows[4],
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
53
|
+
export const Label = styled(Box)(({ theme }) => ({
|
|
54
|
+
fontSize: '14px',
|
|
55
|
+
fontWeight: 500,
|
|
56
|
+
color: theme.palette.text.primary,
|
|
57
|
+
textTransform: 'uppercase',
|
|
58
|
+
display: 'flex',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'center',
|
|
61
|
+
gap: '4px',
|
|
62
|
+
padding: '8px',
|
|
63
|
+
img: { width: 17, borderRadius: '4px' },
|
|
64
|
+
}));
|
package/package.json
CHANGED