@fullcalendar/interaction 7.0.0-beta.4 → 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} +157 -148
- package/{index.d.ts → esm/index.d.ts} +38 -32
- package/{index.js → esm/index.js} +47 -42
- package/{index.global.js → global.js} +52 -44
- 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;
|
|
@@ -121,7 +126,7 @@ class PointerDragging {
|
|
|
121
126
|
}
|
|
122
127
|
};
|
|
123
128
|
this.containerEl = containerEl;
|
|
124
|
-
this.emitter = new
|
|
129
|
+
this.emitter = new internal.Emitter();
|
|
125
130
|
containerEl.addEventListener('mousedown', this.handleMouseDown);
|
|
126
131
|
containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
|
|
127
132
|
listenerCreated();
|
|
@@ -261,7 +266,7 @@ function startIgnoringMouse() {
|
|
|
261
266
|
ignoreMouseDepth += 1;
|
|
262
267
|
setTimeout(() => {
|
|
263
268
|
ignoreMouseDepth -= 1;
|
|
264
|
-
},
|
|
269
|
+
}, internal.config.touchMouseIgnoreWait);
|
|
265
270
|
}
|
|
266
271
|
// We want to attach touchmove as early as possible for Safari
|
|
267
272
|
// ----------------------------------------------------------------------------------------------------
|
|
@@ -318,7 +323,9 @@ class ElementMirror {
|
|
|
318
323
|
if (bool) {
|
|
319
324
|
if (!this.isVisible) {
|
|
320
325
|
if (this.mirrorEl) {
|
|
321
|
-
|
|
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');
|
|
322
329
|
}
|
|
323
330
|
this.isVisible = bool; // needs to happen before updateElPosition
|
|
324
331
|
this.updateElPosition(); // because was not updating the position while invisible
|
|
@@ -326,7 +333,9 @@ class ElementMirror {
|
|
|
326
333
|
}
|
|
327
334
|
else if (this.isVisible) {
|
|
328
335
|
if (this.mirrorEl) {
|
|
329
|
-
|
|
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');
|
|
330
339
|
}
|
|
331
340
|
this.isVisible = bool;
|
|
332
341
|
}
|
|
@@ -355,11 +364,11 @@ class ElementMirror {
|
|
|
355
364
|
mirrorEl.style.transition =
|
|
356
365
|
'top ' + revertDuration + 'ms,' +
|
|
357
366
|
'left ' + revertDuration + 'ms';
|
|
358
|
-
|
|
367
|
+
internal.applyStyle(mirrorEl, {
|
|
359
368
|
left: finalSourceElRect.left,
|
|
360
369
|
top: finalSourceElRect.top,
|
|
361
370
|
});
|
|
362
|
-
|
|
371
|
+
internal.whenTransitionDone(mirrorEl, () => {
|
|
363
372
|
mirrorEl.style.transition = '';
|
|
364
373
|
callback();
|
|
365
374
|
});
|
|
@@ -373,7 +382,7 @@ class ElementMirror {
|
|
|
373
382
|
}
|
|
374
383
|
updateElPosition() {
|
|
375
384
|
if (this.sourceEl && this.isVisible) {
|
|
376
|
-
|
|
385
|
+
internal.applyStyle(this.getMirrorEl(), {
|
|
377
386
|
left: this.sourceElRect.left + this.deltaX,
|
|
378
387
|
top: this.sourceElRect.top + this.deltaY,
|
|
379
388
|
});
|
|
@@ -386,11 +395,11 @@ class ElementMirror {
|
|
|
386
395
|
mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
|
|
387
396
|
// we don't want long taps or any mouse interaction causing selection/menus.
|
|
388
397
|
// would use preventSelection(), but that prevents selectstart, causing problems.
|
|
398
|
+
// TODO: make className for this?
|
|
389
399
|
mirrorEl.style.userSelect = 'none';
|
|
390
400
|
mirrorEl.style.webkitUserSelect = 'none';
|
|
391
401
|
mirrorEl.style.pointerEvents = 'none';
|
|
392
|
-
|
|
393
|
-
internal_cjs.applyStyle(mirrorEl, {
|
|
402
|
+
internal.applyStyle(mirrorEl, {
|
|
394
403
|
position: 'fixed',
|
|
395
404
|
zIndex: this.zIndex,
|
|
396
405
|
visibility: '',
|
|
@@ -415,7 +424,7 @@ The cache can be in one of two modes:
|
|
|
415
424
|
- doesListening:false - ignores when the container is scrolled by someone else
|
|
416
425
|
- doesListening:true - watch for scrolling and update the cache
|
|
417
426
|
*/
|
|
418
|
-
class ScrollGeomCache extends
|
|
427
|
+
class ScrollGeomCache extends internal.ScrollController {
|
|
419
428
|
constructor(scrollController, doesListening) {
|
|
420
429
|
super();
|
|
421
430
|
this.handleScroll = () => {
|
|
@@ -483,19 +492,19 @@ class ScrollGeomCache extends internal_cjs.ScrollController {
|
|
|
483
492
|
|
|
484
493
|
class ElementScrollGeomCache extends ScrollGeomCache {
|
|
485
494
|
constructor(el, doesListening) {
|
|
486
|
-
super(new
|
|
495
|
+
super(new internal.ElementScrollController(el), doesListening);
|
|
487
496
|
}
|
|
488
497
|
getEventTarget() {
|
|
489
498
|
return this.scrollController.el;
|
|
490
499
|
}
|
|
491
500
|
computeClientRect() {
|
|
492
|
-
return
|
|
501
|
+
return internal.computeInnerRect(this.scrollController.el);
|
|
493
502
|
}
|
|
494
503
|
}
|
|
495
504
|
|
|
496
505
|
class WindowScrollGeomCache extends ScrollGeomCache {
|
|
497
506
|
constructor(doesListening) {
|
|
498
|
-
super(new
|
|
507
|
+
super(new internal.WindowScrollController(), doesListening);
|
|
499
508
|
}
|
|
500
509
|
getEventTarget() {
|
|
501
510
|
return window;
|
|
@@ -529,7 +538,7 @@ class AutoScroller {
|
|
|
529
538
|
constructor() {
|
|
530
539
|
// options that can be set by caller
|
|
531
540
|
this.isEnabled = true;
|
|
532
|
-
this.scrollQuery = [window,
|
|
541
|
+
this.scrollQuery = [window, `.${classNames__default["default"].internalScroller}`];
|
|
533
542
|
this.edgeThreshold = 50; // pixels
|
|
534
543
|
this.maxVelocity = 300; // pixels per second
|
|
535
544
|
// internal state
|
|
@@ -699,7 +708,7 @@ Monitors dragging on an element. Has a number of high-level features:
|
|
|
699
708
|
- minimum wait time ("delay") before dragging
|
|
700
709
|
- a mirror element that follows the pointer
|
|
701
710
|
*/
|
|
702
|
-
class FeaturefulElementDragging extends
|
|
711
|
+
class FeaturefulElementDragging extends internal.ElementDragging {
|
|
703
712
|
constructor(containerEl, selector) {
|
|
704
713
|
super(containerEl);
|
|
705
714
|
this.containerEl = containerEl;
|
|
@@ -721,8 +730,8 @@ class FeaturefulElementDragging extends internal_cjs.ElementDragging {
|
|
|
721
730
|
this.isDistanceSurpassed = false;
|
|
722
731
|
this.emitter.trigger('pointerdown', ev);
|
|
723
732
|
if (this.isInteracting) { // not cancelled?
|
|
724
|
-
|
|
725
|
-
|
|
733
|
+
internal.preventSelection(document.body);
|
|
734
|
+
internal.preventContextMenu(document.body);
|
|
726
735
|
// prevent links from being visited if there's an eventual drag.
|
|
727
736
|
// also prevents selection in older browsers (maybe?).
|
|
728
737
|
// not necessary for touch, besides, browser would complain about passiveness.
|
|
@@ -764,8 +773,8 @@ class FeaturefulElementDragging extends internal_cjs.ElementDragging {
|
|
|
764
773
|
this.onPointerUp = (ev) => {
|
|
765
774
|
if (this.isInteracting) {
|
|
766
775
|
this.isInteracting = false;
|
|
767
|
-
|
|
768
|
-
|
|
776
|
+
internal.allowSelection(document.body);
|
|
777
|
+
internal.allowContextMenu(document.body);
|
|
769
778
|
this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
|
|
770
779
|
if (this.isDragging) {
|
|
771
780
|
this.autoScroller.stop();
|
|
@@ -866,9 +875,10 @@ and an determine if a given point is inside the combined clipping rectangle.
|
|
|
866
875
|
class OffsetTracker {
|
|
867
876
|
constructor(el) {
|
|
868
877
|
this.el = el;
|
|
869
|
-
this.origRect =
|
|
878
|
+
this.origRect = internal.computeRect(el);
|
|
879
|
+
this.isRtl = internal.computeElIsRtl(el);
|
|
870
880
|
// will work fine for divs that have overflow:hidden
|
|
871
|
-
this.scrollCaches =
|
|
881
|
+
this.scrollCaches = internal.getClippingParents(el).map((scrollEl) => new ElementScrollGeomCache(scrollEl, true));
|
|
872
882
|
}
|
|
873
883
|
destroy() {
|
|
874
884
|
for (let scrollCache of this.scrollCaches) {
|
|
@@ -893,7 +903,7 @@ class OffsetTracker {
|
|
|
893
903
|
let point = { left: pageX, top: pageY };
|
|
894
904
|
for (let scrollCache of this.scrollCaches) {
|
|
895
905
|
if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
|
|
896
|
-
!
|
|
906
|
+
!internal.pointInsideRect(point, scrollCache.clientRect)) {
|
|
897
907
|
return false;
|
|
898
908
|
}
|
|
899
909
|
}
|
|
@@ -971,7 +981,7 @@ class HitDragging {
|
|
|
971
981
|
dragging.emitter.on('pointerup', this.handlePointerUp);
|
|
972
982
|
dragging.emitter.on('dragend', this.handleDragEnd);
|
|
973
983
|
this.dragging = dragging;
|
|
974
|
-
this.emitter = new
|
|
984
|
+
this.emitter = new internal.Emitter();
|
|
975
985
|
}
|
|
976
986
|
// sets initialHit
|
|
977
987
|
// sets coordAdjust
|
|
@@ -981,18 +991,18 @@ class HitDragging {
|
|
|
981
991
|
let subjectEl = ev.subjectEl;
|
|
982
992
|
let subjectRect;
|
|
983
993
|
if (subjectEl instanceof HTMLElement) { // i.e. not a Document/ShadowRoot
|
|
984
|
-
subjectRect =
|
|
985
|
-
adjustedPoint =
|
|
994
|
+
subjectRect = internal.computeRect(subjectEl);
|
|
995
|
+
adjustedPoint = internal.constrainPoint(adjustedPoint, subjectRect);
|
|
986
996
|
}
|
|
987
997
|
let initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
|
|
988
998
|
if (initialHit) {
|
|
989
999
|
if (this.useSubjectCenter && subjectRect) {
|
|
990
|
-
let slicedSubjectRect =
|
|
1000
|
+
let slicedSubjectRect = internal.intersectRects(subjectRect, initialHit.rect);
|
|
991
1001
|
if (slicedSubjectRect) {
|
|
992
|
-
adjustedPoint =
|
|
1002
|
+
adjustedPoint = internal.getRectCenter(slicedSubjectRect);
|
|
993
1003
|
}
|
|
994
1004
|
}
|
|
995
|
-
this.coordAdjust =
|
|
1005
|
+
this.coordAdjust = internal.diffPoints(adjustedPoint, origPoint);
|
|
996
1006
|
}
|
|
997
1007
|
else {
|
|
998
1008
|
this.coordAdjust = { left: 0, top: 0 };
|
|
@@ -1006,7 +1016,7 @@ class HitDragging {
|
|
|
1006
1016
|
}
|
|
1007
1017
|
}
|
|
1008
1018
|
prepareHits() {
|
|
1009
|
-
this.offsetTrackers =
|
|
1019
|
+
this.offsetTrackers = internal.mapHash(this.droppableStore, (interactionSettings) => {
|
|
1010
1020
|
interactionSettings.component.prepareHits();
|
|
1011
1021
|
return new OffsetTracker(interactionSettings.el);
|
|
1012
1022
|
});
|
|
@@ -1037,10 +1047,10 @@ class HitDragging {
|
|
|
1037
1047
|
// must be within the element's bounds
|
|
1038
1048
|
positionLeft >= 0 && positionLeft < width &&
|
|
1039
1049
|
positionTop >= 0 && positionTop < height) {
|
|
1040
|
-
let hit = component.queryHit(positionLeft, positionTop, width, height);
|
|
1050
|
+
let hit = component.queryHit(offsetTracker.isRtl, positionLeft, positionTop, width, height);
|
|
1041
1051
|
if (hit && (
|
|
1042
1052
|
// make sure the hit is within activeRange, meaning it's not a dead cell
|
|
1043
|
-
|
|
1053
|
+
internal.rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range)) &&
|
|
1044
1054
|
// Ensure the component we are querying for the hit is accessibly my the pointer
|
|
1045
1055
|
// Prevents obscured calendars (ex: under a modal dialog) from accepting hit
|
|
1046
1056
|
// https://github.com/fullcalendar/fullcalendar/issues/5026
|
|
@@ -1071,7 +1081,7 @@ function isHitsEqual(hit0, hit1) {
|
|
|
1071
1081
|
if (Boolean(hit0) !== Boolean(hit1)) {
|
|
1072
1082
|
return false;
|
|
1073
1083
|
}
|
|
1074
|
-
return
|
|
1084
|
+
return internal.isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
|
|
1075
1085
|
}
|
|
1076
1086
|
|
|
1077
1087
|
function buildDatePointApiWithContext(dateSpan, context) {
|
|
@@ -1094,12 +1104,15 @@ function buildDatePointApi(span, dateEnv) {
|
|
|
1094
1104
|
Monitors when the user clicks on a specific date/time of a component.
|
|
1095
1105
|
A pointerdown+pointerup on the same "hit" constitutes a click.
|
|
1096
1106
|
*/
|
|
1097
|
-
class DateClicking extends
|
|
1107
|
+
class DateClicking extends internal.Interaction {
|
|
1098
1108
|
constructor(settings) {
|
|
1099
1109
|
super(settings);
|
|
1100
1110
|
this.handlePointerDown = (pev) => {
|
|
1101
1111
|
let { dragging } = this;
|
|
1102
1112
|
let downEl = pev.origEvent.target;
|
|
1113
|
+
/*
|
|
1114
|
+
If no dateClick, allow text on dates to be text-selectable
|
|
1115
|
+
*/
|
|
1103
1116
|
const canDateClick = this.component.context.emitter.hasHandlers('dateClick') &&
|
|
1104
1117
|
this.component.isValidDateDownEl(downEl);
|
|
1105
1118
|
if (!canDateClick) {
|
|
@@ -1114,15 +1127,15 @@ class DateClicking extends internal_cjs.Interaction {
|
|
|
1114
1127
|
let { initialHit, finalHit } = this.hitDragging;
|
|
1115
1128
|
if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
|
|
1116
1129
|
let { context } = component;
|
|
1117
|
-
let
|
|
1118
|
-
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);
|
|
1119
1132
|
}
|
|
1120
1133
|
}
|
|
1121
1134
|
};
|
|
1122
1135
|
// we DO want to watch pointer moves because otherwise finalHit won't get populated
|
|
1123
1136
|
this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1124
1137
|
this.dragging.autoScroller.isEnabled = false;
|
|
1125
|
-
let hitDragging = this.hitDragging = new HitDragging(this.dragging,
|
|
1138
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, internal.interactionSettingsToStore(settings));
|
|
1126
1139
|
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1127
1140
|
hitDragging.emitter.on('dragend', this.handleDragEnd);
|
|
1128
1141
|
}
|
|
@@ -1135,7 +1148,7 @@ class DateClicking extends internal_cjs.Interaction {
|
|
|
1135
1148
|
Tracks when the user selects a portion of time of a component,
|
|
1136
1149
|
constituted by a drag over date cells, with a possible delay at the beginning of the drag.
|
|
1137
1150
|
*/
|
|
1138
|
-
class DateSelecting extends
|
|
1151
|
+
class DateSelecting extends internal.Interaction {
|
|
1139
1152
|
constructor(settings) {
|
|
1140
1153
|
super(settings);
|
|
1141
1154
|
this.dragSelection = null;
|
|
@@ -1167,7 +1180,7 @@ class DateSelecting extends internal_cjs.Interaction {
|
|
|
1167
1180
|
if (!disallowed) {
|
|
1168
1181
|
dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
|
|
1169
1182
|
}
|
|
1170
|
-
if (!dragSelection || !
|
|
1183
|
+
if (!dragSelection || !internal.isDateSelectionValid(dragSelection, hit.dateProfile, context)) {
|
|
1171
1184
|
isInvalid = true;
|
|
1172
1185
|
dragSelection = null;
|
|
1173
1186
|
}
|
|
@@ -1179,10 +1192,10 @@ class DateSelecting extends internal_cjs.Interaction {
|
|
|
1179
1192
|
context.dispatch({ type: 'UNSELECT_DATES' });
|
|
1180
1193
|
}
|
|
1181
1194
|
if (!isInvalid) {
|
|
1182
|
-
|
|
1195
|
+
internal.enableCursor();
|
|
1183
1196
|
}
|
|
1184
1197
|
else {
|
|
1185
|
-
|
|
1198
|
+
internal.disableCursor();
|
|
1186
1199
|
}
|
|
1187
1200
|
if (!isFinal) {
|
|
1188
1201
|
this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
|
|
@@ -1191,7 +1204,7 @@ class DateSelecting extends internal_cjs.Interaction {
|
|
|
1191
1204
|
this.handlePointerUp = (pev) => {
|
|
1192
1205
|
if (this.dragSelection) {
|
|
1193
1206
|
// selection is already rendered, so just need to report selection
|
|
1194
|
-
|
|
1207
|
+
internal.triggerDateSelect(this.dragSelection, pev, this.component.context);
|
|
1195
1208
|
this.dragSelection = null;
|
|
1196
1209
|
}
|
|
1197
1210
|
};
|
|
@@ -1201,7 +1214,7 @@ class DateSelecting extends internal_cjs.Interaction {
|
|
|
1201
1214
|
dragging.touchScrollAllowed = false;
|
|
1202
1215
|
dragging.minDistance = options.selectMinDistance || 0;
|
|
1203
1216
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
1204
|
-
let hitDragging = this.hitDragging = new HitDragging(this.dragging,
|
|
1217
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, internal.interactionSettingsToStore(settings));
|
|
1205
1218
|
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1206
1219
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1207
1220
|
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
@@ -1228,7 +1241,7 @@ function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
|
|
|
1228
1241
|
dateSpan1.range.start,
|
|
1229
1242
|
dateSpan1.range.end,
|
|
1230
1243
|
];
|
|
1231
|
-
ms.sort(
|
|
1244
|
+
ms.sort(internal.compareNumbers);
|
|
1232
1245
|
let props = {};
|
|
1233
1246
|
for (let transformer of dateSelectionTransformers) {
|
|
1234
1247
|
let res = transformer(hit0, hit1);
|
|
@@ -1244,7 +1257,7 @@ function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
|
|
|
1244
1257
|
return props;
|
|
1245
1258
|
}
|
|
1246
1259
|
|
|
1247
|
-
class EventDragging extends
|
|
1260
|
+
class EventDragging extends internal.Interaction {
|
|
1248
1261
|
constructor(settings) {
|
|
1249
1262
|
super(settings);
|
|
1250
1263
|
// internal state
|
|
@@ -1262,24 +1275,19 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1262
1275
|
let { options } = component.context;
|
|
1263
1276
|
let initialContext = component.context;
|
|
1264
1277
|
this.subjectEl = ev.subjectEl;
|
|
1265
|
-
let eventRange = this.eventRange =
|
|
1278
|
+
let eventRange = this.eventRange = internal.getElEventRange(ev.subjectEl);
|
|
1266
1279
|
let eventInstanceId = eventRange.instance.instanceId;
|
|
1267
|
-
this.relevantEvents =
|
|
1280
|
+
this.relevantEvents = internal.getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
|
|
1268
1281
|
dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
|
|
1269
1282
|
dragging.delay =
|
|
1270
1283
|
// only do a touch delay if touch and this event hasn't been selected yet
|
|
1271
1284
|
(ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
|
|
1272
1285
|
getComponentTouchDelay(component) :
|
|
1273
1286
|
null;
|
|
1274
|
-
|
|
1275
|
-
mirror.parentNode = options.fixedMirrorParent;
|
|
1276
|
-
}
|
|
1277
|
-
else {
|
|
1278
|
-
mirror.parentNode = origTarget.closest('.fc');
|
|
1279
|
-
}
|
|
1287
|
+
mirror.parentNode = internal.getAppendableRoot(origTarget);
|
|
1280
1288
|
mirror.revertDuration = options.dragRevertDuration;
|
|
1281
1289
|
let isValid = component.isValidSegDownEl(origTarget) &&
|
|
1282
|
-
!origTarget.closest(
|
|
1290
|
+
!origTarget.closest(`.${classNames__default["default"].internalEventResizer}`); // NOT on a resizer
|
|
1283
1291
|
if (!isValid) {
|
|
1284
1292
|
dragging.cancel();
|
|
1285
1293
|
}
|
|
@@ -1287,7 +1295,8 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1287
1295
|
// disable dragging for elements that are resizable (ie, selectable)
|
|
1288
1296
|
// but are not draggable
|
|
1289
1297
|
// TODO: merge this with .cancel() ?
|
|
1290
|
-
this.isDragging = ev.subjectEl
|
|
1298
|
+
this.isDragging = ev.subjectEl
|
|
1299
|
+
.classList.contains(classNames__default["default"].internalEventDraggable);
|
|
1291
1300
|
}
|
|
1292
1301
|
};
|
|
1293
1302
|
this.handleDragStart = (ev) => {
|
|
@@ -1308,7 +1317,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1308
1317
|
initialContext.calendarApi.unselect(ev); // unselect *date* selection
|
|
1309
1318
|
initialContext.emitter.trigger('eventDragStart', {
|
|
1310
1319
|
el: this.subjectEl,
|
|
1311
|
-
event: new
|
|
1320
|
+
event: new internal.EventImpl(initialContext, eventRange.def, eventRange.instance),
|
|
1312
1321
|
jsEvent: ev.origEvent,
|
|
1313
1322
|
view: initialContext.viewApi,
|
|
1314
1323
|
});
|
|
@@ -1328,7 +1337,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1328
1337
|
let isInvalid = false;
|
|
1329
1338
|
let interaction = {
|
|
1330
1339
|
affectedEvents: relevantEvents,
|
|
1331
|
-
mutatedEvents:
|
|
1340
|
+
mutatedEvents: internal.createEmptyEventStore(),
|
|
1332
1341
|
isEvent: true,
|
|
1333
1342
|
};
|
|
1334
1343
|
if (hit) {
|
|
@@ -1338,13 +1347,13 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1338
1347
|
(receivingOptions.editable && receivingOptions.droppable)) {
|
|
1339
1348
|
mutation = computeEventMutation(initialHit, hit, this.eventRange.instance.range.start, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
|
|
1340
1349
|
if (mutation) {
|
|
1341
|
-
mutatedRelevantEvents =
|
|
1350
|
+
mutatedRelevantEvents = internal.applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
|
|
1342
1351
|
interaction.mutatedEvents = mutatedRelevantEvents;
|
|
1343
|
-
if (!
|
|
1352
|
+
if (!internal.isInteractionValid(interaction, hit.dateProfile, receivingContext)) {
|
|
1344
1353
|
isInvalid = true;
|
|
1345
1354
|
mutation = null;
|
|
1346
1355
|
mutatedRelevantEvents = null;
|
|
1347
|
-
interaction.mutatedEvents =
|
|
1356
|
+
interaction.mutatedEvents = internal.createEmptyEventStore();
|
|
1348
1357
|
}
|
|
1349
1358
|
}
|
|
1350
1359
|
}
|
|
@@ -1354,10 +1363,10 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1354
1363
|
}
|
|
1355
1364
|
this.displayDrag(receivingContext, interaction);
|
|
1356
1365
|
if (!isInvalid) {
|
|
1357
|
-
|
|
1366
|
+
internal.enableCursor();
|
|
1358
1367
|
}
|
|
1359
1368
|
else {
|
|
1360
|
-
|
|
1369
|
+
internal.disableCursor();
|
|
1361
1370
|
}
|
|
1362
1371
|
if (!isFinal) {
|
|
1363
1372
|
if (initialContext === receivingContext && // TODO: write test for this
|
|
@@ -1367,7 +1376,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1367
1376
|
this.dragging.setMirrorNeedsRevert(!mutation);
|
|
1368
1377
|
// render the mirror if no already-rendered mirror
|
|
1369
1378
|
// TODO: wish we could somehow wait for dispatch to guarantee render
|
|
1370
|
-
this.dragging.setMirrorIsVisible(!hit || !this.subjectEl.getRootNode().querySelector(
|
|
1379
|
+
this.dragging.setMirrorIsVisible(!hit || !this.subjectEl.getRootNode().querySelector(`.${classNames__default["default"].internalEventMirror}`));
|
|
1371
1380
|
// assign states based on new hit
|
|
1372
1381
|
this.receivingContext = receivingContext;
|
|
1373
1382
|
this.validMutation = mutation;
|
|
@@ -1386,7 +1395,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1386
1395
|
let { receivingContext, validMutation } = this;
|
|
1387
1396
|
let eventDef = this.eventRange.def;
|
|
1388
1397
|
let eventInstance = this.eventRange.instance;
|
|
1389
|
-
let eventApi = new
|
|
1398
|
+
let eventApi = new internal.EventImpl(initialContext, eventDef, eventInstance);
|
|
1390
1399
|
let relevantEvents = this.relevantEvents;
|
|
1391
1400
|
let mutatedRelevantEvents = this.mutatedRelevantEvents;
|
|
1392
1401
|
let { finalHit } = this.hitDragging;
|
|
@@ -1400,15 +1409,15 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1400
1409
|
if (validMutation) {
|
|
1401
1410
|
// dropped within same calendar
|
|
1402
1411
|
if (receivingContext === initialContext) {
|
|
1403
|
-
let updatedEventApi = new
|
|
1412
|
+
let updatedEventApi = new internal.EventImpl(initialContext, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
|
|
1404
1413
|
initialContext.dispatch({
|
|
1405
1414
|
type: 'MERGE_EVENTS',
|
|
1406
1415
|
eventStore: mutatedRelevantEvents,
|
|
1407
1416
|
});
|
|
1408
|
-
let
|
|
1417
|
+
let eventChangeData = {
|
|
1409
1418
|
oldEvent: eventApi,
|
|
1410
1419
|
event: updatedEventApi,
|
|
1411
|
-
relatedEvents:
|
|
1420
|
+
relatedEvents: internal.buildEventApis(mutatedRelevantEvents, initialContext, eventInstance),
|
|
1412
1421
|
revert() {
|
|
1413
1422
|
initialContext.dispatch({
|
|
1414
1423
|
type: 'MERGE_EVENTS',
|
|
@@ -1420,14 +1429,14 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1420
1429
|
for (let transformer of initialContext.getCurrentData().pluginHooks.eventDropTransformers) {
|
|
1421
1430
|
Object.assign(transformed, transformer(validMutation, initialContext));
|
|
1422
1431
|
}
|
|
1423
|
-
initialContext.emitter.trigger('eventDrop', Object.assign(Object.assign(Object.assign({},
|
|
1424
|
-
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);
|
|
1425
1434
|
// dropped in different calendar
|
|
1426
1435
|
}
|
|
1427
1436
|
else if (receivingContext) {
|
|
1428
|
-
let
|
|
1437
|
+
let eventRemoveData = {
|
|
1429
1438
|
event: eventApi,
|
|
1430
|
-
relatedEvents:
|
|
1439
|
+
relatedEvents: internal.buildEventApis(relevantEvents, initialContext, eventInstance),
|
|
1431
1440
|
revert() {
|
|
1432
1441
|
initialContext.dispatch({
|
|
1433
1442
|
type: 'MERGE_EVENTS',
|
|
@@ -1435,22 +1444,22 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1435
1444
|
});
|
|
1436
1445
|
},
|
|
1437
1446
|
};
|
|
1438
|
-
initialContext.emitter.trigger('eventLeave', Object.assign(Object.assign({},
|
|
1447
|
+
initialContext.emitter.trigger('eventLeave', Object.assign(Object.assign({}, eventRemoveData), { draggedEl: ev.subjectEl, view: initialView }));
|
|
1439
1448
|
initialContext.dispatch({
|
|
1440
1449
|
type: 'REMOVE_EVENTS',
|
|
1441
1450
|
eventStore: relevantEvents,
|
|
1442
1451
|
});
|
|
1443
|
-
initialContext.emitter.trigger('eventRemove',
|
|
1452
|
+
initialContext.emitter.trigger('eventRemove', eventRemoveData);
|
|
1444
1453
|
let addedEventDef = mutatedRelevantEvents.defs[eventDef.defId];
|
|
1445
1454
|
let addedEventInstance = mutatedRelevantEvents.instances[eventInstance.instanceId];
|
|
1446
|
-
let addedEventApi = new
|
|
1455
|
+
let addedEventApi = new internal.EventImpl(receivingContext, addedEventDef, addedEventInstance);
|
|
1447
1456
|
receivingContext.dispatch({
|
|
1448
1457
|
type: 'MERGE_EVENTS',
|
|
1449
1458
|
eventStore: mutatedRelevantEvents,
|
|
1450
1459
|
});
|
|
1451
|
-
let
|
|
1460
|
+
let eventAddData = {
|
|
1452
1461
|
event: addedEventApi,
|
|
1453
|
-
relatedEvents:
|
|
1462
|
+
relatedEvents: internal.buildEventApis(mutatedRelevantEvents, receivingContext, addedEventInstance),
|
|
1454
1463
|
revert() {
|
|
1455
1464
|
receivingContext.dispatch({
|
|
1456
1465
|
type: 'REMOVE_EVENTS',
|
|
@@ -1458,7 +1467,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1458
1467
|
});
|
|
1459
1468
|
},
|
|
1460
1469
|
};
|
|
1461
|
-
receivingContext.emitter.trigger('eventAdd',
|
|
1470
|
+
receivingContext.emitter.trigger('eventAdd', eventAddData);
|
|
1462
1471
|
if (ev.isTouch) {
|
|
1463
1472
|
receivingContext.dispatch({
|
|
1464
1473
|
type: 'SELECT_EVENT',
|
|
@@ -1466,7 +1475,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1466
1475
|
});
|
|
1467
1476
|
}
|
|
1468
1477
|
receivingContext.emitter.trigger('drop', Object.assign(Object.assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.context.viewApi }));
|
|
1469
|
-
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 }));
|
|
1470
1479
|
}
|
|
1471
1480
|
}
|
|
1472
1481
|
else {
|
|
@@ -1481,7 +1490,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1481
1490
|
dragging.pointer.selector = EventDragging.SELECTOR;
|
|
1482
1491
|
dragging.touchScrollAllowed = false;
|
|
1483
1492
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
1484
|
-
let hitDragging = this.hitDragging = new HitDragging(this.dragging,
|
|
1493
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, internal.interactionSettingsStore);
|
|
1485
1494
|
hitDragging.useSubjectCenter = settings.useEventCenter;
|
|
1486
1495
|
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1487
1496
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
@@ -1505,7 +1514,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1505
1514
|
type: 'SET_EVENT_DRAG',
|
|
1506
1515
|
state: {
|
|
1507
1516
|
affectedEvents: state.affectedEvents,
|
|
1508
|
-
mutatedEvents:
|
|
1517
|
+
mutatedEvents: internal.createEmptyEventStore(),
|
|
1509
1518
|
isEvent: true,
|
|
1510
1519
|
},
|
|
1511
1520
|
});
|
|
@@ -1541,7 +1550,7 @@ class EventDragging extends internal_cjs.Interaction {
|
|
|
1541
1550
|
}
|
|
1542
1551
|
// TODO: test this in IE11
|
|
1543
1552
|
// QUESTION: why do we need it on the resizable???
|
|
1544
|
-
EventDragging.SELECTOR =
|
|
1553
|
+
EventDragging.SELECTOR = `.${classNames__default["default"].internalEventDraggable}, .${classNames__default["default"].internalEventResizable}`;
|
|
1545
1554
|
function computeEventMutation(hit0, hit1, eventInstanceStart, massagers) {
|
|
1546
1555
|
let dateSpan0 = hit0.dateSpan;
|
|
1547
1556
|
let dateSpan1 = hit1.dateSpan;
|
|
@@ -1554,7 +1563,7 @@ function computeEventMutation(hit0, hit1, eventInstanceStart, massagers) {
|
|
|
1554
1563
|
if (dateSpan1.allDay) {
|
|
1555
1564
|
// means date1 is already start-of-day,
|
|
1556
1565
|
// but date0 needs to be converted
|
|
1557
|
-
date0 =
|
|
1566
|
+
date0 = internal.startOfDay(eventInstanceStart);
|
|
1558
1567
|
}
|
|
1559
1568
|
else {
|
|
1560
1569
|
// Moving from allDate->timed
|
|
@@ -1562,7 +1571,7 @@ function computeEventMutation(hit0, hit1, eventInstanceStart, massagers) {
|
|
|
1562
1571
|
date0 = eventInstanceStart;
|
|
1563
1572
|
}
|
|
1564
1573
|
}
|
|
1565
|
-
let delta =
|
|
1574
|
+
let delta = internal.diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ?
|
|
1566
1575
|
hit0.largeUnit :
|
|
1567
1576
|
null);
|
|
1568
1577
|
if (delta.milliseconds) { // has hours/minutes/seconds
|
|
@@ -1586,7 +1595,7 @@ function getComponentTouchDelay(component) {
|
|
|
1586
1595
|
return delay;
|
|
1587
1596
|
}
|
|
1588
1597
|
|
|
1589
|
-
class EventResizing extends
|
|
1598
|
+
class EventResizing extends internal.Interaction {
|
|
1590
1599
|
constructor(settings) {
|
|
1591
1600
|
super(settings);
|
|
1592
1601
|
// internal state
|
|
@@ -1599,7 +1608,7 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1599
1608
|
this.handlePointerDown = (ev) => {
|
|
1600
1609
|
let { component } = this;
|
|
1601
1610
|
let segEl = this.querySegEl(ev);
|
|
1602
|
-
let eventRange = this.eventRange =
|
|
1611
|
+
let eventRange = this.eventRange = internal.getElEventRange(segEl);
|
|
1603
1612
|
this.dragging.minDistance = component.context.options.eventDragMinDistance;
|
|
1604
1613
|
const isValid = this.component.isValidSegDownEl(ev.origEvent.target) &&
|
|
1605
1614
|
!(ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId);
|
|
@@ -1610,14 +1619,14 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1610
1619
|
this.handleDragStart = (ev) => {
|
|
1611
1620
|
let { context } = this.component;
|
|
1612
1621
|
let eventRange = this.eventRange;
|
|
1613
|
-
this.relevantEvents =
|
|
1622
|
+
this.relevantEvents = internal.getRelevantEvents(context.getCurrentData().eventStore, this.eventRange.instance.instanceId);
|
|
1614
1623
|
let segEl = this.querySegEl(ev);
|
|
1615
1624
|
this.draggingSegEl = segEl;
|
|
1616
|
-
this.draggingEventRange =
|
|
1625
|
+
this.draggingEventRange = internal.getElEventRange(segEl);
|
|
1617
1626
|
context.calendarApi.unselect();
|
|
1618
1627
|
context.emitter.trigger('eventResizeStart', {
|
|
1619
1628
|
el: segEl,
|
|
1620
|
-
event: new
|
|
1629
|
+
event: new internal.EventImpl(context, eventRange.def, eventRange.instance),
|
|
1621
1630
|
jsEvent: ev.origEvent,
|
|
1622
1631
|
view: context.viewApi,
|
|
1623
1632
|
});
|
|
@@ -1632,7 +1641,7 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1632
1641
|
let isInvalid = false;
|
|
1633
1642
|
let interaction = {
|
|
1634
1643
|
affectedEvents: relevantEvents,
|
|
1635
|
-
mutatedEvents:
|
|
1644
|
+
mutatedEvents: internal.createEmptyEventStore(),
|
|
1636
1645
|
isEvent: true,
|
|
1637
1646
|
};
|
|
1638
1647
|
if (hit) {
|
|
@@ -1640,13 +1649,13 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1640
1649
|
&& this.isHitComboAllowed
|
|
1641
1650
|
&& !this.isHitComboAllowed(initialHit, hit);
|
|
1642
1651
|
if (!disallowed) {
|
|
1643
|
-
mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains(
|
|
1652
|
+
mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains(classNames__default["default"].internalEventResizerStart), eventInstance.range);
|
|
1644
1653
|
}
|
|
1645
1654
|
}
|
|
1646
1655
|
if (mutation) {
|
|
1647
|
-
mutatedRelevantEvents =
|
|
1656
|
+
mutatedRelevantEvents = internal.applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
|
|
1648
1657
|
interaction.mutatedEvents = mutatedRelevantEvents;
|
|
1649
|
-
if (!
|
|
1658
|
+
if (!internal.isInteractionValid(interaction, hit.dateProfile, context)) {
|
|
1650
1659
|
isInvalid = true;
|
|
1651
1660
|
mutation = null;
|
|
1652
1661
|
mutatedRelevantEvents = null;
|
|
@@ -1663,10 +1672,10 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1663
1672
|
context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
|
|
1664
1673
|
}
|
|
1665
1674
|
if (!isInvalid) {
|
|
1666
|
-
|
|
1675
|
+
internal.enableCursor();
|
|
1667
1676
|
}
|
|
1668
1677
|
else {
|
|
1669
|
-
|
|
1678
|
+
internal.disableCursor();
|
|
1670
1679
|
}
|
|
1671
1680
|
if (!isFinal) {
|
|
1672
1681
|
if (mutation && isHitsEqual(initialHit, hit)) {
|
|
@@ -1680,7 +1689,7 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1680
1689
|
let { context } = this.component;
|
|
1681
1690
|
let eventDef = this.eventRange.def;
|
|
1682
1691
|
let eventInstance = this.eventRange.instance;
|
|
1683
|
-
let eventApi = new
|
|
1692
|
+
let eventApi = new internal.EventImpl(context, eventDef, eventInstance);
|
|
1684
1693
|
let relevantEvents = this.relevantEvents;
|
|
1685
1694
|
let mutatedRelevantEvents = this.mutatedRelevantEvents;
|
|
1686
1695
|
context.emitter.trigger('eventResizeStop', {
|
|
@@ -1690,15 +1699,15 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1690
1699
|
view: context.viewApi,
|
|
1691
1700
|
});
|
|
1692
1701
|
if (this.validMutation) {
|
|
1693
|
-
let updatedEventApi = new
|
|
1702
|
+
let updatedEventApi = new internal.EventImpl(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
|
|
1694
1703
|
context.dispatch({
|
|
1695
1704
|
type: 'MERGE_EVENTS',
|
|
1696
1705
|
eventStore: mutatedRelevantEvents,
|
|
1697
1706
|
});
|
|
1698
|
-
let
|
|
1707
|
+
let eventChangeData = {
|
|
1699
1708
|
oldEvent: eventApi,
|
|
1700
1709
|
event: updatedEventApi,
|
|
1701
|
-
relatedEvents:
|
|
1710
|
+
relatedEvents: internal.buildEventApis(mutatedRelevantEvents, context, eventInstance),
|
|
1702
1711
|
revert() {
|
|
1703
1712
|
context.dispatch({
|
|
1704
1713
|
type: 'MERGE_EVENTS',
|
|
@@ -1706,8 +1715,8 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1706
1715
|
});
|
|
1707
1716
|
},
|
|
1708
1717
|
};
|
|
1709
|
-
context.emitter.trigger('eventResize', Object.assign(Object.assign({},
|
|
1710
|
-
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);
|
|
1711
1720
|
}
|
|
1712
1721
|
else {
|
|
1713
1722
|
context.emitter.trigger('_noEventResize');
|
|
@@ -1720,10 +1729,10 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1720
1729
|
};
|
|
1721
1730
|
let { component } = settings;
|
|
1722
1731
|
let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1723
|
-
dragging.pointer.selector =
|
|
1732
|
+
dragging.pointer.selector = `.${classNames__default["default"].internalEventResizer}`;
|
|
1724
1733
|
dragging.touchScrollAllowed = false;
|
|
1725
1734
|
dragging.autoScroller.isEnabled = component.context.options.dragScroll;
|
|
1726
|
-
let hitDragging = this.hitDragging = new HitDragging(this.dragging,
|
|
1735
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, internal.interactionSettingsToStore(settings));
|
|
1727
1736
|
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1728
1737
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1729
1738
|
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
@@ -1733,14 +1742,14 @@ class EventResizing extends internal_cjs.Interaction {
|
|
|
1733
1742
|
this.dragging.destroy();
|
|
1734
1743
|
}
|
|
1735
1744
|
querySegEl(ev) {
|
|
1736
|
-
return ev.subjectEl.closest(
|
|
1745
|
+
return ev.subjectEl.closest(`.${classNames__default["default"].internalEvent}`);
|
|
1737
1746
|
}
|
|
1738
1747
|
}
|
|
1739
1748
|
function computeMutation(hit0, hit1, isFromStart, instanceRange) {
|
|
1740
1749
|
let dateEnv = hit0.context.dateEnv;
|
|
1741
1750
|
let date0 = hit0.dateSpan.range.start;
|
|
1742
1751
|
let date1 = hit1.dateSpan.range.start;
|
|
1743
|
-
let delta =
|
|
1752
|
+
let delta = internal.diffDates(date0, date1, dateEnv, hit0.largeUnit);
|
|
1744
1753
|
if (isFromStart) {
|
|
1745
1754
|
if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
|
|
1746
1755
|
return { startDelta: delta };
|
|
@@ -1758,14 +1767,14 @@ class UnselectAuto {
|
|
|
1758
1767
|
this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
|
|
1759
1768
|
this.matchesCancel = false;
|
|
1760
1769
|
this.matchesEvent = false;
|
|
1761
|
-
this.onSelect = (
|
|
1762
|
-
if (
|
|
1770
|
+
this.onSelect = (selectData) => {
|
|
1771
|
+
if (selectData.jsEvent) {
|
|
1763
1772
|
this.isRecentPointerDateSelect = true;
|
|
1764
1773
|
}
|
|
1765
1774
|
};
|
|
1766
1775
|
this.onDocumentPointerDown = (pev) => {
|
|
1767
1776
|
let unselectCancel = this.context.options.unselectCancel;
|
|
1768
|
-
let downEl =
|
|
1777
|
+
let downEl = internal.getEventTargetViaRoot(pev.origEvent);
|
|
1769
1778
|
this.matchesCancel = !!downEl.closest(unselectCancel);
|
|
1770
1779
|
this.matchesEvent = !!downEl.closest(EventDragging.SELECTOR); // interaction started on an event?
|
|
1771
1780
|
};
|
|
@@ -1807,20 +1816,18 @@ class UnselectAuto {
|
|
|
1807
1816
|
}
|
|
1808
1817
|
}
|
|
1809
1818
|
|
|
1810
|
-
const OPTION_REFINERS = {
|
|
1811
|
-
fixedMirrorParent: internal_cjs.identity,
|
|
1812
|
-
};
|
|
1819
|
+
const OPTION_REFINERS = {};
|
|
1813
1820
|
const LISTENER_REFINERS = {
|
|
1814
|
-
dateClick:
|
|
1815
|
-
eventDragStart:
|
|
1816
|
-
eventDragStop:
|
|
1817
|
-
eventDrop:
|
|
1818
|
-
eventResizeStart:
|
|
1819
|
-
eventResizeStop:
|
|
1820
|
-
eventResize:
|
|
1821
|
-
drop:
|
|
1822
|
-
eventReceive:
|
|
1823
|
-
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,
|
|
1824
1831
|
};
|
|
1825
1832
|
|
|
1826
1833
|
/*
|
|
@@ -1843,18 +1850,18 @@ class ExternalElementDragging {
|
|
|
1843
1850
|
let droppableEvent = null;
|
|
1844
1851
|
let isInvalid = false;
|
|
1845
1852
|
let interaction = {
|
|
1846
|
-
affectedEvents:
|
|
1847
|
-
mutatedEvents:
|
|
1853
|
+
affectedEvents: internal.createEmptyEventStore(),
|
|
1854
|
+
mutatedEvents: internal.createEmptyEventStore(),
|
|
1848
1855
|
isEvent: this.dragMeta.create,
|
|
1849
1856
|
};
|
|
1850
1857
|
if (hit) {
|
|
1851
1858
|
receivingContext = hit.context;
|
|
1852
1859
|
if (this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
|
|
1853
1860
|
droppableEvent = computeEventForDateSpan(hit.dateSpan, this.dragMeta, receivingContext);
|
|
1854
|
-
interaction.mutatedEvents =
|
|
1855
|
-
isInvalid = !
|
|
1861
|
+
interaction.mutatedEvents = internal.eventTupleToStore(droppableEvent);
|
|
1862
|
+
isInvalid = !internal.isInteractionValid(interaction, hit.dateProfile, receivingContext);
|
|
1856
1863
|
if (isInvalid) {
|
|
1857
|
-
interaction.mutatedEvents =
|
|
1864
|
+
interaction.mutatedEvents = internal.createEmptyEventStore();
|
|
1858
1865
|
droppableEvent = null;
|
|
1859
1866
|
}
|
|
1860
1867
|
}
|
|
@@ -1862,12 +1869,14 @@ class ExternalElementDragging {
|
|
|
1862
1869
|
this.displayDrag(receivingContext, interaction);
|
|
1863
1870
|
// show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
|
|
1864
1871
|
// TODO: wish we could somehow wait for dispatch to guarantee render
|
|
1865
|
-
dragging.setMirrorIsVisible(isFinal ||
|
|
1872
|
+
dragging.setMirrorIsVisible(isFinal ||
|
|
1873
|
+
!droppableEvent ||
|
|
1874
|
+
!document.querySelector(`.${classNames__default["default"].internalEventMirror}`));
|
|
1866
1875
|
if (!isInvalid) {
|
|
1867
|
-
|
|
1876
|
+
internal.enableCursor();
|
|
1868
1877
|
}
|
|
1869
1878
|
else {
|
|
1870
|
-
|
|
1879
|
+
internal.disableCursor();
|
|
1871
1880
|
}
|
|
1872
1881
|
if (!isFinal) {
|
|
1873
1882
|
dragging.setMirrorNeedsRevert(!droppableEvent);
|
|
@@ -1884,7 +1893,7 @@ class ExternalElementDragging {
|
|
|
1884
1893
|
let dragMeta = this.dragMeta;
|
|
1885
1894
|
receivingContext.emitter.trigger('drop', Object.assign(Object.assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
|
|
1886
1895
|
if (dragMeta.create) {
|
|
1887
|
-
let addingEvents =
|
|
1896
|
+
let addingEvents = internal.eventTupleToStore(droppableEvent);
|
|
1888
1897
|
receivingContext.dispatch({
|
|
1889
1898
|
type: 'MERGE_EVENTS',
|
|
1890
1899
|
eventStore: addingEvents,
|
|
@@ -1897,7 +1906,7 @@ class ExternalElementDragging {
|
|
|
1897
1906
|
}
|
|
1898
1907
|
// signal that an external event landed
|
|
1899
1908
|
receivingContext.emitter.trigger('eventReceive', {
|
|
1900
|
-
event: new
|
|
1909
|
+
event: new internal.EventImpl(receivingContext, droppableEvent.def, droppableEvent.instance),
|
|
1901
1910
|
relatedEvents: [],
|
|
1902
1911
|
revert() {
|
|
1903
1912
|
receivingContext.dispatch({
|
|
@@ -1913,7 +1922,7 @@ class ExternalElementDragging {
|
|
|
1913
1922
|
this.receivingContext = null;
|
|
1914
1923
|
this.droppableEvent = null;
|
|
1915
1924
|
};
|
|
1916
|
-
let hitDragging = this.hitDragging = new HitDragging(dragging,
|
|
1925
|
+
let hitDragging = this.hitDragging = new HitDragging(dragging, internal.interactionSettingsStore);
|
|
1917
1926
|
hitDragging.requireInitial = false; // will start outside of a component
|
|
1918
1927
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1919
1928
|
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
@@ -1922,10 +1931,10 @@ class ExternalElementDragging {
|
|
|
1922
1931
|
}
|
|
1923
1932
|
buildDragMeta(subjectEl) {
|
|
1924
1933
|
if (typeof this.suppliedDragMeta === 'object') {
|
|
1925
|
-
return
|
|
1934
|
+
return internal.parseDragMeta(this.suppliedDragMeta);
|
|
1926
1935
|
}
|
|
1927
1936
|
if (typeof this.suppliedDragMeta === 'function') {
|
|
1928
|
-
return
|
|
1937
|
+
return internal.parseDragMeta(this.suppliedDragMeta(subjectEl));
|
|
1929
1938
|
}
|
|
1930
1939
|
return getDragMetaFromEl(subjectEl);
|
|
1931
1940
|
}
|
|
@@ -1961,8 +1970,8 @@ function computeEventForDateSpan(dateSpan, dragMeta, context) {
|
|
|
1961
1970
|
for (let transform of context.pluginHooks.externalDefTransforms) {
|
|
1962
1971
|
Object.assign(defProps, transform(dateSpan, dragMeta));
|
|
1963
1972
|
}
|
|
1964
|
-
let { refined, extra } =
|
|
1965
|
-
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
|
|
1966
1975
|
context);
|
|
1967
1976
|
let start = dateSpan.range.start;
|
|
1968
1977
|
// only rely on time info if drop zone is all-day,
|
|
@@ -1972,8 +1981,8 @@ function computeEventForDateSpan(dateSpan, dragMeta, context) {
|
|
|
1972
1981
|
}
|
|
1973
1982
|
let end = dragMeta.duration ?
|
|
1974
1983
|
context.dateEnv.add(start, dragMeta.duration) :
|
|
1975
|
-
|
|
1976
|
-
let instance =
|
|
1984
|
+
internal.getDefaultEventEnd(dateSpan.allDay, start, context);
|
|
1985
|
+
let instance = internal.createEventInstance(def.defId, { start, end });
|
|
1977
1986
|
return { def, instance };
|
|
1978
1987
|
}
|
|
1979
1988
|
// Utils for extracting data from element
|
|
@@ -1983,11 +1992,11 @@ function getDragMetaFromEl(el) {
|
|
|
1983
1992
|
let obj = str ?
|
|
1984
1993
|
JSON.parse(str) :
|
|
1985
1994
|
{ create: false }; // if no embedded data, assume no event creation
|
|
1986
|
-
return
|
|
1995
|
+
return internal.parseDragMeta(obj);
|
|
1987
1996
|
}
|
|
1988
|
-
|
|
1997
|
+
internal.config.dataAttrPrefix = '';
|
|
1989
1998
|
function getEmbeddedElData(el, name) {
|
|
1990
|
-
let prefix =
|
|
1999
|
+
let prefix = internal.config.dataAttrPrefix;
|
|
1991
2000
|
let prefixedName = (prefix ? prefix + '-' : '') + name;
|
|
1992
2001
|
return el.getAttribute('data-' + prefixedName) || '';
|
|
1993
2002
|
}
|
|
@@ -2005,17 +2014,17 @@ class ExternalDraggable {
|
|
|
2005
2014
|
dragging.minDistance =
|
|
2006
2015
|
minDistance != null ?
|
|
2007
2016
|
minDistance :
|
|
2008
|
-
(ev.isTouch ? 0 :
|
|
2017
|
+
(ev.isTouch ? 0 : internal.BASE_OPTION_DEFAULTS.eventDragMinDistance);
|
|
2009
2018
|
dragging.delay =
|
|
2010
2019
|
ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
|
|
2011
|
-
(longPressDelay != null ? longPressDelay :
|
|
2020
|
+
(longPressDelay != null ? longPressDelay : internal.BASE_OPTION_DEFAULTS.longPressDelay) :
|
|
2012
2021
|
0;
|
|
2013
2022
|
};
|
|
2014
2023
|
this.handleDragStart = (ev) => {
|
|
2015
2024
|
if (ev.isTouch &&
|
|
2016
2025
|
this.dragging.delay &&
|
|
2017
|
-
ev.subjectEl.classList.contains(
|
|
2018
|
-
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);
|
|
2019
2028
|
}
|
|
2020
2029
|
};
|
|
2021
2030
|
this.settings = settings;
|
|
@@ -2042,7 +2051,7 @@ The third-party system is responsible for drawing the visuals effects of the dra
|
|
|
2042
2051
|
This class simply monitors for pointer movements and fires events.
|
|
2043
2052
|
It also has the ability to hide the moving element (the "mirror") during the drag.
|
|
2044
2053
|
*/
|
|
2045
|
-
class InferredElementDragging extends
|
|
2054
|
+
class InferredElementDragging extends internal.ElementDragging {
|
|
2046
2055
|
constructor(containerEl) {
|
|
2047
2056
|
super(containerEl);
|
|
2048
2057
|
this.shouldIgnoreMove = false;
|
|
@@ -2137,7 +2146,7 @@ class ThirdPartyDraggable {
|
|
|
2137
2146
|
}
|
|
2138
2147
|
}
|
|
2139
2148
|
|
|
2140
|
-
var index =
|
|
2149
|
+
var index = core.createPlugin({
|
|
2141
2150
|
name: '@fullcalendar/interaction',
|
|
2142
2151
|
componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
|
|
2143
2152
|
calendarInteractions: [UnselectAuto],
|