@tap-payments/os-micro-frontend-shared 0.1.202 → 0.1.203
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/MultiSelectDropdownButton/MultiSelectDropdownButton.js +1 -1
- package/build/components/MultiSelectDropdownButton/components/StatusButton.d.ts +10 -0
- package/build/components/MultiSelectDropdownButton/components/StatusButton.js +34 -0
- package/build/components/StatusBar/StatusBar.d.ts +1 -1
- package/build/components/StatusBar/StatusBar.js +8 -14
- package/build/components/StatusBar/type.js +0 -6
- package/build/components/StatusButton/StatusButton.js +3 -5
- package/build/components/StatusButton/type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { memo, useState } from 'react';
|
|
|
3
3
|
import { Popper } from '@mui/material';
|
|
4
4
|
import { ButtonLabel } from './style';
|
|
5
5
|
import CustomBackdrop from '../CustomBackdrop';
|
|
6
|
-
import StatusButton from '
|
|
6
|
+
import StatusButton from './components/StatusButton';
|
|
7
7
|
import ListColumnFilter from '../VirtualTables/components/ColumnFilter/List';
|
|
8
8
|
import { downArrowIcon } from '../../constants/index.js';
|
|
9
9
|
function MultiSelectDropdownButton({ buttonLabel, onClear, onConfirm, dropdownItems, apiKey, data, styles, buttonDisabled, }) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ButtonProps } from '@mui/material';
|
|
3
|
+
import { StatusButtonVariant } from '../../StatusButton/style';
|
|
4
|
+
interface StatusButtonProps extends Omit<ButtonProps, 'variant' | 'children'> {
|
|
5
|
+
variant?: StatusButtonVariant;
|
|
6
|
+
badgeCount: number;
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare const StatusButton: import("react").MemoExoticComponent<(props: StatusButtonProps) => import("react/jsx-runtime").JSX.Element>;
|
|
10
|
+
export default StatusButton;
|
|
@@ -0,0 +1,34 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { memo, useCallback, useMemo, useRef } from 'react';
|
|
14
|
+
import StyledBadge, { BadgeVariants } from '../../CountBadge';
|
|
15
|
+
import { convertToNumber, formatNumber } from '../../../utils/index.js';
|
|
16
|
+
import { Label, LabelWrapper, statusButtonVariants } from '../../StatusButton/style';
|
|
17
|
+
const StatusButton = memo((props) => {
|
|
18
|
+
const { variant = 'inActive', badgeCount, label } = props, restProps = __rest(props, ["variant", "badgeCount", "label"]);
|
|
19
|
+
const buttonRef = useRef(null);
|
|
20
|
+
// Memoized computed values
|
|
21
|
+
const statusBadge = useMemo(() => {
|
|
22
|
+
if (!badgeCount || Number.isNaN(convertToNumber(badgeCount)))
|
|
23
|
+
return null;
|
|
24
|
+
return _jsx(StyledBadge, Object.assign({ variant: BadgeVariants.INACTIVE }, { children: formatNumber(Number(badgeCount)) }));
|
|
25
|
+
}, [badgeCount]);
|
|
26
|
+
const handleButtonClick = useCallback((e) => {
|
|
27
|
+
var _a;
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
(_a = props === null || props === void 0 ? void 0 : props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
30
|
+
}, [props]);
|
|
31
|
+
const ButtonComponent = statusButtonVariants[variant];
|
|
32
|
+
return (_jsx(ButtonComponent, Object.assign({ "data-testid": "MultiSelectStatusButton" }, restProps, { ref: buttonRef, onClick: handleButtonClick }, { children: _jsx(LabelWrapper, { children: _jsxs(Label, Object.assign({ variant: variant }, { children: [label, statusBadge] })) }) })));
|
|
33
|
+
});
|
|
34
|
+
export default StatusButton;
|
|
@@ -6,6 +6,6 @@ interface StatusBarProps<IStatus extends TableHeaderStatus | TableHeaderStatus[]
|
|
|
6
6
|
isFilteredIdsShown?: boolean;
|
|
7
7
|
onStatusChange?: (status?: IStatus) => void;
|
|
8
8
|
}
|
|
9
|
-
declare function StatusBar<IStatus extends TableHeaderStatus | TableHeaderStatus[] = undefined>({ isFilteredIdsShown,
|
|
9
|
+
declare function StatusBar<IStatus extends TableHeaderStatus | TableHeaderStatus[] = undefined>({ isFilteredIdsShown, availableStatuses, status, onStatusChange, }: Readonly<StatusBarProps<IStatus>>): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
declare const _default: typeof StatusBar;
|
|
11
11
|
export default _default;
|
|
@@ -11,12 +11,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { createElement as _createElement } from "react";
|
|
13
13
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
-
import { Fragment, memo, useCallback
|
|
14
|
+
import { Fragment, memo, useCallback } from 'react';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import StatusButton from '../StatusButton';
|
|
17
|
-
function StatusBar({ isFilteredIdsShown,
|
|
17
|
+
function StatusBar({ isFilteredIdsShown, availableStatuses, status, onStatusChange, }) {
|
|
18
18
|
const { t } = useTranslation();
|
|
19
|
-
const isMultiSelection = useMemo(() => Array.isArray(status), [status]);
|
|
20
19
|
const getButtonStatus = useCallback((buttonStatus) => {
|
|
21
20
|
return buttonStatus === status && !isFilteredIdsShown ? 'active' : 'inActive';
|
|
22
21
|
}, [status, isFilteredIdsShown]);
|
|
@@ -39,20 +38,15 @@ function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, stat
|
|
|
39
38
|
const statusItems = s.status;
|
|
40
39
|
if (!statusItems)
|
|
41
40
|
return null;
|
|
42
|
-
const formattedStatuses =
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, s, { label: t(statusLabel || ''), variant: variant, onButtonBodyClick: (buttonStatus) => {
|
|
48
|
-
handleStatusChange(buttonStatus);
|
|
49
|
-
}, dropdownOptions: formattedStatuses.map((stat) => ({
|
|
41
|
+
const formattedStatuses = statusItems.filter(Boolean).map((item) => (typeof item === 'string' ? { value: item } : item)) || [];
|
|
42
|
+
const hasMatchingDropdownStatus = !!status && formattedStatuses.some((item) => (item === null || item === void 0 ? void 0 : item.value) === status);
|
|
43
|
+
const variant = hasMatchingDropdownStatus ? 'active' : 'inActive';
|
|
44
|
+
const selectedStatus = hasMatchingDropdownStatus ? status : (_b = formattedStatuses[0]) === null || _b === void 0 ? void 0 : _b.value;
|
|
45
|
+
return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, s, { selectedStatus: selectedStatus, variant: variant, onButtonBodyClick: (buttonStatus) => handleStatusChange(buttonStatus), dropdownOptions: formattedStatuses.map((stat) => ({
|
|
50
46
|
label: t((stat === null || stat === void 0 ? void 0 : stat.value) || ''),
|
|
51
|
-
onClick: () => {
|
|
52
|
-
handleStatusChange(stat.value);
|
|
53
|
-
},
|
|
54
47
|
status: stat === null || stat === void 0 ? void 0 : stat.value,
|
|
55
48
|
icon: stat.icon,
|
|
49
|
+
onClick: () => handleStatusChange(stat.value),
|
|
56
50
|
})) })) }, (_c = formattedStatuses[0]) === null || _c === void 0 ? void 0 : _c.value));
|
|
57
51
|
}) }));
|
|
58
52
|
}
|
|
@@ -19,12 +19,12 @@ import { ChevronContainer, Label, LabelWrapper, StyledStatusIcon, StyledDropdown
|
|
|
19
19
|
import { statusButtonIcons } from './constant';
|
|
20
20
|
const StatusButton = memo((props) => {
|
|
21
21
|
var _a;
|
|
22
|
-
const { variant = 'inActive', badgeCount, icon, label, dropdownOptions, onButtonBodyClick, iconMapper = statusButtonIcons } = props, restProps = __rest(props, ["variant", "badgeCount", "icon", "label", "dropdownOptions", "onButtonBodyClick", "iconMapper"]);
|
|
22
|
+
const { variant = 'inActive', badgeCount, icon, label, dropdownOptions, selectedStatus: initialStatus, onButtonBodyClick, iconMapper = statusButtonIcons } = props, restProps = __rest(props, ["variant", "badgeCount", "icon", "label", "dropdownOptions", "selectedStatus", "onButtonBodyClick", "iconMapper"]);
|
|
23
23
|
const [buttonClicks, setButtonClicks] = useState(0);
|
|
24
24
|
const { t } = useTranslation();
|
|
25
25
|
const buttonRef = useRef(null);
|
|
26
26
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
27
|
-
const [selectedStatus, setSelectedStatus] = useState((_a = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions[0]) === null || _a === void 0 ? void 0 : _a.status);
|
|
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
28
|
// Memoized computed values
|
|
29
29
|
const hasDropdown = useMemo(() => Boolean(dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.length), [dropdownOptions]);
|
|
30
30
|
// only open if button is clicked more than once
|
|
@@ -75,8 +75,6 @@ const StatusButton = memo((props) => {
|
|
|
75
75
|
const menuItems = useMemo(() => (dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((item) => (Object.assign(Object.assign({}, item), { onClick: handleMenuItemClick(item) })))) || [], [dropdownOptions, handleMenuItemClick]);
|
|
76
76
|
const ButtonComponent = statusButtonVariants[variant];
|
|
77
77
|
const displayLabel = selectedStatus ? t(selectedStatus) : label;
|
|
78
|
-
return (_jsxs(_Fragment, { children: [_jsx(ButtonComponent, Object.assign({ "data-testid": "StatusButton" }, restProps, { ref: buttonRef, onClick: handleButtonClick, sx: Object.assign({}, (hasDropdown && {
|
|
79
|
-
paddingInlineEnd: '27px',
|
|
80
|
-
})) }, { 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 }))] }));
|
|
78
|
+
return (_jsxs(_Fragment, { children: [_jsx(ButtonComponent, Object.assign({ "data-testid": "StatusButton" }, restProps, { ref: buttonRef, onClick: handleButtonClick, sx: Object.assign({}, (hasDropdown && { paddingInlineEnd: '27px' })) }, { 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 }))] }));
|
|
81
79
|
});
|
|
82
80
|
export default StatusButton;
|
|
@@ -12,6 +12,7 @@ export interface StatusButtonProps extends Omit<ButtonProps, 'variant' | 'childr
|
|
|
12
12
|
label?: ReactNode | null;
|
|
13
13
|
showDropdownIcon?: boolean;
|
|
14
14
|
totalCount?: number;
|
|
15
|
+
selectedStatus?: TableHeaderStatus;
|
|
15
16
|
onButtonBodyClick?: (status: TableHeaderStatus) => void;
|
|
16
17
|
/**
|
|
17
18
|
* @description
|
package/package.json
CHANGED