@tap-payments/os-micro-frontend-shared 0.1.139-test.1 → 0.1.139-test.10
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/TableCells/CustomCells/StatusCell/StatusCell.d.ts +1 -4
- package/build/components/TableCells/CustomCells/StatusCell/StatusCell.js +5 -10
- package/build/components/TableCells/CustomCells/StatusCell/StatusCellSheet.d.ts +4 -0
- package/build/components/TableCells/CustomCells/StatusCell/StatusCellSheet.js +21 -0
- package/build/components/TableCells/CustomCells/StatusCell/StatusCellText.d.ts +6 -0
- package/build/components/TableCells/CustomCells/StatusCell/StatusCellText.js +42 -0
- package/build/components/TableCells/CustomCells/StatusCell/type.d.ts +2 -4
- package/build/components/TableCells/CustomCells/StatusCell/useStatusCell.d.ts +6 -0
- package/build/components/TableCells/CustomCells/StatusCell/useStatusCell.js +8 -0
- package/build/components/TableCells/CustomCells/StatusCell/utils.d.ts +2 -1
- package/build/components/TableCells/CustomCells/StatusCell/utils.js +2 -1
- package/package.json +2 -2
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { StatusCellProps } from './type';
|
|
2
|
-
declare function StatusCell({ statuses,
|
|
3
|
-
isChargesService?: boolean;
|
|
4
|
-
isAuthorizationsService?: boolean;
|
|
5
|
-
}>): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare function StatusCell({ statuses, centerIconKey, ...props }: StatusCellProps): import("react/jsx-runtime").JSX.Element;
|
|
6
3
|
export default StatusCell;
|
|
@@ -12,16 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { TableCell } from '../../../TableCells';
|
|
14
14
|
import { StatusIcon, StatusContainer, StatusWrapper } from './style';
|
|
15
|
-
import {
|
|
15
|
+
import { useStatusCell } from './useStatusCell';
|
|
16
16
|
function StatusCell(_a) {
|
|
17
|
-
var { statuses,
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
if (tableMode === 'sheet') {
|
|
21
|
-
return (_jsx(TableCell, Object.assign({}, props, { children: _jsx(StatusContainer, Object.assign({ sx: { paddingRight: '30px' } }, { children: statusesList.map((status) => status) })) })));
|
|
22
|
-
}
|
|
23
|
-
const xGapValue = isTextShown ? xGap || 120 : 40;
|
|
24
|
-
const centerIconIndex = centerIconKey ? Object.entries(statusesFilteredObject).findIndex(([key]) => key === centerIconKey) : 0;
|
|
17
|
+
var { statuses, centerIconKey } = _a, props = __rest(_a, ["statuses", "centerIconKey"]);
|
|
18
|
+
const { centerIconIndex, statusesList } = useStatusCell({ statuses, centerIconKey });
|
|
19
|
+
const xGapValue = 40;
|
|
25
20
|
return (_jsx(TableCell, Object.assign({}, props, { "data-testid": "StatusCell", sx: {
|
|
26
21
|
position: 'relative',
|
|
27
22
|
overflow: 'visible',
|
|
@@ -41,7 +36,7 @@ function StatusCell(_a) {
|
|
|
41
36
|
x: xHoverPosition,
|
|
42
37
|
zIndex: 100 - Math.abs(centerIconIndex - index),
|
|
43
38
|
},
|
|
44
|
-
}, transition: { duration: 0.3, type: 'tween', ease: 'easeOut' }, statusesCount: statusesList.length || 0 }, { children: _jsx(StatusIcon,
|
|
39
|
+
}, transition: { duration: 0.3, type: 'tween', ease: 'easeOut' }, statusesCount: statusesList.length || 0 }, { children: _jsx(StatusIcon, { children: status }) }), index));
|
|
45
40
|
}) })) })));
|
|
46
41
|
}
|
|
47
42
|
export default StatusCell;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TableCellProps } from '@mui/material/TableCell';
|
|
2
|
+
import type { StatusCellProps } from './type';
|
|
3
|
+
declare function StatusCellSheet({ statuses, ...props }: Pick<StatusCellProps, 'statuses'> & TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export default StatusCellSheet;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { TableCell } from '../../../TableCells';
|
|
14
|
+
import { StatusContainer } from './style';
|
|
15
|
+
import { useStatusCell } from './useStatusCell';
|
|
16
|
+
function StatusCellSheet(_a) {
|
|
17
|
+
var { statuses } = _a, props = __rest(_a, ["statuses"]);
|
|
18
|
+
const { statusesList } = useStatusCell({ statuses });
|
|
19
|
+
return (_jsx(TableCell, Object.assign({}, props, { children: _jsx(StatusContainer, Object.assign({ sx: { paddingRight: '30px' } }, { children: statusesList.map((status) => status) })) })));
|
|
20
|
+
}
|
|
21
|
+
export default StatusCellSheet;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StatusCellProps } from './type';
|
|
2
|
+
interface StatusCellTextProps extends StatusCellProps {
|
|
3
|
+
xGap?: number;
|
|
4
|
+
}
|
|
5
|
+
declare function StatusCellText({ statuses, centerIconKey, xGap, ...props }: StatusCellTextProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default StatusCellText;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { TableCell } from '../../../TableCells';
|
|
14
|
+
import { StatusIcon, StatusContainer, StatusWrapper } from './style';
|
|
15
|
+
import { useStatusCell } from './useStatusCell';
|
|
16
|
+
function StatusCellText(_a) {
|
|
17
|
+
var { statuses, centerIconKey, xGap } = _a, props = __rest(_a, ["statuses", "centerIconKey", "xGap"]);
|
|
18
|
+
const { statusesList, centerIconIndex } = useStatusCell({ statuses, centerIconKey });
|
|
19
|
+
const xGapValue = xGap || 120;
|
|
20
|
+
return (_jsx(TableCell, Object.assign({}, props, { "data-testid": "StatusCell", sx: {
|
|
21
|
+
position: 'relative',
|
|
22
|
+
overflow: 'visible',
|
|
23
|
+
} }, { children: _jsx(StatusContainer, Object.assign({ initial: "initial", whileHover: "hover", animate: "start" }, { children: statusesList.map((status, index) => {
|
|
24
|
+
if (!status)
|
|
25
|
+
return;
|
|
26
|
+
// To keep x position of each icon while hovering consistent
|
|
27
|
+
const xHoverPosition = (index - centerIconIndex) * xGapValue;
|
|
28
|
+
const isIconAfterCenterIcon = index > centerIconIndex;
|
|
29
|
+
const isIconBeforeCenterIcon = index < centerIconIndex;
|
|
30
|
+
return (_jsx(StatusWrapper, Object.assign({ variants: {
|
|
31
|
+
initial: {
|
|
32
|
+
x: isIconBeforeCenterIcon ? -5 : isIconAfterCenterIcon ? 5 : 0,
|
|
33
|
+
zIndex: isIconBeforeCenterIcon ? 100 - index : isIconAfterCenterIcon ? index : 100,
|
|
34
|
+
},
|
|
35
|
+
hover: {
|
|
36
|
+
x: xHoverPosition,
|
|
37
|
+
zIndex: 100 - Math.abs(centerIconIndex - index),
|
|
38
|
+
},
|
|
39
|
+
}, transition: { duration: 0.3, type: 'tween', ease: 'easeOut' }, statusesCount: statusesList.length || 0 }, { children: _jsx(StatusIcon, Object.assign({ isTextShown: true }, { children: status })) }), index));
|
|
40
|
+
}) })) })));
|
|
41
|
+
}
|
|
42
|
+
export default StatusCellText;
|
|
@@ -4,10 +4,8 @@ import { authorizedStatusIcons, payoutStatusIcons, refundStatusIcons } from './c
|
|
|
4
4
|
export type RefundStatusType = keyof typeof refundStatusIcons;
|
|
5
5
|
export type PayoutStatusType = keyof typeof payoutStatusIcons;
|
|
6
6
|
export type AuthorizedStatusType = keyof typeof authorizedStatusIcons;
|
|
7
|
+
export type Statuses = Record<string, React.ReactNode | undefined | null>;
|
|
7
8
|
export interface StatusCellProps extends TableCellProps {
|
|
8
|
-
statuses:
|
|
9
|
-
isTextShown?: boolean;
|
|
9
|
+
statuses: Statuses;
|
|
10
10
|
centerIconKey?: string;
|
|
11
|
-
xGap?: number;
|
|
12
|
-
tableMode?: 'default' | 'text' | 'sheet';
|
|
13
11
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StatusCellProps } from './type';
|
|
3
|
+
export declare const useStatusCell: ({ statuses, centerIconKey }: Pick<StatusCellProps, 'statuses' | 'centerIconKey'>) => {
|
|
4
|
+
statusesList: import("react").ReactNode[];
|
|
5
|
+
centerIconIndex: number;
|
|
6
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { getStatusesFilteredObject } from './utils';
|
|
3
|
+
export const useStatusCell = ({ statuses, centerIconKey }) => {
|
|
4
|
+
const statusesFilteredObject = useMemo(() => getStatusesFilteredObject(statuses), [statuses]);
|
|
5
|
+
const statusesList = useMemo(() => Object.values(statusesFilteredObject).filter(Boolean), [statusesFilteredObject]);
|
|
6
|
+
const centerIconIndex = useMemo(() => (centerIconKey ? Object.entries(statusesFilteredObject).findIndex(([key]) => key === centerIconKey) : 0), [statusesFilteredObject, centerIconKey]);
|
|
7
|
+
return { statusesList, centerIconIndex };
|
|
8
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { Statuses } from './type';
|
|
3
|
+
export declare const getStatusesFilteredObject: (statuses: Statuses) => Record<string, import("react").ReactNode>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export const getStatusesFilteredObject = (statuses) => {
|
|
2
|
-
|
|
2
|
+
const filteredList = Object.keys(statuses)
|
|
3
3
|
.filter((key) => statuses[key])
|
|
4
4
|
.reduce((acc, key) => {
|
|
5
5
|
acc[key] = statuses[key];
|
|
6
6
|
return acc;
|
|
7
7
|
}, {});
|
|
8
|
+
return statuses ? filteredList : {};
|
|
8
9
|
};
|
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.139-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.139-test.10",
|
|
5
|
+
"testVersion": 10,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|