@tap-payments/os-micro-frontend-shared 0.1.171-test.3 → 0.1.171-test.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/RangeCalender/RangeCalender.js +3 -1
- package/build/components/RangeCalender/components/CustomTimepicker/CustomTimepicker.d.ts +1 -1
- package/build/components/RangeCalender/components/CustomTimepicker/CustomTimepicker.js +22 -17
- package/build/components/Timepicker/Timepicker.d.ts +2 -1
- package/build/components/Timepicker/Timepicker.js +2 -2
- package/build/components/Timepicker/index.d.ts +1 -0
- package/build/components/Timepicker/index.js +1 -0
- package/build/components/Timepicker/style.d.ts +1 -0
- package/build/components/Timepicker/style.js +1 -1
- package/build/utils/date.js +2 -1
- package/package.json +2 -2
|
@@ -16,9 +16,11 @@ import { ButtonsWrapper, CalenderWrapper, CancelButton, FiltersArea, Footer, Mai
|
|
|
16
16
|
import { getEndOfDate, getStartOfDate } from './utils';
|
|
17
17
|
import { CustomTimePicker } from './components/CustomTimepicker';
|
|
18
18
|
function RangeCalender({ defaultDate, onDateChange, mode = 'gregorian', onCalendarModeSwitch, numberOfMonths, noTimezone, noQuickFilter, maxDateRange, onCalendarGroupChange, groupBy, timezone, onChangeTimezoneHistory, onChangeTimezone, defaultTimezone, browserTimezone, renderCalendarButton, mainSx, popperProps, rangeDatePickerProps, }) {
|
|
19
|
+
var _a, _b;
|
|
19
20
|
const [dates, setDates] = useState([new DateObject(defaultDate === null || defaultDate === void 0 ? void 0 : defaultDate[0]), new DateObject(defaultDate === null || defaultDate === void 0 ? void 0 : defaultDate[1])]);
|
|
20
21
|
const [values, setValues] = useState(dates);
|
|
21
22
|
const [selectedTimezone, setSelectedTimezone] = useState(timezone);
|
|
23
|
+
console.log({ s: (_a = values[0]) === null || _a === void 0 ? void 0 : _a.format('MM/DD/YYYY HH:mma'), e: (_b = values[1]) === null || _b === void 0 ? void 0 : _b.format('MM/DD/YYYY HH:mma') });
|
|
22
24
|
const [selectedGroupBy, setSelectedGroupBy] = useState(groupBy || 'day');
|
|
23
25
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
24
26
|
const open = Boolean(anchorEl);
|
|
@@ -97,6 +99,6 @@ function RangeCalender({ defaultDate, onDateChange, mode = 'gregorian', onCalend
|
|
|
97
99
|
onCloseCalender();
|
|
98
100
|
} })), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-end" }, popperProps, { 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) => {
|
|
99
101
|
setSelectedGroupBy(group);
|
|
100
|
-
} })), _jsx(Hijri, { isHijri: isHijri, onCalendarModeSwitch: onCalendarModeSwitch })] })] })), _jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', justifyContent: 'space-between' } }, { children: [_jsx(RangeDatePicker, Object.assign({ values: values, onChange: onChange, isHijri: isHijri, ref: calendarRef, numberOfMonths: numberOfMonths }, rangeDatePickerProps)), _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", {})), _jsx(CustomTimePicker, { values: values, setValues: setValues }), _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') }))] })] }))] }))] }) }))] })));
|
|
102
|
+
} })), _jsx(Hijri, { isHijri: isHijri, onCalendarModeSwitch: onCalendarModeSwitch })] })] })), _jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', justifyContent: 'space-between' } }, { children: [_jsx(RangeDatePicker, Object.assign({ values: values, onChange: onChange, isHijri: isHijri, ref: calendarRef, numberOfMonths: numberOfMonths }, rangeDatePickerProps)), _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", {})), new DateObject(values[0]).dayOfYear === new DateObject(values[1]).dayOfYear && (_jsx(CustomTimePicker, { values: values, setValues: setValues })), _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') }))] })] }))] }))] }) }))] })));
|
|
101
103
|
}
|
|
102
104
|
export default RangeCalender;
|
|
@@ -3,5 +3,5 @@ interface CustomTimePickerProps {
|
|
|
3
3
|
values: Dates;
|
|
4
4
|
setValues: (values: Dates) => void;
|
|
5
5
|
}
|
|
6
|
-
export declare function CustomTimePicker({ values, setValues
|
|
6
|
+
export declare function CustomTimePicker({ values, setValues }: CustomTimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState
|
|
2
|
+
import { useState } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { DateObject } from 'react-multi-date-picker';
|
|
5
|
-
// import TimePicker from 'react-multi-date-picker/plugins/time_picker'
|
|
6
5
|
import { IOSSwitch } from '../../../index.js';
|
|
6
|
+
import TimePicker, { convertTo12Hour, maxHour } from '../../../Timepicker';
|
|
7
7
|
import { AllDayStyled, TimeArea, TimePickerWrapper, TimeAreaInner } from './style';
|
|
8
|
-
import { getEndOfDate } from '../../utils';
|
|
9
|
-
|
|
10
|
-
export function CustomTimePicker({ values, setValues, }) {
|
|
11
|
-
const [isAllDay, setIsAllDay] = useState();
|
|
12
|
-
// const [lastTime, setLastTime] = useState<DateObject[]>(values)
|
|
13
|
-
const fromDate = new DateObject(values[0]);
|
|
14
|
-
const toDate = new DateObject(values[1] || values[0]);
|
|
8
|
+
import { getEndOfDate, getStartOfDate } from '../../utils';
|
|
9
|
+
export function CustomTimePicker({ values, setValues }) {
|
|
15
10
|
const { t } = useTranslation();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, [values]);
|
|
20
|
-
if (new DateObject(values[0]).dayOfYear !== new DateObject(values[1]).dayOfYear)
|
|
21
|
-
return null;
|
|
11
|
+
const startDate = new DateObject(values[0]);
|
|
12
|
+
const endDate = new DateObject(values[1] || values[0]);
|
|
13
|
+
const [isAllDay, setIsAllDay] = useState(startDate.dayOfYear === endDate.dayOfYear && startDate.hour === 0 && startDate.minute === 0 && endDate.hour === 23 && endDate.minute === 59);
|
|
22
14
|
return (_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) => {
|
|
23
15
|
setIsAllDay(!isAllDay);
|
|
24
16
|
if (e.target.checked) {
|
|
25
|
-
setValues([
|
|
17
|
+
setValues([getStartOfDate(values[0]), getEndOfDate(values[1])]);
|
|
26
18
|
}
|
|
27
19
|
else {
|
|
28
20
|
setValues(values);
|
|
29
21
|
}
|
|
30
|
-
} })] })), !isAllDay && (_jsxs(TimePickerWrapper, { children: [_jsx(TimePicker, {
|
|
22
|
+
} })] })), !isAllDay && (_jsxs(TimePickerWrapper, { children: [_jsx(TimePicker, { defaultTime: {
|
|
23
|
+
hour: convertTo12Hour(startDate.hour),
|
|
24
|
+
minute: startDate.minute,
|
|
25
|
+
period: startDate.hour >= maxHour ? 'PM' : 'AM',
|
|
26
|
+
}, size: "small", onChange: ({ hour, minute, period }) => {
|
|
27
|
+
console.log('from', { hour });
|
|
28
|
+
setValues([startDate.setHour(period === 'PM' ? hour + 12 : hour).setMinute(minute), endDate]);
|
|
29
|
+
} }, `${values[0].toString()}-start`), _jsx(TimePicker, { defaultTime: {
|
|
30
|
+
hour: convertTo12Hour(endDate.hour),
|
|
31
|
+
minute: endDate.minute,
|
|
32
|
+
period: endDate.hour >= maxHour ? 'PM' : 'AM',
|
|
33
|
+
}, size: "small", onChange: ({ hour, minute, period }) => {
|
|
34
|
+
setValues([startDate, endDate.setHour(period === 'PM' ? hour + 12 : hour).setMinute(minute)]);
|
|
35
|
+
} }, `${values[1].toString()}-end`)] }))] }) }));
|
|
31
36
|
}
|
|
@@ -7,6 +7,7 @@ interface TimePickerProps {
|
|
|
7
7
|
defaultTime?: Time;
|
|
8
8
|
onChange?: (time: Time) => void;
|
|
9
9
|
enableRealTimeChange?: boolean;
|
|
10
|
+
size?: 'large' | 'small';
|
|
10
11
|
}
|
|
11
|
-
export declare function TimePicker({ onChange, defaultTime, enableRealTimeChange }: TimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function TimePicker({ onChange, defaultTime, enableRealTimeChange, size }: TimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -8,7 +8,7 @@ import { greyUpArrowIcon, greyDownArrowIcon } from '../../constants/index.js';
|
|
|
8
8
|
import { Arrow, Button, Period, PeriodWrapper, Wrapper, Time, TimeWrapper, Input } from './style';
|
|
9
9
|
import { getDefaultHour, getDefaultMinute } from './utils';
|
|
10
10
|
import { maxHour, maxMinute, periodList } from './constant';
|
|
11
|
-
export function TimePicker({ onChange, defaultTime, enableRealTimeChange }) {
|
|
11
|
+
export function TimePicker({ onChange, defaultTime, enableRealTimeChange, size = 'large' }) {
|
|
12
12
|
var _a, _b, _c;
|
|
13
13
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
14
14
|
const [period, setPeriod] = useState((_a = defaultTime === null || defaultTime === void 0 ? void 0 : defaultTime.period) !== null && _a !== void 0 ? _a : (new Date().getHours() >= maxHour ? 'PM' : 'AM'));
|
|
@@ -80,7 +80,7 @@ export function TimePicker({ onChange, defaultTime, enableRealTimeChange }) {
|
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
82
|
const formatTime = useCallback((time) => (time < 10 ? `0${time}` : time), []);
|
|
83
|
-
return (_jsx(ClickAwayListener, Object.assign({ onClickAway: onClose }, { children: _jsxs(Box, { children: [_jsx(Button, Object.assign({ open: open, onClick: onOpen }, { children: `${formatTime(hours)}:${formatTime(minutes)}${period.toLowerCase()}` })), _jsx(Menu, Object.assign({ open: open, anchorEl: anchorEl, placement: "top-start", sx: { marginTop: '8px', marginBottom: '8px' } }, { children: _jsxs(Wrapper, { children: [_jsxs(TimeWrapper, { children: [_jsxs(Time, { children: [_jsx(Arrow, Object.assign({ onClick: onIncreaseHours }, { children: _jsx("img", { src: greyUpArrowIcon, alt: "arrow" }) })), _jsx(Input, { value: formatTime(hours), onChange: onChangeHours }), _jsx(Arrow, Object.assign({ onClick: onDecreaseHours }, { children: _jsx("img", { src: greyDownArrowIcon, alt: "arrow" }) }))] }), _jsx(Text, { children: ":" }), _jsxs(Time, { children: [_jsx(Arrow, Object.assign({ onClick: onIncreaseMinutes }, { children: _jsx("img", { src: greyUpArrowIcon, alt: "arrow" }) })), _jsx(Input, { value: formatTime(minutes), onChange: onChangeMinutes }), _jsx(Arrow, Object.assign({ onClick: onDecreaseMinutes }, { children: _jsx("img", { src: greyDownArrowIcon, alt: "arrow" }) }))] })] }), _jsx(PeriodWrapper, { children: periodList.map((item) => (_jsx(Period, Object.assign({ onClick: () => {
|
|
83
|
+
return (_jsx(ClickAwayListener, Object.assign({ onClickAway: onClose }, { children: _jsxs(Box, { children: [_jsx(Button, Object.assign({ size: size, open: open, onClick: onOpen }, { children: `${formatTime(hours)}:${formatTime(minutes)}${period.toLowerCase()}` })), _jsx(Menu, Object.assign({ open: open, anchorEl: anchorEl, placement: "top-start", sx: { marginTop: '8px', marginBottom: '8px' } }, { children: _jsxs(Wrapper, { children: [_jsxs(TimeWrapper, { children: [_jsxs(Time, { children: [_jsx(Arrow, Object.assign({ onClick: onIncreaseHours }, { children: _jsx("img", { src: greyUpArrowIcon, alt: "arrow" }) })), _jsx(Input, { value: formatTime(hours), onChange: onChangeHours }), _jsx(Arrow, Object.assign({ onClick: onDecreaseHours }, { children: _jsx("img", { src: greyDownArrowIcon, alt: "arrow" }) }))] }), _jsx(Text, { children: ":" }), _jsxs(Time, { children: [_jsx(Arrow, Object.assign({ onClick: onIncreaseMinutes }, { children: _jsx("img", { src: greyUpArrowIcon, alt: "arrow" }) })), _jsx(Input, { value: formatTime(minutes), onChange: onChangeMinutes }), _jsx(Arrow, Object.assign({ onClick: onDecreaseMinutes }, { children: _jsx("img", { src: greyDownArrowIcon, alt: "arrow" }) }))] })] }), _jsx(PeriodWrapper, { children: periodList.map((item) => (_jsx(Period, Object.assign({ onClick: () => {
|
|
84
84
|
onClickPeriod(item);
|
|
85
85
|
}, selected: period === item }, { children: item }), item))) })] }) }))] }) })));
|
|
86
86
|
}
|
|
@@ -8,6 +8,7 @@ export declare const Button: import("@emotion/styled").StyledComponent<import("@
|
|
|
8
8
|
component?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
9
9
|
} & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
10
10
|
open: boolean;
|
|
11
|
+
size: 'large' | 'small';
|
|
11
12
|
}, {}, {}>;
|
|
12
13
|
export declare const Arrow: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
13
14
|
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
@@ -10,7 +10,7 @@ export const Wrapper = styled(Box)(() => ({
|
|
|
10
10
|
justifyContent: 'center',
|
|
11
11
|
gap: '16px',
|
|
12
12
|
}));
|
|
13
|
-
export const Button = styled(Text, { shouldForwardProp: (props) => props !== 'open' })(({ theme, open }) => (Object.assign({ fontSize: '11px', fontWeight: 500, background: theme.palette.common.white, border: `1px solid ${theme.palette.divider}`, borderRadius: '19px', height: 32, width: 74, display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer' }, (open && { boxShadow: '0px 0px 4px 0px #1F88D080', borderColor: theme.palette.info.dark }))));
|
|
13
|
+
export const Button = styled(Text, { shouldForwardProp: (props) => props !== 'open' && props !== 'size' })(({ theme, open, size }) => (Object.assign({ fontSize: '11px', fontWeight: 500, background: theme.palette.common.white, border: `1px solid ${theme.palette.divider}`, borderRadius: '19px', height: size === 'large' ? 32 : 24, width: size === 'large' ? 74 : 58, display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer' }, (open && { boxShadow: '0px 0px 4px 0px #1F88D080', borderColor: theme.palette.info.dark }))));
|
|
14
14
|
export const Arrow = styled(Box)(() => ({
|
|
15
15
|
textAlign: 'center',
|
|
16
16
|
cursor: 'pointer',
|
package/build/utils/date.js
CHANGED
|
@@ -65,7 +65,8 @@ export const formatUTCOffset = (offset = 0) => {
|
|
|
65
65
|
* @returns - Array of two dates [startDate, endDate]
|
|
66
66
|
*/
|
|
67
67
|
export const getDefaultDateRange = (startDay = 6) => {
|
|
68
|
-
const monthDaysMinus = dayjs().subtract(startDay, 'day').hour(0).minute(0).second(0).toDate()
|
|
68
|
+
// const monthDaysMinus = dayjs().subtract(startDay, 'day').hour(0).minute(0).second(0).toDate()
|
|
69
|
+
const monthDaysMinus = dayjs(new Date()).hour(10).minute(0).second(0).toDate();
|
|
69
70
|
const today = dayjs(new Date()).hour(23).minute(59).second(59).toDate();
|
|
70
71
|
return [monthDaysMinus, today];
|
|
71
72
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/os-micro-frontend-shared",
|
|
3
3
|
"description": "Shared components and utilities for Tap Payments micro frontends",
|
|
4
|
-
"version": "0.1.171-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.171-test.4",
|
|
5
|
+
"testVersion": 4,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|