{"version":3,"file":"main.js","sources":["../../node_modules/tslib/tslib.es6.js","../../src/interaction/dnd/PointerDragging.ts","../../src/interaction/dnd/ElementMirror.ts","../../src/interaction/scroll-geom-cache.ts","../../src/interaction/dnd/AutoScroller.ts","../../src/interaction/dnd/FeaturefulElementDragging.ts","../../src/interaction/OffsetTracker.ts","../../src/interaction/interactions/HitDragging.ts","../../src/interaction/interactions/DateClicking.ts","../../src/interaction/interactions/DateSelecting.ts","../../src/interaction/interactions/EventDragging.ts","../../src/interaction/interactions/EventResizing.ts","../../src/interaction/interactions/UnselectAuto.ts","../../src/interaction/interactions-external/ExternalElementDragging.ts","../../src/interaction/interactions-external/ExternalDraggable.ts","../../src/interaction/interactions-external/InferredElementDragging.ts","../../src/interaction/interactions-external/ThirdPartyDraggable.ts","../../src/interaction/main.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\r\n t[p[i]] = s[p[i]];\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","import { config, elementClosest, EmitterMixin, PointerDragEvent } from '@fullcalendar/core'\n\nconfig.touchMouseIgnoreWait = 500\n\nlet ignoreMouseDepth = 0\nlet listenerCnt = 0\nlet isWindowTouchMoveCancelled = false\n\n/*\nUses a \"pointer\" abstraction, which monitors UI events for both mouse and touch.\nTracks when the pointer \"drags\" on a certain element, meaning down+move+up.\n\nAlso, tracks if there was touch-scrolling.\nAlso, can prevent touch-scrolling from happening.\nAlso, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.\n\nemits:\n- pointerdown\n- pointermove\n- pointerup\n*/\nexport default class PointerDragging {\n\n containerEl: EventTarget\n subjectEl: HTMLElement | null = null\n downEl: HTMLElement | null = null\n emitter: EmitterMixin\n\n // options that can be directly assigned by caller\n selector: string = '' // will cause subjectEl in all emitted events to be this element\n handleSelector: string = ''\n shouldIgnoreMove: boolean = false\n shouldWatchScroll: boolean = true // for simulating pointermove on scroll\n\n // internal states\n isDragging: boolean = false\n isTouchDragging: boolean = false\n wasTouchScroll: boolean = false\n origPageX: number\n origPageY: number\n prevPageX: number\n prevPageY: number\n prevScrollX: number // at time of last pointer pageX/pageY capture\n prevScrollY: number // \"\n\n constructor(containerEl: EventTarget) {\n this.containerEl = containerEl\n this.emitter = new EmitterMixin()\n containerEl.addEventListener('mousedown', this.handleMouseDown as EventListener)\n containerEl.addEventListener('touchstart', this.handleTouchStart as EventListener, { passive: true })\n listenerCreated()\n }\n\n destroy() {\n this.containerEl.removeEventListener('mousedown', this.handleMouseDown as EventListener)\n this.containerEl.removeEventListener('touchstart', this.handleTouchStart as EventListener, { passive: true } as AddEventListenerOptions)\n listenerDestroyed()\n }\n\n tryStart(ev: UIEvent): boolean {\n let subjectEl = this.querySubjectEl(ev)\n let downEl = ev.target as HTMLElement\n\n if (\n subjectEl &&\n (!this.handleSelector || elementClosest(downEl, this.handleSelector))\n ) {\n this.subjectEl = subjectEl\n this.downEl = downEl\n this.isDragging = true // do this first so cancelTouchScroll will work\n this.wasTouchScroll = false\n\n return true\n }\n\n return false\n }\n\n cleanup() {\n isWindowTouchMoveCancelled = false\n this.isDragging = false\n this.subjectEl = null\n this.downEl = null\n // keep wasTouchScroll around for later access\n this.destroyScrollWatch()\n }\n\n querySubjectEl(ev: UIEvent): HTMLElement {\n if (this.selector) {\n return elementClosest(ev.target as HTMLElement, this.selector)\n } else {\n return this.containerEl as HTMLElement\n }\n }\n\n\n // Mouse\n // ----------------------------------------------------------------------------------------------------\n\n handleMouseDown = (ev: MouseEvent) => {\n if (\n !this.shouldIgnoreMouse() &&\n isPrimaryMouseButton(ev) &&\n this.tryStart(ev)\n ) {\n let pev = this.createEventFromMouse(ev, true)\n this.emitter.trigger('pointerdown', pev)\n this.initScrollWatch(pev)\n\n if (!this.shouldIgnoreMove) {\n document.addEventListener('mousemove', this.handleMouseMove)\n }\n\n document.addEventListener('mouseup', this.handleMouseUp)\n }\n }\n\n handleMouseMove = (ev: MouseEvent) => {\n let pev = this.createEventFromMouse(ev)\n this.recordCoords(pev)\n this.emitter.trigger('pointermove', pev)\n }\n\n handleMouseUp = (ev: MouseEvent) => {\n document.removeEventListener('mousemove', this.handleMouseMove)\n document.removeEventListener('mouseup', this.handleMouseUp)\n\n this.emitter.trigger('pointerup', this.createEventFromMouse(ev))\n\n this.cleanup() // call last so that pointerup has access to props\n }\n\n shouldIgnoreMouse() {\n return ignoreMouseDepth || this.isTouchDragging\n }\n\n\n // Touch\n // ----------------------------------------------------------------------------------------------------\n\n handleTouchStart = (ev: TouchEvent) => {\n if (this.tryStart(ev)) {\n this.isTouchDragging = true\n\n let pev = this.createEventFromTouch(ev, true)\n this.emitter.trigger('pointerdown', pev)\n this.initScrollWatch(pev)\n\n // unlike mouse, need to attach to target, not document\n // https://stackoverflow.com/a/45760014\n let target = ev.target as HTMLElement\n\n if (!this.shouldIgnoreMove) {\n target.addEventListener('touchmove', this.handleTouchMove)\n }\n\n target.addEventListener('touchend', this.handleTouchEnd)\n target.addEventListener('touchcancel', this.handleTouchEnd) // treat it as a touch end\n\n // attach a handler to get called when ANY scroll action happens on the page.\n // this was impossible to do with normal on/off because 'scroll' doesn't bubble.\n // http://stackoverflow.com/a/32954565/96342\n window.addEventListener(\n 'scroll',\n this.handleTouchScroll,\n true // useCapture\n )\n }\n\n }\n\n handleTouchMove = (ev: TouchEvent) => {\n let pev = this.createEventFromTouch(ev)\n this.recordCoords(pev)\n this.emitter.trigger('pointermove', pev)\n }\n\n handleTouchEnd = (ev: TouchEvent) => {\n if (this.isDragging) { // done to guard against touchend followed by touchcancel\n let target = ev.target as HTMLElement\n\n target.removeEventListener('touchmove', this.handleTouchMove)\n target.removeEventListener('touchend', this.handleTouchEnd)\n target.removeEventListener('touchcancel', this.handleTouchEnd)\n window.removeEventListener('scroll', this.handleTouchScroll, true) // useCaptured=true\n\n this.emitter.trigger('pointerup', this.createEventFromTouch(ev))\n\n this.cleanup() // call last so that pointerup has access to props\n this.isTouchDragging = false\n startIgnoringMouse()\n }\n }\n\n handleTouchScroll = () => {\n this.wasTouchScroll = true\n }\n\n // can be called by user of this class, to cancel touch-based scrolling for the current drag\n cancelTouchScroll() {\n if (this.isDragging) {\n isWindowTouchMoveCancelled = true\n }\n }\n\n\n // Scrolling that simulates pointermoves\n // ----------------------------------------------------------------------------------------------------\n\n initScrollWatch(ev: PointerDragEvent) {\n if (this.shouldWatchScroll) {\n this.recordCoords(ev)\n window.addEventListener('scroll', this.handleScroll, true) // useCapture=true\n }\n }\n\n recordCoords(ev: PointerDragEvent) {\n if (this.shouldWatchScroll) {\n this.prevPageX = (ev as any).pageX\n this.prevPageY = (ev as any).pageY\n this.prevScrollX = window.pageXOffset\n this.prevScrollY = window.pageYOffset\n }\n }\n\n handleScroll = (ev: UIEvent) => {\n if (!this.shouldIgnoreMove) {\n let pageX = (window.pageXOffset - this.prevScrollX) + this.prevPageX\n let pageY = (window.pageYOffset - this.prevScrollY) + this.prevPageY\n\n this.emitter.trigger('pointermove', {\n origEvent: ev,\n isTouch: this.isTouchDragging,\n subjectEl: this.subjectEl,\n pageX,\n pageY,\n deltaX: pageX - this.origPageX,\n deltaY: pageY - this.origPageY\n } as PointerDragEvent)\n }\n }\n\n destroyScrollWatch() {\n if (this.shouldWatchScroll) {\n window.removeEventListener('scroll', this.handleScroll, true) // useCaptured=true\n }\n }\n\n\n // Event Normalization\n // ----------------------------------------------------------------------------------------------------\n\n createEventFromMouse(ev: MouseEvent, isFirst?: boolean): PointerDragEvent {\n let deltaX = 0\n let deltaY = 0\n\n // TODO: repeat code\n if (isFirst) {\n this.origPageX = ev.pageX\n this.origPageY = ev.pageY\n } else {\n deltaX = ev.pageX - this.origPageX\n deltaY = ev.pageY - this.origPageY\n }\n\n return {\n origEvent: ev,\n isTouch: false,\n subjectEl: this.subjectEl,\n pageX: ev.pageX,\n pageY: ev.pageY,\n deltaX,\n deltaY\n }\n }\n\n createEventFromTouch(ev: TouchEvent, isFirst?: boolean): PointerDragEvent {\n let touches = ev.touches\n let pageX\n let pageY\n let deltaX = 0\n let deltaY = 0\n\n // if touch coords available, prefer,\n // because FF would give bad ev.pageX ev.pageY\n if (touches && touches.length) {\n pageX = touches[0].pageX\n pageY = touches[0].pageY\n } else {\n pageX = (ev as any).pageX\n pageY = (ev as any).pageY\n }\n\n // TODO: repeat code\n if (isFirst) {\n this.origPageX = pageX\n this.origPageY = pageY\n } else {\n deltaX = pageX - this.origPageX\n deltaY = pageY - this.origPageY\n }\n\n return {\n origEvent: ev,\n isTouch: true,\n subjectEl: this.subjectEl,\n pageX,\n pageY,\n deltaX,\n deltaY\n }\n }\n\n}\n\n// Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)\nfunction isPrimaryMouseButton(ev: MouseEvent) {\n return ev.button === 0 && !ev.ctrlKey\n}\n\n\n// Ignoring fake mouse events generated by touch\n// ----------------------------------------------------------------------------------------------------\n\nfunction startIgnoringMouse() { // can be made non-class function\n ignoreMouseDepth++\n\n setTimeout(() => {\n ignoreMouseDepth--\n }, config.touchMouseIgnoreWait)\n}\n\n\n// We want to attach touchmove as early as possible for Safari\n// ----------------------------------------------------------------------------------------------------\n\nfunction listenerCreated() {\n if (!(listenerCnt++)) {\n window.addEventListener('touchmove', onWindowTouchMove, { passive: false })\n }\n}\n\nfunction listenerDestroyed() {\n if (!(--listenerCnt)) {\n window.removeEventListener('touchmove', onWindowTouchMove, { passive: false } as AddEventListenerOptions)\n }\n}\n\nfunction onWindowTouchMove(ev: UIEvent) {\n if (isWindowTouchMoveCancelled) {\n ev.preventDefault()\n }\n}\n","import { removeElement, applyStyle, whenTransitionDone, Rect } from '@fullcalendar/core'\n\n/*\nAn effect in which an element follows the movement of a pointer across the screen.\nThe moving element is a clone of some other element.\nMust call start + handleMove + stop.\n*/\nexport default class ElementMirror {\n\n isVisible: boolean = false // must be explicitly enabled\n origScreenX?: number\n origScreenY?: number\n deltaX?: number\n deltaY?: number\n sourceEl: HTMLElement | null = null\n mirrorEl: HTMLElement | null = null\n sourceElRect: Rect | null = null // screen coords relative to viewport\n\n // options that can be set directly by caller\n parentNode: HTMLElement = document.body\n zIndex: number = 9999\n revertDuration: number = 0\n\n start(sourceEl: HTMLElement, pageX: number, pageY: number) {\n this.sourceEl = sourceEl\n this.sourceElRect = this.sourceEl.getBoundingClientRect()\n this.origScreenX = pageX - window.pageXOffset\n this.origScreenY = pageY - window.pageYOffset\n this.deltaX = 0\n this.deltaY = 0\n this.updateElPosition()\n }\n\n handleMove(pageX: number, pageY: number) {\n this.deltaX = (pageX - window.pageXOffset) - this.origScreenX!\n this.deltaY = (pageY - window.pageYOffset) - this.origScreenY!\n this.updateElPosition()\n }\n\n // can be called before start\n setIsVisible(bool: boolean) {\n if (bool) {\n if (!this.isVisible) {\n if (this.mirrorEl) {\n this.mirrorEl.style.display = ''\n }\n\n this.isVisible = bool // needs to happen before updateElPosition\n this.updateElPosition() // because was not updating the position while invisible\n }\n } else {\n if (this.isVisible) {\n if (this.mirrorEl) {\n this.mirrorEl.style.display = 'none'\n }\n\n this.isVisible = bool\n }\n }\n }\n\n // always async\n stop(needsRevertAnimation: boolean, callback: () => void) {\n let done = () => {\n this.cleanup()\n callback()\n }\n\n if (\n needsRevertAnimation &&\n this.mirrorEl &&\n this.isVisible &&\n this.revertDuration && // if 0, transition won't work\n (this.deltaX || this.deltaY) // if same coords, transition won't work\n ) {\n this.doRevertAnimation(done, this.revertDuration)\n } else {\n setTimeout(done, 0)\n }\n }\n\n doRevertAnimation(callback: () => void, revertDuration: number) {\n let mirrorEl = this.mirrorEl!\n let finalSourceElRect = this.sourceEl!.getBoundingClientRect() // because autoscrolling might have happened\n\n mirrorEl.style.transition =\n 'top ' + revertDuration + 'ms,' +\n 'left ' + revertDuration + 'ms'\n\n applyStyle(mirrorEl, {\n left: finalSourceElRect.left,\n top: finalSourceElRect.top\n })\n\n whenTransitionDone(mirrorEl, () => {\n mirrorEl.style.transition = ''\n callback()\n })\n }\n\n cleanup() {\n if (this.mirrorEl) {\n removeElement(this.mirrorEl)\n this.mirrorEl = null\n }\n\n this.sourceEl = null\n }\n\n updateElPosition() {\n if (this.sourceEl && this.isVisible) {\n applyStyle(this.getMirrorEl(), {\n left: this.sourceElRect!.left + this.deltaX!,\n top: this.sourceElRect!.top + this.deltaY!\n })\n }\n }\n\n getMirrorEl(): HTMLElement {\n let sourceElRect = this.sourceElRect!\n let mirrorEl = this.mirrorEl\n\n if (!mirrorEl) {\n mirrorEl = this.mirrorEl = this.sourceEl!.cloneNode(true) as HTMLElement // cloneChildren=true\n\n // we don't want long taps or any mouse interaction causing selection/menus.\n // would use preventSelection(), but that prevents selectstart, causing problems.\n mirrorEl.classList.add('fc-unselectable')\n\n mirrorEl.classList.add('fc-dragging')\n\n applyStyle(mirrorEl, {\n position: 'fixed',\n zIndex: this.zIndex,\n visibility: '', // in case original element was hidden by the drag effect\n boxSizing: 'border-box', // for easy width/height\n width: sourceElRect.right - sourceElRect.left, // explicit height in case there was a 'right' value\n height: sourceElRect.bottom - sourceElRect.top, // explicit width in case there was a 'bottom' value\n right: 'auto', // erase and set width instead\n bottom: 'auto', // erase and set height instead\n margin: 0\n })\n\n this.parentNode.appendChild(mirrorEl)\n }\n\n return mirrorEl\n }\n\n}\n","import {\n Rect, computeInnerRect,\n ScrollController, ElementScrollController, WindowScrollController\n} from '@fullcalendar/core'\n\n/*\nIs a cache for a given element's scroll information (all the info that ScrollController stores)\nin addition the \"client rectangle\" of the element.. the area within the scrollbars.\n\nThe cache can be in one of two modes:\n- doesListening:false - ignores when the container is scrolled by someone else\n- doesListening:true - watch for scrolling and update the cache\n*/\nexport abstract class ScrollGeomCache extends ScrollController {\n\n clientRect: Rect\n origScrollTop: number\n origScrollLeft: number\n\n protected scrollController: ScrollController\n protected doesListening: boolean\n protected scrollTop: number\n protected scrollLeft: number\n protected scrollWidth: number\n protected scrollHeight: number\n protected clientWidth: number\n protected clientHeight: number\n\n constructor(scrollController: ScrollController, doesListening: boolean) {\n super()\n this.scrollController = scrollController\n this.doesListening = doesListening\n this.scrollTop = this.origScrollTop = scrollController.getScrollTop()\n this.scrollLeft = this.origScrollLeft = scrollController.getScrollLeft()\n this.scrollWidth = scrollController.getScrollWidth()\n this.scrollHeight = scrollController.getScrollHeight()\n this.clientWidth = scrollController.getClientWidth()\n this.clientHeight = scrollController.getClientHeight()\n this.clientRect = this.computeClientRect() // do last in case it needs cached values\n\n if (this.doesListening) {\n this.getEventTarget().addEventListener('scroll', this.handleScroll)\n }\n }\n\n abstract getEventTarget(): EventTarget\n abstract computeClientRect(): Rect\n\n destroy() {\n if (this.doesListening) {\n this.getEventTarget().removeEventListener('scroll', this.handleScroll)\n }\n }\n\n handleScroll = () => {\n this.scrollTop = this.scrollController.getScrollTop()\n this.scrollLeft = this.scrollController.getScrollLeft()\n this.handleScrollChange()\n }\n\n getScrollTop() {\n return this.scrollTop\n }\n\n getScrollLeft() {\n return this.scrollLeft\n }\n\n setScrollTop(top: number) {\n this.scrollController.setScrollTop(top)\n\n if (!this.doesListening) {\n // we are not relying on the element to normalize out-of-bounds scroll values\n // so we need to sanitize ourselves\n this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0)\n\n this.handleScrollChange()\n }\n }\n\n setScrollLeft(top: number) {\n this.scrollController.setScrollLeft(top)\n\n if (!this.doesListening) {\n // we are not relying on the element to normalize out-of-bounds scroll values\n // so we need to sanitize ourselves\n this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0)\n\n this.handleScrollChange()\n }\n }\n\n getClientWidth() {\n return this.clientWidth\n }\n\n getClientHeight() {\n return this.clientHeight\n }\n\n getScrollWidth() {\n return this.scrollWidth\n }\n\n getScrollHeight() {\n return this.scrollHeight\n }\n\n handleScrollChange() {\n }\n\n}\n\nexport class ElementScrollGeomCache extends ScrollGeomCache {\n\n constructor(el: HTMLElement, doesListening: boolean) {\n super(new ElementScrollController(el), doesListening)\n }\n\n getEventTarget(): EventTarget {\n return (this.scrollController as ElementScrollController).el\n }\n\n computeClientRect() {\n return computeInnerRect((this.scrollController as ElementScrollController).el)\n }\n\n}\n\nexport class WindowScrollGeomCache extends ScrollGeomCache {\n\n constructor(doesListening: boolean) {\n super(new WindowScrollController(), doesListening)\n }\n\n getEventTarget(): EventTarget {\n return window\n }\n\n computeClientRect(): Rect {\n return {\n left: this.scrollLeft,\n right: this.scrollLeft + this.clientWidth,\n top: this.scrollTop,\n bottom: this.scrollTop + this.clientHeight\n }\n }\n\n // the window is the only scroll object that changes it's rectangle relative\n // to the document's topleft as it scrolls\n handleScrollChange() {\n this.clientRect = this.computeClientRect()\n }\n\n}\n","import { ScrollGeomCache, ElementScrollGeomCache, WindowScrollGeomCache } from '../scroll-geom-cache'\n\ninterface Edge {\n scrollCache: ScrollGeomCache\n name: 'top' | 'left' | 'right' | 'bottom'\n distance: number // how many pixels the current pointer is from the edge\n}\n\n// If available we are using native \"performance\" API instead of \"Date\"\n// Read more about it on MDN:\n// https://developer.mozilla.org/en-US/docs/Web/API/Performance\nconst getTime = typeof performance === 'function' ? (performance as any).now : Date.now\n\n/*\nFor a pointer interaction, automatically scrolls certain scroll containers when the pointer\napproaches the edge.\n\nThe caller must call start + handleMove + stop.\n*/\nexport default class AutoScroller {\n\n // options that can be set by caller\n isEnabled: boolean = true\n scrollQuery: (Window | string)[] = [ window, '.fc-scroller' ]\n edgeThreshold: number = 50 // pixels\n maxVelocity: number = 300 // pixels per second\n\n // internal state\n pointerScreenX: number | null = null\n pointerScreenY: number | null = null\n isAnimating: boolean = false\n scrollCaches: ScrollGeomCache[] | null = null\n msSinceRequest?: number\n\n // protect against the initial pointerdown being too close to an edge and starting the scroll\n everMovedUp: boolean = false\n everMovedDown: boolean = false\n everMovedLeft: boolean = false\n everMovedRight: boolean = false\n\n start(pageX: number, pageY: number) {\n if (this.isEnabled) {\n this.scrollCaches = this.buildCaches()\n this.pointerScreenX = null\n this.pointerScreenY = null\n this.everMovedUp = false\n this.everMovedDown = false\n this.everMovedLeft = false\n this.everMovedRight = false\n this.handleMove(pageX, pageY)\n }\n }\n\n handleMove(pageX: number, pageY: number) {\n if (this.isEnabled) {\n let pointerScreenX = pageX - window.pageXOffset\n let pointerScreenY = pageY - window.pageYOffset\n\n let yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY\n let xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX\n\n if (yDelta < 0) {\n this.everMovedUp = true\n } else if (yDelta > 0) {\n this.everMovedDown = true\n }\n\n if (xDelta < 0) {\n this.everMovedLeft = true\n } else if (xDelta > 0) {\n this.everMovedRight = true\n }\n\n this.pointerScreenX = pointerScreenX\n this.pointerScreenY = pointerScreenY\n\n if (!this.isAnimating) {\n this.isAnimating = true\n this.requestAnimation(getTime())\n }\n }\n }\n\n stop() {\n if (this.isEnabled) {\n this.isAnimating = false // will stop animation\n\n for (let scrollCache of this.scrollCaches!) {\n scrollCache.destroy()\n }\n\n this.scrollCaches = null\n }\n }\n\n requestAnimation(now: number) {\n this.msSinceRequest = now\n requestAnimationFrame(this.animate)\n }\n\n private animate = () => {\n if (this.isAnimating) { // wasn't cancelled between animation calls\n let edge = this.computeBestEdge(\n this.pointerScreenX! + window.pageXOffset,\n this.pointerScreenY! + window.pageYOffset\n )\n\n if (edge) {\n let now = getTime()\n this.handleSide(edge, (now - this.msSinceRequest!) / 1000)\n this.requestAnimation(now)\n } else {\n this.isAnimating = false // will stop animation\n }\n }\n }\n\n private handleSide(edge: Edge, seconds: number) {\n let { scrollCache } = edge\n let { edgeThreshold } = this\n let invDistance = edgeThreshold - edge.distance\n let velocity = // the closer to the edge, the faster we scroll\n (invDistance * invDistance) / (edgeThreshold * edgeThreshold) * // quadratic\n this.maxVelocity * seconds\n let sign = 1\n\n switch (edge.name) {\n\n case 'left':\n sign = -1\n // falls through\n case 'right':\n scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign)\n break\n\n case 'top':\n sign = -1\n // falls through\n case 'bottom':\n scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign)\n break\n }\n }\n\n // left/top are relative to document topleft\n private computeBestEdge(left: number, top: number): Edge | null {\n let { edgeThreshold } = this\n let bestSide: Edge | null = null\n\n for (let scrollCache of this.scrollCaches!) {\n let rect = scrollCache.clientRect\n let leftDist = left - rect.left\n let rightDist = rect.right - left\n let topDist = top - rect.top\n let bottomDist = rect.bottom - top\n\n // completely within the rect?\n if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {\n\n if (\n topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&\n (!bestSide || bestSide.distance > topDist)\n ) {\n bestSide = { scrollCache, name: 'top', distance: topDist }\n }\n\n if (\n bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&\n (!bestSide || bestSide.distance > bottomDist)\n ) {\n bestSide = { scrollCache, name: 'bottom', distance: bottomDist }\n }\n\n if (\n leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&\n (!bestSide || bestSide.distance > leftDist)\n ) {\n bestSide = { scrollCache, name: 'left', distance: leftDist }\n }\n\n if (\n rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&\n (!bestSide || bestSide.distance > rightDist)\n ) {\n bestSide = { scrollCache, name: 'right', distance: rightDist }\n }\n }\n }\n\n return bestSide\n }\n\n private buildCaches() {\n return this.queryScrollEls().map((el) => {\n if (el === window) {\n return new WindowScrollGeomCache(false) // false = don't listen to user-generated scrolls\n } else {\n return new ElementScrollGeomCache(el, false) // false = don't listen to user-generated scrolls\n }\n })\n }\n\n private queryScrollEls() {\n let els = []\n\n for (let query of this.scrollQuery) {\n if (typeof query === 'object') {\n els.push(query)\n } else {\n els.push(...Array.prototype.slice.call(document.querySelectorAll(query)))\n }\n }\n\n return els\n }\n\n}\n","import { PointerDragEvent, preventSelection, allowSelection, preventContextMenu, allowContextMenu, ElementDragging } from '@fullcalendar/core'\nimport PointerDragging from './PointerDragging'\nimport ElementMirror from './ElementMirror'\nimport AutoScroller from './AutoScroller'\n\n/*\nMonitors dragging on an element. Has a number of high-level features:\n- minimum distance required before dragging\n- minimum wait time (\"delay\") before dragging\n- a mirror element that follows the pointer\n*/\nexport default class FeaturefulElementDragging extends ElementDragging {\n\n pointer: PointerDragging\n mirror: ElementMirror\n autoScroller: AutoScroller\n\n // options that can be directly set by caller\n // the caller can also set the PointerDragging's options as well\n delay: number | null = null\n minDistance: number = 0\n touchScrollAllowed: boolean = true // prevents drag from starting and blocks scrolling during drag\n\n mirrorNeedsRevert: boolean = false\n isInteracting: boolean = false // is the user validly moving the pointer? lasts until pointerup\n isDragging: boolean = false // is it INTENTFULLY dragging? lasts until after revert animation\n isDelayEnded: boolean = false\n isDistanceSurpassed: boolean = false\n delayTimeoutId: number | null = null\n\n\n constructor(containerEl: HTMLElement) {\n super(containerEl)\n\n let pointer = this.pointer = new PointerDragging(containerEl)\n pointer.emitter.on('pointerdown', this.onPointerDown)\n pointer.emitter.on('pointermove', this.onPointerMove)\n pointer.emitter.on('pointerup', this.onPointerUp)\n\n this.mirror = new ElementMirror()\n this.autoScroller = new AutoScroller()\n }\n\n destroy() {\n this.pointer.destroy()\n }\n\n onPointerDown = (ev: PointerDragEvent) => {\n if (!this.isDragging) { // so new drag doesn't happen while revert animation is going\n\n this.isInteracting = true\n this.isDelayEnded = false\n this.isDistanceSurpassed = false\n\n preventSelection(document.body)\n preventContextMenu(document.body)\n\n // prevent links from being visited if there's an eventual drag.\n // also prevents selection in older browsers (maybe?).\n // not necessary for touch, besides, browser would complain about passiveness.\n if (!ev.isTouch) {\n ev.origEvent.preventDefault()\n }\n\n this.emitter.trigger('pointerdown', ev)\n\n if (!this.pointer.shouldIgnoreMove) {\n // actions related to initiating dragstart+dragmove+dragend...\n\n this.mirror.setIsVisible(false) // reset. caller must set-visible\n this.mirror.start(ev.subjectEl as HTMLElement, ev.pageX, ev.pageY) // must happen on first pointer down\n\n this.startDelay(ev)\n\n if (!this.minDistance) {\n this.handleDistanceSurpassed(ev)\n }\n }\n }\n }\n\n onPointerMove = (ev: PointerDragEvent) => {\n if (this.isInteracting) { // if false, still waiting for previous drag's revert\n\n this.emitter.trigger('pointermove', ev)\n\n if (!this.isDistanceSurpassed) {\n let minDistance = this.minDistance\n let distanceSq // current distance from the origin, squared\n let { deltaX, deltaY } = ev\n\n distanceSq = deltaX * deltaX + deltaY * deltaY\n if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem\n this.handleDistanceSurpassed(ev)\n }\n }\n\n if (this.isDragging) {\n\n // a real pointer move? (not one simulated by scrolling)\n if (ev.origEvent.type !== 'scroll') {\n this.mirror.handleMove(ev.pageX, ev.pageY)\n this.autoScroller.handleMove(ev.pageX, ev.pageY)\n }\n\n this.emitter.trigger('dragmove', ev)\n }\n }\n }\n\n onPointerUp = (ev: PointerDragEvent) => {\n if (this.isInteracting) { // if false, still waiting for previous drag's revert\n this.isInteracting = false\n\n allowSelection(document.body)\n allowContextMenu(document.body)\n\n this.emitter.trigger('pointerup', ev) // can potentially set mirrorNeedsRevert\n\n if (this.isDragging) {\n this.autoScroller.stop()\n this.tryStopDrag(ev) // which will stop the mirror\n }\n\n if (this.delayTimeoutId) {\n clearTimeout(this.delayTimeoutId)\n this.delayTimeoutId = null\n }\n }\n }\n\n startDelay(ev: PointerDragEvent) {\n if (typeof this.delay === 'number') {\n this.delayTimeoutId = setTimeout(() => {\n this.delayTimeoutId = null\n this.handleDelayEnd(ev)\n }, this.delay)\n } else {\n this.handleDelayEnd(ev)\n }\n }\n\n handleDelayEnd(ev: PointerDragEvent) {\n this.isDelayEnded = true\n this.tryStartDrag(ev)\n }\n\n handleDistanceSurpassed(ev: PointerDragEvent) {\n this.isDistanceSurpassed = true\n this.tryStartDrag(ev)\n }\n\n tryStartDrag(ev: PointerDragEvent) {\n if (this.isDelayEnded && this.isDistanceSurpassed) {\n if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {\n this.isDragging = true\n this.mirrorNeedsRevert = false\n\n this.autoScroller.start(ev.pageX, ev.pageY)\n this.emitter.trigger('dragstart', ev)\n\n if (this.touchScrollAllowed === false) {\n this.pointer.cancelTouchScroll()\n }\n }\n }\n }\n\n tryStopDrag(ev: PointerDragEvent) {\n // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events\n // that come from the document to fire beforehand. much more convenient this way.\n this.mirror.stop(\n this.mirrorNeedsRevert,\n this.stopDrag.bind(this, ev) // bound with args\n )\n }\n\n stopDrag(ev: PointerDragEvent) {\n this.isDragging = false\n this.emitter.trigger('dragend', ev)\n }\n\n // fill in the implementations...\n\n setIgnoreMove(bool: boolean) {\n this.pointer.shouldIgnoreMove = bool\n }\n\n setMirrorIsVisible(bool: boolean) {\n this.mirror.setIsVisible(bool)\n }\n\n setMirrorNeedsRevert(bool: boolean) {\n this.mirrorNeedsRevert = bool\n }\n\n setAutoScrollEnabled(bool: boolean) {\n this.autoScroller.isEnabled = bool\n }\n\n}\n","import {\n getClippingParents, computeRect,\n pointInsideRect, Rect\n} from '@fullcalendar/core'\nimport { ElementScrollGeomCache } from './scroll-geom-cache'\n\n/*\nWhen this class is instantiated, it records the offset of an element (relative to the document topleft),\nand continues to monitor scrolling, updating the cached coordinates if it needs to.\nDoes not access the DOM after instantiation, so highly performant.\n\nAlso keeps track of all scrolling/overflow:hidden containers that are parents of the given element\nand an determine if a given point is inside the combined clipping rectangle.\n*/\nexport default class OffsetTracker { // ElementOffsetTracker\n\n scrollCaches: ElementScrollGeomCache[]\n origRect: Rect\n\n constructor(el: HTMLElement) {\n this.origRect = computeRect(el)\n\n // will work fine for divs that have overflow:hidden\n this.scrollCaches = getClippingParents(el).map(function(el) {\n return new ElementScrollGeomCache(el, true) // listen=true\n })\n }\n\n destroy() {\n for (let scrollCache of this.scrollCaches) {\n scrollCache.destroy()\n }\n }\n\n computeLeft() {\n let left = this.origRect.left\n\n for (let scrollCache of this.scrollCaches) {\n left += scrollCache.origScrollLeft - scrollCache.getScrollLeft()\n }\n\n return left\n }\n\n computeTop() {\n let top = this.origRect.top\n\n for (let scrollCache of this.scrollCaches) {\n top += scrollCache.origScrollTop - scrollCache.getScrollTop()\n }\n\n return top\n }\n\n isWithinClipping(pageX: number, pageY: number): boolean {\n let point = { left: pageX, top: pageY }\n\n for (let scrollCache of this.scrollCaches) {\n if (\n !isIgnoredClipping(scrollCache.getEventTarget()) &&\n !pointInsideRect(point, scrollCache.clientRect)\n ) {\n return false\n }\n }\n\n return true\n }\n\n}\n\n// certain clipping containers should never constrain interactions, like and
\n// https://github.com/fullcalendar/fullcalendar/issues/3615\nfunction isIgnoredClipping(node: EventTarget) {\n let tagName = (node as HTMLElement).tagName\n\n return tagName === 'HTML' || tagName === 'BODY'\n}\n","import {\n EmitterMixin, PointerDragEvent,\n isDateSpansEqual,\n computeRect,\n constrainPoint, intersectRects, getRectCenter, diffPoints, Point,\n rangeContainsRange,\n Hit,\n InteractionSettingsStore,\n mapHash,\n ElementDragging\n} from '@fullcalendar/core'\nimport OffsetTracker from '../OffsetTracker'\n\n/*\nTracks movement over multiple droppable areas (aka \"hits\")\nthat exist in one or more DateComponents.\nRelies on an existing draggable.\n\nemits:\n- pointerdown\n- dragstart\n- hitchange - fires initially, even if not over a hit\n- pointerup\n- (hitchange - again, to null, if ended over a hit)\n- dragend\n*/\nexport default class HitDragging {\n\n droppableStore: InteractionSettingsStore\n dragging: ElementDragging\n emitter: EmitterMixin\n\n // options that can be set by caller\n useSubjectCenter: boolean = false\n requireInitial: boolean = true // if doesn't start out on a hit, won't emit any events\n\n // internal state\n offsetTrackers: { [componentUid: string]: OffsetTracker }\n initialHit: Hit | null = null\n movingHit: Hit | null = null\n finalHit: Hit | null = null // won't ever be populated if shouldIgnoreMove\n coordAdjust?: Point\n\n constructor(dragging: ElementDragging, droppableStore: InteractionSettingsStore) {\n this.droppableStore = droppableStore\n\n dragging.emitter.on('pointerdown', this.handlePointerDown)\n dragging.emitter.on('dragstart', this.handleDragStart)\n dragging.emitter.on('dragmove', this.handleDragMove)\n dragging.emitter.on('pointerup', this.handlePointerUp)\n dragging.emitter.on('dragend', this.handleDragEnd)\n\n this.dragging = dragging\n this.emitter = new EmitterMixin()\n }\n\n handlePointerDown = (ev: PointerDragEvent) => {\n let { dragging } = this\n\n this.initialHit = null\n this.movingHit = null\n this.finalHit = null\n\n this.prepareHits()\n this.processFirstCoord(ev)\n\n if (this.initialHit || !this.requireInitial) {\n dragging.setIgnoreMove(false)\n this.emitter.trigger('pointerdown', ev) // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(\n } else {\n dragging.setIgnoreMove(true)\n }\n }\n\n // sets initialHit\n // sets coordAdjust\n processFirstCoord(ev: PointerDragEvent) {\n let origPoint = { left: ev.pageX, top: ev.pageY }\n let adjustedPoint = origPoint\n let subjectEl = ev.subjectEl\n let subjectRect\n\n if (subjectEl !== document) {\n subjectRect = computeRect(subjectEl)\n adjustedPoint = constrainPoint(adjustedPoint, subjectRect)\n }\n\n let initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top)\n\n if (initialHit) {\n if (this.useSubjectCenter && subjectRect) {\n let slicedSubjectRect = intersectRects(subjectRect, initialHit.rect)\n if (slicedSubjectRect) {\n adjustedPoint = getRectCenter(slicedSubjectRect)\n }\n }\n\n this.coordAdjust = diffPoints(adjustedPoint, origPoint)\n } else {\n this.coordAdjust = { left: 0, top: 0 }\n }\n }\n\n handleDragStart = (ev: PointerDragEvent) => {\n this.emitter.trigger('dragstart', ev)\n this.handleMove(ev, true) // force = fire even if initially null\n }\n\n handleDragMove = (ev: PointerDragEvent) => {\n this.emitter.trigger('dragmove', ev)\n this.handleMove(ev)\n }\n\n handlePointerUp = (ev: PointerDragEvent) => {\n this.releaseHits()\n this.emitter.trigger('pointerup', ev)\n }\n\n handleDragEnd = (ev: PointerDragEvent) => {\n if (this.movingHit) {\n this.emitter.trigger('hitupdate', null, true, ev)\n }\n\n this.finalHit = this.movingHit\n this.movingHit = null\n this.emitter.trigger('dragend', ev)\n }\n\n handleMove(ev: PointerDragEvent, forceHandle?: boolean) {\n let hit = this.queryHitForOffset(\n ev.pageX + this.coordAdjust!.left,\n ev.pageY + this.coordAdjust!.top\n )\n\n if (forceHandle || !isHitsEqual(this.movingHit, hit)) {\n this.movingHit = hit\n this.emitter.trigger('hitupdate', hit, false, ev)\n }\n }\n\n prepareHits() {\n this.offsetTrackers = mapHash(this.droppableStore, function(interactionSettings) {\n interactionSettings.component.buildPositionCaches()\n\n return new OffsetTracker(interactionSettings.el)\n })\n }\n\n releaseHits() {\n let { offsetTrackers } = this\n\n for (let id in offsetTrackers) {\n offsetTrackers[id].destroy()\n }\n\n this.offsetTrackers = {}\n }\n\n queryHitForOffset(offsetLeft: number, offsetTop: number): Hit | null {\n let { droppableStore, offsetTrackers } = this\n let bestHit: Hit | null = null\n\n for (let id in droppableStore) {\n let component = droppableStore[id].component\n let offsetTracker = offsetTrackers[id]\n\n if (offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {\n let originLeft = offsetTracker.computeLeft()\n let originTop = offsetTracker.computeTop()\n let positionLeft = offsetLeft - originLeft\n let positionTop = offsetTop - originTop\n let { origRect } = offsetTracker\n let width = origRect.right - origRect.left\n let height = origRect.bottom - origRect.top\n\n if (\n // must be within the element's bounds\n positionLeft >= 0 && positionLeft < width &&\n positionTop >= 0 && positionTop < height\n ) {\n let hit = component.queryHit(positionLeft, positionTop, width, height)\n\n if (\n hit &&\n (\n // make sure the hit is within activeRange, meaning it's not a deal cell\n !component.props.dateProfile || // hack for DayTile\n rangeContainsRange(component.props.dateProfile.activeRange, hit.dateSpan.range)\n ) &&\n (!bestHit || hit.layer > bestHit.layer)\n ) {\n\n // TODO: better way to re-orient rectangle\n hit.rect.left += originLeft\n hit.rect.right += originLeft\n hit.rect.top += originTop\n hit.rect.bottom += originTop\n\n bestHit = hit\n }\n }\n }\n }\n\n return bestHit\n }\n\n}\n\nexport function isHitsEqual(hit0: Hit | null, hit1: Hit | null): boolean {\n if (!hit0 && !hit1) {\n return true\n }\n\n if (Boolean(hit0) !== Boolean(hit1)) {\n return false\n }\n\n return isDateSpansEqual(hit0!.dateSpan, hit1!.dateSpan)\n}\n","import { PointerDragEvent, Interaction, InteractionSettings, interactionSettingsToStore } from '@fullcalendar/core'\nimport FeaturefulElementDragging from '../dnd/FeaturefulElementDragging'\nimport HitDragging, { isHitsEqual } from './HitDragging'\n\n/*\nMonitors when the user clicks on a specific date/time of a component.\nA pointerdown+pointerup on the same \"hit\" constitutes a click.\n*/\nexport default class DateClicking extends Interaction {\n\n dragging: FeaturefulElementDragging\n hitDragging: HitDragging\n\n constructor(settings: InteractionSettings) {\n super(settings)\n let { component } = settings\n\n // we DO want to watch pointer moves because otherwise finalHit won't get populated\n this.dragging = new FeaturefulElementDragging(component.el)\n this.dragging.autoScroller.isEnabled = false\n\n let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsToStore(settings))\n hitDragging.emitter.on('pointerdown', this.handlePointerDown)\n hitDragging.emitter.on('dragend', this.handleDragEnd)\n }\n\n destroy() {\n this.dragging.destroy()\n }\n\n handlePointerDown = (ev: PointerDragEvent) => {\n let { dragging } = this\n\n // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired\n dragging.setIgnoreMove(\n !this.component.isValidDateDownEl(dragging.pointer.downEl!)\n )\n }\n\n // won't even fire if moving was ignored\n handleDragEnd = (ev: PointerDragEvent) => {\n let { component } = this\n let { pointer } = this.dragging\n\n if (!pointer.wasTouchScroll) {\n let { initialHit, finalHit } = this.hitDragging\n\n if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {\n component.calendar.triggerDateClick(\n initialHit.dateSpan,\n initialHit.dayEl,\n component.view,\n ev.origEvent\n )\n }\n }\n }\n\n}\n","import {\n compareNumbers, enableCursor, disableCursor, DateComponent, Hit,\n DateSpan, PointerDragEvent, dateSelectionJoinTransformer,\n Interaction, InteractionSettings, interactionSettingsToStore\n} from '@fullcalendar/core'\nimport HitDragging from './HitDragging'\nimport FeaturefulElementDragging from '../dnd/FeaturefulElementDragging'\nimport { __assign } from 'tslib'\n\n/*\nTracks when the user selects a portion of time of a component,\nconstituted by a drag over date cells, with a possible delay at the beginning of the drag.\n*/\nexport default class DateSelecting extends Interaction {\n\n dragging: FeaturefulElementDragging\n hitDragging: HitDragging\n dragSelection: DateSpan | null = null\n\n constructor(settings: InteractionSettings) {\n super(settings)\n let { component } = settings\n\n let dragging = this.dragging = new FeaturefulElementDragging(component.el)\n dragging.touchScrollAllowed = false\n dragging.minDistance = component.opt('selectMinDistance') || 0\n dragging.autoScroller.isEnabled = component.opt('dragScroll')\n\n let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsToStore(settings))\n hitDragging.emitter.on('pointerdown', this.handlePointerDown)\n hitDragging.emitter.on('dragstart', this.handleDragStart)\n hitDragging.emitter.on('hitupdate', this.handleHitUpdate)\n hitDragging.emitter.on('pointerup', this.handlePointerUp)\n }\n\n destroy() {\n this.dragging.destroy()\n }\n\n handlePointerDown = (ev: PointerDragEvent) => {\n let { component, dragging } = this\n let canSelect = component.opt('selectable') &&\n component.isValidDateDownEl(ev.origEvent.target as HTMLElement)\n\n // don't bother to watch expensive moves if component won't do selection\n dragging.setIgnoreMove(!canSelect)\n\n // if touch, require user to hold down\n dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null\n }\n\n handleDragStart = (ev: PointerDragEvent) => {\n this.component.calendar.unselect(ev) // unselect previous selections\n }\n\n handleHitUpdate = (hit: Hit | null, isFinal: boolean) => {\n let calendar = this.component.calendar\n let dragSelection: DateSpan | null = null\n let isInvalid = false\n\n if (hit) {\n dragSelection = joinHitsIntoSelection(\n this.hitDragging.initialHit!,\n hit,\n calendar.pluginSystem.hooks.dateSelectionTransformers\n )\n\n if (!dragSelection || !this.component.isDateSelectionValid(dragSelection)) {\n isInvalid = true\n dragSelection = null\n }\n }\n\n if (dragSelection) {\n calendar.dispatch({ type: 'SELECT_DATES', selection: dragSelection })\n } else if (!isFinal) { // only unselect if moved away while dragging\n calendar.dispatch({ type: 'UNSELECT_DATES' })\n }\n\n if (!isInvalid) {\n enableCursor()\n } else {\n disableCursor()\n }\n\n if (!isFinal) {\n this.dragSelection = dragSelection // only clear if moved away from all hits while dragging\n }\n }\n\n handlePointerUp = (pev: PointerDragEvent) => {\n if (this.dragSelection) {\n\n // selection is already rendered, so just need to report selection\n this.component.calendar.triggerDateSelect(this.dragSelection, pev)\n\n this.dragSelection = null\n }\n }\n\n}\n\nfunction getComponentTouchDelay(component: DateComponent