@tap-payments/os-micro-frontend-shared 0.1.31-test.24 → 0.1.31-test.27-test.28

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.
@@ -1,3 +1,3 @@
1
1
  import { MaskedTextProps } from './type';
2
- declare const MaskedText: ({ text, startLength, endLength, chipIndex, copyText, cellInfo }: MaskedTextProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const MaskedText: ({ text, startLength, endLength, chipIndex, copyText, selectionProps }: 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, cellInfo }) => {
4
+ const MaskedText = ({ text, startLength = 8, endLength = 4, chipIndex, copyText, selectionProps }) => {
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, cellInfo: cellInfo }, { children: [startText, _jsx("img", { src: passwordDotsIcon, alt: "passwordDots" }), endText] })));
7
+ return (_jsxs(StatusChipWithCopy, Object.assign({ chipIndex: chipIndex, copyText: copyText, selectionProps: selectionProps }, { children: [startText, _jsx("img", { src: passwordDotsIcon, alt: "passwordDots" }), endText] })));
8
8
  };
9
9
  export default MaskedText;
@@ -40,10 +40,6 @@ const StatusChip = (_a) => {
40
40
  };
41
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
42
  paddingRight: isSelected && copyText ? 12 : 0,
43
- }, transition: { delay: !isSelected ? 0.2 : 0 } }, { children: [_jsx(Wrapper, { children: children }), _jsx(AnimatePresence, { children: isSelected && copyText && (_jsx(CopyWrapper, { children: _jsx(motion.img, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, onClick: handleCopy, src: showCopy ? greenCheckIcon : blueCopyIcon, style: {
44
- height: 12,
45
- width: 12,
46
- objectFit: 'contain',
47
- } }) })) })] })) }))] })));
43
+ }, transition: { delay: !isSelected ? 0.2 : 0 } }, { children: [_jsx(Wrapper, { children: children }), _jsx(AnimatePresence, { children: isSelected && copyText && (_jsx(CopyWrapper, { children: _jsx(motion.img, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, onClick: handleCopy, src: showCopy ? greenCheckIcon : blueCopyIcon, style: Object.assign({ height: 12, width: 12, objectFit: 'contain' }, (showCopy && { filter: 'none' })) }) })) })] })) }))] })));
48
44
  };
49
45
  export default StatusChip;
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { StatusChipProps } from '../StatusChip';
3
- import { CellInfo } from '../../types/index.js';
3
+ import { SelectionProps } from '../../types/index.js';
4
4
  export interface StatusChipWithCopyProps extends StatusChipProps {
5
5
  copyText?: string;
6
6
  chipIndex: number;
7
- cellInfo: CellInfo;
7
+ selectionProps: SelectionProps;
8
8
  }
9
- declare function StatusChipWithCopy({ children, copyText, chipIndex, cellInfo: { onChipClick, rowIndex, colIndex, selectedChip }, ...reset }: StatusChipWithCopyProps): import("react/jsx-runtime").JSX.Element;
9
+ declare function StatusChipWithCopy({ children, copyText, chipIndex, selectionProps: { onClick, rowIndex, colIndex, selectedId }, ...reset }: StatusChipWithCopyProps): import("react/jsx-runtime").JSX.Element;
10
10
  declare const _default: import("react").MemoExoticComponent<typeof StatusChipWithCopy>;
11
11
  export default _default;
@@ -12,12 +12,12 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { memo, useMemo } from 'react';
14
14
  import StatusChip from '../StatusChip';
15
- import { checkIsChipSelected } from './utils';
15
+ import { checkIsSelected } from './utils';
16
16
  function StatusChipWithCopy(_a) {
17
- var { children, copyText, chipIndex, cellInfo: { onChipClick, rowIndex, colIndex, selectedChip } } = _a, reset = __rest(_a, ["children", "copyText", "chipIndex", "cellInfo"]);
18
- const isSelected = useMemo(() => checkIsChipSelected({ rowIndex, colIndex, selectedChip, chipIndex }), [rowIndex, colIndex, selectedChip, chipIndex]);
17
+ var { children, copyText, chipIndex, selectionProps: { onClick, rowIndex, colIndex, selectedId } } = _a, reset = __rest(_a, ["children", "copyText", "chipIndex", "selectionProps"]);
18
+ const isSelected = useMemo(() => checkIsSelected({ rowIndex, colIndex, selectedId, chipIndex }), [rowIndex, colIndex, selectedId, chipIndex]);
19
19
  return (_jsx(StatusChip, Object.assign({}, reset, { copyText: copyText, onClick: (e) => {
20
- onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(e, chipIndex);
20
+ onClick === null || onClick === void 0 ? void 0 : onClick(e, chipIndex);
21
21
  }, isSelected: isSelected }, { children: children })));
22
22
  }
23
23
  export default memo(StatusChipWithCopy);
