@tap-payments/os-micro-frontend-shared 0.0.232 → 0.0.233-test.20

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.
@@ -17,7 +17,6 @@ export const MenuItemStyled = styled(Box, { shouldForwardProp: (props) => props
17
17
  }));
18
18
  export const CheckboxStyled = styled(Checkbox)(({ theme }) => ({
19
19
  padding: 0,
20
- paddingRight: '4px',
21
20
  width: '14px !important',
22
21
  svg: {
23
22
  width: '12px !important',
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { MultiSelectStatusButtonProps } from './type';
3
- declare function MultiSelectStatusButton({ options, selectedValues, onSelectionChange, label, variant }: MultiSelectStatusButtonProps): import("react/jsx-runtime").JSX.Element;
3
+ declare function MultiSelectStatusButton({ options, selectedValues, onSelectionChange, label, variant, render, }: MultiSelectStatusButtonProps): import("react/jsx-runtime").JSX.Element;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof MultiSelectStatusButton>;
5
5
  export default _default;
@@ -1,45 +1,25 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { memo, useState, useRef, useEffect } from 'react';
3
- import { useTranslation } from 'react-i18next';
4
- import { Typography, Checkbox } from '@mui/material';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useState, useRef } from 'react';
3
+ import { Typography, ClickAwayListener, Box } from '@mui/material';
5
4
  import { ChevronIcon } from '../StatusButton/ChevronIcon';
6
5
  import StyledBadge, { BadgeVariants } from '../CountBadge';
7
- import CountryFlag from '../CountryFlag';
8
6
  import { formatNumber } from '../../utils/index.js';
9
- import { closeXIcon, SUPPORTED_CURRENCY_DETAILS } from '../../constants/index.js';
10
- import { ChevronContainer, Label, LabelWrapper, StyledDropdown, MenuItemContainer, CheckboxStyles, StyledStatusButton, ClearIcon, ChevronIconWrapper, } from './style';
11
- function MultiSelectStatusButton({ options = [], selectedValues, onSelectionChange, label, variant = 'inActive' }) {
12
- const { t } = useTranslation();
7
+ import { closeXIcon } from '../../constants/index.js';
8
+ import { ChevronContainer, Label, LabelWrapper, StyledStatusButton, ClearIcon, ChevronIconWrapper, } from './style';
9
+ import Menu from '../Menu';
10
+ import MenuItem from '../MenuItem';
11
+ function MultiSelectStatusButton({ options = [], selectedValues, onSelectionChange, label, variant = 'inActive', render, }) {
13
12
  const [anchorEl, setAnchorEl] = useState(null);
14
13
  const buttonRef = useRef(null);
15
14
  const [internalSelectedValues, setInternalSelectedValues] = useState(selectedValues);
16
- const [dropdownWidth, setDropdownWidth] = useState(0);
17
15
  const [isHovered, setIsHovered] = useState(false);
18
16
  const isOpen = Boolean(anchorEl);
19
- useEffect(() => {
20
- if (!isOpen) {
21
- setInternalSelectedValues(selectedValues);
22
- }
23
- }, [selectedValues, isOpen]);
24
17
  const handleDropdownClick = (event) => {
25
- var _a;
26
- event.stopPropagation();
27
- event.preventDefault();
28
- if (isOpen) {
29
- handleClose();
30
- return;
31
- }
32
18
  setAnchorEl(buttonRef.current);
33
- const buttonWidth = ((_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) || 200;
34
- setDropdownWidth(Math.max(buttonWidth, 200));
35
19
  };
36
20
  const handleClose = () => {
37
- const hasChanged = JSON.stringify([...internalSelectedValues].sort()) !== JSON.stringify([...selectedValues].sort());
38
- if (hasChanged) {
39
- onSelectionChange(internalSelectedValues);
40
- }
41
21
  setAnchorEl(null);
42
- setDropdownWidth(0);
22
+ setInternalSelectedValues(selectedValues);
43
23
  };
44
24
  const handleClearAll = (event) => {
45
25
  event.stopPropagation();
@@ -47,54 +27,33 @@ function MultiSelectStatusButton({ options = [], selectedValues, onSelectionChan
47
27
  setInternalSelectedValues([]);
48
28
  onSelectionChange([]);
49
29
  };
50
- const handleOptionToggle = (optionStatus, event) => {
51
- if (event) {
52
- event.stopPropagation();
53
- event.preventDefault();
30
+ const isOptionSelected = (optionStatus) => internalSelectedValues.includes(optionStatus);
31
+ const handleOptionToggle = (event, optionStatus) => {
32
+ event.preventDefault();
33
+ event.stopPropagation();
34
+ if (isOptionSelected(optionStatus)) {
35
+ setInternalSelectedValues(internalSelectedValues.filter((status) => status !== optionStatus));
36
+ return;
54
37
  }
55
- const newSelection = internalSelectedValues.includes(optionStatus)
56
- ? internalSelectedValues.filter((status) => status !== optionStatus)
57
- : [...internalSelectedValues, optionStatus];
58
- setInternalSelectedValues(newSelection);
59
- };
60
- const getDisplayLabel = () => {
61
- return (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: "11px", variant: "inherit" }, { children: t('Currencies') })));
38
+ setInternalSelectedValues([...internalSelectedValues, optionStatus]);
62
39
  };
63
- const countBadge = (_jsx(StyledBadge, Object.assign({ pointer: true, variant: variant === 'active' ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE }, { children: formatNumber(selectedValues.length > 0 ? selectedValues.length : options.length) })));
64
- return (_jsxs(_Fragment, { children: [_jsx(StyledStatusButton, Object.assign({ buttonVariant: variant, ref: buttonRef, sx: {
65
- paddingInlineEnd: '27px',
66
- }, "data-testid": "MultiSelectStatusButton", onClick: handleDropdownClick, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), disabled: !options.length }, { children: _jsxs(LabelWrapper, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [getDisplayLabel(), countBadge] })), _jsxs(ChevronContainer, Object.assign({ onClick: isHovered && internalSelectedValues.length > 0 ? handleClearAll : undefined, sx: {
67
- '&:hover': {
68
- backgroundColor: 'transparent',
69
- },
70
- } }, { children: [_jsx(ClearIcon, { variant: variant, src: closeXIcon, alt: "clear all", sx: {
71
- opacity: isHovered && internalSelectedValues.length > 0 ? 1 : 0,
72
- pointerEvents: isHovered && internalSelectedValues.length > 0 ? 'auto' : 'none',
73
- } }), _jsx(ChevronIconWrapper, Object.assign({ isVisible: !(isHovered && internalSelectedValues.length > 0) }, { children: _jsx(ChevronIcon, { disableHover: true, isActive: variant === 'active' }) }))] }))] }) })), isOpen && anchorEl && (_jsx(StyledDropdown, { open: isOpen, onClose: handleClose, anchorEl: anchorEl, allowShadows: false, style: {
74
- minWidth: dropdownWidth || 200,
75
- width: dropdownWidth || 'auto',
76
- marginTop: '6px',
40
+ return (_jsxs(Box, { children: [_jsx(ClickAwayListener, Object.assign({ onClickAway: handleClose }, { children: _jsx(StyledStatusButton, Object.assign({ buttonVariant: variant, ref: buttonRef, sx: {
41
+ paddingInlineEnd: '27px',
42
+ }, "data-testid": "MultiSelectStatusButton", onClick: handleDropdownClick, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), disabled: !options.length }, { children: _jsxs(LabelWrapper, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: "11px", variant: "inherit" }, { children: label })), _jsx(StyledBadge, Object.assign({ pointer: true, variant: variant === 'active' ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE }, { children: formatNumber(selectedValues.length > 0 ? selectedValues.length : options.length) }))] })), _jsxs(ChevronContainer, Object.assign({ onClick: isHovered && internalSelectedValues.length > 0 ? handleClearAll : undefined, sx: {
43
+ '&:hover': {
44
+ backgroundColor: 'transparent',
45
+ },
46
+ } }, { children: [_jsx(ClearIcon, { variant: variant, src: closeXIcon, alt: "clear all", sx: {
47
+ opacity: isHovered && internalSelectedValues.length > 0 ? 1 : 0,
48
+ pointerEvents: isHovered && internalSelectedValues.length > 0 ? 'auto' : 'none',
49
+ } }), _jsx(ChevronIconWrapper, Object.assign({ isVisible: !(isHovered && internalSelectedValues.length > 0) }, { children: _jsx(ChevronIcon, { disableHover: true, isActive: variant === 'active' }) }))] }))] }) })) })), _jsx(Menu, Object.assign({ anchorEl: anchorEl, open: isOpen, sx: {
50
+ minWidth: 200,
51
+ width: 'auto',
52
+ marginTop: '8px',
77
53
  maxWidth: 300,
78
- }, sx: {
79
- boxShadow: 'none !important',
80
- '&:hover': {
81
- boxShadow: 'none !important',
82
- },
83
- }, menuItems: options.map((option) => {
84
- var _a;
85
- return ({
86
- label: (_jsxs(MenuItemContainer, { children: [_jsx(Checkbox, { checked: internalSelectedValues.includes(option.status), size: "small", sx: CheckboxStyles, onClick: (e) => {
87
- var _a;
88
- e.stopPropagation();
89
- handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
90
- } }), _jsx(CountryFlag, { code: ((_a = SUPPORTED_CURRENCY_DETAILS[option.code]) === null || _a === void 0 ? void 0 : _a.country) || '', sx: { border: '1px solid white', borderRadius: '3px' } }), _jsx(Typography, Object.assign({ variant: "body2" }, { children: option.name }))] })),
91
- onClick: (e) => {
92
- var _a;
93
- e.preventDefault();
94
- e.stopPropagation();
95
- handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
96
- },
97
- });
98
- }) }))] }));
54
+ } }, { children: options.map((option) => (_jsx(MenuItem, Object.assign({ isSelected: isOptionSelected(option.status), onClick: (e) => {
55
+ var _a;
56
+ handleOptionToggle(e, (_a = option.status) !== null && _a !== void 0 ? _a : '');
57
+ } }, { children: render ? render() : _jsx(Typography, Object.assign({ variant: "body2" }, { children: option.name })) })))) }))] }));
99
58
  }
