@fullcalendar/interaction 4.0.2 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.js CHANGED
@@ -1,8 +1,9 @@
1
1
  /*!
2
- FullCalendar Interaction Plugin v4.0.2
2
+ FullCalendar Interaction Plugin v4.4.0
3
3
  Docs & License: https://fullcalendar.io/
4
4
  (c) 2019 Adam Shaw
5
5
  */
6
+
6
7
  (function (global, factory) {
7
8
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
8
9
  typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
@@ -842,7 +843,7 @@ Docs & License: https://fullcalendar.io/
842
843
  this.delayTimeoutId = setTimeout(function () {
843
844
  _this.delayTimeoutId = null;
844
845
  _this.handleDelayEnd(ev);
845
- }, this.delay);
846
+ }, this.delay); // not assignable to number!
846
847
  }
847
848
  else {
848
849
  this.handleDelayEnd(ev);
@@ -1053,6 +1054,7 @@ Docs & License: https://fullcalendar.io/
1053
1054
  };
1054
1055
  HitDragging.prototype.prepareHits = function () {
1055
1056
  this.offsetTrackers = core.mapHash(this.droppableStore, function (interactionSettings) {
1057
+ interactionSettings.component.buildPositionCaches();
1056
1058
  return new OffsetTracker(interactionSettings.el);
1057
1059
  });
1058
1060
  };
@@ -1128,11 +1130,12 @@ Docs & License: https://fullcalendar.io/
1128
1130
  // won't even fire if moving was ignored
1129
1131
  _this.handleDragEnd = function (ev) {
1130
1132
  var component = _this.component;
1133
+ var _a = component.context, calendar = _a.calendar, view = _a.view;
1131
1134
  var pointer = _this.dragging.pointer;
1132
1135
  if (!pointer.wasTouchScroll) {
1133
- var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
1136
+ var _b = _this.hitDragging, initialHit = _b.initialHit, finalHit = _b.finalHit;
1134
1137
  if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
1135
- component.calendar.triggerDateClick(initialHit.dateSpan, initialHit.dayEl, component.view, ev.origEvent);
1138
+ calendar.triggerDateClick(initialHit.dateSpan, initialHit.dayEl, view, ev.origEvent);
1136
1139
  }
1137
1140
  }
1138
1141
  };
@@ -1162,7 +1165,8 @@ Docs & License: https://fullcalendar.io/
1162
1165
  _this.dragSelection = null;
1163
1166
  _this.handlePointerDown = function (ev) {
1164
1167
  var _a = _this, component = _a.component, dragging = _a.dragging;
1165
- var canSelect = component.opt('selectable') &&
1168
+ var options = component.context.options;
1169
+ var canSelect = options.selectable &&
1166
1170
  component.isValidDateDownEl(ev.origEvent.target);
1167
1171
  // don't bother to watch expensive moves if component won't do selection
1168
1172
  dragging.setIgnoreMove(!canSelect);
@@ -1170,10 +1174,10 @@ Docs & License: https://fullcalendar.io/
1170
1174
  dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null;
1171
1175
  };
1172
1176
  _this.handleDragStart = function (ev) {
1173
- _this.component.calendar.unselect(ev); // unselect previous selections
1177
+ _this.component.context.calendar.unselect(ev); // unselect previous selections
1174
1178
  };
1175
1179
  _this.handleHitUpdate = function (hit, isFinal) {
1176
- var calendar = _this.component.calendar;
1180
+ var calendar = _this.component.context.calendar;
1177
1181
  var dragSelection = null;
1178
1182
  var isInvalid = false;
1179
1183
  if (hit) {
@@ -1202,15 +1206,16 @@ Docs & License: https://fullcalendar.io/
1202
1206
  _this.handlePointerUp = function (pev) {
1203
1207
  if (_this.dragSelection) {
1204
1208
  // selection is already rendered, so just need to report selection
1205
- _this.component.calendar.triggerDateSelect(_this.dragSelection, pev);
1209
+ _this.component.context.calendar.triggerDateSelect(_this.dragSelection, pev);
1206
1210
  _this.dragSelection = null;
1207
1211
  }
1208
1212
  };
1209
1213
  var component = settings.component;
1214
+ var options = component.context.options;
1210
1215
  var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
1211
1216
  dragging.touchScrollAllowed = false;
1212
- dragging.minDistance = component.opt('selectMinDistance') || 0;
1213
- dragging.autoScroller.isEnabled = component.opt('dragScroll');
1217
+ dragging.minDistance = options.selectMinDistance || 0;
1218
+ dragging.autoScroller.isEnabled = options.dragScroll;
1214
1219
  var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
1215
1220
  hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1216
1221
  hitDragging.emitter.on('dragstart', _this.handleDragStart);
@@ -1224,9 +1229,10 @@ Docs & License: https://fullcalendar.io/
1224
1229
  return DateSelecting;
1225
1230
  }(core.Interaction));
