@tap-payments/os-micro-frontend-shared 0.1.390-test.2-test.3 → 0.1.391-test.1

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 (52) hide show
  1. package/build/components/StatusBar/StatusBar.js +3 -3
  2. package/build/components/StatusButton/StatusButton.js +4 -16
  3. package/build/components/StatusButton/style.d.ts +0 -5
  4. package/build/components/StatusButton/style.js +0 -11
  5. package/build/components/TableCells/CustomCells/InvoiceStatusCell/ChargeStatusIcon.d.ts +11 -0
  6. package/build/components/TableCells/CustomCells/InvoiceStatusCell/ChargeStatusIcon.js +15 -0
  7. package/build/components/TableCells/CustomCells/InvoiceStatusCell/InvoiceStatusCell.d.ts +2 -2
  8. package/build/components/TableCells/CustomCells/InvoiceStatusCell/InvoiceStatusCell.js +39 -59
  9. package/build/components/TableCells/CustomCells/InvoiceStatusCell/style.d.ts +2 -0
  10. package/build/components/TableCells/CustomCells/InvoiceStatusCell/style.js +18 -0
  11. package/build/components/TableCells/CustomCells/InvoiceStatusCell/type.d.ts +2 -1
  12. package/build/components/TreeDropdown/TreeDropdown.d.ts +4 -0
  13. package/build/components/TreeDropdown/TreeDropdown.js +53 -0
  14. package/build/components/TreeDropdown/TreeNodeItem/SelectionControl.d.ts +8 -0
  15. package/build/components/TreeDropdown/TreeNodeItem/SelectionControl.js +17 -0
  16. package/build/components/TreeDropdown/TreeNodeItem/TreeNodeItem.d.ts +12 -0
  17. package/build/components/TreeDropdown/TreeNodeItem/TreeNodeItem.js +64 -0
  18. package/build/components/TreeDropdown/TreeNodeItem/index.d.ts +2 -0
  19. package/build/components/TreeDropdown/TreeNodeItem/index.js +2 -0
  20. package/build/components/TreeDropdown/TreeNodeItem/style.d.ts +14 -0
  21. package/build/components/TreeDropdown/TreeNodeItem/style.js +46 -0
  22. package/build/components/TreeDropdown/TreeNodeList/List.d.ts +6 -0
  23. package/build/components/TreeDropdown/TreeNodeList/List.js +17 -0
  24. package/build/components/TreeDropdown/TreeNodeList/TreeNodeList.d.ts +17 -0
  25. package/build/components/TreeDropdown/TreeNodeList/TreeNodeList.js +36 -0
  26. package/build/components/TreeDropdown/TreeNodeList/index.d.ts +2 -0
  27. package/build/components/TreeDropdown/TreeNodeList/index.js +2 -0
  28. package/build/components/TreeDropdown/TreeNodeList/style.d.ts +7 -0
  29. package/build/components/TreeDropdown/TreeNodeList/style.js +60 -0
  30. package/build/components/TreeDropdown/context/TreeDropdownProvider.d.ts +15 -0
  31. package/build/components/TreeDropdown/context/TreeDropdownProvider.js +13 -0
  32. package/build/components/TreeDropdown/hooks/useSearch.d.ts +17 -0
  33. package/build/components/TreeDropdown/hooks/useSearch.js +38 -0
  34. package/build/components/TreeDropdown/hooks/useTreeDropdown.d.ts +12 -0
  35. package/build/components/TreeDropdown/hooks/useTreeDropdown.js +10 -0
  36. package/build/components/TreeDropdown/index.d.ts +4 -0
  37. package/build/components/TreeDropdown/index.js +4 -0
  38. package/build/components/TreeDropdown/style.d.ts +9 -0
  39. package/build/components/TreeDropdown/style.js +43 -0
  40. package/build/components/TreeDropdown/type.d.ts +83 -0
  41. package/build/components/TreeDropdown/type.js +6 -0
  42. package/build/components/TreeDropdown/utils.d.ts +21 -0
  43. package/build/components/TreeDropdown/utils.js +161 -0
  44. package/build/components/index.d.ts +2 -0
  45. package/build/components/index.js +2 -0
  46. package/build/constants/assets.d.ts +0 -4
  47. package/build/constants/assets.js +0 -4
  48. package/build/hooks/index.d.ts +1 -0
  49. package/build/hooks/index.js +1 -0
  50. package/build/hooks/useScrolledTo.d.ts +13 -0
  51. package/build/hooks/useScrolledTo.js +45 -0
  52. package/package.json +2 -2
@@ -23,7 +23,7 @@ function StatusBar({ isFilteredIdsShown, availableStatuses, status, onStatusChan
23
23
  onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange(selected);
24
24
  }, [onStatusChange]);
