@tap-payments/os-micro-frontend-shared 0.0.234-test.2-test.3 → 0.0.235
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.
- package/build/components/MultiSelectStatusButton/MultiSelectStatusButton.js +25 -15
- package/build/components/MultiSelectStatusButton/type.d.ts +0 -2
- package/build/components/StatusBar/StatusBar.d.ts +1 -1
- package/build/components/StatusBar/StatusBar.js +5 -5
- package/build/components/StatusBar/type.d.ts +7 -2
- package/package.json +3 -3
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useState, useRef, useEffect } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import { Typography, Checkbox } from '@mui/material';
|
|
4
5
|
import { ChevronIcon } from '../StatusButton/ChevronIcon';
|
|
5
6
|
import StyledBadge, { BadgeVariants } from '../CountBadge';
|
|
7
|
+
import CountryFlag from '../CountryFlag';
|
|
6
8
|
import { formatNumber } from '../../utils/index.js';
|
|
7
|
-
import { closeXIcon } from '../../constants/index.js';
|
|
9
|
+
import { closeXIcon, SUPPORTED_CURRENCY_DETAILS } from '../../constants/index.js';
|
|
8
10
|
import { ChevronContainer, Label, LabelWrapper, StyledDropdown, MenuItemContainer, CheckboxStyles, StyledStatusButton, ClearIcon, ChevronIconWrapper, } from './style';
|
|
9
11
|
function MultiSelectStatusButton({ options = [], selectedValues, onSelectionChange, label, variant = 'inActive' }) {
|
|
12
|
+
const { t } = useTranslation();
|
|
10
13
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
11
14
|
const buttonRef = useRef(null);
|
|
12
15
|
const [internalSelectedValues, setInternalSelectedValues] = useState(selectedValues);
|
|
@@ -54,9 +57,13 @@ function MultiSelectStatusButton({ options = [], selectedValues, onSelectionChan
|
|
|
54
57
|
: [...internalSelectedValues, optionStatus];
|
|
55
58
|
setInternalSelectedValues(newSelection);
|
|
56
59
|
};
|
|
60
|
+
const getDisplayLabel = () => {
|
|
61
|
+
return (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: "11px", variant: "inherit" }, { children: t('Currencies') })));
|
|
62
|
+
};
|
|
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) })));
|
|
57
64
|
return (_jsxs(_Fragment, { children: [_jsx(StyledStatusButton, Object.assign({ buttonVariant: variant, ref: buttonRef, sx: {
|
|
58
65
|
paddingInlineEnd: '27px',
|
|
59
|
-
}, "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: [
|
|
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: {
|
|
60
67
|
'&:hover': {
|
|
61
68
|
backgroundColor: 'transparent',
|
|
62
69
|
},
|
|
@@ -73,18 +80,21 @@ function MultiSelectStatusButton({ options = [], selectedValues, onSelectionChan
|
|
|
73
80
|
'&:hover': {
|
|
74
81
|
boxShadow: 'none !important',
|
|
75
82
|
},
|
|
76
|
-
}, menuItems: options.map((option) =>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
e
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
+
}) }))] }));
|
|
89
99
|
}
|
|
90
100
|
export default memo(MultiSelectStatusButton);
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TableHeaderStatus } from '../../types/index.js';
|
|
3
2
|
export interface CurrencyOption {
|
|
4
3
|
code: string;
|
|
5
4
|
name: string;
|
|
6
5
|
flagCode?: string;
|
|
7
6
|
status: TableHeaderStatus;
|
|
8
|
-
render?: () => JSX.Element;
|
|
9
7
|
}
|
|
10
8
|
export interface MultiSelectStatusButtonProps {
|
|
11
9
|
options: CurrencyOption[];
|
|
@@ -4,7 +4,7 @@ interface StatusBarProps<IStatus extends TableHeaderStatus | TableHeaderStatus[]
|
|
|
4
4
|
status?: IStatus;
|
|
5
5
|
availableStatuses?: AvailableStatus<IStatus>[];
|
|
6
6
|
isFilteredIdsShown?: boolean;
|
|
7
|
-
onStatusChange?: (status
|
|
7
|
+
onStatusChange?: (status?: IStatus) => void;
|
|
8
8
|
}
|
|
9
9
|
declare function StatusBar<IStatus extends TableHeaderStatus | TableHeaderStatus[] = undefined>({ isFilteredIdsShown, onStatusChange, availableStatuses, status, }: StatusBarProps<IStatus>): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
declare const _default: typeof StatusBar;
|
|
@@ -20,19 +20,19 @@ function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, stat
|
|
|
20
20
|
const getButtonStatus = useCallback((buttonStatus) => {
|
|
21
21
|
return buttonStatus === status && !isFilteredIdsShown ? 'active' : 'inActive';
|
|
22
22
|
}, [status, isFilteredIdsShown]);
|
|
23
|
-
const
|
|
23
|
+
const handleStatusChange = useCallback((selected) => {
|
|
24
24
|
onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(selected);
|
|
25
25
|
}, [onStatusChange]);
|
|
26
26
|
return (_jsx(_Fragment, { children: availableStatuses === null || availableStatuses === void 0 ? void 0 : availableStatuses.map((_a, index) => {
|
|
27
27
|
var _b, _c;
|
|
28
28
|
var { render } = _a, s = __rest(_a, ["render"]);
|
|
29
29
|
if (render) {
|
|
30
|
-
return _jsx(Fragment, { children: render(status,
|
|
30
|
+
return (_jsx(Fragment, { children: render({ status: status, onChange: handleStatusChange }, Object.assign(Object.assign({}, s), { index })) }, `custom-status-slot-${index}`));
|
|
31
31
|
}
|
|
32
32
|
if (!Array.isArray(s.status)) {
|
|
33
33
|
return (_createElement(StatusButton, Object.assign({}, s, { key: `status-button-array-${s.status}`, variant: getButtonStatus(s.status), onClick: () => {
|
|
34
34
|
if (!Array.isArray(s.status)) {
|
|
35
|
-
|
|
35
|
+
handleStatusChange(s.status);
|
|
36
36
|
}
|
|
37
37
|
} })));
|
|
38
38
|
}
|
|
@@ -40,11 +40,11 @@ function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, stat
|
|
|
40
40
|
const variant = isCurrentStatusDropdown ? 'active' : 'inActive';
|
|
41
41
|
const statusLabel = isCurrentStatusDropdown && !isMultiSelection ? status : s.status[0];
|
|
42
42
|
return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, s, { label: t(statusLabel || ''), variant: variant, onButtonBodyClick: (buttonStatus) => {
|
|
43
|
-
|
|
43
|
+
handleStatusChange(buttonStatus);
|
|
44
44
|
}, dropdownOptions: s.status.map((stat) => ({
|
|
45
45
|
label: t(stat || ''),
|
|
46
46
|
onClick: () => {
|
|
47
|
-
|
|
47
|
+
handleStatusChange(stat);
|
|
48
48
|
},
|
|
49
49
|
status: stat,
|
|
50
50
|
})) })) }, (_c = s === null || s === void 0 ? void 0 : s.status) === null || _c === void 0 ? void 0 : _c[0]));
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
import { StatusButtonProps } from '../StatusButton';
|
|
3
3
|
import { TableHeaderStatus } from '../../types/index.js';
|
|
4
4
|
export type AvailableStatus<T extends TableHeaderStatus | TableHeaderStatus[] = undefined> = StatusButtonProps & {
|
|
5
|
-
status
|
|
6
|
-
render?: <IStatus extends T>(
|
|
5
|
+
status?: T;
|
|
6
|
+
render?: <IStatus extends T>(controls: {
|
|
7
|
+
status: IStatus;
|
|
8
|
+
onChange: (selected?: AvailableStatus<T>['status']) => void;
|
|
9
|
+
}, options?: Omit<AvailableStatus<T>, 'render'> & {
|
|
10
|
+
index: number;
|
|
11
|
+
}) => React.ReactNode;
|
|
7
12
|
};
|
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.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.0.235",
|
|
5
|
+
"testVersion": 19,
|
|
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
|
+
}
|