@fullcalendar/interaction 7.0.0-beta.3 → 7.0.0-beta.5
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/LICENSE.md +1 -1
- package/README.md +7 -1
- package/{index.cjs → cjs/index.cjs} +211 -179
- package/{index.d.ts → esm/index.d.ts} +55 -48
- package/{index.js → esm/index.js} +103 -75
- package/{index.global.js → global.js} +108 -77
- package/global.min.js +6 -0
- package/package.json +17 -14
- package/index.global.min.js +0 -6
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var core = require('@fullcalendar/core');
|
|
6
|
+
var internal = require('@fullcalendar/core/internal');
|
|
7
|
+
var classNames = require('@fullcalendar/core/internal-classnames');
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
12
|
+
|
|
13
|
+
internal.config.touchMouseIgnoreWait = 500;
|
|
9
14
|
let ignoreMouseDepth = 0;
|
|
10
15
|
let listenerCnt = 0;
|
|
11
16
|
let isWindowTouchMoveCancelled = false;
|
|
@@ -33,7 +38,7 @@ class PointerDragging {
|
|
|
33
38
|
// internal states
|
|
34
39
|
this.isDragging = false;
|
|
35
40
|
this.isTouchDragging = false;
|
|
36
|
-
this.wasTouchScroll = false;
|
|
41
|
+
this.wasTouchScroll = false; // HACK public
|
|
37
42
|
// Mouse
|
|
38
43
|
// ----------------------------------------------------------------------------------------------------
|
|
39
44
|
this.handleMouseDown = (ev) => {
|
|
@@ -83,9 +88,11 @@ class PointerDragging {
|
|
|
83
88
|
}
|
|
84
89
|
};
|
|
85
90
|
this.handleTouchMove = (ev) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
if (this.isDragging) {
|
|
92
|
+
let pev = this.createEventFromTouch(ev);
|
|
93
|
+
this.recordCoords(pev);
|
|
94
|
+
this.emitter.trigger('pointermove', pev);
|
|
95
|
+
}
|
|
89
96
|
};
|
|
90
97
|
this.handleTouchEnd = (ev) => {
|
|
91
98
|
if (this.isDragging) { // done to guard against touchend followed by touchcancel
|
|
@@ -119,7 +126,7 @@ class PointerDragging {
|
|
|
119
126
|
}
|
|
120
127
|
};
|
|
121
128
|
this.containerEl = containerEl;
|
|
122
|
-
this.emitter = new
|
|
129
|
+
this.emitter = new internal.Emitter();
|
|
123
130
|
containerEl.addEventListener('mousedown', this.handleMouseDown);
|
|
124
131
|
containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
|
|
125
132
|
listenerCreated();
|
|
@@ -129,6 +136,11 @@ class PointerDragging {
|
|
|
129
136
|
this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
|
|
130
137
|
listenerDestroyed();
|
|
131
138
|
}
|
|
139
|
+
cancel() {
|
|
140
|
+
if (this.isDragging) {
|
|
141
|
+
this.cleanup();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
132
144
|
tryStart(ev) {
|
|
133
145
|
let subjectEl = this.querySubjectEl(ev);
|
|
134
146
|
let downEl = ev.target;
|
|
@@ -254,7 +266,7 @@ function startIgnoringMouse() {
|
|
|
254
266
|
ignoreMouseDepth += 1;
|
|
255
267
|
setTimeout(() => {
|
|
256
268
|
ignoreMouseDepth -= 1;
|
|
257
|
-
},
|
|
269
|
+
}, internal.config.touchMouseIgnoreWait);
|
|
258
270
|
}
|
|
259
271
|
// We want to attach touchmove as early as possible for Safari
|
|
260
272
|
// ----------------------------------------------------------------------------------------------------
|
|
@@ -311,7 +323,9 @@ class ElementMirror {
|
|
|
311
323
|
if (bool) {
|
|
312
324
|
if (!this.isVisible) {
|
|
313
325
|
if (this.mirrorEl) {
|
|
314
|
-
|
|
326
|
+
// important because competes with util.module.css classNames, which are all important
|
|
327
|
+
// TODO: attach a util className here instead?
|
|
328
|
+
this.mirrorEl.style.setProperty('display', '', 'important');
|
|
315
329
|
}
|
|
316
330
|
this.isVisible = bool; // needs to happen before updateElPosition
|
|
317
331
|
this.updateElPosition(); // because was not updating the position while invisible
|
|
@@ -319,7 +333,9 @@ class ElementMirror {
|
|
|
319
333
|
}
|
|
320
334
|
else if (this.isVisible) {
|
|
321
335
|
if (this.mirrorEl) {
|
|
322
|
-
|
|
336
|
+
// important because competes with util.module.css classNames, which are all important
|
|
337
|
+
// TODO: attach a util className here instead?
|
|
338
|
+
this.mirrorEl.style.setProperty('display', 'none', 'important');
|
|
323
339
|
}
|
|
324
340
|
this.isVisible = bool;
|
|
325
341
|
}
|
|
@@ -348,11 +364,11 @@ class ElementMirror {
|
|
|
348
364
|
mirrorEl.style.transition =
|
|
349
365
|
'top ' + revertDuration + 'ms,' +
|
|
350
366
|
'left ' + revertDuration + 'ms';
|
|
351
|
-
|
|
367
|
+
internal.applyStyle(mirrorEl, {
|
|
352
368
|
left: finalSourceElRect.left,
|
|
353
369
|
top: finalSourceElRect.top,
|
|
354
370
|
});
|
|
355
|
-
|
|
371
|
+
internal.whenTransitionDone(mirrorEl, () => {
|
|
356
372
|
mirrorEl.style.transition = '';
|
|
357
373
|
callback();
|
|
358
374
|
});
|
|
@@ -366,7 +382,7 @@ class ElementMirror {
|
|
|
366
382
|
}
|
|
367
383
|
updateElPosition() {
|
|
368
384
|
if (this.sourceEl && this.isVisible) {
|
|
369
|
-
|
|
385
|
+
internal.applyStyle(this.getMirrorEl(), {
|
|
370
386
|
left: this.sourceElRect.left + this.deltaX,
|
|
371
387
|
top: this.sourceElRect.top + this.deltaY,
|
|
372
388
|
});
|
|
@@ -379,11 +395,11 @@ class ElementMirror {
|
|
|
379
395
|
mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
|
|
380
396
|
// we don't want long taps or any mouse interaction causing selection/menus.
|
|
381
397
|
// would use preventSelection(), but that prevents selectstart, causing problems.
|
|
398
|
+
// TODO: make className for this?
|
|
382
399
|
mirrorEl.style.userSelect = 'none';
|
|
383
400
|
mirrorEl.style.webkitUserSelect = 'none';
|
|
384
401
|
mirrorEl.style.pointerEvents = 'none';
|
|
385
|
-
|
|
386
|
-
internal_cjs.applyStyle(mirrorEl, {
|
|
402
|
+
internal.applyStyle(mirrorEl, {
|
|
387
403
|
position: 'fixed',
|
|
388
404
|
zIndex: this.zIndex,
|
|
389
405
|
visibility: '',
|
|
@@ -408,7 +424,7 @@ The cache can be in one of two modes:
|
|
|
408
424
|
- doesListening:false - ignores when the container is scrolled by someone else
|
|
409
425
|
- doesListening:true - watch for scrolling and update the cache
|
|
410
426
|
*/
|
|
411
|
-
class ScrollGeomCache extends
|
|
427
|
+
class ScrollGeomCache extends internal.ScrollController {
|
|
412
428
|
constructor(scrollController, doesListening) {
|
|
413
429
|
super();
|
|
414
430
|
this.handleScroll = () => {
|
|
@@ -476,19 +492,19 @@ class ScrollGeomCache extends internal_cjs.ScrollController {
|
|
|
476
492
|
|
|
477
493
|
class ElementScrollGeomCache extends ScrollGeomCache {
|
|
478
494
|
constructor(el, doesListening) {
|
|
479
|
-
super(new
|
|
495
|
+
super(new internal.ElementScrollController(el), doesListening);
|
|
480
496
|
}
|
|
481
497
|
getEventTarget() {
|
|
482
498
|
return this.scrollController.el;
|
|
483
499
|
}
|
|
484
500
|
computeClientRect() {
|
|
485
|
-
return
|
|
501
|
+
return internal.computeInnerRect(this.scrollController.el);
|
|
486
502
|
}
|
|
487
503
|
}
|
|
488
504
|
|
|
489
505
|
class WindowScrollGeomCache extends ScrollGeomCache {
|
|
490
506
|
constructor(doesListening) {
|
|
491
|
-
super(new
|
|
507
|
+
super(new internal.WindowScrollController(), doesListening);
|
|
492
508
|
}
|
|
493
509
|
getEventTarget() {
|
|
494
510
|
return window;
|
|
@@ -522,7 +538,7 @@ class AutoScroller {
|
|
|
522
538
|
constructor() {
|
|
523
539
|
// options that can be set by caller
|
|
524
540
|
this.isEnabled = true;
|
|
525
|
-
this.scrollQuery = [window,
|
|
541
|
+
this.scrollQuery = [window, `.${classNames__default["default"].internalScroller}`];
|
|
526
542
|
this.edgeThreshold = 50; // pixels
|
|
527
543
|
this.maxVelocity = 300; // pixels per second
|
|
528
544
|
// internal state
|
|
@@ -692,7 +708,7 @@ Monitors dragging on an element. Has a number of high-level features:
|
|
|
692
708
|
- minimum wait time ("delay") before dragging
|
|
693
709
|
- a mirror element that follows the pointer
|
|
694
710
|
*/
|
|
695
|
-
class FeaturefulElementDragging extends
|
|
711
|
+
class FeaturefulElementDragging extends internal.ElementDragging {
|
|
696
712
|
constructor(containerEl, selector) {
|
|
697
713
|
super(containerEl);
|
|
698
714
|
this.containerEl = containerEl;
|
|
@@ -712,17 +728,16 @@ class FeaturefulElementDragging extends internal_cjs.ElementDragging {
|
|
|
712
728
|
this.isInteracting = true;
|
|
713
729
|
this.isDelayEnded = false;
|
|
714
730
|
this.isDistanceSurpassed = false;
|
|
715
|
-
internal_cjs.preventSelection(document.body);
|
|
716
|
-
internal_cjs.preventContextMenu(document.body);
|
|
717
|
-
// prevent links from being visited if there's an eventual drag.
|
|
718
|
-
// also prevents selection in older browsers (maybe?).
|
|
719
|
-
// not necessary for touch, besides, browser would complain about passiveness.
|
|
720
|
-
if (!ev.isTouch) {
|
|
721
|
-
ev.origEvent.preventDefault();
|
|
722
|
-
}
|
|
723
731
|
this.emitter.trigger('pointerdown', ev);
|
|
724
|
-
if (this.isInteracting
|
|
725
|
-
|
|
732
|
+
if (this.isInteracting) { // not cancelled?
|
|
733
|
+
internal.preventSelection(document.body);
|
|
734
|
+
internal.preventContextMenu(document.body);
|
|
735
|
+
// prevent links from being visited if there's an eventual drag.
|
|
736
|
+
// also prevents selection in older browsers (maybe?).
|
|
737
|
+
// not necessary for touch, besides, browser would complain about passiveness.
|
|
738
|
+
if (!ev.isTouch) {
|
|
739
|
+
ev.origEvent.preventDefault();
|
|
740
|
+
}
|
|
726
741
|
// actions related to initiating dragstart+dragmove+dragend...
|
|
727
742
|
this.mirror.setIsVisible(false); // reset. caller must set-visible
|
|
728
743
|
this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
|
|
@@ -758,8 +773,8 @@ class FeaturefulElementDragging extends internal_cjs.ElementDragging {
|
|
|
758
773
|
this.onPointerUp = (ev) => {
|
|
759
774
|
if (this.isInteracting) {
|
|
760
775
|
this.isInteracting = false;
|
|
761
|
-
|
|
762
|
-
|
|
776
|
+
internal.allowSelection(document.body);
|
|
777
|
+
internal.allowContextMenu(document.body);
|
|
763
778
|
this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
|
|
764
779
|
if (this.isDragging) {
|
|
765
780
|
this.autoScroller.stop();
|
|
@@ -829,8 +844,14 @@ class FeaturefulElementDragging extends internal_cjs.ElementDragging {
|
|
|
829
844
|
this.emitter.trigger('dragend', ev);
|
|
830
845
|
}
|
|
831
846
|
// fill in the implementations...
|
|
832
|
-
|
|
833
|
-
|
|
847
|
+
/*
|
|
848
|
+
Can only be called by pointerdown to prevent drag
|
|
849
|
+
*/
|
|
850
|
+
cancel() {
|
|
851
|
+
if (this.isInteracting) {
|
|
852
|
+
this.isInteracting = false;
|
|
853
|
+
this.pointer.cancel();
|
|
854
|
+
}
|
|
834
855
|
}
|
|
835
856
|
setMirrorIsVisible(bool) {
|
|
836
857
|
this.mirror.setIsVisible(bool);
|
|
@@ -854,9 +875,10 @@ and an determine if a given point is inside the combined clipping rectangle.
|
|
|
854
875
|
class OffsetTracker {
|
|
855
876
|
constructor(el) {
|
|
856
877
|
this.el = el;
|
|
857
|
-
this.origRect =
|
|
878
|
+
this.origRect = internal.computeRect(el);
|
|
879
|
+
this.isRtl = internal.computeElIsRtl(el);
|
|
858
880
|
// will work fine for divs that have overflow:hidden
|
|
859
|
-
this.scrollCaches =
|
|
881
|
+
this.scrollCaches = internal.getClippingParents(el).map((scrollEl) => new ElementScrollGeomCache(scrollEl, true));
|
|
860
882
|
}
|
|
861
883
|
destroy() {
|
|
862
884
|
for (let scrollCache of this.scrollCaches) {
|
|
@@ -881,7 +903,7 @@ class OffsetTracker {
|
|
|
881
903
|
let point = { left: pageX, top: pageY };
|
|
882
904
|
for (let scrollCache of this.scrollCaches) {
|
|
883
905
|
if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
|
|
884
|
-
!
|
|
906
|
+
!internal.pointInsideRect(point, scrollCache.clientRect)) {
|
|
885
907
|
return false;
|
|
886
908
|
}
|
|
887
909
|
}
|
|
@@ -925,12 +947,11 @@ class HitDragging {
|
|
|
925
947
|
this.prepareHits();
|
|
926
948
|
this.processFirstCoord(ev);
|
|
927
949
|
if (this.initialHit || !this.requireInitial) {
|
|
928
|
-
dragging.setIgnoreMove(false);
|
|
929
950
|
// TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
|
|
930
951
|
this.emitter.trigger('pointerdown', ev);
|
|
931
952
|
}
|
|
932
953
|
else {
|
|
933
|
-
dragging.
|
|
954
|
+
dragging.cancel();
|
|
934
955
|
}
|
|
935
956
|
};
|
|
936
957
|
this.handleDragStart = (ev) => {
|
|
@@ -960,7 +981,7 @@ class HitDragging {
|
|
|
960
981
|
dragging.emitter.on('pointerup', this.handlePointerUp);
|
|
961
982
|
dragging.emitter.on('dragend', this.handleDragEnd);
|
|
962
983
|
this.dragging = dragging;
|
|
963
|
-
this.emitter = new
|
|
984
|
+
this.emitter = new internal.Emitter();
|
|
964
985
|
}
|
|
965
986
|
// sets initialHit
|
|
966
987
|
// sets coordAdjust
|
|
@@ -970,18 +991,18 @@ class HitDragging {
|
|
|
970
991
|
let subjectEl = ev.subjectEl;
|
|
971
992
|
let subjectRect;
|
|
972
993
|
if (subjectEl instanceof HTMLElement) { // i.e. not a Document/ShadowRoot
|
|
973
|
-
subjectRect =
|
|
974
|
-
adjustedPoint =
|
|
994
|
+
subjectRect = internal.computeRect(subjectEl);
|
|
995
|
+
adjustedPoint = internal.constrainPoint(adjustedPoint, subjectRect);
|
|
975
996
|
}
|
|
976
997
|
let initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
|
|
977
998
|
if (initialHit) {
|
|
978
999
|
if (this.useSubjectCenter && subjectRect) {
|
|
979
|
-
let slicedSubjectRect =
|
|
1000
|
+
let slicedSubjectRect = internal.intersectRects(subjectRect, initialHit.rect);
|
|
980
1001
|
if (slicedSubjectRect) {
|
|
981
|
-
adjustedPoint =
|
|
1002
|
+
adjustedPoint = internal.getRectCenter(slicedSubjectRect);
|
|
982
1003
|
}
|
|
983
1004
|
}
|
|
984
|
-
this.coordAdjust =
|
|
1005
|
+
this.coordAdjust = internal.diffPoints(adjustedPoint, origPoint);
|
|
985
1006
|
}
|
|
986
1007
|
else {
|
|
987
1008
|
this.coordAdjust = { left: 0, top: 0 };
|
|
@@ -995,7 +1016,7 @@ class HitDragging {
|
|
|
995
1016
|
}
|
|
996
1017
|
}
|
|
997
1018
|
prepareHits() {
|
|
998
|
-
this.offsetTrackers =
|
|
1019
|
+
this.offsetTrackers = internal.mapHash(this.droppableStore, (interactionSettings) => {
|
|
999
1020
|
interactionSettings.component.prepareHits();
|
|
1000
1021
|
return new OffsetTracker(interactionSettings.el);
|
|
1001
1022
|
});
|
|
@@ -1026,10 +1047,10 @@ class HitDragging {
|
|
|
1026
1047
|
// must be within the element's bounds
|
|
1027
1048
|
positionLeft >= 0 && positionLeft < width &&
|
|
1028
1049
|
positionTop >= 0 && positionTop < height) {
|
|
1029
|
-
let hit = component.queryHit(positionLeft, positionTop, width, height);
|
|
1050
|
+
let hit = component.queryHit(offsetTracker.isRtl, positionLeft, positionTop, width, height);
|
|
1030
1051
|
if (hit && (
|
|
1031
1052
|
// make sure the hit is within activeRange, meaning it's not a dead cell
|
|
1032
|
-
|
|
1053
|
+
internal.rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range)) &&
|
|
1033
1054
|
// Ensure the component we are querying for the hit is accessibly my the pointer
|
|
1034
1055
|
// Prevents obscured calendars (ex: under a modal dialog) from accepting hit
|
|
1035
1056
|
// https://github.com/fullcalendar/fullcalendar/issues/5026
|
|
@@ -1060,7 +1081,7 @@ function isHitsEqual(hit0, hit1) {
|
|
|
1060
1081
|
if (Boolean(hit0) !== Boolean(hit1)) {
|
|
1061
1082
|
return false;
|
|
1062
1083
|
}
|
|
1063
|
-
return
|
|
1084
|
+
return internal.isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
|
|
1064
1085
|
}
|
|
1065
1086
|
|
|
1066
1087
|
function buildDatePointApiWithContext(dateSpan, context) {
|
|
@@ -1083,14 +1104,20 @@ function buildDatePointApi(span, dateEnv) {
|
|
|
1083
1104
|
Monitors when the user clicks on a specific date/time of a component.
|
|
1084
1105
|
A pointerdown+pointerup on the same "hit" constitutes a click.
|
|
1085
1106
|
*/
|
|
1086
|
-
class DateClicking extends
|
|
1107
|
+
class DateClicking extends internal.Interaction {
|
|
1087
1108
|
constructor(settings) {
|
|
1088
1109
|
super(settings);
|
|
1089
1110
|
this.handlePointerDown = (pev) => {
|
|
1090
1111
|
let { dragging } = this;
|
|
1091
1112
|
let downEl = pev.origEvent.target;
|
|
1092
|
-
|
|
1093
|
-
|
|
1113
|
+
/*
|
|
1114
|
+
If no dateClick, allow text on dates to be text-selectable
|
|
1115
|
+
*/
|
|
1116
|
+
const canDateClick = this.component.context.emitter.hasHandlers('dateClick') &&
|
|
1117
|
+
this.component.isValidDateDownEl(downEl);
|
|
1118
|
+
if (!canDateClick) {
|
|
1119
|
+
dragging.cancel();
|
|
1120
|
+
}
|
|
1094
1121
|
};
|
|
1095
1122
|
// won't even fire if moving was ignored
|
|
1096
1123
|
this.handleDragEnd = (ev) => {
|
|
@@ -1100,15 +1127,15 @@ class DateClicking extends internal_cjs.Interaction {
|
|
|
1100
1127
|
let { initialHit, finalHit } = this.hitDragging;
|
|
1101
1128
|
if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
|
|
1102
1129
|
let { context } = component;
|
|
1103
|
-
let
|
|
1104
|
-
context.emitter.trigger('dateClick',
|
|
1130
|
+
let data = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.getDayEl(), jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
|
|
1131
|
+
context.emitter.trigger('dateClick', data);
|
|
1105
1132
|
}
|
|
1106
1133
|
}
|
|
1107
1134
|
};
|
|
1108
1135
|
// we DO want to watch pointer moves because otherwise finalHit won't get populated
|
|
1109
1136
|
this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1110
1137
|
this.dragging.autoScroller.isEnabled = false;
|
|
1111
|
-
let hitDragging = this.hitDragging = new HitDragging(this.dragging,
|
|
1138
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, internal.interactionSettingsToStore(settings));
|
|
1112
1139
|
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1113
1140
|
hitDragging.emitter.on('dragend', this.handleDragEnd);
|
|
1114
1141
|
}
|
|
@@ -1121,19 +1148,22 @@ class DateClicking extends internal_cjs.Interaction {
|
|
|
1121
1148
|
Tracks when the user selects a portion of time of a component,
|
|
1122
1149
|
constituted by a drag over date cells, with a possible delay at the beginning of the drag.
|
|
1123
1150
|
*/
|
|
1124
|
-
class DateSelecting extends
|
|
1151
|
+
class DateSelecting extends internal.Interaction {
|
|
1125
1152
|
constructor(settings) {
|
|
1126
1153
|
super(settings);
|
|
1127
1154
|
this.dragSelection = null;
|
|
1128
1155
|
this.handlePointerDown = (ev) => {
|
|
1129
1156
|
let { component, dragging } = this;
|
|
1130
1157
|
let { options } = component.context;
|
|
1131
|
-
let
|
|
1158
|
+
let canDateSelect = options.selectable &&
|
|
1132
1159
|
component.isValidDateDownEl(ev.origEvent.target);
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1160
|
+
if (!canDateSelect) {
|
|
1161
|
+
dragging.cancel();
|
|
1162
|
+
}
|
|
1163
|
+
else {
|
|
1164
|
+
// if touch, require user to hold down
|
|
1165
|
+
dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
|
|
1166
|
+
}
|
|
1137
1167
|
};
|
|
1138
1168
|
this.handleDragStart = (ev) => {
|
|
1139
1169
|
this.component.context.calendarApi.unselect(ev); // unselect previous selections
|
|
@@ -1150,7 +1180,7 @@ class DateSelecting extends internal_cjs.Interaction {
|
|
|
1150
1180
|
if (!disallowed) {
|
|
1151
1181
|
dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
|
|
1152
1182
|
}
|
|
1153
|
-
if (!dragSelection || !
|
|
1183
|
+
if (!dragSelection || !internal.isDateSelectionValid(dragSelection, hit.dateProfile, context)) {
|
|
1154
1184
|
isInvalid = true;
|
|
1155
1185
|
dragSelection = null;
|
|
1156
1186
|
}
|
|
@@ -1162,10 +1192,10 @@ class DateSelecting extends internal_cjs.Interaction {
|
|
|
1162
1192
|
context.dispatch({ type: 'UNSELECT_DATES' });
|
|
1163
1193
|
}
|
|
1164
1194
|
if (!isInvalid) {
|
|
1165
|
-
|
|
1195
|
+
internal.enableCursor();
|
|
1166
1196
|
}
|
|
1167
1197
|
else {
|
|
1168
|
-
|
|
1198
|
+
internal.disableCursor();
|
|
1169
1199
|
}
|
|
1170
1200
|
if (!isFinal) {
|
|
1171
1201
|
this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
|
|
@@ -1174,7 +1204,7 @@ class DateSelecting extends internal_cjs.Interaction {
|
|
|
1174
1204
|
this.handlePointerUp = (pev) => {
|
|
1175
1205
|
if (this.dragSelection) {
|
|
1176
1206
|
// selection is already rendered, so just need to report selection
|
|
1177
|
-
|
|
1207
|
+
internal.triggerDateSelect(this.dragSelection, pev, this.component.context);
|
|
1178
1208
|
this.dragSelection = null;
|
|
1179
1209
|
}
|
|
1180
1210
|
};
|
|
@@ -1184,7 +1214,7 @@ class DateSelecting extends internal_cjs.Interaction {
|
|
|
1184
1214
|
dragging.touchScrollAllowed = false;
|
|
1185
1215
|
dragging.minDistance = options.selectMinDistance || 0;
|
|
1186
1216
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
1187
|
-
let hitDragging = this.hitDragging = new HitDragging(this.dragging,
|
|
1217
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, internal.interactionSettingsToStore(settings));
|
|
1188
1218
|
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1189
1219
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1190
1220
|
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
@@ -1211,7 +1241,7 @@ function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
|
|
|
1211
1241
|
dateSpan1.range.start,
|
|
1212
1242
|
dateSpan1.range.end,
|
|
1213
1243
|
];
|
|
1214
|
-
ms.sort(
|
|
1244
|
+
ms.sort(internal.compareNumbers);
|
|
1215
1245
|
let props = {};
|
|
1216
1246
|
for (let transformer of dateSelectionTransformers) {
|
|
1217
1247
|
let res = transformer(hit0, hit1);
|
|
@@ -1227,7 +1257,7 @@ function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
|
|
|
1227
1257
|
return props;
|
|
1228
1258
|
}
|
|
1229
1259
|
|
|
1230
|
-
class EventDragging extends
|
|
1260
|
+
class EventDragging extends internal.Interaction {
|
|
1231
1261
|
constructor(settings) {
|
|
1232
1262
|
super(settings);
|
|
1233
1263
|
// internal state
|
|
@@ -1245,29 +1275,29 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1245
1275
|
let { options } = component.context;
|
|
1246
1276
|
let initialContext = component.context;
|
|
1247
1277
|
this.subjectEl = ev.subjectEl;
|
|
1248
|
-
let eventRange = this.eventRange =
|
|
1278
|
+
let eventRange = this.eventRange = internal.getElEventRange(ev.subjectEl);
|
|
1249
1279
|
let eventInstanceId = eventRange.instance.instanceId;
|
|
1250
|
-
this.relevantEvents =
|
|
1280
|
+
this.relevantEvents = internal.getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
|
|
1251
1281
|
dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
|
|
1252
1282
|
dragging.delay =
|
|
1253
1283
|
// only do a touch delay if touch and this event hasn't been selected yet
|
|
1254
1284
|
(ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
|
|
1255
1285
|
getComponentTouchDelay(component) :
|
|
1256
1286
|
null;
|
|
1257
|
-
|
|
1258
|
-
|
|
1287
|
+
mirror.parentNode = internal.getAppendableRoot(origTarget);
|
|
1288
|
+
mirror.revertDuration = options.dragRevertDuration;
|
|
1289
|
+
let isValid = component.isValidSegDownEl(origTarget) &&
|
|
1290
|
+
!origTarget.closest(`.${classNames__default["default"].internalEventResizer}`); // NOT on a resizer
|
|
1291
|
+
if (!isValid) {
|
|
1292
|
+
dragging.cancel();
|
|
1259
1293
|
}
|
|
1260
1294
|
else {
|
|
1261
|
-
|
|
1295
|
+
// disable dragging for elements that are resizable (ie, selectable)
|
|
1296
|
+
// but are not draggable
|
|
1297
|
+
// TODO: merge this with .cancel() ?
|
|
1298
|
+
this.isDragging = ev.subjectEl
|
|
1299
|
+
.classList.contains(classNames__default["default"].internalEventDraggable);
|
|
1262
1300
|
}
|
|
1263
|
-
mirror.revertDuration = options.dragRevertDuration;
|
|
1264
|
-
let isValid = component.isValidSegDownEl(origTarget) &&
|
|
1265
|
-
!origTarget.closest('.fc-event-resizer'); // NOT on a resizer
|
|
1266
|
-
dragging.setIgnoreMove(!isValid);
|
|
1267
|
-
// disable dragging for elements that are resizable (ie, selectable)
|
|
1268
|
-
// but are not draggable
|
|
1269
|
-
this.isDragging = isValid &&
|
|
1270
|
-
ev.subjectEl.classList.contains('fc-event-draggable');
|
|
1271
1301
|
};
|
|
1272
1302
|
this.handleDragStart = (ev) => {
|
|
1273
1303
|
let initialContext = this.component.context;
|
|
@@ -1287,7 +1317,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1287
1317
|
initialContext.calendarApi.unselect(ev); // unselect *date* selection
|
|
1288
1318
|
initialContext.emitter.trigger('eventDragStart', {
|
|
1289
1319
|
el: this.subjectEl,
|
|
1290
|
-
event: new
|
|
1320
|
+
event: new internal.EventImpl(initialContext, eventRange.def, eventRange.instance),
|
|
1291
1321
|
jsEvent: ev.origEvent,
|
|
1292
1322
|
view: initialContext.viewApi,
|
|
1293
1323
|
});
|
|
@@ -1307,7 +1337,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1307
1337
|
let isInvalid = false;
|
|
1308
1338
|
let interaction = {
|
|
1309
1339
|
affectedEvents: relevantEvents,
|
|
1310
|
-
mutatedEvents:
|
|
1340
|
+
mutatedEvents: internal.createEmptyEventStore(),
|
|
1311
1341
|
isEvent: true,
|
|
1312
1342
|
};
|
|
1313
1343
|
if (hit) {
|
|
@@ -1317,13 +1347,13 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1317
1347
|
(receivingOptions.editable && receivingOptions.droppable)) {
|
|
1318
1348
|
mutation = computeEventMutation(initialHit, hit, this.eventRange.instance.range.start, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
|
|
1319
1349
|
if (mutation) {
|
|
1320
|
-
mutatedRelevantEvents =
|
|
1350
|
+
mutatedRelevantEvents = internal.applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
|
|
1321
1351
|
interaction.mutatedEvents = mutatedRelevantEvents;
|
|
1322
|
-
if (!
|
|
1352
|
+
if (!internal.isInteractionValid(interaction, hit.dateProfile, receivingContext)) {
|
|
1323
1353
|
isInvalid = true;
|
|
1324
1354
|
mutation = null;
|
|
1325
1355
|
mutatedRelevantEvents = null;
|
|
1326
|
-
interaction.mutatedEvents =
|
|
1356
|
+
interaction.mutatedEvents = internal.createEmptyEventStore();
|
|
1327
1357
|
}
|
|
1328
1358
|
}
|
|
1329
1359
|
}
|
|
@@ -1333,10 +1363,10 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1333
1363
|
}
|
|
1334
1364
|
this.displayDrag(receivingContext, interaction);
|
|
1335
1365
|
if (!isInvalid) {
|
|
1336
|
-
|
|
1366
|
+
internal.enableCursor();
|
|
1337
1367
|
}
|
|
1338
1368
|
else {
|
|
1339
|
-
|
|
1369
|
+
internal.disableCursor();
|
|
1340
1370
|
}
|
|
1341
1371
|
if (!isFinal) {
|
|
1342
1372
|
if (initialContext === receivingContext && // TODO: write test for this
|
|
@@ -1346,7 +1376,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1346
1376
|
this.dragging.setMirrorNeedsRevert(!mutation);
|
|
1347
1377
|
// render the mirror if no already-rendered mirror
|
|
1348
1378
|
// TODO: wish we could somehow wait for dispatch to guarantee render
|
|
1349
|
-
this.dragging.setMirrorIsVisible(!hit || !this.subjectEl.getRootNode().querySelector(
|
|
1379
|
+
this.dragging.setMirrorIsVisible(!hit || !this.subjectEl.getRootNode().querySelector(`.${classNames__default["default"].internalEventMirror}`));
|
|
1350
1380
|
// assign states based on new hit
|
|
1351
1381
|
this.receivingContext = receivingContext;
|
|
1352
1382
|
this.validMutation = mutation;
|
|
@@ -1365,7 +1395,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1365
1395
|
let { receivingContext, validMutation } = this;
|
|
1366
1396
|
let eventDef = this.eventRange.def;
|
|
1367
1397
|
let eventInstance = this.eventRange.instance;
|
|
1368
|
-
let eventApi = new
|
|
1398
|
+
let eventApi = new internal.EventImpl(initialContext, eventDef, eventInstance);
|
|
1369
1399
|
let relevantEvents = this.relevantEvents;
|
|
1370
1400
|
let mutatedRelevantEvents = this.mutatedRelevantEvents;
|
|
1371
1401
|
let { finalHit } = this.hitDragging;
|
|
@@ -1379,15 +1409,15 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1379
1409
|
if (validMutation) {
|
|
1380
1410
|
// dropped within same calendar
|
|
1381
1411
|
if (receivingContext === initialContext) {
|
|
1382
|
-
let updatedEventApi = new
|
|
1412
|
+
let updatedEventApi = new internal.EventImpl(initialContext, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
|
|
1383
1413
|
initialContext.dispatch({
|
|
1384
1414
|
type: 'MERGE_EVENTS',
|
|
1385
1415
|
eventStore: mutatedRelevantEvents,
|
|
1386
1416
|
});
|
|
1387
|
-
let
|
|
1417
|
+
let eventChangeData = {
|
|
1388
1418
|
oldEvent: eventApi,
|
|
1389
1419
|
event: updatedEventApi,
|
|
1390
|
-
relatedEvents:
|
|
1420
|
+
relatedEvents: internal.buildEventApis(mutatedRelevantEvents, initialContext, eventInstance),
|
|
1391
1421
|
revert() {
|
|
1392
1422
|
initialContext.dispatch({
|
|
1393
1423
|
type: 'MERGE_EVENTS',
|
|
@@ -1399,14 +1429,14 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1399
1429
|
for (let transformer of initialContext.getCurrentData().pluginHooks.eventDropTransformers) {
|
|
1400
1430
|
Object.assign(transformed, transformer(validMutation, initialContext));
|
|
1401
1431
|
}
|
|
1402
|
-
initialContext.emitter.trigger('eventDrop', Object.assign(Object.assign(Object.assign({},
|
|
1403
|
-
initialContext.emitter.trigger('eventChange',
|
|
1432
|
+
initialContext.emitter.trigger('eventDrop', Object.assign(Object.assign(Object.assign({}, eventChangeData), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
|
|
1433
|
+
initialContext.emitter.trigger('eventChange', eventChangeData);
|
|
1404
1434
|
// dropped in different calendar
|
|
1405
1435
|
}
|
|
1406
1436
|
else if (receivingContext) {
|
|
1407
|
-
let
|
|
1437
|
+
let eventRemoveData = {
|
|
1408
1438
|
event: eventApi,
|
|
1409
|
-
relatedEvents:
|
|
1439
|
+
relatedEvents: internal.buildEventApis(relevantEvents, initialContext, eventInstance),
|
|
1410
1440
|
revert() {
|
|
1411
1441
|
initialContext.dispatch({
|
|
1412
1442
|
type: 'MERGE_EVENTS',
|
|
@@ -1414,22 +1444,22 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1414
1444
|
});
|
|
1415
1445
|
},
|
|
1416
1446
|
};
|
|
1417
|
-
initialContext.emitter.trigger('eventLeave', Object.assign(Object.assign({},
|
|
1447
|
+
initialContext.emitter.trigger('eventLeave', Object.assign(Object.assign({}, eventRemoveData), { draggedEl: ev.subjectEl, view: initialView }));
|
|
1418
1448
|
initialContext.dispatch({
|
|
1419
1449
|
type: 'REMOVE_EVENTS',
|
|
1420
1450
|
eventStore: relevantEvents,
|
|
1421
1451
|
});
|
|
1422
|
-
initialContext.emitter.trigger('eventRemove',
|
|
1452
|
+
initialContext.emitter.trigger('eventRemove', eventRemoveData);
|
|
1423
1453
|
let addedEventDef = mutatedRelevantEvents.defs[eventDef.defId];
|
|
1424
1454
|
let addedEventInstance = mutatedRelevantEvents.instances[eventInstance.instanceId];
|
|
1425
|
-
let addedEventApi = new
|
|
1455
|
+
let addedEventApi = new internal.EventImpl(receivingContext, addedEventDef, addedEventInstance);
|
|
1426
1456
|
receivingContext.dispatch({
|
|
1427
1457
|
type: 'MERGE_EVENTS',
|
|
1428
1458
|
eventStore: mutatedRelevantEvents,
|
|
1429
1459
|
});
|
|
1430
|
-
let
|
|
1460
|
+
let eventAddData = {
|
|
1431
1461
|
event: addedEventApi,
|
|
1432
|
-
relatedEvents:
|
|
1462
|
+
relatedEvents: internal.buildEventApis(mutatedRelevantEvents, receivingContext, addedEventInstance),
|
|
1433
1463
|
revert() {
|
|
1434
1464
|
receivingContext.dispatch({
|
|
1435
1465
|
type: 'REMOVE_EVENTS',
|
|
@@ -1437,7 +1467,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1437
1467
|
});
|
|
1438
1468
|
},
|
|
1439
1469
|
};
|
|
1440
|
-
receivingContext.emitter.trigger('eventAdd',
|
|
1470
|
+
receivingContext.emitter.trigger('eventAdd', eventAddData);
|
|
1441
1471
|
if (ev.isTouch) {
|
|
1442
1472
|
receivingContext.dispatch({
|
|
1443
1473
|
type: 'SELECT_EVENT',
|
|
@@ -1445,7 +1475,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1445
1475
|
});
|
|
1446
1476
|
}
|
|
1447
1477
|
receivingContext.emitter.trigger('drop', Object.assign(Object.assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.context.viewApi }));
|
|
1448
|
-
receivingContext.emitter.trigger('eventReceive', Object.assign(Object.assign({},
|
|
1478
|
+
receivingContext.emitter.trigger('eventReceive', Object.assign(Object.assign({}, eventAddData), { draggedEl: ev.subjectEl, view: finalHit.context.viewApi }));
|
|
1449
1479
|
}
|
|
1450
1480
|
}
|
|
1451
1481
|
else {
|
|
@@ -1460,7 +1490,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1460
1490
|
dragging.pointer.selector = EventDragging.SELECTOR;
|
|
1461
1491
|
dragging.touchScrollAllowed = false;
|
|
1462
1492
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
1463
|
-
let hitDragging = this.hitDragging = new HitDragging(this.dragging,
|
|
1493
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, internal.interactionSettingsStore);
|
|
1464
1494
|
hitDragging.useSubjectCenter = settings.useEventCenter;
|
|
1465
1495
|
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1466
1496
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
@@ -1484,7 +1514,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1484
1514
|
type: 'SET_EVENT_DRAG',
|
|
1485
1515
|
state: {
|
|
1486
1516
|
affectedEvents: state.affectedEvents,
|
|
1487
|
-
mutatedEvents:
|
|
1517
|
+
mutatedEvents: internal.createEmptyEventStore(),
|
|
1488
1518
|
isEvent: true,
|
|
1489
1519
|
},
|
|
1490
1520
|
});
|
|
@@ -1520,7 +1550,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1520
1550
|
}
|
|
1521
1551
|
// TODO: test this in IE11
|
|
1522
1552
|
// QUESTION: why do we need it on the resizable???
|
|
1523
|
-
EventDragging.SELECTOR =
|
|
1553
|
+
EventDragging.SELECTOR = `.${classNames__default["default"].internalEventDraggable}, .${classNames__default["default"].internalEventResizable}`;
|
|
1524
1554
|
function computeEventMutation(hit0, hit1, eventInstanceStart, massagers) {
|
|
1525
1555
|
let dateSpan0 = hit0.dateSpan;
|
|
1526
1556
|
let dateSpan1 = hit1.dateSpan;
|
|
@@ -1533,7 +1563,7 @@ function computeEventMutation(hit0, hit1, eventInstanceStart, massagers) {
|
|
|
1533
1563
|
if (dateSpan1.allDay) {
|
|
1534
1564
|
// means date1 is already start-of-day,
|
|
1535
1565
|
// but date0 needs to be converted
|
|
1536
|
-
date0 =
|
|
1566
|
+
date0 = internal.startOfDay(eventInstanceStart);
|
|
1537
1567
|
}
|
|
1538
1568
|
else {
|
|
1539
1569
|
// Moving from allDate->timed
|
|
@@ -1541,7 +1571,7 @@ function computeEventMutation(hit0, hit1, eventInstanceStart, massagers) {
|
|
|
1541
1571
|
date0 = eventInstanceStart;
|
|
1542
1572
|
}
|
|
1543
1573
|
}
|
|
1544
|
-
let delta =
|
|
1574
|
+
let delta = internal.diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ?
|
|
1545
1575
|
hit0.largeUnit :
|
|
1546
1576
|
null);
|
|
1547
1577
|
if (delta.milliseconds) { // has hours/minutes/seconds
|
|
@@ -1565,7 +1595,7 @@ function getComponentTouchDelay(component) {
|
|
|
1565
1595
|
return delay;
|
|
1566
1596
|
}
|
|
1567
1597
|
|
|
1568
|
-
class EventResizing extends
|
|
1598
|
+
class EventResizing extends internal.Interaction {
|
|
1569
1599
|
constructor(settings) {
|
|
1570
1600
|
super(settings);
|
|
1571
1601
|
// internal state
|
|
@@ -1578,23 +1608,25 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1578
1608
|
this.handlePointerDown = (ev) => {
|
|
1579
1609
|
let { component } = this;
|
|
1580
1610
|
let segEl = this.querySegEl(ev);
|
|
1581
|
-
let eventRange = this.eventRange =
|
|
1611
|
+
let eventRange = this.eventRange = internal.getElEventRange(segEl);
|
|
1582
1612
|
this.dragging.minDistance = component.context.options.eventDragMinDistance;
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1613
|
+
const isValid = this.component.isValidSegDownEl(ev.origEvent.target) &&
|
|
1614
|
+
!(ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId);
|
|
1615
|
+
if (!isValid) {
|
|
1616
|
+
this.dragging.cancel();
|
|
1617
|
+
}
|
|
1586
1618
|
};
|
|
1587
1619
|
this.handleDragStart = (ev) => {
|
|
1588
1620
|
let { context } = this.component;
|
|
1589
1621
|
let eventRange = this.eventRange;
|
|
1590
|
-
this.relevantEvents =
|
|
1622
|
+
this.relevantEvents = internal.getRelevantEvents(context.getCurrentData().eventStore, this.eventRange.instance.instanceId);
|
|
1591
1623
|
let segEl = this.querySegEl(ev);
|
|
1592
1624
|
this.draggingSegEl = segEl;
|
|
1593
|
-
this.draggingEventRange =
|
|
1625
|
+
this.draggingEventRange = internal.getElEventRange(segEl);
|
|
1594
1626
|
context.calendarApi.unselect();
|
|
1595
1627
|
context.emitter.trigger('eventResizeStart', {
|
|
1596
1628
|
el: segEl,
|
|
1597
|
-
event: new
|
|
1629
|
+
event: new internal.EventImpl(context, eventRange.def, eventRange.instance),
|
|
1598
1630
|
jsEvent: ev.origEvent,
|
|
1599
1631
|
view: context.viewApi,
|
|
1600
1632
|
});
|
|
@@ -1609,7 +1641,7 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1609
1641
|
let isInvalid = false;
|
|
1610
1642
|
let interaction = {
|
|
1611
1643
|
affectedEvents: relevantEvents,
|
|
1612
|
-
mutatedEvents:
|
|
1644
|
+
mutatedEvents: internal.createEmptyEventStore(),
|
|
1613
1645
|
isEvent: true,
|
|
1614
1646
|
};
|
|
1615
1647
|
if (hit) {
|
|
@@ -1617,13 +1649,13 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1617
1649
|
&& this.isHitComboAllowed
|
|
1618
1650
|
&& !this.isHitComboAllowed(initialHit, hit);
|
|
1619
1651
|
if (!disallowed) {
|
|
1620
|
-
mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains(
|
|
1652
|
+
mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains(classNames__default["default"].internalEventResizerStart), eventInstance.range);
|
|
1621
1653
|
}
|
|
1622
1654
|
}
|
|
1623
1655
|
if (mutation) {
|
|
1624
|
-
mutatedRelevantEvents =
|
|
1656
|
+
mutatedRelevantEvents = internal.applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
|
|
1625
1657
|
interaction.mutatedEvents = mutatedRelevantEvents;
|
|
1626
|
-
if (!
|
|
1658
|
+
if (!internal.isInteractionValid(interaction, hit.dateProfile, context)) {
|
|
1627
1659
|
isInvalid = true;
|
|
1628
1660
|
mutation = null;
|
|
1629
1661
|
mutatedRelevantEvents = null;
|
|
@@ -1640,10 +1672,10 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1640
1672
|
context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
|
|
1641
1673
|
}
|
|
1642
1674
|
if (!isInvalid) {
|
|
1643
|
-
|
|
1675
|
+
internal.enableCursor();
|
|
1644
1676
|
}
|
|
1645
1677
|
else {
|
|
1646
|
-
|
|
1678
|
+
internal.disableCursor();
|
|
1647
1679
|
}
|
|
1648
1680
|
if (!isFinal) {
|
|
1649
1681
|
if (mutation && isHitsEqual(initialHit, hit)) {
|
|
@@ -1657,7 +1689,7 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1657
1689
|
let { context } = this.component;
|
|
1658
1690
|
let eventDef = this.eventRange.def;
|
|
1659
1691
|
let eventInstance = this.eventRange.instance;
|
|
1660
|
-
let eventApi = new
|
|
1692
|
+
let eventApi = new internal.EventImpl(context, eventDef, eventInstance);
|
|
1661
1693
|
let relevantEvents = this.relevantEvents;
|
|
1662
1694
|
let mutatedRelevantEvents = this.mutatedRelevantEvents;
|
|
1663
1695
|
context.emitter.trigger('eventResizeStop', {
|
|
@@ -1667,15 +1699,15 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1667
1699
|
view: context.viewApi,
|
|
1668
1700
|
});
|
|
1669
1701
|
if (this.validMutation) {
|
|
1670
|
-
let updatedEventApi = new
|
|
1702
|
+
let updatedEventApi = new internal.EventImpl(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
|
|
1671
1703
|
context.dispatch({
|
|
1672
1704
|
type: 'MERGE_EVENTS',
|
|
1673
1705
|
eventStore: mutatedRelevantEvents,
|
|
1674
1706
|
});
|
|
1675
|
-
let
|
|
1707
|
+
let eventChangeData = {
|
|
1676
1708
|
oldEvent: eventApi,
|
|
1677
1709
|
event: updatedEventApi,
|
|
1678
|
-
relatedEvents:
|
|
1710
|
+
relatedEvents: internal.buildEventApis(mutatedRelevantEvents, context, eventInstance),
|
|
1679
1711
|
revert() {
|
|
1680
1712
|
context.dispatch({
|
|
1681
1713
|
type: 'MERGE_EVENTS',
|
|
@@ -1683,8 +1715,8 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1683
1715
|
});
|
|
1684
1716
|
},
|
|
1685
1717
|
};
|
|
1686
|
-
context.emitter.trigger('eventResize', Object.assign(Object.assign({},
|
|
1687
|
-
context.emitter.trigger('eventChange',
|
|
1718
|
+
context.emitter.trigger('eventResize', Object.assign(Object.assign({}, eventChangeData), { el: this.draggingSegEl, startDelta: this.validMutation.startDelta || internal.createDuration(0), endDelta: this.validMutation.endDelta || internal.createDuration(0), jsEvent: ev.origEvent, view: context.viewApi }));
|
|
1719
|
+
context.emitter.trigger('eventChange', eventChangeData);
|
|
1688
1720
|
}
|
|
1689
1721
|
else {
|
|
1690
1722
|
context.emitter.trigger('_noEventResize');
|
|
@@ -1697,10 +1729,10 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1697
1729
|
};
|
|
1698
1730
|
let { component } = settings;
|
|
1699
1731
|
let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1700
|
-
dragging.pointer.selector =
|
|
1732
|
+
dragging.pointer.selector = `.${classNames__default["default"].internalEventResizer}`;
|
|
1701
1733
|
dragging.touchScrollAllowed = false;
|
|
1702
1734
|
dragging.autoScroller.isEnabled = component.context.options.dragScroll;
|
|
1703
|
-
let hitDragging = this.hitDragging = new HitDragging(this.dragging,
|
|
1735
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, internal.interactionSettingsToStore(settings));
|
|
1704
1736
|
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1705
1737
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1706
1738
|
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
@@ -1710,14 +1742,14 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1710
1742
|
this.dragging.destroy();
|
|
1711
1743
|
}
|
|
1712
1744
|
querySegEl(ev) {
|
|
1713
|
-
return ev.subjectEl.closest(
|
|
1745
|
+
return ev.subjectEl.closest(`.${classNames__default["default"].internalEvent}`);
|
|
1714
1746
|
}
|
|
1715
1747
|
}
|
|
1716
1748
|
function computeMutation(hit0, hit1, isFromStart, instanceRange) {
|
|
1717
1749
|
let dateEnv = hit0.context.dateEnv;
|
|
1718
1750
|
let date0 = hit0.dateSpan.range.start;
|
|
1719
1751
|
let date1 = hit1.dateSpan.range.start;
|
|
1720
|
-
let delta =
|
|
1752
|
+
let delta = internal.diffDates(date0, date1, dateEnv, hit0.largeUnit);
|
|
1721
1753
|
if (isFromStart) {
|
|
1722
1754
|
if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
|
|
1723
1755
|
return { startDelta: delta };
|
|
@@ -1735,14 +1767,14 @@ class UnselectAuto {
|
|
|
1735
1767
|
this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
|
|
1736
1768
|
this.matchesCancel = false;
|
|
1737
1769
|
this.matchesEvent = false;
|
|
1738
|
-
this.onSelect = (
|
|
1739
|
-
if (
|
|
1770
|
+
this.onSelect = (selectData) => {
|
|
1771
|
+
if (selectData.jsEvent) {
|
|
1740
1772
|
this.isRecentPointerDateSelect = true;
|
|
1741
1773
|
}
|
|
1742
1774
|
};
|
|
1743
1775
|
this.onDocumentPointerDown = (pev) => {
|
|
1744
1776
|
let unselectCancel = this.context.options.unselectCancel;
|
|
1745
|
-
let downEl =
|
|
1777
|
+
let downEl = internal.getEventTargetViaRoot(pev.origEvent);
|
|
1746
1778
|
this.matchesCancel = !!downEl.closest(unselectCancel);
|
|
1747
1779
|
this.matchesEvent = !!downEl.closest(EventDragging.SELECTOR); // interaction started on an event?
|
|
1748
1780
|
};
|
|
@@ -1784,20 +1816,18 @@ class UnselectAuto {
|
|
|
1784
1816
|
}
|
|
1785
1817
|
}
|
|
1786
1818
|
|
|
1787
|
-
const OPTION_REFINERS = {
|
|
1788
|
-
fixedMirrorParent: internal_cjs.identity,
|
|
1789
|
-
};
|
|
1819
|
+
const OPTION_REFINERS = {};
|
|
1790
1820
|
const LISTENER_REFINERS = {
|
|
1791
|
-
dateClick:
|
|
1792
|
-
eventDragStart:
|
|
1793
|
-
eventDragStop:
|
|
1794
|
-
eventDrop:
|
|
1795
|
-
eventResizeStart:
|
|
1796
|
-
eventResizeStop:
|
|
1797
|
-
eventResize:
|
|
1798
|
-
drop:
|
|
1799
|
-
eventReceive:
|
|
1800
|
-
eventLeave:
|
|
1821
|
+
dateClick: internal.identity,
|
|
1822
|
+
eventDragStart: internal.identity,
|
|
1823
|
+
eventDragStop: internal.identity,
|
|
1824
|
+
eventDrop: internal.identity,
|
|
1825
|
+
eventResizeStart: internal.identity,
|
|
1826
|
+
eventResizeStop: internal.identity,
|
|
1827
|
+
eventResize: internal.identity,
|
|
1828
|
+
drop: internal.identity,
|
|
1829
|
+
eventReceive: internal.identity,
|
|
1830
|
+
eventLeave: internal.identity,
|
|
1801
1831
|
};
|
|
1802
1832
|
|
|
1803
1833
|
/*
|
|
@@ -1820,18 +1850,18 @@ class ExternalElementDragging {
|
|
|
1820
1850
|
let droppableEvent = null;
|
|
1821
1851
|
let isInvalid = false;
|
|
1822
1852
|
let interaction = {
|
|
1823
|
-
affectedEvents:
|
|
1824
|
-
mutatedEvents:
|
|
1853
|
+
affectedEvents: internal.createEmptyEventStore(),
|
|
1854
|
+
mutatedEvents: internal.createEmptyEventStore(),
|
|
1825
1855
|
isEvent: this.dragMeta.create,
|
|
1826
1856
|
};
|
|
1827
1857
|
if (hit) {
|
|
1828
1858
|
receivingContext = hit.context;
|
|
1829
1859
|
if (this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
|
|
1830
1860
|
droppableEvent = computeEventForDateSpan(hit.dateSpan, this.dragMeta, receivingContext);
|
|
1831
|
-
interaction.mutatedEvents =
|
|
1832
|
-
isInvalid = !
|
|
1861
|
+
interaction.mutatedEvents = internal.eventTupleToStore(droppableEvent);
|
|
1862
|
+
isInvalid = !internal.isInteractionValid(interaction, hit.dateProfile, receivingContext);
|
|
1833
1863
|
if (isInvalid) {
|
|
1834
|
-
interaction.mutatedEvents =
|
|
1864
|
+
interaction.mutatedEvents = internal.createEmptyEventStore();
|
|
1835
1865
|
droppableEvent = null;
|
|
1836
1866
|
}
|
|
1837
1867
|
}
|
|
@@ -1839,12 +1869,14 @@ class ExternalElementDragging {
|
|
|
1839
1869
|
this.displayDrag(receivingContext, interaction);
|
|
1840
1870
|
// show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
|
|
1841
1871
|
// TODO: wish we could somehow wait for dispatch to guarantee render
|
|
1842
|
-
dragging.setMirrorIsVisible(isFinal ||
|
|
1872
|
+
dragging.setMirrorIsVisible(isFinal ||
|
|
1873
|
+
!droppableEvent ||
|
|
1874
|
+
!document.querySelector(`.${classNames__default["default"].internalEventMirror}`));
|
|
1843
1875
|
if (!isInvalid) {
|
|
1844
|
-
|
|
1876
|
+
internal.enableCursor();
|
|
1845
1877
|
}
|
|
1846
1878
|
else {
|
|
1847
|
-
|
|
1879
|
+
internal.disableCursor();
|
|
1848
1880
|
}
|
|
1849
1881
|
if (!isFinal) {
|
|
1850
1882
|
dragging.setMirrorNeedsRevert(!droppableEvent);
|
|
@@ -1861,7 +1893,7 @@ class ExternalElementDragging {
|
|
|
1861
1893
|
let dragMeta = this.dragMeta;
|
|
1862
1894
|
receivingContext.emitter.trigger('drop', Object.assign(Object.assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
|
|
1863
1895
|
if (dragMeta.create) {
|
|
1864
|
-
let addingEvents =
|
|
1896
|
+
let addingEvents = internal.eventTupleToStore(droppableEvent);
|
|
1865
1897
|
receivingContext.dispatch({
|
|
1866
1898
|
type: 'MERGE_EVENTS',
|
|
1867
1899
|
eventStore: addingEvents,
|
|
@@ -1874,7 +1906,7 @@ class ExternalElementDragging {
|
|
|
1874
1906
|
}
|
|
1875
1907
|
// signal that an external event landed
|
|
1876
1908
|
receivingContext.emitter.trigger('eventReceive', {
|
|
1877
|
-
event: new
|
|
1909
|
+
event: new internal.EventImpl(receivingContext, droppableEvent.def, droppableEvent.instance),
|
|
1878
1910
|
relatedEvents: [],
|
|
1879
1911
|
revert() {
|
|
1880
1912
|
receivingContext.dispatch({
|
|
@@ -1890,7 +1922,7 @@ class ExternalElementDragging {
|
|
|
1890
1922
|
this.receivingContext = null;
|
|
1891
1923
|
this.droppableEvent = null;
|
|
1892
1924
|
};
|
|
1893
|
-
let hitDragging = this.hitDragging = new HitDragging(dragging,
|
|
1925
|
+
let hitDragging = this.hitDragging = new HitDragging(dragging, internal.interactionSettingsStore);
|
|
1894
1926
|
hitDragging.requireInitial = false; // will start outside of a component
|
|
1895
1927
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1896
1928
|
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
@@ -1899,10 +1931,10 @@ class ExternalElementDragging {
|
|
|
1899
1931
|
}
|
|
1900
1932
|
buildDragMeta(subjectEl) {
|
|
1901
1933
|
if (typeof this.suppliedDragMeta === 'object') {
|
|
1902
|
-
return
|
|
1934
|
+
return internal.parseDragMeta(this.suppliedDragMeta);
|
|
1903
1935
|
}
|
|
1904
1936
|
if (typeof this.suppliedDragMeta === 'function') {
|
|
1905
|
-
return
|
|
1937
|
+
return internal.parseDragMeta(this.suppliedDragMeta(subjectEl));
|
|
1906
1938
|
}
|
|
1907
1939
|
return getDragMetaFromEl(subjectEl);
|
|
1908
1940
|
}
|
|
@@ -1938,8 +1970,8 @@ function computeEventForDateSpan(dateSpan, dragMeta, context) {
|
|
|
1938
1970
|
for (let transform of context.pluginHooks.externalDefTransforms) {
|
|
1939
1971
|
Object.assign(defProps, transform(dateSpan, dragMeta));
|
|
1940
1972
|
}
|
|
1941
|
-
let { refined, extra } =
|
|
1942
|
-
let def =
|
|
1973
|
+
let { refined, extra } = internal.refineEventDef(defProps, context);
|
|
1974
|
+
let def = internal.parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), // hasEnd
|
|
1943
1975
|
context);
|
|
1944
1976
|
let start = dateSpan.range.start;
|
|
1945
1977
|
// only rely on time info if drop zone is all-day,
|
|
@@ -1949,8 +1981,8 @@ function computeEventForDateSpan(dateSpan, dragMeta, context) {
|
|
|
1949
1981
|
}
|
|
1950
1982
|
let end = dragMeta.duration ?
|
|
1951
1983
|
context.dateEnv.add(start, dragMeta.duration) :
|
|
1952
|
-
|
|
1953
|
-
let instance =
|
|
1984
|
+
internal.getDefaultEventEnd(dateSpan.allDay, start, context);
|
|
1985
|
+
let instance = internal.createEventInstance(def.defId, { start, end });
|
|
1954
1986
|
return { def, instance };
|
|
1955
1987
|
}
|
|
1956
1988
|
// Utils for extracting data from element
|
|
@@ -1960,11 +1992,11 @@ function getDragMetaFromEl(el) {
|
|
|
1960
1992
|
let obj = str ?
|
|
1961
1993
|
JSON.parse(str) :
|
|
1962
1994
|
{ create: false }; // if no embedded data, assume no event creation
|
|
1963
|
-
return
|
|
1995
|
+
return internal.parseDragMeta(obj);
|
|
1964
1996
|
}
|
|
1965
|
-
|
|
1997
|
+
internal.config.dataAttrPrefix = '';
|
|
1966
1998
|
function getEmbeddedElData(el, name) {
|
|
1967
|
-
let prefix =
|
|
1999
|
+
let prefix = internal.config.dataAttrPrefix;
|
|
1968
2000
|
let prefixedName = (prefix ? prefix + '-' : '') + name;
|
|
1969
2001
|
return el.getAttribute('data-' + prefixedName) || '';
|
|
1970
2002
|
}
|
|
@@ -1982,17 +2014,17 @@ class ExternalDraggable {
|
|
|
1982
2014
|
dragging.minDistance =
|
|
1983
2015
|
minDistance != null ?
|
|
1984
2016
|
minDistance :
|
|
1985
|
-
(ev.isTouch ? 0 :
|
|
2017
|
+
(ev.isTouch ? 0 : internal.BASE_OPTION_DEFAULTS.eventDragMinDistance);
|
|
1986
2018
|
dragging.delay =
|
|
1987
2019
|
ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
|
|
1988
|
-
(longPressDelay != null ? longPressDelay :
|
|
2020
|
+
(longPressDelay != null ? longPressDelay : internal.BASE_OPTION_DEFAULTS.longPressDelay) :
|
|
1989
2021
|
0;
|
|
1990
2022
|
};
|
|
1991
2023
|
this.handleDragStart = (ev) => {
|
|
1992
2024
|
if (ev.isTouch &&
|
|
1993
2025
|
this.dragging.delay &&
|
|
1994
|
-
ev.subjectEl.classList.contains(
|
|
1995
|
-
this.dragging.mirror.getMirrorEl().classList.add(
|
|
2026
|
+
ev.subjectEl.classList.contains(classNames__default["default"].internalEvent)) {
|
|
2027
|
+
this.dragging.mirror.getMirrorEl().classList.add(classNames__default["default"].internalEventSelected);
|
|
1996
2028
|
}
|
|
1997
2029
|
};
|
|
1998
2030
|
this.settings = settings;
|
|
@@ -2019,7 +2051,7 @@ The third-party system is responsible for drawing the visuals effects of the dra
|
|
|
2019
2051
|
This class simply monitors for pointer movements and fires events.
|
|
2020
2052
|
It also has the ability to hide the moving element (the "mirror") during the drag.
|
|
2021
2053
|
*/
|
|
2022
|
-
class InferredElementDragging extends
|
|
2054
|
+
class InferredElementDragging extends internal.ElementDragging {
|
|
2023
2055
|
constructor(containerEl) {
|
|
2024
2056
|
super(containerEl);
|
|
2025
2057
|
this.shouldIgnoreMove = false;
|
|
@@ -2052,8 +2084,8 @@ class InferredElementDragging extends internal_cjs.ElementDragging {
|
|
|
2052
2084
|
destroy() {
|
|
2053
2085
|
this.pointer.destroy();
|
|
2054
2086
|
}
|
|
2055
|
-
|
|
2056
|
-
this.shouldIgnoreMove =
|
|
2087
|
+
cancel() {
|
|
2088
|
+
this.shouldIgnoreMove = true;
|
|
2057
2089
|
}
|
|
2058
2090
|
setMirrorIsVisible(bool) {
|
|
2059
2091
|
if (bool) {
|
|
@@ -2114,7 +2146,7 @@ class ThirdPartyDraggable {
|
|
|
2114
2146
|
}
|
|
2115
2147
|
}
|
|
2116
2148
|
|
|
2117
|
-
var index =
|
|
2149
|
+
var index = core.createPlugin({
|
|
2118
2150
|
name: '@fullcalendar/interaction',
|
|
2119
2151
|
componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
|
|
2120
2152
|
calendarInteractions: [UnselectAuto],
|