25
25
  return (_jsx(_Fragment, { children: availableStatuses === null || availableStatuses === void 0 ? void 0 : availableStatuses.map((_a, index) => {
26
- var _b;
26
+ var _b, _c;
27
27
  var { render } = _a, s = __rest(_a, ["render"]);
28
28
  if (render) {
29
29
  return (_jsx(Fragment, { children: render({ status: status, onChange: handleStatusChange }, Object.assign(Object.assign({}, s), { index })) }, `custom-status-slot-${index}`));
@@ -42,13 +42,13 @@ function StatusBar({ isFilteredIdsShown, availableStatuses, status, onStatusChan
42
42
  []);
43
43
  const hasMatchingDropdownStatus = !!status && formattedStatuses.some((item) => (item === null || item === void 0 ? void 0 : item.value) === status);
44
44
  const variant = hasMatchingDropdownStatus ? 'active' : 'inActive';
45
- const selectedStatus = hasMatchingDropdownStatus ? status : undefined;
45
+ const selectedStatus = hasMatchingDropdownStatus ? status : (_b = formattedStatuses[0]) === null || _b === void 0 ? void 0 : _b.value;
46
46
  return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, s, { selectedStatus: selectedStatus, variant: variant, onButtonBodyClick: (buttonStatus) => handleStatusChange(buttonStatus), dropdownOptions: formattedStatuses.map((stat) => ({
47
47
  label: t((stat === null || stat === void 0 ? void 0 : stat.value) || ''),
48
48
  status: stat === null || stat === void 0 ? void 0 : stat.value,
49
49
  icon: stat.icon,
50
50
  onClick: () => handleStatusChange(stat.value),
51
- })), buttonSx: buttonSx })) }, (_b = formattedStatuses[0]) === null || _b === void 0 ? void 0 : _b.value));
51
+ })), buttonSx: buttonSx })) }, (_c = formattedStatuses[0]) === null || _c === void 0 ? void 0 : _c.value));
52
52
  }) }));
53
53
  }
54
54
  export default memo(StatusBar);
@@ -15,7 +15,7 @@ import { useTranslation } from 'react-i18next';
15
15
  import StyledBadge, { BadgeVariants } from '../CountBadge';
16
16
  import { convertToNumber, formatNumber } from '../../utils/index.js';
17
17
  import { ChevronIcon } from './ChevronIcon';
18
- import { ChevronContainer, Label, LabelWrapper, StyledStatusIcon, StyledDropdown, statusButtonVariants, IconWrapper } from './style';
18
+ import { ChevronContainer, Label, LabelWrapper, StyledStatusIcon, StyledDropdown, statusButtonVariants } from './style';
19
19
  import { statusButtonIcons } from './constant';
20
20
  const StatusButton = memo((props) => {
21
21
  var _a;
@@ -25,26 +25,14 @@ const StatusButton = memo((props) => {
25
25
  const buttonRef = useRef(null);
26
26
  const [anchorEl, setAnchorEl] = useState(null);
27
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
- useEffect(() => {
29
- if (initialStatus !== undefined) {
30
- setSelectedStatus(initialStatus);
31
- }
32
- }, [initialStatus]);
28
+ // Memoized computed values
33
29
  const hasDropdown = useMemo(() => Boolean(dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.length), [dropdownOptions]);
34
30
  // only open if button is clicked more than once
35
31
  const isDropdownOpen = Boolean(anchorEl) && buttonClicks > 1;
36
32
  const isActiveVariant = variant === 'active';
37
33
  const badgeVariant = useMemo(() => (isActiveVariant ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE), [isActiveVariant]);
38
- const statusIcon = useMemo(() => {
39
- const selectedOption = selectedStatus ? dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => option.status === selectedStatus) : null;
40
- if (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.icon) {
41
- return _jsx(IconWrapper, Object.assign({ variant: variant }, { children: selectedOption.icon }));
42
- }
43
- const iconKey = selectedStatus && iconMapper[selectedStatus] ? selectedStatus : icon;
44
- if (iconKey && iconMapper[iconKey]) {
45
- return _jsx(StyledStatusIcon, { icon: iconKey, variant: variant, src: iconMapper[iconKey], alt: `${iconKey}-icon` });
46
- }
47
- }, [selectedStatus, dropdownOptions, iconMapper, icon, variant]);
34
+ // Memoized UI elements
35
+ const statusIcon = useMemo(() => (icon ? _jsx(StyledStatusIcon, { icon: icon, variant: variant, src: iconMapper[icon], alt: `${icon}-icon` }) : null), [icon, iconMapper, variant]);
48
36
  const statusBadge = useMemo(() => {
49
37
  if (!badgeCount || Number.isNaN(convertToNumber(badgeCount)))
50
38
  return null;
@@ -38,8 +38,3 @@ export declare const StyledStatusIcon: import("@emotion/styled").StyledComponent
38
38
  variant: StatusButtonVariant;
39
39
  icon?: StatusButtonProps['icon'];
40
40
  }, React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
41
- export declare const IconWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
42
- ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
43
- }, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme> & {
44
- variant: StatusButtonVariant;
45
- }, {}, {}>;
@@ -79,14 +79,3 @@ export const StyledStatusIcon = styled('img')(({ theme, variant, icon }) => {
79
79
  filter: variant === 'active' ? 'brightness(0) invert(1)' : 'brightness(0) invert(0)',
80
80
  })), { maxWidth: '14px', maxHeight: '14px' }));
