@tap-payments/os-micro-frontend-shared 0.0.88 → 0.0.89

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 (55) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +12 -12
  3. package/build/components/RangeCalender/RangeCalender.d.ts +20 -0
  4. package/build/components/RangeCalender/RangeCalender.js +92 -0
  5. package/build/components/RangeCalender/components/CustomTimepicker/CustomTimepicker.d.ts +11 -0
  6. package/build/components/RangeCalender/components/CustomTimepicker/CustomTimepicker.js +33 -0
  7. package/build/components/RangeCalender/components/CustomTimepicker/index.d.ts +2 -0
  8. package/build/components/RangeCalender/components/CustomTimepicker/index.js +2 -0
  9. package/build/components/RangeCalender/components/CustomTimepicker/style.d.ts +15 -0
  10. package/build/components/RangeCalender/components/CustomTimepicker/style.js +132 -0
  11. package/build/components/RangeCalender/components/GroupBy/GroupBy.d.ts +10 -0
  12. package/build/components/RangeCalender/components/GroupBy/GroupBy.js +33 -0
  13. package/build/components/RangeCalender/components/GroupBy/index.d.ts +2 -0
  14. package/build/components/RangeCalender/components/GroupBy/index.js +2 -0
  15. package/build/components/RangeCalender/components/GroupBy/style.d.ts +15 -0
  16. package/build/components/RangeCalender/components/GroupBy/style.js +39 -0
  17. package/build/components/RangeCalender/components/Hijri/Hijri.d.ts +7 -0
  18. package/build/components/RangeCalender/components/Hijri/Hijri.js +13 -0
  19. package/build/components/RangeCalender/components/Hijri/index.d.ts +2 -0
  20. package/build/components/RangeCalender/components/Hijri/index.js +2 -0
  21. package/build/components/RangeCalender/components/Hijri/style.d.ts +4 -0
  22. package/build/components/RangeCalender/components/Hijri/style.js +25 -0
  23. package/build/components/RangeCalender/components/QuickFilters/QuickFilters.d.ts +8 -0
  24. package/build/components/RangeCalender/components/QuickFilters/QuickFilters.js +47 -0
  25. package/build/components/RangeCalender/components/QuickFilters/index.d.ts +2 -0
  26. package/build/components/RangeCalender/components/QuickFilters/index.js +2 -0
  27. package/build/components/RangeCalender/components/QuickFilters/style.d.ts +7 -0
  28. package/build/components/RangeCalender/components/QuickFilters/style.js +27 -0
  29. package/build/components/RangeCalender/components/RangeDatepicker/RangeDatepicker.d.ts +12 -0
  30. package/build/components/RangeCalender/components/RangeDatepicker/RangeDatepicker.js +29 -0
  31. package/build/components/RangeCalender/components/RangeDatepicker/index.d.ts +2 -0
  32. package/build/components/RangeCalender/components/RangeDatepicker/index.js +2 -0
  33. package/build/components/RangeCalender/components/RangeDatepicker/style.d.ts +4 -0
  34. package/build/components/RangeCalender/components/RangeDatepicker/style.js +9 -0
  35. package/build/components/RangeCalender/components/Timezone/Timezone.d.ts +11 -0
  36. package/build/components/RangeCalender/components/Timezone/Timezone.js +32 -0
  37. package/build/components/RangeCalender/components/Timezone/components/EntitiesTimezone.d.ts +12 -0
  38. package/build/components/RangeCalender/components/Timezone/components/EntitiesTimezone.js +37 -0
  39. package/build/components/RangeCalender/components/Timezone/components/UserTimezone.d.ts +8 -0
  40. package/build/components/RangeCalender/components/Timezone/components/UserTimezone.js +14 -0
  41. package/build/components/RangeCalender/components/Timezone/index.d.ts +2 -0
  42. package/build/components/RangeCalender/components/Timezone/index.js +2 -0
  43. package/build/components/RangeCalender/components/Timezone/style.d.ts +21 -0
  44. package/build/components/RangeCalender/components/Timezone/style.js +61 -0
  45. package/build/components/RangeCalender/index.d.ts +2 -0
  46. package/build/components/RangeCalender/index.js +2 -0
  47. package/build/components/RangeCalender/style.d.ts +33 -0
  48. package/build/components/RangeCalender/style.js +189 -0
  49. package/build/components/RangeCalender/type.d.ts +2 -0
  50. package/build/components/RangeCalender/type.js +1 -0
  51. package/build/components/RangeCalender/utils.d.ts +6 -0
  52. package/build/components/RangeCalender/utils.js +15 -0
  53. package/build/components/index.d.ts +1 -0
  54. package/build/components/index.js +1 -0
  55. package/package.json +129 -129
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
+ ```
@@ -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;
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,2 @@
1
+ import CustomTimepicker from './CustomTimepicker';
2
+ export default CustomTimepicker;
@@ -0,0 +1,2 @@
1
+ import CustomTimepicker from './CustomTimepicker';
2
+ 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>, {}, {}>;
@@ -0,0 +1,132 @@
1
+ import Box from '@mui/material/Box';
2
+ import { styled } from '@mui/material/styles';
3
+ import { grayUpArrowIcon } from '../../../../constants/index.js';
4
+ export const AllDayStyled = styled(Box, { shouldForwardProp: (props) => props !== 'isAllDay' })(({ theme, isAllDay }) => (Object.assign({ display: 'flex', alignItems: 'center', gap: theme.spacing(1), position: 'relative', paddingInline: '5px', '.label': {
5
+ width: 'max-content',
6
+ } }, (!isAllDay && {
7
+ paddingRight: theme.spacing(1),
8
+ '&:after': {
9
+ content: '""',
10
+ position: 'absolute',
11
+ width: '1px',
12
+ background: theme.palette.divider,
13
+ right: 0,
14
+ height: 17,
15
+ },
16
+ }))));
17
+ export const TimeArea = styled(Box)(() => ({
18
+ width: 235,
19
+ }));
20
+ export const TimePickerWrapper = styled(Box)(({ theme }) => ({
21
+ display: 'flex',
22
+ gap: '4px',
23
+ '.rmdp-input': {
24
+ width: '64px',
25
+ borderRadius: '19px',
26
+ border: '1px solid',
27
+ borderColor: theme.palette.divider,
28
+ color: theme.palette.text.primary,
29
+ fontSize: '11px',
30
+ fontWeight: 500,
31
+ background: 'transparent',
32
+ cursor: 'pointer',
33
+ },
34
+ '.rmdp-input:focus': {
35
+ boxShadow: theme.shadows[7],
36
+ border: `1px solid ${theme.palette.info.dark}`,
37
+ borderRadius: '19px',
38
+ },
39
+ '.rmdp-time-picker': {
40
+ boxShadow: theme.shadows[5],
41
+ borderRadius: theme.spacing(1),
42
+ padding: theme.spacing(2),
43
+ minWidth: 'auto !important',
44
+ div: {
45
+ marginTop: 0,
46
+ display: 'block',
47
+ },
48
+ '> div': {
49
+ width: 32,
50
+ height: 64,
51
+ },
52
+ '.rmdp-arrow': {
53
+ borderColor: `${theme.palette.background.transparent[1]} !important`,
54
+ },
55
+ '.rmdp-arrow-container': {
56
+ justifyContent: 'center',
57
+ '&:hover': {
58
+ backgroundColor: 'transparent',
59
+ boxShadow: 'unset',
60
+ },
61
+ },
62
+ input: {
63
+ borderRadius: '4px',
64
+ border: `1px solid ${theme.palette.divider}`,
65
+ padding: 0,
66
+ width: 32,
67
+ height: 32,
68
+ fontSize: '11px',
69
+ color: theme.palette.text.primary,
70
+ fontWeight: 500,
71
+ '&:focus, &:focus-visible': {
72
+ border: `1px solid ${theme.palette.info.dark}`,
73
+ outline: 'unset',
74
+ },
75
+ },
76
+ '.dvdr': {
77
+ margin: '7px 4px 0',
78
+ },
79
+ '.rmdp-am, .rmdp-pm': {
80
+ margin: 0,
81
+ width: 32,
82
+ height: 32,
83
+ flex: 'auto',
84
+ justifyContent: 'center',
85
+ fontSize: '11px',
86
+ color: theme.palette.text.primary,
87
+ fontWeight: 500,
88
+ display: 'flex',
89
+ cursor: 'default',
90
+ },
91
+ '> div:last-child': {
92
+ marginInlineStart: '4px',
93
+ display: 'block !important',
94
+ },
95
+ '.rmdp-down, .rmdp-up': {
96
+ position: 'relative',
97
+ i: {
98
+ display: 'none',
99
+ },
100
+ '&:before': {
101
+ content: '""',
102
+ position: 'absolute',
103
+ top: '5px',
104
+ width: '10px',
105
+ height: '10px',
106
+ backgroundImage: `url(${grayUpArrowIcon})`,
107
+ },
108
+ },
109
+ '.rmdp-down:before': {
110
+ transform: 'rotate(180deg)',
111
+ },
112
+ },
113
+ '.rmdp-container': {
114
+ position: 'relative',
115
+ '> div': {
116
+ top: 'unset !important',
117
+ bottom: '28px',
118
+ transform: 'unset !important',
119
+ },
120
+ },
121
+ }));
122
+ export const TimeAreaInner = styled(Box)(({ theme }) => ({
123
+ display: 'flex',
124
+ gap: '8px',
125
+ alignItems: 'center',
126
+ borderRadius: '50px',
127
+ border: '1px solid',
128
+ borderColor: theme.palette.divider,
129
+ paddingInline: '5px',
130
+ width: 'fit-content',
131
+ height: 32,
132
+ }));
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { BoxProps } from '@mui/material/Box';
3
+ interface GroupByProps extends BoxProps {
4
+ groupBy: string;
5
+ isCalenderOpen: boolean;
6
+ onUpdate?: (value: string) => void;
7
+ }
8
+ declare function GroupBy({ sx, groupBy, isCalenderOpen, onUpdate }: GroupByProps): import("react/jsx-runtime").JSX.Element;
9
+ declare const _default: import("react").MemoExoticComponent<typeof GroupBy>;
10
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useState } from 'react';
3
+ import Box from '@mui/material/Box';
4
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
5
+ import Popper from '@mui/material/Popper';
6
+ import { useTranslation } from 'react-i18next';
7
+ import { blackHeadingDownArrow } from '../../../../constants/index.js';
8
+ import { GroupByLabel, GroupByDropdownButton, GroupByDropdown, Option } from './style';
9
+ const groupByLabel = {
10
+ day: 'Day',
11
+ month: 'Month',
12
+ quarter: 'Quarter',
13
+ year: 'Year',
14
+ };
15
+ function GroupBy({ sx, groupBy, isCalenderOpen, onUpdate }) {
16
+ const [anchorEl, setAnchorEl] = useState(null);
17
+ const open = Boolean(anchorEl) && isCalenderOpen;
18
+ const { t } = useTranslation();
19
+ const onClose = () => {
20
+ setAnchorEl(null);
21
+ };
22
+ const onOpen = (e) => {
23
+ setAnchorEl(e.currentTarget);
24
+ };
25
+ const onSelect = (value) => {
26
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(value);
27
+ onClose();
28
+ };
29
+ return (_jsx(ClickAwayListener, Object.assign({ onClickAway: onClose }, { children: _jsxs(Box, Object.assign({ sx: sx }, { children: [_jsx(GroupByLabel, { children: t('groupedBy') }), _jsxs(GroupByDropdownButton, Object.assign({ onClick: onOpen, open: open }, { children: [_jsx("span", { children: groupByLabel[groupBy] }), _jsx(Box, { component: "img", src: blackHeadingDownArrow, alt: "arrow", sx: Object.assign({}, (open && { transform: 'rotate(180deg)' })) })] })), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, sx: { zIndex: 3 } }, { children: _jsx(GroupByDropdown, Object.assign({ sx: { width: anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.clientWidth } }, { children: Object.entries(groupByLabel).map(([key, value]) => (_jsx(Option, Object.assign({ onClick: () => {
30
+ onSelect(key);
31
+ }, className: groupBy === key ? 'active' : '' }, { children: value }), `${key}-groupedBy`))) })) }))] })) })));
32
+ }
33
+ export default memo(GroupBy);
@@ -0,0 +1,2 @@
1
+ import GroupBy from './GroupBy';
2
+ export default GroupBy;
@@ -0,0 +1,2 @@
1
+ import GroupBy from './GroupBy';
2
+ export default GroupBy;
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ export declare const GroupByLabel: 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
+ export declare const GroupByDropdownButton: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").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/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
8
+ open: boolean;
9
+ }, {}, {}>;
10
+ export declare const GroupByDropdown: 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 Option: 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>, {}, {}>;
@@ -0,0 +1,39 @@
1
+ import Box from '@mui/material/Box';
2
+ import { styled } from '@mui/material/styles';
3
+ export const GroupByLabel = styled(Box)(({ theme }) => ({
4
+ color: theme.palette.grey[700],
5
+ fontSize: '9px',
6
+ fontWeight: 500,
7
+ marginBottom: '6px',
8
+ }));
9
+ export const GroupByDropdownButton = styled(Box, { shouldForwardProp: (props) => props !== 'open' })(({ theme, open }) => (Object.assign({ borderRadius: '4px', border: `1px solid ${theme.palette.divider}`, background: theme.palette.common.white, height: 32, padding: '8px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer' }, (open && {
10
+ border: `1px solid ${theme.palette.info.dark}`,
11
+ background: theme.palette.common.white,
12
+ boxShadow: theme.shadows[7],
13
+ }))));
14
+ export const GroupByDropdown = styled(Box)(({ theme }) => ({
15
+ borderRadius: '8px',
16
+ background: theme.palette.common.white,
17
+ boxShadow: '0px 8px 36px 0px rgba(0, 0, 0, 0.15)',
18
+ textAlign: 'center',
19
+ color: theme.palette.grey[900],
20
+ fontSize: '12px',
21
+ fontWeight: 500,
22
+ lineHeight: '20px',
23
+ letterSpacing: '0.1px',
24
+ padding: '16px',
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ justifyContent: 'center',
28
+ gap: '12px',
29
+ flexDirection: 'column',
30
+ }));
31
+ export const Option = styled(Box)(({ theme }) => ({
32
+ width: 71,
33
+ padding: '4px 0',
34
+ cursor: 'pointer',
35
+ '&:hover, &.active': {
36
+ borderRadius: '100px',
37
+ background: theme.palette.info.light,
38
+ },
39
+ }));
@@ -0,0 +1,7 @@
1
+ import type { CalenderMode } from '../../../../types/index.js';
2
+ interface CalenderSettingsProps {
3
+ isHijri: boolean;
4
+ onCalendarModeSwitch?: (mode: CalenderMode) => void;
5
+ }
6
+ export default function Hijri({ isHijri, onCalendarModeSwitch }: CalenderSettingsProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,13 @@
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 { IOSSwitch } from '../../../index.js';
5
+ import { hijriIcon } from '../../../../constants/index.js';
6
+ import { CalenderSetting } from './style';
7
+ export default function Hijri({ isHijri, onCalendarModeSwitch }) {
8
+ const { t } = useTranslation();
9
+ const onChange = () => {
10
+ onCalendarModeSwitch === null || onCalendarModeSwitch === void 0 ? void 0 : onCalendarModeSwitch(isHijri ? 'gregorian' : 'hijri');
11
+ };
12
+ return (_jsx(Box, { children: _jsxs(CalenderSetting, { children: [_jsxs(Box, { children: [_jsx("img", { src: hijriIcon, alt: "hijri" }), _jsx("span", { children: t('hijri') })] }), _jsx(IOSSwitch, { checked: isHijri, onChange: onChange })] }) }));
13
+ }
@@ -0,0 +1,2 @@
1
+ import CalenderSettings from './Hijri';
2
+ export default CalenderSettings;
@@ -0,0 +1,2 @@
1
+ import CalenderSettings from './Hijri';
2
+ export default CalenderSettings;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const CalenderSetting: 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>, {}, {}>;
@@ -0,0 +1,25 @@
1
+ import Box from '@mui/material/Box';
2
+ import { styled } from '@mui/material/styles';
3
+ export const CalenderSetting = styled(Box)(({ theme }) => ({
4
+ border: '1px solid',
5
+ borderColor: theme.palette.divider,
6
+ borderRadius: '50px',
7
+ paddingInline: '6px 12px',
8
+ color: theme.palette.text.primary,
9
+ fontSize: '11px',
10
+ display: 'flex',
11
+ gap: '8px',
12
+ alignItems: 'center',
13
+ justifyContent: 'space-between',
14
+ height: 32,
15
+ marginTop: '8px',
16
+ img: {
17
+ width: 16,
18
+ height: 16,
19
+ },
20
+ '& > div': {
21
+ display: 'flex',
22
+ alignItems: 'center',
23
+ gap: '2px',
24
+ },
25
+ }));
@@ -0,0 +1,8 @@
1
+ import { DateObject } from 'react-multi-date-picker';
2
+ interface QuickFiltersProps {
3
+ onChange: (dates: [DateObject, DateObject]) => void;
4
+ isHijri: boolean;
5
+ isAr?: boolean;
6
+ }
7
+ export default function QuickFilters({ onChange, isHijri, isAr }: QuickFiltersProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import Box from '@mui/material/Box';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { DateObject } from 'react-multi-date-picker';
6
+ import { CustomLabel, FiltersWrapper } from './style';
7
+ import { getCalender, getLocale } from '../../utils';
8
+ export default function QuickFilters({ onChange, isHijri, isAr = false }) {
9
+ const calenderSettings = { locale: getLocale({ isHijri, isAr }), calendar: getCalender(isHijri) };
10
+ const filterList = useMemo(() => [
11
+ { id: 'today', value: [new DateObject(calenderSettings), new DateObject(calenderSettings)] },
12
+ {
13
+ id: 'lastWeek',
14
+ value: [new DateObject(calenderSettings).subtract(7, 'day'), new DateObject(calenderSettings)],
15
+ },
16
+ {
17
+ id: 'lastMonth',
18
+ value: [new DateObject(calenderSettings).subtract(30, 'day'), new DateObject(calenderSettings)],
19
+ },
20
+ {
21
+ id: new DateObject(calenderSettings).subtract(1, 'month').toFirstOfMonth().format('MMMM YYYY'),
22
+ value: [
23
+ new DateObject(calenderSettings).subtract(1, 'month').toFirstOfMonth(),
24
+ new DateObject(calenderSettings).subtract(1, 'month').toLastOfMonth(),
25
+ ],
26
+ },
27
+ {
28
+ id: new DateObject(calenderSettings).subtract(2, 'month').toFirstOfMonth().format('MMMM YYYY'),
29
+ value: [
30
+ new DateObject(calenderSettings).subtract(2, 'month').toFirstOfMonth(),
31
+ new DateObject(calenderSettings).subtract(2, 'month').toLastOfMonth(),
32
+ ],
33
+ },
34
+ {
35
+ id: new DateObject(calenderSettings).subtract(3, 'month').toFirstOfMonth().format('MMMM YYYY'),
36
+ value: [
37
+ new DateObject(calenderSettings).subtract(3, 'month').toFirstOfMonth(),
38
+ new DateObject(calenderSettings).subtract(3, 'month').toLastOfMonth(),
39
+ ],
40
+ },
41
+ ], [isHijri, isAr]);
42
+ const { t } = useTranslation();
43
+ return (_jsx(Box, Object.assign({ "data-testid": "RangeCalender_QuickFilters" }, { children: _jsx(FiltersWrapper, { children: filterList.map((item) => (_jsx(CustomLabel, Object.assign({ onClick: (e) => {
44
+ e.preventDefault();
45
+ onChange(item.value);
46
+ } }, { children: t(item.id) }), item.id))) }) })));
47
+ }
@@ -0,0 +1,2 @@
1
+ import QuickFilters from './QuickFilters';
2
+ export default QuickFilters;
@@ -0,0 +1,2 @@
1
+ import QuickFilters from './QuickFilters';
2
+ export default QuickFilters;