1226
1231
  function getComponentTouchDelay(component) {
1227
- var delay = component.opt('selectLongPressDelay');
1232
+ var options = component.context.options;
1233
+ var delay = options.selectLongPressDelay;
1228
1234
  if (delay == null) {
1229
- delay = component.opt('longPressDelay');
1235
+ delay = options.longPressDelay;
1230
1236
  }
1231
1237
  return delay;
1232
1238
  }
@@ -1272,21 +1278,22 @@ Docs & License: https://fullcalendar.io/
1272
1278
  var origTarget = ev.origEvent.target;
1273
1279
  var _a = _this, component = _a.component, dragging = _a.dragging;
1274
1280
  var mirror = dragging.mirror;
1275
- var initialCalendar = component.calendar;
1281
+ var options = component.context.options;
1282
+ var initialCalendar = component.context.calendar;
1276
1283
  var subjectSeg = _this.subjectSeg = core.getElSeg(ev.subjectEl);
1277
1284
  var eventRange = _this.eventRange = subjectSeg.eventRange;
1278
1285
  var eventInstanceId = eventRange.instance.instanceId;
1279
1286
  _this.relevantEvents = core.getRelevantEvents(initialCalendar.state.eventStore, eventInstanceId);
1280
- dragging.minDistance = ev.isTouch ? 0 : component.opt('eventDragMinDistance');
1287
+ dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
1281
1288
  dragging.delay =
1282
1289
  // only do a touch delay if touch and this event hasn't been selected yet
1283
1290
  (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
1284
1291
  getComponentTouchDelay$1(component) :
1285
1292
  null;
1286
1293
  mirror.parentNode = initialCalendar.el;
1287
- mirror.revertDuration = component.opt('dragRevertDuration');
1294
+ mirror.revertDuration = options.dragRevertDuration;
1288
1295
  var isValid = component.isValidSegDownEl(origTarget) &&
1289
- !core.elementClosest(origTarget, '.fc-resizer');
1296
+ !core.elementClosest(origTarget, '.fc-resizer'); // NOT on a resizer
1290
1297
  dragging.setIgnoreMove(!isValid);
1291
1298
  // disable dragging for elements that are resizable (ie, selectable)
1292
1299
  // but are not draggable
@@ -1294,7 +1301,8 @@ Docs & License: https://fullcalendar.io/
1294
1301
  ev.subjectEl.classList.contains('fc-draggable');
1295
1302
  };
1296
1303
  _this.handleDragStart = function (ev) {
1297
- var initialCalendar = _this.component.calendar;
1304
+ var context = _this.component.context;
1305
+ var initialCalendar = context.calendar;
1298
1306
  var eventRange = _this.eventRange;
1299
1307
  var eventInstanceId = eventRange.instance.instanceId;
1300
1308
  if (ev.isTouch) {
@@ -1314,7 +1322,7 @@ Docs & License: https://fullcalendar.io/
1314
1322
  el: _this.subjectSeg.el,
1315
1323
  event: new core.EventApi(initialCalendar, eventRange.def, eventRange.instance),
1316
1324
  jsEvent: ev.origEvent,
1317
- view: _this.component.view
1325
+ view: context.view
1318
1326
  }
1319
1327
  ]);
1320
1328
  }
@@ -1325,7 +1333,7 @@ Docs & License: https://fullcalendar.io/
1325
1333
  }
1326
1334
  var relevantEvents = _this.relevantEvents;
1327
1335
  var initialHit = _this.hitDragging.initialHit;
1328
- var initialCalendar = _this.component.calendar;
1336
+ var initialCalendar = _this.component.context.calendar;
1329
1337
  // states based on new hit
1330
1338
  var receivingCalendar = null;
1331
1339
  var mutation = null;
@@ -1339,9 +1347,10 @@ Docs & License: https://fullcalendar.io/
1339
1347
  };