81
81
  });
82
- export const IconWrapper = styled(Box)(({ variant }) => ({
83
- width: '14px',
84
- height: '14px',
85
- display: 'flex',
86
- alignItems: 'center',
87
- '& img': {
88
- width: '14px',
89
- height: '14px',
90
- filter: variant === 'active' ? 'brightness(0) invert(1)' : 'brightness(0) invert(0)',
91
- },
92
- }));
@@ -0,0 +1,11 @@
1
+ import { CSSProperties } from 'react';
2
+ import { type ChargeStatus } from '../../../TableCells';
3
+ interface SmallChargeStatusIconProps {
4
+ chargeStatus?: ChargeStatus;
5
+ chargeTooltip?: string;
6
+ errorCode?: string;
7
+ iconStyles?: CSSProperties;
8
+ iconWrapperStyles?: CSSProperties;
9
+ }
10
+ export declare function ChargeStatusIcon({ chargeStatus, chargeTooltip, errorCode, iconStyles, iconWrapperStyles }: Readonly<SmallChargeStatusIconProps>): import("react/jsx-runtime").JSX.Element | null;
11
+ export {};
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Box from '@mui/material/Box';
3
+ import { useTranslation } from 'react-i18next';
4
+ import Tooltip from '../../../Tooltip';
5
+ import { statusIcons, unCapturedStatusesStyles } from '../../../TableCells/CustomCells/StatusCell/constant';
6
+ import { StatusIcon } from '../../../TableCells/CustomCells/style';
7
+ import { ErrorChip, StatusIconWrapper } from './style';
8
+ export function ChargeStatusIcon({ chargeStatus, chargeTooltip, errorCode, iconStyles, iconWrapperStyles }) {
9
+ const { t } = useTranslation();
10
+ const unCapturedStatusStyle = chargeStatus ? unCapturedStatusesStyles[chargeStatus] : null;
11
+ const chargeIcon = chargeStatus && statusIcons[chargeStatus] && (_jsx(StatusIconWrapper, Object.assign({ style: iconWrapperStyles }, { children: _jsx(StatusIcon, { src: statusIcons[chargeStatus], alt: "charge-icon", style: Object.assign({ width: '16px', height: '16px' }, iconStyles) }) })));
12
+ if (!chargeStatus)
13
+ return null;
14
+ return (_jsx(Tooltip, Object.assign({ title: chargeTooltip !== null && chargeTooltip !== void 0 ? chargeTooltip : t(chargeStatus) }, { children: _jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '6px', alignItems: 'center' } }, { children: [chargeIcon, errorCode && _jsx(ErrorChip, Object.assign({ style: { background: unCapturedStatusStyle === null || unCapturedStatusStyle === void 0 ? void 0 : unCapturedStatusStyle.color } }, { children: errorCode }))] })) })));
15
+ }
@@ -1,2 +1,2 @@
1
- import { DueCellProps } from './type';
2
- export default function InvoiceStatusCell({ status, date, viewsCount, chargeStatus, errorCode, chargeTooltip, isTextShown, ...props }: DueCellProps): import("react/jsx-runtime").JSX.Element;
1
+ import { InvoiceStatusCellProps } from './type';
2
+ export default function InvoiceStatusCell({ status, date, viewsCount, chargeStatus, errorCode, chargeTooltip, remindedCount, ...props }: InvoiceStatusCellProps): import("react/jsx-runtime").JSX.Element | null;
@@ -9,81 +9,61 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useTranslation } from 'react-i18next';
14
14
  import dayjs from 'dayjs';
15
- import { motion } from 'framer-motion';
16
- import camelCase from 'lodash/camelCase';
17
- import capitalize from 'lodash/capitalize';
15
+ import Box from '@mui/material/Box';
18
16
  import { useTheme } from '@mui/material/styles';
19
17
  import StyledBadge, { BadgeVariants } from '../../../CountBadge';
20
18
  import Tooltip from '../../../Tooltip';
21
19
  import { TableCell } from '../../../TableCells';
22
20
  import { formatDate } from '../../../TableCells/CustomCells/DueDateCell/utils';
23
21
  import { chargeStatusIcons } from '../../../TableCells/CustomCells/AuthenticationStatusCell/constant';
24
- import { ChargeStatusIcon } from '../../../StatusIcons';
22
+ import { remindedRedIcon } from '../../../../constants/index.js';
23
+ import { RightLeftExpandingCenterChip } from '../../../RightLeftExpandingCenterChip';
25
24
  import { statusIcons } from './constant';
