UNPKG

react-dnd

Version:
221 lines (186 loc) 280 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react")); else if(typeof define === 'function' && define.amd) define(["react"], factory); else if(typeof exports === 'object') exports["ReactDnD"] = factory(require("react")); else root["ReactDnD"] = factory(root["React"]); })(window, function(__WEBPACK_EXTERNAL_MODULE_react__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./src/index.ts"); /******/ }) /************************************************************************/ /******/ ({ /***/ "../../node_modules/asap/browser-asap.js": /*!*********************************************************************************!*\ !*** /Users/christrevino/workspace/react-dnd/node_modules/asap/browser-asap.js ***! \*********************************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\n// rawAsap provides everything we need except exception management.\nvar rawAsap = __webpack_require__(/*! ./raw */ \"../../node_modules/asap/browser-raw.js\");\n// RawTasks are recycled to reduce GC churn.\nvar freeTasks = [];\n// We queue errors to ensure they are thrown in right order (FIFO).\n// Array-as-queue is good enough here, since we are just dealing with exceptions.\nvar pendingErrors = [];\nvar requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError);\n\nfunction throwFirstError() {\n if (pendingErrors.length) {\n throw pendingErrors.shift();\n }\n}\n\n/**\n * Calls a task as soon as possible after returning, in its own event, with priority\n * over other events like animation, reflow, and repaint. An error thrown from an\n * event will not interrupt, nor even substantially slow down the processing of\n * other events, but will be rather postponed to a lower priority event.\n * @param {{call}} task A callable object, typically a function that takes no\n * arguments.\n */\nmodule.exports = asap;\nfunction asap(task) {\n var rawTask;\n if (freeTasks.length) {\n rawTask = freeTasks.pop();\n } else {\n rawTask = new RawTask();\n }\n rawTask.task = task;\n rawAsap(rawTask);\n}\n\n// We wrap tasks with recyclable task objects. A task object implements\n// `call`, just like a function.\nfunction RawTask() {\n this.task = null;\n}\n\n// The sole purpose of wrapping the task is to catch the exception and recycle\n// the task object after its single use.\nRawTask.prototype.call = function () {\n try {\n this.task.call();\n } catch (error) {\n if (asap.onerror) {\n // This hook exists purely for testing purposes.\n // Its name will be periodically randomized to break any code that\n // depends on its existence.\n asap.onerror(error);\n } else {\n // In a web browser, exceptions are not fatal. However, to avoid\n // slowing down the queue of pending tasks, we rethrow the error in a\n // lower priority turn.\n pendingErrors.push(error);\n requestErrorThrow();\n }\n } finally {\n this.task = null;\n freeTasks[freeTasks.length] = this;\n }\n};\n\n\n//# sourceURL=webpack://ReactDnD//Users/christrevino/workspace/react-dnd/node_modules/asap/browser-asap.js?"); /***/ }), /***/ "../../node_modules/asap/browser-raw.js": /*!********************************************************************************!*\ !*** /Users/christrevino/workspace/react-dnd/node_modules/asap/browser-raw.js ***! \********************************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("/* WEBPACK VAR INJECTION */(function(global) {\n\n// Use the fastest means possible to execute a task in its own turn, with\n// priority over other events including IO, animation, reflow, and redraw\n// events in browsers.\n//\n// An exception thrown by a task will permanently interrupt the processing of\n// subsequent tasks. The higher level `asap` function ensures that if an\n// exception is thrown by a task, that the task queue will continue flushing as\n// soon as possible, but if you use `rawAsap` directly, you are responsible to\n// either ensure that no exceptions are thrown from your task, or to manually\n// call `rawAsap.requestFlush` if an exception is thrown.\nmodule.exports = rawAsap;\nfunction rawAsap(task) {\n if (!queue.length) {\n requestFlush();\n flushing = true;\n }\n // Equivalent to push, but avoids a function call.\n queue[queue.length] = task;\n}\n\nvar queue = [];\n// Once a flush has been requested, no further calls to `requestFlush` are\n// necessary until the next `flush` completes.\nvar flushing = false;\n// `requestFlush` is an implementation-specific method that attempts to kick\n// off a `flush` event as quickly as possible. `flush` will attempt to exhaust\n// the event queue before yielding to the browser's own event loop.\nvar requestFlush;\n// The position of the next task to execute in the task queue. This is\n// preserved between calls to `flush` so that it can be resumed if\n// a task throws an exception.\nvar index = 0;\n// If a task schedules additional tasks recursively, the task queue can grow\n// unbounded. To prevent memory exhaustion, the task queue will periodically\n// truncate already-completed tasks.\nvar capacity = 1024;\n\n// The flush function processes all tasks that have been scheduled with\n// `rawAsap` unless and until one of those tasks throws an exception.\n// If a task throws an exception, `flush` ensures that its state will remain\n// consistent and will resume where it left off when called again.\n// However, `flush` does not make any arrangements to be called again if an\n// exception is thrown.\nfunction flush() {\n while (index < queue.length) {\n var currentIndex = index;\n // Advance the index before calling the task. This ensures that we will\n // begin flushing on the next task the task throws an error.\n index = index + 1;\n queue[currentIndex].call();\n // Prevent leaking memory for long chains of recursive calls to `asap`.\n // If we call `asap` within tasks scheduled by `asap`, the queue will\n // grow, but to avoid an O(n) walk for every task we execute, we don't\n // shift tasks off the queue after they have been executed.\n // Instead, we periodically shift 1024 tasks off the queue.\n if (index > capacity) {\n // Manually shift all values starting at the index back to the\n // beginning of the queue.\n for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) {\n queue[scan] = queue[scan + index];\n }\n queue.length -= index;\n index = 0;\n }\n }\n queue.length = 0;\n index = 0;\n flushing = false;\n}\n\n// `requestFlush` is implemented using a strategy based on data collected from\n// every available SauceLabs Selenium web driver worker at time of writing.\n// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593\n\n// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that\n// have WebKitMutationObserver but not un-prefixed MutationObserver.\n// Must use `global` or `self` instead of `window` to work in both frames and web\n// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.\n\n/* globals self */\nvar scope = typeof global !== \"undefined\" ? global : self;\nvar BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;\n\n// MutationObservers are desirable because they have high priority and work\n// reliably everywhere they are implemented.\n// They are implemented in all modern browsers.\n//\n// - Android 4-4.3\n// - Chrome 26-34\n// - Firefox 14-29\n// - Internet Explorer 11\n// - iPad Safari 6-7.1\n// - iPhone Safari 7-7.1\n// - Safari 6-7\nif (typeof BrowserMutationObserver === \"function\") {\n requestFlush = makeRequestCallFromMutationObserver(flush);\n\n// MessageChannels are desirable because they give direct access to the HTML\n// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera\n// 11-12, and in web workers in many engines.\n// Although message channels yield to any queued rendering and IO tasks, they\n// would be better than imposing the 4ms delay of timers.\n// However, they do not work reliably in Internet Explorer or Safari.\n\n// Internet Explorer 10 is the only browser that has setImmediate but does\n// not have MutationObservers.\n// Although setImmediate yields to the browser's renderer, it would be\n// preferrable to falling back to setTimeout since it does not have\n// the minimum 4ms penalty.\n// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and\n// Desktop to a lesser extent) that renders both setImmediate and\n// MessageChannel useless for the purposes of ASAP.\n// https://github.com/kriskowal/q/issues/396\n\n// Timers are implemented universally.\n// We fall back to timers in workers in most engines, and in foreground\n// contexts in the following browsers.\n// However, note that even this simple case requires nuances to operate in a\n// broad spectrum of browsers.\n//\n// - Firefox 3-13\n// - Internet Explorer 6-9\n// - iPad Safari 4.3\n// - Lynx 2.8.7\n} else {\n requestFlush = makeRequestCallFromTimer(flush);\n}\n\n// `requestFlush` requests that the high priority event queue be flushed as\n// soon as possible.\n// This is useful to prevent an error thrown in a task from stalling the event\n// queue if the exception handled by Node.js’s\n// `process.on(\"uncaughtException\")` or by a domain.\nrawAsap.requestFlush = requestFlush;\n\n// To request a high priority event, we induce a mutation observer by toggling\n// the text of a text node between \"1\" and \"-1\".\nfunction makeRequestCallFromMutationObserver(callback) {\n var toggle = 1;\n var observer = new BrowserMutationObserver(callback);\n var node = document.createTextNode(\"\");\n observer.observe(node, {characterData: true});\n return function requestCall() {\n toggle = -toggle;\n node.data = toggle;\n };\n}\n\n// The message channel technique was discovered by Malte Ubl and was the\n// original foundation for this library.\n// http://www.nonblocking.io/2011/06/windownexttick.html\n\n// Safari 6.0.5 (at least) intermittently fails to create message ports on a\n// page's first load. Thankfully, this version of Safari supports\n// MutationObservers, so we don't need to fall back in that case.\n\n// function makeRequestCallFromMessageChannel(callback) {\n// var channel = new MessageChannel();\n// channel.port1.onmessage = callback;\n// return function requestCall() {\n// channel.port2.postMessage(0);\n// };\n// }\n\n// For reasons explained above, we are also unable to use `setImmediate`\n// under any circumstances.\n// Even if we were, there is another bug in Internet Explorer 10.\n// It is not sufficient to assign `setImmediate` to `requestFlush` because\n// `setImmediate` must be called *by name* and therefore must be wrapped in a\n// closure.\n// Never forget.\n\n// function makeRequestCallFromSetImmediate(callback) {\n// return function requestCall() {\n// setImmediate(callback);\n// };\n// }\n\n// Safari 6.0 has a problem where timers will get lost while the user is\n// scrolling. This problem does not impact ASAP because Safari 6.0 supports\n// mutation observers, so that implementation is used instead.\n// However, if we ever elect to use timers in Safari, the prevalent work-around\n// is to add a scroll event listener that calls for a flush.\n\n// `setTimeout` does not call the passed callback if the delay is less than\n// approximately 7 in web workers in Firefox 8 through 18, and sometimes not\n// even then.\n\nfunction makeRequestCallFromTimer(callback) {\n return function requestCall() {\n // We dispatch a timeout with a specified delay of 0 for engines that\n // can reliably accommodate that request. This will usually be snapped\n // to a 4 milisecond delay, but once we're flushing, there's no delay\n // between events.\n var timeoutHandle = setTimeout(handleTimer, 0);\n // However, since this timer gets frequently dropped in Firefox\n // workers, we enlist an interval handle that will try to fire\n // an event 20 times per second until it succeeds.\n var intervalHandle = setInterval(handleTimer, 50);\n\n function handleTimer() {\n // Whichever timer succeeds will cancel both timers and\n // execute the callback.\n clearTimeout(timeoutHandle);\n clearInterval(intervalHandle);\n callback();\n }\n };\n}\n\n// This is for `asap.js` only.\n// Its name will be periodically randomized to break any code that depends on\n// its existence.\nrawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;\n\n// ASAP was originally a nextTick shim included in Q. This was factored out\n// into this ASAP package. It was later adapted to RSVP which made further\n// amendments. These decisions, particularly to marginalize MessageChannel and\n// to capture the MutationObserver implementation in a closure, were integrated\n// back into ASAP proper.\n// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"../../node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://ReactDnD//Users/christrevino/workspace/react-dnd/node_modules/asap/browser-raw.js?"); /***/ }), /***/ "../../node_modules/shallowequal/index.js": /*!**********************************************************************************!*\ !*** /Users/christrevino/workspace/react-dnd/node_modules/shallowequal/index.js ***! \**********************************************************************************/ /*! no static exports found */ /***/ (function(module, exports) { eval("module.exports = function shallowEqual(objA, objB, compare, compareContext) {\n\n var ret = compare ? compare.call(compareContext, objA, objB) : void 0;\n\n if(ret !== void 0) {\n return !!ret;\n }\n\n if(objA === objB) {\n return true;\n }\n\n if(typeof objA !== 'object' || !objA ||\n typeof objB !== 'object' || !objB) {\n return false;\n }\n\n var keysA = Object.keys(objA);\n var keysB = Object.keys(objB);\n\n if(keysA.length !== keysB.length) {\n return false;\n }\n\n var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);\n\n // Test for A's keys different from B.\n for(var idx = 0; idx < keysA.length; idx++) {\n\n var key = keysA[idx];\n\n if(!bHasOwnProperty(key)) {\n return false;\n }\n\n var valueA = objA[key];\n var valueB = objB[key];\n\n ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;\n\n if(ret === false ||\n ret === void 0 && valueA !== valueB) {\n return false;\n }\n\n }\n\n return true;\n\n};\n\n\n//# sourceURL=webpack://ReactDnD//Users/christrevino/workspace/react-dnd/node_modules/shallowequal/index.js?"); /***/ }), /***/ "../../node_modules/webpack/buildin/global.js": /*!***********************************!*\ !*** (webpack)/buildin/global.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports) { eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://ReactDnD/(webpack)/buildin/global.js?"); /***/ }), /***/ "../../node_modules/webpack/buildin/harmony-module.js": /*!*******************************************!*\ !*** (webpack)/buildin/harmony-module.js ***! \*******************************************/ /*! no static exports found */ /***/ (function(module, exports) { eval("module.exports = function(originalModule) {\n\tif (!originalModule.webpackPolyfill) {\n\t\tvar module = Object.create(originalModule);\n\t\t// module.parent = undefined by default\n\t\tif (!module.children) module.children = [];\n\t\tObject.defineProperty(module, \"loaded\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.l;\n\t\t\t}\n\t\t});\n\t\tObject.defineProperty(module, \"id\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.i;\n\t\t\t}\n\t\t});\n\t\tObject.defineProperty(module, \"exports\", {\n\t\t\tenumerable: true\n\t\t});\n\t\tmodule.webpackPolyfill = 1;\n\t}\n\treturn module;\n};\n\n\n//# sourceURL=webpack://ReactDnD/(webpack)/buildin/harmony-module.js?"); /***/ }), /***/ "../dnd-core/lib/DragDropManagerImpl.js": /*!**********************************************!*\ !*** ../dnd-core/lib/DragDropManagerImpl.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar redux_1 = __webpack_require__(/*! redux */ \"../dnd-core/node_modules/redux/es/redux.js\");\nvar reducers_1 = __importDefault(__webpack_require__(/*! ./reducers */ \"../dnd-core/lib/reducers/index.js\"));\nvar dragDrop_1 = __importDefault(__webpack_require__(/*! ./actions/dragDrop */ \"../dnd-core/lib/actions/dragDrop.js\"));\nvar DragDropMonitorImpl_1 = __importDefault(__webpack_require__(/*! ./DragDropMonitorImpl */ \"../dnd-core/lib/DragDropMonitorImpl.js\"));\nvar HandlerRegistryImpl_1 = __importDefault(__webpack_require__(/*! ./HandlerRegistryImpl */ \"../dnd-core/lib/HandlerRegistryImpl.js\"));\nvar DragDropManagerImpl = /** @class */function () {\n function DragDropManagerImpl(createBackend, context) {\n if (context === void 0) {\n context = {};\n }\n this.context = context;\n this.isSetUp = false;\n var store = redux_1.createStore(reducers_1.default);\n this.store = store;\n this.monitor = new DragDropMonitorImpl_1.default(store, new HandlerRegistryImpl_1.default(store));\n this.backend = createBackend(this);\n store.subscribe(this.handleRefCountChange.bind(this));\n }\n DragDropManagerImpl.prototype.getContext = function () {\n return this.context;\n };\n DragDropManagerImpl.prototype.getMonitor = function () {\n return this.monitor;\n };\n DragDropManagerImpl.prototype.getBackend = function () {\n return this.backend;\n };\n DragDropManagerImpl.prototype.getRegistry = function () {\n return this.monitor.registry;\n };\n DragDropManagerImpl.prototype.getActions = function () {\n var manager = this;\n var dispatch = this.store.dispatch;\n function bindActionCreator(actionCreator) {\n return function () {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n var action = actionCreator.apply(manager, args);\n if (typeof action !== 'undefined') {\n dispatch(action);\n }\n };\n }\n var actions = dragDrop_1.default(this);\n return Object.keys(actions).reduce(function (boundActions, key) {\n var action = actions[key];\n boundActions[key] = bindActionCreator(action);\n return boundActions;\n }, {});\n };\n DragDropManagerImpl.prototype.dispatch = function (action) {\n this.store.dispatch(action);\n };\n DragDropManagerImpl.prototype.handleRefCountChange = function () {\n var shouldSetUp = this.store.getState().refCount > 0;\n if (shouldSetUp && !this.isSetUp) {\n this.backend.setup();\n this.isSetUp = true;\n } else if (!shouldSetUp && this.isSetUp) {\n this.backend.teardown();\n this.isSetUp = false;\n }\n };\n return DragDropManagerImpl;\n}();\nexports.default = DragDropManagerImpl;\n//# sourceMappingURL=DragDropManagerImpl.js.map\n\n//# sourceURL=webpack://ReactDnD/../dnd-core/lib/DragDropManagerImpl.js?"); /***/ }), /***/ "../dnd-core/lib/DragDropMonitorImpl.js": /*!**********************************************!*\ !*** ../dnd-core/lib/DragDropMonitorImpl.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar invariant_1 = __importDefault(__webpack_require__(/*! invariant */ \"./node_modules/invariant/browser.js\"));\nvar isArray_1 = __importDefault(__webpack_require__(/*! lodash/isArray */ \"./node_modules/lodash/isArray.js\"));\nvar matchesType_1 = __importDefault(__webpack_require__(/*! ./utils/matchesType */ \"../dnd-core/lib/utils/matchesType.js\"));\nvar coords_1 = __webpack_require__(/*! ./utils/coords */ \"../dnd-core/lib/utils/coords.js\");\nvar dirtiness_1 = __webpack_require__(/*! ./utils/dirtiness */ \"../dnd-core/lib/utils/dirtiness.js\");\nvar DragDropMonitorImpl = /** @class */function () {\n function DragDropMonitorImpl(store, registry) {\n this.store = store;\n this.registry = registry;\n }\n DragDropMonitorImpl.prototype.subscribeToStateChange = function (listener, options) {\n var _this = this;\n if (options === void 0) {\n options = { handlerIds: undefined };\n }\n var handlerIds = options.handlerIds;\n invariant_1.default(typeof listener === 'function', 'listener must be a function.');\n invariant_1.default(typeof handlerIds === 'undefined' || isArray_1.default(handlerIds), 'handlerIds, when specified, must be an array of strings.');\n var prevStateId = this.store.getState().stateId;\n var handleChange = function () {\n var state = _this.store.getState();\n var currentStateId = state.stateId;\n try {\n var canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !dirtiness_1.areDirty(state.dirtyHandlerIds, handlerIds);\n if (!canSkipListener) {\n listener();\n }\n } finally {\n prevStateId = currentStateId;\n }\n };\n return this.store.subscribe(handleChange);\n };\n DragDropMonitorImpl.prototype.subscribeToOffsetChange = function (listener) {\n var _this = this;\n invariant_1.default(typeof listener === 'function', 'listener must be a function.');\n var previousState = this.store.getState().dragOffset;\n var handleChange = function () {\n var nextState = _this.store.getState().dragOffset;\n if (nextState === previousState) {\n return;\n }\n previousState = nextState;\n listener();\n };\n return this.store.subscribe(handleChange);\n };\n DragDropMonitorImpl.prototype.canDragSource = function (sourceId) {\n var source = this.registry.getSource(sourceId);\n invariant_1.default(source, 'Expected to find a valid source.');\n if (this.isDragging()) {\n return false;\n }\n return source.canDrag(this, sourceId);\n };\n DragDropMonitorImpl.prototype.canDropOnTarget = function (targetId) {\n var target = this.registry.getTarget(targetId);\n invariant_1.default(target, 'Expected to find a valid target.');\n if (!this.isDragging() || this.didDrop()) {\n return false;\n }\n var targetType = this.registry.getTargetType(targetId);\n var draggedItemType = this.getItemType();\n return matchesType_1.default(targetType, draggedItemType) && target.canDrop(this, targetId);\n };\n DragDropMonitorImpl.prototype.isDragging = function () {\n return Boolean(this.getItemType());\n };\n DragDropMonitorImpl.prototype.isDraggingSource = function (sourceId) {\n var source = this.registry.getSource(sourceId, true);\n invariant_1.default(source, 'Expected to find a valid source.');\n if (!this.isDragging() || !this.isSourcePublic()) {\n return false;\n }\n var sourceType = this.registry.getSourceType(sourceId);\n var draggedItemType = this.getItemType();\n if (sourceType !== draggedItemType) {\n return false;\n }\n return source.isDragging(this, sourceId);\n };\n DragDropMonitorImpl.prototype.isOverTarget = function (targetId, options) {\n if (options === void 0) {\n options = { shallow: false };\n }\n var shallow = options.shallow;\n if (!this.isDragging()) {\n return false;\n }\n var targetType = this.registry.getTargetType(targetId);\n var draggedItemType = this.getItemType();\n if (draggedItemType && !matchesType_1.default(targetType, draggedItemType)) {\n return false;\n }\n var targetIds = this.getTargetIds();\n if (!targetIds.length) {\n return false;\n }\n var index = targetIds.indexOf(targetId);\n if (shallow) {\n return index === targetIds.length - 1;\n } else {\n return index > -1;\n }\n };\n DragDropMonitorImpl.prototype.getItemType = function () {\n return this.store.getState().dragOperation.itemType;\n };\n DragDropMonitorImpl.prototype.getItem = function () {\n return this.store.getState().dragOperation.item;\n };\n DragDropMonitorImpl.prototype.getSourceId = function () {\n return this.store.getState().dragOperation.sourceId;\n };\n DragDropMonitorImpl.prototype.getTargetIds = function () {\n return this.store.getState().dragOperation.targetIds;\n };\n DragDropMonitorImpl.prototype.getDropResult = function () {\n return this.store.getState().dragOperation.dropResult;\n };\n DragDropMonitorImpl.prototype.didDrop = function () {\n return this.store.getState().dragOperation.didDrop;\n };\n DragDropMonitorImpl.prototype.isSourcePublic = function () {\n return this.store.getState().dragOperation.isSourcePublic;\n };\n DragDropMonitorImpl.prototype.getInitialClientOffset = function () {\n return this.store.getState().dragOffset.initialClientOffset;\n };\n DragDropMonitorImpl.prototype.getInitialSourceClientOffset = function () {\n return this.store.getState().dragOffset.initialSourceClientOffset;\n };\n DragDropMonitorImpl.prototype.getClientOffset = function () {\n return this.store.getState().dragOffset.clientOffset;\n };\n DragDropMonitorImpl.prototype.getSourceClientOffset = function () {\n return coords_1.getSourceClientOffset(this.store.getState().dragOffset);\n };\n DragDropMonitorImpl.prototype.getDifferenceFromInitialOffset = function () {\n return coords_1.getDifferenceFromInitialOffset(this.store.getState().dragOffset);\n };\n return DragDropMonitorImpl;\n}();\nexports.default = DragDropMonitorImpl;\n//# sourceMappingURL=DragDropMonitorImpl.js.map\n\n//# sourceURL=webpack://ReactDnD/../dnd-core/lib/DragDropMonitorImpl.js?"); /***/ }), /***/ "../dnd-core/lib/HandlerRegistryImpl.js": /*!**********************************************!*\ !*** ../dnd-core/lib/HandlerRegistryImpl.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar invariant_1 = __importDefault(__webpack_require__(/*! invariant */ \"./node_modules/invariant/browser.js\"));\nvar registry_1 = __webpack_require__(/*! ./actions/registry */ \"../dnd-core/lib/actions/registry.js\");\nvar getNextUniqueId_1 = __importDefault(__webpack_require__(/*! ./utils/getNextUniqueId */ \"../dnd-core/lib/utils/getNextUniqueId.js\"));\nvar interfaces_1 = __webpack_require__(/*! ./interfaces */ \"../dnd-core/lib/interfaces.js\");\nvar contracts_1 = __webpack_require__(/*! ./contracts */ \"../dnd-core/lib/contracts.js\");\n// @ts-ignore\nvar asap_1 = __importDefault(__webpack_require__(/*! asap */ \"../../node_modules/asap/browser-asap.js\"));\nfunction getNextHandlerId(role) {\n var id = getNextUniqueId_1.default().toString();\n switch (role) {\n case interfaces_1.HandlerRole.SOURCE:\n return \"S\" + id;\n case interfaces_1.HandlerRole.TARGET:\n return \"T\" + id;\n default:\n throw new Error(\"Unknown Handler Role: \" + role);\n }\n}\nfunction parseRoleFromHandlerId(handlerId) {\n switch (handlerId[0]) {\n case 'S':\n return interfaces_1.HandlerRole.SOURCE;\n case 'T':\n return interfaces_1.HandlerRole.TARGET;\n default:\n invariant_1.default(false, \"Cannot parse handler ID: \" + handlerId);\n }\n}\nfunction mapContainsValue(map, searchValue) {\n var entries = map.entries();\n var isDone = false;\n do {\n var _a = entries.next(),\n done = _a.done,\n _b = _a.value,\n key = _b[0],\n value = _b[1];\n if (value === searchValue) {\n return true;\n }\n isDone = done;\n } while (!isDone);\n return false;\n}\nvar HandlerRegistryImpl = /** @class */function () {\n function HandlerRegistryImpl(store) {\n this.store = store;\n this.types = new Map();\n this.dragSources = new Map();\n this.dropTargets = new Map();\n this.pinnedSourceId = null;\n this.pinnedSource = null;\n }\n HandlerRegistryImpl.prototype.addSource = function (type, source) {\n contracts_1.validateType(type);\n contracts_1.validateSourceContract(source);\n var sourceId = this.addHandler(interfaces_1.HandlerRole.SOURCE, type, source);\n this.store.dispatch(registry_1.addSource(sourceId));\n return sourceId;\n };\n HandlerRegistryImpl.prototype.addTarget = function (type, target) {\n contracts_1.validateType(type, true);\n contracts_1.validateTargetContract(target);\n var targetId = this.addHandler(interfaces_1.HandlerRole.TARGET, type, target);\n this.store.dispatch(registry_1.addTarget(targetId));\n return targetId;\n };\n HandlerRegistryImpl.prototype.containsHandler = function (handler) {\n return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler);\n };\n HandlerRegistryImpl.prototype.getSource = function (sourceId, includePinned) {\n if (includePinned === void 0) {\n includePinned = false;\n }\n invariant_1.default(this.isSourceId(sourceId), 'Expected a valid source ID.');\n var isPinned = includePinned && sourceId === this.pinnedSourceId;\n var source = isPinned ? this.pinnedSource : this.dragSources.get(sourceId);\n return source;\n };\n HandlerRegistryImpl.prototype.getTarget = function (targetId) {\n invariant_1.default(this.isTargetId(targetId), 'Expected a valid target ID.');\n return this.dropTargets.get(targetId);\n };\n HandlerRegistryImpl.prototype.getSourceType = function (sourceId) {\n invariant_1.default(this.isSourceId(sourceId), 'Expected a valid source ID.');\n return this.types.get(sourceId);\n };\n HandlerRegistryImpl.prototype.getTargetType = function (targetId) {\n invariant_1.default(this.isTargetId(targetId), 'Expected a valid target ID.');\n return this.types.get(targetId);\n };\n HandlerRegistryImpl.prototype.isSourceId = function (handlerId) {\n var role = parseRoleFromHandlerId(handlerId);\n return role === interfaces_1.HandlerRole.SOURCE;\n };\n HandlerRegistryImpl.prototype.isTargetId = function (handlerId) {\n var role = parseRoleFromHandlerId(handlerId);\n return role === interfaces_1.HandlerRole.TARGET;\n };\n HandlerRegistryImpl.prototype.removeSource = function (sourceId) {\n var _this = this;\n invariant_1.default(this.getSource(sourceId), 'Expected an existing source.');\n this.store.dispatch(registry_1.removeSource(sourceId));\n asap_1.default(function () {\n _this.dragSources.delete(sourceId);\n _this.types.delete(sourceId);\n });\n };\n HandlerRegistryImpl.prototype.removeTarget = function (targetId) {\n invariant_1.default(this.getTarget(targetId), 'Expected an existing target.');\n this.store.dispatch(registry_1.removeTarget(targetId));\n this.dropTargets.delete(targetId);\n this.types.delete(targetId);\n };\n HandlerRegistryImpl.prototype.pinSource = function (sourceId) {\n var source = this.getSource(sourceId);\n invariant_1.default(source, 'Expected an existing source.');\n this.pinnedSourceId = sourceId;\n this.pinnedSource = source;\n };\n HandlerRegistryImpl.prototype.unpinSource = function () {\n invariant_1.default(this.pinnedSource, 'No source is pinned at the time.');\n this.pinnedSourceId = null;\n this.pinnedSource = null;\n };\n HandlerRegistryImpl.prototype.addHandler = function (role, type, handler) {\n var id = getNextHandlerId(role);\n this.types.set(id, type);\n if (role === interfaces_1.HandlerRole.SOURCE) {\n this.dragSources.set(id, handler);\n } else if (role === interfaces_1.HandlerRole.TARGET) {\n this.dropTargets.set(id, handler);\n }\n return id;\n };\n return HandlerRegistryImpl;\n}();\nexports.default = HandlerRegistryImpl;\n//# sourceMappingURL=HandlerRegistryImpl.js.map\n\n//# sourceURL=webpack://ReactDnD/../dnd-core/lib/HandlerRegistryImpl.js?"); /***/ }), /***/ "../dnd-core/lib/actions/dragDrop.js": /*!*******************************************!*\ !*** ../dnd-core/lib/actions/dragDrop.js ***! \*******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nvar __assign = this && this.__assign || Object.assign || function (t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n};\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar invariant_1 = __importDefault(__webpack_require__(/*! invariant */ \"./node_modules/invariant/browser.js\"));\nvar isArray_1 = __importDefault(__webpack_require__(/*! lodash/isArray */ \"./node_modules/lodash/isArray.js\"));\nvar isObject_1 = __importDefault(__webpack_require__(/*! lodash/isObject */ \"./node_modules/lodash/isObject.js\"));\nvar matchesType_1 = __importDefault(__webpack_require__(/*! ../utils/matchesType */ \"../dnd-core/lib/utils/matchesType.js\"));\nexports.BEGIN_DRAG = 'dnd-core/BEGIN_DRAG';\nexports.PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE';\nexports.HOVER = 'dnd-core/HOVER';\nexports.DROP = 'dnd-core/DROP';\nexports.END_DRAG = 'dnd-core/END_DRAG';\nfunction createDragDropActions(manager) {\n return {\n beginDrag: function (sourceIds, _a) {\n if (sourceIds === void 0) {\n sourceIds = [];\n }\n var _b = _a === void 0 ? {\n publishSource: true\n } : _a,\n publishSource = _b.publishSource,\n clientOffset = _b.clientOffset,\n getSourceClientOffset = _b.getSourceClientOffset;\n var monitor = manager.getMonitor();\n var registry = manager.getRegistry();\n invariant_1.default(!monitor.isDragging(), 'Cannot call beginDrag while dragging.');\n for (var _i = 0, sourceIds_1 = sourceIds; _i < sourceIds_1.length; _i++) {\n var s = sourceIds_1[_i];\n invariant_1.default(registry.getSource(s), 'Expected sourceIds to be registered.');\n }\n var sourceId = null;\n for (var i = sourceIds.length - 1; i >= 0; i--) {\n if (monitor.canDragSource(sourceIds[i])) {\n sourceId = sourceIds[i];\n break;\n }\n }\n if (sourceId === null) {\n return;\n }\n var sourceClientOffset = null;\n if (clientOffset) {\n invariant_1.default(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.');\n sourceClientOffset = getSourceClientOffset(sourceId);\n }\n var source = registry.getSource(sourceId);\n var item = source.beginDrag(monitor, sourceId);\n invariant_1.default(isObject_1.default(item), 'Item must be an object.');\n registry.pinSource(sourceId);\n var itemType = registry.getSourceType(sourceId);\n return {\n type: exports.BEGIN_DRAG,\n payload: {\n itemType: itemType,\n item: item,\n sourceId: sourceId,\n clientOffset: clientOffset || null,\n sourceClientOffset: sourceClientOffset || null,\n isSourcePublic: !!publishSource\n }\n };\n },\n publishDragSource: function () {\n var monitor = manager.getMonitor();\n if (!monitor.isDragging()) {\n return;\n }\n return { type: exports.PUBLISH_DRAG_SOURCE };\n },\n hover: function (targetIdsArg, _a) {\n var clientOffset = (_a === void 0 ? {} : _a).clientOffset;\n invariant_1.default(isArray_1.default(targetIdsArg), 'Expected targetIds to be an array.');\n var targetIds = targetIdsArg.slice(0);\n var monitor = manager.getMonitor();\n var registry = manager.getRegistry();\n invariant_1.default(monitor.isDragging(), 'Cannot call hover while not dragging.');\n invariant_1.default(!monitor.didDrop(), 'Cannot call hover after drop.');\n // First check invariants.\n for (var i = 0; i < targetIds.length; i++) {\n var targetId = targetIds[i];\n invariant_1.default(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');\n var target = registry.getTarget(targetId);\n invariant_1.default(target, 'Expected targetIds to be registered.');\n }\n var draggedItemType = monitor.getItemType();\n // Remove those targetIds that don't match the targetType. This\n // fixes shallow isOver which would only be non-shallow because of\n // non-matching targets.\n for (var i = targetIds.length - 1; i >= 0; i--) {\n var targetId = targetIds[i];\n var targetType = registry.getTargetType(targetId);\n if (!matchesType_1.default(targetType, draggedItemType)) {\n targetIds.splice(i, 1);\n }\n }\n // Finally call hover on all matching targets.\n for (var _i = 0, targetIds_1 = targetIds; _i < targetIds_1.length; _i++) {\n var targetId = targetIds_1[_i];\n var target = registry.getTarget(targetId);\n target.hover(monitor, targetId);\n }\n return {\n type: exports.HOVER,\n payload: {\n targetIds: targetIds,\n clientOffset: clientOffset || null\n }\n };\n },\n drop: function (options) {\n if (options === void 0) {\n options = {};\n }\n var monitor = manager.getMonitor();\n var registry = manager.getRegistry();\n invariant_1.default(monitor.isDragging(), 'Cannot call drop while not dragging.');\n invariant_1.default(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.');\n var targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor);\n targetIds.reverse();\n // Multiple actions are dispatched here, which is why this doesn't return an action\n targetIds.forEach(function (targetId, index) {\n var target = registry.getTarget(targetId);\n var dropResult = target.drop(monitor, targetId);\n invariant_1.default(typeof dropResult === 'undefined' || isObject_1.default(dropResult), 'Drop result must either be an object or undefined.');\n if (typeof dropResult === 'undefined') {\n dropResult = index === 0 ? {} : monitor.getDropResult();\n }\n var action = {\n type: exports.DROP,\n payload: {\n dropResult: __assign({}, options, dropResult)\n }\n };\n manager.dispatch(action);\n });\n },\n endDrag: function () {\n var monitor = manager.getMonitor();\n var registry = manager.getRegistry();\n invariant_1.default(monitor.isDragging(), 'Cannot call endDrag while not dragging.');\n var sourceId = monitor.getSourceId();\n var source = registry.getSource(sourceId, true);\n source.endDrag(monitor, sourceId);\n registry.unpinSource();\n return { type: exports.END_DRAG };\n }\n };\n}\nexports.default = createDragDropActions;\n//# sourceMappingURL=dragDrop.js.map\n\n//# sourceURL=webpack://ReactDnD/../dnd-core/lib/actions/dragDrop.js?"); /***/ }), /***/ "../dnd-core/lib/actions/registry.js": /*!*******************************************!*\ !*** ../dnd-core/lib/actions/registry.js ***! \*******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ADD_SOURCE = 'dnd-core/ADD_SOURCE';\nexports.ADD_TARGET = 'dnd-core/ADD_TARGET';\nexports.REMOVE_SOURCE = 'dnd-core/REMOVE_SOURCE';\nexports.REMOVE_TARGET = 'dnd-core/REMOVE_TARGET';\nfunction addSource(sourceId) {\n return {\n type: exports.ADD_SOURCE,\n payload: {\n sourceId: sourceId\n }\n };\n}\nexports.addSource = addSource;\nfunction addTarget(targetId) {\n return {\n type: exports.ADD_TARGET,\n payload: {\n targetId: targetId\n }\n };\n}\nexports.addTarget = addTarget;\nfunction removeSource(sourceId) {\n return {\n type: exports.REMOVE_SOURCE,\n payload: {\n sourceId: sourceId\n }\n };\n}\nexports.removeSource = removeSource;\nfunction removeTarget(targetId) {\n return {\n type: exports.REMOVE_TARGET,\n payload: {\n targetId: targetId\n }\n };\n}\nexports.removeTarget = removeTarget;\n//# sourceMappingURL=registry.js.map\n\n//# sourceURL=webpack://ReactDnD/../dnd-core/lib/actions/registry.js?"); /***/ }), /***/ "../dnd-core/lib/contracts.js": /*!************************************!*\ !*** ../dnd-core/lib/contracts.js ***! \************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar invariant_1 = __importDefault(__webpack_require__(/*! invariant */ \"./node_modules/invariant/browser.js\"));\nvar isArray_1 = __importDefault(__webpack_require__(/*! lodash/isArray */ \"./node_modules/lodash/isArray.js\"));\nfunction validateSourceContract(source) {\n invariant_1.default(typeof source.canDrag === 'function', 'Expected canDrag to be a function.');\n invariant_1.default(typeof source.beginDrag === 'function', 'Expected beginDrag to be a function.');\n invariant_1.default(typeof source.endDrag === 'function', 'Expected endDrag to be a function.');\n}\nexports.validateSourceContract = validateSourceContract;\nfunction validateTargetContract(target) {\n invariant_1.default(typeof target.canDrop === 'function', 'Expected canDrop to be a function.');\n invariant_1.default(typeof target.hover === 'function', 'Expected hover to be a function.');\n invariant_1.default(typeof target.drop === 'function', 'Expected beginDrag to be a function.');\n}\nexports.validateTargetContract = validateTargetContract;\nfunction validateType(type, allowArray) {\n if (allowArray && isArray_1.default(type)) {\n type.forEach(function (t) {\n return validateType(t, false);\n });\n return;\n }\n invariant_1.default(typeof type === 'string' || typeof type === 'symbol', allowArray ? 'Type can only be a string, a symbol, or an array of either.' : 'Type can only be a string or a symbol.');\n}\nexports.validateType = validateType;\n//# sourceMappingURL=contracts.js.map\n\n//# sourceURL=webpack://ReactDnD/../dnd-core/lib/contracts.js?"); /***/ }), /***/ "../dnd-core/lib/factories.js": /*!************************************!*\ !*** ../dnd-core/lib/factories.js ***! \************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nvar __impor