@isma91/react-scheduler 4.0.0
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/.github/workflows/publish.yml +29 -0
- package/.github/workflows/tests.yml +35 -0
- package/.gitignore +32 -0
- package/.husky/pre-commit +2 -0
- package/.prettierignore +1 -0
- package/.prettierrc.json +7 -0
- package/.yarnrc.yml +1 -0
- package/LICENSE +24 -0
- package/README.md +172 -0
- package/dist/LICENSE +24 -0
- package/dist/README.md +172 -0
- package/dist/SchedulerComponent.d.ts +3 -0
- package/dist/components/common/Cell.d.ts +13 -0
- package/dist/components/common/LocaleArrow.d.ts +8 -0
- package/dist/components/common/ResourceHeader.d.ts +6 -0
- package/dist/components/common/Tabs.d.ts +16 -0
- package/dist/components/common/TodayTypo.d.ts +8 -0
- package/dist/components/common/WithResources.d.ts +6 -0
- package/dist/components/events/Actions.d.ts +8 -0
- package/dist/components/events/AgendaEventsList.d.ts +7 -0
- package/dist/components/events/CurrentTimeBar.d.ts +11 -0
- package/dist/components/events/EmptyAgenda.d.ts +2 -0
- package/dist/components/events/EventItem.d.ts +10 -0
- package/dist/components/events/EventItemPopover.d.ts +9 -0
- package/dist/components/events/MonthEvents.d.ts +13 -0
- package/dist/components/events/TodayEvents.d.ts +16 -0
- package/dist/components/hoc/DateProvider.d.ts +5 -0
- package/dist/components/inputs/DatePicker.d.ts +14 -0
- package/dist/components/inputs/Input.d.ts +19 -0
- package/dist/components/inputs/SelectInput.d.ts +22 -0
- package/dist/components/month/MonthTable.d.ts +8 -0
- package/dist/components/nav/DayDateBtn.d.ts +6 -0
- package/dist/components/nav/MonthDateBtn.d.ts +6 -0
- package/dist/components/nav/Navigation.d.ts +3 -0
- package/dist/components/nav/WeekDateBtn.d.ts +8 -0
- package/dist/components/week/WeekTable.d.ts +11 -0
- package/dist/helpers/constants.d.ts +4 -0
- package/dist/helpers/generals.d.ts +78 -0
- package/dist/hooks/useArrowDisable.d.ts +5 -0
- package/dist/hooks/useCellAttributes.d.ts +18 -0
- package/dist/hooks/useDragAttributes.d.ts +10 -0
- package/dist/hooks/useEventPermissions.d.ts +7 -0
- package/dist/hooks/useStore.d.ts +2 -0
- package/dist/hooks/useSyncScroll.d.ts +8 -0
- package/dist/hooks/useWindowResize.d.ts +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2853 -0
- package/dist/package.json +65 -0
- package/dist/positionManger/context.d.ts +14 -0
- package/dist/positionManger/provider.d.ts +5 -0
- package/dist/positionManger/usePosition.d.ts +4 -0
- package/dist/store/context.d.ts +2 -0
- package/dist/store/default.d.ts +245 -0
- package/dist/store/provider.d.ts +7 -0
- package/dist/store/types.d.ts +27 -0
- package/dist/styles/styles.d.ts +30 -0
- package/dist/types.d.ts +372 -0
- package/dist/views/Day.d.ts +2 -0
- package/dist/views/DayAgenda.d.ts +7 -0
- package/dist/views/Editor.d.ts +11 -0
- package/dist/views/Month.d.ts +2 -0
- package/dist/views/MonthAgenda.d.ts +7 -0
- package/dist/views/Week.d.ts +2 -0
- package/dist/views/WeekAgenda.d.ts +8 -0
- package/eslint.config.js +79 -0
- package/index.html +41 -0
- package/jest.config.ts +194 -0
- package/package.json +137 -0
- package/public/favicon.ico +0 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/scripts/post-pack.js +34 -0
- package/src/App.tsx +25 -0
- package/src/Page1.tsx +67 -0
- package/src/events.tsx +227 -0
- package/src/index.tsx +21 -0
- package/src/lib/SchedulerComponent.tsx +78 -0
- package/src/lib/__tests__/index.test.tsx +24 -0
- package/src/lib/components/common/Cell.tsx +52 -0
- package/src/lib/components/common/LocaleArrow.tsx +38 -0
- package/src/lib/components/common/ResourceHeader.tsx +73 -0
- package/src/lib/components/common/Tabs.tsx +119 -0
- package/src/lib/components/common/TodayTypo.tsx +44 -0
- package/src/lib/components/common/WithResources.tsx +98 -0
- package/src/lib/components/events/Actions.tsx +65 -0
- package/src/lib/components/events/AgendaEventsList.tsx +115 -0
- package/src/lib/components/events/CurrentTimeBar.tsx +59 -0
- package/src/lib/components/events/EmptyAgenda.tsx +27 -0
- package/src/lib/components/events/EventItem.tsx +180 -0
- package/src/lib/components/events/EventItemPopover.tsx +179 -0
- package/src/lib/components/events/MonthEvents.tsx +141 -0
- package/src/lib/components/events/TodayEvents.tsx +99 -0
- package/src/lib/components/hoc/DateProvider.tsx +19 -0
- package/src/lib/components/inputs/DatePicker.tsx +95 -0
- package/src/lib/components/inputs/Input.tsx +113 -0
- package/src/lib/components/inputs/SelectInput.tsx +164 -0
- package/src/lib/components/month/MonthTable.tsx +207 -0
- package/src/lib/components/nav/DayDateBtn.tsx +77 -0
- package/src/lib/components/nav/MonthDateBtn.tsx +80 -0
- package/src/lib/components/nav/Navigation.tsx +201 -0
- package/src/lib/components/nav/WeekDateBtn.tsx +89 -0
- package/src/lib/components/week/WeekTable.tsx +229 -0
- package/src/lib/helpers/constants.ts +4 -0
- package/src/lib/helpers/generals.tsx +354 -0
- package/src/lib/hooks/useArrowDisable.ts +26 -0
- package/src/lib/hooks/useCellAttributes.ts +67 -0
- package/src/lib/hooks/useDragAttributes.ts +31 -0
- package/src/lib/hooks/useEventPermissions.ts +42 -0
- package/src/lib/hooks/useStore.ts +8 -0
- package/src/lib/hooks/useSyncScroll.ts +31 -0
- package/src/lib/hooks/useWindowResize.ts +37 -0
- package/src/lib/index.tsx +14 -0
- package/src/lib/positionManger/context.ts +14 -0
- package/src/lib/positionManger/provider.tsx +113 -0
- package/src/lib/positionManger/usePosition.ts +8 -0
- package/src/lib/store/context.ts +5 -0
- package/src/lib/store/default.ts +157 -0
- package/src/lib/store/provider.tsx +211 -0
- package/src/lib/store/types.ts +33 -0
- package/src/lib/styles/styles.ts +256 -0
- package/src/lib/types.ts +423 -0
- package/src/lib/views/Day.tsx +265 -0
- package/src/lib/views/DayAgenda.tsx +57 -0
- package/src/lib/views/Editor.tsx +258 -0
- package/src/lib/views/Month.tsx +82 -0
- package/src/lib/views/MonthAgenda.tsx +84 -0
- package/src/lib/views/Week.tsx +92 -0
- package/src/lib/views/WeekAgenda.tsx +81 -0
- package/src/vite-env.d.ts +3 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +27 -0
- package/vite.config.js +40 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { Paper, alpha, styled } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
export const Wrapper = styled("div")<{ dialog: number }>(({ theme, dialog }) => ({
|
|
4
|
+
position: "relative",
|
|
5
|
+
"& .rs__table_loading": {
|
|
6
|
+
position: "absolute",
|
|
7
|
+
left: 0,
|
|
8
|
+
right: 0,
|
|
9
|
+
top: 0,
|
|
10
|
+
bottom: 0,
|
|
11
|
+
zIndex: 999999,
|
|
12
|
+
"& .rs__table_loading_internal": {
|
|
13
|
+
background: dialog ? "" : alpha(theme.palette.background.paper, 0.4),
|
|
14
|
+
height: "100%",
|
|
15
|
+
"& > span": {
|
|
16
|
+
display: "flex",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
justifyContent: "center",
|
|
19
|
+
height: "100%",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
"& >span": {
|
|
22
|
+
marginBottom: 15,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
export const Table = styled("div")<{ resource_count: number }>(({ resource_count }) => ({
|
|
30
|
+
position: "relative",
|
|
31
|
+
display: "flex",
|
|
32
|
+
flexDirection: resource_count > 1 ? "row" : "column",
|
|
33
|
+
width: "100%",
|
|
34
|
+
boxSizing: "content-box",
|
|
35
|
+
"& > div": {
|
|
36
|
+
flexShrink: 0,
|
|
37
|
+
flexGrow: 1,
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
export const NavigationDiv = styled(Paper)<{ sticky?: string; offset?: number }>(
|
|
42
|
+
({ sticky = "0", offset = 0 }) => ({
|
|
43
|
+
display: "flex",
|
|
44
|
+
justifyContent: "space-between",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
position: sticky === "1" ? "sticky" : "relative",
|
|
47
|
+
top: sticky === "1" ? offset : undefined,
|
|
48
|
+
zIndex: sticky === "1" ? 999 : undefined,
|
|
49
|
+
boxShadow: "none",
|
|
50
|
+
padding: "2px 0",
|
|
51
|
+
"& > .rs__view_navigator": {
|
|
52
|
+
display: "flex",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
export const AgendaDiv = styled("div")<{ stickyOffset?: number; stickyHeight?: number }>(
|
|
59
|
+
({ theme, stickyOffset = 0, stickyHeight = 40 }) => ({
|
|
60
|
+
borderStyle: "solid",
|
|
61
|
+
borderColor: theme.palette.grey[300],
|
|
62
|
+
borderWidth: "1px 1px 0 0",
|
|
63
|
+
"& > .rs__agenda_row": {
|
|
64
|
+
display: "flex",
|
|
65
|
+
"& >.rs__agenda__cell": {
|
|
66
|
+
padding: 4,
|
|
67
|
+
width: "100%",
|
|
68
|
+
maxWidth: 60,
|
|
69
|
+
"& > .MuiTypography-root": {
|
|
70
|
+
position: "sticky",
|
|
71
|
+
top: stickyOffset + stickyHeight,
|
|
72
|
+
"&.rs__hover__op": {
|
|
73
|
+
cursor: "pointer",
|
|
74
|
+
"&:hover": {
|
|
75
|
+
opacity: 0.7,
|
|
76
|
+
textDecoration: "underline",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
"& .rs__cell": {
|
|
82
|
+
borderStyle: "solid",
|
|
83
|
+
borderColor: theme.palette.grey[300],
|
|
84
|
+
borderWidth: "0 0 1px 1px",
|
|
85
|
+
},
|
|
86
|
+
"& > .rs__agenda_items": {
|
|
87
|
+
flexGrow: 1,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
export const TableGrid = styled("div")<{
|
|
94
|
+
days: number;
|
|
95
|
+
sticky?: string;
|
|
96
|
+
stickyNavigation?: boolean;
|
|
97
|
+
stickyOffset?: number;
|
|
98
|
+
stickyHeight?: number;
|
|
99
|
+
indent?: string;
|
|
100
|
+
}>(
|
|
101
|
+
({
|
|
102
|
+
days,
|
|
103
|
+
sticky = "0",
|
|
104
|
+
stickyNavigation,
|
|
105
|
+
indent = "1",
|
|
106
|
+
theme,
|
|
107
|
+
stickyOffset = 0,
|
|
108
|
+
stickyHeight = 40,
|
|
109
|
+
}) => ({
|
|
110
|
+
display: "grid",
|
|
111
|
+
gridTemplateColumns: +indent > 0 ? `10% repeat(${days}, 1fr)` : `repeat(${days}, 1fr)`,
|
|
112
|
+
overflowX: "auto",
|
|
113
|
+
overflowY: "hidden",
|
|
114
|
+
position: sticky === "1" ? "sticky" : "relative",
|
|
115
|
+
top: sticky === "1" ? (stickyNavigation ? stickyOffset + stickyHeight : 0) : undefined,
|
|
116
|
+
zIndex: sticky === "1" ? 99 : undefined,
|
|
117
|
+
[theme.breakpoints.down("sm")]: {
|
|
118
|
+
gridTemplateColumns: +indent > 0 ? `30px repeat(${days}, 1fr)` : "",
|
|
119
|
+
},
|
|
120
|
+
borderStyle: "solid",
|
|
121
|
+
borderColor: theme.palette.grey[300],
|
|
122
|
+
borderWidth: "0 0 0 1px",
|
|
123
|
+
"&:first-of-type": {
|
|
124
|
+
borderWidth: "1px 0 0 1px",
|
|
125
|
+
},
|
|
126
|
+
"&:last-of-type": {
|
|
127
|
+
borderWidth: "0 0 1px 1px",
|
|
128
|
+
},
|
|
129
|
+
"& .rs__cell": {
|
|
130
|
+
background: theme.palette.background.paper,
|
|
131
|
+
position: "relative",
|
|
132
|
+
borderStyle: "solid",
|
|
133
|
+
borderColor: theme.palette.grey[300],
|
|
134
|
+
borderWidth: "0 1px 1px 0",
|
|
135
|
+
"&.rs__header": {
|
|
136
|
+
"& > :first-of-type": {
|
|
137
|
+
padding: "2px 5px",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
"&.rs__header__center": {
|
|
141
|
+
padding: "6px 0px",
|
|
142
|
+
},
|
|
143
|
+
"&.rs__time": {
|
|
144
|
+
display: "flex",
|
|
145
|
+
alignItems: "center",
|
|
146
|
+
justifyContent: "center",
|
|
147
|
+
position: "sticky",
|
|
148
|
+
left: 0,
|
|
149
|
+
zIndex: 99,
|
|
150
|
+
[theme.breakpoints.down("sm")]: {
|
|
151
|
+
writingMode: "vertical-rl",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
"& > button": {
|
|
155
|
+
width: "100%",
|
|
156
|
+
height: "100%",
|
|
157
|
+
borderRadius: 0,
|
|
158
|
+
cursor: "pointer",
|
|
159
|
+
"&:hover": {
|
|
160
|
+
background: alpha(theme.palette.primary.main, 0.1),
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
"& .rs__event__item": {
|
|
164
|
+
position: "absolute",
|
|
165
|
+
zIndex: 1,
|
|
166
|
+
},
|
|
167
|
+
"& .rs__multi_day": {
|
|
168
|
+
position: "absolute",
|
|
169
|
+
zIndex: 1,
|
|
170
|
+
textOverflow: "ellipsis",
|
|
171
|
+
},
|
|
172
|
+
"& .rs__block_col": {
|
|
173
|
+
display: "block",
|
|
174
|
+
position: "relative",
|
|
175
|
+
},
|
|
176
|
+
"& .rs__hover__op": {
|
|
177
|
+
cursor: "pointer",
|
|
178
|
+
"&:hover": {
|
|
179
|
+
opacity: 0.7,
|
|
180
|
+
textDecoration: "underline",
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
"&:not(.rs__time)": {
|
|
184
|
+
minWidth: 65,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
})
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
export const EventItemPaper = styled(Paper)<{ disabled?: boolean }>(({ disabled }) => ({
|
|
191
|
+
width: "99.5%",
|
|
192
|
+
height: "100%",
|
|
193
|
+
display: "block",
|
|
194
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
195
|
+
overflow: "hidden",
|
|
196
|
+
"& .MuiButtonBase-root": {
|
|
197
|
+
width: "100%",
|
|
198
|
+
height: "100%",
|
|
199
|
+
display: "block",
|
|
200
|
+
textAlign: "left",
|
|
201
|
+
"& > div": {
|
|
202
|
+
height: "100%",
|
|
203
|
+
// padding: "2px 4px",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
}));
|
|
207
|
+
|
|
208
|
+
export const PopperInner = styled("div")(({ theme }) => ({
|
|
209
|
+
maxWidth: "100%",
|
|
210
|
+
width: 400,
|
|
211
|
+
"& > div": {
|
|
212
|
+
padding: "5px 10px",
|
|
213
|
+
"& .rs__popper_actions": {
|
|
214
|
+
display: "flex",
|
|
215
|
+
alignItems: "center",
|
|
216
|
+
justifyContent: "space-between",
|
|
217
|
+
"& .MuiIconButton-root": {
|
|
218
|
+
color: theme.palette.primary.contrastText,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
}));
|
|
223
|
+
|
|
224
|
+
export const EventActions = styled("div")(({ theme }) => ({
|
|
225
|
+
display: "inherit",
|
|
226
|
+
"& .MuiIconButton-root": {
|
|
227
|
+
color: theme.palette.primary.contrastText,
|
|
228
|
+
},
|
|
229
|
+
"& .MuiButton-root": {
|
|
230
|
+
"&.delete": {
|
|
231
|
+
color: theme.palette.error.main,
|
|
232
|
+
},
|
|
233
|
+
"&.cancel": {
|
|
234
|
+
color: theme.palette.action.disabled,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
}));
|
|
238
|
+
|
|
239
|
+
export const TimeIndicatorBar = styled("div")<{ color?: string }>(({ theme, color }) => ({
|
|
240
|
+
position: "absolute",
|
|
241
|
+
zIndex: 9,
|
|
242
|
+
width: "100%",
|
|
243
|
+
display: "flex",
|
|
244
|
+
"& > div:first-of-type": {
|
|
245
|
+
height: 12,
|
|
246
|
+
width: 12,
|
|
247
|
+
borderRadius: "50%",
|
|
248
|
+
background: color || theme.palette.error.light,
|
|
249
|
+
marginLeft: -6,
|
|
250
|
+
marginTop: -5,
|
|
251
|
+
},
|
|
252
|
+
"& > div:last-of-type": {
|
|
253
|
+
borderTop: `solid 2px ${color || theme.palette.error.light}`,
|
|
254
|
+
width: "100%",
|
|
255
|
+
},
|
|
256
|
+
}));
|
package/src/lib/types.ts
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { DialogProps, GridSize } from "@mui/material";
|
|
2
|
+
import { DateCalendarProps } from "@mui/x-date-pickers";
|
|
3
|
+
import { Locale } from "date-fns";
|
|
4
|
+
import { DragEvent } from "react";
|
|
5
|
+
import { SelectOption } from "./components/inputs/SelectInput";
|
|
6
|
+
import { View } from "./components/nav/Navigation";
|
|
7
|
+
import { Store } from "./store/types";
|
|
8
|
+
import { StateItem } from "./views/Editor";
|
|
9
|
+
import type { RRule } from "rrule";
|
|
10
|
+
|
|
11
|
+
export type DayHours =
|
|
12
|
+
| 0
|
|
13
|
+
| 1
|
|
14
|
+
| 2
|
|
15
|
+
| 3
|
|
16
|
+
| 4
|
|
17
|
+
| 5
|
|
18
|
+
| 6
|
|
19
|
+
| 7
|
|
20
|
+
| 8
|
|
21
|
+
| 9
|
|
22
|
+
| 10
|
|
23
|
+
| 11
|
|
24
|
+
| 12
|
|
25
|
+
| 13
|
|
26
|
+
| 14
|
|
27
|
+
| 15
|
|
28
|
+
| 16
|
|
29
|
+
| 17
|
|
30
|
+
| 18
|
|
31
|
+
| 19
|
|
32
|
+
| 20
|
|
33
|
+
| 21
|
|
34
|
+
| 22
|
|
35
|
+
| 23
|
|
36
|
+
| 24;
|
|
37
|
+
|
|
38
|
+
export type WeekDays = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
39
|
+
|
|
40
|
+
interface CommonWeekViewProps {
|
|
41
|
+
weekDays: WeekDays[];
|
|
42
|
+
weekStartOn: WeekDays;
|
|
43
|
+
disableGoToDay?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface CommonViewProps {
|
|
47
|
+
startHour: DayHours;
|
|
48
|
+
endHour: DayHours;
|
|
49
|
+
cellRenderer?(props: CellRenderedProps): React.ReactNode;
|
|
50
|
+
headRenderer?(props: {
|
|
51
|
+
day: Date;
|
|
52
|
+
events: ProcessedEvent[];
|
|
53
|
+
resource?: DefaultResource;
|
|
54
|
+
}): React.ReactNode;
|
|
55
|
+
navigation?: boolean;
|
|
56
|
+
step: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface MonthProps extends CommonWeekViewProps, CommonViewProps {}
|
|
60
|
+
|
|
61
|
+
export interface WeekProps extends CommonWeekViewProps, CommonViewProps {
|
|
62
|
+
hourRenderer?(hour: string): React.ReactNode;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface DayProps extends CommonViewProps {
|
|
66
|
+
hourRenderer?(hour: string): React.ReactNode;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface CellRenderedProps {
|
|
70
|
+
day: Date;
|
|
71
|
+
start: Date;
|
|
72
|
+
end: Date;
|
|
73
|
+
height: number;
|
|
74
|
+
onClick(): void;
|
|
75
|
+
onDragOver(e: DragEvent<HTMLButtonElement>): void;
|
|
76
|
+
onDragEnter(e: DragEvent<HTMLButtonElement>): void;
|
|
77
|
+
onDragLeave(e: DragEvent<HTMLButtonElement>): void;
|
|
78
|
+
onDrop(e: DragEvent<HTMLButtonElement>): void;
|
|
79
|
+
}
|
|
80
|
+
interface CalendarEvent {
|
|
81
|
+
event_id: number | string;
|
|
82
|
+
title: React.ReactNode;
|
|
83
|
+
subtitle?: React.ReactNode;
|
|
84
|
+
start: Date;
|
|
85
|
+
end: Date;
|
|
86
|
+
recurring?: RRule;
|
|
87
|
+
disabled?: boolean;
|
|
88
|
+
color?: string;
|
|
89
|
+
textColor?: string;
|
|
90
|
+
editable?: boolean;
|
|
91
|
+
deletable?: boolean;
|
|
92
|
+
draggable?: boolean;
|
|
93
|
+
allDay?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @default " "
|
|
96
|
+
* passed as a children to mui <Avatar /> component
|
|
97
|
+
*/
|
|
98
|
+
agendaAvatar?: React.ReactElement | string;
|
|
99
|
+
/** @internal Original start date before segment clipping */
|
|
100
|
+
_originalStart?: Date;
|
|
101
|
+
/** @internal Original end date before segment clipping */
|
|
102
|
+
_originalEnd?: Date;
|
|
103
|
+
/** @internal Segment continues from previous day */
|
|
104
|
+
_hasPrev?: boolean;
|
|
105
|
+
/** @internal Segment continues to next day */
|
|
106
|
+
_hasNext?: boolean;
|
|
107
|
+
}
|
|
108
|
+
export interface Translations {
|
|
109
|
+
navigation: Record<View, string> & { today: string; agenda: string };
|
|
110
|
+
form: {
|
|
111
|
+
addTitle: string;
|
|
112
|
+
editTitle: string;
|
|
113
|
+
confirm: string;
|
|
114
|
+
delete: string;
|
|
115
|
+
cancel: string;
|
|
116
|
+
};
|
|
117
|
+
event: Record<string, string> & {
|
|
118
|
+
title: string;
|
|
119
|
+
subtitle: string;
|
|
120
|
+
start: string;
|
|
121
|
+
end: string;
|
|
122
|
+
allDay: string;
|
|
123
|
+
};
|
|
124
|
+
validation?: {
|
|
125
|
+
required?: string;
|
|
126
|
+
invalidEmail?: string;
|
|
127
|
+
onlyNumbers?: string;
|
|
128
|
+
min?: string | ((min: number) => string);
|
|
129
|
+
max?: string | ((max: number) => string);
|
|
130
|
+
};
|
|
131
|
+
moreEvents: string;
|
|
132
|
+
noDataToDisplay: string;
|
|
133
|
+
loading: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type InputTypes = "input" | "date" | "select" | "hidden";
|
|
137
|
+
|
|
138
|
+
export interface EventRendererProps extends Pick<
|
|
139
|
+
React.HTMLAttributes<HTMLElement>,
|
|
140
|
+
"draggable" | "onDragStart" | "onDragEnd" | "onDragOver" | "onDragEnter" | "onClick"
|
|
141
|
+
> {
|
|
142
|
+
event: ProcessedEvent;
|
|
143
|
+
}
|
|
144
|
+
export interface FieldInputProps {
|
|
145
|
+
/** Available to all InputTypes */
|
|
146
|
+
label?: string;
|
|
147
|
+
/** Available to all InputTypes */
|
|
148
|
+
placeholder?: string;
|
|
149
|
+
/** Available to all InputTypes
|
|
150
|
+
* @default false
|
|
151
|
+
*/
|
|
152
|
+
required?: boolean;
|
|
153
|
+
/** Available to all InputTypes
|
|
154
|
+
* @default "outline"
|
|
155
|
+
*/
|
|
156
|
+
variant?: "standard" | "filled" | "outlined";
|
|
157
|
+
/** Available to all InputTypes */
|
|
158
|
+
disabled?: boolean;
|
|
159
|
+
/** Available when @input="text" ONLY - Minimum length */
|
|
160
|
+
min?: number;
|
|
161
|
+
/** Available when @input="text" ONLY - Maximum length */
|
|
162
|
+
max?: number;
|
|
163
|
+
/** Available when @input="text" ONLY - Apply email Regex */
|
|
164
|
+
email?: boolean;
|
|
165
|
+
/** Available when @input="text" ONLY - Only numbers(int/float) allowed */
|
|
166
|
+
decimal?: boolean;
|
|
167
|
+
/** Available when @input="text" ONLY - Allow Multiline input. Use @rows property to set initial rows height */
|
|
168
|
+
multiline?: boolean;
|
|
169
|
+
/** Available when @input="text" ONLY - initial rows height*/
|
|
170
|
+
rows?: number;
|
|
171
|
+
/** Available when @input="date" ONLY
|
|
172
|
+
* @default "datetime"
|
|
173
|
+
*/
|
|
174
|
+
type?: "date" | "datetime";
|
|
175
|
+
/** Available when @input="select" ONLY - Multi-Select input style.
|
|
176
|
+
* if you use "default" property with this, make sure your "default" property is an instance of Array
|
|
177
|
+
*/
|
|
178
|
+
multiple?: "chips" | "default";
|
|
179
|
+
/** Available when @input="select" ONLY - display loading spinner instead of expand arrow */
|
|
180
|
+
loading?: boolean;
|
|
181
|
+
/** Available when @input="select" ONLY - Custom error message */
|
|
182
|
+
errMsg?: string;
|
|
183
|
+
|
|
184
|
+
/* Used for Grid alignment in a single row md | sm | xs */
|
|
185
|
+
md?: GridSize;
|
|
186
|
+
/* Used for Grid alignment in a single row md | sm | xs */
|
|
187
|
+
sm?: GridSize;
|
|
188
|
+
/* Used for Grid alignment in a single row md | sm | xs */
|
|
189
|
+
xs?: GridSize;
|
|
190
|
+
}
|
|
191
|
+
export interface FieldProps {
|
|
192
|
+
name: string;
|
|
193
|
+
type: InputTypes;
|
|
194
|
+
/** Required for type="select" */
|
|
195
|
+
options?: Array<SelectOption>;
|
|
196
|
+
default?: string | number | Date | any;
|
|
197
|
+
config?: FieldInputProps;
|
|
198
|
+
}
|
|
199
|
+
export type ProcessedEvent = CalendarEvent & Record<string, any>;
|
|
200
|
+
export type EventActions = "create" | "edit";
|
|
201
|
+
export type RemoteQuery = {
|
|
202
|
+
start: Date;
|
|
203
|
+
end: Date;
|
|
204
|
+
view: "day" | "week" | "month";
|
|
205
|
+
};
|
|
206
|
+
export type DefaultResource = {
|
|
207
|
+
assignee?: string | number;
|
|
208
|
+
text?: string;
|
|
209
|
+
subtext?: string;
|
|
210
|
+
avatar?: string;
|
|
211
|
+
color?: string;
|
|
212
|
+
} & Record<string, any>;
|
|
213
|
+
export type ResourceFields = {
|
|
214
|
+
idField: string;
|
|
215
|
+
textField: string;
|
|
216
|
+
subTextField?: string;
|
|
217
|
+
avatarField?: string;
|
|
218
|
+
colorField?: string;
|
|
219
|
+
} & Record<string, string>;
|
|
220
|
+
|
|
221
|
+
export interface SchedulerHelpers {
|
|
222
|
+
state: Record<string, StateItem>;
|
|
223
|
+
close(): void;
|
|
224
|
+
loading(status: boolean): void;
|
|
225
|
+
edited?: ProcessedEvent;
|
|
226
|
+
onConfirm(event: ProcessedEvent | ProcessedEvent[], action: EventActions): void;
|
|
227
|
+
[resourceKey: string]: unknown;
|
|
228
|
+
}
|
|
229
|
+
export interface SchedulerProps {
|
|
230
|
+
/**Min height of table
|
|
231
|
+
* @default 600
|
|
232
|
+
*/
|
|
233
|
+
height: number;
|
|
234
|
+
/** Initial view to load */
|
|
235
|
+
view: View;
|
|
236
|
+
/**Activate Agenda view */
|
|
237
|
+
agenda?: boolean;
|
|
238
|
+
/** if true, day rows without event will be shown */
|
|
239
|
+
alwaysShowAgendaDays?: boolean;
|
|
240
|
+
/**Month view settings */
|
|
241
|
+
month: MonthProps | null;
|
|
242
|
+
/**Week view settings */
|
|
243
|
+
week: WeekProps | null;
|
|
244
|
+
/**Day view settings */
|
|
245
|
+
day: DayProps | null;
|
|
246
|
+
/**Initial date selected */
|
|
247
|
+
selectedDate: Date;
|
|
248
|
+
/** Show/Hide date navigation */
|
|
249
|
+
navigation?: boolean;
|
|
250
|
+
/** Show/Hide view navigator */
|
|
251
|
+
disableViewNavigator?: boolean;
|
|
252
|
+
/** */
|
|
253
|
+
navigationPickerProps?: Partial<
|
|
254
|
+
Omit<
|
|
255
|
+
DateCalendarProps,
|
|
256
|
+
"open" | "onClose" | "openTo" | "views" | "value" | "readOnly" | "onChange"
|
|
257
|
+
>
|
|
258
|
+
>;
|
|
259
|
+
/**Events to display */
|
|
260
|
+
events: ProcessedEvent[];
|
|
261
|
+
/** Custom event render method */
|
|
262
|
+
eventRenderer?: (props: EventRendererProps) => React.ReactNode | null;
|
|
263
|
+
/**Async function to load remote data with current view data. */
|
|
264
|
+
getRemoteEvents?(params: RemoteQuery): Promise<ProcessedEvent[] | void>;
|
|
265
|
+
/**Custom additional fields with it's settings */
|
|
266
|
+
fields: FieldProps[];
|
|
267
|
+
/**Table loading state */
|
|
268
|
+
loading?: boolean;
|
|
269
|
+
/** Custom loading component */
|
|
270
|
+
loadingComponent?: React.ReactNode;
|
|
271
|
+
/**Async function triggered when add/edit event */
|
|
272
|
+
onConfirm?(event: ProcessedEvent, action: EventActions): Promise<ProcessedEvent>;
|
|
273
|
+
/**Async function triggered when delete event */
|
|
274
|
+
onDelete?(deletedId: string | number): Promise<string | number | void>;
|
|
275
|
+
/**Override editor modal */
|
|
276
|
+
customEditor?(scheduler: SchedulerHelpers): React.ReactNode;
|
|
277
|
+
/** Custom viewer/popper component. If used, `viewerExtraComponent` & `viewerTitleComponent` will be ignored */
|
|
278
|
+
customViewer?(event: ProcessedEvent, close: () => void): React.ReactNode;
|
|
279
|
+
/**Additional component in event viewer popper */
|
|
280
|
+
viewerExtraComponent?:
|
|
281
|
+
| React.ReactNode
|
|
282
|
+
| ((fields: FieldProps[], event: ProcessedEvent) => React.ReactNode);
|
|
283
|
+
/**Override viewer title component */
|
|
284
|
+
viewerTitleComponent?(event: ProcessedEvent): React.ReactNode;
|
|
285
|
+
/**Override viewer subtitle component */
|
|
286
|
+
viewerSubtitleComponent?(event: ProcessedEvent): React.ReactNode;
|
|
287
|
+
/** if true, the viewer popover will be disabled globally */
|
|
288
|
+
disableViewer?: boolean;
|
|
289
|
+
/**Resources array to split event views with resources */
|
|
290
|
+
resources: DefaultResource[];
|
|
291
|
+
/**Map resources fields */
|
|
292
|
+
resourceFields: ResourceFields;
|
|
293
|
+
/**Override header component of resource */
|
|
294
|
+
resourceHeaderComponent?(resource: DefaultResource): React.ReactNode;
|
|
295
|
+
/** Triggered when resource tabs changes */
|
|
296
|
+
onResourceChange?(resource: DefaultResource): void;
|
|
297
|
+
/**Resource header view mode
|
|
298
|
+
* @default "default"
|
|
299
|
+
*/
|
|
300
|
+
resourceViewMode: "default" | "vertical" | "tabs";
|
|
301
|
+
/**Direction of table */
|
|
302
|
+
direction: "rtl" | "ltr";
|
|
303
|
+
/**Editor dialog maxWith
|
|
304
|
+
* @default "md"
|
|
305
|
+
*/
|
|
306
|
+
dialogMaxWidth: DialogProps["maxWidth"];
|
|
307
|
+
/**
|
|
308
|
+
* date-fns Locale object
|
|
309
|
+
*/
|
|
310
|
+
locale: Locale;
|
|
311
|
+
/**
|
|
312
|
+
* Localization
|
|
313
|
+
*/
|
|
314
|
+
translations: Translations;
|
|
315
|
+
/**
|
|
316
|
+
* Hour Format
|
|
317
|
+
*/
|
|
318
|
+
hourFormat: "12" | "24";
|
|
319
|
+
/**
|
|
320
|
+
* Time zone IANA ID: https://data.iana.org/time-zones/releases
|
|
321
|
+
*/
|
|
322
|
+
timeZone?: string;
|
|
323
|
+
/**
|
|
324
|
+
* Triggered when event is dropped on time slot.
|
|
325
|
+
*/
|
|
326
|
+
onEventDrop?(
|
|
327
|
+
event: DragEvent<HTMLButtonElement>,
|
|
328
|
+
droppedOn: Date,
|
|
329
|
+
updatedEvent: ProcessedEvent,
|
|
330
|
+
originalEvent: ProcessedEvent
|
|
331
|
+
): Promise<ProcessedEvent | void>;
|
|
332
|
+
/**
|
|
333
|
+
*
|
|
334
|
+
*/
|
|
335
|
+
onEventClick?(event: ProcessedEvent): void;
|
|
336
|
+
/**
|
|
337
|
+
* Triggered when an event item is being edited from the popover
|
|
338
|
+
*/
|
|
339
|
+
onEventEdit?(event: ProcessedEvent): void;
|
|
340
|
+
/**
|
|
341
|
+
* If event is deletable, applied to all events globally, overridden by event specific deletable prop
|
|
342
|
+
* @default true
|
|
343
|
+
*/
|
|
344
|
+
deletable?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* If calendar is editable, applied to all events/cells globally, overridden by event specific editable prop
|
|
347
|
+
* @default true
|
|
348
|
+
*/
|
|
349
|
+
editable?: boolean;
|
|
350
|
+
/**
|
|
351
|
+
* If event is draggable, applied to all events globally, overridden by event specific draggable prop
|
|
352
|
+
* @default true
|
|
353
|
+
*/
|
|
354
|
+
draggable?: boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Triggered when the `selectedDate` prop changes by navigation date picker or `today` button.
|
|
357
|
+
*/
|
|
358
|
+
onSelectedDateChange?(date: Date): void;
|
|
359
|
+
/**
|
|
360
|
+
* Triggered when navigation view changes.
|
|
361
|
+
*/
|
|
362
|
+
onViewChange?(view: View, agenda?: boolean): void;
|
|
363
|
+
/**
|
|
364
|
+
* If true, the navigation controller bar will be sticky
|
|
365
|
+
*/
|
|
366
|
+
stickyNavigation?: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Overrides the default behavior of more events button
|
|
369
|
+
*/
|
|
370
|
+
onClickMore?(date: Date, gotToDay: (date: Date) => void): void;
|
|
371
|
+
/**
|
|
372
|
+
*
|
|
373
|
+
*/
|
|
374
|
+
onCellClick?(start: Date, end: Date, resourceKey?: string, resourceVal?: string | number): void;
|
|
375
|
+
/**
|
|
376
|
+
* Custom content to display in the scheduler header.
|
|
377
|
+
* Wrap with useCallback if using state/props to avoid re-renders.
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* const header = useCallback(() => <Button>{state}</Button>, [state]);
|
|
381
|
+
*/
|
|
382
|
+
customHeaderContent?: () => React.ReactNode;
|
|
383
|
+
/**
|
|
384
|
+
* Top offset when sticky navigation is enabled (in pixels).
|
|
385
|
+
* @default 0
|
|
386
|
+
*/
|
|
387
|
+
stickyNavigationOffset?: number;
|
|
388
|
+
/**
|
|
389
|
+
* Height of the sticky navigation header in pixels.
|
|
390
|
+
* Used to calculate offset for sticky elements below the header.
|
|
391
|
+
* @default 40
|
|
392
|
+
*/
|
|
393
|
+
stickyNavigationHeight?: number;
|
|
394
|
+
/**
|
|
395
|
+
* Override the current time used for the red indicator bar.
|
|
396
|
+
* Useful when working with different timezones or for testing.
|
|
397
|
+
*/
|
|
398
|
+
currentTime?: Date;
|
|
399
|
+
/**
|
|
400
|
+
* Show/hide the current time indicator bar.
|
|
401
|
+
* @default true
|
|
402
|
+
*/
|
|
403
|
+
showCurrentTimeBar?: boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Color of the current time indicator bar.
|
|
406
|
+
* @default theme.palette.error.light (red)
|
|
407
|
+
*/
|
|
408
|
+
currentTimeBarColor?: string;
|
|
409
|
+
/**
|
|
410
|
+
* When true, events spanning multiple days with allDay: false
|
|
411
|
+
* will be displayed in the time grid instead of the all-day header.
|
|
412
|
+
* Events will be split visually at midnight boundaries.
|
|
413
|
+
* @default false
|
|
414
|
+
*/
|
|
415
|
+
forceInlineMultiDay?: boolean;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export interface SchedulerRef {
|
|
419
|
+
el: HTMLDivElement;
|
|
420
|
+
scheduler: Store;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export interface Scheduler extends Partial<SchedulerProps> {}
|