26
- import { DueDateCellContainer, DateIcon, StatusTextLabel } from './style';
25
+ import { DateIcon } from './style';
27
26
  import { invoiceStatusStyles } from './utils';
28
- import { StatusIconWrapper } from '../style';
27
+ import { ChargeStatusIcon } from './ChargeStatusIcon';
28
+ import { useMemo } from 'react';
29
29
  export default function InvoiceStatusCell(_a) {
30
- var { status, date, viewsCount, chargeStatus, errorCode, chargeTooltip, isTextShown } = _a, props = __rest(_a, ["status", "date", "viewsCount", "chargeStatus", "errorCode", "chargeTooltip", "isTextShown"]);
31
- const theme = useTheme();
30
+ var { status, date, viewsCount, chargeStatus, errorCode, chargeTooltip, remindedCount = 0 } = _a, props = __rest(_a, ["status", "date", "viewsCount", "chargeStatus", "errorCode", "chargeTooltip", "remindedCount"]);
32
31
  const { t } = useTranslation();
32
+ const theme = useTheme();
33
33
  const icon = status ? statusIcons[status] : null;
34
34
  const statusStyles = invoiceStatusStyles(status);
35
- const showExpansion = viewsCount !== 0 && !!viewsCount && status === 'VIEWED';
36
35
  const statusTooltip = `${t((status === null || status === void 0 ? void 0 : status.toLowerCase()) || '')} ${formatDate(dayjs(date).valueOf())}`;
36
+ const statusIcon = useMemo(() => _jsx(ChargeStatusIcon, { chargeStatus: chargeStatus, errorCode: errorCode, chargeTooltip: chargeTooltip }), [chargeStatus, errorCode, chargeTooltip]);
37
+ const remindedIcon = useMemo(() => (_jsx(Tooltip, Object.assign({ title: t('reminded') }, { children: _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '6px' } }, { children: [_jsx(DateIcon, { sx: {
38
+ width: '14px',
39
+ height: '14px',
40
+ }, src: remindedRedIcon, alt: "icon" }), _jsx(StyledBadge, Object.assign({ variant: BadgeVariants.DEFAULT, style: {
41
+ background: theme.palette.error.main,
42
+ fontWeight: 600,
43
+ color: theme.palette.common.white,
44
+ } }, { children: remindedCount }))] })) }))), [remindedCount]);
45
+ const centerIcon = useMemo(() => {
46
+ if (icon) {
47
+ return (_jsx(Tooltip, Object.assign({ title: t(statusTooltip || '') }, { children: _jsx(DateIcon, { src: icon, alt: "status icon" }) })));
48
+ }
49
+ if (chargeStatus && chargeStatusIcons[chargeStatus])
50
+ return statusIcon;
51
+ if (remindedCount)
52
+ return remindedIcon;
53
+ return undefined;
54
+ }, [icon, chargeStatus, remindedCount]);
55
+ if (!status && !chargeStatus && !remindedCount)
56
+ return null;
37
57
  return (_jsx(TableCell, Object.assign({}, props, { sx: {
38
58
  position: 'relative',
39
59
  overflow: 'visible',
40
- } }, { children: _jsxs("div", Object.assign({ style: {
41
- display: 'flex',
42
- alignItems: 'center',
43
- justifyContent: 'flex-start',
44
- gap: '8px',
45
- overflow: 'visible',
46
- } }, { children: [_jsx(Tooltip, Object.assign({ title: t(statusTooltip || '') }, { children: _jsx(DueDateCellContainer, Object.assign({ whileHover: showExpansion ? ['animate', 'fadeIn'] : [], animate: "start", sx: Object.assign({ zIndex: 25, position: 'absolute' }, (isTextShown && {
47
- border: `1px solid ${statusStyles.color}1A`,
48
- })), variants: {
49
- animate: Object.assign({}, (showExpansion && {
50
- boxShadow: theme.shadows[4],
51
- })),
52
- }, background: statusStyles.background }, { children: (icon || (isTextShown && status)) && (_jsxs(_Fragment, { children: [isTextShown ? (_jsx(StatusTextLabel, Object.assign({ sx: {
53
- color: statusStyles.color,
54
- } }, { children: capitalize(status) }))) : (icon && _jsx(DateIcon, { src: icon, alt: "icon" })), _jsx(motion.div, Object.assign({ style: {
55
- alignItems: 'center',
56
- justifyContent: 'center',
57
- gap: '4px',
58
- display: 'none',
59
- width: 0,
60
- }, initial: { width: 0, opacity: 0 }, transition: {
61
- animate: {
62
- duration: 0.5,
63
- },
64
- fadeIn: {
65
- duration: 0.2,
66
- },
67
- }, variants: {
68
- animate: {
69
- width: 'auto',
70
- display: 'flex',
71
- },
72
- fadeIn: {
73
- transition: {
74
- delay: 0.5,
75
- },
76
- opacity: 1,
77
- },
78
- } }, { children: showExpansion && (_jsx(StyledBadge, Object.assign({ variant: BadgeVariants.DEFAULT, style: {
79
- color: '#fff',
80
- backgroundColor: statusStyles.color,
81
- } }, { children: viewsCount }))) }))] })) })) })), _jsx(StatusIconWrapper, Object.assign({ sx: {
82
- position: 'absolute',
83
- left: isTextShown ? '88px' : '32px',
84
- width: isTextShown ? '65px' : '24px',
85
- } }, { children: chargeStatus && chargeStatusIcons[chargeStatus] && (_jsx(_Fragment, { children: isTextShown ? (_jsx(Tooltip, Object.assign({ title: t(camelCase(chargeStatus)) }, { children: _jsx(StatusTextLabel, Object.assign({ sx: {
86
- color: invoiceStatusStyles('VIEWED').color,
87
- backgroundColor: `${invoiceStatusStyles('VIEWED').color}0d`,
88
- } }, { children: capitalize(chargeStatus) })) }))) : (_jsx(ChargeStatusIcon, { chargeStatus: chargeStatus, errorCode: errorCode, chargeTooltip: chargeTooltip })) })) }))] })) })));
60
+ } }, { children: _jsx(RightLeftExpandingCenterChip, { sx: { justifyContent: 'flex-start' }, expandableCenterRight: !!viewsCount && status === 'VIEWED' && icon
61
+ ? [
62
+ _jsx(StyledBadge, Object.assign({ variant: BadgeVariants.DEFAULT, style: {
63
+ marginRight: '8px',
64
+ color: '#fff',
65
+ backgroundColor: statusStyles.color,
66
+ } }, { children: viewsCount })),
67
+ ]
68
+ : undefined, centerIcon: centerIcon, leftIcons: !!remindedCount && icon ? [remindedIcon] : undefined, rightIcons: chargeStatus && chargeStatusIcons[chargeStatus] && icon ? [statusIcon] : undefined }) })));
89
69
  }