100
59
  export default memo(MultiSelectStatusButton);
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { TableHeaderStatus } from '../../types/index.js';
2
3
  export interface CurrencyOption {
3
4
  code: string;
@@ -11,4 +12,5 @@ export interface MultiSelectStatusButtonProps {
11
12
  onSelectionChange: (selected: TableHeaderStatus[]) => void;
12
13
  label?: string;
13
14
  variant?: 'active' | 'inActive';
15
+ render?: () => JSX.Element;
14
16
  }
@@ -1,3 +1,3 @@
1
1
  import type { ReferenceCellProps } from './type';
2
- declare function ReferenceCell({ isTextShown, tableMode, ...props }: ReferenceCellProps): import("react/jsx-runtime").JSX.Element;
2
+ declare function ReferenceCell({ isTextShown, ...props }: ReferenceCellProps): import("react/jsx-runtime").JSX.Element;
3
3
  export default ReferenceCell;
@@ -16,12 +16,10 @@ import startCase from 'lodash/startCase';
16
16
  import Tooltip from '../../../Tooltip';
17
17
  import { ImageWrapper } from '../../../index.js';
18
18
  import { TableCell } from '../../../TableCells';
19
- import StatusChip from '../../../StatusChip';
20
- import { referenceIcons, REFERENCE_WIDTH_MAP } from './constant';
19
+ import { referenceIcons } from './constant';
21
20
  import { ReferenceTextLabel, ReferenceTextWrapper, ReferenceSourcesContainer, StyledSourceCell, StyledSourceImage, referenceSourceAnimation, } from './style';
22
- import { Box } from '@mui/material';
23
21
  function ReferenceCell(_a) {
24
- var { isTextShown, tableMode } = _a, props = __rest(_a, ["isTextShown", "tableMode"]);
22
+ var { isTextShown } = _a, props = __rest(_a, ["isTextShown"]);
25
23
  const [isTooltipOpen, setIsTooltipOpen] = useState(false);
26
24
  const theme = useTheme();
27
25
  const references = useMemo(() => Object.keys(referenceIcons).filter((key) => !!props[key]), [props]);
@@ -36,21 +34,6 @@ function ReferenceCell(_a) {
36
34
  } }, { children: isTextShown ? (_jsx(ReferenceTextWrapper, { children: _jsx(ReferenceTextLabel, { children: startCase(reference) }) })) : (_jsx(StyledSourceImage, { src: referenceIcons[reference], alt: reference, sx: Object.assign({}, (reference === 'order' && { width: '11.82px' })) })) })) }), `${reference}-${index}`));
