@tap-payments/os-micro-frontend-shared 0.1.31-test.16 → 0.1.31-test.17
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/MaskedText/MaskedText.d.ts +1 -1
- package/build/components/MaskedText/MaskedText.js +2 -2
- package/build/components/StatusChip/StatusChip.js +11 -15
- package/build/components/StatusChip/style.js +1 -1
- package/build/components/StatusChipWithCopy/StatusChipWithCopy.d.ts +3 -3
- package/build/components/StatusChipWithCopy/StatusChipWithCopy.js +1 -1
- package/build/components/StatusChipWithCopy/utils.d.ts +2 -2
- package/build/components/TableCells/CustomCells/type.d.ts +2 -2
- package/build/components/VirtualTables/components/TableRow.js +1 -1
- package/build/types/table.d.ts +2 -2
- package/package.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { MaskedTextProps } from './type';
|
|
2
|
-
declare const MaskedText: ({ text, startLength, endLength, chipIndex, copyText,
|
|
2
|
+
declare const MaskedText: ({ text, startLength, endLength, chipIndex, copyText, cellContext }: MaskedTextProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default MaskedText;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import StatusChipWithCopy from '../StatusChipWithCopy';
|
|
3
3
|
import { passwordDotsIcon } from '../../constants/index.js';
|
|
4
|
-
const MaskedText = ({ text, startLength = 8, endLength = 4, chipIndex, copyText,
|
|
4
|
+
const MaskedText = ({ text, startLength = 8, endLength = 4, chipIndex, copyText, cellContext }) => {
|
|
5
5
|
const startText = text.slice(0, startLength);
|
|
6
6
|
const endText = text.slice(text.length - endLength);
|
|
7
|
-
return (_jsxs(StatusChipWithCopy, Object.assign({ chipIndex: chipIndex, copyText: copyText,
|
|
7
|
+
return (_jsxs(StatusChipWithCopy, Object.assign({ chipIndex: chipIndex, copyText: copyText, cellContext: cellContext }, { children: [startText, _jsx("img", { src: passwordDotsIcon, alt: "passwordDots" }), endText] })));
|
|
8
8
|
};
|
|
9
9
|
export default MaskedText;
|
|
@@ -11,7 +11,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useState } from 'react';
|
|
14
|
-
import Box from '@mui/material/Box';
|
|
15
14
|
import { useTranslation } from 'react-i18next';
|
|
16
15
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
17
16
|
import { copyText as copyTextHandler } from '../../utils/index.js';
|
|
@@ -22,7 +21,10 @@ const StatusChip = (_a) => {
|
|
|
22
21
|
var { children, unknownText, copyText } = _a, props = __rest(_a, ["children", "unknownText", "copyText"]);
|
|
23
22
|
const [showCopy, setShowCopy] = useState(false);
|
|
24
23
|
const { t } = useTranslation();
|
|
25
|
-
const
|
|
24
|
+
const isSelected = props.isSelected;
|
|
25
|
+
if (!children) {
|
|
26
|
+
return (_jsx(ChipStyled, Object.assign({}, unknownGeographyColors, props, { isSelected: false }, { children: unknownText ? t(unknownText) : t('unknown') })));
|
|
27
|
+
}
|
|
26
28
|
const handleCopy = (e) => {
|
|
27
29
|
e.stopPropagation();
|
|
28
30
|
if (copyText) {
|
|
@@ -36,21 +38,15 @@ const StatusChip = (_a) => {
|
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
40
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
stiffness: 180,
|
|
43
|
-
damping: 25,
|
|
44
|
-
mass: 0.4,
|
|
45
|
-
} }, { children: _jsxs(ChipStyled, Object.assign({}, chipProps, { sx: {
|
|
46
|
-
position: 'absolute',
|
|
47
|
-
top: 0,
|
|
48
|
-
left: 0,
|
|
49
|
-
zIndex: props.isSelected ? 3 : 0,
|
|
50
|
-
} }, { children: [_jsx(Wrapper, { children: content }), _jsx(AnimatePresence, Object.assign({ mode: "wait" }, { children: props.isSelected && copyText && (_jsx(motion.img, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, onClick: handleCopy, src: showCopy ? greenCheckIcon : blueCopyIcon, style: {
|
|
41
|
+
return (_jsxs(motion.div, Object.assign({ style: { position: 'relative' }, animate: { zIndex: isSelected ? 3 : 0 } }, { children: [_jsx(ChipStyled, Object.assign({}, props, { sx: { visibility: 'hidden', pointerEvents: 'none' } }, { children: _jsx(Wrapper, { children: children }) })), _jsx(ChipStyled, Object.assign({}, props, { isSelected: isSelected, style: { position: 'absolute', top: 0, left: 0, zIndex: isSelected ? 3 : 0 } }, { children: _jsxs(motion.div, Object.assign({ layout: "size", style: { display: 'flex', gap: '4px' }, animate: {
|
|
42
|
+
paddingRight: isSelected ? 12 : 0,
|
|
43
|
+
}, transition: { delay: !isSelected ? 0.2 : 0 } }, { children: [_jsx(Wrapper, { children: children }), _jsx(AnimatePresence, { children: isSelected && copyText && (_jsx(motion.img, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, onClick: handleCopy, src: showCopy ? greenCheckIcon : blueCopyIcon, style: {
|
|
51
44
|
height: 12,
|
|
52
45
|
width: 12,
|
|
53
46
|
objectFit: 'contain',
|
|
54
|
-
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
right: 8,
|
|
49
|
+
top: 2,
|
|
50
|
+
} })) })] })) }))] })));
|
|
55
51
|
};
|
|
56
52
|
export default StatusChip;
|
|
@@ -4,7 +4,7 @@ import { SELECTION_COLORS } from '../../utils/index.js';
|
|
|
4
4
|
export const ChipStyled = styled(Box, {
|
|
5
5
|
shouldForwardProp: (prop) => !['textColor', 'bgColor', 'borderColor', 'disabled', 'padding', 'maxWidth', 'isSelected'].includes(prop),
|
|
6
6
|
})(({ theme, isSelected, textColor = theme.palette.text.primary, bgColor = '#EFF1F2', borderColor = '#EFF1F2', disabled = false, padding, maxWidth, }) => {
|
|
7
|
-
return Object.assign({ display: 'flex', alignItems: 'center', gap: '4px', height: '18px', padding:
|
|
7
|
+
return Object.assign({ display: 'flex', alignItems: 'center', gap: '4px', height: '18px', padding: 0, borderRadius: '30px', border: `1px solid ${borderColor}`, backgroundColor: bgColor, color: textColor, cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.5 : 1, whiteSpace: 'nowrap', fontSize: '11px', minWidth: '67px', maxWidth: maxWidth || 'none', overflow: 'hidden', textOverflow: maxWidth ? 'ellipsis' : 'unset', boxSizing: 'border-box' }, (isSelected && { color: SELECTION_COLORS.primary, borderColor: SELECTION_COLORS.primary }));
|
|
8
8
|
});
|
|
9
9
|
export const Wrapper = styled(Box)(() => ({
|
|
10
10
|
display: 'flex',
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { StatusChipProps } from '../StatusChip';
|
|
3
|
-
import {
|
|
3
|
+
import { CellContext } from '../../types/index.js';
|
|
4
4
|
export interface StatusChipWithCopyProps extends StatusChipProps {
|
|
5
5
|
copyText?: string;
|
|
6
6
|
chipIndex: number;
|
|
7
|
-
|
|
7
|
+
cellContext: CellContext;
|
|
8
8
|
}
|
|
9
|
-
declare function StatusChipWithCopy({ children, copyText, chipIndex,
|
|
9
|
+
declare function StatusChipWithCopy({ children, copyText, chipIndex, cellContext: { onChipClick, rowIndex, colIndex, selectedChip }, ...reset }: StatusChipWithCopyProps): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
declare const _default: import("react").MemoExoticComponent<typeof StatusChipWithCopy>;
|
|
11
11
|
export default _default;
|
|
@@ -14,7 +14,7 @@ import { memo, useMemo } from 'react';
|
|
|
14
14
|
import StatusChip from '../StatusChip';
|
|
15
15
|
import { checkIsChipSelected } from './utils';
|
|
16
16
|
function StatusChipWithCopy(_a) {
|
|
17
|
-
var { children, copyText, chipIndex,
|
|
17
|
+
var { children, copyText, chipIndex, cellContext: { onChipClick, rowIndex, colIndex, selectedChip } } = _a, reset = __rest(_a, ["children", "copyText", "chipIndex", "cellContext"]);
|
|
18
18
|
const isSelected = useMemo(() => checkIsChipSelected({ rowIndex, colIndex, selectedChip, chipIndex }), [rowIndex, colIndex, selectedChip, chipIndex]);
|
|
19
19
|
return (_jsx(StatusChip, Object.assign({}, reset, { copyText: copyText, onClick: (e) => {
|
|
20
20
|
onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(e, chipIndex);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const checkIsChipSelected: ({ chipIndex, rowIndex, colIndex, selectedChip, }: Pick<
|
|
1
|
+
import { CellContext } from '../../types/index.js';
|
|
2
|
+
export declare const checkIsChipSelected: ({ chipIndex, rowIndex, colIndex, selectedChip, }: Pick<CellContext, "rowIndex" | "selectedChip" | "colIndex"> & {
|
|
3
3
|
chipIndex: number;
|
|
4
4
|
}) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { TableCellProps } from '@mui/material';
|
|
3
|
-
import type { Charge, TableMode,
|
|
3
|
+
import type { Charge, TableMode, CellContext } from '../../../types/index.js';
|
|
4
4
|
import type { ActionType, FlagType } from './ActionCell';
|
|
5
5
|
import { getGeographyBoxColor } from '../../../utils/index.js';
|
|
6
6
|
export type GeographyBoxVariant = keyof ReturnType<typeof getGeographyBoxColor>;
|
|
@@ -62,7 +62,7 @@ export interface AmountCellProps extends TableCellProps {
|
|
|
62
62
|
isTextShown?: boolean;
|
|
63
63
|
tableMode?: TableMode;
|
|
64
64
|
}
|
|
65
|
-
export interface DestinationCellProps extends TableCellProps,
|
|
65
|
+
export interface DestinationCellProps extends TableCellProps, CellContext {
|
|
66
66
|
destinationsCount?: number;
|
|
67
67
|
flagIcon?: string;
|
|
68
68
|
destinationsTooltip?: React.ReactNode;
|
|
@@ -15,7 +15,7 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
|
|
|
15
15
|
return null;
|
|
16
16
|
const value = selector ? selector({ row, index, value: row[column === null || column === void 0 ? void 0 : column.id] }) : row[column === null || column === void 0 ? void 0 : column.id];
|
|
17
17
|
const formattedValue = format ? format({ value, row, index }) : value;
|
|
18
|
-
return render ? (render({ row, column, index, value: row[column === null || column === void 0 ? void 0 : column.id],
|
|
18
|
+
return render ? (render({ row, column, index, value: row[column === null || column === void 0 ? void 0 : column.id], cellContext: { onChipClick: handleChipClick, rowIndex, colIndex, selectedChip } })) : (_jsx(_Fragment, { children: formattedValue }));
|
|
19
19
|
};
|
|
20
20
|
const content = useMemo(() => (_jsx(_Fragment, { children: columns.map((column, colIndex) => {
|
|
21
21
|
var _a, _b;
|
package/build/types/table.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface TableFooterProps extends BoxProps {
|
|
|
50
50
|
export interface TableChipProps {
|
|
51
51
|
onChipClick?: (rowIndex: number, columnIndex: number, event: React.MouseEvent, chipIndex: number, pinnedType?: 'start' | 'end') => void;
|
|
52
52
|
}
|
|
53
|
-
export interface
|
|
53
|
+
export interface CellContext {
|
|
54
54
|
onChipClick?: (event: React.MouseEvent, chipIndex: number) => void;
|
|
55
55
|
colIndex?: number;
|
|
56
56
|
rowIndex?: number;
|
|
@@ -61,7 +61,7 @@ export interface IRenderAttr<R, C> {
|
|
|
61
61
|
column: C;
|
|
62
62
|
index: number;
|
|
63
63
|
value: any;
|
|
64
|
-
|
|
64
|
+
cellContext?: CellContext;
|
|
65
65
|
}
|
|
66
66
|
export interface IFormatAttr<R> {
|
|
67
67
|
value: string | Record<string, any> | number;
|
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.31-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.31-test.17",
|
|
5
|
+
"testVersion": 17,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|