@tap-payments/os-micro-frontend-shared 0.1.30 → 0.1.31-test.11

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.
Files changed (48) hide show
  1. package/build/components/MaskedText/MaskedText.d.ts +1 -1
  2. package/build/components/MaskedText/MaskedText.js +3 -3
  3. package/build/components/MaskedText/type.d.ts +2 -1
  4. package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.d.ts +3 -0
  5. package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.js +43 -0
  6. package/build/components/RightLeftExpandingCenterChip/index.d.ts +2 -0
  7. package/build/components/RightLeftExpandingCenterChip/index.js +2 -0
  8. package/build/components/RightLeftExpandingCenterChip/style.d.ts +3415 -0
  9. package/build/components/RightLeftExpandingCenterChip/style.js +104 -0
  10. package/build/components/RightLeftExpandingCenterChip/type.d.ts +10 -0
  11. package/build/components/RightLeftExpandingCenterChip/type.js +1 -0
  12. package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.d.ts +31 -0
  13. package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.js +156 -0
  14. package/build/components/StatusChip/StatusChip.d.ts +1 -1
  15. package/build/components/StatusChip/StatusChip.js +37 -4
  16. package/build/components/StatusChip/style.d.ts +10 -3
  17. package/build/components/StatusChip/style.js +14 -36
  18. package/build/components/StatusChip/type.d.ts +2 -0
  19. package/build/components/StatusChipWithCopy/StatusChipWithCopy.d.ts +11 -0
  20. package/build/components/StatusChipWithCopy/StatusChipWithCopy.js +23 -0
  21. package/build/components/StatusChipWithCopy/index.d.ts +4 -0
  22. package/build/components/StatusChipWithCopy/index.js +4 -0
  23. package/build/components/StatusChipWithCopy/utils.d.ts +4 -0
  24. package/build/components/StatusChipWithCopy/utils.js +4 -0
  25. package/build/components/StatusGroupChips/style.d.ts +2 -0
  26. package/build/components/StatusGroupChips/type.d.ts +2 -0
  27. package/build/components/TableCells/CustomCells/DestinationCell/DestinationCell.d.ts +1 -1
  28. package/build/components/TableCells/CustomCells/DestinationCell/DestinationCell.js +12 -11
  29. package/build/components/TableCells/CustomCells/type.d.ts +2 -2
  30. package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +3 -1
  31. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.d.ts +2 -0
  32. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.js +19 -0
  33. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts +7 -3
  34. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js +5 -3
  35. package/build/components/VirtualTables/components/TableRow.d.ts +4 -2
  36. package/build/components/VirtualTables/components/TableRow.js +11 -5
  37. package/build/components/VirtualTables/components/style.js +1 -1
  38. package/build/components/VirtualTables/components/virtualScroll/ListItemWrapper.js +1 -1
  39. package/build/components/index.d.ts +1 -0
  40. package/build/components/index.js +1 -0
  41. package/build/constants/assets.d.ts +3 -0
  42. package/build/constants/assets.js +3 -0
  43. package/build/constants/table/cell/chargeTableCellWidth.d.ts +5 -0
  44. package/build/constants/table/cell/chargeTableCellWidth.js +5 -0
  45. package/build/types/table.d.ts +10 -0
  46. package/build/utils/style.d.ts +6 -0
  47. package/build/utils/style.js +1 -1
  48. package/package.json +2 -2
