@mailstep/design-system 0.7.21 → 0.7.22-beta.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.
- package/package.json +1 -1
- package/ui/Blocks/CommonGrid/styles.js +1 -1
- package/ui/Blocks/Scheduler/Scheduler.d.ts +3 -0
- package/ui/Blocks/Scheduler/Scheduler.js +27 -0
- package/ui/Blocks/Scheduler/components/CurrentTimeMarker/hooks/useCurrentTime.d.ts +5 -0
- package/ui/Blocks/Scheduler/components/CurrentTimeMarker/hooks/useCurrentTime.js +17 -0
- package/ui/Blocks/Scheduler/components/CurrentTimeMarker/index.d.ts +2 -0
- package/ui/Blocks/Scheduler/components/CurrentTimeMarker/index.js +9 -0
- package/ui/Blocks/Scheduler/components/CurrentTimeMarker/styles.d.ts +5 -0
- package/ui/Blocks/Scheduler/components/CurrentTimeMarker/styles.js +13 -0
- package/ui/Blocks/Scheduler/components/DateChanger/index.d.ts +14 -0
- package/ui/Blocks/Scheduler/components/DateChanger/index.js +19 -0
- package/ui/Blocks/Scheduler/components/DateChanger/styles.d.ts +4 -0
- package/ui/Blocks/Scheduler/components/DateChanger/styles.js +11 -0
- package/ui/Blocks/Scheduler/components/Groups/index.d.ts +7 -0
- package/ui/Blocks/Scheduler/components/Groups/index.js +6 -0
- package/ui/Blocks/Scheduler/components/Groups/styles.d.ts +6 -0
- package/ui/Blocks/Scheduler/components/Groups/styles.js +16 -0
- package/ui/Blocks/Scheduler/components/TimeSlots/hooks/useRangeSelection.d.ts +12 -0
- package/ui/Blocks/Scheduler/components/TimeSlots/hooks/useRangeSelection.js +47 -0
- package/ui/Blocks/Scheduler/components/TimeSlots/hooks/useScroll.d.ts +6 -0
- package/ui/Blocks/Scheduler/components/TimeSlots/hooks/useScroll.js +16 -0
- package/ui/Blocks/Scheduler/components/TimeSlots/index.d.ts +13 -0
- package/ui/Blocks/Scheduler/components/TimeSlots/index.js +29 -0
- package/ui/Blocks/Scheduler/components/TimeSlots/styles.d.ts +14 -0
- package/ui/Blocks/Scheduler/components/TimeSlots/styles.js +33 -0
- package/ui/Blocks/Scheduler/hooks/useChangeDate.d.ts +15 -0
- package/ui/Blocks/Scheduler/hooks/useChangeDate.js +34 -0
- package/ui/Blocks/Scheduler/index.d.ts +2 -0
- package/ui/Blocks/Scheduler/index.js +1 -0
- package/ui/Blocks/Scheduler/stories/Scheduler.stories.d.ts +7 -0
- package/ui/Blocks/Scheduler/stories/Scheduler.stories.js +35 -0
- package/ui/Blocks/Scheduler/styles.d.ts +1 -0
- package/ui/Blocks/Scheduler/styles.js +7 -0
- package/ui/Blocks/Scheduler/types.d.ts +29 -0
- package/ui/Blocks/Scheduler/types.js +1 -0
- package/ui/Blocks/Scheduler/utils/constants.d.ts +6 -0
- package/ui/Blocks/Scheduler/utils/constants.js +6 -0
- package/ui/Blocks/Scheduler/utils/convertDateToTime.d.ts +1 -0
- package/ui/Blocks/Scheduler/utils/convertDateToTime.js +5 -0
- package/ui/Blocks/Scheduler/utils/convertIndexToISOString.d.ts +1 -0
- package/ui/Blocks/Scheduler/utils/convertIndexToISOString.js +9 -0
- package/ui/Blocks/Scheduler/utils/formatDate.d.ts +1 -0
- package/ui/Blocks/Scheduler/utils/formatDate.js +4 -0
- package/ui/Blocks/Scheduler/utils/generateTimeArray.d.ts +1 -0
- package/ui/Blocks/Scheduler/utils/generateTimeArray.js +16 -0
- package/ui/Blocks/Scheduler/utils/getClosestStep.d.ts +1 -0
- package/ui/Blocks/Scheduler/utils/getClosestStep.js +9 -0
- package/ui/Blocks/Scheduler/utils/getMinutesFromString.d.ts +1 -0
- package/ui/Blocks/Scheduler/utils/getMinutesFromString.js +3 -0
- package/ui/Blocks/Scheduler/utils/getMinutesFromTime.d.ts +1 -0
- package/ui/Blocks/Scheduler/utils/getMinutesFromTime.js +4 -0
- package/ui/Blocks/Scheduler/utils/isActiveTime.d.ts +8 -0
- package/ui/Blocks/Scheduler/utils/isActiveTime.js +10 -0
- package/ui/Blocks/Scheduler/utils/isToday.d.ts +1 -0
- package/ui/Blocks/Scheduler/utils/isToday.js +4 -0
- package/ui/index.d.ts +3 -1
- package/ui/index.es.js +25623 -21576
- package/ui/index.js +3 -1
- package/ui/index.umd.js +781 -629
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ export var BottomWrapper = styled(x.div)(templateObject_1 || (templateObject_1 =
|
|
|
10
10
|
export var ContentContainer = styled(x.div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n background-color: white;\n box-shadow: gridShadow;\n border-radius: 8px;\n flex-grow: 1;\n height: 100%;\n"], ["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n background-color: white;\n box-shadow: gridShadow;\n border-radius: 8px;\n flex-grow: 1;\n height: 100%;\n"])));
|
|
11
11
|
export var CommonGridWrap = styled(x.div)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: calc(100% - ", "px);\n\n @media (min-width: 1024px) {\n height: calc(100% - ", "px);\n }\n"], ["\n height: calc(100% - ", "px);\n\n @media (min-width: 1024px) {\n height: calc(100% - ", "px);\n }\n"])), gridFooterHeight, gridFooterHeight);
|
|
12
12
|
export var StyledButtonStrip = styled(x.div)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n padding: 18px 20px;\n display: flex;\n justify-content: space-between;\n width: 100%;\n min-height: ", "px;\n flex-wrap: wrap;\n z-index: 3;\n"], ["\n position: relative;\n padding: 18px 20px;\n display: flex;\n justify-content: space-between;\n width: 100%;\n min-height: ", "px;\n flex-wrap: wrap;\n z-index: 3;\n"])), gridButtonStripHeight);
|
|
13
|
-
export var CommonGridWithStyles = styled(CommonGrid)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n height: calc(100% - ", "px);\n\n & .cell {\n padding: 0 4px;\n }\n & .dataRow {\n font-size: 12px;\n font-family: ", ";\n color: typoPrimary;\n font-weight: normal;\n border-bottom: 1px solid;\n border-color: lightGray3;\n height: ", "px;\n }\n & .gridHead {\n height: ", "px;\n background-color: neutral20;\n padding-bottom: 8px;\n position: sticky;\n top: -1px;\n z-index: 2;\n padding-left: 12px;\n border-top: 1px solid ", ";\n @media (min-width: 1024px) {\n padding-left: 20px;\n }\n }\n & .headRow {\n font-size: 12px;\n font-family: ", ";\n color: typoPrimary;\n font-weight: bold;\n border-bottom: none; // TODO fix in common-grid\n\n & .cell {\n overflow: hidden;\n max-height: 32px;\n position: relative;\n }\n\n & .sticky {\n background-color: bgLightGray1;\n }\n }\n\n & .filterRow {\n & .cell {\n overflow: visible;\n }\n\n & .cell > div {\n width: 100%; // TODO fix in common-grid\n }\n\n & .sticky {\n background-color: bgLightGray1;\n }\n border-bottom: none; // TODO fix in common-grid\n }\n\n & .body {\n margin: 0 1px 1px 1px; // matching margin with .gridHead\n padding-left: 12px;\n flex-grow: 1;\n @media (min-width: 1024px) {\n padding-left: 20px;\n }\n }\n\n & .gridWrapper {\n background-color: ", ";\n width:
|
|
13
|
+
export var CommonGridWithStyles = styled(CommonGrid)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n height: calc(100% - ", "px);\n\n & .cell {\n padding: 0 4px;\n }\n & .dataRow {\n font-size: 12px;\n font-family: ", ";\n color: typoPrimary;\n font-weight: normal;\n border-bottom: 1px solid;\n border-color: lightGray3;\n height: ", "px;\n }\n & .gridHead {\n height: ", "px;\n background-color: neutral20;\n padding-bottom: 8px;\n position: sticky;\n top: -1px;\n z-index: 2;\n padding-left: 12px;\n border-top: 1px solid ", ";\n @media (min-width: 1024px) {\n padding-left: 20px;\n }\n }\n & .headRow {\n font-size: 12px;\n font-family: ", ";\n color: typoPrimary;\n font-weight: bold;\n border-bottom: none; // TODO fix in common-grid\n\n & .cell {\n overflow: hidden;\n max-height: 32px;\n position: relative;\n }\n\n & .sticky {\n background-color: bgLightGray1;\n }\n }\n\n & .filterRow {\n & .cell {\n overflow: visible;\n }\n\n & .cell > div {\n width: 100%; // TODO fix in common-grid\n }\n\n & .sticky {\n background-color: bgLightGray1;\n }\n border-bottom: none; // TODO fix in common-grid\n }\n\n & .body {\n margin: 0 1px 1px 1px; // matching margin with .gridHead\n padding-left: 12px;\n flex-grow: 1;\n @media (min-width: 1024px) {\n padding-left: 20px;\n }\n }\n\n & .gridWrapper {\n background-color: ", ";\n width: auto;\n padding-bottom: 35px;\n\n @media (min-width: 1024px) {\n height: 100%;\n overflow-y: auto;\n padding-bottom: 0;\n }\n @media print {\n margin: 0;\n width: 100%;\n height: auto;\n overflow-x: hidden;\n }\n }\n\n & .fullWidthGrid > .gridWrapper > div {\n width: 100% !important;\n }\n\n & .paginatorWrapper,\n & .buttonsStrip {\n @media print {\n display: none;\n }\n }\n & .cell {\n padding-left: 2px;\n padding-right: 2px;\n @media print {\n white-space: unset;\n }\n }\n\n .dataRow {\n &.grayedOut {\n background: lightGray1;\n }\n\n .sticky-right, .sticky-left {\n background: white;\n z-index: 1;\n }\n\n .sticky-right {\n border-left: 1px solid #dfe1e6;\n \n }\n\n .sticky-left {\n border-right: 1px solid #dfe1e6;\n }\n }\n\n .dataRow:nth-child(even) {\n .sticky-left, .sticky-right {\n background-color: bgLightGray;\n }\n }\n\n @media print {\n .filterRow .sticky {\n display: none;\n }\n\n .headRow .sticky {\n display: none;\n }\n\n .dataRow .sticky {\n display: none;\n }\n }\n\n .resizer {\n z-index: unset;\n }\n\n // hotfix table head\n .cell .sortable {\n display: flex;\n align-items: center;\n padding-right: 2px;\n }\n\n .sticky {\n position: sticky !important;\n max-width: 88px;\n }\n\n .sticky-left {\n left: 0;\n }\n\n .sticky-right {\n right: 0;\n }\n"], ["\n height: calc(100% - ", "px);\n\n & .cell {\n padding: 0 4px;\n }\n & .dataRow {\n font-size: 12px;\n font-family: ", ";\n color: typoPrimary;\n font-weight: normal;\n border-bottom: 1px solid;\n border-color: lightGray3;\n height: ", "px;\n }\n & .gridHead {\n height: ", "px;\n background-color: neutral20;\n padding-bottom: 8px;\n position: sticky;\n top: -1px;\n z-index: 2;\n padding-left: 12px;\n border-top: 1px solid ", ";\n @media (min-width: 1024px) {\n padding-left: 20px;\n }\n }\n & .headRow {\n font-size: 12px;\n font-family: ", ";\n color: typoPrimary;\n font-weight: bold;\n border-bottom: none; // TODO fix in common-grid\n\n & .cell {\n overflow: hidden;\n max-height: 32px;\n position: relative;\n }\n\n & .sticky {\n background-color: bgLightGray1;\n }\n }\n\n & .filterRow {\n & .cell {\n overflow: visible;\n }\n\n & .cell > div {\n width: 100%; // TODO fix in common-grid\n }\n\n & .sticky {\n background-color: bgLightGray1;\n }\n border-bottom: none; // TODO fix in common-grid\n }\n\n & .body {\n margin: 0 1px 1px 1px; // matching margin with .gridHead\n padding-left: 12px;\n flex-grow: 1;\n @media (min-width: 1024px) {\n padding-left: 20px;\n }\n }\n\n & .gridWrapper {\n background-color: ", ";\n width: auto;\n padding-bottom: 35px;\n\n @media (min-width: 1024px) {\n height: 100%;\n overflow-y: auto;\n padding-bottom: 0;\n }\n @media print {\n margin: 0;\n width: 100%;\n height: auto;\n overflow-x: hidden;\n }\n }\n\n & .fullWidthGrid > .gridWrapper > div {\n width: 100% !important;\n }\n\n & .paginatorWrapper,\n & .buttonsStrip {\n @media print {\n display: none;\n }\n }\n & .cell {\n padding-left: 2px;\n padding-right: 2px;\n @media print {\n white-space: unset;\n }\n }\n\n .dataRow {\n &.grayedOut {\n background: lightGray1;\n }\n\n .sticky-right, .sticky-left {\n background: white;\n z-index: 1;\n }\n\n .sticky-right {\n border-left: 1px solid #dfe1e6;\n \n }\n\n .sticky-left {\n border-right: 1px solid #dfe1e6;\n }\n }\n\n .dataRow:nth-child(even) {\n .sticky-left, .sticky-right {\n background-color: bgLightGray;\n }\n }\n\n @media print {\n .filterRow .sticky {\n display: none;\n }\n\n .headRow .sticky {\n display: none;\n }\n\n .dataRow .sticky {\n display: none;\n }\n }\n\n .resizer {\n z-index: unset;\n }\n\n // hotfix table head\n .cell .sortable {\n display: flex;\n align-items: center;\n padding-right: 2px;\n }\n\n .sticky {\n position: sticky !important;\n max-width: 88px;\n }\n\n .sticky-left {\n left: 0;\n }\n\n .sticky-right {\n right: 0;\n }\n"])), gridButtonStripHeight, th('fonts.primary'), gridRowHeight, gridHeadHeight, th('colors.lightGray6'), th('fonts.primary'), function (_a) {
|
|
14
14
|
var theme = _a.theme;
|
|
15
15
|
return theme.colors.white;
|
|
16
16
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { groupBy } from 'lodash';
|
|
4
|
+
import { useToggleAndClose } from '../../hooks/useToggleAndClose';
|
|
5
|
+
import { DateChanger } from './components/DateChanger';
|
|
6
|
+
import { Groups } from './components/Groups';
|
|
7
|
+
import { TimeSlots } from './components/TimeSlots';
|
|
8
|
+
import { useChangeDate } from './hooks/useChangeDate';
|
|
9
|
+
import { generateTimeArray } from './utils/generateTimeArray';
|
|
10
|
+
import { getClosestStep } from './utils/getClosestStep';
|
|
11
|
+
import { Container } from './styles';
|
|
12
|
+
var timeArray = generateTimeArray();
|
|
13
|
+
export var Scheduler = function (_a) {
|
|
14
|
+
var groups = _a.groups, activeHours = _a.activeHours, data = _a.data, handleSelectTimeSlot = _a.handleSelectTimeSlot, handleReloadTimeSlots = _a.handleReloadTimeSlots, handleTimeSlotClick = _a.handleTimeSlotClick, isLoading = _a.isLoading;
|
|
15
|
+
var groupedTimeSlots = useMemo(function () { return groupBy(data, function (_a) {
|
|
16
|
+
var groupId = _a.groupId, start = _a.start;
|
|
17
|
+
return "".concat(groupId, "-").concat(getClosestStep(start));
|
|
18
|
+
}); }, [data]);
|
|
19
|
+
var _b = useToggleAndClose(false), isDatepickerOpen = _b[0], toggleDatepicker = _b[1], closeDatePicker = _b[2];
|
|
20
|
+
var _c = useChangeDate({
|
|
21
|
+
closeDatePicker: closeDatePicker,
|
|
22
|
+
handleReloadTimeSlots: handleReloadTimeSlots
|
|
23
|
+
}), handlePrevDay = _c.handlePrevDay, handleNextDay = _c.handleNextDay, handleChangeDate = _c.handleChangeDate, date = _c.date, isTodayDate = _c.isTodayDate;
|
|
24
|
+
if (!(groups === null || groups === void 0 ? void 0 : groups.length))
|
|
25
|
+
return null;
|
|
26
|
+
return (_jsxs("div", { children: [_jsx(DateChanger, { isLoading: isLoading, isDatepickerOpen: isDatepickerOpen, toggleDatepicker: toggleDatepicker, closeDatePicker: closeDatePicker, handlePrevDay: handlePrevDay, handleNextDay: handleNextDay, handleChangeDate: handleChangeDate, date: date }), _jsxs(Container, { children: [_jsx(Groups, { groups: groups }), _jsx(TimeSlots, { timeArray: timeArray, groups: groups, activeHours: activeHours, timeSlots: groupedTimeSlots, handleSelectTimeSlot: !isLoading ? handleSelectTimeSlot : undefined, handleTimeSlotClick: !isLoading ? handleTimeSlotClick : undefined, isTodayDate: isTodayDate })] })] }));
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { convertDateToTime } from '../../../utils/convertDateToTime';
|
|
3
|
+
export var useCurrentTime = function () {
|
|
4
|
+
var _a = useState(new Date()), time = _a[0], setTime = _a[1];
|
|
5
|
+
useEffect(function () {
|
|
6
|
+
var interval = setInterval(function () {
|
|
7
|
+
setTime(new Date());
|
|
8
|
+
}, 60000);
|
|
9
|
+
return function () {
|
|
10
|
+
clearInterval(interval);
|
|
11
|
+
};
|
|
12
|
+
}, []);
|
|
13
|
+
var formattedTime = convertDateToTime(time);
|
|
14
|
+
return {
|
|
15
|
+
time: formattedTime
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getMinutesFromTime } from '../../utils/getMinutesFromTime';
|
|
3
|
+
import { useCurrentTime } from './hooks/useCurrentTime';
|
|
4
|
+
import { CurrentTime, CurrentTimeContainer, Line } from './styles';
|
|
5
|
+
export var CurrentTimeMarker = function () {
|
|
6
|
+
var time = useCurrentTime().time;
|
|
7
|
+
var minutes = getMinutesFromTime(time);
|
|
8
|
+
return (_jsxs(CurrentTimeContainer, { minutes: minutes, children: [_jsx(CurrentTime, { children: time }), _jsx(Line, {})] }));
|
|
9
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CurrentTimeContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
2
|
+
minutes: number;
|
|
3
|
+
}, never>;
|
|
4
|
+
export declare const CurrentTime: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
5
|
+
export declare const Line: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { currentTimeHeight, currentTimeWidth, minuteHeight } from '../../utils/constants';
|
|
6
|
+
import styled, { th } from '@xstyled/styled-components';
|
|
7
|
+
export var CurrentTimeContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: ", ";\n left: 0;\n padding-left: 10px;\n width: 100%;\n display: flex;\n align-items: center;\n height: ", "px;\n z-index: 1;\n"], ["\n position: absolute;\n top: ", ";\n left: 0;\n padding-left: 10px;\n width: 100%;\n display: flex;\n align-items: center;\n height: ", "px;\n z-index: 1;\n"])), function (_a) {
|
|
8
|
+
var minutes = _a.minutes;
|
|
9
|
+
return "".concat(minutes * minuteHeight - currentTimeHeight / 2, "px");
|
|
10
|
+
}, currentTimeHeight);
|
|
11
|
+
export var CurrentTime = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n font-size: 10px;\n color: white;\n font-weight: 600;\n background-color: ", ";\n width: ", "px;\n padding: 5px;\n border-radius: 14px;\n"], ["\n font-size: 10px;\n color: white;\n font-weight: 600;\n background-color: ", ";\n width: ", "px;\n padding: 5px;\n border-radius: 14px;\n"])), th.color('red1'), currentTimeWidth);
|
|
12
|
+
export var Line = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n width: calc(100% - ", "px);\n height: 1px;\n"], ["\n background-color: ", ";\n width: calc(100% - ", "px);\n height: 1px;\n"])), th.color('red1'), currentTimeWidth);
|
|
13
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import { type DatePickerType } from '../../../../Elements/DatePicker/DatePicker';
|
|
3
|
+
type DateChangerProps = {
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
isDatepickerOpen: boolean;
|
|
6
|
+
toggleDatepicker: () => void;
|
|
7
|
+
closeDatePicker: () => void;
|
|
8
|
+
handlePrevDay: () => void;
|
|
9
|
+
handleNextDay: () => void;
|
|
10
|
+
handleChangeDate: DatePickerType['onChange'];
|
|
11
|
+
date: Date;
|
|
12
|
+
};
|
|
13
|
+
export declare const DateChanger: FC<DateChangerProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useRef } from 'react';
|
|
3
|
+
import DatePicker from '../../../../Elements/DatePicker';
|
|
4
|
+
import { ArrowDown } from '../../../../Elements/Icon';
|
|
5
|
+
import Spinner from '../../../../Elements/Spinner/Spinner';
|
|
6
|
+
import { LanguageContext } from '../../../../ThemeProvider/ThemeProvider';
|
|
7
|
+
import Popover from '../../../Popover';
|
|
8
|
+
import { formatDate } from '../../utils/formatDate';
|
|
9
|
+
import { x } from '@xstyled/styled-components';
|
|
10
|
+
import { ArrowContainer, DateChangerContainer } from './styles';
|
|
11
|
+
export var DateChanger = function (_a) {
|
|
12
|
+
var isLoading = _a.isLoading, date = _a.date, handleChangeDate = _a.handleChangeDate, closeDatePicker = _a.closeDatePicker, handleNextDay = _a.handleNextDay, handlePrevDay = _a.handlePrevDay, toggleDatepicker = _a.toggleDatepicker, isDatepickerOpen = _a.isDatepickerOpen;
|
|
13
|
+
var ref = useRef(null);
|
|
14
|
+
var locale = useContext(LanguageContext);
|
|
15
|
+
if (isLoading) {
|
|
16
|
+
return (_jsx(x.div, { p: "6px 12px", children: _jsx(Spinner, { variant: "sm" }) }));
|
|
17
|
+
}
|
|
18
|
+
return (_jsxs(DateChangerContainer, { children: [_jsx(ArrowContainer, { onClick: handlePrevDay, rotate: 90, children: _jsx(ArrowDown, {}) }), _jsx(x.span, { ref: ref, onClick: toggleDatepicker, cursor: "pointer", children: formatDate(date, locale) }), isDatepickerOpen && (_jsx(Popover, { parentRef: ref, onClose: closeDatePicker, children: _jsx(DatePicker, { value: date, input: false, onChange: handleChangeDate, isSecondDatePicker: true }) })), _jsx(ArrowContainer, { onClick: handleNextDay, rotate: -90, children: _jsx(ArrowDown, {}) })] }));
|
|
19
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const DateChangerContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
2
|
+
export declare const ArrowContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
3
|
+
rotate: number;
|
|
4
|
+
}, never>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import styled from '@xstyled/styled-components';
|
|
6
|
+
export var DateChangerContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n margin-bottom: 24px;\n margin-top: 12px;\n width: fit-content;\n align-items: center;\n column-gap: 12px;\n font-size: 16px;\n font-weight: 500;\n"], ["\n display: flex;\n margin-bottom: 24px;\n margin-top: 12px;\n width: fit-content;\n align-items: center;\n column-gap: 12px;\n font-size: 16px;\n font-weight: 500;\n"])));
|
|
7
|
+
export var ArrowContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n height: 15px;\n width: 15px;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transform: ", ";\n"], ["\n display: flex;\n height: 15px;\n width: 15px;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transform: ", ";\n"])), function (_a) {
|
|
8
|
+
var rotate = _a.rotate;
|
|
9
|
+
return "rotate(".concat(rotate, "deg)");
|
|
10
|
+
});
|
|
11
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { GroupContainer, GroupItem, Gap } from './styles';
|
|
3
|
+
export var Groups = function (_a) {
|
|
4
|
+
var groups = _a.groups;
|
|
5
|
+
return (_jsxs(GroupContainer, { children: [_jsx(Gap, {}), groups === null || groups === void 0 ? void 0 : groups.map(function (group, i) { return (_jsx(GroupItem, { groupsCount: groups === null || groups === void 0 ? void 0 : groups.length, children: group.name }, group.id)); })] }));
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const GroupContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
2
|
+
export declare const GroupItem: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
3
|
+
bg?: string | undefined;
|
|
4
|
+
groupsCount: number;
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const Gap: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { groupsHeight, timeIntervalWidth } from '../../utils/constants';
|
|
6
|
+
import styled, { th } from '@xstyled/styled-components';
|
|
7
|
+
export var GroupContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: ", "px;\n display: flex;\n border-bottom: 1px solid ", ";\n"], ["\n height: ", "px;\n display: flex;\n border-bottom: 1px solid ", ";\n"])), groupsHeight, th.color('lightGray6'));
|
|
8
|
+
export var GroupItem = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n width: ", ";\n max-width: 400px;\n height: 100%;\n font-size: 14px;\n font-weight: 600;\n padding: 10px;\n border-right: 1px solid ", ";\n\n &:last-child {\n border-right: none;\n }\n"], ["\n background-color: ", ";\n width: ", ";\n max-width: 400px;\n height: 100%;\n font-size: 14px;\n font-weight: 600;\n padding: 10px;\n border-right: 1px solid ", ";\n\n &:last-child {\n border-right: none;\n }\n"])), function (_a) {
|
|
9
|
+
var bg = _a.bg;
|
|
10
|
+
return bg || th.color('bgLightGray');
|
|
11
|
+
}, function (_a) {
|
|
12
|
+
var groupsCount = _a.groupsCount;
|
|
13
|
+
return "calc((100% / ".concat(groupsCount, ") - (").concat(timeIntervalWidth, "px / ").concat(groupsCount, "))");
|
|
14
|
+
}, th.color('lightGray6'));
|
|
15
|
+
export var Gap = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n height: 100%;\n width: ", "px;\n border-right: 1px solid ", ";\n"], ["\n background-color: ", ";\n height: 100%;\n width: ", "px;\n border-right: 1px solid ", ";\n"])), th.color('bgLightGray1'), timeIntervalWidth, th.color('lightGray6'));
|
|
16
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type SchedulerProps } from '../../../types';
|
|
2
|
+
type Props = {
|
|
3
|
+
handleSelectTimeSlot: SchedulerProps['handleSelectTimeSlot'];
|
|
4
|
+
};
|
|
5
|
+
type HookType = (props: Props) => {
|
|
6
|
+
handleMouseDown: (index: number, groupId: string) => () => void;
|
|
7
|
+
handleMouseOver: (index: number) => () => void;
|
|
8
|
+
handleMouseUp: () => void;
|
|
9
|
+
isSlotSelected: (index: number, groupId: string) => boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const useRangeSelection: HookType;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { convertIndexToISOString } from '../../../utils/convertIndexToISOString';
|
|
3
|
+
export var useRangeSelection = function (_a) {
|
|
4
|
+
var handleSelectTimeSlot = _a.handleSelectTimeSlot;
|
|
5
|
+
var _b = useState(false), isSelecting = _b[0], setIsSelecting = _b[1];
|
|
6
|
+
var _c = useState([]), selectionRange = _c[0], setSelectionRange = _c[1];
|
|
7
|
+
var _d = useState(null), selectedGroup = _d[0], setSelectedGroup = _d[1];
|
|
8
|
+
var handleMouseDown = useCallback(function (index, groupId) { return function () {
|
|
9
|
+
setSelectionRange([index]);
|
|
10
|
+
setIsSelecting(true);
|
|
11
|
+
setSelectedGroup(groupId);
|
|
12
|
+
}; }, []);
|
|
13
|
+
var handleMouseOver = useCallback(function (index) { return function () {
|
|
14
|
+
if (!isSelecting)
|
|
15
|
+
return;
|
|
16
|
+
setSelectionRange(function (prevRange) {
|
|
17
|
+
var start = prevRange[0];
|
|
18
|
+
var end = prevRange.at(-1);
|
|
19
|
+
if (end && (end < index ? end + 1 !== index : end - 1 !== index)) {
|
|
20
|
+
return [index];
|
|
21
|
+
}
|
|
22
|
+
return Array.from({ length: Math.abs(index - start) + 1 }, function (_, i) { return (start < index ? start + i : start - i); });
|
|
23
|
+
});
|
|
24
|
+
}; }, [isSelecting]);
|
|
25
|
+
var handleMouseUp = useCallback(function () {
|
|
26
|
+
var _a;
|
|
27
|
+
setIsSelecting(false);
|
|
28
|
+
if (selectedGroup && (selectionRange === null || selectionRange === void 0 ? void 0 : selectionRange.length)) {
|
|
29
|
+
var start = selectionRange[0];
|
|
30
|
+
var end = ((_a = selectionRange.at(-1)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
31
|
+
handleSelectTimeSlot === null || handleSelectTimeSlot === void 0 ? void 0 : handleSelectTimeSlot({
|
|
32
|
+
groupId: selectedGroup,
|
|
33
|
+
from: convertIndexToISOString(start),
|
|
34
|
+
to: convertIndexToISOString(end)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
setSelectedGroup(null);
|
|
38
|
+
setSelectionRange([]);
|
|
39
|
+
}, [handleSelectTimeSlot, selectedGroup, selectionRange]);
|
|
40
|
+
var isSlotSelected = useCallback(function (index, groupId) { return groupId === selectedGroup && selectionRange.includes(index); }, [selectionRange, selectedGroup]);
|
|
41
|
+
return {
|
|
42
|
+
handleMouseDown: handleMouseDown,
|
|
43
|
+
handleMouseOver: handleMouseOver,
|
|
44
|
+
handleMouseUp: handleMouseUp,
|
|
45
|
+
isSlotSelected: isSlotSelected
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
export var useScroll = function () {
|
|
3
|
+
var containerRef = useRef(null);
|
|
4
|
+
useEffect(function () {
|
|
5
|
+
var _a;
|
|
6
|
+
var now = new Date();
|
|
7
|
+
var hours = String(now.getHours()).padStart(2, '0');
|
|
8
|
+
var timeElement = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-time=\"".concat(hours, ":00\"]"));
|
|
9
|
+
if (timeElement) {
|
|
10
|
+
timeElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
11
|
+
}
|
|
12
|
+
}, []);
|
|
13
|
+
return {
|
|
14
|
+
containerRef: containerRef
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import { type SchedulerProps, type TimeSlotType } from '../../types';
|
|
3
|
+
type TimeSlotsProps = {
|
|
4
|
+
timeArray: string[];
|
|
5
|
+
groups?: SchedulerProps['groups'];
|
|
6
|
+
activeHours?: SchedulerProps['activeHours'];
|
|
7
|
+
timeSlots?: Record<string, TimeSlotType[]>;
|
|
8
|
+
handleSelectTimeSlot: SchedulerProps['handleSelectTimeSlot'];
|
|
9
|
+
handleTimeSlotClick?: SchedulerProps['handleTimeSlotClick'];
|
|
10
|
+
isTodayDate: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const TimeSlots: FC<TimeSlotsProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { convertDateToTime } from '../../utils/convertDateToTime';
|
|
3
|
+
import { getMinutesFromTime } from '../../utils/getMinutesFromTime';
|
|
4
|
+
import { isActiveTime } from '../../utils/isActiveTime';
|
|
5
|
+
import { CurrentTimeMarker } from '../CurrentTimeMarker';
|
|
6
|
+
import { useRangeSelection } from './hooks/useRangeSelection';
|
|
7
|
+
import { useScroll } from './hooks/useScroll';
|
|
8
|
+
import { EmptyTimeSlot, TimeInterval, TimeRow, TimeSlotsContainer, BookedTimeSlot } from './styles';
|
|
9
|
+
export var TimeSlots = function (_a) {
|
|
10
|
+
var timeArray = _a.timeArray, groups = _a.groups, activeHours = _a.activeHours, timeSlots = _a.timeSlots, handleSelectTimeSlot = _a.handleSelectTimeSlot, handleTimeSlotClick = _a.handleTimeSlotClick, isTodayDate = _a.isTodayDate;
|
|
11
|
+
var containerRef = useScroll().containerRef;
|
|
12
|
+
var _b = useRangeSelection({ handleSelectTimeSlot: handleSelectTimeSlot }), handleMouseUp = _b.handleMouseUp, handleMouseDown = _b.handleMouseDown, handleMouseOver = _b.handleMouseOver, isSlotSelected = _b.isSlotSelected;
|
|
13
|
+
return (_jsxs(TimeSlotsContainer, { ref: containerRef, children: [timeArray.map(function (time, index) {
|
|
14
|
+
var activeTime = isActiveTime({ activeHours: activeHours, time: time });
|
|
15
|
+
return (_jsxs(TimeRow, { disabled: !activeTime, "data-time": time, children: [_jsx(TimeInterval, { children: time }), groups === null || groups === void 0 ? void 0 : groups.map(function (group) {
|
|
16
|
+
var _a;
|
|
17
|
+
var bookedTimeSlots = (_a = timeSlots === null || timeSlots === void 0 ? void 0 : timeSlots["".concat(group.id, "-").concat(time)]) !== null && _a !== void 0 ? _a : [];
|
|
18
|
+
var canSelectSlot = !bookedTimeSlots.length && activeTime;
|
|
19
|
+
return (_jsx(EmptyTimeSlot, { groupsCount: groups === null || groups === void 0 ? void 0 : groups.length, activeTime: activeTime, isSlotSelected: canSelectSlot && isSlotSelected(index, group.id), onMouseDown: canSelectSlot ? handleMouseDown(index, group.id) : undefined, onMouseOver: canSelectSlot ? handleMouseOver(index) : undefined, onMouseUp: canSelectSlot ? handleMouseUp : undefined, children: bookedTimeSlots.map(function (_a) {
|
|
20
|
+
var id = _a.id, start = _a.start, end = _a.end;
|
|
21
|
+
var startTime = convertDateToTime(new Date(start));
|
|
22
|
+
var endTime = convertDateToTime(new Date(end));
|
|
23
|
+
var startTimeInMinutes = getMinutesFromTime(startTime);
|
|
24
|
+
var endTimeInMinutes = getMinutesFromTime(endTime);
|
|
25
|
+
return (_jsx(BookedTimeSlot, { startPoint: startTimeInMinutes - getMinutesFromTime(time) + 1, heightInMinutes: endTimeInMinutes - startTimeInMinutes - 2, onClick: handleTimeSlotClick === null || handleTimeSlotClick === void 0 ? void 0 : handleTimeSlotClick(id), children: "".concat(startTime, " - ").concat(endTime) }, id));
|
|
26
|
+
}) }, group.id));
|
|
27
|
+
})] }, time));
|
|
28
|
+
}), isTodayDate && _jsx(CurrentTimeMarker, {})] }));
|
|
29
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const TimeSlotsContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
2
|
+
export declare const EmptyTimeSlot: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
3
|
+
isSlotSelected?: boolean | undefined;
|
|
4
|
+
activeTime: boolean;
|
|
5
|
+
groupsCount: number;
|
|
6
|
+
}, never>;
|
|
7
|
+
export declare const BookedTimeSlot: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
8
|
+
startPoint: number;
|
|
9
|
+
heightInMinutes: number;
|
|
10
|
+
}, never>;
|
|
11
|
+
export declare const TimeInterval: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
12
|
+
export declare const TimeRow: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
}, never>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { minuteHeight, stepInMinutes, timeIntervalWidth } from '../../utils/constants';
|
|
6
|
+
import styled, { th } from '@xstyled/styled-components';
|
|
7
|
+
export var TimeSlotsContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n\n -ms-overflow-style: none;\n scrollbar-width: none;\n scroll-behavior: smooth;\n\n &::-webkit-scrollbar {\n display: none;\n }\n"], ["\n position: relative;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n\n -ms-overflow-style: none;\n scrollbar-width: none;\n scroll-behavior: smooth;\n\n &::-webkit-scrollbar {\n display: none;\n }\n"])));
|
|
8
|
+
export var EmptyTimeSlot = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: ", "px;\n width: ", ";\n max-width: 400px;\n position: relative;\n background-color: ", ";\n cursor: ", ";\n border-right: 1px solid ", ";\n\n &:last-child {\n border-right: none;\n }\n\n &:hover {\n background-color: ", ";\n }\n"], ["\n height: ", "px;\n width: ", ";\n max-width: 400px;\n position: relative;\n background-color: ", ";\n cursor: ", ";\n border-right: 1px solid ", ";\n\n &:last-child {\n border-right: none;\n }\n\n &:hover {\n background-color: ", ";\n }\n"])), minuteHeight * stepInMinutes, function (_a) {
|
|
9
|
+
var groupsCount = _a.groupsCount;
|
|
10
|
+
return "calc((100% / ".concat(groupsCount, ") - (").concat(timeIntervalWidth, "px / ").concat(groupsCount, "))");
|
|
11
|
+
}, function (_a) {
|
|
12
|
+
var isSlotSelected = _a.isSlotSelected;
|
|
13
|
+
return (isSlotSelected ? th.color('blue20') : '');
|
|
14
|
+
}, function (_a) {
|
|
15
|
+
var isSlotSelected = _a.isSlotSelected, activeTime = _a.activeTime;
|
|
16
|
+
return (isSlotSelected || !activeTime ? 'default' : 'pointer');
|
|
17
|
+
}, th.color('lightGray6'), function (_a) {
|
|
18
|
+
var isSlotSelected = _a.isSlotSelected, activeTime = _a.activeTime;
|
|
19
|
+
return (!isSlotSelected && activeTime ? th.color('blue10') : '');
|
|
20
|
+
});
|
|
21
|
+
export var BookedTimeSlot = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n z-index: 1;\n top: ", ";\n background-color: ", ";\n border-radius: 4px;\n box-shadow: ", ";\n height: ", ";\n border-left: 4px solid ", ";\n padding: 10px;\n margin-right: 10px;\n margin-left: 6px; // -4px border\n width: calc(100% - 16px);\n cursor: pointer;\n"], ["\n position: absolute;\n z-index: 1;\n top: ", ";\n background-color: ", ";\n border-radius: 4px;\n box-shadow: ", ";\n height: ", ";\n border-left: 4px solid ", ";\n padding: 10px;\n margin-right: 10px;\n margin-left: 6px; // -4px border\n width: calc(100% - 16px);\n cursor: pointer;\n"])), function (_a) {
|
|
22
|
+
var startPoint = _a.startPoint;
|
|
23
|
+
return "".concat(startPoint * minuteHeight, "px");
|
|
24
|
+
}, th.color('bgLightGray1'), th.shadow('gridShadow'), function (_a) {
|
|
25
|
+
var heightInMinutes = _a.heightInMinutes;
|
|
26
|
+
return "".concat(heightInMinutes * minuteHeight, "px");
|
|
27
|
+
}, th.color('green60'));
|
|
28
|
+
export var TimeInterval = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: 12px;\n font-weight: 500;\n height: ", "px;\n width: ", "px;\n border-right: 1px solid ", ";\n padding: 10px;\n"], ["\n font-size: 12px;\n font-weight: 500;\n height: ", "px;\n width: ", "px;\n border-right: 1px solid ", ";\n padding: 10px;\n"])), minuteHeight * stepInMinutes, timeIntervalWidth, th.color('lightGray6'));
|
|
29
|
+
export var TimeRow = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background-color: ", ";\n display: flex;\n border-bottom: 1px solid ", ";\n"], ["\n background-color: ", ";\n display: flex;\n border-bottom: 1px solid ", ";\n"])), function (_a) {
|
|
30
|
+
var disabled = _a.disabled;
|
|
31
|
+
return (disabled ? th.color('lightGray7') : 'white');
|
|
32
|
+
}, th.color('lightGray6'));
|
|
33
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type DatePickerType } from '../../../Elements/DatePicker/DatePicker';
|
|
2
|
+
import type { SchedulerProps } from '../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
closeDatePicker: () => void;
|
|
5
|
+
handleReloadTimeSlots: SchedulerProps['handleReloadTimeSlots'];
|
|
6
|
+
};
|
|
7
|
+
type HookType = (props: Props) => {
|
|
8
|
+
handlePrevDay: () => void;
|
|
9
|
+
handleNextDay: () => void;
|
|
10
|
+
handleChangeDate: DatePickerType['onChange'];
|
|
11
|
+
isTodayDate: boolean;
|
|
12
|
+
date: Date;
|
|
13
|
+
};
|
|
14
|
+
export declare const useChangeDate: HookType;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { isToday } from '../utils/isToday';
|
|
3
|
+
export var useChangeDate = function (_a) {
|
|
4
|
+
var closeDatePicker = _a.closeDatePicker, handleReloadTimeSlots = _a.handleReloadTimeSlots;
|
|
5
|
+
var _b = useState(new Date()), date = _b[0], setDate = _b[1];
|
|
6
|
+
var handlePrevDay = useCallback(function () {
|
|
7
|
+
var newDate = new Date(date);
|
|
8
|
+
newDate.setDate(date.getDate() - 1);
|
|
9
|
+
setDate(newDate);
|
|
10
|
+
}, [date]);
|
|
11
|
+
var handleNextDay = useCallback(function () {
|
|
12
|
+
var newDate = new Date(date);
|
|
13
|
+
newDate.setDate(date.getDate() + 1);
|
|
14
|
+
setDate(newDate);
|
|
15
|
+
}, [date]);
|
|
16
|
+
var handleChangeDate = useCallback(function (dateValue) {
|
|
17
|
+
var date = new Date(dateValue);
|
|
18
|
+
date && setDate(date);
|
|
19
|
+
closeDatePicker();
|
|
20
|
+
}, []);
|
|
21
|
+
var isTodayDate = isToday(date);
|
|
22
|
+
useEffect(function () {
|
|
23
|
+
if (!handleReloadTimeSlots)
|
|
24
|
+
return;
|
|
25
|
+
handleReloadTimeSlots(date).catch(console.error);
|
|
26
|
+
}, [date]);
|
|
27
|
+
return {
|
|
28
|
+
handlePrevDay: handlePrevDay,
|
|
29
|
+
handleNextDay: handleNextDay,
|
|
30
|
+
handleChangeDate: handleChangeDate,
|
|
31
|
+
isTodayDate: isTodayDate,
|
|
32
|
+
date: date
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Scheduler as default } from './Scheduler';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { LinguiContainer } from '../../../utils/LinguiContainer';
|
|
3
|
+
import { Scheduler } from '../Scheduler';
|
|
4
|
+
var groups = [
|
|
5
|
+
{ id: 'group1', name: 'Inbound DEA', color: '#DCEFFF' },
|
|
6
|
+
{ id: 'group2', name: 'Aktin', color: '#FFEBE6' },
|
|
7
|
+
{ id: 'group3', name: 'Top4Sport', color: '#F0EDFF' },
|
|
8
|
+
{ id: 'group4', name: 'Wendys', color: '#DEFBE6' }
|
|
9
|
+
];
|
|
10
|
+
var activeHours = {
|
|
11
|
+
start: '07:00',
|
|
12
|
+
end: '19:00'
|
|
13
|
+
};
|
|
14
|
+
var timeSlots = [
|
|
15
|
+
{ id: '1', start: '2025-02-06T07:30:00Z', end: '2025-02-06T09:00:00Z', groupId: 'group1' },
|
|
16
|
+
{ id: '2', start: '2025-02-06T14:35:00Z', end: '2025-02-06T16:30:00Z', groupId: 'group1' },
|
|
17
|
+
{ id: '3', start: '2025-02-06T09:40:00Z', end: '2025-02-06T11:45:00Z', groupId: 'group2' },
|
|
18
|
+
{ id: '4', start: '2025-02-06T12:05:00Z', end: '2025-02-06T15:30:00Z', groupId: 'group2' },
|
|
19
|
+
{ id: '5', start: '2025-02-06T08:15:00Z', end: '2025-02-06T09:45:00Z', groupId: 'group3' },
|
|
20
|
+
{ id: '6', start: '2025-02-06T11:30:00Z', end: '2025-02-06T13:15:00Z', groupId: 'group3' },
|
|
21
|
+
{ id: '7', start: '2025-02-06T07:30:00Z', end: '2025-02-06T09:15:00Z', groupId: 'group4' },
|
|
22
|
+
{ id: '8', start: '2025-02-06T09:30:00Z', end: '2025-02-06T11:30:00Z', groupId: 'group4' },
|
|
23
|
+
{ id: '9', start: '2025-02-06T13:30:00Z', end: '2025-02-06T15:00:00Z', groupId: 'group4' }
|
|
24
|
+
];
|
|
25
|
+
var handleSelectTimeSlot = function (data) {
|
|
26
|
+
console.log(data);
|
|
27
|
+
};
|
|
28
|
+
var meta = {
|
|
29
|
+
title: 'Blocks/Scheduler',
|
|
30
|
+
tags: ['autodocs']
|
|
31
|
+
};
|
|
32
|
+
export default meta;
|
|
33
|
+
export var Default = function () {
|
|
34
|
+
return (_jsx(LinguiContainer, { children: _jsx(Scheduler, { groups: groups, activeHours: activeHours, data: timeSlots, handleSelectTimeSlot: handleSelectTimeSlot }) }));
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Container: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import styled, { th } from '@xstyled/styled-components';
|
|
6
|
+
export var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: white;\n color: ", ";\n overflow-x: auto;\n text-align: center;\n display: flex;\n flex-direction: column;\n height: 100%;\n max-height: 80vh;\n border: 1px solid ", ";\n user-select: none;\n}\n"], ["\n background-color: white;\n color: ", ";\n overflow-x: auto;\n text-align: center;\n display: flex;\n flex-direction: column;\n height: 100%;\n max-height: 80vh;\n border: 1px solid ", ";\n user-select: none;\n}\n"])), th.color('typoPrimary'), th.color('lightGray6'));
|
|
7
|
+
var templateObject_1;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type GroupType = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
color?: string;
|
|
5
|
+
};
|
|
6
|
+
export type ActiveHours = {
|
|
7
|
+
start: string;
|
|
8
|
+
end: string;
|
|
9
|
+
};
|
|
10
|
+
export type TimeSlotType = {
|
|
11
|
+
id: string;
|
|
12
|
+
start: string;
|
|
13
|
+
end: string;
|
|
14
|
+
groupId: string;
|
|
15
|
+
};
|
|
16
|
+
export type SelectedTimeSlotType = {
|
|
17
|
+
groupId: string;
|
|
18
|
+
from: string;
|
|
19
|
+
to: string;
|
|
20
|
+
};
|
|
21
|
+
export type SchedulerProps = {
|
|
22
|
+
groups?: GroupType[];
|
|
23
|
+
activeHours?: ActiveHours;
|
|
24
|
+
data?: TimeSlotType[];
|
|
25
|
+
handleSelectTimeSlot?: (data: SelectedTimeSlotType) => void;
|
|
26
|
+
handleReloadTimeSlots?: (date: Date) => Promise<void>;
|
|
27
|
+
handleTimeSlotClick?: (timeSlotId: string) => () => void;
|
|
28
|
+
isLoading?: boolean;
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const convertDateToTime: (date: Date) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const convertIndexToISOString: (index: number) => string;
|