@tap-payments/os-micro-frontend-shared 0.1.253 → 0.1.254-test.2
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/Chip/style.d.ts +0 -1
- package/build/components/CountBadge/style.d.ts +0 -1
- package/build/components/Dialog/style.d.ts +0 -1
- package/build/components/FileInputPreview/FileInputPreview.d.ts +5 -0
- package/build/components/FileInputPreview/FileInputPreview.js +51 -0
- package/build/components/FileInputPreview/index.d.ts +1 -0
- package/build/components/FileInputPreview/index.js +1 -0
- package/build/components/FileInputPreview/style.d.ts +9 -0
- package/build/components/FileInputPreview/style.js +20 -0
- package/build/components/FileInputPreview/type.d.ts +21 -0
- package/build/components/FileInputPreview/type.js +1 -0
- package/build/components/FileInputPreview/utils.d.ts +3 -0
- package/build/components/FileInputPreview/utils.js +14 -0
- package/build/components/FilePreview/FilePreview.d.ts +3 -0
- package/build/components/FilePreview/FilePreview.js +18 -0
- package/build/components/FilePreview/index.d.ts +3 -0
- package/build/components/FilePreview/index.js +3 -0
- package/build/components/FilePreview/style.d.ts +20 -0
- package/build/components/FilePreview/style.js +55 -0
- package/build/components/FilePreview/type.d.ts +12 -0
- package/build/components/FilePreview/type.js +1 -0
- package/build/components/FilterDropdown/FilterDropdown.d.ts +10 -0
- package/build/components/FilterDropdown/FilterDropdown.js +54 -0
- package/build/components/FilterDropdown/components/BrandItem/BrandItem.d.ts +12 -0
- package/build/components/FilterDropdown/components/BrandItem/BrandItem.js +39 -0
- package/build/components/FilterDropdown/components/BrandItem/index.d.ts +2 -0
- package/build/components/FilterDropdown/components/BrandItem/index.js +2 -0
- package/build/components/FilterDropdown/components/BrandItem/style.d.ts +4 -0
- package/build/components/FilterDropdown/components/BrandItem/style.js +9 -0
- package/build/components/FilterDropdown/components/CountriesItem/CountriesItem.d.ts +12 -0
- package/build/components/FilterDropdown/components/CountriesItem/CountriesItem.js +54 -0
- package/build/components/FilterDropdown/components/CountriesItem/index.d.ts +1 -0
- package/build/components/FilterDropdown/components/CountriesItem/index.js +1 -0
- package/build/components/FilterDropdown/components/CurrenciesItem/CurrenciesItem.d.ts +12 -0
- package/build/components/FilterDropdown/components/CurrenciesItem/CurrenciesItem.js +59 -0
- package/build/components/FilterDropdown/components/CurrenciesItem/index.d.ts +1 -0
- package/build/components/FilterDropdown/components/CurrenciesItem/index.js +1 -0
- package/build/components/FilterDropdown/components/FlatMerchantsListMenu/FlatMerchantsListMenu.d.ts +11 -0
- package/build/components/FilterDropdown/components/FlatMerchantsListMenu/FlatMerchantsListMenu.js +39 -0
- package/build/components/FilterDropdown/components/FlatMerchantsListMenu/index.d.ts +2 -0
- package/build/components/FilterDropdown/components/FlatMerchantsListMenu/index.js +2 -0
- package/build/components/FilterDropdown/components/FlatMerchantsListMenu/style.d.ts +12 -0
- package/build/components/FilterDropdown/components/FlatMerchantsListMenu/style.js +23 -0
- package/build/components/FilterDropdown/components/MerchantItem/MerchantItem.d.ts +13 -0
- package/build/components/FilterDropdown/components/MerchantItem/MerchantItem.js +43 -0
- package/build/components/FilterDropdown/components/MerchantItem/index.d.ts +2 -0
- package/build/components/FilterDropdown/components/MerchantItem/index.js +2 -0
- package/build/components/FilterDropdown/components/RetailersItem/RetailersItem.d.ts +14 -0
- package/build/components/FilterDropdown/components/RetailersItem/RetailersItem.js +70 -0
- package/build/components/FilterDropdown/components/RetailersItem/index.d.ts +1 -0
- package/build/components/FilterDropdown/components/RetailersItem/index.js +1 -0
- package/build/components/FilterDropdown/components/RetailersItem/style.d.ts +4 -0
- package/build/components/FilterDropdown/components/RetailersItem/style.js +8 -0
- package/build/components/FilterDropdown/components/index.d.ts +4 -0
- package/build/components/FilterDropdown/components/index.js +4 -0
- package/build/components/FilterDropdown/index.d.ts +3 -0
- package/build/components/FilterDropdown/index.js +3 -0
- package/build/components/FilterDropdown/style.d.ts +20 -0
- package/build/components/FilterDropdown/style.js +60 -0
- package/build/components/FilterDropdown/type.d.ts +4 -0
- package/build/components/FilterDropdown/type.js +1 -0
- package/build/components/FlippingCard/style.d.ts +0 -1
- package/build/components/ImageWrapper/ImageWrapper.d.ts +0 -1
- package/build/components/JSONViewer/style.d.ts +0 -1
- package/build/components/LeftPeekRightExpandingChip/style.d.ts +0 -1
- package/build/components/MenuItem/MenuItem.d.ts +1 -1
- package/build/components/OpenFileInNewTab/OpenFileInNewTab.d.ts +7 -0
- package/build/components/OpenFileInNewTab/OpenFileInNewTab.js +26 -0
- package/build/components/OpenFileInNewTab/index.d.ts +1 -0
- package/build/components/OpenFileInNewTab/index.js +1 -0
- package/build/components/OpenFileInNewTab/style.d.ts +2 -0
- package/build/components/OpenFileInNewTab/style.js +8 -0
- package/build/components/RightLeftExpandingCenterChip/style.d.ts +0 -1
- package/build/components/SearchButton/styles.d.ts +0 -1
- package/build/components/StatusIcons/AuthIcons/style.d.ts +0 -1
- package/build/components/StatusIcons/AuthorizationAutoIcons/style.d.ts +0 -1
- package/build/components/StatusIcons/ChargeStatusIcon/style.d.ts +0 -1
- package/build/components/StatusIcons/SourceIcons/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ActionCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ApplicationStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AuthenticationCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AuthenticationStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/AuthenticationTypeCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/BalanceCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ChannelsCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/CheckoutStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/DestinationStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/DueDateCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/IDButton/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/IntentsStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/InvoiceStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/PayoutStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ProductsCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/ReferenceCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/RefundChargeCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/RefundStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/SalesChannelCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/SegmentsCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/SourceCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/StatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/TokenStatusCell/style.d.ts +0 -1
- package/build/components/TableCells/CustomCells/style.d.ts +0 -1
- package/build/components/VirtualTables/components/style.d.ts +0 -1
- package/build/components/index.d.ts +4 -0
- package/build/components/index.js +4 -0
- package/build/types/destination.d.ts +14 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.js +1 -0
- package/package.json +3 -3
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
import { GetSourceAnimationFunction } from './type';
|
|
4
3
|
export declare const ChipStyled: import("@emotion/styled").StyledComponent<import("react").RefAttributes<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
5
4
|
variant?: import("./type").ChipVariant | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FileInputPreviewProps } from './type';
|
|
3
|
+
declare function FileInputPreview({ options, error, files, label, disabled, hideUpload, preventDuplicates, onChangeFiles, onRemoveFile, renderBrandLogo, renderOpenFileInNewTab, }: Readonly<FileInputPreviewProps>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const _default: import("react").MemoExoticComponent<typeof FileInputPreview>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo, useState } from 'react';
|
|
3
|
+
import { useDropzone } from 'react-dropzone';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { pdfIcon } from '../../constants/index.js';
|
|
6
|
+
import { readableFileSize } from '../../utils/index.js';
|
|
7
|
+
import { FilePreview, FileUploader } from '../index.js';
|
|
8
|
+
import { Wrapper, Title } from './style';
|
|
9
|
+
import { isDuplicateFile } from './utils';
|
|
10
|
+
function FileInputPreview({ options, error, files, label, disabled, hideUpload = false, preventDuplicates, onChangeFiles, onRemoveFile, renderBrandLogo, renderOpenFileInNewTab, }) {
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const [duplicateError, setDuplicateError] = useState(null);
|
|
13
|
+
const { getRootProps, getInputProps, open, isDragReject, fileRejections } = useDropzone(options);
|
|
14
|
+
const maxFileSize = readableFileSize((options === null || options === void 0 ? void 0 : options.maxSize) || 0, 0).toUpperCase();
|
|
15
|
+
const errorMessage = useMemo(() => {
|
|
16
|
+
const rejectedTypeFiles = fileRejections.length && fileRejections[0].errors.some((file) => file.code === 'file-invalid-type');
|
|
17
|
+
const rejectedFileSize = fileRejections.length && fileRejections[0].errors.some((file) => file.code === 'file-too-large');
|
|
18
|
+
if (isDragReject || rejectedTypeFiles)
|
|
19
|
+
return t('invalidFileType');
|
|
20
|
+
if (rejectedFileSize)
|
|
21
|
+
return `File is larger than ${maxFileSize}`;
|
|
22
|
+
if (duplicateError)
|
|
23
|
+
return duplicateError;
|
|
24
|
+
return error;
|
|
25
|
+
}, [isDragReject, error, fileRejections, duplicateError, t, maxFileSize]);
|
|
26
|
+
const getFilePreview = (file) => {
|
|
27
|
+
return file.type.includes('image') ? URL.createObjectURL(file) : file.name.includes('.pdf') ? pdfIcon : file.name;
|
|
28
|
+
};
|
|
29
|
+
const processFiles = (newFilesList) => {
|
|
30
|
+
setDuplicateError(null);
|
|
31
|
+
if (!preventDuplicates) {
|
|
32
|
+
return newFilesList.map((file) => ({ file, id: file.name }));
|
|
33
|
+
}
|
|
34
|
+
const { duplicates, uniqueFiles } = newFilesList.reduce((acc, file) => {
|
|
35
|
+
if (isDuplicateFile(file, files)) {
|
|
36
|
+
acc.duplicates.push(file.name);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
acc.uniqueFiles.push({ file, id: file.name });
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, { duplicates: [], uniqueFiles: [] });
|
|
43
|
+
if (duplicates.length > 0) {
|
|
44
|
+
const fileText = duplicates.length === 1 ? 'file' : 'files';
|
|
45
|
+
setDuplicateError(`Duplicate ${fileText} detected: ${duplicates.join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
return uniqueFiles;
|
|
48
|
+
};
|
|
49
|
+
return (_jsxs(Wrapper, { children: [_jsx(Title, { children: label }), _jsx(FilePreview, { files: files, onRemoveFile: onRemoveFile, disabled: disabled, getFilePreview: getFilePreview, renderBrandLogo: renderBrandLogo, renderOpenFileInNewTab: renderOpenFileInNewTab }), !disabled && !hideUpload && (_jsx(FileUploader, { getRootProps: getRootProps, getInputProps: getInputProps, open: open, onChangeFiles: onChangeFiles, processFiles: processFiles, disabled: disabled, errorMessage: errorMessage, maxFileSize: maxFileSize, preventDuplicates: preventDuplicates }))] }));
|
|
50
|
+
}
|
|
51
|
+
export default memo(FileInputPreview);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FileInputPreview } from './FileInputPreview';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FileInputPreview } from './FileInputPreview';
|
|
@@ -0,0 +1,9 @@
|
|
|
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 Title: import("@emotion/styled").StyledComponent<import("@mui/material").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
6
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
7
|
+
}, "width" | "minHeight" | "height" | "bottom" | "left" | "right" | "top" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "boxSizing" | "color" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "justifyContent" | "justifyItems" | "justifySelf" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "visibility" | "whiteSpace" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint" | "classes" | "align" | "className" | "style" | "children" | "gutterBottom" | "noWrap" | "paragraph" | "sx" | "variant" | "variantMapping"> & {
|
|
8
|
+
component?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
9
|
+
} & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Box from '@mui/material/Box';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import { Text } from '../index.js';
|
|
4
|
+
export const Wrapper = styled(Box)(({ theme }) => ({
|
|
5
|
+
display: 'flex',
|
|
6
|
+
flexDirection: 'column',
|
|
7
|
+
justifyContent: 'center',
|
|
8
|
+
gap: '8px',
|
|
9
|
+
padding: '8px',
|
|
10
|
+
borderRadius: '4px',
|
|
11
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
12
|
+
background: theme.palette.common.white,
|
|
13
|
+
}));
|
|
14
|
+
export const Title = styled(Text)(({ theme }) => ({
|
|
15
|
+
color: theme.palette.grey[700],
|
|
16
|
+
fontSize: '10px',
|
|
17
|
+
fontWeight: 500,
|
|
18
|
+
marginBottom: '8px',
|
|
19
|
+
margin: 0,
|
|
20
|
+
}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DropzoneProps } from 'react-dropzone';
|
|
3
|
+
import { FileType } from '../../types/index.js';
|
|
4
|
+
import { SxProps } from '@mui/material/styles';
|
|
5
|
+
export interface FileInputPreviewProps {
|
|
6
|
+
accept?: string;
|
|
7
|
+
options?: DropzoneProps;
|
|
8
|
+
error?: string;
|
|
9
|
+
files: FileType[];
|
|
10
|
+
label?: string | null;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
hideUpload?: boolean;
|
|
13
|
+
preventDuplicates?: boolean;
|
|
14
|
+
sx?: SxProps;
|
|
15
|
+
hideTitle?: boolean;
|
|
16
|
+
hidePreview?: boolean;
|
|
17
|
+
onChangeFiles: (files: FileType[]) => void;
|
|
18
|
+
onRemoveFile?: (file: FileType) => void;
|
|
19
|
+
renderBrandLogo: (fileId: string) => React.ReactNode;
|
|
20
|
+
renderOpenFileInNewTab: (fileId: string) => React.ReactNode;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isFile } from '../../utils/index.js';
|
|
2
|
+
export const areFilesEqual = (file1, file2) => {
|
|
3
|
+
return file1.name === file2.name && file1.size === file2.size;
|
|
4
|
+
};
|
|
5
|
+
export const isDuplicateFile = (newFile, existingFiles) => {
|
|
6
|
+
if (!(existingFiles === null || existingFiles === void 0 ? void 0 : existingFiles.length))
|
|
7
|
+
return false;
|
|
8
|
+
return existingFiles.some((existingFile) => {
|
|
9
|
+
if (!isFile(existingFile)) {
|
|
10
|
+
return existingFile.name === newFile.name;
|
|
11
|
+
}
|
|
12
|
+
return areFilesEqual(existingFile.file, newFile);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import { closeXIcon } from '../../constants/index.js';
|
|
4
|
+
import { isFile } from '../../utils/index.js';
|
|
5
|
+
import { FileItem, FileWrapper, Content, Upload, TextWrapper, FileIconWrapper, CloseIconWrapper } from './style';
|
|
6
|
+
const FilePreview = ({ files, disabled, sx, onRemoveFile, getFilePreview, renderBrandLogo, renderOpenFileInNewTab }) => {
|
|
7
|
+
return (_jsx(_Fragment, { children: files === null || files === void 0 ? void 0 : files.map((f, index) => {
|
|
8
|
+
const filePreview = isFile(f) ? getFilePreview(f.file) : null;
|
|
9
|
+
const isPdf = isFile(f) && f.file.type.includes('application/pdf');
|
|
10
|
+
const file = isFile(f) ? f.file : f;
|
|
11
|
+
return (_jsx(FileItem, Object.assign({ sx: sx }, { children: _jsxs(FileWrapper, Object.assign({ "data-slot": "file-wrapper" }, { children: [_jsxs(Content, Object.assign({ "data-slot": "file-Content" }, { children: [_jsx(FileIconWrapper, Object.assign({ "data-slot": "file-icon-wrapper" }, { children: isFile(f) && filePreview ? (_jsx(Box, { component: "img", src: filePreview, width: 24, height: 24, sx: { borderRadius: '50%', objectFit: isPdf ? 'none' : 'cover' }, onError: (e) => {
|
|
12
|
+
e.currentTarget.src = file.name; // Fallback or alternative logic
|
|
13
|
+
} })) : (renderBrandLogo === null || renderBrandLogo === void 0 ? void 0 : renderBrandLogo(file.id)) })), _jsxs(TextWrapper, Object.assign({ "data-slot": "text-wrapper" }, { children: [_jsx(Upload, Object.assign({ "data-slot": "filename" }, { children: file.name })), !isFile(f) && !filePreview && (renderOpenFileInNewTab === null || renderOpenFileInNewTab === void 0 ? void 0 : renderOpenFileInNewTab(file.id))] }))] })), !disabled && (_jsx(CloseIconWrapper, Object.assign({ "data-slot": "close-icon-wrapper", onClick: () => {
|
|
14
|
+
onRemoveFile === null || onRemoveFile === void 0 ? void 0 : onRemoveFile(f);
|
|
15
|
+
} }, { children: _jsx(Box, { component: "img", src: closeXIcon, width: 10, height: 10 }) })))] })) }), index));
|
|
16
|
+
}) }));
|
|
17
|
+
};
|
|
18
|
+
export default FilePreview;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const FileItem: 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 FileWrapper: 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 Content: 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 Upload: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
12
|
+
export declare const TextWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
13
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
14
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
15
|
+
export declare const FileIconWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
16
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
17
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
18
|
+
export declare const CloseIconWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
19
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
20
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Box from '@mui/material/Box';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
export const FileItem = styled(Box)(({ theme }) => ({
|
|
4
|
+
width: '100%',
|
|
5
|
+
borderRadius: '4px',
|
|
6
|
+
padding: '4px 8px',
|
|
7
|
+
display: 'flex',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
justifyContent: 'flex-start',
|
|
10
|
+
background: theme.palette.grey[400],
|
|
11
|
+
gap: '8px',
|
|
12
|
+
}));
|
|
13
|
+
export const FileWrapper = styled(Box)(() => ({
|
|
14
|
+
width: '100%',
|
|
15
|
+
display: 'flex',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
justifyContent: 'space-between',
|
|
18
|
+
gap: '8px',
|
|
19
|
+
}));
|
|
20
|
+
export const Content = styled(Box)(({ theme }) => ({
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'flex-start',
|
|
24
|
+
color: theme.palette.text.primary,
|
|
25
|
+
cursor: 'pointer',
|
|
26
|
+
gap: '8px',
|
|
27
|
+
}));
|
|
28
|
+
export const Upload = styled('span')(({ theme }) => ({
|
|
29
|
+
fontWeight: 500,
|
|
30
|
+
color: theme.palette.text.primary,
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
fontSize: '8px',
|
|
33
|
+
}));
|
|
34
|
+
export const TextWrapper = styled(Box)(({ theme }) => ({
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'column',
|
|
37
|
+
alignItems: 'flex-start',
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
gap: '4px',
|
|
40
|
+
color: theme.palette.text.primary,
|
|
41
|
+
}));
|
|
42
|
+
export const FileIconWrapper = styled(Box)(({ theme }) => ({
|
|
43
|
+
display: 'flex',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
background: theme.palette.common.white,
|
|
47
|
+
borderRadius: '4px',
|
|
48
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
49
|
+
}));
|
|
50
|
+
export const CloseIconWrapper = styled(Box)(() => ({
|
|
51
|
+
display: 'flex',
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
justifyContent: 'center',
|
|
54
|
+
cursor: 'pointer',
|
|
55
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import type { FileType } from '../../types/index.js';
|
|
4
|
+
export interface FilePreviewProps {
|
|
5
|
+
files: FileType[] | undefined;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
sx?: SxProps<Theme>;
|
|
8
|
+
onRemoveFile?: (file: FileType) => void;
|
|
9
|
+
getFilePreview: (file: File) => string;
|
|
10
|
+
renderBrandLogo: (fileId: string) => React.ReactNode;
|
|
11
|
+
renderOpenFileInNewTab: (fileId: string) => React.ReactNode;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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: (fileId: 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 {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo } from 'react';
|
|
3
|
+
import { MenuItem, Text } from '../../../index.js';
|
|
4
|
+
import { rightArrow } from '../../../../constants/index.js';
|
|
5
|
+
import { getNameText } from '../../../../utils/index.js';
|
|
6
|
+
import FlatMerchantsListMenu from '../FlatMerchantsListMenu';
|
|
7
|
+
import { Brand } from './style';
|
|
8
|
+
export default function BrandItem({ brand, merchantsIds, isDisabled, atLeastOneMerchantSelected = false, showSearchInput = false, renderBrandLogo, onChangeMerchant, }) {
|
|
9
|
+
var _a;
|
|
10
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
11
|
+
const open = Boolean(anchorEl);
|
|
12
|
+
const onOpen = (e) => {
|
|
13
|
+
setAnchorEl(e.currentTarget);
|
|
14
|
+
};
|
|
15
|
+
const onClose = () => {
|
|
16
|
+
setAnchorEl(null);
|
|
17
|
+
};
|
|
18
|
+
const selectedBrandMerchants = useMemo(() => brand.merchants.filter((merchant) => merchantsIds.includes(merchant.legacy_id)), [merchantsIds, brand.merchants]);
|
|
19
|
+
const isAllBrandsSelected = useMemo(() => selectedBrandMerchants.length === brand.merchants.length, [selectedBrandMerchants.length, brand.merchants.length]);
|
|
20
|
+
const isSomeSelected = useMemo(() => !isAllBrandsSelected && selectedBrandMerchants.length > 0, [isAllBrandsSelected, selectedBrandMerchants]);
|
|
21
|
+
const onClickBrand = (e) => {
|
|
22
|
+
e.stopPropagation();
|
|
23
|
+
if (isAllBrandsSelected) {
|
|
24
|
+
onChangeMerchant === null || onChangeMerchant === void 0 ? void 0 : onChangeMerchant(merchantsIds.filter((merchantId) => !brand.merchants.some(({ legacy_id }) => merchantId === legacy_id)));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (isSomeSelected) {
|
|
28
|
+
const uniqueMids = [...new Set([...merchantsIds, ...selectedBrandMerchants.map(({ legacy_id }) => legacy_id)])];
|
|
29
|
+
onChangeMerchant === null || onChangeMerchant === void 0 ? void 0 : onChangeMerchant(uniqueMids);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
onChangeMerchant === null || onChangeMerchant === void 0 ? void 0 : onChangeMerchant([...merchantsIds, ...brand.merchants.map(({ legacy_id }) => legacy_id)]);
|
|
33
|
+
};
|
|
34
|
+
return (_jsxs(MenuItem, Object.assign({ isSelected: isAllBrandsSelected, isIndeterminate: isSomeSelected, onMouseEnter: onOpen, onMouseLeave: onClose, onClick: (e) => {
|
|
35
|
+
if (isDisabled)
|
|
36
|
+
return;
|
|
37
|
+
onClickBrand(e);
|
|
38
|
+
}, isDisabled: isDisabled, sx: Object.assign({ maxHeight: 35, minHeight: 35 }, (open && { boxShadow: '0px 0px 16px 0px #00000021' })) }, { children: [_jsxs(Brand, { children: [renderBrandLogo === null || renderBrandLogo === void 0 ? void 0 : renderBrandLogo(brand.logo), _jsx(Text, Object.assign({ sx: { fontSize: '11px' } }, { children: getNameText(brand.name) }))] }), ((_a = brand.merchants) === null || _a === void 0 ? void 0 : _a.length) > 0 && _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsx(FlatMerchantsListMenu, { anchorEl: anchorEl, brand: brand, merchantsIds: merchantsIds, onChangeMerchant: onChangeMerchant, atLeastOneMerchantSelected: atLeastOneMerchantSelected, showSearchInput: showSearchInput })] })));
|
|
39
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Brand: 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>, {}, {}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface CountriesItemProps {
|
|
3
|
+
countries: string[];
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
countriesIds: string[];
|
|
6
|
+
onFilterChange?: (value: string[]) => void;
|
|
7
|
+
atLeastOneCountrySelected?: boolean;
|
|
8
|
+
hideCheckbox?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function CountriesItem({ countriesIds, isLoading, countries, onFilterChange, atLeastOneCountrySelected, hideCheckbox, }: Readonly<CountriesItemProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare const _default: import("react").MemoExoticComponent<typeof CountriesItem>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CountryFlag, Menu, MenuItem, Text } from '../../../index.js';
|
|
3
|
+
import { rightArrow } from '../../../../constants/index.js';
|
|
4
|
+
import { getCountryNameByISO } from '../../../../utils/index.js';
|
|
5
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
function CountriesItem({ countriesIds = [], isLoading, countries = [], onFilterChange, atLeastOneCountrySelected = false, hideCheckbox = false, }) {
|
|
8
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
9
|
+
const open = Boolean(anchorEl);
|
|
10
|
+
const { t } = useTranslation();
|
|
11
|
+
const onOpen = (e) => {
|
|
12
|
+
if (!open)
|
|
13
|
+
setAnchorEl(e.currentTarget);
|
|
14
|
+
};
|
|
15
|
+
const onClose = () => {
|
|
16
|
+
if (open)
|
|
17
|
+
setAnchorEl(null);
|
|
18
|
+
};
|
|
19
|
+
const isCountrySelected = useCallback((countryCode) => countriesIds === null || countriesIds === void 0 ? void 0 : countriesIds.includes(countryCode), [countriesIds]);
|
|
20
|
+
const isAllSelected = useMemo(() => {
|
|
21
|
+
if (!countries.length)
|
|
22
|
+
return false;
|
|
23
|
+
return countries.every((country) => isCountrySelected(country));
|
|
24
|
+
}, [countries, isCountrySelected]);
|
|
25
|
+
const isSomeSelected = useMemo(() => !isAllSelected && countriesIds.length > 0, [countriesIds, isAllSelected]);
|
|
26
|
+
const onClick = () => {
|
|
27
|
+
if (atLeastOneCountrySelected)
|
|
28
|
+
return;
|
|
29
|
+
if (isAllSelected) {
|
|
30
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange([]);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(countries);
|
|
34
|
+
};
|
|
35
|
+
const isLastCountryToBeDisabled = (currMid) => {
|
|
36
|
+
return countriesIds.length === 1 && countriesIds[0] === currMid && atLeastOneCountrySelected;
|
|
37
|
+
};
|
|
38
|
+
const onClickCountry = (e, countryCode) => {
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
if (isLastCountryToBeDisabled(countryCode))
|
|
41
|
+
return;
|
|
42
|
+
if (isCountrySelected(countryCode)) {
|
|
43
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(countriesIds.filter((country) => country !== countryCode));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const uniqueMids = [...new Set([...countriesIds, countryCode])];
|
|
47
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(uniqueMids);
|
|
48
|
+
};
|
|
49
|
+
const isDisabled = isLoading || (countries === null || countries === void 0 ? void 0 : countries.length) <= 0 || atLeastOneCountrySelected;
|
|
50
|
+
return (_jsxs(MenuItem, Object.assign({ isDisabled: isDisabled, isSelected: isAllSelected, hideCheckbox: hideCheckbox, isIndeterminate: isSomeSelected, sx: Object.assign(Object.assign({ maxHeight: 35, minHeight: 35, padding: '12px 8px 12px 16px' }, (open && { boxShadow: '0px 0px 16px 0px #00000021' })), (!(countries === null || countries === void 0 ? void 0 : countries.length) && { opacity: 0.5, pointerEvents: 'none' })), onMouseEnter: onOpen, onMouseLeave: onClose, onClick: onClick }, { children: [_jsx(Text, Object.assign({ sx: { fontSize: '11px', flex: 1 } }, { children: t('walletCountry') })), (countries === null || countries === void 0 ? void 0 : countries.length) > 0 && _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsx(Menu, Object.assign({ open: open, anchorEl: anchorEl, placement: "right-start", sx: { width: 200, overflow: 'auto' } }, { children: countries === null || countries === void 0 ? void 0 : countries.map((country, index) => (_jsxs(MenuItem, Object.assign({ isSelected: isCountrySelected(country), isDisabled: isLoading || isLastCountryToBeDisabled(country), onClick: (e) => {
|
|
51
|
+
onClickCountry(e, country);
|
|
52
|
+
}, sx: { maxHeight: 35, minHeight: 35 } }, { children: [_jsx(CountryFlag, { countryCode: country }), _jsx(Text, Object.assign({ sx: { fontSize: '11px !important', fontWeight: '500 !important' } }, { children: getCountryNameByISO(country) }))] }), `key-${country}-${index}`))) }))] })));
|
|
53
|
+
}
|
|
54
|
+
export default memo(CountriesItem);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CountriesItem';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CountriesItem';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface CurrenciesItemProps {
|
|
3
|
+
currencies: string[];
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
currenciesIds: string[];
|
|
6
|
+
atLeastOneCurrencySelected?: boolean;
|
|
7
|
+
hideCheckbox?: boolean;
|
|
8
|
+
onFilterChange?: (value: string[]) => void;
|
|
9
|
+
}
|
|
10
|
+
declare function CurrenciesItem({ currenciesIds, isLoading, currencies, onFilterChange, atLeastOneCurrencySelected, hideCheckbox, }: Readonly<CurrenciesItemProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare const _default: import("react").MemoExoticComponent<typeof CurrenciesItem>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CountryFlag, Menu, MenuItem, Text } from '../../../index.js';
|
|
3
|
+
import { rightArrow, SUPPORTED_CURRENCY_DETAILS } from '../../../../constants/index.js';
|
|
4
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
function CurrenciesItem({ currenciesIds = [], isLoading, currencies = [], onFilterChange, atLeastOneCurrencySelected = false, hideCheckbox = false, }) {
|
|
7
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
8
|
+
const open = Boolean(anchorEl);
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const onOpen = (e) => {
|
|
11
|
+
if (!open)
|
|
12
|
+
setAnchorEl(e.currentTarget);
|
|
13
|
+
};
|
|
14
|
+
const onClose = () => {
|
|
15
|
+
if (open)
|
|
16
|
+
setAnchorEl(null);
|
|
17
|
+
};
|
|
18
|
+
const isCurrencySelected = useCallback((currencyCode) => currenciesIds === null || currenciesIds === void 0 ? void 0 : currenciesIds.includes(currencyCode), [currenciesIds]);
|
|
19
|
+
const isAllSelected = useMemo(() => {
|
|
20
|
+
if (!currencies.length)
|
|
21
|
+
return false;
|
|
22
|
+
return currencies.every((currency) => isCurrencySelected(currency));
|
|
23
|
+
}, [currencies, isCurrencySelected]);
|
|
24
|
+
const isSomeSelected = useMemo(() => !isAllSelected && currenciesIds.length > 0, [currenciesIds, isAllSelected]);
|
|
25
|
+
const onClick = () => {
|
|
26
|
+
if (atLeastOneCurrencySelected)
|
|
27
|
+
return;
|
|
28
|
+
if (isAllSelected) {
|
|
29
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange([]);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(currencies);
|
|
33
|
+
};
|
|
34
|
+
const isLastCurrencyToBeDisabled = (currMid) => {
|
|
35
|
+
return currenciesIds.length === 1 && currenciesIds[0] === currMid && atLeastOneCurrencySelected;
|
|
36
|
+
};
|
|
37
|
+
const onClickCurrency = (e, currencyCode) => {
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
if (isLastCurrencyToBeDisabled(currencyCode))
|
|
40
|
+
return;
|
|
41
|
+
if (isCurrencySelected(currencyCode)) {
|
|
42
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(currenciesIds.filter((currency) => currency !== currencyCode));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const uniqueMids = [...new Set([...currenciesIds, currencyCode])];
|
|
46
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(uniqueMids);
|
|
47
|
+
};
|
|
48
|
+
const isDisabled = isLoading || (currencies === null || currencies === void 0 ? void 0 : currencies.length) <= 0 || atLeastOneCurrencySelected;
|
|
49
|
+
return (_jsxs(MenuItem, Object.assign({ isDisabled: isDisabled, isSelected: isAllSelected, hideCheckbox: hideCheckbox, isIndeterminate: isSomeSelected, sx: Object.assign(Object.assign({ maxHeight: 35, minHeight: 35, padding: '12px 8px 12px 16px' }, (open && { boxShadow: '0px 0px 16px 0px #00000021' })), (!(currencies === null || currencies === void 0 ? void 0 : currencies.length) && { opacity: 0.5, pointerEvents: 'none' })), onMouseEnter: onOpen, onMouseLeave: onClose, onClick: onClick }, { children: [_jsx(Text, Object.assign({ sx: { fontSize: '11px', flex: 1 } }, { children: t('currency') })), (currencies === null || currencies === void 0 ? void 0 : currencies.length) > 0 && _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsx(Menu, Object.assign({ open: open, anchorEl: anchorEl, placement: "right-start", sx: { width: 200, overflow: 'auto' } }, { children: currencies === null || currencies === void 0 ? void 0 : currencies.map((currency, index) => {
|
|
50
|
+
var _a;
|
|
51
|
+
const countryCode = (_a = SUPPORTED_CURRENCY_DETAILS[currency]) === null || _a === void 0 ? void 0 : _a.country;
|
|
52
|
+
if (!countryCode)
|
|
53
|
+
return null;
|
|
54
|
+
return (_jsxs(MenuItem, Object.assign({ isSelected: isCurrencySelected(currency), isDisabled: isLoading || isLastCurrencyToBeDisabled(currency), onClick: (e) => {
|
|
55
|
+
onClickCurrency(e, currency);
|
|
56
|
+
}, sx: { maxHeight: 35, minHeight: 35 } }, { children: [_jsx(CountryFlag, { countryCode: SUPPORTED_CURRENCY_DETAILS[currency].country }), ' ', _jsx(Text, Object.assign({ sx: { fontSize: '11px !important', fontWeight: '500 !important' } }, { children: currency }))] }), `key-${currency}-${index}`));
|
|
57
|
+
}) }))] })));
|
|
58
|
+
}
|
|
59
|
+
export default memo(CurrenciesItem);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CurrenciesItem';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CurrenciesItem';
|