@@ -0,0 +1,104 @@
1
+ import { styled } from '@mui/material/styles';
2
+ import { motion } from 'framer-motion';
3
+ export const CHIP_GAP = 3;
4
+ export const CenterIconWrapper = styled(motion.div)(({ theme }) => ({
5
+ display: 'flex',
6
+ alignItems: 'center',
7
+ justifyContent: 'center',
8
+ gap: 0,
9
+ minWidth: 0,
10
+ height: 'auto',
11
+ lineHeight: 1,
12
+ position: 'relative',
13
+ zIndex: 1001,
14
+ fontSize: '12px',
15
+ color: theme.palette.text.primary,
16
+ }));
17
+ export const CenterShiftWrapper = styled(motion.div)(() => ({
18
+ display: 'inline-flex',
19
+ }));
20
+ export const LeftExpandIcon = styled(motion.span)(({ theme }) => ({
21
+ position: 'static',
22
+ display: 'inline-flex',
23
+ alignItems: 'center',
24
+ justifyContent: 'center',
25
+ width: 0,
26
+ overflow: 'visible',
27
+ margin: 0,
28
+ padding: 0,
29
+ fontSize: '10px',
30
+ lineHeight: 1,
31
+ color: theme.palette.text.secondary,
32
+ fontWeight: 'bold',
33
+ userSelect: 'none',
34
+ }));
35
+ export const RightExpandIcon = styled(motion.span)(({ theme }) => ({
36
+ position: 'static',
37
+ display: 'inline-flex',
38
+ alignItems: 'center',
39
+ justifyContent: 'center',
40
+ width: 0,
41
+ overflow: 'visible',
42
+ margin: 0,
43
+ padding: 0,
44
+ fontSize: '10px',
45
+ lineHeight: 1,
46
+ color: theme.palette.text.secondary,
47
+ fontWeight: 'bold',
48
+ userSelect: 'none',
49
+ }));
50
+ export const ExpandedSection = styled(motion.div)(({ side }) => (Object.assign(Object.assign(Object.assign({ position: 'absolute', display: 'flex', alignItems: 'center' }, (side === 'left' ? { right: '100%', flexDirection: 'row-reverse', transformOrigin: 'right center' } : {})), (side === 'right' ? { left: '100%', flexDirection: 'row', transformOrigin: 'left center' } : {})), { top: '50%', transform: 'translateY(-50%)', gap: 0, pointerEvents: 'auto', overflow: 'visible' })));
51
+ export const HoverBridge = styled('div')(({ side }) => (Object.assign(Object.assign({ position: 'absolute', top: 0, bottom: 0 }, (side === 'left' ? { right: '100%' } : { left: '100%' })), { pointerEvents: 'auto', background: 'transparent' })));
52
+ export const PeekContainer = styled(motion.div)(() => ({
53
+ position: 'relative',
54
+ display: 'inline-flex',
55
+ alignItems: 'center',
56
+ justifyContent: 'center',
57
+ height: 24,
58
+ overflow: 'visible',
59
+ }));
60
+ const baseChipStyles = (theme) => ({
61
+ border: `1px solid ${theme.palette.divider}`,
62
+ borderRadius: '12px',
63
+ backgroundColor: theme.palette.background.paper,
64
+ paddingInline: '8px',
65
+ height: '24px',
66
+ display: 'flex',
67
+ alignItems: 'center',
68
+ justifyContent: 'center',
69
+ lineHeight: 1,
70
+ fontSize: 12,
71
+ boxSizing: 'border-box',
72
+ whiteSpace: 'nowrap',
73
+ overflow: 'visible',
74
+ });
75
+ export const CenterChip = styled(motion.div)(({ theme }) => (Object.assign(Object.assign({}, baseChipStyles(theme)), { position: 'relative', zIndex: 2, minWidth: 24, flex: '0 0 auto', display: 'inline-flex', overflow: 'hidden', willChange: 'transform' })));
76
+ export const CenterContent = styled(motion.span)(() => ({
77
+ display: 'inline-flex',
78
+ alignItems: 'center',
79
+ transform: 'translateZ(0)',
80
+ }));
81
+ export const ExpandableContainer = styled(motion.span)(() => ({
82
+ display: 'inline-flex',
83
+ whiteSpace: 'nowrap',
84
+ overflow: 'hidden',
85
+ boxSizing: 'border-box',
86
+ willChange: 'width',
87
+ }));
88
+ export const ExpandableInner = styled(motion.span)(() => ({
89
+ display: 'inline-flex',
90
+ whiteSpace: 'nowrap',
91
+ paddingLeft: `${CHIP_GAP}px`,
92
+ }));
93
+ export const LeftPeekChip = styled(motion.div)(({ theme }) => (Object.assign(Object.assign({}, baseChipStyles(theme)), { position: 'absolute', left: 0, zIndex: 1, pointerEvents: 'none', minWidth: 24, paddingInline: 0 })));
94
+ export const RightPeekChip = styled(motion.div)(({ theme }) => (Object.assign(Object.assign({}, baseChipStyles(theme)), { position: 'absolute', right: 0, zIndex: 1, pointerEvents: 'none', minWidth: 24, paddingInline: 0 })));
95
+ export const ExpandChip = styled(motion.div)(({ theme }) => (Object.assign(Object.assign({}, baseChipStyles(theme)), { minWidth: 24, flex: '0 0 auto', display: 'inline-flex' })));
96
+ export const tableCellSx = {
97
+ position: 'relative',
98
+ overflow: 'visible',
99
+ zIndex: 101,
100
+ display: 'flex',
101
+ alignItems: 'center',
102
+ justifyContent: 'center',
103
+ minHeight: '20px',
104
+ };
@@ -0,0 +1,10 @@
1
+ import type React from 'react';
2
+ import type { SxProps } from '@mui/material';
3
+ export interface RightLeftExpandingCenterChipProps {
4
+ leftIcons?: React.ReactNode[];
5
+ rightIcons?: React.ReactNode[];
6
+ centerIcon: React.ReactNode;
7
+ expandableCenter?: React.ReactNode;
8
+ sx?: SxProps;
9
+ expandedZIndex?: number;
10
+ }
@@ -0,0 +1,31 @@
1
+ import { type ReactNode } from 'react';
2
+ export declare const DEFAULT_CHIP_MIN_WIDTH = 24;
3
+ export type UseRightLeftExpandingCenterChipArgs = {
4
+ leftIcons: ReactNode[];
5
+ rightIcons: ReactNode[];
6
+ centerIcon: ReactNode;
7
+ expandableCenter?: ReactNode;
8
+ };
9
+ export declare function useRightLeftExpandingCenterChip({ leftIcons, rightIcons, centerIcon, expandableCenter }: UseRightLeftExpandingCenterChipArgs): {
10
+ isHovering: boolean;
11
+ handleMouseEnter: () => void;
12
+ handleMouseLeave: () => void;
13
+ centerWrapRef: import("react").MutableRefObject<HTMLDivElement | null>;
14
+ centerContentRef: import("react").MutableRefObject<HTMLSpanElement | null>;
15
+ centerChipRef: import("react").MutableRefObject<HTMLDivElement | null>;
16
+ anchors: {
17
+ left: number;
18
+ right: number;
19
+ };
20
+ leftChipRefs: import("react").MutableRefObject<(HTMLDivElement | null)[]>;
21
+ rightChipRefs: import("react").MutableRefObject<(HTMLDivElement | null)[]>;
22
+ leftOffsets: number[];
23
+ rightOffsets: number[];
24
+ expandableInnerRef: import("react").MutableRefObject<HTMLSpanElement | null>;
25
+ expandableWidth: number;
26
+ expandedMV: import("framer-motion").MotionValue<number>;
27
+ shiftX: import("framer-motion").MotionValue<number>;
28
+ rightShift: number;
29
+ leftHoverWidth: number;
30
+ rightHoverWidth: number;
31
+ };
@@ -0,0 +1,156 @@
1
+ import { useRef, useEffect, useState, useMemo, useCallback } from 'react';
2
+ import { animate, useMotionValue, useTransform } from 'framer-motion';
3
+ import { CHIP_GAP } from './style';
4
+ export const DEFAULT_CHIP_MIN_WIDTH = 24;
5
+ export function useRightLeftExpandingCenterChip({ leftIcons, rightIcons, centerIcon, expandableCenter }) {
6
+ const [isHovering, setIsHovering] = useState(false);
7
+ const [anchors, setAnchors] = useState({ left: 0, right: 0 });
8
+ const [leftWidths, setLeftWidths] = useState([]);
9
+ const [rightWidths, setRightWidths] = useState([]);
10
+ const [expandableWidth, setExpandableWidth] = useState(0);
11
+ const hoverTimeoutRef = useRef(null);
12
+ const centerWrapRef = useRef(null);
13
+ const centerContentRef = useRef(null);
14
+ const centerChipRef = useRef(null);
15
+ const leftChipRefs = useRef([]);
16
+ const rightChipRefs = useRef([]);
17
+ const expandableInnerRef = useRef(null);
18
+ const resizeRaf = useRef(null);
19
+ const expandedMV = useMotionValue(0);
20
+ const shiftX = useTransform(expandedMV, (v) => v / 2);
21
+ const leftOffsets = useMemo(() => {
22
+ if (!leftWidths.length)
23
+ return [];
24
+ const acc = [];
25
+ let sum = CHIP_GAP + leftWidths[0] / 2;
26
+ acc.push(sum);
27
+ for (let i = 1; i < leftWidths.length; i++) {
28
+ sum += leftWidths[i - 1] / 2 + CHIP_GAP + leftWidths[i] / 2;
29
+ acc.push(sum);
30
+ }
31
+ return acc;
32
+ }, [leftWidths]);
33
+ const rightOffsets = useMemo(() => {
34
+ if (!rightWidths.length)
35
+ return [];
36
+ const acc = [];
37
+ let sum = CHIP_GAP + rightWidths[0] / 2;
38
+ acc.push(sum);
39
+ for (let i = 1; i < rightWidths.length; i++) {
40
+ sum += rightWidths[i - 1] / 2 + CHIP_GAP + rightWidths[i] / 2;
41
+ acc.push(sum);
42
+ }
43
+ return acc;
44
+ }, [rightWidths]);
45
+ const rightShift = isHovering && expandableCenter ? expandableWidth + CHIP_GAP : 0;
46
+ const maxRightShift = expandableCenter ? expandableWidth + CHIP_GAP : 0;
47
+ const handleMouseEnter = useCallback(() => {
48
+ if (hoverTimeoutRef.current)
49
+ clearTimeout(hoverTimeoutRef.current);
50
+ setIsHovering(true);
51
+ }, []);
52
+ const handleMouseLeave = useCallback(() => {
53
+ if (hoverTimeoutRef.current)
54
+ clearTimeout(hoverTimeoutRef.current);
55
+ hoverTimeoutRef.current = setTimeout(() => setIsHovering(false), 120);
56
+ }, []);
57
+ const measureAnchors = useCallback(() => {
58
+ var _a;
59
+ const wrap = centerWrapRef.current;
60
+ const chip = centerChipRef.current;
61
+ const content = centerContentRef.current;
62
+ if (!wrap)
63
+ return;
64
+ const wrapRect = wrap.getBoundingClientRect();
65
+ const targetRect = (_a = (chip !== null && chip !== void 0 ? chip : content)) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
66
+ if (!targetRect)
67
+ return;
68
+ const left = targetRect.left - wrapRect.left;
69
+ const right = targetRect.right - wrapRect.left;
70
+ setAnchors({ left, right });
71
+ }, []);
72
+ const measureStackChipWidths = useCallback(() => {
73
+ setLeftWidths(leftChipRefs.current.map((el) => (el ? el.offsetWidth : DEFAULT_CHIP_MIN_WIDTH)));
74
+ setRightWidths(rightChipRefs.current.map((el) => (el ? el.offsetWidth : DEFAULT_CHIP_MIN_WIDTH)));
75
+ }, []);
76
+ const measureExpandableWidth = useCallback(() => {
77
+ var _a, _b;
78
+ setExpandableWidth((_b = (_a = expandableInnerRef.current) === null || _a === void 0 ? void 0 : _a.scrollWidth) !== null && _b !== void 0 ? _b : 0);
79
+ }, []);
80
+ const onResize = useCallback(() => {
81
+ if (resizeRaf.current)
82
+ cancelAnimationFrame(resizeRaf.current);
83
+ resizeRaf.current = requestAnimationFrame(() => {
84
+ measureAnchors();
85
+ measureStackChipWidths();
86
+ measureExpandableWidth();
87
+ });
88
+ }, [measureAnchors, measureStackChipWidths, measureExpandableWidth]);
89
+ useEffect(() => {
90
+ return () => {
91
+ if (hoverTimeoutRef.current)
92
+ clearTimeout(hoverTimeoutRef.current);
93
+ };
94
+ }, []);
95
+ useEffect(() => {
96
+ measureAnchors();
97
+ }, [centerIcon, measureAnchors]);
98
+ useEffect(() => {
99
+ measureStackChipWidths();
100
+ }, [leftIcons, rightIcons, measureStackChipWidths]);
101
+ useEffect(() => {
102
+ measureExpandableWidth();
103
+ }, [expandableCenter, measureExpandableWidth]);
104
+ useEffect(() => {
105
+ onResize();
106
+ window.addEventListener('resize', onResize);
107
+ return () => {
108
+ window.removeEventListener('resize', onResize);
109
+ if (resizeRaf.current)
110
+ cancelAnimationFrame(resizeRaf.current);
111
+ };
112
+ }, [onResize]);
113
+ useEffect(() => {
114
+ const target = isHovering && expandableCenter ? expandableWidth + CHIP_GAP : 0;
115
+ const controls = animate(expandedMV, target, { duration: 0.2, ease: 'easeOut' });
116
+ return () => controls.stop();
117
+ }, [isHovering, expandableCenter, expandableWidth, expandedMV]);
118
+ const leftHoverWidth = useMemo(() => {
119
+ var _a;
120
+ if (!leftOffsets.length)
121
+ return 0;
122
+ const last = leftOffsets.length - 1;
123
+ const lastWidth = (_a = leftWidths[last]) !== null && _a !== void 0 ? _a : DEFAULT_CHIP_MIN_WIDTH;
124
+ const farthest = leftOffsets[last] + lastWidth / 2;
125
+ return farthest + CHIP_GAP;
126
+ }, [leftOffsets, leftWidths]);
127
+ const rightHoverWidth = useMemo(() => {
128
+ var _a;
129
+ if (!rightOffsets.length)
130
+ return 0;
131
+ const last = rightOffsets.length - 1;
132
+ const lastWidth = (_a = rightWidths[last]) !== null && _a !== void 0 ? _a : DEFAULT_CHIP_MIN_WIDTH;
133
+ const farthest = maxRightShift + rightOffsets[last] + lastWidth / 2;
134
+ return farthest + CHIP_GAP;
135
+ }, [rightOffsets, rightWidths, maxRightShift]);
136
+ return {
137
+ isHovering,
138
+ handleMouseEnter,
139
+ handleMouseLeave,
140
+ centerWrapRef,
141
+ centerContentRef,
142
+ centerChipRef,
143
+ anchors,
144
+ leftChipRefs,
145
+ rightChipRefs,
146
+ leftOffsets,
147
+ rightOffsets,
148
+ expandableInnerRef,
149
+ expandableWidth,
150
+ expandedMV,
151
+ shiftX,
152
+ rightShift,
153
+ leftHoverWidth,
154
+ rightHoverWidth,
155
+ };
156
+ }
@@ -1,3 +1,3 @@
1
1
  import { ChipProps } from './type';
