@isma91/react-scheduler 4.0.0 → 4.0.2
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/{dist/index.js → index.js} +218 -203
- package/package.json +4 -76
- package/.github/workflows/publish.yml +0 -29
- package/.github/workflows/tests.yml +0 -35
- package/.gitignore +0 -32
- package/.husky/pre-commit +0 -2
- package/.prettierignore +0 -1
- package/.prettierrc.json +0 -7
- package/.yarnrc.yml +0 -1
- package/dist/LICENSE +0 -24
- package/dist/README.md +0 -172
- package/dist/package.json +0 -65
- package/eslint.config.js +0 -79
- package/index.html +0 -41
- package/jest.config.ts +0 -194
- package/public/favicon.ico +0 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/scripts/post-pack.js +0 -34
- package/src/App.tsx +0 -25
- package/src/Page1.tsx +0 -67
- package/src/events.tsx +0 -227
- package/src/index.tsx +0 -21
- package/src/lib/SchedulerComponent.tsx +0 -78
- package/src/lib/__tests__/index.test.tsx +0 -24
- package/src/lib/components/common/Cell.tsx +0 -52
- package/src/lib/components/common/LocaleArrow.tsx +0 -38
- package/src/lib/components/common/ResourceHeader.tsx +0 -73
- package/src/lib/components/common/Tabs.tsx +0 -119
- package/src/lib/components/common/TodayTypo.tsx +0 -44
- package/src/lib/components/common/WithResources.tsx +0 -98
- package/src/lib/components/events/Actions.tsx +0 -65
- package/src/lib/components/events/AgendaEventsList.tsx +0 -115
- package/src/lib/components/events/CurrentTimeBar.tsx +0 -59
- package/src/lib/components/events/EmptyAgenda.tsx +0 -27
- package/src/lib/components/events/EventItem.tsx +0 -180
- package/src/lib/components/events/EventItemPopover.tsx +0 -179
- package/src/lib/components/events/MonthEvents.tsx +0 -141
- package/src/lib/components/events/TodayEvents.tsx +0 -99
- package/src/lib/components/hoc/DateProvider.tsx +0 -19
- package/src/lib/components/inputs/DatePicker.tsx +0 -95
- package/src/lib/components/inputs/Input.tsx +0 -113
- package/src/lib/components/inputs/SelectInput.tsx +0 -164
- package/src/lib/components/month/MonthTable.tsx +0 -207
- package/src/lib/components/nav/DayDateBtn.tsx +0 -77
- package/src/lib/components/nav/MonthDateBtn.tsx +0 -80
- package/src/lib/components/nav/Navigation.tsx +0 -201
- package/src/lib/components/nav/WeekDateBtn.tsx +0 -89
- package/src/lib/components/week/WeekTable.tsx +0 -229
- package/src/lib/helpers/constants.ts +0 -4
- package/src/lib/helpers/generals.tsx +0 -354
- package/src/lib/hooks/useArrowDisable.ts +0 -26
- package/src/lib/hooks/useCellAttributes.ts +0 -67
- package/src/lib/hooks/useDragAttributes.ts +0 -31
- package/src/lib/hooks/useEventPermissions.ts +0 -42
- package/src/lib/hooks/useStore.ts +0 -8
- package/src/lib/hooks/useSyncScroll.ts +0 -31
- package/src/lib/hooks/useWindowResize.ts +0 -37
- package/src/lib/index.tsx +0 -14
- package/src/lib/positionManger/context.ts +0 -14
- package/src/lib/positionManger/provider.tsx +0 -113
- package/src/lib/positionManger/usePosition.ts +0 -8
- package/src/lib/store/context.ts +0 -5
- package/src/lib/store/default.ts +0 -157
- package/src/lib/store/provider.tsx +0 -211
- package/src/lib/store/types.ts +0 -33
- package/src/lib/styles/styles.ts +0 -256
- package/src/lib/types.ts +0 -423
- package/src/lib/views/Day.tsx +0 -265
- package/src/lib/views/DayAgenda.tsx +0 -57
- package/src/lib/views/Editor.tsx +0 -258
- package/src/lib/views/Month.tsx +0 -82
- package/src/lib/views/MonthAgenda.tsx +0 -84
- package/src/lib/views/Week.tsx +0 -92
- package/src/lib/views/WeekAgenda.tsx +0 -81
- package/src/vite-env.d.ts +0 -3
- package/tsconfig.build.json +0 -5
- package/tsconfig.json +0 -27
- package/vite.config.js +0 -40
- /package/{dist/SchedulerComponent.d.ts → SchedulerComponent.d.ts} +0 -0
- /package/{dist/components → components}/common/Cell.d.ts +0 -0
- /package/{dist/components → components}/common/LocaleArrow.d.ts +0 -0
- /package/{dist/components → components}/common/ResourceHeader.d.ts +0 -0
- /package/{dist/components → components}/common/Tabs.d.ts +0 -0
- /package/{dist/components → components}/common/TodayTypo.d.ts +0 -0
- /package/{dist/components → components}/common/WithResources.d.ts +0 -0
- /package/{dist/components → components}/events/Actions.d.ts +0 -0
- /package/{dist/components → components}/events/AgendaEventsList.d.ts +0 -0
- /package/{dist/components → components}/events/CurrentTimeBar.d.ts +0 -0
- /package/{dist/components → components}/events/EmptyAgenda.d.ts +0 -0
- /package/{dist/components → components}/events/EventItem.d.ts +0 -0
- /package/{dist/components → components}/events/EventItemPopover.d.ts +0 -0
- /package/{dist/components → components}/events/MonthEvents.d.ts +0 -0
- /package/{dist/components → components}/events/TodayEvents.d.ts +0 -0
- /package/{dist/components → components}/hoc/DateProvider.d.ts +0 -0
- /package/{dist/components → components}/inputs/DatePicker.d.ts +0 -0
- /package/{dist/components → components}/inputs/Input.d.ts +0 -0
- /package/{dist/components → components}/inputs/SelectInput.d.ts +0 -0
- /package/{dist/components → components}/month/MonthTable.d.ts +0 -0
- /package/{dist/components → components}/nav/DayDateBtn.d.ts +0 -0
- /package/{dist/components → components}/nav/MonthDateBtn.d.ts +0 -0
- /package/{dist/components → components}/nav/Navigation.d.ts +0 -0
- /package/{dist/components → components}/nav/WeekDateBtn.d.ts +0 -0
- /package/{dist/components → components}/week/WeekTable.d.ts +0 -0
- /package/{dist/helpers → helpers}/constants.d.ts +0 -0
- /package/{dist/helpers → helpers}/generals.d.ts +0 -0
- /package/{dist/hooks → hooks}/useArrowDisable.d.ts +0 -0
- /package/{dist/hooks → hooks}/useCellAttributes.d.ts +0 -0
- /package/{dist/hooks → hooks}/useDragAttributes.d.ts +0 -0
- /package/{dist/hooks → hooks}/useEventPermissions.d.ts +0 -0
- /package/{dist/hooks → hooks}/useStore.d.ts +0 -0
- /package/{dist/hooks → hooks}/useSyncScroll.d.ts +0 -0
- /package/{dist/hooks → hooks}/useWindowResize.d.ts +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/positionManger → positionManger}/context.d.ts +0 -0
- /package/{dist/positionManger → positionManger}/provider.d.ts +0 -0
- /package/{dist/positionManger → positionManger}/usePosition.d.ts +0 -0
- /package/{dist/store → store}/context.d.ts +0 -0
- /package/{dist/store → store}/default.d.ts +0 -0
- /package/{dist/store → store}/provider.d.ts +0 -0
- /package/{dist/store → store}/types.d.ts +0 -0
- /package/{dist/styles → styles}/styles.d.ts +0 -0
- /package/{dist/types.d.ts → types.d.ts} +0 -0
- /package/{dist/views → views}/Day.d.ts +0 -0
- /package/{dist/views → views}/DayAgenda.d.ts +0 -0
- /package/{dist/views → views}/Editor.d.ts +0 -0
- /package/{dist/views → views}/Month.d.ts +0 -0
- /package/{dist/views → views}/MonthAgenda.d.ts +0 -0
- /package/{dist/views → views}/Week.d.ts +0 -0
- /package/{dist/views → views}/WeekAgenda.d.ts +0 -0
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AgendaDiv } from "../../styles/styles";
|
|
2
|
-
import { Typography } from "@mui/material";
|
|
3
|
-
import useStore from "../../hooks/useStore";
|
|
4
|
-
|
|
5
|
-
const EmptyAgenda = () => {
|
|
6
|
-
const { height, translations, stickyNavigationOffset, stickyNavigationHeight } = useStore();
|
|
7
|
-
return (
|
|
8
|
-
<AgendaDiv
|
|
9
|
-
stickyOffset={stickyNavigationOffset}
|
|
10
|
-
stickyHeight={stickyNavigationHeight}
|
|
11
|
-
sx={{
|
|
12
|
-
borderWidth: 1,
|
|
13
|
-
padding: 1,
|
|
14
|
-
height: height / 2,
|
|
15
|
-
display: "flex",
|
|
16
|
-
alignItems: "center",
|
|
17
|
-
justifyContent: "center",
|
|
18
|
-
}}
|
|
19
|
-
>
|
|
20
|
-
<div className="rs__cell rs__agenda_items">
|
|
21
|
-
<Typography>{translations.noDataToDisplay}</Typography>
|
|
22
|
-
</div>
|
|
23
|
-
</AgendaDiv>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default EmptyAgenda;
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { Fragment, MouseEvent, useCallback, useMemo, useState } from "react";
|
|
2
|
-
import { Typography, ButtonBase, useTheme } from "@mui/material";
|
|
3
|
-
import { format } from "date-fns";
|
|
4
|
-
import { ProcessedEvent } from "../../types";
|
|
5
|
-
import ArrowRightRoundedIcon from "@mui/icons-material/ArrowRightRounded";
|
|
6
|
-
import ArrowLeftRoundedIcon from "@mui/icons-material/ArrowLeftRounded";
|
|
7
|
-
import { EventItemPaper } from "../../styles/styles";
|
|
8
|
-
import { differenceInDaysOmitTime, getHourFormat } from "../../helpers/generals";
|
|
9
|
-
import useStore from "../../hooks/useStore";
|
|
10
|
-
import useDragAttributes from "../../hooks/useDragAttributes";
|
|
11
|
-
import EventItemPopover from "./EventItemPopover";
|
|
12
|
-
import useEventPermissions from "../../hooks/useEventPermissions";
|
|
13
|
-
|
|
14
|
-
interface EventItemProps {
|
|
15
|
-
event: ProcessedEvent;
|
|
16
|
-
multiday?: boolean;
|
|
17
|
-
hasPrev?: boolean;
|
|
18
|
-
hasNext?: boolean;
|
|
19
|
-
showdate?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const EventItem = ({ event, multiday, hasPrev, hasNext, showdate = true }: EventItemProps) => {
|
|
23
|
-
const { direction, locale, hourFormat, eventRenderer, onEventClick, view, disableViewer } =
|
|
24
|
-
useStore();
|
|
25
|
-
const dragProps = useDragAttributes(event);
|
|
26
|
-
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
|
|
27
|
-
const [deleteConfirm, setDeleteConfirm] = useState(false);
|
|
28
|
-
const theme = useTheme();
|
|
29
|
-
const hFormat = getHourFormat(hourFormat);
|
|
30
|
-
|
|
31
|
-
const NextArrow = direction === "rtl" ? ArrowLeftRoundedIcon : ArrowRightRoundedIcon;
|
|
32
|
-
const PrevArrow = direction === "rtl" ? ArrowRightRoundedIcon : ArrowLeftRoundedIcon;
|
|
33
|
-
const hideDates = differenceInDaysOmitTime(event.start, event.end) <= 0 && event.allDay;
|
|
34
|
-
|
|
35
|
-
const { canDrag } = useEventPermissions(event);
|
|
36
|
-
|
|
37
|
-
const triggerViewer = useCallback(
|
|
38
|
-
(el?: MouseEvent<Element>) => {
|
|
39
|
-
if (!el?.currentTarget && deleteConfirm) {
|
|
40
|
-
setDeleteConfirm(false);
|
|
41
|
-
}
|
|
42
|
-
setAnchorEl(el?.currentTarget || null);
|
|
43
|
-
},
|
|
44
|
-
[deleteConfirm]
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const renderEvent = useMemo(() => {
|
|
48
|
-
// Check if has custom render event method
|
|
49
|
-
// only applicable to non-multiday events and not in month-view
|
|
50
|
-
if (typeof eventRenderer === "function" && !multiday && view !== "month") {
|
|
51
|
-
const custom = eventRenderer({ event, onClick: triggerViewer, ...dragProps });
|
|
52
|
-
if (custom) {
|
|
53
|
-
return (
|
|
54
|
-
<EventItemPaper key={`${event.start.getTime()}_${event.end.getTime()}_${event.event_id}`}>
|
|
55
|
-
{custom}
|
|
56
|
-
</EventItemPaper>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let item = (
|
|
62
|
-
<div style={{ padding: "2px 6px" }}>
|
|
63
|
-
<Typography variant="subtitle2" style={{ fontSize: 12 }} noWrap>
|
|
64
|
-
{event.title}
|
|
65
|
-
</Typography>
|
|
66
|
-
{event.subtitle && (
|
|
67
|
-
<Typography variant="body2" style={{ fontSize: 11 }} noWrap>
|
|
68
|
-
{event.subtitle}
|
|
69
|
-
</Typography>
|
|
70
|
-
)}
|
|
71
|
-
{showdate && (
|
|
72
|
-
<Typography style={{ fontSize: 11 }} noWrap>
|
|
73
|
-
{`${format(event.start, hFormat, {
|
|
74
|
-
locale,
|
|
75
|
-
})} - ${format(event.end, hFormat, { locale })}`}
|
|
76
|
-
</Typography>
|
|
77
|
-
)}
|
|
78
|
-
</div>
|
|
79
|
-
);
|
|
80
|
-
if (multiday) {
|
|
81
|
-
item = (
|
|
82
|
-
<div
|
|
83
|
-
style={{
|
|
84
|
-
padding: 2,
|
|
85
|
-
display: "flex",
|
|
86
|
-
alignItems: "center",
|
|
87
|
-
justifyContent: "space-between",
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
<Typography sx={{ fontSize: 11 }} noWrap>
|
|
91
|
-
{hasPrev ? (
|
|
92
|
-
<PrevArrow fontSize="small" sx={{ display: "flex" }} />
|
|
93
|
-
) : (
|
|
94
|
-
showdate && !hideDates && format(event.start, hFormat, { locale })
|
|
95
|
-
)}
|
|
96
|
-
</Typography>
|
|
97
|
-
<Typography variant="subtitle2" align="center" sx={{ fontSize: 12 }} noWrap>
|
|
98
|
-
{event.title}
|
|
99
|
-
</Typography>
|
|
100
|
-
<Typography sx={{ fontSize: 11 }} noWrap>
|
|
101
|
-
{hasNext ? (
|
|
102
|
-
<NextArrow fontSize="small" sx={{ display: "flex" }} />
|
|
103
|
-
) : (
|
|
104
|
-
showdate && !hideDates && format(event.end, hFormat, { locale })
|
|
105
|
-
)}
|
|
106
|
-
</Typography>
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
return (
|
|
111
|
-
<EventItemPaper
|
|
112
|
-
key={`${event.start.getTime()}_${event.end.getTime()}_${event.event_id}`}
|
|
113
|
-
disabled={event.disabled}
|
|
114
|
-
sx={{
|
|
115
|
-
bgcolor: event.disabled ? "#d0d0d0" : event.color || theme.palette.primary.main,
|
|
116
|
-
color: event.disabled ? "#808080" : event.textColor || theme.palette.primary.contrastText,
|
|
117
|
-
borderTop: event._hasPrev
|
|
118
|
-
? `3px dashed ${event.textColor || theme.palette.primary.contrastText}`
|
|
119
|
-
: undefined,
|
|
120
|
-
borderBottom: event._hasNext
|
|
121
|
-
? `3px dashed ${event.textColor || theme.palette.primary.contrastText}`
|
|
122
|
-
: undefined,
|
|
123
|
-
...(event.sx || {}),
|
|
124
|
-
}}
|
|
125
|
-
>
|
|
126
|
-
<ButtonBase
|
|
127
|
-
onClick={(e) => {
|
|
128
|
-
e.preventDefault();
|
|
129
|
-
e.stopPropagation();
|
|
130
|
-
if (!disableViewer) {
|
|
131
|
-
triggerViewer(e);
|
|
132
|
-
}
|
|
133
|
-
if (typeof onEventClick === "function") {
|
|
134
|
-
onEventClick(event);
|
|
135
|
-
}
|
|
136
|
-
}}
|
|
137
|
-
focusRipple
|
|
138
|
-
tabIndex={disableViewer ? -1 : 0}
|
|
139
|
-
disableRipple={disableViewer}
|
|
140
|
-
disabled={event.disabled}
|
|
141
|
-
>
|
|
142
|
-
<div {...dragProps} draggable={canDrag}>
|
|
143
|
-
{item}
|
|
144
|
-
</div>
|
|
145
|
-
</ButtonBase>
|
|
146
|
-
</EventItemPaper>
|
|
147
|
-
);
|
|
148
|
-
}, [
|
|
149
|
-
eventRenderer,
|
|
150
|
-
multiday,
|
|
151
|
-
view,
|
|
152
|
-
event,
|
|
153
|
-
showdate,
|
|
154
|
-
hFormat,
|
|
155
|
-
locale,
|
|
156
|
-
theme.palette.primary.main,
|
|
157
|
-
theme.palette.primary.contrastText,
|
|
158
|
-
disableViewer,
|
|
159
|
-
dragProps,
|
|
160
|
-
canDrag,
|
|
161
|
-
triggerViewer,
|
|
162
|
-
hasPrev,
|
|
163
|
-
PrevArrow,
|
|
164
|
-
hideDates,
|
|
165
|
-
hasNext,
|
|
166
|
-
NextArrow,
|
|
167
|
-
onEventClick,
|
|
168
|
-
]);
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<Fragment>
|
|
172
|
-
{renderEvent}
|
|
173
|
-
|
|
174
|
-
{/* Viewer */}
|
|
175
|
-
<EventItemPopover anchorEl={anchorEl} event={event} onTriggerViewer={triggerViewer} />
|
|
176
|
-
</Fragment>
|
|
177
|
-
);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default EventItem;
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { MouseEvent } from "react";
|
|
2
|
-
import { Box, IconButton, Popover, Typography, useTheme } from "@mui/material";
|
|
3
|
-
import useStore from "../../hooks/useStore";
|
|
4
|
-
import { ProcessedEvent } from "../../types";
|
|
5
|
-
import { PopperInner } from "../../styles/styles";
|
|
6
|
-
import EventActions from "./Actions";
|
|
7
|
-
import { differenceInDaysOmitTime, getHourFormat } from "../../helpers/generals";
|
|
8
|
-
import EventNoteRoundedIcon from "@mui/icons-material/EventNoteRounded";
|
|
9
|
-
import ClearRoundedIcon from "@mui/icons-material/ClearRounded";
|
|
10
|
-
import SupervisorAccountRoundedIcon from "@mui/icons-material/SupervisorAccountRounded";
|
|
11
|
-
import { format } from "date-fns";
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
event: ProcessedEvent;
|
|
15
|
-
anchorEl: Element | null;
|
|
16
|
-
onTriggerViewer: (el?: MouseEvent<Element>) => void;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const EventItemPopover = ({ anchorEl, event, onTriggerViewer }: Props) => {
|
|
20
|
-
const {
|
|
21
|
-
triggerDialog,
|
|
22
|
-
onDelete,
|
|
23
|
-
events,
|
|
24
|
-
handleState,
|
|
25
|
-
triggerLoading,
|
|
26
|
-
customViewer,
|
|
27
|
-
viewerExtraComponent,
|
|
28
|
-
fields,
|
|
29
|
-
resources,
|
|
30
|
-
resourceFields,
|
|
31
|
-
locale,
|
|
32
|
-
viewerTitleComponent,
|
|
33
|
-
viewerSubtitleComponent,
|
|
34
|
-
hourFormat,
|
|
35
|
-
translations,
|
|
36
|
-
onEventEdit,
|
|
37
|
-
} = useStore();
|
|
38
|
-
const theme = useTheme();
|
|
39
|
-
const hFormat = getHourFormat(hourFormat);
|
|
40
|
-
const displayStart = event._originalStart || event.start;
|
|
41
|
-
const displayEnd = event._originalEnd || event.end;
|
|
42
|
-
const hideDates = differenceInDaysOmitTime(displayStart, displayEnd) <= 0 && event.allDay;
|
|
43
|
-
|
|
44
|
-
const idKey = resourceFields.idField;
|
|
45
|
-
const hasResource = resources.filter((res) =>
|
|
46
|
-
Array.isArray(event[idKey]) ? event[idKey].includes(res[idKey]) : res[idKey] === event[idKey]
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const handleDelete = async () => {
|
|
50
|
-
try {
|
|
51
|
-
triggerLoading(true);
|
|
52
|
-
let deletedId = event.event_id;
|
|
53
|
-
// Trigger custom/remote when provided
|
|
54
|
-
if (onDelete) {
|
|
55
|
-
const remoteId = await onDelete(deletedId);
|
|
56
|
-
if (remoteId) {
|
|
57
|
-
deletedId = remoteId;
|
|
58
|
-
} else {
|
|
59
|
-
deletedId = "";
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (deletedId) {
|
|
63
|
-
onTriggerViewer();
|
|
64
|
-
const updatedEvents = events.filter((e) => e.event_id !== deletedId);
|
|
65
|
-
handleState(updatedEvents, "events");
|
|
66
|
-
}
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error(error);
|
|
69
|
-
} finally {
|
|
70
|
-
triggerLoading(false);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<Popover
|
|
76
|
-
open={Boolean(anchorEl)}
|
|
77
|
-
anchorEl={anchorEl}
|
|
78
|
-
onClose={() => {
|
|
79
|
-
onTriggerViewer();
|
|
80
|
-
}}
|
|
81
|
-
anchorOrigin={{
|
|
82
|
-
vertical: "center",
|
|
83
|
-
horizontal: "center",
|
|
84
|
-
}}
|
|
85
|
-
transformOrigin={{
|
|
86
|
-
vertical: "top",
|
|
87
|
-
horizontal: "center",
|
|
88
|
-
}}
|
|
89
|
-
onClick={(e) => {
|
|
90
|
-
e.stopPropagation();
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
{typeof customViewer === "function" ? (
|
|
94
|
-
customViewer(event, () => onTriggerViewer())
|
|
95
|
-
) : (
|
|
96
|
-
<PopperInner>
|
|
97
|
-
<Box
|
|
98
|
-
sx={{
|
|
99
|
-
bgcolor: event.color || theme.palette.primary.main,
|
|
100
|
-
color: theme.palette.primary.contrastText,
|
|
101
|
-
}}
|
|
102
|
-
>
|
|
103
|
-
<div className="rs__popper_actions">
|
|
104
|
-
<div>
|
|
105
|
-
<IconButton
|
|
106
|
-
size="small"
|
|
107
|
-
onClick={() => {
|
|
108
|
-
onTriggerViewer();
|
|
109
|
-
}}
|
|
110
|
-
>
|
|
111
|
-
<ClearRoundedIcon color="disabled" />
|
|
112
|
-
</IconButton>
|
|
113
|
-
</div>
|
|
114
|
-
<EventActions
|
|
115
|
-
event={event}
|
|
116
|
-
onDelete={handleDelete}
|
|
117
|
-
onEdit={() => {
|
|
118
|
-
onTriggerViewer();
|
|
119
|
-
triggerDialog(true, event);
|
|
120
|
-
|
|
121
|
-
if (onEventEdit && typeof onEventEdit === "function") {
|
|
122
|
-
onEventEdit(event);
|
|
123
|
-
}
|
|
124
|
-
}}
|
|
125
|
-
/>
|
|
126
|
-
</div>
|
|
127
|
-
{viewerTitleComponent instanceof Function ? (
|
|
128
|
-
viewerTitleComponent(event)
|
|
129
|
-
) : (
|
|
130
|
-
<Typography style={{ padding: "5px 0" }} noWrap>
|
|
131
|
-
{event.title}
|
|
132
|
-
</Typography>
|
|
133
|
-
)}
|
|
134
|
-
</Box>
|
|
135
|
-
<div style={{ padding: "5px 10px" }}>
|
|
136
|
-
<Typography
|
|
137
|
-
style={{ display: "flex", alignItems: "center", gap: 8 }}
|
|
138
|
-
color="textSecondary"
|
|
139
|
-
variant="caption"
|
|
140
|
-
noWrap
|
|
141
|
-
>
|
|
142
|
-
<EventNoteRoundedIcon />
|
|
143
|
-
{hideDates
|
|
144
|
-
? translations.event.allDay
|
|
145
|
-
: `${format(displayStart, `dd MMMM yyyy ${hFormat}`, {
|
|
146
|
-
locale: locale,
|
|
147
|
-
})} - ${format(displayEnd, `dd MMMM yyyy ${hFormat}`, {
|
|
148
|
-
locale: locale,
|
|
149
|
-
})}`}
|
|
150
|
-
</Typography>
|
|
151
|
-
{viewerSubtitleComponent instanceof Function ? (
|
|
152
|
-
viewerSubtitleComponent(event)
|
|
153
|
-
) : (
|
|
154
|
-
<Typography variant="body2" style={{ padding: "5px 0" }}>
|
|
155
|
-
{event.subtitle}
|
|
156
|
-
</Typography>
|
|
157
|
-
)}
|
|
158
|
-
{hasResource.length > 0 && (
|
|
159
|
-
<Typography
|
|
160
|
-
style={{ display: "flex", alignItems: "center", gap: 8 }}
|
|
161
|
-
color="textSecondary"
|
|
162
|
-
variant="caption"
|
|
163
|
-
noWrap
|
|
164
|
-
>
|
|
165
|
-
<SupervisorAccountRoundedIcon />
|
|
166
|
-
{hasResource.map((res) => res[resourceFields.textField]).join(", ")}
|
|
167
|
-
</Typography>
|
|
168
|
-
)}
|
|
169
|
-
{viewerExtraComponent instanceof Function
|
|
170
|
-
? viewerExtraComponent(fields, event)
|
|
171
|
-
: viewerExtraComponent}
|
|
172
|
-
</div>
|
|
173
|
-
</PopperInner>
|
|
174
|
-
)}
|
|
175
|
-
</Popover>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export default EventItemPopover;
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Fragment, useMemo } from "react";
|
|
2
|
-
import {
|
|
3
|
-
closestTo,
|
|
4
|
-
isBefore,
|
|
5
|
-
startOfWeek,
|
|
6
|
-
differenceInDays,
|
|
7
|
-
differenceInCalendarWeeks,
|
|
8
|
-
format,
|
|
9
|
-
} from "date-fns";
|
|
10
|
-
import { ProcessedEvent } from "../../types";
|
|
11
|
-
import { Typography } from "@mui/material";
|
|
12
|
-
import EventItem from "./EventItem";
|
|
13
|
-
import {
|
|
14
|
-
MONTH_BAR_HEIGHT,
|
|
15
|
-
MONTH_NUMBER_HEIGHT,
|
|
16
|
-
MULTI_DAY_EVENT_HEIGHT,
|
|
17
|
-
} from "../../helpers/constants";
|
|
18
|
-
import { convertEventTimeZone, differenceInDaysOmitTime } from "../../helpers/generals";
|
|
19
|
-
import useStore from "../../hooks/useStore";
|
|
20
|
-
import usePosition from "../../positionManger/usePosition";
|
|
21
|
-
|
|
22
|
-
interface MonthEventProps {
|
|
23
|
-
events: ProcessedEvent[];
|
|
24
|
-
resourceId?: string;
|
|
25
|
-
today: Date;
|
|
26
|
-
eachWeekStart: Date[];
|
|
27
|
-
eachFirstDayInCalcRow: Date | null;
|
|
28
|
-
daysList: Date[];
|
|
29
|
-
onViewMore(day: Date): void;
|
|
30
|
-
cellHeight: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const MonthEvents = ({
|
|
34
|
-
events,
|
|
35
|
-
resourceId,
|
|
36
|
-
today,
|
|
37
|
-
eachWeekStart,
|
|
38
|
-
eachFirstDayInCalcRow,
|
|
39
|
-
daysList,
|
|
40
|
-
onViewMore,
|
|
41
|
-
cellHeight,
|
|
42
|
-
}: MonthEventProps) => {
|
|
43
|
-
const LIMIT = Math.round((cellHeight - MONTH_NUMBER_HEIGHT) / MULTI_DAY_EVENT_HEIGHT - 1);
|
|
44
|
-
const { translations, month, locale, timeZone } = useStore();
|
|
45
|
-
const { renderedSlots } = usePosition();
|
|
46
|
-
|
|
47
|
-
const renderEvents = useMemo(() => {
|
|
48
|
-
const elements: React.ReactNode[] = [];
|
|
49
|
-
|
|
50
|
-
for (let i = 0; i < Math.min(events.length, LIMIT + 1); i++) {
|
|
51
|
-
const event = convertEventTimeZone(events[i], timeZone);
|
|
52
|
-
const fromPrevWeek = !!eachFirstDayInCalcRow && isBefore(event.start, eachFirstDayInCalcRow);
|
|
53
|
-
const start = fromPrevWeek && eachFirstDayInCalcRow ? eachFirstDayInCalcRow : event.start;
|
|
54
|
-
let eventLength = differenceInDaysOmitTime(start, event.end) + 1;
|
|
55
|
-
|
|
56
|
-
const toNextWeek =
|
|
57
|
-
differenceInCalendarWeeks(event.end, start, {
|
|
58
|
-
weekStartsOn: month?.weekStartOn,
|
|
59
|
-
locale,
|
|
60
|
-
}) > 0;
|
|
61
|
-
|
|
62
|
-
if (toNextWeek) {
|
|
63
|
-
// Rethink it
|
|
64
|
-
const NotAccurateWeekStart = startOfWeek(event.start, {
|
|
65
|
-
weekStartsOn: month?.weekStartOn,
|
|
66
|
-
locale,
|
|
67
|
-
});
|
|
68
|
-
const closestStart = closestTo(NotAccurateWeekStart, eachWeekStart);
|
|
69
|
-
if (closestStart) {
|
|
70
|
-
eventLength =
|
|
71
|
-
daysList.length -
|
|
72
|
-
(!eachFirstDayInCalcRow ? differenceInDays(event.start, closestStart) : 0);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const day = format(today, "yyyy-MM-dd");
|
|
77
|
-
const rendered = renderedSlots?.[resourceId || "all"]?.[day];
|
|
78
|
-
const position = rendered?.[event.event_id] || 0;
|
|
79
|
-
|
|
80
|
-
const topSpace = Math.min(position, LIMIT) * MULTI_DAY_EVENT_HEIGHT + MONTH_NUMBER_HEIGHT;
|
|
81
|
-
|
|
82
|
-
if (position >= LIMIT) {
|
|
83
|
-
elements.push(
|
|
84
|
-
<Typography
|
|
85
|
-
key={i}
|
|
86
|
-
width="100%"
|
|
87
|
-
className="rs__multi_day rs__hover__op"
|
|
88
|
-
style={{ top: topSpace, fontSize: 11 }}
|
|
89
|
-
onClick={(e) => {
|
|
90
|
-
e.stopPropagation();
|
|
91
|
-
onViewMore(today);
|
|
92
|
-
}}
|
|
93
|
-
>
|
|
94
|
-
{`${Math.abs(events.length - i)} ${translations.moreEvents}`}
|
|
95
|
-
</Typography>
|
|
96
|
-
);
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
elements.push(
|
|
101
|
-
<div
|
|
102
|
-
key={`${event.event_id}_${i}`}
|
|
103
|
-
className="rs__multi_day"
|
|
104
|
-
style={{
|
|
105
|
-
top: topSpace,
|
|
106
|
-
width: `${100 * eventLength}%`,
|
|
107
|
-
height: MONTH_BAR_HEIGHT,
|
|
108
|
-
}}
|
|
109
|
-
>
|
|
110
|
-
<EventItem
|
|
111
|
-
event={event}
|
|
112
|
-
showdate={false}
|
|
113
|
-
multiday={differenceInDaysOmitTime(event.start, event.end) > 0}
|
|
114
|
-
hasPrev={fromPrevWeek}
|
|
115
|
-
hasNext={toNextWeek}
|
|
116
|
-
/>
|
|
117
|
-
</div>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return elements;
|
|
122
|
-
}, [
|
|
123
|
-
resourceId,
|
|
124
|
-
renderedSlots,
|
|
125
|
-
events,
|
|
126
|
-
LIMIT,
|
|
127
|
-
eachFirstDayInCalcRow,
|
|
128
|
-
month?.weekStartOn,
|
|
129
|
-
locale,
|
|
130
|
-
today,
|
|
131
|
-
eachWeekStart,
|
|
132
|
-
daysList.length,
|
|
133
|
-
translations.moreEvents,
|
|
134
|
-
onViewMore,
|
|
135
|
-
timeZone,
|
|
136
|
-
]);
|
|
137
|
-
|
|
138
|
-
return <Fragment>{renderEvents}</Fragment>;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export default MonthEvents;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { differenceInMinutes } from "date-fns";
|
|
2
|
-
import { Fragment } from "react";
|
|
3
|
-
import { BORDER_HEIGHT } from "../../helpers/constants";
|
|
4
|
-
import { isTimeZonedToday, traversCrossingEvents } from "../../helpers/generals";
|
|
5
|
-
import { ProcessedEvent } from "../../types";
|
|
6
|
-
import CurrentTimeBar from "./CurrentTimeBar";
|
|
7
|
-
import EventItem from "./EventItem";
|
|
8
|
-
|
|
9
|
-
interface TodayEventsProps {
|
|
10
|
-
todayEvents: ProcessedEvent[];
|
|
11
|
-
today: Date;
|
|
12
|
-
startHour: number;
|
|
13
|
-
endHour: number;
|
|
14
|
-
step: number;
|
|
15
|
-
minuteHeight: number;
|
|
16
|
-
direction: "rtl" | "ltr";
|
|
17
|
-
timeZone?: string;
|
|
18
|
-
currentTime?: Date;
|
|
19
|
-
showCurrentTimeBar?: boolean;
|
|
20
|
-
currentTimeBarColor?: string;
|
|
21
|
-
}
|
|
22
|
-
const TodayEvents = ({
|
|
23
|
-
todayEvents,
|
|
24
|
-
today,
|
|
25
|
-
startHour,
|
|
26
|
-
endHour,
|
|
27
|
-
step,
|
|
28
|
-
minuteHeight,
|
|
29
|
-
direction,
|
|
30
|
-
timeZone,
|
|
31
|
-
currentTime,
|
|
32
|
-
showCurrentTimeBar = true,
|
|
33
|
-
currentTimeBarColor,
|
|
34
|
-
}: TodayEventsProps) => {
|
|
35
|
-
const crossingIds: Array<number | string> = [];
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Fragment>
|
|
39
|
-
{showCurrentTimeBar && isTimeZonedToday({ dateLeft: today, timeZone }) && (
|
|
40
|
-
<CurrentTimeBar
|
|
41
|
-
startHour={startHour}
|
|
42
|
-
step={step}
|
|
43
|
-
minuteHeight={minuteHeight}
|
|
44
|
-
timeZone={timeZone}
|
|
45
|
-
zIndex={2 * todayEvents.length + 1}
|
|
46
|
-
currentTime={currentTime}
|
|
47
|
-
color={currentTimeBarColor}
|
|
48
|
-
/>
|
|
49
|
-
)}
|
|
50
|
-
|
|
51
|
-
{todayEvents.map((event, i) => {
|
|
52
|
-
const maxHeight = (endHour * 60 - startHour * 60) * minuteHeight;
|
|
53
|
-
const eventHeight = differenceInMinutes(event.end, event.start) * minuteHeight;
|
|
54
|
-
const height = Math.min(eventHeight, maxHeight) - BORDER_HEIGHT;
|
|
55
|
-
|
|
56
|
-
const calendarStartInMins = startHour * 60;
|
|
57
|
-
const eventStartInMins = event.start.getHours() * 60 + event.start.getMinutes();
|
|
58
|
-
const minituesFromTop = Math.max(eventStartInMins - calendarStartInMins, 0);
|
|
59
|
-
|
|
60
|
-
const topSpace = minituesFromTop * minuteHeight;
|
|
61
|
-
/** Add border factor to height of each slot */
|
|
62
|
-
const slots = height / 60;
|
|
63
|
-
const heightBorderFactor = slots * BORDER_HEIGHT;
|
|
64
|
-
|
|
65
|
-
/** Calculate top space */
|
|
66
|
-
const slotsFromTop = minituesFromTop / step;
|
|
67
|
-
const top = topSpace + slotsFromTop;
|
|
68
|
-
|
|
69
|
-
const crossingEvents = traversCrossingEvents(todayEvents, event);
|
|
70
|
-
const alreadyRendered = crossingEvents.filter((e) => crossingIds.includes(e.event_id));
|
|
71
|
-
crossingIds.push(event.event_id);
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<div
|
|
75
|
-
key={`${event.event_id}/${event.recurrenceId || ""}`}
|
|
76
|
-
className="rs__event__item"
|
|
77
|
-
style={{
|
|
78
|
-
height: height + heightBorderFactor,
|
|
79
|
-
top,
|
|
80
|
-
width:
|
|
81
|
-
alreadyRendered.length > 0
|
|
82
|
-
? `calc(100% - ${100 - 98 / (alreadyRendered.length + 1)}%)`
|
|
83
|
-
: "98%", // Leave some space to click cell
|
|
84
|
-
zIndex: todayEvents.length + i,
|
|
85
|
-
[direction === "rtl" ? "right" : "left"]:
|
|
86
|
-
alreadyRendered.length > 0
|
|
87
|
-
? `${(100 / (crossingEvents.length + 1)) * alreadyRendered.length}%`
|
|
88
|
-
: "",
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
<EventItem event={event} />
|
|
92
|
-
</div>
|
|
93
|
-
);
|
|
94
|
-
})}
|
|
95
|
-
</Fragment>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export default TodayEvents;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
|
2
|
-
import useStore from "../../hooks/useStore";
|
|
3
|
-
import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
|
|
4
|
-
|
|
5
|
-
interface AuxProps {
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const DateProvider = ({ children }: AuxProps) => {
|
|
10
|
-
const { locale } = useStore();
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={locale}>
|
|
14
|
-
{children}
|
|
15
|
-
</LocalizationProvider>
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default DateProvider;
|