@mailstep/design-system 0.7.25-beta.2 → 0.7.25-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.7.25-beta.2",
3
+ "version": "0.7.25-beta.4",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -8,10 +8,11 @@ import { TimeSlots } from './components/TimeSlots';
8
8
  import { useChangeDate } from './hooks/useChangeDate';
9
9
  import { generateTimeArray } from './utils/generateTimeArray';
10
10
  import { getClosestStep } from './utils/getClosestStep';
11
+ import { x } from '@xstyled/styled-components';
11
12
  import { Container } from './styles';
12
13
  var timeArray = generateTimeArray();
13
14
  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 groups = _a.groups, activeHours = _a.activeHours, data = _a.data, handleSelectTimeSlot = _a.handleSelectTimeSlot, handleReloadTimeSlots = _a.handleReloadTimeSlots, handleTimeSlotClick = _a.handleTimeSlotClick, isLoading = _a.isLoading, timeSlotDefinitions = _a.timeSlotDefinitions;
15
16
  var groupedTimeSlots = useMemo(function () { return groupBy(data, function (_a) {
16
17
  var groupId = _a.groupId, from = _a.from;
17
18
  return "".concat(groupId, "-").concat(getClosestStep(from));
@@ -23,5 +24,5 @@ export var Scheduler = function (_a) {
23
24
  }), handlePrevDay = _c.handlePrevDay, handleNextDay = _c.handleNextDay, handleChangeDate = _c.handleChangeDate, date = _c.date, isTodayDate = _c.isTodayDate;
24
25
  if (!(groups === null || groups === void 0 ? void 0 : groups.length))
25
26
  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
+ return (_jsxs(x.div, { w: "100%", h: "100%", 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, date: date, timeSlotDefinitions: timeSlotDefinitions })] })] }));
27
28
  };
@@ -0,0 +1,10 @@
1
+ import { type FC } from 'react';
2
+ import type { SchedulerProps, TimeSlotType } from '../../types';
3
+ type BookedTimeSlotsProps = {
4
+ bookedTimeSlots: TimeSlotType[];
5
+ timeSlotDefinitions: SchedulerProps['timeSlotDefinitions'];
6
+ handleTimeSlotClick?: SchedulerProps['handleTimeSlotClick'];
7
+ time: string;
8
+ };
9
+ export declare const BookedTimeSlots: FC<BookedTimeSlotsProps>;
10
+ export {};
@@ -0,0 +1,35 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { convertDateToTime } from '../../utils/convertDateToTime';
14
+ import { convertMinutesToDuration } from '../../utils/convertMinutesToDuration';
15
+ import { getMinutesFromTime } from '../../utils/getMinutesFromTime';
16
+ import { x } from '@xstyled/styled-components';
17
+ import get from 'lodash/get';
18
+ import { Body, BookedTimeSlot, Header } from './styles';
19
+ export var BookedTimeSlots = function (_a) {
20
+ var bookedTimeSlots = _a.bookedTimeSlots, timeSlotDefinitions = _a.timeSlotDefinitions, handleTimeSlotClick = _a.handleTimeSlotClick, time = _a.time;
21
+ return (_jsx(_Fragment, { children: bookedTimeSlots.map(function (_a) {
22
+ var _b;
23
+ var id = _a.id, from = _a.from, to = _a.to, rest = __rest(_a, ["id", "from", "to"]);
24
+ var startTime = convertDateToTime(new Date(from));
25
+ var endTime = convertDateToTime(new Date(to));
26
+ var startTimeInMinutes = getMinutesFromTime(startTime);
27
+ var endTimeInMinutes = getMinutesFromTime(endTime);
28
+ var totalInMinutes = endTimeInMinutes - startTimeInMinutes;
29
+ var count = (timeSlotDefinitions === null || timeSlotDefinitions === void 0 ? void 0 : timeSlotDefinitions.count) ? get(rest, timeSlotDefinitions === null || timeSlotDefinitions === void 0 ? void 0 : timeSlotDefinitions.count) : 0;
30
+ return (_jsxs(BookedTimeSlot, { startPoint: startTimeInMinutes - getMinutesFromTime(time) + 1, heightInMinutes: totalInMinutes - 2, onClick: handleTimeSlotClick === null || handleTimeSlotClick === void 0 ? void 0 : handleTimeSlotClick(id), children: [_jsxs(Header, { children: [_jsx("div", { children: "".concat(startTime, " - ").concat(endTime, " (").concat(convertMinutesToDuration(totalInMinutes), ")") }), _jsxs(x.div, { display: "flex", gap: "6px", alignItems: "center", children: [!!count && count, timeSlotDefinitions === null || timeSlotDefinitions === void 0 ? void 0 : timeSlotDefinitions.icon] })] }), _jsx(Body, { children: (_b = timeSlotDefinitions === null || timeSlotDefinitions === void 0 ? void 0 : timeSlotDefinitions.data) === null || _b === void 0 ? void 0 : _b.map(function (key) {
31
+ var value = get(rest, key);
32
+ return _jsx("span", { children: Array.isArray(value) ? value.join(', ') : value }, "".concat(key, "-").concat(time));
33
+ }) })] }, id));
34
+ }) }));
35
+ };
@@ -0,0 +1,6 @@
1
+ export declare const BookedTimeSlot: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
2
+ startPoint: number;
3
+ heightInMinutes: number;
4
+ }, never>;
5
+ export declare const Header: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
6
+ export declare const Body: 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 { minuteHeight } from '../../utils/constants';
6
+ import styled, { th } from '@xstyled/styled-components';
7
+ export var BookedTimeSlot = styled.div(templateObject_1 || (templateObject_1 = __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 overflow-y: auto;\n text-align: left;\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 overflow-y: auto;\n text-align: left;\n"])), function (_a) {
8
+ var startPoint = _a.startPoint;
9
+ return "".concat(startPoint * minuteHeight, "px");
10
+ }, th.color('bgLightGray1'), th.shadow('gridShadow'), function (_a) {
11
+ var heightInMinutes = _a.heightInMinutes;
12
+ return "".concat(heightInMinutes * minuteHeight, "px");
13
+ }, th.color('green60'));
14
+ export var Header = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n justify-content: space-between;\n gap: 12px;\n height: fit-content;\n align-items: center;\n"], ["\n display: flex;\n justify-content: space-between;\n gap: 12px;\n height: fit-content;\n align-items: center;\n"])));
15
+ export var Body = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n margin-top: 6px;\n gap: 6px;\n"], ["\n display: flex;\n flex-direction: column;\n margin-top: 6px;\n gap: 6px;\n"])));
16
+ var templateObject_1, templateObject_2, templateObject_3;
@@ -4,8 +4,8 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
4
4
  };