2
- declare const StatusChip: ({ children, unknownText, ...props }: ChipProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const StatusChip: ({ children, unknownText, copyText, ...props }: ChipProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default StatusChip;
@@ -9,16 +9,49 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useState } from 'react';
14
+ import Box from '@mui/material/Box';
13
15
  import { useTranslation } from 'react-i18next';
16
+ import { AnimatePresence, motion } from 'framer-motion';
17
+ import { copyText as copyTextHandler } from '../../utils/index.js';
18
+ import { blueCopyIcon, greenCheckIcon } from '../../constants/index.js';
14
19
  import { unknownGeographyColors } from './constants';
15
- import { ChipStyled } from './style';
20
+ import { ChipStyled, Wrapper } from './style';
16
21
  const StatusChip = (_a) => {
17
- var { children, unknownText } = _a, props = __rest(_a, ["children", "unknownText"]);
22
+ var { children, unknownText, copyText } = _a, props = __rest(_a, ["children", "unknownText", "copyText"]);
23
+ const [showCopy, setShowCopy] = useState(false);
18
24
  const { t } = useTranslation();
19
25
  if (!children) {
20
26
  return (_jsx(ChipStyled, Object.assign({}, unknownGeographyColors, props, { children: unknownText ? t(unknownText) : t('unknown') })));
21
27
  }
22
- return _jsx(ChipStyled, Object.assign({}, props, { children: children }));
28
+ const handleCopy = (e) => {
29
+ e.stopPropagation();
30
+ if (copyText) {
31
+ setShowCopy(true);
32
+ copyTextHandler(copyText);
33
+ const timer = setTimeout(() => {
34
+ setShowCopy(false);
35
+ }, 2000);
36
+ return () => {
37
+ clearTimeout(timer);
38
+ };
39
+ }
40
+ };
41
+ return (_jsxs(Box, Object.assign({ sx: { position: 'relative', zIndex: props.isSelected ? 3 : 0 } }, { children: [_jsx(ChipStyled, Object.assign({}, props, { sx: { visibility: 'hidden', pointerEvents: 'none' } }, { children: _jsx(Wrapper, { children: children }) })), _jsx(motion.div, Object.assign({ layout: true, transition: {
42
+ type: 'spring',
43
+ stiffness: 180,
44
+ damping: 25,
45
+ mass: 0.4,
46
+ } }, { children: _jsxs(ChipStyled, Object.assign({}, props, { sx: {
47
+ position: 'absolute',
48
+ top: 0,
49
+ left: 0,
50
+ zIndex: props.isSelected ? 3 : 0,
51
+ } }, { children: [_jsx(Wrapper, { children: children }), _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: {
52
+ height: 12,
53
+ width: 12,
54
+ objectFit: 'contain',
55
+ } })) }))] })) }))] })));
23
56
  };
