@tap-payments/os-micro-frontend-shared 0.1.391 → 0.1.392

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.
@@ -23,7 +23,7 @@ function StatusBar({ isFilteredIdsShown, availableStatuses, status, onStatusChan
23
23
  onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(selected);
24
24
  }, [onStatusChange]);
25
25
  return (_jsx(_Fragment, { children: availableStatuses === null || availableStatuses === void 0 ? void 0 : availableStatuses.map((_a, index) => {
26
- var _b, _c;
26
+ var _b;
27
27
  var { render } = _a, s = __rest(_a, ["render"]);
28
28
  if (render) {
29
29
  return (_jsx(Fragment, { children: render({ status: status, onChange: handleStatusChange }, Object.assign(Object.assign({}, s), { index })) }, `custom-status-slot-${index}`));
@@ -42,13 +42,13 @@ function StatusBar({ isFilteredIdsShown, availableStatuses, status, onStatusChan
42
42
  []);
43
43
  const hasMatchingDropdownStatus = !!status && formattedStatuses.some((item) => (item === null || item === void 0 ? void 0 : item.value) === status);
44
44
  const variant = hasMatchingDropdownStatus ? 'active' : 'inActive';
45
- const selectedStatus = hasMatchingDropdownStatus ? status : (_b = formattedStatuses[0]) === null || _b === void 0 ? void 0 : _b.value;
45
+ const selectedStatus = hasMatchingDropdownStatus ? status : undefined;
46
46
  return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, s, { selectedStatus: selectedStatus, variant: variant, onButtonBodyClick: (buttonStatus) => handleStatusChange(buttonStatus), dropdownOptions: formattedStatuses.map((stat) => ({
47
47
  label: t((stat === null || stat === void 0 ? void 0 : stat.value) || ''),
48
48
  status: stat === null || stat === void 0 ? void 0 : stat.value,
49
49
  icon: stat.icon,
50
50
  onClick: () => handleStatusChange(stat.value),
51
- })), buttonSx: buttonSx })) }, (_c = formattedStatuses[0]) === null || _c === void 0 ? void 0 : _c.value));
51
+ })), buttonSx: buttonSx })) }, (_b = formattedStatuses[0]) === null || _b === void 0 ? void 0 : _b.value));
52
52
  }) }));
53
53
  }
54
54
  export default memo(StatusBar);
@@ -15,7 +15,7 @@ import { useTranslation } from 'react-i18next';
15
15
  import StyledBadge, { BadgeVariants } from '../CountBadge';
16
16
  import { convertToNumber, formatNumber } from '../../utils/index.js';
17
17
  import { ChevronIcon } from './ChevronIcon';
18
- import { ChevronContainer, Label, LabelWrapper, StyledStatusIcon, StyledDropdown, statusButtonVariants } from './style';
18
+ import { ChevronContainer, Label, LabelWrapper, StyledStatusIcon, StyledDropdown, statusButtonVariants, IconWrapper } from './style';
19
19
  import { statusButtonIcons } from './constant';
