@tap-payments/os-micro-frontend-shared 0.1.24-test.1 → 0.1.24-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.
- package/build/components/ListLayout/ListLayout.d.ts +10 -0
- package/build/components/ListLayout/ListLayout.js +20 -0
- package/build/components/ListLayout/index.d.ts +2 -0
- package/build/components/ListLayout/index.js +2 -0
- package/build/components/ListLayout/styles.d.ts +4 -0
- package/build/components/ListLayout/styles.js +8 -0
- package/build/components/StatusIcons/SourceIcons/SourceIcons.js +2 -2
- package/build/components/ToggleView/ToggleView.d.ts +16 -0
- package/build/components/ToggleView/ToggleView.js +32 -0
- package/build/components/ToggleView/ToggleWrapper.d.ts +4 -0
- package/build/components/ToggleView/ToggleWrapper.js +8 -0
- package/build/components/ToggleView/index.d.ts +3 -0
- package/build/components/ToggleView/index.js +3 -0
- package/build/components/ToggleView/style.d.ts +14 -0
- package/build/components/ToggleView/style.js +31 -0
- package/build/components/ToggleView/types.d.ts +6 -0
- package/build/components/ToggleView/types.js +6 -0
- package/build/components/index.d.ts +4 -0
- package/build/components/index.js +4 -0
- package/package.json +11 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { ListLayoutStyled } from './styles';
|
|
3
|
+
interface ListLayoutProps extends ComponentPropsWithoutRef<typeof ListLayoutStyled> {
|
|
4
|
+
}
|
|
5
|
+
declare function ListLayout({ children, ...props }: Readonly<ListLayoutProps>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare namespace ListLayout {
|
|
7
|
+
var displayName: string;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: import("react").MemoExoticComponent<typeof ListLayout>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 } from 'react';
|
|
14
|
+
import { ListLayoutStyled } from './styles';
|
|
15
|
+
function ListLayout(_a) {
|
|
16
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
17
|
+
return (_jsx(ListLayoutStyled, Object.assign({ component: 'article', "data-testid": 'ListLayout' }, props, { children: children })));
|
|
18
|
+
}
|
|
19
|
+
ListLayout.displayName = 'ListLayout';
|
|
20
|
+
export default memo(ListLayout);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ListLayoutStyled: 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>, {}, {}>;
|
|
@@ -16,10 +16,10 @@ export function SourceIcons({ payment, card, isTextShown, firstIcon }) {
|
|
|
16
16
|
const method = payment === null || payment === void 0 ? void 0 : payment.method;
|
|
17
17
|
const scheme = payment === null || payment === void 0 ? void 0 : payment.scheme;
|
|
18
18
|
if (((_a = getPaymentMethodKey(method)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = getPaymentMethodKey(scheme)) === null || _b === void 0 ? void 0 : _b.toLowerCase())) {
|
|
19
|
-
initialSources.push(...[getPaymentMethodKey(
|
|
19
|
+
initialSources.push(...[getPaymentMethodKey(method), getPaymentMethodKey(type)]);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
initialSources.push(...[getPaymentMethodKey(
|
|
22
|
+
initialSources.push(...[getPaymentMethodKey(method), getPaymentMethodKey(type), getPaymentMethodKey(scheme)]);
|
|
23
23
|
}
|
|
24
24
|
return initialSources;
|
|
25
25
|
}, [payment]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ToggleViews, ToggleViewsValues } from './types';
|
|
3
|
+
declare const DEFAULT_TOGGLE_VIEWS: {
|
|
4
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
value: ToggleViews;
|
|
6
|
+
}[];
|
|
7
|
+
export interface ToggleViewProps {
|
|
8
|
+
onToggleClick: (view: ToggleViewsValues) => void;
|
|
9
|
+
currentView: ToggleViewsValues;
|
|
10
|
+
getOverrideViews?: (defaultViews: typeof DEFAULT_TOGGLE_VIEWS) => {
|
|
11
|
+
icon: React.ReactNode;
|
|
12
|
+
value: ToggleViewsValues;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
declare const ToggleView: (props: ToggleViewProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
+
export default ToggleView;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cardViewButtonIcon, listViewButtonIcon } from '../../constants/index.js';
|
|
3
|
+
import { ActiveOverlay, ViewButton } from './style';
|
|
4
|
+
import { ToggleViews } from './types';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import ToggleWrapper from './ToggleWrapper';
|
|
7
|
+
const DEFAULT_TOGGLE_VIEWS = [
|
|
8
|
+
{
|
|
9
|
+
icon: _jsx("img", { src: cardViewButtonIcon, alt: "card" }),
|
|
10
|
+
value: ToggleViews.CARDS,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
icon: _jsx("img", { src: listViewButtonIcon, alt: ToggleViews.LIST }),
|
|
14
|
+
value: ToggleViews.LIST,
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
const ToggleView = (props) => {
|
|
18
|
+
const { currentView, onToggleClick, getOverrideViews } = props;
|
|
19
|
+
const views = useMemo(() => {
|
|
20
|
+
if (getOverrideViews)
|
|
21
|
+
return getOverrideViews(DEFAULT_TOGGLE_VIEWS);
|
|
22
|
+
return DEFAULT_TOGGLE_VIEWS;
|
|
23
|
+
}, [getOverrideViews]);
|
|
24
|
+
const viewIndex = useMemo(() => views.findIndex((view) => view.value === currentView), [views, currentView]);
|
|
25
|
+
if (!onToggleClick)
|
|
26
|
+
return null;
|
|
27
|
+
return (_jsxs(ToggleWrapper, { children: [views.map((view) => (_jsx(ViewButton, Object.assign({ onClick: () => onToggleClick(view.value), sx: {
|
|
28
|
+
height: '11.6px',
|
|
29
|
+
width: '11.6px',
|
|
30
|
+
}, isActive: currentView === view.value }, { children: view.icon }), view.value))), _jsx(ActiveOverlay, { activeIndex: viewIndex })] }));
|
|
31
|
+
};
|
|
32
|
+
export default ToggleView;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ToggleWrapperStyled } from './style';
|
|
4
|
+
const ToggleWrapper = (props) => {
|
|
5
|
+
const viewTogglers = React.Children.count(props.children) - 1;
|
|
6
|
+
return _jsx(ToggleWrapperStyled, Object.assign({}, props, { sx: { width: viewTogglers * 30 + 2 } }));
|
|
7
|
+
};
|
|
8
|
+
export default ToggleWrapper;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ToggleWrapperStyled: 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
|
+
export declare const ViewButton: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").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").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
8
|
+
isActive: boolean;
|
|
9
|
+
}, {}, {}>;
|
|
10
|
+
export declare const ActiveOverlay: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
11
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
12
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
13
|
+
activeIndex: number;
|
|
14
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Box, styled } from '@mui/material';
|
|
2
|
+
export const ToggleWrapperStyled = styled(Box)(({ theme }) => ({
|
|
3
|
+
height: '32px',
|
|
4
|
+
borderRadius: '4px',
|
|
5
|
+
backgroundColor: theme.palette.action.hover,
|
|
6
|
+
padding: '2px',
|
|
7
|
+
display: 'flex',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
position: 'relative',
|
|
10
|
+
cursor: 'pointer'
|
|
11
|
+
}));
|
|
12
|
+
export const ViewButton = styled(Box, { shouldForwardProp: (props) => props !== 'isActive' })(({ isActive }) => ({
|
|
13
|
+
flex: 1,
|
|
14
|
+
display: 'flex',
|
|
15
|
+
justifyContent: 'center',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
position: 'relative',
|
|
18
|
+
zIndex: 2,
|
|
19
|
+
opacity: isActive ? 1 : 0.5
|
|
20
|
+
}));
|
|
21
|
+
export const ActiveOverlay = styled(Box, { shouldForwardProp: (props) => props !== 'activeIndex' })(({ theme, activeIndex }) => ({
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
top: 2,
|
|
24
|
+
left: activeIndex * 30 + 2,
|
|
25
|
+
transition: 'all 0.25s ease-in-out',
|
|
26
|
+
width: '28px',
|
|
27
|
+
height: '28px',
|
|
28
|
+
backgroundColor: theme.palette.common.white,
|
|
29
|
+
borderRadius: '2px',
|
|
30
|
+
boxShadow: '0px 0px 4px 0px rgba(0, 0, 0, 0.20)'
|
|
31
|
+
}));
|
|
@@ -97,3 +97,7 @@ export { default as AppServices } from './AppServices';
|
|
|
97
97
|
export { default as ScrollLoader } from './ScrollLoader';
|
|
98
98
|
export * from './ScrollLoader';
|
|
99
99
|
export * from './TooltipChip';
|
|
100
|
+
export { default as ListLayout } from './ListLayout';
|
|
101
|
+
export * from './ListLayout';
|
|
102
|
+
export { default as ToggleView } from './ToggleView';
|
|
103
|
+
export * from './ToggleView';
|
|
@@ -97,3 +97,7 @@ export { default as AppServices } from './AppServices';
|
|
|
97
97
|
export { default as ScrollLoader } from './ScrollLoader';
|
|
98
98
|
export * from './ScrollLoader';
|
|
99
99
|
export * from './TooltipChip';
|
|
100
|
+
export { default as ListLayout } from './ListLayout';
|
|
101
|
+
export * from './ListLayout';
|
|
102
|
+
export { default as ToggleView } from './ToggleView';
|
|
103
|
+
export * from './ToggleView';
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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.24-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.24-test.3",
|
|
5
|
+
"testVersion": 3,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|
|
@@ -122,6 +122,15 @@
|
|
|
122
122
|
"vite": "6.0.5",
|
|
123
123
|
"vite-tsconfig-paths": "^4.2.0"
|
|
124
124
|
},
|
|
125
|
+
"peerDependencies": {
|
|
126
|
+
"react": "^18",
|
|
127
|
+
"react-dom": "^18",
|
|
128
|
+
"react-router": "^7.7.0",
|
|
129
|
+
"@emotion/react": "^11",
|
|
130
|
+
"@emotion/styled": "^11",
|
|
131
|
+
"@mui/material": "^5",
|
|
132
|
+
"react-multi-date-picker": "4.1.2"
|
|
133
|
+
},
|
|
125
134
|
"lint-staged": {
|
|
126
135
|
"src/**/*.{ts,tsx,json,js,jsx}": [
|
|
127
136
|
"yarn run prettier:fix",
|