react-big-schedule 8.0.0 → 9.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/README.md +20 -1129
- package/dist/calendar/Calendar.d.ts +28 -0
- package/dist/calendar/Calendar.js +95 -0
- package/dist/calendar/Toolbar.d.ts +18 -0
- package/dist/calendar/Toolbar.js +6 -0
- package/dist/calendar/recurrence.check.d.ts +1 -0
- package/dist/calendar/recurrence.check.js +49 -0
- package/dist/calendar/recurrence.d.ts +8 -0
- package/dist/calendar/recurrence.js +90 -0
- package/dist/calendar/timezone.d.ts +6 -0
- package/dist/calendar/timezone.js +14 -0
- package/dist/calendar/types.d.ts +187 -0
- package/dist/calendar/types.js +1 -0
- package/dist/calendar/useEventSources.d.ts +11 -0
- package/dist/calendar/useEventSources.js +89 -0
- package/dist/calendar/useRecurrence.d.ts +4 -0
- package/dist/calendar/useRecurrence.js +15 -0
- package/dist/calendar/utils.d.ts +38 -0
- package/dist/calendar/utils.js +143 -0
- package/dist/calendar/views/DayGridView.d.ts +3 -0
- package/dist/calendar/views/DayGridView.js +375 -0
- package/dist/calendar/views/ListView.d.ts +4 -0
- package/dist/calendar/views/ListView.js +56 -0
- package/dist/calendar/views/MultiMonthView.d.ts +4 -0
- package/dist/calendar/views/MultiMonthView.js +36 -0
- package/dist/calendar/views/TimeGridView.d.ts +3 -0
- package/dist/calendar/views/TimeGridView.js +334 -0
- package/dist/calendar/views/daygrid/DayCell.d.ts +19 -0
- package/dist/calendar/views/daygrid/DayCell.js +17 -0
- package/dist/calendar/views/daygrid/EventChip.d.ts +19 -0
- package/dist/calendar/views/daygrid/EventChip.js +40 -0
- package/dist/calendar/views/daygrid/layout.d.ts +30 -0
- package/dist/calendar/views/daygrid/layout.js +63 -0
- package/dist/calendar/views/list/bucket.d.ts +8 -0
- package/dist/calendar/views/list/bucket.js +37 -0
- package/dist/calendar/views/multimonth/Cell.d.ts +12 -0
- package/dist/calendar/views/multimonth/Cell.js +44 -0
- package/dist/calendar/views/multimonth/Continuous.d.ts +8 -0
- package/dist/calendar/views/multimonth/Continuous.js +28 -0
- package/dist/calendar/views/multimonth/MonthGrid.d.ts +10 -0
- package/dist/calendar/views/multimonth/MonthGrid.js +36 -0
- package/dist/calendar/views/multimonth/shared.d.ts +27 -0
- package/dist/calendar/views/multimonth/shared.js +40 -0
- package/dist/calendar/views/timegrid/DayColumn.d.ts +49 -0
- package/dist/calendar/views/timegrid/DayColumn.js +86 -0
- package/dist/calendar/views/timegrid/model.d.ts +55 -0
- package/dist/calendar/views/timegrid/model.js +102 -0
- package/dist/components/AddMore.d.ts +13 -0
- package/dist/components/AddMore.js +9 -42
- package/dist/components/AddMorePopover.d.ts +13 -0
- package/dist/components/AddMorePopover.js +24 -95
- package/dist/components/AgendaEventItem.d.ts +10 -0
- package/dist/components/AgendaEventItem.js +33 -81
- package/dist/components/AgendaResourceEvents.d.ts +10 -0
- package/dist/components/AgendaResourceEvents.js +38 -90
- package/dist/components/AgendaView.d.ts +9 -0
- package/dist/components/AgendaView.js +10 -69
- package/dist/components/BodyView.d.ts +11 -0
- package/dist/components/BodyView.js +36 -67
- package/dist/components/DnDContext.d.ts +48 -0
- package/dist/components/DnDContext.js +200 -221
- package/dist/components/DnDSource.d.ts +49 -0
- package/dist/components/DnDSource.js +125 -120
- package/dist/components/EventItem.d.ts +41 -0
- package/dist/components/EventItem.js +585 -787
- package/dist/components/EventItemPopover.d.ts +12 -0
- package/dist/components/EventItemPopover.js +19 -143
- package/dist/components/HeaderView.d.ts +14 -0
- package/dist/components/HeaderView.js +123 -186
- package/dist/components/ResourceEvents.d.ts +54 -0
- package/dist/components/ResourceEvents.js +534 -703
- package/dist/components/ResourceView.d.ts +26 -0
- package/dist/components/ResourceView.js +64 -184
- package/dist/components/SchedulerData.d.ts +136 -0
- package/dist/components/SchedulerData.js +1296 -1226
- package/dist/components/SchedulerHeader.d.ts +25 -0
- package/dist/components/SchedulerHeader.js +50 -150
- package/dist/components/SelectedArea.d.ts +8 -0
- package/dist/components/SelectedArea.js +11 -26
- package/dist/components/Summary.d.ts +11 -0
- package/dist/components/Summary.js +21 -50
- package/dist/components/WrapperFun.d.ts +2 -0
- package/dist/components/WrapperFun.js +5 -10
- package/dist/components/index.d.ts +44 -0
- package/dist/components/index.js +428 -654
- package/dist/components/ui/Icons.d.ts +8 -0
- package/dist/components/ui/Icons.js +7 -0
- package/dist/components/ui/MiniCalendar.d.ts +9 -0
- package/dist/components/ui/MiniCalendar.js +17 -0
- package/dist/components/ui/Popover.d.ts +13 -0
- package/dist/components/ui/Popover.js +80 -0
- package/dist/config/default.d.ts +36 -0
- package/dist/config/default.js +17 -26
- package/dist/config/i18n.d.ts +27 -0
- package/dist/config/i18n.js +21 -37
- package/dist/config/scheduler.d.ts +12 -0
- package/dist/config/scheduler.js +126 -119
- package/dist/css/style.css +2 -316
- package/dist/helper/behaviors.d.ts +14 -0
- package/dist/helper/behaviors.js +75 -75
- package/dist/helper/utility.d.ts +26 -0
- package/dist/helper/utility.js +23 -30
- package/dist/index.d.ts +6 -477
- package/dist/index.js +4 -2
- package/dist/sample-data/sample1.d.ts +11 -0
- package/dist/sample-data/sample1.js +427 -372
- package/dist/types.d.ts +267 -0
- package/dist/types.js +1 -0
- package/package.json +35 -26
|
@@ -1,810 +1,608 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PropTypes } from 'prop-types';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { Component } from 'react';
|
|
4
3
|
import { useDrag } from 'react-dnd';
|
|
5
4
|
import { CellUnit, DATETIME_FORMAT, DnDTypes } from '../config/default';
|
|
6
5
|
import EventItemPopover from './EventItemPopover';
|
|
7
|
-
import
|
|
8
|
-
const stopDragHelper = ({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
result = date.format(DATETIME_FORMAT);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
resolve(result);
|
|
37
|
-
});
|
|
6
|
+
import Popover from './ui/Popover';
|
|
7
|
+
const stopDragHelper = ({ count, cellUnit, config, dragType, eventItem, localeDayjs, value, }) => {
|
|
8
|
+
const whileTrue = true;
|
|
9
|
+
let tCount = 0;
|
|
10
|
+
let i = 0;
|
|
11
|
+
let result = value;
|
|
12
|
+
return new Promise(resolve => {
|
|
13
|
+
if (count !== 0 && cellUnit !== CellUnit.Hour && config.displayWeekend === false) {
|
|
14
|
+
while (whileTrue) {
|
|
15
|
+
i = count > 0 ? i + 1 : i - 1;
|
|
16
|
+
const date = localeDayjs(new Date(eventItem[dragType === 'start' ? 'start' : 'end'])).add(i, 'days');
|
|
17
|
+
const dayOfWeek = date.day();
|
|
18
|
+
if (dayOfWeek !== 0 && dayOfWeek !== 6) {
|
|
19
|
+
tCount = count > 0 ? tCount + 1 : tCount - 1;
|
|
20
|
+
if (tCount === count) {
|
|
21
|
+
result = date.format(DATETIME_FORMAT);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
resolve(result);
|
|
28
|
+
});
|
|
38
29
|
};
|
|
39
|
-
const startResizable = ({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
30
|
+
const startResizable = ({ eventItem, isInPopover, schedulerData }) => schedulerData.config.startResizable === true &&
|
|
31
|
+
isInPopover === false &&
|
|
32
|
+
(eventItem.resizable === undefined || eventItem.resizable !== false) &&
|
|
33
|
+
(eventItem.startResizable === undefined || eventItem.startResizable !== false);
|
|
34
|
+
const endResizable = ({ eventItem, isInPopover, schedulerData }) => schedulerData.config.endResizable === true &&
|
|
35
|
+
isInPopover === false &&
|
|
36
|
+
(eventItem.resizable === undefined || eventItem.resizable !== false) &&
|
|
37
|
+
(eventItem.endResizable === undefined || eventItem.endResizable !== false);
|
|
38
|
+
// Resize handlers take the mouse/touch union (and may be async); DOM listeners are typed for plain Event.
|
|
39
|
+
const asListener = (fn) => fn;
|
|
49
40
|
class EventItem extends Component {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this._isMounted = false;
|
|
73
|
-
}
|
|
74
|
-
componentDidMount() {
|
|
75
|
-
this._isMounted = true;
|
|
76
|
-
this.supportTouch = 'ontouchstart' in window;
|
|
77
|
-
this.subscribeResizeEvent(this.props);
|
|
78
|
-
}
|
|
79
|
-
componentDidUpdate(prevProps) {
|
|
80
|
-
const {
|
|
81
|
-
left,
|
|
82
|
-
top,
|
|
83
|
-
width,
|
|
84
|
-
height
|
|
85
|
-
} = this.props;
|
|
86
|
-
if (prevProps.left !== left || prevProps.top !== top || prevProps.width !== width || prevProps.height !== height) {
|
|
87
|
-
this.setState({
|
|
88
|
-
left,
|
|
89
|
-
top,
|
|
90
|
-
width,
|
|
91
|
-
height
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Re-subscribe when resize-related props change or when position/size changes
|
|
96
|
-
// (size changes indicate a resize occurred and DOM elements may have been recreated)
|
|
97
|
-
if (prevProps.schedulerData !== this.props.schedulerData || prevProps.eventItem !== this.props.eventItem || prevProps.isInPopover !== this.props.isInPopover || prevProps.left !== left || prevProps.top !== top || prevProps.width !== width) {
|
|
98
|
-
this.subscribeResizeEvent(this.props);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
eventItemRef = ref => {
|
|
102
|
-
this.eventItemElement = ref;
|
|
103
|
-
// Attach drag refs if they exist
|
|
104
|
-
const {
|
|
105
|
-
dragRef,
|
|
106
|
-
dragPreviewRef
|
|
107
|
-
} = this.props;
|
|
108
|
-
if (dragRef && ref) {
|
|
109
|
-
dragRef(ref);
|
|
110
|
-
}
|
|
111
|
-
if (dragPreviewRef && ref) {
|
|
112
|
-
dragPreviewRef(ref);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
resizerHelper = (dragType, eventType = 'addEventListener') => {
|
|
116
|
-
const resizer = dragType === 'start' ? this.startResizer : this.endResizer;
|
|
117
|
-
const doDrag = dragType === 'start' ? this.doStartDrag : this.doEndDrag;
|
|
118
|
-
const stopDrag = dragType === 'start' ? this.stopStartDrag : this.stopEndDrag;
|
|
119
|
-
const cancelDrag = dragType === 'start' ? this.cancelStartDrag : this.cancelEndDrag;
|
|
120
|
-
if (this.supportTouch) {
|
|
121
|
-
resizer[eventType]('touchmove', doDrag, false);
|
|
122
|
-
resizer[eventType]('touchend', stopDrag, false);
|
|
123
|
-
resizer[eventType]('touchcancel', cancelDrag, false);
|
|
124
|
-
} else {
|
|
125
|
-
document.documentElement[eventType]('mousemove', doDrag, false);
|
|
126
|
-
document.documentElement[eventType]('mouseup', stopDrag, false);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
initDragHelper = (ev, dragType) => {
|
|
130
|
-
const {
|
|
131
|
-
schedulerData,
|
|
132
|
-
eventItem
|
|
133
|
-
} = this.props;
|
|
134
|
-
const slotId = schedulerData._getEventSlotId(eventItem);
|
|
135
|
-
const slot = schedulerData.getSlotById(slotId);
|
|
136
|
-
if (slot?.groupOnly) return;
|
|
137
|
-
if (schedulerData._isResizing()) return;
|
|
138
|
-
ev.stopPropagation();
|
|
139
|
-
let clientX = 0;
|
|
140
|
-
if (this.supportTouch) {
|
|
141
|
-
if (ev.changedTouches.length === 0) return;
|
|
142
|
-
const touch = ev.changedTouches[0];
|
|
143
|
-
clientX = touch.pageX;
|
|
144
|
-
} else {
|
|
145
|
-
if (ev.buttons !== undefined && ev.buttons !== 1) return;
|
|
146
|
-
clientX = ev.clientX;
|
|
147
|
-
}
|
|
148
|
-
this.setState({
|
|
149
|
-
[dragType === 'start' ? 'startX' : 'endX']: clientX
|
|
150
|
-
});
|
|
151
|
-
schedulerData._startResizing();
|
|
152
|
-
this.resizerHelper(dragType, 'addEventListener');
|
|
153
|
-
document.onselectstart = () => false;
|
|
154
|
-
document.ondragstart = () => false;
|
|
155
|
-
};
|
|
156
|
-
initStartDrag = ev => {
|
|
157
|
-
this.initDragHelper(ev, 'start');
|
|
158
|
-
};
|
|
159
|
-
doStartDrag = ev => {
|
|
160
|
-
ev.stopPropagation();
|
|
161
|
-
let clientX = 0;
|
|
162
|
-
if (this.supportTouch) {
|
|
163
|
-
if (ev.changedTouches.length === 0) return;
|
|
164
|
-
const touch = ev.changedTouches[0];
|
|
165
|
-
clientX = touch.pageX;
|
|
166
|
-
} else {
|
|
167
|
-
clientX = ev.clientX;
|
|
41
|
+
startResizer;
|
|
42
|
+
endResizer;
|
|
43
|
+
supportTouch;
|
|
44
|
+
eventItemElement;
|
|
45
|
+
_isMounted;
|
|
46
|
+
constructor(props) {
|
|
47
|
+
super(props);
|
|
48
|
+
const { left, top, width, height } = props;
|
|
49
|
+
this.state = {
|
|
50
|
+
left,
|
|
51
|
+
top,
|
|
52
|
+
width,
|
|
53
|
+
height,
|
|
54
|
+
contentMousePosX: 0,
|
|
55
|
+
eventItemLeftRect: 0,
|
|
56
|
+
eventItemRightRect: 0,
|
|
57
|
+
};
|
|
58
|
+
this.startResizer = undefined;
|
|
59
|
+
this.endResizer = undefined;
|
|
60
|
+
this.supportTouch = false; // 'ontouchstart' in window;
|
|
61
|
+
this.eventItemElement = null;
|
|
62
|
+
this._isMounted = false;
|
|
168
63
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
rightIndex,
|
|
174
|
-
schedulerData
|
|
175
|
-
} = this.props;
|
|
176
|
-
const cellWidth = schedulerData.getContentCellWidth();
|
|
177
|
-
const offset = leftIndex > 0 ? 5 : 6;
|
|
178
|
-
const minWidth = cellWidth - offset;
|
|
179
|
-
const maxWidth = rightIndex * cellWidth - offset;
|
|
180
|
-
const {
|
|
181
|
-
startX
|
|
182
|
-
} = this.state;
|
|
183
|
-
let newLeft = left + clientX - startX;
|
|
184
|
-
let newWidth = width + startX - clientX;
|
|
185
|
-
if (newWidth < minWidth) {
|
|
186
|
-
newWidth = minWidth;
|
|
187
|
-
newLeft = (rightIndex - 1) * cellWidth + (rightIndex - 1 > 0 ? 2 : 3);
|
|
188
|
-
} else if (newWidth > maxWidth) {
|
|
189
|
-
newWidth = maxWidth;
|
|
190
|
-
newLeft = 3;
|
|
64
|
+
componentDidMount() {
|
|
65
|
+
this._isMounted = true;
|
|
66
|
+
this.supportTouch = 'ontouchstart' in window;
|
|
67
|
+
this.subscribeResizeEvent(this.props);
|
|
191
68
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
rightIndex,
|
|
208
|
-
schedulerData,
|
|
209
|
-
eventItem,
|
|
210
|
-
updateEventStart,
|
|
211
|
-
conflictOccurred
|
|
212
|
-
} = this.props;
|
|
213
|
-
schedulerData._stopResizing();
|
|
214
|
-
if (schedulerData.isVerticalResourceView()) {
|
|
215
|
-
await this.stopVerticalResize(ev, 'start');
|
|
216
|
-
return;
|
|
69
|
+
componentDidUpdate(prevProps) {
|
|
70
|
+
const { left, top, width, height } = this.props;
|
|
71
|
+
if (prevProps.left !== left || prevProps.top !== top || prevProps.width !== width || prevProps.height !== height) {
|
|
72
|
+
this.setState({ left, top, width, height });
|
|
73
|
+
}
|
|
74
|
+
// Re-subscribe when resize-related props change or when position/size changes
|
|
75
|
+
// (size changes indicate a resize occurred and DOM elements may have been recreated)
|
|
76
|
+
if (prevProps.schedulerData !== this.props.schedulerData ||
|
|
77
|
+
prevProps.eventItem !== this.props.eventItem ||
|
|
78
|
+
prevProps.isInPopover !== this.props.isInPopover ||
|
|
79
|
+
prevProps.left !== left ||
|
|
80
|
+
prevProps.top !== top ||
|
|
81
|
+
prevProps.width !== width) {
|
|
82
|
+
this.subscribeResizeEvent(this.props);
|
|
83
|
+
}
|
|
217
84
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
85
|
+
eventItemRef = (ref) => {
|
|
86
|
+
this.eventItemElement = ref;
|
|
87
|
+
// Attach drag refs if they exist
|
|
88
|
+
const { dragRef, dragPreviewRef } = this.props;
|
|
89
|
+
if (dragRef && ref) {
|
|
90
|
+
dragRef(ref);
|
|
91
|
+
}
|
|
92
|
+
if (dragPreviewRef && ref) {
|
|
93
|
+
dragPreviewRef(ref);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
resizerHelper = (dragType, eventType = 'addEventListener') => {
|
|
97
|
+
const resizer = dragType === 'start' ? this.startResizer : this.endResizer;
|
|
98
|
+
const doDrag = dragType === 'start' ? this.doStartDrag : this.doEndDrag;
|
|
99
|
+
const stopDrag = dragType === 'start' ? this.stopStartDrag : this.stopEndDrag;
|
|
100
|
+
const cancelDrag = dragType === 'start' ? this.cancelStartDrag : this.cancelEndDrag;
|
|
101
|
+
if (this.supportTouch) {
|
|
102
|
+
resizer?.[eventType]('touchmove', asListener(doDrag), false);
|
|
103
|
+
resizer?.[eventType]('touchend', asListener(stopDrag), false);
|
|
104
|
+
resizer?.[eventType]('touchcancel', asListener(cancelDrag), false);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
document.documentElement[eventType]('mousemove', asListener(doDrag), false);
|
|
108
|
+
document.documentElement[eventType]('mouseup', asListener(stopDrag), false);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
initDragHelper = (ev, dragType) => {
|
|
112
|
+
const { schedulerData, eventItem } = this.props;
|
|
113
|
+
const slotId = schedulerData._getEventSlotId(eventItem);
|
|
114
|
+
const slot = schedulerData.getSlotById(slotId);
|
|
115
|
+
if (slot?.groupOnly)
|
|
116
|
+
return;
|
|
117
|
+
if (schedulerData._isResizing())
|
|
118
|
+
return;
|
|
119
|
+
ev.stopPropagation();
|
|
120
|
+
let clientX = 0;
|
|
121
|
+
if (this.supportTouch) {
|
|
122
|
+
const { changedTouches } = ev;
|
|
123
|
+
if (changedTouches.length === 0)
|
|
124
|
+
return;
|
|
125
|
+
const touch = changedTouches[0];
|
|
126
|
+
clientX = touch.pageX;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const { buttons } = ev;
|
|
130
|
+
if (buttons !== undefined && buttons !== 1)
|
|
131
|
+
return;
|
|
132
|
+
clientX = ev.clientX;
|
|
133
|
+
}
|
|
134
|
+
if (dragType === 'start')
|
|
135
|
+
this.setState({ startX: clientX });
|
|
136
|
+
else
|
|
137
|
+
this.setState({ endX: clientX });
|
|
138
|
+
schedulerData._startResizing();
|
|
139
|
+
this.resizerHelper(dragType, 'addEventListener');
|
|
140
|
+
document.onselectstart = () => false;
|
|
141
|
+
document.ondragstart = () => false;
|
|
142
|
+
};
|
|
143
|
+
initStartDrag = (ev) => {
|
|
144
|
+
this.initDragHelper(ev, 'start');
|
|
145
|
+
};
|
|
146
|
+
doStartDrag = (ev) => {
|
|
147
|
+
ev.stopPropagation();
|
|
148
|
+
let clientX = 0;
|
|
149
|
+
if (this.supportTouch) {
|
|
150
|
+
const { changedTouches } = ev;
|
|
151
|
+
if (changedTouches.length === 0)
|
|
152
|
+
return;
|
|
153
|
+
const touch = changedTouches[0];
|
|
154
|
+
clientX = touch.pageX;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
clientX = ev.clientX;
|
|
158
|
+
}
|
|
159
|
+
const { left, width, leftIndex, rightIndex, schedulerData } = this.props;
|
|
160
|
+
const cellWidth = schedulerData.getContentCellWidth();
|
|
161
|
+
const offset = leftIndex > 0 ? 5 : 6;
|
|
162
|
+
const minWidth = cellWidth - offset;
|
|
163
|
+
const maxWidth = rightIndex * cellWidth - offset;
|
|
164
|
+
const startX = this.state.startX ?? 0;
|
|
165
|
+
let newLeft = left + clientX - startX;
|
|
166
|
+
let newWidth = width + startX - clientX;
|
|
167
|
+
if (newWidth < minWidth) {
|
|
168
|
+
newWidth = minWidth;
|
|
169
|
+
newLeft = (rightIndex - 1) * cellWidth + (rightIndex - 1 > 0 ? 2 : 3);
|
|
170
|
+
}
|
|
171
|
+
else if (newWidth > maxWidth) {
|
|
172
|
+
newWidth = maxWidth;
|
|
173
|
+
newLeft = 3;
|
|
174
|
+
}
|
|
175
|
+
this.setState({ left: newLeft, width: newWidth });
|
|
176
|
+
};
|
|
177
|
+
stopStartDrag = async (ev) => {
|
|
178
|
+
ev.stopPropagation();
|
|
179
|
+
this.resizerHelper('start', 'removeEventListener');
|
|
180
|
+
document.onselectstart = null;
|
|
181
|
+
document.ondragstart = null;
|
|
182
|
+
const { width, left, top, leftIndex, rightIndex, schedulerData, eventItem, updateEventStart, conflictOccurred } = this.props;
|
|
183
|
+
schedulerData._stopResizing();
|
|
184
|
+
if (schedulerData.isVerticalResourceView()) {
|
|
185
|
+
await this.stopVerticalResize(ev, 'start');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const { width: stateWidth } = this.state;
|
|
189
|
+
if (stateWidth === width)
|
|
190
|
+
return;
|
|
191
|
+
let clientX = 0;
|
|
192
|
+
if (this.supportTouch) {
|
|
193
|
+
const { changedTouches } = ev;
|
|
194
|
+
if (changedTouches.length === 0) {
|
|
195
|
+
this.setState({ left, top, width });
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const touch = changedTouches[0];
|
|
199
|
+
clientX = touch.pageX;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
clientX = ev.clientX;
|
|
203
|
+
}
|
|
204
|
+
const { cellUnit, events, config, localeDayjs } = schedulerData;
|
|
205
|
+
const cellWidth = schedulerData.getContentCellWidth();
|
|
206
|
+
const offset = leftIndex > 0 ? 5 : 6;
|
|
207
|
+
const minWidth = cellWidth - offset;
|
|
208
|
+
const maxWidth = rightIndex * cellWidth - offset;
|
|
209
|
+
const startX = this.state.startX ?? 0;
|
|
210
|
+
const newWidth = width + startX - clientX;
|
|
211
|
+
const deltaX = clientX - startX;
|
|
212
|
+
let sign = 1;
|
|
213
|
+
if (deltaX < 0) {
|
|
214
|
+
sign = -1;
|
|
215
|
+
}
|
|
216
|
+
else if (deltaX === 0) {
|
|
217
|
+
sign = 0;
|
|
218
|
+
}
|
|
219
|
+
let count = Math.round(Math.abs(deltaX) / cellWidth) * sign;
|
|
220
|
+
if (newWidth < minWidth)
|
|
221
|
+
count = rightIndex - leftIndex - 1;
|
|
222
|
+
else if (newWidth > maxWidth)
|
|
223
|
+
count = -leftIndex;
|
|
224
|
+
let newStart = localeDayjs(new Date(eventItem.start))
|
|
225
|
+
.add(cellUnit === CellUnit.Hour ? count * config.minuteStep : count, cellUnit === CellUnit.Hour ? 'minutes' : 'days')
|
|
226
|
+
.format(DATETIME_FORMAT);
|
|
227
|
+
newStart = await stopDragHelper({
|
|
228
|
+
count,
|
|
229
|
+
cellUnit,
|
|
230
|
+
config,
|
|
231
|
+
eventItem,
|
|
232
|
+
localeDayjs,
|
|
233
|
+
dragType: 'start',
|
|
234
|
+
value: newStart,
|
|
229
235
|
});
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
cellUnit,
|
|
264
|
-
config,
|
|
265
|
-
eventItem,
|
|
266
|
-
localeDayjs,
|
|
267
|
-
dragType: 'start',
|
|
268
|
-
value: newStart
|
|
269
|
-
});
|
|
270
|
-
let hasConflict = false;
|
|
271
|
-
const slotId = schedulerData._getEventSlotId(eventItem);
|
|
272
|
-
let slotName;
|
|
273
|
-
const slot = schedulerData.getSlotById(slotId);
|
|
274
|
-
if (slot) slotName = slot.name;
|
|
275
|
-
if (config.checkConflict) {
|
|
276
|
-
const start = localeDayjs(new Date(newStart));
|
|
277
|
-
const end = localeDayjs(new Date(eventItem.end));
|
|
278
|
-
events.forEach(e => {
|
|
279
|
-
if (schedulerData._getEventSlotId(e) === slotId && e.id !== eventItem.id) {
|
|
280
|
-
const eStart = localeDayjs(new Date(e.start));
|
|
281
|
-
const eEnd = localeDayjs(new Date(e.end));
|
|
282
|
-
if (start >= eStart && start < eEnd || end > eStart && end <= eEnd || eStart >= start && eStart < end || eEnd > start && eEnd <= end) hasConflict = true;
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
if (hasConflict) {
|
|
287
|
-
this.setState({
|
|
288
|
-
left,
|
|
289
|
-
top,
|
|
290
|
-
width
|
|
291
|
-
});
|
|
292
|
-
if (conflictOccurred !== undefined) {
|
|
293
|
-
conflictOccurred(schedulerData, 'StartResize', eventItem, DnDTypes.EVENT, slotId, slotName, newStart, eventItem.end);
|
|
294
|
-
} else {
|
|
295
|
-
console.log('Conflict occurred, set conflictOccurred func in Scheduler to handle it');
|
|
296
|
-
}
|
|
297
|
-
this.subscribeResizeEvent(this.props);
|
|
298
|
-
} else if (updateEventStart !== undefined) updateEventStart(schedulerData, eventItem, newStart);
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
// Vertical resource view: rows are time slots, so the row under the pointer gives the new start (its top
|
|
302
|
-
// edge) or end (its bottom edge). The event is drawn once per row, so this works for any row height.
|
|
303
|
-
stopVerticalResize = async (ev, dragType) => {
|
|
304
|
-
const {
|
|
305
|
-
schedulerData,
|
|
306
|
-
eventItem,
|
|
307
|
-
updateEventStart,
|
|
308
|
-
updateEventEnd,
|
|
309
|
-
conflictOccurred
|
|
310
|
-
} = this.props;
|
|
311
|
-
const {
|
|
312
|
-
config,
|
|
313
|
-
events,
|
|
314
|
-
localeDayjs
|
|
315
|
-
} = schedulerData;
|
|
316
|
-
const row = document.elementFromPoint(ev.clientX, ev.clientY)?.closest('[data-slot-id]');
|
|
317
|
-
if (!row) return;
|
|
318
|
-
const rowStart = localeDayjs(row.dataset.slotId);
|
|
319
|
-
const isStart = dragType === 'start';
|
|
320
|
-
const newStart = isStart ? rowStart.format(DATETIME_FORMAT) : eventItem.start;
|
|
321
|
-
const newEnd = isStart ? eventItem.end : rowStart.add(config.minuteStep, 'minutes').format(DATETIME_FORMAT);
|
|
322
|
-
if (!localeDayjs(newEnd).isAfter(localeDayjs(newStart))) return;
|
|
323
|
-
if (isStart ? newStart === eventItem.start : newEnd === eventItem.end) return;
|
|
324
|
-
const slotId = schedulerData._getEventSlotId(eventItem);
|
|
325
|
-
const hasConflict = config.checkConflict && events.some(e => {
|
|
326
|
-
if (schedulerData._getEventSlotId(e) !== slotId || e.id === eventItem.id) return false;
|
|
327
|
-
return localeDayjs(newStart).isBefore(localeDayjs(e.end)) && localeDayjs(newEnd).isAfter(localeDayjs(e.start));
|
|
328
|
-
});
|
|
329
|
-
if (hasConflict) {
|
|
330
|
-
conflictOccurred?.(schedulerData, isStart ? 'StartResize' : 'EndResize', eventItem, DnDTypes.EVENT, slotId, schedulerData.getSlotById(slotId)?.name, newStart, newEnd);
|
|
331
|
-
} else if (isStart) updateEventStart?.(schedulerData, eventItem, newStart);else updateEventEnd?.(schedulerData, eventItem, newEnd);
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
// Vertical resource view: the event is drawn once per time row; only the row holding the event's start
|
|
335
|
-
// (or end) gets the top (or bottom) handle.
|
|
336
|
-
getVerticalEdges = () => {
|
|
337
|
-
const {
|
|
338
|
-
schedulerData,
|
|
339
|
-
eventItem,
|
|
340
|
-
slotId
|
|
341
|
-
} = this.props;
|
|
342
|
-
if (!schedulerData.isVerticalResourceView() || !slotId) return {
|
|
343
|
-
top: true,
|
|
344
|
-
bottom: true
|
|
236
|
+
let hasConflict = false;
|
|
237
|
+
const slotId = schedulerData._getEventSlotId(eventItem);
|
|
238
|
+
let slotName;
|
|
239
|
+
const slot = schedulerData.getSlotById(slotId);
|
|
240
|
+
if (slot)
|
|
241
|
+
slotName = slot.name;
|
|
242
|
+
if (config.checkConflict) {
|
|
243
|
+
const start = localeDayjs(new Date(newStart));
|
|
244
|
+
const end = localeDayjs(new Date(eventItem.end));
|
|
245
|
+
events.forEach(e => {
|
|
246
|
+
if (schedulerData._getEventSlotId(e) === slotId && e.id !== eventItem.id) {
|
|
247
|
+
const eStart = localeDayjs(new Date(e.start));
|
|
248
|
+
const eEnd = localeDayjs(new Date(e.end));
|
|
249
|
+
if ((start >= eStart && start < eEnd) ||
|
|
250
|
+
(end > eStart && end <= eEnd) ||
|
|
251
|
+
(eStart >= start && eStart < end) ||
|
|
252
|
+
(eEnd > start && eEnd <= end))
|
|
253
|
+
hasConflict = true;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
if (hasConflict) {
|
|
258
|
+
this.setState({ left, top, width });
|
|
259
|
+
if (conflictOccurred !== undefined) {
|
|
260
|
+
conflictOccurred(schedulerData, 'StartResize', eventItem, DnDTypes.EVENT, slotId, slotName, newStart, eventItem.end);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
console.log('Conflict occurred, set conflictOccurred func in Scheduler to handle it');
|
|
264
|
+
}
|
|
265
|
+
this.subscribeResizeEvent(this.props);
|
|
266
|
+
}
|
|
267
|
+
else if (updateEventStart !== undefined)
|
|
268
|
+
updateEventStart(schedulerData, eventItem, newStart);
|
|
345
269
|
};
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
270
|
+
// Vertical resource view: rows are time slots, so the row under the pointer gives the new start (its top
|
|
271
|
+
// edge) or end (its bottom edge). The event is drawn once per row, so this works for any row height.
|
|
272
|
+
stopVerticalResize = async (ev, dragType) => {
|
|
273
|
+
const { schedulerData, eventItem, updateEventStart, updateEventEnd, conflictOccurred } = this.props;
|
|
274
|
+
const { config, events, localeDayjs } = schedulerData;
|
|
275
|
+
const { clientX, clientY } = ev;
|
|
276
|
+
const row = document.elementFromPoint(clientX, clientY)?.closest('[data-slot-id]');
|
|
277
|
+
if (!row)
|
|
278
|
+
return;
|
|
279
|
+
const rowStart = localeDayjs(row.dataset.slotId);
|
|
280
|
+
const isStart = dragType === 'start';
|
|
281
|
+
const newStart = isStart ? rowStart.format(DATETIME_FORMAT) : eventItem.start;
|
|
282
|
+
const newEnd = isStart ? eventItem.end : rowStart.add(config.minuteStep, 'minutes').format(DATETIME_FORMAT);
|
|
283
|
+
if (!localeDayjs(newEnd).isAfter(localeDayjs(newStart)))
|
|
284
|
+
return;
|
|
285
|
+
if (isStart ? newStart === eventItem.start : newEnd === eventItem.end)
|
|
286
|
+
return;
|
|
287
|
+
const slotId = schedulerData._getEventSlotId(eventItem);
|
|
288
|
+
const hasConflict = config.checkConflict &&
|
|
289
|
+
events.some(e => {
|
|
290
|
+
if (schedulerData._getEventSlotId(e) !== slotId || e.id === eventItem.id)
|
|
291
|
+
return false;
|
|
292
|
+
return localeDayjs(newStart).isBefore(localeDayjs(e.end)) && localeDayjs(newEnd).isAfter(localeDayjs(e.start));
|
|
293
|
+
});
|
|
294
|
+
if (hasConflict) {
|
|
295
|
+
conflictOccurred?.(schedulerData, isStart ? 'StartResize' : 'EndResize', eventItem, DnDTypes.EVENT, slotId, schedulerData.getSlotById(slotId)?.name, newStart, newEnd);
|
|
296
|
+
}
|
|
297
|
+
else if (isStart)
|
|
298
|
+
updateEventStart?.(schedulerData, eventItem, newStart);
|
|
299
|
+
else
|
|
300
|
+
updateEventEnd?.(schedulerData, eventItem, newEnd);
|
|
357
301
|
};
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
302
|
+
// Vertical resource view: the event is drawn once per time row; only the row holding the event's start
|
|
303
|
+
// (or end) gets the top (or bottom) handle.
|
|
304
|
+
getVerticalEdges = () => {
|
|
305
|
+
const { schedulerData, eventItem, slotId } = this.props;
|
|
306
|
+
if (!schedulerData.isVerticalResourceView() || !slotId)
|
|
307
|
+
return { top: true, bottom: true };
|
|
308
|
+
const { localeDayjs, config } = schedulerData;
|
|
309
|
+
const rowStart = localeDayjs(slotId);
|
|
310
|
+
const rowEnd = rowStart.add(config.minuteStep, 'minutes');
|
|
311
|
+
const eventStart = localeDayjs(eventItem.start);
|
|
312
|
+
const eventEnd = localeDayjs(eventItem.end);
|
|
313
|
+
return {
|
|
314
|
+
top: !eventStart.isBefore(rowStart) && eventStart.isBefore(rowEnd),
|
|
315
|
+
bottom: eventEnd.isAfter(rowStart) && !eventEnd.isAfter(rowEnd),
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
cancelStartDrag = (ev) => {
|
|
319
|
+
ev.stopPropagation();
|
|
320
|
+
this.startResizer?.removeEventListener('touchmove', asListener(this.doStartDrag), false);
|
|
321
|
+
this.startResizer?.removeEventListener('touchend', asListener(this.stopStartDrag), false);
|
|
322
|
+
this.startResizer?.removeEventListener('touchcancel', asListener(this.cancelStartDrag), false);
|
|
323
|
+
document.onselectstart = null;
|
|
324
|
+
document.ondragstart = null;
|
|
325
|
+
const { schedulerData, left, top, width } = this.props;
|
|
326
|
+
schedulerData._stopResizing();
|
|
327
|
+
this.setState({ left, top, width });
|
|
328
|
+
};
|
|
329
|
+
initEndDrag = (ev) => {
|
|
330
|
+
this.initDragHelper(ev, 'end');
|
|
331
|
+
};
|
|
332
|
+
doEndDrag = (ev) => {
|
|
333
|
+
ev.stopPropagation();
|
|
334
|
+
let clientX = 0;
|
|
335
|
+
if (this.supportTouch) {
|
|
336
|
+
const { changedTouches } = ev;
|
|
337
|
+
if (changedTouches.length === 0)
|
|
338
|
+
return;
|
|
339
|
+
const touch = changedTouches[0];
|
|
340
|
+
clientX = touch.pageX;
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
clientX = ev.clientX;
|
|
344
|
+
}
|
|
345
|
+
const { width, leftIndex, schedulerData } = this.props;
|
|
346
|
+
const { headers } = schedulerData;
|
|
347
|
+
const cellWidth = schedulerData.getContentCellWidth();
|
|
348
|
+
const offset = leftIndex > 0 ? 5 : 6;
|
|
349
|
+
const minWidth = cellWidth - offset;
|
|
350
|
+
const maxWidth = (headers.length - leftIndex) * cellWidth - offset;
|
|
351
|
+
const endX = this.state.endX ?? 0;
|
|
352
|
+
let newWidth = width + clientX - endX;
|
|
353
|
+
if (newWidth < minWidth)
|
|
354
|
+
newWidth = minWidth;
|
|
355
|
+
else if (newWidth > maxWidth)
|
|
356
|
+
newWidth = maxWidth;
|
|
357
|
+
this.setState({ width: newWidth });
|
|
358
|
+
};
|
|
359
|
+
stopEndDrag = async (ev) => {
|
|
360
|
+
ev.stopPropagation();
|
|
361
|
+
this.resizerHelper('end', 'removeEventListener');
|
|
362
|
+
document.onselectstart = null;
|
|
363
|
+
document.ondragstart = null;
|
|
364
|
+
const { left, top, width, leftIndex, rightIndex, schedulerData, eventItem, updateEventEnd, conflictOccurred } = this.props;
|
|
365
|
+
schedulerData._stopResizing();
|
|
366
|
+
if (schedulerData.isVerticalResourceView()) {
|
|
367
|
+
await this.stopVerticalResize(ev, 'end');
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const { width: stateWidth } = this.state;
|
|
371
|
+
if (stateWidth === width)
|
|
372
|
+
return;
|
|
373
|
+
let clientX = 0;
|
|
374
|
+
if (this.supportTouch) {
|
|
375
|
+
const { changedTouches } = ev;
|
|
376
|
+
if (changedTouches.length === 0) {
|
|
377
|
+
this.setState({ left, top, width });
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const touch = changedTouches[0];
|
|
381
|
+
clientX = touch.pageX;
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
clientX = ev.clientX;
|
|
385
|
+
}
|
|
386
|
+
const { headers, cellUnit, events, config, localeDayjs } = schedulerData;
|
|
387
|
+
const cellWidth = schedulerData.getContentCellWidth();
|
|
388
|
+
const offset = leftIndex > 0 ? 5 : 6;
|
|
389
|
+
const minWidth = cellWidth - offset;
|
|
390
|
+
const maxWidth = (headers.length - leftIndex) * cellWidth - offset;
|
|
391
|
+
const endX = this.state.endX ?? 0;
|
|
392
|
+
const newWidth = width + clientX - endX;
|
|
393
|
+
const deltaX = newWidth - width;
|
|
394
|
+
let sign = 1;
|
|
395
|
+
if (deltaX < 0) {
|
|
396
|
+
sign = -1;
|
|
397
|
+
}
|
|
398
|
+
else if (deltaX === 0) {
|
|
399
|
+
sign = 0;
|
|
400
|
+
}
|
|
401
|
+
let count = Math.round(Math.abs(deltaX) / cellWidth) * sign;
|
|
402
|
+
if (newWidth < minWidth)
|
|
403
|
+
count = leftIndex - rightIndex + 1;
|
|
404
|
+
else if (newWidth > maxWidth)
|
|
405
|
+
count = headers.length - rightIndex;
|
|
406
|
+
let newEnd = localeDayjs(new Date(eventItem.end))
|
|
407
|
+
.add(cellUnit === CellUnit.Hour ? count * config.minuteStep : count, cellUnit === CellUnit.Hour ? 'minutes' : 'days')
|
|
408
|
+
.format(DATETIME_FORMAT);
|
|
409
|
+
newEnd = await stopDragHelper({
|
|
410
|
+
dragType: 'end',
|
|
411
|
+
cellUnit,
|
|
412
|
+
config,
|
|
413
|
+
count,
|
|
414
|
+
value: newEnd,
|
|
415
|
+
eventItem,
|
|
416
|
+
localeDayjs,
|
|
417
|
+
});
|
|
418
|
+
let hasConflict = false;
|
|
419
|
+
const slotId = schedulerData._getEventSlotId(eventItem);
|
|
420
|
+
const slot = schedulerData.getSlotById(slotId);
|
|
421
|
+
if (config.checkConflict) {
|
|
422
|
+
const start = localeDayjs(new Date(eventItem.start));
|
|
423
|
+
const end = localeDayjs(new Date(newEnd));
|
|
424
|
+
events.forEach(e => {
|
|
425
|
+
if (schedulerData._getEventSlotId(e) === slotId && e.id !== eventItem.id) {
|
|
426
|
+
const eStart = localeDayjs(new Date(e.start));
|
|
427
|
+
const eEnd = localeDayjs(new Date(e.end));
|
|
428
|
+
if ((start >= eStart && start < eEnd) ||
|
|
429
|
+
(end > eStart && end <= eEnd) ||
|
|
430
|
+
(eStart >= start && eStart < end) ||
|
|
431
|
+
(eEnd > start && eEnd <= end)) {
|
|
432
|
+
hasConflict = true;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
if (hasConflict) {
|
|
438
|
+
this.setState({ left, top, width });
|
|
439
|
+
if (conflictOccurred !== undefined) {
|
|
440
|
+
conflictOccurred(schedulerData, 'EndResize', eventItem, DnDTypes.EVENT, slotId, slot ? slot.name : null, eventItem.start, newEnd);
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
console.error('Conflict occurred, set conflictOccurred func in Scheduler to handle it');
|
|
444
|
+
}
|
|
445
|
+
this.subscribeResizeEvent(this.props);
|
|
446
|
+
}
|
|
447
|
+
else if (updateEventEnd !== undefined) {
|
|
448
|
+
updateEventEnd(schedulerData, eventItem, newEnd);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
cancelEndDrag = (ev) => {
|
|
452
|
+
ev.stopPropagation();
|
|
453
|
+
this.endResizer?.removeEventListener('touchmove', asListener(this.doEndDrag), false);
|
|
454
|
+
this.endResizer?.removeEventListener('touchend', asListener(this.stopEndDrag), false);
|
|
455
|
+
this.endResizer?.removeEventListener('touchcancel', asListener(this.cancelEndDrag), false);
|
|
456
|
+
document.onselectstart = null;
|
|
457
|
+
document.ondragstart = null;
|
|
458
|
+
const { schedulerData, left, top, width } = this.props;
|
|
459
|
+
schedulerData._stopResizing();
|
|
460
|
+
this.setState({ left, top, width });
|
|
461
|
+
};
|
|
462
|
+
handleMouseMove = (event) => {
|
|
463
|
+
const rect = this.eventItemElement ? this.eventItemElement.getBoundingClientRect() : { left: 0, right: 0 };
|
|
441
464
|
this.setState({
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
465
|
+
contentMousePosX: event.clientX,
|
|
466
|
+
eventItemLeftRect: rect.left,
|
|
467
|
+
eventItemRightRect: rect.right,
|
|
445
468
|
});
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
const touch = ev.changedTouches[0];
|
|
449
|
-
clientX = touch.pageX;
|
|
450
|
-
} else {
|
|
451
|
-
clientX = ev.clientX;
|
|
452
|
-
}
|
|
453
|
-
const {
|
|
454
|
-
headers,
|
|
455
|
-
cellUnit,
|
|
456
|
-
events,
|
|
457
|
-
config,
|
|
458
|
-
localeDayjs
|
|
459
|
-
} = schedulerData;
|
|
460
|
-
const cellWidth = schedulerData.getContentCellWidth();
|
|
461
|
-
const offset = leftIndex > 0 ? 5 : 6;
|
|
462
|
-
const minWidth = cellWidth - offset;
|
|
463
|
-
const maxWidth = (headers.length - leftIndex) * cellWidth - offset;
|
|
464
|
-
const {
|
|
465
|
-
endX
|
|
466
|
-
} = this.state;
|
|
467
|
-
const newWidth = width + clientX - endX;
|
|
468
|
-
const deltaX = newWidth - width;
|
|
469
|
-
let sign = 1;
|
|
470
|
-
if (deltaX < 0) {
|
|
471
|
-
sign = -1;
|
|
472
|
-
} else if (deltaX === 0) {
|
|
473
|
-
sign = 0;
|
|
474
|
-
}
|
|
475
|
-
let count = Math.round(Math.abs(deltaX) / cellWidth) * sign;
|
|
476
|
-
if (newWidth < minWidth) count = leftIndex - rightIndex + 1;else if (newWidth > maxWidth) count = headers.length - rightIndex;
|
|
477
|
-
let newEnd = localeDayjs(new Date(eventItem.end)).add(cellUnit === CellUnit.Hour ? count * config.minuteStep : count, cellUnit === CellUnit.Hour ? 'minutes' : 'days').format(DATETIME_FORMAT);
|
|
478
|
-
newEnd = await stopDragHelper({
|
|
479
|
-
dragType: 'end',
|
|
480
|
-
cellUnit,
|
|
481
|
-
config,
|
|
482
|
-
count,
|
|
483
|
-
value: newEnd,
|
|
484
|
-
eventItem,
|
|
485
|
-
localeDayjs
|
|
486
|
-
});
|
|
487
|
-
let hasConflict = false;
|
|
488
|
-
const slotId = schedulerData._getEventSlotId(eventItem);
|
|
489
|
-
const slot = schedulerData.getSlotById(slotId);
|
|
490
|
-
if (config.checkConflict) {
|
|
491
|
-
const start = localeDayjs(new Date(eventItem.start));
|
|
492
|
-
const end = localeDayjs(new Date(newEnd));
|
|
493
|
-
events.forEach(e => {
|
|
494
|
-
if (schedulerData._getEventSlotId(e) === slotId && e.id !== eventItem.id) {
|
|
495
|
-
const eStart = localeDayjs(new Date(e.start));
|
|
496
|
-
const eEnd = localeDayjs(new Date(e.end));
|
|
497
|
-
if (start >= eStart && start < eEnd || end > eStart && end <= eEnd || eStart >= start && eStart < end || eEnd > start && eEnd <= end) {
|
|
498
|
-
hasConflict = true;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
if (hasConflict) {
|
|
504
|
-
this.setState({
|
|
505
|
-
left,
|
|
506
|
-
top,
|
|
507
|
-
width
|
|
508
|
-
});
|
|
509
|
-
if (conflictOccurred !== undefined) {
|
|
510
|
-
conflictOccurred(schedulerData, 'EndResize', eventItem, DnDTypes.EVENT, slotId, slot ? slot.name : null, eventItem.start, newEnd);
|
|
511
|
-
} else {
|
|
512
|
-
console.error('Conflict occurred, set conflictOccurred func in Scheduler to handle it');
|
|
513
|
-
}
|
|
514
|
-
this.subscribeResizeEvent(this.props);
|
|
515
|
-
} else if (updateEventEnd !== undefined) {
|
|
516
|
-
updateEventEnd(schedulerData, eventItem, newEnd);
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
cancelEndDrag = ev => {
|
|
520
|
-
ev.stopPropagation();
|
|
521
|
-
this.endResizer.removeEventListener('touchmove', this.doEndDrag, false);
|
|
522
|
-
this.endResizer.removeEventListener('touchend', this.stopEndDrag, false);
|
|
523
|
-
this.endResizer.removeEventListener('touchcancel', this.cancelEndDrag, false);
|
|
524
|
-
document.onselectstart = null;
|
|
525
|
-
document.ondragstart = null;
|
|
526
|
-
const {
|
|
527
|
-
schedulerData,
|
|
528
|
-
left,
|
|
529
|
-
top,
|
|
530
|
-
width
|
|
531
|
-
} = this.props;
|
|
532
|
-
schedulerData._stopResizing();
|
|
533
|
-
this.setState({
|
|
534
|
-
left,
|
|
535
|
-
top,
|
|
536
|
-
width
|
|
537
|
-
});
|
|
538
|
-
};
|
|
539
|
-
handleMouseMove = event => {
|
|
540
|
-
const rect = this.eventItemElement ? this.eventItemElement.getBoundingClientRect() : {
|
|
541
|
-
left: 0,
|
|
542
|
-
right: 0
|
|
543
469
|
};
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
this.
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
render() {
|
|
573
|
-
const {
|
|
574
|
-
eventItem,
|
|
575
|
-
isStart,
|
|
576
|
-
isEnd,
|
|
577
|
-
isInPopover,
|
|
578
|
-
eventItemClick,
|
|
579
|
-
schedulerData,
|
|
580
|
-
isDragging,
|
|
581
|
-
eventItemTemplateResolver
|
|
582
|
-
} = this.props;
|
|
583
|
-
const {
|
|
584
|
-
config,
|
|
585
|
-
localeDayjs
|
|
586
|
-
} = schedulerData;
|
|
587
|
-
const {
|
|
588
|
-
left,
|
|
589
|
-
width,
|
|
590
|
-
top,
|
|
591
|
-
height
|
|
592
|
-
} = this.state;
|
|
593
|
-
let roundCls;
|
|
594
|
-
const popoverPlacement = config.eventItemPopoverPlacement;
|
|
595
|
-
const isPopoverPlacementMousePosition = /(top|bottom)(Right|Left)MousePosition/.test(popoverPlacement);
|
|
596
|
-
if (isStart) {
|
|
597
|
-
roundCls = isEnd ? 'round-all' : 'round-head';
|
|
598
|
-
} else {
|
|
599
|
-
roundCls = isEnd ? 'round-tail' : 'round-none';
|
|
600
|
-
}
|
|
601
|
-
let bgColor = config.defaultEventBgColor;
|
|
602
|
-
if (eventItem.bgColor) bgColor = eventItem.bgColor;
|
|
603
|
-
const titleText = schedulerData.behaviors.getEventTextFunc(schedulerData, eventItem);
|
|
604
|
-
const content = /*#__PURE__*/_jsx(EventItemPopover, {
|
|
605
|
-
...this.props,
|
|
606
|
-
eventItem: eventItem,
|
|
607
|
-
title: eventItem.title,
|
|
608
|
-
startTime: eventItem.start,
|
|
609
|
-
endTime: eventItem.end,
|
|
610
|
-
statusColor: bgColor
|
|
611
|
-
});
|
|
612
|
-
const start = localeDayjs(new Date(eventItem.start));
|
|
613
|
-
const eventTitle = isInPopover ? `${start.format('HH:mm')} ${titleText}` : titleText;
|
|
614
|
-
const verticalEdges = this.getVerticalEdges();
|
|
615
|
-
let startResizeDiv = /*#__PURE__*/_jsx("div", {});
|
|
616
|
-
if (startResizable(this.props) && verticalEdges.top) startResizeDiv = /*#__PURE__*/_jsx("div", {
|
|
617
|
-
className: "event-resizer event-start-resizer",
|
|
618
|
-
ref: ref => this.startResizer = ref
|
|
619
|
-
});
|
|
620
|
-
let endResizeDiv = /*#__PURE__*/_jsx("div", {});
|
|
621
|
-
if (endResizable(this.props) && verticalEdges.bottom) endResizeDiv = /*#__PURE__*/_jsx("div", {
|
|
622
|
-
className: "event-resizer event-end-resizer",
|
|
623
|
-
ref: ref => this.endResizer = ref
|
|
624
|
-
});
|
|
625
|
-
let eventItemTemplate = /*#__PURE__*/_jsx("div", {
|
|
626
|
-
className: `${roundCls} event-item`,
|
|
627
|
-
style: {
|
|
628
|
-
height: height || config.eventItemHeight,
|
|
629
|
-
backgroundColor: bgColor
|
|
630
|
-
},
|
|
631
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
632
|
-
style: {
|
|
633
|
-
marginLeft: '10px',
|
|
634
|
-
lineHeight: `${config.eventItemHeight}px`
|
|
635
|
-
},
|
|
636
|
-
children: eventTitle
|
|
637
|
-
})
|
|
638
|
-
}, eventItem.id);
|
|
639
|
-
if (eventItemTemplateResolver !== undefined) {
|
|
640
|
-
eventItemTemplate = eventItemTemplateResolver(schedulerData, eventItem, bgColor, isStart, isEnd, 'event-item', config.eventItemHeight, undefined);
|
|
641
|
-
}
|
|
642
|
-
const a = /*#__PURE__*/_jsxs("button", {
|
|
643
|
-
type: "button",
|
|
644
|
-
className: "timeline-event",
|
|
645
|
-
ref: this.eventItemRef,
|
|
646
|
-
onMouseMove: isPopoverPlacementMousePosition ? this.handleMouseMove : undefined,
|
|
647
|
-
style: {
|
|
648
|
-
left,
|
|
649
|
-
width,
|
|
650
|
-
top,
|
|
651
|
-
height,
|
|
652
|
-
cursor: 'pointer',
|
|
653
|
-
background: 'none',
|
|
654
|
-
border: 'none',
|
|
655
|
-
padding: 0,
|
|
656
|
-
display: 'block',
|
|
657
|
-
textAlign: 'left'
|
|
658
|
-
},
|
|
659
|
-
onClick: () => {
|
|
660
|
-
if (eventItemClick) eventItemClick(schedulerData, eventItem);
|
|
661
|
-
},
|
|
662
|
-
children: [eventItemTemplate, startResizeDiv, endResizeDiv]
|
|
663
|
-
});
|
|
664
|
-
const getMousePositionOptionsData = () => {
|
|
665
|
-
let popoverOffsetX = 0;
|
|
666
|
-
let mousePositionPlacement = '';
|
|
667
|
-
if (isPopoverPlacementMousePosition) {
|
|
668
|
-
const isMousePositionPlacementLeft = popoverPlacement.includes('Left');
|
|
669
|
-
const {
|
|
670
|
-
contentMousePosX
|
|
671
|
-
} = this.state;
|
|
672
|
-
const popoverWidth = config.eventItemPopoverWidth;
|
|
673
|
-
const {
|
|
674
|
-
eventItemLeftRect
|
|
675
|
-
} = this.state;
|
|
676
|
-
const {
|
|
677
|
-
eventItemRightRect
|
|
678
|
-
} = this.state;
|
|
679
|
-
let eventItemMousePosX = isMousePositionPlacementLeft ? eventItemLeftRect : eventItemRightRect;
|
|
680
|
-
let posAdjustControl = isMousePositionPlacementLeft ? 1 : -1;
|
|
681
|
-
mousePositionPlacement = popoverPlacement.replace('MousePosition', '');
|
|
682
|
-
const distance = 10;
|
|
683
|
-
if (isMousePositionPlacementLeft && this._isMounted) {
|
|
684
|
-
if (contentMousePosX + popoverWidth + distance > window.innerWidth) {
|
|
685
|
-
mousePositionPlacement = `${popoverPlacement.replace(/(Right|Left).*/, '')}Right`;
|
|
686
|
-
eventItemMousePosX = eventItemRightRect;
|
|
687
|
-
posAdjustControl = -1;
|
|
688
|
-
}
|
|
689
|
-
} else if (contentMousePosX - popoverWidth - distance < 0) {
|
|
690
|
-
mousePositionPlacement = `${popoverPlacement.replace(/(Right|Left).*/, '')}Left`;
|
|
691
|
-
eventItemMousePosX = eventItemLeftRect;
|
|
692
|
-
posAdjustControl = 1;
|
|
693
|
-
}
|
|
694
|
-
popoverOffsetX = contentMousePosX - eventItemMousePosX - 20 * posAdjustControl;
|
|
695
|
-
}
|
|
696
|
-
return {
|
|
697
|
-
popoverOffsetX,
|
|
698
|
-
mousePositionPlacement
|
|
699
|
-
};
|
|
470
|
+
subscribeResizeEvent = (props) => {
|
|
471
|
+
if (this.startResizer !== undefined && this.startResizer !== null) {
|
|
472
|
+
if (this.supportTouch) {
|
|
473
|
+
// this.startResizer.removeEventListener('touchstart', this.initStartDrag, false);
|
|
474
|
+
// if (startResizable(props))
|
|
475
|
+
// this.startResizer.addEventListener('touchstart', this.initStartDrag, false);
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
this.startResizer.removeEventListener('mousedown', asListener(this.initStartDrag), false);
|
|
479
|
+
if (startResizable(props))
|
|
480
|
+
this.startResizer.addEventListener('mousedown', asListener(this.initStartDrag), false);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (this.endResizer !== undefined && this.endResizer !== null) {
|
|
484
|
+
if (this.supportTouch) {
|
|
485
|
+
// this.endResizer.removeEventListener('touchstart', this.initEndDrag, false);
|
|
486
|
+
// if (endResizable(props))
|
|
487
|
+
// this.endResizer.addEventListener('touchstart', this.initEndDrag, false);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
this.endResizer.removeEventListener('mousedown', asListener(this.initEndDrag), false);
|
|
491
|
+
if (endResizable(props))
|
|
492
|
+
this.endResizer.addEventListener('mousedown', asListener(this.initEndDrag), false);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
700
495
|
};
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
496
|
+
render() {
|
|
497
|
+
const { eventItem, isStart, isEnd, isInPopover, eventItemClick, schedulerData, isDragging, eventItemTemplateResolver, } = this.props;
|
|
498
|
+
const { config, localeDayjs } = schedulerData;
|
|
499
|
+
const { left, width, top, height } = this.state;
|
|
500
|
+
let roundCls;
|
|
501
|
+
const popoverPlacement = config.eventItemPopoverPlacement;
|
|
502
|
+
const isPopoverPlacementMousePosition = /(top|bottom)(Right|Left)MousePosition/.test(popoverPlacement);
|
|
503
|
+
if (isStart) {
|
|
504
|
+
roundCls = isEnd ? 'round-all' : 'round-head';
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
roundCls = isEnd ? 'round-tail' : 'round-none';
|
|
508
|
+
}
|
|
509
|
+
let bgColor = config.defaultEventBgColor;
|
|
510
|
+
if (eventItem.bgColor)
|
|
511
|
+
bgColor = eventItem.bgColor;
|
|
512
|
+
const titleText = schedulerData.behaviors.getEventTextFunc(schedulerData, eventItem);
|
|
513
|
+
const content = (_jsx(EventItemPopover, { ...this.props, eventItem: eventItem, title: eventItem.title, startTime: eventItem.start, endTime: eventItem.end, statusColor: bgColor }));
|
|
514
|
+
const start = localeDayjs(new Date(eventItem.start));
|
|
515
|
+
const eventTitle = isInPopover ? `${start.format('HH:mm')} ${titleText}` : titleText;
|
|
516
|
+
const verticalEdges = this.getVerticalEdges();
|
|
517
|
+
let startResizeDiv = _jsx("div", {});
|
|
518
|
+
if (startResizable(this.props) && verticalEdges.top)
|
|
519
|
+
startResizeDiv = (_jsx("div", { className: "event-resizer event-start-resizer", ref: ref => {
|
|
520
|
+
this.startResizer = ref;
|
|
521
|
+
} }));
|
|
522
|
+
let endResizeDiv = _jsx("div", {});
|
|
523
|
+
if (endResizable(this.props) && verticalEdges.bottom)
|
|
524
|
+
endResizeDiv = (_jsx("div", { className: "event-resizer event-end-resizer", ref: ref => {
|
|
525
|
+
this.endResizer = ref;
|
|
526
|
+
} }));
|
|
527
|
+
let eventItemTemplate = (_jsx("div", { className: `${roundCls} event-item`, style: { height: height || config.eventItemHeight, backgroundColor: bgColor }, children: _jsx("span", { style: {
|
|
528
|
+
marginLeft: '10px',
|
|
529
|
+
lineHeight: `${config.eventItemHeight}px`,
|
|
530
|
+
}, children: eventTitle }) }, eventItem.id));
|
|
531
|
+
if (eventItemTemplateResolver !== undefined) {
|
|
532
|
+
eventItemTemplate = eventItemTemplateResolver(schedulerData, eventItem, bgColor, isStart, isEnd, 'event-item', config.eventItemHeight, undefined);
|
|
533
|
+
}
|
|
534
|
+
const a = (_jsxs("button", { type: "button", className: "timeline-event", ref: this.eventItemRef, onMouseMove: isPopoverPlacementMousePosition ? this.handleMouseMove : undefined, style: {
|
|
535
|
+
left,
|
|
536
|
+
width,
|
|
537
|
+
top,
|
|
538
|
+
height,
|
|
539
|
+
cursor: 'pointer',
|
|
540
|
+
background: 'none',
|
|
541
|
+
border: 'none',
|
|
542
|
+
padding: 0,
|
|
543
|
+
display: 'block',
|
|
544
|
+
textAlign: 'left',
|
|
545
|
+
}, onClick: () => {
|
|
546
|
+
if (eventItemClick)
|
|
547
|
+
eventItemClick(schedulerData, eventItem);
|
|
548
|
+
}, children: [eventItemTemplate, startResizeDiv, endResizeDiv] }));
|
|
549
|
+
const getMousePositionOptionsData = () => {
|
|
550
|
+
let popoverOffsetX = 0;
|
|
551
|
+
let mousePositionPlacement = '';
|
|
552
|
+
if (isPopoverPlacementMousePosition) {
|
|
553
|
+
const isMousePositionPlacementLeft = popoverPlacement.includes('Left');
|
|
554
|
+
const { contentMousePosX } = this.state;
|
|
555
|
+
const popoverWidth = config.eventItemPopoverWidth;
|
|
556
|
+
const { eventItemLeftRect } = this.state;
|
|
557
|
+
const { eventItemRightRect } = this.state;
|
|
558
|
+
let eventItemMousePosX = isMousePositionPlacementLeft ? eventItemLeftRect : eventItemRightRect;
|
|
559
|
+
let posAdjustControl = isMousePositionPlacementLeft ? 1 : -1;
|
|
560
|
+
mousePositionPlacement = popoverPlacement.replace('MousePosition', '');
|
|
561
|
+
const distance = 10;
|
|
562
|
+
if (isMousePositionPlacementLeft && this._isMounted) {
|
|
563
|
+
if (contentMousePosX + popoverWidth + distance > window.innerWidth) {
|
|
564
|
+
mousePositionPlacement = `${popoverPlacement.replace(/(Right|Left).*/, '')}Right`;
|
|
565
|
+
eventItemMousePosX = eventItemRightRect;
|
|
566
|
+
posAdjustControl = -1;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
else if (contentMousePosX - popoverWidth - distance < 0) {
|
|
570
|
+
mousePositionPlacement = `${popoverPlacement.replace(/(Right|Left).*/, '')}Left`;
|
|
571
|
+
eventItemMousePosX = eventItemLeftRect;
|
|
572
|
+
posAdjustControl = 1;
|
|
573
|
+
}
|
|
574
|
+
popoverOffsetX = contentMousePosX - eventItemMousePosX - 20 * posAdjustControl;
|
|
575
|
+
}
|
|
576
|
+
return { popoverOffsetX, mousePositionPlacement };
|
|
577
|
+
};
|
|
578
|
+
const { popoverOffsetX, mousePositionPlacement } = getMousePositionOptionsData();
|
|
579
|
+
const aItem = a;
|
|
580
|
+
if (isDragging
|
|
581
|
+
? null
|
|
582
|
+
: schedulerData._isResizing() || config.eventItemPopoverEnabled === false || eventItem.showPopover === false) {
|
|
583
|
+
return _jsx("div", { children: aItem });
|
|
584
|
+
}
|
|
585
|
+
return (_jsx(Popover, { offset: isPopoverPlacementMousePosition ? [popoverOffsetX, 0] : undefined, placement: isPopoverPlacementMousePosition ? mousePositionPlacement : popoverPlacement, content: content, trigger: config.eventItemPopoverTrigger, children: aItem }));
|
|
710
586
|
}
|
|
711
|
-
return /*#__PURE__*/_jsx(Popover, {
|
|
712
|
-
motion: isPopoverPlacementMousePosition ? '' : undefined,
|
|
713
|
-
align: isPopoverPlacementMousePosition ? {
|
|
714
|
-
offset: [popoverOffsetX, popoverPlacement.includes('top') ? -10 : 10],
|
|
715
|
-
overflow: {}
|
|
716
|
-
} : undefined,
|
|
717
|
-
placement: isPopoverPlacementMousePosition ? mousePositionPlacement : popoverPlacement,
|
|
718
|
-
content: content,
|
|
719
|
-
trigger: config.eventItemPopoverTrigger,
|
|
720
|
-
children: aItem
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
587
|
}
|
|
724
|
-
|
|
725
588
|
// Wrapper component to use useDrag hook
|
|
726
589
|
function EventItemWithDnD(props) {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
})
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
// Get drag options from dndSource
|
|
748
|
-
return dndSource.getDragOptions(props);
|
|
749
|
-
}, [props, dndSource]);
|
|
750
|
-
return /*#__PURE__*/_jsx(EventItem, {
|
|
751
|
-
...props,
|
|
752
|
-
isDragging: isDragging,
|
|
753
|
-
dragRef: dragRef,
|
|
754
|
-
dragPreviewRef: dragPreviewRef
|
|
755
|
-
});
|
|
590
|
+
const { dndSource } = props;
|
|
591
|
+
// Always call useDrag unconditionally (Rules of Hooks)
|
|
592
|
+
// Disable functionality when dndSource is not provided
|
|
593
|
+
const [{ isDragging }, dragRef, dragPreviewRef] = useDrag(() => {
|
|
594
|
+
// If dndSource is not provided, return a no-op spec
|
|
595
|
+
if (!dndSource) {
|
|
596
|
+
return {
|
|
597
|
+
type: '__NONE__',
|
|
598
|
+
canDrag: () => false,
|
|
599
|
+
collect: () => ({ isDragging: false }),
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
// Get drag options from dndSource
|
|
603
|
+
return dndSource.getDragOptions(props);
|
|
604
|
+
}, [props, dndSource]);
|
|
605
|
+
return _jsx(EventItem, { ...props, isDragging: isDragging, dragRef: dragRef, dragPreviewRef: dragPreviewRef });
|
|
756
606
|
}
|
|
757
|
-
EventItemWithDnD.propTypes = {
|
|
758
|
-
schedulerData: PropTypes.object.isRequired,
|
|
759
|
-
dndSource: PropTypes.object
|
|
760
|
-
};
|
|
761
|
-
EventItemWithDnD.defaultProps = {
|
|
762
|
-
dndSource: undefined
|
|
763
|
-
};
|
|
764
607
|
EventItemWithDnD.displayName = 'EventItemWithDnD';
|
|
765
608
|
export default EventItemWithDnD;
|
|
766
|
-
EventItem.propTypes = {
|
|
767
|
-
schedulerData: PropTypes.object.isRequired,
|
|
768
|
-
eventItem: PropTypes.object.isRequired,
|
|
769
|
-
isStart: PropTypes.bool.isRequired,
|
|
770
|
-
isEnd: PropTypes.bool.isRequired,
|
|
771
|
-
left: PropTypes.number.isRequired,
|
|
772
|
-
width: PropTypes.number.isRequired,
|
|
773
|
-
top: PropTypes.number.isRequired,
|
|
774
|
-
height: PropTypes.number,
|
|
775
|
-
isInPopover: PropTypes.bool.isRequired,
|
|
776
|
-
leftIndex: PropTypes.number.isRequired,
|
|
777
|
-
rightIndex: PropTypes.number.isRequired,
|
|
778
|
-
isDragging: PropTypes.bool,
|
|
779
|
-
dragRef: PropTypes.func,
|
|
780
|
-
dragPreviewRef: PropTypes.func,
|
|
781
|
-
updateEventStart: PropTypes.func,
|
|
782
|
-
updateEventEnd: PropTypes.func,
|
|
783
|
-
moveEvent: PropTypes.func,
|
|
784
|
-
subtitleGetter: PropTypes.func,
|
|
785
|
-
eventItemClick: PropTypes.func,
|
|
786
|
-
viewEventClick: PropTypes.func,
|
|
787
|
-
viewEventText: PropTypes.string,
|
|
788
|
-
viewEvent2Click: PropTypes.func,
|
|
789
|
-
viewEvent2Text: PropTypes.string,
|
|
790
|
-
conflictOccurred: PropTypes.func,
|
|
791
|
-
eventItemTemplateResolver: PropTypes.func,
|
|
792
|
-
eventItemPopoverTemplateResolver: PropTypes.func
|
|
793
|
-
};
|
|
794
|
-
EventItem.defaultProps = {
|
|
795
|
-
isDragging: undefined,
|
|
796
|
-
dragRef: undefined,
|
|
797
|
-
dragPreviewRef: undefined,
|
|
798
|
-
updateEventStart: undefined,
|
|
799
|
-
updateEventEnd: undefined,
|
|
800
|
-
moveEvent: undefined,
|
|
801
|
-
subtitleGetter: undefined,
|
|
802
|
-
eventItemClick: undefined,
|
|
803
|
-
viewEventClick: undefined,
|
|
804
|
-
viewEventText: undefined,
|
|
805
|
-
viewEvent2Click: undefined,
|
|
806
|
-
viewEvent2Text: undefined,
|
|
807
|
-
conflictOccurred: undefined,
|
|
808
|
-
eventItemTemplateResolver: undefined,
|
|
809
|
-
eventItemPopoverTemplateResolver: undefined
|
|
810
|
-
};
|