5
5
  import { groupsHeight, timeIntervalWidth } from '../../utils/constants';
6
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) {
7
+ export var GroupContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: ", "px;\n display: flex;\n border-bottom: 1px solid ", ";\n width: fit-content;\n"], ["\n height: ", "px;\n display: flex;\n border-bottom: 1px solid ", ";\n width: fit-content;\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 min-width: 300px;\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 min-width: 300px;\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
9
  var bg = _a.bg;
10
10
  return bg || th.color('bgLightGray');
11
11
  }, function (_a) {
@@ -1,6 +1,7 @@
1
1
  import { type SchedulerProps } from '../../../types';
2
2
  type Props = {
3
3
  handleSelectTimeSlot: SchedulerProps['handleSelectTimeSlot'];
4
+ date: Date;
4
5
  };
5
6
  type HookType = (props: Props) => {
6
7
  handleMouseDown: (index: number, groupId: string) => () => void;
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useState } from 'react';
2
2
  import { convertIndexToISOString } from '../../../utils/convertIndexToISOString';
3
3
  export var useRangeSelection = function (_a) {
4
- var handleSelectTimeSlot = _a.handleSelectTimeSlot;
4
+ var handleSelectTimeSlot = _a.handleSelectTimeSlot, date = _a.date;
5
5
  var _b = useState(false), isSelecting = _b[0], setIsSelecting = _b[1];
6
6
  var _c = useState([]), selectionRange = _c[0], setSelectionRange = _c[1];
7
7
  var _d = useState(null), selectedGroup = _d[0], setSelectedGroup = _d[1];
@@ -30,13 +30,13 @@ export var useRangeSelection = function (_a) {
30
30
  var end = ((_a = selectionRange.at(-1)) !== null && _a !== void 0 ? _a : 0) + 1;
31
31
  handleSelectTimeSlot === null || handleSelectTimeSlot === void 0 ? void 0 : handleSelectTimeSlot({
32
32
  groupId: selectedGroup,
33
- from: convertIndexToISOString(start),
34
- to: convertIndexToISOString(end)
33
+ from: convertIndexToISOString(start, date),
34
+ to: convertIndexToISOString(end, date)
35
35
  });
36
36
  }
37
37
  setSelectedGroup(null);
38
38
  setSelectionRange([]);
39
- }, [handleSelectTimeSlot, selectedGroup, selectionRange]);
39
+ }, [date, handleSelectTimeSlot, selectedGroup, selectionRange]);
40
40
  var isSlotSelected = useCallback(function (index, groupId) { return groupId === selectedGroup && selectionRange.includes(index); }, [selectionRange, selectedGroup]);
