@tap-payments/os-micro-frontend-shared 0.0.30 → 0.0.31-dev-shared-migration-v1

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.
Files changed (81) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +12 -12
  3. package/build/components/Chip/Chip.d.ts +4 -0
  4. package/build/components/Chip/Chip.js +19 -0
  5. package/build/components/Chip/GroupIconChip.d.ts +3 -0
  6. package/build/components/Chip/GroupIconChip.js +11 -0
  7. package/build/components/Chip/GroupIconChips.d.ts +3 -0
  8. package/build/components/Chip/GroupIconChips.js +10 -0
  9. package/build/components/Chip/index.d.ts +4 -0
  10. package/build/components/Chip/index.js +4 -0
  11. package/build/components/Chip/style.d.ts +293 -0
  12. package/build/components/Chip/style.js +78 -0
  13. package/build/components/Chip/type.d.ts +13 -0
  14. package/build/components/Chip/type.js +1 -0
  15. package/build/components/MultiSelectDropdownButton/MultiSelectDropdownButton.js +3 -3
  16. package/build/components/TableHeader_V2/FiltersRow.d.ts +2 -0
  17. package/build/components/TableHeader_V2/FiltersRow.js +5 -0
  18. package/build/components/TableHeader_V2/TableHeader.d.ts +4 -0
  19. package/build/components/TableHeader_V2/TableHeader.js +7 -0
  20. package/build/components/TableHeader_V2/components/StatusButtons/ChevronIcon.d.ts +2 -0
  21. package/build/components/TableHeader_V2/components/StatusButtons/ChevronIcon.js +16 -0
  22. package/build/components/TableHeader_V2/components/StatusButtons/StatusButton.d.ts +3 -0
  23. package/build/components/TableHeader_V2/components/StatusButtons/StatusButton.js +54 -0
  24. package/build/components/TableHeader_V2/components/StatusButtons/StatusButtons.d.ts +11 -0
  25. package/build/components/TableHeader_V2/components/StatusButtons/StatusButtons.js +38 -0
  26. package/build/components/TableHeader_V2/components/StatusButtons/constant.d.ts +24 -0
  27. package/build/components/TableHeader_V2/components/StatusButtons/constant.js +25 -0
  28. package/build/components/TableHeader_V2/components/StatusButtons/index.d.ts +3 -0
  29. package/build/components/TableHeader_V2/components/StatusButtons/index.js +3 -0
  30. package/build/components/TableHeader_V2/components/StatusButtons/style.d.ts +35 -0
  31. package/build/components/TableHeader_V2/components/StatusButtons/style.js +74 -0
  32. package/build/components/TableHeader_V2/components/StatusButtons/type.d.ts +22 -0
  33. package/build/components/TableHeader_V2/components/StatusButtons/type.js +1 -0
  34. package/build/components/TableHeader_V2/components/TableView/CustomViews.d.ts +13 -0
  35. package/build/components/TableHeader_V2/components/TableView/CustomViews.js +78 -0
  36. package/build/components/TableHeader_V2/components/TableView/DefaultViews.d.ts +13 -0
  37. package/build/components/TableHeader_V2/components/TableView/DefaultViews.js +22 -0
  38. package/build/components/TableHeader_V2/components/TableView/TableView.d.ts +12 -0
  39. package/build/components/TableHeader_V2/components/TableView/TableView.js +55 -0
  40. package/build/components/TableHeader_V2/components/TableView/index.d.ts +3 -0
  41. package/build/components/TableHeader_V2/components/TableView/index.js +3 -0
  42. package/build/components/TableHeader_V2/components/TableView/style.d.ts +24 -0
  43. package/build/components/TableHeader_V2/components/TableView/style.js +102 -0
  44. package/build/components/TableHeader_V2/components/index.d.ts +2 -0
  45. package/build/components/TableHeader_V2/components/index.js +2 -0
  46. package/build/components/TableHeader_V2/data.d.ts +5 -0
  47. package/build/components/TableHeader_V2/data.js +7 -0
  48. package/build/components/TableHeader_V2/index.d.ts +5 -0
  49. package/build/components/TableHeader_V2/index.js +5 -0
  50. package/build/components/TableHeader_V2/style.d.ts +21 -0
  51. package/build/components/TableHeader_V2/style.js +43 -0
  52. package/build/components/TableHeader_V2/type.d.ts +67 -0
  53. package/build/components/TableHeader_V2/type.js +8 -0
  54. package/build/components/VirtualTable/components/ColumnFilter/ColumnFilter.js +16 -10
  55. package/build/components/VirtualTable/components/ColumnFilter/Inputs/Inputs.js +66 -14
  56. package/build/components/VirtualTable/components/ColumnFilter/List/List.js +1 -1
  57. package/build/components/VirtualTable/components/index.d.ts +1 -1
  58. package/build/components/VirtualTable/components/index.js +1 -1
  59. package/build/components/VirtualTable/index.d.ts +1 -0
  60. package/build/components/VirtualTable/index.js +1 -0
  61. package/build/components/index.d.ts +1 -1
  62. package/build/components/index.js +1 -1
  63. package/build/constants/api.d.ts +3 -0
  64. package/build/constants/api.js +3 -0
  65. package/build/constants/apps.d.ts +3 -0
  66. package/build/constants/apps.js +9 -1
  67. package/build/constants/assets.d.ts +8 -0
  68. package/build/constants/assets.js +8 -0
  69. package/build/constants/table/cell/index.d.ts +1 -0
  70. package/build/constants/table/cell/index.js +1 -0
  71. package/build/constants/table/cell/merchantsTableCellWidth.d.ts +6 -2
  72. package/build/constants/table/cell/merchantsTableCellWidth.js +6 -2
  73. package/build/constants/table/cell/terminalsTableCellWidth.d.ts +46 -0
  74. package/build/constants/table/cell/terminalsTableCellWidth.js +46 -0
  75. package/build/theme/palette.js +1 -0
  76. package/build/types/cell.d.ts +5 -1
  77. package/build/types/table.d.ts +17 -7
  78. package/build/utils/string.d.ts +1 -0
  79. package/build/utils/string.js +1 -0
  80. package/build/utils/table.js +3 -1
  81. package/package.json +130 -130