@@ -265,3 +265,5 @@ export declare const DueDateCellContainer: import("@emotion/styled").StyledCompo
265
265
  }, {}, {}>;
266
266
  export declare const DateIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
267
267
  export declare const StatusTextLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
268
+ export declare const ErrorChip: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
269
+ export declare const StatusIconWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -30,3 +30,21 @@ export const StatusTextLabel = styled('div')(() => ({
30
30
  padding: '4.5px 8px',
31
31
  borderRadius: '24px',
32
32
  }));
33
+ export const ErrorChip = styled('div')(({ theme }) => ({
34
+ color: theme.palette.common.white,
35
+ background: theme.palette.error.main,
36
+ fontSize: '0.6rem',
37
+ fontWeight: 600,
38
+ borderRadius: '16px',
39
+ padding: '2px 8px',
40
+ display: 'flex',
41
+ alignItems: 'center',
42
+ justifyContent: 'center',
43
+ }));
44
+ export const StatusIconWrapper = styled('div')(() => ({
45
+ display: 'flex',
46
+ alignItems: 'center',
47
+ justifyContent: 'center',
48
+ width: '16px',
49
+ height: '16px',
50
+ }));
@@ -2,7 +2,7 @@ import { TableCellProps } from '@mui/material/TableCell';
2
2
  import { statusIcons } from './constant';
3
3
  import { ChargeStatus } from '../type';
4
4
  export type StatusIconType = keyof typeof statusIcons;