37
35
  }), [props, references, isTextShown, theme]);
38
36
  const referenceSourcesCount = (ReferenceSources === null || ReferenceSources === void 0 ? void 0 : ReferenceSources.length) || 0;
39
- if (tableMode === 'sheet') {
40
- return (_jsx(TableCell, Object.assign({}, props, { children: _jsx(StyledSourceCell, Object.assign({ sx: { gap: '4px', display: 'flex', flexWrap: 'nowrap' } }, { children: references.map((referenceKey) => {
41
- const referenceValue = props[referenceKey];
42
- const widthConfig = REFERENCE_WIDTH_MAP[referenceKey];
43
- return (_jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: _jsx(StatusChip, Object.assign({ sx: {
44
- maxWidth: widthConfig.width,
45
- overflow: 'hidden',
46
- textOverflow: 'ellipsis',
47
- whiteSpace: 'nowrap',
48
- boxSizing: 'border-box',
49
- display: 'inline-block',
50
- padding: '0.75px 12px',
51
- } }, { children: `${startCase(referenceKey)}: ${referenceValue}` })) }), referenceKey));
52
- }) })) })));
53
- }
54
37
  return (_jsx(TableCell, Object.assign({}, props, { children: _jsx(StyledSourceCell, { children: referenceSourcesCount > 0 ? (_jsx(ReferenceSourcesContainer, Object.assign({ layout: true, className: "reference-sources-container", whileHover: "animate", animate: isTooltipOpen ? 'animate' : 'start', sourcesCount: referenceSourcesCount, variants: { animate: { width: referenceSourcesCount * (6 + 32) } }, style: {
55
38
  zIndex: 29,
56
39
  } }, { children: ReferenceSources }))) : null }) })));
