All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
2 lines
19 KiB
JavaScript
2 lines
19 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis: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)}}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),n(this,"entered",[]),n(this,"isNodeInDocument",void 0),this.isNodeInDocument=t}var t,i;return t=e,(i=[{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 i=[];return r.forEach((function(e){return i.push(e)})),i}(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,i),e}(),o=t((function(){return/firefox/i.test(navigator.userAgent)})),a=t((function(){return Boolean(window.safari)}));function s(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)}}function u(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=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),u(this,"xs",void 0),u(this,"ys",void 0),u(this,"c1s",void 0),u(this,"c2s",void 0),u(this,"c3s",void 0);for(var n=t.length,i=[],o=0;o<n;o++)i.push(o);i.sort((function(e,r){return t[e]<t[r]?-1:1}));for(var a,s,d=[],c=[],l=0;l<n-1;l++)a=t[l+1]-t[l],s=r[l+1]-r[l],d.push(a),c.push(s/a);for(var f=[c[0]],g=0;g<d.length-1;g++){var v=c[g],h=c[g+1];if(v*h<=0)f.push(0);else{a=d[g];var p=d[g+1],m=a+p;f.push(3*m/((m+p)/v+(m+a)/h))}}f.push(c[c.length-1]);for(var D,y=[],T=[],E=0;E<f.length-1;E++){D=c[E];var b=f[E],w=1/d[E],O=b+f[E+1]-D-D;y.push((D-b-O)*w),T.push(O*w*w)}this.xs=t,this.ys=r,this.c1s=f,this.c2s=y,this.c3s=T}var t,r;return t=e,(r=[{key:"interpolate",value:function(e){var t=this.xs,r=this.ys,n=this.c1s,i=this.c2s,o=this.c3s,a=t.length-1;if(e===t[a])return r[a];for(var s,u=0,d=o.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[a=Math.max(0,d)],f=l*l;return r[a]+n[a]*l+i[a]*f+o[a]*l*f}}])&&s(t.prototype,r),e}();function c(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 l(e){return{x:e.clientX,y:e.clientY}}function f(e,t,r,n,i){var s,u,l,f="IMG"===(s=t).nodeName&&(o()||!(null!==(u=document.documentElement)&&void 0!==u&&u.contains(s))),g=c(f?e:t),v={x:r.x-g.x,y:r.y-g.y},h=e.offsetWidth,p=e.offsetHeight,m=n.anchorX,D=n.anchorY,y=function(e,t,r,n){var i=e?t.width:r,o=e?t.height:n;return a()&&e&&(o/=window.devicePixelRatio,i/=window.devicePixelRatio),{dragPreviewWidth:i,dragPreviewHeight:o}}(f,t,h,p),T=y.dragPreviewWidth,E=y.dragPreviewHeight,b=i.offsetX,w=i.offsetY,O=0===w||w;return{x:0===b||b?b:new d([0,.5,1],[v.x,v.x/h*T,v.x+T-h]).interpolate(m),y:O?w:(l=new d([0,.5,1],[v.y,v.y/p*E,v.y+E-p]).interpolate(D),a()&&f&&(l+=(window.devicePixelRatio-1)*E),l)}}var g,v="__NATIVE_FILE__",h="__NATIVE_URL__",p="__NATIVE_TEXT__",m="__NATIVE_HTML__",D=Object.freeze({__proto__:null,FILE:v,URL:h,TEXT:p,HTML:m});function y(e,t,r){var n=t.reduce((function(t,r){return t||e.getData(r)}),"");return null!=n?n:r}function T(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var E=(T(g={},v,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items},dataTransfer:function(e){return e}},matchesTypes:["Files"]}),T(g,m,{exposeProperties:{html:function(e,t){return y(e,t,"")},dataTransfer:function(e){return e}},matchesTypes:["Html","text/html"]}),T(g,h,{exposeProperties:{urls:function(e,t){return y(e,t,"").split("\n")},dataTransfer:function(e){return e}},matchesTypes:["Url","text/uri-list"]}),T(g,p,{exposeProperties:{text:function(e,t){return y(e,t,"")},dataTransfer:function(e){return e}},matchesTypes:["Text","text/plain"]}),g);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)}}function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}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),w(this,"item",void 0),w(this,"config",void 0),this.config=t,this.item={},this.initializeExposedProperties()}var t,r;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(){}}])&&b(t.prototype,r),e}();function N(e){if(!e)return null;var t=Array.prototype.slice.call(e.types||[]);return Object.keys(E).filter((function(e){return E[e].matchesTypes.some((function(e){return t.indexOf(e)>-1}))}))[0]||null}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)}}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}var C=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),S(this,"ownerDocument",null),S(this,"globalContext",void 0),S(this,"optionsArgs",void 0),this.globalContext=t,this.optionsArgs=r}var t,r;return t=e,(r=[{key:"window",get:function(){return this.globalContext?this.globalContext:"undefined"!=typeof window?window:void 0}},{key:"document",get:function(){var e;return null!==(e=this.globalContext)&&void 0!==e&&e.document?this.globalContext.document:this.window?this.window.document:void 0}},{key:"rootElement",get:function(){var e;return(null===(e=this.optionsArgs)||void 0===e?void 0:e.rootElement)||this.window}}])&&I(t.prototype,r),e}();function P(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 L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach((function(t){A(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function k(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)}}function A(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var x,j=function(){function e(t,r,n){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),A(this,"options",void 0),A(this,"actions",void 0),A(this,"monitor",void 0),A(this,"registry",void 0),A(this,"enterLeaveCounter",void 0),A(this,"sourcePreviewNodes",new Map),A(this,"sourcePreviewNodeOptions",new Map),A(this,"sourceNodes",new Map),A(this,"sourceNodeOptions",new Map),A(this,"dragStartSourceIds",null),A(this,"dropTargetIds",[]),A(this,"dragEnterTargetIds",[]),A(this,"currentNativeSource",null),A(this,"currentNativeHandle",null),A(this,"currentDragSourceNode",null),A(this,"altKeyPressed",!1),A(this,"mouseMoveTimeoutTimer",null),A(this,"asyncEndDragFrameId",null),A(this,"dragOverTargetIds",null),A(this,"lastClientOffset",null),A(this,"hoverRafId",null),A(this,"getSourceClientOffset",(function(e){var t=o.sourceNodes.get(e);return t&&c(t)||null})),A(this,"endDragNativeItem",(function(){o.isDraggingNativeItem()&&(o.actions.endDrag(),o.currentNativeHandle&&o.registry.removeSource(o.currentNativeHandle),o.currentNativeHandle=null,o.currentNativeSource=null)})),A(this,"isNodeInDocument",(function(e){return Boolean(e&&o.document&&o.document.body&&o.document.body.contains(e))})),A(this,"endDragIfSourceWasRemovedFromDOM",(function(){var e=o.currentDragSourceNode;null==e||o.isNodeInDocument(e)||o.clearCurrentDragSourceNode()&&o.monitor.isDragging()&&o.actions.endDrag()})),A(this,"handleTopDragStartCapture",(function(){o.clearCurrentDragSourceNode(),o.dragStartSourceIds=[]})),A(this,"handleTopDragStart",(function(e){if(!e.defaultPrevented){var t=o.dragStartSourceIds;o.dragStartSourceIds=null;var r=l(e);o.monitor.isDragging()&&o.actions.endDrag(),o.actions.beginDrag(t||[],{publishSource:!1,getSourceClientOffset:o.getSourceClientOffset,clientOffset:r});var n=e.dataTransfer,i=N(n);if(o.monitor.isDragging()){if(n&&"function"==typeof n.setDragImage){var a=o.monitor.getSourceId(),s=o.sourceNodes.get(a),u=o.sourcePreviewNodes.get(a)||s;if(u){var d=o.getCurrentSourcePreviewNodeOptions(),c=f(s,u,r,{anchorX:d.anchorX,anchorY:d.anchorY},{offsetX:d.offsetX,offsetY:d.offsetY});n.setDragImage(u,c.x,c.y)}}try{null==n||n.setData("application/json",{})}catch(e){}o.setCurrentDragSourceNode(e.target),o.getCurrentSourcePreviewNodeOptions().captureDraggingState?o.actions.publishDragSource():setTimeout((function(){return o.actions.publishDragSource()}),0)}else if(i)o.beginDragNativeItem(i);else{if(n&&!n.types&&(e.target&&!e.target.hasAttribute||!e.target.hasAttribute("draggable")))return;e.preventDefault()}}})),A(this,"handleTopDragEndCapture",(function(){o.clearCurrentDragSourceNode()&&o.monitor.isDragging()&&o.actions.endDrag()})),A(this,"handleTopDragEnterCapture",(function(e){if(o.dragEnterTargetIds=[],o.enterLeaveCounter.enter(e.target)&&!o.monitor.isDragging()){var t=e.dataTransfer,r=N(t);r&&o.beginDragNativeItem(r,t)}})),A(this,"handleTopDragEnter",(function(e){var t=o.dragEnterTargetIds;o.dragEnterTargetIds=[],o.monitor.isDragging()&&(o.altKeyPressed=e.altKey,t.length>0&&o.actions.hover(t,{clientOffset:l(e)}),t.some((function(e){return o.monitor.canDropOnTarget(e)}))&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=o.getCurrentDropEffect())))})),A(this,"handleTopDragOverCapture",(function(){o.dragOverTargetIds=[]})),A(this,"handleTopDragOver",(function(e){var t=o.dragOverTargetIds;if(o.dragOverTargetIds=[],!o.monitor.isDragging())return e.preventDefault(),void(e.dataTransfer&&(e.dataTransfer.dropEffect="none"));o.altKeyPressed=e.altKey,o.lastClientOffset=l(e),null===o.hoverRafId&&"undefined"!=typeof requestAnimationFrame&&(o.hoverRafId=requestAnimationFrame((function(){o.monitor.isDragging()&&o.actions.hover(t||[],{clientOffset:o.lastClientOffset}),o.hoverRafId=null}))),(t||[]).some((function(e){return o.monitor.canDropOnTarget(e)}))?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=o.getCurrentDropEffect())):o.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))})),A(this,"handleTopDragLeaveCapture",(function(e){o.isDraggingNativeItem()&&e.preventDefault(),o.enterLeaveCounter.leave(e.target)&&o.isDraggingNativeItem()&&setTimeout((function(){return o.endDragNativeItem()}),0)})),A(this,"handleTopDropCapture",(function(e){var t;o.dropTargetIds=[],o.isDraggingNativeItem()?(e.preventDefault(),null===(t=o.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer)):N(e.dataTransfer)&&e.preventDefault(),o.enterLeaveCounter.reset()})),A(this,"handleTopDrop",(function(e){var t=o.dropTargetIds;o.dropTargetIds=[],o.actions.hover(t,{clientOffset:l(e)}),o.actions.drop({dropEffect:o.getCurrentDropEffect()}),o.isDraggingNativeItem()?o.endDragNativeItem():o.monitor.isDragging()&&o.actions.endDrag()})),A(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 C(r,n),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new i(this.isNodeInDocument)}var t,r;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:"window",get:function(){return this.options.window}},{key:"document",get:function(){return this.options.document}},{key:"rootElement",get:function(){return this.options.rootElement}},{key:"setup",value:function(){var e=this.rootElement;if(void 0!==e){if(e.__isReactDndBackendSetUp)throw new Error("Cannot have two HTML5 backends at the same time.");e.__isReactDndBackendSetUp=!0,this.addEventListeners(e)}}},{key:"teardown",value:function(){var e,t=this.rootElement;void 0!==t&&(t.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId&&(null===(e=this.window)||void 0===e||e.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 i=function(t){return n.handleDragStart(t,e)},o=function(e){return n.handleSelectStart(e)};return t.setAttribute("draggable","true"),t.addEventListener("dragstart",i),t.addEventListener("selectstart",o),function(){n.sourceNodes.delete(e),n.sourceNodeOptions.delete(e),t.removeEventListener("dragstart",i),t.removeEventListener("selectstart",o),t.setAttribute("draggable","false")}}},{key:"connectDropTarget",value:function(e,t){var r=this,n=function(t){return r.handleDragEnter(t,e)},i=function(t){return r.handleDragOver(t,e)},o=function(t){return r.handleDrop(t,e)};return t.addEventListener("dragenter",n),t.addEventListener("dragover",i),t.addEventListener("drop",o),function(){t.removeEventListener("dragenter",n),t.removeEventListener("dragover",i),t.removeEventListener("drop",o)}}},{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 L({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 L({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}},{key:"isDraggingNativeItem",value:function(){var e=this.monitor.getItemType();return Object.keys(D).some((function(t){return D[t]===e}))}},{key:"beginDragNativeItem",value:function(e,t){this.clearCurrentDragSourceNode(),this.currentNativeSource=function(e,t){var r=new O(E[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(){var e;return null===(e=t.rootElement)||void 0===e?void 0:e.addEventListener("mousemove",t.endDragIfSourceWasRemovedFromDOM,!0)}),1e3)}},{key:"clearCurrentDragSourceNode",value:function(){var e;return!!this.currentDragSourceNode&&(this.currentDragSourceNode=null,this.rootElement&&(null===(e=this.window)||void 0===e||e.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.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)}}])&&k(t.prototype,r),e}();e.HTML5Backend=function(e,t,r){return new j(e,t,r)},e.NativeTypes=D,e.getEmptyImage=function(){return x||((x=new Image).src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),x},Object.defineProperty(e,"__esModule",{value:!0})}));
|