@tap-payments/os-micro-frontend-shared 0.1.247 → 0.1.248

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.
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { BoxProps } from '@mui/material/Box';
3
+ export interface BrandLogoProps extends BoxProps {
4
+ data?: Blob;
5
+ width?: number | string;
6
+ height?: number | string;
7
+ isError?: boolean;
8
+ isLoading?: boolean;
9
+ }
10
+ declare function BrandLogo({ data, isError, isLoading, width, height, ...props }: Readonly<BrandLogoProps>): import("react/jsx-runtime").JSX.Element;
11
+ declare const _default: import("react").MemoExoticComponent<typeof BrandLogo>;
12
+ export default _default;
@@ -0,0 +1,35 @@
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 } from "react/jsx-runtime";
13
+ import { memo, useMemo } from 'react';
14
+ import { useTheme } from '@mui/material/styles';
15
+ import { grayBrandIcon, pdfIcon } from '../../constants/index.js';
16
+ import { Icon } from '../index.js';
17
+ import { Loading } from './Loading';
18
+ function BrandLogo(_a) {
19
+ var { data, isError, isLoading, width = 24, height = 24 } = _a, props = __rest(_a, ["data", "isError", "isLoading", "width", "height"]);
20
+ const theme = useTheme();
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
+ const logoUrl = useMemo(() => (data ? (window.URL ? URL : webkitURL).createObjectURL(data) : ''), [data]);
23
+ const imageSrc = useMemo(() => {
24
+ if (isError || !data)
25
+ return grayBrandIcon;
26
+ if (isPdf)
27
+ return pdfIcon;
28
+ return logoUrl;
29
+ }, [data, isError, isPdf, logoUrl]);
30
+ if (isLoading)
31
+ return _jsx(Loading, { width: width, height: height });
32
+ 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) }));
34
+ }
35
+ export default memo(BrandLogo);
@@ -0,0 +1,6 @@
1
+ interface LoadingProps {
2
+ width?: number | string;
3
+ height?: number | string;
4
+ }
5
+ export declare const Loading: ({ width, height }: Readonly<LoadingProps>) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,3 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Skeleton } from '../index.js';
3
+ export const Loading = ({ width, height }) => _jsx(Skeleton, { variant: "circular", width: width, height: height });
@@ -0,0 +1 @@
1
+ export { default as BrandLogo, BrandLogoProps } from './BrandLogo';
@@ -0,0 +1 @@
1
+ export { default as BrandLogo } from './BrandLogo';
@@ -122,3 +122,4 @@ export * from './ListLayout';
122
122
  export { default as MFWidgetLoader } from './MFWidgetLoader';
123
123
  export { default as BetaBanner } from './BetaBanner';
124
124
  export * from './Autocomplete';
125
+ export * from './BrandLogo';
@@ -122,3 +122,4 @@ export * from './ListLayout';
122
122
  export { default as MFWidgetLoader } from './MFWidgetLoader';
123
123
  export { default as BetaBanner } from './BetaBanner';
124
124
  export * from './Autocomplete';
125
+ export * from './BrandLogo';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.247",
4
+ "version": "0.1.248",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",