24
57
  export default StatusChip;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- export declare const ChipStyled: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
2
+ export declare const ChipStyled: 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
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> & {
4
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
5
5
  textColor?: string | undefined;
6
6
  bgColor?: string | undefined;
7
7
  borderColor?: string | undefined;
@@ -9,8 +9,15 @@ export declare const ChipStyled: import("@emotion/styled").StyledComponent<impor
9
9
  padding?: string | undefined;
10
10
  unknownText?: string | undefined;
11
11
  maxWidth?: string | undefined;
12
+ isSelected?: boolean | undefined;
13
+ copyText?: string | undefined;
12
14
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
13
15
  ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
14
- }, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
16
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & {
15
17
  children?: import("react").ReactNode;
18
+ } & {
19
+ isSelected?: boolean | undefined;
16
20
  }, {}, {}>;
21
+ export declare const Wrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
22
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
23
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
@@ -1,38 +1,16 @@
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 { Box, styled } from '@mui/material';
1
+ import Box from '@mui/material/Box';
2
+ import { styled } from '@mui/material/styles';
3
+ import { SELECTION_COLORS } from '../../utils/index.js';
13
4
  export const ChipStyled = styled(Box, {
14
- shouldForwardProp: (prop) => !['textColor', 'bgColor', 'borderColor', 'disabled', 'padding', 'maxWidth'].includes(prop),
15
- })((_a) => {
16
- var { theme } = _a, props = __rest(_a, ["theme"]);
17
- const { textColor = theme.palette.text.primary, bgColor = '#EFF1F2', borderColor = '#EFF1F2', disabled = false, padding, maxWidth } = props;
18
- return {
19
- display: 'block',
20
- textAlign: 'center',
21
- verticalAlign: 'middle',
22
- height: '18px',
23
- padding: padding || '0px 9.5px',
24
- borderRadius: '30px',
25
- border: `1px solid ${borderColor}`,
26
- backgroundColor: bgColor,
27
- color: textColor,
28
- cursor: disabled ? 'not-allowed' : 'pointer',
29
- opacity: disabled ? 0.5 : 1,
30
- whiteSpace: 'nowrap',
31
- fontSize: '11px',
32
- minWidth: '67px',
33
- maxWidth: maxWidth || 'none',
34
- overflow: 'hidden',
35
- textOverflow: maxWidth ? 'ellipsis' : 'unset',
36
- boxSizing: 'border-box',
37
- };
5
+ shouldForwardProp: (prop) => !['textColor', 'bgColor', 'borderColor', 'disabled', 'padding', 'maxWidth', 'isSelected'].includes(prop),
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: padding || '0px 9.5px', 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', transition: 'width 0.5s ease-in-out' }, (isSelected && { color: SELECTION_COLORS.primary, borderColor: SELECTION_COLORS.primary }));
38
8
  });