1340
1348
  if (hit) {
1341
1349
  var receivingComponent = hit.component;
1342
- receivingCalendar = receivingComponent.calendar;
1350
+ receivingCalendar = receivingComponent.context.calendar;
1351
+ var receivingOptions = receivingComponent.context.options;
1343
1352
  if (initialCalendar === receivingCalendar ||
1344
- receivingComponent.opt('editable') && receivingComponent.opt('droppable')) {
1353
+ receivingOptions.editable && receivingOptions.droppable) {
1345
1354
  mutation = computeEventMutation(initialHit, hit, receivingCalendar.pluginSystem.hooks.eventDragMutationMassagers);
1346
1355
  if (mutation) {
1347
1356
  mutatedRelevantEvents = core.applyMutationToEventStore(relevantEvents, receivingCalendar.eventUiBases, mutation, receivingCalendar);
@@ -1387,9 +1396,10 @@ Docs & License: https://fullcalendar.io/
1387
1396
  };
1388
1397
  _this.handleDragEnd = function (ev) {
1389
1398
  if (_this.isDragging) {
1390
- var initialCalendar_1 = _this.component.calendar;
1391
- var initialView = _this.component.view;
1392
- var receivingCalendar = _this.receivingCalendar;
1399
+ var context = _this.component.context;
1400
+ var initialCalendar_1 = context.calendar;
1401
+ var initialView = context.view;
1402
+ var _a = _this, receivingCalendar = _a.receivingCalendar, validMutation = _a.validMutation;
1393
1403
  var eventDef = _this.eventRange.def;
1394
1404
  var eventInstance = _this.eventRange.instance;
1395
1405
  var eventApi = new core.EventApi(initialCalendar_1, eventDef, eventInstance);
@@ -1405,33 +1415,25 @@ Docs & License: https://fullcalendar.io/
1405
1415
  view: initialView
1406
1416
  }
1407
1417
  ]);
1408
- if (_this.validMutation) {
1418
+ if (validMutation) {
1409
1419
  // dropped within same calendar
1410
1420
  if (receivingCalendar === initialCalendar_1) {
1411
1421
  initialCalendar_1.dispatch({
1412
1422
  type: 'MERGE_EVENTS',
1413
1423
  eventStore: mutatedRelevantEvents
1414
1424
  });
1415
- var eventDropArg = {};
1416
- for (var _i = 0, _a = initialCalendar_1.pluginSystem.hooks.eventDropTransformers; _i < _a.length; _i++) {
1417
- var transformer = _a[_i];
1418
- __assign(eventDropArg, transformer(_this.validMutation, initialCalendar_1));
1425
+ var transformed = {};
1426
+ for (var _i = 0, _b = initialCalendar_1.pluginSystem.hooks.eventDropTransformers; _i < _b.length; _i++) {
1427
+ var transformer = _b[_i];
1428
+ __assign(transformed, transformer(validMutation, initialCalendar_1));
1419
1429
  }
1420
- __assign(eventDropArg, {
1421
- el: ev.subjectEl,
1422
- delta: _this.validMutation.startDelta,
1423
- oldEvent: eventApi,
1424
- event: new core.EventApi(// the data AFTER the mutation
1425
- initialCalendar_1, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null),
1426
- revert: function () {
1430
+ var eventDropArg = __assign({}, transformed, { el: ev.subjectEl, delta: validMutation.datesDelta, oldEvent: eventApi, event: new core.EventApi(// the data AFTER the mutation
1431
+ initialCalendar_1, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null), revert: function () {
1427
1432
  initialCalendar_1.dispatch({
1428
1433
  type: 'MERGE_EVENTS',
1429
1434
  eventStore: relevantEvents_1
1430
1435
  });
1431
- },
1432
- jsEvent: ev.origEvent,
1433
- view: initialView
1434
- });
1436
+ }, jsEvent: ev.origEvent, view: initialView });
1435
1437
  initialCalendar_1.publiclyTrigger('eventDrop', [eventDropArg]);
1436
1438
  // dropped in different calendar
1437
1439
  }
@@ -1457,17 +1459,15 @@ Docs & License: https://fullcalendar.io/
1457
1459
  eventInstanceId: eventInstance.instanceId
1458
1460
  });
1459
1461
  }
1460
- var dropArg = receivingCalendar.buildDatePointApi(finalHit.dateSpan);
1461
- dropArg.draggedEl = ev.subjectEl;
1462
- dropArg.jsEvent = ev.origEvent;
1463
- dropArg.view = finalHit.component; // ?
1462
+ var dropArg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.component // should this be finalHit.component.view? See #4644
1463
+ });
1464
1464
  receivingCalendar.publiclyTrigger('drop', [dropArg]);