@@ -4,23 +4,3 @@ export declare const referenceIcons: {
4
4
  payment: string;
5
5
  order: string;
6
6
  };
7
- export declare const REFERENCE_WIDTH_MAP: {
8
- order: {
9
- width: string;
10
- };
11
- payment: {
12
- width: string;
13
- };
14
- acquirer: {
15
- width: string;
16
- };
17
- generic: {
18
- width: string;
19
- };
20
- merchant: {
21
- width: string;
22
- };
23
- customer: {
24
- width: string;
25
- };
26
- };
@@ -5,11 +5,3 @@ export const referenceIcons = {
5
5
  payment: transactionIcon,
6
6
  order: orderIcon,
7
7
  };
8
- export const REFERENCE_WIDTH_MAP = {
9
- order: { width: '185px' },
10
- payment: { width: '205px' },
11
- acquirer: { width: '155px' },
12
- generic: { width: '166px' },
13
- merchant: { width: '140px' },
14
- customer: { width: '140px' },
15
- };
@@ -9,5 +9,4 @@ export interface ReferenceCellProps extends TableCellProps {
9
9
  generic?: string;
10
10
  payment?: string;
11
11
  isTextShown?: boolean;
12
- tableMode?: 'default' | 'text' | 'sheet';
13
12
  }
@@ -179,4 +179,24 @@ export declare const chargeTableCellWidth: {
179
179
  readonly text: "140px";
180
180
  readonly sheet: "140px";
181
181
  };
182
+ readonly acquirer_ref: {
183
+ readonly default: "125px";
184
+ readonly text: "125px";
185
+ readonly sheet: "125px";
186
+ };
187
+ readonly order_ref: {
188
+ readonly default: "200px";
189
+ readonly text: "200px";
190
+ readonly sheet: "200px";
191
+ };
192
+ readonly payment_ref: {
193
+ readonly default: "150px";
194
+ readonly text: "150px";
195
+ readonly sheet: "150px";
196
+ };
197
+ readonly generic_ref: {
198
+ readonly default: "125px";
199
+ readonly text: "125px";
200
+ readonly sheet: "125px";
201
+ };
182
202
  };
@@ -179,4 +179,24 @@ export const chargeTableCellWidth = {
179
179
  text: '140px',
180
180
  sheet: '140px',
181
181
  },
182
+ acquirer_ref: {
183
+ default: '125px',
184
+ text: '125px',
185
+ sheet: '125px',
186
+ },
187
+ order_ref: {
188
+ default: '200px',
189
+ text: '200px',
190
+ sheet: '200px',
191
+ },
192
+ payment_ref: {
193
+ default: '150px',
194
+ text: '150px',
195
+ sheet: '150px',
196
+ },
197
+ generic_ref: {
198
+ default: '125px',
199
+ text: '125px',
200
+ sheet: '125px',
201
+ },
182
202
  };
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.0.232",
5
- "testVersion": 17,
4
+ "version": "0.0.233-test.20",
5
+ "testVersion": 20,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",
@@ -131,4 +131,4 @@
131
131
  "publishConfig": {
132
132
  "registry": "https://registry.npmjs.org/"
133
133
  }
134
- }
134
+ }