@tap-payments/os-micro-frontend-shared 0.0.91 → 0.0.92-multi-select-status-button-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.
- package/LICENSE +21 -21
- package/README.md +12 -12
- package/build/components/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/build/components/DropdownMenu/DropdownMenu.js +3 -3
- package/build/components/DropdownMenu/type.d.ts +1 -0
- package/build/components/MultiSelectStatusButton/MultiSelectStatusButton.d.ts +5 -0
- package/build/components/MultiSelectStatusButton/MultiSelectStatusButton.js +99 -0
- package/build/components/MultiSelectStatusButton/index.d.ts +3 -0
- package/build/components/MultiSelectStatusButton/index.js +2 -0
- package/build/components/MultiSelectStatusButton/style.d.ts +36 -0
- package/build/components/MultiSelectStatusButton/style.js +59 -0
- package/build/components/MultiSelectStatusButton/type.d.ts +14 -0
- package/build/components/MultiSelectStatusButton/type.js +1 -0
- package/build/components/RangeCalender/RangeCalender.d.ts +20 -0
- package/build/components/RangeCalender/RangeCalender.js +92 -0
- package/build/components/RangeCalender/components/CustomTimepicker/CustomTimepicker.d.ts +11 -0
- package/build/components/RangeCalender/components/CustomTimepicker/CustomTimepicker.js +33 -0
- package/build/components/RangeCalender/components/CustomTimepicker/index.d.ts +2 -0
- package/build/components/RangeCalender/components/CustomTimepicker/index.js +2 -0
- package/build/components/RangeCalender/components/CustomTimepicker/style.d.ts +15 -0
- package/build/components/RangeCalender/components/CustomTimepicker/style.js +132 -0
- package/build/components/RangeCalender/components/GroupBy/GroupBy.d.ts +10 -0
- package/build/components/RangeCalender/components/GroupBy/GroupBy.js +33 -0
- package/build/components/RangeCalender/components/GroupBy/index.d.ts +2 -0
- package/build/components/RangeCalender/components/GroupBy/index.js +2 -0
- package/build/components/RangeCalender/components/GroupBy/style.d.ts +15 -0
- package/build/components/RangeCalender/components/GroupBy/style.js +39 -0
- package/build/components/RangeCalender/components/Hijri/Hijri.d.ts +7 -0
- package/build/components/RangeCalender/components/Hijri/Hijri.js +13 -0
- package/build/components/RangeCalender/components/Hijri/index.d.ts +2 -0
- package/build/components/RangeCalender/components/Hijri/index.js +2 -0
- package/build/components/RangeCalender/components/Hijri/style.d.ts +4 -0
- package/build/components/RangeCalender/components/Hijri/style.js +25 -0
- package/build/components/RangeCalender/components/QuickFilters/QuickFilters.d.ts +8 -0
- package/build/components/RangeCalender/components/QuickFilters/QuickFilters.js +47 -0
- package/build/components/RangeCalender/components/QuickFilters/index.d.ts +2 -0
- package/build/components/RangeCalender/components/QuickFilters/index.js +2 -0
- package/build/components/RangeCalender/components/QuickFilters/style.d.ts +7 -0
- package/build/components/RangeCalender/components/QuickFilters/style.js +27 -0
- package/build/components/RangeCalender/components/RangeDatepicker/RangeDatepicker.d.ts +12 -0
- package/build/components/RangeCalender/components/RangeDatepicker/RangeDatepicker.js +29 -0
- package/build/components/RangeCalender/components/RangeDatepicker/index.d.ts +2 -0
- package/build/components/RangeCalender/components/RangeDatepicker/index.js +2 -0
- package/build/components/RangeCalender/components/RangeDatepicker/style.d.ts +4 -0
- package/build/components/RangeCalender/components/RangeDatepicker/style.js +9 -0
- package/build/components/RangeCalender/components/Timezone/Timezone.d.ts +11 -0
- package/build/components/RangeCalender/components/Timezone/Timezone.js +32 -0
- package/build/components/RangeCalender/components/Timezone/components/EntitiesTimezone.d.ts +12 -0
- package/build/components/RangeCalender/components/Timezone/components/EntitiesTimezone.js +37 -0
- package/build/components/RangeCalender/components/Timezone/components/UserTimezone.d.ts +8 -0
- package/build/components/RangeCalender/components/Timezone/components/UserTimezone.js +14 -0
- package/build/components/RangeCalender/components/Timezone/index.d.ts +2 -0
- package/build/components/RangeCalender/components/Timezone/index.js +2 -0
- package/build/components/RangeCalender/components/Timezone/style.d.ts +21 -0
- package/build/components/RangeCalender/components/Timezone/style.js +61 -0
- package/build/components/RangeCalender/index.d.ts +2 -0
- package/build/components/RangeCalender/index.js +2 -0
- package/build/components/RangeCalender/style.d.ts +33 -0
- package/build/components/RangeCalender/style.js +189 -0
- package/build/components/RangeCalender/type.d.ts +2 -0
- package/build/components/RangeCalender/type.js +1 -0
- package/build/components/RangeCalender/utils.d.ts +6 -0
- package/build/components/RangeCalender/utils.js +15 -0
- package/build/components/StatusBar/StatusBar.d.ts +6 -1
- package/build/components/StatusBar/StatusBar.js +62 -26
- package/build/components/StatusBar/example.d.ts +2 -0
- package/build/components/StatusBar/example.js +72 -0
- package/build/components/StatusBar/index.d.ts +1 -0
- package/build/components/StatusBar/index.js +1 -0
- package/build/components/TableHeader_V2/components/StatusButtons/ChevronIcon.d.ts +1 -1
- package/build/components/TableHeader_V2/components/StatusButtons/ChevronIcon.js +4 -2
- package/build/components/TableHeader_V2/components/StatusButtons/type.d.ts +3 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/package.json +132 -132
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Tap Payments
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tap Payments
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# os-micro-frontend-shared
|
|
2
|
-
|
|
3
|
-
## Publishing Workflow
|
|
4
|
-
|
|
5
|
-
1. Update version in package.json
|
|
6
|
-
2. Commit changes
|
|
7
|
-
3. Create and push a tag:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm version patch # or minor, major
|
|
11
|
-
git push origin main --tags
|
|
12
|
-
```
|
|
1
|
+
# os-micro-frontend-shared
|
|
2
|
+
|
|
3
|
+
## Publishing Workflow
|
|
4
|
+
|
|
5
|
+
1. Update version in package.json
|
|
6
|
+
2. Commit changes
|
|
7
|
+
3. Create and push a tag:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm version patch # or minor, major
|
|
11
|
+
git push origin main --tags
|
|
12
|
+
```
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IProps } from './type';
|
|
2
|
-
declare function Dropdown({ open, menuItems, anchorEl, onClose, selected, ...props }: IProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare function Dropdown({ open, menuItems, anchorEl, onClose, selected, allowShadows, ...props }: IProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default Dropdown;
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Divider, Box, useTheme } from '@mui/material';
|
|
14
14
|
import { StyledListItemText, StyledMenu, StyledListItemIcon, StyledMenuItem } from './styles';
|
|
15
15
|
function Dropdown(_a) {
|
|
16
|
-
var { open, menuItems, anchorEl, onClose, selected } = _a, props = __rest(_a, ["open", "menuItems", "anchorEl", "onClose", "selected"]);
|
|
16
|
+
var { open, menuItems, anchorEl, onClose, selected, allowShadows = true } = _a, props = __rest(_a, ["open", "menuItems", "anchorEl", "onClose", "selected", "allowShadows"]);
|
|
17
17
|
const theme = useTheme();
|
|
18
18
|
return (_jsx(StyledMenu, Object.assign({ open: open, anchorEl: anchorEl, onClose: onClose, onContextMenu: (e) => {
|
|
19
19
|
e.preventDefault();
|
|
@@ -27,7 +27,7 @@ function Dropdown(_a) {
|
|
|
27
27
|
item.onClick(e);
|
|
28
28
|
}, onContextMenu: item.onRightClick, selected: item.selected, sx: Object.assign({ '&:hover': {
|
|
29
29
|
backgroundColor: 'transparent',
|
|
30
|
-
boxShadow: theme.shadows[10],
|
|
30
|
+
boxShadow: allowShadows ? theme.shadows[10] : 'none',
|
|
31
31
|
'& .sandbox-Icon': {
|
|
32
32
|
display: 'none',
|
|
33
33
|
},
|
|
@@ -36,7 +36,7 @@ function Dropdown(_a) {
|
|
|
36
36
|
},
|
|
37
37
|
} }, (idx === selected && {
|
|
38
38
|
backgroundColor: 'transparent',
|
|
39
|
-
boxShadow: theme.shadows[10],
|
|
39
|
+
boxShadow: allowShadows ? theme.shadows[10] : 'none',
|
|
40
40
|
})) }, { children: [item.icon && _jsx(StyledListItemIcon, { children: item.icon }), _jsx(StyledListItemText, { children: item.label }), _jsx(Box, Object.assign({ className: item.alwaysShowRightAction ? '' : 'menu-right-action' }, { children: item.rightAction && item.rightAction }))] }))) }, `${item.label}-${idx}`));
|
|
41
41
|
}) })));
|
|
42
42
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MultiSelectStatusButtonProps } from './type';
|
|
3
|
+
declare function MultiSelectStatusButton({ options, selectedValues, onSelectionChange, label, variant }: MultiSelectStatusButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const _default: import("react").MemoExoticComponent<typeof MultiSelectStatusButton>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useState, useRef, useEffect } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { Typography, Checkbox } from '@mui/material';
|
|
5
|
+
import { ChevronIcon } from '../TableHeader_V2/components/StatusButtons/ChevronIcon';
|
|
6
|
+
import StyledBadge, { BadgeVariants } from '../CountBadge';
|
|
7
|
+
import CountryFlag from '../CountryFlag';
|
|
8
|
+
import { formatNumber } from '../../utils/index.js';
|
|
9
|
+
import { closeXIcon } from '../../constants/index.js';
|
|
10
|
+
import { ChevronContainer, Label, LabelWrapper, StyledDropdown, FlagContainer, MenuItemContainer, CheckboxStyles, StyledStatusButton, ClearIcon, } from './style';
|
|
11
|
+
function MultiSelectStatusButton({ options, selectedValues, onSelectionChange, label, variant = 'inActive' }) {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
14
|
+
const buttonRef = useRef(null);
|
|
15
|
+
const [internalSelectedValues, setInternalSelectedValues] = useState(selectedValues);
|
|
16
|
+
const [dropdownWidth, setDropdownWidth] = useState(0);
|
|
17
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
18
|
+
const isOpen = Boolean(anchorEl);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!isOpen) {
|
|
21
|
+
setInternalSelectedValues(selectedValues);
|
|
22
|
+
}
|
|
23
|
+
}, [selectedValues, isOpen]);
|
|
24
|
+
const handleDropdownClick = (event) => {
|
|
25
|
+
var _a;
|
|
26
|
+
event.stopPropagation();
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
if (isOpen) {
|
|
29
|
+
handleClose();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
setAnchorEl(buttonRef.current);
|
|
33
|
+
const buttonWidth = ((_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) || 200;
|
|
34
|
+
setDropdownWidth(Math.max(buttonWidth, 200));
|
|
35
|
+
};
|
|
36
|
+
const handleClose = () => {
|
|
37
|
+
setAnchorEl(null);
|
|
38
|
+
setDropdownWidth(0);
|
|
39
|
+
};
|
|
40
|
+
const handleClearAll = (event) => {
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
setInternalSelectedValues([]);
|
|
44
|
+
onSelectionChange([]);
|
|
45
|
+
};
|
|
46
|
+
const handleOptionToggle = (optionStatus, event) => {
|
|
47
|
+
if (event) {
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
}
|
|
51
|
+
const newSelection = internalSelectedValues.includes(optionStatus)
|
|
52
|
+
? internalSelectedValues.filter((status) => status !== optionStatus)
|
|
53
|
+
: [...internalSelectedValues, optionStatus];
|
|
54
|
+
setInternalSelectedValues(newSelection);
|
|
55
|
+
onSelectionChange(newSelection);
|
|
56
|
+
};
|
|
57
|
+
const getDisplayLabel = () => {
|
|
58
|
+
if (internalSelectedValues.length === 0) {
|
|
59
|
+
return (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: "11px", variant: "inherit" }, { children: label || t('Select currencies') })));
|
|
60
|
+
}
|
|
61
|
+
if (internalSelectedValues.length === 1) {
|
|
62
|
+
const selectedOption = options.find((opt) => opt.status === internalSelectedValues[0]);
|
|
63
|
+
return selectedOption ? (_jsxs(FlagContainer, { children: [_jsx(CountryFlag, { code: selectedOption.flagCode || selectedOption.code, sx: { border: '1px solid white', borderRadius: '3px' } }), _jsx(Typography, Object.assign({ variant: "inherit" }, { children: selectedOption.name }))] })) : (internalSelectedValues[0]);
|
|
64
|
+
}
|
|
65
|
+
const firstOption = options.find((opt) => opt.status === internalSelectedValues[0]);
|
|
66
|
+
return firstOption ? (_jsxs(FlagContainer, { children: [_jsx(CountryFlag, { code: firstOption.flagCode || firstOption.code, sx: { border: '1px solid white', borderRadius: '3px' } }), _jsx(Typography, Object.assign({ variant: "inherit" }, { children: firstOption.name }))] })) : (internalSelectedValues[0]);
|
|
67
|
+
};
|
|
68
|
+
const countBadge = (_jsx(StyledBadge, Object.assign({ pointer: true, variant: variant === 'active' ? BadgeVariants.ACTIVE : BadgeVariants.INACTIVE }, { children: formatNumber(internalSelectedValues.length > 0 ? internalSelectedValues.length : options.length) })));
|
|
69
|
+
return (_jsxs(_Fragment, { children: [_jsx(StyledStatusButton, Object.assign({ buttonVariant: variant, ref: buttonRef, sx: {
|
|
70
|
+
paddingInlineEnd: '27px',
|
|
71
|
+
}, "data-testid": "MultiSelectStatusButton", onClick: handleDropdownClick, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false) }, { children: _jsxs(LabelWrapper, { children: [_jsxs(Label, Object.assign({ variant: variant }, { children: [getDisplayLabel(), countBadge] })), _jsx(ChevronContainer, Object.assign({ onClick: isHovered && internalSelectedValues.length > 0 ? handleClearAll : undefined, sx: {
|
|
72
|
+
'&:hover': {
|
|
73
|
+
backgroundColor: 'transparent',
|
|
74
|
+
},
|
|
75
|
+
} }, { children: isHovered && internalSelectedValues.length > 0 ? (_jsx(ClearIcon, { variant: variant, src: closeXIcon, alt: "clear all" })) : (_jsx(ChevronIcon, { disableHover: true, isActive: variant === 'active' })) }))] }) })), isOpen && anchorEl && (_jsx(StyledDropdown, { open: isOpen, onClose: handleClose, anchorEl: anchorEl, allowShadows: false, style: {
|
|
76
|
+
minWidth: dropdownWidth || 200,
|
|
77
|
+
width: dropdownWidth || 'auto',
|
|
78
|
+
marginTop: '6px',
|
|
79
|
+
maxWidth: 300,
|
|
80
|
+
}, sx: {
|
|
81
|
+
boxShadow: 'none !important',
|
|
82
|
+
'&:hover': {
|
|
83
|
+
boxShadow: 'none !important',
|
|
84
|
+
},
|
|
85
|
+
}, menuItems: options.map((option) => ({
|
|
86
|
+
label: (_jsxs(MenuItemContainer, { children: [_jsx(Checkbox, { checked: internalSelectedValues.includes(option.status), size: "small", sx: CheckboxStyles, onClick: (e) => {
|
|
87
|
+
var _a;
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
|
|
90
|
+
} }), _jsx(CountryFlag, { code: option.flagCode || option.code, sx: { border: '1px solid white', borderRadius: '3px' } }), _jsx(Typography, Object.assign({ variant: "body2" }, { children: option.name }))] })),
|
|
91
|
+
onClick: (e) => {
|
|
92
|
+
var _a;
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
e.stopPropagation();
|
|
95
|
+
handleOptionToggle((_a = option.status) !== null && _a !== void 0 ? _a : '', e);
|
|
96
|
+
},
|
|
97
|
+
})) }))] }));
|
|
98
|
+
}
|
|
99
|
+
export default memo(MultiSelectStatusButton);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type Theme } from '@mui/material';
|
|
3
|
+
export { statusButtonVariants, ChevronContainer, Label, LabelWrapper, StyledDropdown, } from '../TableHeader_V2/components/StatusButtons/style';
|
|
4
|
+
export declare const StyledStatusButton: 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
|
+
buttonVariant: 'active' | 'inActive';
|
|
8
|
+
}, {}, {}>;
|
|
9
|
+
export declare const FlagContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
10
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
11
|
+
}, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
12
|
+
export declare const MenuItemContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
13
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
14
|
+
}, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
15
|
+
export declare const CheckboxStyles: {
|
|
16
|
+
padding: number;
|
|
17
|
+
color: string;
|
|
18
|
+
'&.Mui-checked': {
|
|
19
|
+
color: string;
|
|
20
|
+
};
|
|
21
|
+
'&.MuiCheckbox-root': {
|
|
22
|
+
color: string;
|
|
23
|
+
};
|
|
24
|
+
'& .MuiSvgIcon-root': {
|
|
25
|
+
color: string;
|
|
26
|
+
};
|
|
27
|
+
'&.Mui-checked .MuiSvgIcon-root': {
|
|
28
|
+
color: string;
|
|
29
|
+
'& path': {
|
|
30
|
+
fill: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const ClearIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme> & {
|
|
35
|
+
variant: 'active' | 'inActive';
|
|
36
|
+
}, React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Box, Button } from '@mui/material';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
export { statusButtonVariants, ChevronContainer, Label, LabelWrapper, StyledDropdown, } from '../TableHeader_V2/components/StatusButtons/style';
|
|
4
|
+
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) }));
|
|
5
|
+
export const StyledStatusButton = styled(Button, {
|
|
6
|
+
shouldForwardProp: (prop) => prop !== 'buttonVariant',
|
|
7
|
+
})(({ theme, buttonVariant }) => (Object.assign(Object.assign({}, baseButtonStyle(theme)), (buttonVariant === 'active'
|
|
8
|
+
? {
|
|
9
|
+
background: theme.palette.background.gradient.shadedBlue,
|
|
10
|
+
color: theme.palette.common.white,
|
|
11
|
+
}
|
|
12
|
+
: {
|
|
13
|
+
backgroundColor: theme.palette.common.white,
|
|
14
|
+
borderColor: theme.palette.grey[100],
|
|
15
|
+
color: theme.palette.text.primary,
|
|
16
|
+
'&:hover': {
|
|
17
|
+
backgroundColor: 'white',
|
|
18
|
+
},
|
|
19
|
+
}))));
|
|
20
|
+
export const FlagContainer = styled(Box)(({ theme }) => ({
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
gap: theme.spacing(0.5),
|
|
24
|
+
}));
|
|
25
|
+
export const MenuItemContainer = styled(Box)(({ theme }) => ({
|
|
26
|
+
display: 'flex',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
gap: theme.spacing(0.3),
|
|
29
|
+
width: '100%',
|
|
30
|
+
}));
|
|
31
|
+
export const CheckboxStyles = {
|
|
32
|
+
padding: 0.3,
|
|
33
|
+
color: '#8C9196',
|
|
34
|
+
'&.Mui-checked': {
|
|
35
|
+
color: '#1F88D0',
|
|
36
|
+
},
|
|
37
|
+
'&.MuiCheckbox-root': {
|
|
38
|
+
color: '#8C9196',
|
|
39
|
+
},
|
|
40
|
+
'& .MuiSvgIcon-root': {
|
|
41
|
+
color: 'inherit',
|
|
42
|
+
},
|
|
43
|
+
'&.Mui-checked .MuiSvgIcon-root': {
|
|
44
|
+
color: '#1F88D0',
|
|
45
|
+
'& path': {
|
|
46
|
+
fill: '#1F88D0',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export const ClearIcon = styled('img')(({ variant }) => ({
|
|
51
|
+
width: '10px',
|
|
52
|
+
height: '10px',
|
|
53
|
+
filter: variant === 'active' ? 'brightness(0) invert(1)' : 'brightness(0) invert(0)',
|
|
54
|
+
cursor: 'pointer',
|
|
55
|
+
position: 'absolute',
|
|
56
|
+
top: '50%',
|
|
57
|
+
left: '47%',
|
|
58
|
+
transform: 'translate(-50%, -50%)',
|
|
59
|
+
}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TableHeaderStatus } from '../../types/index.js';
|
|
2
|
+
export interface CurrencyOption {
|
|
3
|
+
code: string;
|
|
4
|
+
name: string;
|
|
5
|
+
flagCode?: string;
|
|
6
|
+
status: TableHeaderStatus;
|
|
7
|
+
}
|
|
8
|
+
export interface MultiSelectStatusButtonProps {
|
|
9
|
+
options: CurrencyOption[];
|
|
10
|
+
selectedValues: TableHeaderStatus[];
|
|
11
|
+
onSelectionChange: (selected: TableHeaderStatus[]) => void;
|
|
12
|
+
label?: string;
|
|
13
|
+
variant?: 'active' | 'inActive';
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CalenderMode, Timezone } from '../../types/index.js';
|
|
2
|
+
interface RangeCalendarProps {
|
|
3
|
+
defaultDate: [Date, Date];
|
|
4
|
+
onDateChange: (date: [Date, Date], timezoneOffset?: number) => void;
|
|
5
|
+
mode?: CalenderMode;
|
|
6
|
+
onCalendarModeSwitch?: (mode: CalenderMode) => void;
|
|
7
|
+
numberOfMonths?: number;
|
|
8
|
+
noTimezone?: boolean;
|
|
9
|
+
noQuickFilter?: boolean;
|
|
10
|
+
maxDateRange?: number;
|
|
11
|
+
onCalendarGroupChange?: (value: string) => void;
|
|
12
|
+
groupBy?: string;
|
|
13
|
+
timezone: Timezone | null;
|
|
14
|
+
onChangeTimezoneHistory?: (timezone: Timezone) => void;
|
|
15
|
+
onChangeTimezone?: (timezone: Timezone) => void;
|
|
16
|
+
defaultTimezone: Timezone;
|
|
17
|
+
browserTimezone: string;
|
|
18
|
+
}
|
|
19
|
+
declare function RangeCalender({ defaultDate, onDateChange, mode, onCalendarModeSwitch, numberOfMonths, noTimezone, noQuickFilter, maxDateRange, onCalendarGroupChange, groupBy, timezone, onChangeTimezoneHistory, onChangeTimezone, defaultTimezone, browserTimezone, }: RangeCalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default RangeCalender;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Collapse from '@mui/material/Collapse';
|
|
5
|
+
import Popper from '@mui/material/Popper';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
import { DateObject } from 'react-multi-date-picker';
|
|
9
|
+
import { CustomBackdrop, Error } from '../index.js';
|
|
10
|
+
import GroupBy from './components/GroupBy';
|
|
11
|
+
import Hijri from './components/Hijri';
|
|
12
|
+
import QuickFilters from './components/QuickFilters';
|
|
13
|
+
import RangeDatePicker from './components/RangeDatepicker';
|
|
14
|
+
import CustomTimezone from './components/Timezone';
|
|
15
|
+
import { ButtonsWrapper, CalenderWrapper, CancelButton, FiltersArea, Footer, Main, OkayButton, SelectedDate, TimeZone, Settings } from './style';
|
|
16
|
+
function RangeCalender({ defaultDate, onDateChange, mode = 'gregorian', onCalendarModeSwitch, numberOfMonths, noTimezone, noQuickFilter, maxDateRange, onCalendarGroupChange, groupBy, timezone, onChangeTimezoneHistory, onChangeTimezone, defaultTimezone, browserTimezone, }) {
|
|
17
|
+
const [dates, setDates] = useState([new DateObject(defaultDate[0]), new DateObject(defaultDate[1])]);
|
|
18
|
+
const [values, setValues] = useState(dates);
|
|
19
|
+
const [selectedTimezone, setSelectedTimezone] = useState(timezone);
|
|
20
|
+
const [selectedGroupBy, setSelectedGroupBy] = useState(groupBy || 'day');
|
|
21
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
22
|
+
const open = Boolean(anchorEl);
|
|
23
|
+
const [isError, setIsError] = useState(false);
|
|
24
|
+
const { t } = useTranslation();
|
|
25
|
+
const calendarRef = useRef();
|
|
26
|
+
const isHijri = mode === 'hijri';
|
|
27
|
+
const onCloseCalender = () => {
|
|
28
|
+
setAnchorEl(null);
|
|
29
|
+
};
|
|
30
|
+
const onOpenCalender = (event) => {
|
|
31
|
+
setAnchorEl(event.currentTarget);
|
|
32
|
+
};
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!open) {
|
|
35
|
+
if (numberOfMonths === 1)
|
|
36
|
+
return;
|
|
37
|
+
setValues([new DateObject(defaultDate[0]), new DateObject(defaultDate[1])]);
|
|
38
|
+
}
|
|
39
|
+
}, [open]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setSelectedTimezone(timezone);
|
|
42
|
+
}, [timezone, open]);
|
|
43
|
+
const updateTimezone = (newTimezone) => {
|
|
44
|
+
onChangeTimezone === null || onChangeTimezone === void 0 ? void 0 : onChangeTimezone(newTimezone);
|
|
45
|
+
onChangeTimezoneHistory === null || onChangeTimezoneHistory === void 0 ? void 0 : onChangeTimezoneHistory(newTimezone);
|
|
46
|
+
};
|
|
47
|
+
const formatDate = (date) => new Date(date.setHour(new Date().getHours()).setMinute(new Date().getMinutes()).setSecond(new Date().getSeconds()).toDate().toLocaleString('en-us', {
|
|
48
|
+
timeZone: selectedTimezone === null || selectedTimezone === void 0 ? void 0 : selectedTimezone.timezone,
|
|
49
|
+
}));
|
|
50
|
+
const submitDate = () => {
|
|
51
|
+
setDates(values);
|
|
52
|
+
onCloseCalender();
|
|
53
|
+
onDateChange([formatDate(values[0]), formatDate(values[1] || values[0])], timezone === null || timezone === void 0 ? void 0 : timezone.offset);
|
|
54
|
+
onCalendarGroupChange === null || onCalendarGroupChange === void 0 ? void 0 : onCalendarGroupChange(selectedGroupBy || 'day');
|
|
55
|
+
updateTimezone(selectedTimezone);
|
|
56
|
+
};
|
|
57
|
+
const getSelectedDate = () => {
|
|
58
|
+
const startSelectedTime = dates[0].format('MMM D');
|
|
59
|
+
const endSelectedTime = dates[1] ? dates[1].format('MMM D') : dates[0].format('MMM D');
|
|
60
|
+
return startSelectedTime === endSelectedTime && !noTimezone ? startSelectedTime : `${startSelectedTime} - ${endSelectedTime}`;
|
|
61
|
+
};
|
|
62
|
+
const onChange = (newDate) => {
|
|
63
|
+
if (newDate.length < 2 || !maxDateRange) {
|
|
64
|
+
setValues(newDate);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const startDate = newDate[0].toDate();
|
|
68
|
+
const endDate = newDate[1].toDate();
|
|
69
|
+
const numberOfDays = dayjs(endDate).diff(startDate, 'day');
|
|
70
|
+
if (numberOfDays <= maxDateRange) {
|
|
71
|
+
setValues(newDate);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
setIsError(true);
|
|
75
|
+
setValues([newDate[0], newDate[1].subtract(numberOfDays - maxDateRange, 'd')]);
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
setIsError(false);
|
|
78
|
+
}, 3000);
|
|
79
|
+
};
|
|
80
|
+
const onChangeQuickFilter = (newValues) => {
|
|
81
|
+
setValues(newValues);
|
|
82
|
+
if (calendarRef.current)
|
|
83
|
+
calendarRef.current.set({ date: newValues[0] });
|
|
84
|
+
};
|
|
85
|
+
return (_jsxs(Main, Object.assign({ "data-testid": "RangeCalender" }, { children: [_jsx(SelectedDate, Object.assign({ onClick: onOpenCalender, open: open }, { children: (dates[0] || dates[1]) && getSelectedDate() })), open && (_jsx(CustomBackdrop, { onClick: (e) => {
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
onCloseCalender();
|
|
88
|
+
} })), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-end", sx: { zIndex: 3 } }, { children: _jsxs(CalenderWrapper, { children: [!noQuickFilter && (_jsxs(FiltersArea, { children: [_jsx(QuickFilters, { onChange: onChangeQuickFilter, isHijri: isHijri }), _jsxs(Settings, { children: [groupBy && (_jsx(GroupBy, { groupBy: selectedGroupBy, isCalenderOpen: open, onUpdate: (group) => {
|
|
89
|
+
setSelectedGroupBy(group);
|
|
90
|
+
} })), _jsx(Hijri, { isHijri: isHijri, onCalendarModeSwitch: onCalendarModeSwitch })] })] })), _jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', justifyContent: 'space-between' } }, { children: [_jsx(RangeDatePicker, { values: values, onChange: onChange, isHijri: isHijri, ref: calendarRef, numberOfMonths: numberOfMonths }), _jsx(Collapse, Object.assign({ in: isError && Boolean(maxDateRange) }, { children: _jsx(Error, { error: t('dateRangeError', { number: maxDateRange }), sx: { marginInline: '16px', marginBottom: '16px' } }) })), _jsxs(Footer, Object.assign({ sx: { borderBottomLeftRadius: '8px' } }, { children: [!noTimezone ? (_jsx(TimeZone, { children: _jsx(CustomTimezone, { onChange: setSelectedTimezone, selectedTimezone: selectedTimezone, defaultTimezone: defaultTimezone, browserTimezone: browserTimezone }, String(open)) })) : (_jsx("div", {})), _jsxs(ButtonsWrapper, { children: [_jsx(CancelButton, Object.assign({ variant: "contained", onClick: onCloseCalender }, { children: t('cancel') })), _jsx(OkayButton, Object.assign({ variant: "contained", onClick: submitDate }, { children: t('okay') }))] })] }))] }))] }) }))] })));
|
|
91
|
+
}
|
|
92
|
+
export default RangeCalender;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DateObject } from 'react-multi-date-picker';
|
|
2
|
+
import { Dates } from '../../type';
|
|
3
|
+
interface CustomTimePickerProps {
|
|
4
|
+
values: Dates;
|
|
5
|
+
startTime: DateObject;
|
|
6
|
+
endTime: DateObject;
|
|
7
|
+
onChangeStartTime: (value: DateObject) => void;
|
|
8
|
+
onChangeEndTime: (value: DateObject) => void;
|
|
9
|
+
}
|
|
10
|
+
declare function CustomTimePicker({ values, onChangeStartTime, onChangeEndTime, startTime, endTime }: CustomTimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default CustomTimePicker;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import DatePicker, { DateObject } from 'react-multi-date-picker';
|
|
5
|
+
import TimePicker from 'react-multi-date-picker/plugins/time_picker';
|
|
6
|
+
import { IOSSwitch } from '../../../index.js';
|
|
7
|
+
import { AllDayStyled, TimeArea, TimePickerWrapper, TimeAreaInner } from './style';
|
|
8
|
+
function CustomTimePicker({ values, onChangeStartTime, onChangeEndTime, startTime, endTime }) {
|
|
9
|
+
const [isAllDay, setIsAllDay] = useState(false);
|
|
10
|
+
const [lastTime, setLastTime] = useState([startTime, endTime]);
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (isAllDay)
|
|
14
|
+
setIsAllDay(new DateObject(values[0]).dayOfYear === new DateObject(values[1]).dayOfYear);
|
|
15
|
+
}, [values]);
|
|
16
|
+
return (_jsx(_Fragment, { children: new DateObject(values[0]).dayOfYear === new DateObject(values[1]).dayOfYear && (_jsx(TimeArea, { children: _jsxs(TimeAreaInner, { children: [_jsxs(AllDayStyled, Object.assign({ isAllDay: isAllDay }, { children: [_jsx("span", Object.assign({ className: "label" }, { children: t('allDay') })), _jsx(IOSSwitch, { checked: isAllDay, onChange: (e) => {
|
|
17
|
+
setIsAllDay(!isAllDay);
|
|
18
|
+
if (e.target.checked) {
|
|
19
|
+
setLastTime([startTime, endTime]);
|
|
20
|
+
onChangeStartTime(new DateObject().setHour(0).setMinute(0));
|
|
21
|
+
onChangeEndTime(new DateObject().setHour(23).setMinute(59));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
onChangeStartTime(lastTime[0]);
|
|
25
|
+
onChangeEndTime(lastTime[1]);
|
|
26
|
+
}
|
|
27
|
+
} })] })), !isAllDay && (_jsxs(TimePickerWrapper, { children: [_jsx(DatePicker, { arrow: false, disableDayPicker: true, hideOnScroll: true, format: "hh:mma", value: startTime, onChange: (time) => {
|
|
28
|
+
onChangeStartTime(time);
|
|
29
|
+
}, type: "button", plugins: [_jsx(TimePicker, { position: "top", hideSeconds: true })] }), _jsx(DatePicker, { arrow: false, disableDayPicker: true, hideOnScroll: true, format: "hh:mma", value: endTime, onChange: (time) => {
|
|
30
|
+
onChangeEndTime(time);
|
|
31
|
+
}, type: "button", plugins: [_jsx(TimePicker, { position: "top", hideSeconds: true })] })] }))] }) })) }));
|
|
32
|
+
}
|
|
33
|
+
export default CustomTimePicker;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const AllDayStyled: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").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/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
5
|
+
isAllDay: boolean;
|
|
6
|
+
}, {}, {}>;
|
|
7
|
+
export declare const TimeArea: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
8
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
9
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
10
|
+
export declare const TimePickerWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
11
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
12
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
13
|
+
export declare const TimeAreaInner: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
14
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
15
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|