9
+ export const Wrapper = styled(Box)(() => ({
10
+ display: 'flex',
11
+ alignItems: 'center',
12
+ justifyContent: 'center',
13
+ gap: '4px',
14
+ minWidth: 46,
15
+ textAlign: 'center',
16
+ }));
@@ -8,4 +8,6 @@ export type ChipProps = PropsWithChildren<{
8
8
  padding?: string;
9
9
  unknownText?: string;
10
10
  maxWidth?: string;
11
+ isSelected?: boolean;
12
+ copyText?: string;
11
13
  } & BoxProps>;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { StatusChipProps } from '../StatusChip';
3
+ import { ChipSelection } from '../../types/index.js';
4
+ export interface StatusChipWithCopyProps extends StatusChipProps {
5
+ copyText?: string;
6
+ chipIndex: number;
7
+ chipSelection: ChipSelection;
8
+ }
9
+ declare function StatusChipWithCopy({ children, copyText, chipIndex, chipSelection: { onChipClick, rowIndex, colIndex, selectedChip }, ...reset }: StatusChipWithCopyProps): import("react/jsx-runtime").JSX.Element;
10
+ declare const _default: import("react").MemoExoticComponent<typeof StatusChipWithCopy>;
11
+ export default _default;
@@ -0,0 +1,23 @@
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 StatusChip from '../StatusChip';
15
+ import { checkIsChipSelected } from './utils';
16
+ function StatusChipWithCopy(_a) {
17
+ var { children, copyText, chipIndex, chipSelection: { onChipClick, rowIndex, colIndex, selectedChip } } = _a, reset = __rest(_a, ["children", "copyText", "chipIndex", "chipSelection"]);
18
+ const isSelected = useMemo(() => checkIsChipSelected({ rowIndex, colIndex, selectedChip, chipIndex }), [rowIndex, colIndex, selectedChip, chipIndex]);
19
+ return (_jsx(StatusChip, Object.assign({}, reset, { copyText: copyText, onClick: (e) => {
20
+ onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(e, chipIndex);
21
+ }, isSelected: isSelected }, { children: children })));
22
+ }
23
+ export default memo(StatusChipWithCopy);
@@ -0,0 +1,4 @@
1
+ import StatusChipWithCopy from './StatusChipWithCopy';
2
+ export * from './StatusChipWithCopy';
3
+ export * from './utils';
4
+ export default StatusChipWithCopy;
@@ -0,0 +1,4 @@
1
+ import StatusChipWithCopy from './StatusChipWithCopy';
2
+ export * from './StatusChipWithCopy';
3
+ export * from './utils';
4
+ export default StatusChipWithCopy;
@@ -0,0 +1,4 @@
1
+ import { ChipSelection } from '../../types/index.js';
2
+ export declare const checkIsChipSelected: ({ chipIndex, rowIndex, colIndex, selectedChip, }: Pick<ChipSelection, "rowIndex" | "selectedChip" | "colIndex"> & {
3
+ chipIndex: number;
4
+ }) => boolean;
@@ -0,0 +1,4 @@
1
+ export const checkIsChipSelected = ({ chipIndex, rowIndex, colIndex, selectedChip, }) => {
2
+ const [, selectedRowIndex, selectedColumnIndex, selectedChipIndex] = (selectedChip !== null && selectedChip !== void 0 ? selectedChip : '').split('-');
3
+ return Number(selectedRowIndex) === rowIndex && Number(selectedColumnIndex) === colIndex && Number(selectedChipIndex) === chipIndex;
4
+ };
@@ -10,6 +10,8 @@ export declare const StyledStatusChip: import("@emotion/styled").StyledComponent
10
10
  padding?: string | undefined;