41
41
  return {
42
42
  handleMouseDown: handleMouseDown,
@@ -8,6 +8,8 @@ type TimeSlotsProps = {
8
8
  handleSelectTimeSlot: SchedulerProps['handleSelectTimeSlot'];
9
9
  handleTimeSlotClick?: SchedulerProps['handleTimeSlotClick'];
10
10
  isTodayDate: boolean;
11
+ date: Date;
12
+ timeSlotDefinitions: SchedulerProps['timeSlotDefinitions'];
11
13
  };
12
14
  export declare const TimeSlots: FC<TimeSlotsProps>;
13
15
  export {};
@@ -1,29 +1,21 @@
1
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
2
  import { isActiveTime } from '../../utils/isActiveTime';
3
+ import { BookedTimeSlots } from '../BookedTimeSlots';
5
4
  import { CurrentTimeMarker } from '../CurrentTimeMarker';
6
5
  import { useRangeSelection } from './hooks/useRangeSelection';
7
6
  import { useScroll } from './hooks/useScroll';
8
- import { EmptyTimeSlot, TimeInterval, TimeRow, TimeSlotsContainer, BookedTimeSlot } from './styles';
7
+ import { EmptyTimeSlot, TimeInterval, TimeRow, TimeSlotsContainer } from './styles';
9
8
  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;
9
+ var timeArray = _a.timeArray, groups = _a.groups, activeHours = _a.activeHours, timeSlots = _a.timeSlots, handleSelectTimeSlot = _a.handleSelectTimeSlot, handleTimeSlotClick = _a.handleTimeSlotClick, isTodayDate = _a.isTodayDate, date = _a.date, timeSlotDefinitions = _a.timeSlotDefinitions;
11
10
  var containerRef = useScroll().containerRef;
12
- var _b = useRangeSelection({ handleSelectTimeSlot: handleSelectTimeSlot }), handleMouseUp = _b.handleMouseUp, handleMouseDown = _b.handleMouseDown, handleMouseOver = _b.handleMouseOver, isSlotSelected = _b.isSlotSelected;
11
+ var _b = useRangeSelection({ handleSelectTimeSlot: handleSelectTimeSlot, date: date }), handleMouseUp = _b.handleMouseUp, handleMouseDown = _b.handleMouseDown, handleMouseOver = _b.handleMouseOver, isSlotSelected = _b.isSlotSelected;
13
12
  return (_jsxs(TimeSlotsContainer, { ref: containerRef, children: [timeArray.map(function (time, index) {
14
13
  var activeTime = isActiveTime({ activeHours: activeHours, time: time });
15
14
  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
15
  var _a;
17
16
  var bookedTimeSlots = (_a = timeSlots === null || timeSlots === void 0 ? void 0 : timeSlots["".concat(group.id, "-").concat(time)]) !== null && _a !== void 0 ? _a : [];
18
17
  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, from = _a.from, to = _a.to;
21
- var startTime = convertDateToTime(new Date(from));
22
- var endTime = convertDateToTime(new Date(to));
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));
18
+ 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: _jsx(BookedTimeSlots, { bookedTimeSlots: bookedTimeSlots, timeSlotDefinitions: timeSlotDefinitions, time: time, handleTimeSlotClick: handleTimeSlotClick }) }, group.id));
27
19
  })] }, time));
28
20
  }), isTodayDate && _jsx(CurrentTimeMarker, {})] }));
29
21
  };
@@ -4,10 +4,6 @@ export declare const EmptyTimeSlot: import("styled-components").StyledComponent<
4
4
  activeTime: boolean;
5
5
  groupsCount: number;
6
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
7
  export declare const TimeInterval: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
12
8
  export declare const TimeRow: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
13
9
  disabled: boolean;
@@ -4,8 +4,8 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
4
4
  };
5
5
  import { minuteHeight, stepInMinutes, timeIntervalWidth } from '../../utils/constants';