20
20
  const StatusButton = memo((props) => {
21
21
  var _a;
@@ -25,14 +25,26 @@ const StatusButton = memo((props) => {
25
25
  const buttonRef = useRef(null);
26
26
  const [anchorEl, setAnchorEl] = useState(null);
27
27
  const [selectedStatus, setSelectedStatus] = useState(initialStatus !== null && initialStatus !== void 0 ? initialStatus : (_a = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions[0]) === null || _a === void 0 ? void 0 : _a.status);
28
- // Memoized computed values
28
+ useEffect(() => {
29
+ if (initialStatus !== undefined) {
30
+ setSelectedStatus(initialStatus);
31
+ }
32
+ }, [initialStatus]);
29
33
  const hasDropdown = useMemo(() => Boolean(dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.length), [dropdownOptions]);
30
34
  // only open if button is clicked more than once
31
35
  const isDropdownOpen = Boolean(anchorEl) && buttonClicks > 1;
32
36
  const isActiveVariant = variant === 'active';
33
37
  const badgeVariant = useMemo(() => (isActiveVariant ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE), [isActiveVariant]);
34
- // Memoized UI elements
35
- const statusIcon = useMemo(() => (icon ? _jsx(StyledStatusIcon, { icon: icon, variant: variant, src: iconMapper[icon], alt: `${icon}-icon` }) : null), [icon, iconMapper, variant]);
38
+ const statusIcon = useMemo(() => {
39
+ const selectedOption = selectedStatus ? dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => option.status === selectedStatus) : null;
40
+ if (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.icon) {
41
+ return _jsx(IconWrapper, Object.assign({ variant: variant }, { children: selectedOption.icon }));
42
+ }
43
+ const iconKey = selectedStatus && iconMapper[selectedStatus] ? selectedStatus : icon;
44
+ if (iconKey && iconMapper[iconKey]) {
45
+ return _jsx(StyledStatusIcon, { icon: iconKey, variant: variant, src: iconMapper[iconKey], alt: `${iconKey}-icon` });
46
+ }
47
+ }, [selectedStatus, dropdownOptions, iconMapper, icon, variant]);
36
48
  const statusBadge = useMemo(() => {
37
49
  if (!badgeCount || Number.isNaN(convertToNumber(badgeCount)))
38
50
  return null;
@@ -38,3 +38,8 @@ export declare const StyledStatusIcon: import("@emotion/styled").StyledComponent
38
38
  variant: StatusButtonVariant;
39
39
  icon?: StatusButtonProps['icon'];
40
40
  }, React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
41
+ export declare const IconWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
42
+ ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
43
+ }, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme> & {
44
+ variant: StatusButtonVariant;
45
+ }, {}, {}>;
@@ -79,3 +79,14 @@ export const StyledStatusIcon = styled('img')(({ theme, variant, icon }) => {
79
79
  filter: variant === 'active' ? 'brightness(0) invert(1)' : 'brightness(0) invert(0)',
80
80
  })), { maxWidth: '14px', maxHeight: '14px' }));
81
81
  });
82
+ export const IconWrapper = styled(Box)(({ variant }) => ({
83
+ width: '14px',
84
+ height: '14px',
85
+ display: 'flex',
86
+ alignItems: 'center',
87
+ '& img': {
88
+ width: '14px',
89
+ height: '14px',
90
+ filter: variant === 'active' ? 'brightness(0) invert(1)' : 'brightness(0) invert(0)',
91
+ },
92
+ }));
@@ -78,6 +78,9 @@ export declare const minimizeIcon: string;
78
78
  export declare const closeIcon: string;
79
79
  export declare const dashedCheckIcon: string;
80
80
  export declare const outstandingIcon: string;
81
+ export declare const cancelledNoBgIcon: string;
82
+ export declare const expiredNoBgIcon: string;
83
+ export declare const paidNoBgIcon: string;
81
84
  export declare const deactivatedIcon: string;
82
85
  export declare const topUpIcon: string;
83
86
  export declare const deMaximizeIcon: string;
@@ -83,6 +83,9 @@ export const minimizeIcon = `${lightUrl}/minimize.svg`;
83
83
  export const closeIcon = `${lightUrl}/close.svg`;
84
84
  export const dashedCheckIcon = `${lightUrl}/dashedCheckIcon.svg`;
85
85
  export const outstandingIcon = `${lightUrl}/outstandingIcon.svg`;
86
+ export const cancelledNoBgIcon = `${lightUrl}/cancelledStatusIcon.svg`;
87
+ export const expiredNoBgIcon = `${lightUrl}/expiredStatusIcon.svg`;
88
+ export const paidNoBgIcon = `${lightUrl}/paidStatusIcon.svg`;
86
89
  export const deactivatedIcon = `${lightUrl}/deactivatedIcon.svg`;
87
90
  export const topUpIcon = `${lightUrl}/topup.svg`;
88
91
  export const deMaximizeIcon = `${appBaseUrl}/demaximize.svg`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
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.391",
4
+ "version": "0.1.392",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",