1465
1465
  receivingCalendar.publiclyTrigger('eventReceive', [
1466
1466
  {
1467
1467
  draggedEl: ev.subjectEl,
1468
1468
  event: new core.EventApi(// the data AFTER the mutation
1469
1469
  receivingCalendar, mutatedRelevantEvents.defs[eventDef.defId], mutatedRelevantEvents.instances[eventInstance.instanceId]),
1470
- view: finalHit.component
1470
+ view: finalHit.component // should this be finalHit.component.view? See #4644
1471
1471
  }
1472
1472
  ]);
1473
1473
  }
@@ -1479,10 +1479,11 @@ Docs & License: https://fullcalendar.io/
1479
1479
  _this.cleanup();
1480
1480
  };
1481
1481
  var component = _this.component;
1482
+ var options = component.context.options;
1482
1483
  var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
1483
1484
  dragging.pointer.selector = EventDragging.SELECTOR;
1484
1485
  dragging.touchScrollAllowed = false;
1485
- dragging.autoScroller.isEnabled = component.opt('dragScroll');
1486
+ dragging.autoScroller.isEnabled = options.dragScroll;
1486
1487
  var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsStore);
1487
1488
  hitDragging.useSubjectCenter = settings.useEventCenter;
1488
1489
  hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
@@ -1497,7 +1498,7 @@ Docs & License: https://fullcalendar.io/
1497
1498
  };
1498
1499
  // render a drag state on the next receivingCalendar
1499
1500
  EventDragging.prototype.displayDrag = function (nextCalendar, state) {
1500
- var initialCalendar = this.component.calendar;
1501
+ var initialCalendar = this.component.context.calendar;
1501
1502
  var prevCalendar = this.receivingCalendar;
1502
1503
  // does the previous calendar need to be cleared?
1503
1504
  if (prevCalendar && prevCalendar !== nextCalendar) {
@@ -1524,7 +1525,7 @@ Docs & License: https://fullcalendar.io/
1524
1525
  }
1525
1526
  };
1526
1527
  EventDragging.prototype.clearDrag = function () {
1527
- var initialCalendar = this.component.calendar;
1528
+ var initialCalendar = this.component.context.calendar;
1528
1529
  var receivingCalendar = this.receivingCalendar;
1529
1530
  if (receivingCalendar) {
1530
1531
  receivingCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
@@ -1554,22 +1555,21 @@ Docs & License: https://fullcalendar.io/
1554
1555
  var standardProps = {};
1555
1556
  if (dateSpan0.allDay !== dateSpan1.allDay) {
1556
1557
  standardProps.allDay = dateSpan1.allDay;
1557
- standardProps.hasEnd = hit1.component.opt('allDayMaintainDuration');
1558
+ standardProps.hasEnd = hit1.component.context.options.allDayMaintainDuration;
1558
1559
  if (dateSpan1.allDay) {
1559
1560
  // means date1 is already start-of-day,
1560
1561
  // but date0 needs to be converted
1561
1562
  date0 = core.startOfDay(date0);
1562
1563
  }
1563
1564
  }
1564
- var delta = core.diffDates(date0, date1, hit0.component.dateEnv, hit0.component === hit1.component ?
1565
+ var delta = core.diffDates(date0, date1, hit0.component.context.dateEnv, hit0.component === hit1.component ?
1565
1566
  hit0.component.largeUnit :
1566
1567
  null);
1567
1568
  if (delta.milliseconds) { // has hours/minutes/seconds
1568
1569
  standardProps.allDay = false;
1569
1570
  }
1570
1571
  var mutation = {
1571
- startDelta: delta,
1572
- endDelta: delta,
1572
+ datesDelta: delta,
1573
1573
  standardProps: standardProps
1574
1574
  };
1575
1575
  for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
@@ -1579,9 +1579,10 @@ Docs & License: https://fullcalendar.io/
1579
1579
  return mutation;
1580
1580
  }
1581
1581
  function getComponentTouchDelay$1(component) {
1582
- var delay = component.opt('eventLongPressDelay');
1582
+ var options = component.context.options;
1583
+ var delay = options.eventLongPressDelay;
1583
1584
  if (delay == null) {
1584
- delay = component.opt('longPressDelay');
1585
+ delay = options.longPressDelay;
1585
1586
  }
1586
1587
  return delay;
1587
1588
  }
@@ -1600,13 +1601,13 @@ Docs & License: https://fullcalendar.io/
1600
1601
  var component = _this.component;
1601
1602
  var seg = _this.querySeg(ev);
1602
1603
  var eventRange = _this.eventRange = seg.eventRange;
1603
- _this.dragging.minDistance = component.opt('eventDragMinDistance');
1604
+ _this.dragging.minDistance = component.context.options.eventDragMinDistance;
1604
1605
  // if touch, need to be working with a selected event
1605
1606
  _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
1606
1607
  (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
1607
1608
  };
1608
1609
  _this.handleDragStart = function (ev) {
1609
- var calendar = _this.component.calendar;
1610
+ var _a = _this.component.context, calendar = _a.calendar, view = _a.view;
1610
1611
  var eventRange = _this.eventRange;
1611
1612
  _this.relevantEvents = core.getRelevantEvents(calendar.state.eventStore, _this.eventRange.instance.instanceId);
1612
1613
  _this.draggingSeg = _this.querySeg(ev);
@@ -1616,12 +1617,12 @@ Docs & License: https://fullcalendar.io/
1616
1617
  el: _this.draggingSeg.el,
1617
1618
  event: new core.EventApi(calendar, eventRange.def, eventRange.instance),
1618
1619
  jsEvent: ev.origEvent,
1619
- view: _this.component.view
1620
+ view: view
1620
1621
  }
1621
1622
  ]);