11
11
  unknownText?: string | undefined;
12
12
  maxWidth?: string | undefined;
13
+ isSelected?: boolean | undefined;
14
+ copyText?: string | undefined;
13
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"> & {
14
16
  ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
15
17
  }, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
@@ -5,6 +5,8 @@ export interface ChipConfig {
5
5
  content: React.ReactNode;
6
6
  sx?: object;
7
7
  onClick?: (event: React.MouseEvent) => void;
8
+ copyText: string;
9
+ isSelected?: boolean;
8
10
  }
9
11
  export interface StatusGroupChipsProps extends Omit<BoxProps, 'children'> {
10
12
  chips: ChipConfig[];
@@ -1,3 +1,3 @@
1
1
  import { DestinationCellProps } from '../type';
2
- declare function DestinationCell({ destinationsCount, destinationsTooltip, isTextShown, destination, destinationsAmount, hidden, iconDirection, tableMode, ...props }: DestinationCellProps): import("react/jsx-runtime").JSX.Element | null;
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;
3
3
  export default DestinationCell;
@@ -10,16 +10,16 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import Box from '@mui/material/Box';
13
14
  import Tooltip from '../../../Tooltip';
14
15
  import { destinationSolidIcon } from '../../../../constants/index.js';
15
16
  import { formatAmount } from '../../../../utils/index.js';
16
17
  import { DestinationCellContainer, DestinationCount, StyledDestinationCell, StyledDestinationIcon } from './styled';
17
- import TableCell from '../../TableCell';
18
18
  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 } = _a, props = __rest(_a, ["destinationsCount", "destinationsTooltip", "isTextShown", "destination", "destinationsAmount", "hidden", "iconDirection", "tableMode"]);
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"]);
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,15 +27,19 @@ 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;
30
32
  return {
31
33
  key: `destination-${(dest === null || dest === void 0 ? void 0 : dest.id) || index}`,
32
34
  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
+ },
39
+ copyText: `${formattedDestAmount.integerAmount}.${formattedDestAmount.decimalAmount}`,
33
40
  };