6
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) {
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 width: fit-content;\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 width: fit-content;\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 min-width: 300px;\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 min-width: 300px;\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
9
  var groupsCount = _a.groupsCount;
10
10
  return "calc((100% / ".concat(groupsCount, ") - (").concat(timeIntervalWidth, "px / ").concat(groupsCount, "))");
11
11
  }, function (_a) {
@@ -18,16 +18,9 @@ export var EmptyTimeSlot = styled.div(templateObject_2 || (templateObject_2 = __
18
18
  var isSlotSelected = _a.isSlotSelected, activeTime = _a.activeTime;
19
19
  return (!isSlotSelected && activeTime ? th.color('blue10') : '');
20
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) {
21
+ export var TimeInterval = styled.div(templateObject_3 || (templateObject_3 = __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'));
22
+ export var TimeRow = styled.div(templateObject_4 || (templateObject_4 = __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
23
  var disabled = _a.disabled;
31
24
  return (disabled ? th.color('lightGray7') : 'white');
32
25
  }, th.color('lightGray6'));
33
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
26
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Pallet } from '../../../Elements/Icon';
2
3
  import { LinguiContainer } from '../../../utils/LinguiContainer';
3
4
  import { Scheduler } from '../Scheduler';
4
5
  var groups = [
@@ -12,16 +13,93 @@ var activeHours = {
12
13
  end: '19:00'
13
14
  };
14
15
  var timeSlots = [
15
- { id: '1', from: '2025-02-06T07:30:00Z', to: '2025-02-06T09:00:00Z', groupId: 'group1' },
16
- { id: '2', from: '2025-02-06T14:35:00Z', to: '2025-02-06T16:30:00Z', groupId: 'group1' },
17
- { id: '3', from: '2025-02-06T09:40:00Z', to: '2025-02-06T11:45:00Z', groupId: 'group2' },
18
- { id: '4', from: '2025-02-06T12:05:00Z', to: '2025-02-06T15:30:00Z', groupId: 'group2' },
19
- { id: '5', from: '2025-02-06T08:15:00Z', to: '2025-02-06T09:45:00Z', groupId: 'group3' },
20
- { id: '6', from: '2025-02-06T11:30:00Z', to: '2025-02-06T13:15:00Z', groupId: 'group3' },
21
- { id: '7', from: '2025-02-06T07:30:00Z', to: '2025-02-06T09:15:00Z', groupId: 'group4' },
22
- { id: '8', from: '2025-02-06T09:30:00Z', to: '2025-02-06T11:30:00Z', groupId: 'group4' },
23
- { id: '9', from: '2025-02-06T13:30:00Z', to: '2025-02-06T15:00:00Z', groupId: 'group4' }
16
+ {
17
+ id: '1',
18
+ from: '2025-02-06T07:30:00Z',
19
+ to: '2025-02-06T08:00:00Z',
20
+ groupId: 'group1',
21
+ count: 2,
22
+ organisation: 'Deagostiny',
23
+ carrier: 'Česká pošta'
24
+ },
25
+ {
26
+ id: '2',
27
+ from: '2025-02-06T14:35:00Z',
28
+ to: '2025-02-06T16:30:00Z',
29
+ groupId: 'group1',
30
+ count: 5,
31
+ organisation: 'Wendys',
32
+ carrier: 'Česká pošta'
33
+ },
34
+ {
35
+ id: '3',
36
+ from: '2025-02-06T09:40:00Z',
37
+ to: '2025-02-06T11:45:00Z',
38
+ groupId: 'group2',
39
+ count: 1,
40
+ organisation: 'Deagostiny',
41
+ carrier: 'Česká pošta'
42
+ },
43
+ {
44
+ id: '4',
45
+ from: '2025-02-06T12:05:00Z',
46
+ to: '2025-02-06T15:30:00Z',
47
+ groupId: 'group2',
48
+ count: 2,
49
+ organisation: 'Top4Sport',
50
+ carrier: 'Česká pošta'
51
+ },
52
+ {
53
+ id: '5',
54
+ from: '2025-02-06T08:15:00Z',
55
+ to: '2025-02-06T09:45:00Z',
56
+ groupId: 'group3',
57
+ count: 2,
58
+ organisation: 'Aktin',
59
+ carrier: 'Česká pošta'
60
+ },
61
+ {
62
+ id: '6',
63
+ from: '2025-02-06T11:30:00Z',
64
+ to: '2025-02-06T13:15:00Z',
65
+ groupId: 'group3',
66
+ count: 2,
67
+ organisation: 'Wendys',
68
+ carrier: 'DPL'
69
+ },
70
+ {
71
+ id: '7',
72
+ from: '2025-02-06T07:30:00Z',
73
+ to: '2025-02-06T09:15:00Z',
74
+ groupId: 'group4',
75
+ count: 2,
76
+ organisation: 'Top4Sport',
77
+ carrier: 'DPL'
78
+ },
79
+ {
80
+ id: '8',
81
+ from: '2025-02-06T09:30:00Z',
82
+ to: '2025-02-06T11:30:00Z',
83
+ groupId: 'group4',
84
+ count: 2,
85
+ organisation: 'Aktin',
86
+ carrier: 'DPL'
87
+ },
88
+ {
89
+ id: '9',
90
+ from: '2025-02-06T13:30:00Z',
91
+ to: '2025-02-06T15:00:00Z',
92
+ groupId: 'group4',
93
+ count: 2,
94
+ organisation: 'Wendys',
95
+ carrier: 'DPL'
96
+ }
24
97
  ];
98
+ var timeSlotDefinitions = {
99
+ count: 'count',
100
+ icon: _jsx(Pallet, { height: "22px", width: "22px" }),
101
+ data: ['organisation', 'carrier']
102
+ };
25
103
  var handleSelectTimeSlot = function (data) {
26
104
  console.log(data);
27
105
  };
@@ -31,5 +109,5 @@ var meta = {
31
109
  };
32
110
  export default meta;
33
111
  export var Default = function () {
34
- return (_jsx(LinguiContainer, { children: _jsx(Scheduler, { groups: groups, activeHours: activeHours, data: timeSlots, handleSelectTimeSlot: handleSelectTimeSlot }) }));
112
+ return (_jsx(LinguiContainer, { children: _jsx(Scheduler, { groups: groups, activeHours: activeHours, data: timeSlots, handleSelectTimeSlot: handleSelectTimeSlot, timeSlotDefinitions: timeSlotDefinitions }) }));
35
113
  };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type GroupType = {
2
3
  id: string;
3
4
  name: string;
@@ -12,12 +13,17 @@ export type TimeSlotType = {
12
13
  from: string;
13
14
  to: string;
14
15
  groupId: string;
15
- };
16
+ } & Record<string, unknown>;
16
17
  export type SelectedTimeSlotType = {
17
18
  groupId: string;
18
19
  from: string;
19
20
  to: string;
20
21
  };
22
+ export type TimeSlotDefinitionType = {
23
+ count?: string;
24
+ icon?: JSX.Element;
25
+ data?: string[];
26
+ };
21
27
  export type SchedulerProps = {
22
28
  groups?: GroupType[];
23
29
  activeHours?: ActiveHours;
@@ -26,4 +32,5 @@ export type SchedulerProps = {
26
32
  handleReloadTimeSlots?: (date: Date) => Promise<void>;
27
33
  handleTimeSlotClick?: (timeSlotId: string) => () => void;
28
34
  isLoading?: boolean;
35
+ timeSlotDefinitions?: TimeSlotDefinitionType;
29
36
  };
@@ -1 +1 @@
1
- export declare const convertIndexToISOString: (index: number) => string;
1
+ export declare const convertIndexToISOString: (index: number, date: Date) => string;
@@ -1,9 +1,8 @@
1
1
  import { stepInMinutes } from './constants';
2
- export var convertIndexToISOString = function (index) {
2
+ export var convertIndexToISOString = function (index, date) {
3
3
  var totalMinutes = stepInMinutes * index;
4
4
  var hours = Math.floor(totalMinutes / 60);
5
5
  var minutes = totalMinutes % 60;
6
- var today = new Date();
7
- today.setHours(hours, minutes, 0, 0);
8
- return today.toISOString();
6
+ date.setHours(hours, minutes, 0, 0);
7
+ return date.toISOString();
9
8
  };
@@ -0,0 +1 @@
1
+ export declare const convertMinutesToDuration: (minutes: number) => string;
@@ -0,0 +1,11 @@
1
+ export var convertMinutesToDuration = function (minutes) {
2
+ var hours = Math.floor(minutes / 60);
3
+ var minutesLeft = minutes % 60;
4
+ if (!hours) {
5
+ return "".concat(minutesLeft, " min");
6
+ }
7
+ if (!minutesLeft) {
8
+ return "".concat(hours, "h");
9
+ }
10
+ return "".concat(hours, "h ").concat(minutesLeft, "m");
11
+ };