@tap-payments/os-micro-frontend-shared 0.1.395 → 0.1.396
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.
|
@@ -35,8 +35,8 @@ const StatusButton = memo((props) => {
|
|
|
35
35
|
const isDropdownOpen = Boolean(anchorEl) && buttonClicks > 1;
|
|
36
36
|
const isActiveVariant = variant === 'active';
|
|
37
37
|
const badgeVariant = useMemo(() => (isActiveVariant ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE), [isActiveVariant]);
|
|
38
|
+
const selectedOption = useMemo(() => (selectedStatus ? dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => option.status === selectedStatus) : null), [selectedStatus, dropdownOptions]);
|
|
38
39
|
const statusIcon = useMemo(() => {
|
|
39
|
-
const selectedOption = selectedStatus ? dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => option.status === selectedStatus) : null;
|
|
40
40
|
if (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.icon) {
|
|
41
41
|
return _jsx(IconWrapper, Object.assign({ variant: variant }, { children: selectedOption.icon }));
|
|
42
42
|
}
|
|
@@ -44,7 +44,7 @@ const StatusButton = memo((props) => {
|
|
|
44
44
|
if (iconKey && iconMapper[iconKey]) {
|
|
45
45
|
return _jsx(StyledStatusIcon, { icon: iconKey, variant: variant, src: iconMapper[iconKey], alt: `${iconKey}-icon` });
|
|
46
46
|
}
|
|
47
|
-
}, [
|
|
47
|
+
}, [selectedOption, selectedStatus, iconMapper, icon, variant]);
|
|
48
48
|
const statusBadge = useMemo(() => {
|
|
49
49
|
if (!badgeCount || Number.isNaN(convertToNumber(badgeCount)))
|
|
50
50
|
return null;
|
|
@@ -86,7 +86,9 @@ const StatusButton = memo((props) => {
|
|
|
86
86
|
// Enhanced dropdown menu items
|
|
87
87
|
const menuItems = useMemo(() => (dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((item) => (Object.assign(Object.assign({}, item), { onClick: handleMenuItemClick(item) })))) || [], [dropdownOptions, handleMenuItemClick]);
|
|
88
88
|
const ButtonComponent = statusButtonVariants[variant];
|
|
89
|
-
const displayLabel =
|
|
89
|
+
const displayLabel = useMemo(() => {
|
|
90
|
+
return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || (selectedStatus ? t(selectedStatus) : label);
|
|
91
|
+
}, [selectedOption, selectedStatus, t, label]);
|
|
90
92
|
return (_jsxs(_Fragment, { children: [_jsx(ButtonComponent, Object.assign({ "data-testid": "StatusButton" }, restProps, { ref: buttonRef, onClick: handleButtonClick, sx: Object.assign(Object.assign({}, (hasDropdown && { paddingInlineEnd: '27px' })), buttonSx) }, { children: _jsxs(LabelWrapper, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [statusIcon, displayLabel, statusBadge] })), dropdownIcon && _jsx(ChevronContainer, { children: dropdownIcon })] }) })), isDropdownOpen && hasDropdown && (_jsx(StyledDropdown, { open: isDropdownOpen, onClose: handleDropdownClose, anchorEl: anchorEl, menuItems: menuItems }))] }));
|
|
91
93
|
});
|
|
92
94
|
export default StatusButton;
|
package/package.json
CHANGED