@@ -1,4 +1,4 @@
1
- import { CellInfo } from '../../types/index.js';
2
- export declare const checkIsChipSelected: ({ chipIndex, rowIndex, colIndex, selectedChip, }: Pick<CellInfo, "rowIndex" | "selectedChip" | "colIndex"> & {
1
+ import { SelectionProps } from '../../types/index.js';
2
+ export declare const checkIsSelected: ({ chipIndex, rowIndex, colIndex, selectedId, }: Pick<SelectionProps, "rowIndex" | "selectedId" | "colIndex"> & {
3
3
  chipIndex: number;
4
4
  }) => boolean;
@@ -1,4 +1,4 @@
1
- export const checkIsChipSelected = ({ chipIndex, rowIndex, colIndex, selectedChip, }) => {
2
- const [, selectedRowIndex, selectedColumnIndex, selectedChipIndex] = (selectedChip !== null && selectedChip !== void 0 ? selectedChip : '').split('-');
1
+ export const checkIsSelected = ({ chipIndex, rowIndex, colIndex, selectedId, }) => {
2
+ const [, selectedRowIndex, selectedColumnIndex, selectedChipIndex] = (selectedId !== null && selectedId !== void 0 ? selectedId : '').split('-');
3
3
  return Number(selectedRowIndex) === rowIndex && Number(selectedColumnIndex) === colIndex && Number(selectedChipIndex) === chipIndex;
4
4
  };
@@ -2,18 +2,4 @@
2
2
  export declare const StyledContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
3
  ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
4
4
  }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
5
- export declare const StyledStatusChip: import("@emotion/styled").StyledComponent<{
6
- textColor?: string | undefined;
7
- bgColor?: string | undefined;
8
- borderColor?: string | undefined;
9
- disabled?: boolean | undefined;
10
- padding?: string | undefined;
11
- unknownText?: string | undefined;
12
- maxWidth?: string | undefined;
13
- isSelected?: boolean | undefined;
14
- copyText?: string | undefined;
15
- } & import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
16
- ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
17
- }, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
18
- children?: import("react").ReactNode;
19
- } & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
5
+ export declare const StyledStatusChip: import("@emotion/styled").StyledComponent<import("../StatusChipWithCopy").StatusChipWithCopyProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -1,12 +1,12 @@
1
1
  import { styled, Box } from '@mui/material';
2
- import StatusChip from '../StatusChip';
2
+ import StatusChipWithCopy from '../StatusChipWithCopy';
3
3
  export const StyledContainer = styled(Box)(() => ({
4
4
  display: 'flex',
5
5
  gap: '4px',
6
6
  alignItems: 'center',
7
7
  flexDirection: 'row',
8
8
  }));