34
- }, []);
35
- return (_jsx(TableCell, Object.assign({ sx: {
36
- width: 'fit-content',
37
- overflow: 'visible',
38
- } }, props, { children: _jsx(StatusGroupChips, { chips: sheetViewChips }) })));
41
+ }, [selectedChip, rowIndex, colIndex]);
42
+ return (_jsx(Box, Object.assign({}, props, { children: _jsx(StatusGroupChips, { chips: sheetViewChips }) })));
39
43
  }
40
44
  if (!destinationsCount || hidden) {
41
45
  return null;
@@ -45,9 +49,6 @@ function DestinationCell(_a) {
45
49
  justifyContent: 'flex-start',
46
50
  height: 'auto',
47
51
  } }, { children: destinationsCount > 1 ? (_jsxs("div", { children: ["Destination ", (_c = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _c === void 0 ? void 0 : _c.id, " - ", _jsx(CurrencyIcon, { currency: (_d = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _d === void 0 ? void 0 : _d.currency }), ' ', firstDestinationFormattedAmount.integerAmount, ".", firstDestinationFormattedAmount.decimalAmount, " +", destinationsCount - 1] })) : (_jsxs("div", { children: ["Destination ", (_e = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _e === void 0 ? void 0 : _e.id, " - ", _jsx(CurrencyIcon, { currency: (_f = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _f === void 0 ? void 0 : _f.currency }), " ", formattedAmount.integerAmount, ".", formattedAmount.decimalAmount] })) })));
48
- return (_jsx(TableCell, Object.assign({ sx: {
49
- width: 'fit-content',
50
- overflow: 'visible',
51
- } }, props, { children: _jsx(Tooltip, Object.assign({ title: destinationsTooltip }, { children: !isTextShown ? (_jsxs(StyledDestinationCell, Object.assign({ tableMode: tableMode }, { children: [_jsx(StyledDestinationIcon, { src: destinationSolidIcon, pointLeft: iconDirection === 'left' }), destinationsCount > 1 && (_jsx(DestinationCellContainer, Object.assign({ destinationsCount: 1 }, { children: _jsx(DestinationCount, { children: destinationsCount }) })))] }))) : (textView) })) })));
52
+ return (_jsx(Box, Object.assign({}, props, { children: _jsx(Tooltip, Object.assign({ title: destinationsTooltip }, { children: !isTextShown ? (_jsxs(StyledDestinationCell, Object.assign({ tableMode: tableMode }, { children: [_jsx(StyledDestinationIcon, { src: destinationSolidIcon, pointLeft: iconDirection === 'left' }), destinationsCount > 1 && (_jsx(DestinationCellContainer, Object.assign({ destinationsCount: 1 }, { children: _jsx(DestinationCount, { children: destinationsCount }) })))] }))) : (textView) })) })));
52
53
  }
53
54
  export default DestinationCell;
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type { TableCellProps } from '@mui/material';
3
- import type { Charge, TableMode } from '../../../types/index.js';
3
+ import type { Charge, TableMode, ChipSelection } 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, ChipSelection {
66
66
  destinationsCount?: number;
67
67
  flagIcon?: string;
68
68
  destinationsTooltip?: React.ReactNode;