1622
1623
  };
1623
1624
  _this.handleHitUpdate = function (hit, isFinal, ev) {
1624
- var calendar = _this.component.calendar;
1625
+ var calendar = _this.component.context.calendar;
1625
1626
  var relevantEvents = _this.relevantEvents;
1626
1627
  var initialHit = _this.hitDragging.initialHit;
1627
1628
  var eventInstance = _this.eventRange.instance;
@@ -1671,8 +1672,7 @@ Docs & License: https://fullcalendar.io/
1671
1672
  }
1672
1673
  };
1673
1674
  _this.handleDragEnd = function (ev) {
1674
- var calendar = _this.component.calendar;
1675
- var view = _this.component.view;
1675
+ var _a = _this.component.context, calendar = _a.calendar, view = _a.view;
1676
1676
  var eventDef = _this.eventRange.def;
1677
1677
  var eventInstance = _this.eventRange.instance;
1678
1678
  var eventApi = new core.EventApi(calendar, eventDef, eventInstance);
@@ -1723,7 +1723,7 @@ Docs & License: https://fullcalendar.io/
1723
1723
  var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
1724
1724
  dragging.pointer.selector = '.fc-resizer';
1725
1725
  dragging.touchScrollAllowed = false;
1726
- dragging.autoScroller.isEnabled = component.opt('dragScroll');
1726
+ dragging.autoScroller.isEnabled = component.context.options.dragScroll;
1727
1727
  var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
1728
1728
  hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1729
1729
  hitDragging.emitter.on('dragstart', _this.handleDragStart);
@@ -1740,7 +1740,7 @@ Docs & License: https://fullcalendar.io/
1740
1740
  return EventDragging;
1741
1741
  }(core.Interaction));
1742
1742
  function computeMutation(hit0, hit1, isFromStart, instanceRange, transforms) {
1743
- var dateEnv = hit0.component.dateEnv;
1743
+ var dateEnv = hit0.component.context.dateEnv;
1744
1744
  var date0 = hit0.dateSpan.range.start;
1745
1745
  var date1 = hit1.dateSpan.range.start;
1746
1746
  var delta = core.diffDates(date0, date1, dateEnv, hit0.component.largeUnit);
@@ -1845,7 +1845,7 @@ Docs & License: https://fullcalendar.io/
1845
1845
  origSeg: null
1846
1846
  };
1847
1847
  if (hit) {
1848
- receivingCalendar = hit.component.calendar;
1848
+ receivingCalendar = hit.component.context.calendar;
1849
1849
  if (_this.canDropElOnCalendar(ev.subjectEl, receivingCalendar)) {
1850
1850
  droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingCalendar);
1851
1851
  interaction.mutatedEvents = core.eventTupleToStore(droppableEvent);
@@ -1877,12 +1877,9 @@ Docs & License: https://fullcalendar.io/
1877
1877
  _this.clearDrag();
1878
1878
  if (receivingCalendar && droppableEvent) {
1879
1879
  var finalHit = _this.hitDragging.finalHit;
1880
- var finalView = finalHit.component.view;
1880
+ var finalView = finalHit.component.context.view;
1881
1881
  var dragMeta = _this.dragMeta;
1882
- var arg = receivingCalendar.buildDatePointApi(finalHit.dateSpan);
1883
- arg.draggedEl = pev.subjectEl;
1884
- arg.jsEvent = pev.origEvent;
1885
- arg.view = finalView;
1882
+ var arg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView });
1886
1883
  receivingCalendar.publiclyTrigger('drop', [arg]);
1887
1884
  if (dragMeta.create) {
1888
1885
  receivingCalendar.dispatch({