@isma91/react-scheduler 4.0.0 → 4.0.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 +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/index.js → index.js} +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,80 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import DateProvider from "../hoc/DateProvider";
|
|
3
|
-
import { DateCalendar } from "@mui/x-date-pickers";
|
|
4
|
-
import { Button, Popover } from "@mui/material";
|
|
5
|
-
import { format, getMonth, setMonth } from "date-fns";
|
|
6
|
-
import { LocaleArrow } from "../common/LocaleArrow";
|
|
7
|
-
import useStore from "../../hooks/useStore";
|
|
8
|
-
import useArrowDisable from "../../hooks/useArrowDisable";
|
|
9
|
-
|
|
10
|
-
interface MonthDateBtnProps {
|
|
11
|
-
selectedDate: Date;
|
|
12
|
-
onChange(value: Date): void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const MonthDateBtn = ({ selectedDate, onChange }: MonthDateBtnProps) => {
|
|
16
|
-
const { locale, navigationPickerProps } = useStore();
|
|
17
|
-
const currentMonth = getMonth(selectedDate);
|
|
18
|
-
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
|
19
|
-
const { prevDisabled, nextDisabled } = useArrowDisable();
|
|
20
|
-
|
|
21
|
-
const handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
22
|
-
setAnchorEl(event.currentTarget);
|
|
23
|
-
};
|
|
24
|
-
const handleClose = () => {
|
|
25
|
-
setAnchorEl(null);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const handleChange = (e: Date | null) => {
|
|
29
|
-
onChange(e || new Date());
|
|
30
|
-
handleClose();
|
|
31
|
-
};
|
|
32
|
-
const handlePrev = () => {
|
|
33
|
-
const prevMonth = currentMonth - 1;
|
|
34
|
-
onChange(setMonth(selectedDate, prevMonth));
|
|
35
|
-
};
|
|
36
|
-
const handleNext = () => {
|
|
37
|
-
const nextMonth = currentMonth + 1;
|
|
38
|
-
onChange(setMonth(selectedDate, nextMonth));
|
|
39
|
-
};
|
|
40
|
-
return (
|
|
41
|
-
<>
|
|
42
|
-
<LocaleArrow
|
|
43
|
-
type="prev"
|
|
44
|
-
onClick={handlePrev}
|
|
45
|
-
disabled={prevDisabled}
|
|
46
|
-
aria-label="previous month"
|
|
47
|
-
/>
|
|
48
|
-
<Button style={{ padding: 4 }} onClick={handleOpen} aria-label="selected month">
|
|
49
|
-
{format(selectedDate, "MMMM yyyy", { locale })}
|
|
50
|
-
</Button>
|
|
51
|
-
<Popover
|
|
52
|
-
open={Boolean(anchorEl)}
|
|
53
|
-
anchorEl={anchorEl}
|
|
54
|
-
onClose={handleClose}
|
|
55
|
-
anchorOrigin={{
|
|
56
|
-
vertical: "bottom",
|
|
57
|
-
horizontal: "left",
|
|
58
|
-
}}
|
|
59
|
-
>
|
|
60
|
-
<DateProvider>
|
|
61
|
-
<DateCalendar
|
|
62
|
-
{...navigationPickerProps}
|
|
63
|
-
openTo="month"
|
|
64
|
-
views={["year", "month"]}
|
|
65
|
-
value={selectedDate}
|
|
66
|
-
onChange={handleChange}
|
|
67
|
-
/>
|
|
68
|
-
</DateProvider>
|
|
69
|
-
</Popover>
|
|
70
|
-
<LocaleArrow
|
|
71
|
-
type="next"
|
|
72
|
-
onClick={handleNext}
|
|
73
|
-
disabled={nextDisabled}
|
|
74
|
-
aria-label="next month"
|
|
75
|
-
/>
|
|
76
|
-
</>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export { MonthDateBtn };
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { Fragment, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
useTheme,
|
|
5
|
-
useMediaQuery,
|
|
6
|
-
Popover,
|
|
7
|
-
MenuList,
|
|
8
|
-
MenuItem,
|
|
9
|
-
IconButton,
|
|
10
|
-
} from "@mui/material";
|
|
11
|
-
import { WeekDateBtn } from "./WeekDateBtn";
|
|
12
|
-
import { DayDateBtn } from "./DayDateBtn";
|
|
13
|
-
import { MonthDateBtn } from "./MonthDateBtn";
|
|
14
|
-
import MoreVertIcon from "@mui/icons-material/MoreVert";
|
|
15
|
-
import ViewAgendaIcon from "@mui/icons-material/ViewAgenda";
|
|
16
|
-
import useStore from "../../hooks/useStore";
|
|
17
|
-
import { NavigationDiv } from "../../styles/styles";
|
|
18
|
-
import { getTimeZonedDate } from "../../helpers/generals";
|
|
19
|
-
|
|
20
|
-
export type View = "month" | "week" | "day";
|
|
21
|
-
|
|
22
|
-
const Navigation = () => {
|
|
23
|
-
const {
|
|
24
|
-
selectedDate,
|
|
25
|
-
view,
|
|
26
|
-
week,
|
|
27
|
-
handleState,
|
|
28
|
-
getViews,
|
|
29
|
-
translations,
|
|
30
|
-
navigation,
|
|
31
|
-
day,
|
|
32
|
-
month,
|
|
33
|
-
disableViewNavigator,
|
|
34
|
-
onSelectedDateChange,
|
|
35
|
-
onViewChange,
|
|
36
|
-
stickyNavigation,
|
|
37
|
-
timeZone,
|
|
38
|
-
agenda,
|
|
39
|
-
toggleAgenda,
|
|
40
|
-
enableAgenda,
|
|
41
|
-
customHeaderContent,
|
|
42
|
-
stickyNavigationOffset,
|
|
43
|
-
} = useStore();
|
|
44
|
-
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
|
|
45
|
-
const theme = useTheme();
|
|
46
|
-
const isDesktop = useMediaQuery(theme.breakpoints.up("sm"));
|
|
47
|
-
const views = getViews();
|
|
48
|
-
|
|
49
|
-
const toggleMoreMenu = (el?: Element) => {
|
|
50
|
-
setAnchorEl(el || null);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const handleSelectedDateChange = (date: Date) => {
|
|
54
|
-
handleState(date, "selectedDate");
|
|
55
|
-
|
|
56
|
-
if (onSelectedDateChange && typeof onSelectedDateChange === "function") {
|
|
57
|
-
onSelectedDateChange(date);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const handleChangeView = (view: View) => {
|
|
62
|
-
handleState(view, "view");
|
|
63
|
-
if (onViewChange && typeof onViewChange === "function") {
|
|
64
|
-
onViewChange(view, agenda);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const renderDateSelector = () => {
|
|
69
|
-
switch (view) {
|
|
70
|
-
case "month":
|
|
71
|
-
return (
|
|
72
|
-
month?.navigation && (
|
|
73
|
-
<MonthDateBtn selectedDate={selectedDate} onChange={handleSelectedDateChange} />
|
|
74
|
-
)
|
|
75
|
-
);
|
|
76
|
-
case "week":
|
|
77
|
-
return (
|
|
78
|
-
week?.navigation && (
|
|
79
|
-
<WeekDateBtn
|
|
80
|
-
selectedDate={selectedDate}
|
|
81
|
-
onChange={handleSelectedDateChange}
|
|
82
|
-
weekProps={week!}
|
|
83
|
-
/>
|
|
84
|
-
)
|
|
85
|
-
);
|
|
86
|
-
case "day":
|
|
87
|
-
return (
|
|
88
|
-
day?.navigation && (
|
|
89
|
-
<DayDateBtn selectedDate={selectedDate} onChange={handleSelectedDateChange} />
|
|
90
|
-
)
|
|
91
|
-
);
|
|
92
|
-
default:
|
|
93
|
-
return "";
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
if (!navigation && disableViewNavigator) return null;
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<NavigationDiv sticky={stickyNavigation ? "1" : "0"} offset={stickyNavigationOffset}>
|
|
101
|
-
<div data-testid="date-navigator">{navigation && renderDateSelector()}</div>
|
|
102
|
-
|
|
103
|
-
{customHeaderContent && (
|
|
104
|
-
<div className="rs__custom_header_content">{customHeaderContent()}</div>
|
|
105
|
-
)}
|
|
106
|
-
|
|
107
|
-
<div
|
|
108
|
-
className="rs__view_navigator"
|
|
109
|
-
data-testid="view-navigator"
|
|
110
|
-
style={{
|
|
111
|
-
visibility: disableViewNavigator ? "hidden" : "visible",
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
<Button
|
|
115
|
-
onClick={() => handleSelectedDateChange(getTimeZonedDate(new Date(), timeZone))}
|
|
116
|
-
aria-label={translations.navigation.today}
|
|
117
|
-
>
|
|
118
|
-
{translations.navigation.today}
|
|
119
|
-
</Button>
|
|
120
|
-
{enableAgenda &&
|
|
121
|
-
(isDesktop ? (
|
|
122
|
-
<Button
|
|
123
|
-
color={agenda ? "primary" : "inherit"}
|
|
124
|
-
onClick={toggleAgenda}
|
|
125
|
-
aria-label={translations.navigation.agenda}
|
|
126
|
-
>
|
|
127
|
-
{translations.navigation.agenda}
|
|
128
|
-
</Button>
|
|
129
|
-
) : (
|
|
130
|
-
<IconButton
|
|
131
|
-
color={agenda ? "primary" : "default"}
|
|
132
|
-
style={{ padding: 5 }}
|
|
133
|
-
onClick={toggleAgenda}
|
|
134
|
-
>
|
|
135
|
-
<ViewAgendaIcon />
|
|
136
|
-
</IconButton>
|
|
137
|
-
))}
|
|
138
|
-
|
|
139
|
-
{views.length > 1 &&
|
|
140
|
-
(isDesktop ? (
|
|
141
|
-
views.map((v) => (
|
|
142
|
-
<Button
|
|
143
|
-
key={v}
|
|
144
|
-
color={v === view ? "primary" : "inherit"}
|
|
145
|
-
onClick={() => handleChangeView(v)}
|
|
146
|
-
onDragOver={(e) => {
|
|
147
|
-
e.preventDefault();
|
|
148
|
-
handleChangeView(v);
|
|
149
|
-
}}
|
|
150
|
-
>
|
|
151
|
-
{translations.navigation[v]}
|
|
152
|
-
</Button>
|
|
153
|
-
))
|
|
154
|
-
) : (
|
|
155
|
-
<Fragment>
|
|
156
|
-
<IconButton
|
|
157
|
-
style={{ padding: 5 }}
|
|
158
|
-
onClick={(e) => {
|
|
159
|
-
toggleMoreMenu(e.currentTarget);
|
|
160
|
-
}}
|
|
161
|
-
>
|
|
162
|
-
<MoreVertIcon />
|
|
163
|
-
</IconButton>
|
|
164
|
-
<Popover
|
|
165
|
-
open={Boolean(anchorEl)}
|
|
166
|
-
anchorEl={anchorEl}
|
|
167
|
-
onClose={() => {
|
|
168
|
-
toggleMoreMenu();
|
|
169
|
-
}}
|
|
170
|
-
anchorOrigin={{
|
|
171
|
-
vertical: "center",
|
|
172
|
-
horizontal: "center",
|
|
173
|
-
}}
|
|
174
|
-
transformOrigin={{
|
|
175
|
-
vertical: "top",
|
|
176
|
-
horizontal: "center",
|
|
177
|
-
}}
|
|
178
|
-
>
|
|
179
|
-
<MenuList autoFocusItem={!!anchorEl} disablePadding>
|
|
180
|
-
{views.map((v) => (
|
|
181
|
-
<MenuItem
|
|
182
|
-
key={v}
|
|
183
|
-
selected={v === view}
|
|
184
|
-
onClick={() => {
|
|
185
|
-
toggleMoreMenu();
|
|
186
|
-
handleChangeView(v);
|
|
187
|
-
}}
|
|
188
|
-
>
|
|
189
|
-
{translations.navigation[v]}
|
|
190
|
-
</MenuItem>
|
|
191
|
-
))}
|
|
192
|
-
</MenuList>
|
|
193
|
-
</Popover>
|
|
194
|
-
</Fragment>
|
|
195
|
-
))}
|
|
196
|
-
</div>
|
|
197
|
-
</NavigationDiv>
|
|
198
|
-
);
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export { Navigation };
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import DateProvider from "../hoc/DateProvider";
|
|
3
|
-
import { Button, Popover } from "@mui/material";
|
|
4
|
-
import { endOfWeek, format, startOfWeek, addDays } from "date-fns";
|
|
5
|
-
import { LocaleArrow } from "../common/LocaleArrow";
|
|
6
|
-
import { DateCalendar } from "@mui/x-date-pickers";
|
|
7
|
-
import useStore from "../../hooks/useStore";
|
|
8
|
-
import useArrowDisable from "../../hooks/useArrowDisable";
|
|
9
|
-
import { WeekProps } from "../../types";
|
|
10
|
-
|
|
11
|
-
interface WeekDateBtnProps {
|
|
12
|
-
selectedDate: Date;
|
|
13
|
-
onChange(value: Date): void;
|
|
14
|
-
weekProps: WeekProps;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const WeekDateBtn = ({ selectedDate, onChange, weekProps }: WeekDateBtnProps) => {
|
|
18
|
-
const { locale, navigationPickerProps } = useStore();
|
|
19
|
-
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
|
20
|
-
const { weekStartOn } = weekProps;
|
|
21
|
-
const weekStart = startOfWeek(selectedDate, { weekStartsOn: weekStartOn });
|
|
22
|
-
const weekEnd = endOfWeek(selectedDate, { weekStartsOn: weekStartOn });
|
|
23
|
-
const { prevDisabled, nextDisabled } = useArrowDisable();
|
|
24
|
-
|
|
25
|
-
const handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
26
|
-
setAnchorEl(event.currentTarget);
|
|
27
|
-
};
|
|
28
|
-
const handleClose = () => {
|
|
29
|
-
setAnchorEl(null);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const handleChange = (e: Date | null) => {
|
|
33
|
-
onChange(e || new Date());
|
|
34
|
-
handleClose();
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const handlePrev = () => {
|
|
38
|
-
const ladtDayPrevWeek = addDays(weekStart, -1);
|
|
39
|
-
onChange(ladtDayPrevWeek);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const handleNext = () => {
|
|
43
|
-
const firstDayNextWeek = addDays(weekEnd, 1);
|
|
44
|
-
onChange(firstDayNextWeek);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<>
|
|
49
|
-
<LocaleArrow
|
|
50
|
-
type="prev"
|
|
51
|
-
onClick={handlePrev}
|
|
52
|
-
disabled={prevDisabled}
|
|
53
|
-
aria-label="previous week"
|
|
54
|
-
/>
|
|
55
|
-
<Button style={{ padding: 4 }} onClick={handleOpen} aria-label="selected week">
|
|
56
|
-
{`${format(weekStart, "dd", { locale })} - ${format(weekEnd, "dd MMM yyyy", {
|
|
57
|
-
locale,
|
|
58
|
-
})}`}
|
|
59
|
-
</Button>
|
|
60
|
-
<Popover
|
|
61
|
-
open={Boolean(anchorEl)}
|
|
62
|
-
anchorEl={anchorEl}
|
|
63
|
-
onClose={handleClose}
|
|
64
|
-
anchorOrigin={{
|
|
65
|
-
vertical: "bottom",
|
|
66
|
-
horizontal: "left",
|
|
67
|
-
}}
|
|
68
|
-
>
|
|
69
|
-
<DateProvider>
|
|
70
|
-
<DateCalendar
|
|
71
|
-
{...navigationPickerProps}
|
|
72
|
-
openTo="day"
|
|
73
|
-
views={["month", "day"]}
|
|
74
|
-
value={selectedDate}
|
|
75
|
-
onChange={handleChange}
|
|
76
|
-
/>
|
|
77
|
-
</DateProvider>
|
|
78
|
-
</Popover>
|
|
79
|
-
<LocaleArrow
|
|
80
|
-
type="next"
|
|
81
|
-
onClick={handleNext}
|
|
82
|
-
disabled={nextDisabled}
|
|
83
|
-
aria-label="next week"
|
|
84
|
-
/>
|
|
85
|
-
</>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export { WeekDateBtn };
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { Fragment, useMemo } from "react";
|
|
2
|
-
import useStore from "../../hooks/useStore";
|
|
3
|
-
import { TableGrid } from "../../styles/styles";
|
|
4
|
-
import {
|
|
5
|
-
differenceInDaysOmitTime,
|
|
6
|
-
filterMultiDaySlot,
|
|
7
|
-
filterTodayEvents,
|
|
8
|
-
getHourFormat,
|
|
9
|
-
} from "../../helpers/generals";
|
|
10
|
-
import { MULTI_DAY_EVENT_HEIGHT } from "../../helpers/constants";
|
|
11
|
-
import { DefaultResource, ProcessedEvent } from "../../types";
|
|
12
|
-
import useSyncScroll from "../../hooks/useSyncScroll";
|
|
13
|
-
import {
|
|
14
|
-
addMinutes,
|
|
15
|
-
endOfDay,
|
|
16
|
-
format,
|
|
17
|
-
isAfter,
|
|
18
|
-
isBefore,
|
|
19
|
-
isSameDay,
|
|
20
|
-
isToday,
|
|
21
|
-
startOfDay,
|
|
22
|
-
} from "date-fns";
|
|
23
|
-
import TodayTypo from "../common/TodayTypo";
|
|
24
|
-
import usePosition from "../../positionManger/usePosition";
|
|
25
|
-
import EventItem from "../events/EventItem";
|
|
26
|
-
import { Typography } from "@mui/material";
|
|
27
|
-
import TodayEvents from "../events/TodayEvents";
|
|
28
|
-
import Cell from "../common/Cell";
|
|
29
|
-
|
|
30
|
-
type Props = {
|
|
31
|
-
daysList: Date[];
|
|
32
|
-
hours: Date[];
|
|
33
|
-
cellHeight: number;
|
|
34
|
-
minutesHeight: number;
|
|
35
|
-
resource?: DefaultResource;
|
|
36
|
-
resourcedEvents: ProcessedEvent[];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const WeekTable = ({
|
|
40
|
-
daysList,
|
|
41
|
-
hours,
|
|
42
|
-
cellHeight,
|
|
43
|
-
minutesHeight,
|
|
44
|
-
resourcedEvents,
|
|
45
|
-
resource,
|
|
46
|
-
}: Props) => {
|
|
47
|
-
const {
|
|
48
|
-
week,
|
|
49
|
-
events,
|
|
50
|
-
handleGotoDay,
|
|
51
|
-
resources,
|
|
52
|
-
resourceFields,
|
|
53
|
-
resourceViewMode,
|
|
54
|
-
direction,
|
|
55
|
-
locale,
|
|
56
|
-
hourFormat,
|
|
57
|
-
timeZone,
|
|
58
|
-
stickyNavigation,
|
|
59
|
-
stickyNavigationOffset,
|
|
60
|
-
stickyNavigationHeight,
|
|
61
|
-
currentTime,
|
|
62
|
-
showCurrentTimeBar,
|
|
63
|
-
currentTimeBarColor,
|
|
64
|
-
forceInlineMultiDay,
|
|
65
|
-
} = useStore();
|
|
66
|
-
const { startHour, endHour, step, cellRenderer, disableGoToDay, headRenderer, hourRenderer } =
|
|
67
|
-
week!;
|
|
68
|
-
const { renderedSlots } = usePosition();
|
|
69
|
-
const { headersRef, bodyRef } = useSyncScroll();
|
|
70
|
-
const MULTI_SPACE = MULTI_DAY_EVENT_HEIGHT;
|
|
71
|
-
const weekStart = startOfDay(daysList[0]);
|
|
72
|
-
const weekEnd = endOfDay(daysList[daysList.length - 1]);
|
|
73
|
-
const hFormat = getHourFormat(hourFormat);
|
|
74
|
-
|
|
75
|
-
// Equalizing multi-day section height except in resource/tabs mode
|
|
76
|
-
const headerHeight = useMemo(() => {
|
|
77
|
-
const shouldEqualize = resources.length && resourceViewMode === "default";
|
|
78
|
-
const allWeekMulti = filterMultiDaySlot(
|
|
79
|
-
shouldEqualize ? events : resourcedEvents,
|
|
80
|
-
daysList,
|
|
81
|
-
timeZone,
|
|
82
|
-
true,
|
|
83
|
-
forceInlineMultiDay
|
|
84
|
-
);
|
|
85
|
-
return MULTI_SPACE * allWeekMulti.length + 45;
|
|
86
|
-
}, [
|
|
87
|
-
MULTI_SPACE,
|
|
88
|
-
daysList,
|
|
89
|
-
events,
|
|
90
|
-
resourceViewMode,
|
|
91
|
-
resourcedEvents,
|
|
92
|
-
resources.length,
|
|
93
|
-
timeZone,
|
|
94
|
-
]);
|
|
95
|
-
|
|
96
|
-
const renderMultiDayEvents = (
|
|
97
|
-
events: ProcessedEvent[],
|
|
98
|
-
today: Date,
|
|
99
|
-
resource?: DefaultResource
|
|
100
|
-
) => {
|
|
101
|
-
const isFirstDayInWeek = isSameDay(weekStart, today);
|
|
102
|
-
const allWeekMulti = filterMultiDaySlot(
|
|
103
|
-
events,
|
|
104
|
-
daysList,
|
|
105
|
-
timeZone,
|
|
106
|
-
undefined,
|
|
107
|
-
forceInlineMultiDay
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const multiDays = allWeekMulti
|
|
111
|
-
.filter((e) => (isBefore(e.start, weekStart) ? isFirstDayInWeek : isSameDay(e.start, today)))
|
|
112
|
-
.sort((a, b) => b.end.getTime() - a.end.getTime());
|
|
113
|
-
return multiDays.map((event) => {
|
|
114
|
-
const hasPrev = isBefore(startOfDay(event.start), weekStart);
|
|
115
|
-
const hasNext = isAfter(endOfDay(event.end), weekEnd);
|
|
116
|
-
const eventLength =
|
|
117
|
-
differenceInDaysOmitTime(hasPrev ? weekStart : event.start, hasNext ? weekEnd : event.end) +
|
|
118
|
-
1;
|
|
119
|
-
|
|
120
|
-
const day = format(today, "yyyy-MM-dd");
|
|
121
|
-
const resourceId = resource ? resource[resourceFields.idField] : "all";
|
|
122
|
-
const rendered = renderedSlots?.[resourceId]?.[day];
|
|
123
|
-
const position = rendered?.[event.event_id] || 0;
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<div
|
|
127
|
-
key={event.event_id}
|
|
128
|
-
className="rs__multi_day"
|
|
129
|
-
style={{
|
|
130
|
-
top: position * MULTI_SPACE + 45,
|
|
131
|
-
width: `${99.9 * eventLength}%`,
|
|
132
|
-
overflowX: "hidden",
|
|
133
|
-
}}
|
|
134
|
-
>
|
|
135
|
-
<EventItem event={event} hasPrev={hasPrev} hasNext={hasNext} multiday />
|
|
136
|
-
</div>
|
|
137
|
-
);
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<>
|
|
143
|
-
{/* Header days */}
|
|
144
|
-
<TableGrid
|
|
145
|
-
days={daysList.length}
|
|
146
|
-
ref={headersRef}
|
|
147
|
-
sticky="1"
|
|
148
|
-
stickyNavigation={stickyNavigation}
|
|
149
|
-
stickyOffset={stickyNavigationOffset}
|
|
150
|
-
stickyHeight={stickyNavigationHeight}
|
|
151
|
-
>
|
|
152
|
-
<span className="rs__cell rs__time"></span>
|
|
153
|
-
{daysList.map((date, i) => (
|
|
154
|
-
<span
|
|
155
|
-
key={i}
|
|
156
|
-
className={`rs__cell rs__header ${isToday(date) ? "rs__today_cell" : ""}`}
|
|
157
|
-
style={{ height: headerHeight }}
|
|
158
|
-
>
|
|
159
|
-
{typeof headRenderer === "function" ? (
|
|
160
|
-
<div>{headRenderer({ day: date, events: resourcedEvents, resource })}</div>
|
|
161
|
-
) : (
|
|
162
|
-
<TodayTypo
|
|
163
|
-
date={date}
|
|
164
|
-
onClick={!disableGoToDay ? handleGotoDay : undefined}
|
|
165
|
-
locale={locale}
|
|
166
|
-
/>
|
|
167
|
-
)}
|
|
168
|
-
{renderMultiDayEvents(resourcedEvents, date, resource)}
|
|
169
|
-
</span>
|
|
170
|
-
))}
|
|
171
|
-
</TableGrid>
|
|
172
|
-
{/* Time Cells */}
|
|
173
|
-
<TableGrid days={daysList.length} ref={bodyRef}>
|
|
174
|
-
{hours.map((h, i) => (
|
|
175
|
-
<Fragment key={i}>
|
|
176
|
-
<span style={{ height: cellHeight }} className="rs__cell rs__header rs__time">
|
|
177
|
-
{typeof hourRenderer === "function" ? (
|
|
178
|
-
<div>{hourRenderer(format(h, hFormat, { locale }))}</div>
|
|
179
|
-
) : (
|
|
180
|
-
<Typography variant="caption">{format(h, hFormat, { locale })}</Typography>
|
|
181
|
-
)}
|
|
182
|
-
</span>
|
|
183
|
-
{daysList.map((date, ii) => {
|
|
184
|
-
const start = new Date(`${format(date, "yyyy/MM/dd")} ${format(h, hFormat)}`);
|
|
185
|
-
const end = addMinutes(start, step);
|
|
186
|
-
const field = resourceFields.idField;
|
|
187
|
-
return (
|
|
188
|
-
<span key={ii} className={`rs__cell ${isToday(date) ? "rs__today_cell" : ""}`}>
|
|
189
|
-
{/* Events of each day - run once on the top hour column */}
|
|
190
|
-
{i === 0 && (
|
|
191
|
-
<TodayEvents
|
|
192
|
-
todayEvents={filterTodayEvents(
|
|
193
|
-
resourcedEvents,
|
|
194
|
-
date,
|
|
195
|
-
timeZone,
|
|
196
|
-
forceInlineMultiDay
|
|
197
|
-
)}
|
|
198
|
-
today={date}
|
|
199
|
-
minuteHeight={minutesHeight}
|
|
200
|
-
startHour={startHour}
|
|
201
|
-
endHour={endHour}
|
|
202
|
-
step={step}
|
|
203
|
-
direction={direction}
|
|
204
|
-
timeZone={timeZone}
|
|
205
|
-
currentTime={currentTime}
|
|
206
|
-
showCurrentTimeBar={showCurrentTimeBar}
|
|
207
|
-
currentTimeBarColor={currentTimeBarColor}
|
|
208
|
-
/>
|
|
209
|
-
)}
|
|
210
|
-
<Cell
|
|
211
|
-
start={start}
|
|
212
|
-
end={end}
|
|
213
|
-
day={date}
|
|
214
|
-
height={cellHeight}
|
|
215
|
-
resourceKey={field}
|
|
216
|
-
resourceVal={resource ? resource[field] : null}
|
|
217
|
-
cellRenderer={cellRenderer}
|
|
218
|
-
/>
|
|
219
|
-
</span>
|
|
220
|
-
);
|
|
221
|
-
})}
|
|
222
|
-
</Fragment>
|
|
223
|
-
))}
|
|
224
|
-
</TableGrid>
|
|
225
|
-
</>
|
|
226
|
-
);
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
export default WeekTable;
|