@@ -0,0 +1,54 @@
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, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { memo, useRef, useState } from 'react';
14
+ import { useTranslation } from 'react-i18next';
15
+ import StyledBadge, { BadgeVariants } from '../../../CountBadge';
16
+ import { convertToNumber, formatNumber } from '../../../../utils/index.js';
17
+ import { ChevronIcon } from './ChevronIcon';
18
+ import { ChevronContainer, Label, LabelWrapper, StatusIcon, StyledDropdown, statusButtonVariants } from './style';
19
+ import { statusButtonIcons } from './constant';
20
+ export const StatusButton = memo((props) => {
21
+ var _a, _b;
22
+ const { variant = 'inActive', badgeCount, icon, label, dropdownOptions, onButtonBodyClick } = props, restProps = __rest(props, ["variant", "badgeCount", "icon", "label", "dropdownOptions", "onButtonBodyClick"]);
23
+ const [anchorEl, setAnchorEl] = useState(null);
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);
26
+ const { t } = useTranslation();
27
+ const open = Boolean(anchorEl);
28
+ const handleClose = () => {
29
+ setAnchorEl(null);
30
+ };
31
+ const Button = statusButtonVariants[variant];
32
+ const hasDropdown = dropdownOptions && dropdownOptions.length > 0;
33
+ const statusIcon = icon ? _jsx(StatusIcon, { icon: icon, variant: variant, src: statusButtonIcons[icon], alt: `${icon}-icon` }) : null;
34
+ const statusBadge = badgeCount && !Number.isNaN(convertToNumber(badgeCount)) ? (_jsx(StyledBadge, Object.assign({ variant: variant === 'active' ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE }, { children: formatNumber(Number(badgeCount)) }))) : null;
35
+ const dropdownIcon = hasDropdown ? _jsx(ChevronIcon, { isActive: variant === 'active' }) : null;
36
+ return (_jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ "data-testid": "StatusButton" }, restProps, { ref: buttonRef, onClick: (e) => {
37
+ var _a, _b;
38
+ (_a = props === null || props === void 0 ? void 0 : props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
39
+ onButtonBodyClick === null || onButtonBodyClick === void 0 ? void 0 : onButtonBodyClick(lastActiveStatus || ((_b = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions[0]) === null || _b === void 0 ? void 0 : _b.status) || 'all');
40
+ }, sx: Object.assign({}, (hasDropdown && {
41
+ paddingInlineEnd: '27px',
42
+ })) }, { children: _jsxs(LabelWrapper, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [statusIcon, lastActiveStatus ? t(lastActiveStatus) : label, statusBadge] })), dropdownIcon && (_jsx(ChevronContainer, Object.assign({ onClick: (e) => {
43
+ e.stopPropagation();
44
+ e.preventDefault();
45
+ if (hasDropdown) {
46
+ setAnchorEl(buttonRef.current);
47
+ }
48
+ } }, { 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
+ } }))) }))] }));
54
+ });
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { AvailableStatus } from '../../type';
3
+ import { TableHeaderStatus } from '../../../../types/index.js';
4
+ export type StatusButtonsProps = {
5
+ availableStatuses: AvailableStatus[];
6
+ status: TableHeaderStatus;
7
+ onStatusChange?: (status: Partial<TableHeaderStatus>) => void;
8
+ isFilteredIdsShown?: boolean;
9
+ };
10
+ declare const _default: import("react").MemoExoticComponent<(props: StatusButtonsProps) => import("react/jsx-runtime").JSX.Element>;
11
+ export default _default;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ import { memo, useMemo } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { StatusButton } from './StatusButton';
6
+ const StatusButtonItem = memo((props) => {
7
+ var _a;
8
+ const { availableStatus, getButtonStatus, onStatusChange, status } = props;
9
+ const { t } = useTranslation();
10
+ if (!Array.isArray(availableStatus.status)) {
11
+ return (_createElement(StatusButton, Object.assign({}, availableStatus, { key: `status-button-array-${availableStatus.status}`, variant: getButtonStatus(availableStatus.status), onClick: () => {
12
+ if (!Array.isArray(availableStatus.status)) {
13
+ onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(availableStatus.status);
14
+ }
15
+ } })));
16
+ }
17
+ const isCurrentStatusDropdown = (_a = availableStatus.status) === null || _a === void 0 ? void 0 : _a.includes(status || '');
18
+ const variant = isCurrentStatusDropdown ? 'active' : 'inActive';
19
+ const statusLabel = isCurrentStatusDropdown ? status : availableStatus.status[0];
20
+ return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, availableStatus, { label: t(statusLabel || ''), variant: variant, onButtonBodyClick: (buttonStatus) => {
21
+ onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(buttonStatus);
22
+ }, dropdownOptions: availableStatus.status.map((stat) => ({
23
+ label: t(stat || ''),
24
+ onClick: () => {
25
+ onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(stat);
26
+ },
27
+ status: stat,
28
+ })) })) }));
29
+ });
30
+ const StatusButtons = (props) => {
31
+ const { availableStatuses, status, onStatusChange, isFilteredIdsShown } = props;
32
+ const getButtonStatus = useMemo(() => (buttonStatus) => buttonStatus === status && !isFilteredIdsShown ? 'active' : 'inActive', [status, isFilteredIdsShown]);
33
+ return (_jsx(_Fragment, { children: availableStatuses === null || availableStatuses === void 0 ? void 0 : availableStatuses.map((availableStatus) => {
34
+ var _a;
35
+ return (_jsx(StatusButtonItem, { availableStatus: availableStatus, getButtonStatus: getButtonStatus, onStatusChange: onStatusChange, status: status }, Array.isArray(availableStatus.status) ? (_a = availableStatus === null || availableStatus === void 0 ? void 0 : availableStatus.status) === null || _a === void 0 ? void 0 : _a[0] : `status-button-array-${availableStatus.status}`));
36
+ }) }));
37
+ };
38
+ export default memo(StatusButtons);
@@ -0,0 +1,24 @@
1
+ export declare const statusButtonIcons: {
2
+ inProgress: string;
3
+ initiated: string;
4
+ abandoned: string;
5
+ cancelled: string;
6
+ reversed: string;
7
+ reports: string;
8
+ view: string;
9
+ search: string;
10
+ chevronDown: string;
11
+ unAuthorized: string;
12
+ unSettled: string;
13
+ unCaptured: string;
14
+ captured: string;
15
+ authorized: string;
16
+ openFlag: string;
17
+ closedFlag: string;
18
+ unauthenticated: string;
19
+ authenticated: string;
20
+ textView: string;
21
+ paidOut: string;
22
+ scheduled: string;
23
+ trashBin: string;
24
+ };
@@ -0,0 +1,25 @@
1
+ import { initiatedIcon, abandonedIcon, cancelledIcon, reportsIcon, viewIcon, searchIcon, chevronDownIcon, unAuthorizedIcon, settlementInitiatedIcon, unCapturedIcon, capturedIcon, authorizedIcon, openFlagIcon, closedFlagIcon, reverseActionIcon, authenticatedIcon, unauthenticatedIcon, longWordsIcon, paidOutFilterIcon, scheduledFilterIcon, trashBinIcon, } from '../../../../constants/index.js';
2
+ export const statusButtonIcons = {
3
+ inProgress: initiatedIcon,
4
+ initiated: initiatedIcon,
5
+ abandoned: abandonedIcon,
6
+ cancelled: cancelledIcon,
7
+ reversed: reverseActionIcon,
8
+ reports: reportsIcon,
9
+ view: viewIcon,
10
+ search: searchIcon,
11
+ chevronDown: chevronDownIcon,
12
+ unAuthorized: unAuthorizedIcon,
13
+ unSettled: settlementInitiatedIcon,
14
+ unCaptured: unCapturedIcon,
15
+ captured: capturedIcon,
16
+ authorized: authorizedIcon,
17
+ openFlag: openFlagIcon,
18
+ closedFlag: closedFlagIcon,
19
+ unauthenticated: unauthenticatedIcon,
20
+ authenticated: authenticatedIcon,
21
+ textView: longWordsIcon,
22
+ paidOut: paidOutFilterIcon,
23
+ scheduled: scheduledFilterIcon,
24
+ trashBin: trashBinIcon,
25
+ };
@@ -0,0 +1,3 @@
1
+ export { default as StatusButtons } from './StatusButtons';
2
+ export * from './StatusButton';
3
+ export * from './style';
@@ -0,0 +1,3 @@
1
+ export { default as StatusButtons } from './StatusButtons';
2
+ export * from './StatusButton';
3
+ export * from './style';
@@ -0,0 +1,35 @@
1
+ import type React from 'react';
2
+ import { type Theme } from '@mui/material';
3
+ export declare const statusButtonVariants: {
4
+ active: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
5
+ ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
6
+ }, "disabled" | "className" | "style" | "classes" | "color" | "children" | "sx" | "tabIndex" | "size" | "variant" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "href" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "startIcon"> & import("@mui/system").MUIStyledCommonProps<Theme> & {
7
+ icon?: string | undefined;
8
+ }, {}, {}>;
9
+ inActive: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
10
+ ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
11
+ }, "disabled" | "className" | "style" | "classes" | "color" | "children" | "sx" | "tabIndex" | "size" | "variant" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "href" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "startIcon"> & import("@mui/system").MUIStyledCommonProps<Theme> & {
12
+ icon?: string | undefined;
13
+ }, {}, {}>;
14
+ };
15
+ export type StatusButtonVariant = keyof typeof statusButtonVariants;
16
+ export declare const CountBadge: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
17
+ ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
18
+ }, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme> & {
19
+ variant: StatusButtonVariant;
20
+ }, {}, {}>;
21
+ export declare const StatusIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme> & {
22
+ variant: StatusButtonVariant;
23
+ icon?: "initiated" | "captured" | "unCaptured" | "inProgress" | "abandoned" | "cancelled" | "reversed" | "authorized" | "paidOut" | "unauthenticated" | "authenticated" | "scheduled" | "unSettled" | "search" | "view" | "reports" | "chevronDown" | "unAuthorized" | "openFlag" | "closedFlag" | "textView" | "trashBin" | undefined;
24
+ }, React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
25
+ export declare const StyledFilterName: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, {}>;
26
+ export declare const StyledDropdown: import("@emotion/styled").StyledComponent<import("../../..").IProps & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
27
+ export declare const ChevronContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
28
+ export declare const Label: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
29
+ ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
30
+ }, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme> & {
31
+ variant: StatusButtonVariant;
32
+ }, {}, {}>;
33
+ export declare const LabelWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
34
+ ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
35
+ }, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
@@ -0,0 +1,74 @@
1
+ import { styled, Button, Box, alpha } from '@mui/material';
2
+ import Dropdown from '../../../DropdownMenu/DropdownMenu';
3
+ const baseButtonStyle = (theme) => (Object.assign(Object.assign({}, theme.typography.subtitle1), { borderRadius: '50px', borderWidth: '1px', borderStyle: 'solid', minWidth: '135.11px', height: '32px', display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '8px', textTransform: 'none', transition: 'none', paddingInline: theme.spacing(2) }));
4
+ const ActiveButton = styled(Button)(({ theme }) => (Object.assign(Object.assign({}, baseButtonStyle(theme)), { background: theme.palette.background.gradient.shadedBlue, color: theme.palette.common.white, '&:hover': {
5
+ background: theme.palette.background.gradient.shadedBlue,
6
+ opacity: 0.8,
7
+ } })));
8
+ const InActiveButton = styled(Button)(({ theme }) => (Object.assign(Object.assign({}, baseButtonStyle(theme)), { backgroundColor: theme.palette.common.white, borderColor: theme.palette.grey[100], color: theme.palette.text.primary, '&:hover': {
9
+ backgroundColor: theme.palette.common.white,
10
+ opacity: 0.7,
11
+ } })));
12
+ export const statusButtonVariants = {
13
+ active: ActiveButton,
14
+ inActive: InActiveButton,
15
+ };
16
+ export const CountBadge = styled(Box)(({ theme, variant }) => ({
17
+ borderRadius: '50px',
18
+ backgroundColor: variant === 'active' ? alpha(theme.palette.text.primary, 0.1) : theme.palette.grey[100],
19
+ display: 'flex',
20
+ justifyContent: 'center',
21
+ alignItems: 'center',
22
+ paddingInline: theme.spacing(0.5),
23
+ paddingBlock: theme.spacing(0.25),
24
+ color: variant === 'active' ? theme.palette.common.white : theme.palette.text.primary,
25
+ fontSize: '8px',
26
+ fontWeight: 700,
27
+ lineHeight: '10px',
28
+ }));
29
+ export const StatusIcon = styled('img')(({ theme, variant, icon }) => {
30
+ var _a;
31
+ return (Object.assign(Object.assign({ fill: variant === 'active' ? theme.palette.common.white : theme.palette.text.primary, color: variant === 'active' ? theme.palette.common.white : theme.palette.text.primary }, (!(((_a = ['openFlag', 'closedFlag']) === null || _a === void 0 ? void 0 : _a.includes(icon !== null && icon !== void 0 ? icon : '')) && variant === 'inActive') &&
32
+ icon !== 'captured' && {
33
+ filter: variant === 'active' ? 'brightness(0) invert(1)' : 'brightness(0) invert(0)',
34
+ })), { maxWidth: '14px', maxHeight: '14px' }));
35
+ });
36
+ export const StyledFilterName = styled('p')(({ theme }) => ({
37
+ fontSize: '0.6875rem',
38
+ color: theme.palette.background.default,
39
+ fontStyle: 'normal',
40
+ margin: 'auto',
41
+ textTransform: 'capitalize',
42
+ }));
43
+ export const StyledDropdown = styled(Dropdown)(({ theme }) => ({
44
+ backgroundColor: 'white',
45
+ boxShadow: theme.shadows[21],
46
+ borderRadius: '0.25rem',
47
+ '& .MuiPaper-root': {
48
+ borderRadius: '0.25rem',
49
+ width: '12.5rem',
50
+ },
51
+ }));
52
+ export const ChevronContainer = styled('span')(() => ({
53
+ width: '27px',
54
+ height: '100%',
55
+ maxHeight: '100%',
56
+ position: 'absolute',
57
+ top: '0',
58
+ right: '0',
59
+ bottom: '0',
60
+ overflow: 'hidden',
61
+ }));
62
+ export const Label = styled(Box)(({ variant }) => ({
63
+ display: 'flex',
64
+ alignItems: 'center',
65
+ justifyContent: 'flex-start',
66
+ gap: '0.5rem',
67
+ fontWeight: variant === 'active' ? 700 : 400,
68
+ }));
69
+ export const LabelWrapper = styled(Box)(() => ({
70
+ display: 'flex',
71
+ alignItems: 'center',
72
+ justifyContent: 'center',
73
+ width: '100%',
74
+ }));
@@ -0,0 +1,22 @@
1
+ import { ReactNode } from 'react';
2
+ import { type ButtonProps } from '@mui/material';
3
+ import { TableHeaderStatus } from '../../../../types/index.js';
4
+ import { type StatusButtonVariant } from './style';
5
+ import { statusButtonIcons } from './constant';
6
+ import { MenuItemI } from '../../../DropdownMenu';
7
+ export interface StatusButtonProps extends Omit<ButtonProps, 'variant' | 'children'> {
8
+ variant?: StatusButtonVariant;
9
+ badgeCount?: number | string;
10
+ hasDropdown?: boolean;
11
+ icon?: StatusButtonIcon;
12
+ label?: ReactNode | null;
13
+ totalCount?: number;
14
+ onButtonBodyClick?: (status: TableHeaderStatus) => void;
15
+ dropdownOptions?: Array<MenuItemI & {
16
+ status: TableHeaderStatus;
17
+ }>;
18
+ }
19
+ export interface ChevronIconProps {
20
+ isActive?: boolean;
21
+ }
22
+ export type StatusButtonIcon = keyof typeof statusButtonIcons;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { TableHeaderProps } from '../../type';
3
+ interface CustomViewsProps {
4
+ open: boolean;
5
+ onSelect: (e: React.MouseEvent<HTMLDivElement>) => void;
6
+ setTableViews: TableHeaderProps['setTableViews'];
7
+ tableViews: TableHeaderProps['tableViews'];
8
+ anchorEl: Element | null;
9
+ onClose: () => void;
10
+ }
11
+ declare function CustomViews({ open, onSelect, setTableViews: setColumns, tableViews, anchorEl, onClose }: Readonly<CustomViewsProps>): import("react/jsx-runtime").JSX.Element;
12
+ declare const _default: React.MemoExoticComponent<typeof CustomViews>;
13
+ export default _default;
@@ -0,0 +1,78 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import startCase from 'lodash/startCase';
5
+ import { Reorder } from 'framer-motion';
6
+ import Box from '@mui/material/Box';
7
+ import Menu from '@mui/material/Menu';
8
+ import { useTheme } from '@mui/material/styles';
9
+ import { downArrowIcon } from '../../../../constants/index.js';
10
+ import { ButtonStyled, ListStyled, DropdownStyled } from './style';
11
+ import { NestedMenuItem as MenuItem } from '../../../NestedDropdown';
12
+ function CustomViews({ open, onSelect, setTableViews: setColumns, tableViews, anchorEl, onClose }) {
13
+ const columns = tableViews || [];
14
+ const { t } = useTranslation();
15
+ const theme = useTheme();
16
+ const modifyColumns = (selectedCols) => {
17
+ const newColumns = selectedCols === null || selectedCols === void 0 ? void 0 : selectedCols.map((col) => {
18
+ const selectedColumn = columns.find((column) => column.name === col);
19
+ return selectedColumn;
20
+ });
21
+ setColumns === null || setColumns === void 0 ? void 0 : setColumns(newColumns);
22
+ };
23
+ const handleUnSelectColumn = (selectedCols) => {
24
+ const newCols = columns.map((column) => {
25
+ var _a;
26
+ const newMenuItems = (_a = column.menuItems) === null || _a === void 0 ? void 0 : _a.map((menuItem) => {
27
+ if (menuItem.name === selectedCols.name) {
28
+ return Object.assign(Object.assign({}, menuItem), { selected: false });
29
+ }
30
+ return menuItem;
31
+ });
32
+ return Object.assign(Object.assign({}, column), { selected: newMenuItems === null || newMenuItems === void 0 ? void 0 : newMenuItems.every((i) => i.selected), menuItems: newMenuItems });
33
+ });
34
+ setColumns === null || setColumns === void 0 ? void 0 : setColumns(newCols);
35
+ };
36
+ const orderedColumns = columns === null || columns === void 0 ? void 0 : columns.map((column) => column.name);
37
+ return (_jsxs(DropdownStyled, Object.assign({ "data-testid": "TableView_CustomViews" }, { children: [_jsxs(ButtonStyled, Object.assign({ "data-testid": "TableView_CustomViews_Button", onClick: (e) => {
38
+ onSelect(e);
39
+ } }, { children: [_jsx("div", { children: t('columns') }), _jsx("img", { src: downArrowIcon, alt: "arrow", style: Object.assign({}, (Boolean(open) && { transform: 'rotate(180deg)' })) })] })), _jsx(Menu, Object.assign({ open: open, anchorEl: anchorEl, "data-testid": "TableView_CustomViews_Popper", sx: { padding: 0, marginTop: '8px' }, MenuListProps: { sx: { py: 0 } }, onClose: onClose }, { children: _jsx(ListStyled, Object.assign({ component: "article", "data-testid": "TableView_CustomViews_List" }, { children: _jsx(Reorder.Group, Object.assign({ as: "div", axis: "y", onReorder: modifyColumns, values: orderedColumns, style: { maxHeight: 500, overflowY: 'auto' } }, { children: orderedColumns.map((name, index) => {
40
+ var _a;
41
+ const selectedColumn = columns.find((col) => col.name === name);
42
+ return (_jsx(Box, Object.assign({ sx: Object.assign({ borderTop: `1px solid ${theme.palette.divider}` }, (index === 0 && { borderTop: 'none', height: 33 })) }, { children: _jsx(MenuItem, Object.assign({ setSelected: ({ name: selectedName, selected }) => {
43
+ const newMenuItems = columns === null || columns === void 0 ? void 0 : columns.map((menuItem) => {
44
+ var _a;
45
+ if (menuItem.name === selectedName) {
46
+ return Object.assign(Object.assign({}, menuItem), { selected, menuItems: (_a = menuItem.menuItems) === null || _a === void 0 ? void 0 : _a.map((childItem) => {
47
+ return Object.assign(Object.assign({}, childItem), { selected });
48
+ }) });
49
+ }
50
+ return menuItem;
51
+ });
52
+ setColumns === null || setColumns === void 0 ? void 0 : setColumns(newMenuItems || []);
53
+ }, onSelect: (selectedChild, parentName) => {
54
+ handleUnSelectColumn(selectedChild[0]);
55
+ const newMenuItems = columns === null || columns === void 0 ? void 0 : columns.map((menuItem) => {
56
+ var _a;
57
+ if (menuItem.name === parentName) {
58
+ const newChildren = (_a = menuItem.menuItems) === null || _a === void 0 ? void 0 : _a.map((childItem) => {
59
+ var _a, _b;
60
+ if (childItem.name === ((_a = selectedChild[0]) === null || _a === void 0 ? void 0 : _a.name)) {
61
+ return Object.assign(Object.assign({}, childItem), { selected: (_b = selectedChild[0]) === null || _b === void 0 ? void 0 : _b.selected });
62
+ }
63
+ return childItem;
64
+ });
65
+ return Object.assign(Object.assign({}, menuItem), { menuItems: newChildren, selected: newChildren === null || newChildren === void 0 ? void 0 : newChildren.some((i) => i.selected) });
66
+ }
67
+ return menuItem;
68
+ });
69
+ setColumns === null || setColumns === void 0 ? void 0 : setColumns(newMenuItems || []);
70
+ } }, {
71
+ name,
72
+ selected: selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.selected,
73
+ label: (_a = t(selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.label)) !== null && _a !== void 0 ? _a : startCase(selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.label),
74
+ menuItems: selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.menuItems,
75
+ }), `${name}`) }), `${name}`));
76
+ }) })) })) }))] })));
77
+ }
78
+ export default React.memo(CustomViews);
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { ViewOption } from '../../type';
3
+ interface DefaultViewsProps {
4
+ open: boolean;
5
+ selectedViewInfo: ViewOption;
6
+ setSelectedViewInfo: (selectedView: ViewOption) => void;
7
+ onSelect: (e: React.MouseEvent<HTMLDivElement>) => void;
8
+ setViews?: (views: string[]) => void;
9
+ anchorEl: Element | null;
10
+ }
11
+ declare function DefaultViews({ open, selectedViewInfo, setSelectedViewInfo, onSelect, setViews, anchorEl }: Readonly<DefaultViewsProps>): import("react/jsx-runtime").JSX.Element;
12
+ declare const _default: React.MemoExoticComponent<typeof DefaultViews>;
13
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import Popper from '@mui/material/Popper';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { downArrowIcon, checkIcon } from '../../../../constants/index.js';
6
+ import { ButtonStyled, ListStyled, DropdownStyled, MenuItem, Space, SpaceAfter } from './style';
7
+ import { dummyViewList } from '../../data';
8
+ function DefaultViews({ open, selectedViewInfo, setSelectedViewInfo, onSelect, setViews, anchorEl }) {
9
+ const { t } = useTranslation();
10
+ return (_jsxs(DropdownStyled, Object.assign({ "data-testid": "TableView_DefaultViews" }, { children: [_jsxs(ButtonStyled, Object.assign({ onClick: (e) => {
11
+ onSelect(e);
12
+ } }, { children: [_jsx("div", { children: selectedViewInfo.label }), _jsx("img", { src: downArrowIcon, alt: "arrow", style: Object.assign({}, (Boolean(open) && { transform: 'rotate(180deg)' })) })] })), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-start" }, { children: _jsxs(ListStyled, { children: [dummyViewList.map((item) => (_jsxs(MenuItem, Object.assign({ onClick: () => {
13
+ setSelectedViewInfo(item);
14
+ setViews === null || setViews === void 0 ? void 0 : setViews(item.columns);
15
+ } }, { children: [item.id === selectedViewInfo.id ? _jsx("img", { className: "check-icon", src: checkIcon, alt: "arrow" }) : _jsx(Space, {}), _jsx("span", { children: item.label }), _jsx(SpaceAfter, {})] }), item.id))), _jsxs(MenuItem, Object.assign({ sx: {
16
+ border: 'none',
17
+ }, onClick: (e) => {
18
+ e.stopPropagation();
19
+ setSelectedViewInfo({ label: 'Custom view', id: 'custom' });
20
+ } }, { children: [selectedViewInfo.id === 'custom' ? _jsx("img", { className: "check-icon", src: checkIcon, alt: "arrow" }) : _jsx(Space, {}), _jsx("span", { children: t('createCustomView') }), _jsx(SpaceAfter, {})] }))] }) }))] })));
21
+ }
22
+ export default React.memo(DefaultViews);
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { TableHeaderProps } from '../../type';
3
+ interface TableViewProps {
4
+ onViewChange?: TableHeaderProps['onViewChange'];
5
+ setIsViewVisible: (visible: boolean) => void;
6
+ setTableViews: TableHeaderProps['setTableViews'];
7
+ tableViews: TableHeaderProps['tableViews'];
8
+ resetTableViews: TableHeaderProps['resetTableViews'];
9
+ }
10
+ declare function TableView({ onViewChange, setIsViewVisible, setTableViews, tableViews, resetTableViews }: Readonly<TableViewProps>): import("react/jsx-runtime").JSX.Element;
11
+ declare const _default: import("react").MemoExoticComponent<typeof TableView>;
12
+ export default _default;
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useState } from 'react';
3
+ import { Box, ClickAwayListener } from '@mui/material';
4
+ import { useTranslation } from 'react-i18next';
5
+ import ExportButton from '../../../ExportButton';
6
+ import Tooltip from '../../../Tooltip';
7
+ import { closeXIcon } from '../../../../constants/index.js';
8
+ import CustomViews from './CustomViews';
9
+ import DefaultViews from './DefaultViews';
10
+ import { ButtonStyled, ViewWrapper } from './style';
11
+ function TableView({ onViewChange, setIsViewVisible, setTableViews, tableViews, resetTableViews }) {
12
+ const [anchorViewEl, setAnchorViewEl] = useState(null);
13
+ const [defaultViewEl, setDefaultViewElement] = useState(null);
14
+ const [customViewEl, setCustomViewElement] = useState(null);
15
+ const [selectedViewInfo, setSelectedViewInfo] = useState({
16
+ id: 'default',
17
+ label: 'Default',
18
+ });
19
+ const { t } = useTranslation();
20
+ const onViewButtonClick = (event) => {
21
+ onViewChange === null || onViewChange === void 0 ? void 0 : onViewChange();
22
+ setAnchorViewEl(event.currentTarget);
23
+ setIsViewVisible(true);
24
+ };
25
+ const closeViewDropdown = () => {
26
+ setDefaultViewElement(null);
27
+ setCustomViewElement(null);
28
+ };
29
+ const onClose = () => {
30
+ setAnchorViewEl(null);
31
+ setIsViewVisible(false);
32
+ setSelectedViewInfo({ label: 'Default', id: 'default' });
33
+ };
34
+ const handleSelectedViewInfo = (selected) => {
35
+ setSelectedViewInfo(selected);
36
+ closeViewDropdown();
37
+ };
38
+ if (!anchorViewEl) {
39
+ return (_jsx(Tooltip, Object.assign({ title: t('tableView'), "data-testid": "TableView_no_anchorViewEl" }, { children: _jsx(Box, { children: _jsx(ExportButton, { icon: "view", onClick: onViewButtonClick, "data-testid": "TableView_no_anchorViewEl_button" }) }) })));
40
+ }
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) => {
42
+ setCustomViewElement(customViewEl ? null : e.currentTarget);
43
+ setDefaultViewElement(null);
44
+ }, onClose: () => {
45
+ setCustomViewElement(null);
46
+ } })), _jsx(DefaultViews, { open: Boolean(defaultViewEl), anchorEl: defaultViewEl, setSelectedViewInfo: (view) => {
47
+ handleSelectedViewInfo(view);
48
+ }, selectedViewInfo: selectedViewInfo, onSelect: (e) => {
49
+ setDefaultViewElement(defaultViewEl ? null : e.currentTarget);
50
+ setCustomViewElement(null);
51
+ }, setViews: (views) => {
52
+ resetTableViews === null || resetTableViews === void 0 ? void 0 : resetTableViews({ id: views[0], label: views[0] });
53
+ } }), _jsx(ButtonStyled, Object.assign({ sx: { width: 30, justifyContent: 'center' }, onClick: onClose }, { children: _jsx("img", { src: closeXIcon, alt: "close" }) }))] })) })));
54
+ }
55
+ export default memo(TableView);
@@ -0,0 +1,3 @@
1
+ export { default as TableView } from './TableView';
2
+ export * from './TableView';
3
+ export * from './style';
@@ -0,0 +1,3 @@
1
+ export { default as TableView } from './TableView';
2
+ export * from './TableView';
3
+ export * from './style';
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ export declare const ButtonStyled: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
4
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
5
+ export declare const ViewWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
6
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
7
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
8
+ export declare const ListStyled: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
9
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
10
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
11
+ export declare const DropdownStyled: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
12
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
13
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
14
+ export declare const MenuItem: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
15
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
16
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
17
+ addColumnViewEl?: boolean | undefined;
18
+ }, {}, {}>;
19
+ export declare const Space: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
20
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
21
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
22
+ export declare const SpaceAfter: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
23
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
24
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;