9
- export const StyledStatusChip = styled(StatusChip)(() => ({
9
+ export const StyledStatusChip = styled(StatusChipWithCopy)(() => ({
10
10
  padding: '0.75px 12px',
11
11
  overflow: 'hidden',
12
12
  textOverflow: 'ellipsis',
@@ -1,12 +1,10 @@
1
1
  import type React from 'react';
2
- import type { BoxProps } from '@mui/material';
3
- export interface ChipConfig {
2
+ import type { BoxProps } from '@mui/material/Box';
3
+ import { StatusChipWithCopyProps } from '../StatusChipWithCopy';
4
+ export interface ChipConfig extends Omit<StatusChipWithCopyProps, 'content'> {
4
5
  key: string;
5
6
  content: React.ReactNode;
6
7
  sx?: object;
7
- onClick?: (event: React.MouseEvent) => void;
8
- copyText: string;
9
- isSelected?: boolean;
10
8
  }
11
9
  export interface StatusGroupChipsProps extends Omit<BoxProps, 'children'> {
12
10
  chips: ChipConfig[];
@@ -1,3 +1,3 @@
1
1
  import { DestinationCellProps } from '../type';
2
- declare function DestinationCell({ destinationsCount, destinationsTooltip, isTextShown, destination, destinationsAmount, hidden, iconDirection, tableMode, onChipClick, selectedChip, rowIndex, colIndex, ...props }: DestinationCellProps): import("react/jsx-runtime").JSX.Element | null;
2
+ declare function DestinationCell({ destinationsCount, destinationsTooltip, isTextShown, destination, destinationsAmount, hidden, iconDirection, tableMode, selectionProps, ...props }: DestinationCellProps): import("react/jsx-runtime").JSX.Element | null;
3
3
  export default DestinationCell;
@@ -19,7 +19,7 @@ import { TextLabel } from '../style';
19
19
  import { CurrencyIcon, StatusGroupChips } from '../../../index.js';
20
20
  function DestinationCell(_a) {
21
21
  var _b, _c, _d, _e, _f;
22
- var { destinationsCount, destinationsTooltip, isTextShown, destination, destinationsAmount, hidden, iconDirection, tableMode, onChipClick, selectedChip, rowIndex, colIndex } = _a, props = __rest(_a, ["destinationsCount", "destinationsTooltip", "isTextShown", "destination", "destinationsAmount", "hidden", "iconDirection", "tableMode", "onChipClick", "selectedChip", "rowIndex", "colIndex"]);
22
+ var { destinationsCount, destinationsTooltip, isTextShown, destination, destinationsAmount, hidden, iconDirection, tableMode, selectionProps } = _a, props = __rest(_a, ["destinationsCount", "destinationsTooltip", "isTextShown", "destination", "destinationsAmount", "hidden", "iconDirection", "tableMode", "selectionProps"]);
23
23
  const destinations = (destination === null || destination === void 0 ? void 0 : destination.destination) || [];
24
24
  const formattedAmount = formatAmount(destinationsAmount || 0);
25
25
  const firstDestinationFormattedAmount = formatAmount(((_b = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _b === void 0 ? void 0 : _b.amount) || 0);
@@ -27,18 +27,14 @@ function DestinationCell(_a) {
27
27
  if (isSheetView) {
28
28
  const sheetViewChips = destinations === null || destinations === void 0 ? void 0 : destinations.map((dest, index) => {
29
29
  const formattedDestAmount = formatAmount((dest === null || dest === void 0 ? void 0 : dest.amount) || 0);
30
- const [, selectedRowIndex, selectedColumnIndex, selectedChipIndex] = (selectedChip !== null && selectedChip !== void 0 ? selectedChip : '').split('-');
31
- const isSelected = Number(selectedRowIndex) === rowIndex && Number(selectedColumnIndex) === colIndex && Number(selectedChipIndex) === index;
32
30
  return {
33
31
  key: `destination-${(dest === null || dest === void 0 ? void 0 : dest.id) || index}`,
34
32
  content: (_jsxs(_Fragment, { children: [_jsxs("div", { children: [dest === null || dest === void 0 ? void 0 : dest.id, " |"] }), _jsx(CurrencyIcon, { currency: dest === null || dest === void 0 ? void 0 : dest.currency }), _jsxs("span", { children: [formattedDestAmount.integerAmount, ".", formattedDestAmount.decimalAmount] })] })),
35
- isSelected,
36
- onClick: (e) => {
37
- onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(e, index);
38
- },
33
+ chipIndex: index,
34
+ selectionProps,
39
35
  copyText: `${formattedDestAmount.integerAmount}.${formattedDestAmount.decimalAmount}`,
40
36
  };
41
- }, [selectedChip, rowIndex, colIndex]);
37
+ }, [selectionProps]);
42
38
  return (_jsx(Box, Object.assign({}, props, { children: _jsx(StatusGroupChips, { chips: sheetViewChips }) })));
43
39
  }
44
40
  if (!destinationsCount || hidden) {
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type { TableCellProps } from '@mui/material';
3
- import type { Charge, TableMode, CellInfo } from '../../../types/index.js';
3
+ import type { Charge, TableMode, SelectionProps } 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, CellInfo {
65
+ export interface DestinationCellProps extends TableCellProps {
66
66
  destinationsCount?: number;
67
67
  flagIcon?: string;
68
68
  destinationsTooltip?: React.ReactNode;
@@ -91,6 +91,7 @@ export interface DestinationCellProps extends TableCellProps, CellInfo {
91
91
  };
92
92
  iconDirection?: 'left' | 'right';
93
93
  tableMode?: TableMode;
94
+ selectionProps: SelectionProps;
94
95
  }
95
96
  export interface ActionCellProps extends TableCellProps {
96
97
  row?: unknown;
@@ -15,7 +15,13 @@ 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], cellInfo: { onChipClick: handleChipClick, rowIndex, colIndex, selectedChip } })) : (_jsx(_Fragment, { children: formattedValue }));
18
+ return render ? (render({
19
+ row,
20
+ column,
21
+ index,
22
+ value: row[column === null || column === void 0 ? void 0 : column.id],
23
+ selectionProps: { onClick: handleChipClick, rowIndex, colIndex, selectedId: selectedChip },
24
+ })) : (_jsx(_Fragment, { children: formattedValue }));
19
25
  };
20
26
  const content = useMemo(() => (_jsx(_Fragment, { children: columns.map((column, colIndex) => {
21
27
  var _a, _b;
@@ -50,18 +50,18 @@ 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 CellInfo {
54
- onChipClick?: (event: React.MouseEvent, chipIndex: number) => void;
53
+ export interface SelectionProps {
54
+ onClick?: (event: React.MouseEvent, index: number) => void;
55
55
  colIndex?: number;
56
56
  rowIndex?: number;
57
- selectedChip?: string | null;
57
+ selectedId?: string | null;
58
58
  }
59
59
  export interface IRenderAttr<R, C> {
60
60
  row: R;
61
61
  column: C;
62
62
  index: number;
63
63
  value: any;
64
- cellInfo?: CellInfo;
64
+ selectionProps?: SelectionProps;
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.24",
5
- "testVersion": 24,
4
+ "version": "0.1.31-test.27-test.28",
5
+ "testVersion": 28,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",