@fullcalendar/interaction 4.0.2 → 4.4.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/main.esm.js ADDED
@@ -0,0 +1,2141 @@
1
+ /*!
2
+ FullCalendar Interaction Plugin v4.4.0
3
+ Docs & License: https://fullcalendar.io/
4
+ (c) 2019 Adam Shaw
5
+ */
6
+
7
+ import { config, elementClosest, EmitterMixin, applyStyle, whenTransitionDone, removeElement, ScrollController, ElementScrollController, computeInnerRect, WindowScrollController, preventSelection, preventContextMenu, allowSelection, allowContextMenu, ElementDragging, computeRect, getClippingParents, pointInsideRect, isDateSpansEqual, constrainPoint, intersectRects, getRectCenter, diffPoints, mapHash, rangeContainsRange, interactionSettingsToStore, Interaction, enableCursor, disableCursor, compareNumbers, getElSeg, getRelevantEvents, EventApi, createEmptyEventStore, applyMutationToEventStore, interactionSettingsStore, startOfDay, diffDates, createDuration, eventTupleToStore, isInteractionValid, parseDragMeta, elementMatches, parseEventDef, createEventInstance, globalDefaults, createPlugin } from '@fullcalendar/core';
8
+
9
+ /*! *****************************************************************************
10
+ Copyright (c) Microsoft Corporation. All rights reserved.
11
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
12
+ this file except in compliance with the License. You may obtain a copy of the
13
+ License at http://www.apache.org/licenses/LICENSE-2.0
14
+
15
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
17
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
18
+ MERCHANTABLITY OR NON-INFRINGEMENT.
19
+
20
+ See the Apache Version 2.0 License for specific language governing permissions
21
+ and limitations under the License.
22
+ ***************************************************************************** */
23
+ /* global Reflect, Promise */
24
+
25
+ var extendStatics = function(d, b) {
26
+ extendStatics = Object.setPrototypeOf ||
27
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
29
+ return extendStatics(d, b);
30
+ };
31
+
32
+ function __extends(d, b) {
33
+ extendStatics(d, b);
34
+ function __() { this.constructor = d; }
35
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
+ }
37
+
38
+ var __assign = function() {
39
+ __assign = Object.assign || function __assign(t) {
40
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
41
+ s = arguments[i];
42
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
43
+ }
44
+ return t;
45
+ };
46
+ return __assign.apply(this, arguments);
47
+ };
48
+
49
+ config.touchMouseIgnoreWait = 500;
50
+ var ignoreMouseDepth = 0;
51
+ var listenerCnt = 0;
52
+ var isWindowTouchMoveCancelled = false;
53
+ /*
54
+ Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
55
+ Tracks when the pointer "drags" on a certain element, meaning down+move+up.
56
+
57
+ Also, tracks if there was touch-scrolling.
58
+ Also, can prevent touch-scrolling from happening.
59
+ Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
60
+
61
+ emits:
62
+ - pointerdown
63
+ - pointermove
64
+ - pointerup
65
+ */
66
+ var PointerDragging = /** @class */ (function () {
67
+ function PointerDragging(containerEl) {
68
+ var _this = this;
69
+ this.subjectEl = null;
70
+ this.downEl = null;
71
+ // options that can be directly assigned by caller
72
+ this.selector = ''; // will cause subjectEl in all emitted events to be this element
73
+ this.handleSelector = '';
74
+ this.shouldIgnoreMove = false;
75
+ this.shouldWatchScroll = true; // for simulating pointermove on scroll
76
+ // internal states
77
+ this.isDragging = false;
78
+ this.isTouchDragging = false;
79
+ this.wasTouchScroll = false;
80
+ // Mouse
81
+ // ----------------------------------------------------------------------------------------------------
82
+ this.handleMouseDown = function (ev) {
83
+ if (!_this.shouldIgnoreMouse() &&
84
+ isPrimaryMouseButton(ev) &&
85
+ _this.tryStart(ev)) {
86
+ var pev = _this.createEventFromMouse(ev, true);
87
+ _this.emitter.trigger('pointerdown', pev);
88
+ _this.initScrollWatch(pev);
89
+ if (!_this.shouldIgnoreMove) {
90
+ document.addEventListener('mousemove', _this.handleMouseMove);
91
+ }
92
+ document.addEventListener('mouseup', _this.handleMouseUp);
93
+ }
94
+ };
95
+ this.handleMouseMove = function (ev) {
96
+ var pev = _this.createEventFromMouse(ev);
97
+ _this.recordCoords(pev);
98
+ _this.emitter.trigger('pointermove', pev);
99
+ };
100
+ this.handleMouseUp = function (ev) {
101
+ document.removeEventListener('mousemove', _this.handleMouseMove);
102
+ document.removeEventListener('mouseup', _this.handleMouseUp);
103
+ _this.emitter.trigger('pointerup', _this.createEventFromMouse(ev));
104
+ _this.cleanup(); // call last so that pointerup has access to props
105
+ };
106
+ // Touch
107
+ // ----------------------------------------------------------------------------------------------------
108
+ this.handleTouchStart = function (ev) {
109
+ if (_this.tryStart(ev)) {
110
+ _this.isTouchDragging = true;
111
+ var pev = _this.createEventFromTouch(ev, true);
112
+ _this.emitter.trigger('pointerdown', pev);
113
+ _this.initScrollWatch(pev);
114
+ // unlike mouse, need to attach to target, not document
115
+ // https://stackoverflow.com/a/45760014
116
+ var target = ev.target;
117
+ if (!_this.shouldIgnoreMove) {
118
+ target.addEventListener('touchmove', _this.handleTouchMove);
119
+ }
120
+ target.addEventListener('touchend', _this.handleTouchEnd);
121
+ target.addEventListener('touchcancel', _this.handleTouchEnd); // treat it as a touch end
122
+ // attach a handler to get called when ANY scroll action happens on the page.
123
+ // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
124
+ // http://stackoverflow.com/a/32954565/96342
125
+ window.addEventListener('scroll', _this.handleTouchScroll, true // useCapture
126
+ );
127
+ }
128
+ };
129
+ this.handleTouchMove = function (ev) {
130
+ var pev = _this.createEventFromTouch(ev);
131
+ _this.recordCoords(pev);
132
+ _this.emitter.trigger('pointermove', pev);
133
+ };
134
+ this.handleTouchEnd = function (ev) {
135
+ if (_this.isDragging) { // done to guard against touchend followed by touchcancel
136
+ var target = ev.target;
137
+ target.removeEventListener('touchmove', _this.handleTouchMove);
138
+ target.removeEventListener('touchend', _this.handleTouchEnd);
139
+ target.removeEventListener('touchcancel', _this.handleTouchEnd);
140
+ window.removeEventListener('scroll', _this.handleTouchScroll, true); // useCaptured=true
141
+ _this.emitter.trigger('pointerup', _this.createEventFromTouch(ev));
142
+ _this.cleanup(); // call last so that pointerup has access to props
143
+ _this.isTouchDragging = false;
144
+ startIgnoringMouse();
145
+ }
146
+ };
147
+ this.handleTouchScroll = function () {
148
+ _this.wasTouchScroll = true;
149
+ };
150
+ this.handleScroll = function (ev) {
151
+ if (!_this.shouldIgnoreMove) {
152
+ var pageX = (window.pageXOffset - _this.prevScrollX) + _this.prevPageX;
153
+ var pageY = (window.pageYOffset - _this.prevScrollY) + _this.prevPageY;
154
+ _this.emitter.trigger('pointermove', {
155
+ origEvent: ev,
156
+ isTouch: _this.isTouchDragging,
157
+ subjectEl: _this.subjectEl,
158
+ pageX: pageX,
159
+ pageY: pageY,
160
+ deltaX: pageX - _this.origPageX,
161
+ deltaY: pageY - _this.origPageY
162
+ });
163
+ }
164
+ };
165
+ this.containerEl = containerEl;
166
+ this.emitter = new EmitterMixin();
167
+ containerEl.addEventListener('mousedown', this.handleMouseDown);
168
+ containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
169
+ listenerCreated();
170
+ }
171
+ PointerDragging.prototype.destroy = function () {
172
+ this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
173
+ this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
174
+ listenerDestroyed();
175
+ };
176
+ PointerDragging.prototype.tryStart = function (ev) {
177
+ var subjectEl = this.querySubjectEl(ev);
178
+ var downEl = ev.target;
179
+ if (subjectEl &&
180
+ (!this.handleSelector || elementClosest(downEl, this.handleSelector))) {
181
+ this.subjectEl = subjectEl;
182
+ this.downEl = downEl;
183
+ this.isDragging = true; // do this first so cancelTouchScroll will work
184
+ this.wasTouchScroll = false;
185
+ return true;
186
+ }
187
+ return false;
188
+ };
189
+ PointerDragging.prototype.cleanup = function () {
190
+ isWindowTouchMoveCancelled = false;
191
+ this.isDragging = false;
192
+ this.subjectEl = null;
193
+ this.downEl = null;
194
+ // keep wasTouchScroll around for later access
195
+ this.destroyScrollWatch();
196
+ };
197
+ PointerDragging.prototype.querySubjectEl = function (ev) {
198
+ if (this.selector) {
199
+ return elementClosest(ev.target, this.selector);
200
+ }
201
+ else {
202
+ return this.containerEl;
203
+ }
204
+ };
205
+ PointerDragging.prototype.shouldIgnoreMouse = function () {
206
+ return ignoreMouseDepth || this.isTouchDragging;
207
+ };
208
+ // can be called by user of this class, to cancel touch-based scrolling for the current drag
209
+ PointerDragging.prototype.cancelTouchScroll = function () {
210
+ if (this.isDragging) {
211
+ isWindowTouchMoveCancelled = true;
212
+ }
213
+ };
214
+ // Scrolling that simulates pointermoves
215
+ // ----------------------------------------------------------------------------------------------------
216
+ PointerDragging.prototype.initScrollWatch = function (ev) {
217
+ if (this.shouldWatchScroll) {
218
+ this.recordCoords(ev);
219
+ window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
220
+ }
221
+ };
222
+ PointerDragging.prototype.recordCoords = function (ev) {
223
+ if (this.shouldWatchScroll) {
224
+ this.prevPageX = ev.pageX;
225
+ this.prevPageY = ev.pageY;
226
+ this.prevScrollX = window.pageXOffset;
227
+ this.prevScrollY = window.pageYOffset;
228
+ }
229
+ };
230
+ PointerDragging.prototype.destroyScrollWatch = function () {
231
+ if (this.shouldWatchScroll) {
232
+ window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
233
+ }
234
+ };
235
+ // Event Normalization
236
+ // ----------------------------------------------------------------------------------------------------
237
+ PointerDragging.prototype.createEventFromMouse = function (ev, isFirst) {
238
+ var deltaX = 0;
239
+ var deltaY = 0;
240
+ // TODO: repeat code
241
+ if (isFirst) {
242
+ this.origPageX = ev.pageX;
243
+ this.origPageY = ev.pageY;
244
+ }
245
+ else {
246
+ deltaX = ev.pageX - this.origPageX;
247
+ deltaY = ev.pageY - this.origPageY;
248
+ }
249
+ return {
250
+ origEvent: ev,
251
+ isTouch: false,
252
+ subjectEl: this.subjectEl,
253
+ pageX: ev.pageX,
254
+ pageY: ev.pageY,
255
+ deltaX: deltaX,
256
+ deltaY: deltaY
257
+ };
258
+ };
259
+ PointerDragging.prototype.createEventFromTouch = function (ev, isFirst) {
260
+ var touches = ev.touches;
261
+ var pageX;
262
+ var pageY;
263
+ var deltaX = 0;
264
+ var deltaY = 0;
265
+ // if touch coords available, prefer,
266
+ // because FF would give bad ev.pageX ev.pageY
267
+ if (touches && touches.length) {
268
+ pageX = touches[0].pageX;
269
+ pageY = touches[0].pageY;
270
+ }
271
+ else {
272
+ pageX = ev.pageX;
273
+ pageY = ev.pageY;
274
+ }
275
+ // TODO: repeat code
276
+ if (isFirst) {
277
+ this.origPageX = pageX;
278
+ this.origPageY = pageY;
279
+ }
280
+ else {
281
+ deltaX = pageX - this.origPageX;
282
+ deltaY = pageY - this.origPageY;
283
+ }
284
+ return {
285
+ origEvent: ev,
286
+ isTouch: true,
287
+ subjectEl: this.subjectEl,
288
+ pageX: pageX,
289
+ pageY: pageY,
290
+ deltaX: deltaX,
291
+ deltaY: deltaY
292
+ };
293
+ };
294
+ return PointerDragging;
295
+ }());
296
+ // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
297
+ function isPrimaryMouseButton(ev) {
298
+ return ev.button === 0 && !ev.ctrlKey;
299
+ }
300
+ // Ignoring fake mouse events generated by touch
301
+ // ----------------------------------------------------------------------------------------------------
302
+ function startIgnoringMouse() {
303
+ ignoreMouseDepth++;
304
+ setTimeout(function () {
305
+ ignoreMouseDepth--;
306
+ }, config.touchMouseIgnoreWait);
307
+ }
308
+ // We want to attach touchmove as early as possible for Safari
309
+ // ----------------------------------------------------------------------------------------------------
310
+ function listenerCreated() {
311
+ if (!(listenerCnt++)) {
312
+ window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
313
+ }
314
+ }
315
+ function listenerDestroyed() {
316
+ if (!(--listenerCnt)) {
317
+ window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
318
+ }
319
+ }
320
+ function onWindowTouchMove(ev) {
321
+ if (isWindowTouchMoveCancelled) {
322
+ ev.preventDefault();
323
+ }
324
+ }
325
+
326
+ /*
327
+ An effect in which an element follows the movement of a pointer across the screen.
328
+ The moving element is a clone of some other element.
329
+ Must call start + handleMove + stop.
330
+ */
331
+ var ElementMirror = /** @class */ (function () {
332
+ function ElementMirror() {
333
+ this.isVisible = false; // must be explicitly enabled
334
+ this.sourceEl = null;
335
+ this.mirrorEl = null;
336
+ this.sourceElRect = null; // screen coords relative to viewport
337
+ // options that can be set directly by caller
338
+ this.parentNode = document.body;
339
+ this.zIndex = 9999;
340
+ this.revertDuration = 0;
341
+ }
342
+ ElementMirror.prototype.start = function (sourceEl, pageX, pageY) {
343
+ this.sourceEl = sourceEl;
344
+ this.sourceElRect = this.sourceEl.getBoundingClientRect();
345
+ this.origScreenX = pageX - window.pageXOffset;
346
+ this.origScreenY = pageY - window.pageYOffset;
347
+ this.deltaX = 0;
348
+ this.deltaY = 0;
349
+ this.updateElPosition();
350
+ };
351
+ ElementMirror.prototype.handleMove = function (pageX, pageY) {
352
+ this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
353
+ this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
354
+ this.updateElPosition();
355
+ };
356
+ // can be called before start
357
+ ElementMirror.prototype.setIsVisible = function (bool) {
358
+ if (bool) {
359
+ if (!this.isVisible) {
360
+ if (this.mirrorEl) {
361
+ this.mirrorEl.style.display = '';
362
+ }
363
+ this.isVisible = bool; // needs to happen before updateElPosition
364
+ this.updateElPosition(); // because was not updating the position while invisible
365
+ }
366
+ }
367
+ else {
368
+ if (this.isVisible) {
369
+ if (this.mirrorEl) {
370
+ this.mirrorEl.style.display = 'none';
371
+ }
372
+ this.isVisible = bool;
373
+ }
374
+ }
375
+ };
376
+ // always async
377
+ ElementMirror.prototype.stop = function (needsRevertAnimation, callback) {
378
+ var _this = this;
379
+ var done = function () {
380
+ _this.cleanup();
381
+ callback();
382
+ };
383
+ if (needsRevertAnimation &&
384
+ this.mirrorEl &&
385
+ this.isVisible &&
386
+ this.revertDuration && // if 0, transition won't work
387
+ (this.deltaX || this.deltaY) // if same coords, transition won't work
388
+ ) {
389
+ this.doRevertAnimation(done, this.revertDuration);
390
+ }
391
+ else {
392
+ setTimeout(done, 0);
393
+ }
394
+ };
395
+ ElementMirror.prototype.doRevertAnimation = function (callback, revertDuration) {
396
+ var mirrorEl = this.mirrorEl;
397
+ var finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
398
+ mirrorEl.style.transition =
399
+ 'top ' + revertDuration + 'ms,' +
400
+ 'left ' + revertDuration + 'ms';
401
+ applyStyle(mirrorEl, {
402
+ left: finalSourceElRect.left,
403
+ top: finalSourceElRect.top
404
+ });
405
+ whenTransitionDone(mirrorEl, function () {
406
+ mirrorEl.style.transition = '';
407
+ callback();
408
+ });
409
+ };
410
+ ElementMirror.prototype.cleanup = function () {
411
+ if (this.mirrorEl) {
412
+ removeElement(this.mirrorEl);
413
+ this.mirrorEl = null;
414
+ }
415
+ this.sourceEl = null;
416
+ };
417
+ ElementMirror.prototype.updateElPosition = function () {
418
+ if (this.sourceEl && this.isVisible) {
419
+ applyStyle(this.getMirrorEl(), {
420
+ left: this.sourceElRect.left + this.deltaX,
421
+ top: this.sourceElRect.top + this.deltaY
422
+ });
423
+ }
424
+ };
425
+ ElementMirror.prototype.getMirrorEl = function () {
426
+ var sourceElRect = this.sourceElRect;
427
+ var mirrorEl = this.mirrorEl;
428
+ if (!mirrorEl) {
429
+ mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
430
+ // we don't want long taps or any mouse interaction causing selection/menus.
431
+ // would use preventSelection(), but that prevents selectstart, causing problems.
432
+ mirrorEl.classList.add('fc-unselectable');
433
+ mirrorEl.classList.add('fc-dragging');
434
+ applyStyle(mirrorEl, {
435
+ position: 'fixed',
436
+ zIndex: this.zIndex,
437
+ visibility: '',
438
+ boxSizing: 'border-box',
439
+ width: sourceElRect.right - sourceElRect.left,
440
+ height: sourceElRect.bottom - sourceElRect.top,
441
+ right: 'auto',
442
+ bottom: 'auto',
443
+ margin: 0
444
+ });
445
+ this.parentNode.appendChild(mirrorEl);
446
+ }
447
+ return mirrorEl;
448
+ };
449
+ return ElementMirror;
450
+ }());
451
+
452
+ /*
453
+ Is a cache for a given element's scroll information (all the info that ScrollController stores)
454
+ in addition the "client rectangle" of the element.. the area within the scrollbars.
455
+
456
+ The cache can be in one of two modes:
457
+ - doesListening:false - ignores when the container is scrolled by someone else
458
+ - doesListening:true - watch for scrolling and update the cache
459
+ */
460
+ var ScrollGeomCache = /** @class */ (function (_super) {
461
+ __extends(ScrollGeomCache, _super);
462
+ function ScrollGeomCache(scrollController, doesListening) {
463
+ var _this = _super.call(this) || this;
464
+ _this.handleScroll = function () {
465
+ _this.scrollTop = _this.scrollController.getScrollTop();
466
+ _this.scrollLeft = _this.scrollController.getScrollLeft();
467
+ _this.handleScrollChange();
468
+ };
469
+ _this.scrollController = scrollController;
470
+ _this.doesListening = doesListening;
471
+ _this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
472
+ _this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
473
+ _this.scrollWidth = scrollController.getScrollWidth();
474
+ _this.scrollHeight = scrollController.getScrollHeight();
475
+ _this.clientWidth = scrollController.getClientWidth();
476
+ _this.clientHeight = scrollController.getClientHeight();
477
+ _this.clientRect = _this.computeClientRect(); // do last in case it needs cached values
478
+ if (_this.doesListening) {
479
+ _this.getEventTarget().addEventListener('scroll', _this.handleScroll);
480
+ }
481
+ return _this;
482
+ }
483
+ ScrollGeomCache.prototype.destroy = function () {
484
+ if (this.doesListening) {
485
+ this.getEventTarget().removeEventListener('scroll', this.handleScroll);
486
+ }
487
+ };
488
+ ScrollGeomCache.prototype.getScrollTop = function () {
489
+ return this.scrollTop;
490
+ };
491
+ ScrollGeomCache.prototype.getScrollLeft = function () {
492
+ return this.scrollLeft;
493
+ };
494
+ ScrollGeomCache.prototype.setScrollTop = function (top) {
495
+ this.scrollController.setScrollTop(top);
496
+ if (!this.doesListening) {
497
+ // we are not relying on the element to normalize out-of-bounds scroll values
498
+ // so we need to sanitize ourselves
499
+ this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
500
+ this.handleScrollChange();
501
+ }
502
+ };
503
+ ScrollGeomCache.prototype.setScrollLeft = function (top) {
504
+ this.scrollController.setScrollLeft(top);
505
+ if (!this.doesListening) {
506
+ // we are not relying on the element to normalize out-of-bounds scroll values
507
+ // so we need to sanitize ourselves
508
+ this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
509
+ this.handleScrollChange();
510
+ }
511
+ };
512
+ ScrollGeomCache.prototype.getClientWidth = function () {
513
+ return this.clientWidth;
514
+ };
515
+ ScrollGeomCache.prototype.getClientHeight = function () {
516
+ return this.clientHeight;
517
+ };
518
+ ScrollGeomCache.prototype.getScrollWidth = function () {
519
+ return this.scrollWidth;
520
+ };
521
+ ScrollGeomCache.prototype.getScrollHeight = function () {
522
+ return this.scrollHeight;
523
+ };
524
+ ScrollGeomCache.prototype.handleScrollChange = function () {
525
+ };
526
+ return ScrollGeomCache;
527
+ }(ScrollController));
528
+ var ElementScrollGeomCache = /** @class */ (function (_super) {
529
+ __extends(ElementScrollGeomCache, _super);
530
+ function ElementScrollGeomCache(el, doesListening) {
531
+ return _super.call(this, new ElementScrollController(el), doesListening) || this;
532
+ }
533
+ ElementScrollGeomCache.prototype.getEventTarget = function () {
534
+ return this.scrollController.el;
535
+ };
536
+ ElementScrollGeomCache.prototype.computeClientRect = function () {
537
+ return computeInnerRect(this.scrollController.el);
538
+ };
539
+ return ElementScrollGeomCache;
540
+ }(ScrollGeomCache));
541
+ var WindowScrollGeomCache = /** @class */ (function (_super) {
542
+ __extends(WindowScrollGeomCache, _super);
543
+ function WindowScrollGeomCache(doesListening) {
544
+ return _super.call(this, new WindowScrollController(), doesListening) || this;
545
+ }
546
+ WindowScrollGeomCache.prototype.getEventTarget = function () {
547
+ return window;
548
+ };
549
+ WindowScrollGeomCache.prototype.computeClientRect = function () {
550
+ return {
551
+ left: this.scrollLeft,
552
+ right: this.scrollLeft + this.clientWidth,
553
+ top: this.scrollTop,
554
+ bottom: this.scrollTop + this.clientHeight
555
+ };
556
+ };
557
+ // the window is the only scroll object that changes it's rectangle relative
558
+ // to the document's topleft as it scrolls
559
+ WindowScrollGeomCache.prototype.handleScrollChange = function () {
560
+ this.clientRect = this.computeClientRect();
561
+ };
562
+ return WindowScrollGeomCache;
563
+ }(ScrollGeomCache));
564
+
565
+ // If available we are using native "performance" API instead of "Date"
566
+ // Read more about it on MDN:
567
+ // https://developer.mozilla.org/en-US/docs/Web/API/Performance
568
+ var getTime = typeof performance === 'function' ? performance.now : Date.now;
569
+ /*
570
+ For a pointer interaction, automatically scrolls certain scroll containers when the pointer
571
+ approaches the edge.
572
+
573
+ The caller must call start + handleMove + stop.
574
+ */
575
+ var AutoScroller = /** @class */ (function () {
576
+ function AutoScroller() {
577
+ var _this = this;
578
+ // options that can be set by caller
579
+ this.isEnabled = true;
580
+ this.scrollQuery = [window, '.fc-scroller'];
581
+ this.edgeThreshold = 50; // pixels
582
+ this.maxVelocity = 300; // pixels per second
583
+ // internal state
584
+ this.pointerScreenX = null;
585
+ this.pointerScreenY = null;
586
+ this.isAnimating = false;
587
+ this.scrollCaches = null;
588
+ // protect against the initial pointerdown being too close to an edge and starting the scroll
589
+ this.everMovedUp = false;
590
+ this.everMovedDown = false;
591
+ this.everMovedLeft = false;
592
+ this.everMovedRight = false;
593
+ this.animate = function () {
594
+ if (_this.isAnimating) { // wasn't cancelled between animation calls
595
+ var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
596
+ if (edge) {
597
+ var now = getTime();
598
+ _this.handleSide(edge, (now - _this.msSinceRequest) / 1000);
599
+ _this.requestAnimation(now);
600
+ }
601
+ else {
602
+ _this.isAnimating = false; // will stop animation
603
+ }
604
+ }
605
+ };
606
+ }
607
+ AutoScroller.prototype.start = function (pageX, pageY) {
608
+ if (this.isEnabled) {
609
+ this.scrollCaches = this.buildCaches();
610
+ this.pointerScreenX = null;
611
+ this.pointerScreenY = null;
612
+ this.everMovedUp = false;
613
+ this.everMovedDown = false;
614
+ this.everMovedLeft = false;
615
+ this.everMovedRight = false;
616
+ this.handleMove(pageX, pageY);
617
+ }
618
+ };
619
+ AutoScroller.prototype.handleMove = function (pageX, pageY) {
620
+ if (this.isEnabled) {
621
+ var pointerScreenX = pageX - window.pageXOffset;
622
+ var pointerScreenY = pageY - window.pageYOffset;
623
+ var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
624
+ var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
625
+ if (yDelta < 0) {
626
+ this.everMovedUp = true;
627
+ }
628
+ else if (yDelta > 0) {
629
+ this.everMovedDown = true;
630
+ }
631
+ if (xDelta < 0) {
632
+ this.everMovedLeft = true;
633
+ }
634
+ else if (xDelta > 0) {
635
+ this.everMovedRight = true;
636
+ }
637
+ this.pointerScreenX = pointerScreenX;
638
+ this.pointerScreenY = pointerScreenY;
639
+ if (!this.isAnimating) {
640
+ this.isAnimating = true;
641
+ this.requestAnimation(getTime());
642
+ }
643
+ }
644
+ };
645
+ AutoScroller.prototype.stop = function () {
646
+ if (this.isEnabled) {
647
+ this.isAnimating = false; // will stop animation
648
+ for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
649
+ var scrollCache = _a[_i];
650
+ scrollCache.destroy();
651
+ }
652
+ this.scrollCaches = null;
653
+ }
654
+ };
655
+ AutoScroller.prototype.requestAnimation = function (now) {
656
+ this.msSinceRequest = now;
657
+ requestAnimationFrame(this.animate);
658
+ };
659
+ AutoScroller.prototype.handleSide = function (edge, seconds) {
660
+ var scrollCache = edge.scrollCache;
661
+ var edgeThreshold = this.edgeThreshold;
662
+ var invDistance = edgeThreshold - edge.distance;
663
+ var velocity = // the closer to the edge, the faster we scroll
664
+ (invDistance * invDistance) / (edgeThreshold * edgeThreshold) * // quadratic
665
+ this.maxVelocity * seconds;
666
+ var sign = 1;
667
+ switch (edge.name) {
668
+ case 'left':
669
+ sign = -1;
670
+ // falls through
671
+ case 'right':
672
+ scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
673
+ break;
674
+ case 'top':
675
+ sign = -1;
676
+ // falls through
677
+ case 'bottom':
678
+ scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
679
+ break;
680
+ }
681
+ };
682
+ // left/top are relative to document topleft
683
+ AutoScroller.prototype.computeBestEdge = function (left, top) {
684
+ var edgeThreshold = this.edgeThreshold;
685
+ var bestSide = null;
686
+ for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
687
+ var scrollCache = _a[_i];
688
+ var rect = scrollCache.clientRect;
689
+ var leftDist = left - rect.left;
690
+ var rightDist = rect.right - left;
691
+ var topDist = top - rect.top;
692
+ var bottomDist = rect.bottom - top;
693
+ // completely within the rect?
694
+ if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
695
+ if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
696
+ (!bestSide || bestSide.distance > topDist)) {
697
+ bestSide = { scrollCache: scrollCache, name: 'top', distance: topDist };
698
+ }
699
+ if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
700
+ (!bestSide || bestSide.distance > bottomDist)) {
701
+ bestSide = { scrollCache: scrollCache, name: 'bottom', distance: bottomDist };
702
+ }
703
+ if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
704
+ (!bestSide || bestSide.distance > leftDist)) {
705
+ bestSide = { scrollCache: scrollCache, name: 'left', distance: leftDist };
706
+ }
707
+ if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
708
+ (!bestSide || bestSide.distance > rightDist)) {
709
+ bestSide = { scrollCache: scrollCache, name: 'right', distance: rightDist };
710
+ }
711
+ }
712
+ }
713
+ return bestSide;
714
+ };
715
+ AutoScroller.prototype.buildCaches = function () {
716
+ return this.queryScrollEls().map(function (el) {
717
+ if (el === window) {
718
+ return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
719
+ }
720
+ else {
721
+ return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
722
+ }
723
+ });
724
+ };
725
+ AutoScroller.prototype.queryScrollEls = function () {
726
+ var els = [];
727
+ for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
728
+ var query = _a[_i];
729
+ if (typeof query === 'object') {
730
+ els.push(query);
731
+ }
732
+ else {
733
+ els.push.apply(els, Array.prototype.slice.call(document.querySelectorAll(query)));
734
+ }
735
+ }
736
+ return els;
737
+ };
738
+ return AutoScroller;
739
+ }());
740
+
741
+ /*
742
+ Monitors dragging on an element. Has a number of high-level features:
743
+ - minimum distance required before dragging
744
+ - minimum wait time ("delay") before dragging
745
+ - a mirror element that follows the pointer
746
+ */
747
+ var FeaturefulElementDragging = /** @class */ (function (_super) {
748
+ __extends(FeaturefulElementDragging, _super);
749
+ function FeaturefulElementDragging(containerEl) {
750
+ var _this = _super.call(this, containerEl) || this;
751
+ // options that can be directly set by caller
752
+ // the caller can also set the PointerDragging's options as well
753
+ _this.delay = null;
754
+ _this.minDistance = 0;
755
+ _this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
756
+ _this.mirrorNeedsRevert = false;
757
+ _this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
758
+ _this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
759
+ _this.isDelayEnded = false;
760
+ _this.isDistanceSurpassed = false;
761
+ _this.delayTimeoutId = null;
762
+ _this.onPointerDown = function (ev) {
763
+ if (!_this.isDragging) { // so new drag doesn't happen while revert animation is going
764
+ _this.isInteracting = true;
765
+ _this.isDelayEnded = false;
766
+ _this.isDistanceSurpassed = false;
767
+ preventSelection(document.body);
768
+ preventContextMenu(document.body);
769
+ // prevent links from being visited if there's an eventual drag.
770
+ // also prevents selection in older browsers (maybe?).
771
+ // not necessary for touch, besides, browser would complain about passiveness.
772
+ if (!ev.isTouch) {
773
+ ev.origEvent.preventDefault();
774
+ }
775
+ _this.emitter.trigger('pointerdown', ev);
776
+ if (!_this.pointer.shouldIgnoreMove) {
777
+ // actions related to initiating dragstart+dragmove+dragend...
778
+ _this.mirror.setIsVisible(false); // reset. caller must set-visible
779
+ _this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
780
+ _this.startDelay(ev);
781
+ if (!_this.minDistance) {
782
+ _this.handleDistanceSurpassed(ev);
783
+ }
784
+ }
785
+ }
786
+ };
787
+ _this.onPointerMove = function (ev) {
788
+ if (_this.isInteracting) { // if false, still waiting for previous drag's revert
789
+ _this.emitter.trigger('pointermove', ev);
790
+ if (!_this.isDistanceSurpassed) {
791
+ var minDistance = _this.minDistance;
792
+ var distanceSq = void 0; // current distance from the origin, squared
793
+ var deltaX = ev.deltaX, deltaY = ev.deltaY;
794
+ distanceSq = deltaX * deltaX + deltaY * deltaY;
795
+ if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
796
+ _this.handleDistanceSurpassed(ev);
797
+ }
798
+ }
799
+ if (_this.isDragging) {
800
+ // a real pointer move? (not one simulated by scrolling)
801
+ if (ev.origEvent.type !== 'scroll') {
802
+ _this.mirror.handleMove(ev.pageX, ev.pageY);
803
+ _this.autoScroller.handleMove(ev.pageX, ev.pageY);
804
+ }
805
+ _this.emitter.trigger('dragmove', ev);
806
+ }
807
+ }
808
+ };
809
+ _this.onPointerUp = function (ev) {
810
+ if (_this.isInteracting) { // if false, still waiting for previous drag's revert
811
+ _this.isInteracting = false;
812
+ allowSelection(document.body);
813
+ allowContextMenu(document.body);
814
+ _this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
815
+ if (_this.isDragging) {
816
+ _this.autoScroller.stop();
817
+ _this.tryStopDrag(ev); // which will stop the mirror
818
+ }
819
+ if (_this.delayTimeoutId) {
820
+ clearTimeout(_this.delayTimeoutId);
821
+ _this.delayTimeoutId = null;
822
+ }
823
+ }
824
+ };
825
+ var pointer = _this.pointer = new PointerDragging(containerEl);
826
+ pointer.emitter.on('pointerdown', _this.onPointerDown);
827
+ pointer.emitter.on('pointermove', _this.onPointerMove);
828
+ pointer.emitter.on('pointerup', _this.onPointerUp);
829
+ _this.mirror = new ElementMirror();
830
+ _this.autoScroller = new AutoScroller();
831
+ return _this;
832
+ }
833
+ FeaturefulElementDragging.prototype.destroy = function () {
834
+ this.pointer.destroy();
835
+ };
836
+ FeaturefulElementDragging.prototype.startDelay = function (ev) {
837
+ var _this = this;
838
+ if (typeof this.delay === 'number') {
839
+ this.delayTimeoutId = setTimeout(function () {
840
+ _this.delayTimeoutId = null;
841
+ _this.handleDelayEnd(ev);
842
+ }, this.delay); // not assignable to number!
843
+ }
844
+ else {
845
+ this.handleDelayEnd(ev);
846
+ }
847
+ };
848
+ FeaturefulElementDragging.prototype.handleDelayEnd = function (ev) {
849
+ this.isDelayEnded = true;
850
+ this.tryStartDrag(ev);
851
+ };
852
+ FeaturefulElementDragging.prototype.handleDistanceSurpassed = function (ev) {
853
+ this.isDistanceSurpassed = true;
854
+ this.tryStartDrag(ev);
855
+ };
856
+ FeaturefulElementDragging.prototype.tryStartDrag = function (ev) {
857
+ if (this.isDelayEnded && this.isDistanceSurpassed) {
858
+ if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
859
+ this.isDragging = true;
860
+ this.mirrorNeedsRevert = false;
861
+ this.autoScroller.start(ev.pageX, ev.pageY);
862
+ this.emitter.trigger('dragstart', ev);
863
+ if (this.touchScrollAllowed === false) {
864
+ this.pointer.cancelTouchScroll();
865
+ }
866
+ }
867
+ }
868
+ };
869
+ FeaturefulElementDragging.prototype.tryStopDrag = function (ev) {
870
+ // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
871
+ // that come from the document to fire beforehand. much more convenient this way.
872
+ this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev) // bound with args
873
+ );
874
+ };
875
+ FeaturefulElementDragging.prototype.stopDrag = function (ev) {
876
+ this.isDragging = false;
877
+ this.emitter.trigger('dragend', ev);
878
+ };
879
+ // fill in the implementations...
880
+ FeaturefulElementDragging.prototype.setIgnoreMove = function (bool) {
881
+ this.pointer.shouldIgnoreMove = bool;
882
+ };
883
+ FeaturefulElementDragging.prototype.setMirrorIsVisible = function (bool) {
884
+ this.mirror.setIsVisible(bool);
885
+ };
886
+ FeaturefulElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
887
+ this.mirrorNeedsRevert = bool;
888
+ };
889
+ FeaturefulElementDragging.prototype.setAutoScrollEnabled = function (bool) {
890
+ this.autoScroller.isEnabled = bool;
891
+ };
892
+ return FeaturefulElementDragging;
893
+ }(ElementDragging));
894
+
895
+ /*
896
+ When this class is instantiated, it records the offset of an element (relative to the document topleft),
897
+ and continues to monitor scrolling, updating the cached coordinates if it needs to.
898
+ Does not access the DOM after instantiation, so highly performant.
899
+
900
+ Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
901
+ and an determine if a given point is inside the combined clipping rectangle.
902
+ */
903
+ var OffsetTracker = /** @class */ (function () {
904
+ function OffsetTracker(el) {
905
+ this.origRect = computeRect(el);
906
+ // will work fine for divs that have overflow:hidden
907
+ this.scrollCaches = getClippingParents(el).map(function (el) {
908
+ return new ElementScrollGeomCache(el, true); // listen=true
909
+ });
910
+ }
911
+ OffsetTracker.prototype.destroy = function () {
912
+ for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
913
+ var scrollCache = _a[_i];
914
+ scrollCache.destroy();
915
+ }
916
+ };
917
+ OffsetTracker.prototype.computeLeft = function () {
918
+ var left = this.origRect.left;
919
+ for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
920
+ var scrollCache = _a[_i];
921
+ left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
922
+ }
923
+ return left;
924
+ };
925
+ OffsetTracker.prototype.computeTop = function () {
926
+ var top = this.origRect.top;
927
+ for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
928
+ var scrollCache = _a[_i];
929
+ top += scrollCache.origScrollTop - scrollCache.getScrollTop();
930
+ }
931
+ return top;
932
+ };
933
+ OffsetTracker.prototype.isWithinClipping = function (pageX, pageY) {
934
+ var point = { left: pageX, top: pageY };
935
+ for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
936
+ var scrollCache = _a[_i];
937
+ if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
938
+ !pointInsideRect(point, scrollCache.clientRect)) {
939
+ return false;
940
+ }
941
+ }
942
+ return true;
943
+ };
944
+ return OffsetTracker;
945
+ }());
946
+ // certain clipping containers should never constrain interactions, like <html> and <body>
947
+ // https://github.com/fullcalendar/fullcalendar/issues/3615
948
+ function isIgnoredClipping(node) {
949
+ var tagName = node.tagName;
950
+ return tagName === 'HTML' || tagName === 'BODY';
951
+ }
952
+
953
+ /*
954
+ Tracks movement over multiple droppable areas (aka "hits")
955
+ that exist in one or more DateComponents.
956
+ Relies on an existing draggable.
957
+
958
+ emits:
959
+ - pointerdown
960
+ - dragstart
961
+ - hitchange - fires initially, even if not over a hit
962
+ - pointerup
963
+ - (hitchange - again, to null, if ended over a hit)
964
+ - dragend
965
+ */
966
+ var HitDragging = /** @class */ (function () {
967
+ function HitDragging(dragging, droppableStore) {
968
+ var _this = this;
969
+ // options that can be set by caller
970
+ this.useSubjectCenter = false;
971
+ this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
972
+ this.initialHit = null;
973
+ this.movingHit = null;
974
+ this.finalHit = null; // won't ever be populated if shouldIgnoreMove
975
+ this.handlePointerDown = function (ev) {
976
+ var dragging = _this.dragging;
977
+ _this.initialHit = null;
978
+ _this.movingHit = null;
979
+ _this.finalHit = null;
980
+ _this.prepareHits();
981
+ _this.processFirstCoord(ev);
982
+ if (_this.initialHit || !_this.requireInitial) {
983
+ dragging.setIgnoreMove(false);
984
+ _this.emitter.trigger('pointerdown', ev); // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
985
+ }
986
+ else {
987
+ dragging.setIgnoreMove(true);
988
+ }
989
+ };
990
+ this.handleDragStart = function (ev) {
991
+ _this.emitter.trigger('dragstart', ev);
992
+ _this.handleMove(ev, true); // force = fire even if initially null
993
+ };
994
+ this.handleDragMove = function (ev) {
995
+ _this.emitter.trigger('dragmove', ev);
996
+ _this.handleMove(ev);
997
+ };
998
+ this.handlePointerUp = function (ev) {
999
+ _this.releaseHits();
1000
+ _this.emitter.trigger('pointerup', ev);
1001
+ };
1002
+ this.handleDragEnd = function (ev) {
1003
+ if (_this.movingHit) {
1004
+ _this.emitter.trigger('hitupdate', null, true, ev);
1005
+ }
1006
+ _this.finalHit = _this.movingHit;
1007
+ _this.movingHit = null;
1008
+ _this.emitter.trigger('dragend', ev);
1009
+ };
1010
+ this.droppableStore = droppableStore;
1011
+ dragging.emitter.on('pointerdown', this.handlePointerDown);
1012
+ dragging.emitter.on('dragstart', this.handleDragStart);
1013
+ dragging.emitter.on('dragmove', this.handleDragMove);
1014
+ dragging.emitter.on('pointerup', this.handlePointerUp);
1015
+ dragging.emitter.on('dragend', this.handleDragEnd);
1016
+ this.dragging = dragging;
1017
+ this.emitter = new EmitterMixin();
1018
+ }
1019
+ // sets initialHit
1020
+ // sets coordAdjust
1021
+ HitDragging.prototype.processFirstCoord = function (ev) {
1022
+ var origPoint = { left: ev.pageX, top: ev.pageY };
1023
+ var adjustedPoint = origPoint;
1024
+ var subjectEl = ev.subjectEl;
1025
+ var subjectRect;
1026
+ if (subjectEl !== document) {
1027
+ subjectRect = computeRect(subjectEl);
1028
+ adjustedPoint = constrainPoint(adjustedPoint, subjectRect);
1029
+ }
1030
+ var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
1031
+ if (initialHit) {
1032
+ if (this.useSubjectCenter && subjectRect) {
1033
+ var slicedSubjectRect = intersectRects(subjectRect, initialHit.rect);
1034
+ if (slicedSubjectRect) {
1035
+ adjustedPoint = getRectCenter(slicedSubjectRect);
1036
+ }
1037
+ }
1038
+ this.coordAdjust = diffPoints(adjustedPoint, origPoint);
1039
+ }
1040
+ else {
1041
+ this.coordAdjust = { left: 0, top: 0 };
1042
+ }
1043
+ };
1044
+ HitDragging.prototype.handleMove = function (ev, forceHandle) {
1045
+ var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
1046
+ if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
1047
+ this.movingHit = hit;
1048
+ this.emitter.trigger('hitupdate', hit, false, ev);
1049
+ }
1050
+ };
1051
+ HitDragging.prototype.prepareHits = function () {
1052
+ this.offsetTrackers = mapHash(this.droppableStore, function (interactionSettings) {
1053
+ interactionSettings.component.buildPositionCaches();
1054
+ return new OffsetTracker(interactionSettings.el);
1055
+ });
1056
+ };
1057
+ HitDragging.prototype.releaseHits = function () {
1058
+ var offsetTrackers = this.offsetTrackers;
1059
+ for (var id in offsetTrackers) {
1060
+ offsetTrackers[id].destroy();
1061
+ }
1062
+ this.offsetTrackers = {};
1063
+ };
1064
+ HitDragging.prototype.queryHitForOffset = function (offsetLeft, offsetTop) {
1065
+ var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
1066
+ var bestHit = null;
1067
+ for (var id in droppableStore) {
1068
+ var component = droppableStore[id].component;
1069
+ var offsetTracker = offsetTrackers[id];
1070
+ if (offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
1071
+ var originLeft = offsetTracker.computeLeft();
1072
+ var originTop = offsetTracker.computeTop();
1073
+ var positionLeft = offsetLeft - originLeft;
1074
+ var positionTop = offsetTop - originTop;
1075
+ var origRect = offsetTracker.origRect;
1076
+ var width = origRect.right - origRect.left;
1077
+ var height = origRect.bottom - origRect.top;
1078
+ if (
1079
+ // must be within the element's bounds
1080
+ positionLeft >= 0 && positionLeft < width &&
1081
+ positionTop >= 0 && positionTop < height) {
1082
+ var hit = component.queryHit(positionLeft, positionTop, width, height);
1083
+ if (hit &&
1084
+ (
1085
+ // make sure the hit is within activeRange, meaning it's not a deal cell
1086
+ !component.props.dateProfile || // hack for DayTile
1087
+ rangeContainsRange(component.props.dateProfile.activeRange, hit.dateSpan.range)) &&
1088
+ (!bestHit || hit.layer > bestHit.layer)) {
1089
+ // TODO: better way to re-orient rectangle
1090
+ hit.rect.left += originLeft;
1091
+ hit.rect.right += originLeft;
1092
+ hit.rect.top += originTop;
1093
+ hit.rect.bottom += originTop;
1094
+ bestHit = hit;
1095
+ }
1096
+ }
1097
+ }
1098
+ }
1099
+ return bestHit;
1100
+ };
1101
+ return HitDragging;
1102
+ }());
1103
+ function isHitsEqual(hit0, hit1) {
1104
+ if (!hit0 && !hit1) {
1105
+ return true;
1106
+ }
1107
+ if (Boolean(hit0) !== Boolean(hit1)) {
1108
+ return false;
1109
+ }
1110
+ return isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
1111
+ }
1112
+
1113
+ /*
1114
+ Monitors when the user clicks on a specific date/time of a component.
1115
+ A pointerdown+pointerup on the same "hit" constitutes a click.
1116
+ */
1117
+ var DateClicking = /** @class */ (function (_super) {
1118
+ __extends(DateClicking, _super);
1119
+ function DateClicking(settings) {
1120
+ var _this = _super.call(this, settings) || this;
1121
+ _this.handlePointerDown = function (ev) {
1122
+ var dragging = _this.dragging;
1123
+ // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
1124
+ dragging.setIgnoreMove(!_this.component.isValidDateDownEl(dragging.pointer.downEl));
1125
+ };
1126
+ // won't even fire if moving was ignored
1127
+ _this.handleDragEnd = function (ev) {
1128
+ var component = _this.component;
1129
+ var _a = component.context, calendar = _a.calendar, view = _a.view;
1130
+ var pointer = _this.dragging.pointer;
1131
+ if (!pointer.wasTouchScroll) {
1132
+ var _b = _this.hitDragging, initialHit = _b.initialHit, finalHit = _b.finalHit;
1133
+ if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
1134
+ calendar.triggerDateClick(initialHit.dateSpan, initialHit.dayEl, view, ev.origEvent);
1135
+ }
1136
+ }
1137
+ };
1138
+ var component = settings.component;
1139
+ // we DO want to watch pointer moves because otherwise finalHit won't get populated
1140
+ _this.dragging = new FeaturefulElementDragging(component.el);
1141
+ _this.dragging.autoScroller.isEnabled = false;
1142
+ var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
1143
+ hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1144
+ hitDragging.emitter.on('dragend', _this.handleDragEnd);
1145
+ return _this;
1146
+ }
1147
+ DateClicking.prototype.destroy = function () {
1148
+ this.dragging.destroy();
1149
+ };
1150
+ return DateClicking;
1151
+ }(Interaction));
1152
+
1153
+ /*
1154
+ Tracks when the user selects a portion of time of a component,
1155
+ constituted by a drag over date cells, with a possible delay at the beginning of the drag.
1156
+ */
1157
+ var DateSelecting = /** @class */ (function (_super) {
1158
+ __extends(DateSelecting, _super);
1159
+ function DateSelecting(settings) {
1160
+ var _this = _super.call(this, settings) || this;
1161
+ _this.dragSelection = null;
1162
+ _this.handlePointerDown = function (ev) {
1163
+ var _a = _this, component = _a.component, dragging = _a.dragging;
1164
+ var options = component.context.options;
1165
+ var canSelect = options.selectable &&
1166
+ component.isValidDateDownEl(ev.origEvent.target);
1167
+ // don't bother to watch expensive moves if component won't do selection
1168
+ dragging.setIgnoreMove(!canSelect);
1169
+ // if touch, require user to hold down
1170
+ dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null;
1171
+ };
1172
+ _this.handleDragStart = function (ev) {
1173
+ _this.component.context.calendar.unselect(ev); // unselect previous selections
1174
+ };
1175
+ _this.handleHitUpdate = function (hit, isFinal) {
1176
+ var calendar = _this.component.context.calendar;
1177
+ var dragSelection = null;
1178
+ var isInvalid = false;
1179
+ if (hit) {
1180
+ dragSelection = joinHitsIntoSelection(_this.hitDragging.initialHit, hit, calendar.pluginSystem.hooks.dateSelectionTransformers);
1181
+ if (!dragSelection || !_this.component.isDateSelectionValid(dragSelection)) {
1182
+ isInvalid = true;
1183
+ dragSelection = null;
1184
+ }
1185
+ }
1186
+ if (dragSelection) {
1187
+ calendar.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
1188
+ }
1189
+ else if (!isFinal) { // only unselect if moved away while dragging
1190
+ calendar.dispatch({ type: 'UNSELECT_DATES' });
1191
+ }
1192
+ if (!isInvalid) {
1193
+ enableCursor();
1194
+ }
1195
+ else {
1196
+ disableCursor();
1197
+ }
1198
+ if (!isFinal) {
1199
+ _this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
1200
+ }
1201
+ };
1202
+ _this.handlePointerUp = function (pev) {
1203
+ if (_this.dragSelection) {
1204
+ // selection is already rendered, so just need to report selection
1205
+ _this.component.context.calendar.triggerDateSelect(_this.dragSelection, pev);
1206
+ _this.dragSelection = null;
1207
+ }
1208
+ };
1209
+ var component = settings.component;
1210
+ var options = component.context.options;
1211
+ var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
1212
+ dragging.touchScrollAllowed = false;
1213
+ dragging.minDistance = options.selectMinDistance || 0;
1214
+ dragging.autoScroller.isEnabled = options.dragScroll;
1215
+ var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
1216
+ hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1217
+ hitDragging.emitter.on('dragstart', _this.handleDragStart);
1218
+ hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
1219
+ hitDragging.emitter.on('pointerup', _this.handlePointerUp);
1220
+ return _this;
1221
+ }
1222
+ DateSelecting.prototype.destroy = function () {
1223
+ this.dragging.destroy();
1224
+ };
1225
+ return DateSelecting;
1226
+ }(Interaction));
1227
+ function getComponentTouchDelay(component) {
1228
+ var options = component.context.options;
1229
+ var delay = options.selectLongPressDelay;
1230
+ if (delay == null) {
1231
+ delay = options.longPressDelay;
1232
+ }
1233
+ return delay;
1234
+ }
1235
+ function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
1236
+ var dateSpan0 = hit0.dateSpan;
1237
+ var dateSpan1 = hit1.dateSpan;
1238
+ var ms = [
1239
+ dateSpan0.range.start,
1240
+ dateSpan0.range.end,
1241
+ dateSpan1.range.start,
1242
+ dateSpan1.range.end
1243
+ ];
1244
+ ms.sort(compareNumbers);
1245
+ var props = {};
1246
+ for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
1247
+ var transformer = dateSelectionTransformers_1[_i];
1248
+ var res = transformer(hit0, hit1);
1249
+ if (res === false) {
1250
+ return null;
1251
+ }
1252
+ else if (res) {
1253
+ __assign(props, res);
1254
+ }
1255
+ }
1256
+ props.range = { start: ms[0], end: ms[3] };
1257
+ props.allDay = dateSpan0.allDay;
1258
+ return props;
1259
+ }
1260
+
1261
+ var EventDragging = /** @class */ (function (_super) {
1262
+ __extends(EventDragging, _super);
1263
+ function EventDragging(settings) {
1264
+ var _this = _super.call(this, settings) || this;
1265
+ // internal state
1266
+ _this.subjectSeg = null; // the seg being selected/dragged
1267
+ _this.isDragging = false;
1268
+ _this.eventRange = null;
1269
+ _this.relevantEvents = null; // the events being dragged
1270
+ _this.receivingCalendar = null;
1271
+ _this.validMutation = null;
1272
+ _this.mutatedRelevantEvents = null;
1273
+ _this.handlePointerDown = function (ev) {
1274
+ var origTarget = ev.origEvent.target;
1275
+ var _a = _this, component = _a.component, dragging = _a.dragging;
1276
+ var mirror = dragging.mirror;
1277
+ var options = component.context.options;
1278
+ var initialCalendar = component.context.calendar;
1279
+ var subjectSeg = _this.subjectSeg = getElSeg(ev.subjectEl);
1280
+ var eventRange = _this.eventRange = subjectSeg.eventRange;
1281
+ var eventInstanceId = eventRange.instance.instanceId;
1282
+ _this.relevantEvents = getRelevantEvents(initialCalendar.state.eventStore, eventInstanceId);
1283
+ dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
1284
+ dragging.delay =
1285
+ // only do a touch delay if touch and this event hasn't been selected yet
1286
+ (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
1287
+ getComponentTouchDelay$1(component) :
1288
+ null;
1289
+ mirror.parentNode = initialCalendar.el;
1290
+ mirror.revertDuration = options.dragRevertDuration;
1291
+ var isValid = component.isValidSegDownEl(origTarget) &&
1292
+ !elementClosest(origTarget, '.fc-resizer'); // NOT on a resizer
1293
+ dragging.setIgnoreMove(!isValid);
1294
+ // disable dragging for elements that are resizable (ie, selectable)
1295
+ // but are not draggable
1296
+ _this.isDragging = isValid &&
1297
+ ev.subjectEl.classList.contains('fc-draggable');
1298
+ };
1299
+ _this.handleDragStart = function (ev) {
1300
+ var context = _this.component.context;
1301
+ var initialCalendar = context.calendar;
1302
+ var eventRange = _this.eventRange;
1303
+ var eventInstanceId = eventRange.instance.instanceId;
1304
+ if (ev.isTouch) {
1305
+ // need to select a different event?
1306
+ if (eventInstanceId !== _this.component.props.eventSelection) {
1307
+ initialCalendar.dispatch({ type: 'SELECT_EVENT', eventInstanceId: eventInstanceId });
1308
+ }
1309
+ }
1310
+ else {
1311
+ // if now using mouse, but was previous touch interaction, clear selected event
1312
+ initialCalendar.dispatch({ type: 'UNSELECT_EVENT' });
1313
+ }
1314
+ if (_this.isDragging) {
1315
+ initialCalendar.unselect(ev); // unselect *date* selection
1316
+ initialCalendar.publiclyTrigger('eventDragStart', [
1317
+ {
1318
+ el: _this.subjectSeg.el,
1319
+ event: new EventApi(initialCalendar, eventRange.def, eventRange.instance),
1320
+ jsEvent: ev.origEvent,
1321
+ view: context.view
1322
+ }
1323
+ ]);
1324
+ }
1325
+ };
1326
+ _this.handleHitUpdate = function (hit, isFinal) {
1327
+ if (!_this.isDragging) {
1328
+ return;
1329
+ }
1330
+ var relevantEvents = _this.relevantEvents;
1331
+ var initialHit = _this.hitDragging.initialHit;
1332
+ var initialCalendar = _this.component.context.calendar;
1333
+ // states based on new hit
1334
+ var receivingCalendar = null;
1335
+ var mutation = null;
1336
+ var mutatedRelevantEvents = null;
1337
+ var isInvalid = false;
1338
+ var interaction = {
1339
+ affectedEvents: relevantEvents,
1340
+ mutatedEvents: createEmptyEventStore(),
1341
+ isEvent: true,
1342
+ origSeg: _this.subjectSeg
1343
+ };
1344
+ if (hit) {
1345
+ var receivingComponent = hit.component;
1346
+ receivingCalendar = receivingComponent.context.calendar;
1347
+ var receivingOptions = receivingComponent.context.options;
1348
+ if (initialCalendar === receivingCalendar ||
1349
+ receivingOptions.editable && receivingOptions.droppable) {
1350
+ mutation = computeEventMutation(initialHit, hit, receivingCalendar.pluginSystem.hooks.eventDragMutationMassagers);
1351
+ if (mutation) {
1352
+ mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, receivingCalendar.eventUiBases, mutation, receivingCalendar);
1353
+ interaction.mutatedEvents = mutatedRelevantEvents;
1354
+ if (!receivingComponent.isInteractionValid(interaction)) {
1355
+ isInvalid = true;
1356
+ mutation = null;
1357
+ mutatedRelevantEvents = null;
1358
+ interaction.mutatedEvents = createEmptyEventStore();
1359
+ }
1360
+ }
1361
+ }
1362
+ else {
1363
+ receivingCalendar = null;
1364
+ }
1365
+ }
1366
+ _this.displayDrag(receivingCalendar, interaction);
1367
+ if (!isInvalid) {
1368
+ enableCursor();
1369
+ }
1370
+ else {
1371
+ disableCursor();
1372
+ }
1373
+ if (!isFinal) {
1374
+ if (initialCalendar === receivingCalendar && // TODO: write test for this
1375
+ isHitsEqual(initialHit, hit)) {
1376
+ mutation = null;
1377
+ }
1378
+ _this.dragging.setMirrorNeedsRevert(!mutation);
1379
+ // render the mirror if no already-rendered mirror
1380
+ // TODO: wish we could somehow wait for dispatch to guarantee render
1381
+ _this.dragging.setMirrorIsVisible(!hit || !document.querySelector('.fc-mirror'));
1382
+ // assign states based on new hit
1383
+ _this.receivingCalendar = receivingCalendar;
1384
+ _this.validMutation = mutation;
1385
+ _this.mutatedRelevantEvents = mutatedRelevantEvents;
1386
+ }
1387
+ };
1388
+ _this.handlePointerUp = function () {
1389
+ if (!_this.isDragging) {
1390
+ _this.cleanup(); // because handleDragEnd won't fire
1391
+ }
1392
+ };
1393
+ _this.handleDragEnd = function (ev) {
1394
+ if (_this.isDragging) {
1395
+ var context = _this.component.context;
1396
+ var initialCalendar_1 = context.calendar;
1397
+ var initialView = context.view;
1398
+ var _a = _this, receivingCalendar = _a.receivingCalendar, validMutation = _a.validMutation;
1399
+ var eventDef = _this.eventRange.def;
1400
+ var eventInstance = _this.eventRange.instance;
1401
+ var eventApi = new EventApi(initialCalendar_1, eventDef, eventInstance);
1402
+ var relevantEvents_1 = _this.relevantEvents;
1403
+ var mutatedRelevantEvents = _this.mutatedRelevantEvents;
1404
+ var finalHit = _this.hitDragging.finalHit;
1405
+ _this.clearDrag(); // must happen after revert animation
1406
+ initialCalendar_1.publiclyTrigger('eventDragStop', [
1407
+ {
1408
+ el: _this.subjectSeg.el,
1409
+ event: eventApi,
1410
+ jsEvent: ev.origEvent,
1411
+ view: initialView
1412
+ }
1413
+ ]);
1414
+ if (validMutation) {
1415
+ // dropped within same calendar
1416
+ if (receivingCalendar === initialCalendar_1) {
1417
+ initialCalendar_1.dispatch({
1418
+ type: 'MERGE_EVENTS',
1419
+ eventStore: mutatedRelevantEvents
1420
+ });
1421
+ var transformed = {};
1422
+ for (var _i = 0, _b = initialCalendar_1.pluginSystem.hooks.eventDropTransformers; _i < _b.length; _i++) {
1423
+ var transformer = _b[_i];
1424
+ __assign(transformed, transformer(validMutation, initialCalendar_1));
1425
+ }
1426
+ var eventDropArg = __assign({}, transformed, { el: ev.subjectEl, delta: validMutation.datesDelta, oldEvent: eventApi, event: new EventApi(// the data AFTER the mutation
1427
+ initialCalendar_1, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null), revert: function () {
1428
+ initialCalendar_1.dispatch({
1429
+ type: 'MERGE_EVENTS',
1430
+ eventStore: relevantEvents_1
1431
+ });
1432
+ }, jsEvent: ev.origEvent, view: initialView });
1433
+ initialCalendar_1.publiclyTrigger('eventDrop', [eventDropArg]);
1434
+ // dropped in different calendar
1435
+ }
1436
+ else if (receivingCalendar) {
1437
+ initialCalendar_1.publiclyTrigger('eventLeave', [
1438
+ {
1439
+ draggedEl: ev.subjectEl,
1440
+ event: eventApi,
1441
+ view: initialView
1442
+ }
1443
+ ]);
1444
+ initialCalendar_1.dispatch({
1445
+ type: 'REMOVE_EVENT_INSTANCES',
1446
+ instances: _this.mutatedRelevantEvents.instances
1447
+ });
1448
+ receivingCalendar.dispatch({
1449
+ type: 'MERGE_EVENTS',
1450
+ eventStore: _this.mutatedRelevantEvents
1451
+ });
1452
+ if (ev.isTouch) {
1453
+ receivingCalendar.dispatch({
1454
+ type: 'SELECT_EVENT',
1455
+ eventInstanceId: eventInstance.instanceId
1456
+ });
1457
+ }
1458
+ var dropArg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.component // should this be finalHit.component.view? See #4644
1459
+ });
1460
+ receivingCalendar.publiclyTrigger('drop', [dropArg]);
1461
+ receivingCalendar.publiclyTrigger('eventReceive', [
1462
+ {
1463
+ draggedEl: ev.subjectEl,
1464
+ event: new EventApi(// the data AFTER the mutation
1465
+ receivingCalendar, mutatedRelevantEvents.defs[eventDef.defId], mutatedRelevantEvents.instances[eventInstance.instanceId]),
1466
+ view: finalHit.component // should this be finalHit.component.view? See #4644
1467
+ }
1468
+ ]);
1469
+ }
1470
+ }
1471
+ else {
1472
+ initialCalendar_1.publiclyTrigger('_noEventDrop');
1473
+ }
1474
+ }
1475
+ _this.cleanup();
1476
+ };
1477
+ var component = _this.component;
1478
+ var options = component.context.options;
1479
+ var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
1480
+ dragging.pointer.selector = EventDragging.SELECTOR;
1481
+ dragging.touchScrollAllowed = false;
1482
+ dragging.autoScroller.isEnabled = options.dragScroll;
1483
+ var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsStore);
1484
+ hitDragging.useSubjectCenter = settings.useEventCenter;
1485
+ hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1486
+ hitDragging.emitter.on('dragstart', _this.handleDragStart);
1487
+ hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
1488
+ hitDragging.emitter.on('pointerup', _this.handlePointerUp);
1489
+ hitDragging.emitter.on('dragend', _this.handleDragEnd);
1490
+ return _this;
1491
+ }
1492
+ EventDragging.prototype.destroy = function () {
1493
+ this.dragging.destroy();
1494
+ };
1495
+ // render a drag state on the next receivingCalendar
1496
+ EventDragging.prototype.displayDrag = function (nextCalendar, state) {
1497
+ var initialCalendar = this.component.context.calendar;
1498
+ var prevCalendar = this.receivingCalendar;
1499
+ // does the previous calendar need to be cleared?
1500
+ if (prevCalendar && prevCalendar !== nextCalendar) {
1501
+ // does the initial calendar need to be cleared?
1502
+ // if so, don't clear all the way. we still need to to hide the affectedEvents
1503
+ if (prevCalendar === initialCalendar) {
1504
+ prevCalendar.dispatch({
1505
+ type: 'SET_EVENT_DRAG',
1506
+ state: {
1507
+ affectedEvents: state.affectedEvents,
1508
+ mutatedEvents: createEmptyEventStore(),
1509
+ isEvent: true,
1510
+ origSeg: state.origSeg
1511
+ }
1512
+ });
1513
+ // completely clear the old calendar if it wasn't the initial
1514
+ }
1515
+ else {
1516
+ prevCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
1517
+ }
1518
+ }
1519
+ if (nextCalendar) {
1520
+ nextCalendar.dispatch({ type: 'SET_EVENT_DRAG', state: state });
1521
+ }
1522
+ };
1523
+ EventDragging.prototype.clearDrag = function () {
1524
+ var initialCalendar = this.component.context.calendar;
1525
+ var receivingCalendar = this.receivingCalendar;
1526
+ if (receivingCalendar) {
1527
+ receivingCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
1528
+ }
1529
+ // the initial calendar might have an dummy drag state from displayDrag
1530
+ if (initialCalendar !== receivingCalendar) {
1531
+ initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
1532
+ }
1533
+ };
1534
+ EventDragging.prototype.cleanup = function () {
1535
+ this.subjectSeg = null;
1536
+ this.isDragging = false;
1537
+ this.eventRange = null;
1538
+ this.relevantEvents = null;
1539
+ this.receivingCalendar = null;
1540
+ this.validMutation = null;
1541
+ this.mutatedRelevantEvents = null;
1542
+ };
1543
+ EventDragging.SELECTOR = '.fc-draggable, .fc-resizable'; // TODO: test this in IE11
1544
+ return EventDragging;
1545
+ }(Interaction));
1546
+ function computeEventMutation(hit0, hit1, massagers) {
1547
+ var dateSpan0 = hit0.dateSpan;
1548
+ var dateSpan1 = hit1.dateSpan;
1549
+ var date0 = dateSpan0.range.start;
1550
+ var date1 = dateSpan1.range.start;
1551
+ var standardProps = {};
1552
+ if (dateSpan0.allDay !== dateSpan1.allDay) {
1553
+ standardProps.allDay = dateSpan1.allDay;
1554
+ standardProps.hasEnd = hit1.component.context.options.allDayMaintainDuration;
1555
+ if (dateSpan1.allDay) {
1556
+ // means date1 is already start-of-day,
1557
+ // but date0 needs to be converted
1558
+ date0 = startOfDay(date0);
1559
+ }
1560
+ }
1561
+ var delta = diffDates(date0, date1, hit0.component.context.dateEnv, hit0.component === hit1.component ?
1562
+ hit0.component.largeUnit :
1563
+ null);
1564
+ if (delta.milliseconds) { // has hours/minutes/seconds
1565
+ standardProps.allDay = false;
1566
+ }
1567
+ var mutation = {
1568
+ datesDelta: delta,
1569
+ standardProps: standardProps
1570
+ };
1571
+ for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
1572
+ var massager = massagers_1[_i];
1573
+ massager(mutation, hit0, hit1);
1574
+ }
1575
+ return mutation;
1576
+ }
1577
+ function getComponentTouchDelay$1(component) {
1578
+ var options = component.context.options;
1579
+ var delay = options.eventLongPressDelay;
1580
+ if (delay == null) {
1581
+ delay = options.longPressDelay;
1582
+ }
1583
+ return delay;
1584
+ }
1585
+
1586
+ var EventDragging$1 = /** @class */ (function (_super) {
1587
+ __extends(EventDragging, _super);
1588
+ function EventDragging(settings) {
1589
+ var _this = _super.call(this, settings) || this;
1590
+ // internal state
1591
+ _this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
1592
+ _this.eventRange = null;
1593
+ _this.relevantEvents = null;
1594
+ _this.validMutation = null;
1595
+ _this.mutatedRelevantEvents = null;
1596
+ _this.handlePointerDown = function (ev) {
1597
+ var component = _this.component;
1598
+ var seg = _this.querySeg(ev);
1599
+ var eventRange = _this.eventRange = seg.eventRange;
1600
+ _this.dragging.minDistance = component.context.options.eventDragMinDistance;
1601
+ // if touch, need to be working with a selected event
1602
+ _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
1603
+ (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
1604
+ };
1605
+ _this.handleDragStart = function (ev) {
1606
+ var _a = _this.component.context, calendar = _a.calendar, view = _a.view;
1607
+ var eventRange = _this.eventRange;
1608
+ _this.relevantEvents = getRelevantEvents(calendar.state.eventStore, _this.eventRange.instance.instanceId);
1609
+ _this.draggingSeg = _this.querySeg(ev);
1610
+ calendar.unselect();
1611
+ calendar.publiclyTrigger('eventResizeStart', [
1612
+ {
1613
+ el: _this.draggingSeg.el,
1614
+ event: new EventApi(calendar, eventRange.def, eventRange.instance),
1615
+ jsEvent: ev.origEvent,
1616
+ view: view
1617
+ }
1618
+ ]);
1619
+ };
1620
+ _this.handleHitUpdate = function (hit, isFinal, ev) {
1621
+ var calendar = _this.component.context.calendar;
1622
+ var relevantEvents = _this.relevantEvents;
1623
+ var initialHit = _this.hitDragging.initialHit;
1624
+ var eventInstance = _this.eventRange.instance;
1625
+ var mutation = null;
1626
+ var mutatedRelevantEvents = null;
1627
+ var isInvalid = false;
1628
+ var interaction = {
1629
+ affectedEvents: relevantEvents,
1630
+ mutatedEvents: createEmptyEventStore(),
1631
+ isEvent: true,
1632
+ origSeg: _this.draggingSeg
1633
+ };
1634
+ if (hit) {
1635
+ mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-start-resizer'), eventInstance.range, calendar.pluginSystem.hooks.eventResizeJoinTransforms);
1636
+ }
1637
+ if (mutation) {
1638
+ mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, calendar.eventUiBases, mutation, calendar);
1639
+ interaction.mutatedEvents = mutatedRelevantEvents;
1640
+ if (!_this.component.isInteractionValid(interaction)) {
1641
+ isInvalid = true;
1642
+ mutation = null;
1643
+ mutatedRelevantEvents = null;
1644
+ interaction.mutatedEvents = null;
1645
+ }
1646
+ }
1647
+ if (mutatedRelevantEvents) {
1648
+ calendar.dispatch({
1649
+ type: 'SET_EVENT_RESIZE',
1650
+ state: interaction
1651
+ });
1652
+ }
1653
+ else {
1654
+ calendar.dispatch({ type: 'UNSET_EVENT_RESIZE' });
1655
+ }
1656
+ if (!isInvalid) {
1657
+ enableCursor();
1658
+ }
1659
+ else {
1660
+ disableCursor();
1661
+ }
1662
+ if (!isFinal) {
1663
+ if (mutation && isHitsEqual(initialHit, hit)) {
1664
+ mutation = null;
1665
+ }
1666
+ _this.validMutation = mutation;
1667
+ _this.mutatedRelevantEvents = mutatedRelevantEvents;
1668
+ }
1669
+ };
1670
+ _this.handleDragEnd = function (ev) {
1671
+ var _a = _this.component.context, calendar = _a.calendar, view = _a.view;
1672
+ var eventDef = _this.eventRange.def;
1673
+ var eventInstance = _this.eventRange.instance;
1674
+ var eventApi = new EventApi(calendar, eventDef, eventInstance);
1675
+ var relevantEvents = _this.relevantEvents;
1676
+ var mutatedRelevantEvents = _this.mutatedRelevantEvents;
1677
+ calendar.publiclyTrigger('eventResizeStop', [
1678
+ {
1679
+ el: _this.draggingSeg.el,
1680
+ event: eventApi,
1681
+ jsEvent: ev.origEvent,
1682
+ view: view
1683
+ }
1684
+ ]);
1685
+ if (_this.validMutation) {
1686
+ calendar.dispatch({
1687
+ type: 'MERGE_EVENTS',
1688
+ eventStore: mutatedRelevantEvents
1689
+ });
1690
+ calendar.publiclyTrigger('eventResize', [
1691
+ {
1692
+ el: _this.draggingSeg.el,
1693
+ startDelta: _this.validMutation.startDelta || createDuration(0),
1694
+ endDelta: _this.validMutation.endDelta || createDuration(0),
1695
+ prevEvent: eventApi,
1696
+ event: new EventApi(// the data AFTER the mutation
1697
+ calendar, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null),
1698
+ revert: function () {
1699
+ calendar.dispatch({
1700
+ type: 'MERGE_EVENTS',
1701
+ eventStore: relevantEvents
1702
+ });
1703
+ },
1704
+ jsEvent: ev.origEvent,
1705
+ view: view
1706
+ }
1707
+ ]);
1708
+ }
1709
+ else {
1710
+ calendar.publiclyTrigger('_noEventResize');
1711
+ }
1712
+ // reset all internal state
1713
+ _this.draggingSeg = null;
1714
+ _this.relevantEvents = null;
1715
+ _this.validMutation = null;
1716
+ // okay to keep eventInstance around. useful to set it in handlePointerDown
1717
+ };
1718
+ var component = settings.component;
1719
+ var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
1720
+ dragging.pointer.selector = '.fc-resizer';
1721
+ dragging.touchScrollAllowed = false;
1722
+ dragging.autoScroller.isEnabled = component.context.options.dragScroll;
1723
+ var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
1724
+ hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1725
+ hitDragging.emitter.on('dragstart', _this.handleDragStart);
1726
+ hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
1727
+ hitDragging.emitter.on('dragend', _this.handleDragEnd);
1728
+ return _this;
1729
+ }
1730
+ EventDragging.prototype.destroy = function () {
1731
+ this.dragging.destroy();
1732
+ };
1733
+ EventDragging.prototype.querySeg = function (ev) {
1734
+ return getElSeg(elementClosest(ev.subjectEl, this.component.fgSegSelector));
1735
+ };
1736
+ return EventDragging;
1737
+ }(Interaction));
1738
+ function computeMutation(hit0, hit1, isFromStart, instanceRange, transforms) {
1739
+ var dateEnv = hit0.component.context.dateEnv;
1740
+ var date0 = hit0.dateSpan.range.start;
1741
+ var date1 = hit1.dateSpan.range.start;
1742
+ var delta = diffDates(date0, date1, dateEnv, hit0.component.largeUnit);
1743
+ var props = {};
1744
+ for (var _i = 0, transforms_1 = transforms; _i < transforms_1.length; _i++) {
1745
+ var transform = transforms_1[_i];
1746
+ var res = transform(hit0, hit1);
1747
+ if (res === false) {
1748
+ return null;
1749
+ }
1750
+ else if (res) {
1751
+ __assign(props, res);
1752
+ }
1753
+ }
1754
+ if (isFromStart) {
1755
+ if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
1756
+ props.startDelta = delta;
1757
+ return props;
1758
+ }
1759
+ }
1760
+ else {
1761
+ if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
1762
+ props.endDelta = delta;
1763
+ return props;
1764
+ }
1765
+ }
1766
+ return null;
1767
+ }
1768
+
1769
+ var UnselectAuto = /** @class */ (function () {
1770
+ function UnselectAuto(calendar) {
1771
+ var _this = this;
1772
+ this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
1773
+ this.onSelect = function (selectInfo) {
1774
+ if (selectInfo.jsEvent) {
1775
+ _this.isRecentPointerDateSelect = true;
1776
+ }
1777
+ };
1778
+ this.onDocumentPointerUp = function (pev) {
1779
+ var _a = _this, calendar = _a.calendar, documentPointer = _a.documentPointer;
1780
+ var state = calendar.state;
1781
+ // touch-scrolling should never unfocus any type of selection
1782
+ if (!documentPointer.wasTouchScroll) {
1783
+ if (state.dateSelection && // an existing date selection?
1784
+ !_this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
1785
+ ) {
1786
+ var unselectAuto = calendar.viewOpt('unselectAuto');
1787
+ var unselectCancel = calendar.viewOpt('unselectCancel');
1788
+ if (unselectAuto && (!unselectAuto || !elementClosest(documentPointer.downEl, unselectCancel))) {
1789
+ calendar.unselect(pev);
1790
+ }
1791
+ }
1792
+ if (state.eventSelection && // an existing event selected?
1793
+ !elementClosest(documentPointer.downEl, EventDragging.SELECTOR) // interaction DIDN'T start on an event
1794
+ ) {
1795
+ calendar.dispatch({ type: 'UNSELECT_EVENT' });
1796
+ }
1797
+ }
1798
+ _this.isRecentPointerDateSelect = false;
1799
+ };
1800
+ this.calendar = calendar;
1801
+ var documentPointer = this.documentPointer = new PointerDragging(document);
1802
+ documentPointer.shouldIgnoreMove = true;
1803
+ documentPointer.shouldWatchScroll = false;
1804
+ documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
1805
+ /*
1806
+ TODO: better way to know about whether there was a selection with the pointer
1807
+ */
1808
+ calendar.on('select', this.onSelect);
1809
+ }
1810
+ UnselectAuto.prototype.destroy = function () {
1811
+ this.calendar.off('select', this.onSelect);
1812
+ this.documentPointer.destroy();
1813
+ };
1814
+ return UnselectAuto;
1815
+ }());
1816
+
1817
+ /*
1818
+ Given an already instantiated draggable object for one-or-more elements,
1819
+ Interprets any dragging as an attempt to drag an events that lives outside
1820
+ of a calendar onto a calendar.
1821
+ */
1822
+ var ExternalElementDragging = /** @class */ (function () {
1823
+ function ExternalElementDragging(dragging, suppliedDragMeta) {
1824
+ var _this = this;
1825
+ this.receivingCalendar = null;
1826
+ this.droppableEvent = null; // will exist for all drags, even if create:false
1827
+ this.suppliedDragMeta = null;
1828
+ this.dragMeta = null;
1829
+ this.handleDragStart = function (ev) {
1830
+ _this.dragMeta = _this.buildDragMeta(ev.subjectEl);
1831
+ };
1832
+ this.handleHitUpdate = function (hit, isFinal, ev) {
1833
+ var dragging = _this.hitDragging.dragging;
1834
+ var receivingCalendar = null;
1835
+ var droppableEvent = null;
1836
+ var isInvalid = false;
1837
+ var interaction = {
1838
+ affectedEvents: createEmptyEventStore(),
1839
+ mutatedEvents: createEmptyEventStore(),
1840
+ isEvent: _this.dragMeta.create,
1841
+ origSeg: null
1842
+ };
1843
+ if (hit) {
1844
+ receivingCalendar = hit.component.context.calendar;
1845
+ if (_this.canDropElOnCalendar(ev.subjectEl, receivingCalendar)) {
1846
+ droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingCalendar);
1847
+ interaction.mutatedEvents = eventTupleToStore(droppableEvent);
1848
+ isInvalid = !isInteractionValid(interaction, receivingCalendar);
1849
+ if (isInvalid) {
1850
+ interaction.mutatedEvents = createEmptyEventStore();
1851
+ droppableEvent = null;
1852
+ }
1853
+ }
1854
+ }
1855
+ _this.displayDrag(receivingCalendar, interaction);
1856
+ // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
1857
+ // TODO: wish we could somehow wait for dispatch to guarantee render
1858
+ dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-mirror'));
1859
+ if (!isInvalid) {
1860
+ enableCursor();
1861
+ }
1862
+ else {
1863
+ disableCursor();
1864
+ }
1865
+ if (!isFinal) {
1866
+ dragging.setMirrorNeedsRevert(!droppableEvent);
1867
+ _this.receivingCalendar = receivingCalendar;
1868
+ _this.droppableEvent = droppableEvent;
1869
+ }
1870
+ };
1871
+ this.handleDragEnd = function (pev) {
1872
+ var _a = _this, receivingCalendar = _a.receivingCalendar, droppableEvent = _a.droppableEvent;
1873
+ _this.clearDrag();
1874
+ if (receivingCalendar && droppableEvent) {
1875
+ var finalHit = _this.hitDragging.finalHit;
1876
+ var finalView = finalHit.component.context.view;
1877
+ var dragMeta = _this.dragMeta;
1878
+ var arg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView });
1879
+ receivingCalendar.publiclyTrigger('drop', [arg]);
1880
+ if (dragMeta.create) {
1881
+ receivingCalendar.dispatch({
1882
+ type: 'MERGE_EVENTS',
1883
+ eventStore: eventTupleToStore(droppableEvent)
1884
+ });
1885
+ if (pev.isTouch) {
1886
+ receivingCalendar.dispatch({
1887
+ type: 'SELECT_EVENT',
1888
+ eventInstanceId: droppableEvent.instance.instanceId
1889
+ });
1890
+ }
1891
+ // signal that an external event landed
1892
+ receivingCalendar.publiclyTrigger('eventReceive', [
1893
+ {
1894
+ draggedEl: pev.subjectEl,
1895
+ event: new EventApi(receivingCalendar, droppableEvent.def, droppableEvent.instance),
1896
+ view: finalView
1897
+ }
1898
+ ]);
1899
+ }
1900
+ }
1901
+ _this.receivingCalendar = null;
1902
+ _this.droppableEvent = null;
1903
+ };
1904
+ var hitDragging = this.hitDragging = new HitDragging(dragging, interactionSettingsStore);
1905
+ hitDragging.requireInitial = false; // will start outside of a component
1906
+ hitDragging.emitter.on('dragstart', this.handleDragStart);
1907
+ hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
1908
+ hitDragging.emitter.on('dragend', this.handleDragEnd);
1909
+ this.suppliedDragMeta = suppliedDragMeta;
1910
+ }
1911
+ ExternalElementDragging.prototype.buildDragMeta = function (subjectEl) {
1912
+ if (typeof this.suppliedDragMeta === 'object') {
1913
+ return parseDragMeta(this.suppliedDragMeta);
1914
+ }
1915
+ else if (typeof this.suppliedDragMeta === 'function') {
1916
+ return parseDragMeta(this.suppliedDragMeta(subjectEl));
1917
+ }
1918
+ else {
1919
+ return getDragMetaFromEl(subjectEl);
1920
+ }
1921
+ };
1922
+ ExternalElementDragging.prototype.displayDrag = function (nextCalendar, state) {
1923
+ var prevCalendar = this.receivingCalendar;
1924
+ if (prevCalendar && prevCalendar !== nextCalendar) {
1925
+ prevCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
1926
+ }
1927
+ if (nextCalendar) {
1928
+ nextCalendar.dispatch({ type: 'SET_EVENT_DRAG', state: state });
1929
+ }
1930
+ };
1931
+ ExternalElementDragging.prototype.clearDrag = function () {
1932
+ if (this.receivingCalendar) {
1933
+ this.receivingCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
1934
+ }
1935
+ };
1936
+ ExternalElementDragging.prototype.canDropElOnCalendar = function (el, receivingCalendar) {
1937
+ var dropAccept = receivingCalendar.opt('dropAccept');
1938
+ if (typeof dropAccept === 'function') {
1939
+ return dropAccept(el);
1940
+ }
1941
+ else if (typeof dropAccept === 'string' && dropAccept) {
1942
+ return Boolean(elementMatches(el, dropAccept));
1943
+ }
1944
+ return true;
1945
+ };
1946
+ return ExternalElementDragging;
1947
+ }());
1948
+ // Utils for computing event store from the DragMeta
1949
+ // ----------------------------------------------------------------------------------------------------
1950
+ function computeEventForDateSpan(dateSpan, dragMeta, calendar) {
1951
+ var defProps = __assign({}, dragMeta.leftoverProps);
1952
+ for (var _i = 0, _a = calendar.pluginSystem.hooks.externalDefTransforms; _i < _a.length; _i++) {
1953
+ var transform = _a[_i];
1954
+ __assign(defProps, transform(dateSpan, dragMeta));
1955
+ }
1956
+ var def = parseEventDef(defProps, dragMeta.sourceId, dateSpan.allDay, calendar.opt('forceEventDuration') || Boolean(dragMeta.duration), // hasEnd
1957
+ calendar);
1958
+ var start = dateSpan.range.start;
1959
+ // only rely on time info if drop zone is all-day,
1960
+ // otherwise, we already know the time
1961
+ if (dateSpan.allDay && dragMeta.startTime) {
1962
+ start = calendar.dateEnv.add(start, dragMeta.startTime);
1963
+ }
1964
+ var end = dragMeta.duration ?
1965
+ calendar.dateEnv.add(start, dragMeta.duration) :
1966
+ calendar.getDefaultEventEnd(dateSpan.allDay, start);
1967
+ var instance = createEventInstance(def.defId, { start: start, end: end });
1968
+ return { def: def, instance: instance };
1969
+ }
1970
+ // Utils for extracting data from element
1971
+ // ----------------------------------------------------------------------------------------------------
1972
+ function getDragMetaFromEl(el) {
1973
+ var str = getEmbeddedElData(el, 'event');
1974
+ var obj = str ?
1975
+ JSON.parse(str) :
1976
+ { create: false }; // if no embedded data, assume no event creation
1977
+ return parseDragMeta(obj);
1978
+ }
1979
+ config.dataAttrPrefix = '';
1980
+ function getEmbeddedElData(el, name) {
1981
+ var prefix = config.dataAttrPrefix;
1982
+ var prefixedName = (prefix ? prefix + '-' : '') + name;
1983
+ return el.getAttribute('data-' + prefixedName) || '';
1984
+ }
1985
+
1986
+ /*
1987
+ Makes an element (that is *external* to any calendar) draggable.
1988
+ Can pass in data that determines how an event will be created when dropped onto a calendar.
1989
+ Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
1990
+ */
1991
+ var ExternalDraggable = /** @class */ (function () {
1992
+ function ExternalDraggable(el, settings) {
1993
+ var _this = this;
1994
+ if (settings === void 0) { settings = {}; }
1995
+ this.handlePointerDown = function (ev) {
1996
+ var dragging = _this.dragging;
1997
+ var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
1998
+ dragging.minDistance =
1999
+ minDistance != null ?
2000
+ minDistance :
2001
+ (ev.isTouch ? 0 : globalDefaults.eventDragMinDistance);
2002
+ dragging.delay =
2003
+ ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
2004
+ (longPressDelay != null ? longPressDelay : globalDefaults.longPressDelay) :
2005
+ 0;
2006
+ };
2007
+ this.handleDragStart = function (ev) {
2008
+ if (ev.isTouch &&
2009
+ _this.dragging.delay &&
2010
+ ev.subjectEl.classList.contains('fc-event')) {
2011
+ _this.dragging.mirror.getMirrorEl().classList.add('fc-selected');
2012
+ }
2013
+ };
2014
+ this.settings = settings;
2015
+ var dragging = this.dragging = new FeaturefulElementDragging(el);
2016
+ dragging.touchScrollAllowed = false;
2017
+ if (settings.itemSelector != null) {
2018
+ dragging.pointer.selector = settings.itemSelector;
2019
+ }
2020
+ if (settings.appendTo != null) {
2021
+ dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
2022
+ }
2023
+ dragging.emitter.on('pointerdown', this.handlePointerDown);
2024
+ dragging.emitter.on('dragstart', this.handleDragStart);
2025
+ new ExternalElementDragging(dragging, settings.eventData);
2026
+ }
2027
+ ExternalDraggable.prototype.destroy = function () {
2028
+ this.dragging.destroy();
2029
+ };
2030
+ return ExternalDraggable;
2031
+ }());
2032
+
2033
+ /*
2034
+ Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
2035
+ The third-party system is responsible for drawing the visuals effects of the drag.
2036
+ This class simply monitors for pointer movements and fires events.
2037
+ It also has the ability to hide the moving element (the "mirror") during the drag.
2038
+ */
2039
+ var InferredElementDragging = /** @class */ (function (_super) {
2040
+ __extends(InferredElementDragging, _super);
2041
+ function InferredElementDragging(containerEl) {
2042
+ var _this = _super.call(this, containerEl) || this;
2043
+ _this.shouldIgnoreMove = false;
2044
+ _this.mirrorSelector = '';
2045
+ _this.currentMirrorEl = null;
2046
+ _this.handlePointerDown = function (ev) {
2047
+ _this.emitter.trigger('pointerdown', ev);
2048
+ if (!_this.shouldIgnoreMove) {
2049
+ // fire dragstart right away. does not support delay or min-distance
2050
+ _this.emitter.trigger('dragstart', ev);
2051
+ }
2052
+ };
2053
+ _this.handlePointerMove = function (ev) {
2054
+ if (!_this.shouldIgnoreMove) {
2055
+ _this.emitter.trigger('dragmove', ev);
2056
+ }
2057
+ };
2058
+ _this.handlePointerUp = function (ev) {
2059
+ _this.emitter.trigger('pointerup', ev);
2060
+ if (!_this.shouldIgnoreMove) {
2061
+ // fire dragend right away. does not support a revert animation
2062
+ _this.emitter.trigger('dragend', ev);
2063
+ }
2064
+ };
2065
+ var pointer = _this.pointer = new PointerDragging(containerEl);
2066
+ pointer.emitter.on('pointerdown', _this.handlePointerDown);
2067
+ pointer.emitter.on('pointermove', _this.handlePointerMove);
2068
+ pointer.emitter.on('pointerup', _this.handlePointerUp);
2069
+ return _this;
2070
+ }
2071
+ InferredElementDragging.prototype.destroy = function () {
2072
+ this.pointer.destroy();
2073
+ };
2074
+ InferredElementDragging.prototype.setIgnoreMove = function (bool) {
2075
+ this.shouldIgnoreMove = bool;
2076
+ };
2077
+ InferredElementDragging.prototype.setMirrorIsVisible = function (bool) {
2078
+ if (bool) {
2079
+ // restore a previously hidden element.
2080
+ // use the reference in case the selector class has already been removed.
2081
+ if (this.currentMirrorEl) {
2082
+ this.currentMirrorEl.style.visibility = '';
2083
+ this.currentMirrorEl = null;
2084
+ }
2085
+ }
2086
+ else {
2087
+ var mirrorEl = this.mirrorSelector ?
2088
+ document.querySelector(this.mirrorSelector) :
2089
+ null;
2090
+ if (mirrorEl) {
2091
+ this.currentMirrorEl = mirrorEl;
2092
+ mirrorEl.style.visibility = 'hidden';
2093
+ }
2094
+ }
2095
+ };
2096
+ return InferredElementDragging;
2097
+ }(ElementDragging));
2098
+
2099
+ /*
2100
+ Bridges third-party drag-n-drop systems with FullCalendar.
2101
+ Must be instantiated and destroyed by caller.
2102
+ */
2103
+ var ThirdPartyDraggable = /** @class */ (function () {
2104
+ function ThirdPartyDraggable(containerOrSettings, settings) {
2105
+ var containerEl = document;
2106
+ if (
2107
+ // wish we could just test instanceof EventTarget, but doesn't work in IE11
2108
+ containerOrSettings === document ||
2109
+ containerOrSettings instanceof Element) {
2110
+ containerEl = containerOrSettings;
2111
+ settings = settings || {};
2112
+ }
2113
+ else {
2114
+ settings = (containerOrSettings || {});
2115
+ }
2116
+ var dragging = this.dragging = new InferredElementDragging(containerEl);
2117
+ if (typeof settings.itemSelector === 'string') {
2118
+ dragging.pointer.selector = settings.itemSelector;
2119
+ }
2120
+ else if (containerEl === document) {
2121
+ dragging.pointer.selector = '[data-event]';
2122
+ }
2123
+ if (typeof settings.mirrorSelector === 'string') {
2124
+ dragging.mirrorSelector = settings.mirrorSelector;
2125
+ }
2126
+ new ExternalElementDragging(dragging, settings.eventData);
2127
+ }
2128
+ ThirdPartyDraggable.prototype.destroy = function () {
2129
+ this.dragging.destroy();
2130
+ };
2131
+ return ThirdPartyDraggable;
2132
+ }());
2133
+
2134
+ var main = createPlugin({
2135
+ componentInteractions: [DateClicking, DateSelecting, EventDragging, EventDragging$1],
2136
+ calendarInteractions: [UnselectAuto],
2137
+ elementDraggingImpl: FeaturefulElementDragging
2138
+ });
2139
+
2140
+ export default main;
2141
+ export { ExternalDraggable as Draggable, FeaturefulElementDragging, PointerDragging, ThirdPartyDraggable };