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