@tap-payments/os-micro-frontend-shared 0.0.171 → 0.0.173
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/Button/StyledButton/StyledButton.d.ts +1 -1
- package/build/components/Button/StyledButton/StyledButton.js +1 -1
- package/build/components/FileUpload/FileUpload.js +1 -1
- package/build/components/TableHeader_V2/components/StatusButtons/StatusButton.js +49 -30
- package/build/components/TableHeader_V2/components/TableView/TableView.js +4 -5
- package/build/components/index.d.ts +0 -1
- package/build/components/index.js +0 -1
- package/package.json +1 -1
- package/build/components/ExportButton/ExportButton.d.ts +0 -5
- package/build/components/ExportButton/ExportButton.js +0 -13
- package/build/components/ExportButton/index.d.ts +0 -2
- package/build/components/ExportButton/index.js +0 -2
|
@@ -11,8 +11,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { memo } from 'react';
|
|
14
|
-
import { Button } from './style';
|
|
15
14
|
import Tooltip from '../../Tooltip';
|
|
15
|
+
import { Button } from './style';
|
|
16
16
|
function StyledButton(_a) {
|
|
17
17
|
var { children, title } = _a, props = __rest(_a, ["children", "title"]);
|
|
18
18
|
return (_jsx(Tooltip, Object.assign({ title: title }, { children: _jsx(Button, Object.assign({}, props, { children: children })) })));
|
|
@@ -3,12 +3,12 @@ import { memo, useEffect, useMemo, useState } from 'react';
|
|
|
3
3
|
import Box from '@mui/material/Box';
|
|
4
4
|
import { useDropzone } from 'react-dropzone';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import Icon from '../Icon';
|
|
6
7
|
import { blueCircleCheckIcon, redVerifyIcon, trashBinIcon, uploadBlueIcon } from '../../constants/index.js';
|
|
7
8
|
import { readableFileSize } from '../../utils/index.js';
|
|
8
9
|
import { Wrapper, Title, Format, FileUploader, Content, Upload, TextWrapper, Maximum, UploadAgain, StyledButton, SendBulkContainer } from './style';
|
|
9
10
|
import CircularProgressWithLabel from '../CircularProgressWithLabel';
|
|
10
11
|
import Button from '../Button/StyledButton';
|
|
11
|
-
import Icon from '../Icon';
|
|
12
12
|
function FileUpload({ accept, footer, options, isCreateLoading, progress, error, subtitleComponent, isSuccess: isUploadSuccess, onConfirm, isSendDisabled, }) {
|
|
13
13
|
const { t } = useTranslation();
|
|
14
14
|
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
import { memo, useRef, useState } from 'react';
|
|
13
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import StyledBadge, { BadgeVariants } from '../../../CountBadge';
|
|
16
16
|
import { convertToNumber, formatNumber } from '../../../../utils/index.js';
|
|
@@ -18,37 +18,56 @@ import { ChevronIcon } from './ChevronIcon';
|
|
|
18
18
|
import { ChevronContainer, Label, LabelWrapper, StyledStatusIcon, StyledDropdown, statusButtonVariants } from './style';
|
|
19
19
|
import { statusButtonIcons } from './constant';
|
|
20
20
|
export const StatusButton = memo((props) => {
|
|
21
|
-
var _a
|
|
21
|
+
var _a;
|
|
22
22
|
const { variant = 'inActive', badgeCount, icon, label, dropdownOptions, onButtonBodyClick } = props, restProps = __rest(props, ["variant", "badgeCount", "icon", "label", "dropdownOptions", "onButtonBodyClick"]);
|
|
23
|
-
const [
|
|
24
|
-
const buttonRef = useRef(null);
|
|
25
|
-
const [lastActiveStatus, setLastActiveStatus] = useState((_a = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions[0]) === null || _a === void 0 ? void 0 : _a.status);
|
|
23
|
+
const [buttonClicks, setButtonClicks] = useState(0);
|
|
26
24
|
const { t } = useTranslation();
|
|
27
|
-
const
|
|
28
|
-
const
|
|
25
|
+
const buttonRef = useRef(null);
|
|
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);
|
|
28
|
+
const hasDropdown = useMemo(() => Boolean(dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.length), [dropdownOptions]);
|
|
29
|
+
const isDropdownOpen = Boolean(anchorEl) && buttonClicks > 1;
|
|
30
|
+
const isActiveVariant = variant === 'active';
|
|
31
|
+
const badgeVariant = useMemo(() => (isActiveVariant ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE), [isActiveVariant]);
|
|
32
|
+
const statusIcon = useMemo(() => (icon ? _jsx(StyledStatusIcon, { icon: icon, variant: variant, src: statusButtonIcons[icon], alt: `${icon}-icon` }) : null), [icon, variant]);
|
|
33
|
+
const statusBadge = useMemo(() => {
|
|
34
|
+
if (!badgeCount || Number.isNaN(convertToNumber(badgeCount)))
|
|
35
|
+
return null;
|
|
36
|
+
return _jsx(StyledBadge, Object.assign({ variant: badgeVariant }, { children: formatNumber(Number(badgeCount)) }));
|
|
37
|
+
}, [badgeCount, badgeVariant]);
|
|
38
|
+
const dropdownIcon = useMemo(() => (hasDropdown ? _jsx(ChevronIcon, { isActive: isActiveVariant }) : null), [hasDropdown, isActiveVariant]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!isActiveVariant) {
|
|
41
|
+
setButtonClicks(0);
|
|
42
|
+
setAnchorEl(null);
|
|
43
|
+
}
|
|
44
|
+
}, [isActiveVariant]);
|
|
45
|
+
const handleDropdownClose = useCallback(() => {
|
|
29
46
|
setAnchorEl(null);
|
|
30
|
-
};
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
}, []);
|
|
48
|
+
const handleDropdownToggle = useCallback(() => {
|
|
49
|
+
if (!hasDropdown)
|
|
50
|
+
return;
|
|
51
|
+
setAnchorEl(isDropdownOpen ? null : buttonRef.current);
|
|
52
|
+
}, [hasDropdown, isDropdownOpen]);
|
|
53
|
+
const handleButtonClick = useCallback((e) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
(_a = props === null || props === void 0 ? void 0 : props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
57
|
+
onButtonBodyClick === null || onButtonBodyClick === void 0 ? void 0 : onButtonBodyClick(selectedStatus || ((_b = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions[0]) === null || _b === void 0 ? void 0 : _b.status) || 'all');
|
|
58
|
+
handleDropdownToggle();
|
|
59
|
+
setButtonClicks((prev) => prev + 1);
|
|
60
|
+
}, [props, onButtonBodyClick, selectedStatus, dropdownOptions, handleDropdownToggle]);
|
|
61
|
+
const handleMenuItemClick = useCallback((item) => (e) => {
|
|
62
|
+
var _a;
|
|
63
|
+
(_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, e);
|
|
64
|
+
setSelectedStatus(item.status);
|
|
65
|
+
handleDropdownClose();
|
|
66
|
+
}, [handleDropdownClose]);
|
|
67
|
+
const menuItems = useMemo(() => (dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((item) => (Object.assign(Object.assign({}, item), { onClick: handleMenuItemClick(item) })))) || [], [dropdownOptions, handleMenuItemClick]);
|
|
68
|
+
const ButtonComponent = statusButtonVariants[variant];
|
|
69
|
+
const displayLabel = selectedStatus ? t(selectedStatus) : label;
|
|
70
|
+
return (_jsxs(_Fragment, { children: [_jsx(ButtonComponent, Object.assign({ "data-testid": "StatusButton" }, restProps, { ref: buttonRef, onClick: handleButtonClick, sx: Object.assign({}, (hasDropdown && {
|
|
41
71
|
paddingInlineEnd: '27px',
|
|
42
|
-
})) }, { children: _jsxs(LabelWrapper, Object.assign({
|
|
43
|
-
e.stopPropagation();
|
|
44
|
-
e.preventDefault();
|
|
45
|
-
if (hasDropdown) {
|
|
46
|
-
setAnchorEl(buttonRef.current);
|
|
47
|
-
}
|
|
48
|
-
} }, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [statusIcon, lastActiveStatus ? t(lastActiveStatus) : label, statusBadge] })), dropdownIcon && _jsx(ChevronContainer, { children: dropdownIcon })] })) })), open && (_jsx(StyledDropdown, { open: open, onClose: handleClose, anchorEl: anchorEl, menuItems: (_b = (dropdownOptions || [])) === null || _b === void 0 ? void 0 : _b.map((item) => (Object.assign(Object.assign({}, item), { onClick: (e) => {
|
|
49
|
-
var _a;
|
|
50
|
-
(_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, e);
|
|
51
|
-
setLastActiveStatus(item.status);
|
|
52
|
-
handleClose();
|
|
53
|
-
} }))) }))] }));
|
|
72
|
+
})) }, { 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 }))] }));
|
|
54
73
|
});
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { ClickAwayListener } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import Tooltip from '../../../Tooltip';
|
|
6
5
|
import { closeXIcon, viewIcon } from '../../../../constants/index.js';
|
|
6
|
+
import { StyledButton } from '../../../Button';
|
|
7
|
+
import Icon from '../../../Icon';
|
|
7
8
|
import CustomViews from './CustomViews';
|
|
8
9
|
import DefaultViews from './DefaultViews';
|
|
9
10
|
import { ButtonStyled, ViewWrapper } from './style';
|
|
10
|
-
import { StyledButton } from '../../../Button';
|
|
11
|
-
import Icon from '../../../Icon';
|
|
12
11
|
function TableView({ onViewChange, setIsViewVisible, setTableViews, tableViews, resetTableViews }) {
|
|
13
12
|
const [anchorViewEl, setAnchorViewEl] = useState(null);
|
|
14
13
|
const [defaultViewEl, setDefaultViewElement] = useState(null);
|
|
@@ -37,7 +36,7 @@ function TableView({ onViewChange, setIsViewVisible, setTableViews, tableViews,
|
|
|
37
36
|
closeViewDropdown();
|
|
38
37
|
};
|
|
39
38
|
if (!anchorViewEl) {
|
|
40
|
-
return (_jsx(
|
|
39
|
+
return (_jsx(StyledButton, Object.assign({ title: t('tableView'), onClick: onViewButtonClick, "data-testid": "TableView_no_anchorViewEl_button" }, { children: _jsx(Icon, { src: viewIcon, alt: "view-icon", sx: { width: 14, height: 14 } }) })));
|
|
41
40
|
}
|
|
42
41
|
return (_jsx(ClickAwayListener, Object.assign({ onClickAway: closeViewDropdown }, { children: _jsxs(ViewWrapper, Object.assign({ "data-testid": "TableView" }, { children: [selectedViewInfo.id === 'custom' && (_jsx(CustomViews, { tableViews: tableViews, setTableViews: setTableViews, anchorEl: customViewEl, open: Boolean(customViewEl), onSelect: (e) => {
|
|
43
42
|
setCustomViewElement(customViewEl ? null : e.currentTarget);
|
|
@@ -21,7 +21,6 @@ export { default as StatusChip } from './StatusChip';
|
|
|
21
21
|
export { default as SimpleDialog, type SimpleDialogProps } from './SimpleDialog';
|
|
22
22
|
export { default as SearchButton } from './SearchButton';
|
|
23
23
|
export { default as Loaders } from './Loaders';
|
|
24
|
-
export { default as ExportButton } from './ExportButton';
|
|
25
24
|
export { default as DropdownMenu, type IProps, type MenuItemI, StyledIconForDropDown, StyledMenuTitle, StyledOption, StyledSelect, StyledSelectComponent, } from './DropdownMenu';
|
|
26
25
|
export { default as DockButton, type DockButtonProps, type DockButtonWrapperProps } from './DockButton';
|
|
27
26
|
export { default as DateButton } from './DateButton';
|
|
@@ -21,7 +21,6 @@ export { default as StatusChip } from './StatusChip';
|
|
|
21
21
|
export { default as SimpleDialog } from './SimpleDialog';
|
|
22
22
|
export { default as SearchButton } from './SearchButton';
|
|
23
23
|
export { default as Loaders } from './Loaders';
|
|
24
|
-
export { default as ExportButton } from './ExportButton';
|
|
25
24
|
export { default as DropdownMenu, StyledIconForDropDown, StyledMenuTitle, StyledOption, StyledSelect, StyledSelectComponent, } from './DropdownMenu';
|
|
26
25
|
export { default as DockButton } from './DockButton';
|
|
27
26
|
export { default as DateButton } from './DateButton';
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { StatusButtonProps } from '../StatusButton/type';
|
|
3
|
-
declare function SearchButton(props: Omit<StatusButtonProps, 'variant'>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
declare const _default: import("react").MemoExoticComponent<typeof SearchButton>;
|
|
5
|
-
export default _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from 'react';
|
|
3
|
-
import { styled } from '@mui/material';
|
|
4
|
-
import StatusButton from '../StatusButton';
|
|
5
|
-
const StyledExportButton = styled(StatusButton)(() => ({
|
|
6
|
-
minWidth: 'auto',
|
|
7
|
-
borderRadius: '4px',
|
|
8
|
-
paddingInline: '8px',
|
|
9
|
-
}));
|
|
10
|
-
function SearchButton(props) {
|
|
11
|
-
return _jsx(StyledExportButton, Object.assign({}, props, { type: "button", variant: "inActive" }));
|
|
12
|
-
}
|
|
13
|
-
export default memo(SearchButton);
|