@tap-payments/os-micro-frontend-shared 0.1.355 → 0.1.356
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.
|
@@ -6,7 +6,8 @@ export interface BrandLogoProps extends BoxProps {
|
|
|
6
6
|
height?: number | string;
|
|
7
7
|
isError?: boolean;
|
|
8
8
|
isLoading?: boolean;
|
|
9
|
+
imageUrl?: string;
|
|
9
10
|
}
|
|
10
|
-
declare function BrandLogo({ data, isError, isLoading, width, height, ...props }: Readonly<BrandLogoProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function BrandLogo({ data, isError, isLoading, imageUrl, width, height, ...props }: Readonly<BrandLogoProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
declare const _default: import("react").MemoExoticComponent<typeof BrandLogo>;
|
|
12
13
|
export default _default;
|
|
@@ -16,20 +16,24 @@ import { grayBrandIcon, pdfIcon } from '../../constants/index.js';
|
|
|
16
16
|
import { Icon } from '../index.js';
|
|
17
17
|
import { Loading } from './Loading';
|
|
18
18
|
function BrandLogo(_a) {
|
|
19
|
-
var { data, isError, isLoading, width = 24, height = 24 } = _a, props = __rest(_a, ["data", "isError", "isLoading", "width", "height"]);
|
|
19
|
+
var { data, isError, isLoading, imageUrl, width = 24, height = 24 } = _a, props = __rest(_a, ["data", "isError", "isLoading", "imageUrl", "width", "height"]);
|
|
20
20
|
const theme = useTheme();
|
|
21
21
|
const isPdf = useMemo(() => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.type) === null || _a === void 0 ? void 0 : _a.includes('application/pdf'); }, [data]);
|
|
22
22
|
const logoUrl = useMemo(() => (data ? (window.URL ? URL : webkitURL).createObjectURL(data) : ''), [data]);
|
|
23
23
|
const imageSrc = useMemo(() => {
|
|
24
|
+
if (imageUrl)
|
|
25
|
+
return imageUrl;
|
|
24
26
|
if (isError || !data)
|
|
25
27
|
return grayBrandIcon;
|
|
26
28
|
if (isPdf)
|
|
27
29
|
return pdfIcon;
|
|
28
30
|
return logoUrl;
|
|
29
|
-
}, [
|
|
31
|
+
}, [imageUrl, isError, data, isPdf, logoUrl]);
|
|
30
32
|
if (isLoading)
|
|
31
33
|
return _jsx(Loading, { width: width, height: height });
|
|
32
34
|
return (_jsx(Icon, { alt: "brand", src: imageSrc, sx: Object.assign({ borderRadius: '50%', backgroundColor: theme.palette.common.white, width,
|
|
33
|
-
height, objectFit: isPdf ? 'none' : 'contain' }, props.sx)
|
|
35
|
+
height, objectFit: isPdf ? 'none' : 'contain' }, props.sx), onError: (e) => {
|
|
36
|
+
e.currentTarget.src = grayBrandIcon;
|
|
37
|
+
} }));
|
|
34
38
|
}
|
|
35
39
|
export default memo(BrandLogo);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SxProps } from '@mui/material/styles';
|
|
2
2
|
import { Theme } from '@mui/system';
|
|
3
|
-
|
|
3
|
+
import { HTMLAttributes } from 'react';
|
|
4
|
+
export interface IconProps extends HTMLAttributes<HTMLImageElement> {
|
|
4
5
|
src: string;
|
|
5
6
|
onClick?: () => void;
|
|
6
7
|
sx?: SxProps<Theme>;
|
package/package.json
CHANGED