5
- export interface DueCellProps extends TableCellProps {
5
+ export interface InvoiceStatusCellProps extends TableCellProps {
6
6
  status?: StatusIconType;
7
7
  date: Date | '';
8
8
  viewsCount?: number;
@@ -12,4 +12,5 @@ export interface DueCellProps extends TableCellProps {
12
12
  gatewayTooltip?: string;
13
13
  errorCode?: string;
14
14
  isTextShown?: boolean;
15
+ remindedCount?: number;
15
16
  }
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { TreeDropdownProps, TreeDropdownRef } from './type';
3
+ declare const TreeDropdown: import("react").ForwardRefExoticComponent<Readonly<TreeDropdownProps> & import("react").RefAttributes<TreeDropdownRef>>;
4
+ export default TreeDropdown;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useImperativeHandle, useMemo, useState } from 'react';
3
+ import { SelectedState } from './type';
4
+ import TreeNodeList from './TreeNodeList/TreeNodeList';
5
+ import { initializeTreeMapper, promoteSingleChild, TreeManager, updateSelection } from './utils';
6
+ import TreeDropdownProvider from './context/TreeDropdownProvider';
7
+ const TreeDropdown = forwardRef((props, ref) => {
8
+ const { anchorEl, placement = 'bottom-start', treeDefinition, sx, onChange, multiple = true, exposeOnlySelectedTree = false, IconComponent } = props;
9
+ const { header, footer, children: menuItems = [], searchProps, levelKey } = treeDefinition;
10
+ const [internalMapper, setInternalMapper] = useState(() => initializeTreeMapper(menuItems || [], multiple));
11
+ const formattedMenuItems = useMemo(() => promoteSingleChild(menuItems || []), [menuItems]);
12
+ const getFullTree = useCallback(() => TreeManager.denormalizeTree(menuItems, internalMapper), [menuItems, internalMapper]);
13
+ const getSelectedTree = useCallback(() => TreeManager.extractSelectedBranches(getFullTree()), [getFullTree]);
14
+ const handleSelect = useCallback((isChecked, targetNode) => {
15
+ const nextInternal = updateSelection(internalMapper, targetNode.id, isChecked, multiple);
16
+ setInternalMapper(nextInternal);
17
+ if (onChange) {
18
+ if (exposeOnlySelectedTree) {
19
+ onChange(TreeManager.extractSelectedBranches(TreeManager.denormalizeTree(menuItems, nextInternal)));
20
+ }
21
+ else {
22
+ onChange(TreeManager.denormalizeTree(menuItems, nextInternal));
23
+ }
24
+ }
25
+ }, [onChange, menuItems, internalMapper, multiple, exposeOnlySelectedTree]);
26
+ const toggleAll = useCallback((selected) => {
27
+ const setStatus = (tree, isChecked) => {
28
+ const next = Object.assign({}, tree);
29
+ Object.keys(next).forEach((nodeId) => {
30
+ next[nodeId] = Object.assign(Object.assign({}, next[nodeId]), { status: isChecked ? SelectedState.CHECKED : SelectedState.UNCHECKED });
31
+ });
32
+ return next;
33
+ };
34
+ const nextInternal = setStatus(internalMapper, selected);
35
+ setInternalMapper(nextInternal);
36
+ if (onChange) {
37
+ if (exposeOnlySelectedTree) {
38
+ onChange(TreeManager.extractSelectedBranches(TreeManager.denormalizeTree(menuItems, nextInternal)));
39
+ }
40
+ else {
41
+ onChange(TreeManager.denormalizeTree(menuItems, nextInternal));
42
+ }
43
+ }
44
+ }, [internalMapper, onChange, menuItems, exposeOnlySelectedTree]);
45
+ useImperativeHandle(ref, () => ({
46
+ state: internalMapper,
47
+ getFullTree,
48
+ getSelectedTree,
49
+ toggleAll,
50
+ }), [internalMapper, getFullTree, getSelectedTree, toggleAll]);
51
+ return (_jsx(TreeDropdownProvider, Object.assign({ internalMapper: internalMapper, IconComponent: IconComponent, handleSelect: handleSelect, multiple: multiple }, { children: _jsx(TreeNodeList, { anchorEl: anchorEl, sx: sx, header: header, footer: footer, menuItems: formattedMenuItems, levelKey: levelKey, searchProps: searchProps, placement: placement }) })));
52
+ });
53
+ export default TreeDropdown;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ type SelectionControlProps = {
3
+ checked: boolean;
4
+ indeterminate: boolean;
5
+ onSelect: (e: React.ChangeEvent<HTMLInputElement>) => void;
6
+ };
7
+ declare const SelectionControl: (props: SelectionControlProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default SelectionControl;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import useTreeDropdown from '../hooks/useTreeDropdown';
3
+ import { StyledCheckbox as Checkbox, StyledRadioButton as RadioButton } from './style';
4
+ import { useCallback } from 'react';
5
+ const SelectionControl = (props) => {
6
+ const { checked, indeterminate, onSelect } = props;
7
+ const { multiple } = useTreeDropdown();
8
+ const handleSelect = useCallback((e) => {
9
+ e.stopPropagation();
10
+ onSelect(e);
11
+ }, [onSelect]);
12
+ if (multiple) {
13
+ return _jsx(Checkbox, { size: "small", checked: checked, indeterminate: indeterminate, onChange: handleSelect });
14
+ }
15
+ return _jsx(RadioButton, { size: "small", checked: checked, onChange: handleSelect });
16
+ };
17
+ export default SelectionControl;
@@ -0,0 +1,12 @@
1
+ import { SxProps, Theme } from '@mui/material';
2
+ import { TreeNode } from '../type';
3
+ type InternalTreeNodeItemProps = {
4
+ levelIndex?: number;
5
+ nestedMenuSx?: SxProps<Theme>;
6
+ parentMenuFlipped?: boolean;
7
+ subLevelKey?: string;
8
+ disableHovering?: boolean;
9
+ };
10
+ type TreeNodeItemProps = TreeNode & InternalTreeNodeItemProps;
11
+ declare const TreeNodeItem: (props: TreeNodeItemProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default TreeNodeItem;
@@ -0,0 +1,64 @@
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 { useCallback, useEffect, useMemo, useState } from 'react';
14
+ import { Stack } from '@mui/material';
15
+ import { blackRightArrowIcon } from '../../../constants/index.js';
16
+ import { StyledMenuItem as Root } from '../style';
17
+ import { SelectedState } from '../type';
18
+ import TreeNodeList from '../TreeNodeList/TreeNodeList';
19
+ import useTreeDropdown from '../hooks/useTreeDropdown';
20
+ import SelectionControl from './SelectionControl';
21
+ import { ArrowIcon, ChildrenCount, Content, HintText, Label } from './style';
22
+ const TreeNodeItem = (props) => {
23
+ var _a, _b;
24
+ const { renderItem, header, footer } = props, nodeProps = __rest(props, ["renderItem", "header", "footer"]);
25
+ const { internalMapper, handleSelect, multiple, IconComponent } = useTreeDropdown();
26
+ const { label, icon, iconComponent, levelIndex = 0, children, nestedMenuSx, hintText, disableHovering, itemProps, searchProps, subLevelKey, } = nodeProps;
27
+ const [anchorEl, setAnchorEl] = useState(null);
28
+ const hasChildren = !!children;
29
+ const childrenCount = children === null || children === void 0 ? void 0 : children.length;
30
+ const handleMouseEnter = useCallback((event) => {
31
+ if (disableHovering)
32
+ return;
33
+ setAnchorEl(event.currentTarget);
34
+ }, [disableHovering]);
35
+ const handleMouseLeave = useCallback(() => {
36
+ if (disableHovering)
37
+ return;
38
+ setAnchorEl(null);
39
+ }, [disableHovering]);
40
+ useEffect(() => {
41
+ if (disableHovering) {
42
+ setAnchorEl(null);
43
+ }
44
+ }, [disableHovering]);
45
+ const renderedIcon = useMemo(() => {
46
+ var _a, _b;
47
+ if (iconComponent)
48
+ return iconComponent;
49
+ if (!icon)
50
+ return null;
51
+ return IconComponent ? _jsx(IconComponent, { fileId: icon.fileId, width: (_a = icon.width) !== null && _a !== void 0 ? _a : 20, height: (_b = icon.height) !== null && _b !== void 0 ? _b : 20 }) : null;
52
+ }, [iconComponent, icon, IconComponent]);
53
+ const checked = ((_a = internalMapper[nodeProps.id]) === null || _a === void 0 ? void 0 : _a.status) === SelectedState.CHECKED;
54
+ const indeterminate = multiple ? ((_b = internalMapper[nodeProps.id]) === null || _b === void 0 ? void 0 : _b.status) === SelectedState.INDETERMINATE : false;
55
+ const showSelectionControl = multiple || !hasChildren;
56
+ const handleSelectInternal = useCallback((e) => {
57
+ e.stopPropagation();
58
+ handleSelect(e.target.checked, nodeProps);
59
+ }, [handleSelect, nodeProps]);
60
+ return (_jsxs(Root, Object.assign({ hideCheckbox: true, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, "data-testid": nodeProps.id, onClick: () => {
61
+ handleSelect(!checked, nodeProps);
62
+ } }, itemProps, { children: [renderItem ? (renderItem({ nodeProps, checked, indeterminate, onSelect: handleSelectInternal })) : (_jsxs(Content, Object.assign({ width: "100%", "data-testid": "Content" }, { children: [showSelectionControl && _jsx(SelectionControl, { checked: checked, indeterminate: indeterminate, onSelect: handleSelectInternal }), renderedIcon, _jsxs(Stack, Object.assign({ flex: 1, width: "100%", minWidth: 0 }, { children: [_jsx(Label, Object.assign({ title: typeof label === 'string' ? label : undefined }, { children: label })), hintText && _jsx(HintText, Object.assign({ title: typeof hintText === 'string' ? hintText : undefined }, { children: hintText }))] })), _jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", spacing: 0.5 }, { children: [childrenCount && _jsx(ChildrenCount, Object.assign({ isOneDigit: Math.floor(childrenCount / 10) === 0 }, { children: childrenCount })), hasChildren && _jsx(ArrowIcon, { src: blackRightArrowIcon, alt: "Expand" })] }))] }))), !!children && (_jsx(TreeNodeList, { anchorEl: anchorEl, menuItems: children, levelIndex: levelIndex + 1, sx: nestedMenuSx, header: header, levelKey: subLevelKey, footer: footer, searchProps: searchProps }))] })));
63
+ };
64
+ export default TreeNodeItem;
@@ -0,0 +1,2 @@
1
+ import TreeNodeItem from './TreeNodeItem';
2
+ export default TreeNodeItem;
@@ -0,0 +1,2 @@
1
+ import TreeNodeItem from './TreeNodeItem';
2
+ export default TreeNodeItem;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledCheckbox: import("@emotion/styled").StyledComponent<import("@mui/material").CheckboxProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
3
+ export declare const StyledRadioButton: import("@emotion/styled").StyledComponent<import("../../index.js").RadioButtonProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
4
+ export declare const Content: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
5
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
6
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
7
+ export declare const Label: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material/Typography").TypographyTypeMap<{}, "span">>;
8
+ export declare const HintText: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material/Typography").TypographyTypeMap<{}, "span">>;
9
+ export declare const ChildrenCount: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
10
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
11
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
12
+ isOneDigit?: boolean | undefined;
13
+ }, {}, {}>;
14
+ export declare const ArrowIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { alpha, styled } from '@mui/material/styles';
3
+ import Typography from '@mui/material/Typography';
4
+ import Box from '@mui/material/Box';
5
+ import { Checkbox, RadioButton } from '../../index.js';
6
+ export const StyledCheckbox = styled(Checkbox)(({ theme }) => ({
7
+ padding: 0,
8
+ paddingRight: '4px',
9
+ width: '14px !important',
10
+ svg: {
11
+ width: '12px !important',
12
+ height: '12px !important',
13
+ },
14
+ '&.Mui-disabled': {
15
+ '[data-testid="IndeterminateCheckBoxIcon"]': {
16
+ fill: alpha(theme.palette.common.black, 0.26),
17
+ },
18
+ },
19
+ }));
20
+ export const StyledRadioButton = styled(RadioButton)({
21
+ padding: 0,
22
+ });
23
+ export const Content = styled(Box)(() => ({
24
+ display: 'flex',
25
+ gap: '8px',
26
+ justifyContent: 'space-between',
27
+ flexGrow: 1,
28
+ width: '100%',
29
+ alignItems: 'center',
30
+ minWidth: 0,
31
+ }));
32
+ export const Label = styled((props) => _jsx(Typography, Object.assign({ noWrap: true, component: "span" }, props)))(({ theme }) => ({
33
+ flex: 1,
34
+ fontSize: 'inherit',
35
+ width: '100%',
36
+ display: 'inline-block',
37
+ color: theme.palette.text.primary,
38
+ }));
39
+ export const HintText = styled((props) => _jsx(Typography, Object.assign({ noWrap: true }, props)))(({ theme }) => ({
40
+ color: alpha(theme.palette.text.primary, 0.5),
41
+ fontSize: 8,
42
+ }));
43
+ export const ChildrenCount = styled(Box, { shouldForwardProp: (prop) => prop !== 'isOneDigit' })(({ theme, isOneDigit = true }) => (Object.assign({ borderRadius: isOneDigit ? '50%' : '4px', background: theme.palette.divider, width: isOneDigit ? 13 : 'auto', height: 14, fontSize: '8px', fontWeight: 700, display: 'flex', alignItems: 'center', justifyContent: 'center', lineHeight: '10px' }, (!isOneDigit && { padding: '0 3px' }))));
44
+ export const ArrowIcon = styled('img')(() => ({
45
+ height: 12,
46
+ }));
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ declare const List: ({ children, onScroll }: {
3
+ children: React.ReactNode;
4
+ onScroll: (e: React.UIEvent<HTMLElement, UIEvent>) => void;
5
+ }) => import("react/jsx-runtime").JSX.Element;
6
+ export default List;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useScrolledTo } from '../../../hooks/index.js';
3
+ import { useCallback, useMemo, useRef } from 'react';
4
+ import { ListOuterContainer, ListInnerContainer } from './style';
5
+ const List = ({ children, onScroll }) => {
6
+ const containerRef = useRef(null);
7
+ const { scrolledToBottom, scrolledToTop, scrollable, handleScroll: handleScrolling } = useScrolledTo({ containerRef });
8
+ const classes = useMemo(() => {
9
+ return [scrolledToBottom && 'scrolled-to-bottom', scrolledToTop && 'scrolled-to-top', scrollable && 'scrollable'].filter(Boolean).join(' ');
10
+ }, [scrolledToBottom, scrolledToTop, scrollable]);
11
+ const handleScroll = useCallback((e) => {
12
+ onScroll(e);
13
+ handleScrolling(e);
14
+ }, [onScroll, handleScrolling]);
15
+ return (_jsx(ListOuterContainer, Object.assign({ sx: { position: 'relative' }, className: classes }, { children: _jsx(ListInnerContainer, Object.assign({ ref: containerRef, onScroll: handleScroll }, { children: children })) })));
16
+ };
17
+ export default List;
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { PopperProps } from '@mui/material/Popper';
3
+ import { SxProps, Theme } from '@mui/material/styles';
4
+ import { TreeNode } from '../type';
5
+ type TreeNodeListProps = {
6
+ menuItems: TreeNode[];
7
+ anchorEl: HTMLElement | null;
8
+ sx?: SxProps<Theme>;
9
+ header?: React.ReactNode;
10
+ footer?: React.ReactNode;
11
+ levelIndex?: number;
12
+ levelKey?: TreeNode['levelKey'];
13
+ searchProps?: TreeNode['searchProps'];
14
+ placement?: PopperProps['placement'];
15
+ };
16
+ declare const TreeNodeList: (props: TreeNodeListProps) => import("react/jsx-runtime").JSX.Element;
17
+ export default TreeNodeList;