react-dnd-html5-backend
Advanced tools
Comparing version 10.0.2 to 11.0.0
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.EnterLeaveCounter = void 0; | ||
@@ -17,5 +17,3 @@ var _js_utils = require("./utils/js_utils"); | ||
var EnterLeaveCounter = | ||
/*#__PURE__*/ | ||
function () { | ||
var EnterLeaveCounter = /*#__PURE__*/function () { | ||
function EnterLeaveCounter(isNodeInDocument) { | ||
@@ -59,2 +57,2 @@ _classCallCheck(this, EnterLeaveCounter); | ||
exports.default = EnterLeaveCounter; | ||
exports.EnterLeaveCounter = EnterLeaveCounter; |
"use strict"; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -14,5 +14,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.NativeTypes = exports.default = void 0; | ||
exports.NativeTypes = exports.HTML5Backend = void 0; | ||
var _HTML5Backend = _interopRequireDefault(require("./HTML5Backend")); | ||
var _HTML5BackendImpl = require("./HTML5BackendImpl"); | ||
@@ -29,9 +29,6 @@ var NativeTypes = _interopRequireWildcard(require("./NativeTypes")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var createBackend = function createBackend(manager, context) { | ||
return new _HTML5Backend.default(manager, context); | ||
var HTML5Backend = function createBackend(manager, context) { | ||
return new _HTML5BackendImpl.HTML5BackendImpl(manager, context); | ||
}; | ||
var _default = createBackend; | ||
exports.default = _default; | ||
exports.HTML5Backend = HTML5Backend; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.MonotonicInterpolant = void 0; | ||
@@ -15,5 +15,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var MonotonicInterpolant = | ||
/*#__PURE__*/ | ||
function () { | ||
var MonotonicInterpolant = /*#__PURE__*/function () { | ||
function MonotonicInterpolant(xs, ys) { | ||
@@ -133,2 +131,2 @@ _classCallCheck(this, MonotonicInterpolant); | ||
exports.default = MonotonicInterpolant; | ||
exports.MonotonicInterpolant = MonotonicInterpolant; |
@@ -14,5 +14,3 @@ "use strict"; | ||
var NativeDragSource = | ||
/*#__PURE__*/ | ||
function () { | ||
var NativeDragSource = /*#__PURE__*/function () { | ||
function NativeDragSource(config) { | ||
@@ -19,0 +17,0 @@ _classCallCheck(this, NativeDragSource); |
"use strict"; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -5,0 +5,0 @@ Object.defineProperty(exports, "__esModule", { |
@@ -12,6 +12,4 @@ "use strict"; | ||
var _MonotonicInterpolant = _interopRequireDefault(require("./MonotonicInterpolant")); | ||
var _MonotonicInterpolant = require("./MonotonicInterpolant"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var ELEMENT_NODE = 1; | ||
@@ -44,3 +42,5 @@ | ||
function isImageNode(node) { | ||
return node.nodeName === 'IMG' && ((0, _BrowserDetector.isFirefox)() || !document.documentElement.contains(node)); | ||
var _document$documentEle; | ||
return node.nodeName === 'IMG' && ((0, _BrowserDetector.isFirefox)() || !((_document$documentEle = document.documentElement) === null || _document$documentEle === void 0 ? void 0 : _document$documentEle.contains(node))); | ||
} | ||
@@ -83,3 +83,3 @@ | ||
var calculateYOffset = function calculateYOffset() { | ||
var interpolantY = new _MonotonicInterpolant.default([0, 0.5, 1], [// Dock to the top | ||
var interpolantY = new _MonotonicInterpolant.MonotonicInterpolant([0, 0.5, 1], [// Dock to the top | ||
offsetFromDragPreview.y, // Align at the center | ||
@@ -101,3 +101,3 @@ offsetFromDragPreview.y / sourceHeight * dragPreviewHeight, // Dock to the bottom | ||
// If you know a simpler way to do this, let me know | ||
var interpolantX = new _MonotonicInterpolant.default([0, 0.5, 1], [// Dock to the left | ||
var interpolantX = new _MonotonicInterpolant.MonotonicInterpolant([0, 0.5, 1], [// Dock to the left | ||
offsetFromDragPreview.x, // Align at the center | ||
@@ -104,0 +104,0 @@ offsetFromDragPreview.x / sourceWidth * dragPreviewWidth, // Dock to the right |
@@ -14,5 +14,3 @@ "use strict"; | ||
var OptionsReader = | ||
/*#__PURE__*/ | ||
function () { | ||
var OptionsReader = /*#__PURE__*/function () { | ||
function OptionsReader(globalContext) { | ||
@@ -19,0 +17,0 @@ _classCallCheck(this, OptionsReader); |
@@ -8,6 +8,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { union, without } from './utils/js_utils'; | ||
var EnterLeaveCounter = | ||
/*#__PURE__*/ | ||
function () { | ||
export var EnterLeaveCounter = /*#__PURE__*/function () { | ||
function EnterLeaveCounter(isNodeInDocument) { | ||
@@ -49,4 +46,2 @@ _classCallCheck(this, EnterLeaveCounter); | ||
return EnterLeaveCounter; | ||
}(); | ||
export { EnterLeaveCounter as default }; | ||
}(); |
@@ -1,10 +0,7 @@ | ||
import HTML5Backend from './HTML5Backend'; | ||
import { HTML5BackendImpl } from './HTML5BackendImpl'; | ||
import * as NativeTypes from './NativeTypes'; | ||
export { getEmptyImage } from './getEmptyImage'; | ||
export { NativeTypes }; | ||
var createBackend = function createBackend(manager, context) { | ||
return new HTML5Backend(manager, context); | ||
}; | ||
export default createBackend; | ||
export var HTML5Backend = function createBackend(manager, context) { | ||
return new HTML5BackendImpl(manager, context); | ||
}; |
@@ -7,5 +7,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var MonotonicInterpolant = | ||
/*#__PURE__*/ | ||
function () { | ||
export var MonotonicInterpolant = /*#__PURE__*/function () { | ||
function MonotonicInterpolant(xs, ys) { | ||
@@ -123,4 +121,2 @@ _classCallCheck(this, MonotonicInterpolant); | ||
return MonotonicInterpolant; | ||
}(); | ||
export { MonotonicInterpolant as default }; | ||
}(); |
@@ -7,5 +7,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
export var NativeDragSource = | ||
/*#__PURE__*/ | ||
function () { | ||
export var NativeDragSource = /*#__PURE__*/function () { | ||
function NativeDragSource(config) { | ||
@@ -12,0 +10,0 @@ _classCallCheck(this, NativeDragSource); |
import { isSafari, isFirefox } from './BrowserDetector'; | ||
import MonotonicInterpolant from './MonotonicInterpolant'; | ||
import { MonotonicInterpolant } from './MonotonicInterpolant'; | ||
var ELEMENT_NODE = 1; | ||
@@ -28,3 +28,5 @@ export function getNodeClientOffset(node) { | ||
function isImageNode(node) { | ||
return node.nodeName === 'IMG' && (isFirefox() || !document.documentElement.contains(node)); | ||
var _document$documentEle; | ||
return node.nodeName === 'IMG' && (isFirefox() || !((_document$documentEle = document.documentElement) === null || _document$documentEle === void 0 ? void 0 : _document$documentEle.contains(node))); | ||
} | ||
@@ -31,0 +33,0 @@ |
@@ -7,5 +7,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
export var OptionsReader = | ||
/*#__PURE__*/ | ||
function () { | ||
export var OptionsReader = /*#__PURE__*/function () { | ||
function OptionsReader(globalContext) { | ||
@@ -12,0 +10,0 @@ _classCallCheck(this, OptionsReader); |
@@ -51,6 +51,3 @@ (function (global, factory) { | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var EnterLeaveCounter = | ||
/*#__PURE__*/ | ||
function () { | ||
var EnterLeaveCounter = /*#__PURE__*/function () { | ||
function EnterLeaveCounter(isNodeInDocument) { | ||
@@ -107,5 +104,3 @@ _classCallCheck(this, EnterLeaveCounter); | ||
var MonotonicInterpolant = | ||
/*#__PURE__*/ | ||
function () { | ||
var MonotonicInterpolant = /*#__PURE__*/function () { | ||
function MonotonicInterpolant(xs, ys) { | ||
@@ -247,3 +242,5 @@ _classCallCheck$1(this, MonotonicInterpolant); | ||
function isImageNode(node) { | ||
return node.nodeName === 'IMG' && (isFirefox() || !document.documentElement.contains(node)); | ||
var _document$documentEle; | ||
return node.nodeName === 'IMG' && (isFirefox() || !((_document$documentEle = document.documentElement) === null || _document$documentEle === void 0 ? void 0 : _document$documentEle.contains(node))); | ||
} | ||
@@ -374,5 +371,3 @@ | ||
var NativeDragSource = | ||
/*#__PURE__*/ | ||
function () { | ||
var NativeDragSource = /*#__PURE__*/function () { | ||
function NativeDragSource(config) { | ||
@@ -469,5 +464,3 @@ _classCallCheck$2(this, NativeDragSource); | ||
var OptionsReader = | ||
/*#__PURE__*/ | ||
function () { | ||
var OptionsReader = /*#__PURE__*/function () { | ||
function OptionsReader(globalContext) { | ||
@@ -515,10 +508,7 @@ _classCallCheck$3(this, OptionsReader); | ||
function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; } | ||
var HTML5Backend = | ||
/*#__PURE__*/ | ||
function () { | ||
function HTML5Backend(manager, globalContext) { | ||
var HTML5BackendImpl = /*#__PURE__*/function () { | ||
function HTML5BackendImpl(manager, globalContext) { | ||
var _this = this; | ||
_classCallCheck$4(this, HTML5Backend); | ||
_classCallCheck$4(this, HTML5BackendImpl); | ||
@@ -541,3 +531,5 @@ this.sourcePreviewNodes = new Map(); | ||
this.getSourceClientOffset = function (sourceId) { | ||
return getNodeClientOffset(_this.sourceNodes.get(sourceId)); | ||
var source = _this.sourceNodes.get(sourceId); | ||
return source && getNodeClientOffset(source) || null; | ||
}; | ||
@@ -552,3 +544,5 @@ | ||
_this.registry.removeSource(_this.currentNativeHandle); | ||
if (_this.currentNativeHandle) { | ||
_this.registry.removeSource(_this.currentNativeHandle); | ||
} | ||
@@ -561,3 +555,3 @@ _this.currentNativeHandle = null; | ||
// Check the node either in the main document or in the current context | ||
return _this.document && _this.document.body && document.body.contains(node); | ||
return Boolean(node && _this.document && _this.document.body && document.body.contains(node)); | ||
}; | ||
@@ -639,3 +633,3 @@ | ||
// Firefox won't drag without setting data | ||
dataTransfer.setData('application/json', {}); | ||
dataTransfer === null || dataTransfer === void 0 ? void 0 : dataTransfer.setData('application/json', {}); | ||
} catch (err) {} // IE doesn't support MIME types in setData | ||
@@ -821,3 +815,5 @@ // Store drag source node so we can check whether | ||
if (_this.isDraggingNativeItem()) { | ||
_this.currentNativeSource.loadDataTransfer(e.dataTransfer); | ||
var _this$currentNativeSo; | ||
(_this$currentNativeSo = _this.currentNativeSource) === null || _this$currentNativeSo === void 0 ? void 0 : _this$currentNativeSo.loadDataTransfer(e.dataTransfer); | ||
} | ||
@@ -871,6 +867,26 @@ | ||
this.enterLeaveCounter = new EnterLeaveCounter(this.isNodeInDocument); | ||
} // public for test | ||
} | ||
/** | ||
* Generate profiling statistics for the HTML5Backend. | ||
*/ | ||
_createClass$4(HTML5Backend, [{ | ||
_createClass$4(HTML5BackendImpl, [{ | ||
key: "profile", | ||
value: function profile() { | ||
var _this$dragStartSource, _this$dragOverTargetI; | ||
return { | ||
sourcePreviewNodes: this.sourcePreviewNodes.size, | ||
sourcePreviewNodeOptions: this.sourcePreviewNodeOptions.size, | ||
sourceNodeOptions: this.sourceNodeOptions.size, | ||
sourceNodes: this.sourceNodes.size, | ||
dragStartSourceIds: ((_this$dragStartSource = this.dragStartSourceIds) === null || _this$dragStartSource === void 0 ? void 0 : _this$dragStartSource.length) || 0, | ||
dropTargetIds: this.dropTargetIds.length, | ||
dragEnterTargetIds: this.dragEnterTargetIds.length, | ||
dragOverTargetIds: ((_this$dragOverTargetI = this.dragOverTargetIds) === null || _this$dragOverTargetI === void 0 ? void 0 : _this$dragOverTargetI.length) || 0 | ||
}; | ||
} // public for test | ||
}, { | ||
key: "setup", | ||
@@ -1145,3 +1161,3 @@ value: function setup() { | ||
return HTML5Backend; | ||
return HTML5BackendImpl; | ||
}(); | ||
@@ -1159,8 +1175,8 @@ | ||
var createBackend = function createBackend(manager, context) { | ||
return new HTML5Backend(manager, context); | ||
var HTML5Backend = function createBackend(manager, context) { | ||
return new HTML5BackendImpl(manager, context); | ||
}; | ||
exports.HTML5Backend = HTML5Backend; | ||
exports.NativeTypes = NativeTypes; | ||
exports.default = createBackend; | ||
exports.getEmptyImage = getEmptyImage; | ||
@@ -1167,0 +1183,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ReactDnDHTML5Backend={})}(this,(function(e){"use strict";function t(e){var t=null;return function(){return null==t&&(t=e()),t}}function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.entered=[],this.isNodeInDocument=t}var t,n,a;return t=e,(n=[{key:"enter",value:function(e){var t=this,r=this.entered.length;return this.entered=function(e,t){var r=new Set,n=function(e){return r.add(e)};e.forEach(n),t.forEach(n);var a=[];return r.forEach((function(e){return a.push(e)})),a}(this.entered.filter((function(r){return t.isNodeInDocument(r)&&(!r.contains||r.contains(e))})),[e]),0===r&&this.entered.length>0}},{key:"leave",value:function(e){var t,r,n=this.entered.length;return this.entered=(t=this.entered.filter(this.isNodeInDocument),r=e,t.filter((function(e){return e!==r}))),n>0&&0===this.entered.length}},{key:"reset",value:function(){this.entered=[]}}])&&r(t.prototype,n),a&&r(t,a),e}(),a=t((function(){return/firefox/i.test(navigator.userAgent)})),i=t((function(){return Boolean(window.safari)}));function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var s=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);for(var n=t.length,a=[],i=0;i<n;i++)a.push(i);a.sort((function(e,r){return t[e]<t[r]?-1:1}));for(var o,s,u=[],c=[],d=0;d<n-1;d++)o=t[d+1]-t[d],s=r[d+1]-r[d],u.push(o),c.push(s/o);for(var f=[c[0]],l=0;l<u.length-1;l++){var g=c[l],h=c[l+1];if(g*h<=0)f.push(0);else{o=u[l];var v=u[l+1],p=o+v;f.push(3*p/((p+v)/g+(p+o)/h))}}f.push(c[c.length-1]);for(var m,D=[],y=[],w=0;w<f.length-1;w++){m=c[w];var T=f[w],E=1/u[w],b=T+f[w+1]-m-m;D.push((m-T-b)*E),y.push(b*E*E)}this.xs=t,this.ys=r,this.c1s=f,this.c2s=D,this.c3s=y}var t,r,n;return t=e,(r=[{key:"interpolate",value:function(e){var t=this.xs,r=this.ys,n=this.c1s,a=this.c2s,i=this.c3s,o=t.length-1;if(e===t[o])return r[o];for(var s,u=0,c=i.length-1;u<=c;){var d=t[s=Math.floor(.5*(u+c))];if(d<e)u=s+1;else{if(!(d>e))return r[s];c=s-1}}var f=e-t[o=Math.max(0,c)],l=f*f;return r[o]+n[o]*f+a[o]*l+i[o]*f*l}}])&&o(t.prototype,r),n&&o(t,n),e}(),u=1;function c(e){var t=e.nodeType===u?e:e.parentElement;if(!t)return null;var r=t.getBoundingClientRect(),n=r.top;return{x:r.left,y:n}}function d(e){return{x:e.clientX,y:e.clientY}}function f(e,t,r,n,o){var u,d,f="IMG"===(u=t).nodeName&&(a()||!document.documentElement.contains(u)),l=c(f?e:t),g={x:r.x-l.x,y:r.y-l.y},h=e.offsetWidth,v=e.offsetHeight,p=n.anchorX,m=n.anchorY,D=function(e,t,r,n){var a=e?t.width:r,o=e?t.height:n;return i()&&e&&(o/=window.devicePixelRatio,a/=window.devicePixelRatio),{dragPreviewWidth:a,dragPreviewHeight:o}}(f,t,h,v),y=D.dragPreviewWidth,w=D.dragPreviewHeight,T=o.offsetX,E=o.offsetY,b=0===E||E;return{x:0===T||T?T:new s([0,.5,1],[g.x,g.x/h*y,g.x+y-h]).interpolate(p),y:b?E:(d=new s([0,.5,1],[g.y,g.y/v*w,g.y+w-v]).interpolate(m),i()&&f&&(d+=(window.devicePixelRatio-1)*w),d)}}var l,g="__NATIVE_FILE__",h="__NATIVE_URL__",v="__NATIVE_TEXT__",p=Object.freeze({__proto__:null,FILE:g,URL:h,TEXT:v});function m(e,t,r){var n=t.reduce((function(t,r){return t||e.getData(r)}),"");return null!=n?n:r}function D(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var y=(D(l={},g,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items}},matchesTypes:["Files"]}),D(l,h,{exposeProperties:{urls:function(e,t){return m(e,t,"").split("\n")}},matchesTypes:["Url","text/uri-list"]}),D(l,v,{exposeProperties:{text:function(e,t){return m(e,t,"")}},matchesTypes:["Text","text/plain"]}),l);function w(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var T=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=t,this.item={},this.initializeExposedProperties()}var t,r,n;return t=e,(r=[{key:"initializeExposedProperties",value:function(){var e=this;Object.keys(this.config.exposeProperties).forEach((function(t){Object.defineProperty(e.item,t,{configurable:!0,enumerable:!0,get:function(){return console.warn("Browser doesn't allow reading \"".concat(t,'" until the drop event.')),null}})}))}},{key:"loadDataTransfer",value:function(e){var t=this;if(e){var r={};Object.keys(this.config.exposeProperties).forEach((function(n){r[n]={value:t.config.exposeProperties[n](e,t.config.matchesTypes),configurable:!0,enumerable:!0}})),Object.defineProperties(this.item,r)}}},{key:"canDrag",value:function(){return!0}},{key:"beginDrag",value:function(){return this.item}},{key:"isDragging",value:function(e,t){return t===e.getSourceId()}},{key:"endDrag",value:function(){}}])&&w(t.prototype,r),n&&w(t,n),e}();function E(e){if(!e)return null;var t=Array.prototype.slice.call(e.types||[]);return Object.keys(y).filter((function(e){return y[e].matchesTypes.some((function(e){return t.indexOf(e)>-1}))}))[0]||null}function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var O=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.globalContext=t}var t,r,n;return t=e,(r=[{key:"window",get:function(){return this.globalContext?this.globalContext:"undefined"!=typeof window?window:void 0}},{key:"document",get:function(){if(this.window)return this.window.document}}])&&b(t.prototype,r),n&&b(t,n),e}();function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function N(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?S(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function I(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function C(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var L,P=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.sourceNodes=new Map,this.sourceNodeOptions=new Map,this.dragStartSourceIds=null,this.dropTargetIds=[],this.dragEnterTargetIds=[],this.currentNativeSource=null,this.currentNativeHandle=null,this.currentDragSourceNode=null,this.altKeyPressed=!1,this.mouseMoveTimeoutTimer=null,this.asyncEndDragFrameId=null,this.dragOverTargetIds=null,this.getSourceClientOffset=function(e){return c(i.sourceNodes.get(e))},this.endDragNativeItem=function(){i.isDraggingNativeItem()&&(i.actions.endDrag(),i.registry.removeSource(i.currentNativeHandle),i.currentNativeHandle=null,i.currentNativeSource=null)},this.isNodeInDocument=function(e){return i.document&&i.document.body&&document.body.contains(e)},this.endDragIfSourceWasRemovedFromDOM=function(){var e=i.currentDragSourceNode;i.isNodeInDocument(e)||i.clearCurrentDragSourceNode()&&i.actions.endDrag()},this.handleTopDragStartCapture=function(){i.clearCurrentDragSourceNode(),i.dragStartSourceIds=[]},this.handleTopDragStart=function(e){if(!e.defaultPrevented){var t=i.dragStartSourceIds;i.dragStartSourceIds=null;var r=d(e);i.monitor.isDragging()&&i.actions.endDrag(),i.actions.beginDrag(t||[],{publishSource:!1,getSourceClientOffset:i.getSourceClientOffset,clientOffset:r});var n=e.dataTransfer,a=E(n);if(i.monitor.isDragging()){if(n&&"function"==typeof n.setDragImage){var o=i.monitor.getSourceId(),s=i.sourceNodes.get(o),u=i.sourcePreviewNodes.get(o)||s;if(u){var c=i.getCurrentSourcePreviewNodeOptions(),l=f(s,u,r,{anchorX:c.anchorX,anchorY:c.anchorY},{offsetX:c.offsetX,offsetY:c.offsetY});n.setDragImage(u,l.x,l.y)}}try{n.setData("application/json",{})}catch(e){}i.setCurrentDragSourceNode(e.target),i.getCurrentSourcePreviewNodeOptions().captureDraggingState?i.actions.publishDragSource():setTimeout((function(){return i.actions.publishDragSource()}),0)}else if(a)i.beginDragNativeItem(a);else{if(n&&!n.types&&(e.target&&!e.target.hasAttribute||!e.target.hasAttribute("draggable")))return;e.preventDefault()}}},this.handleTopDragEndCapture=function(){i.clearCurrentDragSourceNode()&&i.actions.endDrag()},this.handleTopDragEnterCapture=function(e){if(i.dragEnterTargetIds=[],i.enterLeaveCounter.enter(e.target)&&!i.monitor.isDragging()){var t=e.dataTransfer,r=E(t);r&&i.beginDragNativeItem(r,t)}},this.handleTopDragEnter=function(e){var t=i.dragEnterTargetIds;(i.dragEnterTargetIds=[],i.monitor.isDragging())&&(i.altKeyPressed=e.altKey,a()||i.actions.hover(t,{clientOffset:d(e)}),t.some((function(e){return i.monitor.canDropOnTarget(e)}))&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())))},this.handleTopDragOverCapture=function(){i.dragOverTargetIds=[]},this.handleTopDragOver=function(e){var t=i.dragOverTargetIds;if(i.dragOverTargetIds=[],!i.monitor.isDragging())return e.preventDefault(),void(e.dataTransfer&&(e.dataTransfer.dropEffect="none"));i.altKeyPressed=e.altKey,i.actions.hover(t||[],{clientOffset:d(e)}),(t||[]).some((function(e){return i.monitor.canDropOnTarget(e)}))?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())):i.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))},this.handleTopDragLeaveCapture=function(e){i.isDraggingNativeItem()&&e.preventDefault(),i.enterLeaveCounter.leave(e.target)&&i.isDraggingNativeItem()&&i.endDragNativeItem()},this.handleTopDropCapture=function(e){i.dropTargetIds=[],e.preventDefault(),i.isDraggingNativeItem()&&i.currentNativeSource.loadDataTransfer(e.dataTransfer),i.enterLeaveCounter.reset()},this.handleTopDrop=function(e){var t=i.dropTargetIds;i.dropTargetIds=[],i.actions.hover(t,{clientOffset:d(e)}),i.actions.drop({dropEffect:i.getCurrentDropEffect()}),i.isDraggingNativeItem()?i.endDragNativeItem():i.endDragIfSourceWasRemovedFromDOM()},this.handleSelectStart=function(e){var t=e.target;"function"==typeof t.dragDrop&&("INPUT"===t.tagName||"SELECT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||(e.preventDefault(),t.dragDrop()))},this.options=new O(r),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new n(this.isNodeInDocument)}var t,r,i;return t=e,(r=[{key:"setup",value:function(){if(void 0!==this.window){if(this.window.__isReactDndBackendSetUp)throw new Error("Cannot have two HTML5 backends at the same time.");this.window.__isReactDndBackendSetUp=!0,this.addEventListeners(this.window)}}},{key:"teardown",value:function(){void 0!==this.window&&(this.window.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.window),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId&&this.window.cancelAnimationFrame(this.asyncEndDragFrameId))}},{key:"connectDragPreview",value:function(e,t,r){var n=this;return this.sourcePreviewNodeOptions.set(e,r),this.sourcePreviewNodes.set(e,t),function(){n.sourcePreviewNodes.delete(e),n.sourcePreviewNodeOptions.delete(e)}}},{key:"connectDragSource",value:function(e,t,r){var n=this;this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,r);var a=function(t){return n.handleDragStart(t,e)},i=function(e){return n.handleSelectStart(e)};return t.setAttribute("draggable","true"),t.addEventListener("dragstart",a),t.addEventListener("selectstart",i),function(){n.sourceNodes.delete(e),n.sourceNodeOptions.delete(e),t.removeEventListener("dragstart",a),t.removeEventListener("selectstart",i),t.setAttribute("draggable","false")}}},{key:"connectDropTarget",value:function(e,t){var r=this,n=function(t){return r.handleDragEnter(t,e)},a=function(t){return r.handleDragOver(t,e)},i=function(t){return r.handleDrop(t,e)};return t.addEventListener("dragenter",n),t.addEventListener("dragover",a),t.addEventListener("drop",i),function(){t.removeEventListener("dragenter",n),t.removeEventListener("dragover",a),t.removeEventListener("drop",i)}}},{key:"addEventListeners",value:function(e){e.addEventListener&&(e.addEventListener("dragstart",this.handleTopDragStart),e.addEventListener("dragstart",this.handleTopDragStartCapture,!0),e.addEventListener("dragend",this.handleTopDragEndCapture,!0),e.addEventListener("dragenter",this.handleTopDragEnter),e.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.addEventListener("dragover",this.handleTopDragOver),e.addEventListener("dragover",this.handleTopDragOverCapture,!0),e.addEventListener("drop",this.handleTopDrop),e.addEventListener("drop",this.handleTopDropCapture,!0))}},{key:"removeEventListeners",value:function(e){e.removeEventListener&&(e.removeEventListener("dragstart",this.handleTopDragStart),e.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),e.removeEventListener("dragend",this.handleTopDragEndCapture,!0),e.removeEventListener("dragenter",this.handleTopDragEnter),e.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.removeEventListener("dragover",this.handleTopDragOver),e.removeEventListener("dragover",this.handleTopDragOverCapture,!0),e.removeEventListener("drop",this.handleTopDrop),e.removeEventListener("drop",this.handleTopDropCapture,!0))}},{key:"getCurrentSourceNodeOptions",value:function(){var e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return N({dropEffect:this.altKeyPressed?"copy":"move"},t||{})}},{key:"getCurrentDropEffect",value:function(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}},{key:"getCurrentSourcePreviewNodeOptions",value:function(){var e=this.monitor.getSourceId();return N({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}},{key:"isDraggingNativeItem",value:function(){var e=this.monitor.getItemType();return Object.keys(p).some((function(t){return p[t]===e}))}},{key:"beginDragNativeItem",value:function(e,t){this.clearCurrentDragSourceNode(),this.currentNativeSource=function(e,t){var r=new T(y[e]);return r.loadDataTransfer(t),r}(e,t),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:"setCurrentDragSourceNode",value:function(e){var t=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e,this.mouseMoveTimeoutTimer=setTimeout((function(){return t.window&&t.window.addEventListener("mousemove",t.endDragIfSourceWasRemovedFromDOM,!0)}),1e3)}},{key:"clearCurrentDragSourceNode",value:function(){return!!this.currentDragSourceNode&&(this.currentDragSourceNode=null,this.window&&(this.window.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.window.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)),this.mouseMoveTimeoutTimer=null,!0)}},{key:"handleDragStart",value:function(e,t){e.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(t))}},{key:"handleDragEnter",value:function(e,t){this.dragEnterTargetIds.unshift(t)}},{key:"handleDragOver",value:function(e,t){null===this.dragOverTargetIds&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}},{key:"handleDrop",value:function(e,t){this.dropTargetIds.unshift(t)}},{key:"window",get:function(){return this.options.window}},{key:"document",get:function(){return this.options.document}}])&&C(t.prototype,r),i&&C(t,i),e}();e.NativeTypes=p,e.default=function(e,t){return new P(e,t)},e.getEmptyImage=function(){return L||((L=new Image).src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),L},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ReactDnDHTML5Backend={})}(this,(function(e){"use strict";function t(e){var t=null;return function(){return null==t&&(t=e()),t}}function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.entered=[],this.isNodeInDocument=t}var t,n,a;return t=e,(n=[{key:"enter",value:function(e){var t=this,r=this.entered.length;return this.entered=function(e,t){var r=new Set,n=function(e){return r.add(e)};e.forEach(n),t.forEach(n);var a=[];return r.forEach((function(e){return a.push(e)})),a}(this.entered.filter((function(r){return t.isNodeInDocument(r)&&(!r.contains||r.contains(e))})),[e]),0===r&&this.entered.length>0}},{key:"leave",value:function(e){var t,r,n=this.entered.length;return this.entered=(t=this.entered.filter(this.isNodeInDocument),r=e,t.filter((function(e){return e!==r}))),n>0&&0===this.entered.length}},{key:"reset",value:function(){this.entered=[]}}])&&r(t.prototype,n),a&&r(t,a),e}(),a=t((function(){return/firefox/i.test(navigator.userAgent)})),i=t((function(){return Boolean(window.safari)}));function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var s=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);for(var n=t.length,a=[],i=0;i<n;i++)a.push(i);a.sort((function(e,r){return t[e]<t[r]?-1:1}));for(var o,s,u=[],d=[],c=0;c<n-1;c++)o=t[c+1]-t[c],s=r[c+1]-r[c],u.push(o),d.push(s/o);for(var l=[d[0]],g=0;g<u.length-1;g++){var f=d[g],v=d[g+1];if(f*v<=0)l.push(0);else{o=u[g];var h=u[g+1],p=o+h;l.push(3*p/((p+h)/f+(p+o)/v))}}l.push(d[d.length-1]);for(var m,D=[],y=[],w=0;w<l.length-1;w++){m=d[w];var T=l[w],E=1/u[w],b=T+l[w+1]-m-m;D.push((m-T-b)*E),y.push(b*E*E)}this.xs=t,this.ys=r,this.c1s=l,this.c2s=D,this.c3s=y}var t,r,n;return t=e,(r=[{key:"interpolate",value:function(e){var t=this.xs,r=this.ys,n=this.c1s,a=this.c2s,i=this.c3s,o=t.length-1;if(e===t[o])return r[o];for(var s,u=0,d=i.length-1;u<=d;){var c=t[s=Math.floor(.5*(u+d))];if(c<e)u=s+1;else{if(!(c>e))return r[s];d=s-1}}var l=e-t[o=Math.max(0,d)],g=l*l;return r[o]+n[o]*l+a[o]*g+i[o]*l*g}}])&&o(t.prototype,r),n&&o(t,n),e}();function u(e){var t=1===e.nodeType?e:e.parentElement;if(!t)return null;var r=t.getBoundingClientRect(),n=r.top;return{x:r.left,y:n}}function d(e){return{x:e.clientX,y:e.clientY}}function c(e,t,r,n,o){var d,c,l,g="IMG"===(d=t).nodeName&&(a()||!(null===(c=document.documentElement)||void 0===c?void 0:c.contains(d))),f=u(g?e:t),v={x:r.x-f.x,y:r.y-f.y},h=e.offsetWidth,p=e.offsetHeight,m=n.anchorX,D=n.anchorY,y=function(e,t,r,n){var a=e?t.width:r,o=e?t.height:n;return i()&&e&&(o/=window.devicePixelRatio,a/=window.devicePixelRatio),{dragPreviewWidth:a,dragPreviewHeight:o}}(g,t,h,p),w=y.dragPreviewWidth,T=y.dragPreviewHeight,E=o.offsetX,b=o.offsetY,N=0===b||b;return{x:0===E||E?E:new s([0,.5,1],[v.x,v.x/h*w,v.x+w-h]).interpolate(m),y:N?b:(l=new s([0,.5,1],[v.y,v.y/p*T,v.y+T-p]).interpolate(D),i()&&g&&(l+=(window.devicePixelRatio-1)*T),l)}}var l,g="__NATIVE_FILE__",f="__NATIVE_URL__",v="__NATIVE_TEXT__",h=Object.freeze({__proto__:null,FILE:g,URL:f,TEXT:v});function p(e,t,r){var n=t.reduce((function(t,r){return t||e.getData(r)}),"");return null!=n?n:r}function m(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var D=(m(l={},g,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items}},matchesTypes:["Files"]}),m(l,f,{exposeProperties:{urls:function(e,t){return p(e,t,"").split("\n")}},matchesTypes:["Url","text/uri-list"]}),m(l,v,{exposeProperties:{text:function(e,t){return p(e,t,"")}},matchesTypes:["Text","text/plain"]}),l);function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var w=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=t,this.item={},this.initializeExposedProperties()}var t,r,n;return t=e,(r=[{key:"initializeExposedProperties",value:function(){var e=this;Object.keys(this.config.exposeProperties).forEach((function(t){Object.defineProperty(e.item,t,{configurable:!0,enumerable:!0,get:function(){return console.warn("Browser doesn't allow reading \"".concat(t,'" until the drop event.')),null}})}))}},{key:"loadDataTransfer",value:function(e){var t=this;if(e){var r={};Object.keys(this.config.exposeProperties).forEach((function(n){r[n]={value:t.config.exposeProperties[n](e,t.config.matchesTypes),configurable:!0,enumerable:!0}})),Object.defineProperties(this.item,r)}}},{key:"canDrag",value:function(){return!0}},{key:"beginDrag",value:function(){return this.item}},{key:"isDragging",value:function(e,t){return t===e.getSourceId()}},{key:"endDrag",value:function(){}}])&&y(t.prototype,r),n&&y(t,n),e}();function T(e){if(!e)return null;var t=Array.prototype.slice.call(e.types||[]);return Object.keys(D).filter((function(e){return D[e].matchesTypes.some((function(e){return t.indexOf(e)>-1}))}))[0]||null}function E(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var b=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.globalContext=t}var t,r,n;return t=e,(r=[{key:"window",get:function(){return this.globalContext?this.globalContext:"undefined"!=typeof window?window:void 0}},{key:"document",get:function(){if(this.window)return this.window.document}}])&&E(t.prototype,r),n&&E(t,n),e}();function N(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N(Object(r),!0).forEach((function(t){S(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function S(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function I(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var C,P=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.sourceNodes=new Map,this.sourceNodeOptions=new Map,this.dragStartSourceIds=null,this.dropTargetIds=[],this.dragEnterTargetIds=[],this.currentNativeSource=null,this.currentNativeHandle=null,this.currentDragSourceNode=null,this.altKeyPressed=!1,this.mouseMoveTimeoutTimer=null,this.asyncEndDragFrameId=null,this.dragOverTargetIds=null,this.getSourceClientOffset=function(e){var t=i.sourceNodes.get(e);return t&&u(t)||null},this.endDragNativeItem=function(){i.isDraggingNativeItem()&&(i.actions.endDrag(),i.currentNativeHandle&&i.registry.removeSource(i.currentNativeHandle),i.currentNativeHandle=null,i.currentNativeSource=null)},this.isNodeInDocument=function(e){return Boolean(e&&i.document&&i.document.body&&document.body.contains(e))},this.endDragIfSourceWasRemovedFromDOM=function(){var e=i.currentDragSourceNode;i.isNodeInDocument(e)||i.clearCurrentDragSourceNode()&&i.actions.endDrag()},this.handleTopDragStartCapture=function(){i.clearCurrentDragSourceNode(),i.dragStartSourceIds=[]},this.handleTopDragStart=function(e){if(!e.defaultPrevented){var t=i.dragStartSourceIds;i.dragStartSourceIds=null;var r=d(e);i.monitor.isDragging()&&i.actions.endDrag(),i.actions.beginDrag(t||[],{publishSource:!1,getSourceClientOffset:i.getSourceClientOffset,clientOffset:r});var n=e.dataTransfer,a=T(n);if(i.monitor.isDragging()){if(n&&"function"==typeof n.setDragImage){var o=i.monitor.getSourceId(),s=i.sourceNodes.get(o),u=i.sourcePreviewNodes.get(o)||s;if(u){var l=i.getCurrentSourcePreviewNodeOptions(),g=c(s,u,r,{anchorX:l.anchorX,anchorY:l.anchorY},{offsetX:l.offsetX,offsetY:l.offsetY});n.setDragImage(u,g.x,g.y)}}try{null==n||n.setData("application/json",{})}catch(e){}i.setCurrentDragSourceNode(e.target),i.getCurrentSourcePreviewNodeOptions().captureDraggingState?i.actions.publishDragSource():setTimeout((function(){return i.actions.publishDragSource()}),0)}else if(a)i.beginDragNativeItem(a);else{if(n&&!n.types&&(e.target&&!e.target.hasAttribute||!e.target.hasAttribute("draggable")))return;e.preventDefault()}}},this.handleTopDragEndCapture=function(){i.clearCurrentDragSourceNode()&&i.actions.endDrag()},this.handleTopDragEnterCapture=function(e){if(i.dragEnterTargetIds=[],i.enterLeaveCounter.enter(e.target)&&!i.monitor.isDragging()){var t=e.dataTransfer,r=T(t);r&&i.beginDragNativeItem(r,t)}},this.handleTopDragEnter=function(e){var t=i.dragEnterTargetIds;(i.dragEnterTargetIds=[],i.monitor.isDragging())&&(i.altKeyPressed=e.altKey,a()||i.actions.hover(t,{clientOffset:d(e)}),t.some((function(e){return i.monitor.canDropOnTarget(e)}))&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())))},this.handleTopDragOverCapture=function(){i.dragOverTargetIds=[]},this.handleTopDragOver=function(e){var t=i.dragOverTargetIds;if(i.dragOverTargetIds=[],!i.monitor.isDragging())return e.preventDefault(),void(e.dataTransfer&&(e.dataTransfer.dropEffect="none"));i.altKeyPressed=e.altKey,i.actions.hover(t||[],{clientOffset:d(e)}),(t||[]).some((function(e){return i.monitor.canDropOnTarget(e)}))?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())):i.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))},this.handleTopDragLeaveCapture=function(e){i.isDraggingNativeItem()&&e.preventDefault(),i.enterLeaveCounter.leave(e.target)&&i.isDraggingNativeItem()&&i.endDragNativeItem()},this.handleTopDropCapture=function(e){var t;(i.dropTargetIds=[],e.preventDefault(),i.isDraggingNativeItem())&&(null===(t=i.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer));i.enterLeaveCounter.reset()},this.handleTopDrop=function(e){var t=i.dropTargetIds;i.dropTargetIds=[],i.actions.hover(t,{clientOffset:d(e)}),i.actions.drop({dropEffect:i.getCurrentDropEffect()}),i.isDraggingNativeItem()?i.endDragNativeItem():i.endDragIfSourceWasRemovedFromDOM()},this.handleSelectStart=function(e){var t=e.target;"function"==typeof t.dragDrop&&("INPUT"===t.tagName||"SELECT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||(e.preventDefault(),t.dragDrop()))},this.options=new b(r),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new n(this.isNodeInDocument)}var t,r,i;return t=e,(r=[{key:"profile",value:function(){var e,t;return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:(null===(e=this.dragStartSourceIds)||void 0===e?void 0:e.length)||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:(null===(t=this.dragOverTargetIds)||void 0===t?void 0:t.length)||0}}},{key:"setup",value:function(){if(void 0!==this.window){if(this.window.__isReactDndBackendSetUp)throw new Error("Cannot have two HTML5 backends at the same time.");this.window.__isReactDndBackendSetUp=!0,this.addEventListeners(this.window)}}},{key:"teardown",value:function(){void 0!==this.window&&(this.window.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.window),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId&&this.window.cancelAnimationFrame(this.asyncEndDragFrameId))}},{key:"connectDragPreview",value:function(e,t,r){var n=this;return this.sourcePreviewNodeOptions.set(e,r),this.sourcePreviewNodes.set(e,t),function(){n.sourcePreviewNodes.delete(e),n.sourcePreviewNodeOptions.delete(e)}}},{key:"connectDragSource",value:function(e,t,r){var n=this;this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,r);var a=function(t){return n.handleDragStart(t,e)},i=function(e){return n.handleSelectStart(e)};return t.setAttribute("draggable","true"),t.addEventListener("dragstart",a),t.addEventListener("selectstart",i),function(){n.sourceNodes.delete(e),n.sourceNodeOptions.delete(e),t.removeEventListener("dragstart",a),t.removeEventListener("selectstart",i),t.setAttribute("draggable","false")}}},{key:"connectDropTarget",value:function(e,t){var r=this,n=function(t){return r.handleDragEnter(t,e)},a=function(t){return r.handleDragOver(t,e)},i=function(t){return r.handleDrop(t,e)};return t.addEventListener("dragenter",n),t.addEventListener("dragover",a),t.addEventListener("drop",i),function(){t.removeEventListener("dragenter",n),t.removeEventListener("dragover",a),t.removeEventListener("drop",i)}}},{key:"addEventListeners",value:function(e){e.addEventListener&&(e.addEventListener("dragstart",this.handleTopDragStart),e.addEventListener("dragstart",this.handleTopDragStartCapture,!0),e.addEventListener("dragend",this.handleTopDragEndCapture,!0),e.addEventListener("dragenter",this.handleTopDragEnter),e.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.addEventListener("dragover",this.handleTopDragOver),e.addEventListener("dragover",this.handleTopDragOverCapture,!0),e.addEventListener("drop",this.handleTopDrop),e.addEventListener("drop",this.handleTopDropCapture,!0))}},{key:"removeEventListeners",value:function(e){e.removeEventListener&&(e.removeEventListener("dragstart",this.handleTopDragStart),e.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),e.removeEventListener("dragend",this.handleTopDragEndCapture,!0),e.removeEventListener("dragenter",this.handleTopDragEnter),e.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.removeEventListener("dragover",this.handleTopDragOver),e.removeEventListener("dragover",this.handleTopDragOverCapture,!0),e.removeEventListener("drop",this.handleTopDrop),e.removeEventListener("drop",this.handleTopDropCapture,!0))}},{key:"getCurrentSourceNodeOptions",value:function(){var e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return O({dropEffect:this.altKeyPressed?"copy":"move"},t||{})}},{key:"getCurrentDropEffect",value:function(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}},{key:"getCurrentSourcePreviewNodeOptions",value:function(){var e=this.monitor.getSourceId();return O({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}},{key:"isDraggingNativeItem",value:function(){var e=this.monitor.getItemType();return Object.keys(h).some((function(t){return h[t]===e}))}},{key:"beginDragNativeItem",value:function(e,t){this.clearCurrentDragSourceNode(),this.currentNativeSource=function(e,t){var r=new w(D[e]);return r.loadDataTransfer(t),r}(e,t),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:"setCurrentDragSourceNode",value:function(e){var t=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e,this.mouseMoveTimeoutTimer=setTimeout((function(){return t.window&&t.window.addEventListener("mousemove",t.endDragIfSourceWasRemovedFromDOM,!0)}),1e3)}},{key:"clearCurrentDragSourceNode",value:function(){return!!this.currentDragSourceNode&&(this.currentDragSourceNode=null,this.window&&(this.window.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.window.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)),this.mouseMoveTimeoutTimer=null,!0)}},{key:"handleDragStart",value:function(e,t){e.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(t))}},{key:"handleDragEnter",value:function(e,t){this.dragEnterTargetIds.unshift(t)}},{key:"handleDragOver",value:function(e,t){null===this.dragOverTargetIds&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}},{key:"handleDrop",value:function(e,t){this.dropTargetIds.unshift(t)}},{key:"window",get:function(){return this.options.window}},{key:"document",get:function(){return this.options.document}}])&&I(t.prototype,r),i&&I(t,i),e}();e.HTML5Backend=function(e,t){return new P(e,t)},e.NativeTypes=h,e.getEmptyImage=function(){return C||((C=new Image).src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),C},Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -1,10 +0,10 @@ | ||
declare type NodePredicate = (node: any) => boolean; | ||
export default class EnterLeaveCounter { | ||
declare type NodePredicate = (node: Node | null | undefined) => boolean; | ||
export declare class EnterLeaveCounter { | ||
private entered; | ||
private isNodeInDocument; | ||
constructor(isNodeInDocument: NodePredicate); | ||
enter(enteringNode: any): boolean; | ||
leave(leavingNode: any): boolean; | ||
enter(enteringNode: EventTarget | null): boolean; | ||
leave(leavingNode: EventTarget | null): boolean; | ||
reset(): void; | ||
} | ||
export {}; |
import { union, without } from './utils/js_utils'; | ||
export default class EnterLeaveCounter { | ||
export class EnterLeaveCounter { | ||
constructor(isNodeInDocument) { | ||
@@ -4,0 +4,0 @@ this.entered = []; |
@@ -5,3 +5,2 @@ import * as NativeTypes from './NativeTypes'; | ||
export { NativeTypes }; | ||
declare const createBackend: BackendFactory; | ||
export default createBackend; | ||
export declare const HTML5Backend: BackendFactory; |
@@ -1,6 +0,7 @@ | ||
import HTML5Backend from './HTML5Backend'; | ||
import { HTML5BackendImpl } from './HTML5BackendImpl'; | ||
import * as NativeTypes from './NativeTypes'; | ||
export { getEmptyImage } from './getEmptyImage'; | ||
export { NativeTypes }; | ||
const createBackend = (manager, context) => new HTML5Backend(manager, context); | ||
export default createBackend; | ||
export const HTML5Backend = function createBackend(manager, context) { | ||
return new HTML5BackendImpl(manager, context); | ||
}; |
@@ -1,2 +0,2 @@ | ||
export default class MonotonicInterpolant { | ||
export declare class MonotonicInterpolant { | ||
private xs; | ||
@@ -8,3 +8,3 @@ private ys; | ||
constructor(xs: number[], ys: number[]); | ||
interpolate(x: number): any; | ||
interpolate(x: number): number; | ||
} |
@@ -1,2 +0,2 @@ | ||
export default class MonotonicInterpolant { | ||
export class MonotonicInterpolant { | ||
constructor(xs, ys) { | ||
@@ -3,0 +3,0 @@ const { length } = xs; |
@@ -13,6 +13,6 @@ import { nativeTypesConfig } from './nativeTypesConfig'; | ||
const dataTransferTypes = Array.prototype.slice.call(dataTransfer.types || []); | ||
return (Object.keys(nativeTypesConfig).filter(nativeItemType => { | ||
return (Object.keys(nativeTypesConfig).filter((nativeItemType) => { | ||
const { matchesTypes } = nativeTypesConfig[nativeItemType]; | ||
return matchesTypes.some(t => dataTransferTypes.indexOf(t) > -1); | ||
return matchesTypes.some((t) => dataTransferTypes.indexOf(t) > -1); | ||
})[0] || null); | ||
} |
@@ -8,3 +8,3 @@ export class NativeDragSource { | ||
initializeExposedProperties() { | ||
Object.keys(this.config.exposeProperties).forEach(property => { | ||
Object.keys(this.config.exposeProperties).forEach((property) => { | ||
Object.defineProperty(this.item, property, { | ||
@@ -24,3 +24,3 @@ configurable: true, | ||
const newProperties = {}; | ||
Object.keys(this.config.exposeProperties).forEach(property => { | ||
Object.keys(this.config.exposeProperties).forEach((property) => { | ||
newProperties[property] = { | ||
@@ -27,0 +27,0 @@ value: this.config.exposeProperties[property](dataTransfer, this.config.matchesTypes), |
import { XYCoord } from 'dnd-core'; | ||
export declare function getNodeClientOffset(node: any): { | ||
x: any; | ||
y: any; | ||
} | null; | ||
export declare function getEventClientOffset(e: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
export declare function getDragPreviewOffset(sourceNode: any, dragPreview: any, clientOffset: XYCoord, anchorPoint: any, offsetPoint: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
export declare function getNodeClientOffset(node: Node): XYCoord | null; | ||
export declare function getEventClientOffset(e: MouseEvent): XYCoord; | ||
export declare function getDragPreviewOffset(sourceNode: HTMLElement, dragPreview: HTMLElement, clientOffset: XYCoord, anchorPoint: { | ||
anchorX: number; | ||
anchorY: number; | ||
}, offsetPoint: { | ||
offsetX: number; | ||
offsetY: number; | ||
}): XYCoord; |
import { isSafari, isFirefox } from './BrowserDetector'; | ||
import MonotonicInterpolant from './MonotonicInterpolant'; | ||
import { MonotonicInterpolant } from './MonotonicInterpolant'; | ||
const ELEMENT_NODE = 1; | ||
@@ -20,3 +20,3 @@ export function getNodeClientOffset(node) { | ||
return (node.nodeName === 'IMG' && | ||
(isFirefox() || !document.documentElement.contains(node))); | ||
(isFirefox() || !document.documentElement?.contains(node))); | ||
} | ||
@@ -23,0 +23,0 @@ function getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight) { |
@@ -0,6 +1,7 @@ | ||
import { HTML5BackendContext } from './types'; | ||
export declare class OptionsReader { | ||
private globalContext; | ||
constructor(globalContext: any); | ||
get window(): any; | ||
get document(): any; | ||
constructor(globalContext: HTML5BackendContext); | ||
get window(): Window | undefined; | ||
get document(): Document | undefined; | ||
} |
{ | ||
"name": "react-dnd-html5-backend", | ||
"version": "10.0.2", | ||
"version": "11.0.0", | ||
"description": "HTML5 backend for React DnD", | ||
@@ -20,11 +20,11 @@ "main": "./dist/cjs/index.js", | ||
"dependencies": { | ||
"dnd-core": "^10.0.2" | ||
"dnd-core": "^11.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^16.9.13", | ||
"@types/react": "^16.9.35", | ||
"react": "^16.12.0", | ||
"react-dnd-test-backend": "^10.0.2", | ||
"react-dnd-test-backend": "^11.0.0", | ||
"react-dom": "^16.12.0" | ||
}, | ||
"gitHead": "5d16ab043eb83d49c5b6964ce276d0a6c15210d5" | ||
"gitHead": "418cb25315323efd6c0b9e23ccc28c5607d86edb" | ||
} |
import path from 'path' | ||
import resolve from 'rollup-plugin-node-resolve' | ||
import commonjs from 'rollup-plugin-commonjs' | ||
import resolve from '@rollup/plugin-node-resolve' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import replace from '@rollup/plugin-replace' | ||
import { terser } from 'rollup-plugin-terser' | ||
import replace from '@rollup/plugin-replace' | ||
export default { | ||
input: path.resolve(__dirname, 'dist/esm/index.js'), | ||
output: [ | ||
{ | ||
name: 'ReactDnDHTML5Backend', | ||
file: path.resolve(__dirname, 'dist/umd/ReactDnDHTML5Backend.js'), | ||
format: 'umd', | ||
globals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
'react-dnd': 'ReactDnD', | ||
const input = path.resolve(__dirname, 'dist/esm/index.js') | ||
function replaceNodeEnv(env) { | ||
return replace({ | ||
values: { 'process.env.NODE_ENV': JSON.stringify(env) }, | ||
delimiters: ['', ''], | ||
}) | ||
} | ||
const commonPlugins = [resolve({ browser: true }), commonjs()] | ||
const external = ['react', 'react-dom', 'react-dnd'] | ||
const globals = { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
'react-dnd': 'ReactDnD', | ||
} | ||
export default [ | ||
{ | ||
input, | ||
external, | ||
plugins: [...commonPlugins, replaceNodeEnv('development')], | ||
output: [ | ||
{ | ||
name: 'ReactDnDHTML5Backend', | ||
file: path.resolve(__dirname, 'dist/umd/ReactDnDHTML5Backend.js'), | ||
format: 'umd', | ||
globals, | ||
}, | ||
plugins: [ | ||
replace({ | ||
values: { 'process.env.NODE_ENV': JSON.stringify('development') }, | ||
delimiters: ['', ''], | ||
}), | ||
], | ||
}, | ||
{ | ||
name: 'ReactDnDHTML5Backend', | ||
file: path.resolve(__dirname, 'dist/umd/ReactDnDHTML5Backend.min.js'), | ||
format: 'umd', | ||
globals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
'react-dnd': 'ReactDnD', | ||
], | ||
}, | ||
{ | ||
input, | ||
external, | ||
plugins: [...commonPlugins, replaceNodeEnv('production'), terser()], | ||
output: [ | ||
{ | ||
name: 'ReactDnDHTML5Backend', | ||
file: path.resolve(__dirname, 'dist/umd/ReactDnDHTML5Backend.min.js'), | ||
format: 'umd', | ||
globals, | ||
}, | ||
plugins: [ | ||
terser(), | ||
replace({ | ||
values: { 'process.env.NODE_ENV': JSON.stringify('production') }, | ||
delimiters: ['', ''], | ||
}), | ||
], | ||
}, | ||
], | ||
external: ['react', 'react-dom', 'react-dnd'], | ||
plugins: [resolve({ browser: true }), commonjs()], | ||
} | ||
], | ||
}, | ||
] |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
413810
67
4120
+ Addeddnd-core@11.1.3(transitive)
- Removeddnd-core@10.0.2(transitive)
Updateddnd-core@^11.0.0